camel-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From davscl...@apache.org
Subject svn commit: r1461767 - in /camel/trunk/components/camel-aws/src: main/java/org/apache/camel/component/aws/s3/ test/java/org/apache/camel/component/aws/s3/
Date Wed, 27 Mar 2013 18:22:40 GMT
Author: davsclaus
Date: Wed Mar 27 18:22:39 2013
New Revision: 1461767

URL: http://svn.apache.org/r1461767
Log:
CAMEL-6216: camel-aws Support user metadata on files stored in S3. Thanks to Chris Geer for
the patch.

Modified:
    camel/trunk/components/camel-aws/src/main/java/org/apache/camel/component/aws/s3/S3Constants.java
    camel/trunk/components/camel-aws/src/main/java/org/apache/camel/component/aws/s3/S3Producer.java
    camel/trunk/components/camel-aws/src/test/java/org/apache/camel/component/aws/s3/S3ComponentExistingBucketTest.java

Modified: camel/trunk/components/camel-aws/src/main/java/org/apache/camel/component/aws/s3/S3Constants.java
URL: http://svn.apache.org/viewvc/camel/trunk/components/camel-aws/src/main/java/org/apache/camel/component/aws/s3/S3Constants.java?rev=1461767&r1=1461766&r2=1461767&view=diff
==============================================================================
--- camel/trunk/components/camel-aws/src/main/java/org/apache/camel/component/aws/s3/S3Constants.java
(original)
+++ camel/trunk/components/camel-aws/src/main/java/org/apache/camel/component/aws/s3/S3Constants.java
Wed Mar 27 18:22:39 2013
@@ -36,4 +36,5 @@ public interface S3Constants {
     String VERSION_ID          = "CamelAwsS3VersionId";
     String CANNED_ACL          = "CamelAwsS3CannedAcl";
     String ACL                 = "CamelAwsS3Acl";
+    String USER_METADATA       = "CamelAwsS3UserMetadata";
 }
\ No newline at end of file

Modified: camel/trunk/components/camel-aws/src/main/java/org/apache/camel/component/aws/s3/S3Producer.java
URL: http://svn.apache.org/viewvc/camel/trunk/components/camel-aws/src/main/java/org/apache/camel/component/aws/s3/S3Producer.java?rev=1461767&r1=1461766&r2=1461767&view=diff
==============================================================================
--- camel/trunk/components/camel-aws/src/main/java/org/apache/camel/component/aws/s3/S3Producer.java
(original)
+++ camel/trunk/components/camel-aws/src/main/java/org/apache/camel/component/aws/s3/S3Producer.java
Wed Mar 27 18:22:39 2013
@@ -18,6 +18,7 @@ package org.apache.camel.component.aws.s
 
 import java.io.InputStream;
 import java.util.Date;
+import java.util.Map;
 
 import com.amazonaws.services.s3.model.AccessControlList;
 import com.amazonaws.services.s3.model.CannedAccessControlList;
@@ -84,6 +85,11 @@ public class S3Producer extends DefaultP
             objectMetadata.setLastModified(lastModified);
         }
 
+        Map<String, String> userMetadata = exchange.getIn().getHeader(S3Constants.USER_METADATA,
Map.class);
+        if (userMetadata != null) {
+            objectMetadata.setUserMetadata(userMetadata);
+        }
+
         PutObjectRequest putObjectRequest = new PutObjectRequest(getConfiguration().getBucketName(),
                 determineKey(exchange), exchange.getIn().getMandatoryBody(InputStream.class),
objectMetadata);
 

Modified: camel/trunk/components/camel-aws/src/test/java/org/apache/camel/component/aws/s3/S3ComponentExistingBucketTest.java
URL: http://svn.apache.org/viewvc/camel/trunk/components/camel-aws/src/test/java/org/apache/camel/component/aws/s3/S3ComponentExistingBucketTest.java?rev=1461767&r1=1461766&r2=1461767&view=diff
==============================================================================
--- camel/trunk/components/camel-aws/src/test/java/org/apache/camel/component/aws/s3/S3ComponentExistingBucketTest.java
(original)
+++ camel/trunk/components/camel-aws/src/test/java/org/apache/camel/component/aws/s3/S3ComponentExistingBucketTest.java
Wed Mar 27 18:22:39 2013
@@ -18,6 +18,8 @@ package org.apache.camel.component.aws.s
 
 import java.io.InputStream;
 import java.util.Date;
+import java.util.HashMap;
+import java.util.Map;
 
 import com.amazonaws.services.s3.model.PutObjectRequest;
 
@@ -91,6 +93,8 @@ public class S3ComponentExistingBucketTe
     public void sendCustomHeaderValues() throws Exception {
         result.expectedMessageCount(1);
         final Date now = new Date();
+        final Map<String, String> userMetadata = new HashMap<String, String>();
+        userMetadata.put("CamelName", "Camel");
         
         Exchange exchange = template.send("direct:start", ExchangePattern.InOnly, new Processor()
{
             public void process(Exchange exchange) throws Exception {
@@ -103,6 +107,7 @@ public class S3ComponentExistingBucketTe
                 exchange.getIn().setHeader(S3Constants.CONTENT_ENCODING, "gzip");
                 exchange.getIn().setHeader(S3Constants.CONTENT_MD5, "TWF");
                 exchange.getIn().setHeader(S3Constants.LAST_MODIFIED, now);
+                exchange.getIn().setHeader(S3Constants.USER_METADATA, userMetadata);
                 
                 exchange.getIn().setBody("This is my bucket content.");
             }
@@ -122,6 +127,7 @@ public class S3ComponentExistingBucketTe
         assertEquals("gzip", putObjectRequest.getMetadata().getContentEncoding());
         assertEquals("TWF", putObjectRequest.getMetadata().getContentMD5());
         assertEquals(now, putObjectRequest.getMetadata().getLastModified());
+        assertEquals(userMetadata, putObjectRequest.getMetadata().getUserMetadata());
         
         assertResponseMessage(exchange.getIn());
     }
@@ -140,6 +146,7 @@ public class S3ComponentExistingBucketTe
         assertNull(resultExchange.getIn().getHeader(S3Constants.CONTENT_DISPOSITION));
         assertNull(resultExchange.getIn().getHeader(S3Constants.CONTENT_MD5));
         assertNull(resultExchange.getIn().getHeader(S3Constants.CACHE_CONTROL));
+        assertNull(resultExchange.getIn().getHeader(S3Constants.USER_METADATA));
     }
     
     private void assertResponseMessage(Message message) {



Mime
View raw message