List of usage examples for java.util Properties containsKey
@Override public boolean containsKey(Object key)
From source file:org.cesecore.keys.token.BaseCryptoToken.java
@Override public void setProperties(Properties properties) { if (properties == null) { this.properties = new Properties(); } else {/*from w w w .j a v a2 s. com*/ if (log.isDebugEnabled()) { // This is only a sections for debug logging. If we have enabled debug logging we don't want to display any password in the log. // These properties may contain autoactivation PIN codes and we will, only when debug logging, replace this with "hidden". if (properties.containsKey(CryptoToken.AUTOACTIVATE_PIN_PROPERTY) || properties.containsKey("PIN")) { Properties prop = new Properties(); prop.putAll(properties); if (properties.containsKey(CryptoToken.AUTOACTIVATE_PIN_PROPERTY)) { prop.setProperty(CryptoToken.AUTOACTIVATE_PIN_PROPERTY, "hidden"); } if (properties.containsKey("PIN")) { prop.setProperty("PIN", "hidden"); } log.debug("Prop: " + (prop != null ? prop.toString() : "null")); } else { // If no autoactivation PIN codes exists we can debug log everything as original. log.debug("Properties: " + (properties != null ? properties.toString() : "null")); } } // if (log.isDebugEnabled()) this.properties = properties; String authCode = BaseCryptoToken.getAutoActivatePin(properties); this.mAuthCode = authCode == null ? null : authCode.toCharArray(); } }
From source file:org.apache.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))); }// w w w .j av a2 s . c o m 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)); String eventMetadatadataGeneratorClassName = jobProps.getProperty( ConfigurationKeys.EVENT_METADATA_GENERATOR_CLASS_KEY, ConfigurationKeys.DEFAULT_EVENT_METADATA_GENERATOR_CLASS_KEY); try { ClassAliasResolver<EventMetadataGenerator> aliasResolver = new ClassAliasResolver<>( EventMetadataGenerator.class); this.eventMetadataGenerator = aliasResolver.resolveClass(eventMetadatadataGeneratorClassName) .newInstance(); } catch (ReflectiveOperationException e) { throw new RuntimeException( "Could not construct EventMetadataGenerator " + eventMetadatadataGeneratorClassName, e); } } catch (Exception e) { unlockJob(); throw e; } }
From source file:com.photon.phresco.framework.rest.api.FeatureService.java
private FeatureConfigure getTemplateConfigFile(String appDirName, String customerId, ServiceManager serviceManager, String featureName, String rootModulePath, String subModuleName) throws PhrescoException { List<PropertyTemplate> propertyTemplates = new ArrayList<PropertyTemplate>(); try {// ww w . jav a 2 s . com FeatureConfigure featureConfigure = new FeatureConfigure(); FrameworkServiceUtil frameworkServiceUtil = new FrameworkServiceUtil(); ProjectInfo projectInfo = Utility.getProjectInfo(rootModulePath, subModuleName); List<Configuration> featureConfigurations = frameworkServiceUtil .getApplicationProcessor(appDirName, customerId, serviceManager, rootModulePath, subModuleName) .preFeatureConfiguration(projectInfo.getAppInfos().get(0), featureName); Properties properties = null; boolean hasCustomProperty = false; if (CollectionUtils.isNotEmpty(featureConfigurations)) { for (Configuration featureConfiguration : featureConfigurations) { properties = featureConfiguration.getProperties(); String expandableProp = properties.getProperty("expandable"); if (StringUtils.isEmpty(expandableProp)) { hasCustomProperty = true; } else { hasCustomProperty = Boolean.valueOf(expandableProp); } if (properties.containsKey("expandable")) { properties.remove("expandable"); } Set<Object> keySet = properties.keySet(); for (Object key : keySet) { String keyStr = (String) key; if (!"expandable".equalsIgnoreCase(keyStr)) { String dispName = keyStr.replace(".", " "); PropertyTemplate propertyTemplate = new PropertyTemplate(); propertyTemplate.setKey(keyStr); propertyTemplate.setName(dispName); propertyTemplates.add(propertyTemplate); } } } } featureConfigure.setHasCustomProperty(hasCustomProperty); featureConfigure.setProperties(properties); featureConfigure.setPropertyTemplates(propertyTemplates); return featureConfigure; } catch (PhrescoException e) { throw new PhrescoException(e); } }
From source file:com.impetus.kundera.persistence.EntityManagerFactoryBuilder.java
/** * Builds up EntityManagerFactory for a given persistenceUnitName and * overriding properties.//ww w.j a va 2 s .c o m * * @param persistenceUnitName * the persistence unit name * @param override * the override * @return the entity manager factory */ public EntityManagerFactory buildEntityManagerFactory(String persistenceUnitName, Map<Object, Object> override) { Properties props = new Properties(); // Override properties KunderaMetadata kunderaMetadata = KunderaMetadata.INSTANCE; PersistenceUnitMetadata puMetadata = kunderaMetadata.getApplicationMetadata() .getPersistenceUnitMetadata(persistenceUnitName); Properties metadataProperties = puMetadata.getProperties(); // Make sure, it's empty or Unmodifiable override = override == null ? Collections.EMPTY_MAP : Collections.unmodifiableMap(override); // Take all from Metadata and override with supplied map for (Map.Entry<Object, Object> entry : metadataProperties.entrySet()) { Object key = entry.getKey(); Object value = entry.getValue(); if (override.containsKey(key)) { value = override.get(key); } props.put(key, value); } // Now take all the remaining ones from override for (Map.Entry<Object, Object> entry : override.entrySet()) { Object key = entry.getKey(); Object value = entry.getValue(); if (!props.containsKey(key)) { props.put(key, value); } } LOG.info("Building EntityManagerFactory for name: " + puMetadata.getPersistenceUnitName() + ", and Properties:" + props); return new EntityManagerFactoryImpl(puMetadata, props); }
From source file:org.modelio.vbasic.net.ApacheUriConnection.java
/** * Configure proxy authentication from the given properties. * @see <a href="http://stackoverflow.com/questions/1626549/authenticated-http-proxy-with-java">stackoverflow: Authenticated HTTP proxy with Java</a> * @see org.eclipse.core.internal.net.ProxyType * @param props configuration source// w w w. j a v a 2s. c o m * @param protocol = http/https * @param credsProvider the credential provider to fill */ @objid("fbda3db8-0195-4690-81dc-81ecfe95a586") @SuppressWarnings("javadoc") private void configProxyCredentials(Properties props, String protocol, CredentialsProvider credsProvider) { /* * http://docs.oracle.com/javase/7/docs/api/java/net/doc-files/net-properties.html: * There are 3 properties you can set to specify the proxy that will be used by the http protocol handler: http.proxyHost: the host name of the proxy server http.proxyPort: the port number, the default value being 80. proxyUser and proxyPassword are not used by the JDK but are set by Eclipse preference page. see : org.eclipse.core.internal.net.ProxyType */ String proxyHostKey = protocol + ".proxyHost"; String proxyUserKey = protocol + ".proxyUser"; if (props.containsKey(proxyHostKey) && props.containsKey(proxyUserKey)) { String proxyPortKey = protocol + ".proxyPort"; String proxyPasswdKey = protocol + ".proxyPassword"; String user = props.getProperty(proxyUserKey); String pwd = props.getProperty(proxyPasswdKey); String sport = props.getProperty(proxyPortKey); int port = sport != null ? Integer.parseInt(sport) : AuthScope.ANY_PORT; final UsernamePasswordCredentials credentials = new UsernamePasswordCredentials(user, pwd); final AuthScope authscope = new AuthScope(this.uri.getHost(), port); credsProvider.setCredentials(authscope, credentials); } }
From source file:org.apache.nifi.toolkit.cli.impl.command.registry.flow.ExportFlowVersion.java
@Override public VersionedFlowSnapshotResult doExecute(final NiFiRegistryClient client, final Properties properties) throws ParseException, IOException, NiFiRegistryException { final String flowId = getRequiredArg(properties, CommandOption.FLOW_ID); final Integer version = getIntArg(properties, CommandOption.FLOW_VERSION); // if no version was provided then export the latest, otherwise use specific version final VersionedFlowSnapshot versionedFlowSnapshot; if (version == null) { versionedFlowSnapshot = client.getFlowSnapshotClient().getLatest(flowId); } else {/*ww w. j a v a 2s. c om*/ versionedFlowSnapshot = client.getFlowSnapshotClient().get(flowId, version); } versionedFlowSnapshot.setFlow(null); versionedFlowSnapshot.setBucket(null); versionedFlowSnapshot.getSnapshotMetadata().setBucketIdentifier(null); versionedFlowSnapshot.getSnapshotMetadata().setFlowIdentifier(null); versionedFlowSnapshot.getSnapshotMetadata().setLink(null); // currently export doesn't use the ResultWriter concept, it always writes JSON // destination will be a file if outputFile is specified, otherwise it will be the output stream of the CLI final String outputFile; if (properties.containsKey(CommandOption.OUTPUT_FILE.getLongName())) { outputFile = properties.getProperty(CommandOption.OUTPUT_FILE.getLongName()); } else { outputFile = null; } return new VersionedFlowSnapshotResult(versionedFlowSnapshot, outputFile); }
From source file:org.apache.gora.hbase.store.HBaseStore.java
/** * Initialize the data store by reading the credentials, setting the client's properties up and * reading the mapping file. Initialize is called when then the call to * {@link org.apache.gora.store.DataStoreFactory#createDataStore} is made. * * The mapping can be passed as a configuration parameter 'gora.mapping' or taken from * gora-hbase-mapping.xml (in this order). * * @param keyClass/*from w w w .j a v a 2s.co m*/ * @param persistentClass * @param properties */ @Override public void initialize(Class<K> keyClass, Class<T> persistentClass, Properties properties) throws GoraException { super.initialize(keyClass, persistentClass, properties); try { this.conf = HBaseConfiguration.create(getConf()); admin = ConnectionFactory.createConnection(getConf()).getAdmin(); InputStream mappingInputStream; // If there is a mapping definition in the Properties, use it. if (properties.containsKey(XML_MAPPING_DEFINITION)) { if (LOG.isTraceEnabled()) LOG.trace(XML_MAPPING_DEFINITION + " = " + properties.getProperty(XML_MAPPING_DEFINITION)); mappingInputStream = IOUtils.toInputStream(properties.getProperty(XML_MAPPING_DEFINITION), (Charset) null); } // Otherwise use the configuration from de default file gora-hbase-mapping.xml or whatever // configured in the key "gora.hbase.mapping.file" else { mappingInputStream = getClass().getClassLoader() .getResourceAsStream(getConf().get(PARSE_MAPPING_FILE_KEY, DEFAULT_MAPPING_FILE)); } mapping = readMapping(mappingInputStream); filterUtil = new HBaseFilterUtil<>(this.conf); } catch (FileNotFoundException ex) { throw new GoraException( "Mapping file '" + getConf().get(PARSE_MAPPING_FILE_KEY, DEFAULT_MAPPING_FILE) + "' not found.", ex); } catch (Exception e) { throw new GoraException(e); } // Set scanner caching option try { this.setScannerCaching(Integer.valueOf(DataStoreFactory.findProperty(this.properties, this, SCANNER_CACHING_PROPERTIES_KEY, String.valueOf(SCANNER_CACHING_PROPERTIES_DEFAULT)))); } catch (NumberFormatException e) { LOG.info("Can not load {} from gora.properties. Setting to default value: {}.", SCANNER_CACHING_PROPERTIES_KEY, SCANNER_CACHING_PROPERTIES_DEFAULT); this.setScannerCaching(SCANNER_CACHING_PROPERTIES_DEFAULT); // Default value if something is wrong } if (autoCreateSchema) { createSchema(); } try { boolean autoflush = this.conf.getBoolean("hbase.client.autoflush.default", false); table = new HBaseTableConnection(getConf(), getSchemaName(), autoflush); } catch (Exception e) { throw new GoraException(e); } closeHBaseAdmin(); }
From source file:org.apache.cxf.cwiki.SiteExporter.java
public SiteExporter(String fileName, boolean force) throws Exception { forceAll = force;/*from w ww . ja v a2s . c o m*/ Properties props = new Properties(); props.load(new FileInputStream(fileName)); if (props.containsKey("spaceKey")) { spaceKey = props.getProperty("spaceKey"); } if (props.containsKey("pageCacheFile")) { pageCacheFile = props.getProperty("pageCacheFile"); } if (props.containsKey("templateName")) { templateName = props.getProperty("templateName"); } if (props.containsKey("outputDir")) { outputDir = new File(rootOutputDir, props.getProperty("outputDir")); } if (props.containsKey("mainDivClass")) { mainDivClass = props.getProperty("mainDivClass"); } if (props.containsKey("breadCrumbRoot")) { breadCrumbRoot = props.getProperty("breadCrumbRoot"); } if (props.containsKey("globalPages")) { String globals = props.getProperty("globalPages"); String[] pgs = globals.split(","); globalPages.addAll(Arrays.asList(pgs)); } props = new Properties(); String clzName = URLResourceLoader.class.getName(); props.put("resource.loader", "url"); props.put("url.resource.loader.class", clzName); props.put("url.resource.loader.root", ""); VelocityEngine engine = new VelocityEngine(); engine.init(props); URL url = ClassLoaderUtils.getResource(templateName, this.getClass()); if (url == null) { File file = new File(templateName); if (file.exists()) { url = file.toURI().toURL(); } } template = engine.getTemplate(url.toURI().toString()); outputDir.mkdirs(); }
From source file:io.kahu.hawaii.cucumber.glue.html.HtmlSteps.java
public HtmlSteps() { Properties properties = System.getProperties(); this.browser = properties.containsKey("test.browser") ? System.getProperty("test.browser") : "chrome"; this.remote = properties.containsKey("test.remote") ? Boolean.parseBoolean(System.getProperty("test.remote")) : false;/* ww w .j ava 2s . c om*/ this.baseUrl = properties.containsKey("test.base.url") ? System.getProperty("test.base.url") : "http://target.kahuna.loc:8888"; this.seleniumHub = properties.containsKey("test.selenium.hub") ? System.getProperty("test.selenium.hub") : "http://localhost:4444/wd/hub"; this.relativeUrl = properties.containsKey("test.relative.url") ? System.getProperty("test.relative.url") : ""; this.timeout = properties.containsKey("test.timeout") ? Integer.parseInt(System.getProperty("test.timeout")) : 10; this.acceptCookies = properties.containsKey("test.disable.accept.cookies") ? !Boolean.parseBoolean(System.getProperty("test.disable.accept.cookies")) : true; this.embedScreenshot = properties.containsKey("test.embed.screenshot") ? Boolean.parseBoolean(System.getProperty("test.embed.screenshot")) : true; }
From source file:org.dataconservancy.packaging.tool.cli.AutomatedPackageTool.java
private InputStream createPackageMetadata() { final Properties metadata = new Properties(); if (packageMetadataFile != null) { if (!packageMetadataFile.exists()) { throw new PackageToolException(PackagingToolReturnInfo.CMD_LINE_FILE_NOT_FOUND_EXCEPTION); }/*from w ww . j a va 2 s .co m*/ try (InputStream fileStream = new FileInputStream(packageMetadataFile)) { metadata.load(fileStream); } catch (FileNotFoundException e) { throw new PackageToolException(PackagingToolReturnInfo.CMD_LINE_FILE_NOT_FOUND_EXCEPTION, e); } catch (IOException e) { log.error(e.getMessage()); throw new PackageToolException(PackagingToolReturnInfo.CMD_LINE_FILE_NOT_FOUND_EXCEPTION); } } if (!metadata.containsKey(packageNameKey)) { final List<String> name = packageParams.getParam(packageNameKey); if (name != null && name.size() > 0) { metadata.setProperty(packageNameKey, name.get(name.size() - 1)); } else { metadata.setProperty(packageNameKey, defaultPackageName); } } else if (packageName == null) { packageName = metadata.getProperty(packageNameKey); } else { metadata.setProperty(packageNameKey, packageName); } if (externalID != null) { metadata.setProperty(GeneralParameterNames.EXTERNAL_PROJECT_ID, externalID); } metadata.setProperty(BagItParameterNames.BAGGING_DATE, LocalDate.now().toString()); final ByteArrayOutputStream metaDataOut = new ByteArrayOutputStream(); InputStream metadataStream = null; try { metadata.store(metaDataOut, null); metaDataOut.close(); metadataStream = new ByteArrayInputStream(metaDataOut.toByteArray()); } catch (IOException e) { e.printStackTrace(); } return metadataStream; }