Examples of Publisher


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

  private static final OLog log = Tracing.createLoggerFor(NewUsersNotificationHandler.class);
 
  private List<Identity> identities;

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

    SubscriptionInfo si;
    Translator translator = Util.createPackageTranslator(this.getClass(), locale);
    // there could be news for me, investigate deeper
    try {
View Full Code Here

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

public class DENCourseNodeNotificationHandler implements NotificationsHandler {
  private static final OLog log = Tracing.createLoggerFor(DENCourseNodeNotificationHandler.class);

  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
    try {
      if (NotificationsManager.getInstance().isPublisherValid(p) && compareDate.before(latestNews)) {
        Long courseId = new Long(p.getData());
        final ICourse course = loadCourseFromId(courseId);
        if (course != null) {
          final List<DENCourseNode> denNodes = getCourseDENNodes(course);
          final Translator trans = Util.createPackageTranslator(DENCourseNodeNotificationHandler.class, locale);
View Full Code Here

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

  /**
   * @see org.olat.notifications.NotificationsHandler#createSubscriptionInfo(org.olat.notifications.Subscriber,
   *      java.util.Locale, java.util.Date)
   */
  public SubscriptionInfo createSubscriptionInfo(final Subscriber subscriber, Locale locale, Date compareDate) {
    Publisher p = subscriber.getPublisher();
    Date latestNews = p.getLatestNewsDate();

    String businessPath = p.getBusinessPath() + "[path=";
   
    SubscriptionInfo si;
    // there could be news for me, investigate deeper
    try {
      if (NotificationsManager.getInstance().isPublisherValid(p) && compareDate.before(latestNews)) {
        String folderRoot = p.getData();
        final List<FileInfo> fInfos = FolderManager.getFileInfos(folderRoot, compareDate);
        final Translator translator = Util.createPackageTranslator(FolderNotificationsHandler.class, locale);

        si = new SubscriptionInfo(getTitleItem(p, translator), null);
        SubscriptionListItem subListItem;
        for (Iterator<FileInfo> it_infos = fInfos.iterator(); it_infos.hasNext();) {
          FileInfo fi = it_infos.next();
          String title = fi.getRelPath();
          MetaInfo metaInfo = fi.getMetaInfo();
          String iconCssClass =  null;
          if (metaInfo != null) {
            if (metaInfo.getTitle() != null) {
              title += " (" + metaInfo.getTitle() + ")";
            }
            iconCssClass = metaInfo.getIconCssClass();
          }
          Identity ident = fi.getAuthor();
          Date modDate = fi.getLastModified();

          String desc = translator.translate("notifications.entry", new String[] { title, NotificationHelper.getFormatedName(ident) });
          String urlToSend = null;
          if(p.getBusinessPath() != null) {
            urlToSend = NotificationHelper.getURLFromBusinessPathString(p, businessPath + fi.getRelPath() + "]");
          }
          subListItem = new SubscriptionListItem(desc, urlToSend, modDate, iconCssClass);
          si.addSubscriptionListItem(subListItem);
        }
View Full Code Here

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

   * @return the publisher
   */
  private Publisher findOrCreatePublisher(final SubscriptionContext scontext, final PublisherData pdata) {
    final OLATResourceable ores = OresHelper.createOLATResourceableInstance(scontext.getResName() + "_" + scontext.getSubidentifier(),scontext.getResId());
    //o_clusterOK by:cg
    Publisher publisher = CoordinatorManager.getCoordinator().getSyncer().doInSync(ores, new SyncerCallback<Publisher>(){
      public Publisher execute() {
        Publisher p = getPublisher(scontext.getResName(), scontext.getResId(), scontext.getSubidentifier());
        // if not found, create it
        if (p == null) {
          p = createAndPersistPublisher(scontext.getResName(), scontext.getResId(), scontext.getSubidentifier(), pdata.getType(), pdata
              .getData(), pdata.getBusinessPath());
        }
        if (p.getData() == null || !p.getData().startsWith("[")) {
          //update silently the publisher
          if(pdata.getData() != null) {
            //updatePublisher(p, pdata.getData());
          }
        }
View Full Code Here

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

    query.setLong("resId", resId.longValue());
    query.setString("subidentifier", subidentifier);
    List<Publisher> res = query.list();
    if (res.size() == 0) return null;
    if (res.size() != 1) throw new AssertException("only one subscriber per person and publisher!!");
    Publisher p = res.get(0);
    return p;
  }
View Full Code Here

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

    String type = ores.getResourceableTypeName();
    Long id = ores.getResourceableId();
    if (type == null || id == null) throw new AssertException("type/id cannot be null! type:" + type + " / id:" + id);
    List<Publisher> pubs = getPublishers(type, id);
    for (Iterator<Publisher> it_pub = pubs.iterator(); it_pub.hasNext();) {
      Publisher pub = it_pub.next();
     
      //grab all subscribers to the publisher and delete them
      List<Subscriber> subs = getValidSubscribersOf(pub);
      for (Iterator<Subscriber> iterator = subs.iterator(); iterator.hasNext();) {
        Subscriber sub = iterator.next();
View Full Code Here

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

   *
   * @param identity
   * @param subsContext
   */
  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);
View Full Code Here

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

   * @param subscriptionContext
   * @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
View Full Code Here

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

    final Date now = new Date();

    // two threads with both having a publisher they want to update
    //o_clusterOK by:cg
    final OLATResourceable ores = OresHelper.createOLATResourceableInstance(subscriptionContext.getResName() + "_" + subscriptionContext.getSubidentifier(),subscriptionContext.getResId());
    Publisher publisher = CoordinatorManager.getCoordinator().getSyncer().doInSync(ores, new SyncerCallback<Publisher>(){
      public Publisher execute() {
        Publisher p = getPublisher(subscriptionContext);
        // if no publisher yet, ignore
        //TODO: check if that can be null
        if (p == null) return null;
 
        // force a reload from db loadObject(..., true) by evicting it from
        // hibernates session
        // cache to catch up on a different thread having commited the update of
        // this object
 
        // not needed, since getPublisher()... always loads from db???
        //p = (Publisher) DB.getInstance().loadObject(p, true);

        p.setLatestNewsDate(now);
        updatePublisher(p);
        return p;
      }
    });
    if (publisher == null) {//TODO: check if that can be null
View Full Code Here

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

   * @param identity
   * @param subscriptionContext
   */
  public void unsubscribe(Identity identity, SubscriptionContext subscriptionContext) {
    // 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
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.