Package org.apache.maven.wagon
Class AbstractWagon
java.lang.Object
org.apache.maven.wagon.AbstractWagon
- All Implemented Interfaces:
Wagon
- Direct Known Subclasses:
StreamWagon
Implementation of common facilities for Wagon providers.
- Author:
- Michal Maczka
-
Field Summary
FieldsModifier and TypeFieldDescriptionprotected AuthenticationInfo
protected static final int
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 final int
protected boolean
protected static final int
protected static final int
The desired minimum amount of chunks in which aResource
shall betransferred
.protected ProxyInfo
Deprecated.protected Repository
protected SessionEventSupport
protected TransferEventSupport
Fields inherited from interface org.apache.maven.wagon.Wagon
DEFAULT_CONNECTION_TIMEOUT, DEFAULT_READ_TIMEOUT, ROLE
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoid
addSessionListener
(SessionListener listener) void
addTransferListener
(TransferListener listener) protected void
cleanupGetTransfer
(Resource resource) protected void
cleanupPutTransfer
(Resource resource) protected abstract void
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 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
protected void
fireSessionDebug
(String message) protected void
protected void
protected void
fireSessionError
(Exception exception) protected void
protected void
protected void
protected void
protected void
fireTransferDebug
(String message) protected void
fireTransferError
(Resource resource, Exception e, int requestType) protected void
fireTransferProgress
(TransferEvent transferEvent, byte[] buffer, int n) 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.getFileList
(String destinationDirectory) Returns aList
of strings naming the files and directories in the directory denoted by this abstract pathname.protected static String
protected ProxyInfo
getProxyInfo
(String protocol, String host) int
Get the read timeout limit in millisecondsint
Get the connection timeout limit in millisecondsprotected 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) boolean
hasSessionListener
(SessionListener listener) boolean
hasTransferListener
(TransferListener listener) boolean
void
Initiate the connection to the repository.protected abstract void
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 remoteprotected 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 existsvoid
setInteractive
(boolean interactive) void
setPermissionsOverride
(RepositoryPermissions permissionsOverride) void
setReadTimeout
(int readTimeout) Set the read timeout limit in millisecondsvoid
setSessionEventSupport
(SessionEventSupport sessionEventSupport) void
setTimeout
(int timeoutValue) Set the connection timeout limit in millisecondsvoid
setTransferEventSupport
(TransferEventSupport transferEventSupport) boolean
Flag indicating if this wagon supports directory copy operations.protected void
transfer
(Resource resource, File source, OutputStream output, boolean closeOutput) Write fromFile
toOutputStream
protected void
transfer
(Resource resource, InputStream input, OutputStream output, int requestType) Write fromInputStream
toOutputStream
.protected void
transfer
(Resource resource, InputStream input, OutputStream output, int requestType, int maxSize) Deprecated.Please use the transfer using long as type of maxSizeprotected void
transfer
(Resource resource, InputStream input, OutputStream output, int requestType, long maxSize) Write fromInputStream
toOutputStream
.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 Details
-
DEFAULT_BUFFER_SIZE
protected static final int DEFAULT_BUFFER_SIZE- See Also:
-
MAXIMUM_BUFFER_SIZE
protected static final int MAXIMUM_BUFFER_SIZE- See Also:
-
BUFFER_SEGMENT_SIZE
protected static final int BUFFER_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.- See Also:
-
MINIMUM_AMOUNT_OF_TRANSFER_CHUNKS
protected static final int MINIMUM_AMOUNT_OF_TRANSFER_CHUNKSThe desired minimum amount of chunks in which aResource
shall 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_CHUNKS
in size.- See Also:
-
repository
-
sessionEventSupport
-
transferEventSupport
-
authenticationInfo
-
interactive
protected boolean interactive -
proxyInfo
Deprecated.
-
-
Constructor Details
-
AbstractWagon
public AbstractWagon()
-
-
Method Details
-
getRepository
- Specified by:
getRepository
in interfaceWagon
-
getProxyInfo
-
getAuthenticationInfo
-
openConnection
Description copied from interface:Wagon
Initiate the connection to the repository.- Specified by:
openConnection
in interfaceWagon
- Throws:
ConnectionException
- if there is a problem connectingAuthenticationException
- if ther credentials for connecting are not sufficient
-
connect
Description copied from interface:Wagon
Initiate the connection to the repository.- Specified by:
connect
in 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:Wagon
Initiate the connection to the repository.- Specified by:
connect
in 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:Wagon
Initiate the connection to the repository.- Specified by:
connect
in 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:Wagon
Initiate the connection to the repository.- Specified by:
connect
in 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:Wagon
Initiate the connection to the repository.- Specified by:
connect
in 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:Wagon
Initiate the connection to the repository.- Specified by:
connect
in 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
Description copied from interface:Wagon
Disconnect from the repository.- Specified by:
disconnect
in interfaceWagon
- Throws:
ConnectionException
- if there is a problem disconnecting
-
closeConnection
- Throws:
ConnectionException
-
createParentDirectories
- Throws:
TransferFailedException
-
setTimeout
public void setTimeout(int timeoutValue) Description copied from interface:Wagon
Set the connection timeout limit in milliseconds- Specified by:
setTimeout
in interfaceWagon
-
getTimeout
public int getTimeout()Description copied from interface:Wagon
Get the connection timeout limit in milliseconds- Specified by:
getTimeout
in interfaceWagon
-
getTransfer
protected void getTransfer(Resource resource, File destination, InputStream input) throws TransferFailedException - Throws:
TransferFailedException
-
getTransfer
protected void getTransfer(Resource resource, OutputStream output, InputStream input) throws TransferFailedException - Throws:
TransferFailedException
-
getTransfer
@Deprecated protected void getTransfer(Resource resource, File destination, InputStream input, boolean closeInput, int maxSize) throws TransferFailedException Deprecated.- Throws:
TransferFailedException
-
getTransfer
protected void getTransfer(Resource resource, File destination, InputStream input, boolean closeInput, long maxSize) throws TransferFailedException - Throws:
TransferFailedException
-
getTransfer
@Deprecated protected void getTransfer(Resource resource, OutputStream output, InputStream input, boolean closeInput, int maxSize) throws TransferFailedException Deprecated.- Throws:
TransferFailedException
-
getTransfer
protected void getTransfer(Resource resource, OutputStream output, InputStream input, boolean closeInput, long maxSize) throws TransferFailedException - Throws:
TransferFailedException
-
finishGetTransfer
protected void finishGetTransfer(Resource resource, InputStream input, OutputStream output) throws TransferFailedException - Throws:
TransferFailedException
-
cleanupGetTransfer
-
putTransfer
protected void putTransfer(Resource resource, File source, OutputStream output, boolean closeOutput) throws TransferFailedException, AuthorizationException, ResourceDoesNotExistException -
transfer
protected void transfer(Resource resource, File source, OutputStream output, boolean closeOutput) throws TransferFailedException, AuthorizationException, ResourceDoesNotExistException Write fromFile
toOutputStream
- Parameters:
resource
- resource to transfersource
- file to read fromoutput
- output streamcloseOutput
- whether the output stream should be closed or not- Throws:
TransferFailedException
ResourceDoesNotExistException
AuthorizationException
- Since:
- 1.0-beta-1
-
putTransfer
protected void putTransfer(Resource resource, InputStream input, OutputStream output, boolean closeOutput) throws TransferFailedException, AuthorizationException, ResourceDoesNotExistException -
cleanupPutTransfer
-
finishPutTransfer
protected void finishPutTransfer(Resource resource, InputStream input, OutputStream output) throws TransferFailedException, AuthorizationException, ResourceDoesNotExistException -
transfer
protected void transfer(Resource resource, InputStream input, OutputStream output, int requestType) throws IOException Write fromInputStream
toOutputStream
. 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_GET
orTransferEvent.REQUEST_PUT
- Throws:
IOException
-
transfer
@Deprecated protected void transfer(Resource resource, InputStream input, OutputStream output, int requestType, int maxSize) throws IOException Deprecated.Please use the transfer using long as type of maxSizeWrite fromInputStream
toOutputStream
. 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_GET
orTransferEvent.REQUEST_PUT
maxSize
- size of the buffer- Throws:
IOException
-
transfer
protected void transfer(Resource resource, InputStream input, OutputStream output, int requestType, long maxSize) throws IOException Write fromInputStream
toOutputStream
. 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_GET
orTransferEvent.REQUEST_PUT
maxSize
- size of the buffer- Throws:
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 downstreamlisteners
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.- 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
-
fireGetCompleted
-
fireGetStarted
-
fireGetInitiated
-
firePutInitiated
-
firePutCompleted
-
firePutStarted
-
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
-
fireTransferDebug
-
fireSessionDebug
-
hasTransferListener
- Specified by:
hasTransferListener
in interfaceWagon
-
addTransferListener
- Specified by:
addTransferListener
in interfaceWagon
-
removeTransferListener
- Specified by:
removeTransferListener
in interfaceWagon
-
addSessionListener
- Specified by:
addSessionListener
in interfaceWagon
-
hasSessionListener
- Specified by:
hasSessionListener
in interfaceWagon
-
removeSessionListener
- Specified by:
removeSessionListener
in interfaceWagon
-
fireTransferError
-
getSessionEventSupport
-
setSessionEventSupport
-
getTransferEventSupport
-
setTransferEventSupport
-
postProcessListeners
protected void postProcessListeners(Resource resource, 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(File sourceDirectory, String destinationDirectory) throws TransferFailedException, ResourceDoesNotExistException, AuthorizationException Description copied from interface:Wagon
Copy a directory from local system to remote- Specified by:
putDirectory
in interfaceWagon
- Parameters:
sourceDirectory
- the local directorydestinationDirectory
- the remote destination- Throws:
TransferFailedException
ResourceDoesNotExistException
AuthorizationException
-
supportsDirectoryCopy
public boolean supportsDirectoryCopy()Description copied from interface:Wagon
Flag indicating if this wagon supports directory copy operations.- Specified by:
supportsDirectoryCopy
in interfaceWagon
- Returns:
- whether if this wagon supports directory operations
-
getPath
-
isInteractive
public boolean isInteractive()- Specified by:
isInteractive
in interfaceWagon
-
setInteractive
public void setInteractive(boolean interactive) - Specified by:
setInteractive
in interfaceWagon
-
getFileList
public List<String> getFileList(String destinationDirectory) throws TransferFailedException, ResourceDoesNotExistException, AuthorizationException Description copied from interface:Wagon
Returns aList
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 throwsResourceDoesNotExistException
. Otherwise aList
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.- Specified by:
getFileList
in interfaceWagon
- Parameters:
destinationDirectory
- directory to list contents of- Returns:
- A
List
of strings naming the files and directories in the directory denoted by this abstract pathname. TheList
will 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(String resourceName) throws TransferFailedException, AuthorizationException Description copied from interface:Wagon
Check if a remote resource exists- Specified by:
resourceExists
in 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
-
getPermissionsOverride
-
setPermissionsOverride
-
setReadTimeout
public void setReadTimeout(int readTimeout) Description copied from interface:Wagon
Set the read timeout limit in milliseconds- Specified by:
setReadTimeout
in interfaceWagon
-
getReadTimeout
public int getReadTimeout()Description copied from interface:Wagon
Get the read timeout limit in milliseconds- Specified by:
getReadTimeout
in interfaceWagon
-