Package org.modeshape.jcr.cache

Examples of org.modeshape.jcr.cache.ChildReferences$Context


            CachedNode node = node();
            NodeCache cache = cache();
            NodeTypes nodeTypes = session.nodeTypes();
            // Need to figure out if the child node requires an SNS definition
            ChildReferences refs = node.getChildReferences(cache());
            // Create a sibling counter that reduces the count by 1, since we're always dealing with existing children
            // but the 'findBestDefinitionForChild' logic is looking to *add* a child ...
            SiblingCounter siblingCounter = SiblingCounter.alter(SiblingCounter.create(refs), -1);
            for (Name nodeName : mixinChildNodeNames) {
                int snsCount = siblingCounter.countSiblingsNamed(nodeName);
                if (snsCount == 0) continue;
                Iterator<ChildReference> iter = refs.iterator(nodeName);
                while (iter.hasNext()) {
                    ChildReference ref = iter.next();
                    CachedNode child = cache.getNode(ref);
                    Name childPrimaryType = child.getPrimaryType(cache);
                    boolean skipProtected = true;
View Full Code Here


                SystemContent systemContent = new SystemContent(systemSession);
                CachedNode locksNode = systemContent.locksNode();
                if (locksNode == null) {
                    return;
                }
                ChildReferences childReferences = locksNode.getChildReferences(systemSession);
                if (childReferences.isEmpty()) {
                    return;
                }
                for (ChildReference ref : childReferences) {
                    MutableCachedNode lockNode = systemSession.mutable(ref.getKey());
View Full Code Here

    }

    public Set<String> registerNamespaces( Map<String, String> newUrisByPrefix ) {
        Set<String> removedPrefixes = new HashSet<String>();
        MutableCachedNode namespaces = mutableNamespacesNode();
        ChildReferences childRefs = namespaces.getChildReferences(system);

        // Find any existing namespace nodes for the new namespace URIs ...
        for (Map.Entry<String, String> newNamespaceEntry : newUrisByPrefix.entrySet()) {
            String newPrefix = newNamespaceEntry.getKey().trim();
            String newUri = newNamespaceEntry.getValue().trim();

            // Verify that the prefix is not already used ...
            Name newPrefixName = nameForPrefix(newPrefix);
            ChildReference ref = childRefs.getChild(newPrefixName);
            if (ref != null) {
                // There's an existing node with the same prefix/name ...
                CachedNode existingNode = system.getNode(ref);
                String existingUri = strings.create(existingNode.getProperty(ModeShapeLexicon.URI, system).getFirstValue());
                if (newUri.equals(existingUri)) {
View Full Code Here

     * @throws LockException if there is no such lock with the supplied token
     */
    boolean changeLockHeldBySession( String lockToken,
                                     boolean value ) throws LockException {
        CachedNode locksNode = locksNode();
        ChildReferences childRefs = locksNode.getChildReferences(system);
        Name name = names.create(lockToken);
        ChildReference ref = childRefs.getChild(name);
        if (ref == null) {
            throw new LockException(JcrI18n.invalidLockToken.text(lockToken));
        }
        MutableCachedNode lockNode = system.mutable(ref.getKey());
        boolean isHeld = booleans.create(first(lockNode, ModeShapeLexicon.IS_HELD_BY_SESSION, false));
View Full Code Here

        // Find the parent of the version history node by walking the path and creating any missing intermediate folders ...
        Path parentPathInStorage = versionHistoryPath.getParent().subpath(2);
        Property primaryType = null;
        for (Segment segment : parentPathInStorage) {
            ChildReferences childRefs = node.getChildReferences(system);
            ChildReference ref = childRefs.getChild(segment);
            if (ref != null) {
                // Look up the child node ...
                node = system.getNode(ref);
            } else {
                // Create the intermediate node ...
View Full Code Here

            NodeKey rootVersionKey = historyNode.getChildReferences(system).getChild(JcrLexicon.ROOT_VERSION).getKey();
            Reference rootVersionRef = referenceFactory.create(rootVersionKey, true);
            predecessors = propertyFactory.create(JcrLexicon.PREDECESSORS, new Object[] {rootVersionRef});
            versionName = names.create("1.0");
        } else {
            ChildReferences historyChildren = historyNode.getChildReferences(system);
            predecessors = versionableNode.getProperty(JcrLexicon.PREDECESSORS, cacheForVersionableNode);
            versionName = nextNameForVersionNode(predecessors, historyChildren);
        }

        // Create a 'nt:version' node under the version history node ...
View Full Code Here

        // Create a queue for processing the subgraph
        final Queue<NodeKey> queue = new LinkedList<NodeKey>();

        if (reindexSystemContent) {
            // We need to look for the system node, and index it differently ...
            ChildReferences childRefs = node.getChildReferences(cache);
            ChildReference systemRef = childRefs.getChild(JcrLexicon.SYSTEM);
            NodeKey systemKey = systemRef != null ? systemRef.getKey() : null;
            for (ChildReference childRef : node.getChildReferences(cache)) {
                NodeKey childKey = childRef.getKey();
                if (childKey.equals(systemKey)) {
                    // This is the "/jcr:system" node ...
View Full Code Here

    private Collection<Projection> loadStoredProjections( SessionCache systemSession,
                                                          ChildReference federationNodeRef,
                                                          boolean validate ) {
        MutableCachedNode federationNode = systemSession.mutable(federationNodeRef.getKey());
        ChildReferences federationChildRefs = federationNode.getChildReferences(systemSession);

        Collection<Projection> result = new ArrayList<>();
        Collection<Projection> invalidProjections = new ArrayList<>();

        Map<String, String> workspaceNameByKey = workspaceNamesByKey();

        Iterator<ChildReference> iter = federationChildRefs.iterator(ModeShapeLexicon.PROJECTION);
        while (iter.hasNext()) {
            ChildReference projectionRef = iter.next();
            NodeKey projectionRefKey = projectionRef.getKey();
            CachedNode projectionNode = systemSession.getNode(projectionRefKey);
            String externalNodeKeyString = projectionNode.getProperty(ModeShapeLexicon.EXTERNAL_NODE_KEY, systemSession)
View Full Code Here

        // if we're removing a projection, one had to be stored previously, so there should be a federation node present
        assert federationNodeRef != null;

        NodeKey federationNodeKey = federationNodeRef.getKey();
        MutableCachedNode federationNode = systemSession.mutable(federationNodeKey);
        ChildReferences federationChildRefs = federationNode.getChildReferences(systemSession);

        int projectionsCount = federationChildRefs.getChildCount(ModeShapeLexicon.PROJECTION);

        for (int i = 1; i <= projectionsCount; i++) {
            ChildReference projectionRef = federationChildRefs.getChild(ModeShapeLexicon.PROJECTION, i);
            NodeKey projectionRefKey = projectionRef.getKey();
            CachedNode storedProjection = systemSession.getNode(projectionRefKey);
            String storedProjectionExternalNodeKey = storedProjection.getProperty(ModeShapeLexicon.EXTERNAL_NODE_KEY,
                                                                                  systemSession).getFirstValue().toString();
            assert storedProjectionExternalNodeKey != null;
View Full Code Here

    }

    private void assertUniqueChildren( JcrSession session,
                                       String nodeAbsPath,
                                       Set<String> names ) throws RepositoryException {
        ChildReferences childReferences = session.getNode(nodeAbsPath).node().getChildReferences(session.cache());
        for (String name : names) {
            assertEquals(1, childReferences.getChildCount(session.nameFactory().create(name)));
        }
    }
View Full Code Here

TOP

Related Classes of org.modeshape.jcr.cache.ChildReferences$Context

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.