org.opengts.db
Class SMSOutboundGateway

java.lang.Object
  extended by org.opengts.db.SMSOutboundGateway

public abstract class SMSOutboundGateway
extends java.lang.Object

Outbound SMS gateway handler


Field Summary
static java.lang.String GW_aeris
           
static java.lang.String GW_clickatell
           
static java.lang.String GW_custom
           
static java.lang.String GW_emailBody
           
static java.lang.String GW_emailSubject
           
static java.lang.String GW_httpURL
           
static java.lang.String GW_mail2txt
           
static java.lang.String GW_mail2txt160
           
static java.lang.String GW_mail2txt160id
           
static java.lang.String GW_mail2txtid
           
static java.lang.String GW_ozekisms
           
static java.lang.String GW_twilio
           
 java.lang.String gwName
           
static java.lang.String PROP_aeris_className
           
static java.lang.String PROP_aeris_maxMessageLength
           
static java.lang.String PROP_clickatell_api_id
           
static java.lang.String PROP_clickatell_maxMessageLength
           
static java.lang.String PROP_clickatell_password
           
static java.lang.String PROP_clickatell_smsEmailAddress
           
static java.lang.String PROP_clickatell_user
           
static java.lang.String PROP_custom_className
           
static java.lang.String PROP_custom_maxMessageLength
           
static java.lang.String PROP_defaultMaxMessageLength
           
static java.lang.String PROP_defaultName
           
static java.lang.String PROP_emailBody_maxMessageLength
           
static java.lang.String PROP_emailBody_smsEmailAddress
           
static java.lang.String PROP_emailSubject_maxMessageLength
           
static java.lang.String PROP_emailSubject_smsEmailAddress
           
static java.lang.String PROP_httpURL_maxMessageLength
           
static java.lang.String PROP_httpURL_url
           
static java.lang.String PROP_ignoredSms_file
           
static java.lang.String PROP_mail2txt_maxMessageLength
           
static java.lang.String PROP_mail2txt_smsEmailAddress
           
static java.lang.String PROP_mail2txt160_maxMessageLength
           
static java.lang.String PROP_mail2txt160_smsEmailAddress
           
static java.lang.String PROP_mail2txt160id_from
           
static java.lang.String PROP_mail2txt160id_maxMessageLength
           
static java.lang.String PROP_mail2txt160id_smsEmailAddress
           
static java.lang.String PROP_mail2txtid_from
           
static java.lang.String PROP_mail2txtid_maxMessageLength
           
static java.lang.String PROP_mail2txtid_smsEmailAddress
           
static java.lang.String PROP_ozekisms_hostPort
           
static java.lang.String PROP_ozekisms_maxMessageLength
           
static java.lang.String PROP_ozekisms_originator
           
static java.lang.String PROP_ozekisms_password
           
static java.lang.String PROP_ozekisms_user
           
static java.lang.String PROP_twilio_accountSID
           
static java.lang.String PROP_twilio_authToken
           
static java.lang.String PROP_twilio_className
           
static java.lang.String PROP_twilio_fromPhoneNumber
           
static java.lang.String PROP_twilio_maxMessageLength
           
static java.lang.String[] REPL_1mobile
           
static java.lang.String[] REPL_authID
           
static java.lang.String[] REPL_dataKey
           
static java.lang.String[] REPL_imei
           
static java.lang.String[] REPL_message
           
static java.lang.String[] REPL_mobile
           
static java.lang.String[] REPL_modemID
           
static java.lang.String[] REPL_password
           
static java.lang.String[] REPL_sender
           
static java.lang.String[] REPL_serial
           
static java.lang.String[] REPL_simID
           
static java.lang.String[] REPL_uniqueID
           
static java.lang.String[] REPL_user
           
static java.lang.String SMS_Prefix
           
 
Constructor Summary
SMSOutboundGateway()
           
 
Method Summary
static void _startupInit()
          Initialize outbound SMS gateway handlers
static void AddSMSGateway(java.lang.String name, SMSOutboundGateway smsGW)
          Add SMS Gateway support provider
static java.lang.String GetDefaultGatewayName()
          Returns the default SMS Gateway name
static int GetDefaultMaximumMessageLength()
          Gets the default maximum text message length
protected  java.lang.String getFromEmailAddress(Account account)
           
protected  java.lang.String getFromEmailAddress(Device device)
           
 java.lang.String getName()
           
protected  java.lang.String getSmsEmailAddress(Device device)
           
static SMSOutboundGateway GetSMSGateway(java.lang.String name)
          Gets the SMSoutboubdGateway for the specified name
protected  java.lang.String getSmsPhoneNumber(Device device)
           
protected  java.lang.String getStringProperty(Device device, java.lang.String key, java.lang.String dft)
          Gets the String value for the specified property key.
protected  boolean hasStringProperty(Device device, java.lang.String key)
          Returns true if the specified property key is defined and non-null/blank
static boolean IsDeviceAuthorized(Device device)
          Returns true if device is authorized to send SMS messages
static void main(java.lang.String[] argv)
           
static java.lang.String RemovePrefixSMS(java.lang.String val)
          Removes any prefixing "SMS:" from the specified string.
static java.lang.String REPLACE(java.lang.String s, RTProperties rtp)
          Replace variables in the specified string with the specified property values.
static java.lang.String REPLACE(java.lang.String s, java.lang.String[] r, java.lang.String m)
          Replace specified variables with replacement text
protected  DCServerFactory.ResultCode sendEmail(java.lang.String frEmail, java.lang.String toEmail, java.lang.String subj, java.lang.String body)
           
abstract  DCServerFactory.ResultCode sendSMSCommand(Device device, java.lang.String command)
          Send an SMS command to the specified device
abstract  DCServerFactory.ResultCode sendSMSMessage(Account account, Device device, java.lang.String smsMessage, java.lang.String smsPhone)
          Send an SMS message to the specified phone number.
 void setName(java.lang.String n)
           
static boolean StartsWithSMS(java.lang.String val)
          Return true if string starts with "SMS:"
 java.lang.String toString()
           
static java.lang.String TruncateMessageToLength(java.lang.String message, int length)
          Truncates the specified message to the specified length
static java.lang.String TruncateMessageToMaximumLength(java.lang.String message)
          Truncates the specified message to the maximum text message length
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

PROP_defaultName

public static final java.lang.String PROP_defaultName
See Also:
Constant Field Values

PROP_defaultMaxMessageLength

public static final java.lang.String PROP_defaultMaxMessageLength
See Also:
Constant Field Values

PROP_ignoredSms_file

public static final java.lang.String PROP_ignoredSms_file
See Also:
Constant Field Values

GW_httpURL

public static final java.lang.String GW_httpURL
See Also:
Constant Field Values

PROP_httpURL_url

public static final java.lang.String PROP_httpURL_url
See Also:
Constant Field Values

PROP_httpURL_maxMessageLength

public static final java.lang.String PROP_httpURL_maxMessageLength
See Also:
Constant Field Values

GW_twilio

public static final java.lang.String GW_twilio
See Also:
Constant Field Values

PROP_twilio_className

public static final java.lang.String PROP_twilio_className
See Also:
Constant Field Values

PROP_twilio_maxMessageLength

public static final java.lang.String PROP_twilio_maxMessageLength
See Also:
Constant Field Values

PROP_twilio_accountSID

public static final java.lang.String PROP_twilio_accountSID
See Also:
Constant Field Values

PROP_twilio_authToken

public static final java.lang.String PROP_twilio_authToken
See Also:
Constant Field Values

PROP_twilio_fromPhoneNumber

public static final java.lang.String PROP_twilio_fromPhoneNumber
See Also:
Constant Field Values

GW_ozekisms

public static final java.lang.String GW_ozekisms
See Also:
Constant Field Values

PROP_ozekisms_hostPort

public static final java.lang.String PROP_ozekisms_hostPort
See Also:
Constant Field Values

PROP_ozekisms_originator

public static final java.lang.String PROP_ozekisms_originator
See Also:
Constant Field Values

PROP_ozekisms_user

public static final java.lang.String PROP_ozekisms_user
See Also:
Constant Field Values

PROP_ozekisms_password

public static final java.lang.String PROP_ozekisms_password
See Also:
Constant Field Values

PROP_ozekisms_maxMessageLength

public static final java.lang.String PROP_ozekisms_maxMessageLength
See Also:
Constant Field Values

GW_aeris

public static final java.lang.String GW_aeris
See Also:
Constant Field Values

PROP_aeris_className

public static final java.lang.String PROP_aeris_className
See Also:
Constant Field Values

PROP_aeris_maxMessageLength

public static final java.lang.String PROP_aeris_maxMessageLength
See Also:
Constant Field Values

GW_emailBody

public static final java.lang.String GW_emailBody
See Also:
Constant Field Values

PROP_emailBody_smsEmailAddress

public static final java.lang.String PROP_emailBody_smsEmailAddress
See Also:
Constant Field Values

PROP_emailBody_maxMessageLength

public static final java.lang.String PROP_emailBody_maxMessageLength
See Also:
Constant Field Values

GW_emailSubject

public static final java.lang.String GW_emailSubject
See Also:
Constant Field Values

PROP_emailSubject_smsEmailAddress

public static final java.lang.String PROP_emailSubject_smsEmailAddress
See Also:
Constant Field Values

PROP_emailSubject_maxMessageLength

public static final java.lang.String PROP_emailSubject_maxMessageLength
See Also:
Constant Field Values

GW_clickatell

public static final java.lang.String GW_clickatell
See Also:
Constant Field Values

PROP_clickatell_smsEmailAddress

public static final java.lang.String PROP_clickatell_smsEmailAddress
See Also:
Constant Field Values

PROP_clickatell_user

public static final java.lang.String PROP_clickatell_user
See Also:
Constant Field Values

PROP_clickatell_password

public static final java.lang.String PROP_clickatell_password
See Also:
Constant Field Values

PROP_clickatell_api_id

public static final java.lang.String PROP_clickatell_api_id
See Also:
Constant Field Values

PROP_clickatell_maxMessageLength

public static final java.lang.String PROP_clickatell_maxMessageLength
See Also:
Constant Field Values

GW_mail2txt

public static final java.lang.String GW_mail2txt
See Also:
Constant Field Values

PROP_mail2txt_smsEmailAddress

public static final java.lang.String PROP_mail2txt_smsEmailAddress
See Also:
Constant Field Values

PROP_mail2txt_maxMessageLength

public static final java.lang.String PROP_mail2txt_maxMessageLength
See Also:
Constant Field Values

GW_mail2txt160

public static final java.lang.String GW_mail2txt160
See Also:
Constant Field Values

PROP_mail2txt160_smsEmailAddress

public static final java.lang.String PROP_mail2txt160_smsEmailAddress
See Also:
Constant Field Values

PROP_mail2txt160_maxMessageLength

public static final java.lang.String PROP_mail2txt160_maxMessageLength
See Also:
Constant Field Values

GW_mail2txtid

public static final java.lang.String GW_mail2txtid
See Also:
Constant Field Values

PROP_mail2txtid_smsEmailAddress

public static final java.lang.String PROP_mail2txtid_smsEmailAddress
See Also:
Constant Field Values

PROP_mail2txtid_from

public static final java.lang.String PROP_mail2txtid_from
See Also:
Constant Field Values

PROP_mail2txtid_maxMessageLength

public static final java.lang.String PROP_mail2txtid_maxMessageLength
See Also:
Constant Field Values

GW_mail2txt160id

public static final java.lang.String GW_mail2txt160id
See Also:
Constant Field Values

PROP_mail2txt160id_smsEmailAddress

public static final java.lang.String PROP_mail2txt160id_smsEmailAddress
See Also:
Constant Field Values

PROP_mail2txt160id_from

public static final java.lang.String PROP_mail2txt160id_from
See Also:
Constant Field Values

PROP_mail2txt160id_maxMessageLength

public static final java.lang.String PROP_mail2txt160id_maxMessageLength
See Also:
Constant Field Values

GW_custom

public static final java.lang.String GW_custom
See Also:
Constant Field Values

PROP_custom_className

public static final java.lang.String PROP_custom_className
See Also:
Constant Field Values

PROP_custom_maxMessageLength

public static final java.lang.String PROP_custom_maxMessageLength
See Also:
Constant Field Values

SMS_Prefix

public static final java.lang.String SMS_Prefix
See Also:
Constant Field Values

REPL_mobile

public static final java.lang.String[] REPL_mobile

REPL_1mobile

public static final java.lang.String[] REPL_1mobile

REPL_sender

public static final java.lang.String[] REPL_sender

REPL_dataKey

public static final java.lang.String[] REPL_dataKey

REPL_uniqueID

public static final java.lang.String[] REPL_uniqueID

REPL_modemID

public static final java.lang.String[] REPL_modemID

REPL_simID

public static final java.lang.String[] REPL_simID

REPL_imei

public static final java.lang.String[] REPL_imei

REPL_serial

public static final java.lang.String[] REPL_serial

REPL_user

public static final java.lang.String[] REPL_user

REPL_password

public static final java.lang.String[] REPL_password

REPL_authID

public static final java.lang.String[] REPL_authID

REPL_message

public static final java.lang.String[] REPL_message

gwName

public java.lang.String gwName
Constructor Detail

SMSOutboundGateway

public SMSOutboundGateway()
Method Detail

GetDefaultGatewayName

public static java.lang.String GetDefaultGatewayName()
Returns the default SMS Gateway name


StartsWithSMS

public static boolean StartsWithSMS(java.lang.String val)
Return true if string starts with "SMS:"

Parameters:
val - The string to test
Returns:
True is string starts with "SMS:", false otherwise

RemovePrefixSMS

public static java.lang.String RemovePrefixSMS(java.lang.String val)
Removes any prefixing "SMS:" from the specified string.

Parameters:
val - The string from which the prefixing "SMS:" is removed.
Returns:
The specified string, sans the prefixing "SMS:"

GetDefaultMaximumMessageLength

public static int GetDefaultMaximumMessageLength()
Gets the default maximum text message length


TruncateMessageToMaximumLength

public static java.lang.String TruncateMessageToMaximumLength(java.lang.String message)
Truncates the specified message to the maximum text message length


TruncateMessageToLength

public static java.lang.String TruncateMessageToLength(java.lang.String message,
                                                       int length)
Truncates the specified message to the specified length


IsDeviceAuthorized

public static boolean IsDeviceAuthorized(Device device)
Returns true if device is authorized to send SMS messages


REPLACE

public static java.lang.String REPLACE(java.lang.String s,
                                       java.lang.String[] r,
                                       java.lang.String m)
Replace specified variables with replacement text

Parameters:
s - Target String
r - Replacement variable names
m - Replacement text
Returns:
The new string with variables replaced with specified text

REPLACE

public static java.lang.String REPLACE(java.lang.String s,
                                       RTProperties rtp)
Replace variables in the specified string with the specified property values.

Parameters:
s - Target String
rtp - Replacement property/value list
Returns:
The new string with variables replaced with specified text

AddSMSGateway

public static void AddSMSGateway(java.lang.String name,
                                 SMSOutboundGateway smsGW)
Add SMS Gateway support provider


GetSMSGateway

public static SMSOutboundGateway GetSMSGateway(java.lang.String name)
Gets the SMSoutboubdGateway for the specified name


_startupInit

public static void _startupInit()
Initialize outbound SMS gateway handlers


setName

public void setName(java.lang.String n)

getName

public java.lang.String getName()

toString

public java.lang.String toString()
Overrides:
toString in class java.lang.Object

sendSMSCommand

public abstract DCServerFactory.ResultCode sendSMSCommand(Device device,
                                                          java.lang.String command)
Send an SMS command to the specified device

Parameters:
device - The Device to which the command is sent (must not be null).
command - The command String to send to the Device.
Returns:
The result code

sendSMSMessage

public abstract DCServerFactory.ResultCode sendSMSMessage(Account account,
                                                          Device device,
                                                          java.lang.String smsMessage,
                                                          java.lang.String smsPhone)
Send an SMS message to the specified phone number.

Parameters:
account - The Account for which this SMS message is being sent (must not be null)
device - The Device for which this SMS message is being sent (may be null)
smsMessage - The SMS message sent to the destination phone number
smsPhone - The destination phone number
Returns:
The result code

getFromEmailAddress

protected java.lang.String getFromEmailAddress(Device device)

getFromEmailAddress

protected java.lang.String getFromEmailAddress(Account account)

getSmsEmailAddress

protected java.lang.String getSmsEmailAddress(Device device)

getSmsPhoneNumber

protected java.lang.String getSmsPhoneNumber(Device device)

hasStringProperty

protected boolean hasStringProperty(Device device,
                                    java.lang.String key)
Returns true if the specified property key is defined and non-null/blank


getStringProperty

protected java.lang.String getStringProperty(Device device,
                                             java.lang.String key,
                                             java.lang.String dft)
Gets the String value for the specified property key.

Parameters:
device - The current Device instance
key - The specified property key
dft - The default value to return if the property key is not found
Returns:
The String value for the specified property key.

sendEmail

protected DCServerFactory.ResultCode sendEmail(java.lang.String frEmail,
                                               java.lang.String toEmail,
                                               java.lang.String subj,
                                               java.lang.String body)

main

public static void main(java.lang.String[] argv)