Ejemplo n.º 1
0
  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();

    List<Representation> result = new ArrayList<Representation>();

    if (paths != null) {
      for (Path p : paths) {
        result.add(returnType.toRepresentation(p));
      }
    } else {
      leases.remove(traverserId);
      // Yuck.
      throw new NotFoundException(
          String.format(
              "The results for paged traverser with id [%s] have been fully enumerated",
              traverserId));
    }

    return new ListRepresentation(returnType.repType, result);
  }
Ejemplo n.º 2
0
 public boolean removePagedTraverse(String traverserId) {
   Lease lease = leases.getLeaseById(traverserId);
   if (lease == null) {
     return false;
   } else {
     leases.remove(lease.getId());
     return true;
   }
 }