Search in sources :

Example 16 with PropertyId

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

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

the class BatchTest method testRemove.

public void testRemove() throws RepositoryException {
    NodeId nid = getNodeId(testPath);
    Batch b = rs.createBatch(si, nid);
    NodeId id = getNodeId(testPath + "/aTestNode");
    b.addNode(nid, resolver.getQName("aTestNode"), NameConstants.NT_UNSTRUCTURED, null);
    b.addProperty(id, resolver.getQName("aString"), rs.getQValueFactory().create("ba", PropertyType.STRING));
    rs.submit(b);
    PropertyId pid = getPropertyId(id, resolver.getQName("aString"));
    b = rs.createBatch(si, nid);
    b.remove(pid);
    rs.submit(b);
    try {
        rs.getPropertyInfo(si, pid);
        fail();
    } catch (RepositoryException e) {
    // success
    }
}
Also used : Batch(org.apache.jackrabbit.spi.Batch) NodeId(org.apache.jackrabbit.spi.NodeId) RepositoryException(javax.jcr.RepositoryException) PropertyId(org.apache.jackrabbit.spi.PropertyId)

Example 18 with PropertyId

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

the class BatchTest method testSetPropertyTwice.

public void testSetPropertyTwice() throws RepositoryException {
    NodeId nid = getNodeId(testPath);
    Name propName = resolver.getQName("nameProp");
    PropertyId pid = getPropertyId(nid, propName);
    QValue v = rs.getQValueFactory().create(NameConstants.JCR_AUTOCREATED);
    QValue v2 = rs.getQValueFactory().create(NameConstants.JCR_BASEVERSION);
    QValue v3 = rs.getQValueFactory().create(NameConstants.JCR_CONTENT);
    Batch b = rs.createBatch(si, nid);
    b.addProperty(nid, propName, v);
    b.setValue(pid, v2);
    b.setValue(pid, v3);
    rs.submit(b);
    PropertyInfo pi = rs.getPropertyInfo(si, getPropertyId(nid, propName));
    assertFalse(pi.isMultiValued());
    assertEquals(1, pi.getValues().length);
    assertEquals(v3, pi.getValues()[0]);
    assertEquals(PropertyType.NAME, pi.getType());
    pi = getPropertyInfo(nid, propName);
    assertFalse(pi.isMultiValued());
    assertEquals(1, pi.getValues().length);
    assertEquals(v3, pi.getValues()[0]);
    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) PropertyId(org.apache.jackrabbit.spi.PropertyId)

Example 19 with PropertyId

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

the class ReadTest method testReadNonExistingProperty.

public void testReadNonExistingProperty() throws RepositoryException {
    NodeId nid = getNodeId(testPath);
    PropertyId pid = getPropertyId(nid, NameConstants.JCR_CHILDNODEDEFINITION);
    try {
        rs.getPropertyInfo(si, pid);
        fail();
    } catch (ItemNotFoundException e) {
    // ok
    }
}
Also used : NodeId(org.apache.jackrabbit.spi.NodeId) PropertyId(org.apache.jackrabbit.spi.PropertyId) ItemNotFoundException(javax.jcr.ItemNotFoundException)

Example 20 with PropertyId

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

the class ItemInfoJsonHandler method value.

// --------------------------------------------------------------------------
/**
 * @param value
 * @throws RepositoryException
 */
private void value(QValue value) throws RepositoryException {
    if (!multiValuedProperty) {
        try {
            if (propertyType == PropertyType.UNDEFINED) {
                propertyType = value.getType();
            }
            // create single-valued property info
            NodeInfoImpl parent = getCurrentNodeInfo();
            Path p = pFactory.create(parent.getPath(), name, true);
            PropertyId id = idFactory.createPropertyId(parent.getId(), name);
            PropertyInfoImpl propInfo = new PropertyInfoImpl(id, p, propertyType, value);
            propInfo.checkCompleted();
            // add property info to current list, will be processed on endObject() event
            getCurrentPropInfos().add(propInfo);
        } finally {
            // reset property-related handler state
            propertyType = PropertyType.UNDEFINED;
            multiValuedProperty = false;
            propValues.clear();
            name = null;
            expectingHintValue = false;
        }
    } else {
        // multi-valued property
        // add value to current list, will be processed on endArray() event
        propValues.add(value);
    }
}
Also used : Path(org.apache.jackrabbit.spi.Path) PropertyId(org.apache.jackrabbit.spi.PropertyId)

Aggregations

PropertyId (org.apache.jackrabbit.spi.PropertyId)21 NodeId (org.apache.jackrabbit.spi.NodeId)13 Name (org.apache.jackrabbit.spi.Name)10 RepositoryException (javax.jcr.RepositoryException)8 ArrayList (java.util.ArrayList)6 Path (org.apache.jackrabbit.spi.Path)6 PropertyInfo (org.apache.jackrabbit.spi.PropertyInfo)5 QValue (org.apache.jackrabbit.spi.QValue)5 Batch (org.apache.jackrabbit.spi.Batch)4 NameException (org.apache.jackrabbit.spi.commons.conversion.NameException)4 IOException (java.io.IOException)3 ItemNotFoundException (javax.jcr.ItemNotFoundException)3 DavPropertySet (org.apache.jackrabbit.webdav.property.DavPropertySet)3 Serializable (java.io.Serializable)2 Node (javax.jcr.Node)2 HttpResponse (org.apache.http.HttpResponse)2 ChildInfo (org.apache.jackrabbit.spi.ChildInfo)2 ItemId (org.apache.jackrabbit.spi.ItemId)2 ItemInfo (org.apache.jackrabbit.spi.ItemInfo)2 NamePathResolver (org.apache.jackrabbit.spi.commons.conversion.NamePathResolver)2