ibilling.client
Class Helper

java.lang.Object
  extended by ibilling.client.Helper

public class Helper
extends java.lang.Object

Helper class. Encapsulates all functionality that relies on Java libraries that might not be present in other languages. Used primarily to simplify source code conversion into other languages.

Since:
1.0

Constructor Summary
Helper()
           
 
Method Summary
(package private) static java.util.List<ClientObject> accountTransactionListToClientObjectList(java.util.List<AccountTransaction> transactions)
          Transforms List to List
(package private) static java.util.List<ClientObject> assetTransactionListToClientObjectList(java.util.List<AssetTransaction> transactions)
          Transforms List to List
(package private) static java.util.List<AccountTransaction> clientObjectListToAccountTransactionList(java.util.List<ClientObject> list)
          Transforms List to List
(package private) static java.util.List<CustomerAccount> clientObjectListToCustomerAccountList(java.util.List<ClientObject> list)
          Transforms List to List
(package private) static java.util.List<PaymentOption> clientObjectListToPaymentOptionList(java.util.List<ClientObject> list)
          Transforms List to List
(package private) static java.util.List<PaymentPlan> clientObjectListToPaymentPlanList(java.util.List<ClientObject> list)
          Transforms List to List
static int compareDate(java.util.Date date1, java.util.Date date2)
          Compares two dates.
(package private) static java.util.List<ClientObject> customerAccountListToClientObjectList(java.util.List<CustomerAccount> customerAccounts)
          Transforms List to List
static ElementFacade doPost(ElementFacade requestFacade, java.util.Map<java.lang.String,java.lang.Object> config)
          Performs post of XML data to the server and pasring of the result.
static java.lang.String formatDate(java.util.Date value)
          Formats date using predefined format.
static java.util.Collection<AssetTransaction> getAssetTransactionValues(java.util.Map<java.lang.Integer,AssetTransaction> map)
          Returns values from Map
(package private) static java.lang.String getClassName(ClientObject clientObject)
           
static ClientException getClientException(java.lang.Throwable throwable)
          Converts various types of exceptions (server exceptions) into library-unified ClientException
(package private) static java.util.Collection<CustomerAccount> getCustomerAccountValues(java.util.Map<java.lang.Integer,CustomerAccount> map)
          Returns values from Map
private static java.net.HttpURLConnection getHttpURLConnection(java.util.Map<java.lang.String,java.lang.Object> config)
          Loads SSL Sertificate (if required) and opens connection to the server
static java.util.Date getNextBillingDate(java.util.Date nextBillingDate, java.lang.String billingCycleCode, int chargeIndex)
          Calculates billing date for a charge given initial billing date of the parent plan, code of the billing cycle and index of the charge
(package private) static java.util.Collection<PaymentOption> getPaymentOptionValues(java.util.Map<java.lang.Integer,PaymentOption> map)
          Returns values from Map
(package private) static java.util.Collection<PaymentPlan> getPaymentPlanValues(java.util.Map<java.lang.Integer,PaymentPlan> map)
          Returns values from Map
static java.lang.Integer getRefId(java.lang.String refId)
           
(package private) static java.util.Collection<RevenueTransaction> getRevenueTransactionValues(java.util.Map<java.lang.Integer,RevenueTransaction> map)
          Returns values from Map
static SessionConnection getSessionConnection(java.util.Map<java.lang.String,java.lang.Object> config)
          Instantiates SessionConnection based on configuration settings.
static boolean isNewObject(java.lang.String id)
          Verifies id the id was attributed to a newly created non-persisted object Used exclusively for XML communication protocol.
static java.util.Date parseDate(java.lang.String date)
          Parses the date according to predefined fixed format.
(package private) static java.util.List<ClientObject> paymentOptionListToClientObjectList(java.util.List<PaymentOption> paymentOptions)
          Transforms List to List
(package private) static java.util.List<ClientObject> paymentPlanListToClientObjectList(java.util.List<PaymentPlan> paymentPlans)
          Transforms List to List
private static void printDebug(org.jdom.output.XMLOutputter serializer, ElementFacade facade, java.util.Map<java.lang.String,java.lang.Object> config)
           
(package private) static java.util.List<ClientObject> revenueTransactionListToClientObjectList(java.util.List<RevenueTransaction> transactions)
          Transforms List to List
(package private) static void setQueryParameters(ElementFacade facade, java.util.Map<java.lang.String,java.lang.Object> parameters)
           
(package private) static void sort(java.util.List list)
           
(package private) static java.util.List<ClientObject> toClientObjectList(java.util.List list)
           
(package private) static java.util.List<CustomerAccount> toCustomerAccountList(java.util.List list)
           
static boolean validateFirstBillingDate(java.util.Date firstBillingDate, java.lang.String billingCycleCode)
          Validates value of the First Billing Date for a PaymentPlan given billing cycle
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

Helper

public Helper()
Method Detail

validateFirstBillingDate

public static boolean validateFirstBillingDate(java.util.Date firstBillingDate,
                                               java.lang.String billingCycleCode)
Validates value of the First Billing Date for a PaymentPlan given billing cycle

Parameters:
firstBillingDate - date to be validated
billingCycleCode - code of the cycle to validate the date against
Returns:
true, if the date is valid for the cycle

getNextBillingDate

public static java.util.Date getNextBillingDate(java.util.Date nextBillingDate,
                                                java.lang.String billingCycleCode,
                                                int chargeIndex)
                                         throws ClientException
Calculates billing date for a charge given initial billing date of the parent plan, code of the billing cycle and index of the charge

Parameters:
nextBillingDate - initial billing date of the cycle
billingCycleCode - code of the billing cycle
chargeIndex - index of the charge for which the billing date is required
Returns:
billing date of the charge
Throws:
ClientException - if invalid values are supplied

getClientException

public static ClientException getClientException(java.lang.Throwable throwable)
Converts various types of exceptions (server exceptions) into library-unified ClientException

Parameters:
throwable - initial exception
Returns:
client exception with appropriate message

parseDate

public static java.util.Date parseDate(java.lang.String date)
                                throws java.text.ParseException
Parses the date according to predefined fixed format. Primarily used for XML communication protocol.

Parameters:
date - String representation of the date
Returns:
parsed date
Throws:
java.text.ParseException - in case of invalid date format

formatDate

public static java.lang.String formatDate(java.util.Date value)
Formats date using predefined format. Used primarily for XML communication protocol.

Parameters:
value - date to format
Returns:
String presentation of the date

getRefId

public static java.lang.Integer getRefId(java.lang.String refId)

isNewObject

public static boolean isNewObject(java.lang.String id)
Verifies id the id was attributed to a newly created non-persisted object Used exclusively for XML communication protocol. Facade method for source-code conversion.

Parameters:
id - id to analyze
Returns:
true, if id was attributed to a new object

compareDate

public static int compareDate(java.util.Date date1,
                              java.util.Date date2)
Compares two dates. Returns positive value if first date is greater than the second. Returns negative value if first date is less than the second. Returns zero if the dates are equal

Parameters:
date1 - first date
date2 - second date
Returns:
result of comparison

getSessionConnection

public static SessionConnection getSessionConnection(java.util.Map<java.lang.String,java.lang.Object> config)
Instantiates SessionConnection based on configuration settings. Facade method for source-code conversion.

Parameters:
config - the config
Returns:
the session connection

doPost

public static ElementFacade doPost(ElementFacade requestFacade,
                                   java.util.Map<java.lang.String,java.lang.Object> config)
                            throws ClientException
Performs post of XML data to the server and pasring of the result. Used exclusively for XML communication protocol.

Parameters:
requestFacade - object to be sent as XML to the server
config - configuration map, usually with server path and SSL settings
Returns:
response of the server
Throws:
ClientException - if server returns exception object or on communication error

customerAccountListToClientObjectList

static java.util.List<ClientObject> customerAccountListToClientObjectList(java.util.List<CustomerAccount> customerAccounts)
Transforms List to List

Parameters:
customerAccounts - List
Returns:
List

paymentOptionListToClientObjectList

static java.util.List<ClientObject> paymentOptionListToClientObjectList(java.util.List<PaymentOption> paymentOptions)
Transforms List to List

Parameters:
paymentOptions - List
Returns:
List

revenueTransactionListToClientObjectList

static java.util.List<ClientObject> revenueTransactionListToClientObjectList(java.util.List<RevenueTransaction> transactions)
Transforms List to List

Parameters:
transactions - List
Returns:
List

assetTransactionListToClientObjectList

static java.util.List<ClientObject> assetTransactionListToClientObjectList(java.util.List<AssetTransaction> transactions)
Transforms List to List

Parameters:
transactions - List
Returns:
List

accountTransactionListToClientObjectList

static java.util.List<ClientObject> accountTransactionListToClientObjectList(java.util.List<AccountTransaction> transactions)
Transforms List to List

Parameters:
transactions - List
Returns:
List

paymentPlanListToClientObjectList

static java.util.List<ClientObject> paymentPlanListToClientObjectList(java.util.List<PaymentPlan> paymentPlans)
Transforms List to List

Parameters:
paymentPlans - List
Returns:
List

clientObjectListToCustomerAccountList

static java.util.List<CustomerAccount> clientObjectListToCustomerAccountList(java.util.List<ClientObject> list)
Transforms List to List

Parameters:
list - List
Returns:
List

clientObjectListToPaymentOptionList

static java.util.List<PaymentOption> clientObjectListToPaymentOptionList(java.util.List<ClientObject> list)
Transforms List to List

Parameters:
list - List
Returns:
List

clientObjectListToAccountTransactionList

static java.util.List<AccountTransaction> clientObjectListToAccountTransactionList(java.util.List<ClientObject> list)
Transforms List to List

Parameters:
list - List
Returns:
List

clientObjectListToPaymentPlanList

static java.util.List<PaymentPlan> clientObjectListToPaymentPlanList(java.util.List<ClientObject> list)
Transforms List to List

Parameters:
list - List
Returns:
List

getCustomerAccountValues

static java.util.Collection<CustomerAccount> getCustomerAccountValues(java.util.Map<java.lang.Integer,CustomerAccount> map)
Returns values from Map

Parameters:
map - Map
Returns:
Collection

getPaymentOptionValues

static java.util.Collection<PaymentOption> getPaymentOptionValues(java.util.Map<java.lang.Integer,PaymentOption> map)
Returns values from Map

Parameters:
map - Map
Returns:
Collection

getPaymentPlanValues

static java.util.Collection<PaymentPlan> getPaymentPlanValues(java.util.Map<java.lang.Integer,PaymentPlan> map)
Returns values from Map

Parameters:
map - Map
Returns:
Collection

getRevenueTransactionValues

static java.util.Collection<RevenueTransaction> getRevenueTransactionValues(java.util.Map<java.lang.Integer,RevenueTransaction> map)
Returns values from Map

Parameters:
map - Map
Returns:
Collection

getAssetTransactionValues

public static java.util.Collection<AssetTransaction> getAssetTransactionValues(java.util.Map<java.lang.Integer,AssetTransaction> map)
Returns values from Map

Parameters:
map - Map
Returns:
Collection

getHttpURLConnection

private static java.net.HttpURLConnection getHttpURLConnection(java.util.Map<java.lang.String,java.lang.Object> config)
Loads SSL Sertificate (if required) and opens connection to the server

Parameters:
config - configuration map with server URL and SSL settings
Returns:
URLConnection for the supplied URL

toCustomerAccountList

static java.util.List<CustomerAccount> toCustomerAccountList(java.util.List list)

toClientObjectList

static java.util.List<ClientObject> toClientObjectList(java.util.List list)

setQueryParameters

static void setQueryParameters(ElementFacade facade,
                               java.util.Map<java.lang.String,java.lang.Object> parameters)

sort

static void sort(java.util.List list)

getClassName

static java.lang.String getClassName(ClientObject clientObject)

printDebug

private static void printDebug(org.jdom.output.XMLOutputter serializer,
                               ElementFacade facade,
                               java.util.Map<java.lang.String,java.lang.Object> config)