Package org.apache.jackrabbit.spi

Examples of org.apache.jackrabbit.spi.Batch


    }

    private void createFile(Name fileName) throws RepositoryException, IOException {
        NodeId root = getNodeId(testPath);

        Batch b = rs.createBatch(si, root);
        b.addNode(root, fileName, NameConstants.NT_FILE, null);

        String filePath = testPath + "/" + fileName.getLocalName();
        NodeId file = getNodeId(filePath);
        b.addNode(file, NameConstants.JCR_CONTENT, NameConstants.NT_RESOURCE, null);

        NodeId content = getNodeId(filePath + "/" + NameConstants.JCR_CONTENT);
        b.addProperty(content, resolver.getQName(JcrConstants.JCR_LASTMODIFIED), lastModified);
        b.addProperty(content, resolver.getQName(JcrConstants.JCR_MIMETYPE), mimeType);
        b.addProperty(content, resolver.getQName(JcrConstants.JCR_ENCODING), enc);

        InputStream data = new ByteArrayInputStream("\u0633\u0634".getBytes("UTF-8"));
        b.addProperty(content, resolver.getQName(JcrConstants.JCR_DATA), rs.getQValueFactory().create(data));

        rs.submit(b);
    }
View Full Code Here


            super.tearDown();
        }
    }

    private void createTestNode(String testPath) throws RepositoryException {
        Batch b = rs.createBatch(si, getNodeId("/"));
        String name = Text.getName(testPath);
        b.addNode(getNodeId("/"), resolver.getQName(name), NameConstants.NT_UNSTRUCTURED, null);
        rs.submit(b);
    }
View Full Code Here

        b.addNode(getNodeId("/"), resolver.getQName(name), NameConstants.NT_UNSTRUCTURED, null);
        rs.submit(b);
    }

    private void removeTestNode(String path) throws RepositoryException {
        Batch b = rs.createBatch(si, getNodeId("/"));
        b.remove(getNodeId(path));
        rs.submit(b);
    }
View Full Code Here

        resolver = new DefaultNamePathResolver(nsResolver);
       
        try {
            rs.getNodeInfo(si, getNodeId(testPath));
        } catch (RepositoryException e) {
            Batch b = rs.createBatch(si, getNodeId("/"));
            b.addNode(getNodeId("/"), resolver.getQName("test"), NameConstants.NT_UNSTRUCTURED, null);
            rs.submit(b);
        }
    }
View Full Code Here

    }

    @Override
    protected void tearDown() throws Exception {
        try {
            Batch b = rs.createBatch(si, getNodeId("/"));
            b.remove(getNodeId(testPath));
            rs.submit(b);
        } finally {
            rs.dispose(si);
            super.tearDown();
        }
View Full Code Here

        }
    }

    public void testAddNode() throws RepositoryException {
        NodeId nid = getNodeId(testPath);
        Batch b = rs.createBatch(si, nid);

        b.addNode(nid, resolver.getQName("aNode"), NameConstants.NT_UNSTRUCTURED, null);
        b.addProperty(nid, resolver.getQName("aString"), rs.getQValueFactory().create("ba", PropertyType.STRING));
        b.addProperty(nid, resolver.getQName("aName"), new QValue[] {rs.getQValueFactory().create(NameConstants.JCR_ENCODING), rs.getQValueFactory().create(NameConstants.JCR_DATA)});
        b.addProperty(nid, resolver.getQName("aBinary"), rs.getQValueFactory().create(new byte[] { 'a', 'b', 'c'}));

        rs.submit(b);

        NodeId id = rs.getIdFactory().createNodeId(nid, resolver.getQPath("aNode"));
        Iterator<? extends ItemInfo> it = rs.getItemInfos(si, id);
        while (it.hasNext()) {
            ItemInfo info = it.next();
            if (info.denotesNode()) {
                NodeInfo nInfo = (NodeInfo) info;
                assertEquals(NameConstants.NT_UNSTRUCTURED, nInfo.getNodetype());
                Iterator<ChildInfo> childIt = nInfo.getChildInfos();
                assertTrue(childIt == null || !childIt.hasNext());
                assertEquals(id, nInfo.getId());
            }
        }

        b = rs.createBatch(si, nid);
        b.remove(id);
        rs.submit(b);
    }
View Full Code Here

        rs.submit(b);
    }

    public void testImport() throws RepositoryException {
        NodeId nid = getNodeId(testPath);
        Batch b = rs.createBatch(si, nid);

        String uuid = UUID.randomUUID().toString();
        b.addNode(nid, resolver.getQName("testUUIDNode"), NameConstants.NT_UNSTRUCTURED, uuid);

        NodeId id = getNodeId(testPath + "/testUUIDNode");
        b.setMixins(id, new Name[] {NameConstants.MIX_REFERENCEABLE});

        rs.submit(b);

        NodeInfo nInfo = rs.getNodeInfo(si, id);
        assertEquals(uuid, nInfo.getId().getUniqueID());
        Name[] mixins = nInfo.getMixins();
        assertEquals(1, mixins.length);
        assertEquals(NameConstants.MIX_REFERENCEABLE, mixins[0]);

        b = rs.createBatch(si, nid);
        b.remove(rs.getIdFactory().createNodeId(uuid));
        rs.submit(b);

        try {
            rs.getItemInfos(si, id);
            fail();
View Full Code Here

    }

    public void testSetMixin() throws RepositoryException {
        NodeId nid = getNodeId(testPath);

        Batch b = rs.createBatch(si, nid);
        b.addNode(nid, resolver.getQName("anyNode"), NameConstants.NT_UNSTRUCTURED, null);
        NodeId id = getNodeId(testPath + "/anyNode");
        b.setMixins(id, new Name[] {NameConstants.MIX_LOCKABLE});
        rs.submit(b);

        b = rs.createBatch(si, id);
        b.setMixins(id, new Name[0]);
        rs.submit(b);

        NodeInfo nInfo = rs.getNodeInfo(si, id);
        assertEquals(0, nInfo.getMixins().length);
    }
View Full Code Here

        resolver = new DefaultNamePathResolver(nsResolver);

        try {
            rs.getNodeInfo(si, getNodeId(testPath));
        } catch (RepositoryException e) {
            Batch b = rs.createBatch(si, getNodeId("/"));
            b.addNode(getNodeId("/"), resolver.getQName("test"), NameConstants.NT_UNSTRUCTURED, null);
            QValueFactory qvf = rs.getQValueFactory();
            b.addProperty(getNodeId("/test"), resolver.getQName("prop"), qvf.create("value", PropertyType.STRING));
            b.addProperty(getNodeId("/test"), resolver.getQName("propMV"), new QValue[] {qvf.create(1), qvf.create(2)});
            rs.submit(b);
        }
    }
View Full Code Here

    }

    @Override
    protected void tearDown() throws Exception {
        try {
            Batch b = rs.createBatch(si, getNodeId("/"));
            b.remove(getNodeId(testPath));
            rs.submit(b);
        } finally {
            rs.dispose(si);
            super.tearDown();
        }
View Full Code Here

TOP

Related Classes of org.apache.jackrabbit.spi.Batch

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.