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);
}
}
Aggregations