{
Query query = RequestAtt.getQuery(getRequest());
if (query == null) {
// query is expected to be available in the request attributes
throw new ResourceException(SERVER_ERROR_INTERNAL, "missing query attribute");
}
if (!(query instanceof GraphQuery)) {
throw new ResourceException(SERVER_ERROR_INTERNAL, "unexpected query type: "
+ query.getClass().getName());
}
try {
GraphResult queryResult = ((GraphQuery)query).evaluate();
return new ModelResultRepresentation(queryResult, service, mediaType);
}
catch (StoreException e) {
throw new ResourceException(e);
}
}