Search in sources :

Example 11 with NodeId

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

the class BatchTest method testSetBinaryValue.

public void testSetBinaryValue() throws RepositoryException, IOException {
    NodeId nid = getNodeId(testPath);
    Name propName = resolver.getQName("binProp");
    Batch b = rs.createBatch(si, nid);
    b.addProperty(nid, propName, rs.getQValueFactory().create(new byte[] { 'a', 'b', 'c' }));
    rs.submit(b);
    PropertyInfo pi = rs.getPropertyInfo(si, getPropertyId(nid, propName));
    assertFalse(pi.isMultiValued());
    assertEquals("abc", pi.getValues()[0].getString());
    assertEquals(PropertyType.BINARY, pi.getType());
}
Also used : Batch(org.apache.jackrabbit.spi.Batch) NodeId(org.apache.jackrabbit.spi.NodeId) PropertyInfo(org.apache.jackrabbit.spi.PropertyInfo) Name(org.apache.jackrabbit.spi.Name)

Example 12 with NodeId

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

the class BatchTest method testSetEmptyBinaryValues.

public void testSetEmptyBinaryValues() 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[0]), rs.getQValueFactory().create(new byte[0]), rs.getQValueFactory().create(new byte[0]) };
    b.addProperty(nid, propName, vs);
    rs.submit(b);
    PropertyInfo pi = rs.getPropertyInfo(si, getPropertyId(nid, propName));
    assertTrue(pi.isMultiValued());
    vs = pi.getValues();
    assertEquals("", vs[0].getString());
    assertEquals("", vs[1].getString());
    assertEquals("", vs[2].getString());
    assertEquals(PropertyType.BINARY, pi.getType());
    pi = getPropertyInfo(nid, propName);
    vs = pi.getValues();
    assertEquals("", vs[0].getString());
    assertEquals("", vs[1].getString());
    assertEquals("", 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)

Example 13 with NodeId

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

the class BatchTest method testReorder1.

public void testReorder1() throws RepositoryException {
    NodeId nid = getNodeId(testPath);
    Batch b = rs.createBatch(si, nid);
    b.addNode(nid, resolver.getQName("2"), NameConstants.NT_UNSTRUCTURED, null);
    b.addNode(nid, resolver.getQName("3"), NameConstants.NT_UNSTRUCTURED, null);
    b.addNode(nid, resolver.getQName("1"), NameConstants.NT_UNSTRUCTURED, null);
    rs.submit(b);
    b = rs.createBatch(si, nid);
    b.reorderNodes(nid, getNodeId(testPath + "/1"), getNodeId(testPath + "/2"));
    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 14 with NodeId

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

the class BatchTest method testSetPathValue.

public void testSetPathValue() throws RepositoryException {
    NodeId nid = getNodeId(testPath);
    Name propName = resolver.getQName("pathProp");
    QValue v = rs.getQValueFactory().create(resolver.getQPath(testPath));
    Batch b = rs.createBatch(si, nid);
    b.addProperty(nid, propName, v);
    rs.submit(b);
    PropertyInfo pi = rs.getPropertyInfo(si, getPropertyId(nid, propName));
    assertFalse(pi.isMultiValued());
    assertEquals(v, pi.getValues()[0]);
    assertEquals(PropertyType.PATH, pi.getType());
    pi = getPropertyInfo(nid, propName);
    assertEquals(v.getPath(), pi.getValues()[0].getPath());
    assertEquals(v, pi.getValues()[0]);
    assertEquals(PropertyType.PATH, 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)

Example 15 with NodeId

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

the class BatchTest method testSetBooleanValue.

public void testSetBooleanValue() throws RepositoryException {
    NodeId nid = getNodeId(testPath);
    Name propName = resolver.getQName("booleanProp");
    QValue v = rs.getQValueFactory().create(false);
    Batch b = rs.createBatch(si, nid);
    b.addProperty(nid, propName, v);
    rs.submit(b);
    PropertyInfo pi = rs.getPropertyInfo(si, getPropertyId(nid, propName));
    assertFalse(pi.isMultiValued());
    assertFalse(pi.getValues()[0].getBoolean());
    assertEquals(PropertyType.BOOLEAN, pi.getType());
    pi = getPropertyInfo(nid, propName);
    assertFalse(pi.getValues()[0].getBoolean());
    assertEquals(PropertyType.BOOLEAN, 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