List of usage examples for org.jdom2 Element setName
public Element setName(final String name)
From source file:org.artifactory.update.md.v125rc0.MdFolderConverter.java
License:Open Source License
@Override public void convert(Document doc) { Element rootElement = doc.getRootElement(); rootElement.setName(getNewMetadataName()); RepoPath repoPath = MetadataConverterUtils.extractRepoPath(rootElement); // In this version the relPath is the father and name need to be added if (rootElement.getChild(ARTIFACTORY_NAME) != null) { String name = rootElement.getChildText(ARTIFACTORY_NAME); repoPath = InternalRepoPathFactory.create(repoPath, name); }/*from ww w . ja va 2s . c o m*/ List<Element> toMove = MetadataConverterUtils.extractExtensionFields(rootElement); MetadataConverterUtils.addNewContent(rootElement, repoPath, toMove); // Not used anymore rootElement.removeChild(ARTIFACTORY_NAME); }
From source file:org.artifactory.update.md.v125rc0.MdStatsConverter.java
License:Open Source License
@Override public void convert(Document doc) { Element root = doc.getRootElement(); Element downloadCount = root.getChild("downloadCount"); if (downloadCount == null) { downloadCount = new Element("downloadCount"); downloadCount.setText("0"); }/*w ww . j ava 2 s .co m*/ // rename the root to the stats name root.setName(STATS_NAME); // remove all childer root.removeContent(); // add the download count root.addContent(downloadCount); }
From source file:org.artifactory.update.md.v130beta3.ArtifactoryFileConverter.java
License:Open Source License
@Override public void convert(Document doc) { Element rootElement = doc.getRootElement(); if (rootElement.getName().equals(getNewMetadataName())) { // Already done return;/*from w w w . ja v a 2 s . co m*/ } rootElement.setName(getNewMetadataName()); RepoPath repoPath = MetadataConverterUtils.extractRepoPath(rootElement); List<Element> toMove = MetadataConverterUtils.extractExtensionFields(rootElement); MetadataConverterUtils.addNewContent(rootElement, repoPath, toMove); MimeType ct = NamingUtils.getMimeType(repoPath.getName()); rootElement.removeChild("mimeType"); rootElement.addContent(new Element("mimeType").setText(ct.getType())); }
From source file:org.artifactory.update.md.v130beta3.ArtifactoryFolderConverter.java
License:Open Source License
@Override public void convert(Document doc) { Element rootElement = doc.getRootElement(); rootElement.setName(getNewMetadataName()); RepoPath repoPath = MetadataConverterUtils.extractRepoPath(rootElement); List<Element> toMove = MetadataConverterUtils.extractExtensionFields(rootElement); MetadataConverterUtils.addNewContent(rootElement, repoPath, toMove); }
From source file:org.artifactory.update.md.v130beta6.ChecksumsConverter.java
License:Open Source License
@Override public void convert(Document doc) { Element root = doc.getRootElement(); Element extension = root.getChild("extension"); // rename the extensions to additionalInfo extension.setName("additionalInfo"); // now get the sha1 and md5 values Element sha1Node = extension.getChild("sha1"); String sha1 = null;/*w w w .j ava2 s. co m*/ if (sha1Node != null) { sha1 = sha1Node.getValue(); extension.removeContent(sha1Node); } else { log.debug("SHA1 checksum not found, setting it to {}", sha1); } Element md5Node = extension.getChild("md5"); String md5 = null; if (md5Node != null) { md5 = md5Node.getValue(); extension.removeContent(md5Node); } else { log.debug("MD5 checksum not found, setting it to {}", md5); } // create the new checksums nodes Element checksumsInfo = new Element("checksumsInfo"); extension.addContent(checksumsInfo); Element checksums = new Element("checksums"); checksumsInfo.addContent(checksums); addChecksum(checksums, ChecksumType.sha1, sha1); addChecksum(checksums, ChecksumType.md5, md5); }
From source file:org.artifactory.update.md.v130beta6.FolderAdditionalInfoNameConverter.java
License:Open Source License
@Override public void convert(Document doc) { Element root = doc.getRootElement(); Element extension = root.getChild("extension"); if (extension != null) { extension.setName("additionalInfo"); } else {//w w w. jav a 2 s . c o m log.warn("Folder info extension node not found"); } }
From source file:org.artifactory.update.security.v2.RepoPathAclConverter.java
License:Open Source License
@Override @SuppressWarnings({ "unchecked" }) public void convert(Document doc) { Element aclsTag = doc.getRootElement().getChild("acls"); List<Element> acls = aclsTag.getChildren(); for (Element acl : acls) { if (acl.getName().contains("RepoPathAcl")) { acl.setName("acl"); convertIdentifierToPermissionTarget(acl); Element acesTag = acl.getChild(ACES); Element aceListTag = acesTag.getChild("list"); List<Element> aces = aceListTag.getChildren("org.artifactory.security.RepoPathAce"); Element newAces = new Element(ACES); Element aceTemplate = new Element("ace"); Element groupEl = new Element("group"); groupEl.setText("false"); aceTemplate.addContent(new Element(PRINCIPAL)).addContent(groupEl).addContent(new Element(MASK)); for (Element ace : aces) { Element newAce = (Element) aceTemplate.clone(); newAce.getChild(PRINCIPAL).setText(ace.getChildText(PRINCIPAL)); Element maskEl = ace.getChild(MASK); int mask = Integer.parseInt(maskEl.getText()); if ((mask & (ArtifactoryPermission.MANAGE.getMask() | ArtifactoryPermission.DEPLOY.getMask())) > 0) { mask |= ArtifactoryPermission.DELETE.getMask(); }/*from w w w. j a v a 2s .c om*/ newAce.getChild(MASK).setText("" + mask); newAces.addContent(newAce); } acl.removeChild(ACES); acl.addContent(newAces); } else { log.warn("Acl tag " + acl + " under acls is not a RepoPAthAcl!"); } } }
From source file:org.artifactory.update.security.v2.SimpleUserConverter.java
License:Open Source License
@Override @SuppressWarnings({ "unchecked" }) public void convert(Document doc) { Element usersTag = doc.getRootElement().getChild("users"); List<Element> users = usersTag.getChildren(); for (Element user : users) { if (user.getName().contains("SimpleUser")) { user.setName("user"); user.removeChild("authorities"); } else {//ww w. ja v a 2 s.c o m log.warn("A tag " + user + " under users is not SimpleUSer!!"); } } }
From source file:org.artifactory.update.security.v3.AclRepoKeysConverter.java
License:Open Source License
@Override public void convert(Document doc) { Element aclsTag = doc.getRootElement().getChild("acls"); @SuppressWarnings({ "unchecked" }) List<Element> acls = aclsTag.getChildren(); for (Element acl : acls) { Element permissionTarget = acl.getChild("permissionTarget"); Element repoKeyElement = permissionTarget.getChild("repoKey"); permissionTarget.removeContent(repoKeyElement); // create the new element - repoKeys and add to the acl Element repoKeys = new Element("repoKeys"); repoKeyElement.setName("string"); // the xstream element name repoKeys.addContent(repoKeyElement); permissionTarget.addContent(repoKeys); }// w w w . j a v a2 s . c o m }
From source file:org.artifactory.version.converter.SnapshotUniqueVersionConverter.java
License:Open Source License
@Override public void convert(Document doc) { Element root = doc.getRootElement(); Namespace ns = root.getNamespace(); List localRepos = root.getChild("localRepositories", ns).getChildren(); for (Object localRepo1 : localRepos) { Element localRepo = (Element) localRepo1; Element snapshotBehavior = localRepo.getChild("useSnapshotUniqueVersions", ns); if (snapshotBehavior != null) { // rename the element snapshotBehavior.setName("snapshotVersionBehavior"); String repoKey = localRepo.getChildText("key", ns); log.debug(/* w w w.j a v a2 s . c o m*/ "Renamed element 'useSnapshotUniqueVersions' to " + "'snapshotVersionBehavior' for repo {}", repoKey); // change the element value if (snapshotBehavior.getText().equals("true")) { log.debug("Changed value 'true' to 'deployer' for repo {}", repoKey); snapshotBehavior.setText("deployer"); } else if (snapshotBehavior.getText().equals("false")) { log.debug("Changed value 'false' to 'non-unique' for repo {}", repoKey); snapshotBehavior.setText("non-unique"); } } } }