use of org.openstack4j.model.network.builder.NetworkBuilder in project camel by apache.
the class NetworkProducer method messageToNetwork.
private Network messageToNetwork(Message message) {
Network network = message.getBody(Network.class);
if (network == null) {
Map headers = message.getHeaders();
NetworkBuilder builder = Builders.network();
ObjectHelper.notEmpty(message.getHeader(OpenstackConstants.NAME, String.class), "Name");
builder.name(message.getHeader(OpenstackConstants.NAME, String.class));
if (headers.containsKey(NeutronConstants.ADMIN_STATE_UP)) {
builder.adminStateUp(message.getHeader(NeutronConstants.ADMIN_STATE_UP, Boolean.class));
}
if (headers.containsKey(NeutronConstants.NETWORK_TYPE)) {
builder.networkType(message.getHeader(NeutronConstants.NETWORK_TYPE, NetworkType.class));
}
if (headers.containsKey(NeutronConstants.IS_SHARED)) {
builder.isShared(message.getHeader(NeutronConstants.IS_SHARED, Boolean.class));
}
if (headers.containsKey(NeutronConstants.IS_ROUTER_EXTERNAL)) {
builder.isRouterExternal(message.getHeader(NeutronConstants.IS_ROUTER_EXTERNAL, Boolean.class));
}
if (headers.containsKey(NeutronConstants.TENANT_ID)) {
builder.tenantId(message.getHeader(NeutronConstants.TENANT_ID, String.class));
}
if (headers.containsKey(NeutronConstants.PHYSICAL_NETWORK)) {
builder.physicalNetwork(message.getHeader(NeutronConstants.PHYSICAL_NETWORK, String.class));
}
if (headers.containsKey(NeutronConstants.SEGMENT_ID)) {
builder.segmentId(message.getHeader(NeutronConstants.SEGMENT_ID, String.class));
}
network = builder.build();
}
return network;
}
Aggregations