Search in sources :

Example 1 with UnitRetrieveResponse

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();
    }
}
Also used : DocumentRetrieveResponse(dk.dbc.search.solrdocstore.response.DocumentRetrieveResponse) LogWith(dk.dbc.log.LogWith) UnitRetrieveResponse(dk.dbc.search.solrdocstore.response.UnitRetrieveResponse) Path(javax.ws.rs.Path) Produces(javax.ws.rs.Produces) Timed(org.eclipse.microprofile.metrics.annotation.Timed) GET(javax.ws.rs.GET)

Aggregations

LogWith (dk.dbc.log.LogWith)1 DocumentRetrieveResponse (dk.dbc.search.solrdocstore.response.DocumentRetrieveResponse)1 UnitRetrieveResponse (dk.dbc.search.solrdocstore.response.UnitRetrieveResponse)1 GET (javax.ws.rs.GET)1 Path (javax.ws.rs.Path)1 Produces (javax.ws.rs.Produces)1 Timed (org.eclipse.microprofile.metrics.annotation.Timed)1