org.springframework.extensions.config.Config Java Examples
The following examples show how to use
org.springframework.extensions.config.Config.
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: MimetypeMap.java From alfresco-data-model with GNU Lesser General Public License v3.0 | 6 votes |
public boolean readConfig() { // Config in XML Config config = configService.getConfig(CONFIG_CONDITION, new ConfigLookupContext(CONFIG_AREA)); ConfigElement mimetypesElement = config.getConfigElement(ELEMENT_MIMETYPES); List<ConfigElement> mimetypes = mimetypesElement.getChildren(); registerMimetypes(mimetypes); Data data = getData(); data.xmlCount = mimetypes.size(); // Config in JSON boolean successReadingConfig = true; if (jsonConfigFileFinder != null) { // This should not be "alfresco/mimetype" which is used for the in JVM jodconverter successReadingConfig &= jsonConfigFileFinder.readFiles("alfresco/mimetypes", logger); if (mimetypeJsonConfigDir != null && !mimetypeJsonConfigDir.isBlank()) { successReadingConfig &= jsonConfigFileFinder.readFiles(mimetypeJsonConfigDir, logger); } } data.makeCollectionsReadOnly(); return successReadingConfig; }
Example #2
Source File: SearchProxy.java From alfresco-remote-api with GNU Lesser General Public License v3.0 | 5 votes |
public void afterPropertiesSet() throws Exception { Config config = configService.getConfig("OpenSearch"); searchConfig = (OpenSearchConfigElement)config.getConfigElement(OpenSearchConfigElement.CONFIG_ELEMENT_ID); if (searchConfig == null) { throw new WebScriptException("OpenSearch configuration not found"); } ProxyConfig proxyConfig = searchConfig.getProxy(); if (proxyConfig == null) { throw new WebScriptException("OpenSearch proxy configuration not found"); } proxyPath = proxyConfig.getUrl(); }
Example #3
Source File: ContentFilterLanguagesMap.java From alfresco-repository with GNU Lesser General Public License v3.0 | 4 votes |
/** * Initialises the map using the configuration service provided */ public void init() { ConfigLookupContext clContext = new ConfigLookupContext(CONFIG_AREA); // get which standart is defined by the user (ISO 639-1 by default) String standard = DEFAULT_LANGUAGE_LIST_STANDARD; Config configStandard = configService.getConfig(USED_STANDARD_CONFIG_CONDITION, clContext); if(configStandard != null && configStandard.getConfigElement(USED_STANDARD_ELEMENT) != null) { standard = configStandard.getConfigElement(USED_STANDARD_ELEMENT).getValue(); } else { logger.warn("No standard configured, use by default : " + DEFAULT_LANGUAGE_LIST_STANDARD); } Config configConditions = configService.getConfig(CONFIG_CONDITION, clContext); Map<String, ConfigElement> configElements = configConditions.getConfigElements(); ConfigElement configLanguages = null; // get the list of languages of the matched standard if(configElements.containsKey(standard)) { configLanguages = configElements.get(standard); } // if the santard is not matched, get the first list else { configLanguages = configElements.values().iterator().next(); logger.warn("Ignoring prefered standard doesn't found, choose : " + configLanguages.getName()); } List<ConfigElement> languages = configLanguages.getChildren(); // get the size of the lists int listSize = languages.size(); this.orderedLangCodes = new ArrayList<String>(listSize); this.languagesByCode = new HashMap<String, String>(listSize); // construct the languages map and list for (ConfigElement langElem : languages) { String code = convertToOldISOCode(langElem.getAttribute(ATTR_CODE)); String value = langElem.getValue(); String def = langElem.getAttribute(ATTR_DEFAULT); languagesByCode.put(code, value); boolean isDefault = (def != null && Boolean.parseBoolean(def)); if(isDefault) { if(defaultLanguage != null) { logger.warn("Content filter default language is not unique: " + code); } else { this.defaultLanguage = code; } } if (EqualsHelper.nullSafeEquals(defaultLanguage, code)) { orderedLangCodes.add(0, code); } else { orderedLangCodes.add(code); } } // make the collections read-only this.orderedLangCodes = Collections.unmodifiableList(this.orderedLangCodes); this.languagesByCode = Collections.unmodifiableMap(this.languagesByCode); }
Example #4
Source File: SearchEngines.java From alfresco-remote-api with GNU Lesser General Public License v3.0 | 4 votes |
/** * Retrieve registered search engines * * @return set of search engines */ private Set<UrlTemplate> getUrls(String urlType) { if (logger.isDebugEnabled()) logger.debug("Search Engine parameters: urltype=" + urlType); Set<UrlTemplate> urls = new HashSet<UrlTemplate>(); Config config = configService.getConfig("OpenSearch"); OpenSearchConfigElement searchConfig = (OpenSearchConfigElement)config.getConfigElement(OpenSearchConfigElement.CONFIG_ELEMENT_ID); for (OpenSearchConfigElement.EngineConfig engineConfig : searchConfig.getEngines()) { Map<String, String> engineUrls = engineConfig.getUrls(); for (Map.Entry<String, String> engineUrl : engineUrls.entrySet()) { String type = engineUrl.getKey(); String url = searchProxy.createUrl(engineConfig, type); if ((urlType.equals(URL_ARG_ALL)) || (urlType.equals(URL_ARG_DESCRIPTION) && type.equals(MimetypeMap.MIMETYPE_OPENSEARCH_DESCRIPTION)) || (urlType.equals(URL_ARG_TEMPLATE) && !type.equals(MimetypeMap.MIMETYPE_OPENSEARCH_DESCRIPTION))) { String label = engineConfig.getLabel(); String labelId = engineConfig.getLabelId(); if (labelId != null && labelId.length() > 0) { String i18nLabel = I18NUtil.getMessage(labelId); if (i18nLabel == null && label == null) { label = (i18nLabel == null) ? "$$" + labelId + "$$" : i18nLabel; } } urls.add(new UrlTemplate(label, type, url)); } // TODO: Extract URL templates from OpenSearch description else if (urlType.equals(URL_ARG_TEMPLATE) && type.equals(MimetypeMap.MIMETYPE_OPENSEARCH_DESCRIPTION)) { } } } if (logger.isDebugEnabled()) logger.debug("Retrieved " + urls.size() + " engine registrations"); return urls; }