List of usage examples for org.dom4j.tree DefaultElement clone
public Object clone()
From source file:org.olat.ims.cp.CPCore.java
License:Apache License
/** * duplicates an element and inserts it after targetID * /*w w w .j a v a 2 s .c o m*/ * @param sourceID * @param targetID */ public String copyElement(final String sourceID, final String targetID) { final DefaultElement elementToCopy = rootNode.getElementByIdentifier(sourceID); if (elementToCopy == null) { throw new OLATRuntimeException(CPOrganizations.class, "element with identifier \"" + sourceID + "\" not found..!", new Exception()); } if (elementToCopy instanceof CPItem) { final CPItem newItem = (CPItem) elementToCopy.clone(); cloneResourceOfItemAndSubitems(newItem); addElementAfter(newItem, targetID); return newItem.getIdentifier(); } else { // if (elementToCopy.getClass().equals(CPOrganization.class)) { // not yet supported throw new OLATRuntimeException(CPOrganizations.class, "You can only copy <item>-elements...!", new Exception()); } }