mirror of
https://github.com/Alfresco/alfresco-community-repo.git
synced 2025-08-07 17:49:17 +00:00
Merged HEAD-QA to HEAD (4.2) (including moving test classes into separate folders)
51903 to 54309 git-svn-id: https://svn.alfresco.com/repos/alfresco-enterprise/alfresco/HEAD/root@54310 c4b6b30b-aa2e-2d43-bbcb-ca4b014f7261
This commit is contained in:
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (C) 2005-2010 Alfresco Software Limited.
|
||||
* Copyright (C) 2005-2012 Alfresco Software Limited.
|
||||
*
|
||||
* This file is part of Alfresco
|
||||
*
|
||||
@@ -29,9 +29,12 @@ import org.alfresco.service.cmr.security.PermissionService;
|
||||
*
|
||||
* @author davidc
|
||||
*/
|
||||
public class PermissionActionEvaluator extends AbstractActionEvaluator<NodeRef>
|
||||
public class PermissionActionEvaluator<ObjectType> extends AbstractActionEvaluator<ObjectType>
|
||||
{
|
||||
private String[] permissions;
|
||||
|
||||
private boolean defaultAllowing;
|
||||
|
||||
private PermissionService permissionService;
|
||||
|
||||
/**
|
||||
@@ -40,10 +43,11 @@ public class PermissionActionEvaluator extends AbstractActionEvaluator<NodeRef>
|
||||
* @param serviceRegistry
|
||||
* @param permission
|
||||
*/
|
||||
protected PermissionActionEvaluator(ServiceRegistry serviceRegistry, CMISAllowedActionEnum action, String... permission)
|
||||
protected PermissionActionEvaluator(ServiceRegistry serviceRegistry, CMISAllowedActionEnum action, boolean defaultAllowing, String... permission)
|
||||
{
|
||||
super(serviceRegistry, action);
|
||||
this.permissions = permission;
|
||||
this.defaultAllowing = defaultAllowing;
|
||||
this.permissionService = serviceRegistry.getPermissionService();
|
||||
}
|
||||
|
||||
@@ -51,8 +55,14 @@ public class PermissionActionEvaluator extends AbstractActionEvaluator<NodeRef>
|
||||
* (non-Javadoc)
|
||||
* @see org.alfresco.cmis.CMISActionEvaluator#isAllowed(org.alfresco.service.cmr.repository.NodeRef)
|
||||
*/
|
||||
public boolean isAllowed(NodeRef nodeRef)
|
||||
public boolean isAllowed(ObjectType object)
|
||||
{
|
||||
if (!(object instanceof NodeRef))
|
||||
{
|
||||
return defaultAllowing;
|
||||
}
|
||||
|
||||
NodeRef nodeRef = (NodeRef) object;
|
||||
for (String permission : permissions)
|
||||
{
|
||||
if (permissionService.hasPermission(nodeRef, permission) == AccessStatus.DENIED)
|
||||
@@ -60,9 +70,10 @@ public class PermissionActionEvaluator extends AbstractActionEvaluator<NodeRef>
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public String toString()
|
||||
{
|
||||
@@ -76,5 +87,5 @@ public class PermissionActionEvaluator extends AbstractActionEvaluator<NodeRef>
|
||||
builder.append("]");
|
||||
return builder.toString();
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
Reference in New Issue
Block a user