use of io.swagger.v3.oas.models.parameters.RequestBody in project snow-owl by b2ihealthcare.
the class VersionRestService method createVersion.
@Operation(summary = "Create a new resource version", description = "Creates a new resource version. " + "The version tag (represented by an empty branch) is created on the resource's current working branch. " + "Where applicable, effective times are set on the unpublished content as part of this operation.")
@ApiResponses({ @ApiResponse(responseCode = "201", description = "Created"), @ApiResponse(responseCode = "404", description = "Not found"), @ApiResponse(responseCode = "409", description = "Code system version conflicts with existing branch") })
@PostMapping(consumes = { AbstractRestService.JSON_MEDIA_TYPE })
@ResponseStatus(value = HttpStatus.CREATED)
public ResponseEntity<Void> createVersion(@Parameter(description = "Version parameters") @RequestBody final ResourceRequest<VersionRestInput> input) {
final VersionRestInput change = input.getChange();
ApiValidation.checkInput(change);
String newVersionUri = String.join(Branch.SEPARATOR, change.getResource().toString(), change.getVersion());
String jobId = ResourceRequests.prepareNewVersion().setResource(change.getResource()).setVersion(change.getVersion()).setDescription(change.getDescription()).setEffectiveTime(change.getEffectiveTime()).setForce(change.isForce()).setCommitComment(input.getCommitComment()).buildAsync().runAsJobWithRestart(ResourceRequests.versionJobKey(change.getResource()), "Creating version " + newVersionUri).execute(getBus()).getSync(1, TimeUnit.MINUTES);
RemoteJobEntry job = JobRequests.waitForJob(getBus(), jobId, 500);
if (job.isSuccessful()) {
final URI location = MvcUriComponentsBuilder.fromMethodName(VersionRestService.class, "getVersion", newVersionUri).build().toUri();
return ResponseEntity.created(location).build();
} else if (!Strings.isNullOrEmpty(job.getResult())) {
ApiError error = job.getResultAs(ApplicationContext.getServiceForClass(ObjectMapper.class), ApiError.class);
throw new ApiErrorException(error.withMessage(error.getMessage().replace("Branch name", "Version")));
} else {
throw new SnowowlRuntimeException("Version creation failed.");
}
}
use of io.swagger.v3.oas.models.parameters.RequestBody in project snow-owl by b2ihealthcare.
the class SnomedRelationshipRestService method update.
@Operation(summary = "Update Relationship", description = "Updates properties of the specified Relationship.")
@ApiResponses({ @ApiResponse(responseCode = "204", description = "No content"), @ApiResponse(responseCode = "404", description = "Branch or Relationship not found") })
@PutMapping(value = "/{relationshipId}", consumes = { AbstractRestService.JSON_MEDIA_TYPE })
@ResponseStatus(HttpStatus.NO_CONTENT)
public void update(@Parameter(description = "The resource path", required = true) @PathVariable("path") final String path, @Parameter(description = "The Relationship identifier") @PathVariable("relationshipId") final String relationshipId, @Parameter(description = "Update Relationship parameters") @RequestBody final SnomedResourceRequest<SnomedRelationshipRestUpdate> body, @Parameter(description = "Force update flag") @RequestParam(defaultValue = "false", required = false) final Boolean force, @RequestHeader(value = X_AUTHOR, required = false) final String author) {
final String commitComment = body.getCommitComment();
final SnomedRelationshipRestUpdate update = body.getChange();
final String defaultModuleId = body.getDefaultModuleId();
update.toRequestBuilder(relationshipId).force(force).commit().setDefaultModuleId(defaultModuleId).setAuthor(author).setCommitComment(commitComment).build(path).execute(getBus()).getSync(COMMIT_TIMEOUT, TimeUnit.MINUTES);
}
use of io.swagger.v3.oas.models.parameters.RequestBody in project snow-owl by b2ihealthcare.
the class SnomedRelationshipRestService method create.
@Operation(summary = "Create Relationship", description = "Creates a new Relationship directly on a version path.")
@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("path") final String path, @Parameter(description = "Relationship parameters") @RequestBody final SnomedResourceRequest<SnomedRelationshipRestInput> body, @RequestHeader(value = X_AUTHOR, required = false) final String author) {
final SnomedRelationshipRestInput change = body.getChange();
final String commitComment = body.getCommitComment();
final String defaultModuleId = body.getDefaultModuleId();
final String createdRelationshipId = 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, createdRelationshipId)).build();
}
use of io.swagger.v3.oas.models.parameters.RequestBody in project snow-owl by b2ihealthcare.
the class SnomedConceptRestService method update.
@Operation(summary = "Update Concept", description = "Updates properties of the specified Concept, also managing inactivation indicator and association reference set " + "membership in case of inactivation." + "<p>The following properties are allowed to change:" + "<p>" + "• module identifier<br>" + "• subclass definition status<br>" + "• definition status<br>" + "• associated Concepts<br>" + "" + "<p>The following properties, when changed, will trigger inactivation:" + "<p>" + "• inactivation indicator<br>")
@ApiResponses({ @ApiResponse(responseCode = "204", description = "No Content"), @ApiResponse(responseCode = "404", description = "Branch or Concept not found") })
@PutMapping(value = "/{conceptId}", consumes = { AbstractRestService.JSON_MEDIA_TYPE })
@ResponseStatus(HttpStatus.NO_CONTENT)
public void update(@Parameter(description = "The resource path", required = true) @PathVariable(value = "path") final String path, @Parameter(description = "The Concept identifier") @PathVariable(value = "conceptId") final String conceptId, @Parameter(description = "Updated Concept parameters") @RequestBody final SnomedResourceRequest<SnomedConceptRestUpdate> body, @Parameter(description = "Force update flag") @RequestParam(defaultValue = "false", required = false) final Boolean force, @RequestHeader(value = X_AUTHOR, required = false) final String author) {
final SnomedConceptRestUpdate change = body.getChange();
final String commitComment = body.getCommitComment();
final String defaultModuleId = body.getDefaultModuleId();
change.toRequestBuilder(conceptId).force(force).commit().setDefaultModuleId(defaultModuleId).setAuthor(author).setCommitComment(commitComment).build(path).execute(getBus()).getSync(COMMIT_TIMEOUT, TimeUnit.MINUTES);
}
use of io.swagger.v3.oas.models.parameters.RequestBody in project snow-owl by b2ihealthcare.
the class CisAuthenticationService method authenticate.
@Operation(summary = "Validates a token, checking if it's assigned to a current session, and retrieves user data.")
@ApiResponses({ @ApiResponse(responseCode = "400", description = "Error"), @ApiResponse(responseCode = "401", description = "Unauthorized") })
@PostMapping(value = "/authenticate")
public UserData authenticate(@Parameter(description = "The security access token.", required = true) @RequestBody Token token) {
String username = verify(token.getToken());
if (Strings.isNullOrEmpty(username)) {
throw new UnauthorizedException("Token does not validate.");
} else {
final UserData userData = new UserData();
userData.setUsername(username);
return userData;
}
}
Aggregations