Subversion Repositories bacoAlunos

Rev

Rev 1306 | Go to most recent revision | Blame | Compare with Previous | Last modification | View Log | RSS feed

package pt.estgp.estgweb.services.sms;

import pt.estgp.estgweb.domain.dao.DaoFactory;
import pt.utl.ist.berserk.logic.serviceManager.IService;
import pt.estgp.estgweb.services.expceptions.ServiceException;
import pt.estgp.estgweb.Globals;
import pt.ipportalegre.siges.web.services.SiGesWEB;
import org.apache.log4j.Logger;

import javax.xml.namespace.QName;
import java.util.*;
import java.net.URL;
import java.net.MalformedURLException;

/**
 * @author Jorge Machado
 */

public class SmsService implements IService
{
    private static final 1.5.0/docs/api/java/util/logging/Logger.html">Logger logger = 1.5.0/docs/api/java/util/logging/Logger.html">Logger.getLogger(SmsService.class);

    public void run(1.5.0/docs/api/java/lang/String.html">String message, 1.5.0/docs/api/java/lang/String.html">String phones) throws ServiceException
    {
        if(Globals.MODULE_STATUS_SMS)
        {
            logger.info("start sending sms send");
            try
            {
                SiGesWEB service;
                1.5.0/docs/api/java/lang/String.html">String WSDL = DaoFactory.getConfigurationDaoImpl().getSigesWebServicesWsdl();
                try
                {
                    service = new SiGesWEB(new 1.5.0/docs/api/java/net/URL.html">URL(WSDL), new 1.5.0/docs/api/javax/xml/namespace/QName.html">QName(Globals.SIGES_WEBSERVICE_TARGET_NAMESPACE, "SiGesWEB"));
                }
                catch (1.5.0/docs/api/java/net/MalformedURLException.html">MalformedURLException e)
                {
                    logger.fatal(e, e);
                    return;
                }
//                ArrayOfString phonesArray = new ArrayOfString();
//                for(String phone: phones)
//                {
//                    phonesArray.getString().add(phone);
//                }
                service.getSiGesWEBSoap().sendSmsSeparatedWithComma(message,phones,Globals.SIGES_WEBSERVICE_SECRET);
            }
            catch (1.5.0/docs/api/java/lang/Throwable.html">Throwable e)
            {
                logger.error(e,e);
            }
            logger.info("terminating sms send");
        }
        else
        {
            logger.info("SMS module turned off");
        }
    }


    public static void main(1.5.0/docs/api/java/lang/String.html">String[] args) throws ServiceException
    {
//        AbstractDao.getCurrentSession().beginTransaction();
        List<String> phones = new ArrayList<String>();
        phones.add("916252810");
        phones.add("916252810");

        new SmsService().run("Teste Final","916252810,916252810");
//        AbstractDao.getCurrentSession().getTransaction().commit();
    }


}