1 5 package org.exoplatform.services.communication.sms.impl; 6 7 import org.exoplatform.services.communication.sms.SmsService; 8 import org.exoplatform.services.communication.sms.common.*; 9 import org.exoplatform.services.communication.sms.model.*; 10 import org.exoplatform.services.communication.sms.provider.*; 11 import org.exoplatform.services.communication.sms.provider.SenderImpl; 12 import org.exoplatform.services.communication.sms.provider.prodat.ProdatProviderImpl; 13 14 19 public class SmsServiceImpl implements SmsService { 20 21 public SmsServiceImpl() { 22 } 23 24 28 public Provider createProdatProvider(String username, String password) { 29 Provider provider = new ProdatProviderImpl(); 30 provider.getOperator().setUsername(username); 31 provider.getOperator().setPassword(password); 32 return provider; 33 } 34 35 38 public Messages createMessages() { 39 return new MessagesImpl(); 40 } 41 42 45 public Message createMessage() { 46 return new MessageImpl(); 47 } 48 49 52 public Recipient createRecipient(String to) { 53 return new RecipientImpl(to); 54 } 55 56 59 public Sender createSender(Provider provider) { 60 Sender sender = new SenderImpl(provider); 61 return sender; 62 } 63 64 68 public boolean sendSms(Provider provider, Messages messages) throws CommunicationError, RequestException, ResponseException, ConvertException { 69 Sender sender = new SenderImpl(provider); 70 sender.prepare(messages); 71 sender.send(); 72 return messages.hasErrorOccured(); 73 } 74 75 } | Popular Tags |