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:pt.webdetails.cpf.PentahoBasePluginEnvironment.java
License:Open Source License
/** * @return The plugin's ID. This isn't efficient and should be overridden by plugin. *///from w w w . j a va2 s. com public String getPluginId() { if (pluginId == null) { try { // this depends on cpf being loaded by the plugin classloader IReadAccess reader = new SystemPluginResourceAccess( PentahoBasePluginEnvironment.class.getClassLoader(), null); Node documentNode = XmlDom4JUtils.getDocumentFromFile(reader, "plugin.xml").getRootElement(); pluginId = documentNode.valueOf("/plugin/@name"); if (StringUtils.isEmpty(pluginId)) { pluginId = documentNode.valueOf("/plugin/@title"); } } catch (IOException e) { logger.fatal("Problem reading plugin.xml", e); return "cpf"; } } return pluginId; }
From source file:pt.webdetails.cpf.plugins.Plugin.java
License:Open Source License
@JsonIgnore private void pluginSelfBuild(IReadAccess access) { this.pluginDirAccess = access; try {// w w w . ja v a 2 s . co m if (hasPluginXML()) { Node documentNode = XmlDom4JUtils.getDocumentFromFile(access, PLUGIN_XML_FILENAME).getRootElement(); //String pluginTitle = documentNode.valueOf("/plugin/@title"); String pluginName = documentNode.valueOf("/plugin/@name"); setName(pluginName); //setTitle( pluginTitle ); //setName(documentNode.valueOf("/plugin/content-types/content-type/title")); setDescription(documentNode.valueOf("/plugin/content-types/content-type/description")); setCompany(documentNode.valueOf("/plugin/content-types/content-type/company/@name")); setCompanyUrl(documentNode.valueOf("/plugin/content-types/content-type/company/@url")); setCompanyLogo(documentNode.valueOf("/plugin/content-types/content-type/company/@logo")); } if (hasVersionXML()) { Document versionDoc = XmlDom4JUtils.getDocumentFromFile(access, VERSION_XML_FILENAME); this.version = new VersionChecker.Version(versionDoc).toString(); } else { String unspecified = "unspecified or no version.xml present in plugin directory"; this.version = unspecified; } } catch (IOException e) { logger.error(e); } }
From source file:pt.webdetails.cpf.plugins.Plugin.java
License:Open Source License
@JsonIgnore public String getXmlValue(String xpathExpression, String fileName) { try {/* w w w.j a va 2 s .c o m*/ Node documentRoot = XmlDom4JUtils.getDocumentFromFile(pluginDirAccess, fileName); return documentRoot != null ? documentRoot.valueOf(xpathExpression) : null; } catch (Exception ex) { logger.error(ex); } return null; }
From source file:pt.webdetails.cpk.CpkEngine.java
License:Open Source License
private void loadElements() { try {// w ww . ja va 2s . c om // open settings file InputStream is = this.environment.getContentAccessFactory().getPluginSystemReader(null) .getFileInputStream(this.settingsFilename); // parse settings file SAXReader reader = new SAXReader(); Document doc = reader.read(is); // clean elements map this.elementsMap.clear(); // go through each element type List elementTypeNodes = doc.selectNodes("/cpk/elementTypes/elementType"); for (Object elementTypeNode : elementTypeNodes) { Node type = (Node) elementTypeNode; // get element type attributes String typeName = type.valueOf("./@name"); String typeClass = type.valueOf("./@class"); logger.info("Loading '" + typeName + "' elements [" + typeClass + "]"); // go through each location for elements of that type List elementLocations = type.selectNodes("elementLocations/elementLocation"); for (Object elementLocation : elementLocations) { Node location = (Node) elementLocation; // get location attributes String path = location.valueOf("@path"); Boolean isRecursive = Boolean.parseBoolean(location.valueOf("@isRecursive")); String pattern = location.valueOf("@pattern"); Boolean adminOnly = Boolean.parseBoolean(location.valueOf("@adminOnly")); // go through each file in that location and load elements Collection<File> files = this.environment.getPluginUtils().getPluginResources(path, isRecursive, pattern); if (files != null) { for (File file : files) { loadElement(typeName, typeClass, file.getAbsolutePath(), adminOnly); } } } } // get default element this.defaultElement = findDefaultElement( doc.selectSingleNode("/cpk/elementTypes").valueOf("@defaultElement").toLowerCase()); // close file is.close(); } catch (IOException e) { logger.error("Failed to open settings file '" + this.settingsFilename + "'"); } catch (DocumentException e) { logger.error("Failed to parse settings file '" + this.settingsFilename + "'"); } }
From source file:pt.webdetails.cpk.elements.AbstractElementType.java
License:Mozilla Public License
/** * Scans the location of the directory and returns a list of the content * * @param node//from www. j av a 2 s. c om */ @Override public List<IElement> scanElements(Node node) { // Initialize container ArrayList<IElement> iElements = new ArrayList<IElement>(); // Grab resource loader IPluginResourceLoader resLoader = PentahoSystem.get(IPluginResourceLoader.class, null); // Get list of files to process List<Node> elementLocations = node.selectNodes("elementLocations/elementLocation"); for (Node elementLocation : elementLocations) { // Get the list of elements. We need to filter only the ones we want String elementPath = elementLocation.valueOf("@path"); Boolean isRecursive = Boolean.parseBoolean(elementLocation.valueOf("@isRecursive")); String pattern = elementLocation.valueOf("@pattern"); Collection<File> elements = PluginUtils.getInstance().getPluginResources(elementPath, isRecursive, pattern); if (elements == null) continue; // Found the list we need. Processing it! for (File elementFile : elements) { IElement iElement = this.registerElement(elementFile.getAbsolutePath(), elementLocation); if (iElement != null) { // Now - there are some reserved words for the id iElements.add(iElement); logger.debug("Registred element " + iElement.toString()); } } } return iElements; }
From source file:pt.webdetails.cpk.elements.AbstractElementType.java
License:Mozilla Public License
/** * Main shared initialization code. This assigns the id, location and name * properties/*ww w . ja v a 2s . c o m*/ * * @param element * @param elementLocation * @return */ public void initBaseProperties(AbstractElement element, String elementLocation, Node node) { element.setLocation(elementLocation); element.setId(FilenameUtils.getBaseName(elementLocation)); element.setElementType(this.getType()); element.setName(element.getId()); element.setAdminOnly(Boolean.parseBoolean(node.valueOf("@adminOnly"))); element.setTopLevel(node.valueOf("@path")); element.setElementInfo(createElementInfo()); }
From source file:pt.webdetails.di.baserver.utils.inspector.WadlParser.java
License:Open Source License
private Collection<Endpoint> parseResources(Node resourceNode, final String parentPath) { String path = resourceNode.valueOf("@path"); if (path.isEmpty()) { path = parentPath;/*from w ww . j av a 2s .c o m*/ } else { path = parentPath + "/" + sanitizePath(path); } TreeSet<Endpoint> endpoints = new TreeSet<Endpoint>(); for (Object methodNode : resourceNode.selectNodes("*[name() = 'method']")) { endpoints.add(parseMethod((Node) methodNode, path)); } /* Node methodNode = resourceNode.selectSingleNode( "*[name() = 'method']" ); if ( methodNode != null ) { } */ for (Object innerResourceNode : resourceNode.selectNodes("*[name() = 'resource']")) { endpoints.addAll(parseResources((Node) innerResourceNode, path)); } return endpoints; }
From source file:pt.webdetails.di.baserver.utils.inspector.WadlParser.java
License:Open Source License
private Endpoint parseMethod(Node methodNode, final String path) { Endpoint endpoint = new Endpoint(); endpoint.setId(methodNode.valueOf("@id")); endpoint.setHttpMethod(HttpMethod.valueOf(methodNode.valueOf("@name"))); endpoint.setPath(shortPath(path));/*from w w w . j a v a2 s .c o m*/ Node requestNode = methodNode.selectSingleNode("*[name() = 'request']"); if (requestNode != null) { for (Object queryParamNode : requestNode.selectNodes("*[name() = 'param']")) { endpoint.getQueryParams().add(parseQueryParam((Node) queryParamNode)); } } return endpoint; }
From source file:pt.webdetails.di.baserver.utils.inspector.WadlParser.java
License:Open Source License
private QueryParam parseQueryParam(Node queryParamNode) { QueryParam queryParam = new QueryParam(); queryParam.setName(queryParamNode.valueOf("@name")); queryParam.setType(queryParamNode.valueOf("@type")); return queryParam; }
From source file:ru.itx.ccm.beans.EventListener.java
License:Apache License
private void processPresence(Document document) { users.clear();//from w ww .j av a 2s . c o m for (Node node : (List<Node>) document.selectNodes("/profile/registrations/registration")) { String userName = node.valueOf("user").replace("@" + domain, ""); String userStatus = node.valueOf("agent") + " " + node.valueOf("status").replace("(unknown)", ""); users.put(userName, userStatus); } }