From 6ff69c932c86cc98fda9d1128250e0bc25ff522a Mon Sep 17 00:00:00 2001 From: Josef Rokos Date: Thu, 15 Jan 2015 10:04:00 +0100 Subject: [PATCH] =?UTF-8?q?Do=20agendy=20po=C5=BEadavk=C5=AF=20bylo=20p?= =?UTF-8?q?=C5=99id=C3=A1no=20nov=C3=A9=20opr=C3=A1vn=C4=9Bn=C3=AD=20pro?= =?UTF-8?q?=20maz=C3=A1n=C3=AD=20neschv=C3=A1len=C3=BDch=20po=C5=BEadavk?= =?UTF-8?q?=C5=AF.=20closes=20#183?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/main/java/info/bukova/isspst/Constants.java | 3 +++ .../isspst/security/AbstractRequirementEvaluator.java | 4 ++++ .../java/info/bukova/isspst/services/AbstractService.java | 6 +++++- .../services/requirement/RequirementBaseServiceImpl.java | 5 +++++ 4 files changed, 17 insertions(+), 1 deletion(-) 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; + } }