use of org.openstack4j.model.storage.block.builder.VolumeBuilder in project camel by apache.
the class VolumeProducer method messageToVolume.
private Volume messageToVolume(Message message) {
Volume volume = message.getBody(Volume.class);
if (volume == null) {
Map headers = message.getHeaders();
VolumeBuilder builder = Builders.volume();
final String name = message.getHeader(OpenstackConstants.NAME, String.class);
ObjectHelper.notEmpty(name, "Name ");
builder.name(name);
if (headers.containsKey(OpenstackConstants.DESCRIPTION)) {
builder.description(message.getHeader(OpenstackConstants.DESCRIPTION, String.class));
}
if (headers.containsKey(CinderConstants.SIZE)) {
builder.size(message.getHeader(CinderConstants.SIZE, Integer.class));
}
if (headers.containsKey(CinderConstants.VOLUME_TYPE)) {
builder.volumeType(message.getHeader(CinderConstants.VOLUME_TYPE, String.class));
}
if (headers.containsKey(CinderConstants.IMAGE_REF)) {
builder.imageRef(message.getHeader(CinderConstants.IMAGE_REF, String.class));
}
if (headers.containsKey(CinderConstants.SNAPSHOT_ID)) {
builder.snapshot(message.getHeader(CinderConstants.SNAPSHOT_ID, String.class));
}
if (headers.containsKey(CinderConstants.IS_BOOTABLE)) {
builder.bootable(message.getHeader(CinderConstants.IS_BOOTABLE, Boolean.class));
}
volume = builder.build();
}
return volume;
}
Aggregations