Package org.apache.jackrabbit.mk.simple

Examples of org.apache.jackrabbit.mk.simple.NodeImpl$ChildVisitor


        JsopReader t = mk.getNodesStream(path, revisionId, depth, offset, count, filter);
        if (admin || t == null) {
            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
            n.append(buff, Integer.MAX_VALUE, 0, Integer.MAX_VALUE, true);
        }
        return buff;
    }
View Full Code Here


        for (long pos = 0;; pos++) {
            String childName = n.getChildNodeName(pos);
            if (childName == null) {
                break;
            }
            NodeImpl c = n.getNode(childName);
            NodeImpl c2 = filterAccess(PathUtils.concat(path, childName), c);
            if (c2 != c) {
                if (c2 == null) {
                    n = n.cloneAndRemoveChildNode(childName, 0);
                } else {
                    n = n.setChild(childName, c2, 0);
View Full Code Here

            return true;
        }
        boolean access = false;
        while (true) {
            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);
            }
            Boolean b = hasRights(n);
            if (b != null) {
View Full Code Here

        if (mk.nodeExists(MOUNT, head)) {
            String mounts = mk.getNodes(MOUNT, head, 1, 0, -1, null);
            NodeMap map = new NodeMap();
            JsopReader t = new JsopTokenizer(mounts);
            t.read('{');
            NodeImpl n = NodeImpl.parse(map, t, 0);
            for (long pos = 0;; pos++) {
                String childName = n.getChildNodeName(pos);
                if (childName == null) {
                    break;
                }
                NodeImpl mount = n.getNode(childName);
                String mountUrl = JsopTokenizer.decodeQuoted(mount.getProperty("url"));
                String[] paths = JsopTokenizer.decodeQuoted(mount.getProperty("paths")).split(",");
                addMount(childName, mountUrl, paths);
                getHeadRevision();
            }
        }
    }
View Full Code Here

            String path = PathUtils.relativize("/", PathUtils.concat(rootPath, t.readString()));
            switch (r) {
            case '+':
                t.read(':');
                if (t.matches('{')) {
                    NodeImpl n = NodeImpl.parse(map, t, 0);
                    JsopWriter diff = new JsopBuilder();
                    diff.tag('+').key(path);
                    n.append(diff, Integer.MAX_VALUE, 0, Integer.MAX_VALUE, false);
                    buffer(path, diff);
                } else {
                    String value = t.readRawValue().trim();
                    JsopWriter diff = new JsopBuilder();
                    diff.tag('+').key(path);
View Full Code Here

    public void inlineChildNodes() {
        NodeMap map = new NodeMap();
        map.setDescendantCount(true);
        map.setDescendantInlineCount(3);

        NodeImpl n = new NodeImpl(map, 0);
        Assert.assertEquals("{}", n.asString());
        NodeImpl a = new NodeImpl(map, 0);
        a.setProperty("name", "\"a\"");
        map.addNode(a);
        NodeImpl b = new NodeImpl(map, 0);
        b.setProperty("name", "\"b\"");
        map.addNode(b);
        NodeImpl c = new NodeImpl(map, 0);
        c.setProperty("name", "\"c\"");
        map.addNode(c);
        NodeImpl d = new NodeImpl(map, 0);
        d.setProperty("name", "\"d\"");
        map.addNode(d);
        n = n.cloneAndAddChildNode("a", false, null, a, 11);
        n = n.cloneAndSetProperty("x", "1", 12);
        n.setId(NodeId.get(3));
        Assert.assertEquals("n3={\"x\":1,\"a\":{\"name\":\"a\"}};", n.asString());
        NodeImpl n2 = NodeImpl.fromString(map, n.asString());
        Assert.assertEquals("n3={\"x\":1,\"a\":{\"name\":\"a\"}};", n2.asString());

        n = new NodeImpl(map, 0);
        n = n.cloneAndAddChildNode("a", false, null, a, 1);
        Assert.assertEquals("{\"a\":{\"name\":\"a\"}}", n.asString());
        n = n.cloneAndAddChildNode("b", false, null, b, 2);
        String ab = "{\"a\":{\"name\":\"a\"},\"b\":{\"name\":\"b\"}}";
        Assert.assertEquals(ab, n.asString());
        n = n.cloneAndAddChildNode("c", false, null, c, 3);
        String abc = "{\"a\":{\"name\":\"a\"},\"b\":{\"name\":\"b\"},\"c\":{\"name\":\"c\"}}";
        Assert.assertEquals(abc, n.asString());
        Assert.assertEquals(3, n.getDescendantCount());
        Assert.assertEquals(3, n.getDescendantInlineCount());
        n2 = NodeImpl.fromString(map, n.asString());
        Assert.assertTrue(n2.exists("a"));
        Assert.assertTrue(n2.exists("b"));
        Assert.assertTrue(n2.exists("c"));
        Assert.assertEquals(3, n2.getDescendantCount());
        Assert.assertEquals(3, n2.getDescendantInlineCount());

        NodeImpl root = new NodeImpl(map, 0);
        root = root.cloneAndAddChildNode("test", false, null, n2, 1);
        Assert.assertEquals("{\":size\":4,\"test\":n1}", root.asString());
        Assert.assertEquals(0, root.getDescendantInlineCount());

        n2 = n2.cloneAndRemoveChildNode("c", 4);
        root = new NodeImpl(map, 0);
        root = root.cloneAndAddChildNode("test", false, null, n2, 1);
        Assert.assertEquals("{\":size\":3,\"test\":" + ab + "}", root.asString());

    }
View Full Code Here

        }
        int i = 0;
        String last = first;
        for (String rev : revs) {
            String n = mk.getNodes("/test", rev, 1, 0, -1, null);
            NodeImpl node = NodeImpl.parse(n);
            assertEquals(i, Integer.parseInt(node.getProperty("id")));
            String journal = mk.getJournal(last, rev, null);
            JsopArray array = (JsopArray) Jsop.parse(journal);
            assertEquals(last + ".." + rev + ": " + journal,
                    2, array.size());
            JsopObject obj = (JsopObject) array.get(0);
View Full Code Here

        if (count >= totalCount) {
            return;
        }

        String parentJson = JsopBuilder.prettyPrint(mk.getNodes("/" + parent, mk.getHeadRevision(), 1, 0, -1, null));
        NodeImpl parentNode = NodeImpl.parse(parentJson);
        int width = Integer.parseInt(parentNode.getProperty("width"));

        for (int i = 0; i < width; i++) {
            if (count >= totalCount) {
                break;
            }
View Full Code Here

    public void setUp() throws Exception {
        mk = MicroKernelFactory.getInstance(url + ";clean");
        cleanRepository(mk);

        String root = mk.getNodes("/", mk.getHeadRevision(), 1, 0, -1, null);
        NodeImpl rootNode = NodeImpl.parse(root);
        if (rootNode.getPropertyCount() > 0) {
            System.out.println("Last mk not disposed: " + root);
        }
        if (rootNode.getChildNodeNames(Integer.MAX_VALUE).hasNext()) {
            System.out.println("Last mk not disposed: " + root);
        }
        if (PROFILE) {
            prof = new Profiler();
            prof.interval = 1;
View Full Code Here

            return;
        }

        head = mk.commit("/", "+ \"test1\": { \"id\": 1 }", mk.getHeadRevision(), "");
        head = mk.commit("/", "+ \"test2\": { \"id\": 1 }", mk.getHeadRevision(), "");
        NodeImpl r = NodeImpl.parse(mk.getNodes("/", head, 1, 0, -1, null));
        assertTrue(r.getHash() != null);
        NodeImpl t1 = NodeImpl.parse(mk.getNodes("/test1", head, 1, 0, -1, null));
        NodeImpl t2 = NodeImpl.parse(mk.getNodes("/test2", head, 1, 0, -1, null));
        assertTrue(Arrays.equals(t1.getHash(), t2.getHash()));
        assertFalse(Arrays.equals(t1.getHash(), r.getHash()));
    }
View Full Code Here

TOP

Related Classes of org.apache.jackrabbit.mk.simple.NodeImpl$ChildVisitor

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.