class StateRest {

    @GET
    @Path("{stateId}")
    @Produces(MediaType.APPLICATION_JSON)
    @RolesAllowed("user")
    @ApiOperation("Retrieves State by ID as long it belongs to the User making the request")
    public Response getState(@Context ContainerRequestContext context, @PathParam("stateId") String stateId) {
        String username = RestUtils.getActiveUsername(context);
        try {
            if (!stateManager.stateExistsForUser(factory.createIRI(stateId), username)) {
                throw ErrorUtils.sendError("Not allowed", Response.Status.UNAUTHORIZED);
            }
            Model state = stateManager.getState(factory.createIRI(stateId));
            return Response.ok(convertModel(state)).build();
        } catch (IllegalArgumentException ex) {
            throw ErrorUtils.sendError(ex, ex.getMessage(), Response.Status.NOT_FOUND);
        } catch (MobiException ex) {
            throw ErrorUtils.sendError(ex, ex.getMessage(), Response.Status.INTERNAL_SERVER_ERROR);
        }
    }

}