public interface Transporter extends Closeable
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.
Modifier and Type | Field and 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.
|
Modifier and Type | Method and 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.
|
static final int ERROR_OTHER
classify(Throwable)
,
Constant Field Valuesstatic final int ERROR_NOT_FOUND
ERROR_OTHER
.classify(Throwable)
,
Constant Field Valuesint classify(Throwable error)
error
- The exception to classify, must not be null
.ERROR_NOT_FOUND
or ERROR_OTHER
.void peek(PeekTask task) throws Exception
classify(Throwable)
with that exception yields ERROR_NOT_FOUND
.task
- The existence check to perform, must not be null
.Exception
- If the existence of the specified resource could not be confirmed.void get(GetTask task) throws Exception
GetTask.getDataFile()
and the operation fails midway, the transporter should not delete the partial file
but leave its management to the caller.task
- The download to perform, must not be null
.Exception
- If the transfer failed.void put(PutTask task) throws Exception
task
- The upload to perform, must not be null
.Exception
- If the transfer failed.void close()
IllegalStateException
or similar.
Closing an already closed transporter is harmless and has no effect.close
in interface AutoCloseable
close
in interface Closeable
Copyright © 2010–2017 The Apache Software Foundation. All rights reserved.