Package org.ametys.plugins.sms.broker
Class EtoileDieseBroker
- java.lang.Object
-
- org.apache.avalon.framework.logger.AbstractLogEnabled
-
- org.ametys.plugins.sms.broker.LoggerBroker
-
- org.ametys.plugins.sms.broker.EtoileDieseBroker
-
- All Implemented Interfaces:
Broker
,Configurable
,Contextualizable
,LogEnabled
,Serviceable
public class EtoileDieseBroker extends LoggerBroker implements Configurable, Contextualizable
Broker implementation using the "etoile diese" web service
-
-
Field Summary
Fields Modifier and Type Field Description private static SimpleDateFormat
__DATE_FORMAT
private Context
_context
The Avalon contextprivate String
_etoileDieseBulkWSUrl
Url of Etoile diese's send sms web service in bulk mode (the recipients are listed in a CSV file)private UserManager
_userManager
The users manager-
Fields inherited from class org.ametys.plugins.sms.broker.LoggerBroker
_ametysObjectResolver, _currentUserProvider
-
-
Constructor Summary
Constructors Constructor Description EtoileDieseBroker()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description private InputStream
_getCSVFile(Set<String> phoneNumbersList, String message)
Creates and return a CSV file from a list of numbers and a messagevoid
configure(Configuration configuration)
void
contextualize(Context context)
String
getPhoneNumberFromStopRequest()
When a stop request is arriving from broker, the implementation extract the phone number associatedvoid
send(Set<String> phoneNumbersList, String message, String listId)
Send the message from the sender to all the phones in the listvoid
service(ServiceManager manager)
-
Methods inherited from class org.ametys.plugins.sms.broker.LoggerBroker
getCategory
-
Methods inherited from class org.apache.avalon.framework.logger.AbstractLogEnabled
enableLogging, getLogger, setupLogger, setupLogger, setupLogger
-
-
-
-
Field Detail
-
__DATE_FORMAT
private static SimpleDateFormat __DATE_FORMAT
-
_etoileDieseBulkWSUrl
private String _etoileDieseBulkWSUrl
Url of Etoile diese's send sms web service in bulk mode (the recipients are listed in a CSV file)
-
_userManager
private UserManager _userManager
The users manager
-
-
Constructor Detail
-
EtoileDieseBroker
public EtoileDieseBroker()
-
-
Method Detail
-
configure
public void configure(Configuration configuration) throws ConfigurationException
- Specified by:
configure
in interfaceConfigurable
- Throws:
ConfigurationException
-
contextualize
public void contextualize(Context context) throws ContextException
- Specified by:
contextualize
in interfaceContextualizable
- Throws:
ContextException
-
service
public void service(ServiceManager manager) throws ServiceException
- Specified by:
service
in interfaceServiceable
- Overrides:
service
in classLoggerBroker
- Throws:
ServiceException
-
send
public void send(Set<String> phoneNumbersList, String message, String listId) throws Exception
Description copied from interface:Broker
Send the message from the sender to all the phones in the list- Specified by:
send
in interfaceBroker
- Overrides:
send
in classLoggerBroker
- Parameters:
phoneNumbersList
- the list of phone numbersmessage
- the message to sendlistId
- the jcr id of the list to send mail to- Throws:
Exception
- If the message was not sent correctly
-
getPhoneNumberFromStopRequest
public String getPhoneNumberFromStopRequest() throws Exception
Description copied from interface:Broker
When a stop request is arriving from broker, the implementation extract the phone number associated- Specified by:
getPhoneNumberFromStopRequest
in interfaceBroker
- Overrides:
getPhoneNumberFromStopRequest
in classLoggerBroker
- Returns:
- the phone number from the 'stop' sender at format +{countryCode}{number} (ex: +33612345678), it can be null if the phone number cannot be extracted from the stop request
- Throws:
Exception
- if the phone number was not provided within the stop request
-
_getCSVFile
private InputStream _getCSVFile(Set<String> phoneNumbersList, String message) throws IOException
Creates and return a CSV file from a list of numbers and a message- Parameters:
phoneNumbersList
- the list of phone numbers to send a SMS tomessage
- the message to send- Returns:
- the csv file
- Throws:
IOException
- if an error occurs while converting the list of phone numbers to an input stream
-
-