Search in sources :

Example 56 with NodeId

use of org.apache.jackrabbit.spi.NodeId in project jackrabbit by apache.

the class BatchTest method testEmptyValueArray2.

public void testEmptyValueArray2() throws RepositoryException {
    NodeId nid = getNodeId(testPath);
    Name propName = resolver.getQName("mvProperty");
    Batch b = rs.createBatch(si, nid);
    b.addProperty(nid, propName, new QValue[] { rs.getQValueFactory().create(true) });
    rs.submit(b);
    PropertyId pid = getPropertyId(nid, propName);
    b = rs.createBatch(si, pid);
    b.setValue(pid, new QValue[0]);
    rs.submit(b);
    PropertyInfo pi = rs.getPropertyInfo(si, pid);
    assertTrue(pi.isMultiValued());
    assertEquals(Arrays.asList(new QValue[0]), Arrays.asList(pi.getValues()));
}
Also used : QValue(org.apache.jackrabbit.spi.QValue) Batch(org.apache.jackrabbit.spi.Batch) NodeId(org.apache.jackrabbit.spi.NodeId) PropertyInfo(org.apache.jackrabbit.spi.PropertyInfo) Name(org.apache.jackrabbit.spi.Name) PropertyId(org.apache.jackrabbit.spi.PropertyId)

Example 57 with NodeId

use of org.apache.jackrabbit.spi.NodeId in project jackrabbit by apache.

the class BatchTest method testUseConsumedBatch.

public void testUseConsumedBatch() throws RepositoryException {
    NodeId nid = getNodeId(testPath);
    Batch b = rs.createBatch(si, nid);
    b.addProperty(nid, resolver.getQName("any"), rs.getQValueFactory().create(1.34));
    rs.submit(b);
    try {
        b.remove(nid);
        rs.submit(b);
        fail();
    } catch (IllegalStateException e) {
    // success
    }
}
Also used : Batch(org.apache.jackrabbit.spi.Batch) NodeId(org.apache.jackrabbit.spi.NodeId)

Example 58 with NodeId

use of org.apache.jackrabbit.spi.NodeId in project jackrabbit by apache.

the class BatchTest method testBinary.

public void testBinary() throws RepositoryException, IOException {
    NodeId nid = getNodeId(testPath);
    Name propName = resolver.getQName("binProp");
    Batch b = rs.createBatch(si, nid);
    ClassLoader loader = getClass().getClassLoader();
    InputStream in = loader.getResourceAsStream("org/apache/jackrabbit/spi/spi2davex/image.bmp");
    if (in != null) {
        try {
            QValue v = rs.getQValueFactory().create(in);
            b.addProperty(nid, propName, v);
            rs.submit(b);
            PropertyInfo pi = rs.getPropertyInfo(si, getPropertyId(nid, propName));
            String str1 = pi.getValues()[0].getString();
            pi = getPropertyInfo(nid, propName);
            String str2 = pi.getValues()[0].getString();
            assertEquals(str1, str2);
        } finally {
            in.close();
        }
    }
}
Also used : QValue(org.apache.jackrabbit.spi.QValue) Batch(org.apache.jackrabbit.spi.Batch) InputStream(java.io.InputStream) NodeId(org.apache.jackrabbit.spi.NodeId) PropertyInfo(org.apache.jackrabbit.spi.PropertyInfo) Name(org.apache.jackrabbit.spi.Name)

Example 59 with NodeId

use of org.apache.jackrabbit.spi.NodeId in project jackrabbit by apache.

the class BatchTest method testReorder.

public void testReorder() throws RepositoryException {
    NodeId nid = getNodeId(testPath);
    Batch b = rs.createBatch(si, nid);
    b.addNode(nid, resolver.getQName("1"), NameConstants.NT_UNSTRUCTURED, null);
    b.addNode(nid, resolver.getQName("3"), NameConstants.NT_UNSTRUCTURED, null);
    b.addNode(nid, resolver.getQName("2"), NameConstants.NT_UNSTRUCTURED, null);
    rs.submit(b);
    b = rs.createBatch(si, nid);
    b.reorderNodes(nid, getNodeId(testPath + "/3"), null);
    rs.submit(b);
    Iterator<ChildInfo> it = rs.getChildInfos(si, nid);
    int i = 1;
    while (it.hasNext()) {
        ChildInfo ci = it.next();
        assertEquals(i, Integer.parseInt(ci.getName().getLocalName()));
        i++;
    }
}
Also used : Batch(org.apache.jackrabbit.spi.Batch) NodeId(org.apache.jackrabbit.spi.NodeId) ChildInfo(org.apache.jackrabbit.spi.ChildInfo)

Example 60 with NodeId

use of org.apache.jackrabbit.spi.NodeId in project jackrabbit by apache.

the class BatchTest method testSetBinaryValues.

public void testSetBinaryValues() throws RepositoryException, IOException {
    NodeId nid = getNodeId(testPath);
    Name propName = resolver.getQName("binPropMV");
    Batch b = rs.createBatch(si, nid);
    QValue[] vs = new QValue[] { rs.getQValueFactory().create(new byte[] { 'a', 'b', 'c' }), rs.getQValueFactory().create(new byte[] { 'd', 'e', 'f' }), rs.getQValueFactory().create(new byte[] { 'g', 'h', 'i' }) };
    b.addProperty(nid, propName, vs);
    rs.submit(b);
    PropertyInfo pi = rs.getPropertyInfo(si, getPropertyId(nid, propName));
    assertTrue(pi.isMultiValued());
    vs = pi.getValues();
    assertEquals("abc", vs[0].getString());
    assertEquals("def", vs[1].getString());
    assertEquals("ghi", vs[2].getString());
    assertEquals(PropertyType.BINARY, pi.getType());
    pi = getPropertyInfo(nid, propName);
    vs = pi.getValues();
    assertEquals("abc", vs[0].getString());
    assertEquals("def", vs[1].getString());
    assertEquals("ghi", vs[2].getString());
    assertEquals(PropertyType.BINARY, pi.getType());
}
Also used : QValue(org.apache.jackrabbit.spi.QValue) Batch(org.apache.jackrabbit.spi.Batch) NodeId(org.apache.jackrabbit.spi.NodeId) PropertyInfo(org.apache.jackrabbit.spi.PropertyInfo) Name(org.apache.jackrabbit.spi.Name)

Aggregations

NodeId (org.apache.jackrabbit.spi.NodeId)80 Batch (org.apache.jackrabbit.spi.Batch)35 Name (org.apache.jackrabbit.spi.Name)32 PropertyInfo (org.apache.jackrabbit.spi.PropertyInfo)23 RepositoryException (javax.jcr.RepositoryException)21 QValue (org.apache.jackrabbit.spi.QValue)21 PropertyId (org.apache.jackrabbit.spi.PropertyId)13 Path (org.apache.jackrabbit.spi.Path)11 NodeInfo (org.apache.jackrabbit.spi.NodeInfo)10 ArrayList (java.util.ArrayList)9 ItemNotFoundException (javax.jcr.ItemNotFoundException)9 DavPropertyNameSet (org.apache.jackrabbit.webdav.property.DavPropertyNameSet)9 IOException (java.io.IOException)6 Node (javax.jcr.Node)5 HttpResponse (org.apache.http.HttpResponse)5 ItemId (org.apache.jackrabbit.spi.ItemId)5 DavException (org.apache.jackrabbit.webdav.DavException)5 InputStream (java.io.InputStream)4 ChildInfo (org.apache.jackrabbit.spi.ChildInfo)4 PathNotFoundException (javax.jcr.PathNotFoundException)3