Query query = context.buildQuery(getMatrixParameters(uriInfo, persistenceUnit), queryName, getMatrixParameters(uriInfo, queryName), getQueryParameters(uriInfo));
DatabaseQuery dbQuery = ((EJBQueryImpl<?>) query).getDatabaseQuery();
FeatureSet featureSet = context.getSupportedFeatureSet();
if (featureSet.isSupported(Feature.PAGING)) {
FeatureRequestValidator requestValidator = featureSet.getRequestValidator(Feature.PAGING);
if (requestValidator.isRequested(uriInfo, null)) {
Map<String, Object> map = new HashMap<String, Object>();
map.put(PagingRequestValidator.DB_QUERY, dbQuery);
map.put(PagingRequestValidator.QUERY, query);
if (!requestValidator.isRequestValid(uriInfo, map)) {
// some query parameters for paging are invalid
throw JPARSException.invalidPagingRequest();
}
return namedQueryResponse(context, queryName, dbQuery, query, headers, uriInfo, featureSet.getResponseBuilder(Feature.PAGING));
}