Package com.agiletec.plugins.jpcontentnotifier.aps.system.services.contentnotifier.model

Examples of com.agiletec.plugins.jpcontentnotifier.aps.system.services.contentnotifier.model.NotifierConfig


    return allowedUsers;
  }

  protected boolean sendEMailToUser(UserDetails user, List<ContentMailInfo> contentsToNotify, Map<String, SmallContentType> smallContentTypes) throws ApsSystemException {
    boolean sent = false;
    NotifierConfig config = this.getConfig();
    IUserProfile profile = (IUserProfile) user.getProfile();
    if (profile!=null) {
      String emailAttributeName = config.getMailAttrName();
      Object eMailValue = profile.getValue(emailAttributeName);
      String eMail = eMailValue!=null ? eMailValue.toString() : null;
      if (eMail != null && eMail.length() > 0) {
        List<ContentMailInfo> contentsToNotifyToUser = this.getContentsToNotifyToUser(user, contentsToNotify);
        if (!contentsToNotifyToUser.isEmpty()) {
          String[] eMailAddresses = {eMail};
          String mailBody = this.createBody(user, contentsToNotifyToUser, smallContentTypes);
          String contentType = config.isHtml() ? IMailManager.CONTENTTYPE_TEXT_HTML : IMailManager.CONTENTTYPE_TEXT_PLAIN;
          sent = this.getMailManager().sendMail(mailBody, config.getSubject(),
              eMailAddresses, null, null, config.getSenderCode(), contentType);
        }
      }
    }
    return sent;
  }
View Full Code Here


    }
  }

  private String createBody(UserDetails user, List<ContentMailInfo> contentsToNotifyToUser, Map<String, SmallContentType> smallContentTypes) {
    String defaultLangCode = this.getLangManager().getDefaultLang().getCode();
    NotifierConfig config = this.getConfig();
    StringBuffer body = new StringBuffer(config.getHeader());
    for (ContentMailInfo info : contentsToNotifyToUser) {
      SmallContentType smallContentType = (SmallContentType) smallContentTypes.get(info.getContentTypeCode());
      String link = this.createLink(info, defaultLangCode);

      Map<String, String> params = this.prepareContentParams(info, smallContentType, link);
      switch (info.getOperationCode()) {
      case PublicContentChangedEvent.INSERT_OPERATION_CODE:
        body.append(this.replaceParams(config.getTemplateInsert(), params));
        break;
      case PublicContentChangedEvent.UPDATE_OPERATION_CODE:
        body.append(this.replaceParams(config.getTemplateUpdate(), params));
        break;
      case PublicContentChangedEvent.REMOVE_OPERATION_CODE:
        body.append(this.replaceParams(config.getTemplateRemove(), params));
        break;
      }
    }
    body.append(config.getFooter());
    return body.toString();
  }
View Full Code Here

import com.agiletec.plugins.jpcontentnotifier.aps.system.services.contentnotifier.scheduler.Task;

public class MockContentNotifierManager extends ContentNotifierManager {
 
  protected void openScheduler() {
    NotifierConfig schedulerConfig = this.getConfig();
    if (schedulerConfig.isActive()) {
      long milliSecondsDelay = schedulerConfig.getHoursDelay() * 60 * 60 * 1000;
      Task task = new MailSenderTask(this);
      _mailSenderScheduler = new Scheduler(task, new Date(), milliSecondsDelay);
    }
  }
View Full Code Here

TOP

Related Classes of com.agiletec.plugins.jpcontentnotifier.aps.system.services.contentnotifier.model.NotifierConfig

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.