Package gov.usgs.earthquake.distribution
Class ContentListener
java.lang.Object
gov.usgs.util.DefaultConfigurable
gov.usgs.earthquake.product.AbstractListener
gov.usgs.earthquake.distribution.DefaultNotificationListener
gov.usgs.earthquake.distribution.ContentListener
- All Implemented Interfaces:
NotificationIndexCleanup.Listener
,NotificationListener
,Configurable
A listener that listens for a specific content path.
This is intended for users who wish to output specific pieces of product
content, such as "quakeml.xml", for products that otherwise meet their
configured NotificationListener criteria.
-
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final String
property for default output formatstatic final String
configuration property for includePaths - output directory.static final String
property for output formatstatic final String
property for temporary directoryFields inherited from class gov.usgs.earthquake.distribution.DefaultNotificationListener
CLEANUP_INTERVAL_PROPERTY, CONCURRENT_PRODUCTS_PROPERTY, DEFAULT_CLEANUP_INTERVAL, DEFAULT_CONCURRENT_PRODUCTS, DEFAULT_PROCESS_DUPLICATES, EXCLUDE_PATHS_PROPERTY, INCLUDE_PATHS_PROPERTY, INDEX_FILE_PROPERTY, NOTIFICATION_INDEX_PROPERTY, PROCESS_DUPLICATES
Fields inherited from class gov.usgs.earthquake.product.AbstractListener
ATTEMPT_COUNT_PROPERTY, DEFAULT_ATTEMPT_COUNT, DEFAULT_RETRY_DELAY, DEFAULT_TIMEOUT, EXCLUDE_SOURCES_PROPERTY, EXCLUDE_TYPES_PROPERTY, INCLUDE_ACTUALS_PROPERTY, INCLUDE_DEVELOPMENTS_PROPERTY, INCLUDE_INTERNALS_PROPERTY, INCLUDE_SCENARIOS_PROPERTY, INCLUDE_SOURCES_PROPERTY, INCLUDE_TESTS_PROPERTY, INCLUDE_TYPES_PROPERTY, MAX_TRIES_PROPERTY, RETRY_DELAY_PROPERTY, TIMEOUT_PROPERTY
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoid
Read the include and exclude types from config.protected String
getOutputPath
(ProductId id, String path) Generate an output path based on product id and content path.void
Called by onNotification when a product is retrieved.void
setOutputDirectory
(File outputDirectory) void
setOutputFormat
(String outputFormat) void
setTempDirectory
(File tempDirectory) protected void
writeContent
(ProductId id, String path, Content content) Output a product content that was in includePaths.Methods inherited from class gov.usgs.earthquake.distribution.DefaultNotificationListener
cleanup, getCleanupInterval, getConcurrentProducts, getExcludePaths, getIncludePaths, getNotificationIndex, isProcessDuplicates, onAfterProcessNotification, onBeforeProcessNotification, onBeforeProcessProduct, onExpiredNotification, onNotification, setCleanupInterval, setConcurrentProducts, setNotificationIndex, setProcessDuplicates, shutdown, startup
Methods inherited from class gov.usgs.earthquake.product.AbstractListener
accept, getExcludeSources, getExcludeTypes, getIncludeSources, getIncludeTypes, getMaxTries, getRetryDelay, getTimeout, isIncludeActuals, isIncludeDevelopments, isIncludeInternals, isIncludeScenarios, isIncludeTests, setIncludeActuals, setIncludeDevelopments, setIncludeInternals, setIncludeScenarios, setIncludeTests, setMaxTries, setRetryDelay, setTimeout
Methods inherited from class gov.usgs.util.DefaultConfigurable
getName, setName
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
Methods inherited from interface gov.usgs.util.Configurable
getName, setName
Methods inherited from interface gov.usgs.earthquake.distribution.NotificationListener
getMaxTries, getTimeout
-
Field Details
-
OUTPUT_DIRECTORY_PROPERTY
configuration property for includePaths - output directory.- See Also:
-
TEMP_DIRECTORY_PROPERTY
property for temporary directory- See Also:
-
OUTPUT_FORMAT_PROPERTY
property for output format- See Also:
-
DEFAULT_OUTPUT_FORMAT
property for default output format- See Also:
-
-
Constructor Details
-
ContentListener
public ContentListener()empty constructor for ContentListener
-
-
Method Details
-
configure
Description copied from class:AbstractListener
Read the include and exclude types from config.- Specified by:
configure
in interfaceConfigurable
- Overrides:
configure
in classDefaultNotificationListener
- Parameters:
config
- the Config object with settings.- Throws:
Exception
- if configuration exceptions occur.
-
onProduct
Description copied from class:DefaultNotificationListener
Called by onNotification when a product is retrieved.- Overrides:
onProduct
in classDefaultNotificationListener
- Parameters:
product
- a product whose notification was accepted.- Throws:
Exception
- if error occurs
-
getOutputPath
Generate an output path based on product id and content path.- Parameters:
id
- the product id.path
- the content path.- Returns:
- relative path to write content within output directory.
-
writeContent
Output a product content that was in includePaths.- Parameters:
id
- the product id.path
- the content path.content
- the content.- Throws:
Exception
- when unable to output the content.
-
getOutputDirectory
- Returns:
- the outputDirectory
-
setOutputDirectory
- Parameters:
outputDirectory
- the outputDirectory to set
-
getTempDirectory
- Returns:
- the tempDirectory
-
setTempDirectory
- Parameters:
tempDirectory
- the tempDirectory to set
-
getOutputFormat
- Returns:
- the outputFormat
-
setOutputFormat
- Parameters:
outputFormat
- the outputFormat to set
-