com.elixirtech.ers2.client
Class ERSClient

java.lang.Object
  extended by com.elixirtech.ers2.client.ERSClient

public class ERSClient
extends java.lang.Object

Elixir Repertoire Server Client provides a light weight connection to the Repertoire Server. It provides basic functionalities as listing file system, querying for report deployed on the server repository , querying dynamic parameters in the report, datasource file and generate reports. You also invoke return of data from data source or trigger data store to push data to a location. The triggering of data store requires an ensemble data store license for repertoire server.


Field Summary
static java.lang.String DEFAULT_CONTENT_TYPE
          Content Type for Posting to ensure non-ASCII characters are handled properly
static org.apache.log4j.Logger m_Log
           
static short MODE_NEW_CONNECTION
          Every request is a new connection to the server.
static short MODE_REUSE_CONNECTION
          Keep the current connection alive and submit request through the same connection.
static int PREFERRED_PORT
          Preferred server port.
static java.lang.String PREFERRED_TARGET
          Preferred target name.
static int PREFERRED_TIMEOUT
          Preferred timeout
 
Constructor Summary
ERSClient()
          Default Constructor.
ERSClient(java.lang.String host, int port, java.lang.String user, java.lang.String password)
          Constructor.Creates a new ERSClient with server host name/ IP address, user name and password.
ERSClient(java.lang.String host, int port, java.lang.String user, java.lang.String password, short mode, int timeout)
          Deprecated. Use the version without mode and timeout as they are now ignored
 
Method Summary
 void close()
           
 org.apache.commons.httpclient.HttpClient connect()
           
 IJobInfo generateData(java.lang.String dataName, java.io.OutputStream os, java.util.Properties props)
          Invoke a datasource to generate data.
 short getConnectionMode()
          Get ConnectionMode
 java.lang.String[] getFiles(java.lang.String fs)
          Get the files available in a filesystem.
 IFileSystem getFileSystem(java.lang.String fs)
          Get a Filesystem from the server
 java.lang.String[] getFileSystems()
          Get the filesystems available on the server.
 java.lang.String getHost()
          Get server host name.
 java.io.InputStream getInputStream(java.lang.String filename)
          Get the contents of a file from the server.
 java.lang.String[] getMIMETypes()
          Get the mime-types available on the server.
 Parameter[] getParameters(java.lang.String file)
          Query the parameters needed by a particular server object (report, datasource or trigger)
 java.lang.String getPassword()
          Get password.
 int getPort()
          Get port set.
 java.lang.String[] getReports(java.lang.String fs)
          Get the reports available in a filesystem.
 java.lang.String getServerURL()
           
 int getTimeout()
          Get timeout.
 java.lang.String getUserName()
          Get user name.
 boolean isAutoEscape()
          Deprecated. - the protocol now ensures correct transmission of all characters
 boolean isConnected()
          Deprecated. - connection status is now controlled internally
 boolean isSecure()
          Get the current value of the Secure mode.
 IJobInfo renderDocX(java.lang.String report, java.lang.String format, java.io.OutputStream osm, java.util.Properties properties)
          Send a request to render a docx report as a different back to the client.
 IJobInfo renderReport(java.lang.String report, java.lang.String mimeType, java.io.OutputStream osm, java.util.Properties properties)
          Send a request to render a report back to the client.
 IJobInfo renderReport(java.lang.String report, java.lang.String mimeType, java.io.OutputStream os, java.util.Properties properties, java.lang.String target)
          Deprecated. If requesting a report to be returned, use the renderReport with no target. Else if sending a report to a target, use the renderReport with no output stream. This overloaded version handles both cases, but is more confusing, hence deprecated.
 IJobInfo renderReport(java.lang.String report, java.lang.String mimeType, java.util.Properties properties, java.lang.String target)
          Send a request to render a report.
 IJobInfo renderReport(java.lang.String report, java.lang.String mimeType, java.util.Properties properties, java.lang.String target, java.util.Properties targetProperties)
          Send a request to render a report.
 void setAutoEscape(boolean b)
          Deprecated. - the protocol now ensures correct transmission of all characters
 void setConnectionMode(short mode)
          Set Connection Mode.
 void setHost(java.lang.String host)
          Set server host name.
 void setPassword(java.lang.String password)
          Set password.
 void setPort(int port)
          Set port.
 void setSecure(boolean secure)
          Set Secure mode.
 void setSecure(java.io.File keystore, java.lang.String keystorePassword, java.io.File truststore, java.lang.String truststorePassword)
          Set Secure mode.
 void setTimeout(int timeout)
          With this option set to a non-zero timeout, a read() call on the InputStream associated with this Socket will block for only this amount of time (in milliseconds).
 void setUserName(java.lang.String userName)
          Set user name.
 boolean shutdown()
          Shutdown the server - only available with admin rights
 IJobInfo triggerJob(java.lang.String jobName, java.util.Properties props)
          Triggers a job on the server.
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

DEFAULT_CONTENT_TYPE

public static final java.lang.String DEFAULT_CONTENT_TYPE
Content Type for Posting to ensure non-ASCII characters are handled properly

See Also:
Constant Field Values

MODE_NEW_CONNECTION

public static final short MODE_NEW_CONNECTION
Every request is a new connection to the server.

See Also:
Constant Field Values

MODE_REUSE_CONNECTION

public static final short MODE_REUSE_CONNECTION
Keep the current connection alive and submit request through the same connection.

See Also:
Constant Field Values

PREFERRED_PORT

public static final int PREFERRED_PORT
Preferred server port.

See Also:
Constant Field Values

PREFERRED_TIMEOUT

public static final int PREFERRED_TIMEOUT
Preferred timeout

See Also:
Constant Field Values

PREFERRED_TARGET

public static final java.lang.String PREFERRED_TARGET
Preferred target name.

See Also:
Constant Field Values

m_Log

public static final org.apache.log4j.Logger m_Log
Constructor Detail

ERSClient

public ERSClient()
Default Constructor. Creates a new ERSClient.


ERSClient

public ERSClient(java.lang.String host,
                 int port,
                 java.lang.String user,
                 java.lang.String password)
Constructor.Creates a new ERSClient with server host name/ IP address, user name and password.

Parameters:
host - The server name
port - The server port
user - The User name
password - The User password

ERSClient

public ERSClient(java.lang.String host,
                 int port,
                 java.lang.String user,
                 java.lang.String password,
                 short mode,
                 int timeout)
Deprecated. Use the version without mode and timeout as they are now ignored

Constructor.Creates a new ERSClient with server host name/ IP address, user name and password.

Parameters:
host - The server name
port - The server port
user - The User name
password - The User password
mode - Not used now the underlying transport is HTTP
timeout - Not used now the underlying transport is HTTP
Method Detail

setAutoEscape

public void setAutoEscape(boolean b)
Deprecated. - the protocol now ensures correct transmission of all characters

Set the auto-escape flag, which controls whether slashes, newlines and quotes in parameters are automatically escaped into \\, \n and \" etc. By default this value is false (for backwards compatibility), you should set it to true if you don't handle your own escaping.

Parameters:
b - The auto-escape flag

isAutoEscape

public boolean isAutoEscape()
Deprecated. - the protocol now ensures correct transmission of all characters

Gets the auto-escape flag.

Returns:
The current value of the auto-escape flag (default false)

shutdown

public boolean shutdown()
                 throws com.elixirtech.net.NetException
Shutdown the server - only available with admin rights

Returns:
true if the shutdown request was accepted
Throws:
com.elixirtech.net.NetException

getParameters

public Parameter[] getParameters(java.lang.String file)
                          throws com.elixirtech.net.NetException
Query the parameters needed by a particular server object (report, datasource or trigger)

Returns:
an array of parameters.
Throws:
com.elixirtech.net.NetException

getFileSystem

public IFileSystem getFileSystem(java.lang.String fs)
                          throws com.elixirtech.net.NetException
Get a Filesystem from the server

Returns:
An interface to a server-side filesystem
Throws:
com.elixirtech.net.NetException

getFileSystems

public java.lang.String[] getFileSystems()
                                  throws com.elixirtech.net.NetException
Get the filesystems available on the server.

Returns:
list of filesystems available.
Throws:
com.elixirtech.net.NetException

getFiles

public java.lang.String[] getFiles(java.lang.String fs)
                            throws com.elixirtech.net.NetException
Get the files available in a filesystem.

Parameters:
fs - The filesystem.
Returns:
list of files available
Throws:
com.elixirtech.net.NetException

getInputStream

public java.io.InputStream getInputStream(java.lang.String filename)
                                   throws com.elixirtech.net.NetException
Get the contents of a file from the server.

Parameters:
filename - The filename to read from
Returns:
an InputStream from which the data can be read
Throws:
com.elixirtech.net.NetException

getReports

public java.lang.String[] getReports(java.lang.String fs)
                              throws com.elixirtech.net.NetException
Get the reports available in a filesystem.

Parameters:
fs - The filesystem
Returns:
list of reports available
Throws:
com.elixirtech.net.NetException

getMIMETypes

public java.lang.String[] getMIMETypes()
                                throws com.elixirtech.net.NetException
Get the mime-types available on the server.

Returns:
list of mime-types available.
Throws:
com.elixirtech.net.NetException

renderDocX

public IJobInfo renderDocX(java.lang.String report,
                           java.lang.String format,
                           java.io.OutputStream osm,
                           java.util.Properties properties)
                    throws com.elixirtech.net.NetException
Send a request to render a docx report as a different back to the client.

Parameters:
report - The docx report name
format - The format as docx, pdf, xps or docx_pdf_zip.
osm - Output stream
properties - properties to pass to report - may be null
Returns:
JobInfo, Jobinfo provides information on the job.
Throws:
com.elixirtech.net.NetException

renderReport

public IJobInfo renderReport(java.lang.String report,
                             java.lang.String mimeType,
                             java.io.OutputStream osm,
                             java.util.Properties properties)
                      throws com.elixirtech.net.NetException
Send a request to render a report back to the client.

Parameters:
report - The report name
mimeType - The mime type.
osm - Output stream
properties - properties to pass to report - may be null
Returns:
JobInfo, Jobinfo provides information on the job.
Throws:
com.elixirtech.net.NetException

renderReport

public IJobInfo renderReport(java.lang.String report,
                             java.lang.String mimeType,
                             java.util.Properties properties,
                             java.lang.String target)
                      throws com.elixirtech.net.NetException
Send a request to render a report.

Parameters:
report - The report name
mimeType - The mime type.
properties - properties to pass to report - may be null
target - the name of the report destination
Returns:
JobInfo, Jobinfo provides information on the job.
Throws:
com.elixirtech.net.NetException

renderReport

public IJobInfo renderReport(java.lang.String report,
                             java.lang.String mimeType,
                             java.util.Properties properties,
                             java.lang.String target,
                             java.util.Properties targetProperties)
                      throws com.elixirtech.net.NetException
Send a request to render a report.

Parameters:
report - The report name
mimeType - The mime type.
properties - properties to pass to report - may be null.
target - the name of the report destination
targetProperties - Target properties - may be null.
Returns:
JobInfo JobInfo provide information on the job.
Throws:
com.elixirtech.net.NetException

renderReport

public IJobInfo renderReport(java.lang.String report,
                             java.lang.String mimeType,
                             java.io.OutputStream os,
                             java.util.Properties properties,
                             java.lang.String target)
                      throws com.elixirtech.net.NetException
Deprecated. If requesting a report to be returned, use the renderReport with no target. Else if sending a report to a target, use the renderReport with no output stream. This overloaded version handles both cases, but is more confusing, hence deprecated.

Send a request to render a report.

Parameters:
report - The report name
mimeType - The mime type.
properties - properties to pass to report - may be null.
os - The output stream used if target is a ReplyTarget (eg. "me")
target - the name of the report destination
Returns:
JobInfo JobInfo provide information on the job.
Throws:
com.elixirtech.net.NetException

triggerJob

public IJobInfo triggerJob(java.lang.String jobName,
                           java.util.Properties props)
                    throws com.elixirtech.net.NetException
Triggers a job on the server. The connection is opened, if necessary. The connection will be closed at the end of the operation unless it in reuse connection mode.

Parameters:
jobName - The job name
props - Any parameters required by the job - may be null
Returns:
JobInfo Information on the job
Throws:
com.elixirtech.net.NetException

generateData

public IJobInfo generateData(java.lang.String dataName,
                             java.io.OutputStream os,
                             java.util.Properties props)
                      throws com.elixirtech.net.NetException
Invoke a datasource to generate data. By default, the result will be streamed back to the client. However, if a datastore is named in the properties (by putting datastore=somename in the properties), the datastore will be triggered and will write to it's configured location. In this case, no result is sent back to the client. Datastore invocation is a feature of Ensemble, (The Ensemble license is required to use it).

Parameters:
dataName - file The data source name
os - Output stream return data. May be null only if writing to a DataStore
props - properties of the data file. May be null. To trigger a DataStore to generate on the server. Add a property "datastore" with the value being the name of the DataStore.
Returns:
JobInfo, Jobinfo provides information on the job.
Throws:
com.elixirtech.net.NetException

close

public void close()

setHost

public void setHost(java.lang.String host)
Set server host name.

Parameters:
host - The server name

getHost

public java.lang.String getHost()
Get server host name.

Returns:
Server name or IP

setPort

public void setPort(int port)
Set port.

Parameters:
port - The server port

getPort

public int getPort()
Get port set.

Returns:
port

getUserName

public java.lang.String getUserName()
Get user name.

Returns:
user name.

setUserName

public void setUserName(java.lang.String userName)
Set user name.

Parameters:
userName - The user

getPassword

public java.lang.String getPassword()
Get password.

Returns:
password

setPassword

public void setPassword(java.lang.String password)
Set password.

Parameters:
password - The password

setSecure

public void setSecure(boolean secure)
Set Secure mode. This value must be compatible with the server setting. If the server does not define a secure connection, then you can't use one here. If you need client authentication support then you must not use this call, instead use setSecure(keystore,keystorePass,truststore,truststorePass);

Parameters:
secure - The secure mode

setSecure

public void setSecure(java.io.File keystore,
                      java.lang.String keystorePassword,
                      java.io.File truststore,
                      java.lang.String truststorePassword)
               throws java.io.IOException
Set Secure mode. This value must be compatible with the server setting. If the server does not define a secure connection, then you can't use one here. If you need client authentication support then use this call, otherwise use setSecure(true); Important the Apache Commons HttpClient code that this mechanism depends on requires that the client keystore use the same password for keys as the keystore itself. The server side doesn't have this limitation. The code used here is based on org.apache.commons.httpclient.contrib.ssl.AuthSSLProtocolSocketFactory.

Parameters:
keystore - The client keystore
keystorePassword - The client keystore password
truststore - The client truststore
truststorePassword - The client truststore password
Throws:
java.io.IOException

isSecure

public boolean isSecure()
Get the current value of the Secure mode.

Returns:
The secure mode

getTimeout

public int getTimeout()
Get timeout.

Returns:
timeout in milliseconds.

getConnectionMode

public short getConnectionMode()
Get ConnectionMode

Returns:
Connection Mode

setConnectionMode

public void setConnectionMode(short mode)
Set Connection Mode. If new Connection is set

Parameters:
mode - Connection mode.

isConnected

public boolean isConnected()
Deprecated. - connection status is now controlled internally

Check if the client is still connected.

Returns:
Connection connection status

setTimeout

public void setTimeout(int timeout)
With this option set to a non-zero timeout, a read() call on the InputStream associated with this Socket will block for only this amount of time (in milliseconds). If the timeout expires, a java.net.SocketTimeoutException is raised, though the Socket is still valid. The timeout must be > 0. A timeout of zero is interpreted as an infinite timeout.

Parameters:
timeout - in milliseonds

connect

public org.apache.commons.httpclient.HttpClient connect()
                                                 throws java.io.IOException
Throws:
java.io.IOException

getServerURL

public java.lang.String getServerURL()