Class NetStorageSender

All Implemented Interfaces:
CanUseSharedResource<HttpSession>, FrankElement, HasApplicationContext, HasName, HasPhysicalDestination, IConfigurable, IScopeProvider, ISender, ISenderWithParameters, IWithParameters, NameAware, HasKeystore, HasTruststore, ConfigurableLifecycle, org.springframework.beans.factory.Aware, org.springframework.context.ApplicationContextAware, org.springframework.context.Lifecycle, org.springframework.context.Phased, org.springframework.context.SmartLifecycle

public class NetStorageSender extends AbstractHttpSender
Sender for Akamai NetStorage (HTTP based).

See AbstractHttpSender for more arguments and parameters!

AuthAlias:

If you do not want to specify the nonce and the access token used to authenticate with Akamai, you can use the authalias property. The username represents the nonce and the password the access token.

Since:
7.0-B4
Author:
Niels Meijer
Parameters
Some actions require specific parameters to be set. Optional parameters for the UPLOAD action are: md5, sha1, sha256 and mtime.
  • Field Details

  • Constructor Details

    • NetStorageSender

      public NetStorageSender()
  • Method Details

    • configure

      public void configure() throws ConfigurationException
      Description copied from interface: IConfigurable
      Configure this component.

      configure() is called once at startup of the framework in the configure method of the owner of this IConfigurable. Purpose of this method is to check whether the static configuration of the object is correct. As much as possible class-instantiating should take place in the configure(), to improve performance.

      In the case of a container, this will propagate the configure signal to all components that apply.

      Specified by:
      configure in interface IConfigurable
      Overrides:
      configure in class AbstractHttpSender
      Throws:
      ConfigurationException - in case it was not able to configure the component.
    • getURI

      protected URI getURI(@Nonnull String path) throws URISyntaxException
      Builds the URI with the rootDirectory, optional CpCode and makes sure the path never ends with a slash '/'.
      Overrides:
      getURI in class AbstractHttpSession
      Parameters:
      path - to append to the root
      Returns:
      full path to use as endpoint
      Throws:
      URISyntaxException
    • sendMessage

      @Nonnull public SenderResult sendMessage(@Nonnull Message message, @Nonnull PipeLineSession session) throws SenderException, TimeoutException
      Description copied from interface: ISender
      Send a message to some destination (as configured in the Sender object). This method may only be called after the configure() method is called.

      The following table shows the difference between synchronous and a-synchronous senders:

       synchronousa-synchronous
      ISender.isSynchronous() returnstruefalse
      return value of sendMessage() isthe reply-messagethe messageId of the message sent
      the correlationID specified with sendMessage()may be ignoredis sent with the message
      a {link TimeOutException}may be thrown if a timeout occurs waiting for a replyshould not be expected

      Multiple objects may try to call this method at the same time, from different threads. Implementations of this method should therefore be thread-safe, or synchronized.

      Specified by:
      sendMessage in interface ISender
      Overrides:
      sendMessage in class AbstractHttpSender
      Throws:
      SenderException
      TimeoutException
    • getMethod

      public org.apache.http.client.methods.HttpRequestBase getMethod(URI uri, Message message, @Nonnull ParameterValueList parameters, PipeLineSession session) throws SenderException
      Description copied from class: AbstractHttpSender
      Custom implementation to create a HttpRequest object.
      Specified by:
      getMethod in class AbstractHttpSender
      Parameters:
      uri - endpoint to send the message to
      message - to be sent
      parameters - ParameterValueList that contains all the senders parameters
      session - PipeLineSession to retrieve or store data from, or NULL when not set
      Returns:
      a HttpRequest object
      Throws:
      SenderException
    • extractResult

      public Message extractResult(HttpResponseHandler responseHandler, PipeLineSession session) throws SenderException, IOException
      Description copied from class: AbstractHttpSender
      Custom implementation to extract the response and format it to a String result.
      It is important that the response will be read or will be closed.
      Specified by:
      extractResult in class AbstractHttpSender
      Parameters:
      responseHandler - HttpResponseHandler that contains the response information
      session - PipeLineSession which may be null
      Returns:
      a string that will be passed to the pipeline
      Throws:
      SenderException
      IOException
    • getResponseBodyAsString

      public String getResponseBodyAsString(HttpResponseHandler responseHandler, boolean throwIOExceptionWhenParsingResponse) throws IOException
      When an exception occurs and the response cannot be parsed, we do not want to throw a 'missing response' exception. Since this method is used when handling exceptions, silently return null, to avoid NPE's and IOExceptions
      Throws:
      IOException
    • setHashAlgorithm

      public void setHashAlgorithm(HashAlgorithm hashAlgorithm)
      Only works in combination with the UPLOAD action. If set, and not specified as parameter, the sender will sign the file to be uploaded.
    • setAction

      public void setAction(NetStorageSender.Action action)
      NetStorage action to be used
    • setActionVersion

      public void setActionVersion(int actionVersion)
      At the time of writing, NetStorage only supports version 1
      Default value
      1
    • setCpCode

      public void setCpCode(String cpCode)
      NetStorage CP Code of the storage group
    • setUrl

      public void setUrl(String url)
      The destination URL for the Akamai NetStorage. (Only the hostname, without CpCode; eq. xyz-nsu.akamaihd.net)
      Overrides:
      setUrl in class AbstractHttpSender
    • setNonce

      public void setNonce(String nonce)
      Login is done via a Nonce and AccessToken
      Parameters:
      nonce - to use when logging in
    • setSignVersion

      public void setSignVersion(int signVersion)
      Version to validate queries made to NetStorage backend.
      Parameters:
      signVersion - supports 3 types; 3:MD5, 4:SHA1, 5: SHA256
      Default value
      5
    • getSignType

      public NetStorageCmsSigner.SignType getSignType()
    • setAccessToken

      public void setAccessToken(String accessToken)
      Login is done via a Nonce and AccessToken
      Parameters:
      accessToken - to use when logging in
    • getPhysicalDestinationName

      public String getPhysicalDestinationName()
      Specified by:
      getPhysicalDestinationName in interface HasPhysicalDestination
      Overrides:
      getPhysicalDestinationName in class AbstractHttpSender
    • setRootDir

      public void setRootDir(String rootDir)
      Root directory (appended to the url + cpCode)
    • setAuthAlias

      public void setAuthAlias(String authAlias)
      Alias used to obtain credentials for nonce (username) and accesstoken (password)
      Overrides:
      setAuthAlias in class AbstractHttpSession