code: public Node addNode(String relPath) throws PathNotFoundException, ConstraintViolationException, RepositoryException,
        VersionException, LockException
     {
        checkValid();
        if (JCRPath.THIS_RELPATH.equals(relPath))
        {
           throw new RepositoryException("Can't add node to the path '" + relPath + "'");
        }
  
        // Parent can be not the same as this node
        JCRPath itemPath = locationFactory.parseRelPath(relPath);
  
        // Check if there no final index
        if (itemPath.isIndexSetExplicitly())
        {
           throw new RepositoryException("The relPath provided must not have an index on its final element. "
              + itemPath.getAsString(false));
        }
  
        NodeImpl parent = resolveParent(itemPath);
        InternalQName name = itemPath.getName().getInternalName();
  
        // find node type
        NodeDefinitionData nodeDef =
           session.getWorkspace().getNodeTypesHolder().getChildNodeDefinition(name, parent.nodeData().getPrimaryTypeName(),
              parent.nodeData().getMixinTypeNames());
  
        if (nodeDef == null)
        {
           throw new ConstraintViolationException("Can not define node type for " + name.getAsString());
        }
        InternalQName primaryTypeName = nodeDef.getName();
  
        if (nodeDef.getName().equals(name) || primaryTypeName.equals(Constants.JCR_ANY_NAME))
        {
           primaryTypeName = nodeDef.getDefaultPrimaryType();
  
           if (primaryTypeName == null)
           {
              throw new ConstraintViolationException("Can not define node type for " + name.getAsString()
                 + ". No default primary type defined for child nodes in \""
                 + nodeData().getPrimaryTypeName().getAsString()
                 + "\" node type and no explicit primary type given to create a child node.");
           }
        }
        // try to make new node
        return doAddNode(parent, name, primaryTypeName, nodeDef);
     }
docs: {@inheritDoc}