X-Git-Url: https://gerrit.onap.org/r/gitweb?p=dmaap%2Fdatarouter.git;a=blobdiff_plain;f=datarouter-prov%2Fsrc%2Fmain%2Fjava%2Forg%2Fonap%2Fdmaap%2Fdatarouter%2Fprovisioning%2Futils%2FDRRouteCLI.java;h=187364f97b74682cc1de7c6631a74c6a43377b0b;hp=867d1163b804c39a096b17b31a46f9f0bc0fe003;hb=68a9ca240970fceaf12bbe91b7bad8e1d98ecd93;hpb=f94a3f35ccf9f95455b2840e4465a71b0bb5c71d diff --git a/datarouter-prov/src/main/java/org/onap/dmaap/datarouter/provisioning/utils/DRRouteCLI.java b/datarouter-prov/src/main/java/org/onap/dmaap/datarouter/provisioning/utils/DRRouteCLI.java index 867d1163..187364f9 100644 --- a/datarouter-prov/src/main/java/org/onap/dmaap/datarouter/provisioning/utils/DRRouteCLI.java +++ b/datarouter-prov/src/main/java/org/onap/dmaap/datarouter/provisioning/utils/DRRouteCLI.java @@ -23,6 +23,8 @@ package org.onap.dmaap.datarouter.provisioning.utils; +import static java.lang.System.exit; + import com.att.eelf.configuration.EELFLogger; import com.att.eelf.configuration.EELFManager; import java.io.File; @@ -51,6 +53,7 @@ import org.apache.http.util.EntityUtils; import org.json.JSONArray; import org.json.JSONObject; import org.json.JSONTokener; +import org.onap.dmaap.datarouter.provisioning.ProvRunner; /** * This class provides a Command Line Interface for the routing tables in the DR Release 2.0 DB. @@ -96,9 +99,9 @@ public class DRRouteCLI { } } - public static final String ENV_VAR = "PROVSRVR"; - public static final String PROMPT = "dr-route> "; - public static final String DEFAULT_TRUSTSTORE_PATH = /* $JAVA_HOME + */ "/jre/lib/security/cacerts"; + private static final String ENV_VAR = "PROVSRVR"; + private static final String PROMPT = "dr-route> "; + private static final String DEFAULT_TRUSTSTORE_PATH = /* $JAVA_HOME + */ "/jre/lib/security/cacerts"; private static final EELFLogger intlogger = EELFManager.getInstance().getLogger("InternalLog"); private final String server; @@ -113,12 +116,20 @@ public class DRRouteCLI { */ public DRRouteCLI(String server) throws Exception { this.server = server; - this.width = 120; this.httpclient = new DefaultHttpClient(); - Properties prop = (new DB()).getProperties(); - String truststoreFile = prop.getProperty("org.onap.dmaap.datarouter.provserver.truststore.path"); - String truststorePw = prop.getProperty("org.onap.dmaap.datarouter.provserver.truststore.password"); + Properties provProperties = ProvRunner.getProvProperties(); + try { + AafPropsUtils.init(new File(provProperties.getProperty( + "org.onap.dmaap.datarouter.provserver.aafprops.path", + "/opt/app/osaaf/local/org.onap.dmaap-dr.props"))); + } catch (IOException e) { + intlogger.error("NODE0314 Failed to load AAF props. Exiting", e); + exit(1); + } + + String truststoreFile = AafPropsUtils.getInstance().getTruststorePathProperty(); + String truststorePw = AafPropsUtils.getInstance().getTruststorePassProperty(); KeyStore trustStore = KeyStore.getInstance(KeyStore.getDefaultType()); if (truststoreFile == null || truststoreFile.equals("")) { @@ -139,8 +150,8 @@ public class DRRouteCLI { } finally { try { instream.close(); - } catch (Exception ignore) { - intlogger.error("Ignore error closing input stream: " + ignore.getMessage(), ignore); + } catch (Exception e) { + intlogger.error("Ignore error closing input stream: " + e.getMessage(), e); } } } @@ -178,7 +189,7 @@ public class DRRouteCLI { * @param args The command line arguments. * @return true if the command was valid and succeeded */ - public boolean runCommand(String[] args) { + boolean runCommand(String[] args) { String cmd = args[0].trim().toLowerCase(); if (cmd.equals("add")) { if (args.length > 2) { @@ -471,12 +482,12 @@ public class DRRouteCLI { return rv; } - private void printErrorText(HttpEntity entity) throws IllegalStateException, IOException { + private void printErrorText(HttpEntity entity) throws IOException { // Look for and print only the part of the output between
...
InputStream is = entity.getContent(); StringBuilder sb = new StringBuilder(); byte[] bite = new byte[512]; - int num = 0; + int num; while ((num = is.read(bite)) > 0) { sb.append(new String(bite, 0, num)); }