class UserRest {

    @GET
    @Path("username")
    @RolesAllowed("user")
    @Produces(MediaType.TEXT_PLAIN)
    @ApiOperation("Retrieve a username based on the passed User IRI")
    public Response getUsername(@QueryParam("iri") String userIri) {
        try {
            String username = engineManager.getUsername(vf.createIRI(userIri)).orElseThrow(() ->
                    ErrorUtils.sendError("User not found", Response.Status.NOT_FOUND));
            return Response.ok(username).build();
        } catch (IllegalArgumentException ex) {
            throw ErrorUtils.sendError(ex.getMessage(), Response.Status.BAD_REQUEST);
        }
    }

}