Package fi.luomus.commons.http

Examples of fi.luomus.commons.http.HttpClientService


    this(config.get(Config.TIPU_API_URI), config.get(Config.TIPU_API_USERNAME), config.get(Config.TIPU_API_PASSWORD));
  }
 
  public TipuAPIClientImple(String uri, String username, String password) throws URISyntaxException {
    this.uri = uri;
    this.httpclient = new HttpClientService(uri, username, password);
  }
View Full Code Here


public class HTTPFeedReaderClient implements FeedReaderClient {
    private final HttpClientService client;
    private final List<KeyValuePair> additionalParameters = new ArrayList<KeyValuePair>();

    public HTTPFeedReaderClient() {
        this(new HttpClientService());
    }
View Full Code Here

  private final String uri;
  private final String systemID;

  public KirjekyyhkyAPIClientImple(String uri, String username, String password, String systemID) throws URISyntaxException {
    this.uri = uri;
    this.httpclient = new HttpClientService(uri, username, password);
    this.systemID = systemID.toLowerCase();
  }
View Full Code Here

    if (client != null) client.close();
  }
 
  @Test
  public void nonSSLConnection() throws ClientProtocolException, IOException {
    client = new HttpClientService();
    String content = client.contentAsString(new HttpGet("http://google.fi"));
    Assert.assertEquals(true, content.startsWith("<!doctype html"));
  }
View Full Code Here

    Assert.assertEquals(true, content.startsWith("<!doctype html"));
  }
 
  @Test
  public void SSLConnectionWithValidSertificate() throws ClientProtocolException, IOException {
    client = new HttpClientService();
    String content = client.contentAsString(new HttpGet("https://google.fi"));
    Assert.assertEquals(true, content.startsWith("<!doctype html"));
  }
View Full Code Here

    Assert.assertEquals(true, content.startsWith("<!doctype html"));
  }
 
  @Test
  public void contentAsJson() throws ClientProtocolException, IOException {
    client = new HttpClientService();
    HttpGet request = new HttpGet("http://ws.luomus.fi/util/coordinate-conversion-service?lat=6663841&lon=333229&type=trs-tm35fin&format=json");
    JSONObject json = client.contentAsJson(request);
    Assert.assertEquals(1, json.getKeys().length);
    Assert.assertEquals("conversion-response", json.getKeys()[0]);
  }
View Full Code Here

      if (api != null) api.close();
    }
  }

  private static void httpClientExample() {
    HttpClientService client = null;
    try {
      client = new HttpClientService();
      String content = client.contentAsString(new HttpGet("http://www.google.com"));
      assert(content.length() > 0);
    } catch (Exception e) {
      e.printStackTrace();
    } finally {
      if (client != null) client.close();
    }
  }
View Full Code Here

    return search(searchword, null);
  }

  @Override
  public Document search(String searchword, String checklist) throws Exception {
    HttpClientService client = null;
    try {
      client = new HttpClientService();
      URIBuilder uri = new URIBuilder(getTriplestoreBaseURL() + "/taxon-search/" + Utils.urlEncode(searchword));
      if (given(checklist)) {
        uri.addParameter("checklist", checklist);
      }
      Document response = client.contentAsDocument(new HttpGet(uri.getURI()));
      return response;
    } finally {
      if (client != null) client.close();
    }
  }
View Full Code Here

    public ChecklistLoaderFromTriplestoreAPI(Config config) {
      this.config = config;
    }
    @Override
    public Collection<Checklist> load() {
      HttpClientService client = null;
      try {
        client = new HttpClientService();
        List<Checklist> checklists = loadUsingClient(client);
        Collections.sort(checklists);
        return checklists;
      } catch (Exception e) {
        throw new RuntimeException(e);
      }
      finally {
        if (client != null) client.close();
      }
    }
View Full Code Here

    public PersonLoaderFromTriplestoreAPI(Config config) {
      this.config = config;
    }
    @Override
    public Map<String, Person> load() {
      HttpClientService client = null;
      try {
        client = new HttpClientService();
        return loadUsingClient(client);
      } catch (Exception e) {
        throw new RuntimeException(e);
      }
      finally {
        if (client != null) client.close();
      }
    }
View Full Code Here

TOP

Related Classes of fi.luomus.commons.http.HttpClientService

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.