com.bigllc.retsiq.simpleclient
Class RETSConnection

java.lang.Object
  extended by com.bigllc.retsiq.simpleclient.RETSConnection
All Implemented Interfaces:
java.io.Closeable

public class RETSConnection
extends java.lang.Object
implements java.io.Closeable

RETS server connection. This class is used to configure the server details and create authenticated RETS user sessions.

Author:
Marc G. Smith

Nested Class Summary
static class RETSConnection.HttpMethodType
          HTTP method to use for requests.
 
Constructor Summary
RETSConnection(java.lang.String url)
          Construct a connection factory to RETS server.
RETSConnection(java.lang.String url, java.lang.String userAgent)
          Construct a connection factory to RETS server with a custom user agent string.
RETSConnection(java.lang.String url, java.lang.String userAgent, java.lang.String userAgentPassword)
          Construct a connection factory to RETS server that requires user agent authentication.
 
Method Summary
 void close()
           
 boolean getAutoDigest()
          Is the client set for auto digest.
 boolean getAutoLogin()
          Is the client set for auto login.
 RETSConnection.HttpMethodType getDefaultHttpMethodType()
          Get the default http method to use for RETS transactions.
 com.bigllc.retsiq.api.RETSConstants.Version getDefaultRetsVersion()
          Get the RETS version that the client uses on initiation.
 boolean getFixCompactSearchXmlEncoding()
          Get whether the input stream for compact search is being fixed for XML encoding issues.
 RETSUserSession getSession(java.lang.String username, java.lang.String password)
          Authenticate a user and get a session for them.
 RETSUserSession getSession(java.lang.String username, java.lang.String password, java.lang.String host, java.lang.String domain)
          Authenticate a user and get a session for them.
 boolean getUseCompression()
          Check if the client is configured to request compressed responses.
 boolean getUseMultiThreadedConnectionManager()
          Check if using the multi-threaded connection manager.
 boolean getUseSingleCookieHeader()
          Get whether cookies should will be put in a single response header.
 void setAutoDigest(boolean doAutoDigest)
          Set whether auto digest should be performed.
 void setAutoLogin(boolean doAutoLogin)
          Set whether auto login should be performed.
 void setDefaultHttpMethodType(RETSConnection.HttpMethodType methodType)
          Set the default http method to use for RETS transactions.
 void setDefaultRetsVersion(com.bigllc.retsiq.api.RETSConstants.Version version)
          Set the RETS version that the client should use on initiation.
 void setFixCompactSearchXmlEncoding(boolean fix)
          Set whether the input stream for compact search should be fixed for XML encoding that cause XML parsing errors.
 void setSocketTimeout(int socketTimeout)
          Set the socket timeout in milliseconds which is the timeout for waiting for data.
 void setUseCompression(boolean useCompression)
          Configure the client to request compressed responses.
 void setUseMultiThreadedConnectionManager(boolean useMultiThreadedConnectionManager)
          Use the multi-threaded connection manager.
 void setUseSingleCookieHeader(boolean useSingleHeader)
          Define whether cookies should be put in a single response header.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

RETSConnection

public RETSConnection(java.lang.String url)
               throws java.net.MalformedURLException
Construct a connection factory to RETS server.

Parameters:
url - the full login url to the target RETS server
Throws:
java.net.MalformedURLException

RETSConnection

public RETSConnection(java.lang.String url,
                      java.lang.String userAgent)
               throws java.net.MalformedURLException
Construct a connection factory to RETS server with a custom user agent string.

Parameters:
url - the full login url to the targer RETS server
userAgent - the user agent string to be sent with request in the format USERAGENT/VERSION.
Throws:
java.net.MalformedURLException

RETSConnection

public RETSConnection(java.lang.String url,
                      java.lang.String userAgent,
                      java.lang.String userAgentPassword)
               throws java.net.MalformedURLException
Construct a connection factory to RETS server that requires user agent authentication.

Parameters:
url - the full login url to the targer RETS server
userAgent - the user agent string to be sent with request in the format USERAGENT/VERSION.
userAgentPassword - the user agent password.
Throws:
java.net.MalformedURLException
Method Detail

getAutoLogin

public boolean getAutoLogin()
Is the client set for auto login.

Returns:
true is auto login is switched on, false otherwise.

setAutoLogin

public void setAutoLogin(boolean doAutoLogin)
Set whether auto login should be performed. If a user session has expired and an authentication request is made the client will attempt to log the user in seemlessly.

Parameters:
doAutoLogin - should auto login be performed

getAutoDigest

public boolean getAutoDigest()
Is the client set for auto digest.

Returns:
true is auto digest is switched on, false otherwise.

setAutoDigest

public void setAutoDigest(boolean doAutoDigest)
Set whether auto digest should be performed.

Parameters:
doAutoDigest - should auto digest be performed

getDefaultRetsVersion

public com.bigllc.retsiq.api.RETSConstants.Version getDefaultRetsVersion()
Get the RETS version that the client uses on initiation.

Returns:
the RETS version

setDefaultRetsVersion

public void setDefaultRetsVersion(com.bigllc.retsiq.api.RETSConstants.Version version)
Set the RETS version that the client should use on initiation. The client will revert to the version the server responds with.

Parameters:
version - the RETS version

getUseCompression

public boolean getUseCompression()
Check if the client is configured to request compressed responses. If true then requests will ask the server to compress the responses with gzip. This may provide big performance gains.

Returns:
true if requests send accept gzip encoding header

getUseMultiThreadedConnectionManager

public boolean getUseMultiThreadedConnectionManager()
Check if using the multi-threaded connection manager. All connection managers are thread safe but the multi-thread connection manager will re-use connections and use persistent connections.

Returns:
true if the multi-threaded connection manager is in use, false otherwise.

setUseMultiThreadedConnectionManager

public void setUseMultiThreadedConnectionManager(boolean useMultiThreadedConnectionManager)
Use the multi-threaded connection manager. All connection managers are thread safe but the multi-thread connection manager will re-use connections and use persistent connections.

Parameters:
useMultiThreadedConnectionManager - true to use the multi-threaded connection manager.

setUseSingleCookieHeader

public void setUseSingleCookieHeader(boolean useSingleHeader)
Define whether cookies should be put in a single response header. This may be required for some servers that only process cookies that are in a single header. At the moment some versions of Variman behave in this manner. Typical behaviour is getting a 401 http response on a transaction after a successful login.

Parameters:
useSingleHeader - true to use single header.

getUseSingleCookieHeader

public boolean getUseSingleCookieHeader()
Get whether cookies should will be put in a single response header.

Parameters:
useSingleHeader - true to use single header.

setUseCompression

public void setUseCompression(boolean useCompression)
Configure the client to request compressed responses. If true then requests will ask the server to compress the responses with gzip. This may provide big performance gains.

Parameters:
useCompression - true if requests should send accept gzip encoding header

setFixCompactSearchXmlEncoding

public void setFixCompactSearchXmlEncoding(boolean fix)
Set whether the input stream for compact search should be fixed for XML encoding that cause XML parsing errors. If the target server has unescaped entities or unicode characters that are causing parsing exceptions then set this to true so that they are fixed before they hit the parser.

Parameters:
fix - true to turn on encoding fix

getFixCompactSearchXmlEncoding

public boolean getFixCompactSearchXmlEncoding()
Get whether the input stream for compact search is being fixed for XML encoding issues.

Returns:
true if encoding fix is enabled

setSocketTimeout

public void setSocketTimeout(int socketTimeout)
Set the socket timeout in milliseconds which is the timeout for waiting for data. A timeout value of zero is interpreted as an infinite timeout.

Parameters:
socketTimeout - the timeout in milliseconds.

getDefaultHttpMethodType

public RETSConnection.HttpMethodType getDefaultHttpMethodType()
Get the default http method to use for RETS transactions. This must be set before creating a session. The default is POST.

Returns:
the method type.

setDefaultHttpMethodType

public void setDefaultHttpMethodType(RETSConnection.HttpMethodType methodType)
Set the default http method to use for RETS transactions. The default is POST.

Parameters:
methodType - the method type.

getSession

public RETSUserSession getSession(java.lang.String username,
                                  java.lang.String password)
                           throws RETSClientException
Authenticate a user and get a session for them.

Parameters:
username - the username
password - the password
Returns:
the user session if login is successful
Throws:
RETSClientException

getSession

public RETSUserSession getSession(java.lang.String username,
                                  java.lang.String password,
                                  java.lang.String host,
                                  java.lang.String domain)
                           throws RETSClientException
Authenticate a user and get a session for them. The host and domain may be required for NTLM authentication.

Parameters:
username - the username
password - the password
host - the host
domain - the domain
Returns:
the user session if login is successful
Throws:
RETSClientException

close

public void close()
           throws java.io.IOException
Specified by:
close in interface java.io.Closeable
Throws:
java.io.IOException