Package gov.usgs.earthquake.distribution
Interface ProductStorage
- All Superinterfaces:
Configurable
- All Known Implementing Classes:
ConsolidatedFileProductStorage
,DYFILegacyStorage
,FileProductStorage
,HashFileProductStorage
,JsonProductStorage
,URLProductStorage
Stores and retrieves Products.
This is typically used by a NotificationReceiver to store downloaded
products.
-
Method Summary
Modifier and TypeMethodDescriptionvoid
addStorageListener
(StorageListener listener) Adds aStorageListener
to be notified when a change occurs in thisProductStorage
.getProduct
(ProductId id) Retrieve a stored product.Retrieve a ProductSource for a stored product.boolean
hasProduct
(ProductId id) A method to check whether a product is already in storage.void
notifyListeners
(StorageEvent event) NotifiesStorageListener
s of the change to theProductStorage
.void
Remove a Product from storage, if it exists.void
removeStorageListener
(StorageListener listener) Removes aStorageListener
from being notified when a change occurs in thisProductStorage
.storeProduct
(Product product) Store a product.storeProductSource
(ProductSource input) Store a ProductSource.
-
Method Details
-
hasProduct
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
Retrieve a stored product. May be implemented asreturn 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
Store a product. May be implemented asreturn 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
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
Store a ProductSource.- Parameters:
input
- the product to store.- Returns:
- the stored product's id.
- Throws:
Exception
- if errors occur while storing product.
-
removeProduct
Remove a Product from storage, if it exists.- Parameters:
id
- which product to remove.- Throws:
Exception
- if errors occur while removing product.
-
notifyListeners
NotifiesStorageListener
s of the change to theProductStorage
.- Parameters:
event
- StorageEvent
-
addStorageListener
Adds aStorageListener
to be notified when a change occurs in thisProductStorage
.- Parameters:
listener
- The listener to notify of changes.
-
removeStorageListener
Removes aStorageListener
from being notified when a change occurs in thisProductStorage
.- Parameters:
listener
- The listener to remove
-