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); } }
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); } }