List of usage examples for java.util Properties putAll
@Override public synchronized void putAll(Map<?, ?> t)
From source file:de.knurt.fam.template.model.ViewSystemConfigurationModelFactory.java
public Properties getProperties(TemplateResource templateResource) { Properties result = new Properties(); result.put("configuration_reloaded", templateResource.configurationReloadIsRequested()); Properties props = new Properties(); props.put("config_dir", FamConnector.getConfigDirectory()); props.putAll(FamConnector.getGlobalProperties()); List<KeyValue> kvs = FamDaoProxy.keyValueDao().getAll(); for (KeyValue kv : kvs) { props.put("kv_" + kv.key(), kv.value()); }/*from ww w.j a v a 2 s . c o m*/ props.put("dao_booking_class", FamDaoProxy.bookingDao().getClass()); props.put("dao_facility_availability_class", FamDaoProxy.facilityDao().getClass()); props.put("dao_logbook_class", FamDaoProxy.logbookEntryDao().getClass()); props.put("dao_user_class", FamDaoProxy.userDao().getClass()); props.put("dao_kv_class", FamDaoProxy.keyValueDao().getClass()); props.put("role_standard", RoleConfigDao.getInstance().getStandardId()); props.put("role_admin", RoleConfigDao.getInstance().getAdminId()); props.put("authentication_module", FamAuth.me().getUserAuthentication().getClass()); // put in cronjobs List<CronjobAction> cronjobs = CronjobActionContainer.getInstance().getAllCronjobActions(); int i = 0; for (CronjobAction cronjob : cronjobs) { props.put(++i + "_cronjob_desc", cronjob.getDescription()); props.put(i + "_cronjob_class", cronjob.getClass()); props.put(i + "_cronjob_every", durationAdapter.getText(cronjob.resolveEvery())); } try { BasicDataSource bds = ((BasicDataSource) RequestContextUtils .getWebApplicationContext(templateResource.getRequest()).getBean("dataSource")); props.put("sql_url", bds.getUrl()); props.put("sql_username", bds.getUsername()); } catch (Exception e) { props.put("sql_ERROR", e.getMessage()); } props.put("password_encoding_algorithm", FamEncoder.getInstance().getEncoder().getAlgorithm()); boolean couchdb_test_query_succ = false; try { props.put("couchdb_real_name", FamCouchDBDao.getInstance().databaseName()); props.put("couchdb_document_count", FamCouchDBDao.getInstance().documentCount()); couchdb_test_query_succ = true; } catch (Exception e) { } props.put("couchdb_test_query_succ", couchdb_test_query_succ); result.put("props", props); return result; }
From source file:edu.si.services.fits.itest.UCT_FITS_IT.java
@Override protected String setConfigAdminInitialConfiguration(Properties configAdmin) { configAdmin.putAll(extra); return "edu.si.sidora.karaf"; }
From source file:ws.salient.aws.dynamodb.DynamoDBProfiles.java
private Settings getSettings(String accountId) { return accounts.computeIfAbsent(accountId, (id) -> { Settings settings = new Settings(); ItemCollection<QueryOutcome> items = dynamodb.getTable("SalientProfile") .query(new QuerySpec().withHashKey("accountId", id)); items.pages().forEach((page) -> { page.iterator().forEachRemaining((item) -> { try { Profile profile = new Profile(); if (item.hasAttribute("aliases")) { profile.setAliases(json.readValue(item.getJSON("aliases"), Map.class)); }//www. j a v a2 s. c o m if (item.hasAttribute("properties")) { if (item.get("properties") instanceof byte[]) { log.info("Decrypt profile " + item.getString("profileName")); DecryptResult decrypt = kms.decrypt( new DecryptRequest().addEncryptionContextEntry("accountId", accountId) .withCiphertextBlob(ByteBuffer.wrap(item.getBinary("properties")))); profile.setProperties( json.readValue(decrypt.getPlaintext().array(), Properties.class)); } else { Properties properties = new Properties(); properties.putAll(item.getMap("properties")); profile.setProperties(properties); } } if (item.hasAttribute("repositories")) { profile.setRepositories(json.readValue(item.getJSON("repositories"), json.getTypeFactory().constructCollectionType(Set.class, Repository.class))); } String name = item.getString("profileName"); Boolean active = item.getBoolean("active"); settings.withProfile(name, profile); if (active) { settings.withActiveProfile(name); } } catch (IOException ex) { throw new RuntimeException(ex); } }); }); return settings; }); }
From source file:org.apache.falcon.oozie.ImportWorkflowBuilder.java
@Override public Properties build(Cluster cluster, Path buildPath) throws FalconException { WORKFLOWAPP workflow = new WORKFLOWAPP(); String wfName = EntityUtil.getWorkflowName(Tag.IMPORT, entity).toString(); workflow.setName(wfName);/*from ww w . j ava 2 s. c om*/ Properties p = getWorkflow(cluster, workflow); marshal(cluster, workflow, buildPath); Properties props = FeedHelper.getFeedProperties(entity); if (props == null) { props = new Properties(); } props.putAll(getProperties(buildPath, wfName)); if (createDefaultConfiguration(cluster) != null) { props.putAll(createDefaultConfiguration(cluster)); } if (FeedHelper.getUserWorkflowProperties(getLifecycle()) != null) { props.putAll(FeedHelper.getUserWorkflowProperties(getLifecycle())); } props.put(WorkflowExecutionArgs.OUTPUT_FEED_NAMES.getName(), entity.getName()); props.put(WorkflowExecutionArgs.OUTPUT_FEED_PATHS.getName(), String.format("${coord:dataOut('%s')}", FeedImportCoordinatorBuilder.IMPORT_DATAOUT_NAME)); props.put(WorkflowExecutionArgs.INPUT_FEED_NAMES.getName(), NONE); props.put(WorkflowExecutionArgs.INPUT_FEED_PATHS.getName(), NONE); props.setProperty("srcClusterName", "NA"); props.put(WorkflowExecutionArgs.CLUSTER_NAME.getName(), cluster.getName()); if (StringUtils .isEmpty(FeedHelper.getImportDatasourceName(FeedHelper.getCluster(entity, cluster.getName())))) { throw new FalconException("Datasource name is null or empty"); } props.put(WorkflowExecutionArgs.DATASOURCE_NAME.getName(), FeedHelper.getImportDatasourceName(FeedHelper.getCluster(entity, cluster.getName()))); props.putAll(p); return props; }
From source file:com.flipkart.aesop.runtime.bootstrap.BlockingBootstrapServerFactory.java
@Override public BlockingBootstrapServer getObject() throws Exception { /* HTTP RELAY */ HttpRelay.Config httpConfig = new HttpRelay.Config(); ConfigLoader<HttpRelay.StaticConfig> staticConfigLoader = new ConfigLoader<HttpRelay.StaticConfig>( BootstrapConfig.BOOTSTRAP_PROPERTIES_PREFIX, httpConfig); //Making this a list to initialise each producer seperately with initial SCN HttpRelay.StaticConfig[] staticConfigList = new HttpRelay.StaticConfig[this.producerRegistrationList .size()];//from www. j a va 2 s . c o m PhysicalSourceStaticConfig[] pStaticConfigs = new PhysicalSourceStaticConfig[this.producerRegistrationList .size()]; /* SCHEMA REGISTRY */ FileSystemSchemaRegistryService.Config configBuilder = new FileSystemSchemaRegistryService.Config(); configBuilder.setFallbackToResources(true); configBuilder.setSchemaDir(this.bootstrapConfig.getSchemaRegistryLocation()); FileSystemSchemaRegistryService.StaticConfig schemaRegistryServiceConfig = configBuilder.build(); FileSystemSchemaRegistryService schemaRegistryService = FileSystemSchemaRegistryService .build(schemaRegistryServiceConfig); /* MAX SCN READER WRITER */ for (int i = 0; i < this.producerRegistrationList.size(); i++) { //Get Properties from Relay Config Properties mergedProperties = new Properties(); mergedProperties.putAll(this.bootstrapConfig.getBootstrapProperties()); // Obtain Properties from Product Registration if it exists if (producerRegistrationList.get(i).getProperties() != null) { mergedProperties.putAll(producerRegistrationList.get(i).getProperties()); } staticConfigList[i] = staticConfigLoader.loadConfig(mergedProperties); pStaticConfigs[i] = this.producerRegistrationList.get(i).getPhysicalSourceConfig().build(); } /* Setting relevant details into the Blocking Event Producer */ BlockingBootstrapServer bootstrapServer = new BlockingBootstrapServer(staticConfigList[0], pStaticConfigs, SourceIdNameRegistry.createFromIdNamePairs(staticConfigList[0].getSourceIds()), schemaRegistryService); int i = 0; for (ProducerRegistration producerRegistration : this.producerRegistrationList) { EventProducer producer = producerRegistration.getEventProducer(); if (BlockingEventProducer.class.isAssignableFrom(producer.getClass())) { BlockingEventProducer blockingEventProducer = ((BlockingEventProducer) producer); blockingEventProducer.registerConsumer(consumer); blockingEventProducer.setPhysicalSourceConfig(producerRegistration.getPhysicalSourceConfig()); blockingEventProducer.setSchemaRegistryService(schemaRegistryService); /* Setting Http Config Source Name */ for (LogicalSourceConfig logicalSourceConfig : producerRegistration.getPhysicalSourceConfig() .getSources()) { httpConfig.setSourceName(String.valueOf(logicalSourceConfig.getId()), logicalSourceConfig.getName()); } blockingEventProducer .setDbusEventsStatisticsCollector(bootstrapServer.getInboundEventStatisticsCollector()); blockingEventProducer.registerMetricsCollector(bootstrapServer.getMetricsCollector()); } } bootstrapServer.registerConsumer(consumer); bootstrapServer.setProducerRegistrationList(producerRegistrationList); return bootstrapServer; }
From source file:org.apache.falcon.oozie.ExportWorkflowBuilder.java
@Override public Properties build(Cluster cluster, Path buildPath) throws FalconException { WORKFLOWAPP workflow = new WORKFLOWAPP(); String wfName = EntityUtil.getWorkflowName(Tag.EXPORT, entity).toString(); workflow.setName(wfName);/*from ww w. j a va 2 s .co m*/ Properties p = getWorkflow(cluster, workflow, buildPath); marshal(cluster, workflow, buildPath); Properties props = FeedHelper.getFeedProperties(entity); if (props == null) { props = new Properties(); } props.putAll(getProperties(buildPath, wfName)); if (createDefaultConfiguration(cluster) != null) { props.putAll(createDefaultConfiguration(cluster)); } if (FeedHelper.getUserWorkflowProperties(getLifecycle()) != null) { props.putAll(FeedHelper.getUserWorkflowProperties(getLifecycle())); } props.put(WorkflowExecutionArgs.OUTPUT_FEED_NAMES.getName(), NONE); props.put(WorkflowExecutionArgs.OUTPUT_FEED_PATHS.getName(), NONE); props.put(WorkflowExecutionArgs.INPUT_FEED_NAMES.getName(), entity.getName()); props.put(WorkflowExecutionArgs.INPUT_FEED_PATHS.getName(), String.format("${coord:dataIn('%s')}", FeedExportCoordinatorBuilder.EXPORT_DATAIN_NAME)); props.setProperty("srcClusterName", "NA"); props.put(WorkflowExecutionArgs.CLUSTER_NAME.getName(), cluster.getName()); if (StringUtils .isEmpty(FeedHelper.getExportDatasourceName(FeedHelper.getCluster(entity, cluster.getName())))) { throw new FalconException("Datasource name is null or empty"); } props.put(WorkflowExecutionArgs.DATASOURCE_NAME.getName(), FeedHelper.getExportDatasourceName(FeedHelper.getCluster(entity, cluster.getName()))); props.putAll(p); return props; }
From source file:com.thoughtworks.acceptance.EncodingTestSuite.java
private void addDriverTest(final HierarchicalStreamDriver driver) { final String testName = getShortName(driver); final String allEncodingTests = System.getProperty("xstream.test.encoding.all"); if ("true".equals(allEncodingTests)) { // Native encoding normally fails on most systems!! addTest(new TestCase(testName + "Native") { @Override//from w ww . j a v a 2 s . com protected void runTest() throws Throwable { test(driver, null); } }); // System encoding fails on US-ASCII systems, like Codehaus Bamboo final String systemEncoding = System.getProperty("file.encoding"); addTest(new TestCase(testName + "With" + systemEncoding + "SystemEncoding") { @Override protected void runTest() throws Throwable { final Properties systemProperties = new Properties(); systemProperties.putAll(System.getProperties()); try { // Use BEA reference implementation for StAX // (Woodstox will fail on Windows because of unknown system encoding) System.setProperty(XMLInputFactory.class.getName(), MXParserFactory.class.getName()); test(driver, systemEncoding); } finally { System.setProperties(systemProperties); } } }); } addTest(new TestCase(testName + "WithUTF_8Encoding") { @Override protected void runTest() throws Throwable { test(driver, "UTF-8"); } }); addTest(new TestCase(testName + "WithIS0_8859_1Encoding") { @Override protected void runTest() throws Throwable { test(driver, "ISO-8859-1"); } }); }
From source file:com.mgmtp.jfunk.core.mail.EmailModule.java
@Provides @StoreSession/*from ww w . j a v a 2 s . com*/ Properties provideStoreSession(final Configuration config) throws GeneralSecurityException { String protocol = checkNotNull(config.get(MAIL_STORE_PROTOCOL), "Property %s not configured.", MAIL_STORE_PROTOCOL); Properties sessionProps = new Properties(); sessionProps.putAll(filterKeys(config, contains('.' + protocol + '.'))); sessionProps.setProperty(MAIL_DEBUG, config.get(MAIL_DEBUG, "false")); sessionProps.setProperty(MAIL_STORE_PROTOCOL, protocol); if (config.getBoolean(MAIL_SSL_TRUST)) { MailSSLSocketFactory socketFactory = new MailSSLSocketFactory(); socketFactory.setTrustAllHosts(true); sessionProps.put("mail." + protocol + ".ssl.socketFactory", socketFactory); } return sessionProps; }
From source file:org.wso2.msf4j.spring.property.YamlFileApplicationContextInitializer.java
@Override public void initialize(ConfigurableApplicationContext applicationContext) { Resource resource = applicationContext.getResource("classpath:" + YAML_CONFIG_FILE_NAME); if (!resource.exists()) { resource = applicationContext.getResource("file:" + YAML_CONFIG_FILE_NAME); }/* ww w . j a va 2s . c om*/ if (resource.exists()) { List<Properties> applicationYmlProperties = new ArrayList<>(); String[] activeProfileNames = null; try (InputStream input = resource.getInputStream()) { Yaml yml = new Yaml(new SafeConstructor()); Iterable<Object> objects = yml.loadAll(input); for (Object obj : objects) { Map<String, Object> flattenedMap = getFlattenedMap(asMap(obj)); Properties properties = new Properties(); properties.putAll(flattenedMap); Object activeProfile = properties.get("spring.profiles.active"); if (activeProfile != null) { activeProfileNames = activeProfile.toString().split(","); } applicationYmlProperties.add(properties); } } catch (FileNotFoundException e) { throw new RuntimeException("Couldn't find " + YAML_CONFIG_FILE_NAME, e); } catch (IOException e) { throw new RuntimeException("Error while reading " + YAML_CONFIG_FILE_NAME, e); } if (activeProfileNames == null) { activeProfileNames = applicationContext.getEnvironment().getActiveProfiles(); } for (Properties properties : applicationYmlProperties) { String profile = properties.getProperty("spring.profiles"); PropertySource<?> propertySource; if (profile == null) { propertySource = new MapPropertySource(YAML_CONFIG_FILE_NAME, new HashMap(properties)); applicationContext.getEnvironment().getPropertySources().addLast(propertySource); } else if (activeProfileNames != null && ("default".equals(profile) || (activeProfileNames.length == 1 && activeProfileNames[0].equals(profile)))) { propertySource = new MapPropertySource(YAML_CONFIG_FILE_NAME + "[" + profile + "]", new HashMap(properties)); applicationContext.getEnvironment().getPropertySources().addAfter("systemEnvironment", propertySource); } activeProfileNames = applicationContext.getEnvironment().getActiveProfiles(); } } applicationContext.getEnvironment().getActiveProfiles(); }
From source file:com.mgmtp.jfunk.core.mail.EmailModule.java
@Provides @TransportSession//from www . j a v a 2 s .com Session provideTransportSession(final Configuration config) throws GeneralSecurityException { String protocol = checkNotNull(config.get(MAIL_TRANSPORT_PROTOCOL), "Property %s not configured.", MAIL_TRANSPORT_PROTOCOL); Properties sessionProps = new Properties(); sessionProps.putAll(filterKeys(config, contains('.' + protocol + '.'))); sessionProps.setProperty(MAIL_DEBUG, config.get(MAIL_DEBUG, "false")); sessionProps.setProperty(MAIL_TRANSPORT_PROTOCOL, protocol); String user = config.get("mail." + protocol + ".user"); String password = config.get("mail." + protocol + ".password"); if (config.getBoolean("mail.ssl.trust")) { MailSSLSocketFactory socketFactory = new MailSSLSocketFactory(); socketFactory.setTrustAllHosts(true); sessionProps.put("mail." + protocol + ".ssl.socketFactory", socketFactory); } return !isNullOrEmpty(user) && !isNullOrEmpty(password) ? Session.getInstance(sessionProps, new MailAuthenticator(user, password)) : Session.getInstance(sessionProps); }