Interface Transporter
- All Superinterfaces:
AutoCloseable
,Closeable
- All Known Subinterfaces:
HttpTransporter
- All Known Implementing Classes:
AbstractTransporter
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
Modifier and TypeFieldDescriptionstatic 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 TypeMethodDescriptionint
Classifies the type of exception that has been thrown from a previous request to the transporter.void
close()
Closes this transporter and frees any network resources associated with it.void
Downloads a resource from the repository.void
Checks the existence of a resource in the repository.void
Uploads a resource to the repository.
-
Field Details
-
ERROR_OTHER
Classification for exceptions that denote connectivity or authentication issues and any other kind of error that is not mapped to another classification code.- See Also:
-
ERROR_NOT_FOUND
Classification for exceptions that denote a requested resource does not exist in the remote repository. Note that cases where a remote repository is completely inaccessible should be classified asERROR_OTHER
.- See Also:
-
-
Method Details
-
classify
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 benull
.- Returns:
- The classification of the error, either
ERROR_NOT_FOUND
orERROR_OTHER
.
-
peek
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 invokingclassify(Throwable)
with that exception yieldsERROR_NOT_FOUND
.- Parameters:
task
- The existence check to perform, must not benull
.- Throws:
Exception
- If the existence of the specified resource could not be confirmed.
-
get
Downloads a resource from the repository. If the resource is downloaded to a file as given byGetTask.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 benull
.- Throws:
Exception
- If the transfer failed.
-
put
Uploads a resource to the repository.- Parameters:
task
- The upload to perform, must not benull
.- 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 aIllegalStateException
or similar. Closing an already closed transporter is harmless and has no effect.- Specified by:
close
in interfaceAutoCloseable
- Specified by:
close
in interfaceCloseable
-