use of dk.dbc.search.solrdocstore.response.UnitRetrieveResponse in project solr-document-store by DBCDK.
the class DocumentRetrieveBean method getUnitDocumentsWithHoldingsItems.
@GET
@Produces({ MediaType.APPLICATION_JSON })
@Path("unit/{ unitid }")
@Timed
public Response getUnitDocumentsWithHoldingsItems(@Context UriInfo uriInfo, @PathParam("unitid") String unitId, @DefaultValue("false") @QueryParam("includeHoldingsItemsIndexKeys") boolean includeHoldingsItemsIndexKeys) throws Exception {
log.debug("Fetching manifestations for unit {}, includeHIIK: {}", unitId, includeHoldingsItemsIndexKeys);
try (LogWith logWith = track(null)) {
List<DocumentRetrieveResponse> responses = getDocumentsForUnit(unitId, includeHoldingsItemsIndexKeys);
if (responses == null || responses.isEmpty()) {
return Response.status(Response.Status.NOT_FOUND).header("X-DBC-Status", "200").entity("Unit not found").build();
}
final UnitRetrieveResponse res = new UnitRetrieveResponse(unitId, responses);
return Response.ok(res).build();
} catch (Exception ex) {
log.error("Error retrieving documents for unit {}: {}", unitId, ex.getMessage());
log.debug("Error retrieving documents for unit {}: {}", unitId, ex);
return Response.status(Response.Status.INTERNAL_SERVER_ERROR).entity("Error retrieving documents for unit").build();
}
}
Aggregations