@Consumes(MediaType.APPLICATION_JSON)
@Produces(MediaType.APPLICATION_JSON)
public Role addRolePermission(@PathParam("role_id") String roleId,
PermissionBlueprint permission) {
Role existingRole = lookupRole(roleId);
// Don't allow NONE permissions to be created, this is currently just for
// internal use:
if (permission.getAccess().equals(Access.NONE)) {
throw new BadRequestException(i18n.tr("Access type NONE not supported."));
}
// Attach actual owner objects to each incoming permission:
Owner temp = permission.getOwner();
Owner real = ownerCurator.lookupByKey(temp.getKey());
permission.setOwner(real);
existingRole.addPermission(permission);
Role r = this.userService.updateRole(existingRole);
return r;
}