Package org.apache.jackrabbit.core.nodetype

Examples of org.apache.jackrabbit.core.nodetype.NodeDef


                4, def.getChildNodeDefs().length);
    }

    /** Test for the empty child node definition. */
    public void testEmptyNode() {
        NodeDef def = getChildNode("childNodeType", "emptyNode");
        assertEquals("emptyNode allowsSameNameSiblings",
                false, def.allowsSameNameSiblings());
        assertEquals("emptyNode defaultPrimaryType",
                null, def.getDefaultPrimaryType());
    }
View Full Code Here


                null, def.getDefaultPrimaryType());
    }

    /** Test for the <code>allowsSameNameSiblings</code> child node attribute. */
    public void testSiblingNode() {
        NodeDef def = getChildNode("childNodeType", "siblingNode");
        assertEquals("siblingNode allowsSameNameSiblings",
                true, def.allowsSameNameSiblings());
    }
View Full Code Here

                true, def.allowsSameNameSiblings());
    }

    /** Test for the <code>defaultPrimaryType</code> child node attribute. */
    public void testDefaultTypeNode() {
        NodeDef def = getChildNode("childNodeType", "defaultTypeNode");
        assertEquals("defaultTypeNode defaultPrimaryType",
                FACTORY.create(Name.NS_NT_URI, "base"),
                def.getDefaultPrimaryType());
    }
View Full Code Here

                def.getDefaultPrimaryType());
    }

    /** Test for the <code>requiredPrimaryTypes</code> child node attributes. */
    public void testRequiredTypeNode() {
        NodeDef def = getChildNode("childNodeType", "requiredTypeNode");
        assertEquals("requiredTypeNode requiredPrimaryTypes",
                2, def.getRequiredPrimaryTypes().length);
        Name[] types = def.getRequiredPrimaryTypes();
        Arrays.sort(types);
        assertEquals("requiredTypeNode requiredPrimaryTypes[0]",
                FACTORY.create(Name.NS_NT_URI, "base"), types[0]);
        assertEquals("requiredTypeNode requiredPrimaryTypes[1]",
                FACTORY.create(Name.NS_NT_URI, "unstructured"), types[1]);
View Full Code Here

                                                    ns = (NodeState) getItemState(id);
                                                }
                                            } catch (ItemStateException e) {
                                                return false;
                                            }
                                            NodeDef def = ntReg.getNodeDef(ns.getDefinitionId());
                                            return def != null ? def.allowsSameNameSiblings() : false;
                                        }
                                    };

                            merged = NodeStateMerger.merge((NodeState) state, context);
                        }
View Full Code Here

                    // If the complex type definition contains a complex content model
                    // or a simple content model with attribute uses or an attribute wildcard
                    // then the enclosing element is converted into a node def
                } else {
                    NodeDef nd = complexTypeToNodeDef(ctDef, name, mandatory, multiple);
                    nodeDefList.add(nd);
                }
            }

            // If this particle is a wildcard (an <xs:any> )then it
View Full Code Here

                                    try {
                                        ns = (NodeState) getItemState(id);
                                    } catch (ItemStateException e) {
                                        return false;
                                    }
                                    NodeDef def = ntReg.getNodeDef(ns.getDefinitionId());
                                    return def != null ? def.allowsSameNameSiblings() : false;
                                }
                            };
                    if (NodeStateMerger.merge((NodeState) transientState, context)) {
                        // merge succeeded
                        return;
View Full Code Here

        // add to new parent
        destParentState.addChildNodeEntry(destName.getName(), newState.getNodeId());

        // change definition (id) of new node
        NodeDef newNodeDef =
                findApplicableNodeDefinition(destName.getName(),
                        srcState.getNodeTypeName(), destParentState);
        newState.setDefinitionId(newNodeDef.getId());

        // adjust references that refer to uuid's which have been mapped to
        // newly generated uuid's on copy/clone
        Iterator<Object> iter = refTracker.getProcessedReferences();
        while (iter.hasNext()) {
View Full Code Here

            // add child node entry to new parent
            destParent.addChildNodeEntry(destName.getName(), target.getNodeId());
        }

        // change definition (id) of target node
        NodeDef newTargetDef =
                findApplicableNodeDefinition(destName.getName(),
                        target.getNodeTypeName(), destParent);
        target.setDefinitionId(newTargetDef.getId());

        // store states
        stateMgr.store(target);
        if (renameOnly) {
            stateMgr.store(srcParent);
View Full Code Here

        }

        // 4. node type constraints

        if ((options & CHECK_CONSTRAINTS) == CHECK_CONSTRAINTS) {
            NodeDef parentDef = ntReg.getNodeDef(parentState.getDefinitionId());
            // make sure parent node is not protected
            if (parentDef.isProtected()) {
                throw new ConstraintViolationException(
                        safeGetJCRPath(parentState.getNodeId())
                        + ": cannot add child node to protected parent node");
            }
            // make sure there's an applicable definition for new child node
            EffectiveNodeType entParent = getEffectiveNodeType(parentState);
            entParent.checkAddNodeConstraints(nodeName, nodeTypeName, ntReg);
            NodeDef newNodeDef =
                    findApplicableNodeDefinition(nodeName, nodeTypeName,
                            parentState);

            // check for name collisions
            if (parentState.hasChildNodeEntry(nodeName)) {
                // there's already a node with that name...

                // get definition of existing conflicting node
                ChildNodeEntry entry = parentState.getChildNodeEntry(nodeName, 1);
                NodeState conflictingState;
                NodeId conflictingId = entry.getId();
                try {
                    conflictingState = (NodeState) stateMgr.getItemState(conflictingId);
                } catch (ItemStateException ise) {
                    String msg =
                        "internal error: failed to retrieve state of "
                        + safeGetJCRPath(conflictingId);
                    log.debug(msg);
                    throw new RepositoryException(msg, ise);
                }
                NodeDef conflictingTargetDef =
                        ntReg.getNodeDef(conflictingState.getDefinitionId());
                // check same-name sibling setting of both target and existing node
                if (!conflictingTargetDef.allowsSameNameSiblings()
                        || !newNodeDef.allowsSameNameSiblings()) {
                    throw new ItemExistsException(
                            "cannot add child node '" + nodeName.getLocalName()
                            + "' to " + safeGetJCRPath(parentState.getNodeId())
                            + ": colliding with same-named existing node");
View Full Code Here

TOP

Related Classes of org.apache.jackrabbit.core.nodetype.NodeDef

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.