if(!doesUserHavePermission(permissionable, PermissionAPI.PERMISSION_EDIT_PERMISSIONS, user))
throw new DotSecurityException("User id: " + user.getUserId() + " does not have permission to alter permissions on asset " + permissionable.getPermissionId());
if(permissions == null || permissions.size() == 0) {
throw new DotDataException("This method is not intented to remove all permissionable permissions, instead use deletePermissions");
}
RoleAPI roleAPI = APILocator.getRoleAPI();
List<Permission> currentPermissions = permissionFactory.getPermissions(permissionable, true);
List<String> rolesIncluded = new ArrayList<String>();
List<Permission> includingLockedRolePermissions = new ArrayList<Permission>();
for(Permission current : currentPermissions) {
Role role = roleAPI.loadRoleById(current.getRoleId());
if(!role.isEditPermissions()) {
Permission perm = new Permission(permissionable.getPermissionId(), current.getRoleId(), current.getPermission());
includingLockedRolePermissions.add(perm);
rolesIncluded.add(role.getId());
}
}
for(Permission p : permissions) {
Role role = roleAPI.loadRoleById(p.getRoleId());
if(!role.isEditPermissions()) {
continue;
}
if(!p.getInode().equals(permissionable.getPermissionId()))
throw new DotDataException("Can't assign permissions to a diferent permissionable");
rolesIncluded.add(role.getId());
includingLockedRolePermissions.add(p);
}
for(Permission current : currentPermissions) {