// when there are no child rels, this is an append operation
if (rels.isEmpty()) {
// we have no children, but the ref child is non-null => can't be ours.. :)
if (refChild != null) {
throw new FrameworkException(404, "Referenced child is not a child of parent node.");
}
treeAppendChild(newChild);
return;
}
for (R rel : rels) {
T node = rel.getTargetNode();
if (node.equals(refChild)) {
// will be used only once here..
PropertyMap properties = new PropertyMap();
properties.put(AbstractChildren.position, position);
linkNodes(getChildLinkType(), (T) LinkedTreeNode.this, newChild, properties);
found = true;
position++;
}
rel.setProperty(AbstractChildren.position, position);
position++;
}
// if child is not found, raise an exception
if (!found) {
throw new FrameworkException(404, "Referenced child is not a child of parent node.");
}
// insert new node in linked list
LinkedTreeNode.super.listInsertBefore(refChild, newChild);