List of usage examples for java.util Properties putAll
@Override public synchronized void putAll(Map<?, ?> t)
From source file:org.apache.sqoop.connector.jdbc.oracle.util.OracleConnectionFactory.java
private static Connection createConnection(String jdbcUrl, String username, String password, Properties additionalProps) throws SQLException { Properties props = new Properties(); if (username != null) { props.put("user", username); }// ww w.j a v a 2s. com if (password != null) { props.put("password", password); } if (additionalProps != null && additionalProps.size() > 0) { props.putAll(additionalProps); } OracleUtilities.checkJavaSecurityEgd(); try { Connection result = DriverManager.getConnection(jdbcUrl, props); result.setAutoCommit(false); return result; } catch (SQLException ex) { String errorMsg = String.format("Unable to obtain a JDBC connection to the URL \"%s\" as user \"%s\": ", jdbcUrl, (username != null) ? username : "[null]"); LOG.error(errorMsg, ex); throw ex; } }
From source file:gobblin.hive.metastore.HiveMetaStoreUtils.java
/** * Returns a Deserializer from HiveRegistrationUnit if present and successfully initialized. Else returns null. *///from w w w . j a va 2s . co m private static Deserializer getDeserializer(HiveRegistrationUnit unit) { Optional<String> serdeClass = unit.getSerDeType(); if (!serdeClass.isPresent()) { return null; } String serde = serdeClass.get(); HiveConf hiveConf = new HiveConf(); Deserializer deserializer; try { deserializer = ReflectionUtils .newInstance(hiveConf.getClassByName(serde).asSubclass(Deserializer.class), hiveConf); } catch (ClassNotFoundException e) { LOG.warn("Serde class " + serde + " not found!", e); return null; } Properties props = new Properties(); props.putAll(unit.getProps().getProperties()); props.putAll(unit.getStorageProps().getProperties()); props.putAll(unit.getSerDeProps().getProperties()); try { SerDeUtils.initializeSerDe(deserializer, hiveConf, props, null); // Temporary check that's needed until Gobblin is upgraded to Hive 1.1.0+, which includes the improved error // handling in AvroSerDe added in HIVE-7868. if (deserializer instanceof AvroSerDe) { try { inVokeDetermineSchemaOrThrowExceptionMethod(props, new Configuration()); } catch (SchemaParseException | InvocationTargetException | NoSuchMethodException | IllegalAccessException e) { LOG.warn("Failed to initialize AvroSerDe."); throw new SerDeException(e); } } } catch (SerDeException e) { LOG.warn("Failed to initialize serde " + serde + " with properties " + props + " for table " + unit.getDbName() + "." + unit.getTableName()); return null; } return deserializer; }
From source file:net.firejack.platform.web.security.x509.KeyUtils.java
public static void setProperties(File properties, File keystore, Map<String, String> append) throws IOException { Properties props = getProperties(properties, keystore); if (properties.exists() || properties.createNewFile()) { props.putAll(append); ByteArrayOutputStream baos = new ByteArrayOutputStream(); props.store(baos, null);/*from ww w.j a va 2 s . c o m*/ InputStream stream = new ByteArrayInputStream(baos.toByteArray()); if (keystore.exists()) { KeyPair keyPair = load(keystore); if (keyPair != null) { try { byte[] decrypt = encrypt(keyPair.getPublic(), baos.toByteArray()); stream = new ByteArrayInputStream(decrypt); } catch (Exception e) { logger.trace(e); } } } FileOutputStream writer = new FileOutputStream(properties); IOUtils.copy(stream, writer); IOUtils.closeQuietly(writer); } }
From source file:control.LoadControler.java
public static List<Carte> loadCartes(String filePath) { File folder = new File(userPath(filePath)); Set<File> fileSet = listFilesForFolder(folder); List<Carte> list = new ArrayList<>(); for (File file : fileSet) { try {/*from w w w.j a v a2s . c om*/ PropertiesReader ppr = new PropertiesReader(file.getCanonicalPath()); Properties properties = ppr.readProperties(); Carte carte = new Carte(); try { carte.setNom(properties.getProperty("nom")); carte.setDx(Integer.parseInt(properties.getProperty("dx"))); carte.setDy(Integer.parseInt(properties.getProperty("dy"))); Properties ppts = new Properties(); ppts.putAll(properties); ppts.remove("nom"); ppts.remove("dx"); ppts.remove("dy"); carte.setProperties(ppts); System.out.println(carte.toString()); //DEBUG list.add(carte); } catch (NumberFormatException e) { e.printStackTrace(); System.out.println("##### Erreur lors de la cration de la carte #####"); JOptionPane.showMessageDialog(null, e); } } catch (IOException ex) { Logger.getLogger(LoadControler.class.getName()).log(Level.SEVERE, null, ex); JOptionPane.showMessageDialog(null, ex); } } return list; }
From source file:org.apache.gobblin.hive.metastore.HiveMetaStoreUtils.java
/** * Returns a Deserializer from HiveRegistrationUnit if present and successfully initialized. Else returns null. *///from w w w. j a v a 2 s . c o m private static Deserializer getDeserializer(HiveRegistrationUnit unit) { Optional<String> serdeClass = unit.getSerDeType(); if (!serdeClass.isPresent()) { return null; } String serde = serdeClass.get(); HiveConf hiveConf; Deserializer deserializer; try { hiveConf = SharedResourcesBrokerFactory.getImplicitBroker().getSharedResource(new HiveConfFactory<>(), SharedHiveConfKey.INSTANCE); deserializer = ReflectionUtils .newInstance(hiveConf.getClassByName(serde).asSubclass(Deserializer.class), hiveConf); } catch (ClassNotFoundException e) { LOG.warn("Serde class " + serde + " not found!", e); return null; } catch (NotConfiguredException nce) { LOG.error("Implicit broker is not configured properly", nce); return null; } Properties props = new Properties(); props.putAll(unit.getProps().getProperties()); props.putAll(unit.getStorageProps().getProperties()); props.putAll(unit.getSerDeProps().getProperties()); try { SerDeUtils.initializeSerDe(deserializer, hiveConf, props, null); // Temporary check that's needed until Gobblin is upgraded to Hive 1.1.0+, which includes the improved error // handling in AvroSerDe added in HIVE-7868. if (deserializer instanceof AvroSerDe) { try { inVokeDetermineSchemaOrThrowExceptionMethod(props, new Configuration()); } catch (SchemaParseException | InvocationTargetException | NoSuchMethodException | IllegalAccessException e) { LOG.warn("Failed to initialize AvroSerDe."); throw new SerDeException(e); } } } catch (SerDeException e) { LOG.warn("Failed to initialize serde " + serde + " with properties " + props + " for table " + unit.getDbName() + "." + unit.getTableName()); return null; } return deserializer; }
From source file:org.cloudfoundry.identity.varz.VarzEndpoint.java
/** * @param properties//from www . j a v a 2 s . c om * @return new properties with no plaintext passwords */ public static Properties hidePasswords(Properties properties) { Properties result = new Properties(); result.putAll(properties); for (String key : properties.stringPropertyNames()) { if (isPassword(key)) { result.put(key, "#"); } } return result; }
From source file:de.hypoport.ep2.support.configuration.properties.PropertiesLoader.java
static Properties loadPropertiesLocations(String propertyLocations) { if (isBlank(propertyLocations)) { return new Properties(); }//w ww.j a va 2 s.c om Properties loadedProperties = new Properties(); for (String location : propertyLocations.split(",")) { try { Properties locationProperties = loadPropertiesFromLocation(location); if (propertyLocationsPresent(locationProperties)) { Properties recursiveLoadedProperties = loadPropertiesLocations( locationProperties.getProperty(PROPERTY_LOCATIONS)); locationProperties.putAll(recursiveLoadedProperties); } loadedProperties.putAll(locationProperties); } catch (IOException e) { LOG.warn(format("Cannot load properties from location %s. Error: %s", location, e.getMessage())); } } return loadedProperties; }
From source file:org.hyperic.hq.hqapi1.tools.AbstractCommand.java
private static void configureLogging(String level) { Properties props = new Properties(); props.setProperty("log4j.rootLogger", level.toUpperCase() + ", R"); props.setProperty("log4j.logger.httpclient.wire", level.toUpperCase()); props.setProperty("log4j.logger.org.apache.commons.httpclient", level.toUpperCase()); for (String[] PROPS : LOG_PROPS) { props.setProperty(PROPS[0], PROPS[1]); }//from w w w . j a v a2 s . c o m props.putAll(System.getProperties()); PropertyConfigurator.configure(props); }
From source file:org.apache.geode.internal.cache.ClusterConfigurationLoader.java
/*** * Apply the gemfire properties cluster configuration on this member * /* w w w.ja v a 2 s . c o m*/ * @param response {@link ConfigurationResponse} containing the requested {@link Configuration} * @param config this member's config */ public static void applyClusterPropertiesConfiguration(ConfigurationResponse response, DistributionConfig config) { if (response == null || response.getRequestedConfiguration().isEmpty()) { return; } List<String> groups = getGroups(config); Map<String, Configuration> requestedConfiguration = response.getRequestedConfiguration(); final Properties runtimeProps = new Properties(); // apply the cluster config first Configuration clusterConfiguration = requestedConfiguration.get(ClusterConfigurationService.CLUSTER_CONFIG); if (clusterConfiguration != null) { runtimeProps.putAll(clusterConfiguration.getGemfireProperties()); } // then apply the group config for (String group : groups) { Configuration groupConfiguration = requestedConfiguration.get(group); if (groupConfiguration != null) { runtimeProps.putAll(groupConfiguration.getGemfireProperties()); } } Set<Object> attNames = runtimeProps.keySet(); for (Object attNameObj : attNames) { String attName = (String) attNameObj; String attValue = runtimeProps.getProperty(attName); try { config.setAttribute(attName, attValue, ConfigSource.runtime()); } catch (IllegalArgumentException e) { logger.info(e.getMessage()); } catch (UnmodifiableException e) { logger.info(e.getMessage()); } } }
From source file:com.dtolabs.rundeck.core.tasks.net.SSHTaskBuilder.java
public static void configureSession(Map<String, String> config, Session session) { Properties newconf = new Properties(); newconf.putAll(config); session.setConfig(newconf);/* www .ja va2 s.c o m*/ }