Class ProductBuilder

  • All Implemented Interfaces:
    Configurable
    Direct Known Subclasses:
    EIDSInputWedge, EIDSProductBuilder

    public class ProductBuilder
    extends DefaultConfigurable
    Essentials for building/sending products. This is the base class for other builders. Supported configurable properties:
    senders
    A comma delimited list of product senders to use when sending products.
    trackerURL
    Default tracker URL to assign to products that don't already have one.
    privateKeyFile
    Path to a private key that can be used to sign products.
    • Field Detail

      • SENDERS_PROPERTY

        public static final java.lang.String SENDERS_PROPERTY
        Configurable property for senders.
        See Also:
        Constant Field Values
      • TRACKER_URL_PROPERTY

        public static final java.lang.String TRACKER_URL_PROPERTY
        Property name used for configuring a tracker url.
        See Also:
        Constant Field Values
      • PRIVATE_KEY_PROPERTY

        public static final java.lang.String PRIVATE_KEY_PROPERTY
        Private key filename configuration property.
        See Also:
        Constant Field Values
      • SIGNATURE_VERSION_PROPERTY

        public static final java.lang.String SIGNATURE_VERSION_PROPERTY
        Signature version property.
        See Also:
        Constant Field Values
      • PARALLEL_SEND_PROPERTY

        public static final java.lang.String PARALLEL_SEND_PROPERTY
        Send in parallel.
        See Also:
        Constant Field Values
      • DEFAULT_PARALLEL_SEND

        public static final java.lang.String DEFAULT_PARALLEL_SEND
        Bool for parallel send
        See Also:
        Constant Field Values
      • PARALLEL_SEND_TIMEOUT_PROPERTY

        public static final java.lang.String PARALLEL_SEND_TIMEOUT_PROPERTY
        Timeout in seconds for parallel send.
        See Also:
        Constant Field Values
      • DEFAULT_PARALLEL_SEND_TIMEOUT

        public static final java.lang.String DEFAULT_PARALLEL_SEND_TIMEOUT
        time in ms for parallel send timemout
        See Also:
        Constant Field Values
      • DEFAULT_TRACKER_URL

        public static final java.net.URL DEFAULT_TRACKER_URL
        Default tracker url.
      • parallelSend

        protected boolean parallelSend
        Whether to send in parallel.
      • parallelSendTimeout

        protected long parallelSendTimeout
        How long to wait before parallel send timeout.
    • Constructor Detail

      • ProductBuilder

        public ProductBuilder()
        Default product builder constructor
    • Method Detail

      • sendProduct

        public java.util.Map<ProductSender,​java.lang.Exception> sendProduct​(Product product)
                                                                           throws java.lang.Exception
        Send a product. If the product doesn't yet have a tracker URL, assigns current tracker URL to product. If the product has not yet been signed, and a privateKey is configured, signs the product before sending.
        Parameters:
        product - the product to send.
        Returns:
        map of all exceptions thrown, from Sender to corresponding Exception.
        Throws:
        java.lang.Exception - if an error occurs while signing product.
      • getProductSenders

        public java.util.List<ProductSender> getProductSenders()
        Returns:
        list of product senders
      • addProductSender

        public void addProductSender​(ProductSender sender)
        Add a ProductSender.
        Parameters:
        sender - to add
      • removeProductSender

        public void removeProductSender​(ProductSender sender)
        Remove a previously added ProductSender.
        Parameters:
        sender - to remove
      • getTrackerURL

        public java.net.URL getTrackerURL()
        Returns:
        trackerURL
      • setTrackerURL

        public void setTrackerURL​(java.net.URL trackerURL)
        Parameters:
        trackerURL - to set
      • getPrivateKey

        public java.security.PrivateKey getPrivateKey()
        Returns:
        privateKey
      • setPrivateKey

        public void setPrivateKey​(java.security.PrivateKey privateKey)
        Parameters:
        privateKey - to set
      • getSignatureVersion

        public CryptoUtils.Version getSignatureVersion()
        Returns:
        signatureVersion
      • setSignatureVersion

        public void setSignatureVersion​(CryptoUtils.Version signatureVersion)
        Parameters:
        signatureVersion - to set
      • configure

        public void configure​(Config config)
                       throws java.lang.Exception
        Description copied from class: DefaultConfigurable
        Process configuration settings. Called before startup().
        Specified by:
        configure in interface Configurable
        Overrides:
        configure in class DefaultConfigurable
        Parameters:
        config - the Config object with settings.
        Throws:
        java.lang.Exception - if configuration exceptions occur.
      • parallelSendProduct

        public static java.util.Map<ProductSender,​java.lang.Exception> parallelSendProduct​(java.util.List<ProductSender> senders,
                                                                                                 Product product,
                                                                                                 long timeoutSeconds)
        Send a product to all ProductSenders concurrently.
        Parameters:
        senders - the senders to receive product.
        product - the product to send.
        timeoutSeconds - number of seconds before timing out, interrupting any pending send.
        Returns:
        exceptions that occured while sending. If map is empty, there were no exceptions.