public SparqlQuery(Reader in, String base) throws IOException, MalformedQueryException { try { StringWriter sw = new StringWriter(); int read; char[] cbuf = new char[1024]; while ((read = in.read(cbuf)) >= 0) { sw.write(cbuf, 0, read); } sparql = sw.toString(); this.base = base; try { query = new SPARQLParser().parseQuery(sparql, base); } catch (MalformedQueryException e) { try { query = new SPARQLParser().parseUpdate(sparql, base); } catch (MalformedQueryException u) { throw e; } } } catch (MalformedQueryException e) { logger.warn(base + " " + e.getMessage(), e); } }
public void getRepositoryList(TupleQueryResultHandler handler) throws IOException, TupleQueryResultHandlerException, RepositoryException, UnauthorizedException, QueryInterruptedException { checkServerURL(); HttpGet method = new HttpGet(Protocol.getRepositoriesLocation(serverURL)); try { getTupleQueryResult(method, handler); } catch (MalformedQueryException e) { // This shouldn't happen as no queries are involved logger.warn("Server reported unexpected malfored query error", e); throw new RepositoryException(e.getMessage(), e); } }
@Override protected void runTest() throws Exception { InputStream stream = new URL(queryFileURL).openStream(); String query = IOUtil.readString(new InputStreamReader(stream, "UTF-8")); stream.close(); try { parseQuery(query, queryFileURL); if (!positiveTest) { fail("Negative test case should have failed to parse"); } } catch (MalformedQueryException e) { if (positiveTest) { e.printStackTrace(); fail("Positive test case failed: " + e.getMessage()); } } }
public void getContextIDs(TupleQueryResultHandler handler) throws IOException, TupleQueryResultHandlerException, RepositoryException, UnauthorizedException, QueryInterruptedException { checkRepositoryURL(); HttpGet method = new HttpGet(Protocol.getContextsLocation(getQueryURL())); try { getTupleQueryResult(method, handler); } catch (MalformedQueryException e) { logger.warn("Server reported unexpected malfored query error", e); throw new RepositoryException(e.getMessage(), e); } }
@Override protected void runTest() throws Exception { // Read query from file InputStream stream = new URL(queryFileURL).openStream(); String query = IOUtil.readString(new InputStreamReader(stream, "UTF-8")); stream.close(); try { QueryParserUtil.parseQuery(QueryLanguage.SPARQL, query, queryFileURL); if (!positiveTest) { fail("Negative test case should have failed to parse"); } } catch (MalformedQueryException e) { if (positiveTest) { e.printStackTrace(); fail("Positive test case failed: " + e.getMessage()); } } }
public void getNamespaces(TupleQueryResultHandler handler) throws IOException, TupleQueryResultHandlerException, RepositoryException, UnauthorizedException, QueryInterruptedException { checkRepositoryURL(); HttpUriRequest method = new HttpGet(Protocol.getNamespacesLocation(getQueryURL())); try { getTupleQueryResult(method, handler); } catch (MalformedQueryException e) { logger.warn("Server reported unexpected malfored query error", e); throw new RepositoryException(e.getMessage(), e); } }
public SPARQLQuery(Reader in, String base) throws IOException, MalformedQueryException { try { StringWriter sw = new StringWriter(); int read; char[] cbuf = new char[1024]; while ((read = in.read(cbuf)) >= 0) { sw.write(cbuf, 0, read); } sparql = sw.toString(); this.base = base; try { query = new SPARQLParser().parseQuery(sparql, base); } catch (MalformedQueryException e) { try { query = new SPARQLParser().parseUpdate(sparql, base); } catch (MalformedQueryException u) { throw e; } } } catch (MalformedQueryException e) { throw new MalformedQueryException(base + " " + e.getMessage(), e); } finally { in.close(); } }
} catch (MalformedQueryException ex) { String str = ex.getMessage(); close(conn, ex); return Response.status(Response.Status.BAD_REQUEST).entity(
/** * Returns a <tt>SelectQuery</tt> for the specified SPARQL SELECT query string. * * @param string * the query string, in SPARQL and without relative URIs * @return the corresponding <tt>SelectQuery</tt> * @throws ParseException * in case the string does not denote a valid SPARQL SELECT query */ public static SelectQuery from(final String string) throws ParseException { Preconditions.checkNotNull(string); SelectQuery query = CACHE.getIfPresent(string); if (query == null) { final ParsedTupleQuery parsedQuery; try { parsedQuery = QueryParserUtil.parseTupleQuery(QueryLanguage.SPARQL, string, null); } catch (final IllegalArgumentException ex) { throw new ParseException(string, "SPARQL query not in SELECT form", ex); } catch (final MalformedQueryException ex) { throw new ParseException(string, "Invalid SPARQL query: " + ex.getMessage(), ex); } query = new SelectQuery(string, parsedQuery.getTupleExpr(), parsedQuery.getDataset()); CACHE.put(string, query); } return query; }
@Override protected void runTest() throws Exception { // Read query from file InputStream stream = url(queryFile).openStream(); String query = IOUtil.readString(new InputStreamReader(stream, "UTF-8")); stream.close(); try { QueryParser parser = createParser(); parser.parseQuery(query, null); if (MFX_PARSE_ERROR.equals(result)) { fail("Negative syntax test failed. Malformed query caused no error."); } } catch (MalformedQueryException e) { if (MFX_CORRECT.equals(result)) { fail("Positive syntax test failed: " + e.getMessage()); } else { return; } } }
throw new RepositoryException("Query is malformed. Details: "+ e.getMessage()); } catch (QueryEvaluationException e) { throw new RepositoryException("Query could not be evaluated. Details: " + e.getMessage());
throw new RepositoryException(e.getMessage(), e);
public boolean evaluate() throws QueryEvaluationException { SparqlSession client = getHttpClient(); try { return client.sendBooleanQuery(queryLanguage, getQueryString(), baseURI, dataset, getIncludeInferred(), getMaxExecutionTime(), getBindingsArray()); } catch (IOException e) { throw new QueryEvaluationException(e.getMessage(), e); } catch (RepositoryException e) { throw new QueryEvaluationException(e.getMessage(), e); } catch (MalformedQueryException e) { throw new QueryEvaluationException(e.getMessage(), e); } }
public void evaluate(RDFHandler handler) throws QueryEvaluationException, RDFHandlerException { SparqlSession client = getHttpClient(); try { client.sendGraphQuery(queryLanguage, getQueryString(), baseURI, dataset, getIncludeInferred(), getMaxExecutionTime(), handler, getBindingsArray()); } catch (IOException e) { throw new QueryEvaluationException(e.getMessage(), e); } catch (RepositoryException e) { throw new QueryEvaluationException(e.getMessage(), e); } catch (MalformedQueryException e) { throw new QueryEvaluationException(e.getMessage(), e); } }
public TupleQueryResult evaluate() throws QueryEvaluationException { SparqlSession client = getHttpClient(); try { return client.sendTupleQuery(QueryLanguage.SPARQL, getQueryString(), baseURI, dataset, getIncludeInferred(), getMaxExecutionTime(), getBindingsArray()); } catch (IOException e) { throw new QueryEvaluationException(e.getMessage(), e); } catch (RepositoryException e) { throw new QueryEvaluationException(e.getMessage(), e); } catch (MalformedQueryException e) { throw new QueryEvaluationException(e.getMessage(), e); } }
public void evaluate(TupleQueryResultHandler handler) throws QueryEvaluationException, TupleQueryResultHandlerException { SparqlSession client = getHttpClient(); try { client.sendTupleQuery(QueryLanguage.SPARQL, getQueryString(), baseURI, dataset, getIncludeInferred(), getMaxExecutionTime(), handler, getBindingsArray()); } catch (IOException e) { throw new QueryEvaluationException(e.getMessage(), e); } catch (RepositoryException e) { throw new QueryEvaluationException(e.getMessage(), e); } catch (MalformedQueryException e) { throw new QueryEvaluationException(e.getMessage(), e); } }
public GraphQueryResult evaluate() throws QueryEvaluationException { SparqlSession client = getHttpClient(); try { // TODO getQueryString() already inserts bindings, use emptybindingset // as last argument? return client.sendGraphQuery(queryLanguage, getQueryString(), baseURI, dataset, getIncludeInferred(), getMaxExecutionTime(), getBindingsArray()); } catch (IOException e) { throw new QueryEvaluationException(e.getMessage(), e); } catch (RepositoryException e) { throw new QueryEvaluationException(e.getMessage(), e); } catch (MalformedQueryException e) { throw new QueryEvaluationException(e.getMessage(), e); } }
@Override public void execute() throws UpdateExecutionException { try { // execute update immediately SparqlSession client = getHttpClient(); try { client.sendUpdate(getQueryLanguage(), getQueryString(), getBaseURI(), dataset, includeInferred, getMaxExecutionTime(), getBindingsArray()); } catch (UnauthorizedException e) { throw new UpdateExecutionException(e.getMessage(), e); } catch (QueryInterruptedException e) { throw new UpdateExecutionException(e.getMessage(), e); } catch (MalformedQueryException e) { throw new UpdateExecutionException(e.getMessage(), e); } catch (IOException e) { throw new UpdateExecutionException(e.getMessage(), e); } } catch (RepositoryException e) { throw new UpdateExecutionException(e.getMessage(), e); } }
store, astContainer, globallyScopedBS, dataset, context); } catch (MalformedQueryException e) { throw new QueryEvaluationException(e.getMessage(), e);
store, astContainer, globallyScopedBS, dataset, context); } catch (MalformedQueryException e) { throw new QueryEvaluationException(e.getMessage(), e);