use of org.eclipse.microprofile.openapi.annotations.responses.APIResponses in project solr-document-store by DBCDK.
the class ResourceBean method addResource.
@POST
@Consumes({ MediaType.APPLICATION_JSON })
@Produces({ MediaType.APPLICATION_JSON })
@Path("add")
@Operation(operationId = "add-resource", summary = "Adds a resource to an item", description = "This operation sets the resource and connect" + " it to a number of manifestations item, if possible.")
@APIResponses({ @APIResponse(name = "Success", responseCode = "200", description = "Resource has been added", ref = StatusResponse.NAME) })
@RequestBody(ref = BibliographicResourceSchemaAnnotated.NAME)
public Response addResource(String jsonContent) throws JSONBException {
try (LogWith logWith = track(UUID.randomUUID().toString())) {
AddResourceRequest request = jsonbContext.unmarshall(jsonContent, AddResourceRequest.class);
// Add resource
BibliographicResourceEntity resource = request.asBibliographicResource();
log.debug("POST 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 queueWork.
@GET
@Produces({ MediaType.APPLICATION_JSON })
@Path("work/{ workId : work:\\d+ }")
@Timed
@Operation(summary = "Queue a manifestation", description = "This operation puts a work and its manifestations on queue.")
@APIResponses({ @APIResponse(name = "Success", responseCode = "200", description = "The work 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 work", content = @Content(mediaType = MediaType.APPLICATION_JSON, schema = @Schema(ref = StatusResponse.NAME))) })
@Parameters({ @Parameter(name = "workId", description = "The (corepo-)id of the work", required = true), @Parameter(name = "trackingId", description = "For tracking the request", required = false) })
public Response queueWork(@PathParam("workId") String workId, @QueryParam("trackingId") String trackingId) {
if (trackingId == null || trackingId.isEmpty())
trackingId = UUID.randomUUID().toString();
try (LogWith logWith = LogWith.track(trackingId).pid(workId)) {
List<BibliographicEntity> biblEntitys = BibliographicEntity.fetchByWork(entityManager, workId);
if (biblEntitys.isEmpty()) {
return Response.status(Response.Status.NOT_FOUND).entity(new StatusResponse("No such work")).build();
}
EnqueueCollector enqueueCollector = enqueueSupplier.getEnqueueCollector();
biblEntitys.forEach(biblEntity -> enqueueCollector.add(biblEntity, QueueType.ENDPOINT, QueueType.WORKENDPOINT));
enqueueCollector.commit();
return Response.ok(new StatusResponse()).build();
} catch (SQLException ex) {
log.error("Error queueing: {}: {}", workId, ex.getMessage());
log.debug("Error queueing: {}: ", workId, ex);
return Response.serverError().entity(new StatusResponse(ex.getMessage())).build();
}
}
use of org.eclipse.microprofile.openapi.annotations.responses.APIResponses in project narayana by jbosstm.
the class Coordinator method getLRAInfo.
@GET
@Path("{LraId}")
@Produces(MediaType.APPLICATION_JSON)
@Operation(summary = "Obtain the information about an LRA as a JSON structure")
@APIResponses({ @APIResponse(responseCode = "200", description = "The LRA exists and the information is packed as JSON in the content body.", content = @Content(schema = @Schema(implementation = LRAData.class)), headers = { @Header(ref = LRAConstants.NARAYANA_LRA_API_VERSION_HEADER_NAME) }), @APIResponse(responseCode = "404", description = "The coordinator has no knowledge of this LRA", content = @Content(schema = @Schema(implementation = String.class))), @APIResponse(responseCode = "417", description = "The requested version provided in HTTP Header is not supported by this end point", content = @Content(schema = @Schema(implementation = String.class))) })
public Response getLRAInfo(@Parameter(name = "LraId", description = "The unique identifier of the LRA", required = true) @PathParam("LraId") String lraId, @Parameter(ref = LRAConstants.NARAYANA_LRA_API_VERSION_HEADER_NAME) @HeaderParam(LRAConstants.NARAYANA_LRA_API_VERSION_HEADER_NAME) @DefaultValue(CURRENT_API_VERSION_STRING) String version) {
URI lraIdURI = toURI(lraId);
LRAData lraData = lraService.getLRA(lraIdURI);
return Response.status(OK).entity(lraData).header(NARAYANA_LRA_API_VERSION_HEADER_NAME, version).build();
}
use of org.eclipse.microprofile.openapi.annotations.responses.APIResponses in project narayana by jbosstm.
the class Coordinator method getLRAStatus.
@GET
@Path("{LraId}/status")
@Produces(MediaType.TEXT_PLAIN)
@Operation(summary = "Obtain the status of an LRA as a string")
@APIResponses({ @APIResponse(responseCode = "200", description = "The LRA exists. The status is reported in the content body.", content = @Content(schema = @Schema(implementation = String.class)), headers = { @Header(ref = LRAConstants.NARAYANA_LRA_API_VERSION_HEADER_NAME) }), @APIResponse(responseCode = "404", description = "The coordinator has no knowledge of this LRA", content = @Content(schema = @Schema(implementation = String.class))), @APIResponse(responseCode = "417", description = "The requested version provided in HTTP Header is not supported by this end point", content = @Content(schema = @Schema(implementation = String.class))) })
public Response getLRAStatus(@Parameter(name = "LraId", description = "The unique identifier of the LRA." + "Expecting to be a valid URL where the participant can be contacted at. If not in URL format it will be considered " + "to be an id which will be declared to exist at URL where coordinator is deployed at.", required = true) @PathParam("LraId") String lraId, @Parameter(ref = LRAConstants.NARAYANA_LRA_API_VERSION_HEADER_NAME) @HeaderParam(LRAConstants.NARAYANA_LRA_API_VERSION_HEADER_NAME) @DefaultValue(CURRENT_API_VERSION_STRING) String version) throws NotFoundException {
// throws NotFoundException -> response 404
LongRunningAction transaction = lraService.getTransaction(toURI(lraId));
LRAStatus status = transaction.getLRAStatus();
if (status == null) {
status = LRAStatus.Active;
}
return Response.ok().entity(status.name()).header(NARAYANA_LRA_API_VERSION_HEADER_NAME, version).build();
}
use of org.eclipse.microprofile.openapi.annotations.responses.APIResponses in project narayana by jbosstm.
the class Coordinator method getAllLRAs.
@GET
@Path("/")
@Produces(MediaType.APPLICATION_JSON)
@Operation(summary = "Returns all LRAs", description = "Gets both active and recovering LRAs")
@APIResponses({ @APIResponse(responseCode = "200", description = "The LRAData json array which is known to coordinator", content = @Content(schema = @Schema(type = SchemaType.ARRAY, implementation = LRAData.class)), headers = { @Header(ref = LRAConstants.NARAYANA_LRA_API_VERSION_HEADER_NAME) }), @APIResponse(responseCode = "400", description = "Provided Status is not recognized as a valid LRA status value", content = @Content(schema = @Schema(implementation = String.class)), headers = { @Header(ref = LRAConstants.NARAYANA_LRA_API_VERSION_HEADER_NAME) }), @APIResponse(responseCode = "417", description = "The requested version provided in HTTP Header is not supported by this end point", content = @Content(schema = @Schema(implementation = String.class))) })
public Response getAllLRAs(@Parameter(name = STATUS_PARAM_NAME, description = "Filter the returned LRAs to only those in the give state (see CompensatorStatus)") @QueryParam(STATUS_PARAM_NAME) @DefaultValue("") String state, @Parameter(ref = LRAConstants.NARAYANA_LRA_API_VERSION_HEADER_NAME) @HeaderParam(LRAConstants.NARAYANA_LRA_API_VERSION_HEADER_NAME) @DefaultValue(CURRENT_API_VERSION_STRING) String version) {
LRAStatus requestedLRAStatus = null;
if (!state.isEmpty()) {
try {
requestedLRAStatus = LRAStatus.valueOf(state);
} catch (IllegalArgumentException e) {
String errorMsg = "Status " + state + " is not a valid LRAStatus value";
LRALogger.logger.debugf(errorMsg);
throw new WebApplicationException(errorMsg, e, Response.status(BAD_REQUEST).header(NARAYANA_LRA_API_VERSION_HEADER_NAME, version).entity(errorMsg).build());
}
}
List<LRAData> lras = lraService.getAll(requestedLRAStatus);
return Response.ok().entity(lras).header(NARAYANA_LRA_API_VERSION_HEADER_NAME, version).build();
}
Aggregations