Package org.cyclos.impl.utils.sms
Class GatewaySmsSender
- java.lang.Object
-
- org.cyclos.impl.utils.sms.GatewaySmsSender
-
-
Field Summary
Fields Modifier and Type Field Description protected static intTIMEOUT
-
Constructor Summary
Constructors Constructor Description GatewaySmsSender()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description protected voidapplyAuthentication(ConfigurationAccessor configuration, MobilePhone phone, String phoneNumber, String message, org.apache.http.client.methods.HttpUriRequest request)May be overridden in order to use some custom authentication schemeprotected voidapplyHeaders(ConfigurationAccessor configuration, MobilePhone phone, String phoneNumber, String message, org.apache.http.client.methods.HttpUriRequest request, Properties headers)protected voidapplyPostBody(ConfigurationAccessor configuration, MobilePhone phone, String phoneNumber, String message, org.apache.http.client.methods.HttpPost request, String postBody)protected org.apache.http.client.methods.HttpUriRequestbuildRequest(ConfigurationAccessor configuration, String gatewayUrl, MobilePhone phone, String phoneNumber, String message)Creates the request, either a GET or post, and sets the content type header on itprotected OutboundSmsStatusdoSend(ConfigurationAccessor configuration, MobilePhone phone, String phoneNumber, String message, org.apache.http.client.methods.HttpUriRequest request)May be overriden in order to customize the SMS sendingprotected StringpreProcessMessage(ConfigurationAccessor configuration, String message)By default, according to the outbound sms configuration, makes the message only have ASC-II charactersprotected StringresolveGatewayUrl(ConfigurationAccessor configuration, MobilePhone phone, String phoneNumber, String message, Map<String,String> variables)May be overridden in order to resolve the final gateway URL.protected StringresolvePostBody(ConfigurationAccessor configuration, MobilePhone phone, String phoneNumber, String message, Map<String,String> variables)May be overridden in order to resolve the POST body from the given context and variablesprotected OutboundSmsStatusresolveStatus(ConfigurationAccessor configuration, MobilePhone phone, String message, org.apache.http.client.methods.HttpUriRequest request, int statusCode, org.apache.http.HttpEntity entity)May be overridden to actually resolve the SMS status from the given responseprotected Map<String,String>resolveVariables(ConfigurationAccessor configuration, MobilePhone phone, String phoneNumber, String message)May be overridden in order to resolve custom variablesOutboundSmsStatussend(ConfigurationAccessor configuration, MobilePhone phone, String phoneNumber, String message)Sends the sms message for the given phone, returning the send status.
-
-
-
Field Detail
-
TIMEOUT
protected static final int TIMEOUT
- See Also:
- Constant Field Values
-
-
Method Detail
-
send
public OutboundSmsStatus send(ConfigurationAccessor configuration, @Nullable MobilePhone phone, String phoneNumber, String message)
Description copied from interface:SmsSenderSends the sms message for the given phone, returning the send status. The phone object might be null when sending an SMS to a phone not registered in Cyclos
-
applyAuthentication
protected void applyAuthentication(ConfigurationAccessor configuration, @Nullable MobilePhone phone, String phoneNumber, String message, org.apache.http.client.methods.HttpUriRequest request) throws Exception
May be overridden in order to use some custom authentication scheme- Throws:
Exception
-
applyHeaders
protected void applyHeaders(ConfigurationAccessor configuration, MobilePhone phone, String phoneNumber, String message, org.apache.http.client.methods.HttpUriRequest request, Properties headers)
-
applyPostBody
protected void applyPostBody(ConfigurationAccessor configuration, @Nullable MobilePhone phone, String phoneNumber, String message, org.apache.http.client.methods.HttpPost request, String postBody)
-
buildRequest
protected org.apache.http.client.methods.HttpUriRequest buildRequest(ConfigurationAccessor configuration, String gatewayUrl, @Nullable MobilePhone phone, String phoneNumber, String message)
Creates the request, either a GET or post, and sets the content type header on it
-
doSend
protected OutboundSmsStatus doSend(ConfigurationAccessor configuration, @Nullable MobilePhone phone, String phoneNumber, String message, org.apache.http.client.methods.HttpUriRequest request) throws Exception
May be overriden in order to customize the SMS sending- Throws:
Exception
-
preProcessMessage
protected String preProcessMessage(ConfigurationAccessor configuration, String message)
By default, according to the outbound sms configuration, makes the message only have ASC-II characters
-
resolveGatewayUrl
protected String resolveGatewayUrl(ConfigurationAccessor configuration, @Nullable MobilePhone phone, String phoneNumber, String message, Map<String,String> variables) throws Exception
May be overridden in order to resolve the final gateway URL. The variables are already URL encoded, so are safe to concatenate on the URL- Throws:
Exception
-
resolvePostBody
protected String resolvePostBody(ConfigurationAccessor configuration, @Nullable MobilePhone phone, String phoneNumber, String message, Map<String,String> variables) throws Exception
May be overridden in order to resolve the POST body from the given context and variables- Throws:
Exception
-
resolveStatus
protected OutboundSmsStatus resolveStatus(ConfigurationAccessor configuration, @Nullable MobilePhone phone, String message, org.apache.http.client.methods.HttpUriRequest request, int statusCode, org.apache.http.HttpEntity entity)
May be overridden to actually resolve the SMS status from the given response
-
resolveVariables
protected Map<String,String> resolveVariables(ConfigurationAccessor configuration, @Nullable MobilePhone phone, String phoneNumber, String message) throws Exception
May be overridden in order to resolve custom variables- Throws:
Exception
-
-