Search in sources :

Example 1 with ResourceRestRequest

use of dk.dbc.search.solrdocstore.request.ResourceRestRequest in project solr-document-store by DBCDK.

the class ResourceBean method putResource.

@PUT
@Consumes({ MediaType.APPLICATION_JSON })
@Produces({ MediaType.APPLICATION_JSON })
@Path("{fieldName}/{agencyId}:{bibliographicRecordId}")
@Operation(operationId = "add/update-resource", summary = "Adds/updates/removes a resource to/from an item", description = "This operation sets/removes the resource and connected" + " manifestations item, are queued.")
@APIResponses({ @APIResponse(name = "Success", responseCode = "200", description = "Resource has been added", ref = StatusResponse.NAME) })
@RequestBody(ref = BibliographicResourceSchemaAnnotated.NAME)
public Response putResource(String jsonContent, @PathParam("fieldName") String fieldName, @PathParam("agencyId") Integer agencyId, @PathParam("bibliographicRecordId") String bibliographicRecordId, @QueryParam("trackingId") String trackingId) throws JSONBException {
    if (trackingId == null || trackingId.isEmpty())
        trackingId = UUID.randomUUID().toString();
    try (LogWith logWith = track(trackingId)) {
        ResourceRestRequest request = jsonbContext.unmarshall(jsonContent, ResourceRestRequest.class);
        BibliographicResourceEntity resource = new BibliographicResourceEntity(agencyId, bibliographicRecordId, fieldName, request.getHas());
        log.debug("PUT resource: {}", resource);
        return storeResource(resource);
    }
}
Also used : LogWith(dk.dbc.log.LogWith) ResourceRestRequest(dk.dbc.search.solrdocstore.request.ResourceRestRequest) BibliographicResourceEntity(dk.dbc.search.solrdocstore.jpa.BibliographicResourceEntity) Path(javax.ws.rs.Path) Consumes(javax.ws.rs.Consumes) Produces(javax.ws.rs.Produces) APIResponses(org.eclipse.microprofile.openapi.annotations.responses.APIResponses) Operation(org.eclipse.microprofile.openapi.annotations.Operation) PUT(javax.ws.rs.PUT) RequestBody(org.eclipse.microprofile.openapi.annotations.parameters.RequestBody)

Aggregations

LogWith (dk.dbc.log.LogWith)1 BibliographicResourceEntity (dk.dbc.search.solrdocstore.jpa.BibliographicResourceEntity)1 ResourceRestRequest (dk.dbc.search.solrdocstore.request.ResourceRestRequest)1 Consumes (javax.ws.rs.Consumes)1 PUT (javax.ws.rs.PUT)1 Path (javax.ws.rs.Path)1 Produces (javax.ws.rs.Produces)1 Operation (org.eclipse.microprofile.openapi.annotations.Operation)1 RequestBody (org.eclipse.microprofile.openapi.annotations.parameters.RequestBody)1 APIResponses (org.eclipse.microprofile.openapi.annotations.responses.APIResponses)1