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); }
addedRepositories.add(repository.getUrl());