Package org.olat.core.util.notifications

Examples of org.olat.core.util.notifications.SubscriptionItem


        // find out the info that happened since the date the last email was sent. Only those infos need to be emailed.
        // mail is only sent if users interval is over.
        Date compareDate = getCompareDateFromInterval(userInterval);
        Date latestEmail = sub.getLatestEmailed();
       
        SubscriptionItem subsitem = null;
        if (latestEmail == null || compareDate.after(latestEmail)){
          // no notif. ever sent until now
          if (latestEmail == null) {
            latestEmail = defaultCompareDate;
          else if (latestEmail.before(defaultCompareDate)) {
View Full Code Here


  }
 
  private boolean sendEmail(Identity to, String title, List<SubscriptionItem> subItems) {
    StringBuilder plaintext = new StringBuilder();
    for (Iterator<SubscriptionItem> it_subs = subItems.iterator(); it_subs.hasNext();) {
      SubscriptionItem subitem = it_subs.next();
      plaintext.append(subitem.getTitle());
      if(StringHelper.containsNonWhitespace(subitem.getLink())) {
        plaintext.append("\n");
        plaintext.append(subitem.getLink());
      }
      plaintext.append("\n");
      if(StringHelper.containsNonWhitespace(subitem.getDescription())) {
        plaintext.append(subitem.getDescription());
      }
      plaintext.append("\n\n");
    }
    String mailText = plaintext.toString();
    MailTemplate mailTempl = new MailTemplate(title, mailText, null) {
View Full Code Here

   */
  public SubscriptionItem createSubscriptionItem(Subscriber subscriber, Locale locale, String mimeTypeTitle, String mimeTypeContent, Date latestEmailed) {
    if (latestEmailed == null) throw new AssertException("compareDate may not be null, use a date from history");
   
    try {
      SubscriptionItem si = null;
      Publisher pub = subscriber.getPublisher();
      NotificationsHandler notifHandler = getNotificationsHandler(pub);
      // do not create subscription item when deleted
      if (isPublisherValid(pub)) {
        if (isLogDebugEnabled()) logDebug("NotifHandler: " + notifHandler.getClass().getName() + " compareDate: " + latestEmailed.toString() + " now: " + new Date().toString(), null);
        SubscriptionInfo subsInfo = notifHandler.createSubscriptionInfo(subscriber, locale, latestEmailed);
        if (subsInfo.hasNews()) {
          String title = getFormatedTitle(subsInfo, subscriber, locale, mimeTypeTitle);
         
          String itemLink = null;
          if(subsInfo.getCustomUrl() != null) {
            itemLink = subsInfo.getCustomUrl();
          }
          if(itemLink == null && pub.getBusinessPath() != null) {
            itemLink = NotificationHelper.getURLFromBusinessPathString(pub, pub.getBusinessPath());
          }
         
          String description = subsInfo.getSpecificInfo(mimeTypeContent, locale);
          si = new SubscriptionItem(title, itemLink, description);
        }
      }
      return si;
    } catch (Exception e) {
      log.error("Cannot generate a subscription item.", e);
View Full Code Here

      NotificationsManager man = NotificationsManager.getInstance();
      List<SubscriptionItem> infoList = new ArrayList<SubscriptionItem>();
      List<Subscriber> subsList = new ArrayList<Subscriber>();
      for (Subscriber subscriber : subsInfoMap.keySet()) {
        subsList.add(subscriber);
        SubscriptionItem item = man.createSubscriptionItem(subscriber, getLocale(), SubscriptionInfo.MIME_PLAIN, SubscriptionInfo.MIME_PLAIN, compareDate);
        if(item != null) {
          infoList.add(item);
        }
      }
      if (man.sendMailToUserAndUpdateSubscriber(subscriberIdentity, infoList, getTranslator(), subsList)) {
View Full Code Here

    return subsInfo.getCustomUrl();
  }

  public SubscriptionItem getSubscriptionItem(Subscriber sub) {
    NotificationsManager notiMgr = NotificationsManager.getInstance();
    SubscriptionItem subscrItem = notiMgr.createSubscriptionItem(sub, translator.getLocale(), SubscriptionInfo.MIME_HTML, SubscriptionInfo.MIME_HTML);
    return subscrItem;   
  }
View Full Code Here

    // notification news
    // we are only interested in subscribers which listen to a valid publisher
    List<Subscriber> subs = man.getValidSubscribers(identity);
    for (Subscriber subscriber : subs) {
      SubscriptionItem si = man.createSubscriptionItem(subscriber, locale, SubscriptionInfo.MIME_PLAIN, SubscriptionInfo.MIME_HTML);
      if (si != null) {
        SyndEntry item = new SyndEntryImpl();
        item.setTitle(si.getTitle());
        item.setLink(si.getLink());
        SyndContent itemDescription = new SyndContentImpl();
        itemDescription.setType(SubscriptionInfo.MIME_HTML);
        itemDescription.setValue(si.getDescription());
        item.setDescription(itemDescription);
        entries.add(item);
      }
    }
    setEntries(entries);
View Full Code Here

TOP

Related Classes of org.olat.core.util.notifications.SubscriptionItem

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.