Class AdminConfigEditorBean

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

@Named @SessionScoped public class AdminConfigEditorBean extends Object implements Serializable
JSF backing bean for the admin configuration editor, allowing administrators to view and modify the viewer config file.
See Also:
  • Constructor Details

    • AdminConfigEditorBean

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

    • init

      @PostConstruct public void init()
      init.
    • isRenderBackend

      public boolean isRenderBackend()
      isRenderBackend.
      Returns:
      true if the admin backend is rendered for the current user, false otherwise
    • refresh

      public void refresh()
      refresh.
    • selectBackup

      public void selectBackup(int backupNumber) throws IOException
      Throws:
      IOException
    • upload

      public void upload(Path file)
    • download

      public void download(Path file) throws IOException
      Throws:
      IOException
    • getFileRecordsModel

      public DataModel<FileRecord> getFileRecordsModel()
      getFileRecordsModel.
      Returns:
      the data model wrapping the current list of config file records
    • getFileInEditionNumber

      public int getFileInEditionNumber()
      Getter for the field fileInEditionNumber.
      Returns:
      a int
    • setFileInEditionNumber

      public void setFileInEditionNumber(int fileInEditionNumber)
      Setter for the field fileInEditionNumber.
      Parameters:
      fileInEditionNumber - zero-based index of the file in the file list
    • getCurrentFileRecord

      public FileRecord getCurrentFileRecord()
      Getter for the field currentFileRecord.
      Returns:
      the FileRecord currently open in the config editor, or null if none selected
    • getFileContent

      public String getFileContent()
      Getter for the field fileContent.
      Returns:
      the text content of the currently open configuration file
    • setFileContent

      public void setFileContent(String fileContent)
      Setter for the field fileContent.
      Parameters:
      fileContent - text content of the currently open config file
    • getBackupRecords

      public List<BackupRecord> getBackupRecords()
      Getter for the field backupRecords.
      Returns:
      a list of backup file records for configuration files
    • getBackupRecordsModel

      public DataModel<BackupRecord> getBackupRecordsModel()
      Getter for the field backupRecordsModel.
      Returns:
      the data model wrapping the list of backup file records
    • isEditable

      public boolean isEditable()
      isEditable.
      Returns:
      true if the currently open config file is in write mode, false if it is read-only
    • setEditable

      public void setEditable(boolean editable)
      Setter for the field editable.
      Parameters:
      editable - true to open the file in write mode; false for read-only
    • isBackupsAvailable

      public boolean isBackupsAvailable()
      isBackupsAvailable.
      Returns:
      true if at least one backup record exists for the current config file, false otherwise
    • getCurrentConfigFileType

      public String getCurrentConfigFileType()
      getCurrentConfigFileType.
      Returns:
      the file type of the currently open config file, or an empty string if none is selected
    • isFileLocked

      public boolean isFileLocked(FileRecord fileRecord)
      Determines whether the given fileRecord is locked by a different user session.
      Parameters:
      fileRecord - file record whose lock status is to be checked
      Returns:
      true if file path locked by other session id; false otherwise
    • isNightMode

      public boolean isNightMode()
      isNightMode.
      Returns:
      true if the editor is in night mode, false otherwise
    • changeNightMode

      public void changeNightMode()
      changeNightMode.
    • openFile

      public void openFile() throws IOException
      openFile.
      Throws:
      IOException
    • closeCurrentFileAction

      public String closeCurrentFileAction()
      closeCurrentFileAction.
      Returns:
      Navigation outcome
    • unlockFile

      public static void unlockFile(Path file, String sessionId)
      Unlocks the given file for the given session id in the static (global) fileLocks object.
      Parameters:
      file - path of the config file to unlock
      sessionId - HTTP session ID that holds the lock to release
    • editFile

      public String editFile(boolean writable)
      editFile.
      Parameters:
      writable - true to open the file for editing; false for read-only view
      Returns:
      the navigation outcome redirecting to the config editor file view
    • saveCurrentFileAction

      public String saveCurrentFileAction()
      Saves the currently open file.
      Returns:
      Navigation outcome
    • createBackup

      public void createBackup(FileRecord rec) throws IOException
      Throws:
      IOException
    • createBackup

      public static void createBackup(String backupFolderPath, String fileName, String content) throws IOException
      Creates a timestamped backup of the given file name and content.
      Parameters:
      backupFolderPath - Backup folder path
      fileName - File name
      content - File content
      Throws:
      IOException
    • refreshBackups

      public void refreshBackups(File backupFolder)
      refreshBackups.
      Parameters:
      backupFolder - directory containing timestamped backup files to list
    • isConfigViewer

      public boolean isConfigViewer()
      isConfigViewer.
      Returns:
      true if currently editing config_viewer.xml; false otherwise
    • selectFileAndShowBackups

      public void selectFileAndShowBackups(boolean writable)
      selectFileAndShowBackups.
      Parameters:
      writable - true to open the file for editing; false for read-only view
    • showBackups

      public void showBackups()
      showBackups.
    • downloadFile

      public String downloadFile(BackupRecord rec) throws IOException
      downloadFile.
      Parameters:
      rec - BackupRecord for which to download the file
      Returns:
      Navigation outcome
      Throws:
      IOException
    • clearLocksForSessionId

      public static void clearLocksForSessionId(String sessionId)
      Removes file locks for the given session id.
      Parameters:
      sessionId - HTTP session ID whose locks are to be released
    • getCurrentFileName

      public String getCurrentFileName()
      getCurrentFileName.
      Returns:
      File name of the currently selected file record row
    • setCurrentFileName

      public void setCurrentFileName(String fileName) throws FileNotFoundException
      Getter for the URL pattern.
      Parameters:
      fileName - decoded URL-encoded filename to select from the file list
      Throws:
      FileNotFoundException
    • getRecord

      public FileRecord getRecord(String filename)
    • getCurrentFilePath

      public Path getCurrentFilePath()
      getCurrentFilePath.
      Returns:
      the file system path of the currently open config file, or null if none is selected
    • getFileUploader

      public FileUploader getFileUploader()