use of org.eclipse.microprofile.openapi.annotations.responses.APIResponses in project solr-document-store by DBCDK.
the class ExistenceBean method holdingExists.
@Timed
@GET
@Path("holdingsitem/{agencyId : \\d+}:{bibliographicRecordId : .+}")
@Produces(MediaType.APPLICATION_JSON)
@Operation(summary = "Check if a agency has a 'live' holdings for a bibliographic item", description = "This operation checks for a given agency/item," + " and returns if a holding is retrievable for it.")
@APIResponses({ @APIResponse(name = "Success", responseCode = "200", description = "A holding for the given agency/item has been checked", content = @Content(mediaType = MediaType.APPLICATION_JSON, schema = @Schema(ref = ExistsResponse.NAME))) })
@Parameters({ @Parameter(name = "agencyId", description = "The agency that should own the record", required = true), @Parameter(name = "bibliographicRecordId", description = "The id of the record", required = true) })
public ExistsResponse holdingExists(@PathParam("agencyId") Integer agencyId, @PathParam("bibliographicRecordId") String bibliographicRecordId) {
log.info("Checking existence of holdings item {}:{}", agencyId, bibliographicRecordId);
ExistsResponse response = new ExistsResponse();
HoldingsItemEntity entity = entityManager.find(HoldingsItemEntity.class, new AgencyItemKey(agencyId, bibliographicRecordId));
response.exists = entity != null;
return response;
}
use of org.eclipse.microprofile.openapi.annotations.responses.APIResponses in project solr-document-store by DBCDK.
the class ExistenceBean method bibliographicExists.
@Timed
@GET
@Path("bibliographicitem/{agencyId : \\d+}-{classifier : \\w+}:{bibliographicRecordId : .+}")
@Produces(MediaType.APPLICATION_JSON)
@Operation(summary = "Check if a manifestation-id has a 'live' record", description = "This operation checks for a given identifier," + " and returns if a document is retrievable for it.")
@APIResponses({ @APIResponse(name = "Success", responseCode = "200", description = "An item for the given manifestation-id has been checked", content = @Content(mediaType = MediaType.APPLICATION_JSON, schema = @Schema(ref = ExistsResponse.NAME))) })
@Parameters({ @Parameter(name = "agencyId", description = "The agency that should own the record", required = true), @Parameter(name = "classifier", description = "The classifier of the records (usually basis or katalog)", required = true), @Parameter(name = "bibliographicRecordId", description = "The id of the record", required = true) })
public ExistsResponse bibliographicExists(@PathParam("agencyId") Integer agencyId, @PathParam("classifier") String classifier, @PathParam("bibliographicRecordId") String bibliographicRecordId) {
log.info("Checking existence of bibliographic item {}-{}:{}", agencyId, classifier, bibliographicRecordId);
ExistsResponse response = new ExistsResponse();
BibliographicEntity entity = entityManager.find(BibliographicEntity.class, new AgencyClassifierItemKey(agencyId, classifier, bibliographicRecordId));
if (entity == null) {
response.exists = false;
} else {
response.exists = !entity.isDeleted();
}
return response;
}
use of org.eclipse.microprofile.openapi.annotations.responses.APIResponses 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);
}
}
use of org.eclipse.microprofile.openapi.annotations.responses.APIResponses in project solr-document-store by DBCDK.
the class ResourceBean method deleteResource.
@DELETE
@Consumes({ MediaType.APPLICATION_JSON })
@Produces({ MediaType.APPLICATION_JSON })
@Path("{fieldName}/{agencyId}:{bibliographicRecordId}")
@Operation(operationId = "delete-resource", summary = "Removes a resource to an item", description = "This operation removed the resource and queues old connected" + " manifestations item, if any.")
@APIResponses({ @APIResponse(name = "Success", responseCode = "200", description = "Resource has been added", ref = StatusResponse.NAME) })
@RequestBody(ref = BibliographicResourceSchemaAnnotated.NAME)
public Response deleteResource(@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)) {
BibliographicResourceEntity resource = new BibliographicResourceEntity(agencyId, bibliographicRecordId, fieldName, false);
log.debug("DELETE resource: {}", resource);
return storeResource(resource);
}
}
use of org.eclipse.microprofile.openapi.annotations.responses.APIResponses in project solr-document-store by DBCDK.
the class QueueBean method queueManifestation.
@GET
@Produces({ MediaType.APPLICATION_JSON })
@Path("manifestation/{ agencyId : \\d+}-{ classifier : \\w+ }:{ bibliographicRecordId : .+}")
@Operation(summary = "Queue a manifestation", description = "This operation puts a manifestation," + " and optionally (if it isn't deleted) its work on queue.")
@APIResponses({ @APIResponse(name = "Success", responseCode = "200", description = "The manifestation was found, and put onto the queue", content = @Content(mediaType = MediaType.APPLICATION_JSON, schema = @Schema(ref = StatusResponse.NAME))), @APIResponse(name = "Not Found", responseCode = "404", description = "There's no such manifestation", content = @Content(mediaType = MediaType.APPLICATION_JSON, schema = @Schema(ref = StatusResponse.NAME))) })
@Parameters({ @Parameter(name = "agencyId", description = "The agency that owns the record", required = true), @Parameter(name = "classifier", description = "The classifier of the records (usually basis or katalog)", required = true), @Parameter(name = "bibliographicRecordId", description = "The id of the record", required = true), @Parameter(name = "trackingId", description = "For tracking the request", required = false) })
@Timed
public Response queueManifestation(@PathParam("agencyId") Integer agencyId, @PathParam("classifier") String classifier, @PathParam("bibliographicRecordId") String bibliographicRecordId, @QueryParam("trackingId") String trackingId) {
if (trackingId == null || trackingId.isEmpty())
trackingId = UUID.randomUUID().toString();
String pid = agencyId + "-" + classifier + ":" + bibliographicRecordId;
try (LogWith logWith = LogWith.track(trackingId).pid(pid)) {
AgencyClassifierItemKey bibliographicKey = new AgencyClassifierItemKey(agencyId, classifier, bibliographicRecordId);
BibliographicEntity biblEntity = entityManager.find(BibliographicEntity.class, bibliographicKey);
if (biblEntity == null) {
return Response.status(Response.Status.NOT_FOUND).entity(new StatusResponse("No such manifestation")).build();
}
EnqueueCollector enqueueCollector = enqueueSupplier.getEnqueueCollector();
if (biblEntity.isDeleted()) {
enqueueCollector.add(biblEntity, QueueType.ENDPOINT);
} else {
enqueueCollector.add(biblEntity, QueueType.ENDPOINT, QueueType.WORKENDPOINT);
}
enqueueCollector.commit();
return Response.ok(new StatusResponse()).build();
} catch (SQLException ex) {
log.error("Error queueing: {}: {}", pid, ex.getMessage());
log.debug("Error queueing: {}: ", pid, ex);
return Response.serverError().entity(new StatusResponse(ex.getMessage())).build();
}
}
Aggregations