apply checkstyle check during build for neutron-mapper
[groupbasedpolicy.git] / neutron-mapper / src / main / java / org / opendaylight / groupbasedpolicy / neutron / mapper / mapping / NeutronSecurityGroupAware.java
index 90ecae6185b256f8ad1444b1ab96f22b22a9dd70..3ec4c43b2b34f03b41950180e40be469f56663d8 100644 (file)
@@ -9,6 +9,9 @@ package org.opendaylight.groupbasedpolicy.neutron.mapper.mapping;
 
 import static com.google.common.base.Preconditions.checkNotNull;
 
+import com.google.common.base.Optional;
+import com.google.common.base.Strings;
+
 import org.opendaylight.controller.md.sal.binding.api.DataBroker;
 import org.opendaylight.controller.md.sal.binding.api.ReadWriteTransaction;
 import org.opendaylight.controller.md.sal.common.api.data.LogicalDatastoreType;
@@ -31,9 +34,6 @@ import org.opendaylight.yangtools.yang.binding.InstanceIdentifier;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
-import com.google.common.base.Optional;
-import com.google.common.base.Strings;
-
 public class NeutronSecurityGroupAware implements NeutronAware<SecurityGroup> {
 
     private static final Logger LOG = LoggerFactory.getLogger(NeutronSecurityGroupAware.class);
@@ -66,24 +66,25 @@ public class NeutronSecurityGroupAware implements NeutronAware<SecurityGroup> {
             // TODO This needs to be reworked, SecGroups shouldn't use TenantId, Neutron doesn't always configure it
             return true;
         }
-        TenantId tId = new TenantId(secGroup.getTenantId().getValue());
+        TenantId tenantId = new TenantId(secGroup.getTenantId().getValue());
         EndpointGroupId epgId = new EndpointGroupId(secGroup.getUuid().getValue());
         if (epgId.getValue().equals(MappingUtils.EIG_UUID.getValue())) {
             ExternalImplicitGroup eig = new ExternalImplicitGroupBuilder().setId(epgId).build();
-            rwTx.put(LogicalDatastoreType.CONFIGURATION, IidFactory.externalImplicitGroupIid(tId, epgId), eig, true);
+            rwTx.put(LogicalDatastoreType.CONFIGURATION, IidFactory.externalImplicitGroupIid(tenantId, epgId), eig,
+                true);
         }
         EndpointGroupBuilder epgBuilder = new EndpointGroupBuilder().setId(epgId);
         if (!Strings.isNullOrEmpty(secGroup.getName())) {
             try {
                 epgBuilder.setName(new Name(secGroup.getName()));
-            } catch (Exception e) {
+            } catch (NullPointerException | IllegalArgumentException e) {
                 LOG.info("Name '{}' of Neutron Security-group '{}' is ignored.", secGroup.getName(),
                         secGroup.getUuid().getValue());
                 LOG.debug("Name exception", e);
             }
         }
         epgBuilder.setIntraGroupPolicy(IntraGroupPolicy.RequireContract);
-        rwTx.put(LogicalDatastoreType.CONFIGURATION, IidFactory.endpointGroupIid(tId, epgId),
+        rwTx.put(LogicalDatastoreType.CONFIGURATION, IidFactory.endpointGroupIid(tenantId, epgId),
                 epgBuilder.build(), true);
         return true;
     }