Search in sources :

Example 1 with Lease

use of org.neo4j.server.rest.paging.Lease in project neo4j by neo4j.

the class DatabaseActions method pagedTraverse.

public ListRepresentation pagedTraverse(String traverserId, TraverserReturnType returnType) {
    Lease lease = leases.getLeaseById(traverserId);
    if (lease == null) {
        throw new NotFoundException(String.format("The traverser with id [%s] was not found", traverserId));
    }
    PagedTraverser traverser = lease.getLeasedItemAndRenewLease();
    List<Path> paths = traverser.next();
    if (paths != null) {
        return toListPathRepresentation(paths, returnType);
    } else {
        leases.remove(traverserId);
        // Yuck.
        throw new NotFoundException(String.format("The results for paged traverser with id [%s] have been fully enumerated", traverserId));
    }
}
Also used : Path(org.neo4j.graphdb.Path) WeightedPath(org.neo4j.graphalgo.WeightedPath) Lease(org.neo4j.server.rest.paging.Lease) StartNodeNotFoundException(org.neo4j.server.rest.domain.StartNodeNotFoundException) NotFoundException(org.neo4j.graphdb.NotFoundException) EndNodeNotFoundException(org.neo4j.server.rest.domain.EndNodeNotFoundException) PagedTraverser(org.neo4j.server.rest.paging.PagedTraverser)

Aggregations

WeightedPath (org.neo4j.graphalgo.WeightedPath)1 NotFoundException (org.neo4j.graphdb.NotFoundException)1 Path (org.neo4j.graphdb.Path)1 EndNodeNotFoundException (org.neo4j.server.rest.domain.EndNodeNotFoundException)1 StartNodeNotFoundException (org.neo4j.server.rest.domain.StartNodeNotFoundException)1 Lease (org.neo4j.server.rest.paging.Lease)1 PagedTraverser (org.neo4j.server.rest.paging.PagedTraverser)1