Uploaded image for project: 'OpenOLAT'
  1. OpenOLAT
  2. OO-726

Deleting a bookmarked resource causes a Redscreen in Bookmarks

    XMLWordPrintable

    Details

      Description

      When deleting a resource, the bookmarks associaterd with this resource aren't deleted. When configuring the bookmarks in "Home" you get a Redscreen.

      This patch fixes the deletion process:
      diff -r 4ae804ecc0af src/main/java/org/olat/core/commons/services/mark/MarkManager.java
      — a/src/main/java/org/olat/core/commons/services/mark/MarkManager.java Wed Aug 14 11:28:32 2013 +0200
      +++ b/src/main/java/org/olat/core/commons/services/mark/MarkManager.java Fri Aug 23 15:22:26 2013 +0200
      @@ -26,6 +26,7 @@

      import org.olat.core.id.Identity;
      import org.olat.core.id.OLATResourceable;
      +import org.olat.repository.RepositoryEntry;

      /**

      • @@ -70,5 +71,11 @@
        */
        public void deleteMarks(OLATResourceable ores, String subPath);

      + /**
      + * Delete the marks with resourceableKey for all users
      + * @param resourceableKey
      + */
      + public void deleteMarks(Long resourceableKey);
      +
      public List<MarkResourceStat> getStats(OLATResourceable ores, List<String> subPaths, Identity identity);
      }
      diff -r 4ae804ecc0af src/main/java/org/olat/core/commons/services/mark/impl/MarkManagerImpl.java
      — a/src/main/java/org/olat/core/commons/services/mark/impl/MarkManagerImpl.java Wed Aug 14 11:28:32 2013 +0200
      +++ b/src/main/java/org/olat/core/commons/services/mark/impl/MarkManagerImpl.java Fri Aug 23 15:22:26 2013 +0200
      @@ -36,6 +36,7 @@
      import org.olat.core.commons.services.mark.MarkResourceStat;
      import org.olat.core.id.Identity;
      import org.olat.core.id.OLATResourceable;
      +import org.olat.repository.RepositoryEntry;
      import org.springframework.beans.factory.annotation.Autowired;
      import org.springframework.stereotype.Service;

      @@ -247,6 +248,19 @@
      }

      @Override
      + public void deleteMarks(Long resourceableKey)

      { + StringBuilder sb = new StringBuilder(); + sb.append("delete from ").append(MarkImpl.class.getName()).append(" mark where ") + .append("mark.resId=:resId and mark.resName=:resName"); + + dbInstance.getCurrentEntityManager().createQuery(sb.toString()) + .setParameter("resName", "RepositoryEntry") + .setParameter("resId", resourceableKey.longValue()) + .setFlushMode(FlushModeType.AUTO) + .executeUpdate(); + }

      +
      + @Override
      public List<MarkResourceStat> getStats(OLATResourceable ores, List<String> subPaths, Identity identity) {
      if(subPaths == null || subPaths.isEmpty()) {
      //these stats are optimized
      diff -r 4ae804ecc0af src/main/java/org/olat/repository/RepositoryManager.java
      — a/src/main/java/org/olat/repository/RepositoryManager.java Wed Aug 14 11:28:32 2013 +0200
      +++ b/src/main/java/org/olat/repository/RepositoryManager.java Fri Aug 23 15:22:26 2013 +0200
      @@ -56,7 +56,10 @@
      import org.olat.core.commons.persistence.DBFactory;
      import org.olat.core.commons.persistence.DBQuery;
      import org.olat.core.commons.persistence.PersistenceHelper;
      +import org.olat.core.commons.services.mark.MarkManager;
      +import org.olat.core.commons.services.mark.MarkingService;
      import org.olat.core.commons.services.mark.impl.MarkImpl;
      +import org.olat.core.commons.services.mark.impl.MarkManagerImpl;
      import org.olat.core.gui.UserRequest;
      import org.olat.core.gui.control.WindowControl;
      import org.olat.core.id.Identity;
      @@ -75,6 +78,7 @@
      import org.olat.core.util.image.Size;
      import org.olat.core.util.mail.MailPackage;
      import org.olat.core.util.mail.MailerWithTemplate;
      +import org.olat.core.util.resource.OresHelper;
      import org.olat.core.util.vfs.LocalFolderImpl;
      import org.olat.core.util.vfs.VFSContainer;
      import org.olat.core.util.vfs.VFSItem;
      @@ -85,6 +89,7 @@
      import org.olat.group.GroupLoggingAction;
      import org.olat.group.context.BGContext2Resource;
      import org.olat.group.model.BGResourceRelation;
      +import org.olat.modules.fo.Forum;
      import org.olat.repository.delete.service.RepositoryDeletionManager;
      import org.olat.repository.handlers.RepositoryHandler;
      import org.olat.repository.handlers.RepositoryHandlerFactory;
      @@ -392,6 +397,8 @@

      // delete all bookmarks referencing deleted entry
      //TODO bookmark BookmarkManager.getInstance().deleteAllBookmarksFor(entry);
      + MarkingService markingService = (MarkingService)CoreSpringFactory.getBean(MarkingService.class);
      + markingService.getMarkManager().deleteMarks(entry.getKey());
      // delete all catalog entries referencing deleted entry
      CatalogManager.getInstance().resourceableDeleted(entry);

      But there are still older bookmarks which point to deleted resources. This patch fixes the Redscreen when configuring bookmarks and deletes (for me ) all bookmarks which point to deleted resources:

      diff -r 4ae804ecc0af src/main/java/org/olat/core/commons/services/mark/ui/BookmarksController.java
      — a/src/main/java/org/olat/core/commons/services/mark/ui/BookmarksController.java Wed Aug 14 11:28:32 2013 +0200
      +++ b/src/main/java/org/olat/core/commons/services/mark/ui/BookmarksController.java Fri Aug 23 15:51:29 2013 +0200
      @@ -165,7 +165,9 @@

      for(Mark mark:items)

      { RepositoryEntry repositoryEntry = keyToRepositoryEntryMap.get(mark.getOLATResourceable().getResourceableId()); - convertedList.add(new Bookmark(mark, repositoryEntry)); + if (repositoryEntry != null) + convertedList.add(new Bookmark(mark, repositoryEntry)); + else markManager.removeMark(mark); }

      return convertedList;
      }

        Attachments

          Activity

            People

            • Assignee:
              srosse Stéphane Rossé
              Reporter:
              stephan Stephan Clemenz
            • Votes:
              0 Vote for this issue
              Watchers:
              0 Start watching this issue

              Dates

              • Created:
                Updated:
                Resolved:

                Time Tracking

                Estimated:
                Original Estimate - 0 minutes
                0m
                Remaining:
                Remaining Estimate - 0 minutes
                0m
                Logged:
                Time Spent - 30 minutes
                30m