Package org.olat.modules.webFeed.models

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


  private ItemController displayItemController(UserRequest ureq, Item item) {
    removeAsListenerAndDispose(itemCtr);
    Link editButton = getButtonByUserObject(item, editButtons);
    Link deleteButton = getButtonByUserObject(item, deleteButtons);
    FeedManager feedManager = FeedManager.getInstance();
    Feed feed = feedManager.readFeed(feedResource);
    itemCtr = new ItemController(ureq, getWindowControl(), item, feed, helper, uiFactory, callback, editButton, deleteButton);
    listenTo(itemCtr);
    mainPanel.setContent(itemCtr.getInitialComponent());
    return itemCtr;
  }
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.setDocumentType(getDocumentType());
      searchResourceContext.setParentContextType(getDocumentType());
      searchResourceContext.setParentContextName(repoEntryName);

      // Make sure images are displayed properly
      // TODO:GW It's only working for public resources, because base url is
      // personal. -> fix
      String mapperBaseURL = Path.getFeedBaseUri(feed, null, null, null);
      Filter mediaUrlFilter = FilterFactory.getBaseURLToMediaRelativeURLFilter(mapperBaseURL);

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

   */
  private OLATResourceable createFeedResource(FeedFileResource feedResource) {
    OLATResourceManager rm = OLATResourceManager.getInstance();
    OLATResource ores = rm.createOLATResourceInstance(feedResource);
    rm.saveOLATResource(ores);
    Feed feed = new Feed(feedResource);
    VFSContainer podcastContainer = getFeedContainer(feedResource);
    VFSLeaf leaf = podcastContainer.createChildLeaf(FEED_FILE_NAME);
    podcastContainer.createChildContainer(MEDIA_DIR);
    podcastContainer.createChildContainer(ITEMS_DIR);
    XStreamHelper.writeObject(xstream, leaf, feed);
View Full Code Here

  public Feed readFeed(OLATResourceable ores) {
    return readFeed(ores, true);
  }
 
  Feed readFeed(OLATResourceable ores, boolean inSync) {
    Feed feed = (Feed) initFeedCache().get(ores.getResourceableId().toString());
    if (feed == null) {
      feed = getFeedLigth(ores, inSync);
      getItems(feed);
    } else if (feed.getItems() == null || feed.getItems().size() == 0) {
      getItems(feed);
    }
    return feed;
  }
View Full Code Here

    return getFeedLigth(ores, true);
  }
 
  private Feed getFeedLigth(OLATResourceable ores, boolean inSync) {
    // Attempt to fetch the feed from the cache
    Feed myFeed = (Feed) initFeedCache().get(ores.getResourceableId().toString());
    if (myFeed == null) {
      // Load the feed from file and put it to the cache
      VFSContainer feedContainer = getFeedContainer(ores);
      myFeed = readFeedFile(feedContainer);
      if (myFeed != null) {
        // Reset the feed id. (This is necessary for imported feeds.)
        myFeed.setId(ores.getResourceableId());
        // Get repository entry information
        enrichFeedByRepositoryEntryInfromation(myFeed);
        // must be final for sync
        final Feed feed = myFeed;
        syncedFeedCacheUpdate(feed, inSync);
      }
    }
    return myFeed;
  }
View Full Code Here

   *
   * @param feedContainer
   * @return The Feed upon success
   */
  public static Feed readFeedFile(VFSContainer feedContainer) {
    Feed myFeed = null;
    if (feedContainer != null) {
      VFSLeaf leaf = (VFSLeaf) feedContainer.resolve(FEED_FILE_NAME);
      if (leaf != null) {
        myFeed = (Feed) XStreamHelper.readObject(xstream, leaf.getInputStream());
      }
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);
        reloadedFeed.remove(item);
        // If the last item has been removed, set the feed to undefined.
        // The user can then newly decide whether to add items manually or from
        // an external source.
        if (!reloadedFeed.hasItems()) {
          // set undefined
          reloadedFeed.setExternal(null);
        }
       
        // Delete the item's container on the virtual file system.
        VFSContainer itemContainer = getItemContainer(item, reloadedFeed);
        if (itemContainer != null) {
          itemContainer.delete();
        }
       
        // Update feed
        reloadedFeed.setLastModified(new Date());
        update(reloadedFeed, false);
       
        // Delete comments and ratings
        CommentAndRatingService commentAndRatingService = (CommentAndRatingService) ServiceFactory.getServiceOrNull(CommentAndRatingService.class);
        if (commentAndRatingService != null) {       
View Full Code Here

  public FeedPeekviewController(OLATResource olatResource, UserRequest ureq, WindowControl wControl, FeedSecurityCallback callback,
      Long courseId, String nodeId, FeedUIFactory feedUIFactory, int itemsToDisplay, String wrapperCssClass) {
    super(ureq, wControl);
    this.nodeId = nodeId;
    FeedManager feedManager = FeedManager.getInstance();
    Feed feed = feedManager.readFeed(olatResource);

    VelocityContainer peekviewVC = createVelocityContainer("peekview");
    peekviewVC.contextPut("wrapperCssClass", wrapperCssClass != null ? wrapperCssClass : "");
    // add gui helper
    FeedViewHelper helper = new FeedViewHelper(feed, getIdentity(), getTranslator(), courseId, nodeId, callback);
View Full Code Here

      // ____/item
      // ______...
      VFSContainer root = new LocalFolderImpl(directory);
      // try to read podcast
      try {
        Feed feed = FeedManagerImpl.readFeedFile(root);
        if (feed != null) {
          // The feed is valid, let's check the items
          if (feed.isInternal()) {
            List<String> itemIds = feed.getItemIds();
            VFSContainer itemsContainer = (VFSContainer) root.resolve(FeedManagerImpl.ITEMS_DIR);
            if (itemsContainer == null) {
              valid = itemIds.isEmpty(); //empty podcast
            } else {
              int validItemsCount = 0;
              for (String itemId : itemIds) {
                // Try loading each item
                VFSItem itemContainer = itemsContainer.resolve(itemId);
                Item item = FeedManagerImpl.loadItem(itemContainer);
                if (item != null) {
                  // This item is valid, increase the counter
                  validItemsCount++;
                }
              }
              if (validItemsCount == itemIds.size()) {
                // The feed and all items are valid
                valid = true;
              }
            }
          } else if (feed.isExternal()) {
            // assume the feed url is valid.
            valid = true;
          } else if (feed.isUndefined()) {
            // the feed is empty.
            valid = true;
          }
          // check type
          if (!type.equals(feed.getResourceableTypeName())) {
            valid = false;
          }
        }
      } catch (Exception e) {
        // Reading feed failed, the directory is hence invalid
View Full Code Here

  /**
   * Test method create
   */
  public void testCreatePodcast() {
    OLATResourceable podcastResource = feedManager.createPodcastResource();
    Feed newPodcast = feedManager.readFeed(podcastResource);
    assertNotNull(newPodcast);
    assertNotNull(newPodcast.getId());

    // Has a feed folder been created?
    VFSContainer podcastContainer = feedManager.getFeedContainer(newPodcast);
    assertNotNull(podcastContainer);
    feedManager.delete(newPodcast);
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.