Examples of JsopStream


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

    @Override
    public JsopReader diffStream(String fromRevisionId, String toRevisionId, String path, int depth) {
        fromRevisionId = fromRevisionId == null ? headRevision : fromRevisionId;
        toRevisionId = toRevisionId == null ? headRevision : toRevisionId;
        // TODO implement if required
        return new JsopStream();
    }
View Full Code Here

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

            n = getRevisionDataRoot(revisionId).getNode(path.substring(1));
        }
        if (n == null) {
            return null;
        }
        JsopStream json = new JsopStream();
        n.append(json, depth, offset, count, true);
        return json;
    }
View Full Code Here

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

            // not a query (expected: /index/prefix:x?y) - treat as regular node lookup
            return mk.getNodesStream(path, revisionId, depth, offset, count, filter);
        }
        String data = index.substring(idx + 1);
        index = index.substring(0, idx);
        JsopStream s = new JsopStream();
        s.array();
        if (index.startsWith(Indexer.TYPE_PREFIX)) {
            String prefix = index.substring(Indexer.TYPE_PREFIX.length());
            PrefixIndex prefixIndex = indexer.getPrefixIndex(prefix);
            if (prefixIndex == null) {
                throw ExceptionFactory.get("Unknown index: " + index);
            }
            Iterator<String> it = prefixIndex.getPaths(data, revisionId);
            while (it.hasNext()) {
                s.value(it.next());
            }
        } else if (index.startsWith(Indexer.TYPE_PROPERTY)) {
            String property = index.substring(Indexer.TYPE_PROPERTY.length());
            boolean unique = false;
            if (property.endsWith("," + Indexer.UNIQUE)) {
                unique = true;
                property = property.substring(0, property.length() - Indexer.UNIQUE.length() - 1);
            }
            PropertyIndex propertyIndex = indexer.getPropertyIndex(property);
            if (propertyIndex == null) {
                throw ExceptionFactory.get("Unknown index: " + index);
            }
            if (unique) {
                String value = propertyIndex.getPath(data, revisionId);
                if (value != null) {
                    s.value(value);
                }
            } else {
                Iterator<String> it = propertyIndex.getPaths(data, revisionId);
                while (it.hasNext()) {
                    s.value(it.next());
                }
            }
        }
        s.endArray();
        return s;
    }
View Full Code Here

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

        }
        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);
                }
            } while (t.matches(','));
            buff.endObject();
            t.read('}');
        } while (t.matches(','));
        buff.endArray();
        return buff;
    }
View Full Code Here

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

        }
        return filterDiff(diff, toRevisionId);
    }

    private JsopReader filterDiff(JsopReader t, String revisionId) {
        JsopStream buff = new JsopStream();
        verifyDiff(t, revisionId, null, buff);
        return buff;
    }
View Full Code Here

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

            return t;
        }
        t.read('{');
        NodeImpl n = NodeImpl.parse(map, t, 0);
        n = filterAccess(path, n);
        JsopStream buff = new JsopStream();
        if (n == null) {
            return null;
        } else {
            // TODO childNodeCount properties might be wrong
            // when count and offset are used
View Full Code Here

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

        Revision rev = Revision.fromString(revisionId);
        Node n = nodeStore.getNode(path, rev);
        if (n == null) {
            return null;
        }
        JsopStream json = new JsopStream();
        boolean includeId = filter != null && filter.contains(":id");
        includeId |= filter != null && filter.contains(":hash");
        json.object();
        n.append(json, includeId);
        int max;
        if (maxChildNodes == -1) {
            max = Integer.MAX_VALUE;
            maxChildNodes = Integer.MAX_VALUE;
        } else {
            // use long to avoid overflows
            long m = ((long) maxChildNodes) + offset;
            max = (int) Math.min(m, Integer.MAX_VALUE);
        }
        Children c = nodeStore.getChildren(n, null, max);
        for (long i = offset; i < c.children.size(); i++) {
            if (maxChildNodes-- <= 0) {
                break;
            }
            String name = PathUtils.getName(c.children.get((int) i));
            json.key(name).object().endObject();
        }
        if (c.hasMore) {
            // TODO use a better way to notify there are more children
            json.key(":childNodeCount").value(Long.MAX_VALUE);
        } else {
            json.key(":childNodeCount").value(c.children.size());
        }
        json.endObject();
        return json.toString();
    }
View Full Code Here

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

            // not a query (expected: /index/prefix:x?y) - treat as regular node lookup
            return mk.getNodesStream(path, revisionId, depth, offset, count, filter);
        }
        String data = index.substring(idx + 1);
        index = index.substring(0, idx);
        JsopStream s = new JsopStream();
        s.array();
        if (index.startsWith(PropertyIndexConstants.TYPE_PREFIX)) {
            String prefix = index.substring(PropertyIndexConstants.TYPE_PREFIX.length());
            PrefixIndex prefixIndex = indexer.getPrefixIndex(prefix);
            if (prefixIndex == null) {
                throw ExceptionFactory.get("Unknown index: " + index);
            }
            Iterator<String> it = prefixIndex.getPaths(data, revisionId);
            while (it.hasNext()) {
                s.value(it.next());
            }
        } else if (index.startsWith(PropertyIndexConstants.TYPE_PROPERTY)) {
            String property = index.substring(PropertyIndexConstants.TYPE_PROPERTY.length());
            boolean unique = false;
            if (property.endsWith("," + PropertyIndexConstants.UNIQUE)) {
                unique = true;
                property = property.substring(0, property.length() - PropertyIndexConstants.UNIQUE.length() - 1);
            }
            PropertyIndex propertyIndex = indexer.getPropertyIndex(property);
            if (propertyIndex == null) {
                throw ExceptionFactory.get("Unknown index: " + index);
            }
            if (unique) {
                String value = propertyIndex.getPath(data, revisionId);
                if (value != null) {
                    s.value(value);
                }
            } else {
                Iterator<String> it = propertyIndex.getPaths(data, revisionId);
                while (it.hasNext()) {
                    s.value(it.next());
                }
            }
        }
        s.endArray();
        return s;
    }
View Full Code Here

Examples of org.apache.jackrabbit.oak.commons.json.JsopStream

            c.children.addAll(set);
            nodeChildrenCache.put(key, c);
        } else if (!isDelete) {
            // update diff cache for modified nodes
            PathRev key = diffCacheKey(path, before, rev);
            JsopWriter w = new JsopStream();
            for (String p : added) {
                w.tag('+').key(p).object().endObject().newline();
            }
            for (String p : removed) {
                w.tag('-').value(p).newline();
            }
            for (String p : changed) {
                w.tag('^').key(p).object().endObject().newline();
            }
            diffCache.put(key, new StringValue(w.toString()));
        }
        // update docChildrenCache
        if (!added.isEmpty()) {
            CacheValue docChildrenKey = new StringValue(path);
            NodeDocument.Children docChildren = docChildrenCache.getIfPresent(docChildrenKey);
View Full Code Here

Examples of org.apache.jackrabbit.oak.commons.json.JsopStream

                    path, fromRev, from != null, toRev, to != null);
            throw new MicroKernelException(msg);
        }
        PathRev key = diffCacheKey(path, fromRev, toRev);
        try {
            JsopWriter writer = new JsopStream();
            diffProperties(from, to, writer);
            return writer.toString() + diffCache.get(key, new Callable<StringValue>() {
                @Override
                public StringValue call() throws Exception {
                    return new StringValue(diffImpl(from, to));
                }
            });
View Full Code Here
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.