@Override
protected Object doExecute() throws Exception {
BlobStore blobStore = getBlobStore();
ListContainerOptions options = ListContainerOptions.Builder.recursive();
if (directoryPath != null) {
options = options.inDirectory(directoryPath);
}
while (true) {
PageSet<? extends StorageMetadata> blobStoreMetadatas = blobStore.list(containerName, options);
List<String> blobNames = Lists.newArrayList();
for (StorageMetadata blobMetadata : blobStoreMetadatas) {
String blobName = blobMetadata.getName();
// do not add to cacheProvider since long lists will cause OutOfMemoryError
blobNames.add(blobName);
}
Collections.sort(blobNames);
for (String blobName : blobNames) {
System.out.println(blobName);
}
String marker = blobStoreMetadatas.getNextMarker();
if (marker == null) {
break;
}
options = options.afterMarker(marker);
}
return null;
}