01: /*
02: * Copyright Aduna (http://www.aduna-software.com/) (c) 2007.
03: *
04: * Licensed under the Aduna BSD-style license.
05: */
06: package org.openrdf.repository.http;
07:
08: import java.io.IOException;
09:
10: import org.openrdf.http.client.HTTPClient;
11: import org.openrdf.query.GraphQuery;
12: import org.openrdf.query.GraphQueryResult;
13: import org.openrdf.query.MalformedQueryException;
14: import org.openrdf.query.QueryLanguage;
15: import org.openrdf.repository.RepositoryException;
16: import org.openrdf.rio.RDFHandler;
17: import org.openrdf.rio.RDFHandlerException;
18:
19: /**
20: * GraphQuery implementation specific to the HTTP protocol.
21: *
22: * Methods in this class may throw the specific RepositoryException subclasses
23: * UnautorizedException and NotAllowedException, the semantics of which are
24: * defined by the HTTP protocol.
25: *
26: * @see org.openrdf.http.protocol.UnauthorizedException
27: * @see org.openrdf.http.protocol.NotAllowedException
28: *
29: * @author Arjohn Kampman
30: * @author Herko ter Horst
31: */
32: public class HTTPGraphQuery extends HTTPQuery implements GraphQuery {
33:
34: public HTTPGraphQuery(HTTPRepositoryConnection con,
35: QueryLanguage ql, String queryString, String baseURI) {
36: super (con, ql, queryString, baseURI);
37: }
38:
39: public GraphQueryResult evaluate()
40: throws HTTPQueryEvaluationException {
41: HTTPClient client = httpCon.getRepository().getHTTPClient();
42:
43: try {
44: return client.sendGraphQuery(queryLanguage, queryString,
45: dataset, includeInferred, getBindingsArray());
46: } catch (IOException e) {
47: throw new HTTPQueryEvaluationException(e.getMessage(), e);
48: } catch (RepositoryException e) {
49: throw new HTTPQueryEvaluationException(e.getMessage(), e);
50: } catch (MalformedQueryException e) {
51: throw new HTTPQueryEvaluationException(e.getMessage(), e);
52: }
53: }
54:
55: public void evaluate(RDFHandler handler)
56: throws HTTPQueryEvaluationException, RDFHandlerException {
57: HTTPClient client = httpCon.getRepository().getHTTPClient();
58: try {
59: client.sendGraphQuery(queryLanguage, queryString, dataset,
60: includeInferred, handler);
61: } catch (IOException e) {
62: throw new HTTPQueryEvaluationException(e.getMessage(), e);
63: } catch (RepositoryException e) {
64: throw new HTTPQueryEvaluationException(e.getMessage(), e);
65: } catch (MalformedQueryException e) {
66: throw new HTTPQueryEvaluationException(e.getMessage(), e);
67: }
68: }
69: }
|