class StateRest {

    @GET
    @Produces(MediaType.APPLICATION_JSON)
    @RolesAllowed("user")
    @ApiOperation("Retrieves State for the User making the request based on filter criteria")
    public Response getStates(@Context ContainerRequestContext context,
                       @QueryParam("application") String applicationId,
                       @QueryParam("subjects") List<String> subjectIds) {
        String username = RestUtils.getActiveUsername(context);
        Set<Resource> subjects = subjectIds.stream()
                .map(factory::createIRI)
                .collect(Collectors.toSet());
        try {
            Map<Resource, Model> results = stateManager.getStates(username, applicationId, subjects);
            JSONArray array = new JSONArray();
            results.keySet().forEach(resource -> {
                JSONObject state = new JSONObject();
                state.put("id", resource.stringValue());
                state.put("model", convertModel(results.get(resource)));
                array.add(state);
            });
            return Response.ok(array).build();
        } catch (MobiException ex) {
            throw ErrorUtils.sendError(ex, ex.getMessage(), Response.Status.INTERNAL_SERVER_ERROR);
        }
    }

}