@Test public void testListContainers() throws Exception { final Path container = new Path("/", EnumSet.of(Path.Type.directory)); final AttributedList<Path> list = new GoogleStorageBucketListService(session).list(container, new DisabledListProgressListener()); assertFalse(list.isEmpty()); }
@Override public AttributedList<Path> list(final Path directory, final ListProgressListener listener) throws BackgroundException { try { final AttributedList<Path> buckets = new AttributedList<Path>(); Buckets response; String page = null; do { response = session.getClient().buckets().list(session.getHost().getCredentials().getUsername()) .setMaxResults(preferences.getLong("googlestorage.listing.chunksize")) .setPageToken(page) .execute(); if(null != response.getItems()) { for(Bucket item : response.getItems()) { final Path bucket = new Path(PathNormalizer.normalize(item.getName()), EnumSet.of(Path.Type.volume, Path.Type.directory), attributes.toAttributes(item) ); buckets.add(bucket); listener.chunk(directory, buckets); } } page = response.getNextPageToken(); } while(page != null); return buckets; } catch(IOException e) { throw new GoogleStorageExceptionMappingService().map("Listing directory {0} failed", e, directory); } }
GoogleStorageBucketListService implements ListService { @Override public AttributedList<Path> list(final Path directory, final ListProgressListener listener) throws BackgroundException { try { final AttributedList<Path> buckets = new AttributedList<Path>(); Buckets response; String page = null; do { response = session.getClient().buckets().list(session.getHost().getCredentials().getUsername()) .setMaxResults(preferences.getLong("googlestorage.listing.chunksize")) .setPageToken(page) .execute(); if(null != response.getItems()) { for(Bucket item : response.getItems()) { final Path bucket = new Path(PathNormalizer.normalize(item.getName()), EnumSet.of(Path.Type.volume, Path.Type.directory), attributes.toAttributes(item) ); buckets.add(bucket); listener.chunk(directory, buckets); } } page = response.getNextPageToken(); } while(page != null); return buckets; } catch(IOException e) { throw new GoogleStorageExceptionMappingService().map("Listing directory {0} failed", e, directory); } } }
GoogleStorageBucketListService implements ListService { @Override public AttributedList<Path> list(final Path directory, final ListProgressListener listener) throws BackgroundException { try { final AttributedList<Path> buckets = new AttributedList<Path>(); Buckets response; String page = null; do { response = session.getClient().buckets().list(session.getHost().getCredentials().getUsername()) .setMaxResults(preferences.getLong("googlestorage.listing.chunksize")) .setPageToken(page) .execute(); if(null != response.getItems()) { for(Bucket item : response.getItems()) { final Path bucket = new Path(PathNormalizer.normalize(item.getName()), EnumSet.of(Path.Type.volume, Path.Type.directory), attributes.toAttributes(item) ); buckets.add(bucket); listener.chunk(directory, buckets); } } page = response.getNextPageToken(); } while(page != null); return buckets; } catch(IOException e) { throw new GoogleStorageExceptionMappingService().map("Listing directory {0} failed", e, directory); } } GoogleStorageBucketListService(final GoogleStorageSession session); }
GoogleStorageBucketListService implements ListService { @Override public AttributedList<Path> list(final Path directory, final ListProgressListener listener) throws BackgroundException { try { final AttributedList<Path> buckets = new AttributedList<Path>(); Buckets response; String page = null; do { response = session.getClient().buckets().list(session.getHost().getCredentials().getUsername()) .setMaxResults(preferences.getLong("googlestorage.listing.chunksize")) .setPageToken(page) .execute(); if(null != response.getItems()) { for(Bucket item : response.getItems()) { final Path bucket = new Path(PathNormalizer.normalize(item.getName()), EnumSet.of(Path.Type.volume, Path.Type.directory), attributes.toAttributes(item) ); buckets.add(bucket); listener.chunk(directory, buckets); } } page = response.getNextPageToken(); } while(page != null); return buckets; } catch(IOException e) { throw new GoogleStorageExceptionMappingService().map("Listing directory {0} failed", e, directory); } } GoogleStorageBucketListService(final GoogleStorageSession session); @Override AttributedList<Path> list(final Path directory, final ListProgressListener listener); }
GoogleStorageBucketListService implements ListService { @Override public AttributedList<Path> list(final Path directory, final ListProgressListener listener) throws BackgroundException { try { final AttributedList<Path> buckets = new AttributedList<Path>(); Buckets response; String page = null; do { response = session.getClient().buckets().list(session.getHost().getCredentials().getUsername()) .setMaxResults(preferences.getLong("googlestorage.listing.chunksize")) .setPageToken(page) .execute(); if(null != response.getItems()) { for(Bucket item : response.getItems()) { final Path bucket = new Path(PathNormalizer.normalize(item.getName()), EnumSet.of(Path.Type.volume, Path.Type.directory), attributes.toAttributes(item) ); buckets.add(bucket); listener.chunk(directory, buckets); } } page = response.getNextPageToken(); } while(page != null); return buckets; } catch(IOException e) { throw new GoogleStorageExceptionMappingService().map("Listing directory {0} failed", e, directory); } } GoogleStorageBucketListService(final GoogleStorageSession session); @Override AttributedList<Path> list(final Path directory, final ListProgressListener listener);  }