Program: 69866
Project: 69866
Buggy source:
/** 
 * @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.getFeed(feedResource);
  vcItems.contextPut("String_Node_Str",feed);
  if (source == cmc) {
    if (event.equals(CloseableModalController.CLOSE_MODAL_EVENT)) {
      removeAsListenerAndDispose(cmc);
      cmc=null;
      removeAsListenerAndDispose(itemFormCtr);
      itemFormCtr=null;
      cleanupTmpItemMediaDir(currentItem,feed,feedManager);
      if (!feed.hasItems()) {
        feedManager.updateFeedMode(null,feed);
        makeInternalAndExternalButtons();
      }
      feedManager.releaseLock(lock);
    }
  }
 else   if (source == confirmDialogCtr && DialogBoxUIFactory.isYesEvent(event)) {
    Item item=(Item)((DialogBoxController)source).getUserObject();
    lock=feedManager.acquireLock(feed,item,getIdentity());
    if (lock.isSuccess()) {
      naviCtr.remove(item);
      helper.removeItem(item);
      feedManager.remove(item,feed);
      deleteButtons.remove(source);
      for (      Link editButton : editButtons) {
        if (editButton.getUserObject() == item) {
          editButtons.remove(editButton);
          break;
        }
      }
      if (!feed.hasItems()) {
        makeInternalAndExternalButtons();
        fireEvent(ureq,ItemsController.FEED_INFO_IS_DIRTY_EVENT);
      }
 else {
        if (callback.mayEditItems() || callback.mayCreateItems()) {
          createEditButtons(ureq,feed);
        }
        createCommentsAndRatingsLinks(ureq,feed);
      }
      vcItems.setDirty(true);
      mainPanel.setContent(vcItems);
      feedManager.releaseLock(lock);
      lock=null;
      ThreadLocalUserActivityLogger.log(FeedLoggingAction.FEED_ITEM_DELETE,getClass(),LoggingResourceable.wrap(item));
    }
 else {
      showInfo("String_Node_Str",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 (feedManager.getItemContainer(currentItem,feed) == null) {
          naviCtr.remove(currentItem);
          helper.removeItem(currentItem);
        }
 else {
          if (!feed.getItems().contains(currentItem)) {
            feedManager.addItem(currentItem,mediaFile,feed);
            createButtonsForItem(ureq,currentItem);
            createItemLink(currentItem);
            String guid=currentItem.getGuid();
            if (currentItem.getDate() != null) {
              DateComponentFactory.createDateComponentWithYear("String_Node_Str" + guid,currentItem.getDate(),vcItems);
            }
            createCommentsAndRatingsLink(ureq,feed,currentItem);
            naviCtr.add(currentItem);
            helper.addItem(currentItem);
            if (feed.getItems().size() == 1) {
              fireEvent(ureq,ItemsController.FEED_INFO_IS_DIRTY_EVENT);
              helper.setURIs();
            }
            ThreadLocalUserActivityLogger.log(FeedLoggingAction.FEED_ITEM_CREATE,getClass(),LoggingResourceable.wrap(currentItem));
          }
 else {
            feedManager.updateItem(currentItem,mediaFile,feed);
            helper.updateItem(currentItem);
            ThreadLocalUserActivityLogger.log(FeedLoggingAction.FEED_ITEM_EDIT,getClass(),LoggingResourceable.wrap(currentItem));
          }
        }
        vcItems.setDirty(true);
        if (itemCtr != null) {
          itemCtr.getInitialComponent().setDirty(true);
        }
      }
 else       if (event.equals(Event.CANCELLED_EVENT)) {
        cleanupTmpItemMediaDir(currentItem,feed,feedManager);
        if (!feed.hasItems()) {
          feedManager.updateFeedMode(null,feed);
          makeInternalAndExternalButtons();
        }
      }
      feedManager.releaseLock(lock);
      cmc.deactivate();
      removeAsListenerAndDispose(cmc);
      cmc=null;
      removeAsListenerAndDispose(itemFormCtr);
      itemFormCtr=null;
    }
  }
 else   if (source == naviCtr && event instanceof NavigationEvent) {
    List<? extends Dated> selItems=((NavigationEvent)event).getSelectedItems();
    List<Item> items=new ArrayList<Item>();
    for (    Dated item : selItems) {
      if (item instanceof Item) {
        items.add((Item)item);
      }
    }
    Collections.sort(items,new ItemPublishDateComparator());
    helper.setSelectedItems(items);
    if (callback.mayEditItems() || callback.mayCreateItems()) {
      createEditButtons(ureq,feed);
    }
    createCommentsAndRatingsLinks(ureq,feed);
    vcItems.setDirty(true);
    mainPanel.setContent(vcItems);
  }
 else   if (source == itemCtr) {
    if (event == Event.BACK_EVENT) {
      mainPanel.setContent(vcItems);
    }
  }
 else   if (source instanceof UserCommentsAndRatingsController) {
    UserCommentsAndRatingsController commentsRatingsCtr=(UserCommentsAndRatingsController)source;
    if (event == UserCommentsAndRatingsController.EVENT_COMMENT_LINK_CLICKED) {
      Item item=(Item)commentsRatingsCtr.getUserObject();
      ItemController myItemCtr=displayItemController(ureq,item);
      List<ContextEntry> entries=BusinessControlFactory.getInstance().createCEListFromResourceType(ItemController.ACTIVATION_KEY_COMMENTS);
      myItemCtr.activate(ureq,entries,null);
    }
  }
  if (!isSameAllItems(feed.getFilteredItems(callback,ureq.getIdentity()))) {
    resetItems(ureq,feed);
  }
}

Fixed version (ground truth):
/** 
 * @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.getFeed(feedResource);
  vcItems.contextPut("String_Node_Str",feed);
  if (source == cmc) {
    if (event.equals(CloseableModalController.CLOSE_MODAL_EVENT)) {
      removeAsListenerAndDispose(cmc);
      cmc=null;
      removeAsListenerAndDispose(itemFormCtr);
      itemFormCtr=null;
      cleanupTmpItemMediaDir(currentItem,feed,feedManager);
      if (!feed.hasItems()) {
        feedManager.updateFeedMode(null,feed);
        makeInternalAndExternalButtons();
      }
      feedManager.releaseLock(lock);
    }
  }
 else   if (source == confirmDialogCtr && DialogBoxUIFactory.isYesEvent(event)) {
    Item item=(Item)((DialogBoxController)source).getUserObject();
    lock=feedManager.acquireLock(feed,item,getIdentity());
    if (lock.isSuccess()) {
      naviCtr.remove(item);
      helper.removeItem(item);
      feed=feedManager.remove(item,feed);
      deleteButtons.remove(source);
      for (      Link editButton : editButtons) {
        if (item.equals(editButton.getUserObject())) {
          editButtons.remove(editButton);
          break;
        }
      }
      if (!feed.hasItems()) {
        makeInternalAndExternalButtons();
        fireEvent(ureq,ItemsController.FEED_INFO_IS_DIRTY_EVENT);
      }
 else {
        if (callback.mayEditItems() || callback.mayCreateItems()) {
          createEditButtons(ureq,feed);
        }
        createCommentsAndRatingsLinks(ureq,feed);
      }
      vcItems.setDirty(true);
      mainPanel.setContent(vcItems);
      feedManager.releaseLock(lock);
      lock=null;
      ThreadLocalUserActivityLogger.log(FeedLoggingAction.FEED_ITEM_DELETE,getClass(),LoggingResourceable.wrap(item));
    }
 else {
      showInfo("String_Node_Str",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 (feedManager.getItemContainer(currentItem,feed) == null) {
          naviCtr.remove(currentItem);
          helper.removeItem(currentItem);
        }
 else {
          if (!feed.getItems().contains(currentItem)) {
            feed=feedManager.addItem(currentItem,mediaFile,feed);
            createButtonsForItem(ureq,currentItem);
            createItemLink(currentItem);
            String guid=currentItem.getGuid();
            if (currentItem.getDate() != null) {
              DateComponentFactory.createDateComponentWithYear("String_Node_Str" + guid,currentItem.getDate(),vcItems);
            }
            createCommentsAndRatingsLink(ureq,feed,currentItem);
            naviCtr.add(currentItem);
            helper.addItem(currentItem);
            if (feed.getItems().size() == 1) {
              fireEvent(ureq,ItemsController.FEED_INFO_IS_DIRTY_EVENT);
              helper.setURIs();
            }
            ThreadLocalUserActivityLogger.log(FeedLoggingAction.FEED_ITEM_CREATE,getClass(),LoggingResourceable.wrap(currentItem));
          }
 else {
            feed=feedManager.updateItem(currentItem,mediaFile,feed);
            helper.updateItem(currentItem);
            ThreadLocalUserActivityLogger.log(FeedLoggingAction.FEED_ITEM_EDIT,getClass(),LoggingResourceable.wrap(currentItem));
          }
        }
        vcItems.setDirty(true);
        if (itemCtr != null) {
          itemCtr.getInitialComponent().setDirty(true);
        }
      }
 else       if (event.equals(Event.CANCELLED_EVENT)) {
        cleanupTmpItemMediaDir(currentItem,feed,feedManager);
        if (!feed.hasItems()) {
          feedManager.updateFeedMode(null,feed);
          makeInternalAndExternalButtons();
        }
      }
      feedManager.releaseLock(lock);
      cmc.deactivate();
      removeAsListenerAndDispose(cmc);
      cmc=null;
      removeAsListenerAndDispose(itemFormCtr);
      itemFormCtr=null;
    }
  }
 else   if (source == naviCtr && event instanceof NavigationEvent) {
    List<? extends Dated> selItems=((NavigationEvent)event).getSelectedItems();
    List<Item> items=new ArrayList<Item>();
    for (    Dated item : selItems) {
      if (item instanceof Item) {
        items.add((Item)item);
      }
    }
    Collections.sort(items,new ItemPublishDateComparator());
    helper.setSelectedItems(items);
    if (callback.mayEditItems() || callback.mayCreateItems()) {
      createEditButtons(ureq,feed);
    }
    createCommentsAndRatingsLinks(ureq,feed);
    vcItems.setDirty(true);
    mainPanel.setContent(vcItems);
  }
 else   if (source == itemCtr) {
    if (event == Event.BACK_EVENT) {
      mainPanel.setContent(vcItems);
    }
  }
 else   if (source instanceof UserCommentsAndRatingsController) {
    UserCommentsAndRatingsController commentsRatingsCtr=(UserCommentsAndRatingsController)source;
    if (event == UserCommentsAndRatingsController.EVENT_COMMENT_LINK_CLICKED) {
      Item item=(Item)commentsRatingsCtr.getUserObject();
      ItemController myItemCtr=displayItemController(ureq,item);
      List<ContextEntry> entries=BusinessControlFactory.getInstance().createCEListFromResourceType(ItemController.ACTIVATION_KEY_COMMENTS);
      myItemCtr.activate(ureq,entries,null);
    }
  }
  if (!isSameAllItems(feed.getFilteredItems(callback,ureq.getIdentity()))) {
    resetItems(ureq,feed);
  }
}