Package org.olat.core.util.notifications

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


   */
  public void markSubscriberRead(Identity identity, SubscriptionContext subsContext) {
    Publisher p = getPublisher(subsContext.getResName(), subsContext.getResId(), subsContext.getSubidentifier());
    if (p == null) throw new AssertException("cannot markRead for identity " + identity.getName()
        + ", since the publisher for the given subscriptionContext does not exist: subscontext = " + subsContext);
    Subscriber sub = getSubscriber(identity, p);
    if (sub == null) throw new AssertException("cannot markRead, since identity " + identity.getName()
        + " is not subscribed to subscontext " + subsContext);
    updateSubscriber(sub);
  }
View Full Code Here


   * @param publisherData
   */
  public void subscribe(Identity identity, SubscriptionContext subscriptionContext, PublisherData publisherData) {
    // no need to sync, since an identity only has one gui thread / one mouse
    Publisher p = findOrCreatePublisher(subscriptionContext, publisherData);
    Subscriber s = getSubscriber(identity, p);
    if (s == null) {
      // no subscriber -> create.
      // s.latestReadDate >= p.latestNewsDate == no news for subscriber when no
      // news after subscription time
      doCreateAndPersistSubscriber(p, identity);
View Full Code Here

    }
   
    // no need to sync, since there is only one gui thread at a time from one
    // user
    if (ignoreNewsFor != null) {
      Subscriber sub = getSubscriber(ignoreNewsFor, publisher);
      if (sub != null) { // mark as read if subscribed
        updateSubscriber(sub);
      }
    }
   
   
    // channel-notify all interested listeners (e.g. the pnotificationsportletruncontroller)
    // 1. find all subscribers which can be affected
    List<Subscriber> subscribers = getValidSubscribersOf(publisher);
   
    Set<Long> subsKeys = new HashSet<Long>();
    // 2. collect all keys of the affected subscribers
    for (Iterator<Subscriber> it_subs = subscribers.iterator(); it_subs.hasNext();) {
      Subscriber su = it_subs.next();
      subsKeys.add(su.getKey());
    }
    // fire the event
    MultiUserEvent mue = EventFactory.createAffectedEvent(subsKeys);
    CoordinatorManager.getCoordinator().getEventBus().fireEventToListenersOf(mue, oresMyself);
   
View Full Code Here

    // no need to sync, since an identity only has one gui thread / one mouse
    Publisher p = getPublisher(subscriptionContext);
    // if no publisher yet.
    //TODO: check race condition: can p be null at all?
    if (p == null) return;
    Subscriber s = getSubscriber(identity, p);
    if (s != null) {
      deleteSubscriber(s);
    } else {
      logWarn("could not unsubscribe " + identity.getName() + " from publisher:" + p.getResName() + ","  + p.getResId() + "," + p.getSubidentifier(), null);
    }
View Full Code Here

  /**
   *
   * @see org.olat.core.util.notifications.NotificationsManager#unsubscribe(org.olat.core.util.notifications.Subscriber)
   */
  public void unsubscribe(Subscriber s) {
    Subscriber foundSub = getSubscriber(s.getKey());
    if (foundSub != null) {
      deleteSubscriber(foundSub);
    } else {
      logWarn("could not unsubscribe " + s.getIdentity().getName() + " from publisher:" + s.getPublisher().getResName() + ","  + s.getPublisher().getResId() + "," + s.getPublisher().getSubidentifier(), null);
    }
View Full Code Here

  }

   protected Comparator getComparator(final SortingCriteria sortingCriteria) {
      return new Comparator(){     
        public int compare(final Object o1, final Object o2) {
          Subscriber subscriber1= (Subscriber)o1;
          Subscriber subscriber2 = (Subscriber)o2;   
          int comparisonResult = 0;
          if(sortingCriteria.getSortingTerm()==SortingCriteria.ALPHABETICAL_SORTING) {         
            comparisonResult = collator.compare(subscriber1.getPublisher().getResName(), subscriber1.getPublisher().getResName());               
          } else if(sortingCriteria.getSortingTerm()==SortingCriteria.DATE_SORTING) {
            comparisonResult = subscriber1.getLastModified().compareTo(subscriber1.getLastModified());
          } else if(sortingCriteria.getSortingTerm()==SortingCriteria.TYPE_SORTING) {
            String type1 = ControllerFactory.translateResourceableTypeName(subscriber1.getPublisher().getType(), getTranslator().getLocale());
            String type2 = ControllerFactory.translateResourceableTypeName(subscriber2.getPublisher().getType(), getTranslator().getLocale());
            comparisonResult = type1.compareTo(type2);
          }
          if(!sortingCriteria.isAscending()) {
            //if not isAscending return (-comparisonResult)         
            return -comparisonResult;
View Full Code Here

       this.subToSubInfo = subToSubInfo;
     }
    
     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;
View Full Code Here

            return "ERROR";
        }
      }
    
     public Subscriber getSubscriberAt(int row) {
        Subscriber subscriber = (Subscriber) getObject(row).getValue();
        return subscriber;
      }
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);
          }
View Full Code Here

      subscriptionKey = new Long(constSID.trim());
    } catch (NumberFormatException nfe) {
      return null;
    }

    Subscriber sub = NotificationsManagerImpl.getInstance().getSubscriber(subscriptionKey);
    if (sub == null) { // the subscription does not exist anymore
      return null;
    }
    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 = "";
View Full Code Here

TOP

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

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.