// inform the listeners
LayoutEvent ev=new LayoutEvent( this, node);
for( Iterator i=listeners.iterator(); i.hasNext(); )
{
LayoutEventListener lel=(LayoutEventListener)i.next();
lel.channelUpdated( ev );
}
pushChanDiffsIntoPlf( newChannelElement,
(IUserLayoutChannelDescription) node,
oldChannel );
}
else
{
throw new PortalException("Change channel to folder is " +
"not allowed by updateNode() method! Occurred " +
"in layout for "
+ owner.getAttribute(IPerson.USERNAME) + ".");
}
}
else
{
// must be a folder
UserLayoutFolderDescription oldFolder=(UserLayoutFolderDescription) oldNode;
if (oldFolder.getId().equals(getRootFolderId()))
throw new PortalException("Update of root node is not currently allowed!");
if( node instanceof IUserLayoutFolderDescription )
{
Document uld=this.userLayoutDocument;
// generate new XML Element
Element newFolderElement=node.getXML(uld);
Element oldFolderElement=(Element)uld.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(Constants.ATT_ID, true);
// inform the listeners
LayoutEvent ev=new LayoutEvent(this,node);
for(Iterator i=listeners.iterator();i.hasNext();) {
LayoutEventListener lel=(LayoutEventListener)i.next();
lel.folderUpdated(ev);
}
pushFolderDiffsIntoPlf( newFolderElement,
(UserLayoutFolderDescription) node,
oldFolder );
}