You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@camel.apache.org by ac...@apache.org on 2023/02/10 13:25:43 UTC

[camel] branch main updated (cc42c7716ce -> d04e760547e)

This is an automated email from the ASF dual-hosted git repository.

acosentino pushed a change to branch main
in repository https://gitbox.apache.org/repos/asf/camel.git


    from cc42c7716ce Regen for commit ef0f147680fdc6400ad187d493b248aef35a4d1d (#9331)
     new 9bf5d03c90c CAMEL-19034 - Camel-AWS2-S3: GetObject should preserve the metadata
     new 261b32f0bd0 CAMEL-19034 - Camel-AWS2-S3: GetObject should preserve the metadata
     new d04e760547e CAMEL-19034 - Camel-AWS2-S3: GetObject should preserve the metadata

The 3 revisions listed above as "new" are entirely new to this
repository and will be described in separate emails.  The revisions
listed as "add" were already present in the repository and have only
been added to this reference.


Summary of changes:
 .../camel/component/aws2/s3/AWS2S3Producer.java    | 17 +++++++++
 ...perationIT.java => S3GetObjectOperationIT.java} | 40 +++++++---------------
 2 files changed, 30 insertions(+), 27 deletions(-)
 copy components/camel-aws/camel-aws2-s3/src/test/java/org/apache/camel/component/aws2/s3/integration/{S3SimpleEncryptedUploadOperationIT.java => S3GetObjectOperationIT.java} (69%)


[camel] 03/03: CAMEL-19034 - Camel-AWS2-S3: GetObject should preserve the metadata

Posted by ac...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

acosentino pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/camel.git

commit d04e760547ee6b808450be704b4b44904695bcbe
Author: Andrea Cosentino <an...@gmail.com>
AuthorDate: Fri Feb 10 14:24:06 2023 +0100

    CAMEL-19034 - Camel-AWS2-S3: GetObject should preserve the metadata
    
    Signed-off-by: Andrea Cosentino <an...@gmail.com>
---
 .../camel/component/aws2/s3/integration/S3GetObjectOperationIT.java | 6 +++++-
 1 file changed, 5 insertions(+), 1 deletion(-)

diff --git a/components/camel-aws/camel-aws2-s3/src/test/java/org/apache/camel/component/aws2/s3/integration/S3GetObjectOperationIT.java b/components/camel-aws/camel-aws2-s3/src/test/java/org/apache/camel/component/aws2/s3/integration/S3GetObjectOperationIT.java
index b897cd1845f..f76d4026744 100644
--- a/components/camel-aws/camel-aws2-s3/src/test/java/org/apache/camel/component/aws2/s3/integration/S3GetObjectOperationIT.java
+++ b/components/camel-aws/camel-aws2-s3/src/test/java/org/apache/camel/component/aws2/s3/integration/S3GetObjectOperationIT.java
@@ -18,7 +18,11 @@ package org.apache.camel.component.aws2.s3.integration;
 
 import java.io.InputStream;
 
-import org.apache.camel.*;
+import org.apache.camel.EndpointInject;
+import org.apache.camel.Exchange;
+import org.apache.camel.Message;
+import org.apache.camel.Processor;
+import org.apache.camel.ProducerTemplate;
 import org.apache.camel.builder.RouteBuilder;
 import org.apache.camel.component.aws2.s3.AWS2S3Constants;
 import org.apache.camel.component.aws2.s3.AWS2S3Operations;


[camel] 02/03: CAMEL-19034 - Camel-AWS2-S3: GetObject should preserve the metadata

Posted by ac...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

acosentino pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/camel.git

commit 261b32f0bd0fd7d1872995a657543fe0e04aeb41
Author: Andrea Cosentino <an...@gmail.com>
AuthorDate: Fri Feb 10 14:10:57 2023 +0100

    CAMEL-19034 - Camel-AWS2-S3: GetObject should preserve the metadata
    
    Signed-off-by: Andrea Cosentino <an...@gmail.com>
---
 .../camel/component/aws2/s3/integration/S3GetObjectOperationIT.java   | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/components/camel-aws/camel-aws2-s3/src/test/java/org/apache/camel/component/aws2/s3/integration/S3GetObjectOperationIT.java b/components/camel-aws/camel-aws2-s3/src/test/java/org/apache/camel/component/aws2/s3/integration/S3GetObjectOperationIT.java
index 99003ec4f14..b897cd1845f 100644
--- a/components/camel-aws/camel-aws2-s3/src/test/java/org/apache/camel/component/aws2/s3/integration/S3GetObjectOperationIT.java
+++ b/components/camel-aws/camel-aws2-s3/src/test/java/org/apache/camel/component/aws2/s3/integration/S3GetObjectOperationIT.java
@@ -16,6 +16,8 @@
  */
 package org.apache.camel.component.aws2.s3.integration;
 
+import java.io.InputStream;
+
 import org.apache.camel.*;
 import org.apache.camel.builder.RouteBuilder;
 import org.apache.camel.component.aws2.s3.AWS2S3Constants;
@@ -24,8 +26,6 @@ import org.apache.camel.component.mock.MockEndpoint;
 import org.junit.jupiter.api.Test;
 import software.amazon.awssdk.utils.IoUtils;
 
-import java.io.InputStream;
-
 import static org.junit.jupiter.api.Assertions.assertEquals;
 import static org.junit.jupiter.api.Assertions.assertNotNull;
 


[camel] 01/03: CAMEL-19034 - Camel-AWS2-S3: GetObject should preserve the metadata

Posted by ac...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

acosentino pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/camel.git

commit 9bf5d03c90cc4bdd4e0680d2408780b8da34c755
Author: Andrea Cosentino <an...@gmail.com>
AuthorDate: Fri Feb 10 14:06:24 2023 +0100

    CAMEL-19034 - Camel-AWS2-S3: GetObject should preserve the metadata
    
    Signed-off-by: Andrea Cosentino <an...@gmail.com>
---
 .../camel/component/aws2/s3/AWS2S3Producer.java    | 17 +++++
 .../s3/integration/S3GetObjectOperationIT.java     | 85 ++++++++++++++++++++++
 2 files changed, 102 insertions(+)

diff --git a/components/camel-aws/camel-aws2-s3/src/main/java/org/apache/camel/component/aws2/s3/AWS2S3Producer.java b/components/camel-aws/camel-aws2-s3/src/main/java/org/apache/camel/component/aws2/s3/AWS2S3Producer.java
index 1394b26ff6a..4fad7100258 100644
--- a/components/camel-aws/camel-aws2-s3/src/main/java/org/apache/camel/component/aws2/s3/AWS2S3Producer.java
+++ b/components/camel-aws/camel-aws2-s3/src/main/java/org/apache/camel/component/aws2/s3/AWS2S3Producer.java
@@ -510,6 +510,7 @@ public class AWS2S3Producer extends DefaultProducer {
                         = s3Client.getObject((GetObjectRequest) payload, ResponseTransformer.toInputStream());
                 Message message = getMessageForResponse(exchange);
                 message.setBody(res);
+                populateMetadata(res, message);
             }
         } else {
             final String bucketName = AWS2S3Utils.determineBucketName(exchange, getConfiguration());
@@ -519,6 +520,7 @@ public class AWS2S3Producer extends DefaultProducer {
 
             Message message = getMessageForResponse(exchange);
             message.setBody(res);
+            populateMetadata(res, message);
         }
     }
 
@@ -663,6 +665,21 @@ public class AWS2S3Producer extends DefaultProducer {
         return objectMetadata;
     }
 
+    private static void populateMetadata(ResponseInputStream<GetObjectResponse> res, Message message) {
+        message.setHeader(AWS2S3Constants.E_TAG, res.response().eTag());
+        message.setHeader(AWS2S3Constants.VERSION_ID, res.response().versionId());
+        message.setHeader(AWS2S3Constants.CONTENT_TYPE, res.response().contentType());
+        message.setHeader(AWS2S3Constants.CONTENT_LENGTH, res.response().contentLength());
+        message.setHeader(AWS2S3Constants.CONTENT_ENCODING, res.response().contentEncoding());
+        message.setHeader(AWS2S3Constants.CONTENT_DISPOSITION, res.response().contentDisposition());
+        message.setHeader(AWS2S3Constants.CACHE_CONTROL, res.response().cacheControl());
+        message.setHeader(AWS2S3Constants.SERVER_SIDE_ENCRYPTION, res.response().serverSideEncryption());
+        message.setHeader(AWS2S3Constants.EXPIRATION_TIME, res.response().expiration());
+        message.setHeader(AWS2S3Constants.REPLICATION_STATUS, res.response().replicationStatus());
+        message.setHeader(AWS2S3Constants.STORAGE_CLASS, res.response().storageClass());
+        message.setHeader(AWS2S3Constants.METADATA, res.response().metadata());
+    }
+
     protected AWS2S3Configuration getConfiguration() {
         return getEndpoint().getConfiguration();
     }
diff --git a/components/camel-aws/camel-aws2-s3/src/test/java/org/apache/camel/component/aws2/s3/integration/S3GetObjectOperationIT.java b/components/camel-aws/camel-aws2-s3/src/test/java/org/apache/camel/component/aws2/s3/integration/S3GetObjectOperationIT.java
new file mode 100644
index 00000000000..99003ec4f14
--- /dev/null
+++ b/components/camel-aws/camel-aws2-s3/src/test/java/org/apache/camel/component/aws2/s3/integration/S3GetObjectOperationIT.java
@@ -0,0 +1,85 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.camel.component.aws2.s3.integration;
+
+import org.apache.camel.*;
+import org.apache.camel.builder.RouteBuilder;
+import org.apache.camel.component.aws2.s3.AWS2S3Constants;
+import org.apache.camel.component.aws2.s3.AWS2S3Operations;
+import org.apache.camel.component.mock.MockEndpoint;
+import org.junit.jupiter.api.Test;
+import software.amazon.awssdk.utils.IoUtils;
+
+import java.io.InputStream;
+
+import static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertNotNull;
+
+public class S3GetObjectOperationIT extends Aws2S3Base {
+
+    @EndpointInject
+    private ProducerTemplate template;
+
+    @EndpointInject("mock:result")
+    private MockEndpoint result;
+
+    @Test
+    public void sendIn() throws Exception {
+        result.expectedMessageCount(1);
+
+        template.send("direct:putObject", new Processor() {
+
+            @Override
+            public void process(Exchange exchange) {
+                exchange.getIn().setHeader(AWS2S3Constants.KEY, "camel.txt");
+                exchange.getIn().setHeader(AWS2S3Constants.CONTENT_TYPE, "application/text");
+                exchange.getIn().setBody("Camel rocks!");
+            }
+        });
+
+        template.request("direct:getObject", new Processor() {
+
+            @Override
+            public void process(Exchange exchange) {
+                exchange.getIn().setHeader(AWS2S3Constants.BUCKET_NAME, "mycamel");
+                exchange.getIn().setHeader(AWS2S3Constants.KEY, "camel.txt");
+                exchange.getIn().setHeader(AWS2S3Constants.S3_OPERATION, AWS2S3Operations.getObject);
+            }
+        });
+
+        Message resp = result.getExchanges().get(0).getMessage();
+        assertEquals("Camel rocks!", new String(IoUtils.toByteArray(resp.getBody(InputStream.class))));
+        assertEquals("application/text", resp.getHeader(AWS2S3Constants.CONTENT_TYPE));
+        assertNotNull(resp.getHeader(AWS2S3Constants.E_TAG));
+        MockEndpoint.assertIsSatisfied(context);
+    }
+
+    @Override
+    protected RouteBuilder createRouteBuilder() {
+        return new RouteBuilder() {
+            @Override
+            public void configure() {
+                String awsEndpoint = "aws2-s3://mycamel?autoCreateBucket=true";
+
+                from("direct:putObject").to(awsEndpoint);
+
+                from("direct:getObject").to(awsEndpoint).to("mock:result");
+
+            }
+        };
+    }
+}