aboutsummaryrefslogtreecommitdiffstats
path: root/framework/src/main
diff options
context:
space:
mode:
authorKanagaraj Manickam k00365106 <kanagaraj.manickam@huawei.com>2017-08-10 16:35:11 +0530
committerKanagaraj Manickam k00365106 <kanagaraj.manickam@huawei.com>2017-08-10 18:05:17 +0530
commitfe2e261b250be6724c305d4c6f940ca35263596f (patch)
treefadaa0bf9543b8a1650e50d0a8b0e83635e52f75 /framework/src/main
parent2741f49b3b5e92c5c31f44133fd458c4f15b5479 (diff)
Introduce direct service mode
CLI-29 Change-Id: I68cfd8e7b68d6e3839f202509899509c2cdb539b Signed-off-by: Kanagaraj Manickam k00365106 <kanagaraj.manickam@huawei.com>
Diffstat (limited to 'framework/src/main')
-rw-r--r--framework/src/main/java/org/onap/cli/fw/ad/OnapAuthClient.java3
-rw-r--r--framework/src/main/java/org/onap/cli/fw/ad/OnapService.java27
-rw-r--r--framework/src/main/java/org/onap/cli/fw/conf/Constants.java3
-rw-r--r--framework/src/main/java/org/onap/cli/fw/utils/OnapCommandUtils.java4
4 files changed, 35 insertions, 2 deletions
diff --git a/framework/src/main/java/org/onap/cli/fw/ad/OnapAuthClient.java b/framework/src/main/java/org/onap/cli/fw/ad/OnapAuthClient.java
index 9c7e4a66..e6c69a11 100644
--- a/framework/src/main/java/org/onap/cli/fw/ad/OnapAuthClient.java
+++ b/framework/src/main/java/org/onap/cli/fw/ad/OnapAuthClient.java
@@ -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);
diff --git a/framework/src/main/java/org/onap/cli/fw/ad/OnapService.java b/framework/src/main/java/org/onap/cli/fw/ad/OnapService.java
index 16752f25..f9d4a638 100644
--- a/framework/src/main/java/org/onap/cli/fw/ad/OnapService.java
+++ b/framework/src/main/java/org/onap/cli/fw/ad/OnapService.java
@@ -16,8 +16,10 @@
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
diff --git a/framework/src/main/java/org/onap/cli/fw/conf/Constants.java b/framework/src/main/java/org/onap/cli/fw/conf/Constants.java
index 5f95518c..e487bbf2 100644
--- a/framework/src/main/java/org/onap/cli/fw/conf/Constants.java
+++ b/framework/src/main/java/org/onap/cli/fw/conf/Constants.java
@@ -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";
diff --git a/framework/src/main/java/org/onap/cli/fw/utils/OnapCommandUtils.java b/framework/src/main/java/org/onap/cli/fw/utils/OnapCommandUtils.java
index 1a5aba0f..b4df2ace 100644
--- a/framework/src/main/java/org/onap/cli/fw/utils/OnapCommandUtils.java
+++ b/framework/src/main/java/org/onap/cli/fw/utils/OnapCommandUtils.java
@@ -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());
}
}