if (!getPrimaryNodeType().hasOrderableChildNodes()) {
String msg = JcrI18n.notOrderable.text(getPrimaryNodeType().getName(), location());
throw new UnsupportedRepositoryOperationException(msg);
}
Path srcPath = session.pathFactory().create(srcChildRelPath);
if (srcPath.isAbsolute() || srcPath.size() != 1) {
throw new ItemNotFoundException(JcrI18n.invalidPathParameter.text(srcChildRelPath, "srcChildRelPath"));
}
session.checkPermission(this, ModeShapePermissions.ADD_NODE);
SessionCache cache = session.cache();
ChildReferences childRefs = node().getChildReferences(cache);
ChildReference srcRef = childRefs.getChild(srcPath.getLastSegment());
if (srcRef == null) {
String workspaceName = workspaceName();
throw new ItemNotFoundException(JcrI18n.pathNotFound.text(srcChildRelPath, workspaceName));
}
NodeKey destKey = null;
if (destChildRelPath != null) {
Path destPath = session.pathFactory().create(destChildRelPath);
if (destPath.isAbsolute() || destPath.size() != 1) {
throw new ItemNotFoundException(JcrI18n.invalidPathParameter.text(destChildRelPath, "destChildRelPath"));
}
if (srcPath.isSameAs(destPath)) {
return;
}
ChildReference destRef = childRefs.getChild(destPath.getLastSegment());
if (destRef == null) {
String workspaceName = workspaceName();
throw new ItemNotFoundException(JcrI18n.pathNotFound.text(destChildRelPath, workspaceName));
}
destKey = destRef.getKey();