List of usage examples for java.util Properties keys
@Override
public Enumeration<Object> keys()
From source file:org.openecomp.sdnc.sli.aai.AAIService.java
private static Properties initialize(URL url) throws ConfigurationException { if (url == null) { throw new NullPointerException(); }// w ww . jav a2s. 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:gdt.data.store.Entigrator.java
/** * List keys of entities having certain properties assigned. * @param criteria the properties object that contains a set * of property name/value pairs.//from w w w .j av a 2 s . c o m * @return string array of entities keys. */ public String[] indx_listEntities(Properties criteria) { if (criteria == null) return null; Enumeration<?> en = criteria.keys(); String propertyName$; String propertyValue$; String[] cur = null; String[] sum = null; int i = 0; while (en.hasMoreElements()) { try { propertyName$ = (String) en.nextElement(); propertyValue$ = criteria.getProperty(propertyName$); cur = indx_listEntities(propertyName$, propertyValue$); if (cur == null) return null; if (i++ == 0) sum = cur; else sum = intersect(sum, cur); if (sum == null || sum.length < 1) return null; } catch (Exception e) { LOGGER.severe(":indx_listEntities:" + e.toString()); } } return sum; }
From source file:org.sakaiproject.basiclti.util.SakaiBLTIUtil.java
/** * An LTI 2.0 ContentItemSelectionRequest launch * * This must return an HTML message as the [0] in the array * If things are successful - the launch URL is in [1] *///w w w . ja v a2s . c o m public static String[] postContentItemSelectionRequest(Long toolKey, Map<String, Object> tool, ResourceLoader rb, String contentReturn, Properties dataProps) { if (tool == null) { return postError( "<p>" + getRB(rb, "error.tool.missing", "Tool is missing or improperly configured.") + "</p>"); } String launch_url = (String) tool.get("launch"); if (launch_url == null) return postError("<p>" + getRB(rb, "error.tool.noreg", "This tool is has no launch url.") + "</p>"); String consumerkey = (String) tool.get(LTIService.LTI_CONSUMERKEY); String secret = (String) tool.get(LTIService.LTI_SECRET); // If secret is encrypted, decrypt it secret = decryptSecret(secret); if (secret == null || consumerkey == null) { return postError("<p>" + getRB(rb, "error.tool.partial", "Tool is incomplete, missing a key and secret.") + "</p>"); } // Start building up the properties Properties ltiProps = new Properties(); setProperty(ltiProps, BasicLTIConstants.LTI_VERSION, BasicLTIConstants.LTI_VERSION_1); setProperty(ltiProps, BasicLTIUtil.BASICLTI_SUBMIT, getRB(rb, "launch.button", "Press to Launch External Tool")); setProperty(ltiProps, BasicLTIConstants.LTI_MESSAGE_TYPE, LTI2Messages.CONTENT_ITEM_SELECTION_REQUEST); setProperty(ltiProps, ContentItem.ACCEPT_MEDIA_TYPES, ContentItem.MEDIA_LTILINKITEM); setProperty(ltiProps, BasicLTIConstants.ACCEPT_PRESENTATION_DOCUMENT_TARGETS, "iframe,window"); // Nice to add overlay setProperty(ltiProps, BasicLTIConstants.ACCEPT_UNSIGNED, "true"); setProperty(ltiProps, BasicLTIConstants.ACCEPT_MULTIPLE, "false"); setProperty(ltiProps, BasicLTIConstants.ACCEPT_COPY_ADVICE, "false"); // ??? setProperty(ltiProps, BasicLTIConstants.AUTO_CREATE, "true"); setProperty(ltiProps, BasicLTIConstants.CAN_CONFIRM, "false"); // setProperty(ltiProps, BasicLTIConstants.TITLE, ""); // setProperty(ltiProps, BasicLTIConstants.TEXT, ""); // Pull in additonal data JSONObject dataJSON = new JSONObject(); Enumeration en = dataProps.keys(); while (en.hasMoreElements()) { String key = (String) en.nextElement(); String value = dataProps.getProperty(key); if (value == null) continue; // Allow overrides if (BasicLTIConstants.ACCEPT_MEDIA_TYPES.equals(key)) { setProperty(ltiProps, BasicLTIConstants.ACCEPT_MEDIA_TYPES, value); continue; } else if (BasicLTIConstants.ACCEPT_PRESENTATION_DOCUMENT_TARGETS.equals(key)) { setProperty(ltiProps, BasicLTIConstants.ACCEPT_PRESENTATION_DOCUMENT_TARGETS, value); continue; } else if (BasicLTIConstants.ACCEPT_UNSIGNED.equals(key)) { setProperty(ltiProps, BasicLTIConstants.ACCEPT_UNSIGNED, value); continue; } else if (BasicLTIConstants.AUTO_CREATE.equals(key)) { setProperty(ltiProps, BasicLTIConstants.AUTO_CREATE, value); continue; } else if (BasicLTIConstants.CAN_CONFIRM.equals(key)) { setProperty(ltiProps, BasicLTIConstants.CAN_CONFIRM, value); continue; } else if (BasicLTIConstants.TITLE.equals(key)) { setProperty(ltiProps, BasicLTIConstants.TITLE, value); continue; } else if (BasicLTIConstants.TEXT.equals(key)) { setProperty(ltiProps, BasicLTIConstants.TEXT, value); continue; } // Pass in data for use to get back. dataJSON.put(key, value); } setProperty(ltiProps, BasicLTIConstants.DATA, dataJSON.toString()); setProperty(ltiProps, BasicLTIConstants.CONTENT_ITEM_RETURN_URL, contentReturn); // This must always be there String context = (String) tool.get(LTIService.LTI_SITE_ID); Site site = null; try { site = SiteService.getSite(context); } catch (Exception e) { dPrint("No site/page associated with Launch context=" + context); return postError("<p>" + getRB(rb, "error.site.missing", "Cannot load site.") + context + "</p>"); } Properties lti2subst = new Properties(); addGlobalData(site, ltiProps, lti2subst, rb); addSiteInfo(ltiProps, lti2subst, site); addRoleInfo(ltiProps, lti2subst, context, (String) tool.get("rolemap")); addUserInfo(ltiProps, lti2subst, tool); int debug = getInt(tool.get(LTIService.LTI_DEBUG)); debug = 1; String customstr = toNull((String) tool.get(LTIService.LTI_CUSTOM)); parseCustom(ltiProps, customstr); Map<String, String> extra = new HashMap<String, String>(); ltiProps = BasicLTIUtil.signProperties(ltiProps, launch_url, "POST", consumerkey, secret, null, null, null, extra); M_log.debug("signed ltiProps=" + ltiProps); boolean dodebug = debug == 1; String postData = BasicLTIUtil.postLaunchHTML(ltiProps, launch_url, dodebug, extra); String[] retval = { postData, launch_url }; return retval; }
From source file:org.projectforge.web.admin.AdminPage.java
protected void checkI18nProperties() { log.info("Administration: check i18n properties."); checkAccess();//from www . j av a2 s. co m final StringBuffer buf = new StringBuffer(); final Properties props = new Properties(); final Properties props_en = new Properties(); final Properties props_de = new Properties(); final Properties propsFound = new Properties(); final ClassLoader cLoader = this.getClass().getClassLoader(); try { load(props, ""); load(props_en, "_en"); load(props_de, "_de"); final InputStream is = cLoader.getResourceAsStream(WebConstants.FILE_I18N_KEYS); propsFound.load(is); } catch (final IOException ex) { log.error("Could not load i18n properties: " + ex.getMessage(), ex); throw new RuntimeException(ex); } buf.append("Checking the differences between the " + PFUserContext.BUNDLE_NAME + " properties (default and _de)\n\n"); buf.append("Found " + props.size() + " entries in default property file (en).\n\n"); buf.append("Missing in _de:\n"); buf.append("---------------\n"); List<String> keys = new ArrayList<String>(); for (final Object key : props.keySet()) { if (props_de.containsKey(key) == false) { keys.add(String.valueOf(key)); } } Collections.sort(keys); for (final String key : keys) { buf.append(key + "=" + props.getProperty(key) + "\n"); } buf.append("\n\nOnly in _de (not in _en):\n"); buf.append("-------------------------\n"); keys = new ArrayList<String>(); for (final Object key : props_de.keySet()) { if (props.containsKey(key) == false) { keys.add(String.valueOf(key)); } } Collections.sort(keys); for (final String key : keys) { buf.append(key + "=" + props_de.getProperty(key) + "\n"); } if (WebConfiguration.isDevelopmentMode() == true) { buf.append("\n\nMaybe not defined but used (found in java, jsp or Wicket's html code):\n"); buf.append("----------------------------------------------------------------------\n"); keys = new ArrayList<String>(); for (final Object key : propsFound.keySet()) { if (props.containsKey(key) == false && props_de.containsKey(key) == false && props.containsKey(key) == false) { keys.add(String.valueOf(key) + "=" + propsFound.getProperty((String) key)); } } Collections.sort(keys); for (final String key : keys) { buf.append(key + "\n"); } buf.append( "\n\nExperimental (in progress): Maybe unused (not found in java, jsp or Wicket's html code):\n"); buf.append( "----------------------------------------------------------------------------------------\n"); final Set<String> all = new TreeSet<String>(); CollectionUtils.addAll(all, props.keys()); CollectionUtils.addAll(all, props_en.keys()); CollectionUtils.addAll(all, props_de.keys()); keys = new ArrayList<String>(); for (final String key : all) { if (propsFound.containsKey(key) == false) { keys.add(String.valueOf(key)); } } Collections.sort(keys); for (final String key : keys) { String value = props_de.getProperty(key); if (value == null) { value = props_en.getProperty(key); } if (value == null) { value = props.getProperty(key); } buf.append(key + "=" + value + "\n"); } } final String result = buf.toString(); final String filename = "projectforge_i18n_check" + DateHelper.getDateAsFilenameSuffix(new Date()) + ".txt"; DownloadUtils.setDownloadTarget(result.getBytes(), filename); }
From source file:com.liferay.portal.struts.MultiMessageResources.java
private void _loadProps(String name, String localeKey) { if (name.contains("cms_language")) { LanguageAPI langAPI = APILocator.getLanguageAPI(); List<LanguageKey> keys; if (localeKey.split("_").length > 1) { keys = langAPI.getLanguageKeys(localeKey.split("_")[0], localeKey.split("_")[1]); } else {//w w w. j a v a 2 s . co m keys = langAPI.getLanguageKeys(localeKey.split("_")[0]); } if (keys.size() < 1) { return; } synchronized (messages) { Iterator<LanguageKey> names = keys.iterator(); while (names.hasNext()) { LanguageKey langkey = (LanguageKey) names.next(); String key = langkey.getKey(); messages.put(messageKey(localeKey, key), langkey.getValue()); } } } else { Properties props = new Properties(); try { URL url = null; url = _servletContext.getResource("/WEB-INF/" + name); if (url != null) { InputStream is = url.openStream(); BufferedReader buffy = new BufferedReader(new InputStreamReader(is)); String line = null; while ((line = buffy.readLine()) != null) { if (UtilMethods.isSet(line) && line.indexOf("=") > -1 && !line.startsWith("#")) { String[] arr = line.split("=", 2); if (arr.length > 1) { String key = arr[0].trim(); String val = arr[1].trim(); if (val.indexOf("\\u") > -1) { if (val.indexOf("\\u") > -1) { StringBuffer buffer = new StringBuffer(val.length()); boolean precedingBackslash = false; for (int i = 0; i < val.length(); i++) { char c = val.charAt(i); if (precedingBackslash) { switch (c) { case 'f': c = '\f'; break; case 'n': c = '\n'; break; case 'r': c = '\r'; break; case 't': c = '\t'; break; case 'u': String hex = val.substring(i + 1, i + 5); c = (char) Integer.parseInt(hex, 16); i += 4; } precedingBackslash = false; } else { precedingBackslash = (c == '\\'); } if (!precedingBackslash) { buffer.append(c); } } val = buffer.toString(); } } props.put(key, val); } } } buffy.close(); is.close(); } } catch (Exception e) { Logger.error(this, e.getMessage(), e); } if (props.size() < 1) { return; } synchronized (messages) { Enumeration names = props.keys(); while (names.hasMoreElements()) { String key = (String) names.nextElement(); messages.put(messageKey(localeKey, key), props.getProperty(key)); } } } }
From source file:org.webdavaccess.servlet.WebdavServlet.java
/** * Propfind helper method./* w w w . j a v a2 s. com*/ * * @param req * The servlet request * @param generatedXML * XML response to the Propfind request * @param path * Path of the current resource * @param type * Propfind type * @param propertiesVector * If the propfind type is find properties by name, then this * Vector contains those properties */ private void parseProperties(HttpServletRequest req, XMLWriter generatedXML, String path, int type, Vector propertiesVector) throws WebdavException { String creationdate = getISOCreationDate(fStore.getCreationDate(path).getTime()); boolean isFolder = fStore.isFolder(path); SimpleDateFormat formatter = new SimpleDateFormat("EEE, dd MMM yyyy HH:mm:ss z", Locale.US); formatter.setTimeZone(TimeZone.getTimeZone("GMT")); String lastModified = formatter.format(fStore.getLastModified(path)); String resourceLength = String.valueOf(fStore.getResourceLength(path)); // ResourceInfo resourceInfo = new ResourceInfo(path, resources); generatedXML.writeElement(null, "response", XMLWriter.OPENING); String status = new String( "HTTP/1.1 " + WebdavStatus.SC_OK + " " + WebdavStatus.getStatusText(WebdavStatus.SC_OK)); // Generating href element generatedXML.writeElement(null, "href", XMLWriter.OPENING); String href = req.getContextPath(); if ((href.endsWith("/")) && (path.startsWith("/"))) href += path.substring(1); else href += path; if ((isFolder) && (!href.endsWith("/"))) href += "/"; generatedXML.writeText(rewriteUrl(href)); generatedXML.writeElement(null, "href", XMLWriter.CLOSING); String resourceName = path; int lastSlash = path.lastIndexOf('/'); if (lastSlash != -1) resourceName = resourceName.substring(lastSlash + 1); Properties customProperties; Enumeration en; switch (type) { case FIND_ALL_PROP: generatedXML.writeElement(null, "propstat", XMLWriter.OPENING); generatedXML.writeElement(null, "prop", XMLWriter.OPENING); generatedXML.writeProperty(null, "creationdate", creationdate); generatedXML.writeElement(null, "displayname", XMLWriter.OPENING); generatedXML.writeData(resourceName); generatedXML.writeElement(null, "displayname", XMLWriter.CLOSING); if (!isFolder) { generatedXML.writeProperty(null, "getlastmodified", lastModified); generatedXML.writeProperty(null, "getcontentlength", resourceLength); String contentType = getServletContext().getMimeType(path); if (contentType != null) { generatedXML.writeProperty(null, "getcontenttype", contentType); } generatedXML.writeProperty(null, "getetag", getETag(path, resourceLength, lastModified)); generatedXML.writeElement(null, "resourcetype", XMLWriter.NO_CONTENT); } else { generatedXML.writeElement(null, "resourcetype", XMLWriter.OPENING); generatedXML.writeElement(null, "collection", XMLWriter.NO_CONTENT); generatedXML.writeElement(null, "resourcetype", XMLWriter.CLOSING); } // Get custom properties customProperties = fStore.getCustomProperties(path); if (customProperties != null && customProperties.size() > 0) { en = customProperties.keys(); while (en.hasMoreElements()) { String key = (String) en.nextElement(); generatedXML.writeProperty(null, key, customProperties.getProperty(key)); } } generatedXML.writeProperty(null, "source", ""); generatedXML.writeElement(null, "prop", XMLWriter.CLOSING); generatedXML.writeElement(null, "status", XMLWriter.OPENING); generatedXML.writeText(status); generatedXML.writeElement(null, "status", XMLWriter.CLOSING); generatedXML.writeElement(null, "propstat", XMLWriter.CLOSING); break; case FIND_PROPERTY_NAMES: generatedXML.writeElement(null, "propstat", XMLWriter.OPENING); generatedXML.writeElement(null, "prop", XMLWriter.OPENING); generatedXML.writeElement(null, "creationdate", XMLWriter.NO_CONTENT); generatedXML.writeElement(null, "displayname", XMLWriter.NO_CONTENT); if (!isFolder) { generatedXML.writeElement(null, "getcontentlanguage", XMLWriter.NO_CONTENT); generatedXML.writeElement(null, "getcontentlength", XMLWriter.NO_CONTENT); generatedXML.writeElement(null, "getcontenttype", XMLWriter.NO_CONTENT); generatedXML.writeElement(null, "getetag", XMLWriter.NO_CONTENT); generatedXML.writeElement(null, "getlastmodified", XMLWriter.NO_CONTENT); } generatedXML.writeElement(null, "resourcetype", XMLWriter.NO_CONTENT); generatedXML.writeElement(null, "source", XMLWriter.NO_CONTENT); generatedXML.writeElement(null, "lockdiscovery", XMLWriter.NO_CONTENT); // Get custom properties customProperties = fStore.getCustomProperties(path); if (customProperties != null && customProperties.size() > 0) { customProperties = fStore.getCustomProperties(path); en = customProperties.keys(); while (en.hasMoreElements()) { String key = (String) en.nextElement(); generatedXML.writeElement(null, key, XMLWriter.NO_CONTENT); } } generatedXML.writeElement(null, "prop", XMLWriter.CLOSING); generatedXML.writeElement(null, "status", XMLWriter.OPENING); generatedXML.writeText(status); generatedXML.writeElement(null, "status", XMLWriter.CLOSING); generatedXML.writeElement(null, "propstat", XMLWriter.CLOSING); break; case FIND_BY_PROPERTY: Vector propertiesNotFound = new Vector(); // Parse the list of properties generatedXML.writeElement(null, "propstat", XMLWriter.OPENING); generatedXML.writeElement(null, "prop", XMLWriter.OPENING); Enumeration properties = propertiesVector.elements(); customProperties = fStore.getCustomProperties(path); while (properties.hasMoreElements()) { String property = (String) properties.nextElement(); if (property.equals("creationdate")) { generatedXML.writeProperty(null, "creationdate", creationdate); } else if (property.equals("displayname")) { generatedXML.writeElement(null, "displayname", XMLWriter.OPENING); generatedXML.writeData(resourceName); generatedXML.writeElement(null, "displayname", XMLWriter.CLOSING); } else if (property.equals("getcontentlanguage")) { if (isFolder) { propertiesNotFound.addElement(property); } else { generatedXML.writeElement(null, "getcontentlanguage", XMLWriter.NO_CONTENT); } } else if (property.equals("getcontentlength")) { if (isFolder) { propertiesNotFound.addElement(property); } else { generatedXML.writeProperty(null, "getcontentlength", resourceLength); } } else if (property.equals("getcontenttype")) { if (isFolder) { propertiesNotFound.addElement(property); } else { generatedXML.writeProperty(null, "getcontenttype", getServletContext().getMimeType(path)); } } else if (property.equals("getetag")) { if (isFolder) { propertiesNotFound.addElement(property); } else { generatedXML.writeProperty(null, "getetag", getETag(path, resourceLength, lastModified)); } } else if (property.equals("getlastmodified")) { if (isFolder) { propertiesNotFound.addElement(property); } else { generatedXML.writeProperty(null, "getlastmodified", lastModified); } } else if (property.equals("resourcetype")) { if (isFolder) { generatedXML.writeElement(null, "resourcetype", XMLWriter.OPENING); generatedXML.writeElement(null, "collection", XMLWriter.NO_CONTENT); generatedXML.writeElement(null, "resourcetype", XMLWriter.CLOSING); } else { generatedXML.writeElement(null, "resourcetype", XMLWriter.NO_CONTENT); } } else if (property.equals("source")) { generatedXML.writeProperty(null, "source", ""); } else if (customProperties != null && customProperties.containsKey(property)) { generatedXML.writeProperty(null, property, customProperties.getProperty(property)); } else { propertiesNotFound.addElement(property); } } generatedXML.writeElement(null, "prop", XMLWriter.CLOSING); generatedXML.writeElement(null, "status", XMLWriter.OPENING); generatedXML.writeText(status); generatedXML.writeElement(null, "status", XMLWriter.CLOSING); generatedXML.writeElement(null, "propstat", XMLWriter.CLOSING); Enumeration propertiesNotFoundList = propertiesNotFound.elements(); if (propertiesNotFoundList.hasMoreElements()) { status = new String("HTTP/1.1 " + WebdavStatus.SC_NOT_FOUND + " " + WebdavStatus.getStatusText(WebdavStatus.SC_NOT_FOUND)); generatedXML.writeElement(null, "propstat", XMLWriter.OPENING); generatedXML.writeElement(null, "prop", XMLWriter.OPENING); while (propertiesNotFoundList.hasMoreElements()) { generatedXML.writeElement(null, (String) propertiesNotFoundList.nextElement(), XMLWriter.NO_CONTENT); } generatedXML.writeElement(null, "prop", XMLWriter.CLOSING); generatedXML.writeElement(null, "status", XMLWriter.OPENING); generatedXML.writeText(status); generatedXML.writeElement(null, "status", XMLWriter.CLOSING); generatedXML.writeElement(null, "propstat", XMLWriter.CLOSING); } break; } generatedXML.writeElement(null, "response", XMLWriter.CLOSING); }
From source file:org.joget.apps.app.controller.ConsoleWebController.java
@RequestMapping("/console/i18n/(*:name)") public String consoleI18n(ModelMap map, HttpServletResponse response, @RequestParam("name") String name) throws IOException { Properties keys = new Properties(); //get message key from property file InputStream inputStream = null; try {/*from w w w.j a v a2s . c om*/ inputStream = this.getClass().getClassLoader().getResourceAsStream(name + ".properties"); if (inputStream != null) { keys.load(inputStream); map.addAttribute("name", name); map.addAttribute("keys", keys.keys()); return "console/i18n/lang"; } else { return "error404"; } } finally { if (inputStream != null) { inputStream.close(); } } }
From source file:org.alfresco.reporting.action.executer.ReportContainerExecutor.java
private void processReport(final ReportTemplate report, final ReportingContainer reportingContainer, final ReportingRoot reportingRoot) { Properties keyValues = new Properties(); if (logger.isDebugEnabled()) logger.debug("enter processReport, report=" + report.getName()); String targetPath = report.getTargetPath(); Properties targetQueries = reportingRoot.getTargetQueries(); // 1. Determine/get/create target Path // Lets see if there is a relative distribution by Site if (targetPath != null) { targetPath = targetPath.trim();/*from w ww . j a va 2s. c om*/ if ((targetPath.indexOf("${") == 0) && (targetPath.indexOf("}") > -1)) { // 1a. it is a distribution by Site or other placeholder logger.debug("processReportable: it is a distribution by container"); // get the target container query key String placeHolder = targetPath.substring(2, targetPath.indexOf("}")); String relativePath = targetPath.substring(targetPath.indexOf("}") + 1); relativePath = processDateElementsInPath(relativePath); logger.debug(" placeholder: " + placeHolder); logger.debug(" relative path: " + relativePath); if (placeHolder != null) { if (targetQueries.containsKey(placeHolder)) { // execute Lucene query. For each result find node. // For each node, append relative path // get or create this path // execute ReportExecuter against each of these end nodes (in proper output format) logger.debug("processReport: Processing with placeholder: " + placeHolder); String placeHolderQuery = targetQueries.getProperty(placeHolder); String searchLanguage = reportingHelper .getSearchLanguage(reportingRoot.getRootQueryLanguage()); logger.debug("processReport: query2=" + placeHolderQuery + "(" + searchLanguage + ")"); ResultSet placeHolderResults = searchService.query(StoreRef.STORE_REF_WORKSPACE_SPACESSTORE, searchLanguage, placeHolderQuery); // cycle the resultset of containers for (ResultSetRow placeHolderRow : placeHolderResults) { final NodeRef targetRootRef = placeHolderRow.getChildAssocRef().getChildRef(); logger.debug("Found targetRoot: " + nodeService.getProperty(targetRootRef, ContentModel.PROP_NAME)); // Introduce a storageNodeRef. This is used if you do a query against // persons. The resulting report will be stored in the UserHome space. // The value substitution will however be executed against the Person object. NodeRef storageNodeRef = targetRootRef; logger.debug("processReport: storageNodeRef before=" + storageNodeRef); try { // if a Person object is found, replace it by its HomeFolder. For the best fun! if (nodeService.getType(targetRootRef).equals(ContentModel.TYPE_PERSON)) { logger.debug("processReport: The value=" + nodeService.getProperty(targetRootRef, ContentModel.PROP_HOMEFOLDER)); if (nodeService.getProperty(targetRootRef, ContentModel.PROP_HOMEFOLDER) != null) { logger.debug( "processReport: createGetRepositoryPath: SWAPPING Person for UserHome"); storageNodeRef = (NodeRef) nodeService.getProperty(targetRootRef, ContentModel.PROP_HOMEFOLDER); logger.debug( "processReport: createGetRepositoryPath: storageNodeRef after swap=" + storageNodeRef); } else { logger.debug( "processReport: createGetRepositoryPath: ow boy, no UserHome available for user " + nodeService.getProperty(targetRootRef, ContentModel.PROP_USERNAME)); throw new ReportingException("No UserHome found for user " + nodeService .getProperty(targetRootRef, ContentModel.PROP_USERNAME)); } } else { logger.debug("createGetRepositoryPath: no SWAPPING"); } } catch (ReportingException re) { logger.fatal("processReport: User without a UserHome... Silent ignore"); } logger.debug( "processReport: processReportstorageNodeRef fully after=" + storageNodeRef); // keyValues now contains the keys and the related short-form qnames keyValues = report.getSubstitution(); logger.debug("processReport: initial keyValues = " + keyValues); // process of *replacing* the short-form qnames into actual // node-property values Enumeration keys = keyValues.keys(); while (keys.hasMoreElements()) { final String key = (String) keys.nextElement(); final String value = keyValues.getProperty(key, ""); logger.debug("Initial key=value; " + key + "=" + value); if (value.contains(":") && !"".equals(value)) { // system property final QName property = reportingHelper.replaceShortQNameIntoLong(value); logger.debug("processReport: QName=" + property); logger.debug("processReport: key=" + key + " value=" + nodeService.getProperty(targetRootRef, property)); final String propertyValue = nodeService.getProperty(targetRootRef, property) .toString(); logger.debug("processReport: propertyValue=" + propertyValue); keyValues.setProperty(key, propertyValue); } else { // ordinary property keyValues.setProperty(key, value); logger.debug("processReport: key=" + key + " value=" + value + " targetRootRef=" + targetRootRef); } // end if/else } // end while logger.debug("processReport: final keyValues = " + keyValues); final NodeRef targetRef = createGetRepositoryPath(storageNodeRef, relativePath); logger.debug("processReport: Found full path: " + nodeService.getPath(targetRef)); logger.debug("processReport: keyValues = " + keyValues); createExecuteReport(targetRef, report, keyValues); } // end for ResultSetRow } else { // we cannot deal with this unknown placeholder. // silently let go?! logger.warn("Cannot deal with placeholder: " + placeHolder); } // end if/else targetQueries.containsKey } // end if matcher.find } else { // 1b. it is a single fixed path. Start at companyhome, and find your way in //NodeRef targetRef = createGetRepositoryPath(targetRootRef, relativePath); // execute ReportExecuter against each of these end nodes (in proper output format) } } // end if targetPath !=null if ((report.getTargetNode() != null) && (!"".equals(report.getTargetNode()))) { NodeRef newTarget = null; // create option to concatinate targetPath to targetNode if ((report.getTargetPath() != null) && (!"".equals(report.getTargetPath()))) { final String relativePath = processDateElementsInPath(report.getTargetPath()); newTarget = createGetRepositoryPath(report.getTargetNode(), relativePath); } else { newTarget = report.getTargetNode(); } logger.debug("executing fixed output path"); logger.debug(" report : " + report.getName()); logger.debug(" targetNode: " + newTarget); // keyValues now contains the keys and the related short-form qnames keyValues = report.getSubstitution(); logger.debug("processReport: initial keyValues = " + keyValues); // process of replacing the short-form qnames into actual // node-property values Enumeration keys = keyValues.keys(); while (keys.hasMoreElements()) { String key = (String) keys.nextElement(); String value = keyValues.getProperty(key, ""); // ordinary property keyValues.setProperty(key, value); logger.debug("processReport: key=" + key + " value=" + value); } logger.debug("processReport: final keyValues = " + keyValues); createExecuteReport(newTarget, report, keyValues); } // end if targetPath != null if (logger.isDebugEnabled()) logger.debug("exit processReportable"); }
From source file:com.redhat.rcm.version.Cli.java
private void loadConfiguration() throws VManException { final Logger logger = LoggerFactory.getLogger(getClass()); File config = null;/*from ww w . j a v a 2 s. c om*/ if (configuration != null) { config = InputUtils.getFile(configuration, workspace); } if (config == null) { config = loadBootstrapConfig(); } if (config == null) { configLocation = DEFAULT_CONFIG_FILE.getAbsolutePath(); config = DEFAULT_CONFIG_FILE; } if (config != null && config.canRead()) { InputStream is = null; try { is = new FileInputStream(config); final Properties props = new Properties(); props.load(is); final StringWriter sWriter = new StringWriter(); for (final Enumeration<?> e = props.propertyNames(); e.hasMoreElements();) { final String key = (String) e.nextElement(); sWriter.write(" "); sWriter.write(key); sWriter.write(" = "); sWriter.write(props.getProperty(key)); sWriter.write("\n"); } props.list(new PrintWriter(sWriter)); logger.info("Loading configuration from: " + config + ":\n\n" + sWriter); final File downloadsDir = VersionManagerSession.getDownloadsDir(workspace); final List<String> relocations = readListProperty(props, RELOCATIONS_PROPERTY); if (relocations != null) { relocatedCoords = readPropertiesList(relocations, downloadsDir, true); } else { relocatedCoords = new HashMap<String, String>(); } final List<String> mappingsLocations = readListProperty(props, PROPERTY_MAPPINGS_PROPERTY); if (mappingsLocations != null) { this.propertyMappings = readPropertiesList(mappingsLocations, downloadsDir, true); } else { this.propertyMappings = new HashMap<String, String>(); } if (removedPluginsList == null) { removedPlugins = readListProperty(props, REMOVED_PLUGINS_PROPERTY); } if (removedTestsList == null) { removedTests = readListProperty(props, REMOVED_TESTS_PROPERTY); } if (extensionsWhitelistList == null) { extensionsWhitelist = readListProperty(props, EXTENSIONS_WHITELIST_PROPERTY); } if (pomExcludeModules == null) { pomExcludeModules = props.getProperty(POM_EXCLUDE_MODULE_PROPERTY); } if (pomExcludePattern == null) { pomExcludePattern = props.getProperty(POM_EXCLUDE_FILE_PROPERTY); } if (modifications == null) { final List<String> lst = readListProperty(props, MODIFICATIONS); logger.info("modifications from properties: '" + join(lst, " ") + "'"); if (lst != null) { modders = modders == null ? new ArrayList<String>() : new ArrayList<String>(modders); modders.addAll(lst); } } if (bomList == null) { if (boms == null) { boms = new ArrayList<String>(); } final List<String> pBoms = readListProperty(props, BOMS_LIST_PROPERTY); if (pBoms != null) { boms.addAll(pBoms); } } if (toolchain == null) { toolchain = props.getProperty(TOOLCHAIN_PROPERTY); if (toolchain != null) { toolchain = toolchain.trim(); } } if (versionSuffix == null) { versionSuffix = props.getProperty(VERSION_SUFFIX_PROPERTY); if (versionSuffix != null) { versionSuffix = versionSuffix.trim(); } } if (versionModifier == null) { versionModifier = props.getProperty(VERSION_MODIFIER_PROPERTY); if (versionModifier != null) { versionModifier = versionModifier.trim(); } } if (remoteRepositories == null) { remoteRepositories = props.getProperty(REMOTE_REPOSITORIES_PROPERTY); if (remoteRepositories != null) { remoteRepositories = remoteRepositories.trim(); } else { remoteRepositories = props.getProperty(REMOTE_REPOSITORY_PROPERTY); if (remoteRepositories != null) { logger.warn("Using deprecated " + REMOTE_REPOSITORY_PROPERTY); remoteRepositories = remoteRepositories.trim(); } } } if (settings == null) { final String s = props.getProperty(SETTINGS_PROPERTY); if (s != null) { settings = s; } } if (localRepository == null) { final String l = props.getProperty(LOCAL_REPOSITORY_PROPERTY); if (l != null) { localRepository = new File(l); } } if (capturePom == null) { final String p = props.getProperty(CAPTURE_POM_PROPERTY); if (p != null) { capturePom = new File(p); } } if (!strict) { strict = Boolean .valueOf(props.getProperty(STRICT_MODE_PROPERTY, Boolean.toString(Boolean.FALSE))); } if (!useEffectivePoms) { useEffectivePoms = Boolean.valueOf( props.getProperty(USE_EFFECTIVE_POMS_PROPERTY, Boolean.toString(Boolean.FALSE))); } if (truststorePath == null) { truststorePath = props.getProperty(TRUSTSTORE_PATH_PROPERTY); } final Map<String, String> userProps = new HashMap<String, String>(); for (final Enumeration<?> keys = props.keys(); keys.hasMoreElements();) { final String key = (String) keys.nextElement(); if (key.startsWith(REPORT_PROPERTY_PREFIX)) { userProps.put(key.substring(REPORT_PROPERTY_PREFIX.length()), props.getProperty(key)); } } if (!userProps.isEmpty()) { if (reportProperties == null) { reportProperties = userProps; } else { userProps.putAll(reportProperties); reportProperties = userProps; } } } catch (final IOException e) { throw new VManException("Failed to load configuration from: " + config, e); } finally { closeQuietly(is); } } else { configLocation = "command-line"; } }
From source file:org.alfresco.reporting.action.executer.ReportContainerExecuter.java
private void processReport(final ReportTemplate report, final ReportingContainer reportingContainer, final ReportingRoot reportingRoot) { Properties keyValues = new Properties(); if (logger.isDebugEnabled()) logger.debug("enter processReport, report=" + report.getName()); String targetPath = report.getTargetPath(); Properties targetQueries = reportingRoot.getTargetQueries(); // 1. Determine/get/create target Path // Lets see if there is a relative distribution by Site if (targetPath != null) { targetPath = targetPath.trim();//from w w w . jav a 2 s . co m if ((targetPath.indexOf("${") == 0) && (targetPath.indexOf("}") > -1)) { // 1a. it is a distribution by Site or other placeholder if (logger.isDebugEnabled()) logger.debug("processReportable: it is a distribution by container"); // get the target container query key String placeHolder = targetPath.substring(2, targetPath.indexOf("}")); String relativePath = targetPath.substring(targetPath.indexOf("}") + 1); relativePath = processDateElementsInPath(relativePath); if (logger.isDebugEnabled()) { logger.debug(" placeholder: " + placeHolder); logger.debug(" relative path: " + relativePath); } if (placeHolder != null) { if (targetQueries.containsKey(placeHolder)) { // execute Lucene query. For each result find node. // For each node, append relative path // get or create this path // execute ReportExecuter against each of these end // nodes (in proper output format) if (logger.isDebugEnabled()) logger.debug("processReport: Processing with placeholder: " + placeHolder); String placeHolderQuery = targetQueries.getProperty(placeHolder); String searchLanguage = reportingHelper .getSearchLanguage(reportingRoot.getRootQueryLanguage()); if (logger.isDebugEnabled()) logger.debug("processReport: query2=" + placeHolderQuery + "(" + searchLanguage + ")"); ResultSet placeHolderResults = searchService.query(StoreRef.STORE_REF_WORKSPACE_SPACESSTORE, searchLanguage, placeHolderQuery); // cycle the resultset of containers for (ResultSetRow placeHolderRow : placeHolderResults) { final NodeRef targetRootRef = placeHolderRow.getChildAssocRef().getChildRef(); if (logger.isDebugEnabled()) logger.debug("Found targetRoot: " + nodeService.getProperty(targetRootRef, ContentModel.PROP_NAME)); // Introduce a storageNodeRef. This is used if you // do a query against // persons. The resulting report will be stored in // the UserHome space. // The value substitution will however be executed // against the Person object. NodeRef storageNodeRef = targetRootRef; if (logger.isDebugEnabled()) logger.debug("processReport: storageNodeRef before=" + storageNodeRef); try { // if a Person object is found, replace it by // its HomeFolder. For the best fun! if (nodeService.getType(targetRootRef).equals(ContentModel.TYPE_PERSON)) { if (logger.isDebugEnabled()) logger.debug("processReport: The value=" + nodeService .getProperty(targetRootRef, ContentModel.PROP_HOMEFOLDER)); if (nodeService.getProperty(targetRootRef, ContentModel.PROP_HOMEFOLDER) != null) { if (logger.isDebugEnabled()) logger.debug( "processReport: createGetRepositoryPath: SWAPPING Person for UserHome"); storageNodeRef = (NodeRef) nodeService.getProperty(targetRootRef, ContentModel.PROP_HOMEFOLDER); if (logger.isDebugEnabled()) logger.debug( "processReport: createGetRepositoryPath: storageNodeRef after swap=" + storageNodeRef); } else { if (logger.isDebugEnabled()) logger.debug( "processReport: createGetRepositoryPath: ow boy, no UserHome available for user " + nodeService.getProperty(targetRootRef, ContentModel.PROP_USERNAME)); throw new ReportingException("No UserHome found for user " + nodeService .getProperty(targetRootRef, ContentModel.PROP_USERNAME)); } } else { if (logger.isDebugEnabled()) logger.debug("createGetRepositoryPath: no SWAPPING"); } } catch (ReportingException re) { logger.fatal("processReport: User without a UserHome... Silent ignore"); } if (logger.isDebugEnabled()) logger.debug( "processReport: processReportstorageNodeRef fully after=" + storageNodeRef); // keyValues now contains the keys and the related // short-form qnames keyValues = report.getSubstitution(); if (logger.isDebugEnabled()) logger.debug("processReport: initial keyValues = " + keyValues); // process of *replacing* the short-form qnames into // actual // node-property values Enumeration keys = keyValues.keys(); while (keys.hasMoreElements()) { final String key = (String) keys.nextElement(); final String value = keyValues.getProperty(key, ""); if (logger.isDebugEnabled()) logger.debug("Initial key=value; " + key + "=" + value); if (value.contains(":") && !"".equals(value)) { // system property final QName property = reportingHelper.replaceShortQNameIntoLong(value); if (logger.isDebugEnabled()) { logger.debug("processReport: QName=" + property); logger.debug("processReport: key=" + key + " value=" + nodeService.getProperty(targetRootRef, property)); } final String propertyValue = nodeService.getProperty(targetRootRef, property) .toString(); if (logger.isDebugEnabled()) logger.debug("processReport: propertyValue=" + propertyValue); keyValues.setProperty(key, propertyValue); } else { // ordinary property keyValues.setProperty(key, value); if (logger.isDebugEnabled()) logger.debug("processReport: key=" + key + " value=" + value + " targetRootRef=" + targetRootRef); } // end if/else } // end while if (logger.isDebugEnabled()) logger.debug("processReport: final keyValues = " + keyValues); final NodeRef targetRef = createGetRepositoryPath(storageNodeRef, relativePath); if (logger.isDebugEnabled()) { logger.debug("processReport: Found full path: " + nodeService.getPath(targetRef)); logger.debug("processReport: keyValues = " + keyValues); } createExecuteReport(targetRef, report, keyValues); } // end for ResultSetRow } else { // we cannot deal with this unknown placeholder. // silently let go?! logger.warn("Cannot deal with placeholder: " + placeHolder); } // end if/else targetQueries.containsKey } // end if matcher.find } else { // 1b. it is a single fixed path. Start at companyhome, and find // your way in // NodeRef targetRef = createGetRepositoryPath(targetRootRef, // relativePath); // execute ReportExecuter against each of these end nodes (in // proper output format) } } // end if targetPath !=null if ((report.getTargetNode() != null) && (!"".equals(report.getTargetNode()))) { NodeRef newTarget = null; // create option to concatinate targetPath to targetNode if ((report.getTargetPath() != null) && (!"".equals(report.getTargetPath()))) { final String relativePath = processDateElementsInPath(report.getTargetPath()); newTarget = createGetRepositoryPath(report.getTargetNode(), relativePath); } else { newTarget = report.getTargetNode(); } if (logger.isDebugEnabled()) { logger.debug("executing fixed output path"); logger.debug(" report : " + report.getName()); logger.debug(" targetNode: " + newTarget); } // keyValues now contains the keys and the related short-form qnames keyValues = report.getSubstitution(); logger.debug("processReport: initial keyValues = " + keyValues); // process of replacing the short-form qnames into actual // node-property values Enumeration keys = keyValues.keys(); while (keys.hasMoreElements()) { String key = (String) keys.nextElement(); String value = keyValues.getProperty(key, ""); // ordinary property keyValues.setProperty(key, value); logger.debug("processReport: key=" + key + " value=" + value); } logger.debug("processReport: final keyValues = " + keyValues); createExecuteReport(newTarget, report, keyValues); } // end if targetPath != null if (logger.isDebugEnabled()) logger.debug("exit processReportable"); }