List of usage examples for java.util Properties putAll
@Override public synchronized void putAll(Map<?, ?> t)
From source file:com.alfaariss.oa.engine.core.EngineLauncher.java
/** * Restarts the engine./*from w w w. j a va2s .c om*/ * * Uses the supplied properties or if they are <code>null</code> the * properties used during the start to restart the OA engine. * @param pConfig properties with the location of the configuration * @throws OAException if restart fails */ public void restart(Properties pConfig) throws OAException { Properties pRestartConfig = null; try { if (!_engine.isInitialized()) { _logger.info("Engine is not started yet; Trying to start"); start(pConfig); } else { pRestartConfig = _pConfig; if (pConfig != null) pRestartConfig.putAll(pConfig); _configurationManager.stop(); _configurationManager.start(pRestartConfig); _engine.restart(null); _logger.info("Restarted EngineLauncher"); } } catch (OAException e) { throw e; } catch (Exception e) { StringBuffer sbError = new StringBuffer("Internal error during restart "); if (pRestartConfig == null) sbError.append("without supplied configuration"); else { sbError.append("with the following supplied configuration: "); sbError.append(pRestartConfig.toString()); } _logger.error(sbError.toString(), e); throw new OAException(SystemErrors.ERROR_INTERNAL); } }
From source file:com.urbanmania.spring.beans.factory.config.annotations.PropertyAnnotationAndPlaceholderConfigurer.java
@Override protected void loadProperties(Properties props) throws IOException { super.loadProperties(props); if (propertyLoaders != null) { for (PropertyLoader propertyLoader : propertyLoaders) { log.info("Loading propertyLoader=[" + propertyLoader + "]"); Properties loaded = propertyLoader.loadProperties(); props.putAll(loaded); propertyLoader.registerPropertyListener(this); }/*from ww w . jav a 2 s. c o m*/ } }
From source file:org.apache.servicemix.platform.testing.support.SmxPlatform.java
protected Properties getPlatformProperties() { // load Felix configuration Properties props = new Properties(); props.putAll(getFelixConfiguration()); props.putAll(getLocalConfiguration()); return props; }
From source file:com.janoz.usenet.searchers.impl.NewzbinConnectorImpl.java
@SuppressWarnings("unchecked") @Override/*w w w. j a va 2 s. c o m*/ public synchronized List<NZB> search(String query, NewzbinCategory category, Integer minSize, Integer maxSize, Set<String> newsgroupsParam, Properties newzbinQueryPropsParam) throws SearchException { //Fill with defaults Set<String> newsgroups; if (newsgroupsParam == null) { newsgroups = this.defaultNewsgroups; } else { newsgroups = newsgroupsParam; } Properties newzbinQueryProps; if (newzbinQueryPropsParam == null) { newzbinQueryProps = this.defaultNewzbinQueryProps; } else { Properties tmpProps = new Properties(this.defaultNewzbinQueryProps); tmpProps.putAll(newzbinQueryPropsParam); newzbinQueryProps = tmpProps; } List<NameValuePair> params = new ArrayList<NameValuePair>(); params.add(new BasicNameValuePair("username", username)); params.add(new BasicNameValuePair("password", password)); params.add(new BasicNameValuePair("retention", "" + retention)); if (newsgroups != null && !newsgroups.isEmpty()) { params.add(new BasicNameValuePair("group", Util.implode(newsgroups, "+"))); } if (category != null) { params.add(new BasicNameValuePair("category", "" + category.getValue())); } if (minSize != null) { params.add(new BasicNameValuePair("u_post_larger_than", "" + minSize)); } if (maxSize != null) { params.add(new BasicNameValuePair("u_post_smaller_than", "" + maxSize)); } params.add(new BasicNameValuePair("query", query)); Enumeration<String> keys = (Enumeration<String>) newzbinQueryProps.propertyNames(); String label = null; String value = null; while (keys.hasMoreElements()) { label = keys.nextElement(); value = newzbinQueryProps.getProperty(label); if (value != null && value.trim().length() > 0) { params.add(new BasicNameValuePair(label, value)); } } HttpResponse response = null; BufferedReader br = null; try { HttpPost method = new HttpPost(constructURL("/api/reportfind/")); method.setEntity(new UrlEncodedFormEntity(params, "UTF-8")); response = client.execute(method); if (LOG.isTraceEnabled()) { LogUtil.logResponseHeader(response); } int status = response.getStatusLine().getStatusCode(); switch (status) { case RESULT_OK: break; case RESULT_EMPTY: return Collections.emptyList(); case RESULT_UNAUTHORIZED: //Unauthorised, check username/password? LOG.error("Newzbin login failed"); throw new SearchException("Incorrect Newzbin credentials for '" + username + "' while searching."); case RESULT_PAYMENT_REQUIRED: //Payment Required, not Premium LOG.error("Payment needed"); throw new SearchException("No premium account while searching."); case RESULT_INTERNAL_SERVER_ERROR: throw new SearchException("Internal newzbin " + "server error while searching."); case RESULT_SERVICE_UNAVAILABLE: throw new SearchException("Newzbin.com currently " + "down while searching."); default: //Service Unavailable, site is currently down throw new SearchException( "Got unknown returncode " + status + " from newzbin.com while searching."); } //we got a result List<NZB> result = new ArrayList<NZB>(); InputStream is = response.getEntity().getContent(); //is = LogUtil.dumpStreamAndReOffer(is); br = new BufferedReader(new InputStreamReader(is, NEWZBIN_ENCODING)); br.readLine(); // read amount; String line; String[] fields; LazyNZB nzb; while (null != (line = br.readLine())) { fields = line.split("\t"); //REPORTID \t SIZE \t NAME nzb = new LazyNZB(Util.saveFileName(fields[2]) + ".nzb", this); nzb.setName(fields[2]); nzb.setReportId(Integer.parseInt(fields[0])); result.add(nzb); } return result; } catch (IOException e) { throw new SearchException("IO error during search.", e); } finally { if (br != null) { try { br.close(); } catch (IOException e) { LOG.warn("Error while cleaning up request.", e); } } if (response != null) { try { response.getEntity().consumeContent(); } catch (IOException e) { LOG.warn("Error while cleaning up request.", e); } } } }
From source file:com.hpe.application.automation.tools.run.RunFromAlmBuilder.java
@Override public void perform(Run<?, ?> build, FilePath workspace, Launcher launcher, TaskListener listener) throws InterruptedException, IOException { // get the alm server settings AlmServerSettingsModel almServerSettingsModel = getAlmServerSettingsModel(); if (almServerSettingsModel == null) { listener.fatalError(//from w ww. ja v a 2 s .c o m "An ALM server is not defined. Go to Manage Jenkins->Configure System and define your ALM server under Application Lifecycle Management"); // set pipeline stage as failure in case if ALM server was not configured build.setResult(Result.FAILURE); return; } EnvVars env = null; try { env = build.getEnvironment(listener); } catch (IOException e2) { // TODO Auto-generated catch block e2.printStackTrace(); } VariableResolver<String> varResolver = new VariableResolver.ByMap<String>(build.getEnvironment(listener)); // now merge them into one list Properties mergedProperties = new Properties(); mergedProperties.putAll(almServerSettingsModel.getProperties()); mergedProperties.putAll(runFromAlmModel.getProperties(env, varResolver)); String encAlmPass = ""; try { encAlmPass = EncryptionUtils.Encrypt(runFromAlmModel.getAlmPassword(), EncryptionUtils.getSecretKey()); mergedProperties.remove(RunFromAlmModel.ALM_PASSWORD_KEY); mergedProperties.put(RunFromAlmModel.ALM_PASSWORD_KEY, encAlmPass); } catch (Exception e) { build.setResult(Result.FAILURE); listener.fatalError("problem in qcPassword encription"); } Date now = new Date(); Format formatter = new SimpleDateFormat("ddMMyyyyHHmmssSSS"); String time = formatter.format(now); // get a unique filename for the params file ParamFileName = "props" + time + ".txt"; ResultFilename = "Results" + time + ".xml"; //KillFileName = "stop" + time + ".txt"; mergedProperties.put("runType", RunType.Alm.toString()); mergedProperties.put("resultsFilename", ResultFilename); // get properties serialized into a stream ByteArrayOutputStream stream = new ByteArrayOutputStream(); try { mergedProperties.store(stream, ""); } catch (IOException e) { build.setResult(Result.FAILURE); // TODO Auto-generated catch block e.printStackTrace(); } String propsSerialization = stream.toString(); InputStream propsStream = IOUtils.toInputStream(propsSerialization); // get the remote workspace filesys FilePath projectWS = workspace; // Get the URL to the Script used to run the test, which is bundled // in the plugin URL cmdExeUrl = Hudson.getInstance().pluginManager.uberClassLoader.getResource(HpToolsLauncher_SCRIPT_NAME); if (cmdExeUrl == null) { listener.fatalError(HpToolsLauncher_SCRIPT_NAME + " not found in resources"); return; } FilePath propsFileName = projectWS.child(ParamFileName); FilePath CmdLineExe = projectWS.child(HpToolsLauncher_SCRIPT_NAME); try { // create a file for the properties file, and save the properties propsFileName.copyFrom(propsStream); // Copy the script to the project workspace CmdLineExe.copyFrom(cmdExeUrl); } catch (IOException e1) { build.setResult(Result.FAILURE); // TODO Auto-generated catch block e1.printStackTrace(); } try { // Run the HpToolsLauncher.exe AlmToolsUtils.runOnBuildEnv(build, launcher, listener, CmdLineExe, ParamFileName); } catch (IOException ioe) { Util.displayIOException(ioe, listener); build.setResult(Result.FAILURE); return; } catch (InterruptedException e) { build.setResult(Result.ABORTED); PrintStream out = listener.getLogger(); // kill processes //FilePath killFile = projectWS.child(KillFileName); /* try { out.println("Sending abort command"); killFile.write("\n", "UTF-8"); while (!killFile.exists()) Thread.sleep(1000); Thread.sleep(1500); } catch (IOException e1) { //build.setResult(Result.FAILURE); // TODO Auto-generated catch block e1.printStackTrace(); } catch (InterruptedException e1) { //build.setResult(Result.FAILURE); // TODO Auto-generated catch block e1.printStackTrace(); }*/ try { AlmToolsUtils.runHpToolsAborterOnBuildEnv(build, launcher, listener, ParamFileName, workspace); } catch (IOException e1) { Util.displayIOException(e1, listener); build.setResult(Result.FAILURE); return; } catch (InterruptedException e1) { // TODO Auto-generated catch block e1.printStackTrace(); } out.println("Operation was aborted by user."); //build.setResult(Result.FAILURE); } return; }
From source file:org.apache.solr.core.SolrXMLCoresLocator.java
@Override public List<CoreDescriptor> discover(CoreContainer cc) { ImmutableList.Builder<CoreDescriptor> listBuilder = ImmutableList.builder(); for (String coreName : cfg.getAllCoreNames()) { String name = cfg.getProperty(coreName, CoreDescriptor.CORE_NAME, DEFAULT_CORE_NAME); String instanceDir = cfg.getProperty(coreName, CoreDescriptor.CORE_INSTDIR, ""); Properties coreProperties = new Properties(); for (String propName : CoreDescriptor.standardPropNames) { String propValue = cfg.getProperty(coreName, propName, ""); if (StringUtils.isNotEmpty(propValue)) coreProperties.setProperty(propName, propValue); }//from w w w . j a va2 s. c o m coreProperties.putAll(cfg.getCoreProperties(coreName)); listBuilder.add(new CoreDescriptor(cc, name, instanceDir, coreProperties)); } return listBuilder.build(); }
From source file:com.zotoh.maedr.device.Device.java
/** * @param rcb The bundle from which messages are read. * @param out This is where the captured values are placed. * @return false means ignore this operation, such as the user decided to cancel during input. * @throws IOException/*from w w w . jav a2 s. c om*/ */ public final boolean showConfigMenu(ResourceBundle rcb, Properties out) throws Exception { Properties props = new Properties(); boolean ok = false; CmdLineSequence s = supportsConfigMenu() ? getCmdSeq(rcb, props) : null; if (s != null) { s.start(props); if (!s.isCanceled()) { out.putAll(props); ok = true; } } return ok; }
From source file:org.apache.flink.api.java.utils.ParameterTool.java
/** * Returns a {@link Properties} object from this {@link ParameterTool} * * @return A {@link Properties}//from w w w. j av a 2 s . c o m */ public Properties getProperties() { Properties props = new Properties(); props.putAll(this.data); return props; }
From source file:com.liferay.ide.project.core.tests.ProjectCoreBase.java
private void persistAppServerProperties() throws FileNotFoundException, IOException, ConfigurationException { Properties initProps = new Properties(); initProps.put("app.server.type", "tomcat"); initProps.put("app.server.tomcat.dir", getLiferayRuntimeDir().toPortableString()); initProps.put("app.server.tomcat.deploy.dir", getLiferayRuntimeDir().append("webapps").toPortableString()); initProps.put("app.server.tomcat.lib.global.dir", getLiferayRuntimeDir().append("lib/ext").toPortableString()); initProps.put("app.server.parent.dir", getLiferayRuntimeDir().removeLastSegments(1).toPortableString()); initProps.put("app.server.tomcat.portal.dir", getLiferayRuntimeDir().append("webapps/ROOT").toPortableString()); IPath loc = getLiferayPluginsSdkDir(); String userName = System.getProperty("user.name"); //$NON-NLS-1$ File userBuildFile = loc.append("build." + userName + ".properties").toFile(); //$NON-NLS-1$ //$NON-NLS-2$ try (FileOutputStream fileOutput = new FileOutputStream(userBuildFile)) { if (userBuildFile.exists()) { PropertiesConfiguration propsConfig = new PropertiesConfiguration(userBuildFile); for (Object key : initProps.keySet()) { propsConfig.setProperty((String) key, initProps.get(key)); }/*from w w w .j a va 2 s . co m*/ propsConfig.setHeader(""); propsConfig.save(fileOutput); } else { Properties props = new Properties(); props.putAll(initProps); props.store(fileOutput, StringPool.EMPTY); } } }
From source file:com.netflix.exhibitor.standalone.ExhibitorCreator.java
private Properties makeDefaultProperties(CommandLine commandLine, BackupProvider backupProvider) throws IOException { Properties properties = new Properties(); properties.putAll(DefaultProperties.get(backupProvider)); // put in standard defaults first addInitialConfigFile(commandLine, properties); return new PropertyBasedInstanceConfig(properties, new Properties()).getProperties(); }