Interface Transporter
-
- All Superinterfaces:
java.lang.AutoCloseable,java.io.Closeable
- All Known Implementing Classes:
AbstractTransporter,WagonTransporter
public interface Transporter extends java.io.CloseableA 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 theTransportListenerconfigured on the underlying task.If applicable, a transporter should obey connect/request timeouts and other relevant settings from the
configuration propertiesof 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 intERROR_NOT_FOUNDClassification for exceptions that denote a requested resource does not exist in the remote repository.static intERROR_OTHERClassification 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 intclassify(java.lang.Throwable error)Classifies the type of exception that has been thrown from a previous request to the transporter.voidclose()Closes this transporter and frees any network resources associated with it.voidget(GetTask task)Downloads a resource from the repository.voidpeek(PeekTask task)Checks the existence of a resource in the repository.voidput(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(java.lang.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_FOUNDorERROR_OTHER.
-
peek
void peek(PeekTask task) throws java.lang.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:
java.lang.Exception- If the existence of the specified resource could not be confirmed.
-
get
void get(GetTask task) throws java.lang.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:
java.lang.Exception- If the transfer failed.
-
put
void put(PutTask task) throws java.lang.Exception
Uploads a resource to the repository.- Parameters:
task- The upload to perform, must not benull.- Throws:
java.lang.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 aIllegalStateExceptionor similar. Closing an already closed transporter is harmless and has no effect.- Specified by:
closein interfacejava.lang.AutoCloseable- Specified by:
closein interfacejava.io.Closeable
-
-