public abstract class AbstractWagon extends Object implements Wagon
Modifier and Type | Field and Description |
---|---|
protected AuthenticationInfo |
authenticationInfo |
protected static int |
BUFFER_SEGMENT_SIZE
To efficiently buffer data, use a multiple of 4 KiB as this is likely to match the hardware
buffer size of certain storage devices.
|
protected static int |
DEFAULT_BUFFER_SIZE |
protected boolean |
interactive |
protected static int |
MAXIMUM_BUFFER_SIZE |
protected static int |
MINIMUM_AMOUNT_OF_TRANSFER_CHUNKS
The desired minimum amount of chunks in which a
Resource shall be
transferred . |
protected ProxyInfo |
proxyInfo
Deprecated.
|
protected Repository |
repository |
protected SessionEventSupport |
sessionEventSupport |
protected TransferEventSupport |
transferEventSupport |
DEFAULT_CONNECTION_TIMEOUT, DEFAULT_READ_TIMEOUT, ROLE
Constructor and Description |
---|
AbstractWagon() |
Modifier and Type | Method and Description |
---|---|
void |
addSessionListener(SessionListener listener) |
void |
addTransferListener(TransferListener listener) |
protected void |
cleanupGetTransfer(Resource resource) |
protected void |
cleanupPutTransfer(Resource resource) |
protected abstract void |
closeConnection() |
void |
connect(Repository repository)
Initiate the connection to the repository.
|
void |
connect(Repository repository,
AuthenticationInfo authenticationInfo)
Initiate the connection to the repository.
|
void |
connect(Repository repository,
AuthenticationInfo authenticationInfo,
ProxyInfo proxyInfo)
Initiate the connection to the repository.
|
void |
connect(Repository repository,
AuthenticationInfo authenticationInfo,
ProxyInfoProvider proxyInfoProvider)
Initiate the connection to the repository.
|
void |
connect(Repository repository,
ProxyInfo proxyInfo)
Initiate the connection to the repository.
|
void |
connect(Repository repository,
ProxyInfoProvider proxyInfoProvider)
Initiate the connection to the repository.
|
protected void |
createParentDirectories(File destination) |
void |
disconnect()
Disconnect from the repository.
|
protected void |
finishGetTransfer(Resource resource,
InputStream input,
OutputStream output) |
protected void |
finishPutTransfer(Resource resource,
InputStream input,
OutputStream output) |
protected void |
fireGetCompleted(Resource resource,
File localFile) |
protected void |
fireGetInitiated(Resource resource,
File localFile) |
protected void |
fireGetStarted(Resource resource,
File localFile) |
protected void |
firePutCompleted(Resource resource,
File localFile) |
protected void |
firePutInitiated(Resource resource,
File localFile) |
protected void |
firePutStarted(Resource resource,
File localFile) |
protected void |
fireSessionConnectionRefused() |
protected void |
fireSessionDebug(String message) |
protected void |
fireSessionDisconnected() |
protected void |
fireSessionDisconnecting() |
protected void |
fireSessionError(Exception exception) |
protected void |
fireSessionLoggedIn() |
protected void |
fireSessionLoggedOff() |
protected void |
fireSessionOpened() |
protected void |
fireSessionOpening() |
protected void |
fireTransferDebug(String message) |
protected void |
fireTransferError(Resource resource,
Exception e,
int requestType) |
protected void |
fireTransferProgress(TransferEvent transferEvent,
byte[] buffer,
int n) |
AuthenticationInfo |
getAuthenticationInfo() |
protected int |
getBufferCapacityForTransfer(long numberOfBytes)
Provides a buffer size for efficiently transferring the given amount of bytes such that
it is not fragmented into too many chunks.
|
List<String> |
getFileList(String destinationDirectory)
Returns a
List of strings naming the files and directories in the directory denoted by
this abstract pathname. |
protected static String |
getPath(String basedir,
String dir) |
RepositoryPermissions |
getPermissionsOverride() |
ProxyInfo |
getProxyInfo() |
protected ProxyInfo |
getProxyInfo(String protocol,
String host) |
int |
getReadTimeout()
Get the read timeout limit in milliseconds
|
Repository |
getRepository() |
SessionEventSupport |
getSessionEventSupport() |
int |
getTimeout()
Get the connection timeout limit in milliseconds
|
protected void |
getTransfer(Resource resource,
File destination,
InputStream input) |
protected void |
getTransfer(Resource resource,
File destination,
InputStream input,
boolean closeInput,
int maxSize)
Deprecated.
|
protected void |
getTransfer(Resource resource,
File destination,
InputStream input,
boolean closeInput,
long maxSize) |
protected void |
getTransfer(Resource resource,
OutputStream output,
InputStream input) |
protected void |
getTransfer(Resource resource,
OutputStream output,
InputStream input,
boolean closeInput,
int maxSize)
Deprecated.
|
protected void |
getTransfer(Resource resource,
OutputStream output,
InputStream input,
boolean closeInput,
long maxSize) |
TransferEventSupport |
getTransferEventSupport() |
boolean |
hasSessionListener(SessionListener listener) |
boolean |
hasTransferListener(TransferListener listener) |
boolean |
isInteractive() |
void |
openConnection()
Initiate the connection to the repository.
|
protected abstract void |
openConnectionInternal() |
protected void |
postProcessListeners(Resource resource,
File source,
int requestType)
This method is used if you are not streaming the transfer, to make sure any listeners dependent on state
(eg checksum observers) succeed.
|
void |
putDirectory(File sourceDirectory,
String destinationDirectory)
Copy a directory from local system to remote
|
protected void |
putTransfer(Resource resource,
File source,
OutputStream output,
boolean closeOutput) |
protected void |
putTransfer(Resource resource,
InputStream input,
OutputStream output,
boolean closeOutput) |
void |
removeSessionListener(SessionListener listener) |
void |
removeTransferListener(TransferListener listener) |
boolean |
resourceExists(String resourceName)
Check if a remote resource exists
|
void |
setInteractive(boolean interactive) |
void |
setPermissionsOverride(RepositoryPermissions permissionsOverride) |
void |
setReadTimeout(int readTimeout)
Set the read timeout limit in milliseconds
|
void |
setSessionEventSupport(SessionEventSupport sessionEventSupport) |
void |
setTimeout(int timeoutValue)
Set the connection timeout limit in milliseconds
|
void |
setTransferEventSupport(TransferEventSupport transferEventSupport) |
boolean |
supportsDirectoryCopy()
Flag indicating if this wagon supports directory copy operations.
|
protected void |
transfer(Resource resource,
File source,
OutputStream output,
boolean closeOutput)
Write from
File to OutputStream |
protected void |
transfer(Resource resource,
InputStream input,
OutputStream output,
int requestType)
Write from
InputStream to OutputStream . |
protected void |
transfer(Resource resource,
InputStream input,
OutputStream output,
int requestType,
int maxSize)
Deprecated.
Please use the transfer using long as type of maxSize
|
protected void |
transfer(Resource resource,
InputStream input,
OutputStream output,
int requestType,
long maxSize)
Write from
InputStream to OutputStream . |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
get, getIfNewer, put
protected static final int DEFAULT_BUFFER_SIZE
protected static final int MAXIMUM_BUFFER_SIZE
protected static final int BUFFER_SEGMENT_SIZE
protected static final int MINIMUM_AMOUNT_OF_TRANSFER_CHUNKS
Resource
shall be
transferred
.
This corresponds to the minimum times fireTransferProgress(TransferEvent, byte[], int)
is executed. 100 notifications is a conservative value that will lead to small chunks for
any artifact less that BUFFER_SEGMENT_SIZE
* MINIMUM_AMOUNT_OF_TRANSFER_CHUNKS
in size.protected Repository repository
protected SessionEventSupport sessionEventSupport
protected TransferEventSupport transferEventSupport
protected AuthenticationInfo authenticationInfo
protected boolean interactive
public AbstractWagon()
public Repository getRepository()
getRepository
in interface Wagon
public ProxyInfo getProxyInfo()
public AuthenticationInfo getAuthenticationInfo()
public void openConnection() throws ConnectionException, AuthenticationException
Wagon
openConnection
in interface Wagon
ConnectionException
- if there is a problem connectingAuthenticationException
- if ther credentials for connecting are not sufficientpublic void connect(Repository repository) throws ConnectionException, AuthenticationException
Wagon
connect
in interface Wagon
repository
- the repository to connect toConnectionException
- if there is a problem connectingAuthenticationException
- if the credentials for connecting are not sufficientpublic void connect(Repository repository, ProxyInfo proxyInfo) throws ConnectionException, AuthenticationException
Wagon
connect
in interface Wagon
repository
- the repository to connect toConnectionException
- if there is a problem connectingAuthenticationException
- if the credentials for connecting are not sufficientpublic void connect(Repository repository, ProxyInfoProvider proxyInfoProvider) throws ConnectionException, AuthenticationException
Wagon
connect
in interface Wagon
repository
- the repository to connect toproxyInfoProvider
- the provider to obtain a network proxy to use to connect to the remote repositoryConnectionException
- if there is a problem connectingAuthenticationException
- if the credentials for connecting are not sufficientpublic void connect(Repository repository, AuthenticationInfo authenticationInfo) throws ConnectionException, AuthenticationException
Wagon
connect
in interface Wagon
repository
- the repository to connect toauthenticationInfo
- authentication credentials for connectingConnectionException
- if there is a problem connectingAuthenticationException
- if the credentials for connecting are not sufficientpublic void connect(Repository repository, AuthenticationInfo authenticationInfo, ProxyInfo proxyInfo) throws ConnectionException, AuthenticationException
Wagon
connect
in interface Wagon
repository
- the repository to connect toauthenticationInfo
- authentication credentials for connectingproxyInfo
- the network proxy to use to connect to the remote repositoryConnectionException
- if there is a problem connectingAuthenticationException
- if the credentials for connecting are not sufficientpublic void connect(Repository repository, AuthenticationInfo authenticationInfo, ProxyInfoProvider proxyInfoProvider) throws ConnectionException, AuthenticationException
Wagon
connect
in interface Wagon
repository
- the repository to connect toauthenticationInfo
- authentication credentials for connectingproxyInfoProvider
- the provider to obtain a network proxy to use to connect to the remote repositoryConnectionException
- if there is a problem connectingAuthenticationException
- if the credentials for connecting are not sufficientprotected abstract void openConnectionInternal() throws ConnectionException, AuthenticationException
public void disconnect() throws ConnectionException
Wagon
disconnect
in interface Wagon
ConnectionException
- if there is a problem disconnectingprotected abstract void closeConnection() throws ConnectionException
ConnectionException
protected void createParentDirectories(File destination) throws TransferFailedException
TransferFailedException
public void setTimeout(int timeoutValue)
Wagon
setTimeout
in interface Wagon
public int getTimeout()
Wagon
getTimeout
in interface Wagon
protected void getTransfer(Resource resource, File destination, InputStream input) throws TransferFailedException
TransferFailedException
protected void getTransfer(Resource resource, OutputStream output, InputStream input) throws TransferFailedException
TransferFailedException
@Deprecated protected void getTransfer(Resource resource, File destination, InputStream input, boolean closeInput, int maxSize) throws TransferFailedException
TransferFailedException
protected void getTransfer(Resource resource, File destination, InputStream input, boolean closeInput, long maxSize) throws TransferFailedException
TransferFailedException
@Deprecated protected void getTransfer(Resource resource, OutputStream output, InputStream input, boolean closeInput, int maxSize) throws TransferFailedException
TransferFailedException
protected void getTransfer(Resource resource, OutputStream output, InputStream input, boolean closeInput, long maxSize) throws TransferFailedException
TransferFailedException
protected void finishGetTransfer(Resource resource, InputStream input, OutputStream output) throws TransferFailedException
TransferFailedException
protected void cleanupGetTransfer(Resource resource)
protected void putTransfer(Resource resource, File source, OutputStream output, boolean closeOutput) throws TransferFailedException, AuthorizationException, ResourceDoesNotExistException
protected void transfer(Resource resource, File source, OutputStream output, boolean closeOutput) throws TransferFailedException, AuthorizationException, ResourceDoesNotExistException
File
to OutputStream
resource
- resource to transfersource
- file to read fromoutput
- output streamcloseOutput
- whether the output stream should be closed or notTransferFailedException
ResourceDoesNotExistException
AuthorizationException
protected void putTransfer(Resource resource, InputStream input, OutputStream output, boolean closeOutput) throws TransferFailedException, AuthorizationException, ResourceDoesNotExistException
protected void cleanupPutTransfer(Resource resource)
protected void finishPutTransfer(Resource resource, InputStream input, OutputStream output) throws TransferFailedException, AuthorizationException, ResourceDoesNotExistException
protected void transfer(Resource resource, InputStream input, OutputStream output, int requestType) throws IOException
InputStream
to OutputStream
.
Equivalent to transfer(Resource, InputStream, OutputStream, int, int)
with a maxSize equals to
Integer.MAX_VALUE
resource
- resource to transferinput
- input streamoutput
- output streamrequestType
- one of TransferEvent.REQUEST_GET
or TransferEvent.REQUEST_PUT
IOException
@Deprecated protected void transfer(Resource resource, InputStream input, OutputStream output, int requestType, int maxSize) throws IOException
InputStream
to OutputStream
.
Equivalent to transfer(Resource, InputStream, OutputStream, int, int)
with a maxSize equals to
Integer.MAX_VALUE
resource
- resource to transferinput
- input streamoutput
- output streamrequestType
- one of TransferEvent.REQUEST_GET
or TransferEvent.REQUEST_PUT
maxSize
- size of the bufferIOException
protected void transfer(Resource resource, InputStream input, OutputStream output, int requestType, long maxSize) throws IOException
InputStream
to OutputStream
.
Equivalent to transfer(Resource, InputStream, OutputStream, int, long)
with a maxSize equals to
Integer.MAX_VALUE
resource
- resource to transferinput
- input streamoutput
- output streamrequestType
- one of TransferEvent.REQUEST_GET
or TransferEvent.REQUEST_PUT
maxSize
- size of the bufferIOException
protected int getBufferCapacityForTransfer(long numberOfBytes)
listeners
are not notified too frequently.
For instance, transferring gigabyte-sized resources would result in millions of notifications when using
only a few kibibytes of buffer, drastically slowing down transfer since transfer progress listeners and
notifications are synchronous and may block, e.g., when writing download progress status to console.numberOfBytes
- can be 0 or less, in which case a default buffer size is used.protected void fireTransferProgress(TransferEvent transferEvent, byte[] buffer, int n)
protected void fireGetCompleted(Resource resource, File localFile)
protected void fireGetStarted(Resource resource, File localFile)
protected void fireGetInitiated(Resource resource, File localFile)
protected void firePutInitiated(Resource resource, File localFile)
protected void firePutCompleted(Resource resource, File localFile)
protected void firePutStarted(Resource resource, File localFile)
protected void fireSessionDisconnected()
protected void fireSessionDisconnecting()
protected void fireSessionLoggedIn()
protected void fireSessionLoggedOff()
protected void fireSessionOpened()
protected void fireSessionOpening()
protected void fireSessionConnectionRefused()
protected void fireSessionError(Exception exception)
protected void fireTransferDebug(String message)
protected void fireSessionDebug(String message)
public boolean hasTransferListener(TransferListener listener)
hasTransferListener
in interface Wagon
public void addTransferListener(TransferListener listener)
addTransferListener
in interface Wagon
public void removeTransferListener(TransferListener listener)
removeTransferListener
in interface Wagon
public void addSessionListener(SessionListener listener)
addSessionListener
in interface Wagon
public boolean hasSessionListener(SessionListener listener)
hasSessionListener
in interface Wagon
public void removeSessionListener(SessionListener listener)
removeSessionListener
in interface Wagon
protected void fireTransferError(Resource resource, Exception e, int requestType)
public SessionEventSupport getSessionEventSupport()
public void setSessionEventSupport(SessionEventSupport sessionEventSupport)
public TransferEventSupport getTransferEventSupport()
public void setTransferEventSupport(TransferEventSupport transferEventSupport)
protected void postProcessListeners(Resource resource, File source, int requestType) throws TransferFailedException
TransferFailedException
public void putDirectory(File sourceDirectory, String destinationDirectory) throws TransferFailedException, ResourceDoesNotExistException, AuthorizationException
Wagon
putDirectory
in interface Wagon
sourceDirectory
- the local directorydestinationDirectory
- the remote destinationTransferFailedException
ResourceDoesNotExistException
AuthorizationException
public boolean supportsDirectoryCopy()
Wagon
supportsDirectoryCopy
in interface Wagon
public boolean isInteractive()
isInteractive
in interface Wagon
public void setInteractive(boolean interactive)
setInteractive
in interface Wagon
public List<String> getFileList(String destinationDirectory) throws TransferFailedException, ResourceDoesNotExistException, AuthorizationException
Wagon
List
of strings naming the files and directories in the directory denoted by
this abstract pathname.
If this abstract pathname does not denote a directory, or does not exist, then this method throws
ResourceDoesNotExistException
.
Otherwise a List
of strings is returned, one for each file or directory in the directory.
Names denoting the directory itself and the directory's parent directory are not included in
the result. Each string is a file name rather than a complete path.
There is no guarantee that the name strings in the resulting list will appear in any specific
order; they are not, in particular, guaranteed to appear in alphabetical order.
getFileList
in interface Wagon
destinationDirectory
- directory to list contents ofList
of strings naming the files and directories in the directory denoted by
this abstract pathname. The List
will be empty if the directory is empty.TransferFailedException
- if there's an error trying to access the remote sideResourceDoesNotExistException
- if destinationDirectory does not exist or is not a directoryAuthorizationException
- if not authorized to list the contents of the directorypublic boolean resourceExists(String resourceName) throws TransferFailedException, AuthorizationException
Wagon
resourceExists
in interface Wagon
TransferFailedException
- if there's an error trying to access the remote sideAuthorizationException
- if not authorized to verify the existence of the resourceprotected ProxyInfo getProxyInfo(String protocol, String host)
public RepositoryPermissions getPermissionsOverride()
public void setPermissionsOverride(RepositoryPermissions permissionsOverride)
public void setReadTimeout(int readTimeout)
Wagon
setReadTimeout
in interface Wagon
public int getReadTimeout()
Wagon
getReadTimeout
in interface Wagon
Copyright © 2003–2022 The Apache Software Foundation. All rights reserved.