use of ch.cyberduck.core.brick.io.swagger.client.api.FoldersApi in project cyberduck by iterate-ch.
the class BrickListService method list.
public AttributedList<Path> list(final Path directory, final ListProgressListener listener, final int chunksize) throws BackgroundException {
try {
final AttributedList<Path> children = new AttributedList<>();
String cursor = null;
List<FileEntity> response;
final BrickApiClient client = new BrickApiClient(session);
do {
response = new FoldersApi(client).foldersListForPath(StringUtils.removeStart(directory.getAbsolute(), String.valueOf(Path.DELIMITER)), cursor, chunksize, null, null, null, null, null, null);
for (FileEntity entity : response) {
children.add(new Path(entity.getPath(), EnumSet.of("directory".equals(entity.getType()) ? Path.Type.directory : Path.Type.file), attributes.toAttributes(entity)));
}
if (client.getResponseHeaders().containsKey("X-Files-Cursor")) {
final Optional<String> header = client.getResponseHeaders().get("X-Files-Cursor").stream().findFirst();
cursor = header.orElse(null);
} else {
cursor = null;
}
listener.chunk(directory, children);
} while (cursor != null);
return children;
} catch (ApiException e) {
throw new BrickExceptionMappingService().map("Listing directory {0} failed", e, directory);
}
}
Aggregations