private void registerRepositoryDefaultConfiguration(HierarchicalConfiguration repositoryConfiguration, Protocol protocol) { HierarchicalConfiguration defConf = null; if (repositoryConfiguration.getKeys("config").hasNext()) { defConf = repositoryConfiguration.configurationAt("config"); } if (defConf != null) { perProtocolMailRepositoryDefaultConfiguration.put(protocol, defConf); } }
/** * Helper method that tries to read the configuration for the extension into a map. The configuration * section must appear as follows for this method to work: * <p/> * <configuration> * <key1>value</key1> * <key2>value</key2> * </configuration> * <p/> * Key values must be unique within the configuration. * * @return A map or null if the parse does not work. */ public Map<String, String> tryGetMapFromConfiguration() { Map<String, String> map = new HashMap<String, String>(); try { final Iterator keys = this.configuration.getKeys(); while (keys.hasNext()) { final String key = keys.next().toString(); map.put(key, this.configuration.getString(key)); } } catch (Exception ex) { logger.error("There is an error in the configuration of this extension [" + this.namespace + ":" + this.extensionName + "]. All values must be of a String data type."); // ignore and return null map = null; } return map; }
/** * Sets bean members using configuration attributes. * * @param endpoint the bean * @param endpointConfig the configuration hierarchy * @throws LegStarConfigurationException if setting value on bean fails */ protected void setValues( final Object endpoint, final HierarchicalConfiguration endpointConfig) throws LegStarConfigurationException { for (Iterator < ? > iterator = endpointConfig.getKeys(); iterator .hasNext();) { String key = (String) iterator.next(); setValue(endpoint, key, endpointConfig.getString(key)); } }
@Override public Iterator<String> getKeys(String prefix) { reload(); synchronized (delegate.getReloadLock()) { return super.getKeys(prefix); } }
@Override public Iterator<String> getKeys() { reload(); synchronized (delegate.getReloadLock()) { return super.getKeys(); } }
@Override public Iterator<String> getKeys() { reload(); synchronized (delegate.getReloadLock()) { return super.getKeys(); } }
@Override public Iterator<String> getKeys(String prefix) { reload(); synchronized (delegate.getReloadLock()) { return super.getKeys(prefix); } }
if (repConf.getKeys("config").hasNext()) {
if (conf.getKeys("usernames").hasNext()) { throw new ConfigurationException("<usernames> parameter in James block was removed. Please configure this data in UsersRepository block"); if (conf.getKeys("servernames").hasNext()) { throw new ConfigurationException("<servernames> parameter in mailserver block was removed. Please configure this data in domainlist block"); if (conf.getKeys("helloName").hasNext()) { HierarchicalConfiguration helloNameConfig = conf.configurationAt("helloName"); boolean autodetect = helloNameConfig.getBoolean("[@autodetect]", true);
@Test public void getConfigurationShouldLoadCorrespondingXMLFilePart() throws Exception { HierarchicalConfiguration hierarchicalConfiguration = configurationProvider.getConfiguration( String.join(CONFIG_SEPARATOR, ROOT_CONFIG_KEY, CONFIG_KEY_4)); assertThat(hierarchicalConfiguration.getKeys()).containsOnly(CONFIG_KEY_2, String.join(CONFIG_SEPARATOR, CONFIG_KEY_5, CONFIG_KEY_2)); assertThat(hierarchicalConfiguration.getProperty(CONFIG_KEY_2)).isEqualTo(VALUE_2); }
@Test public void getConfigurationShouldLoadCorrespondingXMLFile() throws Exception { HierarchicalConfiguration hierarchicalConfiguration = configurationProvider.getConfiguration(ROOT_CONFIG_KEY); assertThat(hierarchicalConfiguration.getKeys()).containsOnly(CONFIG_KEY_1, String.join(CONFIG_SEPARATOR, CONFIG_KEY_4, CONFIG_KEY_2), String.join(CONFIG_SEPARATOR, CONFIG_KEY_4, CONFIG_KEY_5, CONFIG_KEY_2), CONFIG_KEY_ENV, CONFIG_KEY_ENV_WITH_COMMA, CONFIG_KEY_NOT_ENV); assertThat(hierarchicalConfiguration.getProperty(CONFIG_KEY_1)).isEqualTo(VALUE_1); }
@Test public void getConfigurationShouldLoadCorrespondingXMLFileWhenAPathIsProvidedPart() throws Exception { HierarchicalConfiguration hierarchicalConfiguration = configurationProvider.getConfiguration( String.join(CONFIG_SEPARATOR, ROOT_CONFIG_KEY, CONFIG_KEY_4, CONFIG_KEY_5)); assertThat(hierarchicalConfiguration.getKeys()).containsOnly(CONFIG_KEY_2); assertThat(hierarchicalConfiguration.getProperty(CONFIG_KEY_2)).isEqualTo(VALUE_3); }
@Test public void multiplesSeparatorsShouldBeTolerated() throws Exception { HierarchicalConfiguration hierarchicalConfiguration = configurationProvider.getConfiguration( ROOT_CONFIG_KEY + CONFIG_SEPARATOR + CONFIG_SEPARATOR + CONFIG_KEY_4); assertThat(hierarchicalConfiguration.getKeys()).containsOnly(CONFIG_KEY_2, String.join(CONFIG_SEPARATOR, CONFIG_KEY_5, CONFIG_KEY_2)); assertThat(hierarchicalConfiguration.getProperty(CONFIG_KEY_2)).isEqualTo(VALUE_2); }
anim.addChannels(readChannels(channelsConfig)); if(config.getKeys(SYNC_POINT_GROUPS).hasNext()){ HierarchicalConfiguration groupsConfig = config.configurationAt(SYNC_POINT_GROUPS); anim.setSyncGroupConfigs(groups); if(config.getKeys(ADDONS).hasNext()){ HierarchicalConfiguration addonsConfig = config.configurationAt(ADDONS);