Package gov.usgs.earthquake.product
Class Product
- java.lang.Object
-
- gov.usgs.earthquake.product.Product
-
- Direct Known Subclasses:
DYFIProduct
,ShakeMap
public class Product extends java.lang.Object
One or more pieces of Content with metadata.- ID
-
Products each have a unique
ProductId
. - Versioning
-
It is possible to create multiple versions of the same product,
by reusing the same
source
,type
, andcode
, with a differentupdateTime
.
More recent (newer)updateTime
s supersede Less recent (older)updateTime
s. - Status
-
To delete a product, create a new version (updateTime)
and set it's status to
STATUS_DELETE
. All other statuses (STATUS_UPDATE
by default) are considered updates, and any value can be used in product-specific ways. - Properties
- Products have key/value attributes that are Strings. These can be useful to convey summary information about a product, so consumers can quickly decide whether to process before opening any product contents.
- Links
-
Similar to properties, links allow a Product to specify a
relation
and one or morelink
for each relation type. Links must beURI
s, and may beProductId
s. - Contents
-
Many Products start as a directory of files, and metadata is determined later.
It's also possible to create products without any Contents attached,
if all the necessary information can be encoded using Properties or Links.
One special "empty path" content, literally at the empty-string path, is handled differently; since an empty path cannot be written to a file. PDL typically reads this in from standard input, or delivers this on standard input to external processes. - Signature
-
A product can have a digital signature, based on a digest of all
product contents and metadata. These are required for most purposes.
CryptoUtils
provides utilities for working with OpenSSH keypairs. - Tracker URL (Deprecated)
- Tracker URLs were initially used to track processing status as distribution progressed. These are no longer supported, and often introduced new problems.
-
-
Field Summary
Fields Modifier and Type Field Description static java.lang.String
DEPTH_PROPERTY
Property for depthstatic java.lang.String
EVENTSOURCE_PROPERTY
Property for eventsourcestatic java.lang.String
EVENTSOURCECODE_PROPERTY
Property for eventsourcecodestatic java.lang.String
EVENTTIME_PROPERTY
Property for eventtimestatic java.lang.String
LATITUDE_PROPERTY
Property for latitudestatic java.lang.String
LONGITUDE_PROPERTY
Property for longitudestatic java.lang.String
MAGNITUDE_PROPERTY
Property for magnitudestatic java.lang.String
STATUS_DELETE
The status message when a product is being deleted.static java.lang.String
STATUS_UPDATE
The status message when a product is being updated.static java.lang.String
VERSION_PROPERTY
Property for version
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description void
addLink(java.lang.String relation, java.net.URI href)
Add a link to a product.java.util.Map<java.lang.String,Content>
getContents()
Returns a reference to the contents map.java.math.BigDecimal
getDepth()
Get the depth property as a big decimal.java.lang.String
getEventId()
Get the event id.java.lang.String
getEventSource()
Get the event source property.java.lang.String
getEventSourceCode()
Get the event source code property.java.util.Date
getEventTime()
Get the event time property as a date.ProductId
getId()
java.math.BigDecimal
getLatitude()
Get the latitude property as a big decimal.java.util.Map<java.lang.String,java.util.List<java.net.URI>>
getLinks()
Returns a reference to the links map.java.math.BigDecimal
getLongitude()
Get the longitude property as a big decimal.java.math.BigDecimal
getMagnitude()
Get the magnitude property as a big decimal.java.util.Map<java.lang.String,java.lang.String>
getProperties()
java.lang.String
getSignature()
CryptoUtils.Version
getSignatureVersion()
java.lang.String
getStatus()
java.net.URL
getTrackerURL()
java.lang.String
getVersion()
Get the version property.boolean
isDeleted()
Product.STATUS_DELETE.equalsIgnoreCase(status).void
setContents(java.util.Map<java.lang.String,Content> contents)
Copies entries from provided map.void
setDepth(java.math.BigDecimal depth)
Set the depth property as a big decimal.void
setEventId(java.lang.String source, java.lang.String sourceCode)
Set both the network and networkId at the same time.void
setEventSource(java.lang.String eventSource)
Set the event source property.void
setEventSourceCode(java.lang.String eventSourceCode)
Set the event id property.void
setEventTime(java.util.Date eventTime)
Set the event time property as a date.void
setId(ProductId id)
void
setLatitude(java.math.BigDecimal latitude)
Set the latitude property as a big decimal.void
setLinks(java.util.Map<java.lang.String,java.util.List<java.net.URI>> links)
Copies entries from provided map.void
setLongitude(java.math.BigDecimal longitude)
Set the longitude property as a big decimal.void
setMagnitude(java.math.BigDecimal magnitude)
Set the magnitude property as a big decimal.void
setProperties(java.util.Map<java.lang.String,java.lang.String> properties)
void
setSignature(java.lang.String signature)
void
setSignatureVersion(CryptoUtils.Version version)
void
setStatus(java.lang.String status)
void
setTrackerURL(java.net.URL trackerURL)
void
setVersion(java.lang.String version)
Set the version property.void
sign(java.security.PrivateKey privateKey)
Sign this product using a PrivateKey and signature v1.void
sign(java.security.PrivateKey privateKey, CryptoUtils.Version version)
Sign this product using a PrivateKey.boolean
verifySignature(java.security.PublicKey[] publicKeys)
Verify this product's signature using Signature V1.boolean
verifySignature(java.security.PublicKey[] publicKeys, CryptoUtils.Version version)
Verify this product's signature.java.security.PublicKey
verifySignatureKey(java.security.PublicKey[] publicKeys, CryptoUtils.Version version)
Try to verify using multiple candidate keys.
-
-
-
Field Detail
-
STATUS_UPDATE
public static final java.lang.String STATUS_UPDATE
The status message when a product is being updated.- See Also:
- Constant Field Values
-
STATUS_DELETE
public static final java.lang.String STATUS_DELETE
The status message when a product is being deleted.- See Also:
- Constant Field Values
-
EVENTSOURCE_PROPERTY
public static final java.lang.String EVENTSOURCE_PROPERTY
Property for eventsource- See Also:
- Constant Field Values
-
EVENTSOURCECODE_PROPERTY
public static final java.lang.String EVENTSOURCECODE_PROPERTY
Property for eventsourcecode- See Also:
- Constant Field Values
-
EVENTTIME_PROPERTY
public static final java.lang.String EVENTTIME_PROPERTY
Property for eventtime- See Also:
- Constant Field Values
-
MAGNITUDE_PROPERTY
public static final java.lang.String MAGNITUDE_PROPERTY
Property for magnitude- See Also:
- Constant Field Values
-
LATITUDE_PROPERTY
public static final java.lang.String LATITUDE_PROPERTY
Property for latitude- See Also:
- Constant Field Values
-
LONGITUDE_PROPERTY
public static final java.lang.String LONGITUDE_PROPERTY
Property for longitude- See Also:
- Constant Field Values
-
DEPTH_PROPERTY
public static final java.lang.String DEPTH_PROPERTY
Property for depth- See Also:
- Constant Field Values
-
VERSION_PROPERTY
public static final java.lang.String VERSION_PROPERTY
Property for version- See Also:
- Constant Field Values
-
-
Constructor Detail
-
Product
public Product(ProductId id)
Construct a new Product with status "UPDATE".- Parameters:
id
- the product's unique Id.
-
Product
public Product(ProductId id, java.lang.String status)
Construct a new Product.- Parameters:
id
- the product's unique Id.status
- the product's status.
-
Product
public Product(Product that)
Copy constructor.- Parameters:
that
- the product to copy.
-
-
Method Detail
-
getId
public ProductId getId()
- Returns:
- the id
-
setId
public void setId(ProductId id)
- Parameters:
id
- the id to set
-
getStatus
public java.lang.String getStatus()
- Returns:
- the status
-
setStatus
public void setStatus(java.lang.String status)
- Parameters:
status
- the status to set
-
isDeleted
public boolean isDeleted()
Product.STATUS_DELETE.equalsIgnoreCase(status).- Returns:
- whether this product is deleted
-
getProperties
public java.util.Map<java.lang.String,java.lang.String> getProperties()
- Returns:
- the properties
-
setProperties
public void setProperties(java.util.Map<java.lang.String,java.lang.String> properties)
- Parameters:
properties
- the properties to set
-
getLinks
public java.util.Map<java.lang.String,java.util.List<java.net.URI>> getLinks()
Returns a reference to the links map.- Returns:
- the links
-
setLinks
public void setLinks(java.util.Map<java.lang.String,java.util.List<java.net.URI>> links)
Copies entries from provided map.- Parameters:
links
- the links to set
-
addLink
public void addLink(java.lang.String relation, java.net.URI href)
Add a link to a product.- Parameters:
relation
- how link is related to product.href
- actual link.
-
getContents
public java.util.Map<java.lang.String,Content> getContents()
Returns a reference to the contents map.- Returns:
- the contents
-
setContents
public void setContents(java.util.Map<java.lang.String,Content> contents)
Copies entries from provided map.- Parameters:
contents
- the contents to set
-
getTrackerURL
public java.net.URL getTrackerURL()
- Returns:
- the trackerURL
-
setTrackerURL
public void setTrackerURL(java.net.URL trackerURL)
- Parameters:
trackerURL
- the trackerURL to set
-
getSignature
public java.lang.String getSignature()
- Returns:
- the signature
-
getSignatureVersion
public CryptoUtils.Version getSignatureVersion()
- Returns:
- the signature
-
setSignature
public void setSignature(java.lang.String signature)
- Parameters:
signature
- the signature to set
-
setSignatureVersion
public void setSignatureVersion(CryptoUtils.Version version)
- Parameters:
version
- the signature version to set
-
sign
public void sign(java.security.PrivateKey privateKey) throws java.lang.Exception
Sign this product using a PrivateKey and signature v1.- Parameters:
privateKey
- used to sign- Throws:
java.lang.Exception
- if error occurs
-
sign
public void sign(java.security.PrivateKey privateKey, CryptoUtils.Version version) throws java.lang.Exception
Sign this product using a PrivateKey.- Parameters:
privateKey
- a DSAPrivateKey or RSAPrivateKey.version
- the signature version to use.- Throws:
java.lang.Exception
- if error occurs
-
verifySignature
public boolean verifySignature(java.security.PublicKey[] publicKeys) throws java.lang.Exception
Verify this product's signature using Signature V1.- Parameters:
publicKeys
- Array of public keys to verify- Returns:
- true if valid, false otherwise.
- Throws:
java.lang.Exception
- if error occurs
-
verifySignature
public boolean verifySignature(java.security.PublicKey[] publicKeys, CryptoUtils.Version version) throws java.lang.Exception
Verify this product's signature. When a product has no signature, this method returns false. The array of public keys corresponds to one or more keys that may have generated the signature. If any of the keys verify, this method returns true.- Parameters:
publicKeys
- an array of publicKeys to test.version
- the signature version to use.- Returns:
- true if valid, false otherwise.
- Throws:
java.lang.Exception
- if error occurs
-
verifySignatureKey
public java.security.PublicKey verifySignatureKey(java.security.PublicKey[] publicKeys, CryptoUtils.Version version) throws java.lang.Exception
Try to verify using multiple candidate keys.- Parameters:
publicKeys
- an array of publicKeys to testversion
- the signature version to use.- Returns:
- true if valid, false otherwise.
- Throws:
java.lang.Exception
- if error occurs
-
getEventId
public java.lang.String getEventId()
Get the event id. The event id is the combination of event source and event source code.- Returns:
- the event id, or null if either event source or event source code is null.
-
setEventId
public void setEventId(java.lang.String source, java.lang.String sourceCode)
Set both the network and networkId at the same time.- Parameters:
source
- the originating network.sourceCode
- the originating network's id.
-
getEventSource
public java.lang.String getEventSource()
Get the event source property.- Returns:
- the event source property, or null if no event source property set.
-
setEventSource
public void setEventSource(java.lang.String eventSource)
Set the event source property.- Parameters:
eventSource
- the event source to set.
-
getEventSourceCode
public java.lang.String getEventSourceCode()
Get the event source code property.- Returns:
- the event source code property, or null if no event source code property set.
-
setEventSourceCode
public void setEventSourceCode(java.lang.String eventSourceCode)
Set the event id property.- Parameters:
eventSourceCode
- the event id to set.
-
getEventTime
public java.util.Date getEventTime()
Get the event time property as a date.- Returns:
- the event time property as a date, or null if no date property set.
-
setEventTime
public void setEventTime(java.util.Date eventTime)
Set the event time property as a date.- Parameters:
eventTime
- the event time to set.
-
getMagnitude
public java.math.BigDecimal getMagnitude()
Get the magnitude property as a big decimal.- Returns:
- the magnitude property as a big decimal, or null if no magnitude property set.
-
setMagnitude
public void setMagnitude(java.math.BigDecimal magnitude)
Set the magnitude property as a big decimal.- Parameters:
magnitude
- the magnitude to set.
-
getLatitude
public java.math.BigDecimal getLatitude()
Get the latitude property as a big decimal.- Returns:
- latitude property as a big decimal, or null if no latitude property set.
-
setLatitude
public void setLatitude(java.math.BigDecimal latitude)
Set the latitude property as a big decimal.- Parameters:
latitude
- the latitude to set.
-
getLongitude
public java.math.BigDecimal getLongitude()
Get the longitude property as a big decimal.- Returns:
- longitude property as a big decimal, or null if no longitude property set.
-
setLongitude
public void setLongitude(java.math.BigDecimal longitude)
Set the longitude property as a big decimal.- Parameters:
longitude
- the longitude to set.
-
getDepth
public java.math.BigDecimal getDepth()
Get the depth property as a big decimal.- Returns:
- depth property as big decimal, or null if no depth property set.
-
setDepth
public void setDepth(java.math.BigDecimal depth)
Set the depth property as a big decimal.- Parameters:
depth
- the depth to set.
-
getVersion
public java.lang.String getVersion()
Get the version property.- Returns:
- the version property, or null if no version property set.
-
setVersion
public void setVersion(java.lang.String version)
Set the version property.- Parameters:
version
- the version to set.
-
-