List of usage examples for org.jdom2 Element getChildText
public String getChildText(final String cname, final Namespace ns)
From source file:org.artifactory.version.converter.v152.BlackDuckProxyConverter.java
License:Open Source License
private Element findDefaultProxy(Element rootElement, Namespace namespace) { Element proxies = rootElement.getChild("proxies", namespace); if (proxies != null) { for (Object proxy : proxies.getChildren("proxy", namespace)) { if (proxy instanceof Element) { Element proxyElement = (Element) proxy; if ("true".equalsIgnoreCase(proxyElement.getChildText("defaultProxy", namespace))) { return proxyElement; }/*from w w w .j av a2 s.c o m*/ } } } return null; }
From source file:org.artifactory.version.converter.v160.MavenIndexerConverter.java
License:Open Source License
private void replaceExcludedWithIncluded(Element rootElement, Namespace namespace, Element indexer, Element excludedRepositories) { List<String> excluded = excludedRepositories.getChildren().stream().map(Element::getText) .collect(Collectors.toList()); if (StringUtils.equals(indexer.getChildText("enabled", namespace), "true")) { Element includedRepositories = new Element("includedRepositories", namespace); collectRepositories(rootElement, namespace).stream().filter(repo -> !excluded.contains(repo)) .forEach(repo -> {/*w w w . j ava 2 s . co m*/ Element repositoryRef = new Element("repositoryRef", namespace); repositoryRef.setText(repo); includedRepositories.addContent(repositoryRef); }); indexer.addContent(new Text("\n ")); indexer.addContent(includedRepositories); } indexer.removeContent(excludedRepositories); }
From source file:org.artifactory.version.converter.v160.SingleRepoTypeConverter.java
License:Open Source License
private void convertLocalRepos(List<Element> repos) { if (repos == null || repos.isEmpty()) { return;/*from w w w. j ava 2 s . co m*/ } for (Element repo : repos) { List<RepoType> repoTypes = Lists.newArrayList(); fillSharedTypes(repoTypes, repo, false); addType(repoTypes, repo, RepoType.YUM, false); String repoKey = repo.getChildText("key", repo.getNamespace()); convertToSingleRepoType(repo, repoKey, repoTypes, false); } }
From source file:org.artifactory.version.converter.v160.SingleRepoTypeConverter.java
License:Open Source License
private void convertRemoteRepos(List<Element> repos) { if (repos == null || repos.isEmpty()) { return;/*w w w .ja v a 2 s .c o m*/ } for (Element repo : repos) { List<RepoType> repoTypes = Lists.newArrayList(); fillSharedTypes(repoTypes, repo, false); if (!repoTypes.contains(RepoType.Bower)) { // Bower + VCS = Bower repository addType(repoTypes, repo, RepoType.VCS, false); } String repoKey = repo.getChildText("key", repo.getNamespace()); convertToSingleRepoType(repo, repoKey, repoTypes, false); } }
From source file:org.artifactory.version.converter.v160.SingleRepoTypeConverter.java
License:Open Source License
private void convertVirtualRepos(List<Element> repos) { if (repos == null || repos.isEmpty()) { return;/*from www.j av a 2 s.c o m*/ } for (Element repo : repos) { List<RepoType> repoTypes = Lists.newArrayList(); fillSharedTypes(repoTypes, repo, true); Element p2 = repo.getChild("p2", repo.getNamespace()); if (p2 != null) { if (StringUtils.equals(p2.getChildText("enabled", p2.getNamespace()), "true")) { addType(repoTypes, p2, RepoType.P2, true); } } String repoKey = repo.getChildText("key", repo.getNamespace()); convertToSingleRepoType(repo, repoKey, repoTypes, true); } }
From source file:org.artifactory.version.converter.v160.SingleRepoTypeConverter.java
License:Open Source License
private void convertToSingleRepoType(Element repo, String repoKey, List<RepoType> repoTypes, boolean virtualRepo) { if (repoTypes.size() >= 1) { repoTypes.stream().skip(1) // First one is used as the final repository type .forEach(repoType -> log.error( "Disabling package '{}' for repo '{}' " + "since only one packaging type is allowed!", repoType, repoKey)); } else {/*w w w . ja v a 2s. c om*/ String layoutRef = repo.getChildText("repoLayoutRef", repo.getNamespace()); if (StringUtils.equals(layoutRef, "ivy-default")) { repoTypes.add(RepoType.Ivy); } else if (StringUtils.equals(layoutRef, "gradle-default")) { repoTypes.add(RepoType.Gradle); } else { repoTypes.add(RepoType.Maven); } } // Set the final decided repo type RepoType repoType = repoTypes.get(0); log.info("Setting repository '{}' to type {}", repoKey, repoType); Element typeElement = new Element("type", repo.getNamespace()); typeElement.setText(String.valueOf(repoType).toLowerCase()); repo.addContent(2, new Text("\n ")); repo.addContent(3, typeElement); // add the type after the key property removeEnabledFieldsFromRepo(repo, virtualRepo); }
From source file:org.artifactory.version.converter.v160.SingleRepoTypeConverter.java
License:Open Source License
private void addYumForLegacy(List<RepoType> repoTypes, Element element) { String depth = element.getChildText("yumRootDepth", element.getNamespace()); String groupNames = element.getChildText("yumGroupFileNames", element.getNamespace()); try {/*from www . ja v a 2 s.co m*/ if ((StringUtils.isNotBlank(depth) && Integer.valueOf(depth) > 0) || StringUtils.isNotBlank(groupNames)) { repoTypes.add(RepoType.YUM); } } catch (NumberFormatException e) { log.warn("Unresolvable YUM configuration, YUM metadata root depth is {}. ", depth); } }
From source file:org.artifactory.version.converter.v160.SingleRepoTypeConverter.java
License:Open Source License
private void addType(List<RepoType> repoTypes, Element element, RepoType type, boolean virtualRepo) { String fieldName = resolveFieldName(type, virtualRepo); boolean isEnabled = Boolean.valueOf(element.getChildText(fieldName, element.getNamespace())); if (isEnabled) { repoTypes.add(type);/*from w w w. j a v a 2 s. c o m*/ } }
From source file:org.artifactory.version.converter.v169.PasswordMaxAgeConverter.java
License:Open Source License
@Override public void convert(Document doc) { log.info("Starting user PasswordMaxAgeConverter conversion"); Element rootElement = doc.getRootElement(); Namespace namespace = rootElement.getNamespace(); Element securityConfigElement = rootElement.getChild("security", namespace); if (securityConfigElement != null) { Element passwordSettings = securityConfigElement.getChild("passwordSettings", namespace); if (passwordSettings != null) { Element expirationPolicy = passwordSettings.getChild("expirationPolicy", namespace); if (expirationPolicy != null) { String passwordMaxAge = String.valueOf(new PasswordExpirationPolicy().getPasswordMaxAge()); if (expirationPolicy.getChild("expiresIn", namespace) != null) { passwordMaxAge = expirationPolicy.getChildText("expiresIn", namespace); expirationPolicy.removeChild("expiresIn", namespace); }//from w ww.j av a2 s . c o m if (expirationPolicy.getChild("passwordMaxAge", namespace) == null) { expirationPolicy.addContent(3, new Element("passwordMaxAge", namespace).setText(passwordMaxAge)); } } } } log.info("Finished PasswordMaxAgeConverter conversion"); }
From source file:org.helm.notation2.tools.MonomerParser.java
License:Open Source License
/** * Convert ATTACHMENT element to Attachment object * * @param attachment element/*from w ww . j av a 2 s . co m*/ * @return Attachment */ public static Attachment getAttachment(Element attachment) { Namespace ns = attachment.getNamespace(); Attachment att = new Attachment(); att.setAlternateId(attachment.getChildText(ATTACHEMENT_ID_ELEMENT, ns)); att.setLabel(attachment.getChildText(ATTACHEMENT_LABEL_ELEMENT, ns)); att.setCapGroupName(attachment.getChildText(CAP_GROUP_NAME_ELEMENT, ns)); att.setCapGroupSMILES(attachment.getChildText(CAP_GROUP_SMILES_ELEMENT, ns)); return att; }