Package org.olat.core.util.notifications

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


   * delete publisher and subscribers
   *
   * @param scontext the subscriptioncontext
   */
  public void delete(SubscriptionContext scontext) {
    Publisher p = getPublisher(scontext.getResName(), scontext.getResId(), scontext.getSubidentifier());
    // if none found, no one has subscribed yet and therefore no publisher has
    // been generated lazily.
    // -> nothing to do
    if (p == null) return;
    //first delete all subscribers
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);
        }
View Full Code Here

   * @param locale
   * @param mimeType
   * @return
   */
  private String getFormatedTitle(SubscriptionInfo subsInfo, Subscriber subscriber, Locale locale, String mimeType){
    Publisher pub = subscriber.getPublisher();
    String innerType = pub.getType();
    String typeName = ControllerFactory.translateResourceableTypeName(innerType, locale);
    StringBuilder titleSb = new StringBuilder();
    titleSb.append(typeName);
   
    String title = subsInfo.getTitle(mimeType);
View Full Code Here

     }
    
     public Object getValueAt(int row, int col) {
       PortletEntry entry = getObject(row);
        Subscriber subscriber = (Subscriber)entry.getValue();
        Publisher pub = subscriber.getPublisher();
        switch (col) {
          case 0:
            Object subsInfoObj = subToSubInfo.get(subscriber);
            if(subsInfoObj instanceof SubscriptionInfo) {
              SubscriptionInfo subsInfo = (SubscriptionInfo)subsInfoObj;
              int newsCount = subsInfo.countSubscriptionListItems();
              if (newsCount == 1) {
                return translate("notificationsPortlet.single.news.in", subsInfo.getTitle(SubscriptionInfo.MIME_PLAIN));                               
              } else {
                return translate("notificationsPortlet.multiple.news.in", new String[]{newsCount + "" , subsInfo.getTitle(SubscriptionInfo.MIME_PLAIN)});               
              }
            }
            return "";
          case 1:         
            String innerType = pub.getType();
            String typeName = ControllerFactory.translateResourceableTypeName(innerType, locale);
            return typeName;
          default:
            return "ERROR";
        }
View Full Code Here

       * @see org.olat.core.gui.components.table.TableDataModel#getValueAt(int, int)
       */
      public final Object getValueAt(int row, int col) {
        PortletEntry entry = getObject(row);
        Subscriber subscriber = (Subscriber) entry.getValue();
        Publisher pub = subscriber.getPublisher();
        switch (col) {
          case 0: {       
            SubscriptionInfo subsInfo = subToSubInfo.get(subscriber);
            return subsInfo.getTitle(SubscriptionInfo.MIME_PLAIN);
          }
          case 1: {
            SubscriptionInfo subsInfo = subToSubInfo.get(subscriber);
            if (!subsInfo.hasNews()) return "-";
            return subsInfo.getSpecificInfo(SubscriptionInfo.MIME_HTML, locale);
          }
          case 2:
            String innerType = pub.getType();
            String typeName = ControllerFactory.translateResourceableTypeName(innerType, locale);
            return typeName;
          default:
            return "error";
        }
View Full Code Here

    this.translator = translator;
    this.subsInfoMap = subsInfoMap;
  }

  public String getType(Subscriber sub) {
    Publisher pub = sub.getPublisher();
    String innerType = pub.getType();
    String typeName = ControllerFactory.translateResourceableTypeName(innerType, translator.getLocale());
    return typeName;
  }
View Full Code Here

    String typeName = ControllerFactory.translateResourceableTypeName(innerType, translator.getLocale());
    return typeName;
  }

  public String getContainerType(Subscriber sub) {
    Publisher pub = sub.getPublisher();
    String containerType = pub.getResName();
    String containerTypeTrans = ControllerFactory.translateResourceableTypeName(containerType, translator.getLocale());
    return containerTypeTrans;
  }
View Full Code Here

   * @param ureq
   * @param windowControl
   * @param sub
   */
  public static void launchSubscriptionResource(UserRequest ureq, WindowControl windowControl, Subscriber sub) {
    Publisher pub = sub.getPublisher();
    if (!NotificationsManager.getInstance().isPublisherValid(pub)) {
      Translator trans = Util.createPackageTranslator(NotificationUIFactory.class, ureq.getLocale());
      windowControl.setError(trans.translate("error.publisherdeleted"));
      return;
    }
    String resName = pub.getResName();
    Long resId = pub.getResId();
    String subidentifier = pub.getSubidentifier();
    // Special case update course and group name for calendars (why?)
    if (subidentifier.equals(CalendarController.ACTION_CALENDAR_COURSE)) {
      resName = CourseModule.ORES_TYPE_COURSE;
    }
    if (subidentifier.equals(CalendarController.ACTION_CALENDAR_GROUP)) {
      resName = BusinessGroupManagerImpl.getInstance().loadBusinessGroup(pub.getResId(), true).getResourceableTypeName();
    }
    OLATResourceable ores = OresHelper.createOLATResourceableInstance(resName, resId);
    String title = NotificationsManager.getInstance().getNotificationsHandler(sub.getPublisher()).createTitleInfo(sub, ureq.getLocale());
    // Launch in dtab
    DTabs dts = (DTabs) Windows.getWindows(ureq).getWindow(ureq).getAttribute("DTabs");
View Full Code Here

    //all learning and right group calendars
    for (BusinessGroup bg : learningGroups) {
      KalendarRenderWrapper calRenderWrapper = calMan.getGroupCalendar(bg);
      SubscriptionProvider subProvider = new SubscriptionProviderImpl(calRenderWrapper);
      SubscriptionContext subsContext = subProvider.getSubscriptionContext();
      Publisher pub = nfm.getPublisher(subsContext);
      if (pub != null) {
        pub.setState(1); //int 0 is OK -> all other is not OK
      }
    }
    //the course calendar
    try {
      /**
       * TODO:gs 2010-01-26
       * OLAT-4947: if we do not have an repo entry we get an exception here.
       * This is normal in the case of courseimport and click canceling.
       */
      course.getCourseTitle();
      KalendarRenderWrapper courseCalendar = calMan.getCourseCalendar(course);
      SubscriptionProvider subProvider = new SubscriptionProviderImpl(courseCalendar, course);
      Publisher pub = nfm.getPublisher(subProvider.getSubscriptionContext());
      if (pub != null) {
        pub.setState(1);
      }
    } catch (AssertException e) {
      //if we have a broken course (e.g. canceled import or no repo entry somehow) skip calendar deletion...
    }
  }
View Full Code Here

      NotificationsManager notificationMgr = NotificationsManager.getInstance();
      List<Publisher> allPublishers = notificationMgr.getAllPublisher();
      if (log.isDebug()) log.info("Found " + allPublishers.size() + " publishers to migrate.");

      for(Publisher publisher:allPublishers) {
        Publisher publisherToSave = upgrade(publisher);
        if(publisherToSave != null) {
          try {
            DBFactory.getInstance().updateObject(publisherToSave);
          } catch (ObjectDeletedException e) {
            log.warn("Publisher was already deleted, no update possible! Publisher key: "+publisherToSave.getKey() );
          } catch (Exception e) {
            log.warn("Publisher was already deleted, no update possible! Publisher key: "+publisherToSave.getKey() );
          }
          counter++;
        }
        if (counter > 0 && counter % 100 == 0) {
          log.audit("Another 100 publishers done");
View Full Code Here

TOP

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

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.