mirror of https://github.com/apache/jclouds.git
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:
parent
0cf25a1def
commit
92b7a3ea89
|
@ -38,7 +38,7 @@ public class ContainerToBucketListOptions implements Function<ListOptions[], Lis
|
||||||
public ListBucketOptions apply(ListOptions[] optionsList) {
|
public ListBucketOptions apply(ListOptions[] optionsList) {
|
||||||
ListBucketOptions httpOptions = new ListBucketOptions();
|
ListBucketOptions httpOptions = new ListBucketOptions();
|
||||||
if (optionsList.length != 0) {
|
if (optionsList.length != 0) {
|
||||||
if (!optionsList[0].getRecursive()) {
|
if (!optionsList[0].isRecursive()) {
|
||||||
httpOptions.delimiter("/");
|
httpOptions.delimiter("/");
|
||||||
}
|
}
|
||||||
if (optionsList[0].getPath() != null) {
|
if (optionsList[0].getPath() != null) {
|
||||||
|
|
|
@ -23,11 +23,12 @@
|
||||||
*/
|
*/
|
||||||
package org.jclouds.blobstore.domain.internal;
|
package org.jclouds.blobstore.domain.internal;
|
||||||
|
|
||||||
import java.util.SortedSet;
|
|
||||||
import java.util.TreeSet;
|
import java.util.TreeSet;
|
||||||
|
|
||||||
import org.jclouds.blobstore.domain.BoundedSortedSet;
|
import org.jclouds.blobstore.domain.BoundedSortedSet;
|
||||||
|
|
||||||
|
import com.google.common.collect.Iterables;
|
||||||
|
|
||||||
public class BoundedTreeSet<T> extends TreeSet<T> implements BoundedSortedSet<T> {
|
public class BoundedTreeSet<T> extends TreeSet<T> implements BoundedSortedSet<T> {
|
||||||
|
|
||||||
/** The serialVersionUID */
|
/** The serialVersionUID */
|
||||||
|
@ -37,8 +38,9 @@ public class BoundedTreeSet<T> extends TreeSet<T> implements BoundedSortedSet<T>
|
||||||
protected final Integer maxResults;
|
protected final Integer maxResults;
|
||||||
protected final boolean truncated;
|
protected final boolean truncated;
|
||||||
|
|
||||||
public BoundedTreeSet(SortedSet<T> contents, String path, String marker, Integer maxResults, boolean isTruncated) {
|
public BoundedTreeSet(Iterable<T> contents, String path, String marker, Integer maxResults,
|
||||||
this.addAll(contents);
|
boolean isTruncated) {
|
||||||
|
Iterables.addAll(this, contents);
|
||||||
this.path = path;
|
this.path = path;
|
||||||
this.marker = marker;
|
this.marker = marker;
|
||||||
this.maxResults = maxResults;
|
this.maxResults = maxResults;
|
||||||
|
|
|
@ -59,7 +59,7 @@ public class ListOptions {
|
||||||
return marker;
|
return marker;
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean getRecursive() {
|
public boolean isRecursive() {
|
||||||
return recursive;
|
return recursive;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -96,7 +96,7 @@ public class ListOptions {
|
||||||
* return a listing of all objects inside the store, recursively.
|
* return a listing of all objects inside the store, recursively.
|
||||||
*/
|
*/
|
||||||
public ListOptions recursive() {
|
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;
|
this.recursive = true;
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
|
|
@ -176,6 +176,7 @@ public class BaseBlobStoreIntegrationTest<S> {
|
||||||
deleteContainer(context, containerName);
|
deleteContainer(context, containerName);
|
||||||
} catch (Throwable ex) {
|
} catch (Throwable ex) {
|
||||||
System.err.printf("unable to delete container %s, ignoring...%n", containerName);
|
System.err.printf("unable to delete container %s, ignoring...%n", containerName);
|
||||||
|
ex.printStackTrace();
|
||||||
blackListContainers.add(containerName);
|
blackListContainers.add(containerName);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -195,7 +195,7 @@ public class StubBlobStore implements BlobStore {
|
||||||
int maxResults = contents.size();
|
int maxResults = contents.size();
|
||||||
boolean truncated = false;
|
boolean truncated = false;
|
||||||
String marker = null;
|
String marker = null;
|
||||||
if (options.getMaxResults() != null) {
|
if (options.getMaxResults() != null && contents.size() > 0) {
|
||||||
SortedSet<ResourceMetadata> contentsSlice = firstSliceOfSize(contents, options
|
SortedSet<ResourceMetadata> contentsSlice = firstSliceOfSize(contents, options
|
||||||
.getMaxResults().intValue());
|
.getMaxResults().intValue());
|
||||||
maxResults = options.getMaxResults();
|
maxResults = options.getMaxResults();
|
||||||
|
@ -209,7 +209,7 @@ public class StubBlobStore implements BlobStore {
|
||||||
contents = contentsSlice;
|
contents = contentsSlice;
|
||||||
}
|
}
|
||||||
|
|
||||||
final String delimiter = options.getRecursive() ? null : "/";
|
final String delimiter = options.isRecursive() ? null : "/";
|
||||||
if (delimiter != null) {
|
if (delimiter != null) {
|
||||||
SortedSet<String> commonPrefixes = null;
|
SortedSet<String> commonPrefixes = null;
|
||||||
Iterable<String> iterable = Iterables.transform(contents, new CommonPrefixes(
|
Iterable<String> iterable = Iterables.transform(contents, new CommonPrefixes(
|
||||||
|
|
|
@ -42,13 +42,13 @@ public class ListOptionsTest {
|
||||||
public void testRecursive() {
|
public void testRecursive() {
|
||||||
ListOptions options = new ListOptions();
|
ListOptions options = new ListOptions();
|
||||||
options.recursive();
|
options.recursive();
|
||||||
assertTrue(options.getRecursive());
|
assertTrue(options.isRecursive());
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testRecursiveStatic() {
|
public void testRecursiveStatic() {
|
||||||
ListOptions options = recursive();
|
ListOptions options = recursive();
|
||||||
assertTrue(options.getRecursive());
|
assertTrue(options.isRecursive());
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
|
|
Loading…
Reference in New Issue