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

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


   * @return
   * @throws IOException
   * @throws ClientProtocolException
   */
  public static HttpResponse executeGet(String targetURL, POLICY authPolicy, HttpParams params) throws 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);
View Full Code Here


   * @throws IOException
   * @throws ClientProtocolException
   */
  public static HttpResponse executePost(String targetURL, POLICY authPolicy, HttpParams params, Model model) throws SocialHttpClientException {
    HttpHost targetHost = new HttpHost(SocialClientContext.getHost(), SocialClientContext.getPort(), SocialClientContext.getProtocol());
    SocialHttpClient httpClient = SocialHttpClientImpl.newInstance();

    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);
View Full Code Here

   * @throws IOException
   * @throws ClientProtocolException
   */
  public static HttpResponse executeDelete(String targetURL, POLICY authPolicy, HttpParams params) throws SocialHttpClientException {
    HttpHost targetHost = new HttpHost(SocialClientContext.getHost(), SocialClientContext.getPort(), SocialClientContext.getProtocol());
    SocialHttpClient httpClient = SocialHttpClientImpl.newInstance();

    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);
View Full Code Here

TOP

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

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.