Add null checks to ServiceCatalogFactory
[appc.git] / appc-adapters / appc-iaas-adapter / appc-iaas-adapter-bundle / src / main / java / org / openecomp / appc / adapter / iaas / impl / ServiceCatalogFactory.java
index 63d4a31..c6624e8 100644 (file)
@@ -26,7 +26,12 @@ package org.openecomp.appc.adapter.iaas.impl;
 \r
 import java.util.Properties;\r
 \r
+import com.att.eelf.configuration.EELFLogger;\r
+import com.att.eelf.configuration.EELFManager;\r
+\r
 public class ServiceCatalogFactory {\r
+       \r
+       private static EELFLogger logger= EELFManager.getInstance().getLogger(org.openecomp.appc.adapter.iaas.impl.ServiceCatalogFactory.class);\r
 \r
     /**\r
      * This method accepts a fully qualified identity service URL and uses that to determine which version of the\r
@@ -41,9 +46,17 @@ public class ServiceCatalogFactory {
      */\r
     public static ServiceCatalog getServiceCatalog(String url, String projectIdentifier, String principal,\r
             String credential, String domain, Properties properties) {\r
-        String version = IdentityURL.parseURL(url).getVersion();\r
+       IdentityURL idUrl = IdentityURL.parseURL(url);\r
+       if(idUrl == null){\r
+               logger.error("Url " + url + " could not be parsed.");\r
+               return null;\r
+       }\r
+        String version = idUrl.getVersion();\r
+        if(version == null){\r
+               logger.error("Invalid Identity URL check configuration");\r
+               return null;\r
+        }\r
         String prefix = version.split("\\.")[0];\r
-\r
         if (prefix != null) {\r
             switch (prefix) {\r
                 case "v2":\r