Class CmsRfsFileViewer
- All Implemented Interfaces:
Cloneable
Most often the underlying file will be the OpenCms logfile.
The portion of the file that is shown is defined by a "window" of "windowSize" lines of text at a position "windowPosition" which is an enumeration of windows in ascending order.
- Since:
- 6.0.0
-
Field Summary
Modifier and TypeFieldDescriptionprotected static final org.apache.commons.logging.Log
The log object for this class.protected String
The path to the underlying file.protected String
The path to the root for all accessible files.protected int
The current window (numbered from zero to amount of possible different windows).protected int
The amount of lines to show. -
Constructor Summary
ConstructorDescriptionCreates an instance with default settings that tries to use the log file path obtained from
instance.OpenCms
'sCmsSystemInfo
-
Method Summary
Modifier and TypeMethodDescriptionclone()
Returns a clone of this file view settings that is not "frozen" and therefore allows modifications.Returns the canonical name of the character encoding of the underlying file.Returns the path denoting the file that is accessed.boolean
Returns true if the view's internal file path points to a log file in standard OpenCms format.Returns the path denoting the root folder for all accessible files.int
Returns the start position of the current display.int
Get the amount of lines (or entries depending on whether a standard log file is shown) to display per page.boolean
Returns true if this view upon the underlying file via
is enabled.readFilePortion()
Return the view portion of lines of text from the underlying file or an empty String if
returnsisEnabled()
false
.void
setAdditionalRoots
(List<String> roots) Sets the additional root folders from which files can be viewed.void
setEnabled
(boolean preview) Set the boolean that decides if the view to the underlying file via
is enabled.readFilePortion()
void
setFileEncoding
(String fileEncoding) Set the character encoding of the underlying file.void
setFilePath
(String path) Set the path in the real file system that points to the file that should be displayed.void
setFrozen
(boolean frozen) Package friendly access that allows the
to "freeze" this instance within the system-wide assignment in it'sCmsWorkplaceManager
method.CmsWorkplaceManager.setFileViewSettings(org.opencms.file.CmsObject, CmsRfsFileViewer)
void
setIsLogfile
(boolean isLogfile) Set if the internal file is in standard log file format (true) or not (false).void
setRootPath
(String path) Set the path in the real file system that points to the folder/tree containing the log files.void
setWindowPos
(int windowPos) Sets the start position of the current display.void
setWindowSize
(int windowSize) Set the amount of lines (or entries depending on whether a standard log file is shown) to display per page.
-
Field Details
-
LOG
The log object for this class. -
m_filePath
The path to the underlying file. -
m_rootPath
The path to the root for all accessible files. -
m_windowPos
The current window (numbered from zero to amount of possible different windows). -
m_windowSize
The amount of lines to show.
-
-
Constructor Details
-
CmsRfsFileViewer
public CmsRfsFileViewer()Creates an instance with default settings that tries to use the log file path obtained from
instance.OpenCms
'sCmsSystemInfo
If the log file path is invalid or not configured correctly a logging is performed and the path remains empty to allow user-specified file selection.
-
-
Method Details
-
clone
Returns a clone of this file view settings that is not "frozen" and therefore allows modifications.Every instance that plans to modify settings has to obtain a clone first that may be modified. The original instance returned from (
) will throw aCmsWorkplaceManager.getFileViewSettings()
for each setter invocation.CmsRuntimeException
-
getFileEncoding
Returns the canonical name of the character encoding of the underlying file.If no special choice is fed into
before this call always the system default character encoding is returned.setFileEncoding(String)
This value may be ignored outside and will be ignored inside if the underlying does not contain textual content.
- Returns:
- the canonical name of the character encoding of the underlying file
-
getFilePath
Returns the path denoting the file that is accessed.- Returns:
- the path denoting the file that is accessed
-
getIsLogfile
Returns true if the view's internal file path points to a log file in standard OpenCms format.- Returns:
- true if the view's internal file path points to a log file in standard OpenCms format
-
getRootPath
Returns the path denoting the root folder for all accessible files.- Returns:
- the path denoting the root folder for all accessible files
-
getWindowPos
Returns the start position of the current display.This is a count of "windows" that consist of viewable text with "windowSize" lines of text (for a non-standard log file) or log-entries (for a standard log file).
- Returns:
- the start position of the current display
-
getWindowSize
Get the amount of lines (or entries depending on whether a standard log file is shown) to display per page.- Returns:
- the amount of lines to display per page
-
isEnabled
Returns true if this view upon the underlying file via
is enabled.readFilePortion()
- Returns:
- true if this view upon the underlying file via
is enabled.readFilePortion()
-
readFilePortion
Return the view portion of lines of text from the underlying file or an empty String if
returnsisEnabled()
false
.- Returns:
- the view portion of lines of text from the underlying file or an
empty String if
returnsisEnabled()
false
- Throws:
CmsRfsException
- if something goes wrong
-
setAdditionalRoots
Sets the additional root folders from which files can be viewed.- Parameters:
roots
- the list of additional root folders
-
setEnabled
Set the boolean that decides if the view to the underlying file via
is enabled.readFilePortion()
- Parameters:
preview
- the boolean that decides if the view to the underlying file via
is enabledreadFilePortion()
-
setFileEncoding
Set the character encoding of the underlying file.The given String has to match a valid char set name (canonical or alias) of one of the system's supported
instances (seeCharset
).Charset.forName(java.lang.String)
This setting will be used for reading the file. This enables to correctly display files with text in various encodings in UIs.
- Parameters:
fileEncoding
- the character encoding of the underlying file to set
-
setFilePath
Set the path in the real file system that points to the file that should be displayed.This method will only success if the file specified by the
path
argument is valid within the file system, no folder and may be read by the OpenCms process on the current platform.- Parameters:
path
- the path in the real file system that points to the file that should be displayed to set- Throws:
CmsRuntimeException
- if the configuration of this instance has been frozenCmsRfsException
- if the given path is invalid, does not point to a file or cannot be accessed
-
setFrozen
Package friendly access that allows the
to "freeze" this instance within the system-wide assignment in it'sCmsWorkplaceManager
method.CmsWorkplaceManager.setFileViewSettings(org.opencms.file.CmsObject, CmsRfsFileViewer)
- Parameters:
frozen
- if true this instance will freeze and throwCmsRuntimeExceptions
upon setter invocations- Throws:
CmsRuntimeException
- if the configuration of this instance has been frozen (setFrozen(boolean)
)
-
setIsLogfile
Set if the internal file is in standard log file format (true) or not (false).If set to true the file might be treated / displayed in a more convenient format than standard files in future. Currently it is only inverted (last lines appear first) and only the last 'Window Size' lines of the file are displayed.
Do not activate this (it is possible from the log file viewer settings in the workplace administration) if your selected file is no log file: The display will confuse you and be more expensive (imaging scrolling a 20 MB file to view the last 200 lines).
- Parameters:
isLogfile
- determines if the internal file is in standard log file format (true) or not (false)- Throws:
CmsRuntimeException
- if the configuration of this instance has been frozen (setFrozen(boolean)
)
-
setRootPath
Set the path in the real file system that points to the folder/tree containing the log files.This method will only success if the folder specified by the
path
argument is valid within the file system.- Parameters:
path
- the path in the real file system that points to the folder containing the log files- Throws:
CmsRuntimeException
- if the configuration of this instance has been frozenCmsRfsException
- if the given path is invalid
-
setWindowPos
Sets the start position of the current display.This is a count of "windows" that consist of viewable text with "windowSize" lines of text (for a non-standard log file) or log-entries (for a standard log file).
- Parameters:
windowPos
- the start position of the current display to set- Throws:
CmsRuntimeException
- if the configuration of this instance has been frozen (setFrozen(boolean)
)
-
setWindowSize
Set the amount of lines (or entries depending on whether a standard log file is shown) to display per page.- Parameters:
windowSize
- the amount of lines to display per page- Throws:
CmsRuntimeException
- if the configuration of this instance has been frozen (setFrozen(boolean)
)
-