List of usage examples for java.util Properties propertyNames
public Enumeration<?> propertyNames()
From source file:org.glimpse.server.manager.xml.XmlUserManager.java
@SuppressWarnings("unchecked") public Set<String> getUsers() { FileInputStream fis = null;/*from ww w . jav a 2s. c om*/ try { Properties properties = new Properties(); if (passwordsFile.exists()) { fis = new FileInputStream(passwordsFile); properties.load(fis); fis.close(); } TreeSet<String> users = new TreeSet<String>(); Enumeration<String> names = (Enumeration<String>) properties.propertyNames(); while (names.hasMoreElements()) { String user = (String) names.nextElement(); users.add(user); } return users; } catch (IOException e) { throw new RuntimeException(e); } finally { IOUtils.closeQuietly(fis); } }
From source file:org.sakaiproject.status.StatusServlet.java
protected void reportToolDetails(String toolId, HttpServletResponse response) throws Exception { PrintWriter pw = response.getWriter(); ToolManager tm = (ToolManager) ComponentManager.get("org.sakaiproject.tool.api.ActiveToolManager"); if (tm == null) { throw new Exception("Could not get ToolManager bean."); }// w w w .ja v a 2s . c o m Tool tool = tm.getTool(toolId); if (tool == null) { pw.print("ERROR: no such tool ID\n"); return; } pw.print("id: " + tool.getId() + "\n"); pw.print("title: " + tool.getTitle() + "\n"); pw.print("description: " + tool.getDescription() + "\n"); Properties regProps = tool.getRegisteredConfig(); Enumeration propNames = regProps.propertyNames(); SortedSet sortedPropNames = new TreeSet(); while (propNames.hasMoreElements()) { sortedPropNames.add((String) propNames.nextElement()); } if (sortedPropNames.size() > 0) { pw.print("registered_properties:\n"); for (Object pName : sortedPropNames) { String propertyName = (String) pName; String value = regProps.getProperty(propertyName); pw.print(" " + propertyName + ": " + value + "\n"); } } Properties mutableProps = tool.getMutableConfig(); propNames = mutableProps.propertyNames(); sortedPropNames = new TreeSet(); while (propNames.hasMoreElements()) { sortedPropNames.add((String) propNames.nextElement()); } if (sortedPropNames.size() > 0) { pw.print("mutable_properties:\n"); for (Object pName : sortedPropNames) { String propertyName = (String) pName; String value = mutableProps.getProperty(propertyName); pw.print(" " + propertyName + ": " + value + "\n"); } } Properties finalProps = tool.getFinalConfig(); propNames = finalProps.propertyNames(); sortedPropNames = new TreeSet(); while (propNames.hasMoreElements()) { sortedPropNames.add((String) propNames.nextElement()); } if (sortedPropNames.size() > 0) { pw.print("final_properties:\n"); for (Object pName : sortedPropNames) { String propertyName = (String) pName; String value = finalProps.getProperty(propertyName); pw.print(" " + propertyName + ": " + value + "\n"); } } Set keywords = tool.getKeywords(); if (keywords != null) { if (keywords.size() > 0) { pw.print("keywords:\n"); for (Object keyword : keywords) { pw.print(" - " + keyword + "\n"); } } } Set categories = tool.getCategories(); if (categories != null) { if (categories.size() > 0) { pw.print("categories:\n"); for (Object category : categories) { pw.print(" - " + category + "\n"); } } } }
From source file:org.apache.pdfbox.util.PDFStreamEngine.java
/** * Constructor with engine properties. The property keys are all * PDF operators, the values are class names used to execute those * operators. An empty value means that the operator will be silently * ignored.// w ww . j a v a2s .co m * * @param properties The engine properties. * * @throws IOException If there is an error setting the engine properties. */ public PDFStreamEngine(Properties properties) throws IOException { if (properties == null) { throw new NullPointerException("properties cannot be null"); } Enumeration<?> names = properties.propertyNames(); for (Object name : Collections.list(names)) { String operator = name.toString(); String processorClassName = properties.getProperty(operator); if ("".equals(processorClassName)) { unsupportedOperators.add(operator); } else { try { Class<?> klass = Class.forName(processorClassName); OperatorProcessor processor = (OperatorProcessor) klass.newInstance(); registerOperatorProcessor(operator, processor); } catch (Exception e) { throw new WrappedIOException( "OperatorProcessor class " + processorClassName + " could not be instantiated", e); } } } validCharCnt = 0; totalCharCnt = 0; }
From source file:com.wallabystreet.kinjo.common.transport.ws.ServiceDescriptor.java
/** * Loads the transport-specific service-related properties and stores them * in the service descriptor's <code>properties</code> field. * <p />//from www . j a v a 2s . c o m * This method expects a class * <ul> * <li>named <code>Transport</code> * <li>with a public default (no parameter, that is) constructor</li> * <li>which implements the <code>TransportDescriptor</code> interface * </ul> * in the package name specified in the argument. It creates a new instance * of this class, calls the * {@link com.wallabystreet.kinjo.common.transport.protocol.TransportDescriptor#getServiceRelatedProperties(String, String)} * method on it and copies all key/value pairs from the result into the * service descriptor's <code>properties</code> field. * * @param transportPackage * The package containing the <code>Transport</code> class used * for configuration. * @throws MalformedTransportException, * IIF the <code>Transport</code> class is missing, * inaccessible or incompatible. * * @see com.wallabystreet.kinjo.common.transport.protocol.TransportDescriptor * @see com.wallabystreet.kinjo.common.transport.protocol.TransportDescriptor#getServiceRelatedProperties(String, * String) */ private void loadTransportSpecificConfiguration(String transportPackage) throws MalformedTransportException { // constant for the transport class and package name final String transportPackageName = transportPackage.trim(); final String transportClassName = "Transport"; TransportDescriptor d = null; try { d = (TransportDescriptor) Class.forName(transportPackageName + "." + transportClassName).newInstance(); } catch (InstantiationException e) { String msg = "instantiation failed: " + transportPackageName + "." + transportClassName; if (log.isWarnEnabled()) { log.warn(msg, e); } throw new MalformedTransportException(msg); } catch (IllegalAccessException e) { String msg = "illegal access: " + transportPackageName + "." + transportClassName; if (log.isWarnEnabled()) { log.warn(msg, e); } throw new MalformedTransportException(msg); } catch (ClassNotFoundException e) { String msg = "class not found: " + transportPackageName + "." + transportClassName; if (log.isWarnEnabled()) { log.warn(msg, e); } throw new MalformedTransportException(msg); } Properties p = d.getServiceRelatedProperties(this.name, this.pkg); Enumeration e = p.propertyNames(); while (e.hasMoreElements()) { String property = (String) e.nextElement(); /* * since we don't know whether the returned properties are * java.lang.String instances, we have to use the generic * java.util.Hashtable methods to get and set the properties */ this.properties.put(property, p.get(property)); } }
From source file:org.apache.jackrabbit.core.nodetype.NodeTypeManagerImpl.java
/** * Registers the node types defined in the given input stream depending * on the content type specified for the stream. This will also register * any namespaces identified in the input stream if they have not already * been registered./*w ww . j a va2 s . co m*/ * * @param in node type XML stream * @param contentType type of the input stream * @param reregisterExisting flag indicating whether node types should be * reregistered if they already exist * @return registered node types * @throws IOException if the input stream could not be read or parsed * @throws RepositoryException if the node types are invalid or another * repository error occurs */ public NodeType[] registerNodeTypes(InputStream in, String contentType, boolean reregisterExisting) throws IOException, RepositoryException { // make sure the editing session is allowed to register node types. context.getAccessManager().checkRepositoryPermission(Permission.NODE_TYPE_DEF_MNGMT); try { Map<String, String> namespaceMap = new HashMap<String, String>(); List<QNodeTypeDefinition> nodeTypeDefs = new ArrayList<QNodeTypeDefinition>(); if (contentType.equalsIgnoreCase(TEXT_XML) || contentType.equalsIgnoreCase(APPLICATION_XML)) { try { NodeTypeReader ntr = new NodeTypeReader(in); Properties namespaces = ntr.getNamespaces(); if (namespaces != null) { Enumeration<?> prefixes = namespaces.propertyNames(); while (prefixes.hasMoreElements()) { String prefix = (String) prefixes.nextElement(); String uri = namespaces.getProperty(prefix); namespaceMap.put(prefix, uri); } } QNodeTypeDefinition[] defs = ntr.getNodeTypeDefs(); nodeTypeDefs.addAll(Arrays.asList(defs)); } catch (NameException e) { throw new RepositoryException("Illegal JCR name", e); } } else if (contentType.equalsIgnoreCase(TEXT_X_JCR_CND)) { try { NamespaceMapping mapping = new NamespaceMapping(context.getSessionImpl()); CompactNodeTypeDefReader<QNodeTypeDefinition, NamespaceMapping> reader = new CompactNodeTypeDefReader<QNodeTypeDefinition, NamespaceMapping>( new InputStreamReader(in), "cnd input stream", mapping, new QDefinitionBuilderFactory()); namespaceMap.putAll(mapping.getPrefixToURIMapping()); for (QNodeTypeDefinition ntDef : reader.getNodeTypeDefinitions()) { nodeTypeDefs.add(ntDef); } } catch (ParseException e) { IOException e2 = new IOException(e.getMessage()); e2.initCause(e); throw e2; } } else { throw new UnsupportedRepositoryOperationException("Unsupported content type: " + contentType); } new NamespaceHelper(context.getSessionImpl()).registerNamespaces(namespaceMap); if (reregisterExisting) { NodeTypeRegistry registry = context.getNodeTypeRegistry(); // split the node types into new and already registered node types. // this way we can register new node types together with already // registered node types which make circular dependencies possible List<QNodeTypeDefinition> newNodeTypeDefs = new ArrayList<QNodeTypeDefinition>(); List<QNodeTypeDefinition> registeredNodeTypeDefs = new ArrayList<QNodeTypeDefinition>(); for (QNodeTypeDefinition nodeTypeDef : nodeTypeDefs) { if (registry.isRegistered(nodeTypeDef.getName())) { registeredNodeTypeDefs.add(nodeTypeDef); } else { newNodeTypeDefs.add(nodeTypeDef); } } ArrayList<NodeType> nodeTypes = new ArrayList<NodeType>(); // register new node types nodeTypes.addAll(registerNodeTypes(newNodeTypeDefs)); // re-register already existing node types for (QNodeTypeDefinition nodeTypeDef : registeredNodeTypeDefs) { registry.reregisterNodeType(nodeTypeDef); nodeTypes.add(getNodeType(nodeTypeDef.getName())); } return nodeTypes.toArray(new NodeType[nodeTypes.size()]); } else { Collection<NodeType> types = registerNodeTypes(nodeTypeDefs); return types.toArray(new NodeType[types.size()]); } } catch (InvalidNodeTypeDefException e) { throw new RepositoryException("Invalid node type definition", e); } }
From source file:com.liferay.ide.sdk.core.SDK.java
private boolean hasAppServerSpecificProps(Properties props) { Enumeration<?> names = props.propertyNames(); while (names.hasMoreElements()) { String name = names.nextElement().toString(); if (name.matches("app.server.tomcat.*")) //$NON-NLS-1$ {/*from www .j av a 2s.c o m*/ return true; } } return false; }
From source file:com.atlassian.jira.util.system.ExtendedSystemInfoUtilsImpl.java
public Map<String, String> getSystemPropertiesFormatted(final String suffix) { final Properties sysProps = jiraSystemProperties.getProperties(); @SuppressWarnings("unchecked") final Enumeration<String> propNames = (Enumeration<String>) sysProps.propertyNames(); final boolean isWindows = sysProps.getProperty("os.name").toLowerCase(Locale.getDefault()) .startsWith("windows"); final Map<String, String> props = new TreeMap<String, String>(); final Map<String, String> pathProps = new TreeMap<String, String>(); while (propNames.hasMoreElements()) { final String propertyName = propNames.nextElement(); if (!defaultProps.contains(propertyName)) { if (propertyName.endsWith(".path")) { String htmlValue = sysProps.getProperty(propertyName); if (!isWindows)//for non-windows operating systems split on colons as well {// ww w.ja va 2 s . c o m htmlValue = breakSeperators(htmlValue, ":", suffix); } //as this entry spans multiple lines, put it at the end of the map pathProps.put(propertyName, breakSeperators(htmlValue, ";", suffix)); } else { props.put(propertyName, sysProps.getProperty(propertyName)); } } } final Map<String, String> propsMap = new LinkedHashMap<String, String>(); propsMap.putAll(props); //put all the properties to be added later to the end propsMap.putAll(pathProps); return propsMap; }
From source file:org.wso2.carbon.identity.mgt.IdentityMgtConfig.java
/** * This method is used to load the policies declared in the configuration. * * @param properties Loaded properties * @param extensionType Type of extension *//*from www .j a va 2s . c om*/ private void loadPolicyExtensions(Properties properties, String extensionType) { // First property must start with 1. int count = 1; String className = null; int size = 0; Enumeration<String> keyValues = (Enumeration<String>) properties.propertyNames(); while (keyValues.hasMoreElements()) { String currentProp = keyValues.nextElement(); if (currentProp.contains(extensionType)) { size++; } } //setting the number of extensionTypes as the upper bound as there can be many extension policy numbers, //eg: Password.policy.extensions.1, Password.policy.extensions.4, Password.policy.extensions.15 while (size > 0) { className = properties.getProperty(extensionType + "." + count); if (className == null) { count++; continue; } try { Class clazz = Thread.currentThread().getContextClassLoader().loadClass(className); PolicyEnforcer policy = (PolicyEnforcer) clazz.newInstance(); policy.init(getParameters(properties, extensionType, count)); this.policyRegistry.addPolicy((PolicyEnforcer) policy); count++; size--; } catch (ClassNotFoundException | IllegalAccessException | InstantiationException | SecurityException e) { log.error("Error while loading password policies " + className, e); } } }
From source file:org.xwiki.velocity.internal.DefaultVelocityEngine.java
/** * @param velocityEngine the Velocity engine against which to initialize Velocity properties * @param configurationProperties the Velocity properties coming from XWiki's configuration * @param overridingProperties the Velocity properties that override the properties coming from XWiki's * configuration//from w ww .j av a 2 s. c o m */ private void initializeProperties(org.apache.velocity.app.VelocityEngine velocityEngine, Properties configurationProperties, Properties overridingProperties) { // Avoid "unable to find resource 'VM_global_library.vm' in any resource loader." if no // Velocimacro library is defined. This value is overriden below. velocityEngine.setProperty("velocimacro.library", ""); velocityEngine.setProperty(RuntimeConstants.RUNTIME_LOG_LOGSYSTEM, this); // Configure Velocity by passing the properties defined in this component's configuration if (configurationProperties != null) { for (Enumeration<?> e = configurationProperties.propertyNames(); e.hasMoreElements();) { String key = e.nextElement().toString(); // Only set a property if it's not overridden by one of the passed properties if (!overridingProperties.containsKey(key)) { String value = configurationProperties.getProperty(key); velocityEngine.setProperty(key, value); this.logger.debug("Setting property [{}] = [{}]", key, value); } } } // Override the component's static properties with the ones passed in parameter if (overridingProperties != null) { for (Enumeration<?> e = overridingProperties.propertyNames(); e.hasMoreElements();) { String key = e.nextElement().toString(); String value = overridingProperties.getProperty(key); velocityEngine.setProperty(key, value); this.logger.debug("Overriding property [{}] = [{}]", key, value); } } }
From source file:com.alecgorge.minecraft.jsonapi.NanoHTTPD.java
/** * Override this to customize the server. * <p>/*from ww w .ja v a 2 s. com*/ * * (By default, this delegates to serveFile() and allows directory listing.) * * @parm uri Percent-decoded URI without parameters, for example * "/index.cgi" * @parm method "GET", "POST" etc. * @parm parms Parsed, percent decoded parameters from URI and, in case of * POST, data. * @parm header Header entries, percent decoded * @return HTTP response, see class Response for details */ public Response serve(String uri, String method, Properties header, Properties parms) { System.out.println(method + " '" + uri + "' "); Enumeration<?> e = header.propertyNames(); while (e.hasMoreElements()) { String value = (String) e.nextElement(); System.out.println(" HDR: '" + value + "' = '" + header.getProperty(value) + "'"); } e = parms.propertyNames(); while (e.hasMoreElements()) { String value = (String) e.nextElement(); System.out.println(" PRM: '" + value + "' = '" + parms.getProperty(value) + "'"); } return serveFile(uri, header, new File("."), true); }