Class AdminBean

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

@Named @SessionScoped public class AdminBean extends Object implements Serializable
Administration backend functions.
See Also:
  • Constructor Details

    • AdminBean

      public AdminBean()
      Creates a new AdminBean instance.
  • Method Details

    • init

      @PostConstruct public void init()
      init.
    • getAllUsers

      public List<User> getAllUsers() throws DAOException
      Returns all users in the DB. Needed for getting a list of users (e.g for adding user group members).
      Returns:
      a list of all registered users sorted by display name
      Throws:
      DAOException - if any.
    • getAllUsersExcept

      public List<User> getAllUsersExcept(Set<User> usersToExclude) throws DAOException
      getAllUsersExcept.
      Parameters:
      usersToExclude - set of users to omit from the result
      Returns:
      a list of all registered users excluding the specified users
      Throws:
      DAOException - if any.
    • saveUserAction

      public String saveUserAction(User user, boolean forceCheckCurrentPassword, String returnPage) throws DAOException
      saveUserAction.
      Parameters:
      user - user to save
      forceCheckCurrentPassword - If true, even if an admin is changing their own password
      returnPage - navigation outcome returned on success
      Returns:
      the navigation outcome for the return page on success, or empty string on failure
      Throws:
      DAOException - if any.
    • resetUserAction

      public String resetUserAction(User user, String returnPage)
      resetUserAction.
      Parameters:
      user - user whose fields are restored from backup
      returnPage - navigation outcome to return after reset
      Returns:
      the navigation outcome for the return page
    • saveUser

      public boolean saveUser(User user, boolean forceCheckCurrentPassword) throws DAOException
      Saves the given use. Attention: Used by regular users editing their own profile as well.
      Parameters:
      user - User to save
      forceCheckCurrentPassword - If true, even if an admin is changing their own password
      Returns:
      true if the user was saved successfully, false otherwise
      Throws:
      DAOException - if any.
    • deleteUserAction

      public String deleteUserAction(User user, boolean deleteContributions) throws DAOException
      Deletes the given User and optionally their contributions. This method is user for admin-induced deletion of other users as well as self-deletion by a user.
      Parameters:
      user - User to be deleted
      deleteContributions - If true, all content created by this user will also be deleted
      Returns:
      Navigation outcome
      Throws:
      DAOException - if any.
    • resetCurrentUserAction

      public void resetCurrentUserAction()
      resetCurrentUserAction.
    • getAllUserGroups

      public List<UserGroup> getAllUserGroups() throws DAOException
      Returns all user groups in the DB. Needed for getting a list of users (e.g for adding user group members).
      Returns:
      a list of all user groups in the database
      Throws:
      DAOException - if any.
    • saveUserGroupAction

      public String saveUserGroupAction() throws DAOException
      Persists changes in currentUserGroup.
      Returns:
      Navigation outcome
      Throws:
      DAOException - if any.
    • deleteUserGroupAction

      public void deleteUserGroupAction(UserGroup userGroup) throws DAOException
      deleteUserGroupAction.
      Parameters:
      userGroup - user group to delete from the database
      Throws:
      DAOException - if any.
    • resetCurrentUserGroupAction

      public void resetCurrentUserGroupAction()
      resetCurrentUserGroupAction.
    • getAllRoles

      public List<Role> getAllRoles() throws DAOException
      Returns a list of all existing roles. Required for admin tab components.
      Returns:
      a list of all role definitions in the database
      Throws:
      DAOException - if any.
    • saveRoleAction

      public void saveRoleAction() throws DAOException
      saveRoleAction.
      Throws:
      DAOException - if any.
    • deleteRoleAction

      public void deleteRoleAction(Role role) throws DAOException
      deleteRoleAction.
      Parameters:
      role - role to delete from the database
      Throws:
      DAOException - if any.
    • resetCurrentRoleAction

      public void resetCurrentRoleAction()
      resetCurrentRoleAction.
    • resetCurrentUserRoleAction

      public void resetCurrentUserRoleAction()
      resetCurrentUserRoleAction.
    • resetDirtyUserRolesAction

      public void resetDirtyUserRolesAction()
      resetDirtyUserRolesAction.
    • addUserRoleAction

      public void addUserRoleAction() throws DAOException
      Adds currentUserRole to the list of UserRoles to be saved.
      Throws:
      DAOException
    • deleteUserRoleAction

      public void deleteUserRoleAction(UserRole userRole) throws DAOException
      Adds the given UserRole to the list of UserRoles to be deleted.
      Parameters:
      userRole - membership entry to mark for deletion
      Throws:
      DAOException - if any.
    • updateUserRoles

      public void updateUserRoles() throws DAOException
      saveUserRoleAction.
      Throws:
      DAOException - if any.
    • getAllIpRanges

      public List<IpRange> getAllIpRanges() throws DAOException
      getAllIpRanges.
      Returns:
      all IpRanges from the database
      Throws:
      DAOException
    • saveIpRangeAction

      public String saveIpRangeAction() throws DAOException
      saveIpRangeAction.
      Returns:
      Navigation outcome
      Throws:
      DAOException - if any.
    • deleteIpRangeAction

      public void deleteIpRangeAction(IpRange ipRange) throws DAOException
      deleteIpRangeAction.
      Parameters:
      ipRange - IP range entry to delete from the database
      Throws:
      DAOException - if any.
    • resetCurrentIpRangeAction

      public void resetCurrentIpRangeAction()
      resetCurrentIpRangeAction.
    • saveMaintenanceModeAction

      public String saveMaintenanceModeAction() throws DAOException
      saveMaintenanceModeAction.
      Returns:
      Navigation outcome
      Throws:
      DAOException - if any.
    • maintenanceModeToggleChangedListener

      public void maintenanceModeToggleChangedListener(AjaxBehaviorEvent event) throws DAOException
      Ajax event listener for saving the maintenance mode after the enabled/disabled status has been toggled. Using a valueChangeListener instead (via viewerComponent:toggleSwitch) resulted in the listener firing before the setter.
      Parameters:
      event - AjaxBehaviorEvent
      Throws:
      DAOException
    • getCurrentUser

      public User getCurrentUser()
      Getter for the field currentUser.
      Returns:
      the User currently being edited in the admin interface, or null if none selected
    • setCurrentUser

      public void setCurrentUser(User currentUser)
      Setter for the field currentUser.
      Parameters:
      currentUser - the user currently being edited in the admin interface
    • getCurrentUserId

      public Long getCurrentUserId()
      Returns the user ID of currentUser.
      Returns:
      currentUser.id if loaded and has ID; null if not
    • setCurrentUserId

      public void setCurrentUserId(Long id) throws DAOException
      Sets the current user by loading them from the DB via the given user ID.
      Parameters:
      id - database ID of the user to load
      Throws:
      DAOException
    • getCurrentUserGroup

      public UserGroup getCurrentUserGroup()
      Getter for the field currentUserGroup.
      Returns:
      the user group currently selected for editing
    • setCurrentUserGroup

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

      public Long getCurrentUserGroupId()
      Returns the user ID of currentUserGroup.
      Returns:
      currentUserGroup.id if loaded and has ID; null if not
    • setCurrentUserGroupId

      public void setCurrentUserGroupId(Long id) throws DAOException
      Sets currentUserGroup by loading it from the DB via the given ID.
      Parameters:
      id - database ID of the user group to load
      Throws:
      DAOException
    • getCurrentRole

      public Role getCurrentRole()
      Getter for the field currentRole.
      Returns:
      the Role currently being edited in the admin interface, or null if none selected
    • setCurrentRole

      public void setCurrentRole(Role currentRole)
      Setter for the field currentRole.
      Parameters:
      currentRole - the role currently being edited in the admin interface
    • getCurrentUserRole

      public UserRole getCurrentUserRole()
      Getter for the field currentUserRole.
      Returns:
      the UserRole assignment currently being edited, or null if none selected
    • setCurrentUserRole

      public void setCurrentUserRole(UserRole currentUserRole)
      Setter for the field currentUserRole.
      Parameters:
      currentUserRole - the user-role assignment currently being edited
    • getCurrentIpRange

      public IpRange getCurrentIpRange()
      Getter for the field currentIpRange.
      Returns:
      the IpRange currently being edited in the admin interface, or null if none selected
    • setCurrentIpRange

      public void setCurrentIpRange(IpRange currentIpRange)
      Setter for the field currentIpRange.
      Parameters:
      currentIpRange - the IP range currently being edited in the admin interface
    • getCurrentIpRangeId

      public Long getCurrentIpRangeId()
      Returns the user ID of currentIpRange.
      Returns:
      currentIpRange.id if loaded and has ID; null if not
    • setCurrentIpRangeId

      public void setCurrentIpRangeId(Long id) throws DAOException
      Sets currentIpRange by loading it from the DB via the given ID.
      Parameters:
      id - database ID of the IP range to load
      Throws:
      DAOException
    • getLazyModelUsers

      public TableDataProvider<User> getLazyModelUsers()
      Getter for the field lazyModelUsers.
      Returns:
      the TableDataProvider used for paginated user listing in the admin interface
    • getPageUsers

      public List<User> getPageUsers()
      getPageUsers.
      Returns:
      a list of users for the current page in the paginated user list
    • getCurrentPassword

      public String getCurrentPassword()
      Getter for the field currentPassword.
      Returns:
      the current password entered for verification, or null if not set
    • setCurrentPassword

      public void setCurrentPassword(String currentPassword)
      Setter for the field currentPassword.
      Parameters:
      currentPassword - the current password entered for verification
    • getPasswordOne

      public String getPasswordOne()
      Getter for the field passwordOne.
      Returns:
      the new password entered in the first password field, or null if not set
    • setPasswordOne

      public void setPasswordOne(String passwordOne)
      Setter for the field passwordOne.
      Parameters:
      passwordOne - the new password entered in the first password field
    • getPasswordTwo

      public String getPasswordTwo()
      Getter for the field passwordTwo.
      Returns:
      the new password entered in the confirmation password field, or null if not set
    • setPasswordTwo

      public void setPasswordTwo(String passwordTwo)
      Setter for the field passwordTwo.
      Parameters:
      passwordTwo - the new password entered in the confirmation password field
    • getEmailConfirmation

      public String getEmailConfirmation()
      Getter for the field emailConfirmation.
      Returns:
      the email address entered for confirmation during account deletion, or null if not set
    • setEmailConfirmation

      public void setEmailConfirmation(String emailConfirmation)
      Setter for the field emailConfirmation.
      Parameters:
      emailConfirmation - the email address entered for confirmation during account deletion
    • isDeleteUserContributions

      public boolean isDeleteUserContributions()
      isDeleteUserContributions.
      Returns:
      true if all user contributions (comments, bookmarks) should be deleted when deleting the user account; false otherwise
    • setDeleteUserContributions

      public void setDeleteUserContributions(boolean deleteUserContributions)
      Setter for the field deleteUserContributions.
      Parameters:
      deleteUserContributions - true to delete all user contributions (comments, bookmarks) when deleting the user account
    • deleteFromCache

      public int deleteFromCache(List<String> identifiers, boolean fromContentCache, boolean fromThumbnailCache)
      deleteFromCache.
      Parameters:
      identifiers - list of record identifiers to evict from cache
      fromContentCache - true to clear entries from the content cache
      fromThumbnailCache - true to clear entries from the thumbnail cache
      Returns:
      a int.
    • deleteFromCache

      public int deleteFromCache(List<String> identifiers, boolean fromContentCache, boolean fromThumbnailCache, boolean fromPdfCache) throws DAOException
      deleteFromCache.
      Parameters:
      identifiers - list of record identifiers to evict from cache
      fromContentCache - true to clear entries from the content cache
      fromThumbnailCache - true to clear entries from the thumbnail cache
      fromPdfCache - true to delete PDF download jobs and files for each identifier
      Returns:
      a int.
      Throws:
      DAOException
    • setRepresantativeImageAction

      public String setRepresantativeImageAction(String pi, String dataRepository, String fileIdRoot)
      setRepresantativeImageAction.
      Parameters:
      pi - persistent identifier of the record to update
      dataRepository - data repository path containing the METS file
      fileIdRoot - file ID prefix of the image to mark as representative
      Returns:
      an empty string after setting the representative image in the METS file
    • setRepresantativeImageStatic

      public static void setRepresantativeImageStatic(String pi, String dataRepository, String fileIdRoot)
      Opens the METS file for the given identifier and sets the attribute USE='banner' to all file elements that match the given file ID root. Any USE='banner' attributes that do not match the file ID root are removed. Solr schema version "intranda_viewer-20130117" or newer required.
      Parameters:
      pi - persistent identifier of the record to update
      dataRepository - data repository path containing the METS file
      fileIdRoot - file ID prefix of the image to mark as representative
    • toggleSuspendUserAction

      public String toggleSuspendUserAction(User user) throws DAOException
      toggleSuspendUserAction.
      Parameters:
      user - user whose suspended status to toggle
      Returns:
      an empty string after toggling the user's suspended status
      Throws:
      DAOException - if any.
    • triggerMessage

      public void triggerMessage(String message)
      triggerMessage.
      Parameters:
      message - message key to look up and display as info
    • isDisplayTranslationsDashboardWidget

      public boolean isDisplayTranslationsDashboardWidget()
      isDisplayTranslationsDashboardWidget.
      Returns:
      true if at least one group is not fully translated; false otherwise
    • getAllTranslationGroups

      public static List<TranslationGroup> getAllTranslationGroups()
      All available translation groups: the groups configured in config_viewer.xml plus — once at least one database-defined dynamic collection exists — a synthetic group for translating dynamic collection labels. The synthetic group is appended at the end, so the config-index-based group ids stay stable.
      Returns:
      List of all translation groups
    • getDynamicCollectionsTranslationGroupId

      public int getDynamicCollectionsTranslationGroupId()
      getDynamicCollectionsTranslationGroupId.
      Returns:
      id of the synthetic dynamic collections translation group; -1 if it is not available
    • getDynamicCollectionsTranslationGroups

      public List<TranslationGroup> getDynamicCollectionsTranslationGroups()
      getDynamicCollectionsTranslationGroups.
      Returns:
      List containing the synthetic dynamic collections translation group; empty if no dynamic collections exist
    • getConfiguredTranslationGroupsCount

      public long getConfiguredTranslationGroupsCount()
      getConfiguredTranslationGroupsCount.
      Returns:
      Number of configured translation grouns
    • getConfiguredTranslationGroups

      public List<TranslationGroup> getConfiguredTranslationGroups()
      getConfiguredTranslationGroups.
      Returns:
      All configured TranslationGroups
    • resetTranslationGroups

      public void resetTranslationGroups()
      Invalidates the cached translation groups so the next access rebuilds them. Called after translation edits and when entering the translations admin section, so the editor and overview always see current data.
    • getTranslationGroupsForSolrField

      public List<TranslationGroup> getTranslationGroupsForSolrField(String field)
      getTranslationGroupsForSolrField.
      Parameters:
      field - Index field that the translation groups should have as a key
      Returns:
      List of TranslationGroups; null if not found
    • getTranslationGroupForFieldAndKey

      public TranslationGroup getTranslationGroupForFieldAndKey(String field, String key)
      getTranslationGroupForFieldAndKey.
      Parameters:
      field - Solr field
      key - Message key
      Returns:
      First TranslationGroup that contains the requested field+key; null if none found
    • getTranslationGroupsForSolrFieldStatic

      public static List<TranslationGroup> getTranslationGroupsForSolrFieldStatic(String field)
      getTranslationGroupsForSolrFieldStatic.
      Parameters:
      field - Index field that the translation groups should have as a key
      Returns:
      List of TranslationGroups; null if not found
    • saveAndResetCurrentTranslationGroup

      public void saveAndResetCurrentTranslationGroup()
      Saves currentTranslationGroup if it has a selected entry. Resets group to null afterwards.
    • getCurrentTranslationGroup

      public TranslationGroup getCurrentTranslationGroup()
      Getter for the field currentTranslationGroup.
      Returns:
      the TranslationGroup currently being edited, or null if none selected or session is locked
    • resetCurrentTranslationGroupStatusCount

      public void resetCurrentTranslationGroupStatusCount()
      Safe reset method that prevents NPE in EL.
    • setCurrentTranslationGroup

      public void setCurrentTranslationGroup(TranslationGroup currentTranslationGroup)
      Setter for the field currentTranslationGroup.
      Parameters:
      currentTranslationGroup - the translation group currently being edited
    • isNewMessageEntryModeAllowed

      public boolean isNewMessageEntryModeAllowed()
      isNewMessageEntryModeAllowed.
      Returns:
      true if at least one LOCAL_STRINGS type group is found in config; false otherwise
    • triggerNewMessageEntryMode

      public void triggerNewMessageEntryMode()
      Triggers a mode for adding new message keys to the first LOCAL_STRINGS type group found.
    • saveSelectedMessageEntryAction

      public String saveSelectedMessageEntryAction()
      Saves currently selected message entry in the current translation group and returns to the translations overview page.
      Returns:
      Target page
    • cancelSelectedMessageEntryAction

      public String cancelSelectedMessageEntryAction()
      Resets selected message entry and returns to the translations overview page.
      Returns:
      Target page
    • getCurrentTranslationGroupId

      public int getCurrentTranslationGroupId()
      getCurrentTranslationGroupId.
      Returns:
      Index of currentTranslationGroup in the list of configured groups
    • setCurrentTranslationGroupId

      public void setCurrentTranslationGroupId(int id)
      setCurrentTranslationGroupId.
      Parameters:
      id - Looks up and loads currentTranslationGroup that matches the given id
    • getCurrentTranslationMessageKey

      public String getCurrentTranslationMessageKey()
      getCurrentTranslationMessageKey.
      Returns:
      Key of the currently selected entry; otherwise "-"
    • setCurrentTranslationMessageKey

      public void setCurrentTranslationMessageKey(String key)
      If currentTranslationGroup is set, looks up the message entry for the given key and pre-selects it.
      Parameters:
      key - Message key to select
    • isTranslationLocked

      public boolean isTranslationLocked()
      isTranslationLocked.
      Returns:
      true if translations are locked by a different user; false otherwise
    • lockTranslation

      public void lockTranslation()
      lockTranslation.
    • unlockTranslation

      public static void unlockTranslation(String sessionId)
      Releases the translation editor lock if the given session ID matches the current editor. Also deletes vim-compatible swap files for all local messages files.
      Parameters:
      sessionId - the HTTP session ID requesting the unlock
    • getTranslationGroupsEditorSession

      public static String getTranslationGroupsEditorSession()
      Getter for the field translationGroupsEditorSession.
      Returns:
      the session identifier that holds the translation groups editor lock, or null if not locked
    • setTranslationGroupsEditorSession

      public static void setTranslationGroupsEditorSession(String translationGroupsEditorSession)
      Setter for the field translationGroupsEditorSession.
      Parameters:
      translationGroupsEditorSession - session identifier used to coordinate the translation groups editor
    • updateHotfolderFileCount

      public void updateHotfolderFileCount()
      updateHotfolderFileCount.
    • getHotfolderFileCount

      public int getHotfolderFileCount()
      Getter for the field hotfolderFileCount.
      Returns:
      Number of queued records in hotfolder
    • isHasAccessPermissingForTranslationFiles

      public boolean isHasAccessPermissingForTranslationFiles()
      isHasAccessPermissingForTranslationFiles.
      Returns:
      TranslationGroup.isHasFileAccess()
    • setUploadedAvatarFile

      public void setUploadedAvatarFile(Part uploadedAvatarFile)
      Setter for the field uploadedAvatarFile.
      Parameters:
      uploadedAvatarFile - the uploaded file part containing the new avatar image
    • getUploadedAvatarFile

      public Part getUploadedAvatarFile()
      Getter for the field uploadedAvatarFile.
      Returns:
      the uploaded file part containing the new avatar image, or null if none uploaded
    • getMaintenanceMode

      public MaintenanceMode getMaintenanceMode()
    • setMaintenanceMode

      public void setMaintenanceMode(MaintenanceMode maintenanceMode)