private boolean renameKeyForAllLanguages ( String oldKey , String newKey ) { try { loadAllRemainingLocalizations ( ) ; lockAllLocalizations ( oldKey ) ; if ( hasDescriptor ( ) ) { lockDescriptor ( ) ; } } catch ( CmsException | IOException e ) { LOG . error ( e . getLocalizedMessage ( ) , e ) ; return false ; } for ( Entry < Locale , SortedProperties > entry : m_localizations . entrySet ( ) ) { SortedProperties localization = entry . getValue ( ) ; if ( localization . containsKey ( oldKey ) ) { String value = localization . getProperty ( oldKey ) ; localization . remove ( oldKey ) ; localization . put ( newKey , value ) ; m_changedTranslations . add ( entry . getKey ( ) ) ; } } if ( hasDescriptor ( ) ) { CmsXmlContentValueSequence messages = m_descContent . getValueSequence ( Descriptor . N_MESSAGE , Descriptor . LOCALE ) ; for ( int i = 0 ; i < messages . getElementCount ( ) ; i ++ ) { String prefix = messages . getValue ( i ) . getPath ( ) + "/" ; String key = m_descContent . getValue ( prefix + Descriptor . N_KEY , Descriptor . LOCALE ) . getStringValue ( m_cms ) ; if ( key == oldKey ) { m_descContent . getValue ( prefix + Descriptor . N_KEY , Descriptor . LOCALE ) . setStringValue ( m_cms , newKey ) ; break ; } } m_descriptorHasChanges = true ; } m_keyset . renameKey ( oldKey , newKey ) ; return true ; }
Rename a key for all languages .