Examples of NewsletterConfig


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

    }
  }
 
  @Override
  public void startScheduler() throws ApsSystemException {
    NewsletterConfig config = this.getConfig();
    Date start = config.getNextTaskTime();
    this._scheduler = new Scheduler(this, start, config.getHoursDelay());
  }
View Full Code Here

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

 
  @Override
  public String buildMailBody(Content content, boolean html) throws ApsSystemException {
    String mailBody = null;
    try {
      NewsletterConfig config = this.getConfig();
      NewsletterContentType contentType = config.getContentType(content.getTypeCode());
      int modelId = html ? contentType.getHtmlModel() : contentType.getSimpleTextModel();
      mailBody = this.buildMailBody(content, modelId, html);
    } catch (Throwable t) {
      ApsSystemUtils.logThrowable(t, this, "buildMailBody");
      throw new ApsSystemException("Errore in generazione body contenuto " + content.getId(), t);
View Full Code Here

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

    }
    return profileAttributes;
  }
 
  protected NewsletterReport prepareNewsletterReport(List<Content> contents) {
    NewsletterConfig config = this.getConfig();
    NewsletterReport newsletterReport = new NewsletterReport();
    newsletterReport.setSubject(config.getSubject());
    newsletterReport.setSendDate(new Date());
    String defaultLang = this.getLangManager().getDefaultLang().getCode();
    boolean alsoHtml = config.isAlsoHtml();
    for (Content content : contents) {
      boolean isConfiguredWithModels = false;
      ContentReport contentReport = new ContentReport();
      contentReport.setContentId(content.getId());
      String textBodyPart = this.prepareMailBodyContentPart(content, defaultLang, false);
View Full Code Here

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

    return newsletterReport;
  }
 
  private void sendNewsletterToUser(String username, List<Content> contents,
      Map<String, List<String>> profileAttributes, NewsletterReport newsletterReport) {
    NewsletterConfig config = this.getConfig();
    try {
      UserDetails user = this.getUserManager().getUser(username);
      IUserProfile profile = (IUserProfile) user.getProfile();
      if (profile != null) {
        String eMail = (String) profile.getValue(config.getMailAttrName());
        if (eMail != null && eMail.length() > 0) {
          List<Content> userContents = this.extractContentsForUser(user, eMail, contents, profileAttributes, newsletterReport);
          if (userContents.size() > 0) {
            String[] emailAddresses = { eMail };
            String simpleText = this.prepareMailBody(userContents, newsletterReport, false);
            if (config.isAlsoHtml()) {
              String htmlText = this.prepareMailBody(userContents, newsletterReport, true);
              this.getMailManager().sendMixedMail(simpleText, htmlText, config.getSubject(), null, null, null, emailAddresses, config.getSenderCode());
            } else {
              this.getMailManager().sendMail(simpleText, config.getSubject(), null, null, emailAddresses, config.getSenderCode());
            }
          }
        }
      }
    } catch (Throwable t) {
View Full Code Here

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

    }
  }
 
  protected String prepareMailBody(List<Content> userContents, NewsletterReport newsletterReport, boolean isHtml) {
    StringBuffer body = this.prepareMailCommonBody(userContents, newsletterReport, isHtml);
    NewsletterConfig config = this.getConfig();
    body.append(isHtml ? config.getHtmlFooter() : config.getTextFooter());
    return body.toString();
  }
View Full Code Here

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

    body.append(isHtml ? config.getHtmlFooter() : config.getTextFooter());
    return body.toString();
  }
 
  protected StringBuffer prepareMailCommonBody(List<Content> userContents, NewsletterReport newsletterReport, boolean isHtml) {
    NewsletterConfig config = this.getConfig();
    StringBuffer body = new StringBuffer(isHtml ? config.getHtmlHeader() : config.getTextHeader());
    String separator = isHtml ? config.getHtmlSeparator() : config.getTextSeparator();
    boolean first = true;
    for (Content content : userContents) {
      ContentReport contentReport = newsletterReport.getContentReport(content.getId());
      if (contentReport != null) {
        if (first) {
View Full Code Here

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

   * @param html Indica se il modello è di tipo html o testo semplice.
   * @return Il body della mail completo di blocchi iniziale e finale.
   * @throws ApsSystemException
   */
  private String buildMailBody(Content content, long modelId, boolean html) throws ApsSystemException {
    NewsletterConfig config = this.getConfig();
    String header = html ? config.getHtmlHeader() : config.getTextHeader();
    String defaultLang = this.getLangManager().getDefaultLang().getCode();
    String mailContentBody = this.getContentRenderer().render(content, modelId, defaultLang, null);
    mailContentBody = this.getLinkResolver().resolveLinks(mailContentBody, null);
    String footer = html ? config.getHtmlFooter() : config.getTextFooter();
    String mailBody = header.concat(mailContentBody).concat(footer);
    if (!html) {
      return StringEscapeUtils.unescapeHtml(mailBody);
    }
    return mailBody;
View Full Code Here

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

   * Estrae gli username dei destinatari della newsletter.
   * @return Il set contenente gli username dei destinatari della newsletter.
   * @throws ApsSystemException
   */
  private Set<String> extractUsernames() throws ApsSystemException {
    NewsletterConfig config = this.getConfig();
    Set<String> usernames = new HashSet<String>();
    String allContentsAttribute = config.getAllContentsAttributeName();
    if (null != allContentsAttribute && allContentsAttribute.trim().length() > 0) {
      EntitySearchFilter filter = new EntitySearchFilter(allContentsAttribute, true, new Boolean(true), false);
      EntitySearchFilter[] filters = {filter};
      try {
        List<String> usernamesForAllContents = ((IEntityManager) this.getProfileManager()).searchId(filters);
        usernames.addAll(usernamesForAllContents);
      } catch (Throwable t) {
        ApsSystemUtils.logThrowable(t, this, "extractUsernames");
        throw new ApsSystemException("Error searching for usernames on profile's attribute " + allContentsAttribute, t);
      }
    }
    Iterator<Object> subscriptionsIter = config.getSubscriptions().values().iterator();
    while (subscriptionsIter.hasNext()) {
      String boolAttributeName = (String) subscriptionsIter.next();
      if (null != boolAttributeName && boolAttributeName.trim().length() > 0) {
        EntitySearchFilter filter = new EntitySearchFilter(boolAttributeName, true, new Boolean(true), false);
        EntitySearchFilter[] filters = {filter};
View Full Code Here

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

    return usernames;
  }
 
  private List<Content> extractContentsForUser(UserDetails user, String eMail, List<Content> contents,
      Map<String, List<String>> profileAttributes, NewsletterReport newsletterReport) throws ApsSystemException {
    NewsletterConfig config = this.getConfig();
    List<Content> userContents = new ArrayList<Content>();
    String username = user.getUsername();
    IUserProfile profile = (IUserProfile) user.getProfile();
    if (profile != null) {
      String allContentsAttribute = config.getAllContentsAttributeName();
      boolean allContents = false;
      if (null != allContentsAttribute) {
        Boolean value = (Boolean) profile.getValue(allContentsAttribute);
        allContents = value != null && value.booleanValue();
      }
View Full Code Here

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

  @Override
  public List<String> loadNewsletterContentIds(EntitySearchFilter[] filters,
      Collection<String> userGroupCodes, NewsletterSearchBean searchBean) throws ApsSystemException {
    List<String> contentsId = null;
    try {
      NewsletterConfig config = this.getConfig();
      String[] contentTypes = config.getContentTypesArray();
      if (contentTypes==null || contentTypes.length==0) {
        contentsId = new ArrayList<String>();
      } else {
        String[] categories = (null != config.getAllContentsAttributeName()) ? null : config.getCategoriesArray();
        contentsId = this.getNewsletterSearcherDAO().loadNewsletterContentsId(contentTypes,
            categories, filters, userGroupCodes);
        Boolean inQueue = searchBean.getInQueue();
        if (inQueue!=null) {
          List<String> contentQueue = this.getNewsletterDAO().loadContentQueue();
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.