Remove CLI_DEV and replace by discover_always conf 27/17027/1
authorKanagaraj Manickam k00365106 <kanagaraj.manickam@huawei.com>
Fri, 29 Sep 2017 10:22:59 +0000 (15:52 +0530)
committerKanagaraj Manickam k00365106 <kanagaraj.manickam@huawei.com>
Fri, 29 Sep 2017 10:24:27 +0000 (15:54 +0530)
CLI-2
Change-Id: Ic67ac30c6f6c9a0a8928b1fac6d5adc85ca53a5b
Signed-off-by: Kanagaraj Manickam k00365106 <kanagaraj.manickam@huawei.com>
deployment/docker/src/main/docker/docker-compose.yaml
framework/src/main/java/org/onap/cli/fw/OnapCommandRegistrar.java
framework/src/main/java/org/onap/cli/fw/conf/Constants.java
framework/src/main/java/org/onap/cli/fw/conf/OnapCommandConfg.java
framework/src/main/java/org/onap/cli/fw/utils/OnapCommandUtils.java
framework/src/main/resources/onap.properties
framework/src/test/java/org/onap/cli/fw/OnapCommandRegistrarTest.java
main/src/main/java/org/onap/cli/main/OnapCli.java

index aff1f85..f6273cb 100644 (file)
@@ -24,7 +24,6 @@ services:
     tty: true
     image: onap/cli
     environment:
-      CLI_DEV: "true"
       CLI_MODE: 'console'
       ONAP_CLI_DEBUG: "true"
     expose:
index 2a16cb7..72e22b5 100644 (file)
@@ -58,8 +58,6 @@ public class OnapCommandRegistrar {
 
     private boolean isInteractiveMode = false;
 
-    private boolean isDevMode = Boolean.parseBoolean(System.getenv(Constants.CLI_DEV_MODE));
-
     private OnapCommandParameterCache paramCache = OnapCommandParameterCache.getInstance();
 
     public boolean isInteractiveMode() {
@@ -82,14 +80,6 @@ public class OnapCommandRegistrar {
         paramCache.remove(this.getEnabledProductVersion(), paramName);
     }
 
-    public boolean isDevMode() {
-        return isDevMode;
-    }
-
-    public void setDevMode(boolean isDevMode) {
-        this.isDevMode = isDevMode;
-    }
-
     public void setProfile(String profileName) {
         this.paramCache.setProfile(profileName);
     }
index 17b771c..e9e52ba 100644 (file)
@@ -196,7 +196,7 @@ public class Constants {
 
     public static final String PARAM_CACHE_FILE_NAME = "global-profile";
 
-    public static final String CLI_DEV_MODE = "CLI_DEV";
+    public static final String DISCOVER_ALWAYS = "discover_always";
 
     private Constants() {
     }
index b706ea6..249ec0e 100644 (file)
@@ -62,6 +62,19 @@ public final class OnapCommandConfg {
         return false;
     }
 
+    /**
+     * is discovery should do every time.
+     *
+     * @return boolean
+     */
+    public static boolean isDiscoverAlways() {
+        if ("true".equals(prps.getProperty(Constants.DISCOVER_ALWAYS))) {
+            return true;
+        }
+
+        return false;
+    }
+
     public static String getVersion() {
         return prps.getProperty(Constants.ONAP_CLI_VERSION);
     }
index 939c753..77d5017 100644 (file)
@@ -1682,7 +1682,7 @@ public class OnapCommandUtils {
      */
     public static List<ExternalSchema> loadExternalSchemasFromJson() throws OnapCommandException {
         List<ExternalSchema> schemas = new ArrayList<>();
-        if (OnapCommandRegistrar.getRegistrar().isDevMode() || !isJsonFileDiscovered()) {
+        if (OnapCommandConfg.isDiscoverAlways() || !isJsonFileDiscovered()) {
             schemas = findAllExternalSchemas();
             if (!schemas.isEmpty()) {
                 persist(schemas);
index 285e5c8..77be05f 100644 (file)
@@ -1,7 +1,7 @@
 cli.ignore_auth=false
 cli.version=1.0
 cli.http.api_key_use_cookies=true
-
+cli.discover_always=false
 cli.service_name=onap-cli
 cli.api_gateway=msb
 cli.auth_service=auth
index d123a87..c26678d 100644 (file)
@@ -147,9 +147,6 @@ public class OnapCommandRegistrarTest {
         OnapCommandRegistrar.getRegistrar().getParamCache();
         OnapCommandRegistrar.getRegistrar().removeParamCache("a");
 
-        OnapCommandRegistrar.getRegistrar().setDevMode(true);
-        OnapCommandRegistrar.getRegistrar().isDevMode();
-
         OnapCommandRegistrar.getRegistrar().isInteractiveMode();
         OnapCommandRegistrar.getRegistrar().setInteractiveMode(false);
 
index 9255da2..35df0e3 100644 (file)
@@ -37,6 +37,8 @@ import org.onap.cli.fw.output.ResultType;
 import org.onap.cli.main.conf.OnapCliConstants;
 import org.onap.cli.main.interactive.StringCompleter;
 import org.onap.cli.main.utils.OnapCliUtils;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
 
 import jline.TerminalFactory;
 import jline.console.ConsoleReader;
@@ -47,6 +49,8 @@ import jline.console.ConsoleReader;
  */
 public class OnapCli {
 
+    private static Logger LOG = LoggerFactory.getLogger(OnapCli.class);
+
     private List<String> args = new ArrayList<>();
 
     private int exitCode = -1;
@@ -68,14 +72,8 @@ public class OnapCli {
     }
 
     private void print(Throwable throwable) {
-        System.out.println(throwable.getMessage());
-        try {
-            if (OnapCommandRegistrar.getRegistrar().isDevMode()) {
-                throwable.printStackTrace();  // NOSONAR
-            }
-        } catch (OnapCommandException e) {
-            System.out.println(e);
-        }
+        this.print(throwable.getMessage());
+        LOG.error(throwable.getMessage(), throwable);
     }
 
     private String getShortOption(String opt) {