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
public class ContentListener extends DefaultNotificationListener
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
Fields Modifier and Type Field Description static java.lang.StringDEFAULT_OUTPUT_FORMATproperty for default output formatstatic java.lang.StringOUTPUT_DIRECTORY_PROPERTYconfiguration property for includePaths - output directory.static java.lang.StringOUTPUT_FORMAT_PROPERTYproperty for output formatstatic java.lang.StringTEMP_DIRECTORY_PROPERTYproperty for temporary directory-
Fields 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 Constructor Description ContentListener()empty constructor for ContentListener
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description voidconfigure(Config config)Read the include and exclude types from config.java.io.FilegetOutputDirectory()java.lang.StringgetOutputFormat()protected java.lang.StringgetOutputPath(ProductId id, java.lang.String path)Generate an output path based on product id and content path.java.io.FilegetTempDirectory()voidonProduct(Product product)Called by onNotification when a product is retrieved.voidsetOutputDirectory(java.io.File outputDirectory)voidsetOutputFormat(java.lang.String outputFormat)voidsetTempDirectory(java.io.File tempDirectory)protected voidwriteContent(ProductId id, java.lang.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 Detail
-
OUTPUT_DIRECTORY_PROPERTY
public static final java.lang.String OUTPUT_DIRECTORY_PROPERTY
configuration property for includePaths - output directory.- See Also:
- Constant Field Values
-
TEMP_DIRECTORY_PROPERTY
public static final java.lang.String TEMP_DIRECTORY_PROPERTY
property for temporary directory- See Also:
- Constant Field Values
-
OUTPUT_FORMAT_PROPERTY
public static final java.lang.String OUTPUT_FORMAT_PROPERTY
property for output format- See Also:
- Constant Field Values
-
DEFAULT_OUTPUT_FORMAT
public static final java.lang.String DEFAULT_OUTPUT_FORMAT
property for default output format- See Also:
- Constant Field Values
-
-
Method Detail
-
configure
public void configure(Config config) throws java.lang.Exception
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:
java.lang.Exception- if configuration exceptions occur.
-
onProduct
public void onProduct(Product product) throws java.lang.Exception
Description copied from class:DefaultNotificationListenerCalled by onNotification when a product is retrieved.- Overrides:
onProductin classDefaultNotificationListener- Parameters:
product- a product whose notification was accepted.- Throws:
java.lang.Exception- if error occurs
-
getOutputPath
protected java.lang.String getOutputPath(ProductId id, java.lang.String path)
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
protected void writeContent(ProductId id, java.lang.String path, Content content) throws java.lang.Exception
Output a product content that was in includePaths.- Parameters:
id- the product id.path- the content path.content- the content.- Throws:
java.lang.Exception- when unable to output the content.
-
getOutputDirectory
public java.io.File getOutputDirectory()
- Returns:
- the outputDirectory
-
setOutputDirectory
public void setOutputDirectory(java.io.File outputDirectory)
- Parameters:
outputDirectory- the outputDirectory to set
-
getTempDirectory
public java.io.File getTempDirectory()
- Returns:
- the tempDirectory
-
setTempDirectory
public void setTempDirectory(java.io.File tempDirectory)
- Parameters:
tempDirectory- the tempDirectory to set
-
getOutputFormat
public java.lang.String getOutputFormat()
- Returns:
- the outputFormat
-
setOutputFormat
public void setOutputFormat(java.lang.String outputFormat)
- Parameters:
outputFormat- the outputFormat to set
-
-