|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectorg.apache.maven.plugin.AbstractMojo
org.kuali.maven.mojo.s3.BaseMojo
org.kuali.maven.mojo.s3.S3Mojo
org.kuali.maven.mojo.s3.UpdateOriginBucketMojo
public class UpdateOriginBucketMojo
This mojo updates a bucket serving as an origin for a Cloud Front distribution. It generates an html directory listing for each "directory" in the bucket and stores the html under a key in the bucket such that a regular http request for a directory returns html. What would happen otherwise is XML for "object does not exist" would be returned by Amazon.
For example: The url "http://www.mybucket.com/foo/bar" will return an html page containing a listing of all the files and directories under "foo/bar" in the bucket.
If a directory contains an object with a key that is the same as the default object, the plugin copies the object to a key representing the directory structure.
For example, the url "http://www.mybucket.com/foo/bar/index.html" represents an object in an S3 bucket under the key "foo/bar/index.html". This plugin will copy the object from the key "foo/bar/index.html" to the key "foo/bar/". This causes the url "http://www.mybucket.com/foo/bar/" to return the same content as the url "http://www.mybucket.com/foo/bar/index.html"
It also generates an html directory listing at the root of the bucket hierarchy and places that html into the bucket as the default object, unless a default object already exists.
Field Summary |
---|
Fields inherited from class org.kuali.maven.mojo.s3.BaseMojo |
---|
FS, SKIP_PACKAGING_TYPE |
Fields inherited from interface org.apache.maven.plugin.Mojo |
---|
ROLE |
Constructor Summary | |
---|---|
UpdateOriginBucketMojo()
|
Method Summary | |
---|---|
void |
executeMojo()
This method is called after logging has been configured and only if mojo execution should not be skipped. |
protected String |
getAbout()
Show some text about this plugin |
com.amazonaws.services.s3.model.CannedAccessControlList |
getAcl()
|
String |
getBrowseKey()
|
String |
getCacheControl()
|
protected com.amazonaws.services.s3.model.CopyObjectRequest |
getCopyObjectRequest(String bucket,
String sourceKey,
String destKey)
Create a CopyObjectRequest with an ACL set to PublicRead |
String |
getCss()
|
String |
getDateFormat()
|
String |
getDefaultObjectKey()
|
protected String |
getDefaultPrefix(org.apache.maven.project.MavenProject project,
String orgGroupId)
Get a default prefix into the bucket from the project + groupId |
String |
getDirectoryImage()
|
String |
getFileImage()
|
protected SimpleDateFormat |
getLastModifiedDateFormatter()
Return a SimpleDateFormat object initialized with the date format and timezone supplied to the mojo |
protected String |
getListMsg(int subDirectoryCount,
long millis)
Show some information about the current directory |
protected List<ListObjectsContext> |
getListObjectsContexts(S3BucketContext bucketContext,
List<String> prefixes)
Convert prefixes intl ListObjectContext objects |
protected com.amazonaws.services.s3.model.ListObjectsRequest |
getListObjectsRequest(S3BucketContext context,
String prefix)
Given a prefix and a bucket context return a ListObjectsRequest object |
protected com.amazonaws.services.s3.model.ObjectListing |
getObjectListing(S3BucketContext context,
com.amazonaws.services.s3.model.ListObjectsRequest request)
Get an object listing for the current directory |
protected List<com.amazonaws.services.s3.model.ObjectListing> |
getObjectListings(S3BucketContext context,
List<String> prefixes,
int maxThreads)
Make a multi-threaded call to S3 to acquire ObjectListing objects for each of the prefixes |
String |
getOrganizationGroupId()
|
List<String> |
getOrgPomGavs()
|
protected List<String> |
getPathsToRoot(String delimiter,
String startingPrefix)
Split the string up and return a list of Strings representing the path from the starting prefix back to (and including) the root of the bucket. |
protected List<String> |
getPrefixes(com.amazonaws.services.s3.model.ObjectListing listing,
String prefix,
String delimiter)
Return a listing of all the prefixes in this directory plus all the prefixes leading back to (and including) the root directory |
protected com.amazonaws.services.s3.model.PutObjectRequest |
getPutIndexObjectRequest(String html,
String key)
Create a PutObjectRequest for some html generated by this mojo. |
protected S3BucketContext |
getS3BucketContext()
Get context information about the bucket we are operating on |
protected S3PrefixContext |
getS3PrefixContext(S3BucketContext context,
com.amazonaws.services.s3.model.ObjectListing objectListing)
Convert an ObjectListing into an S3PrefixContext |
protected List<S3PrefixContext> |
getS3PrefixContexts(S3BucketContext context,
List<com.amazonaws.services.s3.model.ObjectListing> listings)
Convert ObjectListing objects into S3PrefixContext objects |
int |
getThreads()
|
String |
getTimezone()
|
protected List<UpdateDirectoryContext> |
getUpdateDirContexts(List<S3PrefixContext> contexts)
Convert S3PrefixContext objects into UpdateDirectoryContext objects. |
boolean |
isCopyDefaultObjectWithDelimiter()
|
boolean |
isCopyDefaultObjectWithoutDelimiter()
|
protected boolean |
isCreateOrUpdateDefaultObject(S3PrefixContext context)
Return true if there is no object in the ObjectListing under defaultObjectKey. Return true if the object in the ObjectListing was created by this plugin. Return false otherwise. |
protected boolean |
isEmpty(Collection<?> c)
Return true if the Collection is null or contains no entries, false otherwise |
protected boolean |
isExistingObject(com.amazonaws.services.s3.model.ObjectListing objectListing,
String key)
Return true if the ObjectListing contains an object under "key" |
protected boolean |
isOurObject(com.amazonaws.services.s3.model.S3Object s3Object)
Return true if this S3Object was created by this plugin. |
void |
setAcl(com.amazonaws.services.s3.model.CannedAccessControlList acl)
|
void |
setBrowseKey(String browseHtml)
|
void |
setCacheControl(String cacheControl)
|
void |
setCopyDefaultObjectWithDelimiter(boolean copyDefaultObjectWithDelimiter)
|
void |
setCopyDefaultObjectWithoutDelimiter(boolean copyDefaultObjectWithoutDelimiter)
|
void |
setCss(String css)
|
void |
setDateFormat(String dateFormat)
|
void |
setDefaultObjectKey(String defaultCloudFrontObject)
|
void |
setDirectoryImage(String directoryImage)
|
void |
setFileImage(String fileImage)
|
void |
setOrganizationGroupId(String organizationGroupId)
|
void |
setOrgPomGavs(List<String> orgPomGavs)
|
void |
setThreads(int threadCount)
|
void |
setTimezone(String timezone)
|
protected void |
updateDirectory(S3PrefixContext context)
Update this S3 "directory". |
protected void |
updateDirectory(S3PrefixContext context,
boolean isCopyIfExists,
String copyToKey)
Create an object in the bucket under a key that lets a normal http request function correctly with CloudFront / S3. Either use the client's object or upload some html created by this plugin |
void |
updateDirectory(UpdateDirectoryContext context)
|
protected void |
updateMojoState()
Update the state of this mojo from the project metadata |
protected void |
updatePrefix()
If they supplied a prefix use it. |
protected void |
updateRoot(S3PrefixContext context)
If this is the root of the bucket and the default object either does not exist or was created by this plugin, overwrite the default object with newly generated html. |
void |
updateRoot(UpdateDirectoryContext udc)
If this is the root of the bucket and the default object either does not exist or was created by this plugin, overwrite the default object with newly generated html. |
Methods inherited from class org.kuali.maven.mojo.s3.S3Mojo |
---|
getAccessKeyId, getAuthenticationErrorMessage, getBucket, getCredentials, getDelimiter, getMaxKeys, getObjectMetadata, getPrefix, getPutObjectRequest, getPutObjectRequest, getSecretAccessKey, getServerId, setAccessKeyId, setBucket, setDelimiter, setMaxKeys, setPrefix, setSecretAccessKey, setServerId, updateCredentials, validateCredentials |
Methods inherited from class org.kuali.maven.mojo.s3.BaseMojo |
---|
execute, getEncoding, getMavenSession, getProject, getSettings, isForceMojoExecution, isSkip, setEncoding, setForceMojoExecution, setMavenSession, setProject, setSettings, setSkip, skipMojo |
Methods inherited from class org.apache.maven.plugin.AbstractMojo |
---|
getLog, getPluginContext, setLog, setPluginContext |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Constructor Detail |
---|
public UpdateOriginBucketMojo()
Method Detail |
---|
protected List<String> getPrefixes(com.amazonaws.services.s3.model.ObjectListing listing, String prefix, String delimiter)
listing
- prefix
- delimiter
-
protected com.amazonaws.services.s3.model.ObjectListing getObjectListing(S3BucketContext context, com.amazonaws.services.s3.model.ListObjectsRequest request)
context
- request
-
protected List<ListObjectsContext> getListObjectsContexts(S3BucketContext bucketContext, List<String> prefixes)
bucketContext
- prefixes
-
protected com.amazonaws.services.s3.model.ListObjectsRequest getListObjectsRequest(S3BucketContext context, String prefix)
context
- prefix
-
protected String getListMsg(int subDirectoryCount, long millis)
subDirectoryCount
- millis
-
public void executeMojo() throws org.apache.maven.plugin.MojoExecutionException, org.apache.maven.plugin.MojoFailureException
BaseMojo
executeMojo
in class BaseMojo
org.apache.maven.plugin.MojoExecutionException
org.apache.maven.plugin.MojoFailureException
protected List<com.amazonaws.services.s3.model.ObjectListing> getObjectListings(S3BucketContext context, List<String> prefixes, int maxThreads)
context
- prefixes
- maxThreads
-
protected List<UpdateDirectoryContext> getUpdateDirContexts(List<S3PrefixContext> contexts)
contexts
-
protected List<String> getPathsToRoot(String delimiter, String startingPrefix)
delimiter
- startingPrefix
-
protected String getDefaultPrefix(org.apache.maven.project.MavenProject project, String orgGroupId)
project
- groupId
-
protected void updatePrefix()
protected void updateMojoState() throws org.apache.maven.plugin.MojoExecutionException
org.apache.maven.plugin.MojoExecutionException
protected S3BucketContext getS3BucketContext() throws org.apache.maven.plugin.MojoExecutionException
org.apache.maven.plugin.MojoExecutionException
protected com.amazonaws.services.s3.model.PutObjectRequest getPutIndexObjectRequest(String html, String key)
protected SimpleDateFormat getLastModifiedDateFormatter()
protected boolean isEmpty(Collection<?> c)
protected String getAbout()
public void updateDirectory(UpdateDirectoryContext context) throws IOException
IOException
protected void updateDirectory(S3PrefixContext context, boolean isCopyIfExists, String copyToKey) throws IOException
IOException
protected void updateDirectory(S3PrefixContext context) throws IOException
IOException
public void updateRoot(UpdateDirectoryContext udc) throws IOException
IOException
protected void updateRoot(S3PrefixContext context) throws IOException
IOException
protected List<S3PrefixContext> getS3PrefixContexts(S3BucketContext context, List<com.amazonaws.services.s3.model.ObjectListing> listings)
protected S3PrefixContext getS3PrefixContext(S3BucketContext context, com.amazonaws.services.s3.model.ObjectListing objectListing)
protected boolean isExistingObject(com.amazonaws.services.s3.model.ObjectListing objectListing, String key)
protected boolean isCreateOrUpdateDefaultObject(S3PrefixContext context)
protected boolean isOurObject(com.amazonaws.services.s3.model.S3Object s3Object)
protected com.amazonaws.services.s3.model.CopyObjectRequest getCopyObjectRequest(String bucket, String sourceKey, String destKey)
public String getTimezone()
public void setTimezone(String timezone)
public String getDateFormat()
public void setDateFormat(String dateFormat)
public String getDefaultObjectKey()
public void setDefaultObjectKey(String defaultCloudFrontObject)
public String getFileImage()
public void setFileImage(String fileImage)
public String getDirectoryImage()
public void setDirectoryImage(String directoryImage)
public String getCss()
public void setCss(String css)
public boolean isCopyDefaultObjectWithDelimiter()
public void setCopyDefaultObjectWithDelimiter(boolean copyDefaultObjectWithDelimiter)
public boolean isCopyDefaultObjectWithoutDelimiter()
public void setCopyDefaultObjectWithoutDelimiter(boolean copyDefaultObjectWithoutDelimiter)
public String getCacheControl()
public void setCacheControl(String cacheControl)
public String getBrowseKey()
public void setBrowseKey(String browseHtml)
public String getOrganizationGroupId()
public void setOrganizationGroupId(String organizationGroupId)
organizationGroupId
- the organizationGroupId to setpublic int getThreads()
public void setThreads(int threadCount)
public com.amazonaws.services.s3.model.CannedAccessControlList getAcl()
public void setAcl(com.amazonaws.services.s3.model.CannedAccessControlList acl)
public List<String> getOrgPomGavs()
public void setOrgPomGavs(List<String> orgPomGavs)
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |