// inform the listeners
final String parentNodeId = this.getParentId(nodeId);
final IUserLayoutNodeDescription parentNode = this.getNode(parentNodeId);
LayoutEvent ev = new LayoutEvent(this, parentNode, node);
for(Iterator i=listeners.iterator();i.hasNext();) {
LayoutEventListener lel=(LayoutEventListener)i.next();
lel.channelUpdated(ev);
}
} else {
throw new PortalException("Change channel to folder is not allowed by updateNode() method!");
}
} else {
// must be a folder
if(node instanceof IUserLayoutFolderDescription) {
Document ulm=this.getUserLayoutDOM();
// generate new XML Element
Element newFolderElement=node.getXML(ulm);
Element oldFolderElement=(Element)ulm.getElementById(nodeId);
Node parent=oldFolderElement.getParentNode();
// move children
Vector children=new Vector();
for(Node n=oldFolderElement.getFirstChild(); n!=null;n=n.getNextSibling()) {
children.add(n);
}
for(int i=0;i<children.size();i++) {
newFolderElement.appendChild((Node)children.get(i));
}
// replace the actual node
parent.removeChild(oldFolderElement);
parent.insertBefore(newFolderElement,nextSibling);
// register new child instead
newFolderElement.setIdAttribute("ID", true);
newFolderElement.setAttribute("ID",node.getId());
// inform the listeners
final String parentNodeId = this.getParentId(nodeId);
final IUserLayoutNodeDescription parentNode = this.getNode(parentNodeId);
LayoutEvent ev=new LayoutEvent(this, parentNode, node);
for(Iterator i=listeners.iterator();i.hasNext();) {
LayoutEventListener lel=(LayoutEventListener)i.next();
lel.folderUpdated(ev);
}
}
}
markLayoutDirty();
this.updateCacheKey();