List of usage examples for java.util Properties containsKey
@Override public boolean containsKey(Object key)
From source file:org.apache.solr.update.InvenioKeepRecidUpdated.java
private Properties loadProperties(SolrParams params) throws FileNotFoundException, IOException { Properties prop = new Properties(); File f = getPropertyFile();//from w w w.j a v a2 s .c o m if (f.exists()) { FileInputStream input = new FileInputStream(f); prop.load(input); input.close(); } String prop_recid = null; if (prop.containsKey(LAST_RECID)) { prop_recid = (String) prop.remove(LAST_RECID); } String prop_mod_date = null; if (prop.containsKey(LAST_UPDATE)) { prop_mod_date = (String) prop.remove(LAST_UPDATE); } boolean userParam = false; // parameters in url have always precedence (if both set // it is up to the python to figure out who has precedence if (params.getInt(LAST_RECID) != null) { prop.put(LAST_RECID, params.get(LAST_RECID)); userParam = true; } if (params.get(LAST_UPDATE, null) != null) { prop.put(LAST_UPDATE, params.get(LAST_UPDATE)); userParam = true; } if (!userParam) { // when no user params were supplied, prefer the mod_date over recid if (prop_mod_date != null) { prop.put(LAST_UPDATE, prop_mod_date); } else if (prop_recid != null) { prop.put(LAST_RECID, prop_recid); } } if (params.get(PARAM_BATCHSIZE, null) != null) { int bs = params.getInt(PARAM_BATCHSIZE); if (bs > max_batchsize) { prop.put(PARAM_BATCHSIZE, max_batchsize); } else { prop.put(PARAM_BATCHSIZE, bs); } } if (params.get(PARAM_MAXIMPORT, null) != null) { int mi = params.getInt(PARAM_MAXIMPORT); if (mi > max_maximport) { prop.put(PARAM_MAXIMPORT, max_maximport); } else { prop.put(PARAM_MAXIMPORT, mi); } } prop.put(PARAM_TOKEN, params.get(PARAM_TOKEN, "")); return prop; }
From source file:gobblin.runtime.AbstractJobLauncher.java
public AbstractJobLauncher(Properties jobProps, List<? extends Tag<?>> metadataTags, @Nullable SharedResourcesBroker<GobblinScopeTypes> instanceBroker) throws Exception { Preconditions.checkArgument(jobProps.containsKey(ConfigurationKeys.JOB_NAME_KEY), "A job must have a job name specified by job.name"); // Add clusterIdentifier tag so that it is added to any new TaskState created List<Tag<?>> clusterNameTags = Lists.newArrayList(); clusterNameTags.addAll(Tag.fromMap(ClusterNameTags.getClusterNameTags())); GobblinMetrics.addCustomTagsToProperties(jobProps, clusterNameTags); // Make a copy for both the system and job configuration properties this.jobProps = new Properties(); this.jobProps.putAll(jobProps); if (!tryLockJob(this.jobProps)) { throw new JobException( String.format("Previous instance of job %s is still running, skipping this scheduled run", this.jobProps.getProperty(ConfigurationKeys.JOB_NAME_KEY))); }//from w ww .j av a 2 s .com try { if (instanceBroker == null) { instanceBroker = createDefaultInstanceBroker(jobProps); } this.jobContext = new JobContext(this.jobProps, LOG, instanceBroker); this.eventBus.register(this.jobContext); this.cancellationExecutor = Executors.newSingleThreadExecutor( ExecutorsUtils.newThreadFactory(Optional.of(LOG), Optional.of("CancellationExecutor"))); this.runtimeMetricContext = this.jobContext.getJobMetricsOptional() .transform(new Function<JobMetrics, MetricContext>() { @Override public MetricContext apply(JobMetrics input) { return input.getMetricContext(); } }); this.eventSubmitter = buildEventSubmitter(metadataTags); // Add all custom tags to the JobState so that tags are added to any new TaskState created GobblinMetrics.addCustomTagToState(this.jobContext.getJobState(), metadataTags); JobExecutionEventSubmitter jobExecutionEventSubmitter = new JobExecutionEventSubmitter( this.eventSubmitter); this.mandatoryJobListeners.add(new JobExecutionEventSubmitterListener(jobExecutionEventSubmitter)); } catch (Exception e) { unlockJob(); throw e; } }
From source file:com.googlecode.jgenhtml.Config.java
/** * Loads the lcovrc config file from the home directory or the location specified on the * command line and sets properties in the config object accordingly. * Does not look for a system wide config file because there is no consistent directory to * look in across all platforms./* ww w . j ava 2s . co m*/ * * @param alternatePath */ private void loadConfigFile(final String alternatePath) { try { //don't use FileUtils.getUserDirectoryPath() here, it was causing issues when run from Ant String lcovrc = System.getProperty("user.home") + File.separatorChar + ".lcovrc"; Properties properties = loadFileToProperties(alternatePath); if (properties != null || (properties = loadFileToProperties(lcovrc)) != null) { LOGGER.log(Level.INFO, "Loaded config file {0}.", lcovrc); if (properties.containsKey(ConfFileArg.CSS.toString())) { setCssFile(properties.getProperty(ConfFileArg.CSS.toString())); } Integer optionValue = getNumericValue(properties, ConfFileArg.FUNCOV.toString()); if (optionValue != null) { setFunctionCoverage(optionValue != 0); } optionValue = getNumericValue(properties, ConfFileArg.BRANCOV.toString()); if (optionValue != null) { setBranchCoverage(optionValue != 0); } optionValue = getNumericValue(properties, ConfFileArg.GZIP.toString()); if (optionValue != null) { setGzip(optionValue != 0); } optionValue = getNumericValue(properties, ConfFileArg.KEEPDESC.toString()); if (optionValue != null) { setKeepDescriptions(optionValue != 0); } optionValue = getNumericValue(properties, ConfFileArg.NOSOURCE.toString()); if (optionValue != null) { setNoSource(optionValue != 0); } optionValue = getNumericValue(properties, ConfFileArg.SORT.toString()); if (optionValue != null) { setNoSort(optionValue == 0); } optionValue = getNumericValue(properties, ConfFileArg.SPACES.toString()); if (optionValue != null) { setNumSpaces(optionValue); } optionValue = getNumericValue(properties, ConfFileArg.HILIMIT.toString()); if (optionValue != null) { setHiLimit(optionValue); } optionValue = getNumericValue(properties, ConfFileArg.MEDLIMIT.toString()); if (optionValue != null) { setMedLimit(optionValue); } optionValue = getNumericValue(properties, ConfFileArg.NOPREFIX.toString()); if (optionValue != null) { setNoPrefix(optionValue != 0); } optionValue = getNumericValue(properties, ConfFileArg.LEGEND.toString()); if (optionValue != null) { setLegend(optionValue != 0); } if (properties.containsKey(ConfFileArg.HTML_EXT.toString())) { setHtmlExt(properties.getProperty(ConfFileArg.HTML_EXT.toString())); } optionValue = getNumericValue(properties, ConfFileArg.HTMLONLY.toString()); if (optionValue != null) { setHtmlOnly(optionValue != 0); } optionValue = getNumericValue(properties, ConfFileArg.VERBOSE.toString()); if (optionValue != null) { if (optionValue != 0) { Logger parent = Logger.getLogger("com.googlecode.jgenhtml"); parent.setLevel(Level.ALL); } } } } catch (IOException ex) { LOGGER.log(Level.WARNING, ex.getLocalizedMessage()); } }
From source file:coral.service.ExpServable.java
@Override public void init(Properties properties, BlockingQueue<Message> loopQueue, Linker linker) { this.linker = linker; this.basepath = properties.getProperty("exp.basepath", "./"); String dbname = properties.getProperty("coral.db.name", "db"); String dbmode = properties.getProperty("coral.db.mode", "file"); boolean resetdb = (properties.getProperty("coral.db.reset", "false").equals("true")); dataService = new DataServiceJbdcImpl(dbname, resetdb, dbmode); CoralUtils.hoststr = properties.getProperty("coral.head.coralhost", "exp://host/"); ExpServiceImpl serv = new ExpServiceImpl(this, properties, dataService); if (properties.containsKey("exp.stagesfile")) { this.stagesfile = properties.getProperty("exp.stagesfile"); }/*from ww w. j av a 2 s . c om*/ serv.init(basepath, stagesfile, properties.getProperty("coral.exp.variant")); this.viewname = properties.getProperty("exp.viewname", "_exp.html"); this.server = new ExpServer(0, properties.getProperty("exp.servertype", "none"), this, dataService); serv.debug = (properties.getProperty("coral.debug", "false").equals("true")); logger.debug("debug status is " + properties.getProperty("exp.debug", "false") + " -- " + serv.debug); useScreenwriter = (properties.getProperty("coral.head.screenwriter", "false").equals("true")); this.startMarker = properties.getProperty("coral.cmd.start", CoralUtils.START_KEY); this.refreshMarker = properties.getProperty("coral.cmd.refresh", CoralUtils.REFRESH_KEY); this.serverMarker = properties.getProperty("coral.cmd.server", CoralUtils.SERVER_KEY); this.service = serv; }
From source file:it.geosolutions.figis.security.authentication.CredentialsManager.java
/** * * @throws IOException//from w w w .j a v a2 s. c om */ private void loadProperties() throws IOException { Properties props = new Properties(); InputStream pin = null; try { pin = new BufferedInputStream(new FileInputStream(propertyFile)); if (LOGGER.isTraceEnabled()) { LOGGER.trace("PROPERTIES_FILE reloaded " + PROPERTIES_FILE); } props.load(pin); if (LOGGER.isTraceEnabled()) { LOGGER.trace("PROPERTIES_FILE reloaded: " + PROPERTIES_FILE); } } catch (IOException e) { throw new IOException( "UsersCheckUtils: error on realoading file properties: PROPERTIES_FILE: " + PROPERTIES_FILE); } finally { if (pin != null) { IOUtils.closeQuietly(pin); } } String temp = null; w.lock(); try { if (props.containsKey("PROPERTIES_FILE")) { temp = props.getProperty("PROPERTIES_FILE"); if (temp != null) { PROPERTIES_FILE = temp; } } if (props.containsKey("usersRoleAdmin")) { temp = props.getProperty("usersRoleAdmin"); if (temp != null) { usersRoleAdmin = props.getProperty("usersRoleAdmin"); } } if (props.containsKey("usersRoleUser")) { temp = props.getProperty("usersRoleUser"); if (temp != null) { usersRoleUser = props.getProperty("usersRoleUser"); } } } finally { w.unlock(); } }
From source file:com.messagehub.samples.servlet.KafkaServlet.java
/** * Retrieve client configuration information, using a properties file, for connecting to secure Kafka. * /* w ww. j ava 2 s.c o m*/ * @param broker * {String} A string representing a list of brokers the producer can contact. * @param apiKey * {String} The API key of the Bluemix Message Hub service. * @param isProducer * {Boolean} Flag used to determine whether or not the configuration is for a producer. * @return {Properties} A properties object which stores the client configuration info. */ public final Properties getClientConfiguration(String broker, String apiKey, boolean isProducer) { Properties props = new Properties(); InputStream propsStream; String fileName = resourceDir + File.separator; if (isProducer) { fileName += "producer.properties"; } else { fileName += "consumer.properties"; } try { logger.log(Level.WARN, "Reading properties file from: " + fileName); propsStream = new FileInputStream(fileName); props.load(propsStream); propsStream.close(); } catch (IOException e) { logger.log(Level.ERROR, e); return props; } props.put("bootstrap.servers", broker); if (!props.containsKey("ssl.truststore.location") || props.getProperty("ssl.truststore.location").length() == 0) { props.put("ssl.truststore.location", "/home/vcap/app/.java/jre/lib/security/cacerts"); } logger.log(Level.WARN, "Using properties: " + props); return props; }
From source file:org.alfresco.config.SystemPropertiesFactoryBean.java
@SuppressWarnings("unchecked") @Override/*ww w. ja v a 2 s . c o m*/ protected Properties mergeProperties() throws IOException { // First do the default merge Properties props = super.mergeProperties(); // Now resolve all the merged properties if (this.systemPropertiesMode == PropertyPlaceholderConfigurer.SYSTEM_PROPERTIES_MODE_NEVER) { // If we are in never mode, we don't refer to system properties at all for (String systemProperty : (Set<String>) (Set) props.keySet()) { resolveMergedProperty(systemProperty, props); } } else { // Otherwise, we allow unset properties to drift through from the systemProperties set and potentially set // ones to be overriden by system properties Set<String> propNames = new HashSet<String>((Set<String>) (Set) props.keySet()); propNames.addAll(this.systemProperties); for (String systemProperty : propNames) { resolveMergedProperty(systemProperty, props); if (this.systemPropertiesMode == PropertyPlaceholderConfigurer.SYSTEM_PROPERTIES_MODE_FALLBACK && props.containsKey(systemProperty)) { // It's already there continue; } // Get the system value and assign if present String systemPropertyValue = System.getProperty(systemProperty); if (systemPropertyValue != null) { props.put(systemProperty, systemPropertyValue); } } } return props; }
From source file:edu.gsgp.experiment.config.PropertiesManager.java
private Properties loadProperties(String path) throws Exception { path = this.preProcessPath(path); File parameterFile = new File(path); if (!parameterFile.canRead()) { throw new FileNotFoundException("Parameter file can not be read: " + parameterFile.getCanonicalPath()); }//from w ww .j av a 2s .c o m FileInputStream fileInput = new FileInputStream(parameterFile); Properties property = new Properties(); property.load(fileInput); if (property.containsKey(ParameterList.PARENT_FILE.name)) { Properties propertyParent = loadProperties(property.getProperty("parent").trim()); propertyParent.putAll(property); property = propertyParent; } return property; }
From source file:de.mendelson.comm.as2.message.AS2MessageParser.java
/**If a content transfer encoding is set this will decode the data*/ private byte[] processContentTransferEncoding(byte[] data, Properties header) throws Exception { if (!header.containsKey("content-transfer-encoding")) { //no content transfer encoding set: the AS2 default is "binary" in this case (NOT 7bit!), binary //content transfer encoding requires no decoding return (data); } else {//from ww w. ja v a 2 s. c o m String transferEncoding = header.getProperty("content-transfer-encoding"); return (this.decodeContentTransferEncoding(data, transferEncoding)); } }
From source file:cucumber.templates.PerRepositoryTemplatesTest.java
/** * Checks whether the generated properties file is valid. * @param outputName the output name.//from w w w .j ava 2 s . co m * @param outputFiles the output files. * @param tableNames the table names. * @param vendor the vendor. * @param grammarUtils the {@link EnglishGrammarUtils} instance. */ protected void checkPropertiesIsValid(@NotNull final String outputName, @NotNull final Map<String, File> outputFiles, @NotNull final List<String> tableNames, @NotNull final String vendor, @NotNull final EnglishGrammarUtils grammarUtils, @NotNull final StringUtils stringUtils) { checkPropertiesFiles(outputName, outputFiles); @Nullable final File file = retrieveOutputFile(outputName.concat(Literals.QUERYJ_PROPERTIES)); if (file != null) { @Nullable final Properties properties = readPropertiesFile(file); Assert.assertNotNull("Invalid properties file : " + file.getAbsolutePath(), properties); Assert.assertEquals("Invalid number of entries in " + file.getAbsolutePath(), tableNames.size(), properties.size()); for (@Nullable final String tableName : tableNames) { Assert.assertNotNull(tableName); @NotNull final String singularTableName = toSingular(tableName, grammarUtils); @NotNull final String key = getRepositoryName() + "." + singularTableName + ".dao"; Assert.assertTrue("Missing entry in " + file.getAbsolutePath(), properties.containsKey(key)); Assert.assertEquals("Invalid entry " + key + " in " + file.getAbsolutePath(), DAO_PACKAGE_NAME + ".rdb." + vendor.toLowerCase(Locale.getDefault()) + "." + vendor + capitalize(singularTableName, stringUtils) + "DAOFactory", properties.getProperty(key)); } } }