private void sendContentsToSubscribers(List<Content> contents, NewsletterReport newsletterReport)
     throws ApsSystemException {
   List<Subscriber> subscribers = this.searchSubscribers(null, new Boolean(true));
   NewsletterConfig config = this.getConfig();
   for (Subscriber subscriber : subscribers) {
     String mailAddress = subscriber.getMailAddress();
     String[] emailAddresses = {mailAddress};
     String simpleText =
         this.prepareSubscribersMailBody(contents, newsletterReport, false, mailAddress);
     if (config.isAlsoHtml()) {
       String htmlText =
           this.prepareSubscribersMailBody(contents, newsletterReport, true, mailAddress);
       this.getMailManager()
           .sendMixedMail(
               simpleText,
               htmlText,
               config.getSubject(),
               null,
               null,
               null,
               emailAddresses,
               config.getSenderCode());
     } else {
       this.getMailManager()
           .sendMail(
               simpleText,
               config.getSubject(),
               null,
               null,
               emailAddresses,
               config.getSenderCode());
     }
   }
 }
 public Boolean isDuplicated(String mailAddress) throws Throwable {
   Boolean isDuplicated = true;
   try {
     Subscriber duplicated = this.getNewsletterManager().loadSubscriber(mailAddress);
     if (duplicated == null || !duplicated.isActive()) {
       isDuplicated = false;
     }
   } catch (Throwable t) {
     throw t;
   }
   return isDuplicated;
 }
 @Override
 public void resetSubscriber(String mailAddress) throws ApsSystemException {
   try {
     Subscriber subscriber = new Subscriber();
     subscriber.setMailAddress(mailAddress);
     subscriber.setSubscriptionDate(new Date());
     subscriber.setActive(false);
     String token = this.createToken(mailAddress);
     this.getNewsletterDAO().updateSubscriber(subscriber, token);
     this.sendSubscriptionMail(mailAddress, token);
   } catch (Throwable t) {
     ApsSystemUtils.logThrowable(t, this, "resetSubscriber");
     throw new ApsSystemException("Errore in reset sottoscrizione", t);
   }
 }
 @Override
 public String addSubscription() {
   try {
     String mailAddress = this.getMailAddress();
     INewsletterManager newsletterManager = this.getNewsletterManager();
     Subscriber subscriber = newsletterManager.loadSubscriber(mailAddress);
     if (subscriber == null) {
       newsletterManager.addSubscriber(mailAddress);
     } else if (!subscriber.isActive()) {
       newsletterManager.resetSubscriber(mailAddress);
     } else {
       return INPUT;
     }
   } catch (Throwable t) {
     ApsSystemUtils.logThrowable(
         t, this, "addSubscription", "Errore durante l'aggiunta di una sottoscrizione");
     return FAILURE;
   }
   return SUCCESS;
 }