diff --git a/src/main/java/info/bukova/isspst/Constants.java b/src/main/java/info/bukova/isspst/Constants.java index 875514c2..4ec1b8db 100644 --- a/src/main/java/info/bukova/isspst/Constants.java +++ b/src/main/java/info/bukova/isspst/Constants.java @@ -102,15 +102,18 @@ public class Constants { public final static String PERM_SHOW_ALL_REQ = "PERM_SHOW_ALL_REQ"; public final static String PERM_EDIT_NEW = "PERM_EDIT_NEW"; public final static String PERM_EDIT_OWN = "PERM_EDIT_OWN"; + public final static String PERM_DELETE_NEW = "PERM_DELETE_NEW"; public final static Permission SPECIAL_PERMISSIONS[] = { new Permission(PERM_EDIT_NEW, "Upravit neschválené", MOD_REQUIREMENTS, PermissionType.GLOBAL), + new Permission(PERM_DELETE_NEW, "Mazat neschválené", MOD_REQUIREMENTS, PermissionType.GLOBAL), new Permission(PERM_SHOW_WORKGROUP_REQ, "Zobrazení požadavků komise", MOD_REQUIREMENTS, PermissionType.WORKGROUP), new Permission(PERM_SHOW_CENTRE_REQ, "Zobrazení požadavků střediska", MOD_REQUIREMENTS, PermissionType.CENTRE), new Permission(PERM_SHOW_ALL_REQ, "Zobrazení všech požadavků", MOD_REQUIREMENTS, PermissionType.GLOBAL), new Permission(PERM_APPROVE, "Schválení", MOD_REQUIREMENTS, PermissionType.WORKGROUP), new Permission(PERM_EDIT_NEW, "Upravit neschválené", MOD_TRIPREQUIREMENTS, PermissionType.GLOBAL), + new Permission(PERM_DELETE_NEW, "Mazat neschválené", MOD_TRIPREQUIREMENTS, PermissionType.GLOBAL), new Permission(PERM_SHOW_WORKGROUP_REQ, "Zobrazení požadavků komise", MOD_TRIPREQUIREMENTS, PermissionType.WORKGROUP), new Permission(PERM_SHOW_CENTRE_REQ, "Zobrazení požadavků střediska", MOD_TRIPREQUIREMENTS, PermissionType.CENTRE), new Permission(PERM_SHOW_ALL_REQ, "Zobrazení všech požadavků", MOD_TRIPREQUIREMENTS, PermissionType.GLOBAL), diff --git a/src/main/java/info/bukova/isspst/security/AbstractRequirementEvaluator.java b/src/main/java/info/bukova/isspst/security/AbstractRequirementEvaluator.java index 4becbafb..4fff0edc 100644 --- a/src/main/java/info/bukova/isspst/security/AbstractRequirementEvaluator.java +++ b/src/main/java/info/bukova/isspst/security/AbstractRequirementEvaluator.java @@ -30,6 +30,10 @@ public abstract class AbstractRequirementEvaluator extends AbstractModuleEvaluat return req.getState() == RequirementState.NEW; } + if (permission.equals(Constants.PERM_DELETE_NEW)) { + return req.getState() == RequirementState.NEW; + } + return true; } diff --git a/src/main/java/info/bukova/isspst/services/AbstractService.java b/src/main/java/info/bukova/isspst/services/AbstractService.java index 5289e9e2..5be4e64e 100644 --- a/src/main/java/info/bukova/isspst/services/AbstractService.java +++ b/src/main/java/info/bukova/isspst/services/AbstractService.java @@ -59,6 +59,10 @@ public abstract class AbstractService implements Service return ""; } + public String getDeleteEntityPermission() { + return ""; + } + @Override @PreAuthorize("hasPermission(this, 'PERM_ADD')") public final T create() { @@ -93,7 +97,7 @@ public abstract class AbstractService implements Service @Override @Transactional - @PreAuthorize("hasPermission(this, 'PERM_DELETE')") + @PreAuthorize("hasPermission(this, 'PERM_DELETE') or hasPermission(#entity, this.getDeleteEntityPermission())") public void delete(T entity) { if (dao == null) { throw new IsspstException("DAO is null"); diff --git a/src/main/java/info/bukova/isspst/services/requirement/RequirementBaseServiceImpl.java b/src/main/java/info/bukova/isspst/services/requirement/RequirementBaseServiceImpl.java index 7a40b444..4587eab5 100644 --- a/src/main/java/info/bukova/isspst/services/requirement/RequirementBaseServiceImpl.java +++ b/src/main/java/info/bukova/isspst/services/requirement/RequirementBaseServiceImpl.java @@ -382,5 +382,10 @@ public abstract class RequirementBaseServiceImpl exte public String getUpdateEntityPermission() { return Constants.PERM_EDIT_NEW; } + + @Override + public String getDeleteEntityPermission() { + return Constants.PERM_DELETE_NEW; + } }