Search in sources :

Example 16 with AclChange

use of org.alfresco.repo.security.permissions.impl.AclChange in project alfresco-repository by Alfresco.

the class AbstractPermissionsDaoComponentImpl method setPermission.

public void setPermission(NodePermissionEntry nodePermissionEntry) {
    NodeRef nodeRef = nodePermissionEntry.getNodeRef();
    // Get the access control list
    // Note the logic here requires to know whether it was created or not
    Acl existing = getAccessControlList(nodeRef);
    if (existing != null) {
        deletePermissions(nodeRef);
    }
    // create the access control list
    existing = getAccessControlList(nodeRef);
    CreationReport report = createAccessControlList(nodeRef, nodePermissionEntry.inheritPermissions(), existing);
    // add all entries
    for (PermissionEntry pe : nodePermissionEntry.getPermissionEntries()) {
        SimpleAccessControlEntry entry = new SimpleAccessControlEntry();
        entry.setAuthority(pe.getAuthority());
        entry.setPermission(pe.getPermissionReference());
        entry.setAccessStatus(pe.isAllowed() ? AccessStatus.ALLOWED : AccessStatus.DENIED);
        entry.setAceType(ACEType.ALL);
        entry.setPosition(Integer.valueOf(0));
        List<AclChange> changes = aclDaoComponent.setAccessControlEntry(report.getCreated().getId(), entry);
        List<AclChange> all = new ArrayList<AclChange>(changes.size() + report.getChanges().size());
        all.addAll(report.getChanges());
        all.addAll(changes);
        getACLDAO(nodeRef).updateChangedAcls(nodeRef, all);
    }
}
Also used : NodeRef(org.alfresco.service.cmr.repository.NodeRef) PermissionEntry(org.alfresco.repo.security.permissions.PermissionEntry) SimpleNodePermissionEntry(org.alfresco.repo.security.permissions.impl.SimpleNodePermissionEntry) SimplePermissionEntry(org.alfresco.repo.security.permissions.impl.SimplePermissionEntry) NodePermissionEntry(org.alfresco.repo.security.permissions.NodePermissionEntry) ArrayList(java.util.ArrayList) AclChange(org.alfresco.repo.security.permissions.impl.AclChange) SimpleAccessControlEntry(org.alfresco.repo.security.permissions.SimpleAccessControlEntry)

Aggregations

AclChange (org.alfresco.repo.security.permissions.impl.AclChange)16 ArrayList (java.util.ArrayList)12 SimpleAccessControlEntry (org.alfresco.repo.security.permissions.SimpleAccessControlEntry)10 SimpleAccessControlListProperties (org.alfresco.repo.security.permissions.SimpleAccessControlListProperties)4 InvalidNodeRefException (org.alfresco.service.cmr.repository.InvalidNodeRefException)3 AccessControlEntry (org.alfresco.repo.security.permissions.AccessControlEntry)2 NodeRef (org.alfresco.service.cmr.repository.NodeRef)2 HashSet (java.util.HashSet)1 LinkedList (java.util.LinkedList)1 AlfrescoRuntimeException (org.alfresco.error.AlfrescoRuntimeException)1 AccessControlList (org.alfresco.repo.security.permissions.AccessControlList)1 NodePermissionEntry (org.alfresco.repo.security.permissions.NodePermissionEntry)1 PermissionEntry (org.alfresco.repo.security.permissions.PermissionEntry)1 SimpleAccessControlList (org.alfresco.repo.security.permissions.SimpleAccessControlList)1 SimpleNodePermissionEntry (org.alfresco.repo.security.permissions.impl.SimpleNodePermissionEntry)1 SimplePermissionEntry (org.alfresco.repo.security.permissions.impl.SimplePermissionEntry)1 SimplePermissionReference (org.alfresco.repo.security.permissions.impl.SimplePermissionReference)1 QName (org.alfresco.service.namespace.QName)1