Package com.esri.gpt.framework.http

Examples of com.esri.gpt.framework.http.HttpClientRequest


   * @return the metadata xml string.
   * @throws IOException if the http request fails due to i/o exception
   */
  private String read(BaseAtomInfo info,String url) throws IOException {
    try {
      HttpClientRequest cr = new HttpClientRequest();
      cr.setUrl(url);
      XmlHandler sh = new XmlHandler(false);
      cr.setContentHandler(sh);
      cr.setCredentialProvider(info.newCredentialProvider());
      cr.setBatchHttpClient(info.getBatchHttpClient());
      try {
        cr.execute();
      } catch (IOException e) {
        return "";
      }     
      Document doc = sh.getDocument();     
      String mdText = XmlIoUtil.domToString(doc);
View Full Code Here


    String georssBox = "<georss:box>";
    if(url.length() > 0){
      url = url.substring(0,url.indexOf("?"));
      String params = "&id="+id+"f=json"
      url = url + params;
      HttpClientRequest cr = new HttpClientRequest();
      cr.setUrl(url);
      String response = Val.chkStr(cr.readResponseAsCharacters());
      if(response.length() > 0){
        JSONObject jso = new JSONObject(response);
          if(jso.has("results")){
            JSONArray results = jso.getJSONArray("results");
            for(int i=0; i < results.length(); i++){
View Full Code Here

   * @throws IOException if the http request fails due to i/o exception
   */
  private String read(BaseAtomInfo info, String sourceUri) throws IOException {
    try {
      sourceUri = Val.chkStr(sourceUri).replaceAll("\\{", "%7B").replaceAll("\\}", "%7D");
      HttpClientRequest cr = new HttpClientRequest();
      cr.setUrl(info.newReadMetadataUrl(sourceUri));
      XmlHandler sh = new XmlHandler(false);
      cr.setContentHandler(sh);
      cr.setCredentialProvider(info.newCredentialProvider());
      cr.setBatchHttpClient(info.getBatchHttpClient());
      cr.execute();
      Document doc = sh.getDocument();
      XPath xPath = XPathFactory.newInstance().newXPath();
      Node node = (Node) xPath.evaluate(
          "/feed/entry",
          doc, XPathConstants.NODE);
View Full Code Here

 
 
  try {
    URI uri = this.getConnectionUri();
    URL url = uri.toURL();
    HttpClientRequest clientRequest =
      HttpClientRequest.newRequest(HttpClientRequest.MethodName.GET,
          url.toExternalForm());
    clientRequest.setConnectionTimeMs(getConnectionTimeoutMs());
    clientRequest.setResponseTimeOutMs(getResponseTimeoutMs());
   
    Map map = (Map)
      this.getRequestContext().extractFromSession(SEARCH_CREDENTIAL_MAP);
    if(map != null) {
      CredentialProvider credProvider = (CredentialProvider)
        map.get(this.getKey());
      if(credProvider  != null) {
        clientRequest.setCredentialProvider(credProvider);
      }
    }       
   
    clientRequest.execute();
    String response = clientRequest.readResponseAsCharacters();
    InputStream is = null;
    try {
      SearchXslProfile profile = this.readXslProfile();
      String js = Val.chkStr(profile.getResponsexslt());
      //String js = Val.chkStr(this.getFactoryAttributes().get("searchResponseJsT"));
View Full Code Here

  URL url = null;
  Exception ex = null;
  try {
    url = new URL(metaUrl);

    HttpClientRequest clientRequest = HttpClientRequest.newRequest(
        HttpClientRequest.MethodName.GET, url.toExternalForm());
    clientRequest.setConnectionTimeMs(getConnectionTimeoutMs());
    clientRequest.setResponseTimeOutMs(getResponseTimeoutMs());
    clientRequest.execute();
    String response = clientRequest.readResponseAsCharacters();
    LOG.log(Level.FINER, "Response from get Metadata url = {0}\n response = \n{1}", new Object[]{url.toExternalForm(), response});
    recordX = new SearchXslRecord();
    this.readXslProfile().readGetMetadataByIDResponse(response, recordX);
  } catch (MalformedURLException e) {
    ex = e;
View Full Code Here

    // read the response from the targeted server
    InputStream responseStream = null;
    InputStream wrappedStream = null;
    try {

      HttpClientRequest cr = new HttpClientRequest();
      cr.setUrl(url);
      XmlHandler sh = new XmlHandler(false);
      cr.setContentHandler(sh);
      cr.setCredentialProvider(cp != null ? cp : CredentialProvider.getThreadLocalInstance());
      cr.execute();

      return sh.getDocument();
    } catch (IllegalArgumentException ex) {
      LogUtil.getLogger().log(Level.FINER, "Error accessing host: " + url, ex);
      return null;
View Full Code Here

  @Override
protected InputStream openConnection(String connectionString)
  throws HRConnectionException {
  try {

    HttpClientRequest cr = new HttpClientRequest();
    cr.setUrl(connectionString);
    ByteArrayHandler sh = new ByteArrayHandler();
    cr.setContentHandler(sh);
    CredentialProvider cp = getUserName().length()>0 && getUserPassword().length()>0?
      new CredentialProvider(getUserName(),getUserPassword()):
      CredentialProvider.getThreadLocalInstance();
    cr.setCredentialProvider(cp);
    cr.execute();

    return new ByteArrayInputStream(sh.getContent());

  } catch (MalformedURLException ex) {
    throw new HRInvalidUrlException("Invalid URL: " + getHostUrl(), ex);
View Full Code Here

  initString = Val.chkStr(initString);

  try {

    HttpClientRequest cr = new HttpClientRequest();
    cr.setUrl(connectionString);
    ByteArrayHandler sh = new ByteArrayHandler();
    StringProvider cprov = new StringProvider(initString,"text/plain");
    cr.setContentHandler(sh);
    cr.setContentProvider(cprov);
    CredentialProvider cp = getUserName().length()>0 && getUserPassword().length()>0?
      new CredentialProvider(getUserName(),getUserPassword()):
      CredentialProvider.getThreadLocalInstance();
    cr.setCredentialProvider(cp);
    cr.execute();

    return new ByteArrayInputStream(sh.getContent());

  } catch (MalformedURLException ex) {
    throw new HRInvalidUrlException("Invalid URL: " + getHostUrl(), ex);
View Full Code Here

}

public Content readContent(String sourceUri) throws IOException {
  LOGGER.log(Level.FINER, "Reading metadata of source URI: \"{0}\" through proxy: {1}", new Object[]{sourceUri, this});
  sourceUri = Val.chkStr(sourceUri).replaceAll("\\{", "%7B").replaceAll("\\}", "%7D");
  HttpClientRequest cr = new HttpClientRequest();
  cr.setBatchHttpClient(this.info.getBatchHttpClient());
  cr.setUrl(sourceUri);
  BreakableStringHandler sh = new BreakableStringHandler(criteria!=null? criteria.getFromDate(): null);
  cr.setContentHandler(sh);
  cr.setCredentialProvider(info.newCredentialProvider());
  cr.execute();
  String mdText = sh.getContent();
  LOGGER.log(Level.FINER, "Received metadata of source URI: \"{0}\" through proxy: {1}", new Object[]{sourceUri, this});
  LOGGER.finest(mdText);
  return new Content(sh.getLastModifiedDate(), mdText);
}
View Full Code Here

}

public String read(String sourceUri) throws IOException {
  LOGGER.log(Level.FINER, "Reading metadata of source URI: \"{0}\" through proxy: {1}", new Object[]{sourceUri, this});
  sourceUri = Val.chkStr(sourceUri).replaceAll("\\{", "%7B").replaceAll("\\}", "%7D");
  HttpClientRequest cr = new HttpClientRequest();
  cr.setBatchHttpClient(this.info.getBatchHttpClient());
  cr.setUrl(sourceUri);
  StringHandler sh = new StringHandler();
  cr.setContentHandler(sh);
  cr.setCredentialProvider(info.newCredentialProvider());
  cr.execute();
  String mdText = sh.getContent();
  LOGGER.log(Level.FINER, "Received metadata of source URI: \"{0}\" through proxy: {1}", new Object[]{sourceUri, this});
  LOGGER.finest(mdText);
  return mdText;
}
View Full Code Here

TOP

Related Classes of com.esri.gpt.framework.http.HttpClientRequest

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.