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
FieldsModifier and TypeFieldDescriptionstatic final StringConstantBOOKMARK_LIST_ATTRIBUTE_NAME="bookmarkList" -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoidaddSessionBookmarkListToUser(User user, jakarta.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)booleanaddToBookmarkList(Bookmark item, jakarta.servlet.http.HttpSession session) Adds the given item to the session bookmark list, creating a new bookmark list if requiredcreateBookmarkList(jakarta.servlet.http.HttpSession session) Create a new BookmarkList and store it in the session store in the attribute "bookmarkList"voiddeleteBookmarkList(jakarta.servlet.http.HttpSession session) deleteBookmarkList.static StringgenerateBookmarkListInfo(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 parametertextcontains the complete text with a placeholder {0} which is replaced by the text generated from the bookmarks.static StringgenerateNewBookmarkListName(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(jakarta.servlet.http.HttpSession session) getBookmarkList.getOrCreateBookmarkList(jakarta.servlet.http.HttpSession session) Gets the bookmark list stored in the session.booleanisInBookmarkList(Bookmark item, jakarta.servlet.http.HttpSession session) isInBookmarkList.booleanremoveFromBookself(Bookmark item, jakarta.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- aHttpSessionobject.- 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- aHttpSessionobject.- Returns:
- a
BookmarkListobject. - 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- aHttpSessionobject.- Returns:
- a
BookmarkListobject. - 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- aBookmarkobject.session- aHttpSessionobject.- 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- aBookmarkobject.session- aHttpSessionobject.- Returns:
- a boolean.
- Throws:
NullPointerException- if the session is NULL
-
deleteBookmarkList
public void deleteBookmarkList(jakarta.servlet.http.HttpSession session) deleteBookmarkList.
- Parameters:
session- aHttpSessionobject.- Throws:
NullPointerException- if the session is NULL
-
isInBookmarkList
isInBookmarkList.
- Parameters:
item- aBookmarkobject.session- aHttpSessionobject.- Returns:
- a boolean.
-
addSessionBookmarkListToUser
public void addSessionBookmarkListToUser(User user, jakarta.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- aUserobject.request- aHttpServletRequestobject.- 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 parametertextcontains the complete text with a placeholder {0} which is replaced by the text generated from the bookmarks.itemTextis 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 parameterbookmarkListis the bookmark list containing the items to be inserted- Parameters:
text- aStringobject.itemText- aStringobject.emptyListText- aStringobject.bookmarkList- aBookmarkListobject.- Returns:
- a
Stringobject.
-