Search in sources :

Example 6 with PropertyInfo

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

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

Example 8 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 9 with PropertyInfo

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

the class ItemInfoCacheImpl method put.

/**
     * This implementation cached the item by its id and if the id
     * is uuid based but has no path, also by its path.
     */
public void put(ItemInfo info, long generation) {
    ItemId id = info.getId();
    Entry<? extends ItemInfo> entry = info.denotesNode() ? new Entry<NodeInfo>((NodeInfo) info, generation) : new Entry<PropertyInfo>((PropertyInfo) info, generation);
    put(id, entry);
    if (id.getUniqueID() != null && id.getPath() == null) {
        put(info.getPath(), entry);
    }
}
Also used : NodeInfo(org.apache.jackrabbit.spi.NodeInfo) PropertyInfo(org.apache.jackrabbit.spi.PropertyInfo) ItemId(org.apache.jackrabbit.spi.ItemId)

Example 10 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)

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