List of usage examples for java.util Properties clear
@Override public synchronized void clear()
From source file:com.pureinfo.srmcenter.datasync.client.config.action.WebConfigSetAction.java
/** * @see com.pureinfo.ark.interaction.ActionBase#executeAction() *//*from ww w . j a v a 2 s . c o m*/ public ActionForward executeAction() throws PureException { String sFileName = ClassResourceUtil.mapFullPath("plugin/system/system-datasync.properties", true); File file = new File(sFileName); if (!file.getParentFile().exists()) file.mkdir(); Properties props = new Properties(); props.put("sync.server.host", request.getRequiredString("serverHost", true, "")); props.put("sync.active.start.time", request.getRequiredString("activeTime", true, "")); props.put("sync.upload.start.time", request.getRequiredString("uploadTime", true, "")); props.put("sync.download.start.time", request.getRequiredString("downloadTime", true, "")); props.put("sync.proxy.host", request.getString("proxyHost", true)); props.put("sync.proxy.port", request.getString("proxyPort", true)); props.put("sync.proxy.user", request.getString("proxyUser", true)); props.put("sync.proxy.password", request.getString("proxyPassword", true)); props.put("sync.count.per.time", request.getRequiredString("countPerTime", true, "")); props.put("sync.retry.times", request.getRequiredString("retryTimes", true, "")); try { PropertiesUtil.storeToFile(props, file); PureSystem.getProperties().putAll(props); } catch (FileNotFoundException ex) { throw new PureException(PureException.UNKNOWN, "", ex); } finally { props.clear(); } setProxy(); // restart engine restartEngine(); return mapping.findForward("success"); }
From source file:edu.ku.brc.specify.utilapps.RegisterApp.java
/** * @param entries/*from ww w. ja v a 2s .co m*/ * @return */ private Vector<String> getKeyWordsList(final Collection<RegProcEntry> entries) { Properties props = new Properties(); Hashtable<String, Boolean> statKeywords = new Hashtable<String, Boolean>(); for (RegProcEntry entry : entries) { props.clear(); props.putAll(entry.getProps()); String os = props.getProperty("os_name"); String ver = props.getProperty("os_version"); props.put("platform", os + " " + ver); for (Object keywordObj : props.keySet()) { statKeywords.put(keywordObj.toString(), true); } } String[] trackKeys = rp.getTrackKeys(); for (String keyword : new Vector<String>(statKeywords.keySet())) { if (keyword.startsWith("Usage") || keyword.startsWith("num_") || keyword.endsWith("_portal") || keyword.endsWith("_number") || keyword.endsWith("_website") || keyword.endsWith("id") || keyword.endsWith("os_name") || keyword.endsWith("os_version")) { statKeywords.remove(keyword); } else { for (String key : trackKeys) { if (keyword.startsWith(key)) { statKeywords.remove(keyword); } } } } statKeywords.remove("date"); //statKeywords.remove("time"); statKeywords.put("by_date", true); statKeywords.put("by_month", true); statKeywords.put("by_year", true); return new Vector<String>(statKeywords.keySet()); }
From source file:gemlite.core.internal.db.DBSynchronizer.java
protected synchronized void instantiateConnection() { if (this.driver == null) { initConnection();/*from w w w. ja v a 2s.co m*/ return; } String maskedPasswordDbUrl = null; try { // use Driver directly for connect instead of looping through all // drivers as DriverManager.getConnection() would do, to avoid // hitting any broken drivers in the process (vertica driver is // known to // fail in acceptsURL with this set of properties) final Properties props = new Properties(); // the user/password property names are standard ones also used by // DriverManager.getConnection(String, String, String) itself, so // will work for all drivers if (this.userName != null) { props.put("user", this.userName); } if (this.passwd != null) { props.put("password", this.passwd); } this.conn = this.driver.connect(this.dbUrl, props); // null to GC password as soon as possible props.clear(); try { // try to set the default isolation to at least READ_COMMITTED // need it for proper HA handling if (this.conn.getTransactionIsolation() < Connection.TRANSACTION_READ_COMMITTED && this.conn .getMetaData().supportsTransactionIsolationLevel(Connection.TRANSACTION_READ_COMMITTED)) { this.conn.setTransactionIsolation(Connection.TRANSACTION_READ_COMMITTED); if (this.dbUrl != null) { maskedPasswordDbUrl = maskPassword(this.dbUrl); } logger.info("explicitly set the transaction isolation level to " + "READ_COMMITTED for URL: " + maskedPasswordDbUrl); } } catch (SQLException sqle) { // ignore any exception here } this.conn.setAutoCommit(false); this.shutDown = false; } catch (Exception e) { if (this.dbUrl != null) { maskedPasswordDbUrl = maskPassword(this.dbUrl); } // throttle retries for connection failures try { Thread.sleep(200); } catch (InterruptedException ie) { Thread.currentThread().interrupt(); } throw helper.newRuntimeException( String.format(DB_SYNCHRONIZER__6, this.driverClass, maskedPasswordDbUrl), e); } }
From source file:com.pureinfo.srm.reports.table.data.pinggu.ParameterSetAction.java
/** * @see com.pureinfo.ark.interaction.ActionBase#executeAction() *///from w ww.j a v a 2 s . co m public ActionForward executeAction() throws PureException { tempOrgCode = request.getRequiredParameter("tempOrgCode", "code"); propFileName = ClassResourceUtil.mapFullPath(propFileName, true); Properties prop = new Properties(); InputStream iFile = null; FileOutputStream oFile = null; try { iFile = new FileInputStream(propFileName); prop.load(iFile); String codeInSystem = prop.getProperty("parameter.org.code"); if (StringUtils.isEmpty(codeInSystem)) { codeInSystem = tempOrgCode; } else { String[] codeArr = codeInSystem.split(","); Arrays.sort(codeArr); int index = Arrays.binarySearch(codeArr, tempOrgCode); if (index < 0) { codeInSystem += "," + tempOrgCode; } } prop.setProperty("parameter.org.code", codeInSystem); Enumeration e = request.getParameterNames(); while (e.hasMoreElements()) { String name = (String) e.nextElement(); if (!name.startsWith("para.")) { continue; } String value = request.getParameter(name); if (StringUtils.isEmpty(value)) { logger.debug("the value of " + name.substring(5) + " is empty.SKIP."); continue; } value = value.trim(); logger.debug("to set property:" + name.substring(5) + "with[" + value + "]"); prop.setProperty(name.substring(5), value); } oFile = new FileOutputStream(propFileName, false); prop.store(oFile, "parameter for pinggu"); // to reload properties. PureSystem.shutdown(); } catch (Exception ex) { throw new PureException(0, "", ex); } finally { try { if (iFile != null) iFile.close(); if (oFile != null) oFile.close(); prop.clear(); } catch (IOException e) { e.printStackTrace(System.err); } } return mapping.findForward("success"); }
From source file:domain.Proceso.java
public void subirArchivo_2(String archivo) { Properties filesProperties = new Properties(); Integer countfiles;/* w w w . j av a 2s. c o m*/ Integer cantidad_carpetas; FileInputStream file; // rutaOrigenArchivo = ruta; //nombreArchivo = archivo; cantidad_carpetas = Integer.parseInt(properties.getProperty("number_up")); for (int i = 0; i < cantidad_carpetas; i++) { try { ftp.uploadpath = properties.getProperty("uploadpath" + (i + 1)); ftp.subirArchivo(archivo); File fichero = new File(files); if (fichero.delete()) { log.log("Archivo properties de " + ftp.uploadpath + " eliminado", false); } else { log.log("Error al Eliminar el archivo Files properties de carpeta a subir, en directorio local", true); } //descargar Archivo properties de la carpeta ftp.downloadpath = ftp.uploadpath; ftp.descargarArchivo(files); file = new FileInputStream(files); filesProperties.load(file); file.close(); //Obtener el valor countfiles countfiles = Integer.parseInt(filesProperties.getProperty("countfiles")); //Actualizar el valor countfiles en el archivo + 1 countfiles += 1; filesProperties.replace("countfiles", countfiles + ""); //Insertar valor de "file+[countfiles + 1] = export.nombreArchivo" filesProperties.setProperty("file" + countfiles, archivo); //Insertar valor de "fileStatus +[countfile + 1] filesProperties.setProperty("fileStatus" + countfiles, "S"); // filesProperties.store(file, ""); FileOutputStream fos = new FileOutputStream(files); filesProperties.store(fos, null); ftp.subirArchivo(files); filesProperties.clear(); fos.close(); } catch (IOException ex) { log.log("Error: " + ex.getMessage(), true); Logger.getLogger(Proceso.class.getName()).log(Level.SEVERE, null, ex); } } }
From source file:com.twinsoft.convertigo.eclipse.ConvertigoPlugin.java
static public Properties decodePsc(String psc) throws PscException { if (psc.length() == 0) { throw new PscException("Invalid PSC (empty)!"); } else {/*from www. j av a2 s . co m*/ Properties properties = new Properties(); try { String decipheredPSC = Crypto2.decodeFromHexString("registration", psc); if (decipheredPSC == null) { throw new PscException("Invalid PSC (unable to decipher)!"); } else if (!decipheredPSC.startsWith("# PSC file")) { throw new PscException("Invalid PSC (wrong format)!"); } else { try { properties.load(IOUtils.toInputStream(decipheredPSC, "utf8")); } catch (IOException e) { throw new PscException("Invalid PSC (cannot load properties)!"); } } } catch (PscException e) { try { String decipheredPSC = SimpleCipher.decode(psc); properties.load(IOUtils.toInputStream(decipheredPSC, "utf8")); String server = properties.getProperty("server"); String user = properties.getProperty("admin.user"); String password = properties.getProperty("admin.password"); if (server == null && user == null && password == null) { throw e; } if (server == null || user == null || password == null) { throw new PscException("Invalid PSC (incomplet data)!"); } if (!user.equals(SimpleCipher.decode(password))) { throw new PscException("Invalid PSC (altered data)"); } boolean bHttps = Boolean.parseBoolean(properties.getProperty("https")); properties.clear(); DeploymentKey.adminUser.setValue(properties, 1, user); DeploymentKey.adminPassword.setValue(properties, 1, password); DeploymentKey.server.setValue(properties, 1, server); DeploymentKey.sslHttps.setValue(properties, 1, Boolean.toString(bHttps)); } catch (PscException ex) { throw ex; } catch (Exception ex) { throw e; } } int i = 0; while (++i > 0) { if (i > 1 && !properties.containsKey(DeploymentKey.adminUser.key(i))) { i = -1; } else { for (DeploymentKey key : DeploymentKey.values()) { if (!properties.containsKey(key.key(i))) { if (!key.hasDefault()) { throw new PscException("Invalid PSC (altered data)"); } key.setValue(properties, i); } } } } return properties; } }
From source file:edu.ku.brc.specify.web.SpecifyExplorer.java
/** * @param out/*from ww w . j a va 2 s. c om*/ */ protected void showQueryIndex(final HttpServletResponse response) throws IOException { response.setContentType("text/html"); PrintWriter out = response.getWriter(); int inx = template.indexOf(contentTag); String subContent = template.substring(0, inx); out.println(StringUtils.replace(subContent, "<!-- Title -->", "Queries")); DataProviderSessionIFace session = null; try { session = DataProviderFactory.getInstance().createSession(); Properties props = new Properties(); int cnt = 0; StringBuilder sb = new StringBuilder(); sb.append("<BR><table width=\"100%\" cellspacing=\"0\" class=\"brdr\">\n"); List<?> list = session.getDataList( "SELECT sq.id, sq.name FROM SpQuery sq INNER JOIN sq.specifyUser spu WHERE spu.id = " + AppContextMgr.getInstance().getClassObject(SpecifyUser.class).getId()); for (Object rowObj : list) { Object[] cols = (Object[]) rowObj; props.clear(); props.put("id", cols[0]); props.put("query", "1"); String anchor = makeURLLink(null, cols[1].toString(), props); sb.append("<tr><td class=\"brdr" + ((cnt % 2 == 0) ? "even" : "odd") + "\">" + anchor + "</td></tr>\n"); cnt++; } sb.append("</TABLE>"); out.println(sb.toString()); } catch (org.hibernate.exception.SQLGrammarException ex) { log.error(ex); } finally { if (session != null) { session.close(); } } out.println(template.substring(inx + contentTag.length() + 1, template.length())); }
From source file:op.OPDE.java
private static boolean loadLocalProperties() { boolean success = false; Properties sysprops = System.getProperties(); try {/*from w ww . j av a2s. c o m*/ FileInputStream in = new FileInputStream(new File(opwd + sep + AppInfo.fileConfig)); Properties p = new Properties(); p.load(in); localProps.putAll(p); p.clear(); in.close(); success = true; } catch (FileNotFoundException ex) { fatal(new Throwable(lang.getString("misc.msg.installation.error"))); // // Keine local.properties. Wir richten wohl gerade einen neuen Client ein. // // FrmInit frame = new FrmInit(); // frame.setVisible(true); // SYSTools.center(frame); } catch (IOException ex) { fatal(ex); // System.exit(1); } return success; }
From source file:org.apache.felix.karaf.jaas.modules.properties.PropertiesLoginModule.java
public boolean login() throws LoginException { Properties users = new Properties(); File f = new File(usersFile); try {//from w ww. j a va 2 s .com users.load(new java.io.FileInputStream(f)); } catch (IOException ioe) { throw new LoginException("Unable to load user properties file " + f); } Callback[] callbacks = new Callback[2]; callbacks[0] = new NameCallback("Username: "); callbacks[1] = new PasswordCallback("Password: ", false); try { callbackHandler.handle(callbacks); } catch (IOException ioe) { throw new LoginException(ioe.getMessage()); } catch (UnsupportedCallbackException uce) { throw new LoginException(uce.getMessage() + " not available to obtain information from user"); } user = ((NameCallback) callbacks[0]).getName(); char[] tmpPassword = ((PasswordCallback) callbacks[1]).getPassword(); if (tmpPassword == null) { tmpPassword = new char[0]; } String userInfos = (String) users.get(user); if (userInfos == null) { throw new FailedLoginException("User does not exist"); } String[] infos = userInfos.split(","); if (!new String(tmpPassword).equals(infos[0])) { throw new FailedLoginException("Password does not match"); } principals = new HashSet<Principal>(); principals.add(new UserPrincipal(user)); for (int i = 1; i < infos.length; i++) { principals.add(new RolePrincipal(infos[i])); } users.clear(); if (debug) { LOG.debug("login " + user); } return true; }