org.springframework.aws.maven
Class SimpleStorageServiceWagon

java.lang.Object
  extended by org.springframework.aws.maven.SimpleStorageServiceWagon
All Implemented Interfaces:
org.apache.maven.wagon.Wagon

public final class SimpleStorageServiceWagon
extends Object

An implementation of the Maven Wagon interface that allows you to access the Amazon S3 service. URLs that reference the S3 service should be in the form of s3://bucket.name. As an example s3://static.springframework.org would put files into the static.springframework.org bucket on the S3 service.

This implementation uses the username and passphrase portions of the server authentication metadata for credentials.

Author:
Ben Hale

Field Summary
 
Fields inherited from interface org.apache.maven.wagon.Wagon
ROLE
 
Constructor Summary
SimpleStorageServiceWagon()
           
 
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  void connectToRepository(org.apache.maven.wagon.repository.Repository source, org.apache.maven.wagon.authentication.AuthenticationInfo authenticationInfo, org.apache.maven.wagon.proxy.ProxyInfoProvider proxyInfoProvider)
          Subclass must implement with specific connection behavior
 void disconnect()
           
protected  void disconnectFromRepository()
          Subclasses must implement with specific disconnection behavior
protected  boolean doesRemoteResourceExist(String resourceName)
          Subclass must implement with specific detection behavior
 void get(String resourceName, File destination)
           
 List<String> getFileList(String destinationDirectory)
           
 boolean getIfNewer(String resourceName, File destination, long timestamp)
           
 org.apache.maven.wagon.repository.Repository getRepository()
           
protected  void getResource(String resourceName, File destination, org.springframework.aws.maven.TransferProgress progress)
          Subclass must implement with specific get behavior
 int getTimeout()
           
 boolean hasSessionListener(org.apache.maven.wagon.events.SessionListener listener)
           
 boolean hasTransferListener(org.apache.maven.wagon.events.TransferListener listener)
           
 boolean isInteractive()
           
protected  boolean isRemoteResourceNewer(String resourceName, long timestamp)
          Subclass must implement with newer detection behavior
protected  List<String> listDirectory(String directory)
          Subclass must implement with specific directory listing behavior
 void openConnection()
           
 void put(File source, String destination)
           
 void putDirectory(File sourceDirectory, String destinationDirectory)
           
protected  void putResource(File source, String destination, org.springframework.aws.maven.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 timeout)
           
 boolean supportsDirectoryCopy()
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

SimpleStorageServiceWagon

public SimpleStorageServiceWagon()
Method Detail

connectToRepository

protected void connectToRepository(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.authentication.AuthenticationException
Subclass must implement with specific connection behavior

Parameters:
source - The repository connection information
authenticationInfo - Authentication information, if any
proxyInfoProvider - Proxy information, if any
Throws:
org.apache.maven.wagon.authentication.AuthenticationException

doesRemoteResourceExist

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

Parameters:
resourceName - The remote resource to detect
Returns:
true if the remote resource exists

disconnectFromRepository

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


getResource

protected void getResource(String resourceName,
                           File destination,
                           org.springframework.aws.maven.TransferProgress progress)
                    throws org.apache.maven.wagon.ResourceDoesNotExistException,
                           org.jets3t.service.S3ServiceException,
                           IOException
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:
org.apache.maven.wagon.ResourceDoesNotExistException
org.jets3t.service.S3ServiceException
IOException

isRemoteResourceNewer

protected boolean isRemoteResourceNewer(String resourceName,
                                        long timestamp)
                                 throws org.jets3t.service.ServiceException
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:
org.jets3t.service.ServiceException

listDirectory

protected 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 void putResource(File source,
                           String destination,
                           org.springframework.aws.maven.TransferProgress progress)
                    throws org.jets3t.service.S3ServiceException,
                           IOException
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:
org.jets3t.service.S3ServiceException
IOException

addSessionListener

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

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

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

connect

public final 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

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

connect

public final 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

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

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

putDirectory

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

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

getTimeout

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

setTimeout

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


Copyright © 2007-2011 Spring Framework. All Rights Reserved.