use of org.eclipse.rdf4j.query.UnsupportedQueryLanguageException in project rdf4j by eclipse.
the class SPARQLProtocolSession method execute.
protected HttpResponse execute(HttpUriRequest method) throws IOException, RDF4JException {
boolean consume = true;
if (params != null) {
method.setParams(params);
}
HttpResponse response = httpClient.execute(method, httpContext);
try {
int httpCode = response.getStatusLine().getStatusCode();
if (httpCode >= 200 && httpCode < 300 || httpCode == HttpURLConnection.HTTP_NOT_FOUND) {
consume = false;
// everything OK, control flow can continue
return response;
} else {
switch(httpCode) {
case // 401
HttpURLConnection.HTTP_UNAUTHORIZED:
throw new UnauthorizedException();
case // 503
HttpURLConnection.HTTP_UNAVAILABLE:
throw new QueryInterruptedException();
default:
ErrorInfo errInfo = getErrorInfo(response);
// Throw appropriate exception
if (errInfo.getErrorType() == ErrorType.MALFORMED_DATA) {
throw new RDFParseException(errInfo.getErrorMessage());
} else if (errInfo.getErrorType() == ErrorType.UNSUPPORTED_FILE_FORMAT) {
throw new UnsupportedRDFormatException(errInfo.getErrorMessage());
} else if (errInfo.getErrorType() == ErrorType.MALFORMED_QUERY) {
throw new MalformedQueryException(errInfo.getErrorMessage());
} else if (errInfo.getErrorType() == ErrorType.UNSUPPORTED_QUERY_LANGUAGE) {
throw new UnsupportedQueryLanguageException(errInfo.getErrorMessage());
} else if (errInfo.toString().length() > 0) {
throw new RepositoryException(errInfo.toString());
} else {
throw new RepositoryException(response.getStatusLine().getReasonPhrase());
}
}
}
} finally {
if (consume) {
EntityUtils.consumeQuietly(response.getEntity());
}
}
}
Aggregations