Examples of NodeBuilder


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

            String name = getName(path);
            switch (token) {
            case '+':
                tokenizer.read(':');
                tokenizer.read('{');
                NodeBuilder parent = getNode(builder, getParentPath(path));
                if (builder.hasChildNode(name)) {
                    throw new MicroKernelException(
                            "Node already exists: " + path);
                }
                addNode(parent.setChildNode(name), tokenizer);
                break;
            case '-':
                getNode(builder, path).remove();
                break;
            case '^':
                tokenizer.read(':');
                NodeBuilder node = getNode(builder, getParentPath(path));
                switch (tokenizer.read()) {
                case JsopReader.NULL:
                    node.removeProperty(name);
                    break;
                case JsopReader.FALSE:
                    node.setProperty(name, Boolean.FALSE);
                    break;
                case JsopReader.TRUE:
                    node.setProperty(name, Boolean.TRUE);
                    break;
                case JsopReader.STRING:
                    node.setProperty(name, tokenizer.getToken());
                    break;
                case JsopReader.NUMBER:
                    String value = tokenizer.getToken();
                    try {
                        node.setProperty(name, Long.parseLong(value));
                    } catch (NumberFormatException e) {
                        node.setProperty(name, Double.parseDouble(value));
                    }
                    break;
                default:
                    throw new UnsupportedOperationException();
                }
                break;
            case '>':
                tokenizer.read(':');
                String targetPath = tokenizer.readString();
                NodeBuilder targetParent =
                        getNode(builder, getParentPath(targetPath));
                String targetName = getName(targetPath);
                if (path.equals(targetPath) || PathUtils.isAncestor(path, targetPath)) {
                    throw new MicroKernelException(
                            "Target path must not be the same or a descendant of the source path: " + targetPath);
                }
                if (targetParent.hasChildNode(targetName)) {
                    throw new MicroKernelException(
                            "Target node exists: " + targetPath);
                } else if (!getNode(builder, path).moveTo(
                        targetParent, targetName)) {
                    throw new MicroKernelException("Move failed");

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

        privilegeBits = PrivilegeBits.getInstance(entryTree.getProperty(REP_PRIVILEGE_BITS));
        restriction = restrictionsProvider.getPattern(path, entryTree);
    }

    static void write(NodeBuilder parent, boolean isAllow, int index, PrivilegeBits privilegeBits, Set<Restriction> restrictions) {
        NodeBuilder n = parent.child(String.valueOf(index))
                .setProperty(JCR_PRIMARYTYPE, NT_REP_PERMISSIONS, Type.NAME)
                .setProperty(REP_IS_ALLOW, isAllow)
                .setProperty(privilegeBits.asPropertyState(REP_PRIVILEGE_BITS));
        for (Restriction restriction : restrictions) {
            n.setProperty(restriction.getProperty());
        }
    }

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

class JcrAllCommitHook implements PostValidationHook, PrivilegeConstants {

    @Nonnull
    @Override
    public NodeState processCommit(NodeState before, NodeState after) throws CommitFailedException {
        NodeBuilder builder = after.builder();
        after.compareAgainstBaseState(before, new PrivilegeDiff(null, null, builder));
        return builder.getNodeState();
    }

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

        @Override
        public boolean childNodeAdded(String name, NodeState after) {
            if (PRIVILEGES_PATH.equals(path) && !JCR_ALL.equals(name)) {
                // a new privilege was registered -> update the jcr:all privilege
                NodeBuilder jcrAll = nodeBuilder.child(JCR_ALL);
                PropertyState aggregates = jcrAll.getProperty(REP_AGGREGATES);

                PropertyBuilder<String> propertyBuilder;
                if (aggregates == null) {
                    propertyBuilder = PropertyBuilder.array(Type.NAME, REP_AGGREGATES);
                } else {
                    propertyBuilder = PropertyBuilder.copy(Type.NAME, aggregates);
                }
                if (!propertyBuilder.hasValue(name)) {
                    propertyBuilder.addValue(name);
                    jcrAll.setProperty(propertyBuilder.getPropertyState());
                }

                // update the privilege bits of the jcr:all in case the new
                // privilege isn't an aggregate
                if (!after.hasProperty(REP_AGGREGATES)) {
                    PrivilegeBits bits = PrivilegeBits.getInstance(after.getProperty(REP_BITS));
                    PrivilegeBits all = PrivilegeBits.getInstance(jcrAll.getProperty(REP_BITS));
                    jcrAll.setProperty(PrivilegeBits.getInstance(all).add(bits).asPropertyState(REP_BITS));
                }
            }
            return true;
        }

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

    public NodeState processCommit(
            @Nonnull NodeState before, @Nonnull NodeState after)
            throws CommitFailedException {
        checkNotNull(before);
        checkNotNull(after);
        NodeBuilder builder = after.builder();
        Editor editor = provider.getRootEditor(before, after, builder);
        CommitFailedException exception =
                EditorDiff.process(editor, before, after);
        if (exception == null) {
            return builder.getNodeState();
        } else {
            throw exception;
        }
    }

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

        if (id != null) {
            head = new AtomicReference<RecordId>(id);
            persistedHead = new AtomicReference<RecordId>(id);
        } else {
            NodeBuilder builder = EMPTY_NODE.builder();
            builder.setChildNode("root", initial);
            head = new AtomicReference<RecordId>(
                    getWriter().writeNode(builder.getNodeState()).getRecordId());
            persistedHead = new AtomicReference<RecordId>(null);
        }

        this.flushThread = new Thread(new Runnable() {
            @Override

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

* TODO document
*/
public class IndexUtils {

    public static NodeBuilder getOrCreateOakIndex(NodeBuilder root) {
        NodeBuilder index;
        if (!root.hasChildNode(INDEX_DEFINITIONS_NAME)) {
            index = root.child(INDEX_DEFINITIONS_NAME);
            // TODO: use property node type name
            index.setProperty(JCR_PRIMARYTYPE, NT_UNSTRUCTURED, NAME);
        } else {
            index = root.child(INDEX_DEFINITIONS_NAME);
        }
        return index;
    }

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

                                                    @Nonnull String indexDefName,
                                                    boolean reindex,
                                                    boolean unique,
                                                    @Nonnull Collection<String> propertyNames,
                                                    @Nullable Collection<String> declaringNodeTypeNames) {
        NodeBuilder entry = index.child(indexDefName)
                .setProperty(JCR_PRIMARYTYPE, INDEX_DEFINITIONS_NODE_TYPE, NAME)
                .setProperty(TYPE_PROPERTY_NAME, PropertyIndexEditorProvider.TYPE)
                .setProperty(REINDEX_PROPERTY_NAME, reindex);
        if (unique) {
            entry.setProperty(UNIQUE_PROPERTY_NAME, unique);
        }
        entry.setProperty(PropertyStates.createProperty(PROPERTY_NAMES, propertyNames, NAMES));
        if (declaringNodeTypeNames != null && !declaringNodeTypeNames.isEmpty()) {
            entry.setProperty(PropertyStates.createProperty(DECLARING_NODE_TYPES, declaringNodeTypeNames, NAMES));
        }
        return entry;
    }

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

        if(isAlreadyRunning(store)){
            log.debug("Async job found to be already running. Skipping");
            return;
        }

        NodeBuilder builder = store.getRoot().builder();
        NodeBuilder async = builder.child(ASYNC);

        NodeState before = null;
        final PropertyState state = async.getProperty(name);
        if (state != null && state.getType() == STRING) {
            before = store.retrieve(state.getValue(STRING));
        }
        if (before == null) {
            before = MISSING_NODE;
        }

        AsyncUpdateCallback callback = new AsyncUpdateCallback();
        IndexUpdate indexUpdate = new IndexUpdate(provider, name, after,
                builder, callback);

        CommitFailedException exception = EditorDiff.process(indexUpdate,
                before, after);
        if (exception == null && callback.dirty) {
            async.setProperty(name, checkpoint);
            try {
                store.merge(builder, new CommitHook() {
                    @Override @Nonnull
                    public NodeState processCommit(NodeState before,
                            NodeState after) throws CommitFailedException {

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

            else {
                LOG.warn("Ignoring unknown conflict '" + conflictType + '\'');
            }
        }

        NodeBuilder conflictMarker = getConflictMarker(conflictType);
        if (conflictMarker != null) {
            assert conflictMarker.getChildNodeCount(1) == 0;
        }
    }
TOP
Copyright © 2018 www.massapi.com. 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.