org.awakefw.commons.api.client
Class HttpProtocolParameters

java.lang.Object
  extended by org.awakefw.commons.api.client.HttpProtocolParameters

public final class HttpProtocolParameters
extends Object

Allows to define some parameters for the Awake session:

Allows also to store http protocol parameters that will be passed to the underlying DefaultHttpClient class of the Jakarta HttpClient Library library.

Use this class only if you want to change the default values of the HttpClient library and pass the created instance to AwakeFileSession or AwakeConnection.

For example, the following change the default connection timeout to 10 seconds and the default socket timeout to 60 seconds:

 String url = "https://www.acme.org/AwakeFileManager";
 String username = "myUsername";
 char [] password = {'m', 'y', 'P', 'a', 's', 's', 'w', 'o', 'r', 'd'}; 
          
 HttpProtocolParameters httpProtocolParameters = new HttpProtocolParameters();
  
 // Sets the timeout until a connection is established to 10 seconds
 httpProtocolParameters.setHttpClientParameter(
 "http.connection.timeout", new Integer(10 * 1000));
  
 // Sets the socket timeout (SO_TIMEOUT) to 60 seconds
 httpProtocolParameters.setHttpClientParameter("http.socket.timeout",
 new Integer(60 * 1000));
          
 // We will use no proxy
 HttpProxy httpProxy = null;
          
 AwakeFileSession awakeFileSession 
 = new AwakeFileSession(url, username, password, httpProxy, httpProtocolParameters);
  
 // Etc.
 
See
HttpComponents Tutorial for more info on HTTP parameters.

Since:
1.0
Author:
Nicolas de Pomereu

Constructor Summary
HttpProtocolParameters()
          Constructor.
 
Method Summary
 void clearHttpClientParameters()
          Removes all parameters from this collection.
 int getDownloadBufferSize()
          Returns the buffer size when downloading files.
 char[] getEncryptionPassword()
          Returns the encryption Password that encrypts http request parameters.
 Object getHttpClientParameter(String name)
          Gets the value of this HttpClient Library parameter.
 Set<String> getHttpClientParameterNames()
          Returns the new parameters key set.
 Map<String,Object> getHttpClientParameters()
          Returns the HttpClient Parameters.
 int getMaxLengthForString()
          Returns the maximum authorized length for a string for upload or download (in order to avoid OutOfMemoryException on client and server side).
 int getUploadBufferSize()
          Returns the buffer size when uploading files.
 boolean isAcceptAllSslCertificates()
          Says if client sides allows HTTPS call with all SSL Certificates, including "invalid" or self-signed Certificates.
 boolean isHtmlEncodingOn()
          Says if the upload/download of Clob using character stream or ASCII stream is html encoded.
 void setAcceptAllSslCertificates(boolean acceptAllSslCertificates)
          Sets if client sides must allow HTTPS call with all SSL Certificates, including "invalid" or self-signed Certificates.
 void setDownloadBufferSize(int downloadBufferSize)
          Sets the buffer size when downloading files.
 void setEncryptionPassword(char[] encryptionPassword)
          Sets the encryption Password that encrypts http request parameters.
 void setHtmlEncodingOn(boolean htmlEncodeOn)
          Says if the upload/download of Clob using character stream or ASCII stream must be html encoded.
 void setHttpClientParameter(String name, Object value)
          Sets the value of this HttpClient Library parameter.
 void setHttpClientParameters(Map<String,Object> httpClientParameters)
          Sets the HttpClient Parameters.
 void setMaxLengthForString(int maxLengthForString)
          Sets the maximum authorized length for a string for upload or download (in order to avoid OutOfMemoryException on client and server side).
 void setUploadBufferSize(int uploadBufferSize)
          Sets the buffer size when uploading files.
 String toString()
          Returns a clean representation of the HttpProtocolParameters instance.
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

HttpProtocolParameters

public HttpProtocolParameters()
Constructor.

Method Detail

getMaxLengthForString

public int getMaxLengthForString()
Returns the maximum authorized length for a string for upload or download (in order to avoid OutOfMemoryException on client and server side).

Returns:
the maximum authorized length for a string for upload or download

setMaxLengthForString

public void setMaxLengthForString(int maxLengthForString)
Sets the maximum authorized length for a string for upload or download (in order to avoid OutOfMemoryException on client and server side).

Parameters:
maxLengthForString - the maximum authorized length for a string for upload or download

getUploadBufferSize

public int getUploadBufferSize()
Returns the buffer size when uploading files.

Returns:
the buffer size when uploading files

setUploadBufferSize

public void setUploadBufferSize(int uploadBufferSize)
Sets the buffer size when uploading files.

Parameters:
uploadBufferSize - the buffer size when uploading files

getDownloadBufferSize

public int getDownloadBufferSize()
Returns the buffer size when downloading files.

Returns:
the buffer size when downloading files

setDownloadBufferSize

public void setDownloadBufferSize(int downloadBufferSize)
Sets the buffer size when downloading files.

Parameters:
downloadBufferSize - the buffer size when downloading files to set

getEncryptionPassword

public char[] getEncryptionPassword()
Returns the encryption Password that encrypts http request parameters.

Returns:
the encryption Password that encrypts http request parameters

setEncryptionPassword

public void setEncryptionPassword(char[] encryptionPassword)
Sets the encryption Password that encrypts http request parameters.

Parameters:
encryptionPassword - the encryption Password that encrypts http request parameters

isHtmlEncodingOn

public boolean isHtmlEncodingOn()
Says if the upload/download of Clob using character stream or ASCII stream is html encoded. (For Awake SQL only).

Returns:
true if the upload/download of Clob is html encoded

setHtmlEncodingOn

public void setHtmlEncodingOn(boolean htmlEncodeOn)
Says if the upload/download of Clob using character stream or ASCII stream must be html encoded. (For Awake SQL only).

Parameters:
htmlEncodeOn - true to html encode the upload/download of Clob, else false

isAcceptAllSslCertificates

public boolean isAcceptAllSslCertificates()
Says if client sides allows HTTPS call with all SSL Certificates, including "invalid" or self-signed Certificates.

Returns:
true if client sides allows HTTPS call with all SSL Certificates

setAcceptAllSslCertificates

public void setAcceptAllSslCertificates(boolean acceptAllSslCertificates)
Sets if client sides must allow HTTPS call with all SSL Certificates, including "invalid" or self-signed Certificates.

Parameters:
acceptAllSslCertificates - true if we want client client sides to allow HTTPS call with all SSL Certificates

getHttpClientParameters

public Map<String,Object> getHttpClientParameters()
Returns the HttpClient Parameters.

Returns:
the HttpClient Parameters

setHttpClientParameters

public void setHttpClientParameters(Map<String,Object> httpClientParameters)
Sets the HttpClient Parameters.

Parameters:
httpClientParameters - the HttpClient Parameters to set

setHttpClientParameter

public void setHttpClientParameter(String name,
                                   Object value)
Sets the value of this HttpClient Library parameter.

Parameters:
name - the parameter name
value - the parameter value
Throws:
IllegalArgumentException - if name is null

getHttpClientParameter

public Object getHttpClientParameter(String name)
Gets the value of this HttpClient Library parameter.

Parameters:
name - the parameter name *
Returns:
the parameter value
Throws:
IllegalArgumentException - if name is null

getHttpClientParameterNames

public Set<String> getHttpClientParameterNames()
Returns the new parameters key set.

Returns:
the new parameters key set.
See Also:
Map.keySet()

clearHttpClientParameters

public void clearHttpClientParameters()
Removes all parameters from this collection.


toString

public String toString()
Returns a clean representation of the HttpProtocolParameters instance.

Overrides:
toString in class Object
Returns:
a clean representation of the HttpProtocolParameters instance


Awake File - Easy file upload & download through HTTP for Android, Swing and JavaFX
Copyright © 2013 KawanSoft SAS