Interface ProductStorage

All Superinterfaces:
Configurable
All Known Implementing Classes:
ConsolidatedFileProductStorage, DYFILegacyStorage, FileProductStorage, HashFileProductStorage, JsonProductStorage, URLProductStorage

public interface ProductStorage extends Configurable
Stores and retrieves Products. This is typically used by a NotificationReceiver to store downloaded products.
  • Method Details

    • hasProduct

      boolean hasProduct(ProductId id) throws Exception
      A method to check whether a product is already in storage. Implementers should define this method as more than "getProduct(id) != null" when it is significantly less expensive to check whether a product exists, compared to loading a product from storage.
      Parameters:
      id - the product to check.
      Returns:
      true if the product is in this storage, false otherwise.
      Throws:
      Exception - if an error occurs while checking.
    • getProduct

      Product getProduct(ProductId id) throws Exception
      Retrieve a stored product. May be implemented as
       return ObjectProductHandler.getProduct(getProductInput(id));
       
      Parameters:
      id - which product to retrieve.
      Returns:
      the retrieved product, or null if the product isn't in storage.
      Throws:
      Exception - if errors occur while retrieving product.
    • storeProduct

      ProductId storeProduct(Product product) throws Exception
      Store a product. May be implemented as
       return storeProductSource(new ObjectProductInput(product));
       
      Parameters:
      product - the product to store.
      Returns:
      the stored product's id.
      Throws:
      Exception - if errors occur while storing product.
    • getProductSource

      ProductSource getProductSource(ProductId id) throws Exception
      Retrieve a ProductSource for a stored product.
      Parameters:
      id - which product to retrieve.
      Returns:
      a ProductInput for the stored product, or null if not in storage.
      Throws:
      Exception - if any errors occur while getting the ProductInput.
    • storeProductSource

      ProductId storeProductSource(ProductSource input) throws Exception
      Store a ProductSource.
      Parameters:
      input - the product to store.
      Returns:
      the stored product's id.
      Throws:
      Exception - if errors occur while storing product.
    • removeProduct

      void removeProduct(ProductId id) throws Exception
      Remove a Product from storage, if it exists.
      Parameters:
      id - which product to remove.
      Throws:
      Exception - if errors occur while removing product.
    • notifyListeners

      void notifyListeners(StorageEvent event)
      Notifies StorageListeners of the change to the ProductStorage.
      Parameters:
      event - StorageEvent
    • addStorageListener

      void addStorageListener(StorageListener listener)
      Adds a StorageListener to be notified when a change occurs in this ProductStorage.
      Parameters:
      listener - The listener to notify of changes.
    • removeStorageListener

      void removeStorageListener(StorageListener listener)
      Removes a StorageListener from being notified when a change occurs in this ProductStorage.
      Parameters:
      listener - The listener to remove