From 152320dbd001a2981971271a906a35e6a1af49be Mon Sep 17 00:00:00 2001 From: sgiannopoulos Date: Wed, 26 Jun 2024 11:32:42 +0300 Subject: [PATCH 1/4] migration fixes --- ...escriptionTemplateXmlMigrationService.java | 50 +++++++++---------- .../eudat/migration/DmpMigrationService.java | 15 ++++-- 2 files changed, 37 insertions(+), 28 deletions(-) diff --git a/dmp-migration-tool/web/src/main/java/eu/old/eudat/migration/DescriptionTemplateXmlMigrationService.java b/dmp-migration-tool/web/src/main/java/eu/old/eudat/migration/DescriptionTemplateXmlMigrationService.java index de94e8d66..f2bbb9c62 100644 --- a/dmp-migration-tool/web/src/main/java/eu/old/eudat/migration/DescriptionTemplateXmlMigrationService.java +++ b/dmp-migration-tool/web/src/main/java/eu/old/eudat/migration/DescriptionTemplateXmlMigrationService.java @@ -102,7 +102,7 @@ public class DescriptionTemplateXmlMigrationService { logger.error("Migrate DescriptionTemplate " + item.getId() + " failed read xml"); throw new MyApplicationException("Migrate DescriptionTemplate " + item.getId() + " failed read xml"); } - item.setDefinition(this.xmlHandlingService.toXml(this.buildDefinitionEntity(viewStyleModel, referenceTypeEntityMap, knownReferenceEntities))); + item.setDefinition(this.xmlHandlingService.toXml(this.buildDefinitionEntity(viewStyleModel, referenceTypeEntityMap, knownReferenceEntities, item.getId()))); this.entityManager.merge(item); } @@ -118,22 +118,22 @@ public class DescriptionTemplateXmlMigrationService { this.entityManager.flush(); } - private @NotNull DefinitionEntity buildDefinitionEntity(ViewStyleModel persist, Map referenceTypeEntityMap, Map knownReferenceEntities) throws URISyntaxException { + private @NotNull DefinitionEntity buildDefinitionEntity(ViewStyleModel persist, Map referenceTypeEntityMap, Map knownReferenceEntities, UUID descriptionTemplateId) throws URISyntaxException { DefinitionEntity data = new DefinitionEntity(); if (persist == null) return data; if (!this.conventionService.isListNullOrEmpty(persist.getPages())) { - Map> sectionPerPage = mapSectionsToPage(persist); + Map> sectionPerPage = mapSectionsToPage(persist, descriptionTemplateId); data.setPages(new ArrayList<>()); for (Page pagePersist : persist.getPages()) { - data.getPages().add(this.buildPageEntity(pagePersist, sectionPerPage.get(pagePersist.getId().trim()), referenceTypeEntityMap, knownReferenceEntities)); + data.getPages().add(this.buildPageEntity(pagePersist, sectionPerPage.get(pagePersist.getId().trim()), referenceTypeEntityMap, knownReferenceEntities, descriptionTemplateId)); } } return data; } - private @NotNull SectionEntity buildSectionEntity(Section persist, Map referenceTypeEntityMap, Map knownReferenceEntities) throws URISyntaxException { + private @NotNull SectionEntity buildSectionEntity(Section persist, Map referenceTypeEntityMap, Map knownReferenceEntities, UUID descriptionTemplateId) throws URISyntaxException { SectionEntity data = new SectionEntity(); if (persist == null) return data; @@ -147,21 +147,21 @@ public class DescriptionTemplateXmlMigrationService { if (!this.conventionService.isListNullOrEmpty(persist.getSections())) { data.setSections(new ArrayList<>()); for (Section sectionPersist : persist.getSections()) { - data.getSections().add(this.buildSectionEntity(sectionPersist, referenceTypeEntityMap, knownReferenceEntities)); + data.getSections().add(this.buildSectionEntity(sectionPersist, referenceTypeEntityMap, knownReferenceEntities, descriptionTemplateId)); } } if (!this.conventionService.isListNullOrEmpty(persist.getFieldSets())) { data.setFieldSets(new ArrayList<>()); for (FieldSet fieldSetPersist : persist.getFieldSets()) { - data.getFieldSets().add(this.buildFieldSetEntity(fieldSetPersist, referenceTypeEntityMap, knownReferenceEntities)); + data.getFieldSets().add(this.buildFieldSetEntity(fieldSetPersist, referenceTypeEntityMap, knownReferenceEntities, descriptionTemplateId)); } } return data; } - private @NotNull FieldSetEntity buildFieldSetEntity(FieldSet persist, Map referenceTypeEntityMap, Map knownReferenceEntities) throws URISyntaxException { + private @NotNull FieldSetEntity buildFieldSetEntity(FieldSet persist, Map referenceTypeEntityMap, Map knownReferenceEntities, UUID descriptionTemplateId) throws URISyntaxException { FieldSetEntity data = new FieldSetEntity(); if (persist == null) return data; @@ -180,13 +180,13 @@ public class DescriptionTemplateXmlMigrationService { if (!this.conventionService.isListNullOrEmpty(persist.getFields())) { data.setFields(new ArrayList<>()); for (Field fieldPersist : persist.getFields()) { - data.getFields().add(this.buildFieldEntity(fieldPersist, referenceTypeEntityMap, knownReferenceEntities)); + data.getFields().add(this.buildFieldEntity(fieldPersist, referenceTypeEntityMap, knownReferenceEntities, descriptionTemplateId)); } } return data; } - private @NotNull FieldEntity buildFieldEntity(Field persist, Map referenceTypeEntityMap, Map knownReferenceEntities) throws URISyntaxException { + private @NotNull FieldEntity buildFieldEntity(Field persist, Map referenceTypeEntityMap, Map knownReferenceEntities, UUID descriptionTemplateId) throws URISyntaxException { FieldEntity data = new FieldEntity(); if (persist == null) return data; @@ -230,7 +230,7 @@ public class DescriptionTemplateXmlMigrationService { } } - if (persist.getDefaultValue() != null) data.setDefaultValue(this.buildDefaultValueEntity(persist.getDefaultValue(), data.getData().getFieldType())); + if (persist.getDefaultValue() != null) data.setDefaultValue(this.buildDefaultValueEntity(persist.getDefaultValue(), data.getData().getFieldType(), descriptionTemplateId)); if (persist.getVisible() != null && !this.conventionService.isListNullOrEmpty(persist.getVisible().getRules())) { data.setVisibilityRules(new ArrayList<>()); for (Rule fieldPersist : persist.getVisible().getRules()) { @@ -402,7 +402,7 @@ public class DescriptionTemplateXmlMigrationService { return data; } - private @NotNull DefaultValueEntity buildDefaultValueEntity(DefaultValue persist, FieldType fieldType) { + private @NotNull DefaultValueEntity buildDefaultValueEntity(DefaultValue persist, FieldType fieldType, UUID descriptionTemplateId) { DefaultValueEntity data = new DefaultValueEntity(); if (persist == null) return data; @@ -439,9 +439,9 @@ public class DescriptionTemplateXmlMigrationService { case UPLOAD -> throw new NotSupportedException("Upload validator not supported"); case TAGS -> throw new NotSupportedException("Tags validator not supported"); - case INTERNAL_ENTRIES_DMPS -> throw new NotSupportedException("INTERNAL_ENTRIES_DMPS validator not supported"); - case INTERNAL_ENTRIES_DESCRIPTIONS -> throw new NotSupportedException("INTERNAL_ENTRIES_DESCRIPTIONS validator not supported"); - case REFERENCE_TYPES -> throw new NotSupportedException("REFERENCE_TYPES validator not supported"); + case INTERNAL_ENTRIES_DMPS -> throw new NotSupportedException("INTERNAL_ENTRIES_DMPS validator not supported for description template " + descriptionTemplateId); + case INTERNAL_ENTRIES_DESCRIPTIONS -> throw new NotSupportedException("INTERNAL_ENTRIES_DESCRIPTIONS validator not supported for description template " + descriptionTemplateId); + case REFERENCE_TYPES -> throw new NotSupportedException("REFERENCE_TYPES validator not supported for description template " + descriptionTemplateId); default -> throw new MyApplicationException("unrecognized type " + fieldType); } return data; @@ -514,7 +514,7 @@ public class DescriptionTemplateXmlMigrationService { - private @NotNull PageEntity buildPageEntity(Page persist, List
sections, Map referenceTypeEntityMap, Map knownReferenceEntities) throws URISyntaxException { + private @NotNull PageEntity buildPageEntity(Page persist, List
sections, Map referenceTypeEntityMap, Map knownReferenceEntities, UUID descriptionTemplateId) throws URISyntaxException { PageEntity data = new PageEntity(); if (persist == null) return data; @@ -526,14 +526,14 @@ public class DescriptionTemplateXmlMigrationService { if (!this.conventionService.isListNullOrEmpty(sections)) { data.setSections(new ArrayList<>()); for (Section sectionPersist : sections) { - data.getSections().add(this.buildSectionEntity(sectionPersist, referenceTypeEntityMap, knownReferenceEntities)); + data.getSections().add(this.buildSectionEntity(sectionPersist, referenceTypeEntityMap, knownReferenceEntities, descriptionTemplateId)); } } return data; } - private Map> mapSectionsToPage(ViewStyleModel persist){ + private Map> mapSectionsToPage(ViewStyleModel persist, UUID descriptionTemplateId){ List mappedSectionsIds = new ArrayList<>(); Map> sectionPerPage = new HashMap<>(); if (persist == null || persist.getPages() == null || persist.getSections() == null) return sectionPerPage; @@ -550,7 +550,7 @@ public class DescriptionTemplateXmlMigrationService { } for (Section section : persist.getSections()){ - if (!mappedSectionsIds.contains(section.getId().trim())) throw new MyApplicationException("Orphan section found " + section.getId().trim()); + if (!mappedSectionsIds.contains(section.getId().trim())) throw new MyApplicationException("Orphan section found " + section.getId().trim() + " for description template " + descriptionTemplateId); } return sectionPerPage; @@ -664,12 +664,12 @@ public class DescriptionTemplateXmlMigrationService { String source = persist.getAutoCompleteOptions() != null ? persist.getAutoCompleteOptions().getSource() : null; if ( source == null || source.isEmpty()) { - URI uri; - if (persist.getUrl().contains("?")) { - uri = new URI(persist.getUrl().substring(0, persist.getUrl().trim().lastIndexOf("?"))); - } else { - uri = new URI(persist.getUrl().trim()); - } + URI uri; + if (persist.getUrl().contains("?")) { + uri = new URI(persist.getUrl().substring(0, persist.getUrl().trim().lastIndexOf("?"))); + } else { + uri = new URI(persist.getUrl().trim()); + } source = uri.getHost(); } String parsedUrl = persist.getUrl().trim(); diff --git a/dmp-migration-tool/web/src/main/java/eu/old/eudat/migration/DmpMigrationService.java b/dmp-migration-tool/web/src/main/java/eu/old/eudat/migration/DmpMigrationService.java index 159a96d4a..db8dfeadf 100644 --- a/dmp-migration-tool/web/src/main/java/eu/old/eudat/migration/DmpMigrationService.java +++ b/dmp-migration-tool/web/src/main/java/eu/old/eudat/migration/DmpMigrationService.java @@ -39,6 +39,9 @@ import org.xml.sax.SAXException; import javax.xml.parsers.ParserConfigurationException; import java.io.IOException; import java.time.Instant; +import java.time.LocalDate; +import java.time.ZoneOffset; +import java.time.format.DateTimeParseException; import java.util.*; import java.util.stream.Collectors; @@ -105,7 +108,7 @@ public class DmpMigrationService { for (DMP item : items) { //entityManager.detach(item); - org.opencdmp.commons.types.dmpblueprint.DefinitionEntity definitionEntity = blueprintDefinitionMap.get(item.getId()); + org.opencdmp.commons.types.dmpblueprint.DefinitionEntity definitionEntity = blueprintDefinitionMap.get(item.getProfile().getId()); DataManagementPlan model = new DataManagementPlan(); model.fromDataModel(item); List itemGroupDmps = groupDmpMap.get(item.getGroupId()); @@ -180,10 +183,16 @@ public class DmpMigrationService { DmpBlueprintValueEntity valueEntity = new DmpBlueprintValueEntity(); valueEntity.setFieldId(UUID.fromString(key)); org.opencdmp.commons.types.dmpblueprint.FieldEntity fieldEntity = this.getFieldOfId(definitionEntity, valueEntity.getFieldId()); - if (fieldEntity != null && fieldEntity.getCategory().equals(DmpBlueprintFieldCategory.Extra)){ + if (fieldEntity != null && val != null && fieldEntity.getCategory().equals(DmpBlueprintFieldCategory.Extra)){ ExtraFieldEntity extraFieldEntity = (ExtraFieldEntity) fieldEntity; switch (extraFieldEntity.getType()){ - case Date -> valueEntity.setDateValue(Instant.parse((String) val)); + case Date -> { + try { + valueEntity.setDateValue(Instant.parse((String) val)); + } catch (DateTimeParseException ex) { + valueEntity.setDateValue(LocalDate.parse((String) val).atStartOfDay().toInstant(ZoneOffset.UTC)); + } + } case RichTex, Text -> valueEntity.setValue((String) val); case Number -> valueEntity.setNumberValue(Double.parseDouble((String) val)); default -> throw new MyApplicationException("unrecognized type " + extraFieldEntity.getType().getValue()); From e1780128441c45e9b665c71cd6fd75030bb7b72c Mon Sep 17 00:00:00 2001 From: sgiannopoulos Date: Wed, 26 Jun 2024 11:34:08 +0300 Subject: [PATCH 2/4] Remove unused tables --- .../updates/00.02.000_RemoveUnusedTables.sql | 43 +++++++++++++++++++ 1 file changed, 43 insertions(+) create mode 100644 dmp-db-scema/updates/00.02.000_RemoveUnusedTables.sql diff --git a/dmp-db-scema/updates/00.02.000_RemoveUnusedTables.sql b/dmp-db-scema/updates/00.02.000_RemoveUnusedTables.sql new file mode 100644 index 000000000..7a950e3ab --- /dev/null +++ b/dmp-db-scema/updates/00.02.000_RemoveUnusedTables.sql @@ -0,0 +1,43 @@ +DO $$DECLARE + this_version CONSTANT varchar := '00.02.000'; +BEGIN + PERFORM * FROM "DBVersion" WHERE version = this_version; + IF FOUND THEN RETURN; END IF; + + DROP TABLE public."DatasetDataRepository"; + DROP TABLE public."DatasetExternalDataset"; + DROP TABLE public."DatasetRegistry"; + DROP TABLE public."DatasetService"; + DROP TABLE public."Dataset"; + + DROP TABLE public."DMPDatasetProfile"; + DROP TABLE public."DMPOrganisation"; + DROP TABLE public."DMPResearcher"; + DROP TABLE public."UserDMP"; + DROP TABLE public."Invitation"; + DROP TABLE public."DMP"; + + DROP TABLE public."DoiFunder"; + + DROP TABLE public."DataRepository"; + DROP TABLE public."ExternalDataset"; + DROP TABLE public."Project"; + DROP TABLE public."Funder"; + DROP TABLE public."Grant"; + DROP TABLE public."Organisation"; + DROP TABLE public."Registry"; + DROP TABLE public."Researcher"; + DROP TABLE public."Service"; + + DROP TABLE public."Content"; + DROP TABLE public."Credential"; + DROP TABLE public."EmailConfirmation"; + DROP TABLE public."FileUpload"; + DROP TABLE public."NotificationLegacy"; + DROP TABLE public."UserAssociation"; + DROP TABLE public."UserToken"; + DROP TABLE public."UserInfo"; + + INSERT INTO public."DBVersion" VALUES ('DMPDB', '00.02.000', '2024-06-26 12:00:00.000000+02', now(), 'Remove unused tables.'); + +END$$; \ No newline at end of file From 2b98087b032b8018c528bb1ac0ab33a8d47515b1 Mon Sep 17 00:00:00 2001 From: amentis Date: Wed, 26 Jun 2024 11:50:19 +0300 Subject: [PATCH 3/4] user invite to tenant fix validation --- .../model/persist/UserInviteToTenantRequestPersist.java | 3 --- .../java/org/opencdmp/service/user/UserServiceImpl.java | 2 ++ .../user-invite-to-tenant-dialog-editor.model.ts | 6 +++--- .../user-invite-to-tenant-dialog.component.ts | 6 +++--- dmp-frontend/src/assets/i18n/baq.json | 4 +++- dmp-frontend/src/assets/i18n/de.json | 4 +++- dmp-frontend/src/assets/i18n/en.json | 4 +++- dmp-frontend/src/assets/i18n/es.json | 4 +++- dmp-frontend/src/assets/i18n/gr.json | 4 +++- dmp-frontend/src/assets/i18n/hr.json | 4 +++- dmp-frontend/src/assets/i18n/pl.json | 4 +++- dmp-frontend/src/assets/i18n/pt.json | 4 +++- dmp-frontend/src/assets/i18n/sk.json | 4 +++- dmp-frontend/src/assets/i18n/sr.json | 4 +++- dmp-frontend/src/assets/i18n/tr.json | 4 +++- 15 files changed, 41 insertions(+), 20 deletions(-) diff --git a/backend/core/src/main/java/org/opencdmp/model/persist/UserInviteToTenantRequestPersist.java b/backend/core/src/main/java/org/opencdmp/model/persist/UserInviteToTenantRequestPersist.java index 4a69f719c..a4d55e835 100644 --- a/backend/core/src/main/java/org/opencdmp/model/persist/UserInviteToTenantRequestPersist.java +++ b/backend/core/src/main/java/org/opencdmp/model/persist/UserInviteToTenantRequestPersist.java @@ -75,9 +75,6 @@ public class UserInviteToTenantRequestPersist { this.spec() .must(() -> !this.isEmpty(item.getEmail())) .failOn(UserInviteToTenantRequestPersist._email).failWith(messageSource.getMessage("Validation_Required", new Object[]{UserInviteToTenantRequestPersist._email}, LocaleContextHolder.getLocale())), - this.spec() - .must(() -> !this.isEmpty(item.getTenantCode())) - .failOn(UserInviteToTenantRequestPersist._tenantCode).failWith(messageSource.getMessage("Validation_Required", new Object[]{UserInviteToTenantRequestPersist._tenantCode}, LocaleContextHolder.getLocale())), this.spec() .iff(() -> !this.isEmpty(item.getEmail())) .must(() -> this.isValidEmail(item.getEmail())) 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 f754dedf3..685f2eab9 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 @@ -923,6 +923,8 @@ public class UserServiceImpl implements UserService { public void sendUserToTenantInvitation(UserTenantUsersInviteRequest users) throws InvalidApplicationException, JAXBException { this.authorizationService.authorizeForce(Permission.InviteTenantUser); + this.validatorFactory.validator(UserTenantUsersInviteRequest.UserTenantUsersInviteRequestValidator.class).validateForce(users); + TenantEntity tenantEntity = null; String tenantName = null; String tenantCode; diff --git a/dmp-frontend/src/app/ui/admin/user/listing/user-invite-to-tenant-dialog/user-invite-to-tenant-dialog-editor.model.ts b/dmp-frontend/src/app/ui/admin/user/listing/user-invite-to-tenant-dialog/user-invite-to-tenant-dialog-editor.model.ts index 3b89049d3..c3e76a5d9 100644 --- a/dmp-frontend/src/app/ui/admin/user/listing/user-invite-to-tenant-dialog/user-invite-to-tenant-dialog-editor.model.ts +++ b/dmp-frontend/src/app/ui/admin/user/listing/user-invite-to-tenant-dialog/user-invite-to-tenant-dialog-editor.model.ts @@ -19,7 +19,7 @@ export class UserTenantUsersInviteRequestEditorModel implements UserTenantUsersI users: this.formBuilder.array( (this.users ?? []).map( (item, index) => item.buildForm({ - rootPath: `userInviteToTenantRequest[${index}].`, + rootPath: `users[${index}].`, disabled: disabled }) ), context.getValidation('users').validators @@ -30,7 +30,7 @@ export class UserTenantUsersInviteRequestEditorModel implements UserTenantUsersI createValidationContext(): ValidationContext { const baseContext: ValidationContext = new ValidationContext(); const baseValidationArray: Validation[] = new Array(); - baseValidationArray.push({ key: 'users', validators: [Validators.required, BackendErrorValidator(this.validationErrorModel, 'userInviteToTenantRequest')] }); + baseValidationArray.push({ key: 'users', validators: [Validators.required, BackendErrorValidator(this.validationErrorModel, 'users')] }); baseContext.validation = baseValidationArray; return baseContext; @@ -44,7 +44,7 @@ export class UserTenantUsersInviteRequestEditorModel implements UserTenantUsersI formArray?.controls?.forEach( (control, index) => UserInviteToTenantRequestEditorModel.reapplyValidators({ formGroup: control as UntypedFormGroup, - rootPath: `userInviteToTenantRequest[${index}].`, + rootPath: `users[${index}].`, validationErrorModel: validationErrorModel }) ); diff --git a/dmp-frontend/src/app/ui/admin/user/listing/user-invite-to-tenant-dialog/user-invite-to-tenant-dialog.component.ts b/dmp-frontend/src/app/ui/admin/user/listing/user-invite-to-tenant-dialog/user-invite-to-tenant-dialog.component.ts index fdfdab57d..6f0e3bcd5 100644 --- a/dmp-frontend/src/app/ui/admin/user/listing/user-invite-to-tenant-dialog/user-invite-to-tenant-dialog.component.ts +++ b/dmp-frontend/src/app/ui/admin/user/listing/user-invite-to-tenant-dialog/user-invite-to-tenant-dialog.component.ts @@ -53,7 +53,7 @@ export class UserInviteToTenantDialogComponent extends BaseComponent implements addUser(): void { const formArray = this.formGroup.get("users") as UntypedFormArray; const user: UserInviteToTenantRequestEditorModel = new UserInviteToTenantRequestEditorModel(this.editorModel.validationErrorModel); - formArray.push(user.buildForm({ rootPath: "userInviteToTenantRequest[" + formArray.length + "]." })); + formArray.push(user.buildForm({ rootPath: "users[" + formArray.length + "]." })); } removeUser(userIndex: number): void { @@ -92,13 +92,13 @@ export class UserInviteToTenantDialogComponent extends BaseComponent implements } onCallbackSuccess(): void { - this.uiNotificationService.snackBarNotification(this.language.instant('DMP-USER-INVITATION-DIALOG.SUCCESS'), SnackBarNotificationLevel.Success); + this.uiNotificationService.snackBarNotification(this.language.instant('USER-INVITE-TO-TENANT-DIALOG.SUCCESS'), SnackBarNotificationLevel.Success); } onCallbackError(errorResponse: HttpErrorResponse) { this.inProgressSendButton = false; let errorOverrides = new Map(); - errorOverrides.set(-1, this.language.instant('DMP-USER-INVITATION-DIALOG.ERROR')); + errorOverrides.set(-1, this.language.instant('USER-INVITE-TO-TENANT-DIALOG.ERROR')); this.httpErrorHandlingService.handleBackedRequestError(errorResponse, errorOverrides, SnackBarNotificationLevel.Error); const error: HttpError = this.httpErrorHandlingService.getError(errorResponse); diff --git a/dmp-frontend/src/assets/i18n/baq.json b/dmp-frontend/src/assets/i18n/baq.json index 16c198b89..74ef8bd57 100644 --- a/dmp-frontend/src/assets/i18n/baq.json +++ b/dmp-frontend/src/assets/i18n/baq.json @@ -2110,7 +2110,9 @@ "REMOVE-USER": "Remove User", "INVITE": "Invite" }, - "USERS-REQUIRED": "Required at leat on user" + "USERS-REQUIRED": "Required at leat on user", + "SUCCESS": "Invitation Success", + "ERROR": "Invitation Error" }, "USER-PROFILE": { "MERGING-EMAILS-DIALOG": { diff --git a/dmp-frontend/src/assets/i18n/de.json b/dmp-frontend/src/assets/i18n/de.json index 6f6c8c700..34653499f 100644 --- a/dmp-frontend/src/assets/i18n/de.json +++ b/dmp-frontend/src/assets/i18n/de.json @@ -2110,7 +2110,9 @@ "REMOVE-USER": "Remove User", "INVITE": "Invite" }, - "USERS-REQUIRED": "Required at leat on user" + "USERS-REQUIRED": "Required at leat on user", + "SUCCESS": "Invitation Success", + "ERROR": "Invitation Error" }, "USER-PROFILE": { "MERGING-EMAILS-DIALOG": { diff --git a/dmp-frontend/src/assets/i18n/en.json b/dmp-frontend/src/assets/i18n/en.json index b20292ed0..03d6fb2c5 100644 --- a/dmp-frontend/src/assets/i18n/en.json +++ b/dmp-frontend/src/assets/i18n/en.json @@ -2110,7 +2110,9 @@ "REMOVE-USER": "Remove User", "INVITE": "Invite" }, - "USERS-REQUIRED": "Required at leat on user" + "USERS-REQUIRED": "Required at leat on user", + "SUCCESS": "Invitation Success", + "ERROR": "Invitation Error" }, "USER-PROFILE": { "MERGING-EMAILS-DIALOG": { diff --git a/dmp-frontend/src/assets/i18n/es.json b/dmp-frontend/src/assets/i18n/es.json index 9e56e07aa..94d2d1c20 100644 --- a/dmp-frontend/src/assets/i18n/es.json +++ b/dmp-frontend/src/assets/i18n/es.json @@ -2110,7 +2110,9 @@ "REMOVE-USER": "Remove User", "INVITE": "Invite" }, - "USERS-REQUIRED": "Required at leat on user" + "USERS-REQUIRED": "Required at leat on user", + "SUCCESS": "Invitation Success", + "ERROR": "Invitation Error" }, "USER-PROFILE": { "MERGING-EMAILS-DIALOG": { diff --git a/dmp-frontend/src/assets/i18n/gr.json b/dmp-frontend/src/assets/i18n/gr.json index e11fb35ab..07ead1060 100644 --- a/dmp-frontend/src/assets/i18n/gr.json +++ b/dmp-frontend/src/assets/i18n/gr.json @@ -2110,7 +2110,9 @@ "REMOVE-USER": "Remove User", "INVITE": "Invite" }, - "USERS-REQUIRED": "Required at leat on user" + "USERS-REQUIRED": "Required at leat on user", + "SUCCESS": "Invitation Success", + "ERROR": "Invitation Error" }, "USER-PROFILE": { "MERGING-EMAILS-DIALOG": { diff --git a/dmp-frontend/src/assets/i18n/hr.json b/dmp-frontend/src/assets/i18n/hr.json index dbded156e..b6fbe21a0 100644 --- a/dmp-frontend/src/assets/i18n/hr.json +++ b/dmp-frontend/src/assets/i18n/hr.json @@ -2110,7 +2110,9 @@ "REMOVE-USER": "Remove User", "INVITE": "Invite" }, - "USERS-REQUIRED": "Required at leat on user" + "USERS-REQUIRED": "Required at leat on user", + "SUCCESS": "Invitation Success", + "ERROR": "Invitation Error" }, "USER-PROFILE": { "MERGING-EMAILS-DIALOG": { diff --git a/dmp-frontend/src/assets/i18n/pl.json b/dmp-frontend/src/assets/i18n/pl.json index ca58a98ad..5733961f4 100644 --- a/dmp-frontend/src/assets/i18n/pl.json +++ b/dmp-frontend/src/assets/i18n/pl.json @@ -2110,7 +2110,9 @@ "REMOVE-USER": "Remove User", "INVITE": "Invite" }, - "USERS-REQUIRED": "Required at leat on user" + "USERS-REQUIRED": "Required at leat on user", + "SUCCESS": "Invitation Success", + "ERROR": "Invitation Error" }, "USER-PROFILE": { "MERGING-EMAILS-DIALOG": { diff --git a/dmp-frontend/src/assets/i18n/pt.json b/dmp-frontend/src/assets/i18n/pt.json index 9b1cb6a49..8a7c5e353 100644 --- a/dmp-frontend/src/assets/i18n/pt.json +++ b/dmp-frontend/src/assets/i18n/pt.json @@ -2110,7 +2110,9 @@ "REMOVE-USER": "Remove User", "INVITE": "Invite" }, - "USERS-REQUIRED": "Required at leat on user" + "USERS-REQUIRED": "Required at leat on user", + "SUCCESS": "Invitation Success", + "ERROR": "Invitation Error" }, "USER-PROFILE": { "MERGING-EMAILS-DIALOG": { diff --git a/dmp-frontend/src/assets/i18n/sk.json b/dmp-frontend/src/assets/i18n/sk.json index 242b83963..78f583002 100644 --- a/dmp-frontend/src/assets/i18n/sk.json +++ b/dmp-frontend/src/assets/i18n/sk.json @@ -2110,7 +2110,9 @@ "REMOVE-USER": "Remove User", "INVITE": "Invite" }, - "USERS-REQUIRED": "Required at leat on user" + "USERS-REQUIRED": "Required at leat on user", + "SUCCESS": "Invitation Success", + "ERROR": "Invitation Error" }, "USER-PROFILE": { "MERGING-EMAILS-DIALOG": { diff --git a/dmp-frontend/src/assets/i18n/sr.json b/dmp-frontend/src/assets/i18n/sr.json index 91351aa48..7ca554924 100644 --- a/dmp-frontend/src/assets/i18n/sr.json +++ b/dmp-frontend/src/assets/i18n/sr.json @@ -2110,7 +2110,9 @@ "REMOVE-USER": "Remove User", "INVITE": "Invite" }, - "USERS-REQUIRED": "Required at leat on user" + "USERS-REQUIRED": "Required at leat on user", + "SUCCESS": "Invitation Success", + "ERROR": "Invitation Error" }, "USER-PROFILE": { "MERGING-EMAILS-DIALOG": { diff --git a/dmp-frontend/src/assets/i18n/tr.json b/dmp-frontend/src/assets/i18n/tr.json index 896fd64e4..a0cad4c2e 100644 --- a/dmp-frontend/src/assets/i18n/tr.json +++ b/dmp-frontend/src/assets/i18n/tr.json @@ -2110,7 +2110,9 @@ "REMOVE-USER": "Remove User", "INVITE": "Invite" }, - "USERS-REQUIRED": "Required at leat on user" + "USERS-REQUIRED": "Required at leat on user", + "SUCCESS": "Invitation Success", + "ERROR": "Invitation Error" }, "USER-PROFILE": { "MERGING-EMAILS-DIALOG": { From 23559c1bf44717410d4bd82bbc26e9e131a11125 Mon Sep 17 00:00:00 2001 From: amentis Date: Wed, 26 Jun 2024 11:59:41 +0300 Subject: [PATCH 4/4] add email validation for dmp contact, user --- .../java/org/opencdmp/model/persist/DmpUserPersist.java | 9 +++++++-- .../model/persist/dmpproperties/DmpContactPersist.java | 5 +++++ 2 files changed, 12 insertions(+), 2 deletions(-) diff --git a/backend/core/src/main/java/org/opencdmp/model/persist/DmpUserPersist.java b/backend/core/src/main/java/org/opencdmp/model/persist/DmpUserPersist.java index dfdeff4e4..cbcca13c7 100644 --- a/backend/core/src/main/java/org/opencdmp/model/persist/DmpUserPersist.java +++ b/backend/core/src/main/java/org/opencdmp/model/persist/DmpUserPersist.java @@ -5,6 +5,7 @@ import org.opencdmp.commons.validation.BaseValidator; import gr.cite.tools.validation.specification.Specification; import org.opencdmp.convention.ConventionService; import org.opencdmp.errorcode.ErrorThesaurusProperties; +import org.opencdmp.model.persist.dmpproperties.DmpContactPersist; import org.springframework.beans.factory.config.ConfigurableBeanFactory; import org.springframework.context.MessageSource; import org.springframework.context.annotation.Scope; @@ -98,8 +99,12 @@ public class DmpUserPersist { this.spec() .iff(() -> !this.isNull(item.getSectionId())) .must(() -> this.isValidGuid(item.getSectionId())) - .failOn(DmpUserPersist._sectionId).failWith(messageSource.getMessage("Validation_Required", new Object[]{DmpUserPersist._sectionId}, LocaleContextHolder.getLocale())) - ); + .failOn(DmpUserPersist._sectionId).failWith(messageSource.getMessage("Validation_Required", new Object[]{DmpUserPersist._sectionId}, LocaleContextHolder.getLocale())), + this.spec() + .iff(() -> !this.isEmpty(item.getEmail())) + .must(() -> this.isValidEmail(item.getEmail())) + .failOn(DmpUserPersist._email).failWith(messageSource.getMessage("Validation_UnexpectedValue", new Object[]{DmpUserPersist._email}, LocaleContextHolder.getLocale())) + ); } } diff --git a/backend/core/src/main/java/org/opencdmp/model/persist/dmpproperties/DmpContactPersist.java b/backend/core/src/main/java/org/opencdmp/model/persist/dmpproperties/DmpContactPersist.java index e1b392214..be4adc629 100644 --- a/backend/core/src/main/java/org/opencdmp/model/persist/dmpproperties/DmpContactPersist.java +++ b/backend/core/src/main/java/org/opencdmp/model/persist/dmpproperties/DmpContactPersist.java @@ -4,6 +4,7 @@ import org.opencdmp.commons.validation.BaseValidator; import gr.cite.tools.validation.specification.Specification; import org.opencdmp.convention.ConventionService; import org.opencdmp.errorcode.ErrorThesaurusProperties; +import org.opencdmp.model.persist.UserInviteToTenantRequestPersist; import org.springframework.beans.factory.config.ConfigurableBeanFactory; import org.springframework.context.MessageSource; import org.springframework.context.annotation.Scope; @@ -71,6 +72,10 @@ public class DmpContactPersist { this.spec() .must(() -> !this.isEmpty(item.getEmail())) .failOn(DmpContactPersist._email).failWith(messageSource.getMessage("Validation_Required", new Object[]{DmpContactPersist._email}, LocaleContextHolder.getLocale())), + this.spec() + .iff(() -> !this.isEmpty(item.getEmail())) + .must(() -> this.isValidEmail(item.getEmail())) + .failOn(DmpContactPersist._email).failWith(messageSource.getMessage("Validation_UnexpectedValue", new Object[]{DmpContactPersist._email}, LocaleContextHolder.getLocale())), this.spec() .must(() -> !this.isEmpty(item.getFirstName())) .failOn(DmpContactPersist._firstName).failWith(messageSource.getMessage("Validation_Required", new Object[]{DmpContactPersist._firstName}, LocaleContextHolder.getLocale())),