class UserRest {

    @DELETE
    @Path("{username}/roles")
    @RolesAllowed("admin")
    @ApiOperation("Remove role from a Mobi User")
    public Response removeUserRole(@PathParam("username") String username, @QueryParam("role") String role) {
        if (StringUtils.isEmpty(username) || role == null) {
            throw ErrorUtils.sendError("Both username and role must be provided", Response.Status.BAD_REQUEST);
        }
        try {
            User savedUser = engineManager.retrieveUser(username).orElseThrow(() ->
                    ErrorUtils.sendError("User " + username + " not found", Response.Status.BAD_REQUEST));
            Role roleObj = engineManager.getRole(role).orElseThrow(() ->
                    ErrorUtils.sendError("Role " + role + " not found", Response.Status.BAD_REQUEST));
            savedUser.removeHasUserRole(roleObj);
            engineManager.updateUser(savedUser);
            logger.info("Role " + role + " removed from user " + username);
            return Response.ok().build();
        } catch (IllegalArgumentException ex) {
            throw ErrorUtils.sendError(ex.getMessage(), Response.Status.BAD_REQUEST);
        }
    }

}