use of org.openstack4j.model.image.DiskFormat in project camel by apache.
the class GlanceProducer method messageHeadersToImage.
private Image messageHeadersToImage(Message message, boolean required) {
ImageBuilder imageBuilder = null;
if (required && ObjectHelper.isEmpty(message.getHeader(OpenstackConstants.NAME, String.class))) {
throw new IllegalArgumentException("Image Name must be specified and not empty");
}
if (ObjectHelper.isNotEmpty(message.getHeader(OpenstackConstants.NAME, String.class))) {
imageBuilder = getImageBuilder(imageBuilder).name(message.getHeader(OpenstackConstants.NAME, String.class));
}
if (ObjectHelper.isNotEmpty(message.getHeader(GlanceConstants.DISK_FORMAT, DiskFormat.class))) {
imageBuilder = getImageBuilder(imageBuilder).diskFormat(message.getHeader(GlanceConstants.DISK_FORMAT, DiskFormat.class));
}
if (ObjectHelper.isNotEmpty(message.getHeader(GlanceConstants.CONTAINER_FORMAT, ContainerFormat.class))) {
imageBuilder = getImageBuilder(imageBuilder).containerFormat(message.getHeader(GlanceConstants.CONTAINER_FORMAT, ContainerFormat.class));
}
if (ObjectHelper.isNotEmpty(message.getHeader(GlanceConstants.SIZE, Long.class))) {
imageBuilder = getImageBuilder(imageBuilder).size(message.getHeader(GlanceConstants.SIZE, Long.class));
}
if (ObjectHelper.isNotEmpty(message.getHeader(GlanceConstants.CHECKSUM))) {
imageBuilder = getImageBuilder(imageBuilder).checksum(message.getHeader(GlanceConstants.CHECKSUM, String.class));
}
if (ObjectHelper.isNotEmpty(message.getHeader(GlanceConstants.MIN_DISK))) {
imageBuilder = getImageBuilder(imageBuilder).minDisk(message.getHeader(GlanceConstants.MIN_DISK, Long.class));
}
if (ObjectHelper.isNotEmpty(message.getHeader(GlanceConstants.MIN_RAM))) {
imageBuilder = getImageBuilder(imageBuilder).minRam(message.getHeader(GlanceConstants.MIN_RAM, Long.class));
}
if (ObjectHelper.isNotEmpty(message.getHeader(GlanceConstants.OWNER))) {
imageBuilder = getImageBuilder(imageBuilder).owner(message.getHeader(GlanceConstants.OWNER, String.class));
}
if (ObjectHelper.isNotEmpty(message.getHeader(GlanceConstants.IS_PUBLIC))) {
imageBuilder = getImageBuilder(imageBuilder).isPublic(message.getHeader(GlanceConstants.IS_PUBLIC, Boolean.class));
}
if (ObjectHelper.isNotEmpty(message.getHeader(OpenstackConstants.PROPERTIES))) {
imageBuilder = getImageBuilder(imageBuilder).properties(message.getHeader(OpenstackConstants.PROPERTIES, Map.class));
}
if (!required && imageBuilder == null) {
return null;
}
ObjectHelper.notNull(imageBuilder, "Image");
return imageBuilder.build();
}
Aggregations