code: public Node addNode(String relPath, String nodeTypeName) throws ItemExistsException, PathNotFoundException,
        NoSuchNodeTypeException, 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();
        InternalQName ptName = locationFactory.parseJCRName(nodeTypeName).getInternalName();
  
        // find node type
        NodeDefinitionData nodeDef =
           session.getWorkspace().getNodeTypesHolder()
              .getChildNodeDefinition(name, ptName, parent.nodeData().getPrimaryTypeName(), parent.nodeData().getMixinTypeNames());
  
        if (nodeDef == null)
        {
           throw new ConstraintViolationException("Can not define node type for " + name.getAsString());
        }
  
        // try to make new node
        return doAddNode(parent, name, ptName, nodeDef);
     }
docs: {@inheritDoc}