SF.net SVN: moduleforge:[2294] controltier/branches/controltier-3-6-support /aws

0 views
Skip to first unread message

mose...@users.sourceforge.net

unread,
Jul 13, 2011, 2:42:00 PM7/13/11
to controltier...@googlegroups.com
Revision: 2294
http://moduleforge.svn.sourceforge.net/moduleforge/?rev=2294&view=rev
Author: moseslei
Date: 2011-07-13 18:42:00 +0000 (Wed, 13 Jul 2011)

Log Message:
-----------
Update S3Get task to take s3://bucket/key urls in addition to file/bucket parameters; change AwsS3Util#get to use url

Modified Paths:
--------------
controltier/branches/controltier-3-6-support/aws/src/awstasks/build.xml
controltier/branches/controltier-3-6-support/aws/src/awstasks/java/dak/ant/taskdefs/S3Get.java
controltier/branches/controltier-3-6-support/aws/src/awstasks/test.xml

Added Paths:
-----------
controltier/branches/controltier-3-6-support/aws/jars/awstasks-3.6.1.jar

Removed Paths:
-------------
controltier/branches/controltier-3-6-support/aws/jars/awstasks-3-6-support.jar

Deleted: controltier/branches/controltier-3-6-support/aws/jars/awstasks-3-6-support.jar
===================================================================
(Binary files differ)

Added: controltier/branches/controltier-3-6-support/aws/jars/awstasks-3.6.1.jar
===================================================================
(Binary files differ)


Property changes on: controltier/branches/controltier-3-6-support/aws/jars/awstasks-3.6.1.jar
___________________________________________________________________
Added: svn:mime-type
+ application/octet-stream

Modified: controltier/branches/controltier-3-6-support/aws/src/awstasks/build.xml
===================================================================
--- controltier/branches/controltier-3-6-support/aws/src/awstasks/build.xml 2011-07-13 18:41:39 UTC (rev 2293)
+++ controltier/branches/controltier-3-6-support/aws/src/awstasks/build.xml 2011-07-13 18:42:00 UTC (rev 2294)
@@ -10,6 +10,7 @@

<path id="classpath.compile" >
<fileset dir="${awstasks.lib}"/>
+ <pathelement location="${ant.library.dir}/ant.jar" />
<pathelement location="${awstasks.classes}" />
</path>

Modified: controltier/branches/controltier-3-6-support/aws/src/awstasks/java/dak/ant/taskdefs/S3Get.java
===================================================================
--- controltier/branches/controltier-3-6-support/aws/src/awstasks/java/dak/ant/taskdefs/S3Get.java 2011-07-13 18:41:39 UTC (rev 2293)
+++ controltier/branches/controltier-3-6-support/aws/src/awstasks/java/dak/ant/taskdefs/S3Get.java 2011-07-13 18:42:00 UTC (rev 2294)
@@ -18,6 +18,7 @@
private String remoteFile;
private String destFile;
private String bucket;
+ private String url;

public void setBucket(String bucket) {
this.bucket = bucket;
@@ -31,6 +32,10 @@
this.destFile = file;
}

+ public void setUrl(String url) {
+ this.url = url;
+ }
+
public void execute() throws BuildException {
checkParameters();

@@ -67,16 +72,34 @@

protected void checkParameters() throws BuildException {
super.checkParameters();
- if(this.remoteFile == null) {
- throw new BuildException("file must be specified");
+ if((this.remoteFile == null && this.bucket == null) && this.url == null) {
+ throw new BuildException("either file and bucket must be specified, or url must be specified");
}
+
+ if((this.remoteFile != null || this.bucket != null) && this.url != null) {
+ throw new BuildException("Use of url is exclusive with use of file and bucket");
+ }
+
+ if((this.remoteFile != null && this.bucket == null) || (this.remoteFile == null && this.bucket != null)) {
+ throw new BuildException("You must specify both file and bucket");
+ }
+
+ if(this.url != null && !this.url.startsWith("s3://")) {
+ throw new BuildException("Only the s3:// scheme is supported");
+ }
+
+ if(this.url != null) {
+ // Remove the first five characters ("s3://") then split into two parts separated by "/"
+ String[] splitUrl = this.url.substring(5).split("/",2);
+ if(splitUrl.length < 2) {
+ throw new BuildException("Didn't find both a bucket and a file location in the URL!");
+ }
+ this.bucket = splitUrl[0];
+ this.remoteFile = splitUrl[1];
+ }

if(this.destFile == null) {
throw new BuildException("dest must be specified");
}
-
- if(this.bucket == null) {
- throw new BuildException("bucket must be specified");
- }
}
}

Modified: controltier/branches/controltier-3-6-support/aws/src/awstasks/test.xml
===================================================================
--- controltier/branches/controltier-3-6-support/aws/src/awstasks/test.xml 2011-07-13 18:41:39 UTC (rev 2293)
+++ controltier/branches/controltier-3-6-support/aws/src/awstasks/test.xml 2011-07-13 18:42:00 UTC (rev 2294)
@@ -1,4 +1,10 @@
<project name="test-s3-get" default="get">
+<!--
+# Place credentials in ~/.awscred in this format:
+aws.accessId=ACCESSKEY
+aws.secretKey=SECRETKEY
+-->
+
<property name="awstasks.build" value="build"/>
<property name="awstasks.classes" value="${awstasks.build}/classes"/>
<property name="awstasks.src" value="java"/>
@@ -18,12 +24,19 @@
</taskdef>

<target name="get">
- <property file=".awscred"/>
- <echo>${aws.accessId}</echo>
- <S3Get verbose="true" file="artifacts/modules/JBossEar-head.jar"
- dest="/tmp/s3get-test"
- accessId="AKIAIQSBXJNO6BNHYKFQ"
- secretKey="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"
- bucket="demo.services.dtosolutions.com"/>
+ <property file="${user.home}/.awscred"/>
+ <echo>Using AWS Access Key: ${aws.accessId}</echo>
+ <!-- by url -->
+ <echo>Testing get using url attribute</echo>
+ <S3Get verbose="true" url="s3://demo.services.dtosolutions.com/artifacts/modules/JBossEar-head.jar"
+ dest="/tmp/s3get-test"
+ accessId="${aws.accessId}"
+ secretKey="${aws.secretKey}" />
+ <!-- by file and bucket -->
+ <echo>Testing get using file and bucket attributes</echo>
+ <S3Get verbose="true" bucket="demo.services.dtosolutions.com" file="artifacts/modules/JBossEar-head.jar"
+ dest="/tmp/s3get-test"
+ accessId="${aws.accessId}"
+ secretKey="${aws.secretKey}" />
</target>
</project>


This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.

Reply all
Reply to author
Forward
0 new messages