public class S3Wagon extends AbstractWagon implements RequestFactory
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.
| Modifier and Type | Field and Description |
|---|---|
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. |
| Constructor and Description |
|---|
S3Wagon() |
| Modifier and Type | Method and Description |
|---|---|
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 |
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.cssConvert /foo/bar/../../css/style.css into /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 system properties, environment variables, settings.xml, or EC2 instance metadata (only applicable when running the wagon on
an Amazon EC2 instance)
|
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
|
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, supportsDirectoryCopypublic 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
protected void validateBucket(com.amazonaws.services.s3.AmazonS3Client client,
String bucketName)
protected void validatePermissions(com.amazonaws.services.s3.AmazonS3Client client,
String bucketName)
client - S3 ClientbucketName - AWS S3 Bucket Name.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)
AbstractWagonconnectToRepository in class AbstractWagonsource - The repository connection informationauth - Authentication information, if anyproxy - Proxy information, if anyprotected boolean doesRemoteResourceExist(String resourceName)
AbstractWagondoesRemoteResourceExist in class AbstractWagonresourceName - The remote resource to detectprotected void disconnectFromRepository()
AbstractWagondisconnectFromRepository in class AbstractWagonprotected void getResource(String resourceName, File destination, org.kuali.maven.wagon.TransferProgress progress) throws org.apache.maven.wagon.ResourceDoesNotExistException, IOException
getResource in class AbstractWagonresourceName - 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 correctlyorg.apache.maven.wagon.ResourceDoesNotExistExceptionIOExceptionprotected boolean isRemoteResourceNewer(String resourceName, long timestamp)
isRemoteResourceNewer in class AbstractWagonresourceName - The name of the resource being comparedtimestamp - The timestamp to compare againstprotected List<String> listDirectory(String directory) throws Exception
listDirectory in class AbstractWagondirectory - The directory to list files inException - 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.csskey - S3 Key string.key.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 RequestFactoryprotected InputStream getInputStream(File source, org.kuali.maven.wagon.TransferProgress progress) throws IOException
IOExceptionprotected com.amazonaws.services.s3.model.PutObjectRequest getPutObjectRequest(File source, String destination, org.kuali.maven.wagon.TransferProgress progress)
source - Local file to upload.destination - Destination S3 key.progress - Transfer listener.PutObjectRequest instance.public final void putDirectory(File sourceDir, String destinationDir) throws org.apache.maven.wagon.TransferFailedException
putDirectory in interface org.apache.maven.wagon.Wagonorg.apache.maven.wagon.TransferFailedExceptionprotected 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 AbstractWagonsource - 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 correctlyIOExceptionprotected String getBaseDir(org.apache.maven.wagon.repository.Repository source)
source - Repository info.protected com.amazonaws.auth.AWSCredentials getCredentials(org.apache.maven.wagon.authentication.AuthenticationInfo authenticationInfo)
authenticationInfo - Authentication credentials from Maven settings.protected PutFileContext getPutFileContext(File source, String destination)
getPutFileContext in class AbstractWagonprotected int getMinThreads()
protected int getMaxThreads()
protected int getDivisor()
protected int getValue(String key, int defaultValue)
public int getReadTimeout()
getReadTimeout in interface org.apache.maven.wagon.Wagonpublic void setReadTimeout(int readTimeout)
setReadTimeout in interface org.apache.maven.wagon.WagonCopyright © 2010–2021. All rights reserved.