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

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


    }

    public static NodeBuilder createStandardMappings(NodeBuilder system) {
        checkState(!system.hasChildNode(REP_NAMESPACES));

        NodeBuilder namespaces = system.setChildNode(REP_NAMESPACES);
        namespaces.setProperty(JCR_PRIMARYTYPE, NodeTypeConstants.NT_REP_UNSTRUCTURED, NAME);

        // Standard namespace specified by JCR (default one not included)
        namespaces.setProperty(escapePropertyKey(PREFIX_EMPTY), NAMESPACE_EMPTY);
        namespaces.setProperty(PREFIX_JCR, NAMESPACE_JCR);
        namespaces.setProperty(PREFIX_NT,  NAMESPACE_NT);
        namespaces.setProperty(PREFIX_MIX, NAMESPACE_MIX);
        namespaces.setProperty(PREFIX_XML, NAMESPACE_XML);

        // Namespace included in Jackrabbit 2.x
        namespaces.setProperty(PREFIX_SV, NAMESPACE_SV);
        namespaces.setProperty(PREFIX_REP, NAMESPACE_REP);

        return namespaces;
    }
View Full Code Here


                uris.add(uri);
                reverse.put(escapePropertyKey(uri), prefix);
            }
        }

        NodeBuilder data = namespaces.setChildNode(REP_NSDATA);
        data.setProperty(JCR_PRIMARYTYPE, NodeTypeConstants.NT_REP_UNSTRUCTURED, Type.NAME);
        data.setProperty(REP_PREFIXES, prefixes, Type.STRINGS);
        data.setProperty(REP_URIS, uris, Type.STRINGS);
        for (Entry<String, String> e : reverse.entrySet()) {
            data.setProperty(encodeUri(e.getKey()), e.getValue());
        }
    }
View Full Code Here

    }

    // testing

    public static Tree setupTestNamespaces(Map<String, String> global) {
        NodeBuilder root = EmptyNodeState.EMPTY_NODE.builder();
        NodeBuilder namespaces = root.child(JCR_SYSTEM).child(REP_NAMESPACES);
        namespaces.setProperty(JCR_PRIMARYTYPE, NodeTypeConstants.NT_REP_UNSTRUCTURED, NAME);
        for (Entry<String, String> entry : global.entrySet()) {
            namespaces.setProperty(escapePropertyKey(entry.getKey()),
                    entry.getValue());
        }
        buildIndexNode(namespaces);
        return new ImmutableTree(root.getNodeState());
    }
View Full Code Here

                                 NodeBuilder dest,
                                 VersionSelector selector)
            throws RepositoryException, CommitFailedException {
        // 15.7.6 Restoring Child Nodes
        for (String name : src.getChildNodeNames()) {
            NodeBuilder srcChild = src.getChildNode(name);
            int action = getOPV(dest, srcChild, name);
            if (action == COPY) {
                // replace on destination
                dest.getChildNode(name).remove();
                restoreCopiedNode(srcChild, dest.child(name), selector);
            } else if (action == VERSION) {
                restoreState(srcChild, dest, name, selector);
            }
        }
        for (String name : dest.getChildNodeNames()) {
            if (src.hasChildNode(name)) {
                continue;
            }
            NodeBuilder destChild = dest.getChildNode(name);
            int action = getOPV(dest, destChild, name);
            if (action == COPY || action == VERSION || action == ABORT) {
                dest.getChildNode(name).remove();
            } else if (action == IGNORE) {
                // no action
View Full Code Here

            }
        }, true);

        // add the frozen children and histories
        for (String name : src.getChildNodeNames()) {
            NodeBuilder child = src.getChildNode(name);
            String childId = getChildId(srcId, child, name);
            int opv = getOPV(src, child, name);

            if (opv == OnParentVersionAction.ABORT) {
                throw new CommitFailedException(CommitFailedException.VERSION,
                        VersionExceptionCode.OPV_ABORT_ITEM_PRESENT.ordinal(),
                        "Checkin aborted due to OPV abort in " + name);
            }
            if (opv == OnParentVersionAction.VERSION) {
                if (ntMgr.isNodeType(new ImmutableTree(child.getNodeState()), MIX_VERSIONABLE)) {
                    // create frozen versionable child
                    versionedChild(child, dest.child(name));
                } else {
                    // else copy
                    copy(child, childId, dest.child(name));
View Full Code Here

                      NodeBuilder dest)
            throws RepositoryException, CommitFailedException {
        initFrozen(dest, src, srcId);
        copyProperties(src, dest, OPVForceCopy.INSTANCE, true);
        for (String name : src.getChildNodeNames()) {
            NodeBuilder child = src.getChildNode(name);
            copy(child, getChildId(srcId, child, name), dest.child(name));
        }
    }
View Full Code Here

        }
        ImmutableTree parentTree = new ImmutableTree(parent.getNodeState());
        NodeState childState;
        if (NT_FROZENNODE.equals(child.getName(JCR_PRIMARYTYPE))) {
            // need to translate into a regular node to get proper OPV value
            NodeBuilder builder = new MemoryNodeBuilder(EmptyNodeState.EMPTY_NODE);
            builder.setProperty(JCR_PRIMARYTYPE, child.getName(JCR_FROZENPRIMARYTYPE), Type.NAME);
            builder.setProperty(JCR_MIXINTYPES, child.getNames(JCR_MIXINTYPES), Type.NAMES);
            childState = builder.getNodeState();
        } else {
            childState = child.getNodeState();
        }
        ImmutableTree childTree = new ImmutableTree(
                parentTree, childName, childState);
View Full Code Here

                afterKeys.removeAll(sharedKeys);
            }

            if (!beforeKeys.isEmpty() || !afterKeys.isEmpty()) {
                updateCallback.indexUpdate();
                NodeBuilder index = definition.child(INDEX_CONTENT_NODE_NAME);
                getStrategy(keysToCheckForUniqueness != null).update(
                        index, getPath(), beforeKeys, afterKeys);
                if (keysToCheckForUniqueness != null) {
                    keysToCheckForUniqueness.addAll(afterKeys);
                }
View Full Code Here

    public Editor getRootEditor(NodeState before, NodeState after,
            NodeBuilder builder) {
        if (!builder.hasChildNode(JCR_SYSTEM)) {
            return null;
        }
        NodeBuilder system = builder.child(JCR_SYSTEM);
        if (!system.hasChildNode(JCR_VERSIONSTORAGE)) {
            return null;
        }
        NodeBuilder versionStorage = system.child(JCR_VERSIONSTORAGE);
        return new VisibleEditor(new CompositeEditor(
                new VersionEditor(versionStorage, builder),
                new VersionStorageEditor(versionStorage, builder)));
    }
View Full Code Here

            insert(index, key, path);
        }
    }

    private static void remove(NodeBuilder index, String key, String value) {
        NodeBuilder builder = index.getChildNode(key);
        if (builder.exists()) {
            // Collect all builders along the given path
            Deque<NodeBuilder> builders = newArrayDeque();
            builders.addFirst(builder);

            // Descend to the correct location in the index tree
            for (String name : PathUtils.elements(value)) {
                builder = builder.getChildNode(name);
                builders.addFirst(builder);
            }

            // Drop the match value,  if present
            if (builder.exists()) {
                builder.removeProperty("match");
            }

            // Prune all index nodes that are no longer needed
            for (NodeBuilder node : builders) {
                if (node.getBoolean("match") || node.getChildNodeCount(1) > 0) {
View Full Code Here

TOP

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

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.