Package io.goobi.viewer.model.bookmark
Class SessionStoreBookmarkManager
java.lang.Object
io.goobi.viewer.model.bookmark.SessionStoreBookmarkManager
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, 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, HttpSession session) Adds the given item to the session bookmark list, creating a new bookmark list if required.createBookmarkList(HttpSession session) Creates a new BookmarkList and store it in the session store in the attribute "bookmarkList".voiddeleteBookmarkList(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 list.getBookmarkList(HttpSession session) getBookmarkList.getOrCreateBookmarkList(HttpSession session) Gets the bookmark list stored in the session.booleanisInBookmarkList(Bookmark item, HttpSession session) isInBookmarkList.booleanremoveFromBookself(Bookmark item, 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- HTTP session to look up the bookmark list in- Returns:
- An optional containing the stored bookmark list if one exists
- Throws:
NullPointerException- if the session is NULL
-
createBookmarkList
Creates a new BookmarkList and store it in the session store in the attribute "bookmarkList".- Parameters:
session- HTTP session to store the new bookmark list in- Returns:
- the newly created BookmarkList stored in the session
- 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- HTTP session to retrieve or create the bookmark list in- Returns:
- the BookmarkList from the session, creating a new one if none exists
- 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- bookmark to add to the session listsession- HTTP session holding the bookmark list- 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- bookmark to remove from the session listsession- HTTP session holding the bookmark list- Returns:
- true if the item was successfully removed from the session bookmark list, false if no session list exists or the item was not found
- Throws:
NullPointerException- if the session is NULL
-
deleteBookmarkList
deleteBookmarkList.- Parameters:
session- HTTP session whose bookmark list is removed- Throws:
NullPointerException- if the session is NULL
-
isInBookmarkList
isInBookmarkList.- Parameters:
item- bookmark to look up in the session listsession- HTTP session holding the bookmark list- Returns:
- true if the session bookmark list exists and contains the given item, false otherwise
-
addSessionBookmarkListToUser
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- user to assign the session bookmark list torequest- HTTP request providing the current session- 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.- Parameters:
bookmarkLists- existing bookmark lists used to determine the next available number- Returns:
- the next available bookmark list name in the format "List {n}"
-
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 parameter
bookmarkListis the bookmark list containing the items to be inserted- Parameters:
text- email body template containing placeholder {0} for the item listitemText- per-bookmark text template with placeholders {0} (URL) and {1} (title)emptyListText- text inserted when the bookmark list is emptybookmarkList- bookmark list whose items are rendered into the text- Returns:
- the email body text with bookmark item links substituted into the template
-