Package org.modeshape.jcr.cache

Examples of org.modeshape.jcr.cache.NodeKey


    public AbstractJcrNode getNonSystemNodeByIdentifier( String id ) throws ItemNotFoundException, RepositoryException {
        checkLive();
        if (NodeKey.isValidFormat(id)) {
            // Try the identifier as a node key ...
            try {
                NodeKey key = new NodeKey(id);
                return node(key, null);
            } catch (ItemNotFoundException e) {
                // continue ...
            }
        }
        // Try as node key identifier ...
        NodeKey key = this.rootNode.key.withId(id);
        return node(key, null);
    }
View Full Code Here


            throw (cause instanceof RepositoryException) ? (RepositoryException)cause : new RepositoryException(e.getCause());
        } catch (DocumentNotFoundException e) {
            throw new InvalidItemStateException(JcrI18n.nodeModifiedBySessionWasRemovedByAnotherSession.text(e.getKey()), e);
        } catch (DocumentAlreadyExistsException e) {
            // Try to figure out which node in this transient state was the problem ...
            NodeKey key = new NodeKey(e.getKey());
            AbstractJcrNode problemNode = node(key, null);
            String path = problemNode.getPath();
            throw new InvalidItemStateException(JcrI18n.nodeCreatedBySessionUsedExistingKey.text(path, key), e);
        } catch (org.modeshape.jcr.cache.ReferentialIntegrityException e) {
            throw new ReferentialIntegrityException(e);
View Full Code Here

            throw (cause instanceof RepositoryException) ? (RepositoryException)cause : new RepositoryException(e.getCause());
        } catch (DocumentNotFoundException e) {
            throw new InvalidItemStateException(JcrI18n.nodeModifiedBySessionWasRemovedByAnotherSession.text(e.getKey()), e);
        } catch (DocumentAlreadyExistsException e) {
            // Try to figure out which node in this transient state was the problem ...
            NodeKey key = new NodeKey(e.getKey());
            AbstractJcrNode problemNode = node(key, null);
            String path = problemNode.getPath();
            throw new InvalidItemStateException(JcrI18n.nodeCreatedBySessionUsedExistingKey.text(path, key), e);
        } catch (org.modeshape.jcr.cache.ReferentialIntegrityException e) {
            throw new ReferentialIntegrityException(e);
View Full Code Here

                                                       NodeKey rootKey ) {
        // If this node is a random identifier, then we need to use it as a node key identifier ...
        if (NodeKey.isValidRandomIdentifier(identifier)) {
            return rootKey.withId(identifier);
        }
        return new NodeKey(identifier);
    }
View Full Code Here

        CachedNode node = cache.getNode(nodeKey);
        if (!node.isQueryable(cache)) return 0;
        int result = 1;
        ChildReferences childReferences = node.getChildReferences(cache);
        for (Iterator<NodeKey> nodeKeyIterator = childReferences.getAllKeys(); nodeKeyIterator.hasNext();) {
            NodeKey childKey = nodeKeyIterator.next();
            result += countAllNodesBelow(childKey, cache);
        }
        return result;
    }
View Full Code Here

        for (Value predecessorValue : predecessors.getValues()) {
            addedValues.clear();
            List<JcrValue> newNodeSuccessors = new ArrayList<>();

            // Add each of the successors from the version's predecessor ...
            NodeKey predecessorKey = ((NodeKeyReference)((JcrValue)predecessorValue).value()).getNodeKey();
            AbstractJcrNode predecessor = session().node(predecessorKey, null);
            MutableCachedNode predecessorSystem = system.mutable(predecessor.key());

            JcrValue[] nodeSuccessors = predecessor.getProperty(JcrLexicon.SUCCESSORS).getValues();
            addValuesNotInSet(nodeSuccessors, newNodeSuccessors, versionId, addedValues);

            if (successors != null) {
                // Add each of the successors from the version being removed ...
                addValuesNotInSet(successors.getValues(), newNodeSuccessors, versionId, addedValues);
            }

            // Set the property ...
            Object[] newSuccessorReferences = extractValues(newNodeSuccessors);
            predecessorSystem.setProperty(system, session.propertyFactory().create(JcrLexicon.SUCCESSORS,
                                                                           newSuccessorReferences));
            addedValues.clear();
        }

        if (successors != null) {
            // Remove the reference to the dead version from the predecessors property of all the successors
            for (Value successorValue : successors.getValues()) {
                addedValues.clear();
                List<JcrValue> newNodePredecessors = new ArrayList<>();

                // Add each of the predecessors from the version's successor ...
                NodeKey successorKey = ((NodeKeyReference)((JcrValue)successorValue).value()).getNodeKey();
                AbstractJcrNode successor = session().node(successorKey, null);
                MutableCachedNode successorSystem = system.mutable(successor.key());

                JcrValue[] nodePredecessors = successor.getProperty(JcrLexicon.PREDECESSORS).getValues();
                addValuesNotInSet(nodePredecessors, newNodePredecessors, versionId, addedValues);
View Full Code Here

    }

    protected JcrSharedNode asSharedNode( Node node ) {
        if (node instanceof JcrSharedNode) {
            JcrSharedNode sharedNode = (JcrSharedNode)node;
            NodeKey shareableKey = sharedNode.key();
            // See if the node is already exported ...
            if (!shareableNodes.add(shareableKey)) {
                // Already saw it, so return the shared node ...
                return sharedNode;
            }
View Full Code Here

        }
        AbstractJcrNode node = (AbstractJcrNode)value;
        if (!this.isInTheSameProcessAs(node.session().context().getProcessId())) {
            throw new RepositoryException(JcrI18n.nodeNotInTheSameSession.text(node.path()));
        }
        NodeKey key = ((AbstractJcrNode)value).key();
        Reference ref = session.context().getValueFactories().getReferenceFactory()
                               .create(key, ((AbstractJcrNode)value).isForeign());
        return valueFrom(PropertyType.REFERENCE, ref);
    }
View Full Code Here

                                            .newDocumentKey(key().toString(), childName, childPrimaryNodeTypeName);
            } catch (Exception e) {
                throw new RepositoryException(e);
            }
            if (documentStoreKey != null) {
                desiredKey = new NodeKey(documentStoreKey);
            }
        }

        // We can create the child, so start by building the required properties ...
        PropertyFactory propFactory = session.propertyFactory();
View Full Code Here

        if (srcRef == null) {
            String workspaceName = workspaceName();
            throw new ItemNotFoundException(JcrI18n.pathNotFound.text(srcChildRelPath, workspaceName));
        }

        NodeKey destKey = null;
        if (destChildRelPath != null) {
            Path destPath = session.pathFactory().create(destChildRelPath);
            if (destPath.isAbsolute() || destPath.size() != 1) {
                throw new ItemNotFoundException(JcrI18n.invalidPathParameter.text(destChildRelPath, "destChildRelPath"));
            }
View Full Code Here

TOP

Related Classes of org.modeshape.jcr.cache.NodeKey

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.