Search in sources :

Example 6 with NodeInfo

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

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

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

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

the class BatchTest method testImport.

public void testImport() throws RepositoryException {
    NodeId nid = getNodeId(testPath);
    Batch b = rs.createBatch(si, nid);
    String uuid = UUID.randomUUID().toString();
    b.addNode(nid, resolver.getQName("testUUIDNode"), NameConstants.NT_UNSTRUCTURED, uuid);
    NodeId id = getNodeId(testPath + "/testUUIDNode");
    b.setMixins(id, new Name[] { NameConstants.MIX_REFERENCEABLE });
    rs.submit(b);
    NodeInfo nInfo = rs.getNodeInfo(si, id);
    assertEquals(uuid, nInfo.getId().getUniqueID());
    Name[] mixins = nInfo.getMixins();
    assertEquals(1, mixins.length);
    assertEquals(NameConstants.MIX_REFERENCEABLE, mixins[0]);
    b = rs.createBatch(si, nid);
    b.remove(rs.getIdFactory().createNodeId(uuid));
    rs.submit(b);
    try {
        rs.getItemInfos(si, id);
        fail();
    } catch (RepositoryException e) {
    // success
    }
    try {
        rs.getItemInfos(si, rs.getIdFactory().createNodeId(uuid));
        fail();
    } catch (RepositoryException e) {
    // success
    }
}
Also used : Batch(org.apache.jackrabbit.spi.Batch) NodeInfo(org.apache.jackrabbit.spi.NodeInfo) NodeId(org.apache.jackrabbit.spi.NodeId) RepositoryException(javax.jcr.RepositoryException) Name(org.apache.jackrabbit.spi.Name)

Example 10 with NodeInfo

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

the class CloneTest method testClone.

public void testClone() throws RepositoryException {
    NodeId srcId = getNodeId(testPath);
    NodeId destParentId = getNodeId("/");
    rs.clone(sInfo, si.getWorkspaceName(), srcId, destParentId, resolver.getQName("destname"), true);
    clonedId = getNodeId("/destname");
    NodeInfo nInfo = rs.getNodeInfo(sInfo, clonedId);
    Iterator<? extends ItemInfo> it = rs.getItemInfos(sInfo, clonedId);
    assertTrue(it.hasNext());
    NodeInfo nInfo2 = (NodeInfo) it.next();
    assertEquals(nInfo.getId(), nInfo2.getId());
    assertEquals(nInfo.getNodetype(), nInfo2.getNodetype());
}
Also used : NodeInfo(org.apache.jackrabbit.spi.NodeInfo) NodeId(org.apache.jackrabbit.spi.NodeId)

Aggregations

NodeInfo (org.apache.jackrabbit.spi.NodeInfo)17 NodeId (org.apache.jackrabbit.spi.NodeId)10 Batch (org.apache.jackrabbit.spi.Batch)6 Name (org.apache.jackrabbit.spi.Name)6 ItemInfo (org.apache.jackrabbit.spi.ItemInfo)5 PropertyInfo (org.apache.jackrabbit.spi.PropertyInfo)5 RepositoryException (javax.jcr.RepositoryException)4 IOException (java.io.IOException)2 ArrayList (java.util.ArrayList)2 ItemNotFoundException (javax.jcr.ItemNotFoundException)2 PathNotFoundException (javax.jcr.PathNotFoundException)2 ChildInfo (org.apache.jackrabbit.spi.ChildInfo)2 QValue (org.apache.jackrabbit.spi.QValue)2 ItemVisitor (javax.jcr.ItemVisitor)1 Node (javax.jcr.Node)1 Property (javax.jcr.Property)1 TraversingItemVisitor (javax.jcr.util.TraversingItemVisitor)1 HierarchyEntry (org.apache.jackrabbit.jcr2spi.hierarchy.HierarchyEntry)1 ItemId (org.apache.jackrabbit.spi.ItemId)1 Path (org.apache.jackrabbit.spi.Path)1