public class CmsRfsFileViewer extends java.lang.Object implements java.lang.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.
Modifier and Type | Field and Description |
---|---|
protected static org.apache.commons.logging.Log |
LOG
The log object for this class.
|
protected java.lang.String |
m_filePath
The path to the underlying file.
|
protected java.lang.String |
m_rootPath
The path to the root for all accessible files.
|
protected int |
m_windowPos
The current window (numbered from zero to amount of possible different windows).
|
protected int |
m_windowSize
The amount of lines to show.
|
Constructor and Description |
---|
CmsRfsFileViewer()
Creates an instance with default settings that tries to use the log file path obtained
from
instance. |
Modifier and Type | Method and Description |
---|---|
java.lang.Object |
clone()
Returns a clone of this file view settings that is not "frozen" and therefore allows modifications.
|
java.lang.String |
getFileEncoding()
Returns the canonical name of the character encoding of the underlying file.
|
java.lang.String |
getFilePath()
Returns the path denoting the file that is accessed.
|
boolean |
getIsLogfile()
Returns true if the view's internal file path points to a log file in standard OpenCms format.
|
java.lang.String |
getRootPath()
Returns the path denoting the root folder for all accessible files.
|
int |
getWindowPos()
Returns the start position of the current display.
|
int |
getWindowSize()
Get the amount of lines (or entries depending on whether a standard log file is shown)
to display per page.
|
boolean |
isEnabled()
Returns true if this view upon the underlying file via
is enabled. |
java.lang.String |
readFilePortion()
Return the view portion of lines of text from the underlying file or an
empty String if
returns false . |
void |
setAdditionalRoots(java.util.List<java.lang.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. |
void |
setFileEncoding(java.lang.String fileEncoding)
Set the character encoding of the underlying file.
|
void |
setFilePath(java.lang.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's
method. |
void |
setIsLogfile(boolean isLogfile)
Set if the internal file is in standard log file format (true) or not (false).
|
void |
setRootPath(java.lang.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.
|
protected static final org.apache.commons.logging.Log LOG
protected java.lang.String m_filePath
protected java.lang.String m_rootPath
protected int m_windowPos
protected int m_windowSize
public CmsRfsFileViewer()
OpenCms
's CmsSystemInfo
instance.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.
public java.lang.Object clone()
Every instance that plans to modify settings has to obtain a clone first that may be
modified. The original instance returned from
(
) will throw
a CmsWorkplaceManager.getFileViewSettings()
for each setter invocation. CmsRuntimeException
clone
in class java.lang.Object
public java.lang.String getFileEncoding()
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.
public java.lang.String getFilePath()
public boolean getIsLogfile()
public java.lang.String getRootPath()
public int getWindowPos()
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).
public int getWindowSize()
public boolean isEnabled()
readFilePortion()
is enabled.readFilePortion()
is enabled.public java.lang.String readFilePortion() throws CmsRfsException
isEnabled()
returns false
.isEnabled()
returns false
CmsRfsException
- if something goes wrongpublic void setAdditionalRoots(java.util.List<java.lang.String> roots)
roots
- the list of additional root folderspublic void setEnabled(boolean preview)
readFilePortion()
is enabled.preview
- the boolean that decides if the view to the underlying file via
readFilePortion()
is enabledpublic void setFileEncoding(java.lang.String fileEncoding)
The given String has to match a valid char set name (canonical or alias)
of one of the system's supported
instances
(see Charset
).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.
fileEncoding
- the character encoding of the underlying file to setpublic void setFilePath(java.lang.String path) throws CmsRfsException, CmsRuntimeException
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.
path
- the path in the real file system that points to the file that should be displayed to setCmsRuntimeException
- if the configuration of this instance has been frozenCmsRfsException
- if the given path is invalid, does not point to a file or cannot be accessedpublic void setFrozen(boolean frozen) throws CmsRuntimeException
CmsWorkplaceManager
to "freeze" this instance within the system-wide assignment in it's
CmsWorkplaceManager.setFileViewSettings(org.opencms.file.CmsObject, CmsRfsFileViewer)
method.frozen
- if true this instance will freeze and throw CmsRuntimeExceptions
upon setter invocationsCmsRuntimeException
- if the configuration of this instance has been frozen
(setFrozen(boolean)
)public void setIsLogfile(boolean isLogfile) throws CmsRuntimeException
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).
isLogfile
- determines if the internal file is in standard log file format (true) or not (false)CmsRuntimeException
- if the configuration of this instance has been frozen
(setFrozen(boolean)
)public void setRootPath(java.lang.String path) throws CmsRfsException, CmsRuntimeException
This method will only success if the folder specified by the path
argument is valid within the file system.
path
- the path in the real file system that points to the folder containing the log filesCmsRuntimeException
- if the configuration of this instance has been frozenCmsRfsException
- if the given path is invalidpublic void setWindowPos(int windowPos) throws CmsRuntimeException
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).
windowPos
- the start position of the current display to setCmsRuntimeException
- if the configuration of this instance has been frozen
(setFrozen(boolean)
)public void setWindowSize(int windowSize) throws CmsRuntimeException
windowSize
- the amount of lines to display per pageCmsRuntimeException
- if the configuration of this instance has been frozen
(setFrozen(boolean)
)