Package org.apache.jackrabbit.mk.json

Examples of org.apache.jackrabbit.mk.json.JsopTokenizer


        if (isInIndex(path)) {
            return;
        }
        // TODO add: support large child node lists
        String node = mk.getNodes(path, readRevision, 0, 0, Integer.MAX_VALUE, null);
        JsopTokenizer t = new JsopTokenizer(node);
        NodeMap map = new NodeMap();
        t.read('{');
        NodeImpl n = NodeImpl.parse(map, t, 0, path);
        index.addOrRemoveNode(n, true);
        for (Iterator<String> it = n.getChildNodeNames(Integer.MAX_VALUE); it.hasNext();) {
            addRecursive(index, PathUtils.concat(path, it.next()));
        }
View Full Code Here


*/
public abstract class MicroKernelWrapperBase implements MicroKernel, MicroKernelWrapper {

    @Override
    public final String commit(String path, String jsonDiff, String revisionId, String message) {
        return commitStream(path, new JsopTokenizer(jsonDiff), revisionId, message);
    }
View Full Code Here

                return wrapped.commit(path, jsonDiff.toString(), revisionId, message);
            }

            @Override
            public JsopReader getJournalStream(String fromRevisionId, String toRevisionId, String filter) {
                return new JsopTokenizer(wrapped.getJournal(fromRevisionId, toRevisionId, filter));
            }

            @Override
            public JsopReader getNodesStream(String path, String revisionId) {
                String json = wrapped.getNodes(path, revisionId);
                if (json != null) {
                    return new JsopTokenizer(json);
                } else {
                    return null;
                }
            }

            @Override
            public JsopReader getNodesStream(String path, String revisionId, int depth, long offset, int count, String filter) {
                String json = wrapped.getNodes(
                        path, revisionId, depth, offset, count, filter);
                if (json != null) {
                    return new JsopTokenizer(json);
                } else {
                    return null;
                }
            }

            @Override
            public JsopReader getRevisionsStream(long since, int maxEntries) {
                return new JsopTokenizer(wrapped.getRevisionHistory(since, maxEntries));
            }

            @Override
            public JsopReader diffStream(String fromRevisionId, String toRevisionId, String path) {
                return new JsopTokenizer(wrapped.diff(fromRevisionId, toRevisionId, path));
            }

            @Override
            public String commit(String path, String jsonDiff, String revisionId, String message) {
                return wrapped.commit(path, jsonDiff, revisionId, message);
View Full Code Here

            addOrRemoveRaw(nodePath, value, add);
        }
    }

    private void addOrRemoveRaw(String nodePath, String value, boolean add) {
        JsopTokenizer t = new JsopTokenizer(value);
        if (t.matches(JsopReader.STRING) || t.matches(JsopReader.NUMBER)) {
            String v = t.getToken();
            addOrRemove(nodePath, v, add);
        }
    }
View Full Code Here

        pairs[index + 1] = StringCache.cache(value);
        return pairs;
    }

    public static NodeImpl parse(String json) {
        JsopTokenizer t = new JsopTokenizer(json);
        t.read('{');
        NodeMap map = new NodeMap();
        return NodeImpl.parse(map, t, 0);
    }
View Full Code Here

        }
        return json.toString();
    }

    public static NodeImpl fromString(NodeMap map, String s) {
        JsopTokenizer t = new JsopTokenizer(s);
        NodeImpl node = new NodeImpl(map, 0);
        if (!t.matches('{')) {
            node.id = map.parseId(t.readRawValue());
            t.read('=');
            t.read('{');
        }
        boolean descendantCountSet = false;
        if (!t.matches('}')) {
            do {
                String key = t.readString();
                t.read(':');
                String value = t.readRawValue();
                if (key.length() > 0 && key.charAt(0) == ':') {
                    if (key.equals(CHILDREN)) {
                        node.childNodes = NodeListTrie.read(t, map, value);
                    } else if (key.equals(DESCENDANT_COUNT)) {
                        node.descendantCount = Long.parseLong(value);
                        descendantCountSet = true;
                    } else if (key.equals(HASH)) {
                        node.id.setHash(StringUtils.convertHexToBytes(JsopTokenizer.decodeQuoted(value)));
                    } else {
                        node.setProperty(key, value);
                    }
                } else if (map.isId(value)) {
                    if (node.childNodes == null) {
                        node.childNodes = new NodeListSmall();
                    }
                    NodeId id = map.parseId(value);
                    node.childNodes.add(key, id);
                    if (!descendantCountSet) {
                        node.descendantCount++;
                    }
                    if (id.isInline()) {
                        if (!descendantCountSet) {
                            node.descendantCount += id.getNode(map).descendantCount;
                        }
                        node.descendantInlineCount += 1 + id.getNode(map).descendantInlineCount;
                    }
                } else {
                    node.setProperty(key, value);
                }
            } while (t.matches(','));
            t.read('}');
        }
        return node;
    }
View Full Code Here

    private void init() {
        if (list != null) {
            return;
        }
        tokenizer = new JsopTokenizer(jsop, start);
        tokenizer.read('[');
        if (tokenizer.matches(']')) {
            list = EMPTY_LIST;
            tokenizer = null;
        } else {
View Full Code Here

        this.mk = MicroKernelWrapperBase.wrap(mk);
        // TODO security for the index mechanism

        String role = mk.getNodes("/:user/" + user, mk.getHeadRevision());
        NodeMap map = new NodeMap();
        JsopReader t = new JsopTokenizer(role);
        t.read('{');
        NodeImpl n = NodeImpl.parse(map, t, 0);
        String password = JsopTokenizer.decodeQuoted(n.getProperty("password"));
        if (!pass.equals(password)) {
            throw ExceptionFactory.get("Wrong password");
        }
View Full Code Here

        if (admin) {
            return t;
        }
        t.read('[');
        if (t.matches(']')) {
            return new JsopTokenizer("[]");
        }
        JsopStream buff = new JsopStream();
        buff.array();
        String revision = fromRevisionId;
        do {
            t.read('{');
            buff.object();
            do {
                String key = t.readString();
                buff.key(key);
                t.read(':');
                if (key.equals("id")) {
                    t.read();
                    String value = t.getToken();
                    revision = value;
                    buff.value(value);
                } else if (key.equals("changes")) {
                    t.read();
                    String value = t.getToken();
                    value = filterDiff(new JsopTokenizer(value), revision).toString();
                    buff.value(value);
                } else {
                    String raw = t.readRawValue();
                    //System.out.println(key + ":" + raw);
                    buff.encodedValue(raw);
View Full Code Here

            String key = path + "@" + rightsRevision;
            NodeImpl n = cache.get(key);
            if (n == null) {
                if (mk.nodeExists(path, rightsRevision)) {
                    String json = mk.getNodes(path, rightsRevision, 0, 0, 0, null);
                    JsopReader t = new JsopTokenizer(json);
                    t.read('{');
                    n = NodeImpl.parse(map, t, 0);
                } else {
                    n = new NodeImpl(map, 0);
                }
                cache.put(key, n);
View Full Code Here

TOP

Related Classes of org.apache.jackrabbit.mk.json.JsopTokenizer

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.