add validation errors on user roles persist

This commit is contained in:
CITE\amentis 2024-08-05 12:25:41 +03:00
parent bed157b320
commit b9cf577012
13 changed files with 71 additions and 13 deletions

View File

@ -518,4 +518,24 @@ public class ErrorThesaurusProperties {
public void setPlanBlueprintImportDraft(ErrorDescription planBlueprintImportDraft) { public void setPlanBlueprintImportDraft(ErrorDescription planBlueprintImportDraft) {
this.planBlueprintImportDraft = planBlueprintImportDraft; this.planBlueprintImportDraft = planBlueprintImportDraft;
} }
private ErrorDescription missingTenantRole;
public ErrorDescription getMissingTenantRole() {
return missingTenantRole;
}
public void setMissingTenantRole(ErrorDescription missingTenantRole) {
this.missingTenantRole = missingTenantRole;
}
private ErrorDescription missingGlobalRole;
public ErrorDescription getMissingGlobalRole() {
return missingGlobalRole;
}
public void setMissingGlobalRole(ErrorDescription missingGlobalRole) {
this.missingGlobalRole = missingGlobalRole;
}
} }

View File

@ -334,8 +334,20 @@ public class UserServiceImpl implements UserService {
public User patchRoles(UserRolePatchPersist model, FieldSet fields) throws InvalidApplicationException { public User patchRoles(UserRolePatchPersist model, FieldSet fields) throws InvalidApplicationException {
logger.debug(new MapLogEntry("persisting data UserRole").And("model", model).And("fields", fields)); logger.debug(new MapLogEntry("persisting data UserRole").And("model", model).And("fields", fields));
if (!model.getHasTenantAdminMode()) this.authorizationService.authorizeForce(Permission.EditUser); if (!model.getHasTenantAdminMode()) {
else this.authorizationService.authorizeForce(Permission.EditTenantUserRole); this.authorizationService.authorizeForce(Permission.EditUser);
boolean foundGlobalRole = false;
boolean foundTenantRole = false;
for (String role: model.getRoles()) {
if (authorizationConfiguration.getAuthorizationProperties().getAllowedGlobalRoles().contains(role)) foundGlobalRole = true;
if (authorizationConfiguration.getAuthorizationProperties().getAllowedTenantRoles().contains(role)) foundTenantRole = true;
}
if (!foundGlobalRole && !foundTenantRole) throw new MyValidationException("Wrong role type");
if (!foundGlobalRole) throw new MyValidationException(this.errors.getMissingGlobalRole().getCode(), this.errors.getMissingGlobalRole().getMessage());
if (!foundTenantRole) throw new MyValidationException(this.errors.getMissingTenantRole().getCode(), this.errors.getMissingTenantRole().getMessage());
} else {
this.authorizationService.authorizeForce(Permission.EditTenantUserRole);
}
UserEntity data = this.entityManager.find(UserEntity.class, model.getId(), true); UserEntity data = this.entityManager.find(UserEntity.class, model.getId(), true);
if (data == null) throw new MyNotFoundException(this.messageSource.getMessage("General_ItemNotFound", new Object[]{model.getId(), User.class.getSimpleName()}, LocaleContextHolder.getLocale())); if (data == null) throw new MyNotFoundException(this.messageSource.getMessage("General_ItemNotFound", new Object[]{model.getId(), User.class.getSimpleName()}, LocaleContextHolder.getLocale()));

View File

@ -160,4 +160,10 @@ error-thesaurus:
message: Description template type is not finalised message: Description template type is not finalised
planBlueprintImportDraft: planBlueprintImportDraft:
code: 157 code: 157
message: Plan blueprint is not finalised message: Plan blueprint is not finalised
missingTenantRole:
code: 158
message: tenant role is missing
missingGlobalRole:
code: 159
message: Global role is missing

View File

@ -92,7 +92,9 @@
"BLUEPRINT-DESCRIPTION-TEMPLATE-IMPORT-DRAFT": "Description template with code '{{descriptionTemplateLabel}}' is not finalized yet.", "BLUEPRINT-DESCRIPTION-TEMPLATE-IMPORT-DRAFT": "Description template with code '{{descriptionTemplateLabel}}' is not finalized yet.",
"PLAN-DESCRIPTION-TEMPLATE-IMPORT-DRAFT": "Description template with code '{{descriptionTemplateLabel}}' is not finalized yet.", "PLAN-DESCRIPTION-TEMPLATE-IMPORT-DRAFT": "Description template with code '{{descriptionTemplateLabel}}' is not finalized yet.",
"DESCRIPTION-TEMPLATE-TYPE-IMPORT-DRAFT": "Description template type with code '{{descriptionTemplateTypeCode}}' is not finalized yet.", "DESCRIPTION-TEMPLATE-TYPE-IMPORT-DRAFT": "Description template type with code '{{descriptionTemplateTypeCode}}' is not finalized yet.",
"PLAN-BLUEPRINT-IMPORT-DRAFT": "Plan Blueprint with code '{{planBlueprintCode}}' is not finalized yet." "PLAN-BLUEPRINT-IMPORT-DRAFT": "Plan Blueprint with code '{{planBlueprintCode}}' is not finalized yet.",
"MISSING-TENANT-ROLE": "Υou must also select a tenant role",
"MISSING-GLOBAL-ROLE": "Υou must also select a global role"
}, },
"FORM-VALIDATION-DISPLAY-DIALOG": { "FORM-VALIDATION-DISPLAY-DIALOG": {
"WARNING": "Warnung!", "WARNING": "Warnung!",

View File

@ -92,7 +92,9 @@
"BLUEPRINT-DESCRIPTION-TEMPLATE-IMPORT-DRAFT": "Description template with code '{{descriptionTemplateLabel}}' is not finalized yet.", "BLUEPRINT-DESCRIPTION-TEMPLATE-IMPORT-DRAFT": "Description template with code '{{descriptionTemplateLabel}}' is not finalized yet.",
"PLAN-DESCRIPTION-TEMPLATE-IMPORT-DRAFT": "Description template with code '{{descriptionTemplateLabel}}' is not finalized yet.", "PLAN-DESCRIPTION-TEMPLATE-IMPORT-DRAFT": "Description template with code '{{descriptionTemplateLabel}}' is not finalized yet.",
"DESCRIPTION-TEMPLATE-TYPE-IMPORT-DRAFT": "Description template type with code '{{descriptionTemplateTypeCode}}' is not finalized yet.", "DESCRIPTION-TEMPLATE-TYPE-IMPORT-DRAFT": "Description template type with code '{{descriptionTemplateTypeCode}}' is not finalized yet.",
"PLAN-BLUEPRINT-IMPORT-DRAFT": "Plan Blueprint with code '{{planBlueprintCode}}' is not finalized yet." "PLAN-BLUEPRINT-IMPORT-DRAFT": "Plan Blueprint with code '{{planBlueprintCode}}' is not finalized yet.",
"MISSING-TENANT-ROLE": "Υou must also select a tenant role",
"MISSING-GLOBAL-ROLE": "Υou must also select a global role"
}, },
"FORM-VALIDATION-DISPLAY-DIALOG": { "FORM-VALIDATION-DISPLAY-DIALOG": {
"WARNING": "Warning!", "WARNING": "Warning!",

View File

@ -92,7 +92,9 @@
"BLUEPRINT-DESCRIPTION-TEMPLATE-IMPORT-DRAFT": "Description template with code '{{descriptionTemplateLabel}}' is not finalized yet.", "BLUEPRINT-DESCRIPTION-TEMPLATE-IMPORT-DRAFT": "Description template with code '{{descriptionTemplateLabel}}' is not finalized yet.",
"PLAN-DESCRIPTION-TEMPLATE-IMPORT-DRAFT": "Description template with code '{{descriptionTemplateLabel}}' is not finalized yet.", "PLAN-DESCRIPTION-TEMPLATE-IMPORT-DRAFT": "Description template with code '{{descriptionTemplateLabel}}' is not finalized yet.",
"DESCRIPTION-TEMPLATE-TYPE-IMPORT-DRAFT": "Description template type with code '{{descriptionTemplateTypeCode}}' is not finalized yet.", "DESCRIPTION-TEMPLATE-TYPE-IMPORT-DRAFT": "Description template type with code '{{descriptionTemplateTypeCode}}' is not finalized yet.",
"PLAN-BLUEPRINT-IMPORT-DRAFT": "Plan Blueprint with code '{{planBlueprintCode}}' is not finalized yet." "PLAN-BLUEPRINT-IMPORT-DRAFT": "Plan Blueprint with code '{{planBlueprintCode}}' is not finalized yet.",
"MISSING-TENANT-ROLE": "Υou must also select a tenant role",
"MISSING-GLOBAL-ROLE": "Υou must also select a global role"
}, },
"FORM-VALIDATION-DISPLAY-DIALOG": { "FORM-VALIDATION-DISPLAY-DIALOG": {
"WARNING": "Atención!", "WARNING": "Atención!",

View File

@ -92,7 +92,9 @@
"BLUEPRINT-DESCRIPTION-TEMPLATE-IMPORT-DRAFT": "Description template with code '{{descriptionTemplateLabel}}' is not finalized yet.", "BLUEPRINT-DESCRIPTION-TEMPLATE-IMPORT-DRAFT": "Description template with code '{{descriptionTemplateLabel}}' is not finalized yet.",
"PLAN-DESCRIPTION-TEMPLATE-IMPORT-DRAFT": "Description template with code '{{descriptionTemplateLabel}}' is not finalized yet.", "PLAN-DESCRIPTION-TEMPLATE-IMPORT-DRAFT": "Description template with code '{{descriptionTemplateLabel}}' is not finalized yet.",
"DESCRIPTION-TEMPLATE-TYPE-IMPORT-DRAFT": "Description template type with code '{{descriptionTemplateTypeCode}}' is not finalized yet.", "DESCRIPTION-TEMPLATE-TYPE-IMPORT-DRAFT": "Description template type with code '{{descriptionTemplateTypeCode}}' is not finalized yet.",
"PLAN-BLUEPRINT-IMPORT-DRAFT": "Plan Blueprint with code '{{planBlueprintCode}}' is not finalized yet." "PLAN-BLUEPRINT-IMPORT-DRAFT": "Plan Blueprint with code '{{planBlueprintCode}}' is not finalized yet.",
"MISSING-TENANT-ROLE": "Υou must also select a tenant role",
"MISSING-GLOBAL-ROLE": "Υou must also select a global role"
}, },
"FORM-VALIDATION-DISPLAY-DIALOG": { "FORM-VALIDATION-DISPLAY-DIALOG": {
"WARNING": "Προσοχή!", "WARNING": "Προσοχή!",

View File

@ -92,7 +92,9 @@
"BLUEPRINT-DESCRIPTION-TEMPLATE-IMPORT-DRAFT": "Description template with code '{{descriptionTemplateLabel}}' is not finalized yet.", "BLUEPRINT-DESCRIPTION-TEMPLATE-IMPORT-DRAFT": "Description template with code '{{descriptionTemplateLabel}}' is not finalized yet.",
"PLAN-DESCRIPTION-TEMPLATE-IMPORT-DRAFT": "Description template with code '{{descriptionTemplateLabel}}' is not finalized yet.", "PLAN-DESCRIPTION-TEMPLATE-IMPORT-DRAFT": "Description template with code '{{descriptionTemplateLabel}}' is not finalized yet.",
"DESCRIPTION-TEMPLATE-TYPE-IMPORT-DRAFT": "Description template type with code '{{descriptionTemplateTypeCode}}' is not finalized yet.", "DESCRIPTION-TEMPLATE-TYPE-IMPORT-DRAFT": "Description template type with code '{{descriptionTemplateTypeCode}}' is not finalized yet.",
"PLAN-BLUEPRINT-IMPORT-DRAFT": "Plan Blueprint with code '{{planBlueprintCode}}' is not finalized yet." "PLAN-BLUEPRINT-IMPORT-DRAFT": "Plan Blueprint with code '{{planBlueprintCode}}' is not finalized yet.",
"MISSING-TENANT-ROLE": "Υou must also select a tenant role",
"MISSING-GLOBAL-ROLE": "Υou must also select a global role"
}, },
"FORM-VALIDATION-DISPLAY-DIALOG": { "FORM-VALIDATION-DISPLAY-DIALOG": {
"WARNING": "Oprez!", "WARNING": "Oprez!",

View File

@ -92,7 +92,9 @@
"BLUEPRINT-DESCRIPTION-TEMPLATE-IMPORT-DRAFT": "Description template with code '{{descriptionTemplateLabel}}' is not finalized yet.", "BLUEPRINT-DESCRIPTION-TEMPLATE-IMPORT-DRAFT": "Description template with code '{{descriptionTemplateLabel}}' is not finalized yet.",
"PLAN-DESCRIPTION-TEMPLATE-IMPORT-DRAFT": "Description template with code '{{descriptionTemplateLabel}}' is not finalized yet.", "PLAN-DESCRIPTION-TEMPLATE-IMPORT-DRAFT": "Description template with code '{{descriptionTemplateLabel}}' is not finalized yet.",
"DESCRIPTION-TEMPLATE-TYPE-IMPORT-DRAFT": "Description template type with code '{{descriptionTemplateTypeCode}}' is not finalized yet.", "DESCRIPTION-TEMPLATE-TYPE-IMPORT-DRAFT": "Description template type with code '{{descriptionTemplateTypeCode}}' is not finalized yet.",
"PLAN-BLUEPRINT-IMPORT-DRAFT": "Plan Blueprint with code '{{planBlueprintCode}}' is not finalized yet." "PLAN-BLUEPRINT-IMPORT-DRAFT": "Plan Blueprint with code '{{planBlueprintCode}}' is not finalized yet.",
"MISSING-TENANT-ROLE": "Υou must also select a tenant role",
"MISSING-GLOBAL-ROLE": "Υou must also select a global role"
}, },
"FORM-VALIDATION-DISPLAY-DIALOG": { "FORM-VALIDATION-DISPLAY-DIALOG": {
"WARNING": "Ostrzeżenie!", "WARNING": "Ostrzeżenie!",

View File

@ -92,7 +92,9 @@
"BLUEPRINT-DESCRIPTION-TEMPLATE-IMPORT-DRAFT": "Description template with code '{{descriptionTemplateLabel}}' is not finalized yet.", "BLUEPRINT-DESCRIPTION-TEMPLATE-IMPORT-DRAFT": "Description template with code '{{descriptionTemplateLabel}}' is not finalized yet.",
"PLAN-DESCRIPTION-TEMPLATE-IMPORT-DRAFT": "Description template with code '{{descriptionTemplateLabel}}' is not finalized yet.", "PLAN-DESCRIPTION-TEMPLATE-IMPORT-DRAFT": "Description template with code '{{descriptionTemplateLabel}}' is not finalized yet.",
"DESCRIPTION-TEMPLATE-TYPE-IMPORT-DRAFT": "Description template type with code '{{descriptionTemplateTypeCode}}' is not finalized yet.", "DESCRIPTION-TEMPLATE-TYPE-IMPORT-DRAFT": "Description template type with code '{{descriptionTemplateTypeCode}}' is not finalized yet.",
"PLAN-BLUEPRINT-IMPORT-DRAFT": "Plan Blueprint with code '{{planBlueprintCode}}' is not finalized yet." "PLAN-BLUEPRINT-IMPORT-DRAFT": "Plan Blueprint with code '{{planBlueprintCode}}' is not finalized yet.",
"MISSING-TENANT-ROLE": "Υou must also select a tenant role",
"MISSING-GLOBAL-ROLE": "Υou must also select a global role"
}, },
"FORM-VALIDATION-DISPLAY-DIALOG": { "FORM-VALIDATION-DISPLAY-DIALOG": {
"WARNING": "Atenção!", "WARNING": "Atenção!",

View File

@ -92,7 +92,9 @@
"BLUEPRINT-DESCRIPTION-TEMPLATE-IMPORT-DRAFT": "Description template with code '{{descriptionTemplateLabel}}' is not finalized yet.", "BLUEPRINT-DESCRIPTION-TEMPLATE-IMPORT-DRAFT": "Description template with code '{{descriptionTemplateLabel}}' is not finalized yet.",
"PLAN-DESCRIPTION-TEMPLATE-IMPORT-DRAFT": "Description template with code '{{descriptionTemplateLabel}}' is not finalized yet.", "PLAN-DESCRIPTION-TEMPLATE-IMPORT-DRAFT": "Description template with code '{{descriptionTemplateLabel}}' is not finalized yet.",
"DESCRIPTION-TEMPLATE-TYPE-IMPORT-DRAFT": "Description template type with code '{{descriptionTemplateTypeCode}}' is not finalized yet.", "DESCRIPTION-TEMPLATE-TYPE-IMPORT-DRAFT": "Description template type with code '{{descriptionTemplateTypeCode}}' is not finalized yet.",
"PLAN-BLUEPRINT-IMPORT-DRAFT": "Plan Blueprint with code '{{planBlueprintCode}}' is not finalized yet." "PLAN-BLUEPRINT-IMPORT-DRAFT": "Plan Blueprint with code '{{planBlueprintCode}}' is not finalized yet.",
"MISSING-TENANT-ROLE": "Υou must also select a tenant role",
"MISSING-GLOBAL-ROLE": "Υou must also select a global role"
}, },
"FORM-VALIDATION-DISPLAY-DIALOG": { "FORM-VALIDATION-DISPLAY-DIALOG": {
"WARNING": "Upozornenie!", "WARNING": "Upozornenie!",

View File

@ -92,7 +92,9 @@
"BLUEPRINT-DESCRIPTION-TEMPLATE-IMPORT-DRAFT": "Description template with code '{{descriptionTemplateLabel}}' is not finalized yet.", "BLUEPRINT-DESCRIPTION-TEMPLATE-IMPORT-DRAFT": "Description template with code '{{descriptionTemplateLabel}}' is not finalized yet.",
"PLAN-DESCRIPTION-TEMPLATE-IMPORT-DRAFT": "Description template with code '{{descriptionTemplateLabel}}' is not finalized yet.", "PLAN-DESCRIPTION-TEMPLATE-IMPORT-DRAFT": "Description template with code '{{descriptionTemplateLabel}}' is not finalized yet.",
"DESCRIPTION-TEMPLATE-TYPE-IMPORT-DRAFT": "Description template type with code '{{descriptionTemplateTypeCode}}' is not finalized yet.", "DESCRIPTION-TEMPLATE-TYPE-IMPORT-DRAFT": "Description template type with code '{{descriptionTemplateTypeCode}}' is not finalized yet.",
"PLAN-BLUEPRINT-IMPORT-DRAFT": "Plan Blueprint with code '{{planBlueprintCode}}' is not finalized yet." "PLAN-BLUEPRINT-IMPORT-DRAFT": "Plan Blueprint with code '{{planBlueprintCode}}' is not finalized yet.",
"MISSING-TENANT-ROLE": "Υou must also select a tenant role",
"MISSING-GLOBAL-ROLE": "Υou must also select a global role"
}, },
"FORM-VALIDATION-DISPLAY-DIALOG": { "FORM-VALIDATION-DISPLAY-DIALOG": {
"WARNING": "Oprez!", "WARNING": "Oprez!",

View File

@ -92,7 +92,9 @@
"BLUEPRINT-DESCRIPTION-TEMPLATE-IMPORT-DRAFT": "Description template with code '{{descriptionTemplateLabel}}' is not finalized yet.", "BLUEPRINT-DESCRIPTION-TEMPLATE-IMPORT-DRAFT": "Description template with code '{{descriptionTemplateLabel}}' is not finalized yet.",
"PLAN-DESCRIPTION-TEMPLATE-IMPORT-DRAFT": "Description template with code '{{descriptionTemplateLabel}}' is not finalized yet.", "PLAN-DESCRIPTION-TEMPLATE-IMPORT-DRAFT": "Description template with code '{{descriptionTemplateLabel}}' is not finalized yet.",
"DESCRIPTION-TEMPLATE-TYPE-IMPORT-DRAFT": "Description template type with code '{{descriptionTemplateTypeCode}}' is not finalized yet.", "DESCRIPTION-TEMPLATE-TYPE-IMPORT-DRAFT": "Description template type with code '{{descriptionTemplateTypeCode}}' is not finalized yet.",
"PLAN-BLUEPRINT-IMPORT-DRAFT": "Plan Blueprint with code '{{planBlueprintCode}}' is not finalized yet." "PLAN-BLUEPRINT-IMPORT-DRAFT": "Plan Blueprint with code '{{planBlueprintCode}}' is not finalized yet.",
"MISSING-TENANT-ROLE": "Υou must also select a tenant role",
"MISSING-GLOBAL-ROLE": "Υou must also select a global role"
}, },
"FORM-VALIDATION-DISPLAY-DIALOG": { "FORM-VALIDATION-DISPLAY-DIALOG": {
"WARNING": "Uyarı!", "WARNING": "Uyarı!",