Merge "sonar critical for Exception Handling"
[dmaap/messagerouter/mirroragent.git] / src / main / java / com / att / nsa / dmaapMMAgent / MirrorMakerAgent.java
1 /*******************************************************************************
2  *  ============LICENSE_START=======================================================
3  *  org.onap.dmaap
4  *  ================================================================================
5  *  Copyright © 2017 AT&T Intellectual Property. All rights reserved.
6  *  ================================================================================
7  *  Licensed under the Apache License, Version 2.0 (the "License");
8  *  you may not use this file except in compliance with the License.
9  *  You may obtain a copy of the License at
10  *        http://www.apache.org/licenses/LICENSE-2.0
11  *  
12  *  Unless required by applicable law or agreed to in writing, software
13  *  distributed under the License is distributed on an "AS IS" BASIS,
14  *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15  *  See the License for the specific language governing permissions and
16  *  limitations under the License.
17  *  ============LICENSE_END=========================================================
18  *
19  *  ECOMP is a trademark and service mark of AT&T Intellectual Property.
20  *  
21  *******************************************************************************/
22
23 package com.att.nsa.dmaapMMAgent;
24
25 import java.io.BufferedReader;
26 import java.io.DataOutputStream;
27 import java.io.File;
28 import java.io.FileInputStream;
29 import java.io.FileOutputStream;
30 import java.io.IOException;
31 import java.io.InputStream;
32 import java.io.InputStreamReader;
33 import java.io.OutputStream;
34 import java.net.HttpURLConnection;
35 import java.net.URL;
36 import java.util.ArrayList;
37 import java.util.Properties;
38
39 import org.apache.log4j.Level;
40 import org.apache.log4j.Logger;
41 import org.jasypt.util.text.BasicTextEncryptor;
42
43 import com.att.nsa.dmaapMMAgent.dao.CreateMirrorMaker;
44 import com.att.nsa.dmaapMMAgent.dao.DeleteMirrorMaker;
45 import com.att.nsa.dmaapMMAgent.dao.ListMirrorMaker;
46 import com.att.nsa.dmaapMMAgent.dao.MirrorMaker;
47 import com.att.nsa.dmaapMMAgent.dao.UpdateMirrorMaker;
48 import com.att.nsa.dmaapMMAgent.dao.UpdateWhiteList;
49 import com.att.nsa.dmaapMMAgent.utils.MirrorMakerProcessHandler;
50 import com.google.gson.Gson;
51 import com.google.gson.internal.LinkedTreeMap;
52 import com.sun.org.apache.xerces.internal.impl.dtd.models.CMAny;
53 import com.sun.org.apache.xerces.internal.impl.dv.util.Base64;
54
55 public class MirrorMakerAgent {
56         static final Logger logger = Logger.getLogger(MirrorMakerAgent.class);
57         Properties mirrorMakerProperties = new Properties();
58         ListMirrorMaker mirrorMakers = null;
59         String mmagenthome = "";
60         String kafkahome = "";
61         String topicURL = "";
62         String topicname = "";
63         String mechid = "";
64         String password = "";
65         private static String secret = "utdfpWlgyDQ2ZB8SLVRtmN834I1JcT9J";
66
67         public static void main(String[] args) {
68                 if (args != null && args.length == 2) {
69                         if (args[0].equals("-encrypt")) {
70                                 BasicTextEncryptor textEncryptor = new BasicTextEncryptor();
71                                 textEncryptor.setPassword(secret);
72                                 String plainText = textEncryptor.encrypt(args[1]);
73                                 System.out.println("Encrypted Password is :" + plainText);
74                                 return;
75                         }
76                 } else if (args != null && args.length > 0) {
77                         System.out.println(
78                                         "Usage: ./mmagent to run with the configuration \n -encrypt <password> to Encrypt Password for config ");
79                         return;
80                 }
81                 MirrorMakerAgent agent = new MirrorMakerAgent();
82                 if (agent.checkStartup()) {
83                         logger.info("mmagent started, loading properties");
84                         agent.checkAgentProcess();
85                         agent.readAgentTopic();
86                 } else {
87                         System.out.println(
88                                         "ERROR: mmagent startup unsuccessful, please make sure the mmagenthome /etc/mmagent.config is set and mechid have the rights to the topic");
89                 }
90         }
91
92         private boolean checkStartup() {
93                 FileInputStream input = null;
94                 try {
95                         this.mmagenthome = System.getProperty("MMAGENTHOME");
96                         input = new FileInputStream(mmagenthome + "/etc/mmagent.config");
97                         logger.info("mmagenthome is set :" + mmagenthome + " loading properties at /etc/mmagent.config");
98                 } catch (IOException ex) {
99                         logger.error(mmagenthome + "/etc/mmagent.config not found.  Set -DMMAGENTHOME and check the config file" + ex);
100                         return false;
101                 } finally {
102                         if (input != null) {
103                                 try {
104                                         input.close();
105                                 } catch (IOException e) {
106                                         logger.error(" IOException occers " + e);
107                                 }
108                         }
109                 }
110                 loadProperties();
111                 input = null;
112                 try {
113                         /*input = new FileInputStream(kafkahome + "/bin/kafka-run-class.sh");*/
114                         if(false) {
115                                 throw new IOException();
116                         }
117                         logger.info("kakahome is set :" + kafkahome);
118                 } catch (IOException ex) {
119                         logger.error(kafkahome + "/bin/kafka-run-class.sh not found.  Make sure kafka home is set correctly" + ex);
120                         return false;
121                 } finally {
122                         if (input != null) {
123                                 try {
124                                         input.close();
125                                 } catch (IOException e) {
126                                         logger.error("IOException" + e);
127                                 }
128                         }
129                 }
130                 String response = publishTopic("{\"test\":\"test\"}");
131                 if (response.startsWith("ERROR:")) {
132                         logger.error("Problem publishing to topic, please verify the config " + this.topicname + " MR URL is:"
133                                         + this.topicURL + " Error is:  " + response);
134                         return false;
135                 }
136                 logger.info("Published to Topic :" + this.topicname + " Successfully");
137                 response = subscribeTopic("1");
138                 if (response != null && response.startsWith("ERROR:")) {
139                         logger.error("Problem subscribing to topic, please verify the config " + this.topicname + " MR URL is:"
140                                         + this.topicURL + " Error is:  " + response);
141                         return false;
142                 }
143                 logger.info("Subscribed to Topic :" + this.topicname + " Successfully");
144                 return true;
145         }
146
147         private void checkPropertiesFile(String agentName, String propName, String info, boolean refresh) {
148                 InputStream input = null;
149                 OutputStream out = null;
150                 try {
151                         if (refresh) {
152                                 throw new IOException();
153                         }
154                         input = new FileInputStream(mmagenthome + "/etc/" + agentName + propName + ".properties");
155                 } catch (IOException ex) {
156                         logger.error(" IOException will be handled " + ex);
157                         try {
158                                 input = new FileInputStream(mmagenthome + "/etc/" + propName + ".properties");
159                                 Properties prop = new Properties();
160                                 prop.load(input);
161                                 if (propName.equals("consumer")) {
162                                         prop.setProperty("group.id", agentName);
163                                         prop.setProperty("zookeeper.connect", info);
164                                 } else {
165                                         prop.setProperty("metadata.broker.list", info);
166                                 }
167                                 out = new FileOutputStream(mmagenthome + "/etc/" + agentName + propName + ".properties");
168                                 prop.store(out, "");
169
170                         } catch (Exception e) {
171                                 logger.error("Exception at checkPropertiesFile " +e);
172                         }
173                 } finally {
174                         if (input != null) {
175                                 try {
176                                         input.close();
177                                 } catch (IOException e) {
178                                         logger.error("Exception occurred is " +e);
179                                 }
180                         }
181                         if (out != null) {
182                                 try {
183                                         out.close();
184                                 } catch (IOException e) {
185                                         e.printStackTrace();
186                                         logger.error("IOException" + e);
187                                 }
188                         }
189                 }
190         }
191
192         private void checkAgentProcess() {
193                 logger.info("Checking MirrorMaker Process");
194                 if (mirrorMakers != null) {
195                         int mirrorMakersCount = mirrorMakers.getListMirrorMaker().size();
196                         for (int i = 0; i < mirrorMakersCount; i++) {
197                                 MirrorMaker mm = mirrorMakers.getListMirrorMaker().get(i);
198                                 if (MirrorMakerProcessHandler.checkMirrorMakerProcess(mm.name) == false) {
199                                         checkPropertiesFile(mm.name, "consumer", mm.consumer, false);
200                                         checkPropertiesFile(mm.name, "producer", mm.producer, false);
201
202                                         if (mm.whitelist != null && !mm.whitelist.equals("")) {
203                                                 logger.info("MirrorMaker " + mm.name + " is not running, restarting.  Check Logs for more Details");
204                                                 MirrorMakerProcessHandler.startMirrorMaker(this.mmagenthome, this.kafkahome, mm.name,
205                                                                 mmagenthome + "/etc/" + mm.name + "consumer.properties",
206                                                                 mmagenthome + "/etc/" + mm.name + "producer.properties", mm.whitelist);
207                                                 mm.setStatus("RESTARTING");
208
209                                         } else {
210                                                 logger.info("MirrorMaker " + mm.name + " is STOPPED");
211                                                 mm.setStatus("STOPPED");
212                                         }
213                                         try {
214                                                 Thread.sleep(1000);
215                                         } catch (InterruptedException e) {
216                                                  Thread.currentThread().interrupt();
217                                         }
218                                         mirrorMakers.getListMirrorMaker().set(i, mm);
219                                 } else {
220                                         logger.info("MirrorMaker " + mm.name + " is running");
221                                         mm.setStatus("RUNNING");
222                                         mirrorMakers.getListMirrorMaker().set(i, mm);
223                                 }
224                         }
225                 }
226                 // Gson g = new Gson();
227                 // System.out.println(g.toJson(mirrorMakers));
228         }
229
230         private String subscribeTopic(String timeout) {
231                 String response = "";
232                 try {
233                         String requestURL = this.topicURL + "/events/" + this.topicname + "/mirrormakeragent/1?timeout=" + timeout
234                                         + "&limit=1";
235                         String authString = this.mechid + ":" + this.password;
236                         String authStringEnc = Base64.encode(authString.getBytes());
237                         URL url = new URL(requestURL);
238                         HttpURLConnection connection = (HttpURLConnection) url.openConnection();
239                         connection.setRequestMethod("GET");
240                         connection.setDoOutput(true);
241                         connection.setRequestProperty("Authorization", "Basic " + authStringEnc);
242                         connection.setRequestProperty("Content-Type", "application/json");
243                         InputStream content = (InputStream) connection.getInputStream();
244                         BufferedReader in = new BufferedReader(new InputStreamReader(content));
245                         String line;
246
247                         while ((line = in.readLine()) != null) {
248                                 response = response + line;
249                         }
250                         Gson g = new Gson();
251                         // get message as JSON String Array
252                         String[] topicMessage = g.fromJson(response, String[].class);
253                         if (topicMessage.length != 0) {
254                                 return topicMessage[0];
255                         }
256                 } catch (Exception e) {
257                         logger.error(" Exception Occered " + e);
258                         return "ERROR:" + e.getMessage() + " Server Response is:" + response;
259                 }
260                 return null;
261         }
262
263         private String publishTopic(String message) {
264                 try {
265                         String requestURL = this.topicURL + "/events/" + this.topicname;
266                         String authString = this.mechid + ":" + this.password;
267                         String authStringEnc = Base64.encode(authString.getBytes());
268                         URL url = new URL(requestURL);
269                         HttpURLConnection connection = (HttpURLConnection) url.openConnection();
270                         connection.setRequestMethod("POST");
271                         connection.setDoOutput(true);
272                         connection.setRequestProperty("Authorization", "Basic " + authStringEnc);
273                         connection.setRequestProperty("Content-Type", "application/json");
274                         connection.setRequestProperty("Content-Length", Integer.toString(message.length()));
275                         DataOutputStream wr = new DataOutputStream(connection.getOutputStream());
276                         wr.write(message.getBytes());
277
278                         InputStream content = (InputStream) connection.getInputStream();
279                         BufferedReader in = new BufferedReader(new InputStreamReader(content));
280                         String line;
281                         String response = "";
282                         while ((line = in.readLine()) != null) {
283                                 response = response + line;
284                         }
285                         return response;
286
287                 } catch (Exception e) {
288                         return "ERROR:" + e.getLocalizedMessage();
289                 }
290         }
291
292         private void readAgentTopic() {
293                 try {
294                         int connectionattempt = 0;
295                         while (true) {
296                                 logger.info("--------------------------------");
297                                 logger.info("Waiting for Messages for 60 secs");
298                                 String topicMessage = subscribeTopic("60000");
299                                 Gson g = new Gson();
300                                 LinkedTreeMap<?, ?> object = null;
301                                 if (topicMessage != null) {
302                                         try {
303                                                 object = g.fromJson(topicMessage, LinkedTreeMap.class);
304
305                                                 // Cast the 1st item (since limit=1 and see the type of
306                                                 // object
307                                                 if (object.get("createMirrorMaker") != null) {
308                                                         logger.info("Received createMirrorMaker request from topic");
309                                                         CreateMirrorMaker m = g.fromJson(topicMessage, CreateMirrorMaker.class);
310                                                         createMirrorMaker(m.getCreateMirrorMaker());
311                                                         checkAgentProcess();
312                                                         mirrorMakers.setMessageID(m.getMessageID());
313                                                         publishTopic(g.toJson(mirrorMakers));
314                                                         mirrorMakers.setMessageID("");
315                                                 } else if (object.get("updateMirrorMaker") != null) {
316                                                         logger.info("Received updateMirrorMaker request from topic");
317                                                         UpdateMirrorMaker m = g.fromJson(topicMessage, UpdateMirrorMaker.class);
318                                                         updateMirrorMaker(m.getUpdateMirrorMaker());
319                                                         checkAgentProcess();
320                                                         mirrorMakers.setMessageID(m.getMessageID());
321                                                         publishTopic(g.toJson(mirrorMakers));
322                                                         mirrorMakers.setMessageID("");
323                                                 } else if (object.get("deleteMirrorMaker") != null) {
324                                                         logger.info("Received deleteMirrorMaker request from topic");
325                                                         DeleteMirrorMaker m = g.fromJson(topicMessage, DeleteMirrorMaker.class);
326                                                         deleteMirrorMaker(m.getDeleteMirrorMaker());
327                                                         checkAgentProcess();
328                                                         mirrorMakers.setMessageID(m.getMessageID());
329                                                         publishTopic(g.toJson(mirrorMakers));
330                                                         mirrorMakers.setMessageID("");
331                                                 } else if (object.get("listAllMirrorMaker") != null) {
332                                                         logger.info("Received listALLMirrorMaker request from topic");
333                                                         checkAgentProcess();
334                                                         mirrorMakers.setMessageID((String) object.get("messageID"));
335                                                         publishTopic(g.toJson(mirrorMakers));
336                                                         mirrorMakers.setMessageID("");
337                                                 } else if (object.get("updateWhiteList") != null) {
338                                                         logger.info("Received updateWhiteList request from topic");
339                                                         UpdateWhiteList m = g.fromJson(topicMessage, UpdateWhiteList.class);
340                                                         updateWhiteList(m.getUpdateWhiteList());
341                                                         checkAgentProcess();
342                                                         mirrorMakers.setMessageID(m.getMessageID());
343                                                         publishTopic(g.toJson(mirrorMakers));
344                                                         mirrorMakers.setMessageID("");
345                                                 } else if (object.get("listMirrorMaker") != null) {
346                                                         logger.info("Received listMirrorMaker from topic, skipping messages");
347                                                 } else {
348                                                         logger.info("Received unknown request from topic");
349                                                 }
350                                         } catch (Exception ex) {
351                                                 connectionattempt++;
352                                                 if (connectionattempt > 5) {
353                                                         logger.info("Can't connect to the topic, mmagent shutting down , " + topicMessage);
354                                                         return;
355                                                 }
356                                                 logger.info("Can't connect to the topic, " + topicMessage + " Retrying " + connectionattempt
357                                                                 + " of 5 times in 1 minute" + " Error:" + ex.getLocalizedMessage());
358                                                 Thread.sleep(60000);
359                                         }
360                                 } else {
361                                         // Check all MirrorMaker every min
362                                         connectionattempt = 0;
363                                         checkAgentProcess();
364                                 }
365
366                         }
367                 } catch (Exception e) {
368                         logger.error("Exception is : " +e);
369                 }
370
371         }
372
373         protected void createMirrorMaker(MirrorMaker newMirrorMaker) {
374                 boolean exists = false;
375                 if (mirrorMakers != null) {
376                         int mirrorMakersCount = mirrorMakers.getListMirrorMaker().size();
377                         for (int i = 0; i < mirrorMakersCount; i++) {
378                                 MirrorMaker mm = mirrorMakers.getListMirrorMaker().get(i);
379                                 if (mm.name.equals(newMirrorMaker.name)) {
380                                         exists = true;
381                                         logger.info("MirrorMaker already exist for:" + newMirrorMaker.name);
382                                         return;
383                                 }
384                         }
385                 }
386                 logger.info("Adding new MirrorMaker:" + newMirrorMaker.name);
387                 if (exists == false && mirrorMakers != null) {
388                         mirrorMakers.getListMirrorMaker().add(newMirrorMaker);
389                 } else if (exists == false && mirrorMakers == null) {
390                         mirrorMakers = new ListMirrorMaker();
391                         ArrayList<MirrorMaker> list = mirrorMakers.getListMirrorMaker();
392                         list = new ArrayList<MirrorMaker>();
393                         list.add(newMirrorMaker);
394                         mirrorMakers.setListMirrorMaker(list);
395                 }
396                 checkPropertiesFile(newMirrorMaker.name, "consumer", newMirrorMaker.consumer, true);
397                 checkPropertiesFile(newMirrorMaker.name, "producer", newMirrorMaker.producer, true);
398
399                 Gson g = new Gson();
400                 mirrorMakerProperties.setProperty("mirrormakers", g.toJson(this.mirrorMakers));
401                 OutputStream out = null;
402                 try {
403                         out = new FileOutputStream(mmagenthome + "/etc/mmagent.config");
404                         mirrorMakerProperties.store(out, "");
405                 } catch (IOException ex) {
406                         ex.printStackTrace();
407                 } finally {
408                         if (out != null) {
409                                 try {
410                                         out.close();
411                                 } catch (IOException e) {
412                                         e.printStackTrace();
413                                 }
414                         }
415                 }
416         }
417
418         private void updateMirrorMaker(MirrorMaker newMirrorMaker) {
419                 boolean exists = false;
420                 if (mirrorMakers != null) {
421                         int mirrorMakersCount = mirrorMakers.getListMirrorMaker().size();
422                         for (int i = 0; i < mirrorMakersCount; i++) {
423                                 MirrorMaker mm = mirrorMakers.getListMirrorMaker().get(i);
424                                 if (mm.name.equals(newMirrorMaker.name)) {
425                                         exists = true;
426                                         mm.setConsumer(newMirrorMaker.getConsumer());
427                                         mm.setProducer(newMirrorMaker.getProducer());
428                                         mirrorMakers.getListMirrorMaker().set(i, mm);
429                                         logger.info("Updating MirrorMaker:" + newMirrorMaker.name);
430                                 }
431                         }
432                 }
433                 if (exists) {
434                         checkPropertiesFile(newMirrorMaker.name, "consumer", newMirrorMaker.consumer, true);
435                         checkPropertiesFile(newMirrorMaker.name, "producer", newMirrorMaker.producer, true);
436
437                         Gson g = new Gson();
438                         mirrorMakerProperties.setProperty("mirrormakers", g.toJson(this.mirrorMakers));
439                         OutputStream out = null;
440                         try {
441                                 out = new FileOutputStream(mmagenthome + "/etc/mmagent.config");
442                                 mirrorMakerProperties.store(out, "");
443                                 MirrorMakerProcessHandler.stopMirrorMaker(newMirrorMaker.name);
444                                 try {
445                                         Thread.sleep(1000);
446                                 } catch (InterruptedException e) {
447                                         logger.log(Level.WARN, "Interrupted!", e);
448                                         Thread.currentThread().interrupt();
449                                 }
450                         } catch (IOException ex) {
451                                 logger.error(" IOException Occered " + ex);
452                         } finally {
453                                 if (out != null) {
454                                         try {
455                                                 out.close();
456                                         } catch (IOException e) {
457                                                 logger.error(" IOException Occered " + e);
458                                         }
459                                 }
460                         }
461                 } else {
462                         logger.info("MirrorMaker Not found for:" + newMirrorMaker.name);
463                 }
464         }
465
466         private void updateWhiteList(MirrorMaker newMirrorMaker) {
467                 boolean exists = false;
468                 if (mirrorMakers != null) {
469                         int mirrorMakersCount = mirrorMakers.getListMirrorMaker().size();
470                         for (int i = 0; i < mirrorMakersCount; i++) {
471                                 MirrorMaker mm = mirrorMakers.getListMirrorMaker().get(i);
472                                 if (mm.name.equals(newMirrorMaker.name)) {
473                                         exists = true;
474                                         mm.setWhitelist(newMirrorMaker.whitelist);
475                                         mirrorMakers.getListMirrorMaker().set(i, mm);
476                                         logger.info("Updating MirrorMaker WhiteList:" + newMirrorMaker.name + " WhiteList:"
477                                                         + newMirrorMaker.whitelist);
478                                 }
479                         }
480                 }
481                 if (exists) {
482                         Gson g = new Gson();
483                         mirrorMakerProperties.setProperty("mirrormakers", g.toJson(this.mirrorMakers));
484                         OutputStream out = null;
485                         try {
486                                 out = new FileOutputStream(mmagenthome + "/etc/mmagent.config");
487                                 mirrorMakerProperties.store(out, "");
488                                 MirrorMakerProcessHandler.stopMirrorMaker(newMirrorMaker.name);
489                                 try {
490                                         Thread.sleep(1000);
491                                 } catch (InterruptedException e) {
492                                 }
493                         } catch (IOException ex) {
494                                 ex.printStackTrace();
495                         } finally {
496                                 if (out != null) {
497                                         try {
498                                                 out.close();
499                                         } catch (IOException e) {
500                                                 e.printStackTrace();
501                                                 logger.error("IOException occered " + e);
502                                         }
503                                 }
504                         }
505                 } else {
506                         logger.info("MirrorMaker Not found for:" + newMirrorMaker.name);
507                 }
508         }
509
510         private void deleteMirrorMaker(MirrorMaker newMirrorMaker) {
511                 boolean exists = false;
512                 if (mirrorMakers != null) {
513                         int mirrorMakersCount = mirrorMakers.getListMirrorMaker().size();
514                         for (int i = 0; i < mirrorMakersCount; i++) {
515                                 MirrorMaker mm = mirrorMakers.getListMirrorMaker().get(i);
516                                 if (mm.name.equals(newMirrorMaker.name)) {
517                                         exists = true;
518                                         mirrorMakers.getListMirrorMaker().remove(i);
519                                         logger.info("Removing MirrorMaker:" + newMirrorMaker.name);
520                                         i = mirrorMakersCount;
521                                 }
522                         }
523                 }
524                 if (exists) {
525                         try {
526                                 String path = mmagenthome + "/etc/" + newMirrorMaker.name + "consumer" + ".properties";
527                                 File file = new File(path);
528                                 file.delete();
529                         } catch (Exception ex) {
530                         }
531                         try {
532                                 String path = mmagenthome + "/etc/" + newMirrorMaker.name + "producer" + ".properties";
533                                 File file = new File(path);
534                                 file.delete();
535                         } catch (Exception ex) {
536                         }
537                         Gson g = new Gson();
538                         mirrorMakerProperties.setProperty("mirrormakers", g.toJson(this.mirrorMakers));
539                         OutputStream out = null;
540                         try {
541                                 out = new FileOutputStream(mmagenthome + "/etc/mmagent.config");
542                                 mirrorMakerProperties.store(out, "");
543                                 MirrorMakerProcessHandler.stopMirrorMaker(newMirrorMaker.name);
544                         } catch (IOException ex) {
545                                 ex.printStackTrace();
546                         } finally {
547                                 if (out != null) {
548                                         try {
549                                                 out.close();
550                                         } catch (IOException e) {
551                                                 e.printStackTrace();
552                                         }
553                                 }
554                         }
555                 } else {
556                         logger.info("MirrorMaker Not found for:" + newMirrorMaker.name);
557                 }
558         }
559
560         private void loadProperties() {
561                 InputStream input = null;
562                 try {
563
564                         input = new FileInputStream(mmagenthome + "/etc/mmagent.config");
565                         mirrorMakerProperties.load(input);
566                         Gson g = new Gson();
567                         if (mirrorMakerProperties.getProperty("mirrormakers") == null) {
568                                 this.mirrorMakers = new ListMirrorMaker();
569                                 ArrayList<MirrorMaker> list = this.mirrorMakers.getListMirrorMaker();
570                                 list = new ArrayList<MirrorMaker>();
571                                 this.mirrorMakers.setListMirrorMaker(list);
572                         } else {
573                                 this.mirrorMakers = g.fromJson(mirrorMakerProperties.getProperty("mirrormakers"),
574                                                 ListMirrorMaker.class);
575                         }
576
577                         this.kafkahome = mirrorMakerProperties.getProperty("kafkahome");
578                         this.topicURL = mirrorMakerProperties.getProperty("topicURL");
579                         this.topicname = mirrorMakerProperties.getProperty("topicname");
580                         this.mechid = mirrorMakerProperties.getProperty("mechid");
581
582                         BasicTextEncryptor textEncryptor = new BasicTextEncryptor();
583                         textEncryptor.setPassword(secret);
584                         //this.password = textEncryptor.decrypt(mirrorMakerProperties.getProperty("password"));
585                         this.password = mirrorMakerProperties.getProperty("password");
586                 } catch (IOException ex) {
587                         // ex.printStackTrace();
588                 } finally {
589                         if (input != null) {
590                                 try {
591                                         input.close();
592                                 } catch (IOException e) {
593                                         // e.printStackTrace();
594                                 }
595                         }
596                 }
597
598         }
599 }

© 2017 ONAP. Copyright © The Linux Foundation ®. All Rights Reserved.
The Linux Foundation has registered trademarks and uses trademarks.
For a list of trademarks of The Linux Foundation, please see our Trademark Usage page.
Linux is a registered trademark of Linus Torvalds.
Privacy Policy and Terms of Use