Examples of QNodeDefinition


Examples of org.apache.jackrabbit.spi.QNodeDefinition

            }
            // make sure there's an applicable definition for new child node
            EffectiveNodeType entParent = getEffectiveNodeType(parentState);
            entParent.checkAddNodeConstraints(
                    nodeName, nodeTypeName, context.getNodeTypeRegistry());
            QNodeDefinition 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);
                }
                QNodeDefinition conflictingTargetDef =
                    context.getItemManager().getDefinition(conflictingState).unwrap();
                // 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

Examples of org.apache.jackrabbit.spi.QNodeDefinition

            throw new IllegalStateException(
                    "cannot create node state for " + nodeName
                    + " because manager is not in edit mode");
        }

        QNodeDefinition def = findApplicableNodeDefinition(nodeName, nodeTypeName, parent);
        return createNodeState(parent, nodeName, nodeTypeName, mixinNames, id, def);
    }
View Full Code Here

Examples of org.apache.jackrabbit.spi.QNodeDefinition

     */
    protected NodeDefinitionImpl getApplicableChildNodeDefinition(Name nodeName,
                                                                  Name nodeTypeName)
            throws ConstraintViolationException, RepositoryException {
        NodeTypeManagerImpl ntMgr = sessionContext.getNodeTypeManager();
        QNodeDefinition cnd = getEffectiveNodeType().getApplicableChildNodeDef(
                nodeName, nodeTypeName, sessionContext.getNodeTypeRegistry());
        return ntMgr.getNodeDefinition(cnd);
    }
View Full Code Here

Examples of org.apache.jackrabbit.spi.QNodeDefinition

        } catch (NodeTypeConflictException ntce) {
            throw new ConstraintViolationException(ntce.getMessage());
        }

        // get applicable definition for this node using new primary type
        QNodeDefinition nodeDef;
        try {
            NodeImpl parent = (NodeImpl) getParent();
            nodeDef = parent.getApplicableChildNodeDefinition(getQName(), ntName).unwrap();
        } catch (RepositoryException re) {
            String msg = this + ": no applicable definition found in parent node's node type";
            log.debug(msg);
            throw new ConstraintViolationException(msg, re);
        }

        if (!nodeDef.equals(itemMgr.getDefinition(state).unwrap())) {
            onRedefine(nodeDef);
        }

        Set<QItemDefinition> oldDefs = new HashSet<QItemDefinition>(Arrays.asList(entOld.getAllItemDefs()));
        Set<QItemDefinition> newDefs = new HashSet<QItemDefinition>(Arrays.asList(entNew.getAllItemDefs()));
View Full Code Here

Examples of org.apache.jackrabbit.spi.QNodeDefinition

        int options = ItemStateValidator.CHECK_LOCK | ItemStateValidator.CHECK_COLLISION
            | ItemStateValidator.CHECK_VERSIONING | ItemStateValidator.CHECK_CONSTRAINTS;

        NodeState parent = operation.getParentState();
        ItemDefinitionProvider defProvider = mgrProvider.getItemDefinitionProvider();
        QNodeDefinition def = defProvider.getQNodeDefinition(parent.getAllNodeTypeNames(), operation.getNodeName(), operation.getNodeTypeName());
        List<ItemState> newStates = addNodeState(parent, operation.getNodeName(), operation.getNodeTypeName(), operation.getUuid(), def, options);
        operation.addedState(newStates);

        transientStateMgr.addOperation(operation);
    }
View Full Code Here

Examples of org.apache.jackrabbit.spi.QNodeDefinition

            | ItemStateValidator.CHECK_VERSIONING
            | ItemStateValidator.CHECK_CONSTRAINTS);

        // retrieve applicable definition at the new place
        ItemDefinitionProvider defProvider = mgrProvider.getItemDefinitionProvider();
        QNodeDefinition newDefinition = defProvider.getQNodeDefinition(destParent.getAllNodeTypeNames(), operation.getDestinationName(), srcState.getNodeTypeName());

        // perform the move (modifying states)
        srcParent.moveChildNodeEntry(destParent, srcState, operation.getDestinationName(), newDefinition);

        // remember operation
View Full Code Here

Examples of org.apache.jackrabbit.spi.QNodeDefinition

    /**
     * @see Node#getDefinition()
     */
    public NodeDefinition getDefinition() throws RepositoryException {
        checkStatus();
        QNodeDefinition qnd = getNodeState().getDefinition();
        return session.getNodeTypeManager().getNodeDefinition(qnd);
    }
View Full Code Here

Examples of org.apache.jackrabbit.spi.QNodeDefinition

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

                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
                    QNodeDefinition 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
                        QNodeDefinition 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

Examples of org.apache.jackrabbit.spi.QNodeDefinition

            throw new ConstraintViolationException("not allowed to add node " + name + ": " + nodeTypeDefinition.getName() + " is abstract and cannot be used as primary node type.");
        }
        if (nodeTypeDefinition.isMixin()) {
            throw new ConstraintViolationException("not allowed to add node " + name + ":" + nodeTypeDefinition.getName() + " is a mixin and cannot be used as primary node type.");
        }
        QNodeDefinition nd = definitionProvider.getQNodeDefinition(this, name, nodeTypeDefinition.getName());
        if (nd.isProtected()) {
            throw new ConstraintViolationException(name + " is protected.");
        }
        if (nd.isAutoCreated()) {
            throw new ConstraintViolationException(name + " is auto-created and can not be manually added");
        }
    }
View Full Code Here

Examples of org.apache.jackrabbit.spi.QNodeDefinition

                            log.debug(msg);
                            throw new ConstraintViolationException(msg);
                        }
                    } else {
                        // child node definition
                        QNodeDefinition nd = (QNodeDefinition) qDef;
                        QNodeDefinition end = (QNodeDefinition) existing;
                        // compare required & default primary types
                        if (Arrays.equals(nd.getRequiredPrimaryTypes(), end.getRequiredPrimaryTypes())
                                && (nd.getDefaultPrimaryType() == null
                                ? end.getDefaultPrimaryType() == null
                                : nd.getDefaultPrimaryType().equals(end.getDefaultPrimaryType()))) {
                            // conflict
                            String msg = "A child node definition in node type '"
                                    + qDef.getDeclaringNodeType()
                                    + "' conflicts with node type '"
                                    + existing.getDeclaringNodeType()
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. 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.