org.exoplatform.social.client.core.util
Class SocialHttpClientSupport

java.lang.Object
  extended by org.exoplatform.social.client.core.util.SocialHttpClientSupport

public class SocialHttpClientSupport
extends Object

Created by The eXo Platform SAS Author : eXoPlatform exo@exoplatform.com Jun 29, 2011


Constructor Summary
SocialHttpClientSupport()
           
 
Method Summary
static String buildCommonRestPathFromContext(boolean isPrivate)
          Builds the common rest path from the context.
static void consume(org.apache.http.HttpEntity entity)
          Checks the entity and close InputStream
static byte[] convertModelToByteArray(Model model)
          Gets the byte array from Model object which provides to HttpPost to Rest Service.
static void dumpContent(org.apache.http.HttpResponse response)
          Dump the HttpResponse content which Rest Service to return.
static void dumpHttpResponsetHeader(org.apache.http.HttpResponse response)
          Dump the HttpResponse's header which Rest Service to return.
static org.apache.http.HttpResponse executeDelete(String targetURL, SocialHttpClient.POLICY authPolicy)
          Invokes the social rest service via Delete method with HttpParams is null.
static org.apache.http.HttpResponse executeDelete(String targetURL, SocialHttpClient.POLICY authPolicy, org.apache.http.params.HttpParams params)
          Invokes the social rest service via Delete method with HttpParams
static org.apache.http.HttpResponse executeGet(String targetURL, SocialHttpClient.POLICY authPolicy)
          Invokes the social rest service via Get method
static org.apache.http.HttpResponse executeGet(String targetURL, SocialHttpClient.POLICY authPolicy, org.apache.http.params.HttpParams params)
          Invokes the social rest service via Get method
static org.apache.http.HttpResponse executePost(String targetURL, SocialHttpClient.POLICY authPolicy)
          Invokes the social rest service via Post but both Model and HttpParams are null.
static org.apache.http.HttpResponse executePost(String targetURL, SocialHttpClient.POLICY authPolicy, org.apache.http.params.HttpParams params)
          Invokes the social rest service via Post method with Model and HttpParams is null.
static org.apache.http.HttpResponse executePost(String targetURL, SocialHttpClient.POLICY authPolicy, org.apache.http.params.HttpParams params, Model model)
          Invokes the social rest service via Post method
static org.apache.http.HttpResponse executePost(String targetURL, SocialHttpClient.POLICY authPolicy, Model model)
          Invokes the social rest service via Post method with Model is null and HttpParams.
static String getContent(org.apache.http.HttpResponse response)
          Executes the HttpResponse with read the content to buffered.
static void handleError(org.apache.http.HttpResponse response)
          Handles the error code which contains in HttpResponse.
static org.apache.http.HttpEntity processContent(org.apache.http.HttpResponse response)
          Executes the HttpResponse with read the content to buffered.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

SocialHttpClientSupport

public SocialHttpClientSupport()
Method Detail

executeGet

public static org.apache.http.HttpResponse executeGet(String targetURL,
                                                      SocialHttpClient.POLICY authPolicy,
                                                      org.apache.http.params.HttpParams params)
                                               throws SocialHttpClientException
Invokes the social rest service via Get method

Parameters:
targetURL -
authPolicy - POLICY.NO_AUTH/POLICY.BASIC_AUTH
params - HttpParams for Request
Returns:
Throws:
IOException
org.apache.http.client.ClientProtocolException
SocialHttpClientException

executeGet

public static org.apache.http.HttpResponse executeGet(String targetURL,
                                                      SocialHttpClient.POLICY authPolicy)
                                               throws SocialHttpClientException
Invokes the social rest service via Get method

Parameters:
targetURL -
authPolicy - POLICY.NO_AUTH/POLICY.BASIC_AUTH
Returns:
Throws:
IOException
org.apache.http.client.ClientProtocolException
SocialHttpClientException

executePost

public static org.apache.http.HttpResponse executePost(String targetURL,
                                                       SocialHttpClient.POLICY authPolicy,
                                                       org.apache.http.params.HttpParams params,
                                                       Model model)
                                                throws SocialHttpClientException
Invokes the social rest service via Post method

Parameters:
targetURL -
authPolicy - POLICY.NO_AUTH/POLICY.BASIC_AUTH
params - HttpParams for Request
Returns:
Throws:
IOException
org.apache.http.client.ClientProtocolException
SocialHttpClientException

executePost

public static org.apache.http.HttpResponse executePost(String targetURL,
                                                       SocialHttpClient.POLICY authPolicy,
                                                       org.apache.http.params.HttpParams params)
                                                throws SocialHttpClientException
Invokes the social rest service via Post method with Model and HttpParams is null.

Parameters:
targetURL -
authPolicy - POLICY.NO_AUTH/POLICY.BASIC_AUTH
params - HttpParams for Request
Returns:
Throws:
IOException
org.apache.http.client.ClientProtocolException
SocialHttpClientException

executePost

public static org.apache.http.HttpResponse executePost(String targetURL,
                                                       SocialHttpClient.POLICY authPolicy,
                                                       Model model)
                                                throws SocialHttpClientException
Invokes the social rest service via Post method with Model is null and HttpParams.

Parameters:
targetURL -
authPolicy - POLICY.NO_AUTH/POLICY.BASIC_AUTH
Returns:
Throws:
IOException
org.apache.http.client.ClientProtocolException
SocialHttpClientException

executePost

public static org.apache.http.HttpResponse executePost(String targetURL,
                                                       SocialHttpClient.POLICY authPolicy)
                                                throws SocialHttpClientException
Invokes the social rest service via Post but both Model and HttpParams are null.

Parameters:
targetURL -
authPolicy - POLICY.NO_AUTH/POLICY.BASIC_AUTH
Returns:
Throws:
SocialHttpClientException

executeDelete

public static org.apache.http.HttpResponse executeDelete(String targetURL,
                                                         SocialHttpClient.POLICY authPolicy,
                                                         org.apache.http.params.HttpParams params)
                                                  throws SocialHttpClientException
Invokes the social rest service via Delete method with HttpParams

Parameters:
targetURL -
authPolicy - POLICY.NO_AUTH/POLICY.BASIC_AUTH
params - HttpParams for Request
Returns:
Throws:
IOException
org.apache.http.client.ClientProtocolException
SocialHttpClientException

executeDelete

public static org.apache.http.HttpResponse executeDelete(String targetURL,
                                                         SocialHttpClient.POLICY authPolicy)
                                                  throws SocialHttpClientException
Invokes the social rest service via Delete method with HttpParams is null.

Parameters:
targetURL -
authPolicy - POLICY.NO_AUTH/POLICY.BASIC_AUTH
Returns:
Throws:
IOException
org.apache.http.client.ClientProtocolException
SocialHttpClientException

convertModelToByteArray

public static byte[] convertModelToByteArray(Model model)
                                      throws IOException
Gets the byte array from Model object which provides to HttpPost to Rest Service.

Parameters:
model - Model object
Returns:
Throws:
IOException

processContent

public static org.apache.http.HttpEntity processContent(org.apache.http.HttpResponse response)
                                                 throws SocialHttpClientException
Executes the HttpResponse with read the content to buffered.

Parameters:
response - HttpResponse to process.
Returns:
Throws:
IllegalStateException
IOException
SocialHttpClientException

getContent

public static String getContent(org.apache.http.HttpResponse response)
                         throws SocialHttpClientException
Executes the HttpResponse with read the content to buffered.

Parameters:
response - HttpResponse to process.
Returns:
Content of HttpResponse.
Throws:
IllegalStateException
IOException
SocialHttpClientException

consume

public static void consume(org.apache.http.HttpEntity entity)
                    throws IllegalStateException,
                           IOException
Checks the entity and close InputStream

Parameters:
entity -
Throws:
IllegalStateException
IOException

buildCommonRestPathFromContext

public static String buildCommonRestPathFromContext(boolean isPrivate)
Builds the common rest path from the context. /{restContextName}/|/{private}|/api/social/{restVersion}/{portalContainerName}/ By using this common rest path, it's easy to append the resource name, for example: activity or identity.

Parameters:
isPrivate - indicates is the url needs authentication access.
Returns:
the string path

handleError

public static void handleError(org.apache.http.HttpResponse response)
                        throws SocialClientLibException
Handles the error code which contains in HttpResponse.

Parameters:
response - HttpResponse
Throws:
SocialClientLibException
SocialHttpClientException

dumpHttpResponsetHeader

public static void dumpHttpResponsetHeader(org.apache.http.HttpResponse response)
Dump the HttpResponse's header which Rest Service to return.

Parameters:
response -

dumpContent

public static void dumpContent(org.apache.http.HttpResponse response)
                        throws SocialHttpClientException
Dump the HttpResponse content which Rest Service to return.

Parameters:
response - Entity to dump
Throws:
org.apache.http.ParseException
IOException
SocialHttpClientException


Copyright © 2011 eXo Platform. All Rights Reserved.