Search in sources :

Example 1 with WorkRetrieveResponse

use of dk.dbc.search.solrdocstore.response.WorkRetrieveResponse in project solr-document-store by DBCDK.

the class DocumentRetrieveBean method getWorkDocumentsWithHoldingsItems.

@GET
@Produces({ MediaType.APPLICATION_JSON })
@Path("work/{ workid }")
@Timed
public Response getWorkDocumentsWithHoldingsItems(@Context UriInfo uriInfo, @PathParam("workid") String workId, @DefaultValue("false") @QueryParam("includeHoldingsItemsIndexKeys") boolean includeHoldingsItemsIndexKeys) throws Exception {
    log.debug("Fetching manifestations for work {}, includeHIIK: {}", workId, includeHoldingsItemsIndexKeys);
    try (LogWith logWith = track(null)) {
        List<DocumentRetrieveResponse> responses = getDocumentsForWork(workId, includeHoldingsItemsIndexKeys);
        if (responses == null || responses.isEmpty()) {
            return Response.status(Response.Status.NOT_FOUND).header("X-DBC-Status", "200").entity("Work not found").build();
        }
        final WorkRetrieveResponse res = new WorkRetrieveResponse(workId, responses);
        return Response.ok(res).build();
    } catch (Exception ex) {
        log.error("Error retrieving documents for work {}: {}", workId, ex.getMessage());
        log.debug("Error retrieving documents for work {}: {}", workId, ex);
        return Response.status(Response.Status.INTERNAL_SERVER_ERROR).entity("Error retrieving documents for work").build();
    }
}
Also used : DocumentRetrieveResponse(dk.dbc.search.solrdocstore.response.DocumentRetrieveResponse) LogWith(dk.dbc.log.LogWith) WorkRetrieveResponse(dk.dbc.search.solrdocstore.response.WorkRetrieveResponse) 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 WorkRetrieveResponse (dk.dbc.search.solrdocstore.response.WorkRetrieveResponse)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