if (results.isEmpty())
return;
List<String> paths = new ArrayList<String>();
InvalidationBatch batch = new InvalidationBatch("invalidate-" + d.id);
CreateInvalidationRequest invalidationRequest = new CreateInvalidationRequest()
.withDistributionId(d.id).withInvalidationBatch(batch);
for (Map.Entry<String, PutObjectRequest> entry : results.entrySet()) {
String key = entry.getKey();
PutObjectRequest request = entry.getValue();
if (null != request && request.getBucketName().equals(d.s3Bucket)) {
paths.add("/" + request.getKey());
} else {
paths.add("/" + key);
}
}
if (!paths.isEmpty()) {
batch.setPaths(new Paths().withItems(paths));
invalidationRequest.withInvalidationBatch(batch);
getService().createInvalidation(invalidationRequest);
} else {