Bug 5540 - GroupConvertor, GroupStatsConvertor, GroupDescStatsConvertor
[openflowplugin.git] / openflowplugin / src / main / java / org / opendaylight / openflowplugin / openflow / md / core / sal / OFRpcTaskFactory.java
index ef7741a89c2c4e1c0681db516da3dfd87bbb88c5..a7446eca965c34453999ad9c702c2c8e6815b328 100644 (file)
@@ -34,6 +34,7 @@ import org.opendaylight.openflowplugin.openflow.md.core.sal.convertor.GroupConve
 import org.opendaylight.openflowplugin.openflow.md.core.sal.convertor.MeterConvertor;
 import org.opendaylight.openflowplugin.openflow.md.core.sal.convertor.PortConvertor;
 import org.opendaylight.openflowplugin.openflow.md.core.sal.convertor.data.VersionConvertorData;
+import org.opendaylight.openflowplugin.openflow.md.core.sal.convertor.data.VersionDatapathIdConvertorData;
 import org.opendaylight.openflowplugin.openflow.md.core.sal.convertor.match.MatchReactor;
 import org.opendaylight.openflowplugin.openflow.md.util.FlowCreatorUtil;
 import org.opendaylight.openflowplugin.openflow.md.util.InventoryDataServiceUtil;
@@ -464,17 +465,18 @@ public abstract class OFRpcTaskFactory {
             @Override
             public ListenableFuture<RpcResult<UpdateGroupOutput>> call() {
                 ListenableFuture<RpcResult<UpdateGroupOutput>> result = SettableFuture.create();
+                final VersionDatapathIdConvertorData data = new VersionDatapathIdConvertorData(getVersion());
+                data.setDatapathId(getSession().getFeatures().getDatapathId());
 
                 // Convert the AddGroupInput to GroupModInput
-                GroupModInputBuilder ofGroupModInput = GroupConvertor.toGroupModInput(getInput(),
-                        getVersion(), getSession().getFeatures().getDatapathId());
-                final Long xId = getSession().getNextXid();
-                ofGroupModInput.setXid(xId);
+                final java.util.Optional<GroupModInputBuilder> ofGroupModInput = ConvertorManager.getInstance().convert(getInput(), data);
+                final GroupModInputBuilder groupModInputBuilder = ofGroupModInput
+                        .orElse(GroupConvertor.defaultResult(getVersion()))
+                        .setXid(getSession().getNextXid());
 
                 Future<RpcResult<UpdateGroupOutput>> resultFromOFLib = getMessageService()
-                        .groupMod(ofGroupModInput.build(), getCookie());
+                        .groupMod(groupModInputBuilder.build(), getCookie());
                 result = JdkFutureAdapters.listenInPoolThread(resultFromOFLib);
-
                 result = OFRpcTaskUtil.chainFutureBarrier(this, result);
                 OFRpcTaskUtil.hookFutureNotification(this, result,
                         getRpcNotificationProviderService(), createGroupAddedNotification(getInput()));
@@ -592,16 +594,19 @@ public abstract class OFRpcTaskFactory {
             @Override
             public ListenableFuture<RpcResult<UpdateGroupOutput>> call() {
                 ListenableFuture<RpcResult<UpdateGroupOutput>> result = null;
+                final VersionDatapathIdConvertorData data = new VersionDatapathIdConvertorData(getVersion());
+                data.setDatapathId(getSession().getFeatures().getDatapathId());
 
                 // Convert the UpdateGroupInput to GroupModInput
-                GroupModInputBuilder ofGroupModInput = GroupConvertor.toGroupModInput(
-                        getInput().getUpdatedGroup(), getVersion(),
-                        getSession().getFeatures().getDatapathId());
-                final Long xId = getSession().getNextXid();
-                ofGroupModInput.setXid(xId);
+                final java.util.Optional<GroupModInputBuilder> ofGroupModInput =
+                        ConvertorManager.getInstance().convert(getInput().getUpdatedGroup(), data);
+
+                final GroupModInputBuilder groupModInputBuilder = ofGroupModInput
+                        .orElse(GroupConvertor.defaultResult(getVersion()))
+                        .setXid(getSession().getNextXid());
 
                 Future<RpcResult<UpdateGroupOutput>> resultFromOFLib =
-                        getMessageService().groupMod(ofGroupModInput.build(), getCookie());
+                        getMessageService().groupMod(groupModInputBuilder.build(), getCookie());
                 result = JdkFutureAdapters.listenInPoolThread(resultFromOFLib);
 
                 result = OFRpcTaskUtil.chainFutureBarrier(this, result);
@@ -781,17 +786,20 @@ public abstract class OFRpcTaskFactory {
             @Override
             public ListenableFuture<RpcResult<UpdateGroupOutput>> call() {
                 ListenableFuture<RpcResult<UpdateGroupOutput>> result = SettableFuture.create();
+                final VersionDatapathIdConvertorData data = new VersionDatapathIdConvertorData(getVersion());
+                data.setDatapathId(getSession().getFeatures().getDatapathId());
 
                 // Convert the AddGroupInput to GroupModInput
-                GroupModInputBuilder ofGroupModInput = GroupConvertor.toGroupModInput(getInput(),
-                        getVersion(), getSession().getFeatures().getDatapathId());
-                final Long xId = getSession().getNextXid();
-                ofGroupModInput.setXid(xId);
+                final java.util.Optional<GroupModInputBuilder> ofGroupModInput =
+                        ConvertorManager.getInstance().convert(getInput(), data);
+
+                final GroupModInputBuilder groupModInputBuilder = ofGroupModInput
+                        .orElse(GroupConvertor.defaultResult(getVersion()))
+                        .setXid(getSession().getNextXid());
 
                 Future<RpcResult<UpdateGroupOutput>> resultFromOFLib = getMessageService()
-                        .groupMod(ofGroupModInput.build(), getCookie());
+                        .groupMod(groupModInputBuilder.build(), getCookie());
                 result = JdkFutureAdapters.listenInPoolThread(resultFromOFLib);
-
                 result = OFRpcTaskUtil.chainFutureBarrier(this, result);
                 OFRpcTaskUtil.hookFutureNotification(this, result,
                         getRpcNotificationProviderService(), createGroupRemovedNotification(getInput()));