Interface Transporter

All Superinterfaces:
AutoCloseable, Closeable
All Known Subinterfaces:
HttpTransporter
All Known Implementing Classes:
AbstractTransporter

public interface Transporter extends Closeable
A transporter for a remote repository. A transporter is responsible for transferring resources between the remote repository and the local system. During its operation, the transporter must provide progress feedback via the TransportListener configured on the underlying task.

If applicable, a transporter should obey connect/request timeouts and other relevant settings from the configuration properties of the repository system session.

Note: Implementations must be thread-safe such that a given transporter instance can safely be used for concurrent requests.

  • Field Summary

    Fields
    Modifier and Type
    Field
    Description
    static final int
    Classification for exceptions that denote a requested resource does not exist in the remote repository.
    static final int
    Classification for exceptions that denote connectivity or authentication issues and any other kind of error that is not mapped to another classification code.
  • Method Summary

    Modifier and Type
    Method
    Description
    int
    Classifies the type of exception that has been thrown from a previous request to the transporter.
    void
    Closes this transporter and frees any network resources associated with it.
    void
    get(GetTask task)
    Downloads a resource from the repository.
    void
    peek(PeekTask task)
    Checks the existence of a resource in the repository.
    void
    put(PutTask task)
    Uploads a resource to the repository.
  • Field Details

  • Method Details

    • classify

      int classify(Throwable error)
      Classifies the type of exception that has been thrown from a previous request to the transporter. The exception types employed by a transporter are generally unknown to its caller. Where a caller needs to distinguish between certain error cases, it employs this method to detect which error case corresponds to the exception.
      Parameters:
      error - The exception to classify, must not be null.
      Returns:
      The classification of the error, either ERROR_NOT_FOUND or ERROR_OTHER.
    • peek

      void peek(PeekTask task) throws Exception
      Checks the existence of a resource in the repository. If the remote repository can be contacted successfully but indicates the resource specified in the request does not exist, an exception is thrown such that invoking classify(Throwable) with that exception yields ERROR_NOT_FOUND.
      Parameters:
      task - The existence check to perform, must not be null.
      Throws:
      Exception - If the existence of the specified resource could not be confirmed.
    • get

      void get(GetTask task) throws Exception
      Downloads a resource from the repository. If the resource is downloaded to a file as given by GetTask.getDataFile() and the operation fails midway, the transporter should not delete the partial file but leave its management to the caller.
      Parameters:
      task - The download to perform, must not be null.
      Throws:
      Exception - If the transfer failed.
    • put

      void put(PutTask task) throws Exception
      Uploads a resource to the repository.
      Parameters:
      task - The upload to perform, must not be null.
      Throws:
      Exception - If the transfer failed.
    • close

      void close()
      Closes this transporter and frees any network resources associated with it. Once closed, a transporter must not be used for further transfers, any attempt to do so would yield a IllegalStateException or similar. Closing an already closed transporter is harmless and has no effect.
      Specified by:
      close in interface AutoCloseable
      Specified by:
      close in interface Closeable