try {
authoringTree = getPublication().getTree(Publication.AUTHORING_AREA);
liveTree = getPublication().getTree(Publication.LIVE_AREA);
SiteTreeNode authoringNode = authoringTree.getNode(documentId);
SiteTreeNode[] siblings = authoringNode.getNextSiblings();
String parentId = authoringNode.getAbsoluteParentId();
SiteTreeNode sibling = null;
String siblingDocId = null;
for (int i = 0; i < siblings.length; i++) {
String docId = parentId + "/" + siblings[i].getId();
sibling = liveTree.getNode(docId);
if (sibling != null) {
siblingDocId = docId;
break;
}
}
if (language == null) {
// no language was specified. Simply publish the
// node including all languages.
try {
liveTree.addNode(authoringNode, siblingDocId);
} catch (SiteTreeException e1) {
throw new ParentNodeNotFoundException("Couldn't add document: " + documentId
+ " to live tree.", e1);
}
} else {
// a language was specified. Let's see if this
// node even has an entry for the specified
// language.
Label label = authoringNode.getLabel(language);
if (label != null) {
// check if this node has already been
// published
SiteTreeNode liveNode = liveTree.getNode(documentId);
if (liveNode != null) {
// if the node already exists in the live
// tree simply insert the label in the
// live tree
liveTree.setLabel(documentId, label);