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 Stringproperty for default output formatstatic final Stringconfiguration property for includePaths - output directory.static final Stringproperty for output formatstatic final Stringproperty 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_DUPLICATESFields 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 TypeMethodDescriptionvoidRead the include and exclude types from config.protected StringgetOutputPath(ProductId id, String path) Generate an output path based on product id and content path.voidCalled by onNotification when a product is retrieved.voidsetOutputDirectory(File outputDirectory) voidsetOutputFormat(String outputFormat) voidsetTempDirectory(File tempDirectory) protected voidwriteContent(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, startupMethods 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, setTimeoutMethods inherited from class gov.usgs.util.DefaultConfigurable
getName, setNameMethods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface gov.usgs.util.Configurable
getName, setNameMethods 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:AbstractListenerRead the include and exclude types from config.- Specified by:
configurein interfaceConfigurable- Overrides:
configurein classDefaultNotificationListener- Parameters:
config- the Config object with settings.- Throws:
Exception- if configuration exceptions occur.
-
onProduct
Description copied from class:DefaultNotificationListenerCalled by onNotification when a product is retrieved.- Overrides:
onProductin 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
-