use of org.dcache.restful.providers.billing.DoorTransferRecord in project dcache by dCache.
the class BillingResources method getReads.
@GET
@ApiOperation("Provides a list of read transfers for a specific PNFS-ID.")
@ApiResponses({ @ApiResponse(code = 400, message = "Bad request"), @ApiResponse(code = 404, message = "Not Found"), @ApiResponse(code = 500, message = "Internal Server Error") })
@Produces(MediaType.APPLICATION_JSON)
@Path("reads/{pnfsid}")
public List<DoorTransferRecord> getReads(@ApiParam("The file to list.") @PathParam("pnfsid") PnfsId pnfsid, @ApiParam("Return no reads after this datestamp.") @QueryParam("before") String before, @ApiParam("Return no reads before this datestamp.") @QueryParam("after") String after, @ApiParam("Maximum number of reads to return.") @QueryParam("limit") Integer limit, @ApiParam("Number of reads to skip.") @DefaultValue("0") @QueryParam("offset") Integer offset, @ApiParam("Only select reads from the specified pool.") @QueryParam("pool") String pool, @ApiParam("Only select reads initiated by the specified door.") @QueryParam("door") String door, @ApiParam("Only select reads requested by the client.") @QueryParam("client") String client, @ApiParam("How to sort responses.") @DefaultValue("date") @QueryParam("sort") String sort) {
try {
limit = limit == null ? Integer.MAX_VALUE : limit;
Long suid = RequestUser.getSubjectUidForFileOperations(unlimitedOperationVisibility);
PagedList<DoorTransferRecord> result = service.getReads(pnfsid, before, after, limit, offset, suid, pool, door, client, sort);
response.addIntHeader(TOTAL_COUNT_HEADER, result.total);
return result.contents;
} catch (FileNotFoundCacheException e) {
throw new NotFoundException(e);
} catch (NoRouteToCellException | InterruptedException | CacheException e) {
LOGGER.warn(Exceptions.meaningfulMessage(e));
throw new InternalServerErrorException(e);
} catch (IllegalArgumentException | ParseException e) {
throw new BadRequestException(e.getMessage(), e);
}
}
use of org.dcache.restful.providers.billing.DoorTransferRecord in project dcache by dCache.
the class BillingResources method getWrites.
@GET
@ApiOperation("Provides a list of write transfers for a specific PNFS-ID.")
@ApiResponses({ @ApiResponse(code = 400, message = "Bad request"), @ApiResponse(code = 404, message = "Not Found"), @ApiResponse(code = 500, message = "Internal Server Error") })
@Produces(MediaType.APPLICATION_JSON)
@Path("writes/{pnfsid}")
public List<DoorTransferRecord> getWrites(@ApiParam("The file to list.") @PathParam("pnfsid") PnfsId pnfsid, @ApiParam("Return no writes after this datestamp.") @QueryParam("before") String before, @ApiParam("Return no writes before this datestamp.") @QueryParam("after") String after, @ApiParam("Maximum number of writes to return.") @QueryParam("limit") Integer limit, @ApiParam("Number of writes to skip.") @DefaultValue("0") @QueryParam("offset") int offset, @ApiParam("Only select writes from the specified pool.") @QueryParam("pool") String pool, @ApiParam("Only select writes initiated by the specified door.") @QueryParam("door") String door, @ApiParam("Only select writes requested by the client.") @QueryParam("client") String client, @ApiParam("How to sort responses.") @DefaultValue("date") @QueryParam("sort") String sort) {
try {
limit = limit == null ? Integer.MAX_VALUE : limit;
Long suid = RequestUser.getSubjectUidForFileOperations(unlimitedOperationVisibility);
PagedList<DoorTransferRecord> result = service.getWrites(pnfsid, before, after, limit, offset, suid, pool, door, client, sort);
response.addIntHeader(TOTAL_COUNT_HEADER, result.total);
return result.contents;
} catch (FileNotFoundCacheException e) {
throw new NotFoundException(e);
} catch (NoRouteToCellException | InterruptedException | CacheException e) {
LOGGER.warn(Exceptions.meaningfulMessage(e));
throw new InternalServerErrorException(e);
} catch (IllegalArgumentException | ParseException e) {
throw new BadRequestException(e.getMessage(), e);
}
}
use of org.dcache.restful.providers.billing.DoorTransferRecord in project dcache by dCache.
the class BillingInfoServiceImpl method getDoorTransfers.
private PagedList<DoorTransferRecord> getDoorTransfers(Type type, PnfsId pnfsid, String before, String after, Integer limit, int offset, String door, String pool, String client, String sort, Long suid) throws FileNotFoundCacheException, ParseException, CacheException, NoRouteToCellException, InterruptedException {
if (Strings.isNullOrEmpty(sort)) {
sort = "date";
}
TransferRecordRequestMessage message = new TransferRecordRequestMessage(pnfsid, getDate(before), getDate(after), type, door, null, pool, client, limit == null ? Integer.MAX_VALUE : limit, offset, sort);
message = collector.sendRecordRequest(message);
Predicate<TransferRecord> matchesSubject = r -> suid == null || r.getMappedUid() == null || suid.intValue() == r.getMappedUid();
List<DoorTransferRecord> list = message.getRecords().stream().filter(matchesSubject).map(DoorTransferRecord::new).collect(Collectors.toList());
return new PagedList<>(list, list.size());
}
Aggregations