Merge "update the credentials in subscribe call"
[dmaap/messagerouter/mirroragent.git] / src / main / java / org / onap / dmaap / mr / dmaapMMAgent / MirrorMakerAgent.java
index 86a653d..c205440 100644 (file)
  *******************************************************************************/
 package org.onap.dmaap.mr.dmaapMMAgent;
 
-import java.io.BufferedReader;
-import java.io.DataOutputStream;
 import java.io.File;
 import java.io.FileInputStream;
 import java.io.FileOutputStream;
 import java.io.IOException;
 import java.io.InputStream;
-import java.io.InputStreamReader;
 import java.io.OutputStream;
-import java.net.HttpURLConnection;
-import java.net.URL;
 import java.util.ArrayList;
 import java.util.Properties;
-import org.json.JSONObject;
+
 import org.apache.log4j.Logger;
 import org.jasypt.util.text.BasicTextEncryptor;
-
+import org.json.JSONObject;
 import org.onap.dmaap.mr.dmaapMMAgent.dao.CreateMirrorMaker;
 import org.onap.dmaap.mr.dmaapMMAgent.dao.DeleteMirrorMaker;
 import org.onap.dmaap.mr.dmaapMMAgent.dao.ListMirrorMaker;
@@ -45,18 +40,15 @@ import org.onap.dmaap.mr.dmaapMMAgent.dao.MirrorMaker;
 import org.onap.dmaap.mr.dmaapMMAgent.dao.UpdateMirrorMaker;
 import org.onap.dmaap.mr.dmaapMMAgent.dao.UpdateWhiteList;
 import org.onap.dmaap.mr.dmaapMMAgent.utils.MirrorMakerProcessHandler;
+
 import com.google.gson.Gson;
-import com.google.gson.JsonArray;
 import com.google.gson.internal.LinkedTreeMap;
 
-import com.sun.org.apache.xerces.internal.impl.dtd.models.CMAny;
-import com.sun.org.apache.xerces.internal.impl.dv.util.Base64;
-
 public class MirrorMakerAgent {
        static final Logger logger = Logger.getLogger(MirrorMakerAgent.class);
        Properties mirrorMakerProperties = new Properties();
        ListMirrorMaker mirrorMakers = null;
-       String mmagenthome = "";
+       String mmagenthome = "/opt";
        String kafkahome = "";
        String topicURL = "";
        String topicname = "";
@@ -100,7 +92,7 @@ public class MirrorMakerAgent {
        private boolean checkStartup() {
                FileInputStream input = null;
                try {
-                       this.mmagenthome = System.getProperty("MMAGENTHOME");
+                       //this.mmagenthome = System.getProperty("MMAGENTHOME");
                        input = new FileInputStream(mmagenthome + "/etc/mmagent.config");
                        logger.info("mmagenthome is set :" + mmagenthome + " loading properties at /etc/mmagent.config");
                } catch (IOException ex) {
@@ -111,7 +103,7 @@ public class MirrorMakerAgent {
                                try {
                                        input.close();
                                } catch (IOException e) {
-                                       e.printStackTrace();
+                                       logger.error("exception occured in checkStartup "+e);
                                }
                        }
                }
@@ -128,7 +120,7 @@ public class MirrorMakerAgent {
                                try {
                                        input.close();
                                } catch (IOException e) {
-                                       e.printStackTrace();
+                                       logger.error("exception occured in checkStartup "+e);
                                }
                        }
                }
@@ -139,7 +131,7 @@ public class MirrorMakerAgent {
                        return false;
                }
                logger.info("Published to Topic :" + this.topicname + " Successfully");
-               response = topicUtil.subscribeTopic(topicURL, topicname, "1", response, response);
+               response = topicUtil.subscribeTopic(topicURL, topicname, "1", mechid, password);
                if (response != null && response.startsWith("ERROR:")) {
                        logger.error("Problem subscribing to topic, please verify the config " + this.topicname + " MR URL is:"
                                        + this.topicURL + " Error is:  " + response);
@@ -176,7 +168,7 @@ public class MirrorMakerAgent {
                                prop.store(out, "");
 
                        } catch (Exception e) {
-                               e.printStackTrace();
+                               logger.error("exception occured in checkPropertiesFile "+e);
                        }
                } finally {
                        if (input != null) {
@@ -190,7 +182,7 @@ public class MirrorMakerAgent {
                                try {
                                        out.close();
                                } catch (IOException e) {
-                                       e.printStackTrace();
+                                       logger.error("exception occured in checkPropertiesFile "+e);
                                }
                        }
                }