private void listRequests( @Nonnull String bucket, @Nonnull Jiterator<OfflineStoreRequest> iterator) throws CloudException, InternalException { APITrace.begin(getProvider(), "Blob.listRequests"); try { boolean needQuery = true; String marker = null; Map<String, String> queryParameters = new HashMap<String, String>(1); // glacier can paginate results. it returns a "marker" string in the JSON response // which indicates you should make another query. The marker string should be passed // as a query parameter in the next query. while (needQuery) { if (marker != null) { queryParameters.put("marker", marker); } GlacierMethod method = GlacierMethod.build(getProvider(), GlacierAction.LIST_JOBS) .vaultId(bucket) .queryParameters(queryParameters) .toMethod(); final JSONObject jsonObject = method.invokeJson(); try { JSONArray vaultList = jsonObject.getJSONArray("JobList"); for (int i = 0; i < vaultList.length(); i++) { iterator.push(loadRequestJson(vaultList.getJSONObject(i), bucket)); } marker = getPaginationMarker(jsonObject); if (marker == null) { needQuery = false; } } catch (JSONException e) { throw new CloudException(e); } } } finally { APITrace.end(); } }
private void loadVaults(@Nonnull String regionId, @Nonnull Jiterator<Blob> iterator) throws CloudException, InternalException { boolean needQuery = true; String marker = null; Map<String, String> queryParameters = new HashMap<String, String>(1); // glacier can paginate results. it returns a "marker" string in the JSON response // which indicates you should make another query. The marker string should be passed // as a query parameter in the next query. while (needQuery) { if (marker != null) { queryParameters.put("marker", marker); } GlacierMethod method = GlacierMethod.build(getProvider(), GlacierAction.LIST_VAULTS) .queryParameters(queryParameters) .toMethod(); String baseUrl = method.getUrl(); JSONObject jsonObject = method.invokeJson(); try { JSONArray vaultList = jsonObject.getJSONArray("VaultList"); for (int i = 0; i < vaultList.length(); i++) { iterator.push(loadVaultJson(vaultList.getJSONObject(i), regionId, baseUrl)); } marker = getPaginationMarker(jsonObject); if (marker == null) { needQuery = false; } } catch (JSONException e) { throw new CloudException(e); } } }