add validation errors on user roles persist
This commit is contained in:
parent
bed157b320
commit
b9cf577012
|
@ -518,4 +518,24 @@ public class ErrorThesaurusProperties {
|
|||
public void setPlanBlueprintImportDraft(ErrorDescription 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;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -334,8 +334,20 @@ public class UserServiceImpl implements UserService {
|
|||
public User patchRoles(UserRolePatchPersist model, FieldSet fields) throws InvalidApplicationException {
|
||||
logger.debug(new MapLogEntry("persisting data UserRole").And("model", model).And("fields", fields));
|
||||
|
||||
if (!model.getHasTenantAdminMode()) this.authorizationService.authorizeForce(Permission.EditUser);
|
||||
else this.authorizationService.authorizeForce(Permission.EditTenantUserRole);
|
||||
if (!model.getHasTenantAdminMode()) {
|
||||
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);
|
||||
if (data == null) throw new MyNotFoundException(this.messageSource.getMessage("General_ItemNotFound", new Object[]{model.getId(), User.class.getSimpleName()}, LocaleContextHolder.getLocale()));
|
||||
|
|
|
@ -160,4 +160,10 @@ error-thesaurus:
|
|||
message: Description template type is not finalised
|
||||
planBlueprintImportDraft:
|
||||
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
|
|
@ -92,7 +92,9 @@
|
|||
"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.",
|
||||
"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": {
|
||||
"WARNING": "Warnung!",
|
||||
|
|
|
@ -92,7 +92,9 @@
|
|||
"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.",
|
||||
"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": {
|
||||
"WARNING": "Warning!",
|
||||
|
|
|
@ -92,7 +92,9 @@
|
|||
"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.",
|
||||
"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": {
|
||||
"WARNING": "Atención!",
|
||||
|
|
|
@ -92,7 +92,9 @@
|
|||
"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.",
|
||||
"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": {
|
||||
"WARNING": "Προσοχή!",
|
||||
|
|
|
@ -92,7 +92,9 @@
|
|||
"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.",
|
||||
"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": {
|
||||
"WARNING": "Oprez!",
|
||||
|
|
|
@ -92,7 +92,9 @@
|
|||
"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.",
|
||||
"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": {
|
||||
"WARNING": "Ostrzeżenie!",
|
||||
|
|
|
@ -92,7 +92,9 @@
|
|||
"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.",
|
||||
"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": {
|
||||
"WARNING": "Atenção!",
|
||||
|
|
|
@ -92,7 +92,9 @@
|
|||
"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.",
|
||||
"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": {
|
||||
"WARNING": "Upozornenie!",
|
||||
|
|
|
@ -92,7 +92,9 @@
|
|||
"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.",
|
||||
"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": {
|
||||
"WARNING": "Oprez!",
|
||||
|
|
|
@ -92,7 +92,9 @@
|
|||
"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.",
|
||||
"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": {
|
||||
"WARNING": "Uyarı!",
|
||||
|
|
Loading…
Reference in New Issue