Package com.agiletec.plugins.jpcontentworkflow.aps.system.services.notifier.model

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


    }
    return SUCCESS;
  }
 
  protected NotifierConfig getUpdatedConfig() throws ApsSystemException, ParseException {
    NotifierConfig notifierConfig = this.getConfig();
   
    Date startDate = DateConverter.parseDate(this.getStartDate(), DATE_FORMAT);
    long time = startDate.getTime() + this.getHour()*3600000l + this.getMinute()*60000l;
    startDate.setTime(time);
    notifierConfig.setStartScheduler(startDate);
   
    return notifierConfig;
  }
View Full Code Here


* @author E.Mezzano
*/
public class WorkflowNotifierDOM {
 
  public NotifierConfig extractConfig(String xml) throws ApsSystemException {
    NotifierConfig notifierConfig = new NotifierConfig();
    Element root = this.getRootElement(xml);
    Element schedulerElement = root.getChild(SCHEDULER_CHILD);
    this.extractSchedulerConfig(notifierConfig, schedulerElement);
    Element mailElement = root.getChild(MAIL_CHILD);
    this.extractMailConfig(notifierConfig, mailElement);
View Full Code Here

  }
 
  public void testExtractConfig() throws Throwable {
    WorkflowNotifierDOM configDOM = new WorkflowNotifierDOM();
    String xml = this._configManager.getConfigItem(JpcontentworkflowSystemConstants.WORKFLOW_NOTIFIER_CONFIG_ITEM);
    NotifierConfig notifierConfig = configDOM.extractConfig(xml);
    assertFalse(notifierConfig.isActive());
    assertEquals(24, notifierConfig.getHoursDelay());
    assertTrue(notifierConfig.getStartScheduler().getTime()<(new Date()).getTime());
    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

   * Apre lo scheduler istanziando il task relativo
   * alla spedizione degli sms con i rilevamenti meteo.
   */
  protected void openScheduler() {
    this.closeScheduler();
    NotifierConfig notifierConfig = this.getWorkflowNotifierConfig();
    if (notifierConfig.isActive()) {
      long milliSecondsDelay = notifierConfig.getHoursDelay() * 3600000l; // x minuti secondi millisecondi
      Date startTime = notifierConfig.getStartScheduler();

      startTime = this.calculateStartTime(startTime, milliSecondsDelay);
      Task task = new MailSenderTask(this);
      this._mailSenderScheduler = new Scheduler(task, startTime, milliSecondsDelay);
    }
View Full Code Here

    }
  }

  protected void sendMail(String username, List<ContentStatusChangedEventInfo> contentInfos) {
    try {
      NotifierConfig notifierConfig = this.getWorkflowNotifierConfig();
      String mailAddress = this.getMailAddress(username);
      if (null == mailAddress) {
        return;
      }
      String[] mailAddresses = {mailAddress};
      Map<String, String> params = this.prepareParams(username);
      String subject = this.replaceParams(notifierConfig.getSubject(), params);
      String text = this.prepareMailText(params, contentInfos);
      String senderCode = notifierConfig.getSenderCode();
      String contentType = (notifierConfig.isHtml()) ? IMailManager.CONTENTTYPE_TEXT_HTML : IMailManager.CONTENTTYPE_TEXT_PLAIN;
      this.getMailManager().sendMail(text, subject, mailAddresses, null, null, senderCode, contentType);
    } catch(Throwable t) {
      ApsSystemUtils.logThrowable(t, this, "sendMail", "Error sending mail to user " + username);
    }
  }
View Full Code Here

    params.put("status", contentInfo.getStatus());
    params.put("data", DateConverter.getFormattedDate(contentInfo.getDate(), "dd MMMM yyyy"));
  }

  protected String prepareMailText(Map<String, String> params, List<ContentStatusChangedEventInfo> contentInfos) {
    NotifierConfig notifierConfig = this.getWorkflowNotifierConfig();
    String header = this.replaceParams(notifierConfig.getHeader(), params);
    String footer = this.replaceParams(notifierConfig.getFooter(), params);
    String body = notifierConfig.getTemplate();
    StringBuilder text = new StringBuilder(header);
    for (ContentStatusChangedEventInfo contentInfo : contentInfos) {
      this.addContentParams(params, contentInfo);
      text.append(this.replaceParams(body, params));
    }
View Full Code Here

TOP

Related Classes of com.agiletec.plugins.jpcontentworkflow.aps.system.services.notifier.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.