Package gov.usgs.earthquake.distribution
Class URLProductStorage
- java.lang.Object
-
- gov.usgs.util.DefaultConfigurable
-
- gov.usgs.earthquake.distribution.FileProductStorage
-
- gov.usgs.earthquake.distribution.URLProductStorage
-
- All Implemented Interfaces:
ProductStorage,Configurable
public class URLProductStorage extends FileProductStorage
Store products in a file system which is also available at a URL.
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static classURLProductStorage.FormatDifferent types of formats
-
Field Summary
Fields Modifier and Type Field Description static java.lang.StringBINARY_FORMAT_DEFAULTDefault value for whether to use binary format.static java.lang.StringBINARY_FORMAT_PROPERTY(Deprecated, use STORAGE_PATH) Property name to configure binary or xml format.static java.lang.StringDEFAULT_STORAGE_PATHSets up default storage pathstatic java.lang.StringSTORAGE_FORMAT_PROPERTYProperty for storageFormatstatic java.lang.StringSTORAGE_PATH_PROPERTYProperty for storagePathstatic java.lang.StringURL_PROPERTY_NAMEProperty name representing base URL.-
Fields inherited from class gov.usgs.earthquake.distribution.FileProductStorage
DEFAULT_DIRECTORY, DIRECTORY_NAME_LENGTH, DIRECTORY_PROPERTY_NAME, LEGACY_STORAGES_PROPERTY, STORAGE_LISTENER_PROPERTY, USE_HASH_PATHS_DEFAULT, USE_HASH_PATHS_PROPERTY
-
-
Constructor Summary
Constructors Constructor Description URLProductStorage()Constructor for the Configurable interface.URLProductStorage(java.io.File baseDirectory, java.net.URL baseURL)Construct a new ProductStorage object
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description voidconfigure(Config config)Load the baseURL from configuration.protected ProductHandlergetProductHandlerFormat(java.io.File file)A method for subclasses to override the storage format.java.lang.StringgetProductPath(ProductId id)A method for subclasses to override the storage path.protected ProductSourcegetProductSourceFormat(java.io.File file)A method for subclasses to override the storage format.java.net.URLgetProductURL(ProductId id)Compute the URL to a product.URLProductStorage.FormatgetStorageFormat()java.lang.StringgetStoragePath()voidsetStorageFormat(URLProductStorage.Format format)voidsetStoragePath(java.lang.String path)-
Methods inherited from class gov.usgs.earthquake.distribution.FileProductStorage
addStorageListener, getBaseDirectory, getHashedProductPath, getInMemoryProduct, getKeychain, getLegacyStorages, getNormalProductPath, getProduct, getProductFile, getProductSource, getStorageLocks, hasProduct, isRejectInvalidSignatures, isTestSignatures, notifyListeners, removeProduct, removeStorageListener, setBaseDirectory, setKeychain, setRejectInvalidSignatures, setTestSignatures, shutdown, startup, storeProduct, storeProductSource
-
Methods inherited from class gov.usgs.util.DefaultConfigurable
getName, setName
-
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
-
Methods inherited from interface gov.usgs.util.Configurable
getName, setName
-
-
-
-
Field Detail
-
URL_PROPERTY_NAME
public static final java.lang.String URL_PROPERTY_NAME
Property name representing base URL.- See Also:
- Constant Field Values
-
STORAGE_FORMAT_PROPERTY
public static final java.lang.String STORAGE_FORMAT_PROPERTY
Property for storageFormat- See Also:
- Constant Field Values
-
STORAGE_PATH_PROPERTY
public static final java.lang.String STORAGE_PATH_PROPERTY
Property for storagePath- See Also:
- Constant Field Values
-
DEFAULT_STORAGE_PATH
public static final java.lang.String DEFAULT_STORAGE_PATH
Sets up default storage path- See Also:
- Constant Field Values
-
BINARY_FORMAT_PROPERTY
public static final java.lang.String BINARY_FORMAT_PROPERTY
(Deprecated, use STORAGE_PATH) Property name to configure binary or xml format.- See Also:
- Constant Field Values
-
BINARY_FORMAT_DEFAULT
public static final java.lang.String BINARY_FORMAT_DEFAULT
Default value for whether to use binary format.- See Also:
- Constant Field Values
-
-
Constructor Detail
-
URLProductStorage
public URLProductStorage()
Constructor for the Configurable interface.
-
URLProductStorage
public URLProductStorage(java.io.File baseDirectory, java.net.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 Detail
-
configure
public void configure(Config config) throws java.lang.Exception
Load the baseURL from configuration.- Specified by:
configurein interfaceConfigurable- Overrides:
configurein classFileProductStorage- Parameters:
config- the configuration object.- Throws:
java.lang.Exception- if configuration exceptions occur.
-
getProductURL
public java.net.URL getProductURL(ProductId id) throws java.lang.Exception
Compute the URL to a product.- Parameters:
id- which product.- Returns:
- the URL to a product.
- Throws:
java.lang.Exception- if error occurs
-
getProductPath
public java.lang.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:
getProductPathin classFileProductStorage- Parameters:
id- the product id to convert.- Returns:
- the directory used to store id.
-
getProductHandlerFormat
protected ProductHandler getProductHandlerFormat(java.io.File file) throws java.lang.Exception
A method for subclasses to override the storage format. When overriding this method, the method getProductInputForFile should also be overridden.- Overrides:
getProductHandlerFormatin classFileProductStorage- Parameters:
file- a file that should be converted into a ProductOutput.- Returns:
- the ProductOutput.
- Throws:
java.lang.Exception- if error occurs
-
getProductSourceFormat
protected ProductSource getProductSourceFormat(java.io.File file) throws java.lang.Exception
A method for subclasses to override the storage format. When overriding this method, the method getProductOutputForFile should also be overridden.- Overrides:
getProductSourceFormatin classFileProductStorage- Parameters:
file- a file that should be converted into a ProductInput.- Returns:
- the ProductInput.
- Throws:
java.lang.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 java.lang.String getStoragePath()
- Returns:
- storagePath
-
setStoragePath
public void setStoragePath(java.lang.String path)
- Parameters:
path- set a string as the storagePath
-
-