Package org.exoplatform.social.client.api.net

Examples of org.exoplatform.social.client.api.net.SocialHttpClientException


    SocialHttpClient httpClient = SocialHttpClientImpl.newInstance();
    if (POLICY.BASIC_AUTH == authPolicy) {
      try {
        httpClient.setBasicAuthenticateToRequest();
      } catch (SocialClientLibException e) {
        throw new SocialHttpClientException(e.getMessage(), e);
      }
    }

    HttpGet httpGet = new HttpGet(targetURL);
    Header header = new BasicHeader("Content-Type", "application/json");
    httpGet.setHeader(header);
    HttpHost targetHost = new HttpHost(SocialClientContext.getHost(), SocialClientContext.getPort(), SocialClientContext.getProtocol());
    //Get method with the HttpParams
    if (params != null) {
      httpGet.setParams(params);
    }
   
    try {
      HttpResponse response = httpClient.execute(targetHost, httpGet);
      //handleError(response);
      //Debugging in the devlopment mode
      if (SocialClientContext.isDeveloping()) {
        dumpHttpResponsetHeader(response);
        dumpContent(response);
      }
      return response;
    } catch (ClientProtocolException cpex) {
      throw new SocialHttpClientException(cpex.toString(), cpex);
    } catch (IOException ioex) {
      throw new SocialHttpClientException(ioex.toString(), ioex);
    }
  }
View Full Code Here


    if (POLICY.BASIC_AUTH == authPolicy) {
      try {
        httpClient.setBasicAuthenticateToRequest();
      } catch (SocialClientLibException e) {
        throw new SocialHttpClientException(e.getMessage(), e);
      }
    }

    HttpPost httpPost = new HttpPost(targetURL);
    Header header = new BasicHeader("Content-Type", "application/json");
    httpPost.setHeader(header);
    //Post method with the HttpParams
    if (params != null) {
      httpPost.setParams(params);
    }
    try {

      //Provides when uses post so does not have any data.
      byte[] postData = convertModelToByteArray(model);
      if (postData != null) {
        ByteArrayEntity entity = new ByteArrayEntity(convertModelToByteArray(model));
        httpPost.setEntity(entity);
      }
      HttpResponse response = httpClient.execute(targetHost, httpPost);
     
      //handleError(response);
      //Debugging in the devlopment mode
      if (SocialClientContext.isDeveloping()) {
        dumpHttpResponsetHeader(response);
        dumpContent(response);
      }
      return response; 
    } catch (ClientProtocolException cpex) {
      throw new SocialHttpClientException(cpex.toString(), cpex);
    } catch (IOException ioex) {
      throw new SocialHttpClientException(ioex.toString(), ioex);
    }

  }
View Full Code Here

    if (POLICY.BASIC_AUTH == authPolicy) {
      try {
        httpClient.setBasicAuthenticateToRequest();
      } catch (SocialClientLibException e) {
        new SocialHttpClientException(e.getMessage(), e);
      }
    }
   
    HttpDelete httpDelete = new HttpDelete(targetURL);
    Header header = new BasicHeader("Content-Type", "application/json");
    httpDelete.setHeader(header);
    //Delete method with the HttpParams
    if (params != null) {
      httpDelete.setParams(params);
    }
    try {
      HttpResponse response = httpClient.execute(targetHost, httpDelete);
      //handleError(response);
      //Debugging in the devlopment mode
      if (SocialClientContext.isDeveloping()) {
        dumpHttpResponsetHeader(response);
        dumpContent(response);
      }
      return response;
    } catch (ClientProtocolException cpex) {
      throw new SocialHttpClientException(cpex.toString(), cpex);
    } catch (IOException ioex) {
      throw new SocialHttpClientException(ioex.toString(), ioex);
    }
  
  }
View Full Code Here

        entity = new BufferedHttpEntity(entity);
        //important to setEntity return to Response. If don't assign again, next to get
        //, you can not get the response content
        response.setEntity(entity);
      } catch (IOException ioex) {
        throw new SocialHttpClientException(ioex.toString(), ioex);
      }
    }
    return entity;
  }
View Full Code Here

    String content;
    try {
      if (entity.getContentLength() != -1) {
        content = EntityUtils.toString(entity);
      } else {
        throw new SocialHttpClientException("Content of response is empty.");
      }
    } catch (IOException ioex) {
      throw new SocialHttpClientException(ioex.toString(), ioex);
    }
    return content;
  }
View Full Code Here

          Set<Entry> list = contentMap.entrySet();
          for(Entry e : list) {
            LOGGER.debug(e.getKey() "::" + e.getValue());
          }
      } catch (org.json.simple.parser.ParseException pex) {
        throw new SocialHttpClientException("dumpContent() is parsing error.", pex);
      }
    }
  }
View Full Code Here

          Set<Entry> list = contentMap.entrySet();
          for(Entry e : list) {
            LOGGER.debug(e.getKey() "::" + e.getValue());
          }
      } catch (org.json.simple.parser.ParseException pex) {
        throw new SocialHttpClientException("dumpContent() is parsing error.", pex);
      }
     
    }
  }
View Full Code Here

TOP

Related Classes of org.exoplatform.social.client.api.net.SocialHttpClientException

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.