Package lupos.endpoint.client.formatreader

Examples of lupos.endpoint.client.formatreader.MIMEFormatReader


   * If any answer (response) is received with a given id, store the answer
   * here. The waiting thread for this message is called internally.
   */
  private void addMessageResult(String id, String message) {

    MIMEFormatReader reader = new JSONFormatReader();
    // read in the message (JSON message result)
    Bindings.instanceClass = lupos.datastructures.bindings.BindingsMap.class;

    QueryResult qr = null;
    try {
      qr = reader.getQueryResult(
          new ByteArrayInputStream(message.getBytes("UTF-8")),
          message,bindingsFactory);
    } catch (UnsupportedEncodingException e) {
      e.printStackTrace();
    }
View Full Code Here


    if(contentType==null){
      System.err.println("Content type missing in response of SPARQL endpoint!");
      Thread.dumpStack();
      return null;
    }
    MIMEFormatReader reader = Client.registeredFormatReaders.get(contentType);
    if(reader==null){
      final String[] contentTypeParts=contentType.split(";");
      for(final String contentTypeSecondTry: contentTypeParts){
        reader = Client.registeredFormatReaders.get(contentTypeSecondTry);
        if(reader!=null){
          return reader.getQueryResult(response.getSecond(), query, bindingsFactory);
        }
      }
      if(contentType.compareTo("text/plain")==0){
        final String errorMessage = "Error message received:\n" + FileHelper.readInputStreamToString(response.getSecond());
        System.err.println(errorMessage);
        throw new RuntimeException(errorMessage);
      }
      final String errorText = "Content type "+contentType+" is not supported!";
      System.err.println(errorText);
      throw new IOException(errorText + "Content:\n" + FileHelper.readInputStreamToString(response.getSecond()));
    }
    return reader.getQueryResult(response.getSecond(), query, bindingsFactory);
  }
View Full Code Here

TOP

Related Classes of lupos.endpoint.client.formatreader.MIMEFormatReader

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.