code: public Item getPrimaryItem() throws ItemNotFoundException, RepositoryException
     {
        checkValid();
  
        NodeTypeDataManager nodeTypeDataManager = session.getWorkspace().getNodeTypesHolder();
  
        // load nodeDatas
        List<NodeTypeData> nodeTypes = new ArrayList<NodeTypeData>();
        nodeTypes.add(nodeTypeDataManager.getNodeType(nodeData().getPrimaryTypeName()));
        InternalQName[] mixinNames = nodeData().getMixinTypeNames();
        for (int i = 0; i < mixinNames.length; i++)
        {
           nodeTypes.add(nodeTypeDataManager.getNodeType(mixinNames[i]));
        }
  
        // Searching default
        for (NodeTypeData ntData : nodeTypes)
        {
           if (ntData.getPrimaryItemName() != null)
           {
              Item primaryItem =
                 dataManager.getItem(nodeData(), new QPathEntry(ntData.getPrimaryItemName(), 0), true, ItemType.UNKNOWN);
              if (primaryItem != null)
              {
                 return primaryItem;
              }
  
           }
        }
  
        throw new ItemNotFoundException("Primary item not found for " + getPath());
     }
docs: {@inheritDoc}