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

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


                        return false;
                    }
                }
            }
        } else if (afterChildName != Template.MANY_CHILD_NODES) {
            NodeState afterNode = afterTemplate.getChildNode(
                    afterChildName, afterSegment, afterId);
            NodeState beforeNode = beforeTemplate.getChildNode(
                    afterChildName, beforeSegment, beforeId);
            if (!beforeNode.exists()) {
                if (!diff.childNodeAdded(afterChildName, afterNode)) {
                    return false;
                }
            } else if (!fastEquals(afterNode, beforeNode)) {
                if (!diff.childNodeChanged(
                        afterChildName, beforeNode, afterNode)) {
                    return false;
                }
            }
            if (beforeChildName == Template.MANY_CHILD_NODES
                    || (beforeChildName != Template.ZERO_CHILD_NODES
                        && !beforeNode.exists())) {
                for (ChildNodeEntry entry :
                    beforeTemplate.getChildNodeEntries(beforeSegment, beforeId)) {
                    if (!afterChildName.equals(entry.getName())) {
                        if (!diff.childNodeDeleted(
                                entry.getName(), entry.getNodeState())) {
                            return false;
                        }
                    }
                }
            }
        } else if (beforeChildName == Template.ZERO_CHILD_NODES) {
            for (ChildNodeEntry entry
                    : afterTemplate.getChildNodeEntries(afterSegment, afterId)) {
                if (!diff.childNodeAdded(
                        entry.getName(), entry.getNodeState())) {
                    return false;
                }
            }
        } else if (beforeChildName != Template.MANY_CHILD_NODES) {
            for (ChildNodeEntry entry : afterTemplate.getChildNodeEntries(afterSegment, afterId)) {
                String childName = entry.getName();
                NodeState afterChild = entry.getNodeState();
                if (beforeChildName.equals(childName)) {
                    NodeState beforeChild = beforeTemplate.getChildNode(
                            beforeChildName, beforeSegment, beforeId);
                    if (beforeChild.exists()) {
                        if (!fastEquals(afterChild, beforeChild)
                                && !diff.childNodeChanged(
                                        childName, beforeChild, afterChild)) {
                            return false;
                        }
View Full Code Here


        if (isRoot() || !exists() || newParent.hasChildNode(newName)) {
            return false;
        } else {
            if (newParent.exists()) {
                annotateSourcePath();
                NodeState nodeState = getNodeState();
                newParent.setChildNode(newName, nodeState);
                remove();
                return true;
            } else {
                return false;
View Full Code Here

            return head.getValue(Type.STRING);
        }
    }

    private boolean isTransientlyAdded(String path) {
        NodeState node = rootBuilder.getBaseState();
        for (String name : PathUtils.elements(path)) {
            node = node.getChildNode(name);
        }
        return !node.exists();
    }
View Full Code Here

     * @param root root node state
     * @return read-only node type manager
     */
    @Nonnull
    public static ReadOnlyNodeTypeManager getInstance(NodeState root) {
        NodeState typesNode = root;
        for (String name : PathUtils.elements(NODE_TYPES_PATH)) {
            typesNode = typesNode.getChildNode(name);
        }

        final Tree typesTree = new ImmutableTree(typesNode);
        return new ReadOnlyNodeTypeManager() {
            @Override
View Full Code Here

                    readCount++;
                    if (readCount % 1000 == 0) {
                        LOG.warn("Traversed " + readCount + " nodes using index " + indexName + " with filter " + filter);
                    }

                    NodeState node = entry.getNodeState();

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

                    nodeIterators.addLast(node.getChildNodeEntries().iterator());
                    parentPath = currentPath;

                    if (node.getBoolean("match")) {
                        return;
                    }
                   
                } else {
                    nodeIterators.removeLast();
View Full Code Here

            undefinedType = UNDEFINED.toString();
        }

        // Find matching named property definition
        for (NodeState type : types) {
            NodeState definitions = type
                    .getChildNode(REP_NAMED_PROPERTY_DEFINITIONS)
                    .getChildNode(escapedName);

            NodeState definition = definitions.getChildNode(definedType);
            if (definition.exists()) {
                return definition;
            }

            definition = definitions.getChildNode(undefinedType);
            if (definition.exists()) {
                return definition;
            }

            // OAK-822: a mandatory definition always overrides residual ones
            // TODO: unnecessary if the OAK-713 fallback wasn't needed below
            for (ChildNodeEntry entry : definitions.getChildNodeEntries()) {
                definition = entry.getNodeState();
                if (definition.getBoolean(JCR_MANDATORY)) {
                    return definition;
                }
            }

// TODO: Fall back to residual definitions until we have consensus on OAK-713
//          throw new ConstraintViolationException(
//                "No matching definition found for property " + propertyName);
        }

        // Find matching residual property definition
        for (NodeState type : types) {
            NodeState residual =
                    type.getChildNode(REP_RESIDUAL_PROPERTY_DEFINITIONS);
            NodeState definition = residual.getChildNode(definedType);
            if (!definition.exists()) {
                definition = residual.getChildNode(undefinedType);
            }
            if (definition.exists()) {
                return definition;
            }
        }

        return null;
View Full Code Here

        boolean sns = !name.equals(nameWithIndex);
        Set<String> typeNames = effective.getTypeNames();

        // Find matching named child node definition
        for (NodeState type : types) {
            NodeState definitions = type
                    .getChildNode(REP_NAMED_CHILD_NODE_DEFINITIONS)
                    .getChildNode(name);

            for (String typeName : typeNames) {
                NodeState definition = definitions.getChildNode(typeName);
                if (definition.exists() && snsMatch(sns, definition)) {
                    return true;
                }
            }

            // OAK-822: a mandatory definition always overrides alternatives
            // TODO: unnecessary if the OAK-713 fallback wasn't needed below
            for (ChildNodeEntry entry : definitions.getChildNodeEntries()) {
                NodeState definition = entry.getNodeState();
                if (definition.getBoolean(JCR_MANDATORY)) {
                    return false;
                }
            }

// TODO: Fall back to residual definitions until we have consensus on OAK-713
//          throw new ConstraintViolationException(
//                  "Incorrect node type of child node " + nodeName);
        }

        // Find matching residual child node definition
        for (NodeState type : types) {
            NodeState residual =
                    type.getChildNode(REP_RESIDUAL_CHILD_NODE_DEFINITIONS);
            for (String typeName : typeNames) {
                NodeState definition = residual.getChildNode(typeName);
                if (definition.exists() && snsMatch(sns, definition)) {
                    return true;
                }
            }
        }
View Full Code Here

        @Override
        public Head update() {
            long rootRevision = rootHead().revision;
            if (revision != rootRevision) {
                // root revision changed: recursively re-get state from parent
                NodeState parentState = parent.head().getCurrentNodeState();
                NodeState newState = parentState.getChildNode(name);
                if (newState instanceof MutableNodeState) {
                    // transition state to ConnectedHead
                    return new ConnectedHead((MutableNodeState) newState);
                } else {
                    // update to match the latest revision
View Full Code Here

    String getDefaultType(String nameWithIndex) {
        String name = dropIndexFromName(nameWithIndex);
        boolean sns = !name.equals(nameWithIndex);

        for (NodeState type : types) {
            NodeState named = type
                    .getChildNode(REP_NAMED_CHILD_NODE_DEFINITIONS)
                    .getChildNode(name);
            NodeState residual = type
                    .getChildNode(REP_RESIDUAL_CHILD_NODE_DEFINITIONS);

            for (ChildNodeEntry entry : concat(
                    named.getChildNodeEntries(),
                    residual.getChildNodeEntries())) {
                NodeState definition = entry.getNodeState();
                String defaultType = definition.getName(JCR_DEFAULTPRIMARYTYPE);
                if (defaultType != null && snsMatch(sns, definition)) {
                    return defaultType;
                }
            }
        }
View Full Code Here

    }

    @Override
    public Iterable<String> query(final Filter filter, final String indexName,
            final NodeState indexMeta, final Iterable<String> values) {
        final NodeState index = indexMeta.getChildNode(INDEX_CONTENT_NODE_NAME);
        return new Iterable<String>() {
            @Override
            public Iterator<String> iterator() {
                if (values == null) {
                    return new Iterator<String>() {
                       
                        Iterator<? extends ChildNodeEntry> it = index.getChildNodeEntries().iterator();

                        @Override
                        public boolean hasNext() {
                            return it.hasNext();
                        }

                        @Override
                        public String next() {
                            PropertyState s = it.next().getNodeState().getProperty("entry");
                            return s.getValue(Type.STRING, 0);
                        }

                        @Override
                        public void remove() {
                            it.remove();
                        }
                       
                    };
                }
                ArrayList<String> list = new ArrayList<String>();
                for (String p : values) {
                    NodeState key = index.getChildNode(p);
                    if (key.exists()) {
                        // we have an entry for this value, so use it
                        PropertyState s = key.getProperty("entry");
                        String v = s.getValue(Type.STRING, 0);
                        list.add(v);
                    }
                }
                return list.iterator();
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.