|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object org.kuali.maven.wagon.AbstractWagon org.kuali.maven.wagon.S3Wagon
public class S3Wagon
An implementation of the Maven Wagon interface that is integrated with the Amazon S3 service.
URLs that reference the S3 service should be in the form of s3://bucket.name
. As an example s3://maven.kuali.org
puts files into the
maven.kuali.org
bucket on the S3 service.
This implementation uses the username
and password
portions of the server authentication metadata for credentials.
Field Summary | |
---|---|
static com.amazonaws.services.s3.model.CannedAccessControlList |
DEFAULT_ACL
|
static int |
DEFAULT_DIVISOR
|
static int |
DEFAULT_MAX_THREAD_COUNT
|
static int |
DEFAULT_MIN_THREAD_COUNT
|
static int |
DEFAULT_READ_TIMEOUT
|
static String |
DIVISOR_KEY
|
static String |
HTTP
|
static String |
HTTP_ENDPOINT_VALUE
|
static String |
HTTPS
|
static String |
MAX_THREADS_KEY
|
static String |
MIN_THREADS_KEY
|
static String |
PROTOCOL_KEY
Set the system property maven.wagon.protocol to http to force the wagon to communicate over http . |
Fields inherited from interface org.apache.maven.wagon.Wagon |
---|
DEFAULT_CONNECTION_TIMEOUT, ROLE |
Constructor Summary | |
---|---|
S3Wagon()
|
Method Summary | |
---|---|
protected void |
connectToRepository(org.apache.maven.wagon.repository.Repository source,
org.apache.maven.wagon.authentication.AuthenticationInfo auth,
org.apache.maven.wagon.proxy.ProxyInfo proxy)
Subclass must implement with specific connection behavior |
protected void |
disconnectFromRepository()
Subclasses must implement with specific disconnection behavior |
protected boolean |
doesRemoteResourceExist(String resourceName)
Subclass must implement with specific detection behavior |
protected com.amazonaws.services.s3.model.CannedAccessControlList |
getAclFromRepository(org.apache.maven.wagon.repository.Repository repository)
|
protected com.amazonaws.services.s3.AmazonS3Client |
getAmazonS3Client(com.amazonaws.auth.AWSCredentials credentials)
|
protected String |
getAuthenticationErrorMessage()
|
protected String |
getBaseDir(org.apache.maven.wagon.repository.Repository source)
Convert "/" -> "" Convert "/snapshot/" -> "snapshot/" Convert "/snapshot" -> "snapshot/" |
protected static File |
getCanonicalFile(File file)
|
protected static File |
getCanonicalFile(String path)
|
protected String |
getCanonicalKey(String key)
Normalize the key to our S3 object: Convert ./css/style.css into /css/style.css Convert /foo/bar/../../css/style.css |
protected com.amazonaws.ClientConfiguration |
getClientConfiguration()
|
protected com.amazonaws.auth.AWSCredentials |
getCredentials(org.apache.maven.wagon.authentication.AuthenticationInfo authenticationInfo)
Create AWSCredentionals from the information in settings.xml |
protected String |
getDestinationPath(String destination)
|
protected int |
getDivisor()
|
protected InputStream |
getInputStream(File source,
org.kuali.maven.wagon.TransferProgress progress)
|
protected int |
getMaxThreads()
|
protected int |
getMinThreads()
|
protected com.amazonaws.services.s3.model.ObjectMetadata |
getObjectMetadata(File source,
String destination)
|
protected PutFileContext |
getPutFileContext(File source,
String destination)
|
protected com.amazonaws.services.s3.model.PutObjectRequest |
getPutObjectRequest(File source,
String destination,
org.kuali.maven.wagon.TransferProgress progress)
Create a PutObjectRequest based on the source file and destination passed in |
com.amazonaws.services.s3.model.PutObjectRequest |
getPutObjectRequest(PutFileContext context)
Create a PutObjectRequest based on the PutContext |
int |
getReadTimeout()
|
protected int |
getRequestsPerThread(int threads,
int requests)
|
protected void |
getResource(String resourceName,
File destination,
org.kuali.maven.wagon.TransferProgress progress)
Pull an object out of an S3 bucket and write it to a file |
protected String |
getUploadCompleteMsg(long millis,
long bytes,
long count)
|
protected String |
getUploadStartMsg(int fileCount,
long bytes)
|
protected int |
getValue(String key,
int defaultValue)
|
protected String |
getValue(String key,
String defaultValue)
|
protected void |
info(String msg)
|
protected boolean |
isRemoteResourceNewer(String resourceName,
long timestamp)
Is the S3 object newer than the timestamp passed in? |
protected List<String> |
listDirectory(String directory)
List all of the objects in a given directory |
void |
putDirectory(File sourceDir,
String destinationDir)
On S3 there are no true "directories". |
protected void |
putResource(File source,
String destination,
org.kuali.maven.wagon.TransferProgress progress)
Store a resource into S3 |
void |
setReadTimeout(int readTimeout)
|
protected long |
sum(List<PutFileContext> contexts)
|
protected void |
validateBucket(com.amazonaws.services.s3.AmazonS3Client client,
String bucketName)
|
protected void |
validatePermissions(com.amazonaws.services.s3.AmazonS3Client client,
String bucketName)
Establish that we have enough permissions on this bucket to do what we need to do |
Methods inherited from class org.kuali.maven.wagon.AbstractWagon |
---|
addSessionListener, addTransferListener, connect, connect, connect, connect, connect, connect, disconnect, doConnect, get, getFileList, getIfNewer, getPutFileContexts, getRepository, getSessionListeners, getTimeout, getTransferListeners, handleException, hasSessionListener, hasTransferListener, isInteractive, openConnection, put, removeSessionListener, removeTransferListener, resourceExists, setInteractive, setTimeout, supportsDirectoryCopy |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
---|
public static final String PROTOCOL_KEY
maven.wagon.protocol
to http
to force the wagon to communicate over http
. Default is https
.
public static final String HTTP
public static final String HTTP_ENDPOINT_VALUE
public static final String HTTPS
public static final String MIN_THREADS_KEY
public static final String MAX_THREADS_KEY
public static final String DIVISOR_KEY
public static final int DEFAULT_MIN_THREAD_COUNT
public static final int DEFAULT_MAX_THREAD_COUNT
public static final int DEFAULT_DIVISOR
public static final int DEFAULT_READ_TIMEOUT
public static final com.amazonaws.services.s3.model.CannedAccessControlList DEFAULT_ACL
Constructor Detail |
---|
public S3Wagon()
Method Detail |
---|
protected void validateBucket(com.amazonaws.services.s3.AmazonS3Client client, String bucketName)
protected void validatePermissions(com.amazonaws.services.s3.AmazonS3Client client, String bucketName)
protected com.amazonaws.services.s3.model.CannedAccessControlList getAclFromRepository(org.apache.maven.wagon.repository.Repository repository)
protected com.amazonaws.ClientConfiguration getClientConfiguration()
protected com.amazonaws.services.s3.AmazonS3Client getAmazonS3Client(com.amazonaws.auth.AWSCredentials credentials)
protected void connectToRepository(org.apache.maven.wagon.repository.Repository source, org.apache.maven.wagon.authentication.AuthenticationInfo auth, org.apache.maven.wagon.proxy.ProxyInfo proxy) throws org.apache.maven.wagon.authentication.AuthenticationException
AbstractWagon
connectToRepository
in class AbstractWagon
source
- The repository connection informationauth
- Authentication information, if anyproxy
- Proxy information, if any
org.apache.maven.wagon.authentication.AuthenticationException
protected boolean doesRemoteResourceExist(String resourceName)
AbstractWagon
doesRemoteResourceExist
in class AbstractWagon
resourceName
- The remote resource to detect
protected void disconnectFromRepository()
AbstractWagon
disconnectFromRepository
in class AbstractWagon
protected void getResource(String resourceName, File destination, org.kuali.maven.wagon.TransferProgress progress) throws org.apache.maven.wagon.ResourceDoesNotExistException, IOException
getResource
in class AbstractWagon
resourceName
- The name of the remote resource to readdestination
- The local file to write toprogress
- A progress notifier for the upload. It must be used or hashes will not be calculated correctly
org.apache.maven.wagon.ResourceDoesNotExistException
IOException
protected boolean isRemoteResourceNewer(String resourceName, long timestamp)
isRemoteResourceNewer
in class AbstractWagon
resourceName
- The name of the resource being comparedtimestamp
- The timestamp to compare against
protected List<String> listDirectory(String directory) throws Exception
listDirectory
in class AbstractWagon
directory
- The directory to list files in
Exception
- Implementations can throw any exception and it will be handled by the base classprotected void info(String msg)
protected String getCanonicalKey(String key)
./css/style.css
into /css/style.css
/foo/bar/../../css/style.css into /css/style.css
protected static File getCanonicalFile(String path)
protected static File getCanonicalFile(File file)
protected com.amazonaws.services.s3.model.ObjectMetadata getObjectMetadata(File source, String destination)
public com.amazonaws.services.s3.model.PutObjectRequest getPutObjectRequest(PutFileContext context)
getPutObjectRequest
in interface RequestFactory
protected InputStream getInputStream(File source, org.kuali.maven.wagon.TransferProgress progress) throws FileNotFoundException
FileNotFoundException
protected com.amazonaws.services.s3.model.PutObjectRequest getPutObjectRequest(File source, String destination, org.kuali.maven.wagon.TransferProgress progress)
public final void putDirectory(File sourceDir, String destinationDir) throws org.apache.maven.wagon.TransferFailedException
putDirectory
in interface org.apache.maven.wagon.Wagon
org.apache.maven.wagon.TransferFailedException
protected String getUploadCompleteMsg(long millis, long bytes, long count)
protected String getUploadStartMsg(int fileCount, long bytes)
protected int getRequestsPerThread(int threads, int requests)
protected long sum(List<PutFileContext> contexts)
protected void putResource(File source, String destination, org.kuali.maven.wagon.TransferProgress progress) throws IOException
putResource
in class AbstractWagon
source
- The local source file to read fromdestination
- The name of the remote resource to write toprogress
- A progress notifier for the upload. It must be used or hashes will not be calculated correctly
IOException
protected String getDestinationPath(String destination)
protected String getBaseDir(org.apache.maven.wagon.repository.Repository source)
protected String getAuthenticationErrorMessage()
protected com.amazonaws.auth.AWSCredentials getCredentials(org.apache.maven.wagon.authentication.AuthenticationInfo authenticationInfo) throws org.apache.maven.wagon.authentication.AuthenticationException
org.apache.maven.wagon.authentication.AuthenticationException
protected PutFileContext getPutFileContext(File source, String destination)
getPutFileContext
in class AbstractWagon
protected int getMinThreads()
protected int getMaxThreads()
protected int getDivisor()
protected int getValue(String key, int defaultValue)
protected String getValue(String key, String defaultValue)
public int getReadTimeout()
getReadTimeout
in interface org.apache.maven.wagon.Wagon
public void setReadTimeout(int readTimeout)
setReadTimeout
in interface org.apache.maven.wagon.Wagon
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |