com.paypal.base
Class HttpConnection

java.lang.Object
  extended by com.paypal.base.HttpConnection
Direct Known Subclasses:
DefaultHttpConnection, GoogleAppEngineHttpConnection

public abstract class HttpConnection
extends Object

Base HttpConnection class


Field Summary
protected  HttpConfiguration config
          Subclasses must set the http configuration in the createAndconfigureHttpConnection() method.
protected  HttpURLConnection connection
          Subclasses must create and set the connection in the createAndconfigureHttpConnection() method.
 
Constructor Summary
HttpConnection()
           
 
Method Summary
abstract  void createAndconfigureHttpConnection(HttpConfiguration clientConfiguration)
          create and configure HttpsURLConnection object
 String execute(String url, String payload, Map<String,String> headers)
          Executes HTTP request
protected  String read(BufferedReader reader)
           
protected  void setHttpHeaders(Map<String,String> headers)
          Set headers for HttpsURLConnection object
abstract  void setupClientSSL(String certPath, String certKey)
          Set ssl parameters for client authentication
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

config

protected HttpConfiguration config
Subclasses must set the http configuration in the createAndconfigureHttpConnection() method.


connection

protected HttpURLConnection connection
Subclasses must create and set the connection in the createAndconfigureHttpConnection() method.

Constructor Detail

HttpConnection

public HttpConnection()
Method Detail

execute

public String execute(String url,
                      String payload,
                      Map<String,String> headers)
               throws InvalidResponseDataException,
                      IOException,
                      InterruptedException,
                      HttpErrorException,
                      ClientActionRequiredException
Executes HTTP request

Parameters:
url -
payload -
headers -
Returns:
String response
Throws:
InvalidResponseDataException
IOException
InterruptedException
HttpErrorException
ClientActionRequiredException

setupClientSSL

public abstract void setupClientSSL(String certPath,
                                    String certKey)
                             throws SSLConfigurationException
Set ssl parameters for client authentication

Parameters:
certPath -
certKey -
Throws:
SSLConfigurationException

createAndconfigureHttpConnection

public abstract void createAndconfigureHttpConnection(HttpConfiguration clientConfiguration)
                                               throws IOException
create and configure HttpsURLConnection object

Parameters:
clientConfiguration -
Throws:
MalformedURLException
IOException

read

protected String read(BufferedReader reader)
               throws IOException
Throws:
IOException

setHttpHeaders

protected void setHttpHeaders(Map<String,String> headers)
Set headers for HttpsURLConnection object

Parameters:
headers -


Copyright © 2015. All Rights Reserved.