Interface Transporter
-
- All Superinterfaces:
AutoCloseable
,Closeable
- 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 theTransportListener
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 int
ERROR_NOT_FOUND
Classification for exceptions that denote a requested resource does not exist in the remote repository.static int
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.
-
Method Summary
All Methods Instance Methods Abstract Methods Modifier and Type Method Description int
classify(Throwable error)
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
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 Detail
-
ERROR_OTHER
static final int 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:
classify(Throwable)
, Constant Field Values
-
ERROR_NOT_FOUND
static final int 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:
classify(Throwable)
, Constant Field Values
-
-
Method Detail
-
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 benull
.- Returns:
- The classification of the error, either
ERROR_NOT_FOUND
orERROR_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 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
void get(GetTask task) throws Exception
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
void put(PutTask task) throws Exception
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
-
-