Search in sources :

Example 1 with PropertyInfo

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

the class WorkspaceItemStateFactory method createPropertyState.

/**
 * Creates the PropertyState with information retrieved from the <code>RepositoryService</code>.
 */
public PropertyState createPropertyState(PropertyId propertyId, PropertyEntry entry) throws ItemNotFoundException, RepositoryException {
    try {
        // Get item info from cache and use it if up to date
        Entry<PropertyInfo> cached = cache.getPropertyInfo(propertyId);
        ItemInfo info;
        if (isUpToDate(cached, entry)) {
            info = cached.info;
        } else {
            // otherwise retrieve item info from service and cache the whole batch
            Iterator<? extends ItemInfo> infos = service.getItemInfos(sessionInfo, propertyId);
            info = first(infos, cache, entry.getGeneration());
            if (info == null || info.denotesNode()) {
                throw new ItemNotFoundException("PropertyId: " + propertyId);
            }
        }
        assertMatchingPath(info, entry);
        return createPropertyState((PropertyInfo) info, entry);
    } catch (PathNotFoundException e) {
        throw new ItemNotFoundException(e);
    }
}
Also used : ItemInfo(org.apache.jackrabbit.spi.ItemInfo) PathNotFoundException(javax.jcr.PathNotFoundException) PropertyInfo(org.apache.jackrabbit.spi.PropertyInfo) ItemNotFoundException(javax.jcr.ItemNotFoundException)

Example 2 with PropertyInfo

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

the class RepositoryServiceImpl method getItemInfos.

@Override
public Iterator<? extends ItemInfo> getItemInfos(SessionInfo sessionInfo, ItemId itemId) throws RepositoryException {
    // currently: missing prop-names with child-NodeInfo
    if (itemId.denotesNode()) {
        List<ItemInfo> l = new ArrayList<ItemInfo>();
        NodeInfo nInfo = getNodeInfo(sessionInfo, (NodeId) itemId);
        l.add(nInfo);
        // at least add propertyInfos for the meta-props already known from the
        // nodeInfo.
        l.addAll(buildPropertyInfos(nInfo));
        return l.iterator();
    } else {
        PropertyInfo pInfo = getPropertyInfo(sessionInfo, (PropertyId) itemId);
        return Iterators.singleton(pInfo);
    }
}
Also used : ItemInfo(org.apache.jackrabbit.spi.ItemInfo) NodeInfo(org.apache.jackrabbit.spi.NodeInfo) ArrayList(java.util.ArrayList) PropertyInfo(org.apache.jackrabbit.spi.PropertyInfo)

Example 3 with PropertyInfo

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

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

the class BatchTest method testSetMixedBinaryValues.

public void testSetMixedBinaryValues() 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[0]), 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("", 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("", 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 5 with PropertyInfo

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

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