Package org.olat.core.util.notifications

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


  private List<PortletEntry> getAllPortletEntries() {
    notificationsList = man.getValidSubscribers(identity);
    // calc subscriptioninfo for all subscriptions and, if only those with news are to be shown, remove the other ones
    for (Iterator<Subscriber> it_subs = notificationsList.iterator(); it_subs.hasNext();) {
      Subscriber subscriber = it_subs.next();
      Publisher pub = subscriber.getPublisher();
      NotificationsHandler notifHandler = man.getNotificationsHandler(pub);
      SubscriptionInfo subsInfo = notifHandler.createSubscriptionInfo(subscriber, locale, compareDate);
      if (!subsInfo.hasNews()) {
        it_subs.remove();
      }
View Full Code Here


    if (sortingCriteria.getSortingType() == SortingCriteria.AUTO_SORTING) {
    notificationsList = man.getValidSubscribers(identity);
    // calc subscriptioninfo for all subscriptions and, if only those with news are to be shown, remove the other ones
    for (Iterator<Subscriber> it_subs = notificationsList.iterator(); it_subs.hasNext();) {
      Subscriber subscriber = it_subs.next();
      Publisher pub = subscriber.getPublisher();
      try {
        NotificationsHandler notifHandler = man.getNotificationsHandler(pub);
        SubscriptionInfo subsInfo = notifHandler.createSubscriptionInfo(subscriber, locale, compareDate);
        if (!subsInfo.hasNews()) {
          it_subs.remove();
View Full Code Here

        String actionid = te.getActionId();
        if (actionid.equals(CMD_LAUNCH)) {
          int rowid = te.getRowId();
          Subscriber sub = notificationListModel.getSubscriberAt(rowid);
          if (actionid.equals(CMD_LAUNCH)) {
            Publisher pub = sub.getPublisher();
            if (!man.isPublisherValid(pub)) {
              getWindowControl().setError(getTranslator().translate("error.publisherdeleted"));
            } else {           
              String resName = pub.getResName();
              Long resId = pub.getResId();
              String subidentifier = pub.getSubidentifier();
              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(pub).createTitleInfo(sub, getLocale());
              DTabs dts = (DTabs)Windows.getWindows(ureq).getWindow(ureq).getAttribute("DTabs");
              //was brasato:: DTabs dts = getWindowControl().getDTabs();
View Full Code Here

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

    SubscriptionInfo si;
    // there could be news for me, investigate deeper
    try {
      if (NotificationsManager.getInstance().isPublisherValid(p) && compareDate.before(latestNews)) {
        String displayname = RepositoryManager.getInstance().lookupDisplayNameByOLATResourceableId(p.getResId());
        if(displayname == null) {
          if(!checkPublisher(subscriber.getPublisher())) {
            return NotificationsManager.getInstance().getNoSubscriptionInfo();
          }
        }
        DialogElementsPropertyManager mgr = DialogElementsPropertyManager.getInstance();
        DialogPropertyElements elements = mgr.findDialogElements(p.getResId(), p.getSubidentifier());
        final List<DialogElement> dialogElements = elements.getDialogPropertyElements();
        final Translator translator = Util.createPackageTranslator(FileUploadNotificationHandler.class, locale);

        si = new SubscriptionInfo(new TitleItem(translator.translate("notifications.header", new String[]{displayname}), CSSS_CLASS_UPLOAD_ICON), null);
        SubscriptionListItem subListItem;
        for (DialogElement element : dialogElements) {
          // do only show entries newer then the ones already seen
          if (element.getDate().after(compareDate)) {
            String filename = element.getFilename();
            String creator = element.getAuthor();
            Identity ident = ManagerFactory.getManager().findIdentityByName(creator);
            Date modDate = element.getDate();

            String desc = translator.translate("notifications.entry", new String[] { filename, NotificationHelper.getFormatedName(ident) });
            String urlToSend = NotificationHelper.getURLFromBusinessPathString(p, p.getBusinessPath());
            String cssClass = CSSHelper.createFiletypeIconCssClassFor(filename);

            subListItem = new SubscriptionListItem(desc, urlToSend, modDate, cssClass);
            si.addSubscriptionListItem(subListItem);
          }
View Full Code Here

   * @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) {
    try {
      Publisher p = subscriber.getPublisher();
      Date latestNews = p.getLatestNewsDate();
     
      SubscriptionInfo si;
      // there could be news for me, investigate deeper
      if (NotificationsManager.getInstance().isPublisherValid(p) && compareDate.before(latestNews)) {
        String businessControlString = "";
        Long forumKey = Long.valueOf(0);
        try {
          forumKey = Long.parseLong(p.getData());
        } catch (NumberFormatException e) {
          logError("Could not parse forum key!", e);
          NotificationsManager.getInstance().deactivate(p);
          return NotificationsManager.getInstance().getNoSubscriptionInfo();
        }
        final List<Message> mInfos = ForumManager.getInstance().getNewMessageInfo(forumKey, compareDate);
        final Translator translator = Util.createPackageTranslator(ForumNotificationsHandler.class, locale);
       
        businessControlString = p.getBusinessPath() + "[Message:";
       
        si = new SubscriptionInfo(getTitleItem(p, translator), null);
        for (Message mInfo : mInfos) {
          String title = mInfo.getTitle();
          Identity creator = mInfo.getCreator();
          Identity modifier = mInfo.getModifier();
          Date modDate = mInfo.getLastModified();
         
          String name;
          if(modifier != null) {
            name = NotificationHelper.getFormatedName(modifier);
          } else {
            name = NotificationHelper.getFormatedName(creator);
          }
          String desc = translator.translate("notifications.entry", new String[] { title, name })
          String urlToSend = null;
          if(p.getBusinessPath() != null) {
            urlToSend = NotificationHelper.getURLFromBusinessPathString(p, businessControlString + mInfo.getKey().toString() + "]");
          }
         
          SubscriptionListItem subListItem = new SubscriptionListItem(desc, urlToSend, modDate, ForumHelper.CSS_ICON_CLASS_MESSAGE);
          si.addSubscriptionListItem(subListItem);
View Full Code Here

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

    final Date latestNews = p.getLatestNewsDate();
    Long resId = p.getResId();
    SubscriptionInfo si;
    // there could be news for me, investigate deeper
    logDebug("compareDate=" + compareDate + " ; latestNews=" + latestNews, null);
    try {
      if (NotificationsManager.getInstance().isPublisherValid(p) && compareDate.before(latestNews)) {
        OLATResourceable ores = null;
        if (p.getResName().equals( CourseModule.getCourseTypeName() ) ) {
          // resId = CourseResourceableId           p.getSubidentifier() = wikiCourseNode.getIdent()
          ICourse course = CourseFactory.loadCourse(resId);
          CourseEnvironment cenv = course.getCourseEnvironment();
          CourseNode courseNode = cenv.getRunStructure().getNode(p.getSubidentifier());
          if(courseNode == null){
            //OLAT-3356 because removing wikicoursenodes was not propagated to
            // disable subcriptions, we may end up here with a NULL wikicoursenode
            // Best we can do here -> return noSubsInfo and clean up
            NotificationsManager.getInstance().deactivate(p);
            // return nothing available
            return NotificationsManager.getInstance().getNoSubscriptionInfo();
          }
          ModuleConfiguration config = ((WikiCourseNode)courseNode).getModuleConfiguration();
          RepositoryEntry re = WikiEditController.getWikiRepoReference(config, true);
          resId = re.getOlatResource().getResourceableId();
          logDebug("resId=" + resId, null);
          ores = OresHelper.createOLATResourceableInstance(WikiResource.TYPE_NAME, resId);
          businessControlString = p.getBusinessPath() + "[path=";
        } else {
          // resName = 'BusinessGroup' or 'FileResource.WIKI'
          logDebug("p.getResName()=" + p.getResName(), null);
          ores = OresHelper.createOLATResourceableInstance(p.getResName(), resId);
          businessControlString = p.getBusinessPath() + "[path=";
        }
       
        Wiki wiki = WikiManager.getInstance().getOrLoadWiki(ores);
        final List<WikiPage> pages = wiki.getPagesByDate();
        Translator translator = Util.createPackageTranslator(WikiPageChangeOrCreateNotificationHandler.class, locale);
       
        TitleItem title = getTitleItem(p, translator);
        si = new SubscriptionInfo(title, null);
          SubscriptionListItem subListItem;
            for (Iterator<WikiPage> it = pages.listIterator(); it.hasNext();) {           
              WikiPage element = it.next();
             
              // do only show entries newer then the ones already seen
              Date modDate = new Date(element.getModificationTime());
              logDebug("modDate=" + modDate + " ; compareDate=" + compareDate, null);
              if (modDate.after(compareDate)) {
                if((element.getPageName().startsWith("O_") || element.getPageName().startsWith(WikiPage.WIKI_MENU_PAGE)) &&
                    (element.getModifyAuthor() <= 0)) {
                    //theses pages are created sometimes automatically. Check if this is the case
                    continue;
                }

                //build Businesscontrol-Path           
                String bControlString = businessControlString + element.getPageName() + "]";           
                String urlToSend = null;
                if(p.getBusinessPath() != null) {
                  urlToSend = NotificationHelper.getURLFromBusinessPathString(p, bControlString);
                }
               
                // string[] gets filled into translation key by adding {0...n} to
                // the string
View Full Code Here

   * @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) {
    SubscriptionInfo si = null;
    Publisher p = subscriber.getPublisher();
    if(!NotificationsUpgradeHelper.checkCourse(p)) {
      //course don't exist anymore
      NotificationsManager.getInstance().deactivate(p);
      return NotificationsManager.getInstance().getNoSubscriptionInfo();
    }
   
    try {
      Date latestNews = p.getLatestNewsDate();
      Identity identity = subscriber.getIdentity();

      // 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 courseId = new Long(p.getData());
        final ICourse course = loadCourseFromId(courseId);
        if (course != null) {
          // course admins or users with the course right to have full access to
          // the assessment tool will have full access to user tests
          CourseGroupManager cgm = course.getCourseEnvironment().getCourseGroupManager();
          final boolean hasFullAccess = (cgm.isIdentityCourseAdministrator(identity) ? true : cgm.hasRight(identity,
              CourseRights.RIGHT_ASSESSMENT));
          final List<Identity> coachedUsers = new ArrayList<Identity>();
          if (!hasFullAccess) {
            // initialize list of users, only when user has not full access
            List<BusinessGroup> coachedGroups = cgm.getOwnedLearningGroupsFromAllContexts(identity);
            Manager securityManager = ManagerFactory.getManager();
            for (Iterator<BusinessGroup> iter = coachedGroups.iterator(); iter.hasNext();) {
              BusinessGroup group = iter.next();
              coachedUsers.addAll(securityManager.getIdentitiesOfSecurityGroup(group.getPartipiciantGroup()));
            }
          }

          List<IQTESTCourseNode> testNodes = getCourseTestNodes(course);
          Translator translator = Util.createPackageTranslator(AssessmentNotificationsHandler.class, locale);

          String title = translator.translate("notifications.header", new String[]{course.getCourseTitle()});
          si = new SubscriptionInfo(new TitleItem(title, CSS_CLASSS_IQTEST_ICON), null);

          for (Iterator<IQTESTCourseNode> i = testNodes.iterator(); i.hasNext();) {
            IQTESTCourseNode test = i.next();

            QTIResultManager qrm = QTIResultManager.getInstance();
            List testResultSets = qrm.getResultSets(course.getResourceableId(), test.getIdent(),
                test.getReferencedRepositoryEntry().getKey(), null);

            for (Iterator j = testResultSets.iterator(); j.hasNext();) {
              QTIResultSet qrs = (QTIResultSet) j.next();
              // - modify date on test set must be newer than last visit of
              // assessment tool
              // - user must either be course administrator (access to all
              // users granted)
              // or in a course right group with the assessment tool right or
              // a course
              // coach. in the second case, only tests of users are shown that
              // the coach does actually
              // coach himself. he does not have access to other users
              Date modDate = qrs.getLastModified();
              if (modDate.after(compareDate) && (hasFullAccess || PersistenceHelper.listContainsObjectByKey(coachedUsers, qrs.getIdentity()))) {
                String score = (new Float(qrs.getScore())).toString();
                String desc = translator.translate("notifications.entry", new String[] { test.getShortTitle(),
                    NotificationHelper.getFormatedName(qrs.getIdentity()), score });

                String urlToSend = null;
                if(p.getBusinessPath() != null) {
                  String businessPath = p.getBusinessPath() + "[assessmentTool:0][Identity:" + qrs.getIdentity().getKey() + "][CourseNode:" + test.getIdent() + "]";
                  urlToSend = NotificationHelper.getURLFromBusinessPathString(p, businessPath);
                }
                SubscriptionListItem subListItem = new SubscriptionListItem(desc, urlToSend, modDate, CSS_CLASS_USER_ICON);
                si.addSubscriptionListItem(subListItem);
              }
View Full Code Here

    CalendarManager calMan = CalendarManagerFactory.getInstance().getCalendarManager();
    NotificationsManager nfm = NotificationsManager.getInstance();
    KalendarRenderWrapper calRenderWrapper = calMan.getGroupCalendar(currBusinessGroup);
    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
    }
   
    bgm.deleteBusinessGroupWithMail(currBusinessGroup, getWindowControl(), ureq, getTranslator(), everybody);

    // 4) update Tables
View Full Code Here

*/
public abstract class AbstractTaskNotificationHandler extends LogDelegator {

 
  public SubscriptionInfo createSubscriptionInfo(Subscriber subscriber, Locale locale, Date compareDate) {
    Publisher p = subscriber.getPublisher();
    Date latestNews = p.getLatestNewsDate();
 
    SubscriptionInfo si;
 
    // there could be news for me, investigate deeper
    try {
      if (NotificationsManager.getInstance().isPublisherValid(p) && compareDate.before(latestNews)) {
        String folderRoot = p.getData();
        if (isLogDebugEnabled()){
          logDebug("folderRoot=", folderRoot);
        }
        final List<FileInfo> fInfos = FolderManager.getFileInfos(folderRoot, compareDate);
        final Translator translator = Util.createPackageTranslator(AbstractTaskNotificationHandler.class, locale);
        String displayName = RepositoryManager.getInstance().lookupDisplayNameByOLATResourceableId(p.getResId());
        if(displayName == null) {
          if(!checkPublisher(p)) {
            return NotificationsManager.getInstance().getNoSubscriptionInfo();
          }
        }
       
        si = new SubscriptionInfo(new TitleItem(translator.translate(getNotificationHeaderKey(), new String[]{displayName}), getCssClassIcon() ), null);
        SubscriptionListItem subListItem;
        for (Iterator<FileInfo> it_infos = fInfos.iterator(); it_infos.hasNext();) {
              FileInfo fi = it_infos.next();
              MetaInfo metaInfo = fi.getMetaInfo();
              String filePath = fi.getRelPath();
              if(isLogDebugEnabled()) logDebug("filePath=", filePath);
              String fullUserName = getUserNameFromFilePath(filePath);
             
              Date modDate = fi.getLastModified();
              String desc = translator.translate(getNotificationEntryKey(), new String[] { filePath, fullUserName });
              String urlToSend = NotificationHelper.getURLFromBusinessPathString(p, p.getBusinessPath());
             
              String iconCssClass =  null;
              if (metaInfo != null) {
                iconCssClass = metaInfo.getIconCssClass();
              }
View Full Code Here

    return publisherData;
  }
 
  public Subscriber getNewUsersSubscriber(Identity identity) {
    SubscriptionContext context = getNewUsersSubscriptionContext();
    Publisher publisher = NotificationsManager.getInstance().getPublisher(context);
    if(publisher == null) {
      return null;
    }
    return NotificationsManager.getInstance().getSubscriber(identity, publisher);
  }
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.