List of usage examples for java.util Properties getProperty
public String getProperty(String key)
From source file:org.n52.sos.web.JdbcUrl.java
private static String toURI(Properties p) { StringBuilder sb = new StringBuilder(); sb.append(p.getProperty(DefaultHibernateConstants.CONNECTION_STRING_PROPERTY)); sb.append(QUERSTIONMARK_CHAR).append(QUERY_PARAMETER_USER).append(EQUAL_SIGN_CHAR) .append(p.getProperty(DefaultHibernateConstants.USER_PROPERTY)); sb.append(AMPERSAND_CHAR).append(QUERY_PARAMETER_PASSWORD).append(EQUAL_SIGN_CHAR) .append(p.getProperty(DefaultHibernateConstants.PASS_PROPERTY)); return sb.toString(); }
From source file:com.redhat.poc.jdg.bankofchina.function.TestCase412RemoteMultiThreads.java
public static String jdgProperty(String name) { Properties props = new Properties(); try {/*from w w w. ja v a 2 s . c o m*/ props.load(TestCase412RemoteMultiThreads.class.getClassLoader().getResourceAsStream(PROPERTIES_FILE)); } catch (IOException ioe) { throw new RuntimeException(ioe); } return props.getProperty(name); }
From source file:de.pawlidi.openaletheia.utils.PropertiesUtils.java
public static String getStringProperty(Properties properties, final String key) { if (PropertiesUtils.isEmpty(properties) || StringUtils.isBlank(key)) { return null; }//from w ww .j a va 2s . c o m return properties.getProperty(key); }
From source file:org.jclouds.demo.tweetstore.config.SpringServletConfig.java
private static Iterable<String> getBlobstoreContexts(Properties props) { Set<String> contexts = new CredentialsCollector().apply(props).keySet(); String explicitContexts = props.getProperty(PROPERTY_TWEETSTORE_BLOBSTORES); if (explicitContexts != null) { contexts = filter(contexts, in(copyOf(Splitter.on(',').split(explicitContexts)))); }/*from w w w. ja v a 2s. co m*/ checkState(!contexts.isEmpty(), "no credentials available for any requested context"); return contexts; }
From source file:org.eclipse.lyo.testsuite.server.trsutils.FetchUtil.java
/** * This method uses the username and password specified in config.properties * to attempt basic authentication against a resource server. * /*from ww w .j a v a 2 s.c om*/ * @param httpClient * @param httpContext * @param get * @param uri * @return * @throws FileNotFoundException * @throws IOException */ private static Model performBasicAuthentication(HttpClient httpClient, HttpContext httpContext, HttpGet get, String uri) throws FileNotFoundException, IOException { // Obtain the username and password from the config.properties file Properties prop = TestCore.getConfigPropertiesInstance(); String username = prop.getProperty("username"); String password = prop.getProperty("password"); // Construct the authentication header by using Base64 encoding on the // supplied username and password String authString = username + ":" + password; authString = new String(Base64.encode(authString.getBytes(HttpConstants.DEFAULT_ENCODING))); authString = "Basic " + authString; get.setHeader("Authorization", authString); get.setHeader("OSLC-Core-Version", "2.0"); Model model = null; try { model = httpClient.execute(get, new RDFModelResponseHandler(uri), httpContext); } catch (Exception e) { TestCore.terminateTest(Messages.getServerString("fetch.util.authentication.failure"), e); } return model; }
From source file:com.redhat.poc.jdg.bankofchina.performance.TestCase531RemoteMultiThreads.java
public static String jdgProperty(String name) { Properties props = new Properties(); try {//from ww w .j a v a 2 s . co m props.load(TestCase531RemoteMultiThreads.class.getClassLoader().getResourceAsStream(PROPERTIES_FILE)); } catch (IOException ioe) { throw new RuntimeException(ioe); } return props.getProperty(name); }
From source file:Main.java
public static String getCurrentProject() { try {//from w w w .j a v a 2 s .c o m String value = ""; Properties properties = new Properties(); FileInputStream inputFile = new FileInputStream(System.getProperty("user.dir") + "/system.properties"); properties.load(inputFile); inputFile.close(); if (properties.containsKey("ProjectPath")) { value = properties.getProperty("ProjectPath"); String resultName = new String(value.getBytes("ISO-8859-1"), "gbk"); return resultName; } else return value; } catch (FileNotFoundException e) { e.printStackTrace(); return ""; } catch (IOException e) { e.printStackTrace(); return ""; } catch (Exception ex) { ex.printStackTrace(); return ""; } }
From source file:com.jaspersoft.jasperserver.jaxrs.client.core.RestClientConfiguration.java
public static RestClientConfiguration loadConfiguration(String path) { Properties properties = loadProperties(path); RestClientConfiguration configuration = new RestClientConfiguration(); configuration.setJasperReportsServerUrl(properties.getProperty("url")); String connectionTimeout = properties.getProperty("connectionTimeout"); if (connectionTimeout != null && !connectionTimeout.equals("")) configuration.setConnectionTimeout(Integer.valueOf(connectionTimeout)); String readTimeout = properties.getProperty("readTimeout"); if (readTimeout != null && !readTimeout.equals("")) configuration.setConnectionTimeout(Integer.valueOf(readTimeout)); try {//w w w . j a v a 2 s. co m configuration.setContentMimeType(MimeType.valueOf(properties.getProperty("contentMimeType"))); } catch (Exception e) { log.info("There is no mime type for content type or it isn't supported.", e); } try { configuration.setAcceptMimeType(MimeType.valueOf(properties.getProperty("acceptMimeType"))); } catch (Exception e) { log.info("There is no mime type for accept type or it isn't supported.", e); } return configuration; }
From source file:com.redhat.poc.jdg.bankofchina.performance.TestCase532RemoteMultiThreads.java
public static String jdgProperty(String name) { Properties props = new Properties(); try {/*from w ww . java2 s. co m*/ props.load(TestCase532RemoteMultiThreads.class.getClassLoader().getResourceAsStream(PROPERTIES_FILE)); } catch (IOException ioe) { throw new RuntimeException(ioe); } return props.getProperty(name); }
From source file:com.googlecode.fascinator.messaging.ConveyerBelt.java
/** * Find out what transformers are required to run for a particular render * step.//from w ww .j a v a2 s . co m * * @param object The digital object to transform. * @param config The configuration for the particular harvester. * @param thisType The type of render chain (step). * @param routing Flag if query is for routing. Set this value will force a * check for user priority, and then clear the flag if found. * @return List<String> A list of names for instantiated transformers. */ public static List<String> getTransformList(DigitalObject object, JsonSimpleConfig config, String thisType, boolean routing) throws StorageException { List<String> plugins = new ArrayList<String>(); Properties props = object.getMetadata(); // User initiated event if (routing) { String user = props.getProperty("userPriority"); if (user != null && user.equals("true")) { log.info("User priority flag set: '{}'", object.getId()); plugins.add(CRITICAL_USER_SELECTOR); props.remove("userPriority"); object.close(); } } // Property data, highest priority String pluginList = props.getProperty(thisType); if (pluginList != null) { // Turn the string into a real list for (String plugin : StringUtils.split(pluginList, ",")) { plugins.add(StringUtils.trim(plugin)); } } else { // The harvester specified none, fallback to the // default list for this harvest source. List<String> transformerList = config.getStringList("transformer", thisType); if (transformerList != null) { for (String entry : transformerList) { plugins.add(StringUtils.trim(entry)); } } else { log.info("No transformers configured!"); } } return plugins; }