Package org.olat.modules.webFeed.managers

Examples of org.olat.modules.webFeed.managers.FeedManager


    // hence we need to do an intermediateCommit here
    DBFactory.getInstance().intermediateCommit();

    // Create the resource to be delivered
    MediaResource resource = null;
    FeedManager manager = FeedManager.getInstance();

    if (path.isFeedType()) {
      // Only create feed if modified. Send not modified response else.
      Identity identity = getIdentity(path.getIdentityKey());
      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 {
          response.sendError(HttpServletResponse.SC_NOT_MODIFIED);
          return;
        } catch (IOException e) {
          // Send not modified failed
          log.error("Send not modified failed", e);
          return;
        }
      } else {
        resource = manager.createFeedFile(feed, identity, path.getCourseId(), path.getNodeId());
      }
    } else if (path.isItemType()) {
      resource = manager.createItemMediaFile(feed, path.getItemId(), path.getItemFileName());
    } else if (path.isIconType()) {
      resource = manager.createFeedMediaFile(feed, path.getIconFileName());
    }
    // Eventually deliver the requested resource
    ServletUtil.serveResource(request, response, resource);
  }
View Full Code Here


  /**
   * @see org.olat.repository.handlers.RepositoryHandler#createCopy(org.olat.core.id.OLATResourceable,
   *      org.olat.core.gui.UserRequest)
   */
  public OLATResourceable createCopy(OLATResourceable res, UserRequest ureq) {
    FeedManager manager = FeedManager.getInstance();
    return manager.copy(res);
  }
View Full Code Here

  /**
   * @see org.olat.repository.handlers.RepositoryHandler#getAsMediaResource(org.olat.core.id.OLATResourceable)
   */
  public MediaResource getAsMediaResource(OLATResourceable res) {
    FeedManager manager = FeedManager.getInstance();
    return manager.getFeedArchiveMediaResource(res);
  }
View Full Code Here

   *      org.olat.core.gui.components.Component,
   *      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
      currentItem.setGuid(CodeHelper.getGlobalForeverUniqueID());
      // Create item and media containers
      feedManager.createItemContainer(feed, currentItem);
      itemFormCtr = uiFactory.createItemFormController(ureq, getWindowControl(), currentItem, feed);
      activateModalDialog(itemFormCtr);

    } else if (editButtons != null && editButtons.contains(source)) {
      currentItem = (Item) ((Link) source).getUserObject();
      lock = feedManager.acquireLock(feed, currentItem, getIdentity());
      if (lock.isSuccess()) {

        itemFormCtr = uiFactory.createItemFormController(ureq, getWindowControl(), currentItem, feed);
        activateModalDialog(itemFormCtr);
      } else {
        showInfo("feed.item.is.being.edited.by", lock.getOwner().getName());
      }
    } else if (deleteButtons != null && deleteButtons.contains(source)) {
      Item item = (Item) ((Link) source).getUserObject();
      confirmDialogCtr = activateYesNoDialog(ureq, null, translate("feed.item.confirm.delete"), confirmDialogCtr);
      confirmDialogCtr.setUserObject(item);

    } else if (itemLinks != null && itemLinks.contains(source)) {
      Item item = (Item) ((Link) source).getUserObject();
      displayItemController(ureq, item);

    } else if (source == makeInternalButton) {
      feedManager.updateFeedMode(Boolean.FALSE, feed);
      addItemButton = LinkFactory.createButton("feed.add.item", vcItems, this);
      currentItem = new Item();
      currentItem.setAuthorKey(ureq.getIdentity().getKey());
      // Generate new GUID for item, needed for media files that are stored relative to the GUID
      currentItem.setGuid(CodeHelper.getGlobalForeverUniqueID());
      // Create item and media containers
      feedManager.createItemContainer(feed, currentItem);
      itemFormCtr = uiFactory.createItemFormController(ureq, getWindowControl(), currentItem, feed);
      activateModalDialog(itemFormCtr);
      // do logging
      ThreadLocalUserActivityLogger.log(FeedLoggingAction.FEED_EDIT, getClass(), LoggingResourceable.wrap(feed));

    } else if (source == makeExternalButton) {
      feedManager.updateFeedMode(Boolean.TRUE, feed);
      vcItems.setDirty(true);
      // Ask listening FeedMainController to open and handle a new external
      // feed dialog.
      fireEvent(ureq, HANDLE_NEW_EXTERNAL_FEED_DIALOG_EVENT);
      // do logging
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
        feedManager.releaseLock(lock);

        // Dispose the cmc and the podcastFormCtr.
        cmc.deactivate();
        removeAsListenerAndDispose(cmc);
        cmc = null;
View Full Code Here

   */
  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

   * @param wControl
   */
  protected CreateBlogController(RepositoryAddCallback addCallback, UserRequest ureq, WindowControl wControl) {
    super(wControl);
    if (addCallback != null) {
      FeedManager manager = FeedManager.getInstance();
      // Create a new podcast feed resource
      feedResource = manager.createBlogResource();
      Translator trans = new PackageTranslator("org.olat.repository", ureq.getLocale());
      addCallback.setDisplayName(trans.translate(feedResource.getResourceableTypeName()));
      addCallback.setResourceable(feedResource);
      addCallback.setResourceName(manager.getFeedKind(feedResource));
      addCallback.finished(ureq);
    }
  }
View Full Code Here

   * @param wControl
   */
  protected CreatePodcastController(RepositoryAddCallback addCallback, UserRequest ureq, WindowControl wControl) {
    super(wControl);
    if (addCallback != null) {
      FeedManager manager = FeedManager.getInstance();
      // Create a new podcast feed resource
      feedResource = manager.createPodcastResource();
      Translator trans = new PackageTranslator("org.olat.repository", ureq.getLocale());
      addCallback.setDisplayName(trans.translate(feedResource.getResourceableTypeName()));
      addCallback.setResourceable(feedResource);
      addCallback.setResourceName(manager.getFeedKind(feedResource));
      addCallback.finished(ureq);
    }
  }
View Full Code Here

  /**
   * @see org.olat.repository.handlers.RepositoryHandler#createCopy(org.olat.core.id.OLATResourceable,
   *      org.olat.core.gui.UserRequest)
   */
  public OLATResourceable createCopy(OLATResourceable res, UserRequest ureq) {
    FeedManager manager = FeedManager.getInstance();
    return manager.copy(res);
  }
View Full Code Here

  /**
   * @see org.olat.repository.handlers.RepositoryHandler#getAsMediaResource(org.olat.core.id.OLATResourceable)
   */
  public MediaResource getAsMediaResource(OLATResourceable res) {
    FeedManager manager = FeedManager.getInstance();
    return manager.getFeedArchiveMediaResource(res);
  }
View Full Code Here

TOP

Related Classes of org.olat.modules.webFeed.managers.FeedManager

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.