You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@camel.apache.org by se...@apache.org on 2017/02/17 17:03:19 UTC

[1/2] camel git commit: [CAMEL-10876] BlobInputStrean should be available to the producers like File

Repository: camel
Updated Branches:
  refs/heads/master cd11f2d06 -> af4902b36


[CAMEL-10876] BlobInputStrean should be available to the producers like File


Project: http://git-wip-us.apache.org/repos/asf/camel/repo
Commit: http://git-wip-us.apache.org/repos/asf/camel/commit/c6e58c83
Tree: http://git-wip-us.apache.org/repos/asf/camel/tree/c6e58c83
Diff: http://git-wip-us.apache.org/repos/asf/camel/diff/c6e58c83

Branch: refs/heads/master
Commit: c6e58c830cb57d22e38d75fc9036433f5eef4818
Parents: 451887e
Author: Sergey Beryozkin <sb...@gmail.com>
Authored: Fri Feb 17 17:02:45 2017 +0000
Committer: Sergey Beryozkin <sb...@gmail.com>
Committed: Fri Feb 17 17:02:45 2017 +0000

----------------------------------------------------------------------
 .../component/azure/blob/BlobServiceUtil.java   | 45 +++++++++++---------
 .../blob/BlobServiceBlockConsumerTest.java      |  5 ++-
 2 files changed, 30 insertions(+), 20 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/camel/blob/c6e58c83/components/camel-azure/src/main/java/org/apache/camel/component/azure/blob/BlobServiceUtil.java
----------------------------------------------------------------------
diff --git a/components/camel-azure/src/main/java/org/apache/camel/component/azure/blob/BlobServiceUtil.java b/components/camel-azure/src/main/java/org/apache/camel/component/azure/blob/BlobServiceUtil.java
index d00dd4d..c4a4363 100644
--- a/components/camel-azure/src/main/java/org/apache/camel/component/azure/blob/BlobServiceUtil.java
+++ b/components/camel-azure/src/main/java/org/apache/camel/component/azure/blob/BlobServiceUtil.java
@@ -18,6 +18,7 @@ package org.apache.camel.component.azure.blob;
 
 import java.io.File;
 import java.io.FileOutputStream;
+import java.io.InputStream;
 import java.io.OutputStream;
 import java.net.URI;
 
@@ -81,38 +82,44 @@ public final class BlobServiceUtil {
         BlobServiceUtil.configureCloudBlobForRead(client, cfg);
         BlobServiceRequestOptions opts = getRequestOptions(exchange);
         LOG.trace("Getting a blob [{}] from exchange [{}]...", cfg.getBlobName(), exchange);
-        Long blobOffset = cfg.getBlobOffset();
-        Long blobDataLength = cfg.getDataLength();
-        if (client instanceof CloudPageBlob) {
-            PageRange range = exchange.getIn().getHeader(BlobServiceConstants.PAGE_BLOB_RANGE, PageRange.class);
-            if (range != null) {
-                blobOffset = range.getStartOffset();
-                blobDataLength = range.getEndOffset() - range.getStartOffset();
-            }
-        }
         OutputStream os = exchange.getIn().getBody(OutputStream.class);
         if (os == null) {
             String fileDir = cfg.getFileDir();
             if (fileDir != null) {
-                // Should the range if it is set be reflected in the file name ?
-                String name = cfg.getBlobName();
-                File file = new File(fileDir, name + ".blob");
+                File file = new File(fileDir, getBlobFileName(cfg));
                 ExchangeUtil.getMessageForResponse(exchange).setBody(file);
-                os = new FileOutputStream(file);
+                os = new FileOutputStream(file);  
             }
         }
-        if (os == null) {
-            throw new IllegalArgumentException("OutputStream is not available");
-        }
         try {
-            client.downloadRange(blobOffset, blobDataLength, os,
-                opts.getAccessCond(), opts.getRequestOpts(), opts.getOpContext());
+            if (os == null) {
+                // Let the producers like file: deal with it
+                InputStream blobStream = client.openInputStream(
+                    opts.getAccessCond(), opts.getRequestOpts(), opts.getOpContext());
+                exchange.getIn().setBody(blobStream);
+                exchange.getIn().setHeader(Exchange.FILE_NAME, getBlobFileName(cfg));
+            } else {
+                Long blobOffset = cfg.getBlobOffset();
+                Long blobDataLength = cfg.getDataLength();
+                if (client instanceof CloudPageBlob) {
+                    PageRange range = exchange.getIn().getHeader(BlobServiceConstants.PAGE_BLOB_RANGE, PageRange.class);
+                    if (range != null) {
+                        blobOffset = range.getStartOffset();
+                        blobDataLength = range.getEndOffset() - range.getStartOffset();
+                    }
+                }
+                client.downloadRange(blobOffset, blobDataLength, os,
+                                     opts.getAccessCond(), opts.getRequestOpts(), opts.getOpContext());
+            }
         } finally {
-            if (cfg.isCloseStreamAfterRead()) {
+            if (os != null && cfg.isCloseStreamAfterRead()) {
                 os.close();
             }
         }
     }
+    private static String getBlobFileName(BlobServiceConfiguration cfg) {
+        return cfg.getBlobName()  + ".blob";
+    }
 
     public static CloudBlobContainer createBlobContainerClient(BlobServiceConfiguration cfg)
         throws Exception {

http://git-wip-us.apache.org/repos/asf/camel/blob/c6e58c83/components/camel-azure/src/test/java/org/apache/camel/component/azure/blob/BlobServiceBlockConsumerTest.java
----------------------------------------------------------------------
diff --git a/components/camel-azure/src/test/java/org/apache/camel/component/azure/blob/BlobServiceBlockConsumerTest.java b/components/camel-azure/src/test/java/org/apache/camel/component/azure/blob/BlobServiceBlockConsumerTest.java
index d47b652..c5718d5 100644
--- a/components/camel-azure/src/test/java/org/apache/camel/component/azure/blob/BlobServiceBlockConsumerTest.java
+++ b/components/camel-azure/src/test/java/org/apache/camel/component/azure/blob/BlobServiceBlockConsumerTest.java
@@ -84,7 +84,10 @@ public class BlobServiceBlockConsumerTest extends CamelTestSupport {
                 
                 from("azure-blob://camelazure/container1/blobBlock?credentials=#creds&fileDir="
                     + System.getProperty("java.io.tmpdir")).to("mock:result");
+                
+                //from("azure-blob://camelazure/container1/blobBlock?credentials=#creds")
+                //    .to("file://" + System.getProperty("java.io.tmpdir"));  
             }
         };
     }
-}
\ No newline at end of file
+}


[2/2] camel git commit: Merge branch 'master' of https://git-wip-us.apache.org/repos/asf/camel

Posted by se...@apache.org.
Merge branch 'master' of https://git-wip-us.apache.org/repos/asf/camel


Project: http://git-wip-us.apache.org/repos/asf/camel/repo
Commit: http://git-wip-us.apache.org/repos/asf/camel/commit/af4902b3
Tree: http://git-wip-us.apache.org/repos/asf/camel/tree/af4902b3
Diff: http://git-wip-us.apache.org/repos/asf/camel/diff/af4902b3

Branch: refs/heads/master
Commit: af4902b36dbc99a84d01cb15de1be8137d5c3d07
Parents: c6e58c8 cd11f2d
Author: Sergey Beryozkin <sb...@gmail.com>
Authored: Fri Feb 17 17:03:06 2017 +0000
Committer: Sergey Beryozkin <sb...@gmail.com>
Committed: Fri Feb 17 17:03:06 2017 +0000

----------------------------------------------------------------------
 .../src/main/docs/eips/aggregate-eip.adoc       |   53 +-
 .../maven/packaging/PrepareExampleMojo.java     |    9 +-
 .../maven/packaging/PrepareReadmeMojo.java      |   10 +-
 .../maven/packaging/ReadmeComponentMojo.java    |  908 ---------------
 .../camel/maven/packaging/UpdateReadmeMojo.java | 1091 ++++++++++++++++++
 .../maven/packaging/model/EipOptionModel.java   |   33 +
 .../src/main/resources/eip-options.mvel         |    9 +
 7 files changed, 1182 insertions(+), 931 deletions(-)
----------------------------------------------------------------------