Fix the maven build problem caused by incorrect protobuf model #2

Change-Id: I8a1260d486c99569386ff27fbeac48dfc222fb4b
diff --git a/incubator/rpc-grpc/src/main/java/org/onosproject/incubator/rpc/grpc/DeviceProviderServiceClientProxy.java b/incubator/rpc-grpc/src/main/java/org/onosproject/incubator/rpc/grpc/DeviceProviderServiceClientProxy.java
index d11a834..5438c67 100644
--- a/incubator/rpc-grpc/src/main/java/org/onosproject/incubator/rpc/grpc/DeviceProviderServiceClientProxy.java
+++ b/incubator/rpc-grpc/src/main/java/org/onosproject/incubator/rpc/grpc/DeviceProviderServiceClientProxy.java
@@ -17,7 +17,6 @@
 
 import static com.google.common.base.Preconditions.checkNotNull;
 import static java.util.stream.Collectors.toList;
-import static org.onosproject.incubator.protobuf.models.ProtobufUtils.translate;
 import static org.onosproject.net.DeviceId.deviceId;
 
 import java.util.Collection;
@@ -33,7 +32,6 @@
 import org.onosproject.grpc.net.device.DeviceService.TriggerProbe;
 import org.onosproject.grpc.net.device.models.PortDescriptionProtoOuterClass.PortDescriptionProto;
 import org.onosproject.grpc.net.device.models.PortStatisticsProtoOuterClass.PortStatisticsProto;
-import org.onosproject.incubator.protobuf.models.ProtobufUtils;
 import org.onosproject.net.DeviceId;
 import org.onosproject.net.MastershipRole;
 import org.onosproject.net.device.DeviceDescription;
@@ -42,6 +40,10 @@
 import org.onosproject.net.device.PortDescription;
 import org.onosproject.net.device.PortStatistics;
 import org.onosproject.net.provider.AbstractProviderService;
+import org.onosproject.incubator.protobuf.models.net.device.DeviceProtoTranslator;
+import org.onosproject.incubator.protobuf.models.net.device.PortProtoTranslator;
+import org.onosproject.incubator.protobuf.models.net.MastershipRoleProtoTranslator;
+
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
@@ -93,7 +95,7 @@
         DeviceProviderServiceMsg.Builder builder = DeviceProviderServiceMsg.newBuilder();
         builder.setDeviceConnected(builder.getDeviceConnectedBuilder()
                                       .setDeviceId(deviceId.toString())
-                                      .setDeviceDescription(translate(deviceDescription))
+                                      .setDeviceDescription(DeviceProtoTranslator.translate(deviceDescription))
                                       .build());
 
         devProvService.onNext(builder.build());
@@ -119,7 +121,7 @@
         DeviceProviderServiceMsg.Builder builder = DeviceProviderServiceMsg.newBuilder();
         List<PortDescriptionProto> portDescs =
                 portDescriptions.stream()
-                    .map(ProtobufUtils::translate)
+                    .map(PortProtoTranslator::translate)
                     .collect(toList());
 
         builder.setUpdatePorts(builder.getUpdatePortsBuilder()
@@ -143,7 +145,7 @@
         DeviceProviderServiceMsg.Builder builder = DeviceProviderServiceMsg.newBuilder();
         builder.setPortStatusChanged(builder.getPortStatusChangedBuilder()
                                       .setDeviceId(deviceId.toString())
-                                      .setPortDescription(translate(portDescription))
+                                      .setPortDescription(PortProtoTranslator.translate(portDescription))
                                       .build());
 
         devProvService.onNext(builder.build());
@@ -157,8 +159,8 @@
         DeviceProviderServiceMsg.Builder builder = DeviceProviderServiceMsg.newBuilder();
         builder.setReceivedRoleReply(builder.getReceivedRoleReplyBuilder()
                                       .setDeviceId(deviceId.toString())
-                                      .setRequested(translate(requested))
-                                      .setResponse(translate(response))
+                                      .setRequested(MastershipRoleProtoTranslator.translate(requested))
+                                      .setResponse(MastershipRoleProtoTranslator.translate(response))
                                       .build());
 
         devProvService.onNext(builder.build());
@@ -172,7 +174,7 @@
         DeviceProviderServiceMsg.Builder builder = DeviceProviderServiceMsg.newBuilder();
         List<PortStatisticsProto> portStats =
                 portStatistics.stream()
-                    .map(ProtobufUtils::translate)
+                    .map(PortProtoTranslator::translate)
                     .collect(toList());
         builder.setUpdatePortStatistics(builder.getUpdatePortStatisticsBuilder()
                                       .setDeviceId(deviceId.toString())
@@ -271,7 +273,7 @@
             case ROLE_CHANGED:
                 RoleChanged roleChanged = msg.getRoleChanged();
                 provider.roleChanged(deviceId(roleChanged.getDeviceId()),
-                                     translate(roleChanged.getNewRole()));
+                        (MastershipRole) MastershipRoleProtoTranslator.translate(roleChanged.getNewRole()).get());
                 break;
             case IS_REACHABLE_REQUEST:
                 IsReachableRequest isReachableRequest = msg.getIsReachableRequest();
diff --git a/incubator/rpc-grpc/src/main/java/org/onosproject/incubator/rpc/grpc/GrpcRemoteServiceServer.java b/incubator/rpc-grpc/src/main/java/org/onosproject/incubator/rpc/grpc/GrpcRemoteServiceServer.java
index 270fed2..e7ca04b 100644
--- a/incubator/rpc-grpc/src/main/java/org/onosproject/incubator/rpc/grpc/GrpcRemoteServiceServer.java
+++ b/incubator/rpc-grpc/src/main/java/org/onosproject/incubator/rpc/grpc/GrpcRemoteServiceServer.java
@@ -18,7 +18,9 @@
 import static com.google.common.base.Preconditions.checkNotNull;
 import static java.util.concurrent.Executors.newScheduledThreadPool;
 import static java.util.stream.Collectors.toList;
-import static org.onosproject.incubator.protobuf.models.ProtobufUtils.translate;
+import org.onosproject.incubator.protobuf.models.net.device.DeviceProtoTranslator;
+import org.onosproject.incubator.protobuf.models.net.device.PortProtoTranslator;
+import org.onosproject.incubator.protobuf.models.net.MastershipRoleProtoTranslator;
 import static org.onosproject.net.DeviceId.deviceId;
 
 import java.io.IOException;
@@ -50,7 +52,6 @@
 import org.onosproject.grpc.net.device.DeviceService.RegisterProvider;
 import org.onosproject.grpc.net.device.DeviceService.UpdatePortStatistics;
 import org.onosproject.grpc.net.device.DeviceService.UpdatePorts;
-import org.onosproject.incubator.protobuf.models.ProtobufUtils;
 import org.onosproject.net.DeviceId;
 import org.onosproject.net.MastershipRole;
 import org.onosproject.net.PortNumber;
@@ -272,7 +273,7 @@
             case DEVICE_CONNECTED:
                 DeviceConnected deviceConnected = msg.getDeviceConnected();
                 deviceProviderService.deviceConnected(deviceId(deviceConnected.getDeviceId()),
-                                                      translate(deviceConnected.getDeviceDescription()));
+                        DeviceProtoTranslator.translate(deviceConnected.getDeviceDescription()));
                 break;
             case DEVICE_DISCONNECTED:
                 DeviceDisconnected deviceDisconnected = msg.getDeviceDisconnected();
@@ -283,26 +284,26 @@
                 deviceProviderService.updatePorts(deviceId(updatePorts.getDeviceId()),
                                                   updatePorts.getPortDescriptionsList()
                                                       .stream()
-                                                          .map(ProtobufUtils::translate)
+                                                          .map(PortProtoTranslator::translate)
                                                           .collect(toList()));
                 break;
             case PORT_STATUS_CHANGED:
                 PortStatusChanged portStatusChanged = msg.getPortStatusChanged();
                 deviceProviderService.portStatusChanged(deviceId(portStatusChanged.getDeviceId()),
-                                                        translate(portStatusChanged.getPortDescription()));
+                        PortProtoTranslator.translate(portStatusChanged.getPortDescription()));
                 break;
             case RECEIVED_ROLE_REPLY:
                 ReceivedRoleReply receivedRoleReply = msg.getReceivedRoleReply();
                 deviceProviderService.receivedRoleReply(deviceId(receivedRoleReply.getDeviceId()),
-                                                        translate(receivedRoleReply.getRequested()),
-                                                        translate(receivedRoleReply.getResponse()));
+                        (MastershipRole) MastershipRoleProtoTranslator.translate(receivedRoleReply.getRequested()).get(),
+                        (MastershipRole) MastershipRoleProtoTranslator.translate(receivedRoleReply.getResponse()).get());
                 break;
             case UPDATE_PORT_STATISTICS:
                 UpdatePortStatistics updatePortStatistics = msg.getUpdatePortStatistics();
                 deviceProviderService.updatePortStatistics(deviceId(updatePortStatistics.getDeviceId()),
                                                            updatePortStatistics.getPortStatisticsList()
                                                              .stream()
-                                                                .map(ProtobufUtils::translate)
+                                                                .map(PortProtoTranslator::translate)
                                                                 .collect(toList()));
                 break;
 
@@ -429,7 +430,7 @@
             DeviceProviderMsg.Builder msgBuilder = DeviceProviderMsg.newBuilder();
             msgBuilder.setRoleChanged(msgBuilder.getRoleChangedBuilder()
                                           .setDeviceId(deviceId.toString())
-                                          .setNewRole(translate(newRole))
+                                          .setNewRole(MastershipRoleProtoTranslator.translate(newRole))
                                           .build());
             toDeviceProvider.onNext(msgBuilder.build());
         }
diff --git a/incubator/rpc-grpc/src/main/java/org/onosproject/incubator/rpc/grpc/LinkProviderServiceClientProxy.java b/incubator/rpc-grpc/src/main/java/org/onosproject/incubator/rpc/grpc/LinkProviderServiceClientProxy.java
index e59fa7b..d80fb8d 100644
--- a/incubator/rpc-grpc/src/main/java/org/onosproject/incubator/rpc/grpc/LinkProviderServiceClientProxy.java
+++ b/incubator/rpc-grpc/src/main/java/org/onosproject/incubator/rpc/grpc/LinkProviderServiceClientProxy.java
@@ -40,7 +40,7 @@
 import java.util.concurrent.TimeUnit;
 import java.util.concurrent.TimeoutException;
 
-import static org.onosproject.incubator.protobuf.models.ProtobufUtils.asMap;
+import static org.onosproject.incubator.protobuf.models.net.LinkProtoTranslator.asMap;
 
 /**
  * Proxy object to handle LinkProviderService calls.
diff --git a/incubator/rpc-grpc/src/main/java/org/onosproject/incubator/rpc/grpc/LinkProviderServiceServerProxy.java b/incubator/rpc-grpc/src/main/java/org/onosproject/incubator/rpc/grpc/LinkProviderServiceServerProxy.java
index 15b2e1b..55c93fb 100644
--- a/incubator/rpc-grpc/src/main/java/org/onosproject/incubator/rpc/grpc/LinkProviderServiceServerProxy.java
+++ b/incubator/rpc-grpc/src/main/java/org/onosproject/incubator/rpc/grpc/LinkProviderServiceServerProxy.java
@@ -29,7 +29,7 @@
 import org.onosproject.grpc.net.link.models.LinkEnumsProto.LinkTypeProto;
 import org.onosproject.grpc.net.models.ConnectPointProtoOuterClass.ConnectPointProto;
 import org.onosproject.grpc.net.models.ConnectPointProtoOuterClass.ConnectPointProto.ElementIdCase;
-import org.onosproject.incubator.protobuf.models.ProtobufUtils;
+import org.onosproject.incubator.protobuf.models.net.LinkProtoTranslator;
 import org.onosproject.net.ConnectPoint;
 import org.onosproject.net.DeviceId;
 import org.onosproject.net.Link.Type;
@@ -191,7 +191,7 @@
         ConnectPoint src = translate(linkDescription.getSrc());
         ConnectPoint dst = translate(linkDescription.getDst());
         Type type = translate(linkDescription.getType());
-        SparseAnnotations annotations = ProtobufUtils.asAnnotations(linkDescription.getAnnotations());
+        SparseAnnotations annotations = LinkProtoTranslator.asAnnotations(linkDescription.getAnnotations());
         return new DefaultLinkDescription(src, dst, type, annotations);
     }