Package org.olat.core.util.notifications

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


  private static final String CSS_CLASS_CALENDAR_ICON = "o_calendar_icon";

  public SubscriptionInfo createSubscriptionInfo(Subscriber subscriber, Locale locale, Date compareDate) {
    SubscriptionInfo si = null;
    Publisher p = subscriber.getPublisher();
    Date latestNews = p.getLatestNewsDate();

    // do not try to create a subscription info if state is deleted - results in
    // exceptions, course
    // can't be loaded when already deleted
    if (NotificationsManager.getInstance().isPublisherValid(p) && compareDate.before(latestNews)) {
      Long id = p.getResId();
      String type = p.getSubidentifier();

      try {
        Translator translator = Util.createPackageTranslator(this.getClass(), locale);
       
        String calType = null;
        String title = null;
        if (type.equals(CalendarController.ACTION_CALENDAR_COURSE)) {
          String displayName = RepositoryManager.getInstance().lookupDisplayNameByOLATResourceableId(id);
          calType = CalendarManager.TYPE_COURSE;
          title = translator.translate("cal.notifications.header.course", new String[]{displayName});
        } else if (type.equals(CalendarController.ACTION_CALENDAR_GROUP)) {
          BusinessGroup group = BusinessGroupManagerImpl.getInstance().loadBusinessGroup(id, false);
          calType = CalendarManager.TYPE_GROUP;
          title = translator.translate("cal.notifications.header.group", new String[]{group.getName()});
        }

        if (calType != null) {
          Formatter form = Formatter.getInstance(locale);
          si = new SubscriptionInfo(new TitleItem(title, CSS_CLASS_CALENDAR_ICON), null);
         
          String bPath;
          if(StringHelper.containsNonWhitespace(p.getBusinessPath())) {
            bPath = p.getBusinessPath();
          } else if("CalendarManager.course".equals(p.getResName())) {
            try {
              ICourse course = CourseFactory.loadCourse(p.getResId());
              RepositoryEntry re = RepositoryManager.getInstance().lookupRepositoryEntry(course, true);
              bPath = "[RepositoryEntry:" + re.getKey() + "]";//Fallback
            } catch (Exception e) {
              logError("Error processing calendar notifications of publisher:" + p.getKey(), e);
              return NotificationsManager.getInstance().getNoSubscriptionInfo();
            }
          } else {
            //cannot make link without business path
            return NotificationsManager.getInstance().getNoSubscriptionInfo();
View Full Code Here


    Identity owner = sub.getIdentity();
    Identity requestor = ureq.getIdentity();
    if (!owner.equalsByPersistableKey(requestor)) throw new OLATSecurityException("tried to access subscription sub, key:" + sub.getKey()
        + ", owner is :" + owner.getName() + ", but was requested by " + requestor.getName());

    Publisher pub = sub.getPublisher();
   
    final OLATResourceable ores = OresHelper.createOLATResourceableInstance(pub.getResName(), pub.getResId());
    final String subidentifier = pub.getSubidentifier();
    final String title = "";

    return new JumpInReceptionist() {
      public String getTitle() {
        return title;
View Full Code Here

   *      int)
   */
  @Override
  public Object getValueAt(int row, int col) {
    Subscriber sub = getObject(row);
    Publisher pub = sub.getPublisher();
   
    switch (col) {
      case 0:
        String innerType = pub.getType();
        String typeName = ControllerFactory.translateResourceableTypeName(innerType, getLocale());
        return typeName;
      case 1:
        String containerType = pub.getResName();
        String containerTypeTrans = ControllerFactory.translateResourceableTypeName(containerType, getLocale());
        return containerTypeTrans;
      case 2:
        NotificationsHandler handler = NotificationsManager.getInstance().getNotificationsHandler(pub);
        String title = handler.createTitleInfo(sub, getLocale());
View Full Code Here

    nm.subscribe(identity2, sc2, pd2);
    nm.subscribe(identity, sc2, pd2);
       
    DBFactory.getInstance().closeSession();

    Publisher p = nm.getPublisher(sc);
    assertNotNull(p);
   
    assertEquals(p.getResName(), sc.getResName());
    assertEquals(p.getResId(), sc.getResId());
    assertEquals(p.getSubidentifier(), sc.getSubidentifier());
   
    boolean isSub = nm.isSubscribed(identity, sc);
    assertTrue("subscribed::", isSub);
   
    //List subs = nm.getValidSubscribers(identity);
   
    nm.notifyAllSubscribersByEmail();
   
    DBFactory.getInstance().closeSession();
    nm.unsubscribe(identity, sc);
    DBFactory.getInstance().closeSession();
   
    boolean isStillSub = nm.isSubscribed(identity, sc);
    assertFalse("subscribed::", isStillSub);
   
    nm.delete(sc);
   
    Publisher p2 = nm.getPublisher(sc);
    assertNull("publisher marked deleted should not be found", p2);
  }
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.