Skip to content

Commit

Permalink
[25999] pass bluemedication exception to hin oauth service
Browse files Browse the repository at this point in the history
  • Loading branch information
huthomas committed Dec 7, 2023
1 parent d52057f commit 77115c7
Showing 1 changed file with 15 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -153,6 +153,7 @@ public Result<UploadResult> uploadDocument(IPatient patient, File document, Stri
new UploadResult(appendPath(getBrowserBasePath(), data.getUrl() + "&mode=embed"), data.getId(),
resulttyp, uploadedMediplan));
} catch (ApiException e) {
hinAuthHandleException(e);
if (e.getCode() == 400 || e.getCode() == 422) {
// error result code should be evaluated
try {
Expand All @@ -172,6 +173,16 @@ public Result<UploadResult> uploadDocument(IPatient patient, File document, Stri
}
}

private void hinAuthHandleException(ApiException e) {
if (hinAuthService.isPresent()) {
Optional<String> message = hinAuthService.get().handleException(e,
Collections.singletonMap(IHinAuthService.TOKEN_GROUP, getTokenGroup()));
if (message.isPresent()) {
logger.warn("HIN Auth message", message.get());
}
}
}

private void configureApiClient(ApiClient client) {
client.setBasePath(getAppBasePath());
if(hinAuthService.isPresent()) {
Expand Down Expand Up @@ -249,6 +260,7 @@ public Result<UploadResult> uploadCheck(IPatient patient) {
return new Result<UploadResult>(SEVERITY.ERROR, 0, "No active mandator", null, false);
}
} catch (ApiException e) {
hinAuthHandleException(e);
if (e.getCode() == 400 || e.getCode() == 422) {
// error result code should be evaluated
try {
Expand Down Expand Up @@ -286,6 +298,7 @@ public Result<String> emediplanNotification(IPatient patient) {
DateTimeFormatter.ofPattern("dd.MM.yyyy").format(birthDate));
return Result.OK(response.toString());
} catch (ApiException e) {
hinAuthHandleException(e);
if (e.getCode() == 400 || e.getCode() == 422) {
// error result code should be evaluated
try {
Expand Down Expand Up @@ -388,6 +401,7 @@ public Result<String> downloadEMediplan(UploadResult uploadResult) {
return Result.OK(response.getData());
}
} catch (ApiException e) {
hinAuthHandleException(e);
logger.error("Error downloading Document", e);
return Result.ERROR(e.getMessage());
}
Expand All @@ -408,6 +422,7 @@ public Result<String> downloadPdf(UploadResult uploadResult) {
}
return Result.OK(response.getData().getAbsolutePath());
} catch (ApiException e) {
hinAuthHandleException(e);
logger.error("Error downloading Document Pdf", e);
return Result.ERROR(e.getMessage());
}
Expand Down

0 comments on commit 77115c7

Please sign in to comment.