List of usage examples for java.util Properties propertyNames
public Enumeration<?> propertyNames()
From source file:ORG.oclc.os.SRW.SRWDatabase.java
protected void initDB(final String dbname, String srwHomeVal, String dbHome, String dbPropertiesFileName, Properties dbProperties) { log.debug("Enter: private initDB, dbname=" + dbname); this.dbname = dbname; srwHome = srwHomeVal;//www . j av a2s. c om this.dbHome = dbHome; this.dbPropertiesFileName = dbPropertiesFileName; this.dbProperties = dbProperties; if (dbProperties != null) { String httpHeaderSetterClass = dbProperties.getProperty("HttpHeaderSetter"); if (httpHeaderSetterClass != null) { try { httpHeaderSetter = (HttpHeaderSetter) Class.forName(httpHeaderSetterClass).newInstance(); httpHeaderSetter.init(dbProperties); } catch (InstantiationException ex) { log.error("Unable to create HttpHeaderSetter: " + httpHeaderSetterClass, ex); } catch (IllegalAccessException ex) { log.error("Unable to create HttpHeaderSetter: " + httpHeaderSetterClass, ex); } catch (ClassNotFoundException ex) { log.error("Unable to create HttpHeaderSetter: " + httpHeaderSetterClass, ex); } } // get schema transformers String firstSchema = null, xmlSchemaList = dbProperties.getProperty("xmlSchemas"); StringBuffer schemaInfoBuf = new StringBuffer(" <schemaInfo>\n"); StringTokenizer st; if (xmlSchemaList != null) { Enumeration propertyNames; String name, schemaIdentifier, schemaName, transformerName, value; Vector<String> parms, values; st = new StringTokenizer(xmlSchemaList, ", \t"); log.info("xmlSchemaList=" + xmlSchemaList); while (st.hasMoreTokens()) { schemaName = st.nextToken(); log.debug("looking for schema " + schemaName); if (firstSchema == null) firstSchema = schemaName; schemaIdentifier = dbProperties.getProperty(schemaName + ".identifier"); transformerName = dbProperties.getProperty(schemaName + ".transformer"); if (transformerName == null) { // maybe this is an old .props file and the transformer name // is associated with the bare schemaName transformerName = dbProperties.getProperty(schemaName); } parms = new Vector<String>(); values = new Vector<String>(); propertyNames = dbProperties.propertyNames(); while (propertyNames.hasMoreElements()) { name = (String) propertyNames.nextElement(); if (name.startsWith(schemaName + ".parameter.")) { value = dbProperties.getProperty(name); values.add(value); name = name.substring(schemaName.length() + 11); parms.add(name); if (log.isDebugEnabled()) log.debug("transformer parm: " + name + "=" + value); } } try { addTransformer(schemaName, schemaIdentifier, transformerName, parms, values); addRenderer(schemaName, schemaIdentifier, dbProperties); String schemaLocation = dbProperties.getProperty(schemaName + ".location"); String schemaTitle = dbProperties.getProperty(schemaName + ".title"); String schemaNamespace = dbProperties.getProperty(schemaName + ".namespace"); if (schemaNamespace != null) nameSpaces.put(schemaName, schemaNamespace); else nameSpaces.put(schemaName, "NoNamespaceProvided"); schemaInfoBuf.append(" <schema sort=\"false\" retrieve=\"true\"") .append(" name=\"").append(schemaName).append("\"\n identifier=\"") .append(schemaIdentifier).append("\"\n location=\"") .append(schemaLocation).append("\">\n").append(" <title>") .append(schemaTitle).append("</title>\n").append(" </schema>\n"); } catch (Exception e) { log.error("Unable to load schema " + schemaName); log.error(e, e); } } defaultSchema = dbProperties.getProperty("defaultSchema"); if (defaultSchema == null) defaultSchema = firstSchema; log.info("defaultSchema=" + defaultSchema); schemaIdentifier = schemas.get(defaultSchema); log.info("default schemaID=" + schemaIdentifier); if (schemaIdentifier == null) log.error("Default schema " + defaultSchema + " not loaded"); else { schemas.put("default", schemaIdentifier); Transformer t = transformers.get(defaultSchema); if (t != null) { transformers.put("default", t); } } } schemaInfoBuf.append(" </schemaInfo>\n"); schemaInfo = schemaInfoBuf.toString(); String t = srwProperties.getProperty("SRW.Context"); if (t != null) servletContext = t; explainStyleSheet = dbProperties.getProperty("explainStyleSheet"); //MIH remove///////////////////////////////////////////////////// // if(explainStyleSheet==null) // explainStyleSheet="/$context/explainResponse.xsl"; ///////////////////////////////////////////////////////////////// searchStyleSheet = dbProperties.getProperty("searchStyleSheet"); //MIH remove///////////////////////////////////////////////////// // if(searchStyleSheet==null) // searchStyleSheet="/$context/searchRetrieveResponse.xsl"; ///////////////////////////////////////////////////////////////// scanStyleSheet = dbProperties.getProperty("scanStyleSheet"); //MIH remove///////////////////////////////////////////////////// // if(scanStyleSheet==null) // scanStyleSheet="/$context/scanResponse.xsl"; ///////////////////////////////////////////////////////////////// if (servletContext != null && servletContext.startsWith("/")) servletContext = servletContext.substring(1); if (servletContext != null && servletContext.length() > 0) { //MIH avoid NULL/////////////////////////////////////////////// if (explainStyleSheet != null) { explainStyleSheet = explainStyleSheet.replace("$context", servletContext); } if (searchStyleSheet != null) { searchStyleSheet = searchStyleSheet.replace("$context", servletContext); } if (scanStyleSheet != null) { scanStyleSheet = scanStyleSheet.replace("$context", servletContext); } ///////////////////////////////////////////////////////////////// } else { //MIH avoid NULL/////////////////////////////////////////////// if (explainStyleSheet != null) { explainStyleSheet = explainStyleSheet.replace("/$context", ""); } if (searchStyleSheet != null) { searchStyleSheet = searchStyleSheet.replace("/$context", ""); } if (scanStyleSheet != null) { scanStyleSheet = scanStyleSheet.replace("/$context", ""); } ///////////////////////////////////////////////////////////////// } } log.debug("Exit: private initDB"); }
From source file:org.apache.directory.fortress.core.impl.UserTestData.java
/** * Determine if a given User object contains its assigned properties values. * * @param usr expected user properties/*from w w w. j ava2s . co m*/ * @param properties actual user properties */ public static void assertProps(String[] usr, Properties properties) { Properties usrProps = getProps(usr); if (usrProps != null) { assertNotNull(UserTestData.class.getName() + ".assertProps null for user: " + getUserId(usr), properties); for (Enumeration<?> e = properties.propertyNames(); e.hasMoreElements();) { String key = (String) e.nextElement(); String val = usrProps.getProperty(key); String uval = usrProps.getProperty(key); assertEquals(UserTestData.class.getName() + ".assertProps failed compare props for user: " + getUserId(usr) + ", key: " + key + ", expected value: " + val + ", actual value: " + uval, val, uval); } } }