org.pentaho.platform.dataaccess.client
Class ConnectionServiceClient

java.lang.Object
  extended by org.pentaho.platform.dataaccess.client.ConnectionServiceClient
All Implemented Interfaces:
org.apache.axis2.engine.ObjectSupplier, IConnectionService

public class ConnectionServiceClient
extends Object
implements IConnectionService, org.apache.axis2.engine.ObjectSupplier

Provides a simple API for working with the connections web service. This class implements IConnectionService IConnectionService Example code for using this class: ConnectionServiceClient serviceClient = new ConnectionServiceClient(); serviceClient.setHost("http://localhost:8080/pentaho"); serviceClient.setUserId("joe"); serviceClient.setPassword("password"); List connections = serviceClient.getConnections();

Author:
jamesdixon

Constructor Summary
ConnectionServiceClient()
           
 
Method Summary
 boolean addConnection(IConnection connection)
          Adds a connection to the server's configuration.
 DatabaseConnection convertFromConnection(IConnection connection)
           
 IConnection convertToConnection(IDatabaseConnection arg0)
           
 boolean deleteConnection(IConnection connection)
          Deletes a connection from the server's configuration.
 boolean deleteConnection(String connectionName)
          Deletes a connection from the server's configuration.
 DatabaseConnection deserializeDatabaseConnection(org.dom4j.Element rootNode)
           
 IConnection getConnectionByName(String connectionName)
          Returns a specified connection.
 List<IConnection> getConnections()
          Returns a list of connections known to the server.
 Object getObject(Class clazz)
          Returns an object for the specified class.
 org.dom4j.Document serializeDatabaseConnection(DatabaseConnection databaseConnection)
           
 void setHost(String host)
          Sets the host server, port, and context.
 void setPassword(String password)
          Sets the password to use to connect to the server
 void setUserId(String userId)
          Sets the user id to use to connect to the server
 boolean testConnection(IConnection connection)
          Tests a provided connection on the server.
 boolean updateConnection(IConnection connection)
           
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

ConnectionServiceClient

public ConnectionServiceClient()
Method Detail

addConnection

public boolean addConnection(IConnection connection)
                      throws ConnectionServiceException
Adds a connection to the server's configuration. Returns true if the attempt was successful. setHost(), setUserId() and setPassword() must be called before this method is called.

Specified by:
addConnection in interface IConnectionService
Parameters:
connection - The connection to be added
Returns:
True if the addition was successful
Throws:
ConnectionServiceException

convertFromConnection

public DatabaseConnection convertFromConnection(IConnection connection)
                                         throws ConnectionServiceException
Specified by:
convertFromConnection in interface IConnectionService
Throws:
ConnectionServiceException

serializeDatabaseConnection

public org.dom4j.Document serializeDatabaseConnection(DatabaseConnection databaseConnection)

deserializeDatabaseConnection

public DatabaseConnection deserializeDatabaseConnection(org.dom4j.Element rootNode)
                                                 throws javax.xml.stream.XMLStreamException,
                                                        org.apache.axis2.AxisFault
Throws:
javax.xml.stream.XMLStreamException
org.apache.axis2.AxisFault

convertToConnection

public IConnection convertToConnection(IDatabaseConnection arg0)
                                throws ConnectionServiceException
Specified by:
convertToConnection in interface IConnectionService
Throws:
ConnectionServiceException

deleteConnection

public boolean deleteConnection(IConnection connection)
                         throws ConnectionServiceException
Deletes a connection from the server's configuration. Returns true if the attempt was successful. setHost(), setUserId() and setPassword() must be called before this method is called.

Specified by:
deleteConnection in interface IConnectionService
Parameters:
connection - The connection to be deleted
Returns:
True if the deletion was successful
Throws:
ConnectionServiceException

deleteConnection

public boolean deleteConnection(String connectionName)
                         throws ConnectionServiceException
Deletes a connection from the server's configuration. Returns true if the attempt was successful. setHost(), setUserId() and setPassword() must be called before this method is called.

Specified by:
deleteConnection in interface IConnectionService
Parameters:
connectionName - The name of the connection to be deleted
Returns:
True if the deletion was successful
Throws:
ConnectionServiceException

getConnectionByName

public IConnection getConnectionByName(String connectionName)
                                throws ConnectionServiceException
Returns a specified connection. Returns null is the connection is not defined in the server's configuration. setHost(), setUserId() and setPassword() must be called before this method is called.

Specified by:
getConnectionByName in interface IConnectionService
Parameters:
connectionName - The name of the connection to be returned
Returns:
The connection requested
Throws:
ConnectionServiceException

getConnections

public List<IConnection> getConnections()
                                 throws ConnectionServiceException
Returns a list of connections known to the server. Each one is an IConnection object. Returns an empty list if no connections are defined. setHost(), setUserId() and setPassword() must be called before this method is called.

Specified by:
getConnections in interface IConnectionService
Returns:
List of the connections
Throws:
ConnectionServiceException

testConnection

public boolean testConnection(IConnection connection)
                       throws ConnectionServiceException
Tests a provided connection on the server. This does not store the connection on the server, just validates that the connection works in the server's environment.

Specified by:
testConnection in interface IConnectionService
Parameters:
connection - The connection to be tested
Throws:
ConnectionServiceException

updateConnection

public boolean updateConnection(IConnection connection)
                         throws ConnectionServiceException
Specified by:
updateConnection in interface IConnectionService
Throws:
ConnectionServiceException

setHost

public void setHost(String host)
Sets the host server, port, and context. For example http://server:port/pentaho

Parameters:
host - The host address and context

setUserId

public void setUserId(String userId)
Sets the user id to use to connect to the server

Parameters:
userId -

setPassword

public void setPassword(String password)
Sets the password to use to connect to the server

Parameters:
userId -

getObject

public Object getObject(Class clazz)
                 throws org.apache.axis2.AxisFault
Returns an object for the specified class. This is in the ObjectSupplier interface used by the BeanUtil deserialize methods.

Specified by:
getObject in interface org.apache.axis2.engine.ObjectSupplier
Throws:
org.apache.axis2.AxisFault