List of usage examples for org.dom4j Node getText
String getText();
Returns the text of this node.
From source file:org.craftercms.cstudio.alfresco.dm.service.impl.DmContentTypeServiceImpl.java
License:Open Source License
/** * get a list of string form the given nodes * * @param nodes//from www . jav a 2 s.c o m * @return string values */ protected List<String> getStringList(List<Node> nodes) { if (nodes != null && nodes.size() > 0) { List<String> includes = new ArrayList<String>(nodes.size()); for (Node node : nodes) { String value = node.getText(); if (!StringUtils.isEmpty(value)) { includes.add(value); } } return includes; } return null; }
From source file:org.craftercms.cstudio.alfresco.service.impl.ContentTypesConfigImpl.java
License:Open Source License
/** * get paths //from w ww . j a v a 2s.c o m * * @param root * @param path * @return */ private List<String> getPaths(Element root, String path) { List<String> paths = null; List<Node> nodes = root.selectNodes(path); if (nodes != null && nodes.size() > 0) { paths = new FastList<String>(nodes.size()); for (Node node : nodes) { String role = node.getText(); if (!StringUtils.isEmpty(role)) { paths.add(role); } } } else { paths = new FastList<String>(); } return paths; }
From source file:org.craftercms.cstudio.alfresco.service.impl.ContentTypesConfigImpl.java
License:Open Source License
/** * load a list of allowed roles/* w w w . ja v a2 s.c o m*/ * @param config * @param nodes */ protected void loadRoles(ContentTypeConfigTO config, List<Node> nodes) { Set<String> roles = null; if (nodes != null && nodes.size() > 0) { roles = new FastSet<String>(nodes.size()); for (Node node : nodes) { String role = node.getText(); if (!StringUtils.isEmpty(role)) { roles.add(role); } } } else { roles = new FastSet<String>(); } config.setAllowedRoles(roles); }
From source file:org.craftercms.cstudio.alfresco.service.impl.ContentTypesConfigImpl.java
License:Open Source License
/** * load delete dependencies mapping/* w ww . ja v a 2 s . c o m*/ * * @param contentTypeConfig * @param nodes */ protected void loadDeleteDependencies(ContentTypeConfigTO contentTypeConfig, List<Node> nodes) { List<DeleteDependencyConfigTO> deleteConfigs = new FastList<DeleteDependencyConfigTO>(); if (nodes != null) { for (Node node : nodes) { Node patternNode = node.selectSingleNode("pattern"); Node removeFolderNode = node.selectSingleNode("remove-empty-folder"); if (patternNode != null) { String pattern = patternNode.getText(); String removeEmptyFolder = removeFolderNode.getText(); boolean isRemoveEmptyFolder = false; if (removeEmptyFolder != null) { isRemoveEmptyFolder = Boolean.valueOf(removeEmptyFolder); } if (StringUtils.isNotEmpty(pattern)) { DeleteDependencyConfigTO deleteConfigTO = new DeleteDependencyConfigTO(pattern, isRemoveEmptyFolder); deleteConfigs.add(deleteConfigTO); } } } contentTypeConfig.setDeleteDependencies(deleteConfigs); } }
From source file:org.craftercms.cstudio.alfresco.service.impl.ContentTypesConfigImpl.java
License:Open Source License
/** * /*from w w w .j a v a 2 s . c om*/ * @param config * @param copyDependencyNodes * @return */ protected void loadCopyDependencyPatterns(ContentTypeConfigTO config, List<Node> copyDependencyNodes) { List<CopyDependencyConfigTO> copyConfig = new FastList<CopyDependencyConfigTO>(); if (copyDependencyNodes != null) { for (Node copyDependency : copyDependencyNodes) { Node patternNode = copyDependency.selectSingleNode("pattern"); Node targetNode = copyDependency.selectSingleNode("target"); if (patternNode != null && targetNode != null) { String pattern = patternNode.getText(); String target = targetNode.getText(); if (StringUtils.isNotEmpty(pattern) && StringUtils.isNotEmpty(target)) { CopyDependencyConfigTO copyDependencyConfigTO = new CopyDependencyConfigTO(pattern, target); copyConfig.add(copyDependencyConfigTO); } } } } config.setCopyDepedencyPattern(copyConfig); }
From source file:org.craftercms.cstudio.alfresco.service.impl.ContentTypesConfigImpl.java
License:Open Source License
/** * load search configuration// w w w . j av a 2 s .c o 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 * /*from w w w . j a v a 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/* www.j a v a 2 s . c om*/ * * @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 w w w . j a v a 2s. c o m * * 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.PermissionServiceImpl.java
License:Open Source License
/** * populate user permissions/*from w w w .jav a2 s .co m*/ * * @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; }