Search in sources :

Example 16 with NodeInfo

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

the class ItemInfoJsonHandler method object.

public void object() throws IOException {
    if (name != null) {
        try {
            NodeInfo current = getCurrentNodeInfo();
            Path relPath = pFactory.create(name, index);
            NodeId id = idFactory.createNodeId(current.getId(), relPath);
            Path currentPath = current.getPath();
            Path p = pFactory.create(currentPath, relPath, true);
            NodeInfo nInfo = new NodeInfoImpl(id, p);
            nodeInfos.push(nInfo);
            propInfoLists.push(new ArrayList<PropertyInfoImpl>(8));
        } catch (RepositoryException e) {
            throw new IOException(e.getMessage());
        }
    }
}
Also used : Path(org.apache.jackrabbit.spi.Path) NodeInfo(org.apache.jackrabbit.spi.NodeInfo) NodeId(org.apache.jackrabbit.spi.NodeId) RepositoryException(javax.jcr.RepositoryException) IOException(java.io.IOException)

Example 17 with NodeInfo

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

the class ItemInfoJsonHandler method endObject.

public void endObject() throws IOException {
    try {
        NodeInfoImpl nInfo = (NodeInfoImpl) nodeInfos.pop();
        List<PropertyInfoImpl> props = propInfoLists.pop();
        // all required information to create a node info should now be gathered
        nInfo.setPropertyInfos(props.toArray(new PropertyInfoImpl[props.size()]), idFactory);
        NodeInfo parent = getCurrentNodeInfo();
        if (parent != null) {
            if (nInfo.getPath().getAncestor(1).equals(parent.getPath())) {
                ChildInfo ci = new ChildInfoImpl(nInfo.getName(), nInfo.getUniqueID(), nInfo.getIndex());
                ((NodeInfoImpl) parent).addChildInfo(ci);
            } else {
                log.debug("NodeInfo '" + nInfo.getPath() + "' out of hierarchy. Parent path = " + parent.getPath());
            }
        }
        if (nInfo.isCompleted()) {
            itemInfos.addAll(props);
            itemInfos.add(nInfo);
        } else {
            log.debug("Incomplete NodeInfo '" + nInfo.getPath() + "' -> Only present as ChildInfo with its parent.");
        }
    } catch (RepositoryException e) {
        throw new IOException(e.getMessage());
    } finally {
        // reset all node-related handler state
        name = null;
        index = Path.INDEX_DEFAULT;
    }
}
Also used : NodeInfo(org.apache.jackrabbit.spi.NodeInfo) ChildInfo(org.apache.jackrabbit.spi.ChildInfo) RepositoryException(javax.jcr.RepositoryException) IOException(java.io.IOException)

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