Class ExternalIndexerListener

  • All Implemented Interfaces:
    IndexerListener, Configurable
    Direct Known Subclasses:
    ExternalPreferredListener

    public class ExternalIndexerListener
    extends DefaultIndexerListener
    ExternalIndexerListener triggers external, non-Java listener processes. Provides a translation to a command-line interface for the product indexer to speak with external, non-Java listeners. As a child-class of the AbstractListener, this also accepts the following configration parameters:
    command
    (Required) The command to execute. This must be an executable command and may include arguments. Any product-specific arguments are appended at the end of command.
    storage
    (Required) A directory used to store all products. Each product is extracted into a separate directory within this directory and is referenced by the --directory=/path/to/directory argument when command is executed.
    processUnassociated
    (Optional, Default = false) Whether or not to process unassociated products. Valid values are "true" and "false".
    processPreferredOnly
    (Optional, Default = false) Whether or not to process only preferred products of the type accepted by this listener. Valid values are "true" and "false".
    autoArchive
    (Optional, Default = false) Whether or not to archive products from storage when they are archived by the indexer.
    • Field Detail

      • EVENT_ACTION_ARGUMENT

        public static final java.lang.String EVENT_ACTION_ARGUMENT
        Argument for event action
        See Also:
        Constant Field Values
      • EVENT_IDS_ARGUMENT

        public static final java.lang.String EVENT_IDS_ARGUMENT
        Argument for event ids
        See Also:
        Constant Field Values
      • PREFERRED_ID_ARGUMENT

        public static final java.lang.String PREFERRED_ID_ARGUMENT
        Argument for preferred event id
        See Also:
        Constant Field Values
      • PREFERRED_EVENTSOURCE_ARGUMENT

        public static final java.lang.String PREFERRED_EVENTSOURCE_ARGUMENT
        Argument for preferred eventsource
        See Also:
        Constant Field Values
      • PREFERRED_EVENTSOURCECODE_ARGUMENT

        public static final java.lang.String PREFERRED_EVENTSOURCECODE_ARGUMENT
        Argument for preferred eventsourcecode
        See Also:
        Constant Field Values
      • PREFERRED_MAGNITUDE_ARGUMENT

        public static final java.lang.String PREFERRED_MAGNITUDE_ARGUMENT
        Argument for preferred magnitude
        See Also:
        Constant Field Values
      • PREFERRED_LONGITUDE_ARGUMENT

        public static final java.lang.String PREFERRED_LONGITUDE_ARGUMENT
        Argument for preferred longitude
        See Also:
        Constant Field Values
      • PREFERRED_LATITUDE_ARGUMENT

        public static final java.lang.String PREFERRED_LATITUDE_ARGUMENT
        Argument for preferred latitude
        See Also:
        Constant Field Values
      • PREFERRED_DEPTH_ARGUMENT

        public static final java.lang.String PREFERRED_DEPTH_ARGUMENT
        Argument for preferred depth
        See Also:
        Constant Field Values
      • PREFERRED_ORIGIN_TIME_ARGUMENT

        public static final java.lang.String PREFERRED_ORIGIN_TIME_ARGUMENT
        Argument for preferred eventitme
        See Also:
        Constant Field Values
      • STORAGE_NAME_PROPERTY

        public static final java.lang.String STORAGE_NAME_PROPERTY
        Configuration parameter for storage directory product.
        See Also:
        Constant Field Values
      • STORAGE_DIRECTORY_PROPERTY

        public static final java.lang.String STORAGE_DIRECTORY_PROPERTY
        Short circuit to directly configure storage directory.
        See Also:
        Constant Field Values
      • COMMAND_PROPERTY

        public static final java.lang.String COMMAND_PROPERTY
        Configuration parameter for command.
        See Also:
        Constant Field Values
      • AUTO_ARCHIVE_PROPERTY

        public static final java.lang.String AUTO_ARCHIVE_PROPERTY
        Configuration parameter for autoArchive.
        See Also:
        Constant Field Values
      • AUTO_ARCHIVE_DEFAULT

        public static final java.lang.String AUTO_ARCHIVE_DEFAULT
        Default state for auto archive
        See Also:
        Constant Field Values
      • SIGNATURE_ARGUMENT

        public static final java.lang.String SIGNATURE_ARGUMENT
        Argument used to pass signature to external process.
        See Also:
        Constant Field Values
    • Constructor Detail

      • ExternalIndexerListener

        public ExternalIndexerListener()
        Construct a new ExternalIndexerListener object The listener must be configured with a FileProductStorage and a command to function.
    • Method Detail

      • storeProduct

        public Product storeProduct​(Product product)
                             throws java.lang.Exception
        Store product associated with the change.
        Parameters:
        product - product to be stored.
        Returns:
        a new product object, read from the listener storage.
        Throws:
        java.lang.Exception - if error occurs
      • runProductCommand

        public void runProductCommand​(java.lang.String command,
                                      Product product)
                               throws java.lang.Exception
        Run a product command.
        Parameters:
        command - command and arguments.
        product - product, when set and empty content (path "") is defined, the content is provided to the command on stdin.
        Throws:
        java.lang.Exception - if error occurs
      • getProductSummaryCommand

        public java.lang.String getProductSummaryCommand​(IndexerEvent change,
                                                         IndexerChange indexerChange)
                                                  throws java.lang.Exception
        Get the product command and add the indexer arguments to it.
        Parameters:
        change - The IndexerEvent received by the ExternalIndexerListener
        indexerChange - The IndexerChange
        Returns:
        the command to execute with its arguments as a string
        Throws:
        java.lang.Exception - if error occurs
      • getProductSummaryCommand

        public java.lang.String getProductSummaryCommand​(Event event,
                                                         ProductSummary summary)
                                                  throws java.lang.Exception
        Get the command for a specific event and summary.
        Parameters:
        event - Specific event
        summary - Specific product summary
        Returns:
        command line arguments as a string.
        Throws:
        java.lang.Exception - if error occurs
      • getEventArguments

        public java.lang.String getEventArguments​(Event event)
        Get command line arguments for an event.
        Parameters:
        event - the event
        Returns:
        command line arguments
      • getProductSummaryArguments

        public java.lang.String getProductSummaryArguments​(ProductSummary summary)
                                                    throws java.io.IOException
        Get command line arguments for a product summary.
        Parameters:
        summary - the product summary
        Returns:
        command line arguments
        Throws:
        java.io.IOException - if IO error occurs
      • configure

        public void configure​(Config config)
                       throws java.lang.Exception
        Configure an ExternalNotificationListener using a Config object.
        Specified by:
        configure in interface Configurable
        Overrides:
        configure in class DefaultIndexerListener
        Parameters:
        config - the config containing a
        Throws:
        java.lang.Exception - if configuration exceptions occur.
      • shutdown

        public void shutdown()
                      throws java.lang.Exception
        Called when client is shutting down.
        Specified by:
        shutdown in interface Configurable
        Overrides:
        shutdown in class DefaultConfigurable
        Throws:
        java.lang.Exception - if exceptions occur while starting.
      • startup

        public void startup()
                     throws java.lang.Exception
        Called after client has been configured and should begin processing.
        Specified by:
        startup in interface Configurable
        Overrides:
        startup in class DefaultConfigurable
        Throws:
        java.lang.Exception - if exceptions occur while starting.
      • setStorage

        public void setStorage​(FileProductStorage storage)
        Parameters:
        storage - the storage to set
      • getCommand

        public java.lang.String getCommand()
        Returns:
        the command
      • setCommand

        public void setCommand​(java.lang.String command)
        Parameters:
        command - the command to set
      • isAutoArchive

        public boolean isAutoArchive()
        Returns:
        the autoArchive
      • setAutoArchive

        public void setAutoArchive​(boolean autoArchive)
        Parameters:
        autoArchive - the autoArchive to set