Issue 73: support recursive listing on stubs

git-svn-id: http://jclouds.googlecode.com/svn/trunk@2010 3d8758e0-26b5-11de-8745-db77d3ebf521
This commit is contained in:
adrian.f.cole 2009-10-30 20:48:47 +00:00
parent 0cf25a1def
commit 92b7a3ea89
6 changed files with 13 additions and 10 deletions

View File

@ -38,7 +38,7 @@ public class ContainerToBucketListOptions implements Function<ListOptions[], Lis
public ListBucketOptions apply(ListOptions[] optionsList) {
ListBucketOptions httpOptions = new ListBucketOptions();
if (optionsList.length != 0) {
if (!optionsList[0].getRecursive()) {
if (!optionsList[0].isRecursive()) {
httpOptions.delimiter("/");
}
if (optionsList[0].getPath() != null) {

View File

@ -23,11 +23,12 @@
*/
package org.jclouds.blobstore.domain.internal;
import java.util.SortedSet;
import java.util.TreeSet;
import org.jclouds.blobstore.domain.BoundedSortedSet;
import com.google.common.collect.Iterables;
public class BoundedTreeSet<T> extends TreeSet<T> implements BoundedSortedSet<T> {
/** The serialVersionUID */
@ -37,8 +38,9 @@ public class BoundedTreeSet<T> extends TreeSet<T> implements BoundedSortedSet<T>
protected final Integer maxResults;
protected final boolean truncated;
public BoundedTreeSet(SortedSet<T> contents, String path, String marker, Integer maxResults, boolean isTruncated) {
this.addAll(contents);
public BoundedTreeSet(Iterable<T> contents, String path, String marker, Integer maxResults,
boolean isTruncated) {
Iterables.addAll(this, contents);
this.path = path;
this.marker = marker;
this.maxResults = maxResults;

View File

@ -59,7 +59,7 @@ public class ListOptions {
return marker;
}
public boolean getRecursive() {
public boolean isRecursive() {
return recursive;
}
@ -96,7 +96,7 @@ public class ListOptions {
* return a listing of all objects inside the store, recursively.
*/
public ListOptions recursive() {
checkArgument(path == null, "path and recursive combination currently not supported");
// checkArgument(path == null, "path and recursive combination currently not supported");
this.recursive = true;
return this;
}

View File

@ -176,6 +176,7 @@ public class BaseBlobStoreIntegrationTest<S> {
deleteContainer(context, containerName);
} catch (Throwable ex) {
System.err.printf("unable to delete container %s, ignoring...%n", containerName);
ex.printStackTrace();
blackListContainers.add(containerName);
}
}

View File

@ -195,7 +195,7 @@ public class StubBlobStore implements BlobStore {
int maxResults = contents.size();
boolean truncated = false;
String marker = null;
if (options.getMaxResults() != null) {
if (options.getMaxResults() != null && contents.size() > 0) {
SortedSet<ResourceMetadata> contentsSlice = firstSliceOfSize(contents, options
.getMaxResults().intValue());
maxResults = options.getMaxResults();
@ -209,7 +209,7 @@ public class StubBlobStore implements BlobStore {
contents = contentsSlice;
}
final String delimiter = options.getRecursive() ? null : "/";
final String delimiter = options.isRecursive() ? null : "/";
if (delimiter != null) {
SortedSet<String> commonPrefixes = null;
Iterable<String> iterable = Iterables.transform(contents, new CommonPrefixes(

View File

@ -42,13 +42,13 @@ public class ListOptionsTest {
public void testRecursive() {
ListOptions options = new ListOptions();
options.recursive();
assertTrue(options.getRecursive());
assertTrue(options.isRecursive());
}
@Test
public void testRecursiveStatic() {
ListOptions options = recursive();
assertTrue(options.getRecursive());
assertTrue(options.isRecursive());
}
@Test