Package org.apache.jackrabbit.spi

Examples of org.apache.jackrabbit.spi.QNodeDefinition


                                              Name nodeName, Name ntName,
                                              NodeId nodeId) throws RepositoryException {
        if (parentNodeTypeNames == null) {
            return getRootNodeDefinition();
        }
        QNodeDefinition definition;
        try {
            EffectiveNodeType ent = entProvider.getEffectiveNodeType(parentNodeTypeNames);
            EffectiveNodeType entTarget = getEffectiveNodeType(ntName);
            definition = getQNodeDefinition(ent, entTarget, nodeName);
        } catch (RepositoryException e) {
View Full Code Here


        // try named node definitions first
        QNodeDefinition[] defs = ent.getNamedQNodeDefinitions(name);
        if (defs != null) {
            for (int i = 0; i < defs.length; i++) {
                QNodeDefinition nd = defs[i];
                // node definition with that name exists
                if (entTarget != null && nd.getRequiredPrimaryTypes() != null) {
                    // check 'required primary types' constraint
                    if (entTarget.includesNodeTypes(nd.getRequiredPrimaryTypes())) {
                        // found named node definition
                        return nd;
                    }
                } else {
                    if (nd.getDefaultPrimaryType() != null) {
                        // found node definition with default node type
                        return nd;
                    }
                }
            }
        }

        // no item with that name defined;
        // try residual node definitions
        QNodeDefinition[] nda = ent.getUnnamedQNodeDefinitions();
        for (int i = 0; i < nda.length; i++) {
            QNodeDefinition nd = nda[i];
            if (entTarget != null && nd.getRequiredPrimaryTypes() != null) {
                // check 'required primary types' constraint
                if (entTarget.includesNodeTypes(nd.getRequiredPrimaryTypes())) {
                    // found residual node definition
                    return nd;
                }
            } else {
                // since no node type has been specified for the new node,
                // it must be determined from the default node type;
                if (nd.getDefaultPrimaryType() != null) {
                    // found residual node definition with default node type
                    return nd;
                }
            }
        }
View Full Code Here

     */
    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

        } 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

                                              Name nodeName, Name ntName,
                                              NodeId nodeId) throws RepositoryException {
        if (parentNodeTypeNames == null) {
            return getRootNodeDefinition();
        }
        QNodeDefinition definition;
        try {
            EffectiveNodeType ent = entProvider.getEffectiveNodeType(parentNodeTypeNames);
            EffectiveNodeType entTarget = getEffectiveNodeType(ntName);
            definition = getQNodeDefinition(ent, entTarget, nodeName);
        } catch (RepositoryException e) {
View Full Code Here

        // try named node definitions first
        QNodeDefinition[] defs = ent.getNamedQNodeDefinitions(name);
        if (defs != null) {
            for (int i = 0; i < defs.length; i++) {
                QNodeDefinition nd = defs[i];
                // node definition with that name exists
                if (entTarget != null && nd.getRequiredPrimaryTypes() != null) {
                    // check 'required primary types' constraint
                    if (entTarget.includesNodeTypes(nd.getRequiredPrimaryTypes())) {
                        // found named node definition
                        return nd;
                    }
                } else {
                    if (nd.getDefaultPrimaryType() != null) {
                        // found node definition with default node type
                        return nd;
                    }
                }
            }
        }

        // no item with that name defined;
        // try residual node definitions
        QNodeDefinition[] nda = ent.getUnnamedQNodeDefinitions();
        for (int i = 0; i < nda.length; i++) {
            QNodeDefinition nd = nda[i];
            if (entTarget != null && nd.getRequiredPrimaryTypes() != null) {
                // check 'required primary types' constraint
                if (entTarget.includesNodeTypes(nd.getRequiredPrimaryTypes())) {
                    // found residual node definition
                    return nd;
                }
            } else {
                // since no node type has been specified for the new node,
                // it must be determined from the default node type;
                if (nd.getDefaultPrimaryType() != null) {
                    // found residual node definition with default node type
                    return nd;
                }
            }
        }
View Full Code Here

                                                NodeState parent = getNodeState(ns.getParentId());
                                                Name name = parent.getChildNodeEntry(id).getName();
                                                EffectiveNodeType ent = ntReg.getEffectiveNodeType(
                                                        parent.getNodeTypeName(),
                                                        parent.getMixinTypeNames());
                                                QNodeDefinition def = ent.getApplicableChildNodeDef(name, ns.getNodeTypeName(), ntReg);
                                                return def != null ? def.allowsSameNameSiblings() : false;
                                            } catch (Exception e) {
                                                log.warn("Unable to get node definition", e);
                                                return false;
                                            }
                                        }
View Full Code Here

            }
            // 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

            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

                                                NodeState parent = getNodeState(ns.getParentId());
                                                Name name = parent.getChildNodeEntry(id).getName();
                                                EffectiveNodeType ent = ntReg.getEffectiveNodeType(
                                                        parent.getNodeTypeName(),
                                                        parent.getMixinTypeNames());
                                                QNodeDefinition def = ent.getApplicableChildNodeDef(name, ns.getNodeTypeName(), ntReg);
                                                return def != null ? def.allowsSameNameSiblings() : false;
                                            } catch (Exception e) {
                                                log.warn("Unable to get node definition", e);
                                                return false;
                                            }
                                        }
View Full Code Here

TOP

Related Classes of org.apache.jackrabbit.spi.QNodeDefinition

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.