org.rhq.core.pluginapi.util
Class SnapshotReport

java.lang.Object
  extended by org.rhq.core.pluginapi.util.SnapshotReport

public class SnapshotReport
extends Object

A common snapshot report that allows you to prepare a zip'ed file containing a snapshot of content belonging to a resource. This report contains a snapshot configuration, log and data files along with a customizable set of additional files. Users of this object can pick and choose which types of files to snapshot and filter the files of those types. This class can be subclassed if you wish to alter the way it collects and stores the snapshot content. For example, if the configuration is not stored as files, but instead stored in memory, you can subclass this to obtain the configuration by reading memory, writing that data to a temporary file and then having this class add that temporary file to the snapshot zip file.


Nested Class Summary
protected static class SnapshotReport.RegexFilenameFilter
          Filename filter that matches the filename if it matches a given regular expression.
 
Field Summary
static String PROP_ADDITIONAL_FILES_DIRECTORY
          A config property whose value is a directory relative to the base directory where additional files are located.
static String PROP_ADDITIONAL_FILES_LIST
          The property name for the list of of additional files.
static String PROP_ADDITIONAL_FILES_RECURSIVE
          A config property whose value is the boolean flag to indicate if the snapshot should include files found in subdirectories of the additional files directory.
static String PROP_ADDITIONAL_FILES_REGEX
          A config property whose value is a regular expression that matches all additional files that are to be snapshotted.
static String PROP_BASE_DIRECTORY
          A config property whose value is the base directory where all config, logs and data files are under.
static String PROP_CONFIG_DIRECTORY
          A config property whose value is the directory relative to the base directory where the configuration files are located.
static String PROP_CONFIG_RECURSIVE
          A config property whose value is the boolean flag to indicate if the snapshot should include files found in subdirectories of the config directory.
static String PROP_CONFIG_REGEX
          A config property whose value is a regular expression that matches all config files that are to be snapshotted.
static String PROP_DATA_DIRECTORY
          A config property whose value is the directory relative to the base directory where the data files are located.
static String PROP_DATA_RECURSIVE
          A config property whose value is the boolean flag to indicate if the snapshot should include files found in subdirectories of the data directory.
static String PROP_DATA_REGEX
          A config property whose value is a regular expression that matches all data files that are to be snapshotted.
static String PROP_LOG_DIRECTORY
          A config property whose value is the directory relative to the base directory where the log files are located.
static String PROP_LOG_RECURSIVE
          A config property whose value is the boolean flag to indicate if the snapshot should include files found in subdirectories of the log directory.
static String PROP_LOG_REGEX
          A config property whose value is a regular expression that matches all log files that are to be snapshotted.
static String PROP_REPORT_OUTPUT_DIRECTORY
          Optional property that can be specified to define where to store the output snapshot report.
static String PROP_SNAPSHOT_ADDITIONAL_FILES
          A boolean config property that dictates if a snapshot of the additional files should be in the report.
static String PROP_SNAPSHOT_CONFIG_FILES
          A boolean config property that dictates if a snapshot of config files should be in the report.
static String PROP_SNAPSHOT_DATA_FILES
          A boolean config property that dictates if a snapshot of data files should be in the report.
static String PROP_SNAPSHOT_LOG_FILES
          A boolean config property that dictates if a snapshot of log files should be in the report.
static String REPORT_CONFIG_DIRECTORY
          The relative directory under the report where the config files can be found.
static String REPORT_DATA_DIRECTORY
          The relative directory under the report where the data files can be found.
static String REPORT_LOG_DIRECTORY
          The relative directory under the report where the log files can be found.
 
Constructor Summary
SnapshotReport(String name, String description, Configuration config)
           
 
Method Summary
 File generate()
           
protected  Map<String,URL> getAdditionalFilesToSnapshot()
           
protected  Map<String,URL> getAllFilesToSnapshot()
           
protected  Map<String,URL> getConfigFilesToSnapshot()
           
protected  Configuration getConfiguration()
           
protected  Map<String,URL> getDataFilesToSnapshot()
           
protected  String getDescription()
           
protected  Map<String,URL> getLogFilesToSnapshot()
           
protected  String getName()
           
protected  File getSnapshotReportFile()
          This only returns the file where the snapshot will be stored.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

REPORT_CONFIG_DIRECTORY

public static final String REPORT_CONFIG_DIRECTORY
The relative directory under the report where the config files can be found. This is the directory that will be found inside the zip file.

See Also:
Constant Field Values

REPORT_LOG_DIRECTORY

public static final String REPORT_LOG_DIRECTORY
The relative directory under the report where the log files can be found. This is the directory that will be found inside the zip file.

See Also:
Constant Field Values

REPORT_DATA_DIRECTORY

public static final String REPORT_DATA_DIRECTORY
The relative directory under the report where the data files can be found. This is the directory that will be found inside the zip file.

See Also:
Constant Field Values

PROP_SNAPSHOT_CONFIG_FILES

public static final String PROP_SNAPSHOT_CONFIG_FILES
A boolean config property that dictates if a snapshot of config files should be in the report.

See Also:
Constant Field Values

PROP_CONFIG_DIRECTORY

public static final String PROP_CONFIG_DIRECTORY
A config property whose value is the directory relative to the base directory where the configuration files are located.

See Also:
Constant Field Values

PROP_CONFIG_REGEX

public static final String PROP_CONFIG_REGEX
A config property whose value is a regular expression that matches all config files that are to be snapshotted. This regex must match files under the config directory.

See Also:
Constant Field Values

PROP_CONFIG_RECURSIVE

public static final String PROP_CONFIG_RECURSIVE
A config property whose value is the boolean flag to indicate if the snapshot should include files found in subdirectories of the config directory.

See Also:
Constant Field Values

PROP_SNAPSHOT_LOG_FILES

public static final String PROP_SNAPSHOT_LOG_FILES
A boolean config property that dictates if a snapshot of log files should be in the report.

See Also:
Constant Field Values

PROP_LOG_DIRECTORY

public static final String PROP_LOG_DIRECTORY
A config property whose value is the directory relative to the base directory where the log files are located.

See Also:
Constant Field Values

PROP_LOG_REGEX

public static final String PROP_LOG_REGEX
A config property whose value is a regular expression that matches all log files that are to be snapshotted. This regex must match files under the log directory.

See Also:
Constant Field Values

PROP_LOG_RECURSIVE

public static final String PROP_LOG_RECURSIVE
A config property whose value is the boolean flag to indicate if the snapshot should include files found in subdirectories of the log directory.

See Also:
Constant Field Values

PROP_SNAPSHOT_DATA_FILES

public static final String PROP_SNAPSHOT_DATA_FILES
A boolean config property that dictates if a snapshot of data files should be in the report.

See Also:
Constant Field Values

PROP_DATA_DIRECTORY

public static final String PROP_DATA_DIRECTORY
A config property whose value is the directory relative to the base directory where the data files are located.

See Also:
Constant Field Values

PROP_DATA_REGEX

public static final String PROP_DATA_REGEX
A config property whose value is a regular expression that matches all data files that are to be snapshotted. This regex must match files under the data directory.

See Also:
Constant Field Values

PROP_DATA_RECURSIVE

public static final String PROP_DATA_RECURSIVE
A config property whose value is the boolean flag to indicate if the snapshot should include files found in subdirectories of the data directory.

See Also:
Constant Field Values

PROP_SNAPSHOT_ADDITIONAL_FILES

public static final String PROP_SNAPSHOT_ADDITIONAL_FILES
A boolean config property that dictates if a snapshot of the additional files should be in the report.

See Also:
Constant Field Values

PROP_ADDITIONAL_FILES_LIST

public static final String PROP_ADDITIONAL_FILES_LIST
The property name for the list of of additional files.

See Also:
Constant Field Values

PROP_ADDITIONAL_FILES_DIRECTORY

public static final String PROP_ADDITIONAL_FILES_DIRECTORY
A config property whose value is a directory relative to the base directory where additional files are located. This should be a property inside a map where that map is a list item within a additional files list.

See Also:
Constant Field Values

PROP_ADDITIONAL_FILES_REGEX

public static final String PROP_ADDITIONAL_FILES_REGEX
A config property whose value is a regular expression that matches all additional files that are to be snapshotted. This regex must match files under its associated additional files directory. This should be a property inside a map where that map is a list item within a additional files list.

See Also:
Constant Field Values

PROP_ADDITIONAL_FILES_RECURSIVE

public static final String PROP_ADDITIONAL_FILES_RECURSIVE
A config property whose value is the boolean flag to indicate if the snapshot should include files found in subdirectories of the additional files directory.

See Also:
Constant Field Values

PROP_BASE_DIRECTORY

public static final String PROP_BASE_DIRECTORY
A config property whose value is the base directory where all config, logs and data files are under. If a config, log or data directory was already specified as an absolute directory, this base directory will not be used. Only when a config, log or data directory is relative will it be assumed to be under the base directory.

See Also:
Constant Field Values

PROP_REPORT_OUTPUT_DIRECTORY

public static final String PROP_REPORT_OUTPUT_DIRECTORY
Optional property that can be specified to define where to store the output snapshot report. If not specified, the platform's tmp directory will be used.

See Also:
Constant Field Values
Constructor Detail

SnapshotReport

public SnapshotReport(String name,
                      String description,
                      Configuration config)
Method Detail

generate

public File generate()
              throws Exception
Throws:
Exception

getName

protected String getName()

getDescription

protected String getDescription()

getConfiguration

protected Configuration getConfiguration()

getSnapshotReportFile

protected File getSnapshotReportFile()
                              throws Exception
This only returns the file where the snapshot will be stored. This method does NOT generate the actual snapshot report. Call generate() to get the full snapshot content.

Returns:
the file where the snapshot report will be stored when it is generated
Throws:
Exception - if the file could not be determined for some reason

getAllFilesToSnapshot

protected Map<String,URL> getAllFilesToSnapshot()
                                         throws Exception
Throws:
Exception

getConfigFilesToSnapshot

protected Map<String,URL> getConfigFilesToSnapshot()
                                            throws Exception
Throws:
Exception

getLogFilesToSnapshot

protected Map<String,URL> getLogFilesToSnapshot()
                                         throws Exception
Throws:
Exception

getDataFilesToSnapshot

protected Map<String,URL> getDataFilesToSnapshot()
                                          throws Exception
Throws:
Exception

getAdditionalFilesToSnapshot

protected Map<String,URL> getAdditionalFilesToSnapshot()
                                                throws Exception
Throws:
Exception


Copyright © 2008-2009 RHQ Project Advisory Board (Red Hat, Inc.). All Rights Reserved.