Package org.apache.maven.wagon
Class AbstractWagon
- java.lang.Object
-
- org.apache.maven.wagon.AbstractWagon
-
- All Implemented Interfaces:
Wagon
- Direct Known Subclasses:
StreamWagon
public abstract class AbstractWagon extends java.lang.Object implements Wagon
Implementation of common facilities for Wagon providers.
-
-
Field Summary
Fields Modifier and Type Field Description protected AuthenticationInfoauthenticationInfoprotected static intBUFFER_SEGMENT_SIZETo efficiently buffer data, use a multiple of 4 KiB as this is likely to match the hardware buffer size of certain storage devices.private intconnectionTimeoutprotected static intDEFAULT_BUFFER_SIZEprotected booleaninteractiveprotected static intMAXIMUM_BUFFER_SIZEprotected static intMINIMUM_AMOUNT_OF_TRANSFER_CHUNKSThe desired minimum amount of chunks in which aResourceshall betransferred.private RepositoryPermissionspermissionsOverrideprotected ProxyInfoproxyInfoDeprecated.private ProxyInfoProviderproxyInfoProviderprivate intreadTimeoutread timeout valueprotected Repositoryrepositoryprotected SessionEventSupportsessionEventSupportprotected TransferEventSupporttransferEventSupport-
Fields inherited from interface org.apache.maven.wagon.Wagon
DEFAULT_CONNECTION_TIMEOUT, DEFAULT_READ_TIMEOUT, ROLE
-
-
Constructor Summary
Constructors Constructor Description AbstractWagon()
-
Method Summary
All Methods Static Methods Instance Methods Abstract Methods Concrete Methods Deprecated Methods Modifier and Type Method Description voidaddSessionListener(SessionListener listener)voidaddTransferListener(TransferListener listener)protected voidcleanupGetTransfer(Resource resource)protected voidcleanupPutTransfer(Resource resource)protected abstract voidcloseConnection()voidconnect(Repository repository)Initiate the connection to the repository.voidconnect(Repository repository, AuthenticationInfo authenticationInfo)Initiate the connection to the repository.voidconnect(Repository repository, AuthenticationInfo authenticationInfo, ProxyInfo proxyInfo)Initiate the connection to the repository.voidconnect(Repository repository, AuthenticationInfo authenticationInfo, ProxyInfoProvider proxyInfoProvider)Initiate the connection to the repository.voidconnect(Repository repository, ProxyInfo proxyInfo)Initiate the connection to the repository.voidconnect(Repository repository, ProxyInfoProvider proxyInfoProvider)Initiate the connection to the repository.protected voidcreateParentDirectories(java.io.File destination)voiddisconnect()Disconnect from the repository.protected voidfinishGetTransfer(Resource resource, java.io.InputStream input, java.io.OutputStream output)protected voidfinishPutTransfer(Resource resource, java.io.InputStream input, java.io.OutputStream output)protected voidfireGetCompleted(Resource resource, java.io.File localFile)protected voidfireGetInitiated(Resource resource, java.io.File localFile)protected voidfireGetStarted(Resource resource, java.io.File localFile)protected voidfirePutCompleted(Resource resource, java.io.File localFile)protected voidfirePutInitiated(Resource resource, java.io.File localFile)protected voidfirePutStarted(Resource resource, java.io.File localFile)protected voidfireSessionConnectionRefused()protected voidfireSessionDebug(java.lang.String message)protected voidfireSessionDisconnected()protected voidfireSessionDisconnecting()protected voidfireSessionError(java.lang.Exception exception)protected voidfireSessionLoggedIn()protected voidfireSessionLoggedOff()protected voidfireSessionOpened()protected voidfireSessionOpening()protected voidfireTransferDebug(java.lang.String message)protected voidfireTransferError(Resource resource, java.lang.Exception e, int requestType)protected voidfireTransferProgress(TransferEvent transferEvent, byte[] buffer, int n)AuthenticationInfogetAuthenticationInfo()protected intgetBufferCapacityForTransfer(long numberOfBytes)Provides a buffer size for efficiently transferring the given amount of bytes such that it is not fragmented into too many chunks.java.util.List<java.lang.String>getFileList(java.lang.String destinationDirectory)Returns aListof strings naming the files and directories in the directory denoted by this abstract pathname.protected static java.lang.StringgetPath(java.lang.String basedir, java.lang.String dir)RepositoryPermissionsgetPermissionsOverride()ProxyInfogetProxyInfo()protected ProxyInfogetProxyInfo(java.lang.String protocol, java.lang.String host)intgetReadTimeout()Get the read timeout limit in millisecondsRepositorygetRepository()SessionEventSupportgetSessionEventSupport()intgetTimeout()Get the connection timeout limit in millisecondsprotected voidgetTransfer(Resource resource, java.io.File destination, java.io.InputStream input)protected voidgetTransfer(Resource resource, java.io.File destination, java.io.InputStream input, boolean closeInput, int maxSize)Deprecated.protected voidgetTransfer(Resource resource, java.io.File destination, java.io.InputStream input, boolean closeInput, long maxSize)protected voidgetTransfer(Resource resource, java.io.OutputStream output, java.io.InputStream input)protected voidgetTransfer(Resource resource, java.io.OutputStream output, java.io.InputStream input, boolean closeInput, int maxSize)Deprecated.protected voidgetTransfer(Resource resource, java.io.OutputStream output, java.io.InputStream input, boolean closeInput, long maxSize)TransferEventSupportgetTransferEventSupport()booleanhasSessionListener(SessionListener listener)booleanhasTransferListener(TransferListener listener)booleanisInteractive()voidopenConnection()Initiate the connection to the repository.protected abstract voidopenConnectionInternal()protected voidpostProcessListeners(Resource resource, java.io.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.voidputDirectory(java.io.File sourceDirectory, java.lang.String destinationDirectory)Copy a directory from local system to remoteprotected voidputTransfer(Resource resource, java.io.File source, java.io.OutputStream output, boolean closeOutput)protected voidputTransfer(Resource resource, java.io.InputStream input, java.io.OutputStream output, boolean closeOutput)voidremoveSessionListener(SessionListener listener)voidremoveTransferListener(TransferListener listener)booleanresourceExists(java.lang.String resourceName)Check if a remote resource existsvoidsetInteractive(boolean interactive)voidsetPermissionsOverride(RepositoryPermissions permissionsOverride)voidsetReadTimeout(int readTimeout)Set the read timeout limit in millisecondsvoidsetSessionEventSupport(SessionEventSupport sessionEventSupport)voidsetTimeout(int timeoutValue)Set the connection timeout limit in millisecondsvoidsetTransferEventSupport(TransferEventSupport transferEventSupport)booleansupportsDirectoryCopy()Flag indicating if this wagon supports directory copy operations.protected voidtransfer(Resource resource, java.io.File source, java.io.OutputStream output, boolean closeOutput)Write fromFiletoOutputStreamprotected voidtransfer(Resource resource, java.io.InputStream input, java.io.OutputStream output, int requestType)Write fromInputStreamtoOutputStream.protected voidtransfer(Resource resource, java.io.InputStream input, java.io.OutputStream output, int requestType, int maxSize)Deprecated.Please use the transfer using long as type of maxSizeprotected voidtransfer(Resource resource, java.io.InputStream input, java.io.OutputStream output, int requestType, long maxSize)Write fromInputStreamtoOutputStream.-
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
-
Methods inherited from interface org.apache.maven.wagon.Wagon
get, getIfNewer, put
-
-
-
-
Field Detail
-
DEFAULT_BUFFER_SIZE
protected static final int DEFAULT_BUFFER_SIZE
- See Also:
- Constant Field Values
-
MAXIMUM_BUFFER_SIZE
protected static final int MAXIMUM_BUFFER_SIZE
- See Also:
- Constant Field Values
-
BUFFER_SEGMENT_SIZE
protected static final 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.- See Also:
- Constant Field Values
-
MINIMUM_AMOUNT_OF_TRANSFER_CHUNKS
protected static final int MINIMUM_AMOUNT_OF_TRANSFER_CHUNKS
The desired minimum amount of chunks in which aResourceshall betransferred. This corresponds to the minimum timesfireTransferProgress(TransferEvent, byte[], int)is executed. 100 notifications is a conservative value that will lead to small chunks for any artifact less thatBUFFER_SEGMENT_SIZE*MINIMUM_AMOUNT_OF_TRANSFER_CHUNKSin size.- See Also:
- Constant Field Values
-
repository
protected Repository repository
-
sessionEventSupport
protected SessionEventSupport sessionEventSupport
-
transferEventSupport
protected TransferEventSupport transferEventSupport
-
authenticationInfo
protected AuthenticationInfo authenticationInfo
-
interactive
protected boolean interactive
-
connectionTimeout
private int connectionTimeout
-
readTimeout
private int readTimeout
read timeout value- Since:
- 2.2
-
proxyInfoProvider
private ProxyInfoProvider proxyInfoProvider
-
proxyInfo
protected ProxyInfo proxyInfo
Deprecated.
-
permissionsOverride
private RepositoryPermissions permissionsOverride
-
-
Method Detail
-
getRepository
public Repository getRepository()
- Specified by:
getRepositoryin interfaceWagon
-
getProxyInfo
public ProxyInfo getProxyInfo()
-
getAuthenticationInfo
public AuthenticationInfo getAuthenticationInfo()
-
openConnection
public void openConnection() throws ConnectionException, AuthenticationExceptionDescription copied from interface:WagonInitiate the connection to the repository.- Specified by:
openConnectionin interfaceWagon- Throws:
ConnectionException- if there is a problem connectingAuthenticationException- if ther credentials for connecting are not sufficient
-
connect
public void connect(Repository repository) throws ConnectionException, AuthenticationException
Description copied from interface:WagonInitiate the connection to the repository.- Specified by:
connectin interfaceWagon- Parameters:
repository- the repository to connect to- Throws:
ConnectionException- if there is a problem connectingAuthenticationException- if the credentials for connecting are not sufficient
-
connect
public void connect(Repository repository, ProxyInfo proxyInfo) throws ConnectionException, AuthenticationException
Description copied from interface:WagonInitiate the connection to the repository.- Specified by:
connectin interfaceWagon- Parameters:
repository- the repository to connect to- Throws:
ConnectionException- if there is a problem connectingAuthenticationException- if the credentials for connecting are not sufficient
-
connect
public void connect(Repository repository, ProxyInfoProvider proxyInfoProvider) throws ConnectionException, AuthenticationException
Description copied from interface:WagonInitiate the connection to the repository.- Specified by:
connectin interfaceWagon- Parameters:
repository- the repository to connect toproxyInfoProvider- the provider to obtain a network proxy to use to connect to the remote repository- Throws:
ConnectionException- if there is a problem connectingAuthenticationException- if the credentials for connecting are not sufficient
-
connect
public void connect(Repository repository, AuthenticationInfo authenticationInfo) throws ConnectionException, AuthenticationException
Description copied from interface:WagonInitiate the connection to the repository.- Specified by:
connectin interfaceWagon- Parameters:
repository- the repository to connect toauthenticationInfo- authentication credentials for connecting- Throws:
ConnectionException- if there is a problem connectingAuthenticationException- if the credentials for connecting are not sufficient
-
connect
public void connect(Repository repository, AuthenticationInfo authenticationInfo, ProxyInfo proxyInfo) throws ConnectionException, AuthenticationException
Description copied from interface:WagonInitiate the connection to the repository.- Specified by:
connectin interfaceWagon- Parameters:
repository- the repository to connect toauthenticationInfo- authentication credentials for connectingproxyInfo- the network proxy to use to connect to the remote repository- Throws:
ConnectionException- if there is a problem connectingAuthenticationException- if the credentials for connecting are not sufficient
-
connect
public void connect(Repository repository, AuthenticationInfo authenticationInfo, ProxyInfoProvider proxyInfoProvider) throws ConnectionException, AuthenticationException
Description copied from interface:WagonInitiate the connection to the repository.- Specified by:
connectin interfaceWagon- Parameters:
repository- the repository to connect toauthenticationInfo- authentication credentials for connectingproxyInfoProvider- the provider to obtain a network proxy to use to connect to the remote repository- Throws:
ConnectionException- if there is a problem connectingAuthenticationException- if the credentials for connecting are not sufficient
-
openConnectionInternal
protected abstract void openConnectionInternal() throws ConnectionException, AuthenticationException
-
disconnect
public void disconnect() throws ConnectionExceptionDescription copied from interface:WagonDisconnect from the repository.- Specified by:
disconnectin interfaceWagon- Throws:
ConnectionException- if there is a problem disconnecting
-
closeConnection
protected abstract void closeConnection() throws ConnectionException- Throws:
ConnectionException
-
createParentDirectories
protected void createParentDirectories(java.io.File destination) throws TransferFailedException- Throws:
TransferFailedException
-
setTimeout
public void setTimeout(int timeoutValue)
Description copied from interface:WagonSet the connection timeout limit in milliseconds- Specified by:
setTimeoutin interfaceWagon
-
getTimeout
public int getTimeout()
Description copied from interface:WagonGet the connection timeout limit in milliseconds- Specified by:
getTimeoutin interfaceWagon
-
getTransfer
protected void getTransfer(Resource resource, java.io.File destination, java.io.InputStream input) throws TransferFailedException
- Throws:
TransferFailedException
-
getTransfer
protected void getTransfer(Resource resource, java.io.OutputStream output, java.io.InputStream input) throws TransferFailedException
- Throws:
TransferFailedException
-
getTransfer
@Deprecated protected void getTransfer(Resource resource, java.io.File destination, java.io.InputStream input, boolean closeInput, int maxSize) throws TransferFailedException
Deprecated.- Throws:
TransferFailedException
-
getTransfer
protected void getTransfer(Resource resource, java.io.File destination, java.io.InputStream input, boolean closeInput, long maxSize) throws TransferFailedException
- Throws:
TransferFailedException
-
getTransfer
@Deprecated protected void getTransfer(Resource resource, java.io.OutputStream output, java.io.InputStream input, boolean closeInput, int maxSize) throws TransferFailedException
Deprecated.- Throws:
TransferFailedException
-
getTransfer
protected void getTransfer(Resource resource, java.io.OutputStream output, java.io.InputStream input, boolean closeInput, long maxSize) throws TransferFailedException
- Throws:
TransferFailedException
-
finishGetTransfer
protected void finishGetTransfer(Resource resource, java.io.InputStream input, java.io.OutputStream output) throws TransferFailedException
- Throws:
TransferFailedException
-
cleanupGetTransfer
protected void cleanupGetTransfer(Resource resource)
-
putTransfer
protected void putTransfer(Resource resource, java.io.File source, java.io.OutputStream output, boolean closeOutput) throws TransferFailedException, AuthorizationException, ResourceDoesNotExistException
-
transfer
protected void transfer(Resource resource, java.io.File source, java.io.OutputStream output, boolean closeOutput) throws TransferFailedException, AuthorizationException, ResourceDoesNotExistException
Write fromFiletoOutputStream- Parameters:
resource- resource to transfersource- file to read fromoutput- output streamcloseOutput- whether the output stream should be closed or not- Throws:
TransferFailedExceptionResourceDoesNotExistExceptionAuthorizationException- Since:
- 1.0-beta-1
-
putTransfer
protected void putTransfer(Resource resource, java.io.InputStream input, java.io.OutputStream output, boolean closeOutput) throws TransferFailedException, AuthorizationException, ResourceDoesNotExistException
-
cleanupPutTransfer
protected void cleanupPutTransfer(Resource resource)
-
finishPutTransfer
protected void finishPutTransfer(Resource resource, java.io.InputStream input, java.io.OutputStream output) throws TransferFailedException, AuthorizationException, ResourceDoesNotExistException
-
transfer
protected void transfer(Resource resource, java.io.InputStream input, java.io.OutputStream output, int requestType) throws java.io.IOException
Write fromInputStreamtoOutputStream. Equivalent totransfer(Resource, InputStream, OutputStream, int, int)with a maxSize equals toInteger.MAX_VALUE- Parameters:
resource- resource to transferinput- input streamoutput- output streamrequestType- one ofTransferEvent.REQUEST_GETorTransferEvent.REQUEST_PUT- Throws:
java.io.IOException
-
transfer
@Deprecated protected void transfer(Resource resource, java.io.InputStream input, java.io.OutputStream output, int requestType, int maxSize) throws java.io.IOException
Deprecated.Please use the transfer using long as type of maxSizeWrite fromInputStreamtoOutputStream. Equivalent totransfer(Resource, InputStream, OutputStream, int, int)with a maxSize equals toInteger.MAX_VALUE- Parameters:
resource- resource to transferinput- input streamoutput- output streamrequestType- one ofTransferEvent.REQUEST_GETorTransferEvent.REQUEST_PUTmaxSize- size of the buffer- Throws:
java.io.IOException
-
transfer
protected void transfer(Resource resource, java.io.InputStream input, java.io.OutputStream output, int requestType, long maxSize) throws java.io.IOException
Write fromInputStreamtoOutputStream. Equivalent totransfer(Resource, InputStream, OutputStream, int, long)with a maxSize equals toInteger.MAX_VALUE- Parameters:
resource- resource to transferinput- input streamoutput- output streamrequestType- one ofTransferEvent.REQUEST_GETorTransferEvent.REQUEST_PUTmaxSize- size of the buffer- Throws:
java.io.IOException
-
getBufferCapacityForTransfer
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. For larger files larger buffers are provided such that downstreamlistenersare 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.- Parameters:
numberOfBytes- can be 0 or less, in which case a default buffer size is used.- Returns:
- a byte buffer suitable for transferring the given amount of bytes without too many chunks.
-
fireTransferProgress
protected void fireTransferProgress(TransferEvent transferEvent, byte[] buffer, int n)
-
fireGetCompleted
protected void fireGetCompleted(Resource resource, java.io.File localFile)
-
fireGetStarted
protected void fireGetStarted(Resource resource, java.io.File localFile)
-
fireGetInitiated
protected void fireGetInitiated(Resource resource, java.io.File localFile)
-
firePutInitiated
protected void firePutInitiated(Resource resource, java.io.File localFile)
-
firePutCompleted
protected void firePutCompleted(Resource resource, java.io.File localFile)
-
firePutStarted
protected void firePutStarted(Resource resource, java.io.File localFile)
-
fireSessionDisconnected
protected void fireSessionDisconnected()
-
fireSessionDisconnecting
protected void fireSessionDisconnecting()
-
fireSessionLoggedIn
protected void fireSessionLoggedIn()
-
fireSessionLoggedOff
protected void fireSessionLoggedOff()
-
fireSessionOpened
protected void fireSessionOpened()
-
fireSessionOpening
protected void fireSessionOpening()
-
fireSessionConnectionRefused
protected void fireSessionConnectionRefused()
-
fireSessionError
protected void fireSessionError(java.lang.Exception exception)
-
fireTransferDebug
protected void fireTransferDebug(java.lang.String message)
-
fireSessionDebug
protected void fireSessionDebug(java.lang.String message)
-
hasTransferListener
public boolean hasTransferListener(TransferListener listener)
- Specified by:
hasTransferListenerin interfaceWagon
-
addTransferListener
public void addTransferListener(TransferListener listener)
- Specified by:
addTransferListenerin interfaceWagon
-
removeTransferListener
public void removeTransferListener(TransferListener listener)
- Specified by:
removeTransferListenerin interfaceWagon
-
addSessionListener
public void addSessionListener(SessionListener listener)
- Specified by:
addSessionListenerin interfaceWagon
-
hasSessionListener
public boolean hasSessionListener(SessionListener listener)
- Specified by:
hasSessionListenerin interfaceWagon
-
removeSessionListener
public void removeSessionListener(SessionListener listener)
- Specified by:
removeSessionListenerin interfaceWagon
-
fireTransferError
protected void fireTransferError(Resource resource, java.lang.Exception e, int requestType)
-
getSessionEventSupport
public SessionEventSupport getSessionEventSupport()
-
setSessionEventSupport
public void setSessionEventSupport(SessionEventSupport sessionEventSupport)
-
getTransferEventSupport
public TransferEventSupport getTransferEventSupport()
-
setTransferEventSupport
public void setTransferEventSupport(TransferEventSupport transferEventSupport)
-
postProcessListeners
protected void postProcessListeners(Resource resource, java.io.File source, int requestType) throws TransferFailedException
This method is used if you are not streaming the transfer, to make sure any listeners dependent on state (eg checksum observers) succeed.- Throws:
TransferFailedException
-
putDirectory
public void putDirectory(java.io.File sourceDirectory, java.lang.String destinationDirectory) throws TransferFailedException, ResourceDoesNotExistException, AuthorizationExceptionDescription copied from interface:WagonCopy a directory from local system to remote- Specified by:
putDirectoryin interfaceWagon- Parameters:
sourceDirectory- the local directorydestinationDirectory- the remote destination- Throws:
TransferFailedExceptionResourceDoesNotExistExceptionAuthorizationException
-
supportsDirectoryCopy
public boolean supportsDirectoryCopy()
Description copied from interface:WagonFlag indicating if this wagon supports directory copy operations.- Specified by:
supportsDirectoryCopyin interfaceWagon- Returns:
- whether if this wagon supports directory operations
-
getPath
protected static java.lang.String getPath(java.lang.String basedir, java.lang.String dir)
-
isInteractive
public boolean isInteractive()
- Specified by:
isInteractivein interfaceWagon
-
setInteractive
public void setInteractive(boolean interactive)
- Specified by:
setInteractivein interfaceWagon
-
getFileList
public java.util.List<java.lang.String> getFileList(java.lang.String destinationDirectory) throws TransferFailedException, ResourceDoesNotExistException, AuthorizationExceptionDescription copied from interface:WagonReturns aListof 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 throwsResourceDoesNotExistException. Otherwise aListof 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.- Specified by:
getFileListin interfaceWagon- Parameters:
destinationDirectory- directory to list contents of- Returns:
- A
Listof strings naming the files and directories in the directory denoted by this abstract pathname. TheListwill be empty if the directory is empty. - Throws:
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 directory
-
resourceExists
public boolean resourceExists(java.lang.String resourceName) throws TransferFailedException, AuthorizationExceptionDescription copied from interface:WagonCheck if a remote resource exists- Specified by:
resourceExistsin interfaceWagon- Returns:
- whether the resource exists or not
- Throws:
TransferFailedException- if there's an error trying to access the remote sideAuthorizationException- if not authorized to verify the existence of the resource
-
getProxyInfo
protected ProxyInfo getProxyInfo(java.lang.String protocol, java.lang.String host)
-
getPermissionsOverride
public RepositoryPermissions getPermissionsOverride()
-
setPermissionsOverride
public void setPermissionsOverride(RepositoryPermissions permissionsOverride)
-
setReadTimeout
public void setReadTimeout(int readTimeout)
Description copied from interface:WagonSet the read timeout limit in milliseconds- Specified by:
setReadTimeoutin interfaceWagon
-
getReadTimeout
public int getReadTimeout()
Description copied from interface:WagonGet the read timeout limit in milliseconds- Specified by:
getReadTimeoutin interfaceWagon
-
-