List of usage examples for org.jdom2 Element setName
public Element setName(final String name)
From source file:org.artifactory.version.converter.v100.BackupToElementConverter.java
License:Open Source License
@Override public void convert(Document doc) { Element root = doc.getRootElement(); Namespace ns = root.getNamespace(); Element backupDir = root.getChild("backupDir", ns); if (backupDir != null) { root.removeContent(backupDir);/*w w w .j a va 2 s . c o m*/ backupDir.setName("dir"); log.debug("Renamed 'backupDir' to 'dir'"); } Element backupCron = root.getChild("backupCronExp", ns); if (backupCron != null) { root.removeContent(backupCron); backupCron.setName("cronExp"); log.debug("Renamed 'backupCronExp' to 'cronExp'"); } if (backupDir != null && backupCron != null) { // create the new <backup> element and place before the localRepositories Element backup = new Element("backup", ns); backup.addContent(backupDir); backup.addContent(backupCron); int localReposLocation = root.indexOf(root.getChild("localRepositories", ns)); root.addContent(localReposLocation, backup); } else { log.debug("No backup elements found"); } }
From source file:org.artifactory.version.converter.v120.AnonAccessNameConverter.java
License:Open Source License
@Override public void convert(Document doc) { Element root = doc.getRootElement(); Element oldAnnon = root.getChild(OLD_ANNON, root.getNamespace()); if (oldAnnon != null) { oldAnnon.setName(NEW_ANNON); log.debug("Element {} found and converted", OLD_ANNON); } else {//from w w w .j av a 2s . c o m log.debug("Element {} not found", OLD_ANNON); } }
From source file:org.artifactory.version.converter.v1414.AssumedOfflineConverter.java
License:Open Source License
@Override public void convert(Document doc) { log.debug("Converting failedRetrievalCachePeriodSecs"); Element rootElement = doc.getRootElement(); Namespace namespace = rootElement.getNamespace(); Element remoteRepositoriesElement = rootElement.getChild("remoteRepositories", namespace); if (remoteRepositoriesElement == null) { log.debug("No remote repository exists"); return;/*from w w w. ja va 2 s. c o m*/ } List remoteRepositories = remoteRepositoriesElement.getChildren(); for (Object o : remoteRepositories) { Element remoteRepo = (Element) o; Element failedRetrievalElement = remoteRepo.getChild("failedRetrievalCachePeriodSecs", namespace); if (failedRetrievalElement != null) { failedRetrievalElement.setName("assumedOfflinePeriodSecs"); failedRetrievalElement.setText("300"); } } log.debug("Finished converting failedRetrievalCachePeriodSecs"); }
From source file:org.artifactory.version.converter.v143.RemoteChecksumPolicyConverter.java
License:Open Source License
@Override public void convert(Document doc) { Element root = doc.getRootElement(); Namespace ns = root.getNamespace(); Element remoteReposElement = root.getChild("remoteRepositories", ns); if (remoteReposElement != null) { List remoteRepos = remoteReposElement.getChildren("remoteRepository", ns); for (Object remoteRepoObj : remoteRepos) { Element remoteRepo = (Element) remoteRepoObj; Element checksumPolicy = remoteRepo.getChild("checksumPolicyType", ns); if (checksumPolicy != null) { checksumPolicy.setName("remoteRepoChecksumPolicyType"); }/*w w w . j a va2 s . co m*/ } } }
From source file:org.artifactory.version.converter.v149.ReplicationElementNameConverter.java
License:Open Source License
@Override public void convert(Document doc) { log.info("Starting to convert old remote repository replication configurations."); Element rootElement = doc.getRootElement(); Namespace namespace = rootElement.getNamespace(); Element replications = rootElement.getChild("replications", namespace); if (replications != null) { replications.setName("remoteReplications"); List<Element> replicationList = replications.getChildren("replication", namespace); if (replicationList != null) { for (Element replication : replicationList) { replication.setName("remoteReplication"); }/*from w ww .j av a 2s . c om*/ } } log.info("Finished converting old remote repository replication configurations."); }
From source file:org.dvlyyon.net.netconf.marshalling.Filter.java
License:Open Source License
/** * Given an starting XML node and a container path representing a set of empty containers, creates all the XML elements required to * get to the lowest level container in the container hierarchy. * <p> /*from ww w. java 2 s. c om*/ * This is not really used (it was used originally to skip empty containers, but it is recommended that you treat every container as * a distinct class in the hierarchy). * * @param top Root XML node at which to start. * @param containerPath Empty container hierarchy as a path (that looks like "a/b/c"). * @param namespace Namespace of the containers (it is assumed here that the namespace does not change). * @return XML node representing the lowest level container ("c" in the example above). */ static Element getContainerHierarchy(final Element top, final String containerPath, final Namespace namespace) { Element ret = null; final String[] tokens = StringUtils.tokenizeToStringArray(containerPath, "/"); int index = 0; for (String token : tokens) { if (index == 0) { top.setName(token); ret = top; } else { Element bottom = new Element(token, namespace); ret.addContent(bottom); ret = bottom; } index++; } return ret; }
From source file:org.fnppl.opensdx.keyserverfe.ActiveUser.java
License:Open Source License
private static String buildSessionXml(Hashtable<String, Object> hash) { Element e = new Element("sessiondata"); Enumeration<String> en = hash.keys(); while (en.hasMoreElements()) { String key = (String) en.nextElement(); Object value = hash.get(key); if (value instanceof String) { e.addContent((new Element(key)).setText((String) value)); } else if (value instanceof Long) { e.addContent((new Element(key)).setText("" + value)); } else if (value instanceof Boolean) { e.addContent((new Element(key)).setText("" + value)); } else if (value instanceof Integer) { e.addContent((new Element(key)).setText("" + value)); } else if (value instanceof Element) { Element ke = (Element) ((Element) value).clone(); ke.setName(key);//dirty?! e.addContent(ke);//from w w w.ja v a2 s.c om } } org.jdom2.output.XMLOutputter xout = new org.jdom2.output.XMLOutputter(); return xout.outputString(e); }
From source file:org.mycore.datamodel.ifs2.MCRDirectory.java
License:Open Source License
/** * Repairs additional metadata of this directory and all its children *//*from w w w.jav a 2 s .c o m*/ @Override @SuppressWarnings("unchecked") void repairMetadata() throws IOException { data.setName("dir"); data.setAttribute("name", getName()); for (Element childEntry : (List<Element>) data.getChildren()) { childEntry.setName("node"); } for (MCRNode child : getChildren()) { ((MCRStoredNode) child).repairMetadata(); } data.removeChildren("node"); }
From source file:org.mycore.frontend.editor.MCREditorSubmission.java
License:Open Source License
private void renameRepeatedElements(Element element) { String name = element.getName(); int pos = name.lastIndexOf("_XXX_"); if (pos >= 0) { name = name.substring(0, pos);//from w ww .j a v a 2 s .c om element.setName(name); } pos = name.indexOf(ATTR_SEP); if (pos > 0) { element.setName(name.substring(0, pos)); int pos2 = name.indexOf(ATTR_SEP, pos + 2); String attr = name.substring(pos + 2, pos2); String val = name.substring(pos2 + 2).replace(BLANK_ESCAPED, BLANK).replace(SLASH_ESCAPED, SLASH); setAttribute(element, attr, val); } List children = element.getChildren(); for (Object aChildren : children) { renameRepeatedElements((Element) aChildren); } }
From source file:org.mycore.mods.MCRExtractRelatedItemsEventHandler.java
License:Open Source License
private Element cloneRelatedItem(Element relatedItem) { Element mods = (Element) (relatedItem.clone()); mods.setName("mods"); mods.removeAttribute("type"); mods.removeAttribute("href", MCRConstants.XLINK_NAMESPACE); mods.removeAttribute("type", MCRConstants.XLINK_NAMESPACE); mods.removeChildren("part", MCRConstants.MODS_NAMESPACE); return mods;// w w w .ja v a 2 s.c o m }