Introduce direct service mode 05/7205/1
authorKanagaraj Manickam k00365106 <kanagaraj.manickam@huawei.com>
Thu, 10 Aug 2017 11:05:11 +0000 (16:35 +0530)
committerKanagaraj Manickam k00365106 <kanagaraj.manickam@huawei.com>
Thu, 10 Aug 2017 12:35:17 +0000 (18:05 +0530)
CLI-29
Change-Id: I68cfd8e7b68d6e3839f202509899509c2cdb539b
Signed-off-by: Kanagaraj Manickam k00365106 <kanagaraj.manickam@huawei.com>
framework/src/main/java/org/onap/cli/fw/ad/OnapAuthClient.java
framework/src/main/java/org/onap/cli/fw/ad/OnapService.java
framework/src/main/java/org/onap/cli/fw/conf/Constants.java
framework/src/main/java/org/onap/cli/fw/utils/OnapCommandUtils.java

index 9c7e4a6..e6c69a1 100644 (file)
@@ -137,8 +137,11 @@ public class OnapAuthClient {
     public String getServiceBasePath(OnapService srv) throws OnapCommandException {
         if (srv.getName().equals(OnapCommandConfg.getApiGateway())) {
             return this.getMsbUrl();
+        } else if (srv.isModeDirect()){
+            return this.creds.getMsbUrl();
         }
 
+
         HttpInput input = new HttpInput().setUri(this.creds.getMsbUrl()
                 + String.format(Constants.MSB_SERVICE_URI, srv.getName(), srv.getVersion()));
         HttpResult result = this.http.get(input);
index 16752f2..f9d4a63 100644 (file)
 
 package org.onap.cli.fw.ad;
 
+import org.onap.cli.fw.conf.Constants;
+
 /**
- * Onap Service as reported in Onap MSB like msb v1 or /api/microservice/v1.
+ * Onap Service as reported in api catalog.
  */
 public class OnapService {
     /*
@@ -32,8 +34,29 @@ public class OnapService {
 
     private String basePath;
 
+    /**
+     * Mode of service consideration. By default, it goes with
+     * 'catalog' mode, where basePath will be discovered by
+     * the framework using serviceName and serviceVersion
+     * Another mode is 'direct', in which bastPath will be
+     * same as OnapCredentails.ServiceUrl.
+     */
+    private String mode = Constants.MODE_CATALOG;
+
     private boolean noAuth = false;
 
+    public String getMode() {
+        return mode;
+    }
+
+    public void setMode(String mode) {
+        this.mode = mode;
+    }
+
+    public boolean isModeDirect() {
+        return this.getMode().equals(Constants.MODE_DIRECT);
+    }
+
     public boolean isNoAuth() {
         return noAuth;
     }
@@ -71,4 +94,4 @@ public class OnapService {
         return this.getName() + " " + this.getVersion();
     }
 
-}
+}
\ No newline at end of file
index 5f95518..e487bbf 100644 (file)
@@ -75,6 +75,9 @@ public class Constants {
     public static final String VERSION = "version";
     public static final String BASE_PATH = "base_path";
     public static final String NO_AUTH = "no-auth";
+    public static final String MODE = "mode";
+    public static final String MODE_DIRECT = "direct";
+    public static final String MODE_CATALOG = "catalog";
 
     public static final String SHORT_OPTION = "short_option";
     public static final String LONG_OPTION = "long_option";
index 1a5aba0..b4df2ac 100644 (file)
@@ -251,6 +251,10 @@ public class OnapCommandUtils {
                         } else if (Constants.NO_AUTH.equals(key1)) {
                             Object obj = map.get(key1);
                             srv.setNoAuth("true".equalsIgnoreCase(obj.toString()));
+                        } else if (Constants.MODE.equals(key1)) {
+                            Object obj = map.get(key1);
+                            //TODO mrkanag Validate and raise exception for invalid case
+                            srv.setMode(obj.toString());
                         }
                     }