Search in sources :

Example 6 with ItemInfo

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

the class ReadPerformanceTest method getItemInfos.

@Override
public Iterator<? extends ItemInfo> getItemInfos(SessionInfo sessionInfo, ItemId itemId) throws ItemNotFoundException, RepositoryException {
    roundTripCount++;
    ItemInfo itemInfo = itemInfoStore.getItemInfo(itemId);
    return iteratorChain(singleton(itemInfo), getBatch());
}
Also used : ItemInfo(org.apache.jackrabbit.spi.ItemInfo)

Example 7 with ItemInfo

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

the class BatchTest method testEmptyValueArray.

public void testEmptyValueArray() throws RepositoryException {
    NodeId nid = getNodeId(testPath);
    Name propName = resolver.getQName("mvProperty");
    Batch b = rs.createBatch(si, nid);
    b.addProperty(nid, propName, new QValue[0]);
    rs.submit(b);
    PropertyId pid = getPropertyId(nid, propName);
    PropertyInfo pi = rs.getPropertyInfo(si, pid);
    assertTrue(pi.isMultiValued());
    assertEquals(Arrays.asList(new QValue[0]), Arrays.asList(pi.getValues()));
    assertFalse(pi.getType() == PropertyType.UNDEFINED);
    Iterator<? extends ItemInfo> it = rs.getItemInfos(si, nid);
    while (it.hasNext()) {
        ItemInfo info = it.next();
        if (!info.denotesNode()) {
            PropertyInfo pInfo = (PropertyInfo) info;
            if (propName.equals((pInfo.getId().getName()))) {
                assertTrue(pi.isMultiValued());
                assertEquals(Arrays.asList(new QValue[0]), Arrays.asList(pi.getValues()));
                assertFalse(pi.getType() == PropertyType.UNDEFINED);
                break;
            }
        }
    }
}
Also used : QValue(org.apache.jackrabbit.spi.QValue) Batch(org.apache.jackrabbit.spi.Batch) ItemInfo(org.apache.jackrabbit.spi.ItemInfo) 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 8 with ItemInfo

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

the class BatchTest method testAddNode.

public void testAddNode() throws RepositoryException {
    NodeId nid = getNodeId(testPath);
    Batch b = rs.createBatch(si, nid);
    b.addNode(nid, resolver.getQName("aNode"), NameConstants.NT_UNSTRUCTURED, null);
    b.addProperty(nid, resolver.getQName("aString"), rs.getQValueFactory().create("ba", PropertyType.STRING));
    b.addProperty(nid, resolver.getQName("aName"), new QValue[] { rs.getQValueFactory().create(NameConstants.JCR_ENCODING), rs.getQValueFactory().create(NameConstants.JCR_DATA) });
    b.addProperty(nid, resolver.getQName("aBinary"), rs.getQValueFactory().create(new byte[] { 'a', 'b', 'c' }));
    rs.submit(b);
    NodeId id = rs.getIdFactory().createNodeId(nid, resolver.getQPath("aNode"));
    Iterator<? extends ItemInfo> it = rs.getItemInfos(si, id);
    while (it.hasNext()) {
        ItemInfo info = it.next();
        if (info.denotesNode()) {
            NodeInfo nInfo = (NodeInfo) info;
            assertEquals(NameConstants.NT_UNSTRUCTURED, nInfo.getNodetype());
            Iterator<ChildInfo> childIt = nInfo.getChildInfos();
            assertTrue(childIt == null || !childIt.hasNext());
            assertEquals(id, nInfo.getId());
        }
    }
    b = rs.createBatch(si, nid);
    b.remove(id);
    rs.submit(b);
}
Also used : Batch(org.apache.jackrabbit.spi.Batch) ItemInfo(org.apache.jackrabbit.spi.ItemInfo) NodeInfo(org.apache.jackrabbit.spi.NodeInfo) NodeId(org.apache.jackrabbit.spi.NodeId) ChildInfo(org.apache.jackrabbit.spi.ChildInfo)

Example 9 with ItemInfo

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

the class GetItemsTest method checkHierarchy.

private void checkHierarchy() throws PathNotFoundException, RepositoryException, ItemNotFoundException, AccessDeniedException {
    for (Iterator<ItemInfo> itemInfos = itemInfoStore.getItemInfos(); itemInfos.hasNext(); ) {
        ItemInfo itemInfo = itemInfos.next();
        String jcrPath = toJCRPath(itemInfo.getPath());
        Item item = session.getItem(jcrPath);
        assertEquals(jcrPath, item.getPath());
        if (item.getDepth() > 0) {
            Node parent = item.getParent();
            if (item.isNode()) {
                assertTrue(item.isSame(parent.getNode(item.getName())));
            } else {
                assertTrue(item.isSame(parent.getProperty(item.getName())));
            }
        }
    }
}
Also used : Item(javax.jcr.Item) ItemInfo(org.apache.jackrabbit.spi.ItemInfo) Node(javax.jcr.Node)

Example 10 with ItemInfo

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

the class WorkspaceItemStateFactory method createDeepPropertyState.

/**
     * Creates the PropertyState with information retrieved from the <code>RepositoryService</code>.
     * Intermediate entries are created as needed.
     */
public PropertyState createDeepPropertyState(PropertyId propertyId, NodeEntry anyParent) throws RepositoryException {
    try {
        // Get item info from cache
        Iterator<? extends ItemInfo> infos = null;
        Entry<PropertyInfo> cached = cache.getPropertyInfo(propertyId);
        ItemInfo info;
        if (cached == null) {
            // or from service if not in cache
            infos = service.getItemInfos(sessionInfo, propertyId);
            info = first(infos, null, 0);
            if (info == null || info.denotesNode()) {
                throw new ItemNotFoundException("PropertyId: " + propertyId);
            }
        } else {
            info = cached.info;
        }
        // Build the hierarchy entry for the item info
        HierarchyEntry entry = createHierarchyEntries(info, anyParent);
        if (entry == null || entry.denotesNode()) {
            throw new ItemNotFoundException("HierarchyEntry does not belong to any existing ItemInfo. No ItemState was created.");
        } else {
            long generation = entry.getGeneration();
            if (isOutdated(cached, entry)) {
                // if not, retrieve the item info from the service and put the whole batch into the cache
                infos = service.getItemInfos(sessionInfo, propertyId);
                info = first(infos, cache, generation);
            } else if (infos != null) {
                // Otherwise put the whole batch retrieved from the service earlier into the cache
                cache.put(info, generation);
                first(infos, cache, generation);
            }
            assertMatchingPath(info, entry);
            return createPropertyState((PropertyInfo) info, (PropertyEntry) 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) HierarchyEntry(org.apache.jackrabbit.jcr2spi.hierarchy.HierarchyEntry) ItemNotFoundException(javax.jcr.ItemNotFoundException)

Aggregations

ItemInfo (org.apache.jackrabbit.spi.ItemInfo)10 NodeInfo (org.apache.jackrabbit.spi.NodeInfo)5 PropertyInfo (org.apache.jackrabbit.spi.PropertyInfo)5 ItemNotFoundException (javax.jcr.ItemNotFoundException)4 PathNotFoundException (javax.jcr.PathNotFoundException)4 NodeId (org.apache.jackrabbit.spi.NodeId)3 ArrayList (java.util.ArrayList)2 Node (javax.jcr.Node)2 HierarchyEntry (org.apache.jackrabbit.jcr2spi.hierarchy.HierarchyEntry)2 Batch (org.apache.jackrabbit.spi.Batch)2 Name (org.apache.jackrabbit.spi.Name)2 PropertyId (org.apache.jackrabbit.spi.PropertyId)2 Item (javax.jcr.Item)1 ItemVisitor (javax.jcr.ItemVisitor)1 Property (javax.jcr.Property)1 RepositoryException (javax.jcr.RepositoryException)1 TraversingItemVisitor (javax.jcr.util.TraversingItemVisitor)1 ChildInfo (org.apache.jackrabbit.spi.ChildInfo)1 QValue (org.apache.jackrabbit.spi.QValue)1 NameException (org.apache.jackrabbit.spi.commons.conversion.NameException)1