List of usage examples for java.util Properties stringPropertyNames
public Set<String> stringPropertyNames()
From source file:com.nike.cerberus.server.config.guice.CmsGuiceModule.java
private void loadEnvProperties() { if (appConfig.hasPath(CMS_DISABLE_ENV_LOAD_FLAG) && appConfig.getBoolean(CMS_DISABLE_ENV_LOAD_FLAG)) { logger.warn("CMS environment property loading disabled."); } else {//from w w w .ja v a 2s . co m final CmsEnvPropertiesLoader cmsEnvPropertiesLoader = new CmsEnvPropertiesLoader( System.getenv(BUCKET_NAME_KEY), System.getenv(REGION_KEY), System.getenv(KMS_KEY_ID_KEY)); Properties properties = cmsEnvPropertiesLoader.getProperties(); // bind the props to named props for guice Names.bindProperties(binder(), properties); for (String propertyName : properties.stringPropertyNames()) { logger.info("Successfully loaded: {} from the env data stored in S3", propertyName); appConfig = appConfig.withValue(propertyName, ConfigValueFactory.fromAnyRef(properties.getProperty(propertyName))); } } }
From source file:org.apache.gobblin.data.management.retention.policy.CombineRetentionPolicy.java
@SuppressWarnings("unchecked") public CombineRetentionPolicy(Properties props) throws IOException { Preconditions.checkArgument(props.containsKey(DELETE_SETS_COMBINE_OPERATION), "Combine operation not specified."); ImmutableList.Builder<RetentionPolicy<T>> builder = ImmutableList.builder(); for (String property : props.stringPropertyNames()) { if (property.startsWith(RETENTION_POLICIES_PREFIX)) { try { builder.add((RetentionPolicy<T>) ConstructorUtils .invokeConstructor(Class.forName(props.getProperty(property)), props)); } catch (NoSuchMethodException | IllegalAccessException | InvocationTargetException | InstantiationException | ClassNotFoundException e) { throw new IllegalArgumentException(e); }// w w w . jav a 2 s. c o m } } this.retentionPolicies = builder.build(); if (this.retentionPolicies.size() == 0) { throw new IOException( "No retention policies specified for " + CombineRetentionPolicy.class.getCanonicalName()); } this.combineOperation = DeletableCombineOperation .valueOf(props.getProperty(DELETE_SETS_COMBINE_OPERATION).toUpperCase()); }
From source file:gobblin.data.management.retention.policy.CombineRetentionPolicy.java
@SuppressWarnings("unchecked") public CombineRetentionPolicy(Properties props) throws IOException { Preconditions.checkArgument(props.containsKey(DELETE_SETS_COMBINE_OPERATION), "Combine operation not specified."); ImmutableList.Builder<RetentionPolicy<T>> builder = ImmutableList.builder(); for (String property : props.stringPropertyNames()) { if (property.startsWith(RETENTION_POLICIES_PREFIX)) { try { builder.add((RetentionPolicy<T>) ConstructorUtils .invokeConstructor(Class.forName(props.getProperty(property)), props)); } catch (NoSuchMethodException | IllegalAccessException | InvocationTargetException | InstantiationException | ClassNotFoundException e) { throw new IllegalArgumentException(e); }//from w ww . ja v a2s.com } } this.retentionPolicies = builder.build(); if (this.retentionPolicies.size() == 0) { throw new IOException( "No retention policies specified for " + CombineRetentionPolicy.class.getCanonicalName()); } this.combineOperation = DeletableCombineOperation .valueOf(props.getProperty(DELETE_SETS_COMBINE_OPERATION).toUpperCase()); }
From source file:org.apache.atlas.web.security.BaseSecurityTest.java
protected void generateTestProperties(Properties props) throws ConfigurationException, IOException { PropertiesConfiguration config = new PropertiesConfiguration( System.getProperty("user.dir") + "/../src/conf/" + ApplicationProperties.APPLICATION_PROPERTIES); for (String propName : props.stringPropertyNames()) { config.setProperty(propName, props.getProperty(propName)); }//w w w. j a va 2s . co m File file = new File(System.getProperty("user.dir"), ApplicationProperties.APPLICATION_PROPERTIES); file.deleteOnExit(); Writer fileWriter = new FileWriter(file); config.save(fileWriter); }
From source file:nl.strohalm.cyclos.setup.DataBaseConfiguration.java
private void warnTrailingSpaces(final Properties properties) { for (String key : properties.stringPropertyNames()) { String value = properties.getProperty(key); if (!key.equals("line.separator") && !value.trim().equals(value)) { LOG.warn("Property '" + key + "' has trailing spaces. Its value is : '" + value + "'"); }/* w w w . j a v a2 s .c om*/ } }
From source file:org.vivoweb.harvester.util.args.ArgList.java
/** * Gets the value map for the argument//ww w. j av a2 s. c o m * @param arg argument to get * @return the value map */ public Map<String, String> getValueMap(String arg) { ArgDef argdef = this.argParser.getOptMap().get(arg); if (argdef == null) { throw new IllegalArgumentException("No such parameter: " + arg); } if (!argdef.hasParameter()) { throw new IllegalArgumentException(arg + " has no parameters"); } if (!argdef.isParameterValueMap()) { if (argdef.hasParameters()) { throw new IllegalArgumentException(arg + " is not a value map parameter, use getAll()"); } throw new IllegalArgumentException(arg + " is not a value map parameter, use get()"); } Map<String, String> p = new HashMap<String, String>(); List<String> confVals = null; if ((this.confMap != null) && ((confVals = getConfArgValues(argdef)) != null)) { for (String confVal : confVals) { String[] confValSplit = confVal.split("=", 2); if (confValSplit.length != 2) { throw new IllegalArgumentException( "Invalid config file: contains non-value map (paramName=paramValue) value for parameter '" + argdef.getOptionString() + "'"); } p.put(confValSplit[0].trim(), confValSplit[1].trim()); } } Properties props = this.oCmdSet.getOptionProperties(arg); for (String prop : props.stringPropertyNames()) { p.put(prop.trim(), props.getProperty(prop).trim()); } return p; }
From source file:org.helios.redis.ts.controller.conn.RedisConnectionManager.java
/** * Initializes the pool config from the pool properties * @param configProps the pool properties *///from w ww . ja v a 2s.c o m protected void initPoolConfig(Properties configProps) { String fName = null; try { for (String s : configProps.stringPropertyNames()) { if (s.startsWith("redis.pool.")) { fName = s.replace("redis.pool.", ""); Field f = poolConfigFieldNames.get(fName); if (f != null) { String value = configProps.getProperty(s); if (value == null || value.trim().isEmpty()) continue; value = value.trim(); PropertyEditor pe = PropertyEditorManager.findEditor(f.getType()); pe.setAsText(value); f.set(poolConfig, pe.getValue()); } } } } catch (Exception e) { throw new RuntimeException("Failed to configure Jedis Pool Item [" + fName + "]", e); } }
From source file:org.pentaho.cdf.packager.CdfHeadersProvider.java
private void addCustomDependencies(PathSet pathSet, Properties properties) { for (String name : properties.stringPropertyNames()) { if (name.endsWith(SUFFIX_IE8_SCRIPT_BEFORE_SCRIPT)) { pathSet.ie8ScriptsBeforeScripts.addAll(getProperty(properties, name)); } else if (name.endsWith(SUFFIX_SCRIPT)) { pathSet.scripts.addAll(getProperty(properties, name)); } else if (name.endsWith(SUFFIX_IE8_SCRIPT)) { pathSet.ie8Scripts.addAll(getProperty(properties, name)); } else if (name.endsWith(SUFFIX_STYLE)) { pathSet.styles.addAll(getProperty(properties, name)); } else if (name.endsWith(SUFFIX_MAP)) { pathSet.styleMaps.addAll(getProperty(properties, name)); } else if (name.endsWith(SUFFIX_IE8_STYLE)) { pathSet.ie8Styles.addAll(getProperty(properties, name)); } else if (name.endsWith(SUFFIX_IE8_SCRIPT_AFTER_STYLE)) { pathSet.ie8ScriptsAfterStyles.addAll(getProperty(properties, name)); } else if (!name.equals(BASE_SCRIPTS_PROPERTY) && !name.equals(BASE_STYLES_PROPERTY)) { // no default getLog().error(String.format( "Type of include property '%s' not recognized. Property name must end in one of ( '%s' )", name,/* w ww .j a va2 s .c o m*/ StringUtils.join(new String[] { SUFFIX_SCRIPT, SUFFIX_STYLE, SUFFIX_IE8_STYLE, SUFFIX_IE8_SCRIPT, SUFFIX_IE8_SCRIPT_AFTER_STYLE, SUFFIX_IE8_SCRIPT_BEFORE_SCRIPT }, "', '"))); } } }
From source file:hudson.ivy.builder.AntIvyBuilderType.java
@Override public Builder getBuilder(Properties additionalProperties, String overrideTargets, List<Environment> environments) { StringBuilder properties = new StringBuilder(); if (antProperties != null) { properties.append(antProperties); }//ww w .j a va2 s. c o m if (additionalProperties != null) { for (String key : additionalProperties.stringPropertyNames()) { properties.append("\n"); properties.append(key).append("=").append(additionalProperties.getProperty(key)); } } return new Ant(getCalculatedTargets(overrideTargets == null ? targets : overrideTargets, environments), antName, getCalculatedAntOpts(environments), buildFile, properties.length() == 0 ? null : properties.toString()); }
From source file:gaffer.graph.hook.OperationChainLimiter.java
private void loadMapsFromProperties(final Properties operationScorePropertiesFile, final Properties operationAuthorisationScoreLimitPropertiesFile) { Map<Class<? extends Operation>, Integer> opScores = new LinkedHashMap<>(); for (final String opClassName : operationScorePropertiesFile.stringPropertyNames()) { final Class<? extends Operation> opClass; try {/*w ww .j av a 2s.co m*/ opClass = Class.forName(opClassName).asSubclass(Operation.class); } catch (ClassNotFoundException e) { LOGGER.error("An operation class could not be found for operation score property " + opClassName); throw new IllegalArgumentException(e); } final Integer score = Integer.parseInt(operationScorePropertiesFile.getProperty(opClassName)); opScores.put(opClass, score); } setOpScores(opScores); Map<String, Integer> authScores = new HashMap<>(); for (final String authName : operationAuthorisationScoreLimitPropertiesFile.stringPropertyNames()) { final Integer score = Integer .parseInt(operationAuthorisationScoreLimitPropertiesFile.getProperty(authName)); authScores.put(authName, score); } setAuthScores(authScores); }