Examples of NotifierConfig


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

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

    }
  }

  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

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

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

Examples of com.agiletec.plugins.jpcontentworkflow.aps.system.services.notifier.model.NotifierConfig

  }
 
  public void testSetNotifierConfig() throws Throwable {
    WorkflowNotifierDOM configDOM = new WorkflowNotifierDOM();
   
    NotifierConfig newConfig = this.prepareNotifierConfig();
    String xml = configDOM.createConfigXml(newConfig);
   
    NotifierConfig extractedConfig = configDOM.extractConfig(xml);
    this.compareNotifiers(newConfig, extractedConfig);
  }
View Full Code Here

Examples of com.agiletec.plugins.jpcontentworkflow.aps.system.services.notifier.model.NotifierConfig

    NotifierConfig extractedConfig = configDOM.extractConfig(xml);
    this.compareNotifiers(newConfig, extractedConfig);
  }
 
  private NotifierConfig prepareNotifierConfig() {
    NotifierConfig notifierConfig = new NotifierConfig();
   
    notifierConfig.setActive(true);
    notifierConfig.setHoursDelay(23);
    notifierConfig.setStartScheduler(new Date());
   
    notifierConfig.setSenderCode("CODE2");
    //notifierConfig.setMailAttrName("eMail");
    notifierConfig.setHtml(true);
    notifierConfig.setSubject("Oggetto");
    notifierConfig.setHeader("header");
    notifierConfig.setTemplate("template");
    notifierConfig.setFooter("footer");
   
    return notifierConfig;
  }
View Full Code Here

Examples of com.agiletec.plugins.jpcontentworkflow.aps.system.services.notifier.model.NotifierConfig

    assertEquals("userNotAllowed", result);
   
    result = this.executeConfig("admin");
    assertEquals(Action.SUCCESS, result);
    WorkflowNotifierConfigAction action = (WorkflowNotifierConfigAction) this.getAction();
    NotifierConfig config = action.getConfig();
    assertFalse(config.isActive());
    assertEquals(24, config.getHoursDelay());
    assertEquals("CODE1", config.getSenderCode());
    //assertEquals("email", config.getMailAttrName());
    assertEquals("04/12/2008", action.getStartDate());
    assertEquals(16, action.getHour());
    assertEquals(8, action.getMinute());
   
    assertFalse(config.isHtml());
                assertEquals("[My Own Portal]: A content changed", config.getSubject());
                assertEquals("Hi {user},<br />these contents require your attention<br /><br />", config.getHeader());
                assertEquals("<br />Content {type} - {descr} - Status {status}<br />", config.getTemplate());
                assertEquals("<br />End (footer)", config.getFooter());
  }
View Full Code Here

Examples of com.agiletec.plugins.jpcontentworkflow.aps.system.services.notifier.model.NotifierConfig

      params.put("config.template", "template");
      params.put("config.footer", "footer");
     
      String result = this.executeSave("admin", params);
      assertEquals(Action.SUCCESS, result);
      NotifierConfig updatedNotifierConfig = this._notifierManager.getNotifierConfig();
     
      assertTrue(updatedNotifierConfig.isActive());
      assertEquals(10, updatedNotifierConfig.getHoursDelay());
      String startDate = DateFormatter.format(updatedNotifierConfig.getStartScheduler());
      assertEquals("19/11/2009 20:40", startDate);
      assertEquals("CODE1", updatedNotifierConfig.getSenderCode());
      //assertEquals("email", updatedNotifierConfig.getMailAttrName());
      assertTrue(updatedNotifierConfig.isHtml());
      assertEquals("subject", updatedNotifierConfig.getSubject());
      assertEquals("header", updatedNotifierConfig.getHeader());
      assertEquals("template", updatedNotifierConfig.getTemplate());
      assertEquals("footer", updatedNotifierConfig.getFooter());
    } catch(Throwable t) {
      throw t;
    } finally {
      this._configManager.updateConfigItem(JpcontentworkflowSystemConstants.WORKFLOW_NOTIFIER_CONFIG_ITEM, config);
    }
View Full Code Here

Examples of com.agiletec.plugins.jpcontentworkflow.aps.system.services.notifier.model.NotifierConfig

    this.activeMailManager(true);
    super.tearDown();
  }
 
  public void testGetNotifierConfig() throws Throwable {
    NotifierConfig notifierConfig = this._notifierManager.getNotifierConfig();
    assertFalse(notifierConfig.isActive());
    assertEquals(24, notifierConfig.getHoursDelay());
    assertEquals("CODE1", notifierConfig.getSenderCode());
    //assertEquals("email", notifierConfig.getMailAttrName());
    assertFalse(notifierConfig.isHtml());
    assertEquals("[My Own Portal]: A content changed", notifierConfig.getSubject());
    assertEquals("Hi {user},<br />these contents require your attention<br /><br />", notifierConfig.getHeader());
    assertEquals("<br />Content {type} - {descr} - Status {status}<br />", notifierConfig.getTemplate());
    assertEquals("<br />End (footer)", notifierConfig.getFooter());
  }
View Full Code Here

Examples of com.agiletec.plugins.jpcontentworkflow.aps.system.services.notifier.model.NotifierConfig

    assertEquals("<br />End (footer)", notifierConfig.getFooter());
  }
 
  public void testSetNotifierConfig() throws Throwable {
    String config = this._configManager.getConfigItem(JpcontentworkflowSystemConstants.WORKFLOW_NOTIFIER_CONFIG_ITEM);
    NotifierConfig originaryNotifierConfig = this._notifierManager.getNotifierConfig();
    NotifierConfig newNotifierConfig = this.prepareNotifierConfig();
    try {
      this._notifierManager.saveNotifierConfig(newNotifierConfig);
      NotifierConfig updatedNotifierConfig = this._notifierManager.getNotifierConfig();
      this.compareNotifiers(newNotifierConfig, updatedNotifierConfig);
     
      this._notifierManager.saveNotifierConfig(originaryNotifierConfig);
      updatedNotifierConfig = this._notifierManager.getNotifierConfig();
      this.compareNotifiers(originaryNotifierConfig, updatedNotifierConfig);
View Full Code Here

Examples of com.agiletec.plugins.jpcontentworkflow.aps.system.services.notifier.model.NotifierConfig

    }
  }
 
  public void testSendEMails() throws Throwable {
    String config = this._configManager.getConfigItem(JpcontentworkflowSystemConstants.WORKFLOW_NOTIFIER_CONFIG_ITEM);
    NotifierConfig notifierConfig = this._notifierManager.getNotifierConfig();
    try {
      this.addContentStatusChangedEvent("ART1", Content.STATUS_READY);
      this.addContentStatusChangedEvent("ART180", Content.STATUS_DRAFT);
      this.addContentStatusChangedEvent("EVN41", Content.STATUS_READY);
      assertEquals(0, this._helper.getEventsToNotify().size());
      assertEquals(0, this._helper.getNotifiedEvents().size());
     
      notifierConfig.setActive(true);
      this._notifierManager.saveNotifierConfig(notifierConfig);
     
      this.addContentStatusChangedEvent("ART1", Content.STATUS_DRAFT);
      this.addContentStatusChangedEvent("ART180", Content.STATUS_READY);
      this.addContentStatusChangedEvent("EVN41", Content.STATUS_DRAFT);
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. 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.