Examples of Publisher


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

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

    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

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

   *      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

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

    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

Examples of org.omg.dds.Publisher

                return RETCODE_PRECONDITION_NOT_MET.value ;
            }
        }
        It = Vector_Publisher.iterator() ;
        Publisher pub ;
        while(It.hasNext()){
            pub = (Publisher)It.next() ;
            if (pub.lookup_datawriter(a_topic.get_name())!= null){

                return RETCODE_PRECONDITION_NOT_MET.value ;
            }
        }
        delete_topic(a_topic );
View Full Code Here

Examples of org.umundo.core.Publisher

   
  }
 
  public SpatialMapTicker() {
    node = new Node();
    pub = new Publisher("map/tick");
    greeter = new SensorGreeter();
    pub.setGreeter(greeter);
    node.addPublisher(pub);
   
    double latCenter = 59.32;
View Full Code Here

Examples of org.xmlBlaster.client.filepoller.Publisher

      prop.put("topicName", "dummy");
      prop.put("directoryName", this.dirName);
      prop.put("sent", this.dirNameSent);
      prop.put("discarded", this.dirNameDiscarded);
      try {
         new Publisher(this.global, "test", prop);
      }
      catch (XmlBlasterException ex) {
         ex.printStackTrace();
         assertTrue("An exception should not occur here " + ex.getMessage(), false);
      }
      checkDirs();

      // repeat that with already existing directories
      prop = new PluginProperties();
      prop.put("topicName", "dummy");
      prop.put("directoryName", this.dirName);
      prop.put("sent", this.dirNameSent);
      prop.put("discarded", this.dirNameDiscarded);
      try {
         new Publisher(this.global, "test", prop);
      }
      catch (XmlBlasterException ex) {
         ex.printStackTrace();
         assertTrue("An exception should not occur here " + ex.getMessage(), false);
      }
      checkDirs();
      cleanUpDirs();

      // relative path are added to the 'directoryName'
      prop = new PluginProperties();
      prop.put("topicName", "dummy");
      prop.put("directoryName", this.dirName);
      prop.put("sent", "Sent");
      prop.put("discarded", "Discarded");
      try {
         new Publisher(this.global, "test", prop);
      }
      catch (XmlBlasterException ex) {
         ex.printStackTrace();
         assertTrue("An exception should not occur here " + ex.getMessage(), false);
      }
      checkDirs();
      // relative path are added to the 'directoryName' repeat with existing directories
      prop = new PluginProperties();
      prop.put("topicName", "dummy");
      prop.put("directoryName", this.dirName);
      prop.put("sent", "Sent");
      prop.put("discarded", "Discarded");
      try {
         new Publisher(this.global, "test", prop);
      }
      catch (XmlBlasterException ex) {
         ex.printStackTrace();
         assertTrue("An exception should not occur here " + ex.getMessage(), false);
      }
      checkDirs();
     
      cleanUpDirs();
     
      // now some which should fail:
      // existing file but not a directory
      File file = new File(this.dirName);
      try {
         file.createNewFile();
      }
      catch (IOException ex) {
         assertTrue("could not create the file '" + this.dirName + "'", false);
      }
     
      prop = new PluginProperties();
      prop.put("topicName", "dummy");
      prop.put("directoryName", this.dirName);
      prop.put("sent", "Sent");
      prop.put("discarded", "Discarded");
      try {
         new Publisher(this.global, "test", prop);
         assertTrue("an exception should occur since '" + this.dirName + "' is a file and should be a directory", false);
      }
      catch (XmlBlasterException ex) {
         log.info("Exception is OK here");
      }
      cleanUpDirs();
     
      try {
         file = new File(this.dirName);
         boolean ret = file.mkdir();
         assertTrue("could not create directory '" + this.dirName + "'", ret);
         file = new File(this.dirNameSent);
         file.createNewFile();
      }
      catch (IOException ex) {
         assertTrue("could not create the file '" + this.dirNameSent + "'", false);
      }
     
      prop = new PluginProperties();
      prop.put("topicName", "dummy");
      prop.put("directoryName", this.dirName);
      prop.put("sent", "Sent");
      prop.put("discarded", "Discarded");
      try {
         new Publisher(this.global, "test", prop);
         assertTrue("an exception should occur since '" + this.dirName + "' is a file and should be a directory", false);
      }
      catch (XmlBlasterException ex) {
         log.info("Exception is OK here");
      }
View Full Code Here

Examples of org.xmlBlaster.client.filepoller.Publisher

      String discarded = prop.getProperty("discarded", null);
     
      org.xmlBlaster.engine.ServerScope engineGlobal = new org.xmlBlaster.engine.ServerScope();
      prop.put("connectQos", this.getConnectQos(engineGlobal));
     
      Publisher publisher = null;
      try {
         publisher = new Publisher(engineGlobal, "test", prop);
         publisher.init();

         this.updateInterceptor.clear();
         // too big
         String tooBig = this.dirName + File.separator + "tooBig.dat";
         writeFile(tooBig, maximumSize+1, lockExt, delaySinceLastChange* 2);
         int ret = this.updateInterceptor.waitOnUpdate(delaySinceLastChange* 2);
         assertEquals("expected no updates", 0, ret);

         File tmp = new File(tooBig);
         if (deliverFirst) {
            assertFalse("the file '" + tooBig + "' should have been removed", tmp.exists());
            checkMoved("tooBig.dat", absSubPath, discarded);
         }
         else {
            assertTrue("the file '" + tooBig + "' should still be here", tmp.exists());
         }

         this.updateInterceptor.clear();

         singleDump("ok.dat", maximumSize-1, lockExt, delaySinceLastChange* 2, deliverFirst, absSubPath, sent);
         singleDump("ok.gif", maximumSize-1, lockExt, delaySinceLastChange* 2, deliverSecond, absSubPath, sent);
      }
      catch (XmlBlasterException ex) {
         ex.printStackTrace();
         assertTrue("An exception should not occur here " + ex.getMessage(), false);
      }
      finally {
         if (publisher != null) {
            try {
               publisher.shutdown();
            }
            catch (Throwable ex) {
               ex.printStackTrace();
               fail("exception when shutting down the poller " + ex.getMessage());
            }
View Full Code Here

Examples of org.xmlBlaster.contrib.filewatcher.Publisher

      prop.put("mom.topicName", "dummy");
      prop.put("filewatcher.directoryName", this.pollerDirName);
      prop.put("filewatcher.sent", this.pollerDirNameSent);
      prop.put("filewatcher.discarded", this.pollerDirNameDiscarded);
      try {
         new Publisher(this.global, "test", prop);
      }
      catch (XmlBlasterException ex) {
         ex.printStackTrace();
         assertTrue("An exception should not occur here " + ex.getMessage(), false);
      }
      checkDirs();

      // repeat that with already existing directories
      prop = new PropertiesInfo(new Properties());
      prop.put("mom.topicName", "dummy");
      prop.put("filewatcher.directoryName", this.pollerDirName);
      prop.put("filewatcher.sent", this.pollerDirNameSent);
      prop.put("filewatcher.discarded", this.pollerDirNameDiscarded);
      try {
         new Publisher(this.global, "test", prop);
      }
      catch (XmlBlasterException ex) {
         ex.printStackTrace();
         assertTrue("An exception should not occur here " + ex.getMessage(), false);
      }
      checkDirs();
      cleanUpDirs();

      // relative path are added to the 'directoryName'
      prop = new PropertiesInfo(new Properties());
      prop.put("mom.topicName", "dummy");
      prop.put("filewatcher.directoryName", this.pollerDirName);
      prop.put("filewatcher.sent", "Sent");
      prop.put("filewatcher.discarded", "Discarded");
      try {
         new Publisher(this.global, "test", prop);
      }
      catch (XmlBlasterException ex) {
         ex.printStackTrace();
         assertTrue("An exception should not occur here " + ex.getMessage(), false);
      }
      checkDirs();
      // relative path are added to the 'directoryName' repeat with existing directories
      prop = new PropertiesInfo(new Properties());
      prop.put("mom.topicName", "dummy");
      prop.put("filewatcher.directoryName", this.pollerDirName);
      prop.put("filewatcher.filewatcher.sent", "Sent");
      prop.put("filewatcher.discarded", "Discarded");
      try {
         new Publisher(this.global, "test", prop);
      }
      catch (XmlBlasterException ex) {
         ex.printStackTrace();
         assertTrue("An exception should not occur here " + ex.getMessage(), false);
      }
      checkDirs();
     
      cleanUpDirs();
     
      // now some which should fail:
      // existing file but not a directory
      File file = new File(this.pollerDirName);
      try {
         file.createNewFile();
      }
      catch (IOException ex) {
         assertTrue("could not create the file '" + this.pollerDirName + "'", false);
      }
     
      prop = new PropertiesInfo(new Properties());
      prop.put("mom.topicName", "dummy");
      prop.put("filewatcher.directoryName", this.pollerDirName);
      prop.put("filewatcher.sent", "Sent");
      prop.put("filewatcher.discarded", "Discarded");
      try {
         new Publisher(this.global, "test", prop);
         assertTrue("an exception should occur since '" + this.pollerDirName + "' is a file and should be a directory", false);
      }
      catch (XmlBlasterException ex) {
         log.info("Exception is OK here");
      }
      cleanUpDirs();
     
      try {
         file = new File(this.pollerDirName);
         boolean ret = file.mkdir();
         assertTrue("could not create directory '" + this.pollerDirName + "'", ret);
         file = new File(this.pollerDirNameSent);
         file.createNewFile();
      }
      catch (IOException ex) {
         assertTrue("could not create the file '" + this.pollerDirNameSent + "'", false);
      }
     
      prop = new PropertiesInfo(new Properties());
      prop.put("mom.topicName", "dummy");
      prop.put("filewatcher.directoryName", this.pollerDirName);
      prop.put("filewatcher.sent", "Sent");
      prop.put("filewatcher.discarded", "Discarded");
      try {
         new Publisher(this.global, "test", prop);
         assertTrue("an exception should occur since '" + this.pollerDirName + "' is a file and should be a directory", false);
      }
      catch (XmlBlasterException ex) {
         log.info("Exception is OK here");
      }
View Full Code Here

Examples of org.xmlBlaster.contrib.filewatcher.Publisher

      String discarded = prop.get("filewatcher.discarded", null);
     
      org.xmlBlaster.engine.ServerScope engineGlobal = new org.xmlBlaster.engine.ServerScope();
      prop.put("mom.connectQos", this.getConnectQos(engineGlobal));
     
      Publisher publisher = null;
      try {
         publisher = new Publisher(engineGlobal, "test", prop);
         publisher.init();
         // too big
         String tooBig = this.pollerDirName + File.separator + "tooBig.dat";
         writeFile(tooBig, maximumSize+1, lockExt);
         doWait(delaySinceLastChange*2);
         File tmp = new File(tooBig);
         if (deliverFirst) {
            assertFalse("the file '" + tooBig + "' should have been removed", tmp.exists());
            checkMoved("tooBig.dat", absSubPath, discarded);
         }
         else {
            assertTrue("the file '" + tooBig + "' should still be here", tmp.exists());
         }

         singleDump("ok.dat", maximumSize-1, lockExt, delaySinceLastChange* 2, deliverFirst, absSubPath, sent);
         singleDump("ok.gif", maximumSize-1, lockExt, delaySinceLastChange* 2, deliverSecond, absSubPath, sent);
      }
      catch (XmlBlasterException ex) {
         ex.printStackTrace();
         assertTrue("An exception should not occur here " + ex.getMessage(), false);
      }
      finally {
         if (publisher != null) {
            try {
               publisher.shutdown();
            }
            catch (Throwable ex) {
               ex.printStackTrace();
               fail("exception when shutting down the poller " + ex.getMessage());
            }
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.