/** {@inheritDoc} */ public boolean canAddChildNode(String name, String type) throws RemoteException { return this.type.canAddChildNode(name, type); }
/** {@inheritDoc} */ public boolean canAddChildNode(String name) throws RemoteException { return type.canAddChildNode(name); }
/** * Tests if <code>NodeType.canAddChildNode(String childNodeName)</code> returns * true if <code>NodeType</code> contains a <code>NodeDef</code> named * <code>childNodeName</code> without a default primary type. */ public void testDefinedWithoutDefault() throws NotExecutableException, RepositoryException { NodeDefinition nodeDef = NodeTypeUtil.locateChildNodeDef(session, true, false, false); if (nodeDef == null) { throw new NotExecutableException("No child node def without " + "defaultPrimaryType found"); } NodeType nodeType = nodeDef.getDeclaringNodeType(); assertFalse("NodeType.canAddChildNode(String childNodeName) must return false " + "if child node def 'childNodeName' does not define a defaultPrimaryType.", nodeType.canAddChildNode(nodeDef.getName())); }
if (parentNode.getPrimaryNodeType().canAddChildNode( JcrConstants.JCR_CONTENT, getContentNodeType())) { contentNode = parentNode.addNode(
/** * Tests if <code>NodeType.canAddChildNode(String childNodeName)</code> returns * true if <code>NodeType</code> contains a <code>NodeDef</code> named * <code>childNodeName</code> with a default primary type. */ public void testDefinedWithDefault() throws NotExecutableException, RepositoryException { NodeDefinition nodeDef = NodeTypeUtil.locateChildNodeDef(session, true, true, false); if (nodeDef == null) { throw new NotExecutableException("No child node def with " + "defaultPrimaryType found"); } NodeType nodeType = nodeDef.getDeclaringNodeType(); assertTrue("NodeType.canAddChildNode(String childNodeName) must return " + "true if child node def 'childNodeName' defines a defaultPrimaryType.", nodeType.canAddChildNode(nodeDef.getName())); }
/** * Tests if <code>NodeType.canAddChildNode(String childNodeName)</code> returns * true if <code>NodeType</code> nor does contain a <code>NodeDef</code> named * <code>childNodeName</code> nor a residual definition. */ public void testUndefined() throws NotExecutableException, RepositoryException { NodeDefinition nodeDef = NodeTypeUtil.locateChildNodeDef(session, false, true, false); if (nodeDef == null) { throw new NotExecutableException("No testable node type found."); } NodeType nodeType = nodeDef.getDeclaringNodeType(); String undefinedName = NodeTypeUtil.getUndefinedChildNodeName(nodeType); assertFalse("NodeType.canAddChildNode(String childNodeName) must return " + "false if 'childNodeName' is a undefined child node def", nodeType.canAddChildNode(undefinedName)); }
/** * Tests if <code>NodeType.canAddChildNode(String childNodeName, String nodeTypeName)</code> * returns true if <code>childNodeName</code> and <code>nodeTypeName</code> * match the <code>NodeDef</code>. */ public void testDefinedAndLegalType() throws NotExecutableException, RepositoryException { NodeDefinition nodeDef = NodeTypeUtil.locateChildNodeDef(session, false, false, false); if (nodeDef == null) { throw new NotExecutableException("No child node def with " + "defaultPrimaryType found"); } NodeType nodeType = nodeDef.getDeclaringNodeType(); String childNodeName = nodeDef.getName(); String nodeTypeName = nodeDef.getRequiredPrimaryTypes()[0].getName(); if (nodeTypeName.equals(ntBase)) { // nt:base is abstract and can never be added, upgrade for check below nodeTypeName = ntUnstructured; } assertTrue("NodeType.canAddChildNode(String childNodeName, String nodeTypeName) " + "must return true if childNodeName and nodeTypeName match the " + "child node def of NodeType.", nodeType.canAddChildNode(childNodeName, nodeTypeName)); }
/** * Tests if <code>NodeType.canAddChildNode(String childNodeName)</code> returns * true if <code>NodeType</code> contains a residual <code>NodeDef</code> * with a default primary type. */ public void testResidualWithDefault() throws NotExecutableException, RepositoryException { NodeDefinition nodeDef = NodeTypeUtil.locateChildNodeDef(session, true, true, true); if (nodeDef == null) { throw new NotExecutableException("No residual child node def " + "without a defaultPrimaryType found."); } NodeType nodeType = nodeDef.getDeclaringNodeType(); String undefinedName = NodeTypeUtil.getUndefinedChildNodeName(nodeType); assertTrue("NodeType.canAddChildNode(String childNodeName) must return " + "true for a not defined childNodeName if NodeType has a residual child node " + "definition with a defaultPrimaryType", nodeType.canAddChildNode(undefinedName)); }
/** * Tests if <code>NodeType.canAddChildNode(String childNodeName)</code> returns * true if <code>NodeType</code> contains a residual <code>NodeDef</code> * without a default primary type. */ public void testResidualWithoutDefault() throws NotExecutableException, RepositoryException { NodeDefinition nodeDef = NodeTypeUtil.locateChildNodeDef(session, true, false, true); if (nodeDef == null) { throw new NotExecutableException("No residual child node def " + "with a defaultPrimaryType found."); } NodeType nodeType = nodeDef.getDeclaringNodeType(); String undefinedName = NodeTypeUtil.getUndefinedChildNodeName(nodeType); assertFalse("NodeType.canAddChildNode(String childNodeName) must return " + "false for a not defiend childNodeName if NodeType has a " + "residual child node definition without a defaultPrimaryType", nodeType.canAddChildNode(undefinedName)); } }
continue; if (clone.getPrimaryNodeType().canAddChildNode(child.getName(), child.getPrimaryNodeType().getName())) { JcrUtils.copy(subject.getSession(), child.getPath(), clone.getPath() + "/" + child.getName()); } else if (clone.hasNode(child.getName())) {
/** * Tests if <code>NodeType.canAddChildNode(String childNodeName, String nodeTypeName)</code> * returns false if <code>childNodeName</code> does not match the <code>NodeDef</code>. */ public void testUndefined() throws NotExecutableException, RepositoryException { NodeDefinition nodeDef = NodeTypeUtil.locateChildNodeDef(session, false, true, false); if (nodeDef == null) { throw new NotExecutableException("No testable node type found."); } String type = nodeDef.getRequiredPrimaryTypes()[0].getName(); NodeType nodeType = nodeDef.getDeclaringNodeType(); String undefinedName = NodeTypeUtil.getUndefinedChildNodeName(nodeType); assertFalse("NodeType.canAddChildNode(String childNodeName, String nodeTypeName) " + "must return false if childNodeName does not match the " + "child node def of NodeType.", nodeType.canAddChildNode(undefinedName, type)); }
/** * Tests if <code>NodeType.canAddChildNode(String childNodeName, String nodeTypeName)</code> * returns true if <code>childNodeName</code> does not match the <code>NodeDef</code> * but <code>nodeTypeName</code> matches the node type of a residual <code>NodeDef</code>. */ public void testResidualAndLegalType() throws NotExecutableException, RepositoryException { String type = null; NodeType nodeType = null; for (NodeDefinition nodeDef : NodeTypeUtil.locateAllChildNodeDef( session, false, false, true)) { for (NodeType nt : nodeDef.getRequiredPrimaryTypes()) { if (!nt.isAbstract()) { nodeType = nodeDef.getDeclaringNodeType(); type = nt.getName(); } } } if (nodeType == null || type == null) { throw new NotExecutableException( "No testable residual child node def."); } String undefinedName = NodeTypeUtil.getUndefinedChildNodeName(nodeType); assertTrue("NodeType.canAddChildNode(String childNodeName, String nodeTypeName) " + "must return true for a not defined childNodeName if nodeTypeName " + "matches the type of a residual child node def", nodeType.canAddChildNode(undefinedName, type)); }
/** * Tests if <code>NodeType.canAddChildNode(String childNodeName, String nodeTypeName)</code> * returns false if <code>childNodeName</code> does and <code>nodeTypeName</code> * does not match the <code>NodeDef</code>. */ public void testDefinedAndIllegalType() 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 legalType = nodeDef.getRequiredPrimaryTypes()[0].getName(); String illegalType = NodeTypeUtil.getIllegalChildNodeType(manager, legalType); if (illegalType == null) { throw new NotExecutableException("No illegal node type name found"); } assertFalse("NodeType.canAddChildNode(String childNodeName, String nodeTypeName) " + "must return false if childNodeName does and nodeTypeName does not " + "match the child node def of NodeType.", nodeType.canAddChildNode(childNodeName, illegalType)); }
/** * Tests if <code>NodeType.canAddChildNode(String childNodeName, String nodeTypeName)</code> * returns false if <code>childNodeName</code> does not match the <code>NodeDef</code> * and <code>nodeTypeName</code> does not matches the node type of a residual * <code>NodeDef</code>. */ public void testResidualAndIllegalType() throws NotExecutableException, RepositoryException { NodeDefinition nodeDef = NodeTypeUtil.locateChildNodeDef(session, false, false, true); if (nodeDef == null) { throw new NotExecutableException("No testable residual child node def."); } NodeType nodeType = nodeDef.getDeclaringNodeType(); String undefinedName = NodeTypeUtil.getUndefinedChildNodeName(nodeType); String legalType = nodeDef.getRequiredPrimaryTypes()[0].getName(); String illegalType = NodeTypeUtil.getIllegalChildNodeType(manager, legalType); if (illegalType == null) { throw new NotExecutableException("No illegal node type name found"); } assertFalse("NodeType.canAddChildNode(String childNodeName, String nodeTypeName) " + "must return false for a not defined childNodeName if nodeTypeName " + "does not matches the type of a residual child node def", nodeType.canAddChildNode(undefinedName, illegalType)); } }
/** * 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)); }
/** * 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)); } /**