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

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


The following commit(s) were added to refs/heads/master by this push:
     new ce8b494  CAMEL-15181: Change Created Azure headers (#3909)
ce8b494 is described below

commit ce8b494094cc233ed5f5ae2dde11efceeaa0f9ae
Author: Omar Al-Safi <[email protected]>
AuthorDate: Fri Jun 12 19:23:09 2020 +0200

    CAMEL-15181: Change Created Azure headers (#3909)
---
 .../src/main/docs/azure-storage-blob-component.adoc               | 8 ++++----
 .../apache/camel/component/azure/storage/blob/BlobConstants.java  | 4 ++--
 .../camel/component/azure/storage/blob/BlobExchangeHeaders.java   | 8 ++++----
 .../component/azure/storage/blob/operations/BlobOperations.java   | 8 ++++----
 .../apache/camel/component/azure/storage/blob/BlobProducerIT.java | 2 ++
 .../component/azure/storage/blob/operations/BlobOperationsIT.java | 5 +++++
 6 files changed, 21 insertions(+), 14 deletions(-)

diff --git 
a/components/camel-azure-storage-blob/src/main/docs/azure-storage-blob-component.adoc
 
b/components/camel-azure-storage-blob/src/main/docs/azure-storage-blob-component.adoc
index 5704bec..49d2911 100644
--- 
a/components/camel-azure-storage-blob/src/main/docs/azure-storage-blob-component.adoc
+++ 
b/components/camel-azure-storage-blob/src/main/docs/azure-storage-blob-component.adoc
@@ -170,8 +170,8 @@ can be used to retrieve lower level clients.
 |`CamelAzureStorageBlobContentMD5`|`BlobConstants.CONTENT_MD5`|`byte[]`|Most 
operations related to upload blob|An MD5 hash of the block content. This hash 
is used to verify the integrity of the block during transport. When this header 
is specified, the storage service compares the hash of the content that has 
arrived with this header value. Note that this MD5 hash is not stored with the 
blob. If the two hashes do not match, the operation will fail.
 
|`CamelAzureStorageBlobPageBlobRange`|`BlobConstants.PAGE_BLOB_RANGE`|`PageRange`|Operations
 related to page blob| A {@link PageRange} object. Given that pages must be 
aligned with 512-byte boundaries, the start offset must be a modulus of 512 and 
the end offset must be a modulus of 512 - 1. Examples of valid byte ranges are 
0-511, 512-1023, etc.
 
|`CamelAzureStorageBlobCommitBlobBlockListLater`|`BlobConstants.COMMIT_BLOCK_LIST_LATER`|`boolean`|`stageBlockBlobList`|
 When is set to `true`, the staged blocks will not be committed directly.
-|`CamelAzureStorageBlobAppendBlobCreated`|`BlobConstants.APPEND_BLOCK_CREATED`|`boolean`|`commitAppendBlob`|
 When is set to `true`, the append blocks will not be created when committing 
append blocks.
-|`CamelAzureStorageBlobPageBlockCreated`|`BlobConstants.PAGE_BLOCK_CREATED`|`boolean`|`uploadPageBlob`|
 When is set to `true`, the page blob will not be created when uploading page 
blob.
+|`CamelAzureStorageBlobCreateAppendBlob`|`BlobConstants.CREATE_APPEND_BLOB`|`boolean`|`commitAppendBlob`|
 When is set to `true`, the append blocks will be created when committing 
append blocks.
+|`CamelAzureStorageBlobCreatePageBlob`|`BlobConstants.CREATE_PAGE_BLOB`|`boolean`|`uploadPageBlob`|
 When is set to `true`, the page blob will be created when uploading page blob.
 
|`CamelAzureStorageBlobBlockListType`|`BlobConstants.BLOCK_LIST_TYPE`|`BlockListType`|`getBlobBlockList`|
 Specifies which type of blocks to return.
 
|`CamelAzureStorageBlobPageBlobSize`|`BlobConstants.PAGE_BLOB_SIZE`|`Long`|`createPageBlob`,
 `resizePageBlob`| Specifies the maximum size for the page blob, up to 8 TB. 
The page blob size must be aligned to a 512-byte boundary.
 
|`CamelAzureStorageBlobSequenceNumber`|`BlobConstants.BLOB_SEQUENCE_NUMBER`|`Long`|`createPageBlob`|A
 user-controlled value that you can use to track requests. The value of the 
sequence number must be between 0 and 2^63 - 1.The default value is 0.
@@ -299,9 +299,9 @@ For these operations, `accountName`, `containerName` and 
`blobName` are *require
                                     and existing blocks together. Any blocks 
not specified in the block list and permanently deleted.
 |`getBlobBlockList`  |`BlockBlob`|Returns the list of blocks that have been 
uploaded as part of a block blob using the specified block list filter.
 |`createAppendBlob` |`AppendBlob`|Creates a 0-length append blob. Call 
commitAppendBlo`b operation to append data to an append blob.
-|`commitAppendBlob` |`AppendBlob`|Commits a new block of data to the end of 
the existing append blob. In case of header 
`CamelAzureStorageBlobAppendBlobCreated` is set to false, it will attempt to 
create the appendBlob through internal call to `createAppendBlob` operation.
+|`commitAppendBlob` |`AppendBlob`|Commits a new block of data to the end of 
the existing append blob. In case of header 
`CamelAzureStorageBlobCreateAppendBlob` is set to true, it will attempt to 
create the appendBlob through internal call to `createAppendBlob` operation.
 |`createPageBlob`|`PageBlob`|Creates a page blob of the specified length. Call 
`uploadPageBlob` operation to upload data data to a page blob.
-|`uploadPageBlob`|`PageBlob`|Writes one or more pages to the page blob. The 
write size must be a multiple of 512. In case of header 
`CamelAzureStorageBlobPageBlockCreated` is set to false, it will attempt to 
create the appendBlob through internal call to `createPageBlob` operation.
+|`uploadPageBlob`|`PageBlob`|Writes one or more pages to the page blob. The 
write size must be a multiple of 512. In case of header 
`CamelAzureStorageBlobCreatePageBlob` is set to true, it will attempt to create 
the appendBlob through internal call to `createPageBlob` operation.
 |`resizePageBlob`|`PageBlob`| Resizes the page blob to the specified size 
(which must be a multiple of 512).
 |`clearPageBlob`|`PageBlob`| Frees the specified pages from the page blob. The 
size of the range must be a multiple of 512.
 |`getPageBlobRanges`|`PageBlob`|Returns the list of valid page ranges for a 
page blob or snapshot of a page blob.
diff --git 
a/components/camel-azure-storage-blob/src/main/java/org/apache/camel/component/azure/storage/blob/BlobConstants.java
 
b/components/camel-azure-storage-blob/src/main/java/org/apache/camel/component/azure/storage/blob/BlobConstants.java
index 8356c6c..aa5ecf8 100644
--- 
a/components/camel-azure-storage-blob/src/main/java/org/apache/camel/component/azure/storage/blob/BlobConstants.java
+++ 
b/components/camel-azure-storage-blob/src/main/java/org/apache/camel/component/azure/storage/blob/BlobConstants.java
@@ -74,8 +74,8 @@ public final class BlobConstants {
     public static final String PAGE_BLOB_SIZE = HEADER_PREFIX + "PageBlobSize";
     public static final String COMMIT_BLOCK_LIST_LATER = HEADER_PREFIX + 
"CommitBlobBlockListLater";
     public static final String BLOCK_LIST_TYPE = HEADER_PREFIX + 
"BlockListType";
-    public static final String APPEND_BLOCK_CREATED = HEADER_PREFIX + 
"AppendBlobCreated";
-    public static final String PAGE_BLOCK_CREATED = HEADER_PREFIX + 
"PageBlockCreated";
+    public static final String CREATE_APPEND_BLOB = HEADER_PREFIX + 
"CreateAppendBlob";
+    public static final String CREATE_PAGE_BLOB = HEADER_PREFIX + 
"CreatePageBlob";
     public static final String DELETE_SNAPSHOT_OPTION_TYPE = HEADER_PREFIX + 
"DeleteSnapshotsOptionType";
     public static final String LIST_BLOB_CONTAINERS_OPTIONS = HEADER_PREFIX + 
"ListBlobContainersOptions";
     public static final String PARALLEL_TRANSFER_OPTIONS = HEADER_PREFIX + 
"ParallelTransferOptions";
diff --git 
a/components/camel-azure-storage-blob/src/main/java/org/apache/camel/component/azure/storage/blob/BlobExchangeHeaders.java
 
b/components/camel-azure-storage-blob/src/main/java/org/apache/camel/component/azure/storage/blob/BlobExchangeHeaders.java
index 2d446b2..cbb7f87 100644
--- 
a/components/camel-azure-storage-blob/src/main/java/org/apache/camel/component/azure/storage/blob/BlobExchangeHeaders.java
+++ 
b/components/camel-azure-storage-blob/src/main/java/org/apache/camel/component/azure/storage/blob/BlobExchangeHeaders.java
@@ -189,12 +189,12 @@ public class BlobExchangeHeaders {
         return getObjectFromHeaders(exchange, 
BlobConstants.COMMIT_BLOCK_LIST_LATER, boolean.class);
     }
 
-    public static boolean getAppendBlockCreatedFlagFromHeaders(final Exchange 
exchange) {
-        return getObjectFromHeaders(exchange, 
BlobConstants.APPEND_BLOCK_CREATED, boolean.class);
+    public static boolean getCreateAppendBlobFlagFromHeaders(final Exchange 
exchange) {
+        return getObjectFromHeaders(exchange, 
BlobConstants.CREATE_APPEND_BLOB, boolean.class);
     }
 
-    public static boolean getPageBlockCreatedFlagFromHeaders(final Exchange 
exchange) {
-        return getObjectFromHeaders(exchange, 
BlobConstants.PAGE_BLOCK_CREATED, boolean.class);
+    public static boolean getCreatePageBlobFlagFromHeaders(final Exchange 
exchange) {
+        return getObjectFromHeaders(exchange, BlobConstants.CREATE_PAGE_BLOB, 
boolean.class);
     }
 
     public static BlockListType getBlockListTypeFromHeaders(final Exchange 
exchange) {
diff --git 
a/components/camel-azure-storage-blob/src/main/java/org/apache/camel/component/azure/storage/blob/operations/BlobOperations.java
 
b/components/camel-azure-storage-blob/src/main/java/org/apache/camel/component/azure/storage/blob/operations/BlobOperations.java
index 8a1bddd..3bc4ee8 100644
--- 
a/components/camel-azure-storage-blob/src/main/java/org/apache/camel/component/azure/storage/blob/operations/BlobOperations.java
+++ 
b/components/camel-azure-storage-blob/src/main/java/org/apache/camel/component/azure/storage/blob/operations/BlobOperations.java
@@ -317,9 +317,9 @@ public class BlobOperations {
         ObjectHelper.notNull(exchange, "exchange cannot be null");
 
         final BlobCommonRequestOptions commonRequestOptions = 
BlobUtils.getCommonRequestOptions(exchange);
-        final boolean appendBlockCreated = 
BlobExchangeHeaders.getAppendBlockCreatedFlagFromHeaders(exchange);
+        final boolean createAppendBlob = 
BlobExchangeHeaders.getCreateAppendBlobFlagFromHeaders(exchange);
 
-        if (!appendBlockCreated) {
+        if (createAppendBlob) {
             createAppendBlob(exchange);
         }
 
@@ -356,9 +356,9 @@ public class BlobOperations {
     public BlobOperationResponse uploadPageBlob(final Exchange exchange) 
throws IOException {
         ObjectHelper.notNull(exchange, "exchange cannot be null");
 
-        final boolean pageBlobCreated = 
BlobExchangeHeaders.getPageBlockCreatedFlagFromHeaders(exchange);
+        final boolean createPageBlob = 
BlobExchangeHeaders.getCreatePageBlobFlagFromHeaders(exchange);
 
-        if (!pageBlobCreated) {
+        if (createPageBlob) {
             createPageBlob(exchange);
         }
 
diff --git 
a/components/camel-azure-storage-blob/src/test/java/org/apache/camel/component/azure/storage/blob/BlobProducerIT.java
 
b/components/camel-azure-storage-blob/src/test/java/org/apache/camel/component/azure/storage/blob/BlobProducerIT.java
index 157bdae..27a9f8a 100644
--- 
a/components/camel-azure-storage-blob/src/test/java/org/apache/camel/component/azure/storage/blob/BlobProducerIT.java
+++ 
b/components/camel-azure-storage-blob/src/test/java/org/apache/camel/component/azure/storage/blob/BlobProducerIT.java
@@ -122,6 +122,7 @@ public class BlobProducerIT extends CamelTestSupport {
 
         template.send("direct:commitAppendBlob", ExchangePattern.InOnly, 
exchange -> {
             exchange.getIn().setHeader(BlobConstants.BLOB_NAME, blobName);
+            exchange.getIn().setHeader(BlobConstants.CREATE_APPEND_BLOB, true);
 
             final String data = "Hello world from my awesome tests!";
             final InputStream dataStream = new 
ByteArrayInputStream(data.getBytes(StandardCharsets.UTF_8));
@@ -145,6 +146,7 @@ public class BlobProducerIT extends CamelTestSupport {
 
         template.send("direct:uploadPageBlob", ExchangePattern.InOnly, 
exchange -> {
             exchange.getIn().setHeader(BlobConstants.BLOB_NAME, blobName);
+            exchange.getIn().setHeader(BlobConstants.CREATE_PAGE_BLOB, true);
 
             byte[] dataBytes = new byte[512]; // we set range for the page 
from 0-511
             new Random().nextBytes(dataBytes);
diff --git 
a/components/camel-azure-storage-blob/src/test/java/org/apache/camel/component/azure/storage/blob/operations/BlobOperationsIT.java
 
b/components/camel-azure-storage-blob/src/test/java/org/apache/camel/component/azure/storage/blob/operations/BlobOperationsIT.java
index 5b5162d..a30757c 100644
--- 
a/components/camel-azure-storage-blob/src/test/java/org/apache/camel/component/azure/storage/blob/operations/BlobOperationsIT.java
+++ 
b/components/camel-azure-storage-blob/src/test/java/org/apache/camel/component/azure/storage/blob/operations/BlobOperationsIT.java
@@ -260,6 +260,7 @@ class BlobOperationsIT extends CamelTestSupport {
 
         final Exchange exchange = new DefaultExchange(context);
         exchange.getIn().setBody(dataStream);
+        exchange.getIn().setHeader(BlobConstants.CREATE_APPEND_BLOB, true);
 
         final BlobOperationResponse response = 
operations.commitAppendBlob(exchange);
 
@@ -291,6 +292,7 @@ class BlobOperationsIT extends CamelTestSupport {
         final Exchange exchange = new DefaultExchange(context);
         exchange.getIn().setBody(dataStream);
         exchange.getIn().setHeader(BlobConstants.PAGE_BLOB_RANGE, pageRange);
+        exchange.getIn().setHeader(BlobConstants.CREATE_PAGE_BLOB, true);
 
         final BlobOperationResponse response = 
operations.uploadPageBlob(exchange);
 
@@ -322,6 +324,7 @@ class BlobOperationsIT extends CamelTestSupport {
         final Exchange exchange = new DefaultExchange(context);
         exchange.getIn().setBody(dataStream);
         exchange.getIn().setHeader(BlobConstants.PAGE_BLOB_RANGE, pageRange);
+        exchange.getIn().setHeader(BlobConstants.CREATE_PAGE_BLOB, true);
 
         // create our page
         operations.uploadPageBlob(exchange);
@@ -358,6 +361,7 @@ class BlobOperationsIT extends CamelTestSupport {
         final Exchange exchange = new DefaultExchange(context);
         exchange.getIn().setBody(dataStream);
         exchange.getIn().setHeader(BlobConstants.PAGE_BLOB_RANGE, pageRange);
+        exchange.getIn().setHeader(BlobConstants.CREATE_PAGE_BLOB, true);
 
         // create our page
         operations.uploadPageBlob(exchange);
@@ -386,6 +390,7 @@ class BlobOperationsIT extends CamelTestSupport {
         final Exchange exchange = new DefaultExchange(context);
         exchange.getIn().setBody(dataStream);
         exchange.getIn().setHeader(BlobConstants.PAGE_BLOB_RANGE, pageRange);
+        exchange.getIn().setHeader(BlobConstants.CREATE_PAGE_BLOB, true);
 
         // create our page
         operations.uploadPageBlob(exchange);

Reply via email to