Package io.goobi.viewer.model.bookmark
Class SessionStoreBookmarkManager
java.lang.Object
io.goobi.viewer.model.bookmark.SessionStoreBookmarkManager
This class handles the bookmark list stored in the session store
- Author:
- Florian Alpers
-
Field Summary
Modifier and TypeFieldDescriptionstatic final String
ConstantBOOKMARK_LIST_ATTRIBUTE_NAME="bookmarkList"
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionvoid
addSessionBookmarkListToUser
(User user, javax.servlet.http.HttpServletRequest request) 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 bygenerateNewBookmarkListName(List)
boolean
addToBookmarkList
(Bookmark item, javax.servlet.http.HttpSession session) Adds the given item to the session bookmark list, creating a new bookmark list if requiredcreateBookmarkList
(javax.servlet.http.HttpSession session) Create a new BookmarkList and store it in the session store in the attribute "bookmarkList"void
deleteBookmarkList
(javax.servlet.http.HttpSession session) deleteBookmarkList.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 parametertext
contains the complete text with a placeholder {0} which is replaced by the text generated from the bookmarks.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 listgetBookmarkList
(javax.servlet.http.HttpSession session) getBookmarkList.getOrCreateBookmarkList
(javax.servlet.http.HttpSession session) Gets the bookmark list stored in the session.boolean
isInBookmarkList
(Bookmark item, javax.servlet.http.HttpSession session) isInBookmarkList.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
-
Field Details
-
BOOKMARK_LIST_ATTRIBUTE_NAME
ConstantBOOKMARK_LIST_ATTRIBUTE_NAME="bookmarkList"
- See Also:
-
-
Constructor Details
-
SessionStoreBookmarkManager
public SessionStoreBookmarkManager()
-
-
Method Details
-
getBookmarkList
getBookmarkList.
- Parameters:
session
- aHttpSession
object.- Returns:
- An optional containing the stored bookmark list if one exists
- Throws:
NullPointerException
- if the session is NULL
-
createBookmarkList
Create a new BookmarkList and store it in the session store in the attribute "bookmarkList"- Parameters:
session
- aHttpSession
object.- Returns:
- a
BookmarkList
object. - Throws:
IllegalArgumentException
- if a bookmark list already existsIllegalStateException
- if the bookmark list could not be stored in the sessionNullPointerException
- if the session is NULL
-
getOrCreateBookmarkList
Gets the bookmark list stored in the session. If no bookmark list exists, a new one is created, stored and returned- Parameters:
session
- aHttpSession
object.- Returns:
- a
BookmarkList
object. - Throws:
NullPointerException
- if the session is NULL
-
addToBookmarkList
Adds the given item to the session bookmark list, creating a new bookmark list if required- Parameters:
item
- aBookmark
object.session
- aHttpSession
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
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
- aBookmark
object.session
- aHttpSession
object.- Returns:
- a boolean.
- Throws:
NullPointerException
- if the session is NULL
-
deleteBookmarkList
public void deleteBookmarkList(javax.servlet.http.HttpSession session) deleteBookmarkList.
- Parameters:
session
- aHttpSession
object.- Throws:
NullPointerException
- if the session is NULL
-
isInBookmarkList
isInBookmarkList.
- Parameters:
item
- aBookmark
object.session
- aHttpSession
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 bygenerateNewBookmarkListName(List)
- Parameters:
user
- aUser
object.request
- aHttpServletRequest
object.- Throws:
DAOException
- if any.
-
generateNewBookmarkListName
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 -
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 parametertext
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 parameterbookmarkList
is the bookmark list containing the items to be inserted- Parameters:
text
- aString
object.itemText
- aString
object.emptyListText
- aString
object.bookmarkList
- aBookmarkList
object.- Returns:
- a
String
object.
-