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.
Symlink note: the configuration directory (/opt/digiverso/viewer/config/) legitimately contains symbolic
links to files that live outside the viewer's own filesystem tree:
config_indexer.xml→/opt/digiverso/indexer/config_indexer.xmlrobots.txt→/var/www/robots.txt
These symlinks are intentional and must keep working. Any future migration of this bean's Files
calls to symlink-rejecting helpers (see FileTools.copyRejectingSymlinks / openRejectingSymlinks /
moveRejectingSymlinks / newBufferedWriterRejectingSymlinks) must therefore introduce a path-allowlist
for these two files (or the entire config directory) — applying strict-reject here unconditionally would break the
config editor's read/write of the indexer config and the robots 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(FileRecord record) Selects the given file record for editing and navigates to its edit view.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, either by a different user session holding the in-memory edit lock or by an external vim process holding a swap-file lock on the file.booleanisNightMode.booleanisRenderBackend.static booleanLocks the given file for the given session id and creates its owner-tagged vim swap file.voidopenFile()openFile.voidrefresh()refresh.voidrefreshBackups(File backupFolder) refreshBackups.static voidRemoves all expired leases and deletes each one's owner-tagged vim swap file.static booleanRenews the lease for the given file and session id (heartbeat) in the static (global) fileLocks object.Saves the currently open file.voidselectBackup(int backupNumber) voidselectFileAndShowBackups(boolean writable) selectFileAndShowBackups.voidselectFileAndShowBackups(FileRecord record) Selects the given file record explicitly (not via the DataModel row index), so the clicked file inside theui:repeatis selected reliably.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 and deletes its owner-tagged swap file.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, either by a different user session holding the in-memory edit lock or by an external vim process holding a swap-file lock on the file.- Parameters:
fileRecord- file record whose lock status is to be checked- Returns:
- true if locked by another session or by an external vim process; 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
-
lockFile
Locks the given file for the given session id and creates its owner-tagged vim swap file.- Parameters:
file- path of the config file to locksessionId- HTTP session ID acquiring the lock- Returns:
- true if the lock was acquired; false if held by another session
-
unlockFile
Unlocks the given file for the given session id and deletes its owner-tagged swap file.- Parameters:
file- path of the config file to unlocksessionId- HTTP session ID that holds the lock to release
-
renewLock
Renews the lease for the given file and session id (heartbeat) in the static (global) fileLocks object.- Parameters:
file- path of the config file whose lease should be renewedsessionId- HTTP session ID that must hold the lease- Returns:
- true if the lease was renewed; false otherwise
-
removeExpiredLocks
public static void removeExpiredLocks()Removes all expired leases and deletes each one's owner-tagged vim swap file. Deleting the swap file lets the existingSwapFileWatcherpush a lock-status refresh to clients. Invoked periodically byFileLockReaper. -
editFile
Selects the given file record for editing and navigates to its edit view. The record is passed explicitly (instead of resolving it via the DataModel's row index) so the correct, clicked file is selected even inside theui:repeat; this is a POST command (not a prefetchable GET link), avoiding speculative requests that would mutate the shared session selection.- Parameters:
record- the file record that was clicked- 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
-
selectFileAndShowBackups
Selects the given file record explicitly (not via the DataModel row index), so the clicked file inside theui:repeatis selected reliably. Editability follows the record's own writable flag.- Parameters:
record- the file record to select
-
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
-