Class BookmarkBean

java.lang.Object
io.goobi.viewer.managedbeans.BookmarkBean
All Implemented Interfaces:
Serializable

@Named @SessionScoped public class BookmarkBean extends Object implements Serializable
JSF backing bean for bookmark list management, handling user bookmarks and public sharing.
See Also:
  • Constructor Details

    • BookmarkBean

      public BookmarkBean()
      Empty Constructor.
  • Method Details

    • init

      @PostConstruct public void init()
      init.
    • cancelEditCurrentBookmarkListAction

      public String cancelEditCurrentBookmarkListAction()
      Resets the current bookmark list and returns to the overview of own bookmark lists.
      Returns:
      the pretty URL name for the bookmark lists overview page
    • saveCurrentBookmarkListAction

      public String saveCurrentBookmarkListAction()
      Updates the currently selected bookmark list if it already in the user's list of bookmark lists, adds it to the list otherwise. Saves DataManager in both cases.
      Returns:
      the pretty URL name for the next view after saving (overview on success, edit page on failure)
    • deleteCurrentBookmarkListAction

      public String deleteCurrentBookmarkListAction()
      Deletes currentBookmarkList.
      Returns:
      the pretty URL name for the next view after deletion (overview on success, edit page on failure)
    • unshareCurrentBookmarkListAction

      public void unshareCurrentBookmarkListAction()
      Removes currentUserGroup from the shares list of currentBookmarkList.
    • resetCurrentBookmarkListAction

      public void resetCurrentBookmarkListAction()
      Sets currentBookmarkList to a new object.
    • prepareItemForBookmarkList

      public void prepareItemForBookmarkList() throws IndexUnreachableException
      prepareItemForBookmarkList.
      Throws:
      IndexUnreachableException - if any.
    • saveCurrentBookmarkAction

      public String saveCurrentBookmarkAction()
      Updates the currently selected Bookmark if it is already part of the current BookmarkList, otherwise adds a new Bookmark. Saves DataManager in both cases.
      Returns:
      an empty string or navigation outcome after attempting to save the current bookmark
    • deleteCurrentItemAction

      public void deleteCurrentItemAction(Bookmark bookmark)
      Removes the currently selected Bookmark from the currently selected BookmarkList.
      Parameters:
      bookmark - bookmark to remove from the current list
    • getRemainingUserGroupNames

      public List<String> getRemainingUserGroupNames() throws DAOException
      Returns the names all existing user groups (minus the ones currentBookmarkList is already shared with). TODO Filter some user groups, if required (e.g. admins)
      Returns:
      a list of user group names not yet sharing the current bookmark list
      Throws:
      DAOException - if any.
    • getPublicBookmarkLists

      public List<BookmarkList> getPublicBookmarkLists() throws DAOException
      Returns a list of all existing bookmark list that are marked public.
      Returns:
      a list of all publicly visible bookmark lists
      Throws:
      DAOException - if any.
    • getBookmarkListsSharedWithUser

      public static List<BookmarkList> getBookmarkListsSharedWithUser(User user) throws DAOException
      getBookmarkListsSharedWithUser.
      Parameters:
      user - user whose shared bookmark lists to retrieve
      Returns:
      a list of bookmark lists that have been shared with the given user
      Throws:
      DAOException - if any.
    • getBookmarkLists

      public List<BookmarkList> getBookmarkLists() throws DAOException
      Returns a list of all existing bookmark lists owned by current user.
      Returns:
      a list of bookmark lists owned by the currently logged-in user
      Throws:
      DAOException - if any.
    • getBookmarkListsForUser

      public List<BookmarkList> getBookmarkListsForUser(User user) throws DAOException
      getBookmarkListsForUser.
      Parameters:
      user - user whose owned bookmark lists to load
      Returns:
      a list of bookmark lists owned by the given user
      Throws:
      DAOException - if any.
    • selectBookmarkListAction

      public void selectBookmarkListAction(ValueChangeEvent event) throws DAOException
      selectBookmarkListAction.
      Parameters:
      event - value change event carrying the selected bookmark list name
      Throws:
      DAOException - if any.
    • isNewBookmarkList

      public boolean isNewBookmarkList()
      isNewBookmarkList.
      Returns:
      true if the current bookmark list has not yet been persisted (has no database ID), false otherwise
    • createNewBookmarkListAction

      public String createNewBookmarkListAction()
      createNewBookmarkListAction.
      Returns:
      the pretty URL name for the bookmark list edit page after resetting to a new empty list
    • userGroupSelectedAction

      public void userGroupSelectedAction(ValueChangeEvent event) throws DAOException
      userGroupSelectedAction.
      Parameters:
      event - value change event carrying the selected user group name
      Throws:
      DAOException - if any.
    • validateName

      public void validateName(FacesContext context, UIComponent toValidate, Object value) throws ValidatorException, DAOException
      validateName.
      Parameters:
      context - current JSF faces context
      toValidate - UI component being validated
      value - submitted bookmark list name value
      Throws:
      ValidatorException - if any.
      DAOException - if any.
    • isCurrentBookmarkListMine

      public boolean isCurrentBookmarkListMine()
      isCurrentBookmarkListMine.
      Returns:
      true if the current bookmark list belongs to the logged-in user (or is a new unsaved list), false otherwise
    • getCurrentBookmarkList

      public BookmarkList getCurrentBookmarkList()
      Getter for the field currentBookmarkList.
      Returns:
      the BookmarkList currently selected by the user, or null if none selected
    • isCurrentBookmarkListShared

      public boolean isCurrentBookmarkListShared()
      isCurrentBookmarkListShared.
      Returns:
      true if currentBookmarkListSharedKey matches the shared key value of currentBookmarkList; false otherwise;
    • getCurrentBookmarkListNames

      public List<String> getCurrentBookmarkListNames() throws DAOException
      getCurrentBookmarkListNames.
      Returns:
      a list of bookmark list names owned by the current user
      Throws:
      DAOException - if any.
    • setCurrentBookmarkList

      public void setCurrentBookmarkList(BookmarkList currentBookmarkList)
      Setter for the field currentBookmarkList.
      Parameters:
      currentBookmarkList - bookmark list to set as currently selected
    • getCurrentBookmarkListId

      public String getCurrentBookmarkListId()
      getCurrentBookmarkListId.
      Returns:
      Identifier of currentBookmarkList; null if none loaded
    • setCurrentBookmarkListId

      public void setCurrentBookmarkListId(String bookmarkListId) throws IllegalUrlParameterException, DAOException
      setCurrentBookmarkListId.
      Parameters:
      bookmarkListId - numeric ID string of the bookmark list to load
      Throws:
      PresentationException - if any.
      DAOException - if any.
      IllegalUrlParameterException
    • viewBookmarkListAction

      public String viewBookmarkListAction(BookmarkList bookmarkList)
      viewBookmarkListAction.
      Parameters:
      bookmarkList - bookmark list to open in view mode
      Returns:
      the pretty URL name for the bookmark list view page
    • editBookmarkListAction

      public String editBookmarkListAction(BookmarkList bookmarkList)
      editBookmarkListAction.
      Parameters:
      bookmarkList - bookmark list to open in edit mode
      Returns:
      the pretty URL name for the bookmark list edit page
    • getCurrentBookmark

      public Bookmark getCurrentBookmark()
      Getter for the field currentBookmark.
      Returns:
      the Bookmark currently active for editing or display, or null if none selected
    • setCurrentBookmark

      public void setCurrentBookmark(Bookmark currentBookmark)
      Setter for the field currentBookmark.
      Parameters:
      currentBookmark - bookmark to set as currently active
    • getCurrentUserGroup

      public UserGroup getCurrentUserGroup()
      Getter for the field currentUserGroup.
      Returns:
      the UserGroup currently selected for sharing a bookmark list, or null if none selected
    • setCurrentUserGroup

      public void setCurrentUserGroup(UserGroup currentUserGroup)
      Setter for the field currentUserGroup.
      Parameters:
      currentUserGroup - user group to set as currently selected
    • setSessionBookmarkListEmail

      public void setSessionBookmarkListEmail(String sessionBookmarkListEmail)
      Setter for the field sessionBookmarkListEmail.
      Parameters:
      sessionBookmarkListEmail - email address for sending the session bookmark list
    • getSessionBookmarkListEmail

      public String getSessionBookmarkListEmail()
      Getter for the field sessionBookmarkListEmail.
      Returns:
      the email address for sending the session bookmark list, or null if not set
    • getCurrentBookmarkListKey

      public String getCurrentBookmarkListKey()
    • setCurrentBookmarkListKey

      public void setCurrentBookmarkListKey(String key) throws PresentationException, DAOException
      Throws:
      PresentationException
      DAOException
    • getShareLink

      public String getShareLink(BookmarkList bookmarkList)
      getShareLink.
      Parameters:
      bookmarkList - bookmark list to generate or retrieve share link for
      Returns:
      Absolute share URLto the given bookmark list
    • resetShareLink

      public void resetShareLink(BookmarkList bookmarkList)
    • setPublic

      public void setPublic(BookmarkList bookmarkList, boolean isPublic)
    • getShareKey

      public String getShareKey()
      getShareKey.
      Returns:
      the share key of the current bookmark list, or "-" if no list is selected
    • setShareKey

      public void setShareKey(String key) throws DAOException, IllegalUrlParameterException
      setShareKey.
      Parameters:
      key - share key identifying the bookmark list to load
      Throws:
      DAOException - if any.
      IllegalUrlParameterException
    • sendSessionBookmarkListAsMail

      public void sendSessionBookmarkListAsMail()
      sendSessionBookmarkListAsMail.
    • countSessionBookmarkListItems

      public int countSessionBookmarkListItems()
      countSessionBookmarkListItems.
      Returns:
      Size of items in the session bookmark list
    • getNewBookmarkListName

      public String getNewBookmarkListName()
    • setNewBookmarkListName

      public void setNewBookmarkListName(String newBookmarkListName)
    • addBookmarkList

      public void addBookmarkList()