use of com.amazonaws.services.cognitosync.model.ListDatasetsRequest in project amazon-cognito-android by aws.
the class CognitoSyncStorage method getDatasets.
/*
* (non-Javadoc)
* @see com.amazonaws.cognitov2.RemoteStorage#listDatasets()
*/
@Override
public List<DatasetMetadata> getDatasets() {
List<DatasetMetadata> datasets = new ArrayList<DatasetMetadata>();
String nextToken = null;
do {
ListDatasetsRequest request = new ListDatasetsRequest();
appendUserAgent(request, userAgent);
request.setIdentityPoolId(identityPoolId);
// a large enough number to reduce # of requests
request.setMaxResults("64");
request.setNextToken(nextToken);
ListDatasetsResult result = null;
try {
request.setIdentityId(getIdentityId());
result = client.listDatasets(request);
} catch (AmazonClientException ace) {
throw handleException(ace, "Failed to list dataset metadata");
}
for (com.amazonaws.services.cognitosync.model.Dataset dataset : result.getDatasets()) {
datasets.add(modelToDatasetMetadata(dataset));
}
nextToken = result.getNextToken();
} while (nextToken != null);
return datasets;
}
Aggregations