mirror of
https://github.com/Alfresco/alfresco-community-repo.git
synced 2025-07-24 17:32:48 +00:00
Permissions now exposed in FreeMarker template model
git-svn-id: https://svn.alfresco.com/repos/alfresco-enterprise/alfresco/HEAD/root@3094 c4b6b30b-aa2e-2d43-bbcb-ca4b014f7261
This commit is contained in:
@@ -35,6 +35,7 @@ import org.alfresco.repo.template.XPathResultsMap;
|
||||
import org.alfresco.service.ServiceRegistry;
|
||||
import org.alfresco.service.cmr.dictionary.DictionaryService;
|
||||
import org.alfresco.service.cmr.lock.LockStatus;
|
||||
import org.alfresco.service.cmr.security.AccessPermission;
|
||||
import org.alfresco.service.namespace.QName;
|
||||
import org.alfresco.service.namespace.QNameMap;
|
||||
import org.alfresco.service.namespace.RegexQNamePattern;
|
||||
@@ -82,6 +83,7 @@ public final class TemplateNode implements Serializable
|
||||
private String id;
|
||||
private Set<QName> aspects = null;
|
||||
private QNameMap<String, Object> properties;
|
||||
private List<String> permissions = null;
|
||||
private boolean propsRetrieved = false;
|
||||
private ServiceRegistry services = null;
|
||||
private Boolean isDocument = null;
|
||||
@@ -474,6 +476,32 @@ public final class TemplateNode implements Serializable
|
||||
return locked;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return List of permissions applied to this Node.
|
||||
* Strings returned are of the format [ALLOWED|DENIED];[USERNAME|GROUPNAME];PERMISSION for example
|
||||
* ALLOWED;kevinr;Consumer so can be easily tokenized on the ';' character.
|
||||
*/
|
||||
public List<String> getPermissions()
|
||||
{
|
||||
if (this.permissions == null)
|
||||
{
|
||||
String userName = this.services.getAuthenticationService().getCurrentUserName();
|
||||
this.permissions = new ArrayList<String>(4);
|
||||
Set<AccessPermission> acls = this.services.getPermissionService().getAllSetPermissions(this.nodeRef);
|
||||
for (AccessPermission permission : acls)
|
||||
{
|
||||
StringBuilder buf = new StringBuilder(64);
|
||||
buf.append(permission.getAccessStatus())
|
||||
.append(';')
|
||||
.append(permission.getAuthority())
|
||||
.append(';')
|
||||
.append(permission.getPermission());
|
||||
this.permissions.add(buf.toString());
|
||||
}
|
||||
}
|
||||
return this.permissions;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return the parent node
|
||||
*/
|
||||
|
Reference in New Issue
Block a user