use of com.b2international.commons.exceptions.NotFoundException in project snow-owl by b2ihealthcare.
the class AbstractBranchChangeRequest method execute.
@Override
public Merge execute(RepositoryContext context) {
try {
final Branch source = RepositoryRequests.branching().prepareGet(sourcePath).build().execute(context);
final Branch target = RepositoryRequests.branching().prepareGet(targetPath).build().execute(context);
Merge merge = Merge.builder().source(sourcePath).target(targetPath).build();
try {
Commit commit = applyChanges(context, source, target);
if (commit != null) {
context.service(RepositoryCommitNotificationSender.class).publish(context, commit);
}
return merge.completed();
} catch (BranchMergeConflictException e) {
return merge.failedWithConflicts(e.getMessage(), toMergeConflicts(e.getConflicts()));
} catch (ApiException e) {
return merge.failed(e.toApiError());
} catch (RuntimeException e) {
context.log().error("Failed to merge {} into {}", sourcePath, targetPath, e);
return merge.failed(ApiError.of(e.getMessage()));
}
} catch (NotFoundException e) {
throw e.toBadRequestException();
}
}
use of com.b2international.commons.exceptions.NotFoundException in project snow-owl by b2ihealthcare.
the class CodeSystemRestService method delete.
@Operation(summary = "Delete a CodeSystem", description = "Deletes a CodeSystem permanently from the server")
@ApiResponses({ @ApiResponse(responseCode = "204", description = "No content"), @ApiResponse(responseCode = "400", description = "Bad Request"), @ApiResponse(responseCode = "409", description = "CodeSystem cannot be deleted") })
@DeleteMapping(value = "/{codeSystemId}")
@ResponseStatus(HttpStatus.NO_CONTENT)
public void delete(@Parameter(description = "The code system identifier") @PathVariable(value = "codeSystemId") final String codeSystemId, @RequestHeader(value = X_AUTHOR, required = false) final String author) {
try {
final CodeSystem codeSystem = CodeSystemRequests.prepareGetCodeSystem(codeSystemId).buildAsync().execute(getBus()).getSync(1, TimeUnit.MINUTES);
ResourceRequests.prepareDelete(codeSystemId).build(author, String.format("Deleted Code System %s", codeSystem.getTitle())).execute(getBus()).getSync(COMMIT_TIMEOUT, TimeUnit.MINUTES);
} catch (NotFoundException e) {
// already deleted, ignore error
}
}
use of com.b2international.commons.exceptions.NotFoundException in project snow-owl by b2ihealthcare.
the class CodeSystemUpgradeRestService method complete.
@Operation(summary = "Complete a codesystem upgrade (EXPERIMENTAL)", description = "Completes the upgrade process of a Code System to the newer extensionOf Code System dependency.")
@ApiResponses({ @ApiResponse(responseCode = "204", description = "Code system upgrade completed"), @ApiResponse(responseCode = "400", description = "Code System upgrade cannot be completed") })
@PostMapping("/{id}/complete")
@ResponseStatus(HttpStatus.NO_CONTENT)
public void complete(@Parameter(description = "Code System identifier", required = true) @PathVariable("id") final String codeSystemId) {
CodeSystemRequests.prepareSearchCodeSystem().filterById(codeSystemId).buildAsync().execute(getBus()).getSync(1, TimeUnit.MINUTES).first().orElseThrow(() -> new NotFoundException("Code System", codeSystemId));
CodeSystemRequests.prepareComplete(codeSystemId).buildAsync().execute(getBus());
}
use of com.b2international.commons.exceptions.NotFoundException in project snow-owl by b2ihealthcare.
the class CodeSystemUpgradeRestService method sync.
@Operation(summary = "Synchronize upgrade codesystem with the original codesystem (EXPERIMENTAL)", description = "Synchronize any changes on the original code system with the upgrade code system.")
@ApiResponses({ @ApiResponse(responseCode = "204", description = "Upgrade code system synchronized"), @ApiResponse(responseCode = "400", description = "Code system could not be synchronized with the downstream code system") })
@PostMapping(value = "/sync/", consumes = { AbstractRestService.JSON_MEDIA_TYPE })
@ResponseStatus(HttpStatus.NO_CONTENT)
public void sync(@RequestBody final CodeSystemUpgradeSyncRestInput body) {
final String codeSystemId = body.getCodeSystemId();
final ResourceURI source = body.getSource();
final CodeSystem codeSystem = CodeSystemRequests.prepareSearchCodeSystem().filterById(codeSystemId).buildAsync().execute(getBus()).getSync(1, TimeUnit.MINUTES).first().orElseThrow(() -> new NotFoundException("Code System", codeSystemId));
CodeSystemRequests.prepareUpgradeSynchronization(codeSystem.getResourceURI(), source).buildAsync().execute(getBus());
}
use of com.b2international.commons.exceptions.NotFoundException in project snow-owl by b2ihealthcare.
the class AttachmentRegistryTest method delete.
@Test
public void delete() throws Exception {
final UUID id = UUID.randomUUID();
upload(id, "file-reg-upload.zip");
assertTrue(exists(id));
registry.delete(id);
try {
registry.getAttachment(id);
fail("Expected exception " + NotFoundException.class.getName());
} catch (NotFoundException e) {
// expected
}
}
Aggregations