Package org.olat.modules.webFeed.models

Examples of org.olat.modules.webFeed.models.Feed


      long lastResponseMs = request.getDateHeader("If-Modified-Since");
      Date lastResponse = null;
      if (lastResponseMs != -1) {
        lastResponse = new Date(lastResponseMs);
      }
      Feed feedLight = manager.getFeedLigth(feed);
      Date lastModified = null;
      if (feedLight != null) {
        lastModified = feedLight.getLastModified();
      }
      if (lastResponse != null && lastResponse.before(lastModified)) {
        // Send not modified response
        response.setDateHeader("last-modified", lastModified.getTime());
        try {
View Full Code Here


      // overwriting of changes
      // o_clusterOK by:fg
      CoordinatorManager.getCoordinator().getSyncer().doInSync(feed, new SyncerCallback<Object>() {
        public VFSLeaf execute() {
          // reload feed to prevent stale feed overwriting
          Feed reloadedFeed = readFeed(feed, false);
          // Set the current date as published date.
          if (item.getPublishDate() == null) item.setPublishDate(new Date());

          // Set the file properties to the item and store the file
          setEnclosure(file, item, reloadedFeed);

          // Write the item.xml file
          VFSContainer itemContainer = createItemContainer(feed, item);
          VFSLeaf itemFile = itemContainer.createChildLeaf(ITEM_FILE_NAME);
          XStreamHelper.writeObject(xstream, itemFile, item);

          // finally add the item to the feed
          reloadedFeed.add(item);
          reloadedFeed.setLastModified(item.getLastModified());

          // Save the feed (needed because of itemIds list)
          update(reloadedFeed, false);
          return null;
        }
View Full Code Here

      // overwriting of changes
      // o_clusterOK by:fg
      CoordinatorManager.getCoordinator().getSyncer().doInSync(feed, new SyncerCallback<Object>() {
        public VFSLeaf execute() {
          // reload feed to prevent stale feed overwriting
          Feed reloadedFeed = readFeed(feed, false);
          if (reloadedFeed.getItemIds().contains(item.getGuid())) {
            if (file != null) {
              setEnclosure(file, item, reloadedFeed);
            }
           
            // Write the item.xml file
View Full Code Here

   */
  public Feed updateFeedMode(final Boolean external, final Feed feed) {
    return CoordinatorManager.getCoordinator().getSyncer().doInSync(feed, new SyncerCallback<Feed>() {
      public Feed execute() {
        // reload feed to prevent stale feed overwriting
        Feed reloadedFeed = readFeed(feed, false);
        reloadedFeed.setExternal(external);       
        update(reloadedFeed, false);
        return reloadedFeed;
      }
    });
  }
View Full Code Here

  /**
   * @see org.olat.modules.webFeed.managers.FeedManager#updateFeedMetadata(org.olat.modules.webFeed.models.Feed)
   */
  public Feed updateFeedMetadata(final Feed feed) {
    // reload feed to prevent stale feed overwriting
    final Feed reloadedFeed = readFeed(feed);
    reloadedFeed.setAuthor(feed.getAuthor());
    reloadedFeed.setDescription(feed.getDescription());
    reloadedFeed.setExternalFeedUrl(feed.getExternalFeedUrl());
    reloadedFeed.setExternalImageURL(feed.getExternalImageURL());
    reloadedFeed.setImageName(feed.getImageName());
    reloadedFeed.setTitle(feed.getTitle());
     
    return CoordinatorManager.getCoordinator().getSyncer().doInSync(feed, new SyncerCallback<Feed>() {
      public Feed execute() {
        update(reloadedFeed, false);
        return reloadedFeed;
View Full Code Here

   *      java.lang.String, java.lang.Long)
   */
  @Override
  public MediaResource createFeedFile(OLATResourceable ores, Identity identity, Long courseId, String nodeId) {
    MediaResource media = null;
    Feed feed = readFeed(ores);

    if (feed != null) {
      SyndFeed rssFeed = new RSSFeed(feed, identity, courseId, nodeId);
      media = new SyndFeedMediaResource(rssFeed);
    }
View Full Code Here

    final VFSContainer rootContainer, feedContainer;
    rootContainer = getResourceContainer(resource);
    feedContainer = getFeedContainer(resource);
   
    //prepare fallback for author if needed
    final Feed feed = getFeedLigth(resource, true);
    if(feed.isInternal()) {
      CoordinatorManager.getCoordinator().getSyncer().doInSync(feed, new SyncerCallback<Boolean>() {
        public Boolean execute() { 
          for(Item item : getItems(feed)) {
            if(!item.isAuthorFallbackSet()) {
              //get used authorKey first
View Full Code Here

    try {
      repoEntryName = repositoryEntry.getDisplayname();
      if (log.isDebug()) {
        log.info("Indexing: " + repoEntryName);
      }
      Feed feed = FeedManager.getInstance().readFeed(repositoryEntry.getOlatResource());

      // Set the document type, e.g. type.repository.entry.FileResource.BLOG
      SearchResourceContext nodeSearchContext = new SearchResourceContext(searchResourceContext);
      nodeSearchContext.setBusinessControlFor(node);
      nodeSearchContext.setDocumentType(getDocumentType());

      // Create the olatDocument for the feed course node itself
      OlatDocument feedNodeDoc = new FeedNodeDocument(feed, nodeSearchContext);
      indexer.addDocument(feedNodeDoc.getLuceneDocument());
     
      // Make sure images are displayed properly
      String mapperBaseURL = Path.getFeedBaseUri(feed, null, course.getResourceableId(), node.getIdent());
      Filter mediaUrlFilter = FilterFactory.getBaseURLToMediaRelativeURLFilter(mapperBaseURL);

      // Only index items. Feed itself is indexed by RepositoryEntryIndexer.
      for (Item item : feed.getPublishedItems()) {
        OlatDocument itemDoc = new FeedItemDocument(item, nodeSearchContext, mediaUrlFilter);
        indexer.addDocument(itemDoc.getLuceneDocument());
      }
    } catch (NullPointerException e) {
      log.error("Error indexing feed:" + repoEntryName, e);
View Full Code Here

   *      org.olat.core.gui.control.Event)
   */
  @Override
  protected void event(UserRequest ureq, Component source, @SuppressWarnings("unused") Event event) {
    FeedManager feedManager = FeedManager.getInstance();
    Feed feed = feedManager.readFeed(feedResource);
    if (source == addItemButton) {
      currentItem = new Item();
      currentItem.setDraft(true);
      currentItem.setAuthorKey(ureq.getIdentity().getKey());
      // Generate new GUID for item, needed for media files that are stored relative to the GUID
View Full Code Here

   * @see org.olat.core.gui.control.DefaultController#event(org.olat.core.gui.UserRequest,
   *      org.olat.core.gui.control.Controller, org.olat.core.gui.control.Event)
   */
  protected void event(UserRequest ureq, Controller source, Event event) {
    FeedManager feedManager = FeedManager.getInstance();
    Feed feed = feedManager.readFeed(feedResource);
    if (source == cmc) {
      if (event.equals(CloseableModalController.CLOSE_MODAL_EVENT)) {
        removeAsListenerAndDispose(cmc);
        cmc = null;
        removeAsListenerAndDispose(itemFormCtr);
        itemFormCtr = null;
        // Check if this item has ever been added to the feed. If not, remove the temp dir
        cleanupTmpItemMediaDir(currentItem, feed, feedManager);
        // If there were no items and the user doesn't want to save the
        // first item, go back to the decision whether to make the feed
        // internally or subscribe to an external feed.
        if (!feed.hasItems()) {
          feedManager.updateFeedMode(null, feed);
          makeInternalAndExternalButtons();
        }
      }
    } else if (source == confirmDialogCtr && DialogBoxUIFactory.isYesEvent(event)) {
      // The user confirmed that the item shall be deleted
      Item item = (Item) ((DialogBoxController) source).getUserObject();
      lock = feedManager.acquireLock(feed, item, getIdentity());
      if (lock.isSuccess()) {
        // remove the item from the naviCtr
        naviCtr.remove(item);
        // remove the item also from the helper (cached selection)
        helper.removeItem(item);
        // permanently remove item
        feedManager.remove(item, feed);
        // remove delete and edit buttons of this item
        deleteButtons.remove(source);
        for (Link editButton : editButtons) {
          if (editButton.getUserObject() == item) {
            editButtons.remove(editButton);
            break;
          }
        }
        // If the last item has been deleted, provide buttons for adding
        // items manually or from an external source/feed.
        if (!feed.hasItems()) {
          makeInternalAndExternalButtons();
          // The subscription/feed url from the feed info is obsolete
          fireEvent(ureq, ItemsController.FEED_INFO_IS_DIRTY_EVENT);
        }
        vcItems.setDirty(true);
        // in case we were in single item view, show all items
        mainPanel.setContent(vcItems);
        feedManager.releaseLock(lock);
        lock = null;       
        // do logging
        ThreadLocalUserActivityLogger.log(FeedLoggingAction.FEED_ITEM_DELETE, getClass(), LoggingResourceable.wrap(item));

      } else {
        showInfo("feed.item.is.being.edited.by", lock.getOwner().getName());
      }

    } else if (source == itemFormCtr) {
      if (event.equals(Event.CHANGED_EVENT) || event.equals(Event.CANCELLED_EVENT)) {
        if (event.equals(Event.CHANGED_EVENT)) {
          FileElement mediaFile = currentItem.getMediaFile();
          if (!feed.getItems().contains(currentItem)) {
            // Add the modified item if it is not part of the feed
            feedManager.addItem(currentItem, mediaFile, feed);
            createButtonsForItem(currentItem);
            createItemLink(currentItem);
            // Add date component
            String guid = currentItem.getGuid();
            if(currentItem.getDate() != null) {
              DateComponentFactory.createDateComponentWithYear("date." + guid, currentItem.getDate(), vcItems);
            }
            // Add comments and rating
            createCommentsAndRatingsLink(ureq, feed, currentItem);
            // add it to the navigation controller
            naviCtr.add(currentItem);
            // ... and also to the helper
            helper.addItem(currentItem);
            if (feed.getItems().size() == 1) {
              // First item added, show feed url (for subscription)
              fireEvent(ureq, ItemsController.FEED_INFO_IS_DIRTY_EVENT);
              // Set the base URI of the feed for the current user. All users
              // have unique URIs.
              helper.setURIs();
            }
            // do logging
            ThreadLocalUserActivityLogger.log(FeedLoggingAction.FEED_ITEM_CREATE, getClass(), LoggingResourceable.wrap(currentItem));
          } else {
            // write item file
            feedManager.updateItem(currentItem, mediaFile, feed);
            // do logging
            ThreadLocalUserActivityLogger.log(FeedLoggingAction.FEED_ITEM_EDIT, getClass(), LoggingResourceable.wrap(currentItem));
          }
          vcItems.setDirty(true);
          // if the current item is displayed, update the view
          if (itemCtr != null) {
            itemCtr.getInitialComponent().setDirty(true);
          }

        } else if (event.equals(Event.CANCELLED_EVENT)) {
          // Check if this item has ever been added to the feed. If not, remove the temp dir
          cleanupTmpItemMediaDir(currentItem, feed, feedManager);
          // If there were no items and the user doesn't want to save the
          // first item, go back to the decision whether to make the feed
          // internally or subscribe to an external feed.
          if (!feed.hasItems()) {
            feedManager.updateFeedMode(null, feed);
            makeInternalAndExternalButtons();
          }
        }
        // release the lock
View Full Code Here

TOP

Related Classes of org.olat.modules.webFeed.models.Feed

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.