List of usage examples for java.util Properties get
@Override
public Object get(Object key)
From source file:com.googlecode.fascinator.portal.security.FascinatorWebSecurityExpressionRoot.java
private boolean isPublished(Properties tfObjMeta) { if ("true".equals(tfObjMeta.get("published"))) { return true; }// w w w . j a v a2s . com return false; }
From source file:org.ambraproject.migration.BootstrapMigratorServiceImpl.java
/** * Get the current version of the binaries * <p/>/*from w w w. ja v a 2 s. c o m*/ * Assumptions about the version number: * Only contains single-digit integers between dots (e.g., 2.2.1.6.9.3) * * @return binary version * @throws IOException when the class loader fails */ private void setBinaryVersion() throws IOException { InputStream is = BootstrapMigratorServiceImpl.class.getResourceAsStream("version.properties"); Properties prop = new Properties(); prop.load(is); String sVersion = (String) prop.get("version"); if (sVersion.indexOf("-SNAPSHOT") > 0) { sVersion = sVersion.substring(0, sVersion.indexOf("-SNAPSHOT")); this.isSnapshot = true; } Double dVersion; // If the version has multiple dots, then it cannot be directly parsed as a Double. String[] versionArray = sVersion.split("\\."); if (versionArray.length < 3) { // example version numbers: 2 and 2.2 and 2.46 and 3.65 dVersion = Double.parseDouble(sVersion) * 100; // 200 220 246 365 } else { // example version numbers: 2.1.1 and 2.2.5.3 and dVersion = Double.parseDouble(versionArray[0] + "." + versionArray[1]) * 100; for (int i = 2; i < versionArray.length; i++) { dVersion = dVersion + Math.pow((new Double(versionArray[i])).doubleValue(), (new Double(1 - i)).doubleValue()); } } this.binaryVersion = dVersion.intValue(); }
From source file:com.reversemind.hypergate.server.PayloadProcessor.java
private Hashtable getJndiProperties(Properties jndi) { Set set = jndi.keySet();//from www . j a v a2 s . co m Hashtable localTable = new Hashtable(); for (Object key : set) { localTable.put(key, jndi.get(key)); } return localTable; }
From source file:com.wallabystreet.kinjo.common.transport.protocol.jxta.Transport.java
public Properties getServiceRelatedProperties(final String serviceName, final String servicePackage) { Properties p = new Properties(); String path = null;//from w w w . j a v a2s. c o m path = servicePackage.replace('.', '/') + "/" + serviceName + ".mcadv"; ModuleClassAdvertisement mcadv = (ModuleClassAdvertisement) this.loadFromXML(path); p.put("transport.jxta.adv.mc", mcadv); log.debug("module class advertisement loaded successfully"); path = servicePackage.replace('.', '/') + "/" + serviceName + ".msadv"; ModuleSpecAdvertisement msadv = (ModuleSpecAdvertisement) this.loadFromXML(path); p.put("transport.jxta.adv.ms", msadv); log.debug("module spec advertisement loaded successfully"); Properties pp = new Properties(); path = servicePackage.replace('.', '/') + "/" + serviceName + ".pipe"; try { pp.load(ClassLoader.getSystemResourceAsStream(path)); } catch (IOException e) { // TODO Auto-generated catch block e.printStackTrace(); } p.put("transport.jxta.pipe.name", pp.get("PipeName")); p.put("transport.jxta.pipe.desc", pp.get("PipeDesc")); p.put("transport.jxta.pipe.type", pp.get("PipeType")); log.debug("transport properties loaded successfully"); return p; }
From source file:com.clearspring.metriccatcher.Loader.java
/** * Load properties, build a MetricCatcher, start catching * * @param propertiesFile The config file * @throws IOException if the properties file cannot be read */// ww w . j av a 2 s .com public Loader(File propertiesFile) throws IOException { logger.info("Starting metriccatcher"); logger.info("Loading configuration from: " + propertiesFile.getAbsolutePath()); Properties properties = new Properties(); try { properties.load(new FileReader(propertiesFile)); for (Object key : properties.keySet()) { // copy properties into system properties System.setProperty((String) key, (String) properties.get(key)); } } catch (IOException e) { logger.error("error reading properties file: " + e); System.exit(1); } int reportingInterval = 60; String intervalProperty = properties.getProperty(METRICCATCHER_INTERVAL); if (intervalProperty != null) { try { reportingInterval = Integer.parseInt(intervalProperty); } catch (NumberFormatException e) { logger.warn("Couldn't parse " + METRICCATCHER_INTERVAL + " setting", e); } } boolean disableJvmMetrics = false; String disableJvmProperty = properties.getProperty(METRICCATCHER_DISABLE_JVM_METRICS); if (disableJvmProperty != null) { disableJvmMetrics = BooleanUtils.toBoolean(disableJvmProperty); if (disableJvmMetrics) { logger.info("Disabling JVM metric reporting"); } } boolean reportingEnabled = false; // Start a Ganglia reporter if specified in the config String gangliaHost = properties.getProperty(METRICCATCHER_GANGLIA_HOST); String gangliaPort = properties.getProperty(METRICCATCHER_GANGLIA_PORT); if (gangliaHost != null && gangliaPort != null) { logger.info("Creating Ganglia reporter pointed at " + gangliaHost + ":" + gangliaPort); GangliaReporter gangliaReporter = new GangliaReporter(gangliaHost, Integer.parseInt(gangliaPort)); gangliaReporter.printVMMetrics = !disableJvmMetrics; gangliaReporter.start(reportingInterval, TimeUnit.SECONDS); reportingEnabled = true; } // Start a Graphite reporter if specified in the config String graphiteHost = properties.getProperty(METRICCATCHER_GRAPHITE_HOST); String graphitePort = properties.getProperty(METRICCATCHER_GRAPHITE_PORT); if (graphiteHost != null && graphitePort != null) { String graphitePrefix = properties.getProperty(METRICCATCHER_GRAPHITE_PREFIX); if (graphitePrefix == null) { graphitePrefix = InetAddress.getLocalHost().getHostName(); } logger.info("Creating Graphite reporter pointed at " + graphiteHost + ":" + graphitePort + " with prefix '" + graphitePrefix + "'"); GraphiteReporter graphiteReporter = new GraphiteReporter(graphiteHost, Integer.parseInt(graphitePort), StringUtils.trimToNull(graphitePrefix)); graphiteReporter.printVMMetrics = !disableJvmMetrics; graphiteReporter.start(reportingInterval, TimeUnit.SECONDS); reportingEnabled = true; } String reporterConfigFile = properties.getProperty(METRICCATCHER_REPORTER_CONFIG); if (reporterConfigFile != null) { logger.info("Trying to load reporterConfig from file: {}", reporterConfigFile); try { ReporterConfig.loadFromFileAndValidate(reporterConfigFile).enableAll(); } catch (Exception e) { logger.error("Failed to load metrics-reporter-config, metric sinks will not be activated", e); } reportingEnabled = true; } if (!reportingEnabled) { logger.error("No reporters enabled. MetricCatcher can not do it's job"); throw new RuntimeException("No reporters enabled"); } int maxMetrics = Integer.parseInt(properties.getProperty(METRICCATCHER_MAX_METRICS, "500")); logger.info("Max metrics: " + maxMetrics); Map<String, Metric> lruMap = new LRUMap<String, Metric>(10, maxMetrics); int port = Integer.parseInt(properties.getProperty(METRICCATCHER_UDP_PORT, "1420")); logger.info("Listening on UDP port " + port); DatagramSocket socket = new DatagramSocket(port); metricCatcher = new MetricCatcher(socket, lruMap); metricCatcher.start(); // Register a shutdown hook and wait for termination Runtime.getRuntime().addShutdownHook(new Thread() { @Override public void run() { shutdown(); }; }); }
From source file:com.ephesoft.dcma.mail.service.MailServiceImpl.java
/** * API to Set socket factory class according to the SSL or NON-SSL option selected by user. *///from w ww. j av a2s. co m private void setMailProperties() { Properties mailProperties = mailSender.getJavaMailProperties(); String sslEnabled = (String) mailProperties.get(MailConstants.MAIL_SMTP_SSL_PROPERTY); if (!EphesoftStringUtil.isNullOrEmpty(sslEnabled) && sslEnabled.equalsIgnoreCase(MailConstants.TRUE)) { mailProperties.setProperty(MailConstants.MAIL_SOCKET_PROPERTY, MailConstants.MAIL_SOCKET_CLASS); } }
From source file:edu.amc.sakai.user.SimpleLdapCandidateAttributeMapper.java
/** * Straightforward {@link LdapUserData} to * {@link org.sakaiproject.user.api.UserEdit} field-to-field mapping, including * properties.//from ww w . j a v a2 s . co m */ public void mapUserDataOntoUserEdit(LdapUserData userData, UserEdit userEdit) { Properties userDataProperties = userData.getProperties(); ResourceProperties userEditProperties = userEdit.getProperties(); if (userDataProperties != null) { Object o_prop = userDataProperties.get(AttributeMappingConstants.CANDIDATE_ID_ATTR_MAPPING_KEY); if (o_prop != null) { if (o_prop instanceof String) { userEditProperties.addProperty(USER_PROP_CANDIDATE_ID, encryption.encrypt((String) o_prop, candidateIdLength)); } else if (o_prop instanceof List) { Set<String> propertySet = new HashSet<String>(); //remove duplicate values for (String value : (List<String>) o_prop) { propertySet.add(value); } //add candidate ID, if there is only one value if (propertySet.size() == 1) { for (String value : propertySet) { userEditProperties.addProperty(USER_PROP_CANDIDATE_ID, encryption.encrypt(value, candidateIdLength)); } } } userDataProperties.remove(AttributeMappingConstants.CANDIDATE_ID_ATTR_MAPPING_KEY); } o_prop = userDataProperties.get(AttributeMappingConstants.ADDITIONAL_INFO_ATTR_MAPPING_KEY); if (o_prop != null) { if (o_prop instanceof String) { userEditProperties.addPropertyToList(USER_PROP_ADDITIONAL_INFO, encryption.encrypt((String) o_prop, additionalInfoLength)); } else if (o_prop instanceof List) { List<String> propertyList = new ArrayList<String>(); //remove duplicate values (maintain order) for (String value : (List<String>) o_prop) { if (!propertyList.contains(value)) propertyList.add(value); } for (String value : propertyList) { userEditProperties.addPropertyToList(USER_PROP_ADDITIONAL_INFO, encryption.encrypt(value, additionalInfoLength)); } } userDataProperties.remove(AttributeMappingConstants.ADDITIONAL_INFO_ATTR_MAPPING_KEY); } o_prop = userDataProperties.get(AttributeMappingConstants.STUDENT_NUMBER_ATTR_MAPPING_KEY); if (o_prop != null) { if (o_prop instanceof String) { addStudentNumberProperty((String) o_prop, userEditProperties); } else if (o_prop instanceof List) { Set<String> propertySet = new HashSet<>(); //remove duplicate values for (String value : (List<String>) o_prop) { propertySet.add(value); } //add student number, if there is only one value if (propertySet.size() == 1) { for (String value : propertySet) { addStudentNumberProperty(value, userEditProperties); } } } userDataProperties.remove(AttributeMappingConstants.STUDENT_NUMBER_ATTR_MAPPING_KEY); } // Make sure we have a value for the encrypted properties. if (StringUtils.isEmpty(userEditProperties.getProperty(USER_PROP_CANDIDATE_ID))) { userEditProperties.addProperty(USER_PROP_CANDIDATE_ID, encryption.encrypt(EMPTY, candidateIdLength)); } if (userEditProperties.getPropertyList(USER_PROP_ADDITIONAL_INFO) != null && userEditProperties.getPropertyList(USER_PROP_ADDITIONAL_INFO).isEmpty()) { userEditProperties.addPropertyToList(USER_PROP_ADDITIONAL_INFO, encryption.encrypt(EMPTY, additionalInfoLength)); } if (userEditProperties.getPropertyList(USER_PROP_STUDENT_NUMBER) != null && userEditProperties.getPropertyList(USER_PROP_STUDENT_NUMBER).isEmpty()) { addStudentNumberProperty(EMPTY, userEditProperties); } super.mapUserDataOntoUserEdit(userData, userEdit); } }
From source file:org.sonar.runner.Main.java
private int executeTask() { Stats stats = new Stats().start(); try {//from www . j a v a 2 s.com if (cli.isDisplayStackTrace()) { Logs.info("Error stacktraces are turned on."); } runnerFactory.create(conf.properties()).execute(); } catch (Exception e) { displayExecutionResult(stats, "FAILURE"); showError("Error during Sonar runner execution", e, cli.isDisplayStackTrace()); return Exit.ERROR; } // add permission to buildUserId try { String buildUserId = System.getProperty("build.user.id"); Properties props = conf.properties(); String login = props.getProperty("sonar.login"); String hostUrl = (String) props.get("sonar.host.url"); Map<String, String> env = System.getenv(); String password = SonarContext.getInstance(props).getSonarPassword(); String project_key = props.getProperty("sonar.projectKey"); String command; Process proc; BufferedReader reader; String line = ""; //String tid = (new Long(Thread.currentThread())).toString(); String tid = String.valueOf(Thread.currentThread().getId()); String cookie = "cookie-" + Long.toString(new SecureRandom().nextLong()); // login HttpPost httpRequest; ArrayList<BasicNameValuePair> postParameters = new ArrayList<BasicNameValuePair>(); String reqUrl = URIUtils.extractHost(new URI(hostUrl)).toString() + "/dologin"; httpRequest = new HttpPost(reqUrl); postParameters.clear(); postParameters.add(new BasicNameValuePair("username", login)); postParameters.add(new BasicNameValuePair("password", password)); httpRequest.setEntity(new UrlEncodedFormEntity(postParameters)); doRequest(httpRequest); Logs.info("Login succeed"); //user permission remove anyone reqUrl = hostUrl + "/api/permissions/remove"; //permission=user&group=anyone&component=" + project_key ; httpRequest = new HttpPost(reqUrl); postParameters.clear(); postParameters.add(new BasicNameValuePair("permission", "user")); postParameters.add(new BasicNameValuePair("group", "anyone")); postParameters.add(new BasicNameValuePair("component", project_key)); httpRequest.setEntity(new UrlEncodedFormEntity(postParameters)); doRequest(httpRequest); Logs.info("Removed permission 'user' from group anyone"); //user permission to sonar-users reqUrl = hostUrl + "/api/permissions/add"; //?permission=user&group=sonar-users&component=" + project_key; httpRequest = new HttpPost(reqUrl); postParameters.clear(); postParameters.add(new BasicNameValuePair("permission", "user")); postParameters.add(new BasicNameValuePair("group", "sonar-users")); postParameters.add(new BasicNameValuePair("component", project_key)); httpRequest.setEntity(new UrlEncodedFormEntity(postParameters)); doRequest(httpRequest); Logs.info("Added permission 'user' to group sonar-users"); //admin permission to sonar-administrators reqUrl = hostUrl + "/api/permissions/add"; //?permission=admin&group=sonar-administrators&component=" + project_key + "'"; httpRequest = new HttpPost(reqUrl); postParameters.clear(); postParameters.add(new BasicNameValuePair("permission", "admin")); postParameters.add(new BasicNameValuePair("group", "sonar-administrators")); postParameters.add(new BasicNameValuePair("component", project_key)); httpRequest.setEntity(new UrlEncodedFormEntity(postParameters)); doRequest(httpRequest); Logs.info("Added permission 'admin' to group sonar-administrators"); //admin permission to self reqUrl = hostUrl + "/api/permissions/add"; //?permission=admin&user=" + buildUserId + "&component=" + project_key + "'"; httpRequest = new HttpPost(reqUrl); postParameters.clear(); postParameters.add(new BasicNameValuePair("permission", "admin")); postParameters.add(new BasicNameValuePair("user", buildUserId)); postParameters.add(new BasicNameValuePair("component", project_key)); httpRequest.setEntity(new UrlEncodedFormEntity(postParameters)); doRequest(httpRequest); Logs.info("Added permission 'admin' to user " + buildUserId); //codeviewer permission to self, maybe unnecessary reqUrl = hostUrl + "/api/permissions/add"; //?permission=codeviewer&user=" + buildUserId + "&component=" + project_key; httpRequest = new HttpPost(reqUrl); postParameters.clear(); postParameters.add(new BasicNameValuePair("permission", "codeviewer")); postParameters.add(new BasicNameValuePair("user", buildUserId)); postParameters.add(new BasicNameValuePair("component", project_key)); httpRequest.setEntity(new UrlEncodedFormEntity(postParameters)); doRequest(httpRequest); Logs.info("Added permission 'codeviewer' to user " + buildUserId); //remove codeviewer permission from anyone reqUrl = hostUrl + "/api/permissions/remove"; //?permission=codeviewer&group=anyone&component=" + project_key + "'"; httpRequest = new HttpPost(reqUrl); postParameters.clear(); postParameters.add(new BasicNameValuePair("permission", "codeviewer")); postParameters.add(new BasicNameValuePair("group", "anyone")); postParameters.add(new BasicNameValuePair("component", project_key)); httpRequest.setEntity(new UrlEncodedFormEntity(postParameters)); doRequest(httpRequest); Logs.info("Removed permission 'codeviewer' from group anyone"); } catch (Exception e) { showError("Error during Sonar runner execution", e, cli.isDisplayStackTrace()); return Exit.ERROR; } displayExecutionResult(stats, "SUCCESS"); return Exit.SUCCESS; }
From source file:nl.flotsam.greader.ReaderTemplate.java
private String authenticate() { Properties result = preparePostTo(AUTHENTICATION_URL).using(restTemplate).expecting(Properties.class) .withParam("accountType", "HOSTED_OR_GOOGLE").withParam("Email", email) .withParam("Passwd", password).withParam("service", "reader") .withParam("source", "flotsam-greader-java-1.0").execute(); return (String) result.get("Auth"); }
From source file:com.wavemaker.tools.data.ExportDB.java
private List<Throwable> filterError(List<Throwable> errors, Properties props) { List<Throwable> rtn = new ArrayList<Throwable>(); String dialect = (String) props.get(".dialect"); String dbType;/* w ww.j a v a2 s. c om*/ if (dialect == null) { return rtn; } if (dialect.contains("MySQL")) { dbType = "mysql"; } else if (dialect.contains("HSQL")) { dbType = "hsql"; } else { return rtn; } for (Throwable t : errors) { String msg = t.getMessage(); if (dbType.equals("mysql") && msg.substring(0, 5).equals("Table") && msg.lastIndexOf("doesn't exist") == msg.length() - 13 || dbType.equals("hsql") && msg.substring(0, 16).equals("Table not found:") && msg.contains("in statement [alter table")) { continue; } else { rtn.add(t); } } return rtn; }