/**
   * Tests if <code>NodeType.canAddChildNode(String childNodeName, String nodeTypeName)</code>
   * returns false if <code>nodeTypeName</code> represents an abstract node type.
   */
  public void testCanAddAbstractType() throws NotExecutableException, RepositoryException {

    NodeDefinition nodeDef = NodeTypeUtil.locateChildNodeDef(session, false, false, false);

    if (nodeDef == null) {
      throw new NotExecutableException("No testable node type found.");
    }

    NodeType nodeType = nodeDef.getDeclaringNodeType();
    String childNodeName = nodeDef.getName();
    String abstractName = null;
    NodeTypeIterator it = manager.getPrimaryNodeTypes();
    while (it.hasNext() && abstractName == null) {
      NodeType nt = it.nextNodeType();
      if (nt.isAbstract()) {
        abstractName = nt.getName();
      }
    }
    if (abstractName == null) {
      throw new NotExecutableException("No abstract type found.");
    }

    assertFalse(
        "NodeType.canAddChildNode(String childNodeName, String nodeTypeName) "
            + "must return false if nodeTypeName represents an abstract node type.",
        nodeType.canAddChildNode(childNodeName, abstractName));
  }
예제 #2
0
 @Override
 public String[] getPrimaryTypes(boolean allowAbstract) throws RemoteException {
   ArrayList<String> list = new ArrayList();
   try {
     NodeTypeManager mgr = session().getWorkspace().getNodeTypeManager();
     NodeTypeIterator it = mgr.getPrimaryNodeTypes();
     while (it.hasNext()) {
       NodeType nodeType = it.nextNodeType();
       if (!nodeType.isAbstract() || allowAbstract) {
         list.add(nodeType.getName());
       }
     }
     String[] res = new String[list.size()];
     list.toArray(res);
     return res;
   } catch (RepositoryException e) {
     throw new RemoteException(e.getMessage());
   }
 }