Package org.apache.jackrabbit.core.state

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


     * @param index
     * @return the node state.
     * @throws RepositoryException
     */
    public NodeStateEx getNode(Name name, int index) throws RepositoryException {
        ChildNodeEntry entry = nodeState.getChildNodeEntry(name, index);
        if (entry == null) {
            return null;
        }
        try {
            NodeState state = (NodeState) stateMgr.getItemState(entry.getId());
            return new NodeStateEx(stateMgr, ntReg, state, name);
        } catch (ItemStateException e) {
            throw new RepositoryException("Unable to getNode: " + e.toString());
        }
    }
View Full Code Here


    public NodeStateEx[] getChildNodes() throws RepositoryException {
        try {
            List entries = nodeState.getChildNodeEntries();
            NodeStateEx[] children = new NodeStateEx[entries.size()];
            for (int i = 0; i < entries.size(); i++) {
                ChildNodeEntry entry = (ChildNodeEntry) entries.get(i);
                NodeState state = (NodeState) stateMgr.getItemState(entry.getId());
                children[i] = new NodeStateEx(stateMgr, ntReg, state, entry.getName());
            }
            return children;
        } catch (ItemStateException e) {
            throw new RepositoryException(e);
        }
View Full Code Here

                }
            }
            // now store all child node entries
            List nodes = state.getChildNodeEntries();
            for (int i = 0; i < nodes.size(); i++) {
                ChildNodeEntry entry = (ChildNodeEntry) nodes.get(i);
                NodeState nstate = (NodeState) stateMgr.getItemState(entry.getId());
                store(nstate);
            }
            // and store itself
            stateMgr.store(state);
        }
View Full Code Here

                }
            }
            // now reload all child node entries
            List nodes = state.getChildNodeEntries();
            for (int i = 0; i < nodes.size(); i++) {
                ChildNodeEntry entry = (ChildNodeEntry) nodes.get(i);
                NodeState nstate = (NodeState) stateMgr.getItemState(entry.getId());
                reload(nstate);
            }
            // and reload itself
            state.discard();
        }
View Full Code Here

        NodeDefinitionImpl def = parentImpl.getApplicableChildNodeDefinition(name, ntName);

        // check for name collisions
        // TODO: improve. copied from NodeImpl
        NodeState thisState = (NodeState) parentImpl.getItemState();
        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.session.getItemManager().getItem(newId);
            if (!n.getDefinition().allowsSameNameSiblings()) {
                throw new ItemExistsException();
            }
        }
View Full Code Here

        List<ChildNodeEntry> elements = new ArrayList<ChildNodeEntry>();
        try {
            while (node.getParentId() != null) {
                NodeId parentId = node.getParentId();
                NodeState parent = (NodeState) stateMgr.getItemState(parentId);
                ChildNodeEntry entry = parent.getChildNodeEntry(node.getNodeId());
                elements.add(entry);
                node = parent;
            }
            for (int i = elements.size() - 1; i > -1; i--) {
                ChildNodeEntry entry = (ChildNodeEntry) elements.get(i);
                path.append('/').append(entry.getName().getLocalName());
                if (entry.getIndex() > 1) {
                    path.append('[').append(entry.getIndex()).append(']');
                }
            }
            if (path.length() == 0) {
                path.append('/');
            }
View Full Code Here

        }
        // child nodes (list of name/uuid pairs)
        Collection<ChildNodeEntry> collChild = state.getChildNodeEntries();
        out.writeInt(collChild.size()); // count
        for (Iterator<ChildNodeEntry> iter = collChild.iterator(); iter.hasNext();) {
            ChildNodeEntry entry = iter.next();
            writeQName(out, entry.getName());   // name
            writeID(out, entry.getId())// uuid
        }
        writeModCount(out, state.getModCount());
       
        // shared set (list of parent uuids)
        Collection<NodeId> collShared = state.getSharedSet();
View Full Code Here

            throws ItemStateException, RepositoryException {
        doc.add(new Field(
                FieldNames.PARENT, parentId.toString(),
                Field.Store.YES, Field.Index.NOT_ANALYZED_NO_NORMS, Field.TermVector.NO));
        NodeState parent = (NodeState) stateProvider.getItemState(parentId);
        ChildNodeEntry child = parent.getChildNodeEntry(node.getNodeId());
        if (child == null) {
            // this can only happen when jackrabbit
            // is running in a cluster.
            throw new RepositoryException(
                    "Missing child node entry for node with id: "
                    + node.getNodeId());
        }
        Name name = child.getName();
        addNodeName(doc, name.getNamespaceURI(), name.getLocalName());
    }
View Full Code Here

         */
        public void moveNode(NodeState child, NodeState newParent, String name)
                throws ItemStateException {

            NodeState oldParent = (NodeState) getItemState(child.getParentId());
            ChildNodeEntry cne = oldParent.getChildNodeEntry(child.getNodeId());
            if (cne == null) {
                throw new ItemStateException(child.getNodeId().toString());
            }
            oldParent.removeChildNodeEntry(cne.getName(), cne.getIndex());
            child.setParentId(newParent.getNodeId());
            newParent.addChildNodeEntry(toName(name), child.getNodeId());
        }
View Full Code Here

            ArrayList list = new ArrayList(parent.getChildNodeEntries());

            int srcIndex = -1, destIndex = -1;
            for (int i = 0; i < list.size(); i++) {
                ChildNodeEntry cne = (ChildNodeEntry) list.get(i);
                if (cne.getId().equals(src.getId())) {
                    srcIndex = i;
                } else if (dest != null && cne.getId().equals(dest.getId())) {
                    destIndex = i;
                }
            }
            if (destIndex == -1) {
                list.add(list.remove(srcIndex));
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.