List of usage examples for java.util Properties stringPropertyNames
public Set<String> stringPropertyNames()
From source file:org.openmrs.module.initializer.InitializerMessageSource.java
/** * Refreshes the cache, merged from the custom source and the parent source *///from w w w.j a v a 2 s . c o m public synchronized void refreshCache() { cache = new HashMap<Locale, PresentationMessageMap>(); setUseCodeAsDefaultMessage(true); ConfigDirUtil ahDir = (new ConfigDirUtil(iniz.getConfigDirPath(), iniz.getChecksumsDirPath(), iniz.getRejectionsDirPath(), InitializerConstants.DOMAIN_ADDR)); addMessageProperties(ahDir.getDomainDirPath()); ConfigDirUtil msgDir = (new ConfigDirUtil(iniz.getConfigDirPath(), iniz.getChecksumsDirPath(), iniz.getRejectionsDirPath(), InitializerConstants.DOMAIN_MSGPROP)); addMessageProperties(msgDir.getDomainDirPath()); if (MapUtils.isEmpty(messagePropertiesMap)) { return; } for (Map.Entry<File, Locale> entry : messagePropertiesMap.entrySet()) { Locale locale = entry.getValue(); PresentationMessageMap pmm = new PresentationMessageMap(locale); if (cache.containsKey(locale)) { pmm = cache.get(locale); } Properties messages = loadPropertiesFromFile(entry.getKey()); for (String code : messages.stringPropertyNames()) { String message = messages.getProperty(code); message = message.replace("{{", "'{{'"); message = message.replace("}}", "'}}'"); pmm.put(code, new PresentationMessage(code, locale, message, null)); } cache.put(locale, pmm); } }
From source file:org.agiso.tempel.Tempel.java
public Tempel() { // Odczytujemy waciwoci systemowe i zapamitujemy je w mapie systemProperties: Properties properties = System.getProperties(); Map<String, Object> map = new HashMap<String, Object>(properties.size()); for (String key : properties.stringPropertyNames()) { map.put(key.replace('.', '_'), properties.getProperty(key)); }/*from w ww . jav a 2 s . c om*/ systemProperties = Collections.unmodifiableMap(map); }
From source file:org.jaggeryjs.hostobjects.ws.WSRequestHostObject.java
private static void filterRampartConfig(WSRequestHostObject wsRequest, RampartConfig config) { CryptoConfig crypto = config.getSigCryptoConfig(); if (crypto != null) { filterCryptoConfig(wsRequest, crypto); }//from ww w . j a va 2 s .co m crypto = config.getEncrCryptoConfig(); if (crypto != null) { filterCryptoConfig(wsRequest, crypto); } crypto = config.getDecCryptoConfig(); if (crypto != null) { filterCryptoConfig(wsRequest, crypto); } crypto = config.getStsCryptoConfig(); if (crypto != null) { filterCryptoConfig(wsRequest, crypto); } KerberosConfig kerberosConfig = config.getKerberosConfig(); if (kerberosConfig != null) { Properties properties = kerberosConfig.getProp(); for (String key : properties.stringPropertyNames()) { properties.setProperty(key, properties.getProperty(key)); } } }
From source file:org.openhab.binding.neato.internal.VendorVorwerk.java
@Override public String executeRequest(String httpMethod, String url, Properties httpHeaders, InputStream content, String contentType, int timeout) throws IOException { URL requestUrl = new URL(url); HttpsURLConnection connection = (HttpsURLConnection) requestUrl.openConnection(); applyNucleoSslConfiguration(connection); connection.setRequestMethod(httpMethod); for (String propName : httpHeaders.stringPropertyNames()) { connection.addRequestProperty(propName, httpHeaders.getProperty(propName)); }//from ww w . j a v a2 s . co m connection.setUseCaches(false); connection.setDoOutput(true); connection.setConnectTimeout(10000); connection.setReadTimeout(10000); content.reset(); IOUtils.copy(content, connection.getOutputStream()); java.io.InputStream is = connection.getInputStream(); return IOUtils.toString(is); }
From source file:ch.sdi.UserPropertyOverloader.java
public void overrideByUserProperties() { List<Class<?>> candidates = findCandidates(); for (Class<?> clazz : candidates) { myLog.debug("candidate for user property overloading: " + clazz.getName()); String fileName = SdiMainProperties.USER_OVERRIDE_PREFIX + ConfigUtils.makePropertyResourceName(clazz); InputStream is = this.getClass().getResourceAsStream("/" + fileName); if (is == null) { myLog.debug("Skipping non existing user overloading property file: " + fileName); continue; } // if is == null myLog.debug("Found overloading property file: " + fileName); Properties props = new Properties(); try {//from w w w. j a v a 2s .c om props.load(is); } catch (IOException t) { myLog.error("Problems loading property file " + fileName); } myEnv.setIgnoreUnresolvableNestedPlaceholders(true); try { props.stringPropertyNames().stream().map(key -> { String origValue = myEnv.getProperty(key); String result = "Key " + key + ": "; return (origValue == null || origValue.isEmpty()) ? result + "No default value found. Adding new value to environment: \"" + props.getProperty(key) + "\"" : result + "Overriding default value \"" + origValue + "\" with new value: \"" + props.getProperty(key) + "\""; }).forEach(msg -> myLog.debug(msg)); } finally { myEnv.setIgnoreUnresolvableNestedPlaceholders(false); } PropertySource<?> ps = new PropertiesPropertySource(fileName, props); MutablePropertySources mps = myEnv.getPropertySources(); if (mps.get(ConfigUtils.PROP_SOURCE_NAME_CMD_LINE) != null) { mps.addAfter(ConfigUtils.PROP_SOURCE_NAME_CMD_LINE, ps); } else { mps.addFirst(ps); } myLog.debug("PropertySources after adding overloading: " + mps); } }
From source file:ezbake.common.properties.EzProperties.java
/** * Check to see what properties would "collide" (have the same key name) * * @param toCheck are the properties that we want to compare our properties with * * @return a set of string which are they keys that overlap *///ww w.ja v a 2 s . com public Set<String> getCollisions(Properties toCheck) { Set<String> commonValues = Sets.intersection(stringPropertyNames(), toCheck.stringPropertyNames()) .immutableCopy(); return commonValues; }
From source file:gobblin.util.SchedulerUtilsTest.java
@Test public void testloadGenericJobConfig() throws ConfigurationException, IOException { Path jobConfigPath = new Path(this.subDir11.getAbsolutePath(), "test111.pull"); Properties properties = new Properties(); properties.setProperty(ConfigurationKeys.JOB_CONFIG_FILE_GENERAL_PATH_KEY, this.jobConfigDir.getAbsolutePath()); Properties jobProps = SchedulerUtils.loadGenericJobConfig(properties, jobConfigPath, new Path(this.jobConfigDir.getAbsolutePath())); Assert.assertEquals(jobProps.stringPropertyNames().size(), 7); Assert.assertTrue(jobProps.containsKey(ConfigurationKeys.JOB_CONFIG_FILE_DIR_KEY) || jobProps.containsKey(ConfigurationKeys.JOB_CONFIG_FILE_GENERAL_PATH_KEY)); Assert.assertTrue(jobProps.containsKey(ConfigurationKeys.JOB_CONFIG_FILE_PATH_KEY)); Assert.assertEquals(jobProps.getProperty("k1"), "d1"); Assert.assertEquals(jobProps.getProperty("k2"), "a2"); Assert.assertEquals(jobProps.getProperty("k3"), "a3"); Assert.assertEquals(jobProps.getProperty("k8"), "a8"); Assert.assertEquals(jobProps.getProperty("k9"), "a8"); }
From source file:org.wso2.carbon.core.persistence.metadata.ArtifactMetadataManager.java
public void setParameters(String artifactName, ArtifactType artifactType, Properties properties) throws ArtifactMetadataException { ArtifactMetadata metadataObject = loadParameters(artifactName, artifactType); Properties prop = metadataObject.getProperties(); Set<String> stringPropNames = properties.stringPropertyNames(); for (String name : stringPropNames) { prop.setProperty(name, properties.getProperty(name)); }//from w ww .j a v a 2s . c om saveParameters(metadataObject); }
From source file:org.fornax.toolsupport.sculptor.maven.plugin.AbstractSculptorMojo.java
/** * Reads the list of generated files from the StatusFile (defined via * {@link #statusFile}) and deletes all but the modified one-shot generated * files (different file checksum).// w w w . j ava2s. c o m */ protected boolean deleteGeneratedFiles() { boolean success; File statusFile = getStatusFile(); if (statusFile == null) { // No status file - we can't delete any previously generated files success = true; } else { try { // Read status file and iterate through the list of generated // files Properties statusFileProps = new Properties(); statusFileProps.load(new FileReader(statusFile)); for (String fileName : statusFileProps.stringPropertyNames()) { File file = new File(getProject().getBasedir(), fileName); if (file.exists()) { // For one-shot generated files compare checksum before // deleting boolean delete; if (fileName.startsWith(getProjectRelativePath(outletSrcOnceDir)) || fileName.startsWith(getProjectRelativePath(outletResOnceDir)) || fileName.startsWith(getProjectRelativePath(outletSrcTestOnceDir)) || fileName.startsWith(getProjectRelativePath(outletResTestOnceDir))) { delete = calculateChecksum(file).equals(statusFileProps.getProperty(fileName)); if (!delete && (isVerbose() || getLog().isDebugEnabled())) { getLog().info("Keeping previously generated modified" + " file: " + file); } } else { delete = true; } if (delete) { if (isVerbose() || getLog().isDebugEnabled()) { getLog().info("Deleting previously generated file: " + file); } // We have to make sure the file is deleted on // Windows as well FileUtils.forceDelete(file); // Delete image file generated from dot file if (fileName.endsWith(".dot")) { File imageFile = new File(getProject().getBasedir(), fileName + ".png"); if (imageFile.exists()) { if (isVerbose() || getLog().isDebugEnabled()) { getLog().info("Deleting previously generated file: " + imageFile); } // We have to make sure the file is deleted // on Windows as well FileUtils.forceDelete(imageFile); } } } } } success = true; } catch (IOException e) { getLog().warn("Reading status file failed: " + e.getMessage()); success = false; } } return success; }
From source file:org.gitcontrib.dataset.GitDataSetManager.java
private void initRepositories(String fileName, boolean remote) throws Exception { InputStream is = Thread.currentThread().getContextClassLoader().getResourceAsStream(fileName); if (is != null) { Properties props = new Properties(); props.load(is);/*from w ww .j a v a 2 s .c om*/ String relativePath = props.getProperty("relativePath"); String clonePath = props.getProperty("clonePath"); if (clonePath == null) clonePath = "./repositories"; for (String key : props.stringPropertyNames()) { if (key.equals("relativePath") || key.equals("clonePath")) continue; String value = props.getProperty(key); if (getRepository(key) != null) { log.info("Repository already added. Skipping: " + key); } else { try { String[] repoFields = StringUtils.split(value, ";"); String repoRef = repoFields[2].trim(); if (remote) addRepository(repoFields[0].trim(), repoFields[1].trim(), key, repoRef, clonePath); else addRepository(repoFields[0].trim(), repoFields[1].trim(), key, new File(relativePath, repoRef)); } catch (Exception e) { log.error("Git repository initialization error: " + key); log.error(e.getMessage()); } } } } }