Package gov.usgs.earthquake.product
Class Product
java.lang.Object
gov.usgs.earthquake.product.Product
- Direct Known Subclasses:
DYFIProduct
,ShakeMap
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.
-
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final String
Property for depthstatic final String
Property for eventsourcestatic final String
Property for eventsourcecodestatic final String
Property for eventtimestatic final String
Property for latitudestatic final String
Property for longitudestatic final String
Property for magnitudestatic final String
The status message when a product is being deleted.static final String
The status message when a product is being updated.static final String
Property for version -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoid
Add a link to a product.void
Returns a reference to the contents map.getDepth()
Get the depth property as a big decimal.Get the event id.Get the event source property.Get the event source code property.Get the event time property as a date.getId()
Get the latitude property as a big decimal.getLinks()
Returns a reference to the links map.Get the longitude property as a big decimal.Get the magnitude property as a big decimal.Get the version property.boolean
Product.STATUS_DELETE.equalsIgnoreCase(status).void
setContents
(Map<String, Content> contents) Copies entries from provided map.void
setDepth
(BigDecimal depth) Set the depth property as a big decimal.void
setEventId
(String source, String sourceCode) Set both the network and networkId at the same time.void
setEventSource
(String eventSource) Set the event source property.void
setEventSourceCode
(String eventSourceCode) Set the event id property.void
setEventTime
(Date eventTime) Set the event time property as a date.void
void
setLatitude
(BigDecimal latitude) Set the latitude property as a big decimal.void
Copies entries from provided map.void
setLongitude
(BigDecimal longitude) Set the longitude property as a big decimal.void
setMagnitude
(BigDecimal magnitude) Set the magnitude property as a big decimal.void
setProperties
(Map<String, String> properties) void
setSignature
(String signature) void
setSignatureHistory
(List<ProductSignature> historyList) void
setSignatureVersion
(CryptoUtils.Version version) void
void
setVersion
(String version) Set the version property.void
sign
(PrivateKey privateKey, CryptoUtils.Version version) Sign this product using a PrivateKey.boolean
verifySignature
(PublicKey[] publicKeys) Verify this product's signature using Signature V1.boolean
verifySignature
(PublicKey[] publicKeys, CryptoUtils.Version version, int historyDepth) Verify this product's signature.verifySignatureKey
(PublicKey[] publicKeys, CryptoUtils.Version version) Deprecated.verifySignatureKey
(PublicKey[] publicKeys, CryptoUtils.Version version, int historyDepth) Try to verify using multiple candidate keys.
-
Field Details
-
STATUS_UPDATE
The status message when a product is being updated.- See Also:
-
STATUS_DELETE
The status message when a product is being deleted.- See Also:
-
EVENTSOURCE_PROPERTY
Property for eventsource- See Also:
-
EVENTSOURCECODE_PROPERTY
Property for eventsourcecode- See Also:
-
EVENTTIME_PROPERTY
Property for eventtime- See Also:
-
MAGNITUDE_PROPERTY
Property for magnitude- See Also:
-
LATITUDE_PROPERTY
Property for latitude- See Also:
-
LONGITUDE_PROPERTY
Property for longitude- See Also:
-
DEPTH_PROPERTY
Property for depth- See Also:
-
VERSION_PROPERTY
Property for version- See Also:
-
-
Constructor Details
-
Product
Construct a new Product with status "UPDATE".- Parameters:
id
- the product's unique Id.
-
Product
Construct a new Product.- Parameters:
id
- the product's unique Id.status
- the product's status.
-
Product
Copy constructor.- Parameters:
that
- the product to copy.
-
-
Method Details
-
getId
- Returns:
- the id
-
setId
- Parameters:
id
- the id to set
-
getStatus
- Returns:
- the status
-
setStatus
- Parameters:
status
- the status to set
-
isDeleted
public boolean isDeleted()Product.STATUS_DELETE.equalsIgnoreCase(status).- Returns:
- whether this product is deleted
-
getProperties
- Returns:
- the properties
-
setProperties
- Parameters:
properties
- the properties to set
-
getLinks
Returns a reference to the links map.- Returns:
- the links
-
setLinks
Copies entries from provided map.- Parameters:
links
- the links to set
-
addLink
Add a link to a product.- Parameters:
relation
- how link is related to product.href
- actual link.
-
getContents
Returns a reference to the contents map.- Returns:
- the contents
-
setContents
Copies entries from provided map.- Parameters:
contents
- the contents to set
-
getSignature
- Returns:
- the signature
-
getSignatureVersion
- Returns:
- the signature
-
getSignatureHistory
- Returns:
- the signature history
-
setSignature
- Parameters:
signature
- the signature to set
-
setSignatureVersion
- Parameters:
version
- the signature version to set
-
setSignatureHistory
- Parameters:
historyList
- the signature history to set
-
addToSignatureHistory
- Parameters:
entry
- the map entry to prepend to signature history
-
sign
Sign this product using a PrivateKey.- Parameters:
privateKey
- a DSAPrivateKey or RSAPrivateKey.version
- the signature version to use.- Throws:
Exception
- if error occurs
-
verifySignature
Verify this product's signature using Signature V1.- Parameters:
publicKeys
- Array of public keys to verify- Returns:
- true if valid, false otherwise.
- Throws:
Exception
- if error occurs
-
verifySignature
public boolean verifySignature(PublicKey[] publicKeys, CryptoUtils.Version version, int historyDepth) throws 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.historyDepth
- how far to look into the signatureHistory- Returns:
- true if valid, false otherwise.
- Throws:
Exception
- if error occurs
-
verifySignatureKey
public PublicKey verifySignatureKey(PublicKey[] publicKeys, CryptoUtils.Version version, int historyDepth) throws Exception Try to verify using multiple candidate keys.- Parameters:
publicKeys
- an array of publicKeys to testversion
- the signature version to use.historyDepth
- how far to look into the signatureHistory- Returns:
- true if valid, false otherwise.
- Throws:
Exception
- if error occurs
-
verifySignatureKey
@Deprecated public PublicKey verifySignatureKey(PublicKey[] publicKeys, CryptoUtils.Version version) throws Exception Deprecated.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:
Exception
- if error occurs
-
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
Set both the network and networkId at the same time.- Parameters:
source
- the originating network.sourceCode
- the originating network's id.
-
getEventSource
Get the event source property.- Returns:
- the event source property, or null if no event source property set.
-
setEventSource
Set the event source property.- Parameters:
eventSource
- the event source to set.
-
getEventSourceCode
Get the event source code property.- Returns:
- the event source code property, or null if no event source code property set.
-
setEventSourceCode
Set the event id property.- Parameters:
eventSourceCode
- the event id to set.
-
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
Set the event time property as a date.- Parameters:
eventTime
- the event time to set.
-
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
Set the magnitude property as a big decimal.- Parameters:
magnitude
- the magnitude to set.
-
getLatitude
Get the latitude property as a big decimal.- Returns:
- latitude property as a big decimal, or null if no latitude property set.
-
setLatitude
Set the latitude property as a big decimal.- Parameters:
latitude
- the latitude to set.
-
getLongitude
Get the longitude property as a big decimal.- Returns:
- longitude property as a big decimal, or null if no longitude property set.
-
setLongitude
Set the longitude property as a big decimal.- Parameters:
longitude
- the longitude to set.
-
getDepth
Get the depth property as a big decimal.- Returns:
- depth property as big decimal, or null if no depth property set.
-
setDepth
Set the depth property as a big decimal.- Parameters:
depth
- the depth to set.
-
getVersion
Get the version property.- Returns:
- the version property, or null if no version property set.
-
setVersion
Set the version property.- Parameters:
version
- the version to set.
-