public boolean containsInAnyLanguage(Document doc) throws SiteException {
return getTree(doc.area()).containsInAnyLanguage(doc.getUUID());
}
public void copy(Document srcDoc, Document destDoc) throws SiteException {
SiteTree destinationTree = getTree(destDoc.area());
try {
TreeNodeImpl sourceNode = (TreeNodeImpl) srcDoc.getLink().getNode();
SiteTreeNode[] siblings = sourceNode.getNextSiblings();
SiteNode parent = sourceNode.getParent();
String parentId = "";
if (parent != null) {
parentId = parent.getPath();
}
TreeNodeImpl sibling = null;
String siblingPath = null;
// same UUID -> insert at the same position
if (srcDoc.getUUID().equals(destDoc.getUUID())) {
for (int i = 0; i < siblings.length; i++) {
String path = parentId + "/" + siblings[i].getName();
sibling = (TreeNodeImpl) destinationTree.getNode(path);
if (sibling != null) {
siblingPath = path;
break;
}
}
}
if (!sourceNode.hasLink(srcDoc.getLanguage())) {
// the node that we're trying to publish
// doesn't have this language
throw new SiteException("The node " + srcDoc.getPath()
+ " doesn't contain a label for language " + srcDoc.getLanguage());
}
String destPath = destDoc.getPath();
Link link = sourceNode.getLink(srcDoc.getLanguage());
SiteNode destNode = destinationTree.getNode(destPath);
if (destNode == null) {
if (siblingPath == null) {
// called for side effect of add, not return result
destNode = destinationTree.add(destPath);
} else {
// called for side effect of add, not return result
destNode = destinationTree.add(destPath, siblingPath);
}
destinationTree.add(destPath, destDoc);
} else {
destDoc.getLink().setLabel(link.getLabel());
}
} catch (DocumentException e) {
throw new SiteException(e);