From 76a7b9572da7af63b199bfb8d879b1af784e058d Mon Sep 17 00:00:00 2001 From: "CITE\\spapacharalampous" Date: Tue, 10 Sep 2024 17:32:08 +0300 Subject: [PATCH] added common error --- .../org/opencdmp/errorcode/ErrorThesaurusProperties.java | 6 ++++++ .../java/org/opencdmp/service/user/UserServiceImpl.java | 4 ++-- frontend/src/app/core/common/enum/respone-error-code.ts | 1 + 3 files changed, 9 insertions(+), 2 deletions(-) diff --git a/backend/core/src/main/java/org/opencdmp/errorcode/ErrorThesaurusProperties.java b/backend/core/src/main/java/org/opencdmp/errorcode/ErrorThesaurusProperties.java index bfb82d148..5a0fe404e 100644 --- a/backend/core/src/main/java/org/opencdmp/errorcode/ErrorThesaurusProperties.java +++ b/backend/core/src/main/java/org/opencdmp/errorcode/ErrorThesaurusProperties.java @@ -538,4 +538,10 @@ public class ErrorThesaurusProperties { public void setMissingGlobalRole(ErrorDescription missingGlobalRole) { this.missingGlobalRole = missingGlobalRole; } + + private ErrorDescription userProfileInactive; + + public ErrorDescription getUserProfileInactive() { return userProfileInactive; } + + public void setUserProfileInactive(ErrorDescription userProfileInactive) {this.userProfileInactive = userProfileInactive; } } diff --git a/backend/core/src/main/java/org/opencdmp/service/user/UserServiceImpl.java b/backend/core/src/main/java/org/opencdmp/service/user/UserServiceImpl.java index 74bf204ae..0bd2c495f 100644 --- a/backend/core/src/main/java/org/opencdmp/service/user/UserServiceImpl.java +++ b/backend/core/src/main/java/org/opencdmp/service/user/UserServiceImpl.java @@ -351,9 +351,9 @@ public class UserServiceImpl implements UserService { List userCredentials = this.queryFactory.query(UserCredentialQuery.class).disableTracking().userIds(data.getId()).collect(); if (userCredentials.isEmpty()) - throw new MyApplicationException("Currently cannot update roles for this user"); + throw new MyApplicationException(this.errors.getUserProfileInactive().getCode(), this.errors.getUserProfileInactive().getMessage()); if (userCredentials.getFirst().getExternalId() == null) - throw new MyApplicationException("Currently cannot update roles for this user"); + throw new MyApplicationException(this.errors.getUserProfileInactive().getCode(), this.errors.getUserProfileInactive().getMessage()); if (!model.getHasTenantAdminMode()) this.applyGlobalRoles(data.getId(), model); diff --git a/frontend/src/app/core/common/enum/respone-error-code.ts b/frontend/src/app/core/common/enum/respone-error-code.ts index 44c3a145f..349e7d51d 100644 --- a/frontend/src/app/core/common/enum/respone-error-code.ts +++ b/frontend/src/app/core/common/enum/respone-error-code.ts @@ -55,6 +55,7 @@ export enum ResponseErrorCode { planBlueprintImportDraft = 157, missingTenantRole = 158, missingGlobalRole = 159, + userProfileInactive = 160, // Notification & Annotation Errors InvalidApiKey = 200,