[VOL-4593] Fixing NPE for c/s tags and TP in decoding the subscriber information

Change-Id: I096f4bfd8b5722657e6d35b7bcbc41802d126761
diff --git a/app/src/main/java/org/opencord/sadis/impl/InformationAdapter.java b/app/src/main/java/org/opencord/sadis/impl/InformationAdapter.java
index f10e589..4a65e56 100644
--- a/app/src/main/java/org/opencord/sadis/impl/InformationAdapter.java
+++ b/app/src/main/java/org/opencord/sadis/impl/InformationAdapter.java
@@ -222,7 +222,7 @@
                 info = mapper.readValue(io, getInformationClass());
             } catch (IOException e) {
                 // TODO use a better http library that allows us to read status code
-                log.debug("Exception while reading remote data {} ", e.getMessage());
+                log.debug("Exception while reading remote data {} ", e.getMessage(), e);
             }
         }
 
diff --git a/app/src/main/java/org/opencord/sadis/impl/SubscriberAndDeviceInformationConfig.java b/app/src/main/java/org/opencord/sadis/impl/SubscriberAndDeviceInformationConfig.java
index 43170a8..958d8d7 100644
--- a/app/src/main/java/org/opencord/sadis/impl/SubscriberAndDeviceInformationConfig.java
+++ b/app/src/main/java/org/opencord/sadis/impl/SubscriberAndDeviceInformationConfig.java
@@ -90,6 +90,7 @@
 
     private final Logger log = LoggerFactory.getLogger(this.getClass());
     private static final int NO_PCP = -1;
+    private static final int NO_TP = -1;
     private static final String NO_SN = "";
     private static final String UNI_TAG_MATCH = "uniTagMatch";
     private static final String PON_C_TAG = "ponCTag";
@@ -165,8 +166,10 @@
         return new UniTagInformation.Builder()
                 .setUniTagMatch(VlanId.vlanId(node.get(UNI_TAG_MATCH) == null ? VlanId.NO_VID
                         : (short) node.get(UNI_TAG_MATCH).asInt()))
-                .setPonCTag(VlanId.vlanId((short) node.get(PON_C_TAG).asInt()))
-                .setPonSTag(VlanId.vlanId((short) node.get(PON_S_TAG).asInt()))
+                .setPonCTag(node.get(PON_C_TAG) == null ? VlanId.vlanId(VlanId.NO_VID) :
+                                    VlanId.vlanId(node.get(PON_C_TAG).shortValue()))
+                .setPonSTag(node.get(PON_S_TAG) == null ? VlanId.vlanId(VlanId.NO_VID) :
+                                    VlanId.vlanId(node.get(PON_S_TAG).shortValue()))
                 .setUsPonCTagPriority(node.get(US_C_TAG_PCP) == null ? NO_PCP :
                         node.get(US_C_TAG_PCP).asInt())
                 .setUsPonSTagPriority(node.get(US_S_TAG_PCP) == null ? NO_PCP :
@@ -175,9 +178,8 @@
                         node.get(DS_C_TAG_PCP).asInt())
                 .setDsPonSTagPriority(node.get(DS_S_TAG_PCP) == null ? NO_PCP :
                         node.get(DS_S_TAG_PCP).asInt())
-                .setEnableMacLearning(node.get(MAC_LEARNING) == null ? false :
-                        node.get(MAC_LEARNING).asBoolean())
-                .setTechnologyProfileId(node.get(TP_ID).asInt())
+                .setEnableMacLearning(node.get(MAC_LEARNING) != null && node.get(MAC_LEARNING).asBoolean())
+                .setTechnologyProfileId(node.get(TP_ID) == null ? NO_TP : node.get(TP_ID).asInt())
                 .setUpstreamBandwidthProfile(usBw)
                 .setDownstreamBandwidthProfile(dsBw)
                 .setUpstreamOltBandwidthProfile(node.get(US_OLT_BW) == null ? usBw
@@ -186,8 +188,8 @@
                         : node.get(DS_OLT_BW).asText())
                 .setServiceName(node.get(SERVICE_NAME) == null ? NO_SN :
                         node.get(SERVICE_NAME).asText())
-                .setIsDhcpRequired(node.get(IS_DHCP_REQ) == null ? false : node.get(IS_DHCP_REQ).asBoolean())
-                .setIsIgmpRequired(node.get(IS_IGMP_REQ) == null ? false : node.get(IS_IGMP_REQ).asBoolean())
+                .setIsDhcpRequired(node.get(IS_DHCP_REQ) != null && node.get(IS_DHCP_REQ).asBoolean())
+                .setIsIgmpRequired(node.get(IS_IGMP_REQ) != null && node.get(IS_IGMP_REQ).asBoolean())
                 .setConfiguredMacAddress(node.get(MAC_ADDRESS) == null ? MacAddress.NONE.toString() :
                         node.get(MAC_ADDRESS).asText())
                 .build();
diff --git a/app/src/main/java/org/opencord/sadis/impl/UniTagInformationCodec.java b/app/src/main/java/org/opencord/sadis/impl/UniTagInformationCodec.java
index cad67c0..9afbdcc 100644
--- a/app/src/main/java/org/opencord/sadis/impl/UniTagInformationCodec.java
+++ b/app/src/main/java/org/opencord/sadis/impl/UniTagInformationCodec.java
@@ -81,7 +81,6 @@
         if (json == null || !json.isObject()) {
             return null;
         }
-
         UniTagInformation.Builder tagInfoBuilder = new UniTagInformation.Builder();
         String usBp = json.get(US_BP) == null ? EMPTY_BP :
                 json.get(US_BP).asText();
@@ -93,7 +92,7 @@
                 VlanId.vlanId(json.get(UNI_TAG_MATCH).shortValue()))
                 .setPonCTag(json.get(PON_CTAG) == null ? VlanId.vlanId(VlanId.NO_VID) :
                         VlanId.vlanId(json.get(PON_CTAG).shortValue()))
-                .setPonCTag(json.get(PON_STAG) == null ? VlanId.vlanId(VlanId.NO_VID) :
+                .setPonSTag(json.get(PON_STAG) == null ? VlanId.vlanId(VlanId.NO_VID) :
                         VlanId.vlanId(json.get(PON_STAG).shortValue()))
                 .setUsPonCTagPriority(json.get(US_PON_CTAG_PCP) == null ? NO_PCP :
                         json.get(US_PON_CTAG_PCP).asInt())