You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@jclouds.apache.org by an...@apache.org on 2014/04/22 11:23:40 UTC

git commit: Creating a separate function to delete directories

Repository: jclouds
Updated Branches:
  refs/heads/master b2be14994 -> c6cb169de


Creating a separate function to delete directories

Small refactoring to reuse some code.


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

Branch: refs/heads/master
Commit: c6cb169dee73de8c75c6850b504b6644c12d2ba1
Parents: b2be149
Author: Shri Javadekar <sh...@maginatics.com>
Authored: Wed Apr 16 00:06:58 2014 -0700
Committer: Andrew Phillips <an...@apache.org>
Committed: Tue Apr 22 11:22:13 2014 +0200

----------------------------------------------------------------------
 .../strategy/internal/DeleteAllKeysInList.java  | 44 ++++++++++----------
 1 file changed, 22 insertions(+), 22 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/jclouds/blob/c6cb169d/blobstore/src/main/java/org/jclouds/blobstore/strategy/internal/DeleteAllKeysInList.java
----------------------------------------------------------------------
diff --git a/blobstore/src/main/java/org/jclouds/blobstore/strategy/internal/DeleteAllKeysInList.java b/blobstore/src/main/java/org/jclouds/blobstore/strategy/internal/DeleteAllKeysInList.java
index fe8aa4d..fa35bab 100644
--- a/blobstore/src/main/java/org/jclouds/blobstore/strategy/internal/DeleteAllKeysInList.java
+++ b/blobstore/src/main/java/org/jclouds/blobstore/strategy/internal/DeleteAllKeysInList.java
@@ -177,6 +177,25 @@ public class DeleteAllKeysInList implements ClearListStrategy, ClearContainerStr
       return listing;
    }
 
+   private ListenableFuture<Void> deleteDirectory(final ListContainerOptions options,
+         final String containerName, final String dirName) {
+      ListenableFuture<Void> blobDelFuture;
+
+      if (options.isRecursive()) {
+         blobDelFuture = executorService.submit(new Callable<Void>() {
+            @Override
+            public Void call() {
+               blobStore.deleteDirectory(containerName, dirName);
+               return null;
+            }
+         });
+      } else {
+         blobDelFuture = null;
+      }
+
+      return blobDelFuture;
+   }
+
    /**
     * Delete the blobs from a given PageSet. The PageSet may contain blobs or
     * directories. If there are directories, they are expected to be empty.
@@ -235,30 +254,11 @@ public class DeleteAllKeysInList implements ClearListStrategy, ClearContainerStr
             });
             break;
          case FOLDER:
-            if (options.isRecursive()) {
-               blobDelFuture = executorService.submit(new Callable<Void>() {
-                  @Override
-                  public Void call() {
-                     blobStore.deleteDirectory(containerName, fullPath);
-                     return null;
-                  }
-               });
-            } else {
-               blobDelFuture = null;
-            }
+            blobDelFuture = deleteDirectory(options, containerName, fullPath);
             break;
          case RELATIVE_PATH:
-            if (options.isRecursive()) {
-               blobDelFuture = executorService.submit(new Callable<Void>() {
-                  @Override
-                  public Void call() {
-                     blobStore.deleteDirectory(containerName, md.getName());
-                     return null;
-                  }
-               });
-            } else {
-               blobDelFuture = null;
-            }
+            blobDelFuture = deleteDirectory(options, containerName,
+                  md.getName());
             break;
          case CONTAINER:
             throw new IllegalArgumentException("Container type not supported");