@Override
public List<BlobInfoDTO> load(String filterStr) throws YaacException {
// step 1 : parse query
String strQuery = "select * from " + Blobstore.BLOB_INFO_KIND + " " + filterStr;
GqlQuery gql = new GqlQuery(strQuery);
Query query = gql.query();
logger.info("loading blobs, filter = " + filterStr);
logger.info("parsed query = " + strQuery);
// step 2 : validate query
for (FilterPredicate filter : query.getFilterPredicates()) {
if (! Blobstore.BLOB_INFO_ALL_PROPERTIES.contains(filter.getPropertyName())) {
throw new YaacException(ErrorCode.E201, null);
}
}
for (SortPredicate sort : query.getSortPredicates()) {
if (! Blobstore.BLOB_INFO_ALL_PROPERTIES.contains(sort.getPropertyName())) {
throw new YaacException(ErrorCode.E201, null);
}
}
// step3 : execute query
AsyncDatastoreService datastore = DatastoreServiceFactory.getAsyncDatastoreService();
Iterable<Entity> entities = datastore.prepare(gql.query()).asIterable(gql.fetchOptions());
List<BlobInfoDTO> result = newLinkedList();
for (Entity e : entities) {
result.add(new BlobInfoDTO(e.getKey().getName(),
(Date) e.getProperty(Blobstore.BLOB_INFO_CREATION),