Package org.openrdf.http.client.connections

Examples of org.openrdf.http.client.connections.HTTPRequest


  }

  public QueryClient postQuery(QueryLanguage ql, String query, String baseURI)
    throws StoreException, MalformedQueryException
  {
    HTTPRequest request = pool.post();
    try {
      request.sendForm(getQueryParams(ql, query, baseURI));
      execute(request);
      String url = request.readLocation();
      String type = request.readQueryType();
      HTTPConnectionPool location = pool.location(url);
      if (Protocol.GRAPH_QUERY.equals(type)) {
        return new GraphQueryClient(location);
      }
      if (Protocol.BOOLEAN_QUERY.equals(type)) {
        return new BooleanQueryClient(location);
      }
      if (Protocol.BINDINGS_QUERY.equals(type)) {
        return new TupleQueryClient(location);
      }
      throw new StoreException("Unsupported query type: " + type);
    }
    catch (IOException e) {
      throw new StoreException(e);
    }
    finally {
      request.release();
    }
  }
View Full Code Here


  }

  public GraphQueryClient postGraphQuery(QueryLanguage ql, String query, String baseURI)
    throws StoreException, MalformedQueryException
  {
    HTTPRequest request = pool.post();
    try {
      request.sendForm(getQueryParams(ql, query, baseURI));
      execute(request);
      String url = request.readLocation();
      assert Protocol.GRAPH_QUERY.equals(request.readQueryType());
      return new GraphQueryClient(pool.location(url));
    }
    catch (IOException e) {
      throw new StoreException(e);
    }
    finally {
      request.release();
    }
  }
View Full Code Here

  }

  public BooleanQueryClient postBooleanQuery(QueryLanguage ql, String query, String baseURI)
    throws StoreException, MalformedQueryException
  {
    HTTPRequest request = pool.post();
    try {
      request.sendForm(getQueryParams(ql, query, baseURI));
      execute(request);
      String url = request.readLocation();
      assert Protocol.BOOLEAN_QUERY.equals(request.readQueryType());
      return new BooleanQueryClient(pool.location(url));
    }
    catch (IOException e) {
      throw new StoreException(e);
    }
    finally {
      request.release();
    }
  }
View Full Code Here

  }

  public TupleQueryClient postTupleQuery(QueryLanguage ql, String query, String baseURI)
    throws StoreException, MalformedQueryException
  {
    HTTPRequest request = pool.post();
    try {
      request.sendForm(getQueryParams(ql, query, baseURI));
      execute(request);
      String url = request.readLocation();
      assert Protocol.BINDINGS_QUERY.equals(request.readQueryType());
      return new TupleQueryClient(pool.location(url));
    }
    catch (IOException e) {
      throw new StoreException(e);
    }
    finally {
      request.release();
    }
  }
View Full Code Here

  }

  public void list(TupleQueryResultHandler handler)
    throws TupleQueryResultHandlerException, StoreConfigException
  {
    HTTPRequest request = pool.get();

    try {
      request.acceptTupleQueryResult();
      execute(request);
      request.readTupleQueryResult(handler);
    }
    catch (IOException e) {
      throw new StoreConfigException(e);
    }
    catch (NoCompatibleMediaType e) {
      throw new StoreConfigException(e);
    }
    catch (QueryResultParseException e) {
      throw new StoreConfigException(e);
    }
    finally {
      request.release();
    }
  }
View Full Code Here

  }

  public <T> T get(Class<T> type)
    throws StoreConfigException
  {
    HTTPRequest request = pool.get();

    try {
      request.accept(type);
      execute(request);
      return request.read(type);
    }
    catch (IOException e) {
      throw new StoreConfigException(e);
    }
    catch (NoCompatibleMediaType e) {
      throw new StoreConfigException(e);
    }
    catch (NumberFormatException e) {
      throw new StoreConfigException(e);
    }
    catch (QueryResultParseException e) {
      throw new StoreConfigException(e);
    }
    catch (RDFParseException e) {
      throw new StoreConfigException(e);
    }
    finally {
      request.release();
    }
  }
View Full Code Here

  }

  public void put(Object instance)
    throws StoreConfigException
  {
    HTTPRequest request = pool.put();
    try {
      request.send(instance);
      execute(request);
    }
    catch (IOException e) {
      throw new StoreConfigException(e);
    }
    finally {
      request.release();
    }
  }
View Full Code Here

  }

  public void delete()
    throws StoreConfigException
  {
    HTTPRequest request = pool.delete();
    try {
      execute(request);
    }
    catch (IOException e) {
      throw new StoreConfigException(e);
    }
    finally {
      request.release();
    }
  }
View Full Code Here

  }

  public <T> T get(String id, Class<T> type)
    throws StoreConfigException
  {
    HTTPRequest request = pool.slash(id).get();

    try {
      request.accept(type);
      try {
        request.execute();
      }
      catch (NotFound e) {
        return null;
      }
      catch (UnsupportedQueryLanguage e) {
        throw new UnsupportedQueryLanguageException(e);
      }
      catch (UnsupportedFileFormat e) {
        throw new UnsupportedRDFormatException(e);
      }
      catch (UnsupportedMediaType e) {
        throw new UnsupportedRDFormatException(e);
      }
      catch (Unauthorized e) {
        throw new StoreConfigException(e);
      }
      catch (HTTPException e) {
        throw new StoreConfigException(e);
      }
      return request.read(type);
    }
    catch (IOException e) {
      throw new StoreConfigException(e);
    }
    catch (NumberFormatException e) {
      throw new StoreConfigException(e);
    }
    catch (QueryResultParseException e) {
      throw new StoreConfigException(e);
    }
    catch (RDFParseException e) {
      throw new StoreConfigException(e);
    }
    catch (NoCompatibleMediaType e) {
      throw new StoreConfigException(e);
    }
    finally {
      request.release();
    }
  }
View Full Code Here

  }

  public void put(String id, Object instance)
    throws StoreConfigException
  {
    HTTPRequest request = pool.slash(id).put();
    try {
      request.send(instance);
      execute(request);
    }
    catch (IOException e) {
      throw new StoreConfigException(e);
    }
    finally {
      request.release();
    }
  }
View Full Code Here

TOP

Related Classes of org.openrdf.http.client.connections.HTTPRequest

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.