throws RepositoryException {
// check state of this instance
sanityCheck();
// Get the canonical path of the new node
Path path;
try {
path = PathFactoryImpl.getInstance().create(
getPrimaryPath(), session.getQPath(relPath), true);
} catch (NameException e) {
throw new RepositoryException(
"Failed to resolve path " + relPath
+ " relative to " + this, e);
}
// Get the last path element and check that it's a simple name
Path.Element last = path.getNameElement();
if (!last.denotesName() || last.getIndex() != 0) {
throw new RepositoryException(
"Invalid last path element for adding node "
+ relPath + " relative to " + this);
}
// Get the parent node instance
NodeImpl parentNode;
Path parentPath = path.getAncestor(1);
try {
parentNode = itemMgr.getNode(parentPath);
} catch (PathNotFoundException e) {
if (itemMgr.propertyExists(parentPath)) {
throw new ConstraintViolationException(