List of usage examples for java.util Properties containsKey
@Override public boolean containsKey(Object key)
From source file:org.apache.ranger.tagsync.process.TagSyncConfig.java
static public String getTagAdminPassword(Properties prop) { //update credential from keystore String password = null;/* ww w . ja v a 2s. co m*/ if (prop != null && prop.containsKey(TAGSYNC_TAGADMIN_PASSWORD_PROP)) { password = prop.getProperty(TAGSYNC_TAGADMIN_PASSWORD_PROP); if (password != null && !password.isEmpty()) { return password; } } if (prop != null && prop.containsKey(TAGSYNC_TAGADMIN_KEYSTORE_PROP)) { String path = prop.getProperty(TAGSYNC_TAGADMIN_KEYSTORE_PROP); if (path != null) { if (!path.trim().isEmpty()) { try { password = CredentialReader.getDecryptedString(path.trim(), TAGSYNC_DEST_RANGER_PASSWORD_ALIAS); } catch (Exception ex) { password = null; } if (password != null && !password.trim().isEmpty() && !password.trim().equalsIgnoreCase("none")) { return password; } } } } if (StringUtils.isBlank(password)) { return DEFAULT_TAGADMIN_PASSWORD; } return null; }
From source file:org.apache.ranger.tagsync.process.TagSyncConfig.java
static public String getAtlasRESTPassword(Properties prop) { //update credential from keystore String password = null;// w w w. ja v a 2 s .com if (prop != null && prop.containsKey(TAGSYNC_ATLASREST_PASSWORD_PROP)) { password = prop.getProperty(TAGSYNC_ATLASREST_PASSWORD_PROP); if (password != null && !password.isEmpty()) { return password; } } if (prop != null && prop.containsKey(TAGSYNC_ATLASREST_KEYSTORE_PROP)) { String path = prop.getProperty(TAGSYNC_ATLASREST_KEYSTORE_PROP); if (path != null) { if (!path.trim().isEmpty()) { try { password = CredentialReader.getDecryptedString(path.trim(), TAGSYNC_SOURCE_ATLASREST_PASSWORD_ALIAS); } catch (Exception ex) { password = null; } if (password != null && !password.trim().isEmpty() && !password.trim().equalsIgnoreCase("none")) { return password; } } } } if (StringUtils.isBlank(password)) { return DEFAULT_ATLASREST_PASSWORD; } return null; }
From source file:com.intuit.autumn.utils.PropertyFactory.java
private static void fromJar(final String propertyResourceName, @Nullable final Class base, final Properties properties) { if (base == null) { return;/*from w ww .java 2 s .co m*/ } CodeSource src = base.getProtectionDomain().getCodeSource(); if (src == null) { return; } Properties propertiesFromJar = getPropertyFromJar(base, propertyResourceName.substring(1), src); for (Entry<Object, Object> entry : propertiesFromJar.entrySet()) { if (!properties.containsKey(entry.getKey())) { LOGGER.debug("overriding key: {}, newValue: {}, originalValue: {}", new Object[] { entry.getKey(), propertiesFromJar, entry.getValue() }); properties.setProperty((String) entry.getKey(), (String) entry.getValue()); } } }
From source file:com.adobe.aem.demomachine.gui.AemDemoUtils.java
public static String getPropertyValue(File buildFile, String propertyName) { String propertyValue = null;/*from www . j a va 2 s .c o m*/ Properties defaultProps = loadProperties( buildFile.getParentFile().getAbsolutePath() + File.separator + "build.properties"); Properties personalProps = loadProperties(buildFile.getParentFile().getAbsolutePath() + File.separator + "conf" + File.separator + "build-personal.properties"); if (personalProps.containsKey(propertyName)) { propertyValue = personalProps.getProperty(propertyName); } else { propertyValue = defaultProps.getProperty(propertyName); } return propertyValue; }
From source file:com.adobe.aem.demomachine.gui.AemDemoUtils.java
public static AemDemoProperty[] listOptions(File buildFile, String property) { List<AemDemoProperty> aemMKs = new ArrayList<AemDemoProperty>(); Properties defaultProps = loadProperties( buildFile.getParentFile().getAbsolutePath() + File.separator + "build.properties"); Properties personalProps = loadProperties(buildFile.getParentFile().getAbsolutePath() + File.separator + "conf" + File.separator + "build-personal.properties"); if (personalProps.containsKey(property)) { addPropertyFromString(aemMKs, personalProps.getProperty(property)); } else {/*from www. j a v a 2s. c o m*/ addPropertyFromString(aemMKs, defaultProps.getProperty(property)); } AemDemoProperty[] aemPropertyArray = new AemDemoProperty[aemMKs.size()]; aemMKs.toArray(aemPropertyArray); return aemPropertyArray; }
From source file:net.dries007.coremod.Coremod.java
private static boolean checkDev() throws IOException { if (!Data.debug) return false; msg("###########################################################", "#### DEV MODE ENGAGED. NO CLASSLOADING OR LIB LOADING. ####", "#### ONLY USE IN A DEVELOPMENT ENVIRONMENT ####", "###########################################################"); Properties properties = new Properties(); properties.load(new FileInputStream(new File(Data.FEfolder, "dev.properties"))); if (properties.containsKey(Data.get(Data.CLASSKEY_ASM))) { if (!properties.getProperty(Data.get(Data.CLASSKEY_ASM)).equals("")) { for (String className : properties.getProperty(Data.get(Data.CLASSKEY_ASM)).split(" ")) { msg("DEV ASM class: " + className); try { Data.classLoader.registerTransformer(className); } catch (Exception e) { msg("DEV ASM class ERROR."); e.printStackTrace(); }/*from ww w. j a v a 2 s . c o m*/ } } } if (properties.containsKey(Data.get(Data.FILEKEY_TA))) { if (!properties.getProperty(Data.get(Data.FILEKEY_TA)).equals("")) { for (String ATfile : properties.getProperty(Data.get(Data.FILEKEY_TA)).split(" ")) { msg("DEV AccessTransformer: " + ATfile); try { CustomAT.addTransformerMap(ATfile); } catch (Exception e) { msg("DEV AccessTransformer ERROR."); e.printStackTrace(); } } } for (String ATfile : properties.getProperty(Data.get(Data.FILEKEY_TA)).split(" ")) { msg("DEV AccessTransformer: " + ATfile); try { CustomAT.addTransformerMap(ATfile); } catch (Exception e) { msg("DEV AccessTransformer ERROR."); e.printStackTrace(); } } } return true; }
From source file:org.apache.archiva.web.test.tools.WebdriverUtility.java
public static String getBaseUrl() { if (System.getProperties().containsKey("baseUrl")) { return System.getProperty("baseUrl"); }//from w w w . ja v a 2 s.c om int containerPort = 7777; if (System.getProperties().containsKey("container.http.port")) { containerPort = Integer.parseInt(System.getProperty("container.http.port")); } else if (System.getProperties().containsKey("container.propertiesPortFilePath")) { Properties portProperties = new Properties(); try (InputStream inputStream = Files .newInputStream(Paths.get(System.getProperty("container.propertiesPortFilePath")))) { portProperties.load(inputStream); } catch (IOException e) { log.error("Error during property loading with containger.propertiesPortFilePath"); } if (portProperties.containsKey("tomcat.maven.http.port")) { containerPort = Integer.parseInt(portProperties.getProperty("tomcat.maven.http.port")); } else { containerPort = Integer.parseInt(portProperties.getProperty("container.http.port")); } } return "http://localhost:" + containerPort + "/archiva"; }
From source file:gobblin.source.extractor.extract.kafka.KafkaDeserializerExtractor.java
/** * Constructs a {@link KafkaSchemaRegistry} using the value of {@link #KAFKA_DESERIALIZER_TYPE}, if not set it * defaults to {@link SimpleKafkaSchemaRegistry}. *///from w w w . j a v a 2s . co m private static KafkaSchemaRegistry<?, ?> getKafkaSchemaRegistry(Properties props) throws ReflectiveOperationException { Optional<Deserializers> deserializerType = Enums.getIfPresent(Deserializers.class, props.getProperty(KAFKA_DESERIALIZER_TYPE).toUpperCase()); if (deserializerType.isPresent()) { return ConstructorUtils.invokeConstructor(deserializerType.get().getSchemaRegistryClass(), props); } if (props.containsKey(KafkaSchemaRegistry.KAFKA_SCHEMA_REGISTRY_CLASS)) { return KafkaSchemaRegistry.get(props); } return new SimpleKafkaSchemaRegistry(props); }
From source file:gobblin.util.ConfigUtils.java
/** * Convert all the keys that start with a <code>prefix</code> in {@link Properties} to a {@link Config} instance. * * <p>//from ww w . j ava 2 s. co m * This method will throw an exception if (1) the {@link Object#toString()} method of any two keys in the * {@link Properties} objects returns the same {@link String}, or (2) if any two keys are prefixes of one another, * see the Java Docs of {@link ConfigFactory#parseMap(Map)} for more details. * </p> * * @param properties the given {@link Properties} instance * @param prefix of keys to be converted * @return a {@link Config} instance */ public static Config propertiesToConfig(Properties properties, Optional<String> prefix) { Set<String> blacklistedKeys = new HashSet<>(); if (properties.containsKey(GOBBLIN_CONFIG_BLACKLIST_KEYS)) { blacklistedKeys = new HashSet<>(Splitter.on(',').omitEmptyStrings().trimResults() .splitToList(properties.getProperty(GOBBLIN_CONFIG_BLACKLIST_KEYS))); } Set<String> fullPrefixKeys = findFullPrefixKeys(properties, prefix); ImmutableMap.Builder<String, Object> immutableMapBuilder = ImmutableMap.builder(); for (Map.Entry<Object, Object> entry : properties.entrySet()) { String entryKey = entry.getKey().toString(); if (StringUtils.startsWith(entryKey, prefix.or(StringUtils.EMPTY)) && !blacklistedKeys.contains(entryKey)) { if (fullPrefixKeys.contains(entryKey)) { entryKey = sanitizeFullPrefixKey(entryKey); } else if (entryKey.endsWith(STRIP_SUFFIX)) { throw new RuntimeException("Properties are not allowed to end in " + STRIP_SUFFIX); } immutableMapBuilder.put(entryKey, entry.getValue()); } } return ConfigFactory.parseMap(immutableMapBuilder.build()); }
From source file:com.metamx.emitter.core.Emitters.java
static Map<String, Object> makeHttpMap(Properties props) { Map<String, Object> httpMap = Maps.newHashMap(); final String urlProperty = "com.metamx.emitter.http.url"; final String baseUrl = props.getProperty(urlProperty); if (baseUrl == null) { throw new IAE("Property[%s] must be set", urlProperty); }// w ww . j ava 2 s.c o m httpMap.put("recipientBaseUrl", baseUrl); httpMap.put("flushMillis", Long.parseLong(props.getProperty("com.metamx.emitter.flushMillis", "60000"))); httpMap.put("flushCount", Integer.parseInt(props.getProperty("com.metamx.emitter.flushCount", "300"))); if (props.containsKey("com.metamx.emitter.http.basicAuthentication")) { httpMap.put("basicAuthentication", props.getProperty("com.metamx.emitter.http.basicAuthentication")); } if (props.containsKey("com.metamx.emitter.http.batchingStrategy")) { httpMap.put("batchingStrategy", props.getProperty("com.metamx.emitter.http.batchingStrategy").toUpperCase()); } if (props.containsKey("com.metamx.emitter.http.maxBatchSize")) { httpMap.put("maxBatchSize", Integer.parseInt(props.getProperty("com.metamx.emitter.http.maxBatchSize"))); } if (props.containsKey("com.metamx.emitter.http.maxBufferSize")) { httpMap.put("maxBufferSize", Long.parseLong(props.getProperty("com.metamx.emitter.http.maxBufferSize"))); } return httpMap; }