* @param newElement
* @param id
* @return
*/
public boolean addElementAfter(DefaultElement newElement, String id) {
DefaultElement beforeElement = rootNode.getElementByIdentifier(id);
if (beforeElement == null) return false;
if (beforeElement instanceof CPItem) {
// beforeElement is a <item>
// ==> newElement has to be an <item>
CPItem beforeItem = (CPItem) beforeElement;
DefaultElement parent = beforeItem.getParentElement();
if (!(newElement instanceof CPItem)) { throw new OLATRuntimeException(CPOrganizations.class, "only <item> element allowed",
new Exception()); }
if (parent instanceof CPItem) {
CPItem p = (CPItem) parent;
p.addItemAt((CPItem) newElement, beforeItem.getPosition() + 1);
} else if (parent instanceof CPOrganization) {
CPOrganization o = (CPOrganization) parent;
o.addItemAt((CPItem) newElement, beforeItem.getPosition() + 1);
} else {
throw new OLATRuntimeException(CPOrganizations.class, "you cannot add an <item> element to a " + parent.getName() + " element",
new Exception());
}
}