Пример #1
0
 @Override
 public String[] getMixinTypes(boolean allowAbstract) throws RemoteException {
   ArrayList<String> list = new ArrayList();
   try {
     NodeTypeManager mgr = session().getWorkspace().getNodeTypeManager();
     NodeTypeIterator it = mgr.getMixinNodeTypes();
     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());
   }
 }
  /**
   * Tests if <code>NodeType.canAddChildNode(String childNodeName, String nodeTypeName)</code>
   * returns false if <code>nodeTypeName</code> represents a mixin.
   */
  public void testCanAddMixinType() 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 mixinName;
    NodeTypeIterator it = manager.getMixinNodeTypes();
    if (it.hasNext()) {
      mixinName = it.nextNodeType().getName();
    } else {
      throw new NotExecutableException("No mixin type found.");
    }

    assertFalse(
        "NodeType.canAddChildNode(String childNodeName, String nodeTypeName) "
            + "must return false if nodeTypeName represents a mixin type.",
        nodeType.canAddChildNode(childNodeName, mixinName));
  }