Package org.apache.jackrabbit.oak.api

Examples of org.apache.jackrabbit.oak.api.PropertyState


        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 {
                        // check for concurrent updates by this async task
                        PropertyState stateAfterRebase = before
                                .getChildNode(ASYNC).getProperty(name);
                        if (Objects.equal(state, stateAfterRebase)) {
                            return postAsyncRunStatus(after.builder(), indexStats)
                                    .getNodeState();
                        } else {
View Full Code Here


     * @param tree the tree to check.
     * @return whether the tree is checked out or not.
     */
    public boolean isCheckedOut(@Nonnull Tree tree) {
        if (checkNotNull(tree).exists()) {
            PropertyState p = tree.getProperty(VersionConstants.JCR_ISCHECKEDOUT);
            if (p != null) {
                return p.getValue(Type.BOOLEAN);
            }
        } else {
            // FIXME: this actually means access to the tree is restricted
            // and may result in wrong isCheckedOut value. This should never
            // be the case in a commit hook because it operates on non-access-
View Full Code Here

    private void resolveConflict(ConflictType conflictType, NodeState conflictInfo) {
        PropertyConflictHandler propertyConflictHandler = propertyConflictHandlers.get(conflictType);
        if (propertyConflictHandler != null) {
            for (PropertyState ours : conflictInfo.getProperties()) {
                PropertyState theirs = parent.getProperty(ours.getName());
                Resolution resolution = propertyConflictHandler.resolve(ours, theirs);
                applyResolution(resolution, conflictType, ours);
            }
        }
        else {
View Full Code Here

            return false;
        }

        //Check if already running or timed out
        if (STATUS_RUNNING.equals(indexState.getString("async-status"))) {
            PropertyState startTime = indexState.getProperty("async-start");
            Calendar start = Conversions.convert(startTime.getValue(Type.DATE)).toCalendar();
            Calendar now = Calendar.getInstance();
            long delta = now.getTimeInMillis() - start.getTimeInMillis();

            //Check if the job has timed out and we need to take over
            if (TimeUnit.MILLISECONDS.toMinutes(delta) > ASYNC_TIMEOUT) {
                log.info("Async job found which stated on {} has timed out in {} minutes. " +
                        "This node would take over the job.",
                        startTime.getValue(Type.DATE), ASYNC_TIMEOUT);
                return false;
            }
            return true;
        }
View Full Code Here

        }
    );

    private static void addChild(NodeBuilder target, String name, NodeState state) {
        target.setChildNode(name, state);
        PropertyState childOrder = target.getProperty(AbstractTree.OAK_CHILD_ORDER);
        if (childOrder != null) {
            PropertyBuilder<String> builder = PropertyBuilder.copy(NAME, childOrder);
            builder.addValue(name);
            target.setProperty(builder.getPropertyState());
        }
View Full Code Here

    @CheckForNull
    public Tree getBaseVersion(@Nonnull Tree versionable)
            throws UnsupportedRepositoryOperationException,
            RepositoryException {
        checkVersionable(versionable);
        PropertyState p = versionable.getProperty(VersionConstants.JCR_BASEVERSION);
        if (p == null) {
            // version history does not yet exist
            return null;
        }
        return getIdentifierManager().getTree(p.getValue(Type.STRING));
    }
View Full Code Here

        }
    }

    private static void removeChild(NodeBuilder target, String name) {
        target.getChildNode(name).remove();
        PropertyState childOrder = target.getProperty(AbstractTree.OAK_CHILD_ORDER);
        if (childOrder != null) {
            PropertyBuilder<String> builder = PropertyBuilder.copy(NAME, childOrder);
            builder.removeValue(name);
            target.setProperty(builder.getPropertyState());
        }
View Full Code Here

        NodeState fallback = null;

        NodeState state = node.getChildNode(INDEX_DEFINITIONS_NAME);
        for (ChildNodeEntry entry : state.getChildNodeEntries()) {
            NodeState index = entry.getNodeState();
            PropertyState type = index.getProperty(TYPE_PROPERTY_NAME);
            if (type == null || type.isArray() || !TYPE.equals(type.getValue(Type.STRING))) {
                continue;
            }
            if (contains(index.getNames(PROPERTY_NAMES), propertyName)) {
                NodeState indexContent = index.getChildNode(INDEX_CONTENT_NODE_NAME);
                if (!indexContent.exists()) {
View Full Code Here

        return safeGet(getNamespaceTree(root).getChild(REP_NSDATA), REP_PREFIXES);
    }

    public static String getNamespacePrefix(Tree root, String uri) {
        Tree namespaces = getNamespaceTree(root);
        PropertyState ps = namespaces.getChild(REP_NSDATA)
                .getProperty(encodeUri(escapePropertyKey(uri)));
        if (ps != null) {
            return ps.getValue(STRING);
        }
        return null;
    }
View Full Code Here

        return uris.toArray(new String[uris.size()]);
    }

    public static String getNamespaceURI(Tree root, String prefix) {
        if (isValidPrefix(prefix)) {
            PropertyState property = getNamespaceTree(root).getProperty(
                    escapePropertyKey(prefix));
            if (property != null && STRING.equals(property.getType())) {
                return property.getValue(STRING);
            }
        }
        return null;
    }
View Full Code Here

TOP

Related Classes of org.apache.jackrabbit.oak.api.PropertyState

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.