Refactor Prov DB handling
[dmaap/datarouter.git] / datarouter-prov / src / main / java / org / onap / dmaap / datarouter / provisioning / utils / JSONUtilities.java
index 915aa61..f773599 100644 (file)
  * *\r
  ******************************************************************************/\r
 \r
-\r
 package org.onap.dmaap.datarouter.provisioning.utils;\r
 \r
+import com.att.eelf.configuration.EELFLogger;\r
+import com.att.eelf.configuration.EELFManager;\r
 import java.net.InetAddress;\r
 import java.net.UnknownHostException;\r
 import java.util.Collection;\r
@@ -35,27 +36,37 @@ import java.util.Collection;
  * @version $Id: JSONUtilities.java,v 1.1 2013/04/26 21:00:26 eby Exp $\r
  */\r
 public class JSONUtilities {\r
+\r
+    private static final EELFLogger intlogger = EELFManager.getInstance().getLogger("InternalLog");\r
+\r
+    private JSONUtilities(){\r
+\r
+    }\r
+\r
     /**\r
      * Does the String <i>v</i> represent a valid Internet address (with or without a\r
      * mask length appended).\r
      *\r
-     * @param v the string to check\r
+     * @param str the string to check\r
      * @return true if valid, false otherwise\r
      */\r
-    public static boolean validIPAddrOrSubnet(String v) {\r
-        String[] pp = {v, ""};\r
-        if (v.indexOf('/') > 0)\r
-            pp = v.split("/");\r
+    public static boolean validIPAddrOrSubnet(String str) {\r
+        String[] pp = {str, ""};\r
+        if (str.indexOf('/') > 0) {\r
+            pp = str.split("/");\r
+        }\r
         try {\r
             InetAddress addr = InetAddress.getByName(pp[0]);\r
             if (pp[1].length() > 0) {\r
                 // check subnet mask\r
                 int mask = Integer.parseInt(pp[1]);\r
-                if (mask > (addr.getAddress().length * 8))\r
+                if (mask > (addr.getAddress().length * 8)) {\r
                     return false;\r
+                }\r
             }\r
             return true;\r
         } catch (UnknownHostException e) {\r
+            intlogger.error("PROV0001: " + e.getMessage(), e);\r
             return false;\r
         }\r
     }\r