Class URLProductStorage

All Implemented Interfaces:
ProductStorage, Configurable

public class URLProductStorage extends FileProductStorage
Store products in a file system which is also available at a URL.
  • Field Details

    • URL_PROPERTY_NAME

      public static final String URL_PROPERTY_NAME
      Property name representing base URL.
      See Also:
    • STORAGE_FORMAT_PROPERTY

      public static final String STORAGE_FORMAT_PROPERTY
      Property for storageFormat
      See Also:
    • STORAGE_PATH_PROPERTY

      public static final String STORAGE_PATH_PROPERTY
      Property for storagePath
      See Also:
    • DEFAULT_STORAGE_PATH

      public static final String DEFAULT_STORAGE_PATH
      Sets up default storage path
      See Also:
    • BINARY_FORMAT_PROPERTY

      public static final String BINARY_FORMAT_PROPERTY
      (Deprecated, use STORAGE_PATH) Property name to configure binary or xml format.
      See Also:
    • BINARY_FORMAT_DEFAULT

      public static final String BINARY_FORMAT_DEFAULT
      Default value for whether to use binary format.
      See Also:
  • Constructor Details

    • URLProductStorage

      public URLProductStorage()
      Constructor for the Configurable interface.
    • URLProductStorage

      public URLProductStorage(File baseDirectory, URL baseURL)
      Construct a new ProductStorage object
      Parameters:
      baseDirectory - the storage directory where products are stored.
      baseURL - the url where storage directory is available.
  • Method Details

    • configure

      public void configure(Config config) throws Exception
      Load the baseURL from configuration.
      Specified by:
      configure in interface Configurable
      Overrides:
      configure in class FileProductStorage
      Parameters:
      config - the configuration object.
      Throws:
      Exception - if configuration exceptions occur.
    • getProductURL

      public URL getProductURL(ProductId id) throws Exception
      Compute the URL to a product.
      Parameters:
      id - which product.
      Returns:
      the URL to a product.
      Throws:
      Exception - if error occurs
    • getProductPath

      public String getProductPath(ProductId id)
      A method for subclasses to override the storage path. The returned path is appended to the base directory when storing and retrieving products.
      Overrides:
      getProductPath in class FileProductStorage
      Parameters:
      id - the product id to convert.
      Returns:
      the directory used to store id.
    • getProductHandlerFormat

      protected ProductHandler getProductHandlerFormat(File file) throws Exception
      A method for subclasses to override the storage format. When overriding this method, the method getProductInputForFile should also be overridden.
      Overrides:
      getProductHandlerFormat in class FileProductStorage
      Parameters:
      file - a file that should be converted into a ProductOutput.
      Returns:
      the ProductOutput.
      Throws:
      Exception - if error occurs
    • getProductSourceFormat

      protected ProductSource getProductSourceFormat(File file) throws Exception
      A method for subclasses to override the storage format. When overriding this method, the method getProductOutputForFile should also be overridden.
      Overrides:
      getProductSourceFormat in class FileProductStorage
      Parameters:
      file - a file that should be converted into a ProductInput.
      Returns:
      the ProductInput.
      Throws:
      Exception - if error occurs
    • getStorageFormat

      public URLProductStorage.Format getStorageFormat()
      Returns:
      storageFormat
    • setStorageFormat

      public void setStorageFormat(URLProductStorage.Format format)
      Parameters:
      format - set a storageFormat
    • getStoragePath

      public String getStoragePath()
      Returns:
      storagePath
    • setStoragePath

      public void setStoragePath(String path)
      Parameters:
      path - set a string as the storagePath