Class SessionStoreBookmarkManager

java.lang.Object
io.goobi.viewer.model.bookmark.SessionStoreBookmarkManager

public class SessionStoreBookmarkManager extends Object
This class handles the bookmark list stored in the session store
Author:
Florian Alpers
  • Field Details

    • BOOKMARK_LIST_ATTRIBUTE_NAME

      public static final String BOOKMARK_LIST_ATTRIBUTE_NAME
      Constant BOOKMARK_LIST_ATTRIBUTE_NAME="bookmarkList"
      See Also:
  • Constructor Details

    • SessionStoreBookmarkManager

      public SessionStoreBookmarkManager()
  • Method Details

    • getBookmarkList

      public Optional<BookmarkList> getBookmarkList(javax.servlet.http.HttpSession session)

      getBookmarkList.

      Parameters:
      session - a HttpSession object.
      Returns:
      An optional containing the stored bookmark list if one exists
      Throws:
      NullPointerException - if the session is NULL
    • createBookmarkList

      public BookmarkList createBookmarkList(javax.servlet.http.HttpSession session)
      Create a new BookmarkList and store it in the session store in the attribute "bookmarkList"
      Parameters:
      session - a HttpSession object.
      Returns:
      a BookmarkList object.
      Throws:
      IllegalArgumentException - if a bookmark list already exists
      IllegalStateException - if the bookmark list could not be stored in the session
      NullPointerException - if the session is NULL
    • getOrCreateBookmarkList

      public BookmarkList getOrCreateBookmarkList(javax.servlet.http.HttpSession session)
      Gets the bookmark list stored in the session. If no bookmark list exists, a new one is created, stored and returned
      Parameters:
      session - a HttpSession object.
      Returns:
      a BookmarkList object.
      Throws:
      NullPointerException - if the session is NULL
    • addToBookmarkList

      public boolean addToBookmarkList(Bookmark item, javax.servlet.http.HttpSession session)
      Adds the given item to the session bookmark list, creating a new bookmark list if required
      Parameters:
      item - a Bookmark object.
      session - a HttpSession object.
      Returns:
      false if the item could not be added (usually because it already exists), true otherwise
      Throws:
      NullPointerException - if the session is NULL
    • removeFromBookself

      public boolean removeFromBookself(Bookmark item, javax.servlet.http.HttpSession session)
      Remove the given item (or one with identical pi, logId and order) from the session bookmark list if it exists If no session bookmark list exists, it doesn't contain the item or the item could not be removed for some other reason, false is returned
      Parameters:
      item - a Bookmark object.
      session - a HttpSession object.
      Returns:
      a boolean.
      Throws:
      NullPointerException - if the session is NULL
    • deleteBookmarkList

      public void deleteBookmarkList(javax.servlet.http.HttpSession session)

      deleteBookmarkList.

      Parameters:
      session - a HttpSession object.
      Throws:
      NullPointerException - if the session is NULL
    • isInBookmarkList

      public boolean isInBookmarkList(Bookmark item, javax.servlet.http.HttpSession session)

      isInBookmarkList.

      Parameters:
      item - a Bookmark object.
      session - a HttpSession object.
      Returns:
      a boolean.
    • addSessionBookmarkListToUser

      public void addSessionBookmarkListToUser(User user, javax.servlet.http.HttpServletRequest request) throws DAOException
      Assigns the current session bookmark list (if any) to the given user and saves the bookmark list to the database The bookmark list gets a newly generated name provided by generateNewBookmarkListName(List)
      Parameters:
      user - a User object.
      request - a HttpServletRequest object.
      Throws:
      DAOException - if any.
    • generateNewBookmarkListName

      public static String generateNewBookmarkListName(List<BookmarkList> bookmarkLists)
      Returns a String of the pattern "List {n}" where {n} is the lowest positive integer such that no bookmark list named "List {n}" exists in the given list
      Parameters:
      bookmarkLists - a List object.
      Returns:
      a String object.
    • generateBookmarkListInfo

      public static String generateBookmarkListInfo(String text, String itemText, String emptyListText, BookmarkList bookmarkList)
      This embedds the bookmark list items within a text, to be used in autogenerated mails describing the bookmark list The parameter text contains the complete text with a placeholder {0} which is replaced by the text generated from the bookmarks. itemText is the text for each bookmark with placeholder {0} which is replaced by the link to the bookmarked item, and {1} which is replaced by the title of that item. The parameter bookmarkList is the bookmark list containing the items to be inserted
      Parameters:
      text - a String object.
      itemText - a String object.
      emptyListText - a String object.
      bookmarkList - a BookmarkList object.
      Returns:
      a String object.