List of usage examples for java.util Properties size
@Override public int size()
From source file:org.openecomp.sdnc.sli.aai.AAIService.java
private static Properties initialize(URL url) throws ConfigurationException { if (url == null) { throw new NullPointerException(); }//from w w w . j a va 2 s. c o m InputStream is = null; Properties props = new Properties(); try { if (LOG.isDebugEnabled()) LOG.info("Property file is: " + url.toString()); is = url.openStream(); props.load(is); if (LOG.isDebugEnabled()) { LOG.info("Properties loaded: " + props.size()); Enumeration<Object> en = props.keys(); while (en.hasMoreElements()) { String key = (String) en.nextElement(); String property = props.getProperty(key); LOG.debug(key + " : " + property); } } } catch (Exception e) { throw new ConfigurationException("Could not load properties file.", e); } return props; }
From source file:org.wso2.carbon.registry.core.jdbc.Repository.java
private void dumpRecursively(String path, XMLStreamWriter xmlWriter, Writer writer) throws RegistryException, XMLStreamException { // adding resource meta data ResourceImpl resource = resourceDAO.getResourceMetaData(path); if (resource == null) { return;/*www. java 2 s . c o m*/ } if (!AuthorizationUtils.authorize(path, ActionConstants.GET)) { String msg = getUserNotAuthorizedMsg() + "check out the path " + path + "."; log.warn(msg); throw new AuthorizationFailedException(msg); } xmlWriter.writeStartElement(DumpConstants.RESOURCE); // adding path as an attribute, updated dump has name instead of path xmlWriter.writeAttribute(DumpConstants.RESOURCE_NAME, RegistryUtils.getResourceName(path)); //adding dump attribute xmlWriter.writeAttribute(DumpConstants.RESOURCE_STATUS, DumpConstants.RESOURCE_DUMP); // adding isCollection as an attribute xmlWriter.writeAttribute(DumpConstants.RESOURCE_IS_COLLECTION, (resource instanceof CollectionImpl) ? DumpConstants.RESOURCE_IS_COLLECTION_TRUE : DumpConstants.RESOURCE_IS_COLLECTION_FALSE); OMElement child; // set media type String mediaType = resource.getMediaType(); OMFactory factory = OMAbstractFactory.getOMFactory(); child = factory.createOMElement(new QName(DumpConstants.MEDIA_TYPE)); child.setText(mediaType); child.serialize(xmlWriter); // set version long version = resource.getVersionNumber(); child = factory.createOMElement(new QName(DumpConstants.VERSION)); child.setText(version + ""); child.serialize(xmlWriter); // set creator String creator = resource.getAuthorUserName(); child = factory.createOMElement(new QName(DumpConstants.CREATOR)); child.setText(creator); child.serialize(xmlWriter); // set createdTime Date createdTime = resource.getCreatedTime(); child = factory.createOMElement(new QName(DumpConstants.CREATED_TIME)); child.setText(Long.toString(createdTime.getTime())); child.serialize(xmlWriter); // set updater String updater = resource.getLastUpdaterUserName(); child = factory.createOMElement(new QName(DumpConstants.LAST_UPDATER)); child.setText(updater); child.serialize(xmlWriter); // set LastModified Date lastModified = resource.getLastModified(); child = factory.createOMElement(new QName(DumpConstants.LAST_MODIFIED)); child.setText(Long.toString(lastModified.getTime())); child.serialize(xmlWriter); // set UUID String uuid = resource.getUUID(); child = factory.createOMElement(new QName(DumpConstants.UUID)); child.setText(uuid); child.serialize(xmlWriter); // set Description String description = resource.getDescription(); child = factory.createOMElement(new QName(DumpConstants.DESCRIPTION)); child.setText(description); child.serialize(xmlWriter); // fill properties resourceDAO.fillResourceProperties(resource); Properties properties = resource.getProperties(); if (properties != null && properties.size() > 0) { // properties will be kept inside the <properties> element OMElement propertiesOM = factory.createOMElement(new QName(DumpConstants.PROPERTIES)); for (Object keyObject : properties.keySet()) { String key = (String) keyObject; List<String> propValues = resource.getPropertyValues(key); for (String value : propValues) { OMElement propertyOM = factory.createOMElement(new QName(DumpConstants.PROPERTY_ENTRY)); // adding the key and value as attributes OMAttribute keyAttribute = factory.createOMAttribute(DumpConstants.PROPERTY_ENTRY_KEY, null, key); propertyOM.addAttribute(keyAttribute); if (value != null) { propertyOM.setText(value); } propertiesOM.addChild(propertyOM); } } propertiesOM.serialize(xmlWriter); } // getting comment information Comment[] comments = commentsDAO.getComments(resource); if (comments != null && comments.length > 0) { child = factory.createOMElement(new QName(DumpConstants.COMMENTS)); for (Comment comment : comments) { OMElement commentElement = factory.createOMElement(new QName(DumpConstants.COMMENT_ENTRY)); String user = comment.getAuthorUserName(); String text = comment.getText(); OMElement userElement = factory.createOMElement(new QName(DumpConstants.COMMENT_ENTRY_USER)); userElement.setText(user); commentElement.addChild(userElement); OMElement textElement = factory.createOMElement(new QName(DumpConstants.COMMENT_ENTRY_TEXT)); textElement.setText(text); commentElement.addChild(textElement); child.addChild(commentElement); } child.serialize(xmlWriter); } // getting tagging TaggingDO[] taggings = tagsDAO.getTagging(resource); if (taggings != null && taggings.length > 0) { child = factory.createOMElement(new QName(DumpConstants.TAGGINGS)); for (TaggingDO tagging : taggings) { OMElement taggingElement = factory.createOMElement(new QName(DumpConstants.TAGGING_ENTRY)); String user = tagging.getTaggedUserName(); Date date = tagging.getTaggedTime(); String tagName = tagging.getTagName(); OMElement userElement = factory.createOMElement(new QName(DumpConstants.TAGGING_ENTRY_USER)); userElement.setText(user); taggingElement.addChild(userElement); OMElement dateElement = factory.createOMElement(new QName(DumpConstants.TAGGING_ENTRY_DATE)); String dateString = Long.toString(date.getTime()); dateElement.setText(dateString); taggingElement.addChild(dateElement); OMElement textElement = factory.createOMElement(new QName(DumpConstants.TAGGING_ENTRY_TAG_NAME)); textElement.setText(tagName); taggingElement.addChild(textElement); child.addChild(taggingElement); } child.serialize(xmlWriter); } // getting ratings RatingDO[] ratings = ratingsDAO.getResourceRatingDO(resource); if (ratings != null && ratings.length > 0) { child = factory.createOMElement(new QName(DumpConstants.RATINGS)); for (RatingDO rating : ratings) { OMElement ratingElement = factory.createOMElement(new QName(DumpConstants.RATING_ENTRY)); String user = rating.getRatedUserName(); Date date = rating.getRatedTime(); int rate = rating.getRating(); OMElement userElement = factory.createOMElement(new QName(DumpConstants.RATING_ENTRY_USER)); userElement.setText(user); ratingElement.addChild(userElement); OMElement dateElement = factory.createOMElement(new QName(DumpConstants.RATING_ENTRY_DATE)); String dateString = Long.toString(date.getTime()); dateElement.setText(dateString); ratingElement.addChild(dateElement); OMElement textElement = factory.createOMElement(new QName(DumpConstants.RATING_ENTRY_RATE)); String rateString = String.valueOf(rate); textElement.setText(rateString); ratingElement.addChild(textElement); child.addChild(ratingElement); } child.serialize(xmlWriter); } Association[] associations = associationDAO.getAllAssociations(path); if (associations != null && associations.length > 0) { child = factory.createOMElement(new QName(DumpConstants.ASSOCIATIONS)); for (Association association : associations) { OMElement associationElement = factory.createOMElement(new QName(DumpConstants.ASSOCIATION_ENTRY)); String source = association.getSourcePath(); String destination = association.getDestinationPath(); String type = association.getAssociationType(); // getting the relative paths source = RegistryUtils.getRelativeAssociationPath(source, path); if (destination.startsWith(RegistryConstants.ROOT_PATH)) { // we are treating this as a path destination = RegistryUtils.getRelativeAssociationPath(destination, path); } else { // then the destination is an external association destination = DumpConstants.EXTERNAL_ASSOCIATION_DESTINATION_PREFIX + destination; } OMElement sourceElement = factory .createOMElement(new QName(DumpConstants.ASSOCIATION_ENTRY_SOURCE)); sourceElement.setText(source); associationElement.addChild(sourceElement); OMElement destinationElement = factory .createOMElement(new QName(DumpConstants.ASSOCIATION_ENTRY_DESTINATION)); destinationElement.setText(destination); associationElement.addChild(destinationElement); OMElement typeElement = factory.createOMElement(new QName(DumpConstants.ASSOCIATION_ENTRY_TYPE)); typeElement.setText(type); associationElement.addChild(typeElement); child.addChild(associationElement); } child.serialize(xmlWriter); } // adding contents.. if (!(resource instanceof CollectionImpl)) { resourceDAO.fillResourceContent(resource); byte[] content = (byte[]) resource.getContent(); if (content != null) { child = factory.createOMElement(new QName(DumpConstants.CONTENT)); child.setText(Base64.encode(content)); child.serialize(xmlWriter); } } // getting children and applying dump recursively if (resource instanceof CollectionImpl) { CollectionImpl collection = (CollectionImpl) resource; resourceDAO.fillChildren(collection, 0, -1); String childPaths[] = collection.getChildren(); xmlWriter.writeStartElement(DumpConstants.CHILDREN); OMText emptyText = factory.createOMText(""); emptyText.serialize(xmlWriter); xmlWriter.flush(); for (String childPath : childPaths) { // we would be writing the start element of the child and its name here. try { String resourceName = RegistryUtils.getResourceName(childPath); writer.write("<resource name=\"" + resourceName + "\""); writer.flush(); } catch (IOException e) { String msg = "Error in writing the start element for the path: " + childPath + "."; log.error(msg, e); throw new RegistryException(msg, e); } recursionRepository.dumpRecursively(childPath, new DumpWriter(writer)); } xmlWriter.writeEndElement(); } xmlWriter.writeEndElement(); xmlWriter.flush(); }
From source file:org.olat.core.util.i18n.I18nManager.java
public void setAnnotation(I18nItem i18nItem, String annotation) { Properties properties = getPropertiesWithoutResolvingRecursively(null, i18nItem.getBundleName()); String key = i18nItem.getKey() + METADATA_ANNOTATION_POSTFIX; if (StringHelper.containsNonWhitespace(annotation)) { properties.setProperty(key, annotation); } else if (properties.containsKey(key)) { properties.remove(key);//from ww w.j av a 2s .c om } if (properties.size() == 0) { // delete empty files deleteProperties(null, i18nItem.getBundleName()); } else { // update saveOrUpdateProperties(properties, null, i18nItem.getBundleName()); } }
From source file:com.buaa.cfs.conf.Configuration.java
@Override public void write(DataOutput out) throws IOException { Properties props = getProps(); WritableUtils.writeVInt(out, props.size()); for (Entry<Object, Object> item : props.entrySet()) { com.buaa.cfs.io.Text.writeString(out, (String) item.getKey()); com.buaa.cfs.io.Text.writeString(out, (String) item.getValue()); WritableUtils.writeCompressedStringArray(out, updatingResource.get(item.getKey())); }/* ww w .j a v a 2s . c om*/ }
From source file:de.dal33t.powerfolder.clientserver.ServerClient.java
/** * Load a new configuration from URL configURL * * @param configURL// w w w. ja v a 2 s. co m */ public void loadConfigURL(String configURL) { Reject.ifBlank(configURL, "configURL"); try { // load the configuration from the url ... Properties props = ConfigurationLoader.loadPreConfiguration(configURL.trim()); ConfigurationLoader.merge(props, getController()); String networkID = (String) props.get(ConfigurationEntry.NETWORK_ID.getConfigKey()); String name = (String) props.get(ConfigurationEntry.SERVER_NAME.getConfigKey()); String host = (String) props.get(ConfigurationEntry.SERVER_HOST.getConfigKey()); String nodeId = (String) props.get(ConfigurationEntry.SERVER_NODEID.getConfigKey()); String tunnelURL = (String) props.get(ConfigurationEntry.SERVER_HTTP_TUNNEL_RPC_URL.getConfigKey()); String webURL = (String) props.get(ConfigurationEntry.SERVER_WEB_URL.getConfigKey()); logInfo("Loaded " + props.size() + " from " + configURL + " network ID: " + networkID); if (StringUtils.isBlank(host)) { throw new IOException("Hostname not found"); } String oldNetworkID = getController().getMySelf().getInfo().networkId; if (StringUtils.isNotBlank(networkID)) { getController().getMySelf().getInfo().networkId = networkID; } else { getController().getMySelf().getInfo().networkId = ConfigurationEntry.NETWORK_ID.getDefaultValue(); } String newNetworkID = getController().getMySelf().getInfo().networkId; boolean networkIDChanged = !Util.equals(oldNetworkID, newNetworkID); if (networkIDChanged) { getController().getNodeManager().shutdown(); } init(getController(), name, host, nodeId, allowServerChange, updateConfig); // Store in config setServerWebURLInConfig(webURL); setServerHTTPTunnelURLInConfig(tunnelURL); setServerInConfig(getServer().getInfo()); ConfigurationEntry.NETWORK_ID.setValue(getController(), newNetworkID); ConfigurationEntry.CONFIG_URL.setValue(getController(), configURL); getController().saveConfig(); if (networkIDChanged) { // Restart nodemanager getController().getNodeManager().start(); } connectHostingServers(); } catch (Exception e) { logWarning("Could not load connection infos from " + configURL + ": " + e.getMessage()); } }
From source file:org.apache98.hadoop.conf.Configuration.java
@Override public void write(DataOutput out) throws IOException { Properties props = getProps(); WritableUtils.writeVInt(out, props.size()); for (Map.Entry<Object, Object> item : props.entrySet()) { org.apache98.hadoop.io.Text.writeString(out, (String) item.getKey()); org.apache98.hadoop.io.Text.writeString(out, (String) item.getValue()); WritableUtils.writeCompressedStringArray(out, updatingResource.get(item.getKey())); }// ww w.j a v a2 s. com }
From source file:org.codice.ddf.admin.core.impl.SystemPropertiesAdminTest.java
@Test public void testWriteSystemProperties() throws Exception { Properties userProps = new Properties(); userProps.put("admin", "admin,group,somethingelse"); userProps.put("localhost", "host,group,somethingelse"); try (FileOutputStream outProps = new FileOutputStream(userPropsFile)) { userProps.store(outProps, null); }//from ww w . j a v a 2 s. c o m try (FileOutputStream outAttrs = new FileOutputStream(userAttrsFile)) { String json = "{\n" + " \"admin\" : {\n" + "\n" + " },\n" + " \"localhost\" : {\n" + "\n" + " }\n" + "}"; outAttrs.write(json.getBytes()); } SystemPropertiesAdmin spa = new SystemPropertiesAdmin(mockGuestClaimsHandlerExt); Map<String, String> map = new HashMap<>(); map.put(SystemBaseUrl.INTERNAL_HOST, "newhost"); map.put(SystemBaseUrl.EXTERNAL_HOST, "newhost"); spa.writeSystemProperties(map); // Read the system dot properties file and make sure that the new values evaluate to what we // expect org.apache.felix.utils.properties.Properties systemProps = new org.apache.felix.utils.properties.Properties( systemPropsFile); assertThat(systemProps.getProperty(SystemBaseUrl.EXTERNAL_HOST), equalTo("newhost")); assertThat(systemProps.getProperty(SystemBaseUrl.EXTERNAL_HTTP_PORT), equalTo("5678")); assertThat(systemProps.getProperty(SystemBaseUrl.EXTERNAL_HTTPS_PORT), equalTo("1234")); assertThat(systemProps.getProperty(SystemBaseUrl.INTERNAL_HOST), equalTo("newhost")); assertThat(systemProps.getProperty(SystemBaseUrl.INTERNAL_HTTP_PORT), equalTo("5678")); assertThat(systemProps.getProperty(SystemBaseUrl.INTERNAL_HTTPS_PORT), equalTo("1234")); assertThat(systemProps.getProperty(SystemInfo.ORGANIZATION), equalTo("org")); assertThat(systemProps.getProperty(SystemInfo.SITE_CONTACT), equalTo("contact")); assertThat(systemProps.getProperty(SystemInfo.SITE_NAME), equalTo("site")); assertThat(systemProps.getProperty(SystemInfo.VERSION), equalTo("version")); // only writes out the changed props assertTrue(systemPropsFile.exists()); Properties sysProps = new Properties(); try (FileReader sysPropsReader = new FileReader(systemPropsFile)) { sysProps.load(sysPropsReader); assertThat(sysProps.getProperty(SystemBaseUrl.INTERNAL_HOST), equalTo("newhost")); } userProps = new Properties(); try (FileReader userPropsReader = new FileReader(userPropsFile)) { userProps.load(userPropsReader); assertThat(userProps.size(), is(2)); assertThat(userProps.getProperty("newhost"), equalTo("host,group,somethingelse")); } map.put(SystemBaseUrl.INTERNAL_HOST, "anotherhost"); spa.writeSystemProperties(map); userProps = new Properties(); try (FileReader userPropsReader = new FileReader(userPropsFile)) { userProps.load(userPropsReader); assertThat(userProps.size(), is(2)); assertThat(userProps.getProperty("anotherhost"), equalTo("host,group,somethingelse")); assertNull(userProps.getProperty("newhost")); assertNull(userProps.getProperty("host")); } try (BufferedReader userAttrsReader = new BufferedReader(new FileReader(userAttrsFile))) { String line = null; boolean hasHost = false; while ((line = userAttrsReader.readLine()) != null) { if (line.contains("anotherhost")) { hasHost = true; } } if (!hasHost) { fail("User attribute file did not get updated."); } } }
From source file:org.hyperic.hq.ui.action.resource.ResourceController.java
protected AppdefEntityID setResource(HttpServletRequest request, HttpServletResponse response, AppdefEntityID entityId, boolean config) throws Exception { Integer sessionId = RequestUtils.getSessionId(request); AppdefEntityTypeID aetid;/* w w w . j ava2s . c om*/ if (null == entityId || entityId instanceof AppdefEntityTypeID) { // this can happen if we're an auto-group of platforms request.setAttribute(Constants.CONTROL_ENABLED_ATTR, Boolean.FALSE); request.setAttribute(Constants.PERFORMANCE_SUPPORTED_ATTR, Boolean.FALSE); try { if (entityId != null) { aetid = (AppdefEntityTypeID) entityId; } else { aetid = new AppdefEntityTypeID( RequestUtils.getStringParameter(request, Constants.APPDEF_RES_TYPE_ID)); } AppdefResourceTypeValue resourceTypeVal = appdefBoss.findResourceTypeById(sessionId.intValue(), aetid); request.setAttribute(Constants.RESOURCE_TYPE_ATTR, resourceTypeVal); // Set the title parameters request.setAttribute(Constants.TITLE_PARAM_ATTR, resourceTypeVal.getName()); } catch (Exception e) { log.debug("Error setting resource attributes", e); } } else { try { log.trace("finding resource [" + entityId + "]"); AppdefResourceValue resource = appdefBoss.findById(sessionId.intValue(), entityId); log.trace("finding owner for resource [" + entityId + "]"); AuthzSubject owner = authzBoss.findSubjectByNameNoAuthz(sessionId, resource.getOwner()); log.trace("finding most recent modifier for resource [" + entityId + "]"); AuthzSubject modifier = authzBoss.findSubjectByNameNoAuthz(sessionId, resource.getModifiedBy()); RequestUtils.setResource(request, resource); request.setAttribute(Constants.RESOURCE_OWNER_ATTR, owner); request.setAttribute(Constants.RESOURCE_MODIFIER_ATTR, modifier); request.setAttribute(Constants.TITLE_PARAM_ATTR, resource.getName()); if (resource instanceof AppdefGroupValue) { request.setAttribute(Constants.GROUP_TYPE_ATTR, ((AppdefGroupValue) resource).getGroupType()); } // set the resource controllability flag if (!entityId.isApplication()) { // We were doing group Specific isGroupControlEnabled for // groups. // We should just see if the group control is supported // regardless of whether control is enabled or not. Also we // should be calling isControlSupported on entity and not // controlEnabled. boolean isControllable = controlBoss.isControlSupported(sessionId.intValue(), resource); request.setAttribute(Constants.CONTROL_ENABLED_ATTR, new Boolean(isControllable)); } // Set additional flags UIUtils utils = (UIUtils) ProductProperties.getPropertyInstance("hyperic.hq.ui.utils"); utils.setResourceFlags(resource, config, request, getServlet().getServletContext()); // Get the custom properties Properties cprops = appdefBoss.getCPropDescEntries(sessionId.intValue(), entityId); Resource resourceObj = Bootstrap.getBean(ResourceManager.class).findResource(entityId); if ((entityId.isPlatform() || entityId.isServer()) && appdefBoss.hasVirtualResourceRelation(resourceObj)) { Collection mastheadAttachments = Bootstrap.getBean(ProductBoss.class) .findAttachments(sessionId.intValue(), AttachType.MASTHEAD); Map pluginLinkMap = new HashMap(); for (Iterator i = mastheadAttachments.iterator(); i.hasNext();) { AttachmentDescriptor descriptor = (AttachmentDescriptor) i.next(); if (descriptor.getAttachment().getView().getPlugin().getName().equals("vsphere")) { ResourceEdge parent = Bootstrap.getBean(ResourceManager.class).getParentResourceEdge( resourceObj, Bootstrap.getBean(ResourceManager.class).getVirtualRelation()); // TODO This is ugly and I hate putting it in, but there's no easy way to link into a // plugin right now... if (parent != null && parent.getTo().getPrototype().getName() .equals(AuthzConstants.platformPrototypeVmwareVsphereVm)) { UriTemplate uriTemplate = new UriTemplate( "/mastheadAttach.do?typeId={typeId}&sn={sn}"); cprops.put("VM Instance", "<a href='" + response .encodeURL( uriTemplate .expand(descriptor.getAttachment().getId(), parent.getTo().getId()) .toASCIIString()) + "'>" + parent.getTo().getName() + "</a>"); } else { pluginLinkMap.put("pluginId", descriptor.getAttachment().getId()); pluginLinkMap.put("selectedId", resourceObj.getId()); request.setAttribute("pluginLinkInfo", pluginLinkMap); } break; } } } // Set the properties in the request if (cprops.size() > 0) { request.setAttribute("cprops", cprops); } // Add this resource to the recently used preference WebUser user = RequestUtils.getWebUser(request); ConfigResponse userPrefs = user.getPreferences(); if (DashboardUtils.addEntityToPreferences(Constants.USERPREF_KEY_RECENT_RESOURCES, userPrefs, entityId, 10)) { authzBoss.setUserPrefs(user.getSessionId(), user.getSubject().getId(), userPrefs); } } catch (AppdefEntityNotFoundException aenf) { RequestUtils.setError(request, Constants.ERR_RESOURCE_NOT_FOUND); throw aenf; } catch (PermissionException e) { throw e; } catch (Exception e) { log.error("Unable to find resource", e); throw AppdefEntityNotFoundException.build(entityId, e); } } return entityId; }
From source file:net.wastl.webmail.server.WebMailServlet.java
public void init(ServletConfig config) throws ServletException { final ServletContext sc = config.getServletContext(); log.debug("Init"); final String depName = (String) sc.getAttribute("deployment.name"); final Properties rtProps = (Properties) sc.getAttribute("meta.properties"); log.debug("RT configs retrieved for application '" + depName + "'"); srvlt_config = config;/* ww w . jav a 2 s . c om*/ this.config = new Properties(); final Enumeration enumVar = config.getInitParameterNames(); while (enumVar.hasMoreElements()) { final String s = (String) enumVar.nextElement(); this.config.put(s, config.getInitParameter(s)); log.debug(s + ": " + config.getInitParameter(s)); } /* * Issue a warning if webmail.basepath and/or webmail.imagebase are not * set. */ if (config.getInitParameter("webmail.basepath") == null) { log.warn("webmail.basepath initArg should be set to the WebMail " + "Servlet's base path"); basepath = ""; } else { basepath = config.getInitParameter("webmail.basepath"); } if (config.getInitParameter("webmail.imagebase") == null) { log.error("webmail.basepath initArg should be set to the WebMail " + "Servlet's base path"); imgbase = ""; } else { imgbase = config.getInitParameter("webmail.imagebase"); } /* * Try to get the pathnames from the URL's if no path was given in the * initargs. */ if (config.getInitParameter("webmail.data.path") == null) { this.config.put("webmail.data.path", sc.getRealPath("/data")); } if (config.getInitParameter("webmail.lib.path") == null) { this.config.put("webmail.lib.path", sc.getRealPath("/lib")); } if (config.getInitParameter("webmail.template.path") == null) { this.config.put("webmail.template.path", sc.getRealPath("/lib/templates")); } if (config.getInitParameter("webmail.xml.path") == null) { this.config.put("webmail.xml.path", sc.getRealPath("/lib/xml")); } if (config.getInitParameter("webmail.log.facility") == null) { this.config.put("webmail.log.facility", "net.wastl.webmail.logger.ServletLogger"); } // Override settings with webmail.* meta.properties final Enumeration rte = rtProps.propertyNames(); int overrides = 0; String k; while (rte.hasMoreElements()) { k = (String) rte.nextElement(); if (!k.startsWith("webmail.")) { continue; } overrides++; this.config.put(k, rtProps.getProperty(k)); } log.debug(Integer.toString(overrides) + " settings passed to WebMailServer, out of " + rtProps.size() + " RT properties"); /* * Call the WebMailServer's initialization method and forward all * Exceptions to the ServletServer */ try { doInit(); } catch (final Exception e) { log.error("Could not intialize", e); throw new ServletException("Could not intialize: " + e.getMessage(), e); } Helper.logThreads("Bottom of WebMailServlet.init()"); }
From source file:edu.ku.brc.ui.UIHelper.java
/** * Parses a string for ";" colon separated name/value pairs. In order to allow '=' in the value portion * of the string, the first '=' is assumed to separate the name and value. All other occurances of '=' * are left untouched.//from w ww . j a v a 2 s.c o m * * @param namedValuePairs a string of named/value pairs * @return a properties object with the named value pairs or null if the string it null or empty */ public static Properties parseProperties(final String nameValuePairs) { if (isNotEmpty(nameValuePairs)) { Properties props = new Properties(); for (String pair : StringUtils.split(nameValuePairs, ";")) { int firstEqualsSign = pair.indexOf('='); // the the '=' isn't present or is the last character, ERROR if (firstEqualsSign == -1 || firstEqualsSign == pair.length() - 1) { log.error("Initialize string[" + nameValuePairs + "] must be a set of name/value pairs separated by ';'."); } else { String name = pair.substring(0, firstEqualsSign); String value = pair.substring(firstEqualsSign + 1); props.put(name, value); } } return props.size() > 0 ? props : null; } return null; }