Class Product

java.lang.Object
gov.usgs.earthquake.product.Product
Direct Known Subclasses:
DYFIProduct, ShakeMap

public class Product extends 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, and code, with a different updateTime.
More recent (newer) updateTimes supersede Less recent (older) updateTimes.
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 more link for each relation type. Links must be URIs, and may be ProductIds.
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 Details

  • Constructor Details

    • Product

      public Product(ProductId id)
      Construct a new Product with status "UPDATE".
      Parameters:
      id - the product's unique Id.
    • Product

      public Product(ProductId id, 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 Details

    • getId

      public ProductId getId()
      Returns:
      the id
    • setId

      public void setId(ProductId id)
      Parameters:
      id - the id to set
    • getStatus

      public String getStatus()
      Returns:
      the status
    • setStatus

      public void setStatus(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 Map<String,String> getProperties()
      Returns:
      the properties
    • setProperties

      public void setProperties(Map<String,String> properties)
      Parameters:
      properties - the properties to set
    • getLinks

      public Map<String,List<URI>> getLinks()
      Returns a reference to the links map.
      Returns:
      the links
    • setLinks

      public void setLinks(Map<String,List<URI>> links)
      Copies entries from provided map.
      Parameters:
      links - the links to set
    • addLink

      public void addLink(String relation, URI href)
      Add a link to a product.
      Parameters:
      relation - how link is related to product.
      href - actual link.
    • getContents

      public Map<String,Content> getContents()
      Returns a reference to the contents map.
      Returns:
      the contents
    • setContents

      public void setContents(Map<String,Content> contents)
      Copies entries from provided map.
      Parameters:
      contents - the contents to set
    • getSignature

      public String getSignature()
      Returns:
      the signature
    • getSignatureVersion

      public CryptoUtils.Version getSignatureVersion()
      Returns:
      the signature
    • getSignatureHistory

      public List<ProductSignature> getSignatureHistory()
      Returns:
      the signature history
    • setSignature

      public void setSignature(String signature)
      Parameters:
      signature - the signature to set
    • setSignatureVersion

      public void setSignatureVersion(CryptoUtils.Version version)
      Parameters:
      version - the signature version to set
    • setSignatureHistory

      public void setSignatureHistory(List<ProductSignature> historyList)
      Parameters:
      historyList - the signature history to set
    • addToSignatureHistory

      public void addToSignatureHistory(ProductSignature entry)
      Parameters:
      entry - the map entry to prepend to signature history
    • sign

      public void sign(PrivateKey privateKey, CryptoUtils.Version version) throws Exception
      Sign this product using a PrivateKey.
      Parameters:
      privateKey - a DSAPrivateKey or RSAPrivateKey.
      version - the signature version to use.
      Throws:
      Exception - if error occurs
    • verifySignature

      public boolean verifySignature(PublicKey[] publicKeys) throws Exception
      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 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

      @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 test
      version - the signature version to use.
      Returns:
      true if valid, false otherwise.
      Throws:
      Exception - if error occurs
    • getEventId

      public 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(String source, 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 String getEventSource()
      Get the event source property.
      Returns:
      the event source property, or null if no event source property set.
    • setEventSource

      public void setEventSource(String eventSource)
      Set the event source property.
      Parameters:
      eventSource - the event source to set.
    • getEventSourceCode

      public 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(String eventSourceCode)
      Set the event id property.
      Parameters:
      eventSourceCode - the event id to set.
    • getEventTime

      public 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(Date eventTime)
      Set the event time property as a date.
      Parameters:
      eventTime - the event time to set.
    • getMagnitude

      public 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(BigDecimal magnitude)
      Set the magnitude property as a big decimal.
      Parameters:
      magnitude - the magnitude to set.
    • getLatitude

      public 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(BigDecimal latitude)
      Set the latitude property as a big decimal.
      Parameters:
      latitude - the latitude to set.
    • getLongitude

      public 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(BigDecimal longitude)
      Set the longitude property as a big decimal.
      Parameters:
      longitude - the longitude to set.
    • getDepth

      public 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(BigDecimal depth)
      Set the depth property as a big decimal.
      Parameters:
      depth - the depth to set.
    • getVersion

      public String getVersion()
      Get the version property.
      Returns:
      the version property, or null if no version property set.
    • setVersion

      public void setVersion(String version)
      Set the version property.
      Parameters:
      version - the version to set.