public UnitEmails createEmail(final UnitEmails unitEmails) throws EnMeExpcetion{
if(unitEmails!= null){
try {//
final EmailList emailList = new EmailList();
final String codeSubscribe = MD5Utils.md5(String.valueOf(System.currentTimeMillis()));
final Email emailsDomain = new Email();
emailsDomain.setEmail(unitEmails.getEmailName());
emailsDomain.setSubscribed(Boolean.FALSE); //By Default is FALSE, user need subscribe.
emailsDomain.setIdListEmail(emailList);
getEmailListsDao().saveOrUpdate(emailsDomain);
unitEmails.setIdEmail(emailsDomain.getIdEmail());
//TODO: Necesitamos crear el registro con el hash !!
final EmailSubscribe subscribe = new EmailSubscribe();
subscribe.setEmail(emailsDomain);
subscribe.setList(emailList);
subscribe.setHashCode(codeSubscribe);
getEmailListsDao().saveOrUpdate(subscribe);
if (EnMePlaceHolderConfigurer.getBooleanProperty("application.email.enabled")) {
getMailService().send(emailsDomain.getEmail(),"Invitation to Subscribe Encuestame List","Invitation to Subscribe");
}
//TODO:Enviamos correo al usuario para que confirme su subscripcion.
}
catch (Exception e) {
throw new EnMeExpcetion(e);