org.apache.maven.wagon
Class AbstractWagon

java.lang.Object
  extended by org.apache.maven.wagon.AbstractWagon
All Implemented Interfaces:
Wagon
Direct Known Subclasses:
ScmWagon, ScpExternalWagon, StreamWagon

public abstract class AbstractWagon
extends Object
implements Wagon

Implementation of common facilities for Wagon providers.

Version:
$Id: AbstractWagon.java 1174134 2011-09-22 13:47:58Z olamy $
Author:
Michal Maczka

Field Summary
protected  AuthenticationInfo authenticationInfo
           
protected static int DEFAULT_BUFFER_SIZE
           
protected  boolean interactive
           
protected  ProxyInfo proxyInfo
          Deprecated.  
protected  Repository repository
           
protected  SessionEventSupport sessionEventSupport
           
protected  TransferEventSupport transferEventSupport
           
 
Fields inherited from interface org.apache.maven.wagon.Wagon
ROLE
 
Constructor Summary
AbstractWagon()
           
 
Method Summary
 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()
           
 List 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)
           
 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)
           
protected  void getTransfer(Resource resource, OutputStream output, InputStream input)
           
protected  void getTransfer(Resource resource, OutputStream output, InputStream input, boolean closeInput, int 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 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)
          Write from InputStream to OutputStream.
 
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

repository

protected Repository repository

sessionEventSupport

protected SessionEventSupport sessionEventSupport

transferEventSupport

protected TransferEventSupport transferEventSupport

authenticationInfo

protected AuthenticationInfo authenticationInfo

interactive

protected boolean interactive

proxyInfo

protected ProxyInfo proxyInfo
Deprecated. 
Constructor Detail

AbstractWagon

public AbstractWagon()
Method Detail

getRepository

public Repository getRepository()
Specified by:
getRepository in interface Wagon

getProxyInfo

public ProxyInfo getProxyInfo()

getAuthenticationInfo

public AuthenticationInfo getAuthenticationInfo()

openConnection

public void openConnection()
                    throws ConnectionException,
                           AuthenticationException
Description copied from interface: Wagon
Initiate the connection to the repository.

Specified by:
openConnection in interface Wagon
Throws:
ConnectionException - if there is a problem connecting
AuthenticationException - if ther credentials for connecting are not sufficient

connect

public void connect(Repository repository)
             throws ConnectionException,
                    AuthenticationException
Description copied from interface: Wagon
Initiate the connection to the repository.

Specified by:
connect in interface Wagon
Parameters:
repository - the repository to connect to
Throws:
ConnectionException - if there is a problem connecting
AuthenticationException - 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 interface Wagon
Parameters:
repository - the repository to connect to
Throws:
ConnectionException - if there is a problem connecting
AuthenticationException - 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 interface Wagon
Parameters:
repository - the repository to connect to
proxyInfoProvider - the provider to obtain a network proxy to use to connect to the remote repository
Throws:
ConnectionException - if there is a problem connecting
AuthenticationException - 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 interface Wagon
Parameters:
repository - the repository to connect to
authenticationInfo - authentication credentials for connecting
Throws:
ConnectionException - if there is a problem connecting
AuthenticationException - 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 interface Wagon
Parameters:
repository - the repository to connect to
authenticationInfo - authentication credentials for connecting
proxyInfo - the network proxy to use to connect to the remote repository
Throws:
ConnectionException - if there is a problem connecting
AuthenticationException - 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 interface Wagon
Parameters:
repository - the repository to connect to
authenticationInfo - authentication credentials for connecting
proxyInfoProvider - the provider to obtain a network proxy to use to connect to the remote repository
Throws:
ConnectionException - if there is a problem connecting
AuthenticationException - if the credentials for connecting are not sufficient

openConnectionInternal

protected abstract void openConnectionInternal()
                                        throws ConnectionException,
                                               AuthenticationException
Throws:
ConnectionException
AuthenticationException

disconnect

public void disconnect()
                throws ConnectionException
Description copied from interface: Wagon
Disconnect from the repository.

Specified by:
disconnect in interface Wagon
Throws:
ConnectionException - if there is a problem disconnecting

closeConnection

protected abstract void closeConnection()
                                 throws ConnectionException
Throws:
ConnectionException

createParentDirectories

protected void createParentDirectories(File destination)
                                throws TransferFailedException
Throws:
TransferFailedException

setTimeout

public void setTimeout(int timeoutValue)
Description copied from interface: Wagon
Set the connection timeout limit in milliseconds

Specified by:
setTimeout in interface Wagon

getTimeout

public int getTimeout()
Description copied from interface: Wagon
Get the connection timeout limit in milliseconds

Specified by:
getTimeout in interface Wagon

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

protected void getTransfer(Resource resource,
                           File destination,
                           InputStream input,
                           boolean closeInput,
                           int maxSize)
                    throws TransferFailedException
Throws:
TransferFailedException

getTransfer

protected void getTransfer(Resource resource,
                           OutputStream output,
                           InputStream input,
                           boolean closeInput,
                           int maxSize)
                    throws TransferFailedException
Throws:
TransferFailedException

finishGetTransfer

protected void finishGetTransfer(Resource resource,
                                 InputStream input,
                                 OutputStream output)
                          throws TransferFailedException
Throws:
TransferFailedException

cleanupGetTransfer

protected void cleanupGetTransfer(Resource resource)

putTransfer

protected void putTransfer(Resource resource,
                           File source,
                           OutputStream output,
                           boolean closeOutput)
                    throws TransferFailedException,
                           AuthorizationException,
                           ResourceDoesNotExistException
Throws:
TransferFailedException
AuthorizationException
ResourceDoesNotExistException

transfer

protected void transfer(Resource resource,
                        File source,
                        OutputStream output,
                        boolean closeOutput)
                 throws TransferFailedException,
                        AuthorizationException,
                        ResourceDoesNotExistException
Write from File to OutputStream

Parameters:
resource - resource to transfer
source - file to read from
output - output stream
closeOutput - 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
Throws:
TransferFailedException
AuthorizationException
ResourceDoesNotExistException

cleanupPutTransfer

protected void cleanupPutTransfer(Resource resource)

finishPutTransfer

protected void finishPutTransfer(Resource resource,
                                 InputStream input,
                                 OutputStream output)
                          throws TransferFailedException,
                                 AuthorizationException,
                                 ResourceDoesNotExistException
Throws:
TransferFailedException
AuthorizationException
ResourceDoesNotExistException

transfer

protected void transfer(Resource resource,
                        InputStream input,
                        OutputStream output,
                        int requestType)
                 throws IOException
Write from InputStream to OutputStream. Equivalent to transfer(Resource, InputStream, OutputStream, int, int) with a maxSize equals to Integer.MAX_VALUE

Parameters:
resource - resource to transfer
input - input stream
output - output stream
requestType - one of TransferEvent.REQUEST_GET or TransferEvent.REQUEST_PUT
Throws:
IOException

transfer

protected void transfer(Resource resource,
                        InputStream input,
                        OutputStream output,
                        int requestType,
                        int maxSize)
                 throws IOException
Write from InputStream to OutputStream. Equivalent to transfer(Resource, InputStream, OutputStream, int, int) with a maxSize equals to Integer.MAX_VALUE

Parameters:
resource - resource to transfer
input - input stream
output - output stream
requestType - one of TransferEvent.REQUEST_GET or TransferEvent.REQUEST_PUT
maxSize - size of the buffer
Throws:
IOException

fireTransferProgress

protected void fireTransferProgress(TransferEvent transferEvent,
                                    byte[] buffer,
                                    int n)

fireGetCompleted

protected void fireGetCompleted(Resource resource,
                                File localFile)

fireGetStarted

protected void fireGetStarted(Resource resource,
                              File localFile)

fireGetInitiated

protected void fireGetInitiated(Resource resource,
                                File localFile)

firePutInitiated

protected void firePutInitiated(Resource resource,
                                File localFile)

firePutCompleted

protected void firePutCompleted(Resource resource,
                                File localFile)

firePutStarted

protected void firePutStarted(Resource resource,
                              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(Exception exception)

fireTransferDebug

protected void fireTransferDebug(String message)

fireSessionDebug

protected void fireSessionDebug(String message)

hasTransferListener

public boolean hasTransferListener(TransferListener listener)
Specified by:
hasTransferListener in interface Wagon

addTransferListener

public void addTransferListener(TransferListener listener)
Specified by:
addTransferListener in interface Wagon

removeTransferListener

public void removeTransferListener(TransferListener listener)
Specified by:
removeTransferListener in interface Wagon

addSessionListener

public void addSessionListener(SessionListener listener)
Specified by:
addSessionListener in interface Wagon

hasSessionListener

public boolean hasSessionListener(SessionListener listener)
Specified by:
hasSessionListener in interface Wagon

removeSessionListener

public void removeSessionListener(SessionListener listener)
Specified by:
removeSessionListener in interface Wagon

fireTransferError

protected void fireTransferError(Resource resource,
                                 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,
                                    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 interface Wagon
Parameters:
sourceDirectory - the local directory
destinationDirectory - 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 interface Wagon
Returns:
whether if this wagon supports directory operations

getPath

protected static String getPath(String basedir,
                                String dir)

isInteractive

public boolean isInteractive()
Specified by:
isInteractive in interface Wagon

setInteractive

public void setInteractive(boolean interactive)
Specified by:
setInteractive in interface Wagon

getFileList

public List getFileList(String destinationDirectory)
                 throws TransferFailedException,
                        ResourceDoesNotExistException,
                        AuthorizationException
Description copied from interface: Wagon

Returns a 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.

Specified by:
getFileList in interface Wagon
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. The List will be empty if the directory is empty.
Throws:
TransferFailedException - if there's an error trying to access the remote side
ResourceDoesNotExistException - if destinationDirectory does not exist or is not a directory
AuthorizationException - 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 interface Wagon
Returns:
whether the resource exists or not
Throws:
TransferFailedException - if there's an error trying to access the remote side
AuthorizationException - if not authorized to verify the existence of the resource

getProxyInfo

protected ProxyInfo getProxyInfo(String protocol,
                                 String host)

getPermissionsOverride

public RepositoryPermissions getPermissionsOverride()

setPermissionsOverride

public void setPermissionsOverride(RepositoryPermissions permissionsOverride)


Copyright © 2003-2011 The Apache Software Foundation. All Rights Reserved.