Package org.apache.jackrabbit.oak.spi.state

Examples of org.apache.jackrabbit.oak.spi.state.NodeState


    /**
     * Rebase this builder on top of the head of the underlying store
     */
    NodeState rebase() {
        NodeState head = getNodeState();
        NodeState inMemBase = super.getBaseState();

        // Rebase branch
        branch.rebase();

        // Rebase in memory changes on top of the head of the rebased branch
View Full Code Here


     * Reset this builder by creating a new branch and setting the head
     * state of that branch as the new base state of this builder.
     */
    NodeState reset() {
        branch = store.createBranch(store.getRoot());
        NodeState head = branch.getHead();
        reset(head);
        return head;
    }
View Full Code Here

            return names;
        }
    }

    private void addNodeType(NodeState types, String name) {
        NodeState type = types.getChildNode(name);

        for (String primary : type.getNames(REP_PRIMARY_SUBTYPES)) {
            primaryTypes = add(primaryTypes, primary);
        }

        if (type.getBoolean(JCR_ISMIXIN)) {
            mixinTypes = add(mixinTypes, name);

            // Only mixin types can have mixin descendants, so we
            // only fill the mixinTypes set in this branch of code.
            for (String mixin : type.getNames(REP_MIXIN_SUBTYPES)) {
                mixinTypes = add(mixinTypes, mixin);
            }
        } else {
            // No need to check whether the type actually exists, as if
            // it doesn't there should in any case be no matching content.
View Full Code Here

            this.filter = filter;

            String path = filter.getPath();
            parentPath = null;
            currentPath = "/";
            NodeState parent = null;
            NodeState node = rootState;
           
            if (filter.isAlwaysFalse()) {
                // nothing can match this filter, leave nodes empty
                return;
            }

            if (!path.equals("/")) {
                for (String name : path.substring(1).split("/")) {
                    parentPath = currentPath;
                    currentPath = PathUtils.concat(parentPath, name);

                    parent = node;
                    node = parent.getChildNode(name);
                }
                if (!node.exists()) {
                    // nothing can match this filter, leave nodes empty
                    return;
                }
            }
            Filter.PathRestriction restriction = filter.getPathRestriction();
            switch (restriction) {
            case NO_RESTRICTION:
            case EXACT:
            case ALL_CHILDREN:
                nodeIterators.add(Iterators.singletonIterator(
                        new MemoryChildNodeEntry(currentPath, node)));
                parentPath = "";
                break;
            case PARENT:
                if (parent != null) {
                    nodeIterators.add(Iterators.singletonIterator(
                            new MemoryChildNodeEntry(parentPath, parent)));
                    parentPath = "";
                }
                break;
            case DIRECT_CHILDREN:
                nodeIterators.add(node.getChildNodeEntries().iterator());
                parentPath = currentPath;
                break;
            default:
                throw new IllegalArgumentException("Unknown restriction: " + restriction);
            }
View Full Code Here

    @Override
    public boolean hasChildNode(String name) {
        assert base != null;
        checkNotNull(name);
        // checkArgument(!name.isEmpty()); TODO: should be caught earlier
        NodeState child = nodes.get(name);
        if (child != null) {
            return child.exists();
        } else {
            return base.hasChildNode(name);
        }
    }
View Full Code Here

        return child;
    }

    @Override
    public NodeState getChildNode(String name) {
        NodeState child = nodes.get(name);
        if (child == null) {
            child = base.getChildNode(name);
        }
        return child;
    }
View Full Code Here

                    readCount++;
                    if (readCount % 1000 == 0) {
                        LOG.warn("Traversed " + readCount + " nodes with filter " + filter + "; consider creating an index or changing the query");
                    }

                    NodeState node = entry.getNodeState();

                    String name = entry.getName();
                    if (NodeStateUtils.isHidden(name)) {
                        continue;
                    }
                    currentPath = PathUtils.concat(parentPath, name);

                    PathRestriction r = filter.getPathRestriction();
                    if (r == PathRestriction.ALL_CHILDREN ||
                            r == PathRestriction.NO_RESTRICTION) {
                        nodeIterators.addLast(node.getChildNodeEntries().iterator());
                        parentPath = currentPath;
                    }
                    return;
                } else {
                    nodeIterators.removeLast();
View Full Code Here

    @Override
    public boolean apply(NodeState input) {
        if (!initialized) {
            // lazy initialization of the sets of matching type names
            NodeState types = checkNotNull(root)
                    .getChildNode(JCR_SYSTEM)
                    .getChildNode(JCR_NODE_TYPES);
            for (String name : checkNotNull(names)) {
                addNodeType(types, name);
            }
View Full Code Here

    @Override
    public Editor getRootEditor(
            NodeState before, NodeState after, NodeBuilder builder)
            throws CommitFailedException {
        NodeState beforeTypes =
                before.getChildNode(JCR_SYSTEM).getChildNode(JCR_NODE_TYPES);
        NodeState afterTypes =
                after.getChildNode(JCR_SYSTEM).getChildNode(JCR_NODE_TYPES);

        Set<String> modifiedTypes = Collections.emptySet();
        TypeRegistration registration = new TypeRegistration();
        afterTypes.compareAgainstBaseState(beforeTypes, registration);
        if (registration.isModified()) {
            afterTypes = registration.apply(builder);
            modifiedTypes = registration.getModifiedTypes(beforeTypes);
        }

        String primary = after.getName(JCR_PRIMARYTYPE);
        Iterable<String> mixins = after.getNames(JCR_MIXINTYPES);

        if (primary == null && afterTypes.hasChildNode("rep:root")) {
            // no primary type on the root node, set the hardcoded default
            primary = "rep:root";
            builder.setProperty(JCR_PRIMARYTYPE, primary, NAME);
        }
View Full Code Here

    }

    private static Query parseQuery(String statement, String language,
            ExecutionContext context, NamePathMapper namePathMapper) throws ParseException {
        LOG.debug("Parsing {} statement: {}", language, statement);
        NodeState types = context.getBaseState()
                .getChildNode(JCR_SYSTEM)
                .getChildNode(JCR_NODE_TYPES);
        SQL2Parser parser = new SQL2Parser(namePathMapper, types);
        if (language.endsWith(NO_LITERALS)) {
            language = language.substring(0, language.length() - NO_LITERALS.length());
View Full Code Here

TOP

Related Classes of org.apache.jackrabbit.oak.spi.state.NodeState

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.