NodeDefinitionId(NodeDefinition def) { declaringNodeType = def.getDeclaringNodeType().getName(); name = def.getName(); }
NodeDefinitionId(NodeDefinition def) { declaringNodeType = def.getDeclaringNodeType().getName(); name = def.getName(); }
NodeDefinitionId(NodeDefinition def) { declaringNodeType = def.getDeclaringNodeType().getName(); name = def.getName(); }
/** * Matches if the declaring nodetype of the item is equal to the one * specified in this filter. If the item is a node and <code>propsOnly</code> * flag is <code>true</code> it returns <code>false</code>. * @see org.apache.jackrabbit.commons.predicate.DepthPredicate#matches(javax.jcr.Item) */ @Override protected boolean matches(Item item) throws RepositoryException { if (item.isNode()) { return !propsOnly && ((Node) item).getDefinition().getDeclaringNodeType().getName().equals(nodeType); } return ((Property) item).getDefinition().getDeclaringNodeType().getName().equals(nodeType); } }
/** * Matches if the declaring nodetype of the item is equal to the one * specified in this filter. If the item is a node and <code>propsOnly</code> * flag is <code>true</code> it returns <code>false</code>. * @see org.apache.jackrabbit.commons.predicate.DepthPredicate#matches(javax.jcr.Item) */ protected boolean matches(Item item) throws RepositoryException { if (item.isNode()) { return !propsOnly && ((Node) item).getDefinition().getDeclaringNodeType().getName().equals(nodeType); } return ((Property) item).getDefinition().getDeclaringNodeType().getName().equals(nodeType); } }
/** * {@inheritDoc} * * Matches if the declaring node type of the item is equal to the one * specified in this filter. If the item is a node and {@code propsOnly} * flag is {@code true} it returns {@code false}. */ public boolean matches(Item item) throws RepositoryException { if (item.isNode()) { return !propsOnly && ((Node) item).getDefinition().getDeclaringNodeType().getName().equals(nodeType); } else { return ((Property) item).getDefinition().getDeclaringNodeType().getName().equals(nodeType); } }
private void delete(Node folder, Node offspring) throws RepositoryException, WorkflowException { if (offspring.isNodeType(HippoNodeType.NT_DOCUMENT) && offspring.getParent().isNodeType(NT_HANDLE)) { offspring = offspring.getParent(); } if (!offspring.isNodeType(NT_HANDLE)) { for (NodeIterator iter = offspring.getNodes(); iter.hasNext(); ) { Node child = iter.nextNode(); NodeDefinition nd = child.getDefinition(); if (!nd.getDeclaringNodeType().isMixin()) { throw new WorkflowException("Folder is not empty; cannot be deleted"); } } } offspring.remove(); folder.getSession().save(); }
/** * Matches if the declaring nodetype of the item is equal to the one * specified in this filter. If the item is a node and <code>propsOnly</code> * flag is <code>true</code> it returns <code>false</code>. * @see org.apache.jackrabbit.commons.predicate.DepthPredicate#matches(javax.jcr.Item) */ @Override protected boolean matches(Item item) throws RepositoryException { if (item.isNode()) { return !propsOnly && ((Node) item).getDefinition().getDeclaringNodeType().getName().equals(nodeType); } return ((Property) item).getDefinition().getDeclaringNodeType().getName().equals(nodeType); } }
/** * Matches if the declaring nodetype of the item is equal to the one * specified in this filter. If the item is a node and <code>propsOnly</code> * flag is <code>true</code> it returns <code>false</code>. * @see org.apache.jackrabbit.commons.predicate.DepthPredicate#matches(javax.jcr.Item) */ @Override protected boolean matches(Item item) throws RepositoryException { if (item.isNode()) { return !propsOnly && ((Node) item).getDefinition().getDeclaringNodeType().getName().equals(nodeType); } return ((Property) item).getDefinition().getDeclaringNodeType().getName().equals(nodeType); } }
/** * 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)</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())); }
/** * 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)); } }
@Test public void testRootType() throws RepositoryException { assertEquals(testNodeTypeTestRoot, testRootNode.getDefinition() .getDeclaringNodeType().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)); }
/** * Creates a new node definition based on a JCR <code>NodeDefinition</code>. * * @param nodeDef the node definition. * @param resolver the name/path resolver of the session that provided the * node definition * @throws NameException if <code>nodeDef</code> contains an illegal * name. * @throws NamespaceException if <code>nodeDef</code> contains a name with * an namespace prefix that is unknown to * <code>resolver</code>. */ public QNodeDefinitionImpl(NodeDefinition nodeDef, NamePathResolver resolver) throws NameException, NamespaceException { this(nodeDef.getName().equals(NameConstants.ANY_NAME.getLocalName()) ? NameConstants.ANY_NAME : resolver.getQName(nodeDef.getName()), nodeDef.getDeclaringNodeType() != null ? resolver.getQName(nodeDef.getDeclaringNodeType().getName()) : null, nodeDef.isAutoCreated(), nodeDef.isMandatory(), nodeDef.getOnParentVersion(), nodeDef.isProtected(), nodeDef.getDefaultPrimaryType() != null ? resolver.getQName(nodeDef.getDefaultPrimaryType().getName()) : null, getNodeTypeNames(nodeDef.getRequiredPrimaryTypes(), resolver), nodeDef.allowsSameNameSiblings()); }
/** * Tests if {@link NodeType#canRemoveItem(String)} and * {@link NodeType#canRemoveNode(String)} return * false if the specified node is a protected child node. */ public void testProtectedChildNode() throws NotExecutableException, RepositoryException { NodeDefinition nodeDef = NodeTypeUtil.locateChildNodeDef(session, true, false); if (nodeDef == null) { throw new NotExecutableException("No mandatory property def found."); } NodeType type = nodeDef.getDeclaringNodeType(); assertFalse("NodeType.canRemoveItem(String itemName) must return false " + "if itemName is a protected child node def.", type.canRemoveItem(nodeDef.getName())); assertFalse("NodeType.canRemoveNode(String nodeName) must return false " + "if nodeName is a protected child node def.", type.canRemoveNode(nodeDef.getName())); }
/** * Tests if {@link NodeType#canRemoveItem(String)} and * {@link NodeType#canRemoveNode(String)} return * false if the specified node is a mandatory child node. */ public void testMandatoryChildNode() throws NotExecutableException, RepositoryException { NodeDefinition nodeDef = NodeTypeUtil.locateChildNodeDef(session, true, false); if (nodeDef == null) { throw new NotExecutableException("No mandatory property def found."); } NodeType type = nodeDef.getDeclaringNodeType(); assertFalse("NodeType.canRemoveItem(String itemName) must return false " + "if itemName is a mandatory child node def.", type.canRemoveItem(nodeDef.getName())); assertFalse("NodeType.canRemoveNode(String nodeName) must return false " + "if nodeName is a mandatory child node def.", type.canRemoveNode(nodeDef.getName())); } }
@Test public void shouldAllowAddingNewChildNodeAfterAddingMixin() throws Exception { session.getRootNode().addNode("a", PRIMARY_TYPE_A).addMixin("mix:referenceable"); session.save(); Node rootNode = session.getRootNode(); Node nodeA = rootNode.getNode("a"); assertThat(nodeA.canAddMixin(MIXIN_TYPE_B), is(true)); nodeA.addMixin(MIXIN_TYPE_B); nodeA.addNode(CHILD_NODE_B); session.save(); Node newRootNode = session.getRootNode(); Node newNodeA = newRootNode.getNode("a"); Node newNodeB = newNodeA.getNode(CHILD_NODE_B); assertThat(newNodeB, is(notNullValue())); assertThat(newNodeB.getDefinition().getDeclaringNodeType().getName(), is(MIXIN_TYPE_B)); }