Package io.goobi.viewer.managedbeans
Class AdminConfigEditorBean
java.lang.Object
io.goobi.viewer.managedbeans.AdminConfigEditorBean
- All Implemented Interfaces:
Serializable
JSF backing bean for the admin configuration editor, allowing administrators to view and modify the viewer config file.
- See Also:
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoidchangeNightMode.static voidclearLocksForSessionId(String sessionId) Removes file locks for the given session id.closeCurrentFileAction.voidcreateBackup(FileRecord rec) static voidcreateBackup(String backupFolderPath, String fileName, String content) Creates a timestamped backup of the given file name and content.voiddownloadFile(BackupRecord rec) downloadFile.editFile(boolean writable) editFile.Getter for the fieldbackupRecords.Getter for the fieldbackupRecordsModel.getCurrentConfigFileType.getCurrentFileName.getCurrentFilePath.Getter for the fieldcurrentFileRecord.Getter for the fieldfileContent.intGetter for the fieldfileInEditionNumber.getFileRecordsModel.voidinit()init.booleanisBackupsAvailable.booleanisConfigViewer.booleanisEditable.booleanisFileLocked(FileRecord fileRecord) Determines whether the given fileRecord is locked by a different user session.booleanisNightMode.booleanisRenderBackend.voidopenFile()openFile.voidrefresh()refresh.voidrefreshBackups(File backupFolder) refreshBackups.Saves the currently open file.voidselectBackup(int backupNumber) voidselectFileAndShowBackups(boolean writable) selectFileAndShowBackups.voidsetCurrentFileName(String fileName) Getter for the URL pattern.voidsetEditable(boolean editable) Setter for the fieldeditable.voidsetFileContent(String fileContent) Setter for the fieldfileContent.voidsetFileInEditionNumber(int fileInEditionNumber) Setter for the fieldfileInEditionNumber.voidshowBackups.static voidunlockFile(Path file, String sessionId) Unlocks the given file for the given session id in the static (global) fileLocks object.void
-
Constructor Details
-
AdminConfigEditorBean
public AdminConfigEditorBean()Creates a new AdminConfigEditorBean instance.
-
-
Method Details
-
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
- Throws:
IOException
-
upload
-
download
- Throws:
IOException
-
getFileRecordsModel
getFileRecordsModel.- Returns:
- the data model wrapping the current list of config file records
-
getFileInEditionNumber
public int getFileInEditionNumber()Getter for the fieldfileInEditionNumber.- Returns:
- a int
-
setFileInEditionNumber
public void setFileInEditionNumber(int fileInEditionNumber) Setter for the fieldfileInEditionNumber.- Parameters:
fileInEditionNumber- zero-based index of the file in the file list
-
getCurrentFileRecord
Getter for the fieldcurrentFileRecord.- Returns:
- the
FileRecordcurrently open in the config editor, or null if none selected
-
getFileContent
Getter for the fieldfileContent.- Returns:
- the text content of the currently open configuration file
-
setFileContent
Setter for the fieldfileContent.- Parameters:
fileContent- text content of the currently open config file
-
getBackupRecords
Getter for the fieldbackupRecords.- Returns:
- a list of backup file records for configuration files
-
getBackupRecordsModel
Getter for the fieldbackupRecordsModel.- 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 fieldeditable.- 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
getCurrentConfigFileType.- Returns:
- the file type of the currently open config file, or an empty string if none is selected
-
isFileLocked
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
openFile.- Throws:
IOException
-
closeCurrentFileAction
closeCurrentFileAction.- Returns:
- Navigation outcome
-
unlockFile
Unlocks the given file for the given session id in the static (global) fileLocks object.- Parameters:
file- path of the config file to unlocksessionId- HTTP session ID that holds the lock to release
-
editFile
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
Saves the currently open file.- Returns:
- Navigation outcome
-
createBackup
- 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 pathfileName- File namecontent- File content- Throws:
IOException
-
refreshBackups
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
downloadFile.- Parameters:
rec-BackupRecordfor which to download the file- Returns:
- Navigation outcome
- Throws:
IOException
-
clearLocksForSessionId
Removes file locks for the given session id.- Parameters:
sessionId- HTTP session ID whose locks are to be released
-
getCurrentFileName
getCurrentFileName.- Returns:
- File name of the currently selected file record row
-
setCurrentFileName
Getter for the URL pattern.- Parameters:
fileName- decoded URL-encoded filename to select from the file list- Throws:
FileNotFoundException
-
getRecord
-
getCurrentFilePath
getCurrentFilePath.- Returns:
- the file system path of the currently open config file, or null if none is selected
-
getFileUploader
-