Package org.apache.jackrabbit.core.nodetype

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


        if (id == null) {
            id = new NodeId(UUID.randomUUID());
        }
        NodeState state = stateMgr.createNew(id, nodeTypeName, parentId);

        NodeDef cnd =
                getEffectiveNodeType().getApplicableChildNodeDef(name, nodeTypeName, ntReg);
        state.setDefinitionId(cnd.getId());

        // create Node instance wrapping new node state
        NodeStateEx node = new NodeStateEx(stateMgr, ntReg, state, name);
        node.setPropertyValue(NameConstants.JCR_PRIMARYTYPE, InternalValue.create(nodeTypeName));
View Full Code Here


                // a node with that name already exists...
                ChildNodeEntry entry =
                        parent.getChildNodeEntry(nodeName, 1);
                NodeId idExisting = entry.getId();
                NodeState existing = (NodeState) itemOps.getItemState(idExisting);
                NodeDef def = ntReg.getNodeDef(existing.getDefinitionId());

                if (!def.allowsSameNameSiblings()) {
                    // existing doesn't allow same-name siblings,
                    // check for potential conflicts
                    EffectiveNodeType entExisting =
                            itemOps.getEffectiveNodeType(existing);
                    if (def.isProtected() && entExisting.includesNodeType(ntName)) {
                        // skip protected node
                        parents.push(null); // push null onto stack for skipped node
                        succeeded = true;
                        log.debug("skipping protected node "
                                + itemOps.safeGetJCRPath(existing.getNodeId()));
                        return;
                    }
                    if (def.isAutoCreated() && entExisting.includesNodeType(ntName)) {
                        // this node has already been auto-created,
                        // no need to create it
                        node = existing;
                    } else {
                        // edge case: colliding node does have same uuid
                        // (see http://issues.apache.org/jira/browse/JCR-1128)
                        if (!(idExisting.equals(id)
                                && (uuidBehavior == ImportUUIDBehavior.IMPORT_UUID_COLLISION_REMOVE_EXISTING
                                || uuidBehavior == ImportUUIDBehavior.IMPORT_UUID_COLLISION_REPLACE_EXISTING))) {
                            throw new ItemExistsException(itemOps.safeGetJCRPath(existing.getNodeId()));
                        }
                        // fall through
                    }
                }
            }

            if (node == null) {
                // there's no node with that name...
                if (id == null) {
                    // no potential uuid conflict, always create new node
                    NodeDef def = itemOps.findApplicableNodeDefinition(
                            nodeName, ntName, parent);
                    if (def.isProtected()) {
                        // skip protected node
                        parents.push(null); // push null onto stack for skipped node
                        succeeded = true;
                        log.debug("skipping protected node " + nodeName);
                        return;
                    }

                    // check if new node can be added (check access rights &
                    // node type constraints only, assume locking & versioning status
                    // and retention/hold has already been checked on ancestor)
                    itemOps.checkAddNode(parent, nodeName, ntName,
                            BatchedItemOperations.CHECK_ACCESS
                            | BatchedItemOperations.CHECK_CONSTRAINTS);
                    // do create new node
                    node = itemOps.createNodeState(parent, nodeName, ntName, mixins, null, def);
                } else {
                    // potential uuid conflict
                    try {
                        NodeState conflicting = itemOps.getNodeState(id);
                        // resolve uuid conflict
                        node = resolveUUIDConflict(parent, conflicting, nodeInfo);
                        if (node == null) {
                            // no new node has been created, so skip this node
                            parents.push(null); // push null onto stack for skipped node
                            succeeded = true;
                            log.debug("skipping existing node: " + nodeName);
                            return;
                        }
                    } catch (ItemNotFoundException e) {
                        // create new with given uuid
                        NodeDef def = itemOps.findApplicableNodeDefinition(
                                nodeName, ntName, parent);
                        if (def.isProtected()) {
                            // skip protected node
                            parents.push(null); // push null onto stack for skipped node
                            succeeded = true;
                            log.debug("skipping protected node " + nodeName);
                            return;
View Full Code Here

                    }
                }
                // mandatory child nodes
                NodeDef[] cnda = ent.getMandatoryNodeDefs();
                for (int i = 0; i < cnda.length; i++) {
                    NodeDef cnd = cnda[i];
                    if (!nodeState.hasChildNodeEntry(cnd.getName())) {
                        String msg = itemMgr.safeGetJCRPath(id)
                                + ": mandatory child node " + cnd.getName()
                                + " does not exist";
                        log.debug(msg);
                        throw new ConstraintViolationException(msg);
                    }
                }
View Full Code Here

                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

                                    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

     * write node defs
     */
    private void writeNodeDefs(NodeTypeDef ntd) throws IOException {
        NodeDef[] nda = ntd.getChildNodeDefs();
        for (int i = 0; i < nda.length; i++) {
            NodeDef nd = nda[i];
            writeNodeDef(ntd, nd);
        }
    }
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

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.