Merge "Introduce global SSL flag"
diff --git a/components/datalake-handler/feeder/src/assembly/scripts/init_db.sql b/components/datalake-handler/feeder/src/assembly/scripts/init_db.sql
index 48cb5f9..32b9268 100644
--- a/components/datalake-handler/feeder/src/assembly/scripts/init_db.sql
+++ b/components/datalake-handler/feeder/src/assembly/scripts/init_db.sql
@@ -43,9 +43,9 @@
 ) ENGINE=InnoDB DEFAULT CHARSET=utf8;

 

 

-insert into db (name,host,login,pass,database) values ('Couchbase','dl_couchbase','dl','dl1234','datalake');

+insert into db (name,host,login,pass,`database`) values ('Couchbase','dl_couchbase','dl','dl1234','datalake');

 insert into db (name,host) values ('Elasticsearch','dl_es');

-insert into db (name,host,port,database) values ('MongoDB','dl_mongodb',27017,'datalake');

+insert into db (name,host,port,`database`) values ('MongoDB','dl_mongodb',27017,'datalake');

 insert into db (name,host) values ('Druid','dl_druid');

 

 

@@ -54,4 +54,7 @@
 insert into `topic`(`name`,`enabled`) values ('__consumer_offsets',0);

 

 

+insert into `map_db_topic`(`db_name`,`topic_name`) values ('Couchbase','_DL_DEFAULT_');

+insert into `map_db_topic`(`db_name`,`topic_name`) values ('Elasticsearch','_DL_DEFAULT_');

 insert into `map_db_topic`(`db_name`,`topic_name`) values ('MongoDB','_DL_DEFAULT_');

+insert into `map_db_topic`(`db_name`,`topic_name`) values ('Druid','_DL_DEFAULT_');

diff --git a/components/datalake-handler/feeder/src/main/java/org/onap/datalake/feeder/config/ApplicationConfiguration.java b/components/datalake-handler/feeder/src/main/java/org/onap/datalake/feeder/config/ApplicationConfiguration.java
index 1136e30..6bacf13 100644
--- a/components/datalake-handler/feeder/src/main/java/org/onap/datalake/feeder/config/ApplicationConfiguration.java
+++ b/components/datalake-handler/feeder/src/main/java/org/onap/datalake/feeder/config/ApplicationConfiguration.java
@@ -51,5 +51,6 @@
 	private int kafkaConsumerCount;
 
 	private boolean async;
+	private boolean enableSSL;
 
 }
diff --git a/components/datalake-handler/feeder/src/main/java/org/onap/datalake/feeder/service/MongodbService.java b/components/datalake-handler/feeder/src/main/java/org/onap/datalake/feeder/service/MongodbService.java
index 9008fc9..35426af 100644
--- a/components/datalake-handler/feeder/src/main/java/org/onap/datalake/feeder/service/MongodbService.java
+++ b/components/datalake-handler/feeder/src/main/java/org/onap/datalake/feeder/service/MongodbService.java
@@ -32,7 +32,7 @@
 import org.bson.Document;
 
 import org.json.JSONObject;
-
+import org.onap.datalake.feeder.config.ApplicationConfiguration;
 import org.onap.datalake.feeder.domain.Db;
 import org.onap.datalake.feeder.domain.Topic;
 import org.slf4j.Logger;
@@ -50,7 +50,7 @@
 import com.mongodb.client.MongoDatabase;
 
 /**
- * Service to use MongoDB
+ * Service for using MongoDB
  * 
  * @author Guobiao Mo
  *
@@ -61,6 +61,9 @@
 	private final Logger log = LoggerFactory.getLogger(this.getClass());
 
 	@Autowired
+	private ApplicationConfiguration config;
+
+	@Autowired
 	private DbService dbService;
 
 	private MongoDatabase database;
@@ -89,13 +92,19 @@
 
 		Builder builder = MongoClientOptions.builder();
 		builder.serverSelectionTimeout(30000);//server selection timeout, in milliseconds
-		
+
 		//http://mongodb.github.io/mongo-java-driver/3.0/driver/reference/connecting/ssl/
-		builder.sslEnabled(Boolean.TRUE.equals(mongodb.getEncrypt()));// getEncrypt() can be null
+		if (config.isEnableSSL()) {
+			builder.sslEnabled(Boolean.TRUE.equals(mongodb.getEncrypt()));// getEncrypt() can be null
+		}
 		MongoClientOptions options = builder.build();
 
-		mongoClient = new MongoClient(new ServerAddress(host, port), credential, options);
-		database = mongoClient.getDatabase(mongodb.getDatabase());
+		if (credential == null) {
+			mongoClient = new MongoClient(new ServerAddress(host, port), options);
+		} else {
+			mongoClient = new MongoClient(new ServerAddress(host, port), credential, options);
+		}
+		database = mongoClient.getDatabase(databaseName);
 	}
 
 	@PreDestroy
diff --git a/components/datalake-handler/feeder/src/main/resources/application.properties b/components/datalake-handler/feeder/src/main/resources/application.properties
index ea94d00..42b1345 100644
--- a/components/datalake-handler/feeder/src/main/resources/application.properties
+++ b/components/datalake-handler/feeder/src/main/resources/application.properties
@@ -9,8 +9,8 @@
 
 #spring.datasource.driver-class-name=com.mysql.jdbc.Driver
 spring.datasource.url=jdbc:mariadb://dl_mariadb:3306/datalake?autoReconnect=true&useUnicode=true&characterEncoding=UTF-8
-spring.datasource.username=nook
-spring.datasource.password=nook123
+spring.datasource.username=dl
+spring.datasource.password=dl1234
 
 
 #For Beijing lab
@@ -35,6 +35,9 @@
 #tolerate inconsistency when system crash, see PullThread.run()
 async=true
 
+#SSL global flag, if enabled, still need to check each individual DB SSL flag
+enableSSL=false
+
 #Logging
 logging.level.org.springframework.web=ERROR
 logging.level.com.att.nsa.apiClient.http=ERROR
diff --git a/components/datalake-handler/pom.xml b/components/datalake-handler/pom.xml
index 45db09d..ee53ab3 100644
--- a/components/datalake-handler/pom.xml
+++ b/components/datalake-handler/pom.xml
@@ -31,7 +31,7 @@
 		<springcouchbase.version>3.1.2.RELEASE</springcouchbase.version>
 		<jackson.version>2.9.6</jackson.version>
 		<kafka.version>2.0.0</kafka.version>
-		<elasticsearchjava.version>7.0.0-rc2</elasticsearchjava.version>
+		<elasticsearchjava.version>7.0.0</elasticsearchjava.version>
 
 	</properties>