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.getLogger("gov.usgs.earthquake.dyfi.DYFIIndexerWedge");

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

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

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

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

  31.     return pc.toString();
  32.   }

  33.   @Override
  34.   public void configure(Config config) throws Exception {
  35.     super.configure(config);

  36.     // Base directory
  37.     baseDirectory = config.getProperty(BASE_DIRECTORY_PROPERTY);
  38.     if (baseDirectory == null) {
  39.       throw new ConfigurationException("[" + getName() + "] 'baseDirectory' is a required configuration property");
  40.     }
  41.     LOGGER.config("[" + getName() + "] baseDirectory is '" + baseDirectory + "'");
  42.   }
  43. }