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

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


            }
        }, true);

        // add the frozen children and histories
        for (String name : src.getChildNodeNames()) {
            NodeBuilder child = src.getChildNode(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, dest.child(name));
View Full Code Here


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

            throws RepositoryException {
        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

                }
            }
        }

        if (!journals.containsKey("root")) {
            NodeBuilder builder = EMPTY_NODE.builder();
            builder.setChildNode("root", EMPTY_NODE);
            journals.put("root", new FileJournal(this, builder.getNodeState()));
        }
    }
View Full Code Here

    NodeBuilder getOrCreateVersionHistory(@Nonnull NodeBuilder versionable)
            throws CommitFailedException {
        checkNotNull(versionable);
        String vUUID = uuidFromNode(versionable);
        String relPath = getVersionHistoryPath(vUUID);
        NodeBuilder node = versionStorageNode;
        for (Iterator<String> it = PathUtils.elements(relPath).iterator(); it.hasNext(); ) {
            String name = it.next();
            node = node.child(name);
            if (!node.hasProperty(JCR_PRIMARYTYPE)) {
                String nt;
                if (it.hasNext()) {
                    nt = REP_VERSIONSTORAGE;
                } else {
                    // last path element denotes nt:versionHistory node
                    nt = NT_VERSIONHISTORY;
                }
                node.setProperty(JCR_PRIMARYTYPE, nt, Type.NAME);
            }
        }
        // use jcr:rootVersion node to detect if we need to initialize the
        // version history
        if (!node.hasChildNode(JCR_ROOTVERSION)) {
            // jcr:versionableUuid property
            node.setProperty(JCR_VERSIONABLEUUID, vUUID, Type.STRING);
            node.setProperty(JCR_UUID,
                    IdentifierManager.generateUUID(), Type.STRING);

            // jcr:versionLabels child node
            NodeBuilder vLabels = node.child(JCR_VERSIONLABELS);
            vLabels.setProperty(JCR_PRIMARYTYPE, NT_VERSIONLABELS, Type.NAME);

            // jcr:rootVersion child node
            createVersion(node, versionable);
        }
        return node;
View Full Code Here

        versionable.setProperty(JCR_PREDECESSORS, predecessors, Type.REFERENCES);
    }

    public void checkin(@Nonnull NodeBuilder versionable)
            throws CommitFailedException {
        NodeBuilder history = getOrCreateVersionHistory(versionable);
        createVersion(history, versionable);
    }
View Full Code Here

    public void restore(@Nonnull NodeBuilder versionable,
                        @Nonnull String versionUUID,
                        @Nullable VersionSelector selector)
            throws CommitFailedException {
        String versionPath = getIdentifierManager().getPath(versionUUID);
        NodeBuilder history = getOrCreateVersionHistory(versionable);
        NodeBuilder version = null;
        if (versionPath != null) {
            String versionName = PathUtils.getName(versionPath);
            if (history.hasChildNode(versionName)) {
                version = history.getChildNode(versionName);
            }
View Full Code Here

                 @Nonnull VersionSelector selector,
                 @Nonnull NodeBuilder versionable)
            throws CommitFailedException, RepositoryException {
        String historyPath = getIdentifierManager().getPath(historyIdentifier);
        String historyRelPath = PathUtils.relativize(VERSION_STORE_PATH, historyPath);
        NodeBuilder history = resolve(versionStorageNode, historyRelPath);
        checkState(history.exists(), "Version history does not exist: " + historyPath);
        NodeBuilder version = selector.select(history);
        if (version == null) {
            throw new CommitFailedException(CommitFailedException.VERSION,
                    VersionExceptionCode.NO_VERSION_TO_RESTORE.ordinal(),
                    "VersionSelector did not select any version from " +
                            "history: " + historyPath);
View Full Code Here

     */
    public void addVersionLabel(@Nonnull String historyRelPath,
                                @Nonnull String label,
                                @Nonnull String versionName)
           throws CommitFailedException {
        NodeBuilder labels = getVersionLabelsFor(checkNotNull(historyRelPath));
        if (labels.hasProperty(checkNotNull(label))) {
            throw new CommitFailedException(CommitFailedException.LABEL_EXISTS,
                    VersionExceptionCode.LABEL_EXISTS.ordinal(),
                    "Version label " + label + " already exists on this version history");
        }
        NodeBuilder history = resolve(versionStorageNode, historyRelPath);
        if (checkNotNull(versionName).equals(JCR_ROOTVERSION)
                || !history.hasChildNode(checkNotNull(versionName))) {
            throw new CommitFailedException(CommitFailedException.VERSION,
                    VersionExceptionCode.NO_SUCH_VERSION.ordinal(),
                    "Not a valid version on this history: " + versionName);
        }
        String uuid = uuidFromNode(history.getChildNode(versionName));
        labels.setProperty(label, uuid, Type.REFERENCE);
    }
View Full Code Here

     * there is no label with the given name.
     */
    public void removeVersionLabel(@Nonnull String historyRelPath,
                                   @Nonnull String label)
            throws CommitFailedException {
        NodeBuilder labels = getVersionLabelsFor(checkNotNull(historyRelPath));
        if (!labels.hasProperty(checkNotNull(label))) {
            throw new CommitFailedException(CommitFailedException.VERSION,
                    VersionExceptionCode.NO_SUCH_VERSION_LABEL.ordinal(),
                    "Version label " + label + " does not exist on this version history");
        }
        labels.removeProperty(label);
    }
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.