List of usage examples for java.util Properties containsKey
@Override public boolean containsKey(Object key)
From source file:eu.eidas.node.utils.PropertiesUtil.java
private static void initProps(Properties props) { LOG.info(LoggingMarkerMDC.SYSTEM_EVENT, "Loading properties"); propertiesMap = new HashMap<String, String>(); for (Object key : props.keySet()) { String keyStr = key.toString(); propertiesMap.put(keyStr, props.getProperty(keyStr)); }/*from w w w . j a v a2 s . c om*/ if (eidasXmlLocation != null && !props.containsKey(MASTER_CONF_FILE_PARAM)) { String fileRepositoryDir = eidasXmlLocation.substring(0, eidasXmlLocation.length() - MASTER_CONF_FILE.length()); propertiesMap.put(MASTER_CONF_FILE_PARAM, fileRepositoryDir); props.put(MASTER_CONF_FILE_PARAM, fileRepositoryDir); } }
From source file:ca.hec.commons.utils.MergePropertiesUtils.java
private static void importNewProps(Properties enProperties, Properties frCAProperties) { Set<Object> enKeys = enProperties.keySet(); System.out.println("#----Start importing-----"); for (Object key : enKeys) { if (!frCAProperties.containsKey(key)) { System.out.println(key + "=---TO TRANSLATE ----" + enProperties.getProperty((String) key)); }/* ww w. j a v a 2 s . c o m*/ } System.out.println(); System.out.println(); System.out.println(); }
From source file:org.apache.ranger.tagsync.process.TagSyncConfig.java
static public String getTagAdminUserName(Properties prop) { String userName = null;//from ww w . j a v a 2 s.co m if (prop != null && prop.containsKey(TAGSYNC_TAGADMIN_USERNAME_PROP)) { userName = prop.getProperty(TAGSYNC_TAGADMIN_USERNAME_PROP); } if (StringUtils.isBlank(userName)) { userName = DEFAULT_TAGADMIN_USERNAME; } return userName; }
From source file:org.apache.ranger.tagsync.process.TagSyncConfig.java
static public String getAtlasRESTUserName(Properties prop) { String userName = null;/* w w w.j av a 2 s .c om*/ if (prop != null && prop.containsKey(TAGSYNC_ATLASREST_USERNAME_PROP)) { userName = prop.getProperty(TAGSYNC_ATLASREST_USERNAME_PROP); } if (StringUtils.isBlank(userName)) { userName = DEFAULT_ATLASREST_USERNAME; } return userName; }
From source file:net.big_oh.postoffice.PostOfficeServiceFactory.java
/** * @param postOfficeProperties/*ww w. ja v a2 s . co m*/ * The properties to be used in constructing the new PostOffice * instance. * @return an instance of {@link IPostOfficeService} constructed from the * details provided in the postOfficeProperties parameter. * @throws NullPointerException * Thrown if the postOfficeProperties argument is null. * @throws IllegalArgumentException * Thrown if postOfficeProperties does not contain all mandatory * property keys as defined in {@link #MANDATORY_PROPERTY_KEYS}. * * @see #MANDATORY_PROPERTY_KEYS */ public static IPostOfficeService getInstance(Properties postOfficeProperties) { // validate post office properties if (postOfficeProperties == null) { throw new NullPointerException("postOfficeProperties file cannot be null"); } for (String mandatoryKey : MANDATORY_PROPERTY_KEYS) { if (!postOfficeProperties.containsKey(mandatoryKey)) { throw new IllegalArgumentException("Properties file '" + PROPERTIES_FILE_NAME + "' does not contain the required key '" + mandatoryKey + "'"); } } final String smtpServerHost = postOfficeProperties.getProperty(PROPERTY_KEY_HOST); final String sendersFromAddress = postOfficeProperties.getProperty(PROPERTY_KEY_FROM); final PostOfficeService.Builder builder = new PostOfficeService.Builder(smtpServerHost, sendersFromAddress); builder.setSmtpServerPort( Integer.valueOf(postOfficeProperties.getProperty(PROPERTY_KEY_PORT, Integer.toString(0)))); builder.setDebug( Boolean.valueOf(postOfficeProperties.getProperty(PROPERTY_KEY_DEBUG, Boolean.toString(false)))); builder.setTransportWithSsl(Boolean.valueOf( postOfficeProperties.getProperty(PROPERTY_KEY_TRANSPORT_WITH_SSL, Boolean.toString(false)))); builder.setAuthenticateWithTls(Boolean.valueOf( postOfficeProperties.getProperty(PROPERTY_KEY_AUTHENTICATE_WITH_TLS, Boolean.toString(false)))); builder.setSmtpUserName(postOfficeProperties.getProperty(PROPERTY_KEY_SMTP_USER_NAME)); builder.setSmtpPassword(postOfficeProperties.getProperty(PROPERTY_KEY_SMTP_PASSWORD)); return builder.build(); }
From source file:com.alfaariss.oa.util.database.jdbc.DataSourceFactory.java
/** * Creates a DataSource object specified by the supplied properties: * /*ww w . jav a2 s .c om*/ * <ul> * <li>environment_context</li> * <li>resource-ref</li> * </ul> * * or: * *<ul> * <li>password</li> * <li>url</li> * <li>username</li> * <li>driverClassName</li> * <li>maxActive</li> * <li>maxIdle</li> * <li>maxWait</li> * <li>minIdle</li> * <li>defaultAutoCommit</li> * <li>defaultReadOnly</li> * <li>defaultTransactionIsolation</li> * <li>defaultCatalog</li> * <li>initialSize</li> * <li>testOnBorrow</li> * <li>testOnReturn</li> * <li>timeBetweenEvictionRunsMillis</li> * <li>numTestsPerEvictionRun</li> * <li>minEvictableIdleTimeMillis</li> * <li>testWhileIdle</li> * <li>validationQuery</li> * <li>accessToUnderlyingConnectionAllowed</li> * <li>removeAbandoned</li> * <li>removeAbandonedTimeout</li> * <li>logAbandoned</li> * <li>poolPreparedStatements</li> * <li>maxOpenPreparedStatements</li> * <li>connectionProperties</li> * </ul> * @param pConfig config properties * @return DataSource object * @throws DatabaseException if creation fails */ public static DataSource createDataSource(Properties pConfig) throws DatabaseException { DataSource ds = null; try { if (pConfig.containsKey("environment_context")) { String sContext = pConfig.getProperty("environment_context"); Context envCtx = null; try { envCtx = (Context) new InitialContext().lookup(sContext); } catch (NamingException e) { _logger.warn("Could not find context: " + sContext, e); throw new DatabaseException(SystemErrors.ERROR_INIT); } String sResourceRef = pConfig.getProperty("resource-ref"); try { ds = (DataSource) envCtx.lookup(sResourceRef); } catch (NamingException e) { _logger.warn("Could not find resource ref: " + sResourceRef, e); throw new DatabaseException(SystemErrors.ERROR_INIT); } _logger.info("Created DataSource by reading from context"); } else { ds = BasicDataSourceFactory.createDataSource(pConfig); _logger.info("Created DataSource by reading properties object"); } } catch (Exception e) { _logger.fatal("Could not initialize object", e); throw new DatabaseException(SystemErrors.ERROR_INTERNAL); } return ds; }
From source file:edu.umd.cs.eclipse.courseProjectManager.EclipseLaunchEventLog.java
/** * Uploads a String containing eclipse launch events to the server. * //from w ww . j a va2 s. c o m * @param launchEvents * the eclipse launch events to be uploaded * @param classAccount * the class account of the user who generated the launch events * @param oneTimePassword * the one-time password of the user who generated the launch * events * @param url * the URL of the server that will accept the launch events * @throws IOException * @throws HttpException */ private static int uploadMessages(String launchEvents, Properties props) throws IOException, HttpException { // Replace the path with /eclipse/LogEclipseLaunchEvent. if (!props.containsKey("submitURL")) { props.put("submitURL", "https://submit.cs.umd.edu:8443/eclipse/LogEclipseLaunchEvent"); } String submitURL = props.getProperty("submitURL"); Debug.print("submitURL: " + props.getProperty("submitURL")); int index = submitURL.indexOf("/eclipse/"); if (index == -1) { Debug.print("Cannot find submitURL in .submitUser file"); throw new IOException("Cannot find submitURL in .submitUser file"); } submitURL = submitURL.substring(0, index) + "/eclipse/LogEclipseLaunchEvent"; String version = System.getProperties().getProperty("java.runtime.version"); boolean useEasyHttps = version.startsWith("1.3") || version.startsWith("1.2") || version.startsWith("1.4.0") || version.startsWith("1.4.1") || version.startsWith("1.4.2_0") && version.charAt(7) < '5'; if (useEasyHttps) { if (submitURL.startsWith("https")) submitURL = "easy" + submitURL; } Debug.print("submitURL: " + submitURL); MultipartPostMethod filePost = new MultipartPostMethod(submitURL); // add filepart byte[] bytes = launchEvents.getBytes(); filePost.addPart(new FilePart("eclipseLaunchEvent", new ByteArrayPartSource("eclipseLaunchEvent", bytes))); TurninProjectAction.addAllPropertiesButSubmitURL(props, filePost); filePost.addParameter("clientTime", Long.toString(System.currentTimeMillis())); HttpClient client = new HttpClient(); client.setConnectionTimeout(5000); int status = client.executeMethod(filePost); if (status != HttpStatus.SC_OK) { System.err.println(filePost.getResponseBodyAsString()); throw new HttpException("status is: " + status); } return status; }
From source file:org.commonjava.maven.ext.core.util.PropertiesUtils.java
public static String handleDeprecatedProperty(Properties userProps, PropertyFlag flag, String defaultValue) { String result;/*from w w w . j a v a2 s . c o m*/ if (userProps.containsKey(flag.getDeprecated())) { logger.error("Deprecated property usage {} ", flag.getDeprecated()); logger.warn("Property {} is deprecated. Please use property {} instead.", flag.getDeprecated(), flag.getCurrent()); result = userProps.getProperty(flag.getDeprecated(), defaultValue); } else { result = userProps.getProperty(flag.getCurrent(), defaultValue); } return result; }
From source file:gobblin.source.extractor.extract.kafka.ConfigStoreUtils.java
public static Optional<Config> getConfigForTopic(Properties properties, String topicKey, ConfigClient configClient) {/*from w w w. j a va 2 s .co m*/ Optional<String> configStoreUri = getConfigStoreUri(properties); Optional<Config> config = Optional.<Config>absent(); if (!configStoreUri.isPresent()) { return config; } try { Preconditions.checkArgument(properties.containsKey(GOBBLIN_CONFIG_COMMONPATH), "Missing required property " + GOBBLIN_CONFIG_COMMONPATH); Preconditions.checkArgument(properties.containsKey(topicKey), "Missing required property " + topicKey); String topicName = properties.getProperty(topicKey); String commonPath = properties.getProperty(GOBBLIN_CONFIG_COMMONPATH); config = Optional.fromNullable( getConfig(configClient, getUriStringForTopic(topicName, commonPath, configStoreUri.get()), ConfigClientUtils.getOptionalRuntimeConfig(properties))); } catch (URISyntaxException e) { log.error("Unable to get config", e); } return config; }
From source file:org.colombbus.tangara.Main.java
private static void checkForUpdate() { Configuration conf = Configuration.instance(); // Check for updates if the feature is enabled in conf if (conf.getInteger("checkUpdate.activation") == 1) { boolean checkUpdate = false; GregorianCalendar today = new GregorianCalendar(); GregorianCalendar lastLaunch = new GregorianCalendar(); lastLaunch.setTimeInMillis(0);/*from w ww . j a va2 s. co m*/ Properties properties = conf.loadUpdateProperties(); // Read last Launch date if ((properties != null) && (properties.containsKey("checkUpdate.lastLaunch"))) { String strValue = properties.getProperty("checkUpdate.lastLaunch"); long longValue = Long.parseLong(strValue); lastLaunch.setTimeInMillis(longValue); } else { LOG.warn("Failed to load lastLaunch property"); properties = new Properties(); } // Write last Launch date properties.setProperty("checkUpdate.lastLaunch", Long.toString(today.getTimeInMillis())); conf.saveUpdateProperties(properties); String intervalText = Configuration.instance().getProperty("checkUpdate.interval"); if (intervalText.equals("ALWAYS")) { checkUpdate = true; } else if (intervalText.equals("WEEK")) { lastLaunch.add(GregorianCalendar.DAY_OF_MONTH, 7); checkUpdate = (today.after(lastLaunch)); } else if (intervalText.equals("MONTH")) { lastLaunch.add(GregorianCalendar.MONTH, 1); checkUpdate = (today.after(lastLaunch)); } if (checkUpdate) { SoftwareUpdate.launchVersionCheck(); } } }