Search in sources :

Example 1 with ConversionException

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;
}
Also used : ConversionException(com.sequenceiq.cloudbreak.converter.ConversionException) CustomImageCatalogV4GetImageResponse(com.sequenceiq.cloudbreak.api.endpoint.v4.customimage.response.CustomImageCatalogV4GetImageResponse) CustomImage(com.sequenceiq.cloudbreak.domain.CustomImage) VmImage(com.sequenceiq.cloudbreak.domain.VmImage) Image(com.sequenceiq.cloudbreak.cloud.model.catalog.Image) ConversionException(com.sequenceiq.cloudbreak.converter.ConversionException)

Example 2 with ConversionException

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;
}
Also used : ConversionException(com.sequenceiq.cloudbreak.converter.ConversionException) CustomImageCatalogV4ImageListItemResponse(com.sequenceiq.cloudbreak.api.endpoint.v4.customimage.response.CustomImageCatalogV4ImageListItemResponse) CustomImage(com.sequenceiq.cloudbreak.domain.CustomImage) Image(com.sequenceiq.cloudbreak.cloud.model.catalog.Image) ConversionException(com.sequenceiq.cloudbreak.converter.ConversionException)

Aggregations

Image (com.sequenceiq.cloudbreak.cloud.model.catalog.Image)2 ConversionException (com.sequenceiq.cloudbreak.converter.ConversionException)2 CustomImage (com.sequenceiq.cloudbreak.domain.CustomImage)2 CustomImageCatalogV4GetImageResponse (com.sequenceiq.cloudbreak.api.endpoint.v4.customimage.response.CustomImageCatalogV4GetImageResponse)1 CustomImageCatalogV4ImageListItemResponse (com.sequenceiq.cloudbreak.api.endpoint.v4.customimage.response.CustomImageCatalogV4ImageListItemResponse)1 VmImage (com.sequenceiq.cloudbreak.domain.VmImage)1