* @param destinationElementId the ID of the channel to insert the new channel before or append after
* @throws PortalException
*/
private final void addChannel(Element newChannel, String position, String destinationElementId) throws PortalException
{
IUserLayoutChannelDescription channel=new UserLayoutChannelDescription(newChannel);
if(isTab(destinationElementId)) {
// create a new column and move channel there
IUserLayoutNodeDescription newColumn=ulm.addNode(createFolder("Column"),destinationElementId,null);
ulm.addNode(channel,newColumn.getId(),null);
} else if(isColumn(destinationElementId)) {
// move the channel into the column
ulm.addNode(channel,destinationElementId,null);
} else {
// assume that destinationElementId is that of a sibling channel
String siblingId=null;
if(position.equals("before")) {
siblingId=destinationElementId;
}
ulm.addNode(channel,ulm.getParentId(destinationElementId),siblingId);
}
// Make sure ChannelManager knows about the new channel
final ChannelManager channelManager = pcs.getChannelManager();
channelManager.instantiateChannel(pcs.getHttpServletRequest(), pcs.getHttpServletResponse(), channel.getId());
ulm.saveUserLayout();
}