private static Result grantOrRevokeToUser(String collectionName, String id,
String username, String action, boolean grant, boolean isUUID) {
try {
//converts uuid in rid
String rid= DocumentService.getRidByString(id, isUUID);
Permissions permission=PermissionsHelper.permissionsFromString.get(action.toLowerCase());
if (permission==null) return badRequest(action + " is not a valid action");
if (grant) DocumentService.grantPermissionToUser(collectionName, rid, permission, username);
else DocumentService.revokePermissionToUser(collectionName, rid, permission, username);
} catch (RidNotFoundException e) {
return notFound("id " + id + " not found");