DYFIIndexerWedge.java

  1. package gov.usgs.earthquake.dyfi;

  2. import gov.usgs.earthquake.distribution.ConfigurationException;
  3. import gov.usgs.earthquake.distribution.ExternalNotificationListener;
  4. import gov.usgs.earthquake.product.Product;
  5. import gov.usgs.util.Config;

  6. import java.util.logging.Logger;

  7. /**
  8.  * Legacy interface to trigger pre-Indexer ShakeMap processing.
  9.  */
  10. @Deprecated
  11. public class DYFIIndexerWedge extends ExternalNotificationListener {

  12.     private static final Logger LOGGER = Logger
  13.             .getLogger("gov.usgs.earthquake.dyfi.DYFIIndexerWedge");

  14.     /** Property for baseDirectory */
  15.     public static final String BASE_DIRECTORY_PROPERTY = "baseDirectory";
  16.     private String baseDirectory = null;

  17.     /** Constructor */
  18.     public DYFIIndexerWedge() {
  19.         getIncludeTypes().add("dyfi");
  20.     }

  21.     /**
  22.      * Builds the command to index the product. Just appends the relative
  23.      * product directory (from the DYFILegacyStorage) to the configured index
  24.      * command.
  25.      *
  26.      * @param product
  27.      *            the Product used to build the indexing command.
  28.      * @throws Exception if error occurs
  29.      */
  30.     @Override
  31.     public String getProductCommand(final Product product) throws Exception {
  32.         StringBuffer pc = new StringBuffer(getCommand());

  33.         pc.append(" ").append("--directory=").append(baseDirectory)
  34.                 .append(getStorage().getProductPath(product.getId()));

  35.         return pc.toString();
  36.     }

  37.     @Override
  38.     public void configure(Config config) throws Exception {
  39.         super.configure(config);

  40.         // Base directory
  41.         baseDirectory = config.getProperty(BASE_DIRECTORY_PROPERTY);
  42.         if (baseDirectory == null) {
  43.             throw new ConfigurationException("[" + getName()
  44.                     + "] 'baseDirectory' is a required configuration property");
  45.         }
  46.         LOGGER.config("[" + getName() + "] baseDirectory is '" + baseDirectory
  47.                 + "'");
  48.     }
  49. }