From 32bb9ac7358ae218f37bf8f9ec16ab00c854a5a5 Mon Sep 17 00:00:00 2001 From: amentis Date: Wed, 5 Jun 2024 12:08:15 +0300 Subject: [PATCH] handle ui import description without description template error --- .../opencdmp/errorcode/ErrorThesaurusProperties.java | 11 +++++++++++ .../service/description/DescriptionServiceImpl.java | 4 +++- backend/web/src/main/resources/config/errors.yml | 5 ++++- .../src/app/core/common/enum/respone-error-code.ts | 3 +++ dmp-frontend/src/assets/i18n/en.json | 1 + 5 files changed, 22 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 3a4318e9c..91bccbfdc 100644 --- a/backend/core/src/main/java/org/opencdmp/errorcode/ErrorThesaurusProperties.java +++ b/backend/core/src/main/java/org/opencdmp/errorcode/ErrorThesaurusProperties.java @@ -297,4 +297,15 @@ public class ErrorThesaurusProperties { public void setDmpMissingUserContactInfo(ErrorDescription dmpMissingUserContactInfo) { this.dmpMissingUserContactInfo = dmpMissingUserContactInfo; } + + + private ErrorDescription importDescriptionWithoutDmpDescriptionTemplate; + + public ErrorDescription getImportDescriptionWithoutDmpDescriptionTemplate() { + return importDescriptionWithoutDmpDescriptionTemplate; + } + + public void setImportDescriptionWithoutDmpDescriptionTemplate(ErrorDescription importDescriptionWithoutDmpDescriptionTemplate) { + this.importDescriptionWithoutDmpDescriptionTemplate = importDescriptionWithoutDmpDescriptionTemplate; + } } diff --git a/backend/core/src/main/java/org/opencdmp/service/description/DescriptionServiceImpl.java b/backend/core/src/main/java/org/opencdmp/service/description/DescriptionServiceImpl.java index d49ab6137..b97eacc9e 100644 --- a/backend/core/src/main/java/org/opencdmp/service/description/DescriptionServiceImpl.java +++ b/backend/core/src/main/java/org/opencdmp/service/description/DescriptionServiceImpl.java @@ -1281,7 +1281,7 @@ public class DescriptionServiceImpl implements DescriptionService { if (descriptionXml == null) throw new MyNotFoundException("Description xml not found"); - if (this.conventionService.isListNullOrEmpty(dmpDescriptionTemplates)) throw new MyApplicationException("Error creating description without dmp description template"); + if (this.conventionService.isListNullOrEmpty(dmpDescriptionTemplates)) throw new MyValidationException(this.errors.getImportDescriptionWithoutDmpDescriptionTemplate().getCode(), this.errors.getImportDescriptionWithoutDmpDescriptionTemplate().getMessage()); logger.debug(new MapLogEntry("import description").And("dmpId", dmpId).And("fields", fields)); @@ -1442,6 +1442,8 @@ public class DescriptionServiceImpl implements DescriptionService { public Description importJson(DescriptionModel model, UUID dmpId, List dmpDescriptionTemplates, FieldSet fields) throws MyForbiddenException, MyNotFoundException, InvalidApplicationException, IOException { if (model == null) throw new MyNotFoundException("Description common model not found"); + if (this.conventionService.isListNullOrEmpty(dmpDescriptionTemplates)) throw new MyValidationException(this.errors.getImportDescriptionWithoutDmpDescriptionTemplate().getCode(), this.errors.getImportDescriptionWithoutDmpDescriptionTemplate().getMessage()); + logger.debug(new MapLogEntry("import description").And("dmpId", dmpId).And("fields", fields)); DescriptionPersist persist = new DescriptionPersist(); diff --git a/backend/web/src/main/resources/config/errors.yml b/backend/web/src/main/resources/config/errors.yml index 90cb5d28f..8beb29beb 100644 --- a/backend/web/src/main/resources/config/errors.yml +++ b/backend/web/src/main/resources/config/errors.yml @@ -94,4 +94,7 @@ error-thesaurus: message: user dont exist dmp-missing-user-contact-info: code: 135 - message: missing contact info for this user \ No newline at end of file + message: missing contact info for this user + import-description-without-dmp-description-template: + code: 136 + message: Error creating description without dmp description template \ No newline at end of file diff --git a/dmp-frontend/src/app/core/common/enum/respone-error-code.ts b/dmp-frontend/src/app/core/common/enum/respone-error-code.ts index 86683111e..c9403a864 100644 --- a/dmp-frontend/src/app/core/common/enum/respone-error-code.ts +++ b/dmp-frontend/src/app/core/common/enum/respone-error-code.ts @@ -33,6 +33,7 @@ export enum ResponseErrorCode { DescriptionTemplateMissingUserContactInfo = 133, DmpInactiveUser = 134, DmpMissingUserContactInfo = 135, + ImportDescriptionWithoutDmpDescriptionTemplate = 136, // Notification & Annotation Errors InvalidApiKey = 200, @@ -111,6 +112,8 @@ export class ResponseErrorCodeHelper { return language.instant("GENERAL.BACKEND-ERRORS.DMP-INACTIVE-USER"); case ResponseErrorCode.DmpMissingUserContactInfo: return language.instant("GENERAL.BACKEND-ERRORS.DMP-MISSING-USER-CONTACT-INFO"); + case ResponseErrorCode.ImportDescriptionWithoutDmpDescriptionTemplate: + return language.instant("GENERAL.BACKEND-ERRORS.IMPORT-DESCRIPTION-WITHOUT-DMP-DESCRIPTION-TEMPLATE"); case ResponseErrorCode.InvalidApiKey: return language.instant("GENERAL.BACKEND-ERRORS.INVALID-API-KEY"); case ResponseErrorCode.StaleApiKey: diff --git a/dmp-frontend/src/assets/i18n/en.json b/dmp-frontend/src/assets/i18n/en.json index 180503a3e..d0c75af27 100644 --- a/dmp-frontend/src/assets/i18n/en.json +++ b/dmp-frontend/src/assets/i18n/en.json @@ -56,6 +56,7 @@ "MULTIPLE-TENANT-CONFIGURATION-TYPE-NOT-ALLOWED": "Tenant Configuration already exists for this Tenant.", "TENANT-CODE-EXISTS": "The Tenant code you provided already exists. Please choose a different code.", "DMP-NEW-VERSION-ALREADY-CREATED-DRAFT": "You have already created a new draft version for this plan.", + "IMPORT-DESCRIPTION-WITHOUT-DMP-DESCRIPTION-TEMPLATE": "Υour plan contains descriptions that are not defined in which section they will exist", "INVALID-API-KEY": "Invalid configurations detected. Please contact your administrator.", "STALE-API-KEY": "A problem occurred while trying to authorize you. Please try refreshing the page or logging in again. Contact the system administrator if the problem persists.", "SENSITIVE-INFO": "You've reached a section that contains sensitive information. To protect your privacy, please head back to the public area of the site or log in with your authorized account to access this information.",