private Image buildImage() throws Exception, CloudException {
ImageImports.Metadata metadata = imageImports.getImageMetadata(imageUrl);
List<Image> images = imageService.listImages(project);
Image image = null;
for (Image i : images) {
String imageChecksum = i.getChecksum();
if (imageChecksum.equalsIgnoreCase(metadata.getChecksum())) {
image = i;
break;
}
}
if (image == null) {
log.info("Importing image from: {}", imageUrl);
image = imageImports.importImage(project.getId(), imageUrl);
} else {
log.info("Found image: {}", image.getName());
}
return image;
}