You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@jclouds.apache.org by ga...@apache.org on 2016/02/17 01:30:25 UTC

[4/8] jclouds git commit: JCLOUDS-651: Local blobstore support for conditional copies

JCLOUDS-651: Local blobstore support for conditional copies


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

Branch: refs/heads/master
Commit: 66609e6d70e94bd508a9a84f15c95c768cd13469
Parents: 8945258
Author: Andrew Gaul <ga...@apache.org>
Authored: Fri Feb 12 13:52:15 2016 -0800
Committer: Andrew Gaul <ga...@apache.org>
Committed: Tue Feb 16 16:29:54 2016 -0800

----------------------------------------------------------------------
 .../blobstore/config/LocalBlobStore.java        | 20 ++++++++++++++++++++
 1 file changed, 20 insertions(+)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/jclouds/blob/66609e6d/blobstore/src/main/java/org/jclouds/blobstore/config/LocalBlobStore.java
----------------------------------------------------------------------
diff --git a/blobstore/src/main/java/org/jclouds/blobstore/config/LocalBlobStore.java b/blobstore/src/main/java/org/jclouds/blobstore/config/LocalBlobStore.java
index 42e6f39..5d806aa 100644
--- a/blobstore/src/main/java/org/jclouds/blobstore/config/LocalBlobStore.java
+++ b/blobstore/src/main/java/org/jclouds/blobstore/config/LocalBlobStore.java
@@ -530,6 +530,26 @@ public final class LocalBlobStore implements BlobStore {
          throw new KeyNotFoundException(fromContainer, fromName, "while copying");
       }
 
+      String eTag = maybeQuoteETag(blob.getMetadata().getETag());
+      if (eTag != null) {
+         if (options.ifMatch() != null && !options.ifMatch().equals(eTag)) {
+            throw returnResponseException(412);
+         }
+         if (options.ifNoneMatch() != null && options.ifNoneMatch().equals(eTag)) {
+            throw returnResponseException(412);
+         }
+      }
+
+      Date lastModified = blob.getMetadata().getLastModified();
+      if (lastModified != null) {
+         if (options.ifModifiedSince() != null && lastModified.compareTo(options.ifModifiedSince()) <= 0) {
+            throw returnResponseException(412);
+         }
+         if (options.ifUnmodifiedSince() != null && lastModified.compareTo(options.ifUnmodifiedSince()) >= 0) {
+            throw returnResponseException(412);
+         }
+      }
+
       InputStream is = null;
       try {
          is = blob.getPayload().openStream();