List of usage examples for java.util Properties get
@Override
public Object get(Object key)
From source file:com.cloudera.sqoop.TestSqoopOptions.java
public void testMapColumnHiveParams() throws Exception { String[] args = { "--map-column-hive", "id=STRING", }; SqoopOptions opts = parse(args);// w ww . j a v a 2s . c o m Properties mapping = opts.getMapColumnHive(); assertTrue(mapping.containsKey("id")); assertEquals("STRING", mapping.get("id")); }
From source file:com.cloudera.sqoop.TestSqoopOptions.java
public void testMapColumnJavaParams() throws Exception { String[] args = { "--map-column-java", "id=String", }; SqoopOptions opts = parse(args);//w w w. j av a 2 s.c om Properties mapping = opts.getMapColumnJava(); assertTrue(mapping.containsKey("id")); assertEquals("String", mapping.get("id")); }
From source file:com.liferay.blade.cli.CreateCommand.java
private File getDefaultDir() throws Exception { File baseDir = _blade.getBase(); if (!Util.isWorkspace(baseDir)) { return baseDir; }/*from w ww .ja v a 2s.co m*/ Properties properties = Util.getGradleProperties(baseDir); String modulesDirValue = (String) properties.get(Workspace.DEFAULT_MODULES_DIR_PROPERTY); if (modulesDirValue == null) { modulesDirValue = Workspace.DEFAULT_MODULES_DIR; } File projectDir = Util.getWorkspaceDir(_blade); File modulesDir = new File(projectDir, modulesDirValue); return containsDir(baseDir, modulesDir) ? baseDir : modulesDir; }
From source file:com.zotoh.maedr.device.netty.RestIO.java
@SuppressWarnings("unchecked") protected CmdLineSequence getCmdSeq(ResourceBundle rcb, Properties props) throws Exception { props.put("resources", new HashMap<String, String>()); CmdLineQuestion q3 = new CmdLineMandatory("resproc", getResourceStr(rcb, "cmd.rest.resproc")) { protected String onAnswerSetOutput(String answer, Properties props) { Map<String, String> m = (Map<String, String>) props.get("resources"); String uri = (String) props.remove("resuri"); m.put(uri, answer);//w w w . j a v a2 s . c om return "resptr"; } }; CmdLineQuestion q2 = new CmdLineMandatory("resptr", getResourceStr(rcb, "cmd.rest.resptr")) { protected String onAnswerSetOutput(String answer, Properties props) { if (isEmpty(answer)) { return ""; } props.put("resuri", answer); return "resproc"; } }; final CmdLineQuestion q1 = new CmdLineQuestion("ctx", getResourceStr(rcb, "cmd.http.ctx")) { protected String onAnswerSetOutput(String answer, Properties props) { props.put("contextpath", answer); return "resptr"; } }; return new CmdLineSequence(super.getCmdSeq(rcb, props), q1, q2, q3) { protected String onStart() { return q1.getId(); } }; }
From source file:com.impetus.kundera.service.HostConfiguration.java
/** * Build host array./*from www.j a va 2 s. com*/ * * @param externalProperties * @param servers * @param persistenceUnit */ private void buildHosts(Map externalProperties, List<Server> servers, String persistenceUnit, final KunderaMetadata kunderaMetadata) { persistenceUnitMetadata = kunderaMetadata.getApplicationMetadata() .getPersistenceUnitMetadata(persistenceUnit); Properties props = persistenceUnitMetadata.getProperties(); this.externalProperties = externalProperties; String hosts = null; String portAsString = null; if (externalProperties != null) { hosts = (String) externalProperties.get(PersistenceProperties.KUNDERA_NODES); portAsString = (String) externalProperties.get(PersistenceProperties.KUNDERA_PORT); } if (hosts == null) { hosts = (String) props.get(PersistenceProperties.KUNDERA_NODES); } if (portAsString == null) { portAsString = (String) props.get(PersistenceProperties.KUNDERA_PORT); } if (hosts != null && portAsString != null) { buildHosts(hosts, portAsString, this.hostsList); } else if (servers != null && servers.size() >= 1) { buildHosts(servers, this.hostsList); } }
From source file:com.hp.security.jauth.core.filter.SystemInit.java
public void initMessageProperties(ResourcePatternResolver resolver) throws IOException { //finding system messages. Resource jauthCoreMessages = resolver.getResource("jauth-core-message.properties"); Properties jauthCoreProp = new Properties(); jauthCoreProp.load(jauthCoreMessages.getInputStream()); Set<Object> jauthCoreKeys = jauthCoreProp.keySet(); for (Object k : jauthCoreKeys) { String key = k.toString(); String value = jauthCoreProp.get(key).toString(); MessageContext.messages.put(key, value); }/* w ww. java 2 s . c o m*/ log.info("loaded jauth core messages."); try { Resource jauthAdminMessages = resolver.getResource("jauth-admin-message.properties"); Properties jauthAdminProp = new Properties(); jauthAdminProp.load(jauthAdminMessages.getInputStream()); Set<Object> jauthAdminKeys = jauthAdminProp.keySet(); for (Object k : jauthAdminKeys) { String key = k.toString(); String value = jauthAdminProp.get(key).toString(); MessageContext.messages.put(key, value); } log.info("loaded jauth admin messages."); } catch (FileNotFoundException e) { log.info("didn't find any jauth admin messages."); } try { Resource jauthSoapMessages = resolver.getResource("jauth-soap-message.properties"); Properties jauthSoapProp = new Properties(); jauthSoapProp.load(jauthSoapMessages.getInputStream()); Set<Object> jauthSoapKeys = jauthSoapProp.keySet(); for (Object k : jauthSoapKeys) { String key = k.toString(); String value = jauthSoapProp.get(key).toString(); MessageContext.messages.put(key, value); } log.info("loaded jauth soap messages."); } catch (FileNotFoundException e) { log.info("didn't find any jauth soap messages."); } //finding custom messages. try { Resource customMessages = resolver.getResource("message.properties"); Properties customProp = new Properties(); customProp.load(customMessages.getInputStream()); Set<Object> customKeys = customProp.keySet(); for (Object k : customKeys) { String key = k.toString(); String value = customProp.get(key).toString(); MessageContext.messages.put(key, value); } log.info("loaded jauth custom messages."); } catch (FileNotFoundException e) { log.info("didn't find any jauth custom messages."); } //finding jauth properties try { Resource jauth = resolver.getResource("jauth.properties"); Properties jauthProp = new Properties(); jauthProp.load(jauth.getInputStream()); authActive = jauthProp.get(Constants.CONFIG_KEY_ACTIVE) == null ? configService.findByKey(Constants.CONFIG_KEY_ACTIVE).getValue() : jauthProp.get(Constants.CONFIG_KEY_ACTIVE).toString(); authorizationCheck = jauthProp.get(Constants.CONFIG_AUTHORIZATION_CHECK) == null ? configService.findByKey(Constants.CONFIG_AUTHORIZATION_CHECK).getValue() : jauthProp.get(Constants.CONFIG_AUTHORIZATION_CHECK).toString(); arithmeticIndex = jauthProp.get(Constants.CONFIG_KEY_ARITHMETIC) == null ? configService.findByKey(Constants.CONFIG_KEY_ARITHMETIC).getValue() : jauthProp.get(Constants.CONFIG_KEY_ARITHMETIC).toString(); sessionID = jauthProp.get(Constants.CONFIG_KEY_SESSION_ID) == null ? configService.findByKey(Constants.CONFIG_KEY_SESSION_ID).getValue() : jauthProp.get(Constants.CONFIG_KEY_SESSION_ID).toString(); sessionACL = jauthProp.get(Constants.CONFIG_KEY_SESSION_ACL) == null ? configService.findByKey(Constants.CONFIG_KEY_SESSION_ACL).getValue() : jauthProp.get(Constants.CONFIG_KEY_SESSION_ACL).toString(); rules = jauthProp.get(Constants.CONFIG_KEY_RULES) == null ? configService.findByKey(Constants.CONFIG_KEY_RULES).getValue() : jauthProp.get(Constants.CONFIG_KEY_RULES).toString(); accessiblePage = jauthProp.get(Constants.CONFIG_KEY_ACCESSIBLE_PAGE) == null ? configService.findByKey(Constants.CONFIG_KEY_ACCESSIBLE_PAGE).getValue() : jauthProp.get(Constants.CONFIG_KEY_ACCESSIBLE_PAGE).toString(); accessibleHost = jauthProp.get(Constants.CONFIG_KEY_ACCESSIBLE_HOST) == null ? configService.findByKey(Constants.CONFIG_KEY_ACCESSIBLE_HOST).getValue() : jauthProp.get(Constants.CONFIG_KEY_ACCESSIBLE_HOST).toString(); exceptionPage = jauthProp.get(Constants.CONFIG_KEY_EXCEPTION) == null ? configService.findByKey(Constants.CONFIG_KEY_EXCEPTION).getValue() : jauthProp.get(Constants.CONFIG_KEY_EXCEPTION).toString(); loginPage = jauthProp.get(Constants.CONFIG_KEY_LOGIN_PAGE) == null ? configService.findByKey(Constants.CONFIG_KEY_LOGIN_PAGE).getValue() : jauthProp.get(Constants.CONFIG_KEY_LOGIN_PAGE).toString(); soapEnabled = jauthProp.get(Constants.CONFIG_KEY_SOAP_ENABLED) == null ? configService.findByKey(Constants.CONFIG_KEY_SOAP_ENABLED).getValue() : jauthProp.get(Constants.CONFIG_KEY_SOAP_ENABLED).toString(); protectWSDL = jauthProp.get(Constants.CONFIG_KEY_PROTECT_WSDL) == null ? configService.findByKey(Constants.CONFIG_KEY_PROTECT_WSDL).getValue() : jauthProp.get(Constants.CONFIG_KEY_PROTECT_WSDL).toString(); dbLogEnabled = jauthProp.get(Constants.CONFIG_KEY_DB_LOG_ENABLED) == null ? configService.findByKey(Constants.CONFIG_KEY_DB_LOG_ENABLED).getValue() : jauthProp.get(Constants.CONFIG_KEY_DB_LOG_ENABLED).toString(); logPath = jauthProp.get(Constants.CONFIG_KEY_LOG_PATH) == null ? configService.findByKey(Constants.CONFIG_KEY_LOG_PATH).getValue() : jauthProp.get(Constants.CONFIG_KEY_LOG_PATH).toString(); if (logPath.length() > 0) { File logDir = new File(logPath); if (!logDir.exists()) { logDir.mkdirs(); } } log.info("loaded jauth.properties."); } catch (FileNotFoundException e) { log.info("didn't find jauth.properties."); } }
From source file:hudson.UtilTest.java
@Test public void loadProperties() throws IOException { assertEquals(0, Util.loadProperties("").size()); Properties p = Util.loadProperties("k.e.y=va.l.ue"); assertEquals(p.toString(), "va.l.ue", p.get("k.e.y")); assertEquals(p.toString(), 1, p.size()); }
From source file:com.streamsets.datacollector.MiniSDCTestingUtility.java
/** * Start mini SDC/*from www . ja v a2s . co m*/ * @param executionMode the Execution mode - could be standalone or cluster * @return * @throws Exception */ public MiniSDC createMiniSDC(ExecutionMode executionMode) throws Exception { Properties miniITProps = new Properties(); File miniITProperties = new File(Resources.getResource("miniIT.properties").toURI()); InputStream sdcInStream = new FileInputStream(miniITProperties); miniITProps.load(sdcInStream); String sdcDistRoot = (String) miniITProps.get(SDC_DIST_DIR); File sdcDistFile = new File(sdcDistRoot); if (!sdcDistFile.exists()) { throw new RuntimeException("SDC dist root dir " + sdcDistFile.getAbsolutePath() + "doesn't exist"); } LOG.info("SDC dist root at " + sdcDistFile.getAbsolutePath()); sdcInStream.close(); File target = getDataTestDir(); String targetRoot = target.getAbsolutePath(); File etcTarget = new File(target, "etc"); File resourcesTarget = new File(target, "resources"); FileUtils.copyDirectory(new File(sdcDistRoot + "/etc"), etcTarget); FileUtils.copyDirectory(new File(sdcDistRoot + "/resources"), resourcesTarget); FileUtils.copyDirectory(new File(sdcDistRoot + "/libexec"), new File(target, "libexec")); // Set execute permissions back on script Set<PosixFilePermission> set = new HashSet<PosixFilePermission>(); set.add(PosixFilePermission.OWNER_EXECUTE); set.add(PosixFilePermission.OWNER_READ); set.add(PosixFilePermission.OWNER_WRITE); set.add(PosixFilePermission.OTHERS_READ); Files.setPosixFilePermissions(new File(target, "libexec" + "/_cluster-manager").toPath(), set); File staticWebDir = new File(target, "static-web"); staticWebDir.mkdir(); setExecutePermission(new File(target, "libexec" + "/_cluster-manager").toPath()); File log4jProperties = new File(etcTarget, "sdc-log4j.properties"); if (log4jProperties.exists()) { log4jProperties.delete(); } Files.copy(Paths.get(Resources.getResource("log4j.properties").toURI()), log4jProperties.toPath()); File sdcProperties = new File(etcTarget, "sdc.properties"); System.setProperty("sdc.conf.dir", etcTarget.getAbsolutePath()); System.setProperty("sdc.resources.dir", resourcesTarget.getAbsolutePath()); System.setProperty("sdc.libexec.dir", targetRoot + "/libexec"); System.setProperty("sdc.static-web.dir", targetRoot + "/static-web"); rewriteProperties(sdcProperties, executionMode); this.miniSDC = new MiniSDC(sdcDistRoot); return this.miniSDC; }
From source file:org.sakuli.utils.SakuliPropertyPlaceholderConfigurer.java
private String resolve(String string, Properties props) { if (string != null) { int i = string.indexOf("${"); if (i >= 0) { String result = string.substring(0, i); int iLast = string.indexOf("}"); String key = string.substring(i + 2, iLast); result += props.get(key) + string.substring(iLast + 1); return resolve(result, props); }/*from w w w . j av a 2s . co m*/ } return string; }