use of com.sequenceiq.cloudbreak.converter.ConversionException in project cloudbreak by hortonworks.
the class CustomImageToCustomImageCatalogV4GetImageResponseConverter method convert.
public CustomImageCatalogV4GetImageResponse convert(CustomImage source) {
CustomImageCatalogV4GetImageResponse result = new CustomImageCatalogV4GetImageResponse();
result.setImageId(source.getName());
result.setImageType(source.getImageType() != null ? source.getImageType().name() : null);
result.setSourceImageId(source.getCustomizedImageId());
result.setBaseParcelUrl(source.getBaseParcelUrl());
result.setVmImages(getVmImages(source.getVmImage()));
result.setImageDate(source.getCreated());
try {
Image image = imageCatalogService.getSourceImageByImageType(source).getImage();
result.setSourceImageDate(image.getCreated());
result.setVersions(imageVersionsConverter.convert(image));
result.setCloudProvider(image.getImageSetsByProvider().keySet().stream().findFirst().orElse(null));
} catch (Exception ex) {
throw new ConversionException(ex.getMessage());
}
return result;
}
use of com.sequenceiq.cloudbreak.converter.ConversionException in project cloudbreak by hortonworks.
the class ImageCatalogToCustomImageCatalogV4GetResponseConverter method getImage.
private CustomImageCatalogV4ImageListItemResponse getImage(CustomImage source) {
CustomImageCatalogV4ImageListItemResponse result = new CustomImageCatalogV4ImageListItemResponse();
result.setImageId(source.getName());
result.setImageType(source.getImageType() != null ? source.getImageType().name() : null);
result.setSourceImageId(source.getCustomizedImageId());
result.setImageDate(source.getCreated());
try {
Image image = imageCatalogService.getSourceImageByImageType(source).getImage();
result.setSourceImageDate(image.getCreated());
result.setVersions(imageVersionsConverter.convert(image));
result.setCloudProvider(image.getImageSetsByProvider().keySet().stream().findFirst().orElse(null));
} catch (Exception ex) {
throw new ConversionException(ex.getMessage());
}
return result;
}
Aggregations