Package org.apache.jackrabbit.core.state

Examples of org.apache.jackrabbit.core.state.ChildNodeEntry


                                            NodeState parent = (NodeState) stateMgr.getTransientItemState(newParentId);
                                            // check parent's renamed child node entries
                                            for (Iterator<ChildNodeEntry> cneIt =
                                                    parent.getRenamedChildNodeEntries().iterator();
                                                 cneIt.hasNext();) {
                                                ChildNodeEntry cne =
                                                        cneIt.next();
                                                if (cne.getId().equals(nodeState.getId())) {
                                                    // node has been renamed,
                                                    // add parent to dependencies
                                                    dependentIDs.add(newParentId);
                                                }
                                            }
                                        } catch (ItemStateException ise) {
                                            // should never get here
                                            log.warn("failed to retrieve transient state: " + newParentId, ise);
                                        }
                                    }
                                }
                            }
                        }
                    }

                    // removed child node entries
                    for (Iterator<ChildNodeEntry> cneIt =
                            nodeState.getRemovedChildNodeEntries().iterator();
                         cneIt.hasNext();) {
                        ChildNodeEntry cne = cneIt.next();
                        dependentIDs.add(cne.getId());
                    }
                    // added child node entries
                    for (Iterator<ChildNodeEntry> cneIt =
                            nodeState.getAddedChildNodeEntries().iterator();
                         cneIt.hasNext();) {
                        ChildNodeEntry cne = cneIt.next();
                        dependentIDs.add(cne.getId());
                    }

                    // now walk through dependencies and check whether they
                    // are within the scope of this save operation
                    Iterator<NodeId> depIt = dependentIDs.iterator();
View Full Code Here


                throw new RepositoryException(ex);
            }
        }

        // get child node entry
        ChildNodeEntry cne = parentState.getChildNodeEntry(state.getNodeId());
        if (cne == null) {
            throw new InvalidItemStateException(
                    "Could not find child " + state.getNodeId()
                    + " of node " + parentState.getNodeId());
        }

        NodeTypeRegistry ntReg = sessionContext.getNodeTypeRegistry();
        try {
            EffectiveNodeType ent = ntReg.getEffectiveNodeType(
                    parentState.getNodeTypeName(), parentState.getMixinTypeNames());
            QNodeDefinition def;
            try {
                def = ent.getApplicableChildNodeDef(
                    cne.getName(), state.getNodeTypeName(), ntReg);
            } catch (ConstraintViolationException e) {
                // fallback to child node definition of a nt:unstructured
                ent = ntReg.getEffectiveNodeType(NameConstants.NT_UNSTRUCTURED);
                def = ent.getApplicableChildNodeDef(
                        cne.getName(), state.getNodeTypeName(), ntReg);
                log.warn("Fallback to nt:unstructured due to unknown child " +
                        "node definition for type '" + state.getNodeTypeName() + "'");
            }
            return sessionContext.getNodeTypeManager().getNodeDefinition(def);
        } catch (NodeTypeConflictException e) {
View Full Code Here

        }
        ArrayList<ItemId> childIds = new ArrayList<ItemId>();
        Iterator<ChildNodeEntry> iter = ((NodeState) data.getState()).getChildNodeEntries().iterator();

        while (iter.hasNext()) {
            ChildNodeEntry entry = iter.next();
            // delay check for read-access until item is being built
            // thus avoid duplicate check
            childIds.add(entry.getId());
        }

        return new LazyItemIterator(sessionContext, childIds, parentId);
    }
View Full Code Here

            // 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 "
View Full Code Here

            // remove child nodes
            // use temp array to avoid ConcurrentModificationException
            ArrayList<ChildNodeEntry> tmp = new ArrayList<ChildNodeEntry>(targetState.getChildNodeEntries());
            // remove from tail to avoid problems with same-name siblings
            for (int i = tmp.size() - 1; i >= 0; i--) {
                ChildNodeEntry entry = tmp.get(i);
                NodeId nodeId = entry.getId();
                try {
                    NodeState nodeState = (NodeState) stateMgr.getItemState(nodeId);
                    // check if child node can be removed
                    // (access rights, locking & versioning status as well
                    //  as retention and hold);
                    // referential integrity (references) is checked
                    // on commit
                    checkRemoveNode(nodeState, targetState.getNodeId(),
                            CHECK_ACCESS
                            | CHECK_LOCK
                            | CHECK_CHECKED_OUT
                            | CHECK_HOLD
                            | CHECK_RETENTION
                    );
                    // remove child node
                    recursiveRemoveNodeState(nodeState);
                } catch (ItemStateException ise) {
                    String msg = "internal error: failed to retrieve state of "
                            + nodeId;
                    log.debug(msg);
                    throw new RepositoryException(msg, ise);
                }
                // remove child node entry
                targetState.removeChildNodeEntry(entry.getName(), entry.getIndex());
            }
        }

        // remove properties
        // use temp set to avoid ConcurrentModificationException
View Full Code Here

    /**
     * {@inheritDoc}
     */
    public NodeId getFrozenNodeId() {
        ChildNodeEntry entry = node.getState().getChildNodeEntry(NameConstants.JCR_FROZENNODE, 1);
        if (entry == null) {
            throw new InternalError("version has no frozen node: " + getId());
        }
        return entry.getId();
    }
View Full Code Here

        // check if corresponding ancestor exists
        if (srcRoot.hasNode(m1.getNodeId())) {
            NodeStateEx m2 = srcRoot.getNode(m1.getNodeId());
            Iterator<ChildNodeEntry> iter = elements.iterator();
            while (iter.hasNext() && m2 != null) {
                ChildNodeEntry e = iter.next();
                m2 = m2.getNode(e.getName(), e.getIndex());
            }
            return m2;
        } else {
            return null;
        }
View Full Code Here

                throw new RepositoryException(ex);
            }
        }

        // get child node entry
        ChildNodeEntry cne = parentState.getChildNodeEntry(state.getNodeId());
        NodeTypeRegistry ntReg = sessionContext.getNodeTypeRegistry();
        try {
            EffectiveNodeType ent = ntReg.getEffectiveNodeType(
                    parentState.getNodeTypeName(), parentState.getMixinTypeNames());
            QNodeDefinition def;
            try {
                def = ent.getApplicableChildNodeDef(
                    cne.getName(), state.getNodeTypeName(), ntReg);
            } catch (ConstraintViolationException e) {
                // fallback to child node definition of a nt:unstructured
                ent = ntReg.getEffectiveNodeType(NameConstants.NT_UNSTRUCTURED);
                def = ent.getApplicableChildNodeDef(
                        cne.getName(), state.getNodeTypeName(), ntReg);
                log.warn("Fallback to nt:unstructured due to unknown child " +
                        "node definition for type '" + state.getNodeTypeName() + "'");
            }
            return sessionContext.getNodeTypeManager().getNodeDefinition(def);
        } catch (NodeTypeConflictException e) {
View Full Code Here

        }
        ArrayList<ItemId> childIds = new ArrayList<ItemId>();
        Iterator<ChildNodeEntry> iter = ((NodeState) data.getState()).getChildNodeEntries().iterator();

        while (iter.hasNext()) {
            ChildNodeEntry entry = iter.next();
            // delay check for read-access until item is being built
            // thus avoid duplicate check
            childIds.add(entry.getId());
        }

        return new LazyItemIterator(sessionContext, childIds, parentId);
    }
View Full Code Here

        org.apache.jackrabbit.spi.commons.nodetype.NodeDefinitionImpl def = parentImpl.getApplicableChildNodeDefinition(name, ntName);

        // check for name collisions
        // TODO: improve. copied from NodeImpl
        NodeState thisState = parentImpl.getNodeState();
        ChildNodeEntry cne = thisState.getChildNodeEntry(name, 1);
        if (cne != null) {
            // there's already a child node entry with that name;
            // check same-name sibling setting of new node
            if (!def.allowsSameNameSiblings()) {
                throw new ItemExistsException();
            }
            // check same-name sibling setting of existing node
            NodeId newId = cne.getId();
            NodeImpl n = (NodeImpl) parentImpl.sessionContext.getItemManager().getItem(newId);
            if (!n.getDefinition().allowsSameNameSiblings()) {
                throw new ItemExistsException();
            }
        }
View Full Code Here

TOP

Related Classes of org.apache.jackrabbit.core.state.ChildNodeEntry

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.