|
19 | 19 | import org.elasticsearch.common.Nullable; |
20 | 20 | import org.elasticsearch.common.blobstore.BlobMetaData; |
21 | 21 | import org.elasticsearch.common.blobstore.BlobPath; |
| 22 | +import org.elasticsearch.common.blobstore.BlobContainer; |
22 | 23 | import org.elasticsearch.common.blobstore.DeleteResult; |
23 | 24 | import org.elasticsearch.common.blobstore.support.AbstractBlobContainer; |
24 | 25 | import org.elasticsearch.common.blobstore.support.PlainBlobMetaData; |
@@ -154,6 +155,31 @@ public Map<String, BlobMetaData> listBlobsByPrefix(@Nullable final String blobNa |
154 | 155 | }); |
155 | 156 | } |
156 | 157 |
|
| 158 | + @Override |
| 159 | + public Map<String, BlobContainer> children() throws IOException { |
| 160 | + return SwiftPerms.exec(() -> { |
| 161 | + MapBuilder<String, BlobContainer> blobContainerBuilder = MapBuilder.newMapBuilder(); |
| 162 | + String path = path().buildAsString(); |
| 163 | + Collection<DirectoryOrObject> files = blobStore.swift().listDirectory(new Directory(path, '/')); |
| 164 | + |
| 165 | + if (files != null && !files.isEmpty()) { |
| 166 | + for (DirectoryOrObject directory : files) { |
| 167 | + String name = directory.getName(); |
| 168 | + String indexKey = name.substring(keyPath.length(), name.length() - 1); |
| 169 | + |
| 170 | + if (! blobContainerBuilder.containsKey(indexKey)) { |
| 171 | + BlobPath p = new BlobPath(); |
| 172 | + p = p.add(directory.getName()); |
| 173 | + blobContainerBuilder.put(indexKey, new SwiftBlobContainer(p, blobStore)); |
| 174 | + } |
| 175 | + |
| 176 | + } |
| 177 | + } |
| 178 | + |
| 179 | + return blobContainerBuilder.immutableMap(); |
| 180 | + }); |
| 181 | + } |
| 182 | + |
157 | 183 | /** |
158 | 184 | * Get all the blobs |
159 | 185 | */ |
|
0 commit comments