Enable checkstyle for neutronvpn
[netvirt.git] / vpnservice / neutronvpn / neutronvpn-impl / src / main / java / org / opendaylight / netvirt / neutronvpn / NeutronSecurityRuleListener.java
index e9ceaaedd3a4b94741b8d76e2a5db210dfba1d35..d8df51caec3754433170dffbc20f49f923b2fb08 100644 (file)
@@ -52,8 +52,9 @@ public class NeutronSecurityRuleListener
         extends AsyncDataTreeChangeListenerBase<SecurityRule, NeutronSecurityRuleListener> {
     private static final Logger LOG = LoggerFactory.getLogger(NeutronSecurityRuleListener.class);
     private final DataBroker dataBroker;
-    private static final ImmutableBiMap<Class<? extends DirectionBase>, Class<? extends org.opendaylight.yang.gen.
-            v1.urn.opendaylight.netvirt.aclservice.rev160608.DirectionBase>> DIRECTION_MAP = ImmutableBiMap.of(
+    private static final ImmutableBiMap<Class<? extends DirectionBase>,
+        Class<?extends org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.aclservice.rev160608.DirectionBase>>
+        DIRECTION_MAP = ImmutableBiMap.of(
             DirectionEgress.class, NeutronSecurityRuleConstants.DIRECTION_EGRESS,
             DirectionIngress.class, NeutronSecurityRuleConstants.DIRECTION_INGRESS);
     private static final ImmutableBiMap<Class<? extends ProtocolBase>, Short> PROTOCOL_MAP = ImmutableBiMap.of(
@@ -78,10 +79,10 @@ public class NeutronSecurityRuleListener
     }
 
     @Override
+    // TODO Clean up the exception handling
+    @SuppressWarnings("checkstyle:IllegalCatch")
     protected void add(InstanceIdentifier<SecurityRule> instanceIdentifier, SecurityRule securityRule) {
-        if (LOG.isTraceEnabled()) {
-            LOG.trace("added securityRule: {}", securityRule);
-        }
+        LOG.trace("added securityRule: {}", securityRule);
         try {
             Ace ace = toAceBuilder(securityRule).build();
             InstanceIdentifier<Ace> identifier = getAceInstanceIdentifier(securityRule);
@@ -113,22 +114,13 @@ public class NeutronSecurityRuleListener
             isDirectionIngress = securityRule.getDirection().equals(DirectionIngress.class);
         }
         if (securityRule.getPortRangeMax() != null) {
-            if (isDirectionIngress) {
-                sourcePortRangeBuilder.setUpperPort(new PortNumber(securityRule.getPortRangeMax()));
-            } else {
-                destinationPortRangeBuilder.setUpperPort(new PortNumber(securityRule.getPortRangeMax()));
-            }
+            destinationPortRangeBuilder.setUpperPort(new PortNumber(securityRule.getPortRangeMax()));
+
         }
         if (securityRule.getPortRangeMin() != null) {
-            if (isDirectionIngress) {
-                sourcePortRangeBuilder.setLowerPort(new PortNumber(securityRule.getPortRangeMin()));
-                // set source port range if lower port is specified as it is mandatory parameter in acl model
-                aceIpBuilder.setSourcePortRange(sourcePortRangeBuilder.build());
-            } else {
-                destinationPortRangeBuilder.setLowerPort(new PortNumber(securityRule.getPortRangeMin()));
-                // set destination port range if lower port is specified as it is mandatory parameter in acl model
-                aceIpBuilder.setDestinationPortRange(destinationPortRangeBuilder.build());
-            }
+            destinationPortRangeBuilder.setLowerPort(new PortNumber(securityRule.getPortRangeMin()));
+            // set destination port range if lower port is specified as it is mandatory parameter in acl model
+            aceIpBuilder.setDestinationPortRange(destinationPortRangeBuilder.build());
         }
         aceIpBuilder = handleRemoteIpPrefix(securityRule, aceIpBuilder, isDirectionIngress);
         if (securityRule.getRemoteGroupId() != null) {
@@ -214,10 +206,10 @@ public class NeutronSecurityRuleListener
     }
 
     @Override
+    // TODO Clean up the exception handling
+    @SuppressWarnings("checkstyle:IllegalCatch")
     protected void remove(InstanceIdentifier<SecurityRule> instanceIdentifier, SecurityRule securityRule) {
-        if (LOG.isTraceEnabled()) {
-            LOG.trace("removed securityRule: {}", securityRule);
-        }
+        LOG.trace("removed securityRule: {}", securityRule);
         try {
             InstanceIdentifier<Ace> identifier = getAceInstanceIdentifier(securityRule);
             MDSALUtil.syncDelete(dataBroker, LogicalDatastoreType.CONFIGURATION, identifier);
@@ -227,7 +219,8 @@ public class NeutronSecurityRuleListener
     }
 
     @Override
-    protected void update(InstanceIdentifier<SecurityRule> instanceIdentifier, SecurityRule oldSecurityRule, SecurityRule updatedSecurityRule) {
+    protected void update(InstanceIdentifier<SecurityRule> instanceIdentifier,
+                          SecurityRule oldSecurityRule, SecurityRule updatedSecurityRule) {
         // security rule updation is not supported from openstack, so no need to handle update.
         LOG.trace("updates on security rules not supported.");
     }