org.kuali.maven.wagon
Class AbstractWagon

java.lang.Object
  extended by org.kuali.maven.wagon.AbstractWagon
All Implemented Interfaces:
org.apache.maven.wagon.Wagon
Direct Known Subclasses:
S3Wagon

public abstract class AbstractWagon
extends Object
implements org.apache.maven.wagon.Wagon

An abstract implementation of the Wagon interface. This implementation manages listener and other common behaviors.

Since:
1.1
Author:
Ben Hale, Jeff Caddel - Updates for version 2.0 of the Wagon interface

Field Summary
 
Fields inherited from interface org.apache.maven.wagon.Wagon
DEFAULT_CONNECTION_TIMEOUT, DEFAULT_READ_TIMEOUT, ROLE
 
Constructor Summary
protected AbstractWagon(boolean supportsDirectoryCopy)
           
 
Method Summary
 void addSessionListener(org.apache.maven.wagon.events.SessionListener listener)
           
 void addTransferListener(org.apache.maven.wagon.events.TransferListener listener)
           
 void connect(org.apache.maven.wagon.repository.Repository source)
           
 void connect(org.apache.maven.wagon.repository.Repository source, org.apache.maven.wagon.authentication.AuthenticationInfo authenticationInfo)
           
 void connect(org.apache.maven.wagon.repository.Repository source, org.apache.maven.wagon.authentication.AuthenticationInfo authenticationInfo, org.apache.maven.wagon.proxy.ProxyInfo proxyInfo)
           
 void connect(org.apache.maven.wagon.repository.Repository source, org.apache.maven.wagon.authentication.AuthenticationInfo authenticationInfo, org.apache.maven.wagon.proxy.ProxyInfoProvider proxyInfoProvider)
           
 void connect(org.apache.maven.wagon.repository.Repository source, org.apache.maven.wagon.proxy.ProxyInfo proxyInfo)
           
 void connect(org.apache.maven.wagon.repository.Repository source, org.apache.maven.wagon.proxy.ProxyInfoProvider proxyInfoProvider)
           
protected abstract  void connectToRepository(org.apache.maven.wagon.repository.Repository source, org.apache.maven.wagon.authentication.AuthenticationInfo authenticationInfo, org.apache.maven.wagon.proxy.ProxyInfo proxyInfo)
          Subclass must implement with specific connection behavior
 void disconnect()
           
protected abstract  void disconnectFromRepository()
          Subclasses must implement with specific disconnection behavior
protected  void doConnect(org.apache.maven.wagon.repository.Repository source, org.apache.maven.wagon.authentication.AuthenticationInfo authenticationInfo, org.apache.maven.wagon.proxy.ProxyInfo proxyInfo)
           
protected abstract  boolean doesRemoteResourceExist(String resourceName)
          Subclass must implement with specific detection behavior
protected  String encodeUTF8(String s)
           
 void get(String resourceName, File destination)
           
 List<String> getFileList(String destinationDirectory)
           
 boolean getIfNewer(String resourceName, File destination, long timestamp)
           
protected  PutFileContext getPutFileContext(File source, String destination)
           
protected  List<PutFileContext> getPutFileContexts(File sourceDirectory, String destinationDirectory)
           
 org.apache.maven.wagon.repository.Repository getRepository()
           
protected abstract  void getResource(String resourceName, File destination, org.kuali.maven.wagon.TransferProgress progress)
          Subclass must implement with specific get behavior
protected  org.kuali.maven.wagon.SessionListenerSupport getSessionListeners()
           
 int getTimeout()
           
protected  org.kuali.maven.wagon.TransferListenerSupport getTransferListeners()
           
protected  void handleException(Exception e, PutFileContext context)
           
 boolean hasSessionListener(org.apache.maven.wagon.events.SessionListener listener)
           
 boolean hasTransferListener(org.apache.maven.wagon.events.TransferListener listener)
           
 boolean isInteractive()
           
protected abstract  boolean isRemoteResourceNewer(String resourceName, long timestamp)
          Subclass must implement with newer detection behavior
protected abstract  List<String> listDirectory(String directory)
          Subclass must implement with specific directory listing behavior
 void openConnection()
           
 void put(File source, String destination)
           
protected abstract  void putResource(File source, String destination, org.kuali.maven.wagon.TransferProgress progress)
          Subclasses must implement with specific put behavior
 void removeSessionListener(org.apache.maven.wagon.events.SessionListener listener)
           
 void removeTransferListener(org.apache.maven.wagon.events.TransferListener listener)
           
 boolean resourceExists(String resourceName)
           
 void setInteractive(boolean interactive)
           
 void setTimeout(int timeoutValue)
           
 boolean supportsDirectoryCopy()
           
 
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
getReadTimeout, putDirectory, setReadTimeout
 

Constructor Detail

AbstractWagon

protected AbstractWagon(boolean supportsDirectoryCopy)
Method Detail

addSessionListener

public final void addSessionListener(org.apache.maven.wagon.events.SessionListener listener)
Specified by:
addSessionListener in interface org.apache.maven.wagon.Wagon

getSessionListeners

protected final org.kuali.maven.wagon.SessionListenerSupport getSessionListeners()

hasSessionListener

public final boolean hasSessionListener(org.apache.maven.wagon.events.SessionListener listener)
Specified by:
hasSessionListener in interface org.apache.maven.wagon.Wagon

removeSessionListener

public final void removeSessionListener(org.apache.maven.wagon.events.SessionListener listener)
Specified by:
removeSessionListener in interface org.apache.maven.wagon.Wagon

addTransferListener

public final void addTransferListener(org.apache.maven.wagon.events.TransferListener listener)
Specified by:
addTransferListener in interface org.apache.maven.wagon.Wagon

getTransferListeners

protected final org.kuali.maven.wagon.TransferListenerSupport getTransferListeners()

hasTransferListener

public final boolean hasTransferListener(org.apache.maven.wagon.events.TransferListener listener)
Specified by:
hasTransferListener in interface org.apache.maven.wagon.Wagon

removeTransferListener

public final void removeTransferListener(org.apache.maven.wagon.events.TransferListener listener)
Specified by:
removeTransferListener in interface org.apache.maven.wagon.Wagon

getRepository

public final org.apache.maven.wagon.repository.Repository getRepository()
Specified by:
getRepository in interface org.apache.maven.wagon.Wagon

isInteractive

public final boolean isInteractive()
Specified by:
isInteractive in interface org.apache.maven.wagon.Wagon

setInteractive

public final void setInteractive(boolean interactive)
Specified by:
setInteractive in interface org.apache.maven.wagon.Wagon

connect

public final void connect(org.apache.maven.wagon.repository.Repository source)
                   throws org.apache.maven.wagon.ConnectionException,
                          org.apache.maven.wagon.authentication.AuthenticationException
Specified by:
connect in interface org.apache.maven.wagon.Wagon
Throws:
org.apache.maven.wagon.ConnectionException
org.apache.maven.wagon.authentication.AuthenticationException

connect

public final void connect(org.apache.maven.wagon.repository.Repository source,
                          org.apache.maven.wagon.proxy.ProxyInfo proxyInfo)
                   throws org.apache.maven.wagon.ConnectionException,
                          org.apache.maven.wagon.authentication.AuthenticationException
Specified by:
connect in interface org.apache.maven.wagon.Wagon
Throws:
org.apache.maven.wagon.ConnectionException
org.apache.maven.wagon.authentication.AuthenticationException

connect

public final void connect(org.apache.maven.wagon.repository.Repository source,
                          org.apache.maven.wagon.authentication.AuthenticationInfo authenticationInfo)
                   throws org.apache.maven.wagon.ConnectionException,
                          org.apache.maven.wagon.authentication.AuthenticationException
Specified by:
connect in interface org.apache.maven.wagon.Wagon
Throws:
org.apache.maven.wagon.ConnectionException
org.apache.maven.wagon.authentication.AuthenticationException

doConnect

protected void doConnect(org.apache.maven.wagon.repository.Repository source,
                         org.apache.maven.wagon.authentication.AuthenticationInfo authenticationInfo,
                         org.apache.maven.wagon.proxy.ProxyInfo proxyInfo)
                  throws org.apache.maven.wagon.ConnectionException,
                         org.apache.maven.wagon.authentication.AuthenticationException
Throws:
org.apache.maven.wagon.ConnectionException
org.apache.maven.wagon.authentication.AuthenticationException

connect

public final void connect(org.apache.maven.wagon.repository.Repository source,
                          org.apache.maven.wagon.authentication.AuthenticationInfo authenticationInfo,
                          org.apache.maven.wagon.proxy.ProxyInfo proxyInfo)
                   throws org.apache.maven.wagon.ConnectionException,
                          org.apache.maven.wagon.authentication.AuthenticationException
Specified by:
connect in interface org.apache.maven.wagon.Wagon
Throws:
org.apache.maven.wagon.ConnectionException
org.apache.maven.wagon.authentication.AuthenticationException

disconnect

public final void disconnect()
                      throws org.apache.maven.wagon.ConnectionException
Specified by:
disconnect in interface org.apache.maven.wagon.Wagon
Throws:
org.apache.maven.wagon.ConnectionException

get

public final void get(String resourceName,
                      File destination)
               throws org.apache.maven.wagon.TransferFailedException,
                      org.apache.maven.wagon.ResourceDoesNotExistException,
                      org.apache.maven.wagon.authorization.AuthorizationException
Specified by:
get in interface org.apache.maven.wagon.Wagon
Throws:
org.apache.maven.wagon.TransferFailedException
org.apache.maven.wagon.ResourceDoesNotExistException
org.apache.maven.wagon.authorization.AuthorizationException

getFileList

public final List<String> getFileList(String destinationDirectory)
                               throws org.apache.maven.wagon.TransferFailedException,
                                      org.apache.maven.wagon.ResourceDoesNotExistException,
                                      org.apache.maven.wagon.authorization.AuthorizationException
Specified by:
getFileList in interface org.apache.maven.wagon.Wagon
Throws:
org.apache.maven.wagon.TransferFailedException
org.apache.maven.wagon.ResourceDoesNotExistException
org.apache.maven.wagon.authorization.AuthorizationException

getIfNewer

public final boolean getIfNewer(String resourceName,
                                File destination,
                                long timestamp)
                         throws org.apache.maven.wagon.TransferFailedException,
                                org.apache.maven.wagon.ResourceDoesNotExistException,
                                org.apache.maven.wagon.authorization.AuthorizationException
Specified by:
getIfNewer in interface org.apache.maven.wagon.Wagon
Throws:
org.apache.maven.wagon.TransferFailedException
org.apache.maven.wagon.ResourceDoesNotExistException
org.apache.maven.wagon.authorization.AuthorizationException

openConnection

public final void openConnection()
                          throws org.apache.maven.wagon.ConnectionException,
                                 org.apache.maven.wagon.authentication.AuthenticationException
Specified by:
openConnection in interface org.apache.maven.wagon.Wagon
Throws:
org.apache.maven.wagon.ConnectionException
org.apache.maven.wagon.authentication.AuthenticationException

getPutFileContext

protected PutFileContext getPutFileContext(File source,
                                           String destination)

put

public final void put(File source,
                      String destination)
               throws org.apache.maven.wagon.TransferFailedException,
                      org.apache.maven.wagon.ResourceDoesNotExistException,
                      org.apache.maven.wagon.authorization.AuthorizationException
Specified by:
put in interface org.apache.maven.wagon.Wagon
Throws:
org.apache.maven.wagon.TransferFailedException
org.apache.maven.wagon.ResourceDoesNotExistException
org.apache.maven.wagon.authorization.AuthorizationException

handleException

protected void handleException(Exception e,
                               PutFileContext context)
                        throws org.apache.maven.wagon.TransferFailedException,
                               org.apache.maven.wagon.ResourceDoesNotExistException,
                               org.apache.maven.wagon.authorization.AuthorizationException
Throws:
org.apache.maven.wagon.TransferFailedException
org.apache.maven.wagon.ResourceDoesNotExistException
org.apache.maven.wagon.authorization.AuthorizationException

getPutFileContexts

protected List<PutFileContext> getPutFileContexts(File sourceDirectory,
                                                  String destinationDirectory)

encodeUTF8

protected String encodeUTF8(String s)

resourceExists

public final boolean resourceExists(String resourceName)
                             throws org.apache.maven.wagon.TransferFailedException,
                                    org.apache.maven.wagon.authorization.AuthorizationException
Specified by:
resourceExists in interface org.apache.maven.wagon.Wagon
Throws:
org.apache.maven.wagon.TransferFailedException
org.apache.maven.wagon.authorization.AuthorizationException

supportsDirectoryCopy

public final boolean supportsDirectoryCopy()
Specified by:
supportsDirectoryCopy in interface org.apache.maven.wagon.Wagon

connectToRepository

protected abstract void connectToRepository(org.apache.maven.wagon.repository.Repository source,
                                            org.apache.maven.wagon.authentication.AuthenticationInfo authenticationInfo,
                                            org.apache.maven.wagon.proxy.ProxyInfo proxyInfo)
                                     throws Exception
Subclass must implement with specific connection behavior

Parameters:
source - The repository connection information
authenticationInfo - Authentication information, if any
proxyInfo - Proxy information, if any
Throws:
Exception - Implementations can throw any exception and it will be handled by the base class

doesRemoteResourceExist

protected abstract boolean doesRemoteResourceExist(String resourceName)
                                            throws Exception
Subclass must implement with specific detection behavior

Parameters:
resourceName - The remote resource to detect
Returns:
true if the remote resource exists
Throws:
Exception - Implementations can throw any exception and it will be handled by the base class

disconnectFromRepository

protected abstract void disconnectFromRepository()
                                          throws Exception
Subclasses must implement with specific disconnection behavior

Throws:
Exception - Implementations can throw any exception and it will be handled by the base class

getResource

protected abstract void getResource(String resourceName,
                                    File destination,
                                    org.kuali.maven.wagon.TransferProgress progress)
                             throws Exception
Subclass must implement with specific get behavior

Parameters:
resourceName - The name of the remote resource to read
destination - The local file to write to
progress - A progress notifier for the upload. It must be used or hashes will not be calculated correctly
Throws:
Exception - Implementations can throw any exception and it will be handled by the base class

isRemoteResourceNewer

protected abstract boolean isRemoteResourceNewer(String resourceName,
                                                 long timestamp)
                                          throws Exception
Subclass must implement with newer detection behavior

Parameters:
resourceName - The name of the resource being compared
timestamp - The timestamp to compare against
Returns:
true if the current version of the resource is newer than the timestamp
Throws:
Exception - Implementations can throw any exception and it will be handled by the base class

listDirectory

protected abstract List<String> listDirectory(String directory)
                                       throws Exception
Subclass must implement with specific directory listing behavior

Parameters:
directory - The directory to list files in
Returns:
A collection of file names
Throws:
Exception - Implementations can throw any exception and it will be handled by the base class

putResource

protected abstract void putResource(File source,
                                    String destination,
                                    org.kuali.maven.wagon.TransferProgress progress)
                             throws Exception
Subclasses must implement with specific put behavior

Parameters:
source - The local source file to read from
destination - The name of the remote resource to write to
progress - A progress notifier for the upload. It must be used or hashes will not be calculated correctly
Throws:
Exception - Implementations can throw any exception and it will be handled by the base class

connect

public void connect(org.apache.maven.wagon.repository.Repository source,
                    org.apache.maven.wagon.authentication.AuthenticationInfo authenticationInfo,
                    org.apache.maven.wagon.proxy.ProxyInfoProvider proxyInfoProvider)
             throws org.apache.maven.wagon.ConnectionException,
                    org.apache.maven.wagon.authentication.AuthenticationException
Specified by:
connect in interface org.apache.maven.wagon.Wagon
Throws:
org.apache.maven.wagon.ConnectionException
org.apache.maven.wagon.authentication.AuthenticationException

connect

public void connect(org.apache.maven.wagon.repository.Repository source,
                    org.apache.maven.wagon.proxy.ProxyInfoProvider proxyInfoProvider)
             throws org.apache.maven.wagon.ConnectionException,
                    org.apache.maven.wagon.authentication.AuthenticationException
Specified by:
connect in interface org.apache.maven.wagon.Wagon
Throws:
org.apache.maven.wagon.ConnectionException
org.apache.maven.wagon.authentication.AuthenticationException

getTimeout

public int getTimeout()
Specified by:
getTimeout in interface org.apache.maven.wagon.Wagon

setTimeout

public void setTimeout(int timeoutValue)
Specified by:
setTimeout in interface org.apache.maven.wagon.Wagon


Copyright © 2010-2012 The Kuali Foundation. All Rights Reserved.