idx int64 0 165k | question stringlengths 73 4.15k | target stringlengths 5 918 | len_question int64 21 890 | len_target int64 3 255 |
|---|---|---|---|---|
145,100 | private EditorState getDefaultState ( ) { List < TableProperty > cols = new ArrayList < TableProperty > ( 1 ) ; cols . add ( TableProperty . TRANSLATION ) ; return new EditorState ( cols , false ) ; } | Creates the default editor state for editing a bundle with descriptor . | 53 | 13 |
145,101 | private SortedProperties getLocalization ( Locale locale ) throws IOException , CmsException { if ( null == m_localizations . get ( locale ) ) { switch ( m_bundleType ) { case PROPERTY : loadLocalizationFromPropertyBundle ( locale ) ; break ; case XML : loadLocalizationFromXmlBundle ( locale ) ; break ; case DESCRIPTOR : return null ; default : break ; } } return m_localizations . get ( locale ) ; } | Reads the current properties for a language . If not already done the properties are read from the respective file . | 106 | 22 |
145,102 | private EditorState getMasterState ( ) { List < TableProperty > cols = new ArrayList < TableProperty > ( 4 ) ; cols . add ( TableProperty . KEY ) ; cols . add ( TableProperty . DESCRIPTION ) ; cols . add ( TableProperty . DEFAULT ) ; cols . add ( TableProperty . TRANSLATION ) ; return new EditorState ( cols , true ) ; } | Returns the master mode s editor state for editing a bundle with descriptor . | 88 | 14 |
145,103 | private CmsMessageBundleEditorTypes . BundleType initBundleType ( ) { String resourceTypeName = OpenCms . getResourceManager ( ) . getResourceType ( m_resource ) . getTypeName ( ) ; return CmsMessageBundleEditorTypes . BundleType . toBundleType ( resourceTypeName ) ; } | Init the bundle type member variable . | 71 | 7 |
145,104 | private void initDescriptor ( ) throws CmsXmlException , CmsException { if ( m_bundleType . equals ( CmsMessageBundleEditorTypes . BundleType . DESCRIPTOR ) ) { m_desc = m_resource ; } else { //First try to read from same folder like resource, if it fails use CmsMessageBundleEditorTypes.getDescriptor() try { m_desc = m_cms . readResource ( m_sitepath + m_basename + CmsMessageBundleEditorTypes . Descriptor . POSTFIX ) ; } catch ( CmsVfsResourceNotFoundException e ) { m_desc = CmsMessageBundleEditorTypes . getDescriptor ( m_cms , m_basename ) ; } } unmarshalDescriptor ( ) ; } | Reads the bundle descriptor sets m_desc and m_descContent . | 178 | 15 |
145,105 | private void initEditorStates ( ) { m_editorState = new HashMap < CmsMessageBundleEditorTypes . EditMode , EditorState > ( ) ; List < TableProperty > cols = null ; switch ( m_bundleType ) { case PROPERTY : case XML : if ( hasDescriptor ( ) ) { // bundle descriptor is present, keys are not editable in default mode, maybe master mode is available m_editorState . put ( CmsMessageBundleEditorTypes . EditMode . DEFAULT , getDefaultState ( ) ) ; if ( hasMasterMode ( ) ) { // the bundle descriptor is editable m_editorState . put ( CmsMessageBundleEditorTypes . EditMode . MASTER , getMasterState ( ) ) ; } } else { // no bundle descriptor given - implies no master mode cols = new ArrayList < TableProperty > ( 1 ) ; cols . add ( TableProperty . KEY ) ; cols . add ( TableProperty . TRANSLATION ) ; m_editorState . put ( CmsMessageBundleEditorTypes . EditMode . DEFAULT , new EditorState ( cols , true ) ) ; } break ; case DESCRIPTOR : cols = new ArrayList < TableProperty > ( 3 ) ; cols . add ( TableProperty . KEY ) ; cols . add ( TableProperty . DESCRIPTION ) ; cols . add ( TableProperty . DEFAULT ) ; m_editorState . put ( CmsMessageBundleEditorTypes . EditMode . DEFAULT , new EditorState ( cols , true ) ) ; break ; default : throw new IllegalArgumentException ( ) ; } } | Initializes the editor states for the different modes depending on the type of the opened file . | 351 | 18 |
145,106 | private void initHasMasterMode ( ) throws CmsException { if ( hasDescriptor ( ) && m_cms . hasPermissions ( m_desc , CmsPermissionSet . ACCESS_WRITE , false , CmsResourceFilter . ALL ) ) { m_hasMasterMode = true ; } else { m_hasMasterMode = false ; } } | Initializes the information on an available master mode . | 78 | 10 |
145,107 | private void initKeySetForXmlBundle ( ) { // consider only available locales for ( Locale l : m_locales ) { if ( m_xmlBundle . hasLocale ( l ) ) { Set < Object > keys = new HashSet < Object > ( ) ; for ( I_CmsXmlContentValue msg : m_xmlBundle . getValueSequence ( "Message" , l ) . getValues ( ) ) { String msgpath = msg . getPath ( ) ; keys . add ( m_xmlBundle . getStringValue ( m_cms , msgpath + "/Key" , l ) ) ; } m_keyset . updateKeySet ( null , keys ) ; } } } | Initialize the key set for an xml bundle . | 156 | 10 |
145,108 | private Collection < Locale > initLocales ( ) { Collection < Locale > locales = null ; switch ( m_bundleType ) { case DESCRIPTOR : locales = new ArrayList < Locale > ( 1 ) ; locales . add ( Descriptor . LOCALE ) ; break ; case XML : case PROPERTY : locales = OpenCms . getLocaleManager ( ) . getAvailableLocales ( m_cms , m_resource ) ; break ; default : throw new IllegalArgumentException ( ) ; } return locales ; } | Initializes the locales that can be selected via the language switcher in the bundle editor . | 120 | 19 |
145,109 | private void initPropertyBundle ( ) throws CmsLoaderException , CmsException , IOException { for ( Locale l : m_locales ) { String filePath = m_sitepath + m_basename + "_" + l . toString ( ) ; CmsResource resource = null ; if ( m_cms . existsResource ( filePath , CmsResourceFilter . requireType ( OpenCms . getResourceManager ( ) . getResourceType ( BundleType . PROPERTY . toString ( ) ) ) ) ) { resource = m_cms . readResource ( filePath ) ; SortedProperties props = new SortedProperties ( ) ; CmsFile file = m_cms . readFile ( resource ) ; props . load ( new InputStreamReader ( new ByteArrayInputStream ( file . getContents ( ) ) , CmsFileUtil . getEncoding ( m_cms , file ) ) ) ; m_keyset . updateKeySet ( null , props . keySet ( ) ) ; m_bundleFiles . put ( l , resource ) ; } } } | Initialization necessary for editing a property bundle . | 234 | 9 |
145,110 | private void initXmlBundle ( ) throws CmsException { CmsFile file = m_cms . readFile ( m_resource ) ; m_bundleFiles . put ( null , m_resource ) ; m_xmlBundle = CmsXmlContentFactory . unmarshal ( m_cms , file ) ; initKeySetForXmlBundle ( ) ; } | Unmarshals the XML content and adds the file to the bundle files . | 82 | 16 |
145,111 | private boolean isBundleProperty ( Object property ) { return ( property . equals ( TableProperty . KEY ) || property . equals ( TableProperty . TRANSLATION ) ) ; } | Check if values in the column property are written to the bundle files . | 37 | 14 |
145,112 | private boolean isDescriptorProperty ( Object property ) { return ( getBundleType ( ) . equals ( BundleType . DESCRIPTOR ) || ( hasDescriptor ( ) && ( property . equals ( TableProperty . KEY ) || property . equals ( TableProperty . DEFAULT ) || property . equals ( TableProperty . DESCRIPTION ) ) ) ) ; } | Check if values in the column property are written to the bundle descriptor . | 76 | 14 |
145,113 | private void loadAllRemainingLocalizations ( ) throws CmsException , UnsupportedEncodingException , IOException { if ( ! m_alreadyLoadedAllLocalizations ) { // is only necessary for property bundles if ( m_bundleType . equals ( BundleType . PROPERTY ) ) { for ( Locale l : m_locales ) { if ( null == m_localizations . get ( l ) ) { CmsResource resource = m_bundleFiles . get ( l ) ; if ( resource != null ) { CmsFile file = m_cms . readFile ( resource ) ; m_bundleFiles . put ( l , file ) ; SortedProperties props = new SortedProperties ( ) ; props . load ( new InputStreamReader ( new ByteArrayInputStream ( file . getContents ( ) ) , CmsFileUtil . getEncoding ( m_cms , file ) ) ) ; m_localizations . put ( l , props ) ; } } } } if ( m_bundleType . equals ( BundleType . XML ) ) { for ( Locale l : m_locales ) { if ( null == m_localizations . get ( l ) ) { loadLocalizationFromXmlBundle ( l ) ; } } } m_alreadyLoadedAllLocalizations = true ; } } | Loads all localizations not already loaded . | 287 | 9 |
145,114 | private void loadLocalizationFromXmlBundle ( Locale locale ) { CmsXmlContentValueSequence messages = m_xmlBundle . getValueSequence ( "Message" , locale ) ; SortedProperties props = new SortedProperties ( ) ; if ( null != messages ) { for ( I_CmsXmlContentValue msg : messages . getValues ( ) ) { String msgpath = msg . getPath ( ) ; props . put ( m_xmlBundle . getStringValue ( m_cms , msgpath + "/Key" , locale ) , m_xmlBundle . getStringValue ( m_cms , msgpath + "/Value" , locale ) ) ; } } m_localizations . put ( locale , props ) ; } | Loads the localization for the current locale from a bundle of type xmlvfsbundle . It assumes the content has already been unmarshalled before . | 164 | 31 |
145,115 | private void lockDescriptor ( ) throws CmsException { if ( ( null == m_descFile ) && ( null != m_desc ) ) { m_descFile = LockedFile . lockResource ( m_cms , m_desc ) ; } } | Locks the bundle descriptor . | 55 | 6 |
145,116 | private void lockLocalization ( Locale l ) throws CmsException { if ( null == m_lockedBundleFiles . get ( l ) ) { LockedFile lf = LockedFile . lockResource ( m_cms , m_bundleFiles . get ( l ) ) ; m_lockedBundleFiles . put ( l , lf ) ; } } | Locks the bundle file that contains the translation for the provided locale . | 76 | 14 |
145,117 | private void lockOnChange ( Object propertyId ) throws CmsException { if ( isDescriptorProperty ( propertyId ) ) { lockDescriptor ( ) ; } else { Locale l = m_bundleType . equals ( BundleType . PROPERTY ) ? m_locale : null ; lockLocalization ( l ) ; } } | Lock a file lazily if a value that should be written to the file has changed . | 74 | 18 |
145,118 | private boolean removeKeyForAllLanguages ( String key ) { try { if ( hasDescriptor ( ) ) { lockDescriptor ( ) ; } loadAllRemainingLocalizations ( ) ; lockAllLocalizations ( key ) ; } catch ( CmsException | IOException e ) { LOG . warn ( "Not able lock all localications for bundle." , e ) ; return false ; } if ( ! hasDescriptor ( ) ) { for ( Entry < Locale , SortedProperties > entry : m_localizations . entrySet ( ) ) { SortedProperties localization = entry . getValue ( ) ; if ( localization . containsKey ( key ) ) { localization . remove ( key ) ; m_changedTranslations . add ( entry . getKey ( ) ) ; } } } return true ; } | Remove a key for all language versions . If a descriptor is present the key is only removed in the descriptor . | 174 | 22 |
145,119 | private void removeXmlBundleFile ( ) throws CmsException { lockLocalization ( null ) ; m_cms . deleteResource ( m_resource , CmsResource . DELETE_PRESERVE_SIBLINGS ) ; m_resource = null ; } | Deletes the VFS XML bundle file . | 57 | 9 |
145,120 | 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 . | 393 | 8 |
145,121 | private boolean replaceValues ( Locale locale ) { try { SortedProperties localization = getLocalization ( locale ) ; if ( hasDescriptor ( ) ) { for ( Object itemId : m_container . getItemIds ( ) ) { Item item = m_container . getItem ( itemId ) ; String key = item . getItemProperty ( TableProperty . KEY ) . getValue ( ) . toString ( ) ; Object value = localization . get ( key ) ; item . getItemProperty ( TableProperty . TRANSLATION ) . setValue ( null == value ? "" : value ) ; } } else { m_container . removeAllItems ( ) ; Set < Object > keyset = m_keyset . getKeySet ( ) ; for ( Object key : keyset ) { Object itemId = m_container . addItem ( ) ; Item item = m_container . getItem ( itemId ) ; item . getItemProperty ( TableProperty . KEY ) . setValue ( key ) ; Object value = localization . get ( key ) ; item . getItemProperty ( TableProperty . TRANSLATION ) . setValue ( null == value ? "" : value ) ; } if ( m_container . getItemIds ( ) . isEmpty ( ) ) { m_container . addItem ( ) ; } } return true ; } catch ( IOException | CmsException e ) { // The problem should typically be a problem with locking or reading the file containing the translation. // This should be reported in the editor, if false is returned here. return false ; } } | Replaces the translations in an existing container with the translations for the provided locale . | 334 | 16 |
145,122 | private void saveLocalization ( ) { SortedProperties localization = new SortedProperties ( ) ; for ( Object itemId : m_container . getItemIds ( ) ) { Item item = m_container . getItem ( itemId ) ; String key = item . getItemProperty ( TableProperty . KEY ) . getValue ( ) . toString ( ) ; String value = item . getItemProperty ( TableProperty . TRANSLATION ) . getValue ( ) . toString ( ) ; if ( ! ( key . isEmpty ( ) || value . isEmpty ( ) ) ) { localization . put ( key , value ) ; } } m_keyset . updateKeySet ( m_localizations . get ( m_locale ) . keySet ( ) , localization . keySet ( ) ) ; m_localizations . put ( m_locale , localization ) ; } | Saves the current translations from the container to the respective localization . | 188 | 13 |
145,123 | private void saveToBundleDescriptor ( ) throws CmsException { if ( null != m_descFile ) { m_removeDescriptorOnCancel = false ; updateBundleDescriptorContent ( ) ; m_descFile . getFile ( ) . setContents ( m_descContent . marshal ( ) ) ; m_cms . writeFile ( m_descFile . getFile ( ) ) ; } } | Save the values to the bundle descriptor . | 92 | 8 |
145,124 | private void saveToPropertyVfsBundle ( ) throws CmsException { for ( Locale l : m_changedTranslations ) { SortedProperties props = m_localizations . get ( l ) ; LockedFile f = m_lockedBundleFiles . get ( l ) ; if ( ( null != props ) && ( null != f ) ) { try { ByteArrayOutputStream outputStream = new ByteArrayOutputStream ( ) ; Writer writer = new OutputStreamWriter ( outputStream , f . getEncoding ( ) ) ; props . store ( writer , null ) ; byte [ ] contentBytes = outputStream . toByteArray ( ) ; CmsFile file = f . getFile ( ) ; file . setContents ( contentBytes ) ; String contentEncodingProperty = m_cms . readPropertyObject ( file , CmsPropertyDefinition . PROPERTY_CONTENT_ENCODING , false ) . getValue ( ) ; if ( ( null == contentEncodingProperty ) || ! contentEncodingProperty . equals ( f . getEncoding ( ) ) ) { m_cms . writePropertyObject ( m_cms . getSitePath ( file ) , new CmsProperty ( CmsPropertyDefinition . PROPERTY_CONTENT_ENCODING , f . getEncoding ( ) , f . getEncoding ( ) ) ) ; } m_cms . writeFile ( file ) ; } catch ( IOException e ) { LOG . error ( Messages . get ( ) . getBundle ( ) . key ( Messages . ERR_READING_FILE_UNSUPPORTED_ENCODING_2 , f . getFile ( ) . getRootPath ( ) , f . getEncoding ( ) ) , e ) ; } } } } | Saves messages to a propertyvfsbundle file . | 372 | 12 |
145,125 | private void saveToXmlVfsBundle ( ) throws CmsException { if ( m_lockedBundleFiles . get ( null ) != null ) { // If the file was not locked, no changes were made, i.e., storing is not necessary. for ( Locale l : m_locales ) { SortedProperties props = m_localizations . get ( l ) ; if ( null != props ) { if ( m_xmlBundle . hasLocale ( l ) ) { m_xmlBundle . removeLocale ( l ) ; } m_xmlBundle . addLocale ( m_cms , l ) ; int i = 0 ; List < Object > keys = new ArrayList < Object > ( props . keySet ( ) ) ; Collections . sort ( keys , CmsCaseInsensitiveStringComparator . getInstance ( ) ) ; for ( Object key : keys ) { if ( ( null != key ) && ! key . toString ( ) . isEmpty ( ) ) { String value = props . getProperty ( key . toString ( ) ) ; if ( ! value . isEmpty ( ) ) { m_xmlBundle . addValue ( m_cms , "Message" , l , i ) ; i ++ ; m_xmlBundle . getValue ( "Message[" + i + "]/Key" , l ) . setStringValue ( m_cms , key . toString ( ) ) ; m_xmlBundle . getValue ( "Message[" + i + "]/Value" , l ) . setStringValue ( m_cms , value ) ; } } } } CmsFile bundleFile = m_lockedBundleFiles . get ( null ) . getFile ( ) ; bundleFile . setContents ( m_xmlBundle . marshal ( ) ) ; m_cms . writeFile ( bundleFile ) ; } } } | Saves messages to a xmlvfsbundle file . | 401 | 12 |
145,126 | private void setResourceInformation ( ) { String sitePath = m_cms . getSitePath ( m_resource ) ; int pathEnd = sitePath . lastIndexOf ( ' ' ) + 1 ; String baseName = sitePath . substring ( pathEnd ) ; m_sitepath = sitePath . substring ( 0 , pathEnd ) ; switch ( CmsMessageBundleEditorTypes . BundleType . toBundleType ( OpenCms . getResourceManager ( ) . getResourceType ( m_resource ) . getTypeName ( ) ) ) { case PROPERTY : String localeSuffix = CmsStringUtil . getLocaleSuffixForName ( baseName ) ; if ( ( null != localeSuffix ) && ! localeSuffix . isEmpty ( ) ) { baseName = baseName . substring ( 0 , baseName . lastIndexOf ( localeSuffix ) - ( 1 /* cut off trailing underscore, too*/ ) ) ; m_locale = CmsLocaleManager . getLocale ( localeSuffix ) ; } if ( ( null == m_locale ) || ! m_locales . contains ( m_locale ) ) { m_switchedLocaleOnOpening = true ; m_locale = m_locales . iterator ( ) . next ( ) ; } break ; case XML : m_locale = OpenCms . getLocaleManager ( ) . getBestAvailableLocaleForXmlContent ( m_cms , m_resource , m_xmlBundle ) ; break ; case DESCRIPTOR : m_basename = baseName . substring ( 0 , baseName . length ( ) - CmsMessageBundleEditorTypes . Descriptor . POSTFIX . length ( ) ) ; m_locale = new Locale ( "en" ) ; break ; default : throw new IllegalArgumentException ( Messages . get ( ) . container ( Messages . ERR_UNSUPPORTED_BUNDLE_TYPE_1 , CmsMessageBundleEditorTypes . BundleType . toBundleType ( OpenCms . getResourceManager ( ) . getResourceType ( m_resource ) . getTypeName ( ) ) ) . toString ( ) ) ; } m_basename = baseName ; } | Extract site path base name and locale from the resource opened with the editor . | 491 | 16 |
145,127 | private void unmarshalDescriptor ( ) throws CmsXmlException , CmsException { if ( null != m_desc ) { // unmarshal descriptor m_descContent = CmsXmlContentFactory . unmarshal ( m_cms , m_cms . readFile ( m_desc ) ) ; // configure messages if wanted CmsProperty bundleProp = m_cms . readPropertyObject ( m_desc , PROPERTY_BUNDLE_DESCRIPTOR_LOCALIZATION , true ) ; if ( ! ( bundleProp . isNullProperty ( ) || bundleProp . getValue ( ) . trim ( ) . isEmpty ( ) ) ) { m_configuredBundle = bundleProp . getValue ( ) ; } } } | Unmarshals the descriptor content . | 162 | 8 |
145,128 | private void updateBundleDescriptorContent ( ) throws CmsXmlException { if ( m_descContent . hasLocale ( Descriptor . LOCALE ) ) { m_descContent . removeLocale ( Descriptor . LOCALE ) ; } m_descContent . addLocale ( m_cms , Descriptor . LOCALE ) ; int i = 0 ; Property < Object > descProp ; String desc ; Property < Object > defaultValueProp ; String defaultValue ; Map < String , Item > keyItemMap = getKeyItemMap ( ) ; List < String > keys = new ArrayList < String > ( keyItemMap . keySet ( ) ) ; Collections . sort ( keys , CmsCaseInsensitiveStringComparator . getInstance ( ) ) ; for ( Object key : keys ) { if ( ( null != key ) && ! key . toString ( ) . isEmpty ( ) ) { m_descContent . addValue ( m_cms , Descriptor . N_MESSAGE , Descriptor . LOCALE , i ) ; i ++ ; String messagePrefix = Descriptor . N_MESSAGE + "[" + i + "]/" ; m_descContent . getValue ( messagePrefix + Descriptor . N_KEY , Descriptor . LOCALE ) . setStringValue ( m_cms , ( String ) key ) ; descProp = keyItemMap . get ( key ) . getItemProperty ( TableProperty . DESCRIPTION ) ; if ( ( null != descProp ) && ( null != descProp . getValue ( ) ) ) { desc = descProp . getValue ( ) . toString ( ) ; m_descContent . getValue ( messagePrefix + Descriptor . N_DESCRIPTION , Descriptor . LOCALE ) . setStringValue ( m_cms , desc ) ; } defaultValueProp = keyItemMap . get ( key ) . getItemProperty ( TableProperty . DEFAULT ) ; if ( ( null != defaultValueProp ) && ( null != defaultValueProp . getValue ( ) ) ) { defaultValue = defaultValueProp . getValue ( ) . toString ( ) ; m_descContent . getValue ( messagePrefix + Descriptor . N_DEFAULT , Descriptor . LOCALE ) . setStringValue ( m_cms , defaultValue ) ; } } } } | Update the descriptor content with values from the editor . | 509 | 10 |
145,129 | protected void removeInvalidChildren ( ) { if ( getLoadState ( ) == LoadState . LOADED ) { List < CmsSitemapTreeItem > toDelete = new ArrayList < CmsSitemapTreeItem > ( ) ; for ( int i = 0 ; i < getChildCount ( ) ; i ++ ) { CmsSitemapTreeItem item = ( CmsSitemapTreeItem ) getChild ( i ) ; CmsUUID id = item . getEntryId ( ) ; if ( ( id != null ) && ( CmsSitemapView . getInstance ( ) . getController ( ) . getEntryById ( id ) == null ) ) { toDelete . add ( item ) ; } } for ( CmsSitemapTreeItem deleteItem : toDelete ) { m_children . removeItem ( deleteItem ) ; } } } | Helper method to remove invalid children that don t have a corresponding CmsSitemapClientEntry . | 186 | 20 |
145,130 | @ UiHandler ( "m_everyDay" ) void onEveryDayChange ( ValueChangeEvent < String > event ) { if ( handleChange ( ) ) { m_controller . setInterval ( m_everyDay . getFormValueAsString ( ) ) ; } } | Handle interval change . | 59 | 4 |
145,131 | private String getApiKey ( CmsObject cms , String sitePath ) throws CmsException { String res = cms . readPropertyObject ( sitePath , CmsPropertyDefinition . PROPERTY_GOOGLE_API_KEY_WORKPLACE , true ) . getValue ( ) ; if ( CmsStringUtil . isEmptyOrWhitespaceOnly ( res ) ) { res = cms . readPropertyObject ( sitePath , CmsPropertyDefinition . PROPERTY_GOOGLE_API_KEY , true ) . getValue ( ) ; } return res ; } | Get the correct google api key . Tries to read a workplace key first . | 128 | 16 |
145,132 | private void propagateFacetNames ( ) { // collect all names and configurations Collection < String > facetNames = new ArrayList < String > ( ) ; Collection < I_CmsSearchConfigurationFacet > facetConfigs = new ArrayList < I_CmsSearchConfigurationFacet > ( ) ; facetNames . addAll ( m_fieldFacets . keySet ( ) ) ; facetConfigs . addAll ( m_fieldFacets . values ( ) ) ; facetNames . addAll ( m_rangeFacets . keySet ( ) ) ; facetConfigs . addAll ( m_rangeFacets . values ( ) ) ; if ( null != m_queryFacet ) { facetNames . add ( m_queryFacet . getName ( ) ) ; facetConfigs . add ( m_queryFacet ) ; } // propagate all names for ( I_CmsSearchConfigurationFacet facetConfig : facetConfigs ) { facetConfig . propagateAllFacetNames ( facetNames ) ; } } | Propagates the names of all facets to each single facet . | 213 | 13 |
145,133 | private int getDaysToNextMatch ( WeekDay weekDay ) { for ( WeekDay wd : m_weekDays ) { if ( wd . compareTo ( weekDay ) > 0 ) { return wd . toInt ( ) - weekDay . toInt ( ) ; } } return ( m_weekDays . iterator ( ) . next ( ) . toInt ( ) + ( m_interval * I_CmsSerialDateValue . NUM_OF_WEEKDAYS ) ) - weekDay . toInt ( ) ; } | Returns the number of days from the given weekday to the next weekday the event should occur . | 115 | 18 |
145,134 | public static I_CmsMacroResolver newWorkplaceLocaleResolver ( final CmsObject cms ) { // Resolve macros in the property configuration CmsMacroResolver resolver = new CmsMacroResolver ( ) ; resolver . setCmsObject ( cms ) ; CmsUserSettings userSettings = new CmsUserSettings ( cms . getRequestContext ( ) . getCurrentUser ( ) ) ; CmsMultiMessages multimessages = new CmsMultiMessages ( userSettings . getLocale ( ) ) ; multimessages . addMessages ( OpenCms . getWorkplaceManager ( ) . getMessages ( userSettings . getLocale ( ) ) ) ; resolver . setMessages ( multimessages ) ; resolver . setKeepEmptyMacros ( true ) ; return resolver ; } | Returns a new macro resolver that loads message keys from the workplace bundle in the user setting s language . | 183 | 21 |
145,135 | protected static List < String > parseMandatoryStringValues ( JSONObject json , String key ) throws JSONException { List < String > list = null ; JSONArray array = json . getJSONArray ( key ) ; list = new ArrayList < String > ( array . length ( ) ) ; for ( int i = 0 ; i < array . length ( ) ; i ++ ) { try { String entry = array . getString ( i ) ; list . add ( entry ) ; } catch ( JSONException e ) { LOG . info ( Messages . get ( ) . getBundle ( ) . key ( Messages . LOG_OPTIONAL_STRING_ENTRY_UNPARSABLE_1 , key ) , e ) ; } } return list ; } | Helper for reading a mandatory String value list - throwing an Exception if parsing fails . | 158 | 16 |
145,136 | protected Boolean getEscapeQueryChars ( ) { Boolean isEscape = parseOptionalBooleanValue ( m_configObject , JSON_KEY_ESCAPE_QUERY_CHARACTERS ) ; return ( null == isEscape ) && ( m_baseConfig != null ) ? Boolean . valueOf ( m_baseConfig . getGeneralConfig ( ) . getEscapeQueryChars ( ) ) : isEscape ; } | Returns the flag indicating if the characters in the query string that are commands to Solr should be escaped . | 92 | 21 |
145,137 | protected String getExtraSolrParams ( ) { try { return m_configObject . getString ( JSON_KEY_EXTRASOLRPARAMS ) ; } catch ( JSONException e ) { if ( null == m_baseConfig ) { if ( LOG . isInfoEnabled ( ) ) { LOG . info ( Messages . get ( ) . getBundle ( ) . key ( Messages . LOG_NO_EXTRA_PARAMETERS_0 ) , e ) ; } return "" ; } else { return m_baseConfig . getGeneralConfig ( ) . getExtraSolrParams ( ) ; } } } | Returns the configured extra parameters that should be given to Solr or the empty string if no parameters are configured . | 133 | 22 |
145,138 | protected Boolean getIgnoreExpirationDate ( ) { Boolean isIgnoreExpirationDate = parseOptionalBooleanValue ( m_configObject , JSON_KEY_IGNORE_EXPIRATION_DATE ) ; return ( null == isIgnoreExpirationDate ) && ( m_baseConfig != null ) ? Boolean . valueOf ( m_baseConfig . getGeneralConfig ( ) . getIgnoreExpirationDate ( ) ) : isIgnoreExpirationDate ; } | Returns a flag indicating if also expired resources should be found . | 100 | 12 |
145,139 | protected Boolean getIgnoreQuery ( ) { Boolean isIgnoreQuery = parseOptionalBooleanValue ( m_configObject , JSON_KEY_IGNORE_QUERY ) ; return ( null == isIgnoreQuery ) && ( m_baseConfig != null ) ? Boolean . valueOf ( m_baseConfig . getGeneralConfig ( ) . getIgnoreQueryParam ( ) ) : isIgnoreQuery ; } | Returns a flag indicating if the query given by the parameters should be ignored . | 87 | 15 |
145,140 | protected Boolean getIgnoreReleaseDate ( ) { Boolean isIgnoreReleaseDate = parseOptionalBooleanValue ( m_configObject , JSON_KEY_IGNORE_RELEASE_DATE ) ; return ( null == isIgnoreReleaseDate ) && ( m_baseConfig != null ) ? Boolean . valueOf ( m_baseConfig . getGeneralConfig ( ) . getIgnoreReleaseDate ( ) ) : isIgnoreReleaseDate ; } | Returns a flag indicating if also unreleased resources should be found . | 94 | 13 |
145,141 | protected List < Integer > getPageSizes ( ) { try { return Collections . singletonList ( Integer . valueOf ( m_configObject . getInt ( JSON_KEY_PAGESIZE ) ) ) ; } catch ( JSONException e ) { List < Integer > result = null ; String pageSizesString = null ; try { pageSizesString = m_configObject . getString ( JSON_KEY_PAGESIZE ) ; String [ ] pageSizesArray = pageSizesString . split ( "-" ) ; if ( pageSizesArray . length > 0 ) { result = new ArrayList <> ( pageSizesArray . length ) ; for ( int i = 0 ; i < pageSizesArray . length ; i ++ ) { result . add ( Integer . valueOf ( pageSizesArray [ i ] ) ) ; } } return result ; } catch ( NumberFormatException | JSONException e1 ) { LOG . warn ( Messages . get ( ) . getBundle ( ) . key ( Messages . LOG_PARSING_PAGE_SIZES_FAILED_1 , pageSizesString ) , e ) ; } if ( null == m_baseConfig ) { if ( LOG . isInfoEnabled ( ) ) { LOG . info ( Messages . get ( ) . getBundle ( ) . key ( Messages . LOG_NO_PAGESIZE_SPECIFIED_0 ) , e ) ; } return null ; } else { return m_baseConfig . getPaginationConfig ( ) . getPageSizes ( ) ; } } } | Returns the configured page sizes or the default page size if no core is configured . | 335 | 16 |
145,142 | protected String getQueryModifier ( ) { String queryModifier = parseOptionalStringValue ( m_configObject , JSON_KEY_QUERY_MODIFIER ) ; return ( null == queryModifier ) && ( null != m_baseConfig ) ? m_baseConfig . getGeneralConfig ( ) . getQueryModifier ( ) : queryModifier ; } | Returns the optional query modifier . | 77 | 6 |
145,143 | protected String getQueryParam ( ) { String param = parseOptionalStringValue ( m_configObject , JSON_KEY_QUERYPARAM ) ; if ( param == null ) { return null != m_baseConfig ? m_baseConfig . getGeneralConfig ( ) . getQueryParam ( ) : DEFAULT_QUERY_PARAM ; } else { return param ; } } | Returns the configured request parameter for the query string or the default parameter if no core is configured . | 80 | 19 |
145,144 | protected Boolean getSearchForEmptyQuery ( ) { Boolean isSearchForEmptyQuery = parseOptionalBooleanValue ( m_configObject , JSON_KEY_SEARCH_FOR_EMPTY_QUERY ) ; return ( isSearchForEmptyQuery == null ) && ( null != m_baseConfig ) ? Boolean . valueOf ( m_baseConfig . getGeneralConfig ( ) . getSearchForEmptyQueryParam ( ) ) : isSearchForEmptyQuery ; } | Returns a flag indicating if search should be performed using a wildcard if the empty query is given . | 97 | 20 |
145,145 | protected List < I_CmsSearchConfigurationSortOption > getSortOptions ( ) { List < I_CmsSearchConfigurationSortOption > options = new LinkedList < I_CmsSearchConfigurationSortOption > ( ) ; try { JSONArray sortOptions = m_configObject . getJSONArray ( JSON_KEY_SORTOPTIONS ) ; for ( int i = 0 ; i < sortOptions . length ( ) ; i ++ ) { I_CmsSearchConfigurationSortOption option = parseSortOption ( sortOptions . getJSONObject ( i ) ) ; if ( option != null ) { options . add ( option ) ; } } } catch ( JSONException e ) { if ( null == m_baseConfig ) { if ( LOG . isInfoEnabled ( ) ) { LOG . info ( Messages . get ( ) . getBundle ( ) . key ( Messages . LOG_NO_SORT_CONFIG_0 ) , e ) ; } } else { options = m_baseConfig . getSortConfig ( ) . getSortOptions ( ) ; } } return options ; } | Returns the list of the configured sort options or the empty list if no sort options are configured . | 230 | 19 |
145,146 | protected void init ( String configString , I_CmsSearchConfiguration baseConfig ) throws JSONException { m_configObject = new JSONObject ( configString ) ; m_baseConfig = baseConfig ; } | Initialization that parses the String to a JSON object . | 43 | 12 |
145,147 | protected I_CmsFacetQueryItem parseFacetQueryItem ( JSONObject item ) { String query ; try { query = item . getString ( JSON_KEY_QUERY_FACET_QUERY_QUERY ) ; } catch ( JSONException e ) { // TODO: Log return null ; } String label = parseOptionalStringValue ( item , JSON_KEY_QUERY_FACET_QUERY_LABEL ) ; return new CmsFacetQueryItem ( query , label ) ; } | Parses a single query item for the query facet . | 110 | 12 |
145,148 | protected List < I_CmsFacetQueryItem > parseFacetQueryItems ( JSONObject queryFacetObject ) throws JSONException { JSONArray items = queryFacetObject . getJSONArray ( JSON_KEY_QUERY_FACET_QUERY ) ; List < I_CmsFacetQueryItem > result = new ArrayList < I_CmsFacetQueryItem > ( items . length ( ) ) ; for ( int i = 0 ; i < items . length ( ) ; i ++ ) { I_CmsFacetQueryItem item = parseFacetQueryItem ( items . getJSONObject ( i ) ) ; if ( item != null ) { result . add ( item ) ; } } return result ; } | Parses the list of query items for the query facet . | 156 | 13 |
145,149 | protected I_CmsSearchConfigurationFacetField parseFieldFacet ( JSONObject fieldFacetObject ) { try { String field = fieldFacetObject . getString ( JSON_KEY_FACET_FIELD ) ; String name = parseOptionalStringValue ( fieldFacetObject , JSON_KEY_FACET_NAME ) ; String label = parseOptionalStringValue ( fieldFacetObject , JSON_KEY_FACET_LABEL ) ; Integer minCount = parseOptionalIntValue ( fieldFacetObject , JSON_KEY_FACET_MINCOUNT ) ; Integer limit = parseOptionalIntValue ( fieldFacetObject , JSON_KEY_FACET_LIMIT ) ; String prefix = parseOptionalStringValue ( fieldFacetObject , JSON_KEY_FACET_PREFIX ) ; String sorder = parseOptionalStringValue ( fieldFacetObject , JSON_KEY_FACET_ORDER ) ; I_CmsSearchConfigurationFacet . SortOrder order ; try { order = I_CmsSearchConfigurationFacet . SortOrder . valueOf ( sorder ) ; } catch ( Exception e ) { order = null ; } String filterQueryModifier = parseOptionalStringValue ( fieldFacetObject , JSON_KEY_FACET_FILTERQUERYMODIFIER ) ; Boolean isAndFacet = parseOptionalBooleanValue ( fieldFacetObject , JSON_KEY_FACET_ISANDFACET ) ; List < String > preselection = parseOptionalStringValues ( fieldFacetObject , JSON_KEY_FACET_PRESELECTION ) ; Boolean ignoreFilterAllFacetFilters = parseOptionalBooleanValue ( fieldFacetObject , JSON_KEY_FACET_IGNOREALLFACETFILTERS ) ; return new CmsSearchConfigurationFacetField ( field , name , minCount , limit , prefix , label , order , filterQueryModifier , isAndFacet , preselection , ignoreFilterAllFacetFilters ) ; } catch ( JSONException e ) { LOG . error ( Messages . get ( ) . getBundle ( ) . key ( Messages . ERR_FIELD_FACET_MANDATORY_KEY_MISSING_1 , JSON_KEY_FACET_FIELD ) , e ) ; return null ; } } | Parses the field facet configurations . | 500 | 8 |
145,150 | protected I_CmsSearchConfigurationFacetRange parseRangeFacet ( JSONObject rangeFacetObject ) { try { String range = rangeFacetObject . getString ( JSON_KEY_RANGE_FACET_RANGE ) ; String name = parseOptionalStringValue ( rangeFacetObject , JSON_KEY_FACET_NAME ) ; String label = parseOptionalStringValue ( rangeFacetObject , JSON_KEY_FACET_LABEL ) ; Integer minCount = parseOptionalIntValue ( rangeFacetObject , JSON_KEY_FACET_MINCOUNT ) ; String start = rangeFacetObject . getString ( JSON_KEY_RANGE_FACET_START ) ; String end = rangeFacetObject . getString ( JSON_KEY_RANGE_FACET_END ) ; String gap = rangeFacetObject . getString ( JSON_KEY_RANGE_FACET_GAP ) ; List < String > sother = parseOptionalStringValues ( rangeFacetObject , JSON_KEY_RANGE_FACET_OTHER ) ; Boolean hardEnd = parseOptionalBooleanValue ( rangeFacetObject , JSON_KEY_RANGE_FACET_HARDEND ) ; List < I_CmsSearchConfigurationFacetRange . Other > other = null ; if ( sother != null ) { other = new ArrayList < I_CmsSearchConfigurationFacetRange . Other > ( sother . size ( ) ) ; for ( String so : sother ) { try { I_CmsSearchConfigurationFacetRange . Other o = I_CmsSearchConfigurationFacetRange . Other . valueOf ( so ) ; other . add ( o ) ; } catch ( Exception e ) { LOG . error ( Messages . get ( ) . getBundle ( ) . key ( Messages . ERR_INVALID_OTHER_OPTION_1 , so ) , e ) ; } } } Boolean isAndFacet = parseOptionalBooleanValue ( rangeFacetObject , JSON_KEY_FACET_ISANDFACET ) ; List < String > preselection = parseOptionalStringValues ( rangeFacetObject , JSON_KEY_FACET_PRESELECTION ) ; Boolean ignoreAllFacetFilters = parseOptionalBooleanValue ( rangeFacetObject , JSON_KEY_FACET_IGNOREALLFACETFILTERS ) ; return new CmsSearchConfigurationFacetRange ( range , start , end , gap , other , hardEnd , name , minCount , label , isAndFacet , preselection , ignoreAllFacetFilters ) ; } catch ( JSONException e ) { LOG . error ( Messages . get ( ) . getBundle ( ) . key ( Messages . ERR_RANGE_FACET_MANDATORY_KEY_MISSING_1 , JSON_KEY_RANGE_FACET_RANGE + ", " + JSON_KEY_RANGE_FACET_START + ", " + JSON_KEY_RANGE_FACET_END + ", " + JSON_KEY_RANGE_FACET_GAP ) , e ) ; return null ; } } | Parses the query facet configurations . | 689 | 8 |
145,151 | protected I_CmsSearchConfigurationSortOption parseSortOption ( JSONObject json ) { try { String solrValue = json . getString ( JSON_KEY_SORTOPTION_SOLRVALUE ) ; String paramValue = parseOptionalStringValue ( json , JSON_KEY_SORTOPTION_PARAMVALUE ) ; paramValue = ( paramValue == null ) ? solrValue : paramValue ; String label = parseOptionalStringValue ( json , JSON_KEY_SORTOPTION_LABEL ) ; label = ( label == null ) ? paramValue : label ; return new CmsSearchConfigurationSortOption ( label , paramValue , solrValue ) ; } catch ( JSONException e ) { LOG . error ( Messages . get ( ) . getBundle ( ) . key ( Messages . ERR_SORT_OPTION_NOT_PARSABLE_1 , JSON_KEY_SORTOPTION_SOLRVALUE ) , e ) ; return null ; } } | Returns a single sort option configuration as configured via the methods parameter or null if the parameter does not specify a sort option . | 210 | 24 |
145,152 | private Map < String , String > mergeItem ( String item , Map < String , String > localeValues , Map < String , String > resultLocaleValues ) { if ( resultLocaleValues . get ( item ) != null ) { if ( localeValues . get ( item ) != null ) { localeValues . put ( item , localeValues . get ( item ) + " " + resultLocaleValues . get ( item ) ) ; } else { localeValues . put ( item , resultLocaleValues . get ( item ) ) ; } } return localeValues ; } | Merges the item from the resultLocaleValues into the corresponding item of the localeValues . | 119 | 19 |
145,153 | public static CmsGalleryTabConfiguration resolve ( String configStr ) { CmsGalleryTabConfiguration tabConfig ; if ( CmsStringUtil . isEmptyOrWhitespaceOnly ( configStr ) ) { configStr = "*sitemap,types,galleries,categories,vfstree,search,results" ; } if ( DEFAULT_CONFIGURATIONS != null ) { tabConfig = DEFAULT_CONFIGURATIONS . get ( configStr ) ; if ( tabConfig != null ) { return tabConfig ; } } return parse ( configStr ) ; } | Given a string which is either the name of a predefined tab configuration or a configuration string returns the corresponding tab configuration . | 123 | 24 |
145,154 | private void forward ( ) { Set < String > selected = new HashSet <> ( ) ; for ( CheckBox checkbox : m_componentCheckboxes ) { CmsSetupComponent component = ( CmsSetupComponent ) ( checkbox . getData ( ) ) ; if ( checkbox . getValue ( ) . booleanValue ( ) ) { selected . add ( component . getId ( ) ) ; } } String error = null ; for ( String compId : selected ) { CmsSetupComponent component = m_componentMap . get ( compId ) ; for ( String dep : component . getDependencies ( ) ) { if ( ! selected . contains ( dep ) ) { error = "Unfulfilled dependency: The component " + component . getName ( ) + " can not be installed because its dependency " + m_componentMap . get ( dep ) . getName ( ) + " is not selected" ; break ; } } } if ( error == null ) { Set < String > modules = new HashSet <> ( ) ; for ( CmsSetupComponent component : m_componentMap . values ( ) ) { if ( selected . contains ( component . getId ( ) ) ) { for ( CmsModule module : m_context . getSetupBean ( ) . getAvailableModules ( ) . values ( ) ) { if ( component . match ( module . getName ( ) ) ) { modules . add ( module . getName ( ) ) ; } } } } List < String > moduleList = new ArrayList <> ( modules ) ; m_context . getSetupBean ( ) . setInstallModules ( CmsStringUtil . listAsString ( moduleList , "|" ) ) ; m_context . stepForward ( ) ; } else { CmsSetupErrorDialog . showErrorDialog ( error , error ) ; } } | Moves to the next step . | 393 | 7 |
145,155 | private void initComponents ( List < CmsSetupComponent > components ) { for ( CmsSetupComponent component : components ) { CheckBox checkbox = new CheckBox ( ) ; checkbox . setValue ( component . isChecked ( ) ) ; checkbox . setCaption ( component . getName ( ) + " - " + component . getDescription ( ) ) ; checkbox . setDescription ( component . getDescription ( ) ) ; checkbox . setData ( component ) ; checkbox . setWidth ( "100%" ) ; m_components . addComponent ( checkbox ) ; m_componentCheckboxes . add ( checkbox ) ; m_componentMap . put ( component . getId ( ) , component ) ; } } | Initializes the components . | 156 | 5 |
145,156 | protected void addFacetPart ( CmsSolrQuery query ) { query . set ( "facet" , "true" ) ; String excludes = "" ; if ( m_config . getIgnoreAllFacetFilters ( ) || ( ! m_state . getCheckedEntries ( ) . isEmpty ( ) && ! m_config . getIsAndFacet ( ) ) ) { excludes = "{!ex=" + m_config . getIgnoreTags ( ) + "}" ; } for ( I_CmsFacetQueryItem q : m_config . getQueryList ( ) ) { query . add ( "facet.query" , excludes + q . getQuery ( ) ) ; } } | Add query part for the facet without filters . | 153 | 9 |
145,157 | protected void convertSearchResults ( final Collection < CmsSearchResource > searchResults ) { m_foundResources = new ArrayList < I_CmsSearchResourceBean > ( ) ; for ( final CmsSearchResource searchResult : searchResults ) { m_foundResources . add ( new CmsSearchResourceBean ( searchResult , m_cmsObject ) ) ; } } | Converts the search results from CmsSearchResource to CmsSearchResourceBean . | 80 | 18 |
145,158 | public void addAliasToConfigSite ( String alias , String redirect , String offset ) { long timeOffset = 0 ; try { timeOffset = Long . parseLong ( offset ) ; } catch ( Throwable e ) { // ignore } CmsSiteMatcher siteMatcher = new CmsSiteMatcher ( alias , timeOffset ) ; boolean redirectVal = new Boolean ( redirect ) . booleanValue ( ) ; siteMatcher . setRedirect ( redirectVal ) ; m_aliases . add ( siteMatcher ) ; } | Adds an alias to the currently configured site . | 110 | 9 |
145,159 | private void addServer ( CmsSiteMatcher matcher , CmsSite site ) { Map < CmsSiteMatcher , CmsSite > siteMatcherSites = new HashMap < CmsSiteMatcher , CmsSite > ( m_siteMatcherSites ) ; siteMatcherSites . put ( matcher , site ) ; setSiteMatcherSites ( siteMatcherSites ) ; } | Adds a new Site matcher object to the map of server names . | 90 | 14 |
145,160 | private void updateLetsEncrypt ( ) { getReport ( ) . println ( Messages . get ( ) . container ( Messages . RPT_STARTING_LETSENCRYPT_UPDATE_0 ) ) ; CmsLetsEncryptConfiguration config = OpenCms . getLetsEncryptConfig ( ) ; if ( ( config == null ) || ! config . isValidAndEnabled ( ) ) { return ; } CmsSiteConfigToLetsEncryptConfigConverter converter = new CmsSiteConfigToLetsEncryptConfigConverter ( config ) ; boolean ok = converter . run ( getReport ( ) , OpenCms . getSiteManager ( ) ) ; if ( ok ) { getReport ( ) . println ( org . opencms . ui . apps . Messages . get ( ) . container ( org . opencms . ui . apps . Messages . RPT_LETSENCRYPT_FINISHED_0 ) , I_CmsReport . FORMAT_OK ) ; } } | Updates LetsEncrypt configuration . | 220 | 7 |
145,161 | private String getDynamicAttributeValue ( CmsFile file , I_CmsXmlContentValue value , String attributeName , CmsEntity editedLocalEntity ) { if ( ( null != editedLocalEntity ) && ( editedLocalEntity . getAttribute ( attributeName ) != null ) ) { getSessionCache ( ) . setDynamicValue ( attributeName , editedLocalEntity . getAttribute ( attributeName ) . getSimpleValue ( ) ) ; } String currentValue = getSessionCache ( ) . getDynamicValue ( attributeName ) ; if ( null != currentValue ) { return currentValue ; } if ( null != file ) { if ( value . getTypeName ( ) . equals ( CmsXmlDynamicCategoryValue . TYPE_NAME ) ) { List < CmsCategory > categories = new ArrayList < CmsCategory > ( 0 ) ; try { categories = CmsCategoryService . getInstance ( ) . readResourceCategories ( getCmsObject ( ) , file ) ; } catch ( CmsException e ) { LOG . error ( Messages . get ( ) . getBundle ( ) . key ( Messages . ERROR_FAILED_READING_CATEGORIES_1 ) , e ) ; } I_CmsWidget widget = null ; widget = CmsWidgetUtil . collectWidgetInfo ( value ) . getWidget ( ) ; if ( ( null != widget ) && ( widget instanceof CmsCategoryWidget ) ) { String mainCategoryPath = ( ( CmsCategoryWidget ) widget ) . getStartingCategory ( getCmsObject ( ) , getCmsObject ( ) . getSitePath ( file ) ) ; StringBuffer pathes = new StringBuffer ( ) ; for ( CmsCategory category : categories ) { if ( category . getPath ( ) . startsWith ( mainCategoryPath ) ) { String path = category . getBasePath ( ) + category . getPath ( ) ; path = getCmsObject ( ) . getRequestContext ( ) . removeSiteRoot ( path ) ; pathes . append ( path ) . append ( ' ' ) ; } } String dynamicConfigString = pathes . length ( ) > 0 ? pathes . substring ( 0 , pathes . length ( ) - 1 ) : "" ; getSessionCache ( ) . setDynamicValue ( attributeName , dynamicConfigString ) ; return dynamicConfigString ; } } } return "" ; } | Returns the value that has to be set for the dynamic attribute . | 504 | 13 |
145,162 | public void setMonth ( String monthStr ) { final Month month = Month . valueOf ( monthStr ) ; if ( ( m_model . getMonth ( ) == null ) || ! m_model . getMonth ( ) . equals ( monthStr ) ) { removeExceptionsOnChange ( new Command ( ) { public void execute ( ) { m_model . setMonth ( month ) ; onValueChange ( ) ; } } ) ; } } | Set the month . | 94 | 4 |
145,163 | public void setPatternScheme ( final boolean isWeekDayBased ) { if ( isWeekDayBased ^ ( null != m_model . getWeekDay ( ) ) ) { removeExceptionsOnChange ( new Command ( ) { public void execute ( ) { if ( isWeekDayBased ) { m_model . setWeekDay ( getPatternDefaultValues ( ) . getWeekDay ( ) ) ; m_model . setWeekOfMonth ( getPatternDefaultValues ( ) . getWeekOfMonth ( ) ) ; } else { m_model . setWeekDay ( null ) ; m_model . setWeekOfMonth ( null ) ; } m_model . setMonth ( getPatternDefaultValues ( ) . getMonth ( ) ) ; m_model . setDayOfMonth ( getPatternDefaultValues ( ) . getDayOfMonth ( ) ) ; m_model . setInterval ( getPatternDefaultValues ( ) . getInterval ( ) ) ; onValueChange ( ) ; } } ) ; } } | Set the pattern scheme . | 213 | 5 |
145,164 | public void setWeekDay ( String weekDayStr ) { final WeekDay weekDay = WeekDay . valueOf ( weekDayStr ) ; if ( ( m_model . getWeekDay ( ) != null ) || ! m_model . getWeekDay ( ) . equals ( weekDay ) ) { removeExceptionsOnChange ( new Command ( ) { public void execute ( ) { m_model . setWeekDay ( weekDay ) ; onValueChange ( ) ; } } ) ; } } | Set the week day . | 104 | 5 |
145,165 | public void setWeekOfMonth ( String weekOfMonthStr ) { final WeekOfMonth weekOfMonth = WeekOfMonth . valueOf ( weekOfMonthStr ) ; if ( ( null == m_model . getWeekOfMonth ( ) ) || ! m_model . getWeekOfMonth ( ) . equals ( weekOfMonth ) ) { removeExceptionsOnChange ( new Command ( ) { public void execute ( ) { m_model . setWeekOfMonth ( weekOfMonth ) ; onValueChange ( ) ; } } ) ; } } | Set the week of month . | 115 | 6 |
145,166 | public static String getLocalizedKey ( Map < String , ? > propertiesMap , String key , Locale locale ) { List < String > localizedKeys = CmsLocaleManager . getLocaleVariants ( key , locale , true , false ) ; for ( String localizedKey : localizedKeys ) { if ( propertiesMap . containsKey ( localizedKey ) ) { return localizedKey ; } } return key ; } | Returns the key for the best matching local - specific property version . | 86 | 13 |
145,167 | private List < CmsSearchField > getFields ( ) { CmsSearchManager manager = OpenCms . getSearchManager ( ) ; I_CmsSearchFieldConfiguration fieldConfig = manager . getFieldConfiguration ( getParamFieldconfiguration ( ) ) ; List < CmsSearchField > result ; if ( fieldConfig != null ) { result = fieldConfig . getFields ( ) ; } else { result = Collections . emptyList ( ) ; if ( LOG . isErrorEnabled ( ) ) { LOG . error ( Messages . get ( ) . getBundle ( ) . key ( Messages . ERR_SEARCHINDEX_EDIT_MISSING_PARAM_1 , A_CmsFieldConfigurationDialog . PARAM_FIELDCONFIGURATION ) ) ; } } return result ; } | Returns the configured fields of the current field configuration . | 172 | 10 |
145,168 | public static Function < String , String > createStringTemplateSource ( I_CmsFormatterBean formatter , Supplier < CmsXmlContent > contentSupplier ) { return key -> { String result = null ; if ( formatter != null ) { result = formatter . getAttributes ( ) . get ( key ) ; } if ( result == null ) { CmsXmlContent content = contentSupplier . get ( ) ; if ( content != null ) { result = content . getHandler ( ) . getParameter ( key ) ; } } return result ; } ; } | Helper method to create a string template source for a given formatter and content . | 123 | 16 |
145,169 | private Map < String , String > getContentsByContainerName ( CmsContainerElementBean element , Collection < CmsContainer > containers ) { CmsFormatterConfiguration configs = getFormatterConfiguration ( element . getResource ( ) ) ; Map < String , String > result = new HashMap < String , String > ( ) ; for ( CmsContainer container : containers ) { String content = getContentByContainer ( element , container , configs ) ; if ( content != null ) { content = removeScriptTags ( content ) ; } result . put ( container . getName ( ) , content ) ; } return result ; } | Returns the rendered element content for all the given containers . | 132 | 11 |
145,170 | public void setWorkConnection ( CmsSetupDb db ) { db . setConnection ( m_setupBean . getDbDriver ( ) , m_setupBean . getDbWorkConStr ( ) , m_setupBean . getDbConStrParams ( ) , m_setupBean . getDbWorkUser ( ) , m_setupBean . getDbWorkPwd ( ) ) ; } | Set work connection . | 88 | 4 |
145,171 | private void updateDb ( String dbName , String webapp ) { m_mainLayout . removeAllComponents ( ) ; m_setupBean . setDatabase ( dbName ) ; CmsDbSettingsPanel panel = new CmsDbSettingsPanel ( m_setupBean ) ; m_panel [ 0 ] = panel ; panel . initFromSetupBean ( webapp ) ; m_mainLayout . addComponent ( panel ) ; } | Switches DB type . | 93 | 5 |
145,172 | public void removeExpiration ( ) { if ( getFilterQueries ( ) != null ) { for ( String fq : getFilterQueries ( ) ) { if ( fq . startsWith ( CmsSearchField . FIELD_DATE_EXPIRED + ":" ) || fq . startsWith ( CmsSearchField . FIELD_DATE_RELEASED + ":" ) ) { removeFilterQuery ( fq ) ; } } } m_ignoreExpiration = true ; } | Removes the expiration flag . | 106 | 6 |
145,173 | public Map < String , CmsJspCategoryAccessBean > getReadAllSubCategories ( ) { if ( null == m_allSubCategories ) { m_allSubCategories = CmsCollectionsGenericWrapper . createLazyMap ( new Transformer ( ) { @ Override public Object transform ( Object categoryPath ) { try { List < CmsCategory > categories = CmsCategoryService . getInstance ( ) . readCategories ( m_cms , ( String ) categoryPath , true , m_cms . getRequestContext ( ) . getUri ( ) ) ; CmsJspCategoryAccessBean result = new CmsJspCategoryAccessBean ( m_cms , categories , ( String ) categoryPath ) ; return result ; } catch ( CmsException e ) { LOG . warn ( e . getLocalizedMessage ( ) , e ) ; return null ; } } } ) ; } return m_allSubCategories ; } | Reads all sub - categories below the provided category . | 205 | 11 |
145,174 | public Map < String , CmsCategory > getReadCategory ( ) { if ( null == m_categories ) { m_categories = CmsCollectionsGenericWrapper . createLazyMap ( new Transformer ( ) { public Object transform ( Object categoryPath ) { try { CmsCategoryService catService = CmsCategoryService . getInstance ( ) ; return catService . localizeCategory ( m_cms , catService . readCategory ( m_cms , ( String ) categoryPath , getRequestContext ( ) . getUri ( ) ) , m_cms . getRequestContext ( ) . getLocale ( ) ) ; } catch ( CmsException e ) { LOG . warn ( e . getLocalizedMessage ( ) , e ) ; return null ; } } } ) ; } return m_categories ; } | Transforms the category path of a category to the category . | 176 | 12 |
145,175 | public Map < String , CmsJspCategoryAccessBean > getReadResourceCategories ( ) { if ( null == m_resourceCategories ) { m_resourceCategories = CmsCollectionsGenericWrapper . createLazyMap ( new Transformer ( ) { public Object transform ( Object resourceName ) { try { CmsResource resource = m_cms . readResource ( getRequestContext ( ) . removeSiteRoot ( ( String ) resourceName ) ) ; return new CmsJspCategoryAccessBean ( m_cms , resource ) ; } catch ( CmsException e ) { LOG . warn ( e . getLocalizedMessage ( ) , e ) ; return null ; } } } ) ; } return m_resourceCategories ; } | Reads the categories assigned to a resource . | 159 | 9 |
145,176 | public Map < String , String > getSitePath ( ) { if ( m_sitePaths == null ) { m_sitePaths = CmsCollectionsGenericWrapper . createLazyMap ( new Transformer ( ) { public Object transform ( Object rootPath ) { if ( rootPath instanceof String ) { return getRequestContext ( ) . removeSiteRoot ( ( String ) rootPath ) ; } return null ; } } ) ; } return m_sitePaths ; } | Transforms root paths to site paths . | 102 | 8 |
145,177 | public Map < String , String > getTitleLocale ( ) { if ( m_localeTitles == null ) { m_localeTitles = CmsCollectionsGenericWrapper . createLazyMap ( new Transformer ( ) { public Object transform ( Object inputLocale ) { Locale locale = null ; if ( null != inputLocale ) { if ( inputLocale instanceof Locale ) { locale = ( Locale ) inputLocale ; } else if ( inputLocale instanceof String ) { try { locale = LocaleUtils . toLocale ( ( String ) inputLocale ) ; } catch ( IllegalArgumentException | NullPointerException e ) { // do nothing, just go on without locale } } } return getLocaleSpecificTitle ( locale ) ; } } ) ; } return m_localeTitles ; } | Get the title and read the Title property according the provided locale . | 182 | 13 |
145,178 | protected String getLocaleSpecificTitle ( Locale locale ) { String result = null ; try { if ( isDetailRequest ( ) ) { // this is a request to a detail page CmsResource res = getDetailContent ( ) ; CmsFile file = m_cms . readFile ( res ) ; CmsXmlContent content = CmsXmlContentFactory . unmarshal ( m_cms , file ) ; result = content . getHandler ( ) . getTitleMapping ( m_cms , content , m_cms . getRequestContext ( ) . getLocale ( ) ) ; if ( result == null ) { // title not found, maybe no mapping OR not available in the current locale // read the title of the detail resource as fall back (may contain mapping from another locale) result = m_cms . readPropertyObject ( res , CmsPropertyDefinition . PROPERTY_TITLE , false , locale ) . getValue ( ) ; } } if ( result == null ) { // read the title of the requested resource as fall back result = m_cms . readPropertyObject ( m_cms . getRequestContext ( ) . getUri ( ) , CmsPropertyDefinition . PROPERTY_TITLE , true , locale ) . getValue ( ) ; } } catch ( CmsException e ) { LOG . debug ( e . getLocalizedMessage ( ) , e ) ; } if ( CmsStringUtil . isEmptyOrWhitespaceOnly ( result ) ) { result = "" ; } return result ; } | Returns the title according to the given locale . | 327 | 9 |
145,179 | public void setStringValue ( String value ) { if ( CmsStringUtil . isNotEmptyOrWhitespaceOnly ( value ) ) { try { m_editValue = CmsLocationValue . parse ( value ) ; m_currentValue = m_editValue . cloneValue ( ) ; displayValue ( ) ; if ( ( m_popup != null ) && m_popup . isVisible ( ) ) { m_popupContent . displayValues ( m_editValue ) ; updateMarkerPosition ( ) ; } } catch ( Exception e ) { CmsLog . log ( e . getLocalizedMessage ( ) + "\n" + CmsClientStringUtil . getStackTrace ( e , "\n" ) ) ; } } else { m_currentValue = null ; displayValue ( ) ; } } | Sets the location value as string . | 178 | 8 |
145,180 | public static byte [ ] hashPassword ( String password ) throws InvalidKeyException , NoSuchAlgorithmException { PasswordEncryptor encryptor = new PasswordEncryptor ( ) ; return encryptor . generateEncryptedPassword ( password , null , PasswordEncryptor . MD4 , null , null ) ; } | Computes an MD4 hash for the password . | 64 | 10 |
145,181 | public void setHeader ( String header , String value ) { StringValidator . throwIfEmptyOrNull ( "header" , header ) ; StringValidator . throwIfEmptyOrNull ( "value" , value ) ; if ( headers == null ) { headers = new HashMap < String , String > ( ) ; } headers . put ( header , value ) ; } | Sets a request header with the given name and value . If a header with the specified name has already been set then the new value overwrites the current value . | 77 | 33 |
145,182 | protected List < CmsResource > getTopFolders ( List < CmsResource > folders ) { List < String > folderPaths = new ArrayList < String > ( ) ; List < CmsResource > topFolders = new ArrayList < CmsResource > ( ) ; Map < String , CmsResource > foldersByPath = new HashMap < String , CmsResource > ( ) ; for ( CmsResource folder : folders ) { folderPaths . add ( folder . getRootPath ( ) ) ; foldersByPath . put ( folder . getRootPath ( ) , folder ) ; } Collections . sort ( folderPaths ) ; Set < String > topFolderPaths = new HashSet < String > ( folderPaths ) ; for ( int i = 0 ; i < folderPaths . size ( ) ; i ++ ) { for ( int j = i + 1 ; j < folderPaths . size ( ) ; j ++ ) { if ( folderPaths . get ( j ) . startsWith ( ( folderPaths . get ( i ) ) ) ) { topFolderPaths . remove ( folderPaths . get ( j ) ) ; } else { break ; } } } for ( String path : topFolderPaths ) { topFolders . add ( foldersByPath . get ( path ) ) ; } return topFolders ; } | Gives the roots of a list of folders i . e . the list of folders which are not descendants of any other folders in the original list | 291 | 29 |
145,183 | public void setDates ( SortedSet < Date > dates ) { if ( ! m_model . getIndividualDates ( ) . equals ( dates ) ) { m_model . setIndividualDates ( dates ) ; onValueChange ( ) ; } } | Set the individual dates . | 55 | 5 |
145,184 | public static CmsSolrSpellchecker getInstance ( CoreContainer container ) { if ( null == instance ) { synchronized ( CmsSolrSpellchecker . class ) { if ( null == instance ) { @ SuppressWarnings ( "resource" ) SolrCore spellcheckCore = container . getCore ( CmsSolrSpellchecker . SPELLCHECKER_INDEX_CORE ) ; if ( spellcheckCore == null ) { LOG . error ( Messages . get ( ) . getBundle ( ) . key ( Messages . ERR_SPELLCHECK_CORE_NOT_AVAILABLE_1 , CmsSolrSpellchecker . SPELLCHECKER_INDEX_CORE ) ) ; return null ; } instance = new CmsSolrSpellchecker ( container , spellcheckCore ) ; } } } return instance ; } | Return an instance of this class . | 185 | 7 |
145,185 | public void getSpellcheckingResult ( final HttpServletResponse res , final ServletRequest servletRequest , final CmsObject cms ) throws CmsPermissionViolationException , IOException { // Perform a permission check performPermissionCheck ( cms ) ; // Set the appropriate response headers setResponeHeaders ( res ) ; // Figure out whether a JSON or HTTP request has been sent CmsSpellcheckingRequest cmsSpellcheckingRequest = null ; try { String requestBody = getRequestBody ( servletRequest ) ; final JSONObject jsonRequest = new JSONObject ( requestBody ) ; cmsSpellcheckingRequest = parseJsonRequest ( jsonRequest ) ; } catch ( Exception e ) { LOG . debug ( e . getMessage ( ) , e ) ; cmsSpellcheckingRequest = parseHttpRequest ( servletRequest , cms ) ; } if ( ( null != cmsSpellcheckingRequest ) && cmsSpellcheckingRequest . isInitialized ( ) ) { // Perform the actual spellchecking final SpellCheckResponse spellCheckResponse = performSpellcheckQuery ( cmsSpellcheckingRequest ) ; /* * The field spellCheckResponse is null when exactly one correctly spelled word is passed to the spellchecker. * In this case it's safe to return an empty JSON formatted map, as the passed word is correct. Otherwise, * convert the spellchecker response into a new JSON formatted map. */ if ( null == spellCheckResponse ) { cmsSpellcheckingRequest . m_wordSuggestions = new JSONObject ( ) ; } else { cmsSpellcheckingRequest . m_wordSuggestions = getConvertedResponseAsJson ( spellCheckResponse ) ; } } // Send response back to the client sendResponse ( res , cmsSpellcheckingRequest ) ; } | Performs spellchecking using Solr and returns the spellchecking results using JSON . | 369 | 16 |
145,186 | public void parseAndAddDictionaries ( CmsObject cms ) throws CmsRoleViolationException { OpenCms . getRoleManager ( ) . checkRole ( cms , CmsRole . ROOT_ADMIN ) ; CmsSpellcheckDictionaryIndexer . parseAndAddZippedDictionaries ( m_solrClient , cms ) ; CmsSpellcheckDictionaryIndexer . parseAndAddDictionaries ( m_solrClient , cms ) ; } | Parses and adds dictionaries to the Solr index . | 105 | 13 |
145,187 | private JSONObject getConvertedResponseAsJson ( SpellCheckResponse response ) { if ( null == response ) { return null ; } final JSONObject suggestions = new JSONObject ( ) ; final Map < String , Suggestion > solrSuggestions = response . getSuggestionMap ( ) ; // Add suggestions to the response for ( final String key : solrSuggestions . keySet ( ) ) { // Indicator to ignore words that are erroneously marked as misspelled. boolean ignoreWord = false ; // Suggestions that are in the form "Xxxx" -> "xxxx" should be ignored. if ( Character . isUpperCase ( key . codePointAt ( 0 ) ) ) { final String lowercaseKey = key . toLowerCase ( ) ; // If the suggestion map doesn't contain the lowercased word, ignore this entry. if ( ! solrSuggestions . containsKey ( lowercaseKey ) ) { ignoreWord = true ; } } if ( ! ignoreWord ) { try { // Get suggestions as List final List < String > l = solrSuggestions . get ( key ) . getAlternatives ( ) ; suggestions . put ( key , l ) ; } catch ( JSONException e ) { LOG . debug ( "Exception while converting Solr spellcheckresponse to JSON. " , e ) ; } } } return suggestions ; } | Converts the suggestions from the Solrj format to JSON format . | 283 | 14 |
145,188 | private JSONObject getJsonFormattedSpellcheckResult ( CmsSpellcheckingRequest request ) { final JSONObject response = new JSONObject ( ) ; try { if ( null != request . m_id ) { response . put ( JSON_ID , request . m_id ) ; } response . put ( JSON_RESULT , request . m_wordSuggestions ) ; } catch ( Exception e ) { try { response . put ( JSON_ERROR , true ) ; LOG . debug ( "Error while assembling spellcheck response in JSON format." , e ) ; } catch ( JSONException ex ) { LOG . debug ( "Error while assembling spellcheck response in JSON format." , ex ) ; } } return response ; } | Returns the result of the performed spellcheck formatted in JSON . | 150 | 12 |
145,189 | private String getRequestBody ( ServletRequest request ) throws IOException { final StringBuilder sb = new StringBuilder ( ) ; String line = request . getReader ( ) . readLine ( ) ; while ( null != line ) { sb . append ( line ) ; line = request . getReader ( ) . readLine ( ) ; } return sb . toString ( ) ; } | Returns the body of the request . This method is used to read posted JSON data . | 82 | 17 |
145,190 | private CmsSpellcheckingRequest parseHttpRequest ( final ServletRequest req , final CmsObject cms ) { if ( ( null != cms ) && OpenCms . getRoleManager ( ) . hasRole ( cms , CmsRole . ROOT_ADMIN ) ) { try { if ( null != req . getParameter ( HTTP_PARAMETER_CHECKREBUILD ) ) { if ( CmsSpellcheckDictionaryIndexer . updatingIndexNecessesary ( cms ) ) { parseAndAddDictionaries ( cms ) ; } } if ( null != req . getParameter ( HTTP_PARAMTER_REBUILD ) ) { parseAndAddDictionaries ( cms ) ; } } catch ( CmsRoleViolationException e ) { LOG . error ( e . getLocalizedMessage ( ) , e ) ; } } final String q = req . getParameter ( HTTP_PARAMETER_WORDS ) ; if ( null == q ) { LOG . debug ( "Invalid HTTP request: No parameter \"" + HTTP_PARAMETER_WORDS + "\" defined. " ) ; return null ; } final StringTokenizer st = new StringTokenizer ( q ) ; final List < String > wordsToCheck = new ArrayList < String > ( ) ; while ( st . hasMoreTokens ( ) ) { final String word = st . nextToken ( ) ; wordsToCheck . add ( word ) ; if ( Character . isUpperCase ( word . codePointAt ( 0 ) ) ) { wordsToCheck . add ( word . toLowerCase ( ) ) ; } } final String [ ] w = wordsToCheck . toArray ( new String [ wordsToCheck . size ( ) ] ) ; final String dict = req . getParameter ( HTTP_PARAMETER_LANG ) == null ? LANG_DEFAULT : req . getParameter ( HTTP_PARAMETER_LANG ) ; return new CmsSpellcheckingRequest ( w , dict ) ; } | Parse parameters from this request using HTTP . | 431 | 9 |
145,191 | private CmsSpellcheckingRequest parseJsonRequest ( JSONObject jsonRequest ) { final String id = jsonRequest . optString ( JSON_ID ) ; final JSONObject params = jsonRequest . optJSONObject ( JSON_PARAMS ) ; if ( null == params ) { LOG . debug ( "Invalid JSON request: No field \"params\" defined. " ) ; return null ; } final JSONArray words = params . optJSONArray ( JSON_WORDS ) ; final String lang = params . optString ( JSON_LANG , LANG_DEFAULT ) ; if ( null == words ) { LOG . debug ( "Invalid JSON request: No field \"words\" defined. " ) ; return null ; } // Convert JSON array to array of type String final List < String > wordsToCheck = new LinkedList < String > ( ) ; for ( int i = 0 ; i < words . length ( ) ; i ++ ) { final String word = words . opt ( i ) . toString ( ) ; wordsToCheck . add ( word ) ; if ( Character . isUpperCase ( word . codePointAt ( 0 ) ) ) { wordsToCheck . add ( word . toLowerCase ( ) ) ; } } return new CmsSpellcheckingRequest ( wordsToCheck . toArray ( new String [ wordsToCheck . size ( ) ] ) , lang , id ) ; } | Parse JSON parameters from this request . | 291 | 8 |
145,192 | private void performPermissionCheck ( CmsObject cms ) throws CmsPermissionViolationException { if ( cms . getRequestContext ( ) . getCurrentUser ( ) . isGuestUser ( ) ) { throw new CmsPermissionViolationException ( null ) ; } } | Perform a security check against OpenCms . | 61 | 10 |
145,193 | private SpellCheckResponse performSpellcheckQuery ( CmsSpellcheckingRequest request ) { if ( ( null == request ) || ! request . isInitialized ( ) ) { return null ; } final String [ ] wordsToCheck = request . m_wordsToCheck ; final ModifiableSolrParams params = new ModifiableSolrParams ( ) ; params . set ( "spellcheck" , "true" ) ; params . set ( "spellcheck.dictionary" , request . m_dictionaryToUse ) ; params . set ( "spellcheck.extendedResults" , "true" ) ; // Build one string from array of words and use it as query. final StringBuilder builder = new StringBuilder ( ) ; for ( int i = 0 ; i < wordsToCheck . length ; i ++ ) { builder . append ( wordsToCheck [ i ] + " " ) ; } params . set ( "spellcheck.q" , builder . toString ( ) ) ; final SolrQuery query = new SolrQuery ( ) ; query . setRequestHandler ( "/spell" ) ; query . add ( params ) ; try { QueryResponse qres = m_solrClient . query ( query ) ; return qres . getSpellCheckResponse ( ) ; } catch ( Exception e ) { LOG . debug ( "Exception while performing spellcheck query..." , e ) ; } return null ; } | Performs the actual spell check query using Solr . | 294 | 11 |
145,194 | private void sendResponse ( final HttpServletResponse res , final CmsSpellcheckingRequest request ) throws IOException { final PrintWriter pw = res . getWriter ( ) ; final JSONObject response = getJsonFormattedSpellcheckResult ( request ) ; pw . println ( response . toString ( ) ) ; pw . close ( ) ; } | Sends the JSON - formatted spellchecking results to the client . | 76 | 13 |
145,195 | private void setResponeHeaders ( HttpServletResponse response ) { response . setHeader ( "Cache-Control" , "no-store, no-cache" ) ; response . setHeader ( "Pragma" , "no-cache" ) ; response . setDateHeader ( "Expires" , System . currentTimeMillis ( ) ) ; response . setContentType ( "text/plain; charset=utf-8" ) ; response . setCharacterEncoding ( "utf-8" ) ; } | Sets the appropriate headers to response of this request . | 112 | 11 |
145,196 | public static int toIntWithDefault ( String value , int defaultValue ) { int result = defaultValue ; try { result = Integer . parseInt ( value ) ; } catch ( @ SuppressWarnings ( "unused" ) Exception e ) { // Do nothing, return default. } return result ; } | Parses int value and returns the provided default if the value can t be parsed . | 65 | 18 |
145,197 | @ Override public void init ( NamedList args ) { Object regex = args . remove ( PARAM_REGEX ) ; if ( null == regex ) { throw new SolrException ( ErrorCode . SERVER_ERROR , "Missing required init parameter: " + PARAM_REGEX ) ; } try { m_regex = Pattern . compile ( regex . toString ( ) ) ; } catch ( PatternSyntaxException e ) { throw new SolrException ( ErrorCode . SERVER_ERROR , "Invalid regex: " + regex , e ) ; } Object replacement = args . remove ( PARAM_REPLACEMENT ) ; if ( null == replacement ) { throw new SolrException ( ErrorCode . SERVER_ERROR , "Missing required init parameter: " + PARAM_REPLACEMENT ) ; } m_replacement = replacement . toString ( ) ; Object source = args . remove ( PARAM_SOURCE ) ; if ( null == source ) { throw new SolrException ( ErrorCode . SERVER_ERROR , "Missing required init parameter: " + PARAM_SOURCE ) ; } m_source = source . toString ( ) ; Object target = args . remove ( PARAM_TARGET ) ; if ( null == target ) { throw new SolrException ( ErrorCode . SERVER_ERROR , "Missing required init parameter: " + PARAM_TARGET ) ; } m_target = target . toString ( ) ; } | Read the parameters on initialization . | 308 | 6 |
145,198 | String getDefaultReturnFields ( ) { StringBuffer fields = new StringBuffer ( "" ) ; fields . append ( CmsSearchField . FIELD_PATH ) ; fields . append ( ' ' ) ; fields . append ( CmsSearchField . FIELD_INSTANCEDATE ) . append ( ' ' ) . append ( getSearchLocale ( ) . toString ( ) ) . append ( "_dt" ) ; fields . append ( ' ' ) ; fields . append ( CmsSearchField . FIELD_INSTANCEDATE_END ) . append ( ' ' ) . append ( getSearchLocale ( ) . toString ( ) ) . append ( "_dt" ) ; fields . append ( ' ' ) ; fields . append ( CmsSearchField . FIELD_INSTANCEDATE_CURRENT_TILL ) . append ( ' ' ) . append ( getSearchLocale ( ) . toString ( ) ) . append ( "_dt" ) ; fields . append ( ' ' ) ; fields . append ( CmsSearchField . FIELD_ID ) ; fields . append ( ' ' ) ; fields . append ( CmsSearchField . FIELD_SOLR_ID ) ; fields . append ( ' ' ) ; fields . append ( CmsSearchField . FIELD_DISPTITLE ) . append ( ' ' ) . append ( getSearchLocale ( ) . toString ( ) ) . append ( "_sort" ) ; fields . append ( ' ' ) ; fields . append ( CmsSearchField . FIELD_LINK ) ; return fields . toString ( ) ; } | The fields returned by default . Typically the output is done via display formatters and hence nearly no field is necessary . Returning all fields might cause performance problems . | 342 | 31 |
145,199 | private Map < String , I_CmsSearchConfigurationFacetField > getDefaultFieldFacets ( boolean categoryConjunction ) { Map < String , I_CmsSearchConfigurationFacetField > fieldFacets = new HashMap < String , I_CmsSearchConfigurationFacetField > ( ) ; fieldFacets . put ( CmsListManager . FIELD_CATEGORIES , new CmsSearchConfigurationFacetField ( CmsListManager . FIELD_CATEGORIES , null , Integer . valueOf ( 1 ) , Integer . valueOf ( 200 ) , null , "Category" , SortOrder . index , null , Boolean . valueOf ( categoryConjunction ) , null , Boolean . TRUE ) ) ; fieldFacets . put ( CmsListManager . FIELD_PARENT_FOLDERS , new CmsSearchConfigurationFacetField ( CmsListManager . FIELD_PARENT_FOLDERS , null , Integer . valueOf ( 1 ) , Integer . valueOf ( 200 ) , null , "Folders" , SortOrder . index , null , Boolean . FALSE , null , Boolean . TRUE ) ) ; return Collections . unmodifiableMap ( fieldFacets ) ; } | The default field facets . | 262 | 5 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.