SAP CC 1.0
API 4.2 (Core)

com.highdeal.cnd.message
Class StatelessServiceClient

java.lang.Object
  extended by com.highdeal.cnd.message.StatelessServiceClient

public class StatelessServiceClient
extends java.lang.Object

This class allows a user to send some stateless rating and pre-rating event to SAP Convergent Charging 1.0 Rating Instances by using an efficient message protocol based on TCP/IP.
When a timeout is associated to a given message client, it must be performed during this limited time. If this limited time is exceeded, the operation is rolled back but client timeout does not guarantee that related operations successfully ended (see Technical Reference Guide).


Field Summary
static int POST_RATE_CANCELLATION
           
static int POST_RATE_CONFIRMATION
           
 
Constructor Summary
StatelessServiceClient()
          Creates a non-initialized stateless service client.
StatelessServiceClient(java.lang.String hostName, int port)
          Creates a stateless service client and connect it to a server.
StatelessServiceClient(java.lang.String hostName, int port, FoundLostRatingListener ratingListener)
          Creates a stateless service client and connect it to a server.
StatelessServiceClient(java.lang.String hostName, int port, FoundLostRatingListener ratingListener, int timeout)
          Creates a stateless service client and connect it to a server.
StatelessServiceClient(java.lang.String hostName, int port, int timeout)
          Creates a stateless service client and connect it to a server.
StatelessServiceClient(java.lang.String hostName, int port, java.lang.String bindAddress, FoundLostRatingListener ratingListener, int timeout)
          Creates a stateless service client and connect it to a server.
 
Method Summary
protected  boolean checkDB()
          This method is for internal use only.
 void close()
          Closes the connection.
 void connect(InstanceMap imap, java.lang.String bindAddress, FoundLostRatingListener ratingListener, int timeout, ServiceClientTuning config)
           
 void connect(java.lang.String hostName, int port)
          Connect this stateless service client using the round robin with the server.
 void connect(java.lang.String hostName, int port, FoundLostRatingListener ratingListener)
          Connect this stateless service client using the round robin with the server.
 void connect(java.lang.String hostName, int port, int timeout)
          Connect this stateless service client using the round robin with the server.
 void connect(java.lang.String hostName, int port, java.lang.String bindAddress, FoundLostRatingListener ratingListener, int timeout)
          Connect this stateless service client using the round robin with the server.
 void connect(java.lang.String hostName, int port, java.lang.String bindAddress, FoundLostRatingListener ratingListener, int timeout, ServiceClientTuning config)
          Connect this stateless service client using the round robin with the server.
protected  int currentQueueSize()
          This method is for internal use only.
 BootMode getBootMode()
          Returns which API is used to retrieve from the remote instances, the Instance Map needed for the connection.
 java.lang.String getClusterName()
          Gets the name of the cluster.
 FoundLostRatingListener getFoundLostRatingListener()
          Returns the FoundLostRatingListener previously set.
 int getTimeout()
          Returns the timeout in milliseconds for each request (or -1 to wait indefinitively)
 boolean isConnected()
          Gets the connected status.
 void setBootMode(BootMode mode)
          Defines which API will be used to retrieve from the remote instances, the Instance Map needed for the connection.
 void setClusterName(java.lang.String clusterName)
          Sets cluster name.
 void setFoundLostRatingListener(FoundLostRatingListener ratingListener)
          Sets the FoundLostRatingListener that will be notified each time a Rating Instance will be found or lost.
 StatelessPostRateResult statelessPostRate(long reservationUID, StatelessPreRatingContext preRatingContext, int resolution, boolean withDetails, ChargeableItem newCi)
          This method is dedicated to the stateless post-rating.
 StatelessPostRateResult statelessPostRate(long reservationUID, StatelessPreRatingContext preRatingContext, int resolution, java.lang.String[] retainedDetails, ChargeableItem newCi)
          Similar to statelessPostRate(long, StatelessPreRatingContext, int, boolean, ChargeableItem), but with finest selection of resulting transaction details.
 StatelessPreRateResult statelessPreRate(StatelessRatingEvent ratingEvent, java.lang.String chargeCode, StatelessPreRatingContext preRatingContext, java.util.Date ratingDate, long reservationUID, long postrateDeadline, boolean withDetails, boolean checkDates)
          This method is dedicated to the stateless pre-rating.
 StatelessPreRateResult statelessPreRate(StatelessRatingEvent ratingEvent, java.lang.String chargeCode, StatelessPreRatingContext preRatingContext, java.util.Date ratingDate, long reservationUID, long postrateDeadline, java.lang.String[] retainedDetails, boolean checkDates)
          Similar to statelessPreRate(StatelessRatingEvent, String, StatelessPreRatingContext, Date, long, long, boolean, boolean), but with finest selection of resulting transaction details.
 StatelessRateResult statelessRate(java.lang.String chargeCode, java.util.Date ratingDate, StatelessRatingEvent event, StatelessRatingContext context, boolean withDetails, boolean checkDates)
          This method is dedicated to the stateless rating.
 StatelessRateResult statelessRate(java.lang.String chargeCode, java.util.Date ratingDate, StatelessRatingEvent event, StatelessRatingContext context, java.lang.String[] retainedDetails, boolean checkDates)
          Similar to statelessRate(String, Date, StatelessRatingEvent, StatelessRatingContext, boolean, boolean), but with finest selection of resulting transaction details.
 java.lang.Object[] translate(java.lang.String tableCode, int operator, java.util.Date date, java.util.Date referenceDate, java.lang.String[] inValues)
          Translates some values by using a translation table.
 java.lang.Object[] translate(java.lang.String tableCode, int operator, java.util.Date date, java.lang.String[] inValues)
          Translates some values by using a translation table.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

POST_RATE_CONFIRMATION

public static final int POST_RATE_CONFIRMATION
See Also:
Constant Field Values

POST_RATE_CANCELLATION

public static final int POST_RATE_CANCELLATION
See Also:
Constant Field Values
Constructor Detail

StatelessServiceClient

public StatelessServiceClient()
                       throws java.io.IOException
Creates a non-initialized stateless service client.

One of the methods connect() must then be used to connect it to a server.

Throws:
java.io.IOException - if an error occurred reading the currency resources.

StatelessServiceClient

public StatelessServiceClient(java.lang.String hostName,
                              int port)
                       throws java.io.IOException
Creates a stateless service client and connect it to a server.

Parameters:
hostName - the host name of the server.
port - the port on which the server waits for request.
Throws:
java.io.IOException - if the client cannot connect to the server (if server is not running, for instance) or if an error occurred reading the currency resources.

StatelessServiceClient

public StatelessServiceClient(java.lang.String hostName,
                              int port,
                              int timeout)
                       throws java.io.IOException
Creates a stateless service client and connect it to a server.

Parameters:
hostName - the host name of the server.
port - the port on which the server waits for request.
timeout - the timeout for the client's requests.
Throws:
java.io.IOException - if the client cannot connect to the server (if server is not running, for instance) or if an error occurred reading the currency resources.

StatelessServiceClient

public StatelessServiceClient(java.lang.String hostName,
                              int port,
                              FoundLostRatingListener ratingListener)
                       throws java.io.IOException
Creates a stateless service client and connect it to a server.

Parameters:
hostName - the host name of the server.
port - the port on which the server waits for request.
ratingListener - the listener informed when rating is found or lost.
Throws:
java.io.IOException - if the client cannot connect to the server (if server is not running, for instance) or if an error occurred reading the currency resources.

StatelessServiceClient

public StatelessServiceClient(java.lang.String hostName,
                              int port,
                              FoundLostRatingListener ratingListener,
                              int timeout)
                       throws java.io.IOException
Creates a stateless service client and connect it to a server.

Parameters:
hostName - the host name of the server.
port - the port on which the server waits for request.
ratingListener - the listener informed when rating is found or lost.
timeout - the timeout for the client request.
Throws:
java.io.IOException - if the client cannot connect to the server (if server is not running, for instance) or if an error occurred reading the currency resources.

StatelessServiceClient

public StatelessServiceClient(java.lang.String hostName,
                              int port,
                              java.lang.String bindAddress,
                              FoundLostRatingListener ratingListener,
                              int timeout)
                       throws java.io.IOException
Creates a stateless service client and connect it to a server.

Parameters:
hostName - the host name of the server.
port - the port on which the server waits for request.
bindAddress - address to bind description.
ratingListener - the listener informed when rating is found or lost.
timeout - the timeout for the client request.
Throws:
java.io.IOException - if the client cannot connect to the server (if server is not running, for instance) or if an error occurred reading the currency resources.
Method Detail

setBootMode

public void setBootMode(BootMode mode)
Defines which API will be used to retrieve from the remote instances, the Instance Map needed for the connection.

Parameters:
mode - is MESSAGE_BOOT_MODE to use the Message Api or is HTTP_BOOT_MODE to use the Http api.

getBootMode

public BootMode getBootMode()
Returns which API is used to retrieve from the remote instances, the Instance Map needed for the connection.

Returns:
MESSAGE_BOOT_MODE if the Message Api is used or HTTP_BOOT_MODE if the Http api is used.

getTimeout

public int getTimeout()
Returns the timeout in milliseconds for each request (or -1 to wait indefinitively)

Returns:
the timeout in milliseconds, or -1 if no timeout has been defined.

setClusterName

public void setClusterName(java.lang.String clusterName)
Sets cluster name.

Parameters:
clusterName - the name of the cluster.

getClusterName

public java.lang.String getClusterName()
Gets the name of the cluster.

Returns:
the name of the cluster.

setFoundLostRatingListener

public void setFoundLostRatingListener(FoundLostRatingListener ratingListener)
Sets the FoundLostRatingListener that will be notified each time a Rating Instance will be found or lost.


getFoundLostRatingListener

public FoundLostRatingListener getFoundLostRatingListener()
Returns the FoundLostRatingListener previously set.

See Also:
setFoundLostRatingListener(FoundLostRatingListener)

connect

public void connect(java.lang.String hostName,
                    int port)
             throws java.io.IOException
Connect this stateless service client using the round robin with the server.

Parameters:
hostName - the host name of the server.
port - the port on which the server waits for request.
Throws:
java.io.IOException - if the client cannot connect to the server (if server is not running, for instance).

connect

public void connect(java.lang.String hostName,
                    int port,
                    int timeout)
             throws java.io.IOException
Connect this stateless service client using the round robin with the server.

Parameters:
hostName - the host name of the server.
port - the port on which the server waits for request.
timeout - the timeout for the client's requests.
Throws:
java.io.IOException - if the client cannot connect to the server (if server is not running, for instance).

connect

public void connect(java.lang.String hostName,
                    int port,
                    FoundLostRatingListener ratingListener)
             throws java.io.IOException
Connect this stateless service client using the round robin with the server.

Parameters:
hostName - the host name of the server.
port - the port on which the server waits for request.
ratingListener - the FoundLostRatingListener that will be notified each time a Rating Instance will be found or lost.
Throws:
java.io.IOException - if the client cannot connect to the server (if server is not running, for instance).

connect

public void connect(java.lang.String hostName,
                    int port,
                    java.lang.String bindAddress,
                    FoundLostRatingListener ratingListener,
                    int timeout)
             throws java.io.IOException
Connect this stateless service client using the round robin with the server.

Parameters:
hostName - the host name of the server.
port - the port on which the server waits for request.
bindAddress - the address to bind description.
ratingListener - the FoundLostRatingListener that will be notified each time a Rating Instance will be found or lost.
timeout - the timeout for the clients request.
Throws:
java.io.IOException - if the client cannot connect to the server (if server is not running, for instance).

connect

public void connect(java.lang.String hostName,
                    int port,
                    java.lang.String bindAddress,
                    FoundLostRatingListener ratingListener,
                    int timeout,
                    ServiceClientTuning config)
             throws java.io.IOException
Connect this stateless service client using the round robin with the server.

Parameters:
hostName - the host name of the server.
port - the port on which the server waits for request.
bindAddress - the address to bind description.
ratingListener - the FoundLostRatingListener that will be notified each time a Rating Instance will be found or lost.
timeout - the timeout for the clients request.
config - a tuned configuration for this client, can be null.
Throws:
java.io.IOException - if the client cannot connect to the server (if server is not running, for instance).

connect

public void connect(InstanceMap imap,
                    java.lang.String bindAddress,
                    FoundLostRatingListener ratingListener,
                    int timeout,
                    ServiceClientTuning config)
             throws java.io.IOException
Throws:
java.io.IOException

statelessRate

public StatelessRateResult statelessRate(java.lang.String chargeCode,
                                         java.util.Date ratingDate,
                                         StatelessRatingEvent event,
                                         StatelessRatingContext context,
                                         boolean withDetails,
                                         boolean checkDates)
                                  throws StatelessRateException,
                                         InvalidItemException,
                                         ForbiddenChargeException,
                                         CommunicationFailureException,
                                         ServerFailureException
This method is dedicated to the stateless rating.

This method should not be used on a StatelessRatingContext which is embeded into a StatelessPreRatingContext. See StatelessPreRatingContext documentation.

Parameters:
chargeCode - The code of the charge.
ratingDate - The date of the rating.
event - The event to rate.
context - The context of the rating.
withDetails - With all or main details in results.
checkDates - Check date chronology.
Throws:
StatelessRateException - when the rate stateless fails.
InvalidItemException - when the item is invalid.
ForbiddenChargeException - when the charge process is forbidden (no access, agreement is not valid any longer, the price plan forbids charging or when arguments are not correct).
CommunicationFailureException - if all the raters are unavailable.
ServerFailureException - if a failure occurred on server side.

statelessRate

public StatelessRateResult statelessRate(java.lang.String chargeCode,
                                         java.util.Date ratingDate,
                                         StatelessRatingEvent event,
                                         StatelessRatingContext context,
                                         java.lang.String[] retainedDetails,
                                         boolean checkDates)
                                  throws StatelessRateException,
                                         InvalidItemException,
                                         ForbiddenChargeException,
                                         CommunicationFailureException,
                                         ServerFailureException
Similar to statelessRate(String, Date, StatelessRatingEvent, StatelessRatingContext, boolean, boolean), but with finest selection of resulting transaction details. Indeed, the retainedDetails parameter enables to list the transaction details to retain in the resulting transaction(s).

When retainedDetails is null, this is equivalent to statelessRate(chargeCode, ratingDate, event, context, false, checkDates). Main details that are present in this case are always present, whatever the content of retainedDetails is.

Parameters:
chargeCode - The code of the charge.
ratingDate - The date of the rating.
event - The event to rate.
context - The context of the rating.
retainedDetails - list of names of transaction details to retain in resulting transaction(s).
checkDates - Check date chronology.
Throws:
StatelessRateException - when the rate stateless fails.
InvalidItemException - when the item is invalid.
ForbiddenChargeException - when the charge process is forbidden (no access, agreement is not valid any longer, the price plan forbids charging or when arguments are not correct).
CommunicationFailureException - if all the raters are unavailable.
ServerFailureException - if a failure occurred on server side.
See Also:
statelessRate(String, Date, StatelessRatingEvent, StatelessRatingContext, boolean, boolean)

translate

public java.lang.Object[] translate(java.lang.String tableCode,
                                    int operator,
                                    java.util.Date date,
                                    java.lang.String[] inValues)
                             throws DoesNotExistException,
                                    CommunicationFailureException,
                                    ServerFailureException
Translates some values by using a translation table.

Parameters:
tableCode - the code of the translation table which must be used.
operator - the comparison operator
date - the version date of the translation table
inValues - an array of String which represents the input values
Returns:
an array of the translated Object
Throws:
DoesNotExistException - thrown if the translation table does not exist
CommunicationFailureException - if all the raters are unavailable.
ServerFailureException - if a failure occurred on server side.
See Also:
TranslateValueOp

translate

public java.lang.Object[] translate(java.lang.String tableCode,
                                    int operator,
                                    java.util.Date date,
                                    java.util.Date referenceDate,
                                    java.lang.String[] inValues)
                             throws DoesNotExistException,
                                    CommunicationFailureException,
                                    ServerFailureException
Translates some values by using a translation table.

Parameters:
tableCode - the code of the translation table which must be used.
operator - the comparison operator
date - the version date of the translation table
referenceDate - the reference date used to check column "start date" and column "end date"
inValues - an array of String which represents the input values
Returns:
an array of the translated Object
Throws:
DoesNotExistException - thrown if the translation table does not exist
CommunicationFailureException - if all the raters are unavailable.
ServerFailureException - if a failure occurred on server side.
See Also:
TranslateValueOp

statelessPreRate

public StatelessPreRateResult statelessPreRate(StatelessRatingEvent ratingEvent,
                                               java.lang.String chargeCode,
                                               StatelessPreRatingContext preRatingContext,
                                               java.util.Date ratingDate,
                                               long reservationUID,
                                               long postrateDeadline,
                                               boolean withDetails,
                                               boolean checkDates)
                                        throws StatelessPreRatingException,
                                               StatelessRateException,
                                               InvalidItemException,
                                               ForbiddenChargeException,
                                               CommunicationFailureException,
                                               ServerFailureException
This method is dedicated to the stateless pre-rating.

After a call to this method, the passed StatelessPreRatingContext is not modified. It must be updated (if needed) explicitly calling the StatelessPreRateResult.update(StatelessPreRatingContext) method of the result.

The underlying rating is done using the StatelessRatingContext associated with the charge code in the given StatelessPreRatingContext. If no such StatelessRatingContext exists, it's created (it will be then really added in the StatelessPreRatingContext by the further call to StatelessPreRateResult.update(StatelessPreRatingContext)).

See also StatelessPreRatingContext documentation for limitation and constraints to follow.

Parameters:
ratingEvent - the event to rate.
chargeCode - the code of the charge.
preRatingContext - the context of the stateless pre-rating.
ratingDate - a date based on which the chargeable item is rated.
reservationUID - the unique identifier of the reservation.
postrateDeadline - the delay after which the availability of pending pre-rating is no longer guarantied in case of post-rate call using the related reservationUID. A value <= 0 means the pre-rating is 'auto-confirmed' and not available for post-rate.
withDetails - with all or main details in results.
checkDates - check date chronology.
Throws:
StatelessPreRatingException - when the pre rate stateless fails.
StatelessRateException - when the rate stateless fails.
InvalidItemException - when the item is invalid.
ForbiddenChargeException - when the charge process is forbidden (no access, agreement is not valid any longer, the price plan forbids charging or when arguments are not correct).
CommunicationFailureException - if all the raters are unavailable.
ServerFailureException - if a failure occurred on server side.

statelessPreRate

public StatelessPreRateResult statelessPreRate(StatelessRatingEvent ratingEvent,
                                               java.lang.String chargeCode,
                                               StatelessPreRatingContext preRatingContext,
                                               java.util.Date ratingDate,
                                               long reservationUID,
                                               long postrateDeadline,
                                               java.lang.String[] retainedDetails,
                                               boolean checkDates)
                                        throws StatelessPreRatingException,
                                               StatelessRateException,
                                               InvalidItemException,
                                               ForbiddenChargeException,
                                               CommunicationFailureException,
                                               ServerFailureException
Similar to statelessPreRate(StatelessRatingEvent, String, StatelessPreRatingContext, Date, long, long, boolean, boolean), but with finest selection of resulting transaction details. Indeed, the retainedDetails parameter enables to list the transaction details to retain in the resulting transaction(s).

When retainedDetails is null, this is equivalent to statelessRate(chargeCode, ratingDate, event, context, false, checkDates). Main details that are present in this case are always present, whatever the content of retainedDetails is.

Parameters:
ratingEvent - the event to rate.
chargeCode - the code of the charge.
preRatingContext - the context of the stateless pre-rating.
ratingDate - a date based on which the chargeable item is rated.
reservationUID - the unique identifier of the reservation.
postrateDeadline - the delay after which the availability of pending pre-rating is no longer guarantied in case of post-rate call using the related reservationUID. A value <= 0 means the pre-rating is 'auto-confirmed' and not available for post-rate.
retainedDetails - list of names of transaction details to retain in resulting transaction(s).
checkDates - check date chronology.
Throws:
StatelessPreRatingException - when the pre rate stateless fails.
StatelessRateException - when the rate stateless fails.
InvalidItemException - when the item is invalid.
ForbiddenChargeException - when the charge process is forbidden (no access, agreement is not valid any longer, the price plan forbids charging or when arguments are not correct).
CommunicationFailureException - if all the raters are unavailable.
ServerFailureException - if a failure occurred on server side.
See Also:
statelessPreRate(StatelessRatingEvent, String, StatelessPreRatingContext, Date, long, long, boolean, boolean)

statelessPostRate

public StatelessPostRateResult statelessPostRate(long reservationUID,
                                                 StatelessPreRatingContext preRatingContext,
                                                 int resolution,
                                                 boolean withDetails,
                                                 ChargeableItem newCi)
                                          throws StatelessPreRatingException,
                                                 StatelessRateException,
                                                 InvalidItemException,
                                                 ForbiddenChargeException,
                                                 CommunicationFailureException,
                                                 ServerFailureException
This method is dedicated to the stateless post-rating.

After a call to this method, the passed StatelessPreRatingContext is not modified. It must be updated (if needed) explicitly calling the StatelessPostRateResult.update(StatelessPreRatingContext) method of the result.

Parameters:
reservationUID - the unique identifier of the reservation.
preRatingContext - the context of the stateless pre-rating.
resolution - the resolution (one of POST_RATE_CONFIRMATION or POST_RATE_CONFIRMATION).
withDetails - with all or main details in results.
newCi - the new chargeable item, in case of confirmation with new CI.
Throws:
StatelessPreRatingException - when the pre rate stateless fails.
StatelessRateException - when the rate stateless fails.
InvalidItemException - when the item is invalid.
ForbiddenChargeException - when the charge process is forbidden (no access, agreement is not valid any longer, the price plan forbids charging or when arguments are not correct).
CommunicationFailureException - if all the raters are unavailable.
ServerFailureException - if a failure occurred on server side.

statelessPostRate

public StatelessPostRateResult statelessPostRate(long reservationUID,
                                                 StatelessPreRatingContext preRatingContext,
                                                 int resolution,
                                                 java.lang.String[] retainedDetails,
                                                 ChargeableItem newCi)
                                          throws StatelessPreRatingException,
                                                 StatelessRateException,
                                                 InvalidItemException,
                                                 ForbiddenChargeException,
                                                 CommunicationFailureException,
                                                 ServerFailureException
Similar to statelessPostRate(long, StatelessPreRatingContext, int, boolean, ChargeableItem), but with finest selection of resulting transaction details. Indeed, the retainedDetails parameter enables to list the transaction details to retain in the resulting transaction(s).

When retainedDetails is null, this is equivalent to statelessRate(chargeCode, ratingDate, event, context, false, checkDates). Main details that are present in this case are always present, whatever the content of retainedDetails is.

Parameters:
reservationUID - the unique identifier of the reservation.
preRatingContext - the context of the stateless pre-rating.
resolution - the resolution (one of POST_RATE_CONFIRMATION or POST_RATE_CONFIRMATION).
retainedDetails - list of names of transaction details to retain in resulting transaction(s).
newCi - the new chargeable item, in case of confirmation with new CI.
Throws:
StatelessPreRatingException - when the pre rate stateless fails.
StatelessRateException - when the rate stateless fails.
InvalidItemException - when the item is invalid.
ForbiddenChargeException - when the charge process is forbidden (no access, agreement is not valid any longer, the price plan forbids charging or when arguments are not correct).
CommunicationFailureException - if all the raters are unavailable.
ServerFailureException - if a failure occurred on server side.
See Also:
statelessPostRate(long, StatelessPreRatingContext, int, boolean, ChargeableItem)

isConnected

public boolean isConnected()
Gets the connected status.

Returns:
true if the client is connected and false otherwise.

close

public void close()
Closes the connection.


currentQueueSize

protected int currentQueueSize()
                        throws CommunicationFailureException
This method is for internal use only. It returns the size of the message queue of the stateful service server.

Returns:
the size of the queue of the stateful service server.
Throws:
CommunicationFailureException

checkDB

protected boolean checkDB()
                   throws CommunicationFailureException
This method is for internal use only. It returns a boolean specifying if the server is connected to the database.

Returns:
a boolean specifying if the server is connected to the database.
Throws:
CommunicationFailureException

SAP CC 1.0
API 4.2 (Core)


API Reference - July 2009

SAP Convergent Charging 1.0 (build R4.2.1.35.0.0)
CONVERGENT CHARGING 4.2

(c) Copyright 2009 SAP AG. All rights reserved.