use of io.swagger.v3.oas.annotations.responses.ApiResponse in project oxTrust by GluuFederation.
the class PeopleWebResource method getPersonByInum.
@GET
@Path(ApiConstants.INUM_PARAM_PATH)
@Operation(summary = "Get person by inum", description = "Get a person by inum")
@ApiResponses(value = { @ApiResponse(responseCode = "200", content = @Content(schema = @Schema(implementation = GluuPersonApi.class)), description = "Success"), @ApiResponse(responseCode = "500", description = "Server error") })
@ProtectedApi(scopes = { READ_ACCESS })
public Response getPersonByInum(@PathParam(ApiConstants.INUM) @NotNull String inum) {
log(logger, "Get person " + inum);
try {
Objects.requireNonNull(inum, "inum should not be null");
GluuCustomPerson person = personService.getPersonByInum(inum);
if (person != null) {
return Response.ok(convert(Arrays.asList(person)).get(0)).build();
} else {
return Response.status(Response.Status.NOT_FOUND).build();
}
} catch (Exception e) {
log(logger, e);
return Response.status(Response.Status.INTERNAL_SERVER_ERROR).build();
}
}
use of io.swagger.v3.oas.annotations.responses.ApiResponse in project oxTrust by GluuFederation.
the class UmaResourceWebResource method addClientToUmaResource.
@POST
@Operation(summary = "Add UMA resource client", description = "add client to uma resource")
@ApiResponses(value = { @ApiResponse(responseCode = "201", content = @Content(schema = @Schema(implementation = UmaResource.class)), description = "Success"), @ApiResponse(responseCode = "500", description = "Server error") })
@Path(ApiConstants.ID_PARAM_PATH + ApiConstants.CLIENTS + ApiConstants.INUM_PARAM_PATH)
@ProtectedApi(scopes = { WRITE_ACCESS })
public Response addClientToUmaResource(@PathParam(ApiConstants.ID) @NotNull String id, @PathParam(ApiConstants.INUM) @NotNull String clientInum) {
try {
log(logger, "Add client " + clientInum + " to uma resource " + id);
Objects.requireNonNull(id, "Uma id should not be null");
Objects.requireNonNull(clientInum, "Client inum should not be null");
List<UmaResource> resources = umaResourcesService.findResourcesById(id);
OxAuthClient client = clientService.getClientByInum(clientInum);
if (resources != null && !resources.isEmpty() && client != null) {
UmaResource umaResource = resources.get(0);
List<String> clientsDn = new ArrayList<String>();
if (umaResource.getClients() != null) {
clientsDn.addAll(umaResource.getClients());
}
clientsDn.add(clientService.getDnForClient(clientInum));
umaResource.setClients(clientsDn);
umaResourcesService.updateResource(umaResource);
return Response.status(Response.Status.CREATED).entity(umaResourcesService.findResourcesById(id).get(0)).build();
} else {
return Response.status(Response.Status.NOT_FOUND).build();
}
} catch (Exception e) {
log(logger, e);
return Response.status(Response.Status.INTERNAL_SERVER_ERROR).build();
}
}
use of io.swagger.v3.oas.annotations.responses.ApiResponse in project oxTrust by GluuFederation.
the class UmaResourceWebResource method addScopeToUmaResource.
@POST
@Operation(summary = "Add UMA resource scope", description = "add scope to uma resource")
@ApiResponses(value = { @ApiResponse(responseCode = "200", content = @Content(schema = @Schema(implementation = UmaResource.class)), description = "Success"), @ApiResponse(responseCode = "500", description = "Server error") })
@Path(ApiConstants.ID_PARAM_PATH + ApiConstants.SCOPES + ApiConstants.INUM_PARAM_PATH)
@ProtectedApi(scopes = { WRITE_ACCESS })
public Response addScopeToUmaResource(@PathParam(ApiConstants.ID) @NotNull String id, @PathParam(ApiConstants.INUM) @NotNull String scopeInum) {
log(logger, "Add scope " + scopeInum + " to uma resource " + id);
try {
Objects.requireNonNull(id, "Uma id should not be null");
Objects.requireNonNull(scopeInum, "scope inum should not be null");
List<UmaResource> resources = umaResourcesService.findResourcesById(id);
Scope umaScope = scopeDescriptionService.getUmaScopeByInum(scopeInum);
if (resources != null && !resources.isEmpty() && umaScope != null) {
UmaResource umaResource = resources.get(0);
List<String> scopesDn = new ArrayList<String>();
if (umaResource.getScopes() != null) {
scopesDn.addAll(umaResource.getScopes());
}
scopesDn.add(scopeDescriptionService.getDnForScope(scopeInum));
umaResource.setScopes(scopesDn);
umaResourcesService.updateResource(umaResource);
return Response.ok(umaResourcesService.findResourcesById(id).get(0)).build();
} else {
return Response.status(Response.Status.NOT_FOUND).build();
}
} catch (Exception e) {
log(logger, e);
return Response.status(Response.Status.INTERNAL_SERVER_ERROR).build();
}
}
use of io.swagger.v3.oas.annotations.responses.ApiResponse in project snow-owl by b2ihealthcare.
the class SnomedClassificationRestService method beginClassification.
@Operation(summary = "Start a classification on a branch", description = "Classification runs are async jobs. The call to this method immediately returns with a unique URL " + "pointing to the classification run.<p>The URL can be used to fetch the state of the classification " + "to determine whether it's completed or not.")
@ApiResponses({ @ApiResponse(responseCode = "201", description = "Created"), @ApiResponse(responseCode = "404", description = "Branch not found") })
@PostMapping(consumes = { AbstractRestService.JSON_MEDIA_TYPE })
@ResponseStatus(value = HttpStatus.CREATED)
public Promise<ResponseEntity<?>> beginClassification(@Parameter(description = "Classification parameters") @RequestBody final ClassificationRunRestInput request, @RequestHeader(value = X_AUTHOR, required = false) final String author) {
ApiValidation.checkInput(request);
final UriComponentsBuilder linkTo = MvcUriComponentsBuilder.fromController(SnomedClassificationRestService.class);
return ClassificationRequests.prepareCreateClassification().setReasonerId(request.getReasonerId()).setUserId(author).build(request.getPath()).execute(getBus()).then(id -> {
final URI resourceUri = linkTo.pathSegment(id).build().toUri();
return ResponseEntity.created(resourceUri).build();
});
}
use of io.swagger.v3.oas.annotations.responses.ApiResponse in project snow-owl by b2ihealthcare.
the class SnomedDescriptionRestService method create.
@Operation(summary = "Create Description", description = "Creates a new Description directly on a version.")
@ApiResponses({ @ApiResponse(responseCode = "201", description = "Created"), @ApiResponse(responseCode = "404", description = "Branch not found") })
@PostMapping(consumes = { AbstractRestService.JSON_MEDIA_TYPE })
@ResponseStatus(HttpStatus.CREATED)
public ResponseEntity<Void> create(@Parameter(description = "The resource path", required = true) @PathVariable(value = "path") final String path, @Parameter(description = "Description parameters") @RequestBody final SnomedResourceRequest<SnomedDescriptionRestInput> body, @RequestHeader(value = X_AUTHOR, required = false) final String author) {
final SnomedDescriptionRestInput change = body.getChange();
final String commitComment = body.getCommitComment();
final String defaultModuleId = body.getDefaultModuleId();
final String createdDescriptionId = change.toRequestBuilder().commit().setDefaultModuleId(defaultModuleId).setAuthor(author).setCommitComment(commitComment).build(path).execute(getBus()).getSync(COMMIT_TIMEOUT, TimeUnit.MINUTES).getResultAs(String.class);
return ResponseEntity.created(getResourceLocationURI(path, createdDescriptionId)).build();
}
Aggregations