Package com.agiletec.plugins.jpnewsletter.aps.system.services.newsletter.model

Examples of com.agiletec.plugins.jpnewsletter.aps.system.services.newsletter.model.Subscriber


  public void testAddSubscription() throws Throwable {
    String mail = "inesistente@inesistente.in";
    try {
      String result = this.executeAdd(mail);
      assertEquals(Action.SUCCESS, result);
      Subscriber subscriber = this._newsletterManager.loadSubscriber(mail);
      assertEquals(mail, subscriber.getMailAddress());
      assertFalse(subscriber.isActive());
      assertNotNull(this._helper.getToken(mail));
    } catch (Throwable t) {
      throw t;
    } finally {
      this._helper.cleanAddresses();
View Full Code Here


  @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) {
View Full Code Here

  }
 
  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;
    }
View Full Code Here

 
  @Override
  public String deleteSubscription() {
    try {
      INewsletterManager newsletterManager = this.getNewsletterManager();
      Subscriber subscriber = newsletterManager.loadSubscriber(this.getMailAddress());
      if (null != subscriber) {
        newsletterManager.deleteSubscriber(this.getMailAddress());
      } else {
        String[] args = {this.getMailAddress()};
        this.addActionError(this.getText("jpnewsletter.messsage.emailNotPresent", args));
View Full Code Here

    try {
      conn = this.getConnection();
      stat = conn.prepareStatement(LOAD_SUBSCRIBERS);
      res = stat.executeQuery();
      while(res.next()){
        Subscriber subscriber = this.loadSubscriberFromResulSet(res);
        subscribers.add(subscriber);
      }
    } catch (Throwable t) {
      this.processDaoException(t, "Errore durante il caricamento della lista degli indirizzi e-mail", "loadSubscribers");
    } finally {
View Full Code Here

    if (null != mailAddress && mailAddress.trim().length() > 0) {
      mailAddress = mailAddress.trim().toLowerCase();
      while (res.next()) {
        String id = res.getString("mailaddress");
        if (id.toLowerCase().indexOf(mailAddress) != -1) {
          Subscriber subscriber = this.loadSubscriberFromResulSet(res);
          subscribers.add(subscriber);
        }
      }
    } else {
      while (res.next()) {
        Subscriber subscriber = this.loadSubscriberFromResulSet(res);
        subscribers.add(subscriber);
      }
    }
  }
View Full Code Here

    return hasAppendWhereClause;
  }
 
  @Override
  public Subscriber loadSubscriber(String mailAddress) throws ApsSystemException {
    Subscriber subscriber = null;
    Connection connection = null;
    PreparedStatement statement = null;
    ResultSet res = null;
    try {
      connection = this.getConnection();
View Full Code Here

    }
    return subscriber;
  }
 
  private Subscriber loadSubscriberFromResulSet(ResultSet res) throws SQLException {
    Subscriber subscriber = new Subscriber();
    String mailAddress = res.getString("mailaddress");
    Date subscriptionDate = res.getDate("subscription_date");
    subscriber.setMailAddress(mailAddress);
    subscriber.setSubscriptionDate(subscriptionDate);
    int active = res.getInt("active");
    subscriber.setActive(active==1);
    return subscriber;
  }
View Full Code Here

 
  @Override
  public Subscriber loadSubscriber(String mailAddress) throws ApsSystemException {
    try {
      this.cleanOldSubscribers();
      Subscriber subscriber = this.getNewsletterDAO().loadSubscriber(mailAddress);
      return subscriber;
    } catch (Throwable t) {
      ApsSystemUtils.logThrowable(t, this, "loadSubscriber");
      throw new ApsSystemException("Errore caricamento di un sottoscrizioni " + mailAddress, t);
    }
View Full Code Here

  }
 
  @Override
  public void addSubscriber(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().addSubscriber(subscriber, token);
      this.sendSubscriptionMail(mailAddress, token);
    } catch (Throwable t) {
      ApsSystemUtils.logThrowable(t, this, "addSubscriber");
View Full Code Here

TOP

Related Classes of com.agiletec.plugins.jpnewsletter.aps.system.services.newsletter.model.Subscriber

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.