Ontimize Web Services 1.003EN

com.ontimize.webservice.server
Class OntimizeWebServiceImpl

java.lang.Object
  extended by com.ontimize.webservice.server.OntimizeWebServiceImpl

public class OntimizeWebServiceImpl
extends java.lang.Object

Implements the operations that can be performed in an Ontimize Web Service, such as, standard initSession, query, insert, update and delete, and also a generic method (called execute) which allow developers to run whatever remote method.


Field Summary
static boolean DEBUG
           
protected  com.ontimize.locator.SecureEntityReferenceLocator locator
           
protected  java.lang.String remoteLocatorRegistryName
           
protected  java.lang.String webServicehost
           
protected  int webServicePort
           
 
Constructor Summary
OntimizeWebServiceImpl()
           
 
Method Summary
protected static boolean belongToARemoteInterface(java.lang.String methodName, java.lang.Class<?> c, java.lang.Class[] parameterType)
          Checks if the remote method belongs to a remote interface.
protected  com.ontimize.db.EntityResult createEmptyWrongEntityResult()
          Creates a new entity result and set its code to indicated that the operation has been wrong.
 com.ontimize.webservice.server.OWSEntityResult delete(java.util.List<com.ontimize.webservice.server.OWSDoubleData> deleteKeys, int sessionId, java.lang.String entityName, java.lang.String userName)
          This method performs the standard Ontimize delete.
 java.lang.Integer endSession(int sessionId, int sleepingMiliseconds)
          method that ends the Ontimize session for the indicated sessionId.
 com.ontimize.webservice.server.OWSEntityResult execute(java.lang.String interfaceName, java.lang.String methodName, java.util.List<com.ontimize.webservice.server.OWSComplexData> parameters, int sessionId, java.lang.String entityName, java.lang.String userName)
          This method has been developed to allow programmers to execute whatever method (apart from the standard query, insert, update and delete).
protected  java.lang.Object getObject(java.lang.String host, int port, java.lang.String name)
          Get the unique rmi object indicated by the parameters host-port-name.
protected  java.util.Properties getPropertiesFile()
          This method get the client configuration properties file named webservice.properties.
 java.lang.Integer initSession(java.lang.String userLogin, java.lang.String userPassword, int sessionId)
          This method performs the init session of the client through the web service.
 com.ontimize.webservice.server.OWSEntityResult insert(java.util.List<com.ontimize.webservice.server.OWSDoubleData> insertValues, int sessionId, java.lang.String entityName, java.lang.String userName)
          This method performs the standard Ontimize insert.
protected static boolean interfaceExtendsInterface(java.lang.Class interfaceClass, java.lang.String interfaceName)
          Checks if the indicated interface class extends interfaceName.
protected  boolean isARemoteMethod(java.lang.reflect.Method method, java.lang.String methodName, java.lang.Class<?> c, java.lang.Class[] parameterType)
          Return true if the indicated methods is a remote method and which also belong to a remote (or extended remote) interface.
 com.ontimize.webservice.server.OWSEntityResult query(java.util.List<com.ontimize.webservice.server.OWSDoubleData> keysValues, java.util.List<com.ontimize.webservice.server.OWSComplexData> av, int sessionId, java.lang.String entityName, java.lang.String userName)
          This method performs the standard Ontimize query.
protected  void readProperties()
          Read the configuration properties file called webservice.properties to fill the neccesary parameters to be able to init session.
protected static boolean throwsRemoteExceptions(java.lang.reflect.Method method)
          Checks if the method throw (remote) exceptions.
 com.ontimize.webservice.server.OWSEntityResult update(java.util.List<com.ontimize.webservice.server.OWSDoubleData> attributesValues, java.util.List<com.ontimize.webservice.server.OWSDoubleData> keysValues, int sessionId, java.lang.String entityName, java.lang.String userName)
          This method performs the standard Ontimize update.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

DEBUG

public static boolean DEBUG

locator

protected com.ontimize.locator.SecureEntityReferenceLocator locator

webServicePort

protected int webServicePort

webServicehost

protected java.lang.String webServicehost

remoteLocatorRegistryName

protected java.lang.String remoteLocatorRegistryName
Constructor Detail

OntimizeWebServiceImpl

public OntimizeWebServiceImpl()
Method Detail

initSession

public java.lang.Integer initSession(java.lang.String userLogin,
                                     java.lang.String userPassword,
                                     int sessionId)
This method performs the init session of the client through the web service.

Parameters:
WebServicehost - the host in which the web service is running
webServicePort - the port in which the web service is running
remoteLocatorRegistry - Name in registry the Remote Locator object will have, that is, that indicates the process name
userLogin - The user's name (login)
userPassword - The user's password (login)
sessionId - The identifier of this user during the current session
Returns:

query

public com.ontimize.webservice.server.OWSEntityResult query(java.util.List<com.ontimize.webservice.server.OWSDoubleData> keysValues,
                                                            java.util.List<com.ontimize.webservice.server.OWSComplexData> av,
                                                            int sessionId,
                                                            java.lang.String entityName,
                                                            java.lang.String userName)
This method performs the standard Ontimize query.

Parameters:
keysValues - Hashtable of keys and values which indicates the query restrictions (that is, the 'where' information)
av - Vector of objects which contains the column names of the table/view which must be queried
sessionId - The identifier of this user during the current session
entityName - The entity name in which the query will be made
userName - The user's name (login)
Returns:
EntityResult which contains the query result

delete

public com.ontimize.webservice.server.OWSEntityResult delete(java.util.List<com.ontimize.webservice.server.OWSDoubleData> deleteKeys,
                                                             int sessionId,
                                                             java.lang.String entityName,
                                                             java.lang.String userName)
This method performs the standard Ontimize delete.

Parameters:
deleteKeys - Hashtable of keys and values which indicates the field that must be removed
sessionId - The identifier of this user during the current session
entityName - The entity name in which the delete will be made
userName - The user's name (login)
Returns:
EntityResult which contains the delete result

insert

public com.ontimize.webservice.server.OWSEntityResult insert(java.util.List<com.ontimize.webservice.server.OWSDoubleData> insertValues,
                                                             int sessionId,
                                                             java.lang.String entityName,
                                                             java.lang.String userName)
This method performs the standard Ontimize insert.

Parameters:
insertValues - Hashtable of keys and values which indicates the field that must be inserted and their values
sessionId - The identifier of this user during the current session
entityName - The entity name in which the insert will be made
userName - The user's name (login)
Returns:
EntityResult which contains the insert result

update

public com.ontimize.webservice.server.OWSEntityResult update(java.util.List<com.ontimize.webservice.server.OWSDoubleData> attributesValues,
                                                             java.util.List<com.ontimize.webservice.server.OWSDoubleData> keysValues,
                                                             int sessionId,
                                                             java.lang.String entityName,
                                                             java.lang.String userName)
This method performs the standard Ontimize update.

Parameters:
attributesValues - Hashtable of keys and values which contains the new information that will be setted
keysValues - Hashtable of keys and values which indicates the fields that must be updated
sessionId - The identifier of this user during the current session
entityName - The entity name in which the update will be made
userName - The user's name (login)
Returns:
EntityResult which contains the update result

execute

public com.ontimize.webservice.server.OWSEntityResult execute(java.lang.String interfaceName,
                                                              java.lang.String methodName,
                                                              java.util.List<com.ontimize.webservice.server.OWSComplexData> parameters,
                                                              int sessionId,
                                                              java.lang.String entityName,
                                                              java.lang.String userName)
This method has been developed to allow programmers to execute whatever method (apart from the standard query, insert, update and delete). To be able of executing whatever method, additional information must be included in the parameters to collect the whole necessary information.

Parameters:
entityName - The name of the entity in which this method performs the operation
interfaceName - The name of the remote interface that contains this remote execute method
methodName - The name of the remote method which will be executed by this generic "execute" method
parameters - A list of OWSComplexData (a vector) which contains to data per item. The first one is the kind of parameters that the execute method recives. The second one is the value that the method receives. There is one paar(Class, value) per parameter that the execute method receives
sessionId - The identifier of this user during the current session
userName - The user's name (login)
Returns:
EntityResult which contains the result of the current operation

endSession

public java.lang.Integer endSession(int sessionId,
                                    int sleepingMiliseconds)
method that ends the Ontimize session for the indicated sessionId. A possitive delayed time can be indicated to wait it before closing the session.

Parameters:
sessionId -
sleepingMiliseconds -
Returns:

readProperties

protected void readProperties()
Read the configuration properties file called webservice.properties to fill the neccesary parameters to be able to init session.


getPropertiesFile

protected java.util.Properties getPropertiesFile()
This method get the client configuration properties file named webservice.properties. In that web service port, web service host, and the remote locator registry name must be indicated to allow web service serve to connect to Ontimize server.

Returns:

getObject

protected java.lang.Object getObject(java.lang.String host,
                                     int port,
                                     java.lang.String name)
                              throws java.lang.Exception
Get the unique rmi object indicated by the parameters host-port-name.

Parameters:
host - machine in which the object is running
port - port in which this object can be located
name - the name of the object
Returns:
Throws:
java.lang.Exception

createEmptyWrongEntityResult

protected com.ontimize.db.EntityResult createEmptyWrongEntityResult()
Creates a new entity result and set its code to indicated that the operation has been wrong.

Returns:

isARemoteMethod

protected boolean isARemoteMethod(java.lang.reflect.Method method,
                                  java.lang.String methodName,
                                  java.lang.Class<?> c,
                                  java.lang.Class[] parameterType)
Return true if the indicated methods is a remote method and which also belong to a remote (or extended remote) interface.

Parameters:
method -
methodName -
c -
parameterType -
Returns:

throwsRemoteExceptions

protected static boolean throwsRemoteExceptions(java.lang.reflect.Method method)
Checks if the method throw (remote) exceptions. If one method does not throw a Exception or RemoteException => it is not to be a remote method.

Parameters:
method -
Returns:

belongToARemoteInterface

protected static boolean belongToARemoteInterface(java.lang.String methodName,
                                                  java.lang.Class<?> c,
                                                  java.lang.Class[] parameterType)
Checks if the remote method belongs to a remote interface.

Parameters:
methodName -
c -
parameterType -
Returns:

interfaceExtendsInterface

protected static boolean interfaceExtendsInterface(java.lang.Class interfaceClass,
                                                   java.lang.String interfaceName)
Checks if the indicated interface class extends interfaceName.

Parameters:
interfaceClass -
interfaceName -
Returns:

Ontimize Web Services