List of usage examples for java.util Properties remove
@Override public synchronized Object remove(Object key)
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(/*w w w . j a va 2s . 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.kuali.rice.krad.lookup.LookupControllerServiceImpl.java
/** * Builds the URL for returning back to the calling view and passing the selected line values. * * <p>We attempt to pass back all the selected line identifiers as a request parameter on the return URL. * However, this could result in an URL longer than the max length supported by browsers (the most restrictive * is used). If this happens, for local lookups we use Spring flash attributes. In the case of a remote * lookup, there is nothing we can do and return an error message.</p> * * {@inheritDoc}/*from w w w . j a v a 2 s. c o m*/ */ @Override public String returnSelected(LookupForm lookupForm, RedirectAttributes redirectAttributes) { LookupUtils.refreshLookupResultSelections(lookupForm); Properties urlParams = buildReturnSelectedParameters(lookupForm); String returnUrl = UrlFactory.parameterizeUrl(lookupForm.getReturnLocation(), urlParams); boolean lookupCameFromDifferentServer = KRADUtils.areDifferentDomains(lookupForm.getReturnLocation(), lookupForm.getRequestUrl()); boolean urlGreaterThanMaxLength = returnUrl.length() > RiceConstants.MAXIMUM_URL_LENGTH; if (urlGreaterThanMaxLength) { // removed selected values parameter from the return url urlParams.remove(UifParameters.SELECTED_LINE_VALUES); // if lookup was on a different server, we can't return the selected lines and instead // will return an error message if (lookupCameFromDifferentServer) { urlParams.setProperty(UifParameters.REFRESH_STATUS, UifConstants.RefreshStatus.ERROR); urlParams.setProperty(UifParameters.MESSAGE_TO_DISPLAY, RiceKeyConstants.INFO_LOOKUP_RESULTS_MV_RETURN_EXCEEDS_LIMIT); } else { // otherwise use flash attributes instead of the URL to return the selected line identifiers String selectedLineValues = getSelectedLineValues(lookupForm); redirectAttributes.addFlashAttribute(UifParameters.SELECTED_LINE_VALUES, selectedLineValues); } } GlobalVariables.getUifFormManager().removeSessionForm(lookupForm); // rebuild url based on updated parameters returnUrl = UrlFactory.parameterizeUrl(lookupForm.getReturnLocation(), urlParams); return UifConstants.REDIRECT_PREFIX + returnUrl; }
From source file:org.xz.qstruts.views.velocity.VelocityManager.java
/** * load optional velocity properties using the following loading strategy * <ul>/*from www.j a va 2 s. co m*/ * <li>relative to the servlet context path</li> * <li>relative to the WEB-INF directory</li> * <li>on the classpath</li> * </ul> * * @param context the current ServletContext. may <b>not</b> be null * @return the optional properties if struts.velocity.configfile was specified, an empty Properties file otherwise */ public Properties loadConfiguration(ServletContext context) { if (context == null) { String gripe = "Error attempting to create a loadConfiguration from a null ServletContext!"; LOG.error(gripe); throw new IllegalArgumentException(gripe); } Properties properties = new Properties(); // now apply our systemic defaults, then allow user to override applyDefaultConfiguration(context, properties); String defaultUserDirective = properties.getProperty("userdirective"); properties.remove("userdirective"); /** * if the user has specified an external velocity configuration file, we'll want to search for it in the * following order * * 1. relative to the context path * 2. relative to /WEB-INF * 3. in the class path */ String configfile; if (customConfigFile != null) { configfile = customConfigFile; } else { configfile = "velocity.properties"; } configfile = configfile.trim(); InputStream in = null; String resourceLocation = null; try { if (context.getRealPath(configfile) != null) { // 1. relative to context path, i.e. /velocity.properties String filename = context.getRealPath(configfile); if (filename != null) { File file = new File(filename); if (file.isFile()) { resourceLocation = file.getCanonicalPath() + " from file system"; in = new FileInputStream(file); } // 2. if nothing was found relative to the context path, search relative to the WEB-INF directory if (in == null) { file = new File(context.getRealPath("/WEB-INF/" + configfile)); if (file.isFile()) { resourceLocation = file.getCanonicalPath() + " from file system"; in = new FileInputStream(file); } } } } // 3. finally, if there's no physical file, how about something in our classpath if (in == null) { in = VelocityManager.class.getClassLoader().getResourceAsStream(configfile); if (in != null) { resourceLocation = configfile + " from classloader"; } } // if we've got something, load 'er up if (in != null) { LOG.info("Initializing velocity using " + resourceLocation); properties.load(in); } } catch (IOException e) { LOG.warn("Unable to load velocity configuration " + resourceLocation, e); } finally { if (in != null) { try { in.close(); } catch (IOException e) { } } } // overide with programmatically set properties if (this.velocityProperties != null) { Iterator keys = this.velocityProperties.keySet().iterator(); while (keys.hasNext()) { String key = (String) keys.next(); properties.setProperty(key, this.velocityProperties.getProperty(key)); } } String userdirective = properties.getProperty("userdirective"); if ((userdirective == null) || userdirective.trim().equals("")) { userdirective = defaultUserDirective; } else { userdirective = userdirective.trim() + "," + defaultUserDirective; } properties.setProperty("userdirective", userdirective); // for debugging purposes, allows users to dump out the properties that have been configured if (LOG.isDebugEnabled()) { LOG.debug("Initializing Velocity with the following properties ..."); for (Iterator iter = properties.keySet().iterator(); iter.hasNext();) { String key = (String) iter.next(); String value = properties.getProperty(key); if (LOG.isDebugEnabled()) { LOG.debug(" '" + key + "' = '" + value + "'"); } } } return properties; }
From source file:org.kawanfw.sql.api.client.RemoteDriver.java
/** * Gets information about the possible properties for this driver. * <P>// w ww . j ava 2 s.co m * The <code>getPropertyInfo</code> method is intended to allow a generic * GUI tool to discover what properties it should prompt a human for in * order to get enough information to connect to a database. Note that * depending on the values the human has supplied so far, additional values * may become necessary, so it may be necessary to iterate though several * calls to the <code>getPropertyInfo</code> method. * * @param url * the URL of the database to which to connect * @param info * a proposed list of tag/value pairs that will be sent on * connect open * @return an array of <code>DriverPropertyInfo</code> objects describing * possible properties. * @exception SQLException * if a database access error occurs */ @Override public DriverPropertyInfo[] getPropertyInfo(String url, Properties info) throws SQLException { List<DriverPropertyInfo> driverPropertyInfoList = new ArrayList<DriverPropertyInfo>(); if (info != null) { info.remove("RemarksReporting"); } DriverPropertyInfo driverPropertyInfo = null; driverPropertyInfo = getNewDriverPropertyInfo("user", info); driverPropertyInfo.description = "Username to connect to the remote database as"; driverPropertyInfo.required = true; driverPropertyInfoList.add(driverPropertyInfo); driverPropertyInfo = new DriverPropertyInfo("password", null); driverPropertyInfo.description = "Password to use when authenticating"; driverPropertyInfo.required = true; driverPropertyInfoList.add(driverPropertyInfo); driverPropertyInfo = getNewDriverPropertyInfo("proxyType", info); driverPropertyInfo.description = "Proxy Type to use: HTTP or SOCKS. Defaults to HTTP"; driverPropertyInfo.required = false; driverPropertyInfoList.add(driverPropertyInfo); driverPropertyInfo = getNewDriverPropertyInfo("proxyHostname", info); driverPropertyInfo.description = "Proxy hostname to use"; driverPropertyInfo.required = false; driverPropertyInfoList.add(driverPropertyInfo); driverPropertyInfo = getNewDriverPropertyInfo("proxyPort", info); driverPropertyInfo.description = "Proxy Port to use"; driverPropertyInfo.required = false; driverPropertyInfoList.add(driverPropertyInfo); driverPropertyInfo = getNewDriverPropertyInfo("proxyUsername", info); driverPropertyInfo.description = "Proxy credential username"; driverPropertyInfo.required = false; driverPropertyInfoList.add(driverPropertyInfo); driverPropertyInfo = getNewDriverPropertyInfo("proxyPassword", info); driverPropertyInfo.description = "Proxy credential password"; driverPropertyInfo.required = false; driverPropertyInfoList.add(driverPropertyInfo); driverPropertyInfo = getNewDriverPropertyInfo("maxLengthForString", info); driverPropertyInfo.description = "Int for the maximum authorized length for a string for upload or download Should be <= 2097152 (2Mb). Defaults to 2097152."; driverPropertyInfo.required = false; driverPropertyInfoList.add(driverPropertyInfo); driverPropertyInfo = getNewDriverPropertyInfo("encryptionPassword", info); driverPropertyInfo.description = "The password to use to encrypt all request parameter names and values. Defaults to null (no encryption)."; driverPropertyInfo.required = false; driverPropertyInfoList.add(driverPropertyInfo); driverPropertyInfo = getNewDriverPropertyInfo("htmlEncoding", info); driverPropertyInfo.description = "Boolean that says if the upload/download of Clob using character stream or ASCII stream must be html encoded. Defaults to true."; driverPropertyInfo.required = false; driverPropertyInfoList.add(driverPropertyInfo); driverPropertyInfo = getNewDriverPropertyInfo("compression", info); driverPropertyInfo.description = "Boolean to say if the Driver is configured to contact the remote server using http compression. Defaults to true. Defaults to true."; driverPropertyInfo.required = false; driverPropertyInfoList.add(driverPropertyInfo); driverPropertyInfo = getNewDriverPropertyInfo("acceptAllSslCertificates", info); driverPropertyInfo.description = "Boolean thats says if client sides allows HTTPS call with all SSL Certificates, including \"invalid\" or self-signed Certificates. Defaults to false."; driverPropertyInfo.required = false; driverPropertyInfoList.add(driverPropertyInfo); driverPropertyInfo = getNewDriverPropertyInfo("statelessMode", info); driverPropertyInfo.description = "Boolean that says if the Driver is configured to contact the remote server in stateless mode. Defaults to false."; driverPropertyInfo.required = false; driverPropertyInfoList.add(driverPropertyInfo); driverPropertyInfo = getNewDriverPropertyInfo("uploadChunkLength", info); driverPropertyInfo.description = "Long for upload chunk length to be used by FileSession.upload(File, String). Defaults to 10Mb. 0 means files are not chunked."; driverPropertyInfo.required = false; driverPropertyInfoList.add(driverPropertyInfo); driverPropertyInfo = getNewDriverPropertyInfo("downloadChunkLength", info); driverPropertyInfo.description = "Long for download chunk length to be used by FileSession.download(String, File). Defaults to 10Mb. 0 means files are not chunked."; driverPropertyInfo.required = false; driverPropertyInfoList.add(driverPropertyInfo); driverPropertyInfo = getNewDriverPropertyInfo("joinResultSetMetaData", info); driverPropertyInfo.description = "Boolean to say if ResultSet MetaData is to be downloaded along with ResultSet. Defaults to false."; driverPropertyInfo.required = false; driverPropertyInfoList.add(driverPropertyInfo); driverPropertyInfo = getNewDriverPropertyInfo("zipResultSet", info); driverPropertyInfo.description = "Boolean to tell server to GZIP ResultSet before download. Defaults to true."; driverPropertyInfo.required = false; driverPropertyInfoList.add(driverPropertyInfo); DriverPropertyInfo[] arrayOfDriverPropertyInfo = driverPropertyInfoList .toArray(new DriverPropertyInfo[driverPropertyInfoList.size()]); return arrayOfDriverPropertyInfo; }
From source file:org.apache.wiki.providers.VersioningFileProvider.java
/** * {@inheritDoc}/*from w w w. j a v a2s .c o m*/ * * Deleting versions has never really worked, * JSPWiki assumes that version histories are "not gappy". * Using deleteVersion() is definitely not recommended. * */ public void deleteVersion(String page, int version) throws ProviderException { File dir = findOldPageDir(page); int latest = findLatestVersion(page); if (version == WikiPageProvider.LATEST_VERSION || version == latest || (version == 1 && latest == -1)) { // // Delete the properties // try { Properties props = getPageProperties(page); props.remove(((latest > 0) ? latest : 1) + ".author"); putPageProperties(page, props); } catch (IOException e) { log.error("Unable to modify page properties", e); throw new ProviderException("Could not modify page properties: " + e.getMessage()); } // We can let the FileSystemProvider take care // of the actual deletion super.deleteVersion(page, WikiPageProvider.LATEST_VERSION); // // Copy the old file to the new location // latest = findLatestVersion(page); File pageDir = findOldPageDir(page); File previousFile = new File(pageDir, Integer.toString(latest) + FILE_EXT); InputStream in = null; OutputStream out = null; try { if (previousFile.exists()) { in = new BufferedInputStream(new FileInputStream(previousFile)); File pageFile = findPage(page); out = new BufferedOutputStream(new FileOutputStream(pageFile)); FileUtil.copyContents(in, out); // // We need also to set the date, since we rely on this. // pageFile.setLastModified(previousFile.lastModified()); } } catch (IOException e) { log.fatal("Something wrong with the page directory - you may have just lost data!", e); } finally { IOUtils.closeQuietly(in); IOUtils.closeQuietly(out); } return; } File pageFile = new File(dir, "" + version + FILE_EXT); if (pageFile.exists()) { if (!pageFile.delete()) { log.error("Unable to delete page."); } } else { throw new NoSuchVersionException("Page " + page + ", version=" + version); } }
From source file:org.wso2.carbon.identity.notification.mgt.json.bean.JsonSubscription.java
/** * Takes all properties which has json.subscribe.eventName as key prefix and build an event out of it * * @param eventName name of the event. * @param subscriptionProperties properties which has json.subscribe.eventName as prefix * @throws NotificationManagementException *//*w w w . j a v a 2 s. c o m*/ private void build(String eventName, Properties subscriptionProperties) throws NotificationManagementException { // Subscription properties will never be null, Therefore no need to check if (StringUtils.isEmpty(eventName)) { throw new NotificationManagementException( "No valid event name found. Cannot proceed with event building"); } String eventKey = JsonModuleConstants.Config.SUBSCRIPTION_NS + "." + eventName; if (log.isDebugEnabled()) { log.debug("Building Event object for event " + eventName + " from json notification sending module"); } // Reading json template for event String templatePath = (String) subscriptionProperties .remove(eventKey + "." + JsonModuleConstants.Config.JSON_CONTENT_QNAME); if (templatePath != null) { String template = NotificationManagementUtils.readMessageTemplate(templatePath); this.setJsonContent(template); } else { log.warn("No default json template found for event " + eventName); } // Sets endpoint information for the event String endpointKey = eventKey + "." + JsonModuleConstants.Config.ENDPOINT_QNAME; setEndpoints(endpointKey, NotificationManagementUtils.getPropertiesWithPrefix(endpointKey, subscriptionProperties)); }
From source file:org.mule.endpoint.MuleEndpointURI.java
public MuleEndpointURI(String address, String endpointName, String connectorName, String transformers, String responseTransformers, Properties properties, URI uri, MuleContext muleContext) { this.address = address; this.endpointName = endpointName; this.connectorName = connectorName; this.transformers = transformers; this.responseTransformers = responseTransformers; this.params = properties; this.uri = uri; this.userInfo = uri.getUserInfo(); this.muleContext = muleContext; if (properties != null) { resourceInfo = (String) properties.remove("resourceInfo"); }/*from w w w . ja v a 2 s . c o m*/ }
From source file:org.springframework.batch.core.jsr.launch.JsrJobOperator.java
@Override public Properties getParameters(long executionId) throws NoSuchJobExecutionException, JobSecurityException { org.springframework.batch.core.JobExecution execution = jobExplorer.getJobExecution(executionId); if (execution == null) { throw new NoSuchJobExecutionException("Unable to find the JobExecution for id " + executionId); }/*from w w w . j ava 2s.c o m*/ Properties properties = jobParametersConverter.getProperties(execution.getJobParameters()); properties.remove(JsrJobParametersConverter.JOB_RUN_ID); return properties; }
From source file:com.zotoh.maedr.device.JettyIO.java
@SuppressWarnings("unchecked") protected CmdLineSequence getCmdSeq(ResourceBundle rcb, Properties props) throws Exception { props.put("filters", new ArrayList<Map<String, Object>>()); props.put("urlpatterns", new ArrayList<String>()); CmdLineQuestion q7 = new CmdLineMandatory("fcz", getResourceStr(rcb, "cmd.http.fcz")) { protected String onAnswerSetOutput(String answer, Properties props) { List<Map<String, Object>> a = (List<Map<String, Object>>) props.get("filters"); Map<String, Object> m = MP(); String uri = nsb(props.remove("f_uri")); m.put("urlpattern", uri); m.put("class", answer); m.put("params", new HashMap<String, String>()); a.add(m);/*ww w . j a va 2 s. co m*/ return "fpath"; } }; CmdLineQuestion q6 = new CmdLineMandatory("fpath", getResourceStr(rcb, "cmd.http.fpath")) { protected String onAnswerSetOutput(String answer, Properties props) { if (isEmpty(answer)) { props.remove("f_uri"); return ""; } props.put("f_uri", answer); return "fcz"; } }; CmdLineQuestion q5 = new CmdLineQuestion("filters", getResourceStr(rcb, "cmd.http.filters"), "y/n", "n") { protected String onAnswerSetOutput(String answer, Properties props) { return "Yy".indexOf(answer) >= 0 ? "fpath" : ""; } }; CmdLineQuestion q4 = new CmdLineMandatory("spath", getResourceStr(rcb, "cmd.http.spath")) { protected String onAnswerSetOutput(String answer, Properties props) { if (isEmpty(answer)) return "filters"; List<String> lst = (List<String>) props.get("urlpatterns"); lst.add(answer); return "spath"; } }; CmdLineQuestion q2 = new CmdLineQuestion("base", getResourceStr(rcb, "cmd.http.resbase"), "", ".") { protected String onAnswerSetOutput(String answer, Properties props) { props.put("resbase", answer); return "spath"; } }; final CmdLineQuestion q1 = new CmdLineQuestion("ctx", getResourceStr(rcb, "cmd.http.ctx")) { protected String onAnswerSetOutput(String answer, Properties props) { props.put("contextpath", answer); return "base"; } }; return new CmdLineSequence(super.getCmdSeq(rcb, props), q1, q2, q4, q5, q6, q7) { protected String onStart() { return q1.getId(); } }; }
From source file:org.aon.esolutions.appconfig.web.controller.EnvironmentController.java
@Transactional @RequestMapping(value = "/{environmentName}/import", method = RequestMethod.POST) public void importProperties(@PathVariable String applicationName, @PathVariable String environmentName, @RequestParam(value = "file") MultipartFile multipartFile, @RequestParam(value = "importMode") String importMode) { if (multipartFile.getName().endsWith(".xml") || multipartFile.getOriginalFilename().endsWith(".xml")) { new XmlImporter(applicationRepository, environmentRepository, updateUtility) .importFromXml(multipartFile, importMode); return;// w ww.j av a 2 s . c o m } Environment env = updateUtility.getEnvironmentForWrite(applicationName, environmentName); if (env != null) { Properties props = new Properties(); try { props.load(multipartFile.getInputStream()); } catch (IOException e) { logger.error("Error importing properties", e); throw new IllegalArgumentException("Uploaded file does not look like a properties file"); } if ("full".equals(importMode)) { env.clearVariables(); } else if ("newOnly".equals(importMode)) { for (Entry<String, String> entry : env.getVariableEntries()) { props.remove(entry.getKey()); } } for (Object key : props.keySet()) { env.put((String) key, props.getProperty((String) key)); env.getEncryptedVariables().remove((String) key); } updateUtility.saveEnvironment(env); } }