List of usage examples for org.dom4j Node valueOf
String valueOf(String xpathExpression);
valueOf
evaluates an XPath expression and returns the textual representation of the results the XPath string-value of this node.
From source file:org.craftercms.cstudio.alfresco.dm.util.impl.DmImportServiceImpl.java
License:Open Source License
/** * create files from a list// w w w . jav a 2 s . c o m * * @param site * @param importedFiles * @param nodes * @param fileRoot * @param parentRef * @param targetRoot * the target location root * @param parentPath * the target location to import to * @param overWrite * @param channels * @param user */ protected void createFiles(String site, Set<String> importedPaths, List<String> importedFullPaths, List<Node> nodes, String fileRoot, NodeRef parentRef, String targetRoot, String parentPath, boolean overWrite, List<PublishingChannel> channels, String user) { if (LOGGER.isInfoEnabled()) { LOGGER.info("[IMPORT] createFiles: fileRoot [" + fileRoot + "] parentFullPath [" + parentPath + "] overwrite[" + overWrite + "]"); } if (nodes != null) { for (Node node : nodes) { String name = node.valueOf("@name"); String value = node.valueOf("@over-write"); boolean fileOverwrite = (StringUtils.isEmpty(value)) ? overWrite : ContentFormatUtils.getBooleanValue(value); if (!StringUtils.isEmpty(name)) { writeContentInTransaction(site, importedPaths, importedFullPaths, fileRoot, parentRef, targetRoot, parentPath, name, fileOverwrite, channels, user); } } } }
From source file:org.craftercms.cstudio.alfresco.service.impl.ContentTypesConfigImpl.java
License:Open Source License
/** * create a list of QNames from the given set of nodes * * @param nodes//from w w w. j a va 2 s . c om */ protected List<QName> createListOfQNames(List<Node> nodes) { if (nodes != null) { List<QName> components = new FastList<QName>(nodes.size()); PersistenceManagerService persistenceManagerService = getService(PersistenceManagerService.class); for (Node node : nodes) { QName property = persistenceManagerService.createQName(node.valueOf("@name")); if (property != null) { components.add(property); } } return components; } return null; }
From source file:org.craftercms.cstudio.alfresco.service.impl.ContentTypesConfigImpl.java
License:Open Source License
/** * load search configuration/*ww w. j a v a2 s. co m*/ * * @param node */ @SuppressWarnings("unchecked") public SearchConfigTO loadSearchConfig(Node node) { SearchConfigTO searchConfig = new SearchConfigTO(); if (node != null) { // get the maximum number of results to search for String maxCount = node.valueOf("max-count"); if (!StringUtils.isEmpty(maxCount)) { int max = ContentFormatUtils.getIntValue(node.valueOf("max-count")); searchConfig.setMaxCount((max <= 0) ? 100 : max); } else { searchConfig.setMaxCount(100); } // get wcm searchPath String wcmSearchPath = node.valueOf("wcm-search-path"); searchConfig.setWcmSearchPath(wcmSearchPath); // set base search filters List<Node> propNodes = node.selectNodes("base-searchable-properties/property"); if (propNodes != null && propNodes.size() > 0) { List<SearchColumnTO> columns = new FastList<SearchColumnTO>(propNodes.size()); for (Node propNode : propNodes) { String key = propNode.valueOf("@name"); if (!StringUtils.isEmpty(key)) { SearchColumnTO column = new SearchColumnTO(); column.setName(key); column.setTitle(propNode.valueOf("@title")); String useWildCard = propNode.valueOf("@use-wild-card"); column.setUseWildCard(ContentFormatUtils.getBooleanValue(useWildCard)); column.setSearchable(true); columns.add(column); } } searchConfig.setBaseSearchableColumns(columns); } // set searchable content-types List<Node> ctypeNodes = node.selectNodes("searchable-content-types/searchable-content-type"); if (ctypeNodes != null && ctypeNodes.size() > 0) { List<String> ctypes = new FastList<String>(ctypeNodes.size()); for (Node ctypeNode : ctypeNodes) { String s = ctypeNode.getText(); if (!StringUtils.isEmpty(s)) { ctypes.add(ctypeNode.getText()); } } searchConfig.setSearchableContentTypes(ctypes); } // set extractable metadata qnames Map<QName, String> extractableMetadata = getConfigMapWithStringValue( node.selectNodes("extractable-properties/property")); searchConfig.setExtractableMetadata(extractableMetadata); loadSearchColumnConfig(searchConfig, node.selectNodes("search-result/column")); } return searchConfig; }
From source file:org.craftercms.cstudio.alfresco.service.impl.ContentTypesConfigImpl.java
License:Open Source License
/** * load search column configuration from the given nodes * //ww w . j a va 2s .c o m * @param nodes * @return search column configuration */ protected void loadSearchColumnConfig(SearchConfigTO config, List<Node> nodes) { Map<String, QName> columns = new FastMap<String, QName>(); if (nodes != null && nodes.size() > 0) { PersistenceManagerService persistenceManagerService = getService(PersistenceManagerService.class); for (Node node : nodes) { String name = node.valueOf("@name"); String typeStr = node.getText(); QName type = persistenceManagerService.createQName(typeStr); columns.put(name, type); } } config.setSearchColumnMap(columns); }
From source file:org.craftercms.cstudio.alfresco.service.impl.ContentTypesConfigImpl.java
License:Open Source License
/** * get configuration map that has string values * @param nodes//from w w w.j a va 2 s . c o m * * @return */ protected Map<QName, String> getConfigMapWithStringValue(List<Node> nodes) { if (nodes != null) { Map<QName, String> configMap = new FastMap<QName, String>(); PersistenceManagerService persistenceManagerService = getService(PersistenceManagerService.class); for (Node node : nodes) { String typeStr = node.valueOf("@name"); QName name = persistenceManagerService.createQName(typeStr); String value = node.getText(); if (name != null) { configMap.put(name, value); } } return configMap; } else { return null; } }
From source file:org.craftercms.cstudio.alfresco.service.impl.NotificationServiceImpl.java
License:Open Source License
/** * load messages from the given nodes/*from ww w .j a v a 2 s.com*/ * * notification config to store messages * @param nodes * message nodes */ protected Map<String, String> loadMessages(final List<Node> nodes) { if (nodes != null) { Map<String, String> messagesMap = new HashMap<String, String>(); for (Node node : nodes) { String name = node.valueOf("@name"); if (!StringUtils.isEmpty(name)) { String message = node.getText(); messagesMap.put(name, message); } } return messagesMap; } return null; }
From source file:org.craftercms.cstudio.alfresco.service.impl.NotificationServiceImpl.java
License:Open Source License
/** * load canned messages from the configuration file * * @param config/*from w ww. j a v a 2 s . c om*/ * notification config to store messages * @param nodes * canned messages nodes * @return a list of canned messages */ @SuppressWarnings("unchecked") protected void loadCannedMessages(final NotificationConfigTO config, final List<Node> nodes) { if (nodes != null) { Map<String, List<MessageTO>> messageMap = new HashMap<String, List<MessageTO>>(); for (Node listNode : nodes) { String name = listNode.valueOf("@name"); if (!StringUtils.isEmpty(name)) { List<Node> messageNodes = listNode.selectNodes("message"); if (messageNodes != null) { List<MessageTO> messages = new ArrayList<MessageTO>(messageNodes.size()); for (Node messageNode : messageNodes) { MessageTO message = new MessageTO(); message.setTitle(messageNode.valueOf("title")); message.setBody(messageNode.valueOf("body")); messages.add(message); } messageMap.put(name, messages); } } } config.setCannedMessages(messageMap); } }
From source file:org.craftercms.cstudio.alfresco.service.impl.NotificationServiceImpl.java
License:Open Source License
protected void loadEmailMessageTemplates(final NotificationConfigTO config, final List<Node> nodes) { if (nodes != null) { Map<String, EmailMessageTemplateTO> messageMap = new HashMap<String, EmailMessageTemplateTO>(); for (Node listNode : nodes) { String name = listNode.valueOf("@name"); if (!StringUtils.isEmpty(name)) { EmailMessageTemplateTO message = new EmailMessageTemplateTO(); message.setSubject(listNode.valueOf("Subject")); message.setMessage(listNode.valueOf("message")); messageMap.put(name, message); }//from ww w. j a va 2 s . c om } config.setEmailMessageTemplates(messageMap); } }
From source file:org.craftercms.cstudio.alfresco.service.impl.PermissionServiceImpl.java
License:Open Source License
/** * populate user permissions/*from ww w . ja v a 2s. c om*/ * * @param site * @param path * @param roles * @param permissionsConfig */ protected Set<String> populateUserPermissions(String site, String path, Set<String> roles, PermissionsConfigTO permissionsConfig) { Set<String> permissions = new FastSet<String>(); if (roles != null && !roles.isEmpty()) { for (String role : roles) { Map<String, Map<String, List<Node>>> permissionsMap = permissionsConfig.getPermissions(); Map<String, List<Node>> siteRoles = permissionsMap.get(site); if (siteRoles == null || siteRoles.isEmpty()) { siteRoles = permissionsMap.get("*"); } if (siteRoles != null && !siteRoles.isEmpty()) { List<Node> ruleNodes = siteRoles.get(role); if (ruleNodes == null || ruleNodes.isEmpty()) { ruleNodes = siteRoles.get("*"); } if (ruleNodes != null && !ruleNodes.isEmpty()) { for (Node ruleNode : ruleNodes) { String regex = ruleNode.valueOf(CStudioXmlConstants.DOCUMENT_ATTR_REGEX); if (path.matches(regex)) { if (LOGGER.isDebugEnabled()) { LOGGER.debug("Permissions found by matching " + regex + " for " + role + " in " + site); } List<Node> permissionNodes = ruleNode .selectNodes(CStudioXmlConstants.DOCUMENT_ELM_ALLOWED_PERMISSIONS); for (Node permissionNode : permissionNodes) { String permission = permissionNode.getText().toLowerCase(); if (LOGGER.isDebugEnabled()) { LOGGER.debug("adding permissions " + permission + " to " + path + " for " + role + " in " + site); } permissions.add(permission); } } } } else { if (LOGGER.isDebugEnabled()) { LOGGER.debug("No default role is set. adding default permission: " + CStudioConstants.PERMISSION_VALUE_READ); } // If no default role is set permissions.add(CStudioConstants.PERMISSION_VALUE_READ); } } else { if (LOGGER.isDebugEnabled()) { LOGGER.debug("No default site is set. adding default permission: " + CStudioConstants.PERMISSION_VALUE_READ); } // If no default site is set permissions.add(CStudioConstants.PERMISSION_VALUE_READ); } } } else { if (LOGGER.isDebugEnabled()) { LOGGER.debug("No user or group matching found. adding default permission: " + CStudioConstants.PERMISSION_VALUE_READ); } // If user or group did not match the roles-mapping file permissions.add(CStudioConstants.PERMISSION_VALUE_READ); } return permissions; }
From source file:org.craftercms.cstudio.alfresco.service.impl.PermissionServiceImpl.java
License:Open Source License
@SuppressWarnings("unchecked") protected Map<String, List<String>> getRoles(List<Node> nodes, Map<String, List<String>> rolesMap) { for (Node node : nodes) { String name = node.valueOf(CStudioXmlConstants.DOCUMENT_ATTR_PERMISSIONS_NAME); if (!StringUtils.isEmpty(name)) { List<Node> roleNodes = node.selectNodes(CStudioXmlConstants.DOCUMENT_ELM_PERMISSION_ROLE); List<String> roles = new FastList<String>(); for (Node roleNode : roleNodes) { roles.add(roleNode.getText()); }//from w ww .jav a 2 s . com rolesMap.put(name, roles); } } return rolesMap; }