handle ui import description without description template error

This commit is contained in:
amentis 2024-06-05 12:08:15 +03:00
parent b2715dcf24
commit 32bb9ac735
5 changed files with 22 additions and 2 deletions

View File

@ -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;
}
}

View File

@ -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<DmpDescriptionTemplateEntity> 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();

View File

@ -95,3 +95,6 @@ error-thesaurus:
dmp-missing-user-contact-info:
code: 135
message: missing contact info for this user
import-description-without-dmp-description-template:
code: 136
message: Error creating description without dmp description template

View File

@ -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:

View File

@ -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.",