mirror of https://github.com/apache/jclouds.git
Implement partial prefix support for Atmos
Atmos only supports listing by directories while other blobstores allow listing via arbitrary prefixes. Allow requests which list directories via both prefix and delimiter = "/" to succeed instead of failing all requests. Also change a test which specified recursive to instead be delimiter = "/". Fixes gaul/s3proxy#244.
This commit is contained in:
parent
b95809046a
commit
c61e8bc28b
|
@ -220,8 +220,15 @@ public class AtmosBlobStore extends BaseBlobStore {
|
||||||
@Override
|
@Override
|
||||||
public PageSet<? extends StorageMetadata> list(String container,
|
public PageSet<? extends StorageMetadata> list(String container,
|
||||||
org.jclouds.blobstore.options.ListContainerOptions options) {
|
org.jclouds.blobstore.options.ListContainerOptions options) {
|
||||||
checkArgument(Strings.isNullOrEmpty(options.getPrefix()), "does not support prefixes");
|
// TODO: recursive?
|
||||||
|
if (!Strings.nullToEmpty(options.getDelimiter()).equals("/") && !Strings.isNullOrEmpty(options.getPrefix())) {
|
||||||
|
throw new IllegalArgumentException("Atmos can only list via prefix if delimiter is / and the prefix matches an existing directory");
|
||||||
|
}
|
||||||
container = AtmosUtils.adjustContainerIfDirOptionPresent(container, options);
|
container = AtmosUtils.adjustContainerIfDirOptionPresent(container, options);
|
||||||
|
if (!Strings.isNullOrEmpty(options.getPrefix())) {
|
||||||
|
// this only works when the prefix exactly matches a directory, the common usage
|
||||||
|
container += "/" + options.getPrefix();
|
||||||
|
}
|
||||||
ListOptions nativeOptions = container2ContainerListOptions.apply(options);
|
ListOptions nativeOptions = container2ContainerListOptions.apply(options);
|
||||||
// until includeMeta() option works for namespace interface
|
// until includeMeta() option works for namespace interface
|
||||||
PageSet<? extends StorageMetadata> list = container2ResourceList.apply(sync.listDirectory(container,
|
PageSet<? extends StorageMetadata> list = container2ResourceList.apply(sync.listDirectory(container,
|
||||||
|
|
|
@ -58,16 +58,11 @@ public class AtmosContainerIntegrationLiveTest extends BaseContainerIntegrationT
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void testContainerListWithPrefix() {
|
public void testContainerListWithPrefix() {
|
||||||
throw new SkipException("Prefix option has not been plumbed down to Atmos");
|
throw new SkipException("Atmos can only list prefix which matches an existing directory");
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void testDelimiterList() {
|
public void testDelimiterList() {
|
||||||
throw new SkipException("Delimiter support is not yet implemented");
|
throw new SkipException("Delimiter support is not yet implemented");
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
public void testListContainerPrefix() throws InterruptedException {
|
|
||||||
throw new SkipException("Prefix support is not yet implemented");
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -310,7 +310,7 @@ public class BaseContainerIntegrationTest extends BaseBlobStoreIntegrationTest {
|
||||||
add15UnderRoot(containerName);
|
add15UnderRoot(containerName);
|
||||||
awaitConsistency();
|
awaitConsistency();
|
||||||
PageSet<? extends StorageMetadata> container = view.getBlobStore().list(
|
PageSet<? extends StorageMetadata> container = view.getBlobStore().list(
|
||||||
containerName, new ListContainerOptions().recursive().prefix(prefix));
|
containerName, new ListContainerOptions().prefix(prefix).delimiter("/"));
|
||||||
assert container.getNextMarker() == null;
|
assert container.getNextMarker() == null;
|
||||||
assertEquals(container.size(), 10);
|
assertEquals(container.size(), 10);
|
||||||
} finally {
|
} finally {
|
||||||
|
|
Loading…
Reference in New Issue