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

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


    this.init();
    this.activeMailManager(false);
  }
 
  public void testGetConfig() {
    NotifierConfig expectedConfig = new NotifierConfig();
    expectedConfig.setActive(true);
    expectedConfig.setHoursDelay(24);
    expectedConfig.setOnlyOwner(true);
    expectedConfig.setStartScheduler(DateConverter.parseDate("03/04/2009 18:25", "dd/MM/yyyy HH:mm"));
   
    expectedConfig.setSenderCode("CODE1");
    expectedConfig.setMailAttrName("email");
    expectedConfig.setHtml(true);
    expectedConfig.setSubject("Oggetto della mail di notifica");
    expectedConfig.setHeader("Inizio Mail (testata)<br/>");
    expectedConfig.setTemplateInsert("<br />Contenuto tipo {type} - {descr} <br /> Data Operazione {date} {time} <br /> {link} <br />");
    expectedConfig.setTemplateUpdate("<br />Aggiornamento Contenuto tipo {type} - {descr} <br /> Data Operazione {date} {time} <br /> {link} <br />");
    expectedConfig.setTemplateRemove("<br />Rimozione Contenuto tipo {type} - {descr} <br /> Data Operazione {date} {time} <br />");
    expectedConfig.setFooter("<br />Fine Mail (footer)");
   
    this.compareConfigs(expectedConfig,
        this._notifierManager.getConfig());
  }
View Full Code Here


    this.compareConfigs(expectedConfig,
        this._notifierManager.getConfig());
  }
 
  public void testUpdateNotifierConfig() throws Throwable {
    NotifierConfig oldConfig = this._notifierManager.getConfig();
    try {
      NotifierConfig newConfig = this.createConfig(true, 12, false, DateConverter.parseDate("120120101002", "ddMMyyHHmm"),
          "CODE2", "eMail", false, "Oggetto", "header", "templateInsert", "templateUpdate", "templateRemove", "footer");
      this._notifierManager.updateNotifierConfig(newConfig);
      this.compareConfigs(newConfig, this._notifierManager.getConfig());
    } catch (Throwable t) {
      throw t;
View Full Code Here

  }
 
  private NotifierConfig createConfig(boolean active, int hoursDelay, boolean onlyOwner, Date startScheduler,
      String senderCode,String mailAttrName, boolean html, String subject, String header,
      String templateInsert, String templateUpdate, String templateRemove, String footer) {
    NotifierConfig config = new NotifierConfig();
    config.setActive(active);
    config.setHoursDelay(hoursDelay);
    config.setOnlyOwner(onlyOwner);
    config.setStartScheduler(startScheduler);
   
    config.setSenderCode(senderCode);
    config.setMailAttrName(mailAttrName);
    config.setHtml(html);
    config.setSubject(subject);
    config.setHeader(header);
    config.setTemplateInsert(templateInsert);
    config.setTemplateUpdate(templateUpdate);
    if (templateRemove != null) {
      config.setTemplateRemove(templateRemove);
    }
    config.setFooter(footer);
    return config;
  }
View Full Code Here

    try {
      String result = this.executeSave("admin", false, 10l, false, 10, 3, 2009, 21, 45, "CODE2", "eMail", true, "subject", "header",
          "templateInsert", "templateUpdate", "", true, "footer");
      assertEquals(Action.SUCCESS, result);
     
      NotifierConfig config = this._notifierManager.getConfig();
     
      assertEquals(false, config.isActive());
      assertEquals("10/04/2009 21:45", DateConverter.getFormattedDate(config.getStartScheduler(), "dd/MM/yyyy HH:mm"));
      assertEquals(10, config.getHoursDelay());
      assertEquals(false, config.isOnlyOwner());
     
      assertEquals("CODE2", config.getSenderCode());
      assertEquals("eMail", config.getMailAttrName());
      assertEquals(true, config.isHtml());
      assertEquals("subject", config.getSubject());
      assertEquals("header", config.getHeader());
      assertEquals("templateInsert", config.getTemplateInsert());
      assertEquals("templateUpdate", config.getTemplateUpdate());
      assertEquals("", config.getTemplateRemove());
      assertEquals(false, config.isNotifyRemove());
      assertEquals("footer", config.getFooter());
    } catch(Throwable t) {
      throw t;
    } finally {
      this._configManager.updateConfigItem(JpcontentnotifierSystemConstants.CONTENT_NOTIFIER_CONFIG_ITEM, notifierConfig);
    }
View Full Code Here

   * @param xml The xml containing the configuration.
   * @return The newsletter configuration.
   * @throws ApsSystemException In case of parsing errors.
   */
  public NotifierConfig extractConfig(String xml) throws ApsSystemException {
    NotifierConfig config = new NotifierConfig();
    Element root = this.getRootElement(xml);
    this.extractScheduler(root, config);
    this.extractMailConfig(root, config);
    return config;
  }
View Full Code Here

  }
 
  @Override
  public String save() {
    try {
      NotifierConfig config = this.prepareConfig();
      this.getContentNotifierManager().updateNotifierConfig(config);
    } catch (Throwable t) {
      ApsSystemUtils.logThrowable(t, this, "save");
      return FAILURE;
    }
View Full Code Here

    }
    return Action.SUCCESS;
  }
 
  protected NotifierConfig prepareConfig() {
    NotifierConfig config = new NotifierConfig();
    config.setActive(this.isActive());
    config.setHoursDelay(this.getHoursDelay());
    config.setOnlyOwner(this.isOnlyOwner());
   
    Calendar start = Calendar.getInstance();
    start.set(Calendar.MONTH, this.getMonth());
    start.set(Calendar.YEAR, this.getYear());
    if (this.getDay() <= start.getActualMaximum(Calendar.DAY_OF_MONTH)) {
      start.set(Calendar.DAY_OF_MONTH, this.getDay());
    } else {
      start.set(Calendar.DAY_OF_MONTH, start.getActualMaximum(Calendar.DAY_OF_MONTH));
    }
    start.set(Calendar.HOUR_OF_DAY, this.getHour());
    start.set(Calendar.MINUTE, this.getMinute());
    config.setStartScheduler(start.getTime());
   
    config.setSenderCode(this.getSenderCode());
    config.setMailAttrName(this.getMailAttrName());
    config.setHtml(this.isHtml());
    config.setSubject(this.getSubject());
    config.setHeader(this.getHeader());
    config.setTemplateInsert(this.getTemplateInsert().trim());
    config.setTemplateUpdate(this.getTemplateUpdate().trim());
    String templateRemove = this.getTemplateRemove();
    config.setTemplateRemove(templateRemove);
    config.setFooter(this.getFooter().trim());
   
    return config;
  }
View Full Code Here

  }
 
  protected void initConfig() {
    IContentNotifierManager notifierManager = this.getContentNotifierManager();
   
    NotifierConfig config = notifierManager.getConfig();
   
    this.setActive(config.isActive());
    this.setHoursDelay(config.getHoursDelay());
    this.setOnlyOwner(config.isOnlyOwner());
   
    Calendar start = Calendar.getInstance();
    start.setTime(config.getStartScheduler());
    this.setDay(start.get(Calendar.DAY_OF_MONTH));
    this.setMonth(start.get(Calendar.MONTH));
    this.setYear(start.get(Calendar.YEAR));
    this.setHour(start.get(Calendar.HOUR_OF_DAY));
    this.setMinute(start.get(Calendar.MINUTE));
   
    this.setSenderCode(config.getSenderCode());
    this.setMailAttrName(config.getMailAttrName());
    this.setHtml(config.isHtml());
    this.setSubject(config.getSubject());
    this.setHeader(config.getHeader());
    this.setTemplateInsert(config.getTemplateInsert());
    this.setTemplateUpdate(config.getTemplateUpdate());
    String templateRemove = config.getTemplateRemove();
    this.setTemplateRemove(templateRemove);
    this.setNotifyRemove(config.isNotifyRemove());
    this.setFooter(config.getFooter());
  }
View Full Code Here

    this.closeScheduler();
  }

  @Override
  public void updateFromPublicContentChanged(PublicContentChangedEvent event) {
    NotifierConfig config = this.getConfig();
    if (config.isActive()) {
      if ((config.isNotifyRemove() || PublicContentChangedEvent.REMOVE_OPERATION_CODE!=event.getOperationCode())) {
        try {
          this.getContentNotifierDao().saveEvent(event);
          ApsSystemUtils.getLogger().trace("Traced operation " + event.getOperationCode() + " on Content " + event.getContent().getId());
        } catch (ApsSystemException e) {
          ApsSystemUtils.logThrowable(e, this, "updateFromPublicContentChanged");
View Full Code Here

   * Apre lo scheduler istanziando il task relativo
   * alla spedizione degli sms con i rilevamenti meteo.
   */
  protected void openScheduler() {
    this.closeScheduler();
    NotifierConfig config = this.getConfig();
    if (config.isActive()) {
      Date startTime = config.getStartScheduler();
      long milliSecondsDelay = config.getHoursDelay() * 3600000l; // x minuti secondi millisecondi
      startTime = this.calculateStartTime(startTime, milliSecondsDelay);
      Task task = new MailSenderTask(this);
      this._mailSenderScheduler = new Scheduler(task, startTime, 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.