private Iterator<String> createIterator() throws Exception { if (listObjectsSrvcHandle == null) initListing(); List<String> temp = Lists.newArrayList(); // a container of results // Sends the metadata request to the server and returns the parsed metadata response. this.objectsContainerHandle = listObjectsSrvcHandle.execute(); for (StorageObject object : this.objectsContainerHandle.getItems()) { // processing a page of results temp.add(object.getName()); } return temp.iterator(); }
Objects objects; do { objects = listObjects.execute(); List<StorageObject> items = objects.getItems(); if (items != null) {
/** {@inheritDoc} */ @Override public Collection<InetSocketAddress> getRegisteredAddresses() throws IgniteSpiException { init(); Collection<InetSocketAddress> addrs = new ArrayList<>(); try { Storage.Objects.List listObjects = storage.objects().list(bucketName); com.google.api.services.storage.model.Objects objects; do { objects = listObjects.execute(); if (objects == null || objects.getItems() == null) break; for (StorageObject object : objects.getItems()) addrs.add(addrFromString(object.getName())); listObjects.setPageToken(objects.getNextPageToken()); } while (null != objects.getNextPageToken()); } catch (Exception e) { throw new IgniteSpiException("Failed to get content from the bucket: " + bucketName, e); } return addrs; }
items = listObject.execute(); } catch (IOException e) { String resource =
when(mockStorageGet.execute()) .thenReturn(new StorageObject().setBucket("testbucket").setName("testdirectory/otherfile")); when(mockStorageList.execute()).thenReturn(modelObjects);
.thenReturn( new StorageObject().setBucket("testbucket").setName("test/directory/otherfile")); when(mockStorageList.execute()).thenReturn(modelObjects);
.setFields(Option.FIELDS.getString(options)) .setUserProject(Option.USER_PROJECT.getString(options)) .execute(); Iterable<StorageObject> storageObjects = Iterables.concat(
objects = listMethod.execute(); List<StorageObject> items = objects.getItems(); if (items != null) {
listObjects.setMaxResults(maxResults); do { Objects objects = listObjects.execute(); List<StorageObject> items = objects.getItems();
/** * Lists the objects in a bucket * * @param bucketName bucket name to list * @return Array of object names * @throws Exception */ public static List<String> listBucket(String bucketName) throws Exception { Storage storage = getStorage(); List<String> list = new ArrayList<String>(); List<StorageObject> objects = storage.objects().list(bucketName).execute().getItems(); if(objects != null) { for(StorageObject o : objects) { list.add(o.getName()); } } return list; }
objects = objectsList.execute(); List<StorageObject> items = objects.getItems();
/** * Fetch a list of the objects within the given bucket. * * @param bucketName the name of the bucket to list. * @return a list of the contents of the specified bucket. */ public static List<StorageObject> listBucket(String bucketName) throws IOException, GeneralSecurityException { Storage client = StorageFactory.getService(); Storage.Objects.List listRequest = client.objects().list(bucketName); List<StorageObject> results = new ArrayList<StorageObject>(); Objects objects; // Iterate through each page of results, and add them to our results list. do { objects = listRequest.execute(); // Add the items in this page of results to the list we'll return. results.addAll(objects.getItems()); // Get the next page, in the next iteration of this loop. listRequest.setPageToken(objects.getNextPageToken()); } while (null != objects.getNextPageToken()); return results; } // [END list_bucket]
public static Iterable<StorageObject> list(Storage storage, String bucketName) throws IOException { List<List<StorageObject>> pagedList = Lists.newArrayList(); Storage.Objects.List listObjects = storage.objects().list(bucketName); Objects objects; do { objects = listObjects.execute(); List<StorageObject> items = objects.getItems(); if (items != null) { pagedList.add(objects.getItems()); } listObjects.setPageToken(objects.getNextPageToken()); } while (objects.getNextPageToken() != null); return Iterables.concat(pagedList); }
private StorageObject resolveSingularItem(ObjectType objectType, String objectKey, GoogleNamedAccountCredentials credentials, Storage storage, String bucketName) { String rootFolder = daoRoot(credentials, objectType.getGroup()) + "/" + objectKey; try { Storage.Objects.List objectsList = storage.objects().list(bucketName).setPrefix(rootFolder); Objects objects = objectsList.execute(); List<StorageObject> items = objects.getItems(); if (items != null && items.size() == 1) { return items.get(0); } else { throw new IllegalArgumentException("Unable to resolve singular " + objectType + " at " + daoRoot(credentials, objectType.getGroup()) + '/' + objectKey + "."); } } catch (IOException e) { throw new IllegalArgumentException("Could not fetch items from Google Cloud Storage: " + e.getMessage(), e); } }
.setFields(Option.FIELDS.getString(options)) .setUserProject(Option.USER_PROJECT.getString(options)) .execute(); Iterable<StorageObject> storageObjects = Iterables.concat(