Search in sources :

Example 16 with PropertyInfo

use of org.apache.jackrabbit.spi.PropertyInfo 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 17 with PropertyInfo

use of org.apache.jackrabbit.spi.PropertyInfo 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 18 with PropertyInfo

use of org.apache.jackrabbit.spi.PropertyInfo 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)

Example 19 with PropertyInfo

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

the class BatchTest method testSetStringValue.

public void testSetStringValue() throws RepositoryException {
    NodeId nid = getNodeId(testPath);
    Name propName = resolver.getQName("stringProp");
    QValueFactory vf = rs.getQValueFactory();
    List<String> l = new ArrayList<String>();
    l.add("String value containing \"double quotes\" and \'single\' and \"undeterminated quote.");
    l.add("String value \ncontaining \n\rline \r\nseparators and \t tab.");
    l.add("String value containing \r\n\r\r\n\r\n multiple \r\n\r\n line separators in sequence.");
    l.add("String value containing >diff -char +act ^ters.");
    l.add("String value containing \n>line sep \r+and \r\n-diff\n\r^chars.");
    l.add("String value containing سش unicode chars.");
    for (String val : l) {
        QValue v = vf.create(val, PropertyType.STRING);
        Batch b = rs.createBatch(si, nid);
        b.addProperty(nid, propName, v);
        rs.submit(b);
        PropertyInfo pi = getPropertyInfo(nid, propName);
        assertEquals(v, pi.getValues()[0]);
        assertEquals(v.getString(), pi.getValues()[0].getString());
        assertEquals(PropertyType.STRING, pi.getType());
        pi = rs.getPropertyInfo(si, getPropertyId(nid, propName));
        assertEquals(v, pi.getValues()[0]);
        assertEquals(v.getString(), pi.getValues()[0].getString());
        assertEquals(PropertyType.STRING, pi.getType());
    }
}
Also used : QValue(org.apache.jackrabbit.spi.QValue) Batch(org.apache.jackrabbit.spi.Batch) NodeId(org.apache.jackrabbit.spi.NodeId) ArrayList(java.util.ArrayList) PropertyInfo(org.apache.jackrabbit.spi.PropertyInfo) QValueFactory(org.apache.jackrabbit.spi.QValueFactory) Name(org.apache.jackrabbit.spi.Name)

Example 20 with PropertyInfo

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

the class BatchTest method testSetNameValue.

public void testSetNameValue() throws RepositoryException {
    NodeId nid = getNodeId(testPath);
    Name propName = resolver.getQName("nameProp");
    QValue[] vs = new QValue[] { rs.getQValueFactory().create(NameConstants.JCR_BASEVERSION), rs.getQValueFactory().create(NameConstants.JCR_DEFAULTPRIMARYTYPE), rs.getQValueFactory().create(NameConstants.MIX_LOCKABLE), rs.getQValueFactory().create(NameConstants.JCR_PRIMARYTYPE), rs.getQValueFactory().create(NameConstants.NT_VERSION) };
    Batch b = rs.createBatch(si, nid);
    b.addProperty(nid, propName, vs);
    rs.submit(b);
    PropertyInfo pi = rs.getPropertyInfo(si, getPropertyId(nid, propName));
    assertTrue(pi.isMultiValued());
    assertEquals(Arrays.asList(vs), Arrays.asList(pi.getValues()));
    assertEquals(PropertyType.NAME, pi.getType());
    pi = getPropertyInfo(nid, propName);
    assertEquals(vs[0].getName(), pi.getValues()[0].getName());
    assertEquals(Arrays.asList(vs), Arrays.asList(pi.getValues()));
    assertEquals(PropertyType.NAME, 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

PropertyInfo (org.apache.jackrabbit.spi.PropertyInfo)27 NodeId (org.apache.jackrabbit.spi.NodeId)23 Name (org.apache.jackrabbit.spi.Name)22 Batch (org.apache.jackrabbit.spi.Batch)19 QValue (org.apache.jackrabbit.spi.QValue)18 ItemInfo (org.apache.jackrabbit.spi.ItemInfo)5 NodeInfo (org.apache.jackrabbit.spi.NodeInfo)5 PropertyId (org.apache.jackrabbit.spi.PropertyId)5 ArrayList (java.util.ArrayList)4 ItemNotFoundException (javax.jcr.ItemNotFoundException)3 InputStream (java.io.InputStream)2 PathNotFoundException (javax.jcr.PathNotFoundException)2 RepositoryException (javax.jcr.RepositoryException)2 Path (org.apache.jackrabbit.spi.Path)2 IOException (java.io.IOException)1 ItemVisitor (javax.jcr.ItemVisitor)1 Node (javax.jcr.Node)1 Property (javax.jcr.Property)1 TraversingItemVisitor (javax.jcr.util.TraversingItemVisitor)1 HttpEntity (org.apache.http.HttpEntity)1