Package org.modeshape.jcr.cache

Examples of org.modeshape.jcr.cache.CachedNode


            Set<Name> mixinChildNodeNames = new HashSet<Name>();
            for (JcrNodeDefinition nodeDefinition : mixinType.allChildNodeDefinitions()) {
                mixinChildNodeNames.add(nodeDefinition.getInternalName());
            }

            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;
                    NodeDefinitionSet childDefns = nodeTypes.findChildNodeDefinitions(mixinType.getInternalName(), null);
                    JcrNodeDefinition childDefn = childDefns.findBestDefinitionForChild(nodeName, childPrimaryType,
                                                                                        skipProtected, siblingCounter);
                    if (childDefn == null) {
View Full Code Here


        CachedDefinition defn = cachedDefn;
        NodeTypes nodeTypes = session().nodeTypes();
        if (defn == null || nodeTypes.getVersion() > defn.nodeTypesVersion) {
            assert !this.isRoot();
            // Determine the node type based upon this node's type information ...
            CachedNode parent = getParent().node();
            SessionCache cache = sessionCache();
            Name nodeName = name();
            Name primaryType = node().getPrimaryType(cache);
            Name parentPrimaryType = parent.getPrimaryType(cache);
            Set<Name> parentMixins = parent.getMixinTypes(cache);
            SiblingCounter siblingCounter = SiblingCounter.create(parent, cache);
            boolean skipProtected = true;
            NodeDefinitionSet childDefns = nodeTypes.findChildNodeDefinitions(parentPrimaryType, parentMixins);
            JcrNodeDefinition childDefn = childDefns.findBestDefinitionForChild(nodeName, primaryType, skipProtected,
                                                                                siblingCounter);
View Full Code Here

        CachedDefinition defn = cachedDefn;
        NodeTypes nodeTypes = session().nodeTypes();
        if (defn == null || nodeTypes.getVersion() > defn.nodeTypesVersion) {
            assert !this.isRoot();
            // Determine the node type based upon this node's type information ...
            CachedNode parent = getParent().node();
            SessionCache cache = sessionCache();
            Name nodeName = name();
            Name primaryType = node().getPrimaryType(cache);
            Name parentPrimaryType = parent.getPrimaryType(cache);
            Set<Name> parentMixins = parent.getMixinTypes(cache);
            // The node is already a child, so create a counter that returns the count as if it were not a child ...
            SiblingCounter siblingCounter = SiblingCounter.alter(SiblingCounter.create(parent, cache), -1);
            boolean skipProtected = false;
            NodeDefinitionSet childDefns = nodeTypes.findChildNodeDefinitions(parentPrimaryType, parentMixins);
            JcrNodeDefinition childDefn = childDefns.findBestDefinitionForChild(nodeName, primaryType, skipProtected,
View Full Code Here

    }

    @Override
    public boolean isNew() {
        try {
            CachedNode node = node();
            return node instanceof MutableCachedNode && ((MutableCachedNode)node).isNew();
        } catch (RepositoryException e) {
            // continue by returning false, since the node probably doesn't exist anymore
            return false;
        }
View Full Code Here

    }

    @Override
    public boolean isModified() {
        try {
            CachedNode node = node();
            if (node instanceof MutableCachedNode) {
                MutableCachedNode mutable = (MutableCachedNode)node;
                return !mutable.isNew() && mutable.hasChanges();
            }
        } catch (RepositoryException e) {
View Full Code Here

        }
    }

    @Override
    public void refresh( boolean keepChanges ) throws RepositoryException {
        CachedNode node = node(); // TCK: this should throw an exception if the node has been removed
        if (!keepChanges) {
            session.cache().clear(node);
        }
    }
View Full Code Here

        @SuppressWarnings( "deprecation" )
        private void updateLocks( RunningState repository ) {
            try {
                SessionCache systemSession = repository.createSystemSession(repository.context(), false);
                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

         *
         * @param removedNode the removed node
         */
        protected void preRemoveNode( AbstractJcrNode removedNode ) {
            // Figure out if the node has backreferences ...
            CachedNode node;
            try {
                node = removedNode.node();
                ReferrerCounts referrers = node.getReferrerCounts(cache);
                if (referrers != null) referrersByNodeKey.put(node.getKey(), referrers);
            } catch (ItemNotFoundException | InvalidItemStateException err) {
                // do nothing ...
            }
        }
View Full Code Here

    }

    public NodeKey systemKey() {
        if (systemKey == null) {
            // This is idempotent, so no need to lock
            CachedNode rootNode = system.getNode(system.getRootKey());
            ChildReference systemRef = rootNode.getChildReferences(system).getChild(JcrLexicon.SYSTEM);
            systemKey = systemRef.getKey();
        }
        return systemKey;
    }
View Full Code Here

    }

    public NodeKey nodeTypesKey() {
        if (nodeTypesKey == null) {
            // This is idempotent, so no need to lock
            CachedNode systemNode = systemNode();
            ChildReference nodeTypesRef = systemNode.getChildReferences(system).getChild(JcrLexicon.NODE_TYPES);
            nodeTypesKey = nodeTypesRef.getKey();
        }
        return nodeTypesKey;
    }
View Full Code Here

TOP

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

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.