Creating a separate function to delete directories

Small refactoring to reuse some code.
This commit is contained in:
Shri Javadekar 2014-04-16 00:06:58 -07:00 committed by Andrew Phillips
parent b2be149946
commit c6cb169dee
1 changed files with 22 additions and 22 deletions

View File

@ -177,6 +177,25 @@ public class DeleteAllKeysInList implements ClearListStrategy, ClearContainerStr
return listing; 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 * Delete the blobs from a given PageSet. The PageSet may contain blobs or
* directories. If there are directories, they are expected to be empty. * directories. If there are directories, they are expected to be empty.
@ -235,30 +254,11 @@ public class DeleteAllKeysInList implements ClearListStrategy, ClearContainerStr
}); });
break; break;
case FOLDER: case FOLDER:
if (options.isRecursive()) { blobDelFuture = deleteDirectory(options, containerName, fullPath);
blobDelFuture = executorService.submit(new Callable<Void>() {
@Override
public Void call() {
blobStore.deleteDirectory(containerName, fullPath);
return null;
}
});
} else {
blobDelFuture = null;
}
break; break;
case RELATIVE_PATH: case RELATIVE_PATH:
if (options.isRecursive()) { blobDelFuture = deleteDirectory(options, containerName,
blobDelFuture = executorService.submit(new Callable<Void>() { md.getName());
@Override
public Void call() {
blobStore.deleteDirectory(containerName, md.getName());
return null;
}
});
} else {
blobDelFuture = null;
}
break; break;
case CONTAINER: case CONTAINER:
throw new IllegalArgumentException("Container type not supported"); throw new IllegalArgumentException("Container type not supported");