@Override public SoapBindingType getBindingTypeFromWsdlFile(String wsdlPath) { // Check if provided wsdl file exists if (getFileManager().exists(wsdlPath)) { // Obtain document final Document document = XmlUtils.readXml(getFileManager().getInputStream(wsdlPath)); // Get soap attribute String soapAttr = document.getDocumentElement().getAttribute("xmlns:soap"); if ("http://schemas.xmlsoap.org/wsdl/soap/".equals(soapAttr)) { return SoapBindingType.SOAP11; } else if ("http://schemas.xmlsoap.org/wsdl/soap12/".equals(soapAttr)) { return SoapBindingType.SOAP12; } else if (soapAttr == null || "".equals(soapAttr)) { // Maybe attribute is called soap12 String soap12Attr = document.getDocumentElement().getAttribute("xmlns:soap12"); if ("http://schemas.xmlsoap.org/wsdl/soap12/".equals(soap12Attr)) { return SoapBindingType.SOAP12; } } } return null; }
private void resolveParentPom(final String pomPath, final Map<String, String> pomSet, final Element parentElement) { final String relativePath = XmlUtils.getTextContent("/relativePath", parentElement, DEFAULT_RELATIVE_PATH); final String parentPomPath = resolveRelativePath(pomPath, relativePath); final boolean alreadyDiscovered = pomSet.containsKey(parentPomPath); if (!alreadyDiscovered) { pomSet.put(parentPomPath, pomSet.get(parentPomPath)); if (new File(parentPomPath).isFile()) { final Document pomDocument = XmlUtils.readXml(getFileManager().getInputStream(parentPomPath)); final Element root = pomDocument.getDocumentElement(); resolvePoms(root, parentPomPath, pomSet); } } }
@Override public String getTargetNameSpaceFromWsdlFile(String wsdlPath) { // Check if provided wsdl file exists if (getFileManager().exists(wsdlPath)) { // Obtain document final Document document = XmlUtils.readXml(getFileManager().getInputStream(wsdlPath)); // Return targetNamespace return document.getDocumentElement().getAttribute("targetNamespace"); } return null; }
@Override public List<String> getEndPointsFromWsdlFile(String wsdlPath) { List<String> availableEndPoints = new ArrayList<String>(); // Check if provided wsdl file exists if (getFileManager().exists(wsdlPath)) { // Obtain document final Document document = XmlUtils.readXml(getFileManager().getInputStream(wsdlPath)); // Finding service elements List<Element> services = XmlUtils.findElements("service", document.getDocumentElement()); for (Element service : services) { NodeList ports = service.getChildNodes(); for (int i = 0; i < ports.getLength(); i++) { Element port = (Element) ports.item(1); if (port != null && port.getAttribute("name") != null) { availableEndPoints.add(port.getAttribute("name")); } } } } return availableEndPoints; }
@Override public String getServiceUrlForEndpointFromWsdlFile(String endPoint, String wsdlPath) { // Check if provided wsdl file exists if (getFileManager().exists(wsdlPath)) { // Obtain document final Document document = XmlUtils.readXml(getFileManager().getInputStream(wsdlPath)); // Finding service elements List<Element> services = XmlUtils.findElements("service", document.getDocumentElement()); for (Element service : services) { NodeList ports = service.getChildNodes(); for (int i = 0; i < ports.getLength(); i++) { Element port = (Element) ports.item(1); // Check if current endPoint has the same name as the provided one if (port != null && port.getAttribute("name") != null && endPoint.equals(port.getAttribute("name"))) { NodeList addresses = port.getChildNodes(); for (int x = 0; x < addresses.getLength(); x++) { if (addresses.item(x) != null && addresses.item(x) instanceof Element) { Element address = (Element) addresses.item(x); return address.getAttribute("location"); } } } } } } return null; }
private void resolveChildModulePoms(final Element pomRoot, final String pomPath, final Map<String, String> pomSet) { for (final Element module : XmlUtils.findElements("/project/modules/module", pomRoot)) { final String moduleName = module.getTextContent(); if (StringUtils.isNotBlank(moduleName)) { final String modulePath = resolveRelativePath(pomPath, moduleName); final boolean alreadyDiscovered = pomSet.containsKey(modulePath); pomSet.put(modulePath, moduleName); if (!alreadyDiscovered) { final Document pomDocument = XmlUtils.readXml(getFileManager().getInputStream(modulePath)); final Element root = pomDocument.getDocumentElement(); resolvePoms(root, modulePath, pomSet); } } } }
InputStream inputStream = fileManager.getInputStream(pomRooAddonSuite);
@Override public List<Dependency> addDependencies(final String moduleName, final Collection<? extends Dependency> newDependencies, boolean addToDependencyManagement, boolean checkFullDependency) { Validate.isTrue(isProjectAvailable(moduleName), "Dependency modification prohibited; no such module '%s'", moduleName); final Pom parentPom = getPomFromModuleName(""); boolean isSamePom = false; Pom pom = null; if ("".equals(moduleName)) { isSamePom = true; pom = parentPom; } else { pom = getPomFromModuleName(moduleName); } Validate.notNull(pom, "The pom is not available, so dependencies cannot be added"); final Document parentDocument = XmlUtils.readXml(fileManager.getInputStream(parentPom.getPath())); Document document = null; if (isSamePom) { document = parentDocument; } else { document = XmlUtils.readXml(fileManager.getInputStream(pom.getPath())); } return writeDependencyInPom(newDependencies, parentPom, pom, parentDocument, document, parentDocument.getDocumentElement(), document.getDocumentElement(), addToDependencyManagement, isSamePom, checkFullDependency); }
XmlUtils.readXml(fileManager.getInputStream(parentPom.getPath())); Document document = null; if (isSamePom) { document = parentDocument; } else { document = XmlUtils.readXml(fileManager.getInputStream(pom.getPath()));
public void updateProjectType(final String moduleName, final ProjectType projectType) { Validate.notNull(projectType, "Project type required"); final Pom pom = getPomFromModuleName(moduleName); Validate.notNull(pom, "The pom is not available, so the project type cannot be changed"); final Document document = XmlUtils.readXml(fileManager.getInputStream(pom.getPath())); final Element packaging = DomUtils.createChildIfNotExists("packaging", document.getDocumentElement(), document); if (packaging.getTextContent().equals(projectType.getType())) { return; } packaging.setTextContent(projectType.getType()); final String descriptionOfChange = highlight(UPDATED + " project type") + " to " + projectType.getType(); fileManager.createOrUpdateTextFileIfRequired(pom.getPath(), XmlUtils.nodeToString(document), descriptionOfChange, false); }
private void updateParentModulePom(final String moduleName) { final String parentPomPath = pomManagementService.getFocusedModule().getPath(); final Document parentPomDocument = XmlUtils.readXml(fileManager.getInputStream(parentPomPath)); final Element parentPomRoot = parentPomDocument.getDocumentElement(); DomUtils.createChildIfNotExists("packaging", parentPomRoot, parentPomDocument).setTextContent( "pom"); addModuleDeclaration(moduleName, parentPomDocument, parentPomRoot); final String addModuleMessage = getDescriptionOfChange(ADDED, Collections.singleton(moduleName), "module", "modules"); fileManager.createOrUpdateTextFileIfRequired(getFocusedModule().getPath(), XmlUtils.nodeToString(parentPomDocument), addModuleMessage, false); }
public void addResource(final String moduleName, final Resource resource) { Validate .isTrue(isProjectAvailable(moduleName), "Resource modification prohibited at this time"); Validate.notNull(resource, "Resource to add required"); final Pom pom = getPomFromModuleName(moduleName); Validate.notNull(pom, "The pom is not available, so resource addition cannot be performed"); if (pom.isResourceRegistered(resource)) { return; } final Document document = XmlUtils.readXml(fileManager.getInputStream(pom.getPath())); final Element buildElement = XmlUtils.findFirstElement("/project/build", document.getDocumentElement()); final Element resourcesElement = DomUtils.createChildIfNotExists("resources", buildElement, document); resourcesElement.appendChild(resource.getElement(document)); final String descriptionOfChange = highlight(ADDED + " resource") + " " + resource.getSimpleDescription(); fileManager.createOrUpdateTextFileIfRequired(pom.getPath(), XmlUtils.nodeToString(document), descriptionOfChange, false); }
private void removeRepository(final String moduleName, final Repository repository, final String path) { Validate.isTrue(isProjectAvailable(moduleName), "Repository modification prohibited at this time"); Validate.notNull(repository, "Repository required"); final Pom pom = getPomFromModuleName(moduleName); Validate.notNull(pom, "The pom is not available, so repository removal cannot be performed"); if ("pluginRepository".equals(path)) { if (!pom.isPluginRepositoryRegistered(repository)) { return; } } else { if (!pom.isRepositoryRegistered(repository)) { return; } } final Document document = XmlUtils.readXml(fileManager.getInputStream(pom.getPath())); final Element root = document.getDocumentElement(); String descriptionOfChange = ""; for (final Element candidate : XmlUtils.findElements(path, root)) { if (repository.equals(new Repository(candidate))) { candidate.getParentNode().removeChild(candidate); descriptionOfChange = highlight(REMOVED + " repository") + " " + repository.getUrl(); // We stay in the loop just in case it was in the POM more than // once } } fileManager.createOrUpdateTextFileIfRequired(pom.getPath(), XmlUtils.nodeToString(document), descriptionOfChange, false); }
final Document document = XmlUtils.readXml(fileManager.getInputStream(pom.getPath())); final Element root = document.getDocumentElement();
public void removeProperty(final String moduleName, final Property property) { Validate .isTrue(isProjectAvailable(moduleName), "Property modification prohibited at this time"); Validate.notNull(property, "Property to remove required"); final Pom pom = getPomFromModuleName(moduleName); Validate.notNull(pom, "The pom is not available, so property removal cannot be performed"); if (!pom.isPropertyRegistered(property)) { return; } final Document document = XmlUtils.readXml(fileManager.getInputStream(pom.getPath())); final Element root = document.getDocumentElement(); final Element propertiesElement = XmlUtils.findFirstElement("/project/properties", root); String descriptionOfChange = ""; for (final Element candidate : XmlUtils.findElements("/project/properties/*", document.getDocumentElement())) { if (property.equals(new Property(candidate))) { propertiesElement.removeChild(candidate); descriptionOfChange = highlight(REMOVED + " property") + " " + property.getName(); // Stay in the loop just in case it was in the POM more than // once } } DomUtils.removeTextNodes(propertiesElement); fileManager.createOrUpdateTextFileIfRequired(pom.getPath(), XmlUtils.nodeToString(document), descriptionOfChange, false); }
final Document document = XmlUtils.readXml(fileManager.getInputStream(pom.getPath())); final Element root = document.getDocumentElement(); final Element resourcesElement = XmlUtils.findFirstElement("/project/build/resources", root);
public void addFilter(final String moduleName, final Filter filter) { Validate.isTrue(isProjectAvailable(moduleName), "Filter modification prohibited at this time"); Validate.notNull(filter, "Filter required"); final Pom pom = getPomFromModuleName(moduleName); Validate.notNull(pom, "The pom is not available, so filter addition cannot be performed"); if (filter == null || pom.isFilterRegistered(filter)) { return; } final Document document = XmlUtils.readXml(fileManager.getInputStream(pom.getPath())); final Element root = document.getDocumentElement(); final String descriptionOfChange; final Element buildElement = XmlUtils.findFirstElement("/project/build", root); final Element existingFilter = XmlUtils.findFirstElement("filters/filter['" + filter.getValue() + "']", buildElement); if (existingFilter == null) { // No such filter; add it final Element filtersElement = DomUtils.createChildIfNotExists("filters", buildElement, document); filtersElement.appendChild(XmlUtils.createTextElement(document, "filter", filter.getValue())); descriptionOfChange = highlight(ADDED + " filter") + " '" + filter.getValue() + "'"; } else { existingFilter.setTextContent(filter.getValue()); descriptionOfChange = highlight(UPDATED + " filter") + " '" + filter.getValue() + "'"; } fileManager.createOrUpdateTextFileIfRequired(pom.getPath(), XmlUtils.nodeToString(document), descriptionOfChange, false); }
final Document document = XmlUtils.readXml(fileManager.getInputStream(pom.getPath())); final Element root = document.getDocumentElement();
final Document document = XmlUtils.readXml(fileManager.getInputStream(pom.getPath())); final Element root = document.getDocumentElement(); final Element dependencyElement =
final Document document = XmlUtils.readXml(fileManager.getInputStream(pom.getPath())); final Element root = document.getDocumentElement(); final String descriptionOfChange;