Class 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 Details

    • OUTPUT_DIRECTORY_PROPERTY

      public static final String OUTPUT_DIRECTORY_PROPERTY
      configuration property for includePaths - output directory.
      See Also:
    • TEMP_DIRECTORY_PROPERTY

      public static final String TEMP_DIRECTORY_PROPERTY
      property for temporary directory
      See Also:
    • OUTPUT_FORMAT_PROPERTY

      public static final String OUTPUT_FORMAT_PROPERTY
      property for output format
      See Also:
    • DEFAULT_OUTPUT_FORMAT

      public static final String DEFAULT_OUTPUT_FORMAT
      property for default output format
      See Also:
  • Constructor Details

    • ContentListener

      public ContentListener()
      empty constructor for ContentListener
  • Method Details

    • configure

      public void configure(Config config) throws Exception
      Description copied from class: AbstractListener
      Read the include and exclude types from config.
      Specified by:
      configure in interface Configurable
      Overrides:
      configure in class DefaultNotificationListener
      Parameters:
      config - the Config object with settings.
      Throws:
      Exception - if configuration exceptions occur.
    • onProduct

      public void onProduct(Product product) throws Exception
      Description copied from class: DefaultNotificationListener
      Called by onNotification when a product is retrieved.
      Overrides:
      onProduct in class DefaultNotificationListener
      Parameters:
      product - a product whose notification was accepted.
      Throws:
      Exception - if error occurs
    • getOutputPath

      protected String getOutputPath(ProductId id, 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, String path, Content content) throws Exception
      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

      public File getOutputDirectory()
      Returns:
      the outputDirectory
    • setOutputDirectory

      public void setOutputDirectory(File outputDirectory)
      Parameters:
      outputDirectory - the outputDirectory to set
    • getTempDirectory

      public File getTempDirectory()
      Returns:
      the tempDirectory
    • setTempDirectory

      public void setTempDirectory(File tempDirectory)
      Parameters:
      tempDirectory - the tempDirectory to set
    • getOutputFormat

      public String getOutputFormat()
      Returns:
      the outputFormat
    • setOutputFormat

      public void setOutputFormat(String outputFormat)
      Parameters:
      outputFormat - the outputFormat to set