diff options
author | Rama-Huawei <rama.subba.reddy.s@huawei.com> | 2019-08-07 14:15:52 +0530 |
---|---|---|
committer | Rama-Huawei <rama.subba.reddy.s@huawei.com> | 2019-08-07 14:15:52 +0530 |
commit | 50896f0eab1bc427ee724d8e74cc8469ab04fa0c (patch) | |
tree | 7e1c2e9b03180d9de950a6946f7e9ca0ab51434b | |
parent | 985ec5787f1131b629b8eed01e1bf1734998e2dd (diff) |
Return an empty collection instead of null
Issue-ID: DCAEGEN2-1468
Signed-off-by: Rama-Huawei <rama.subba.reddy.s@huawei.com>
Change-Id: I294014cd009ae02983e575c94e830b2ff30e7b07
6 files changed, 7 insertions, 29 deletions
diff --git a/components/datalake-handler/feeder/src/main/java/com/mongodb/internal/validator/CollectibleDocumentFieldNameValidator.java b/components/datalake-handler/feeder/src/main/java/com/mongodb/internal/validator/CollectibleDocumentFieldNameValidator.java index e7a8e1b9..cde4d43d 100644 --- a/components/datalake-handler/feeder/src/main/java/com/mongodb/internal/validator/CollectibleDocumentFieldNameValidator.java +++ b/components/datalake-handler/feeder/src/main/java/com/mongodb/internal/validator/CollectibleDocumentFieldNameValidator.java @@ -42,15 +42,7 @@ public class CollectibleDocumentFieldNameValidator implements FieldNameValidator throw new IllegalArgumentException("Field name can not be null");
}
- /* dl change
- if (fieldName.contains(".")) {
- return false;
- }*/
-
- if (fieldName.startsWith("$") && !EXCEPTIONS.contains(fieldName)) {
- return false;
- }
- return true;
+ return !fieldName.startsWith("$") || EXCEPTIONS.contains(fieldName);
}
@Override
diff --git a/components/datalake-handler/feeder/src/main/java/org/onap/datalake/feeder/controller/DbController.java b/components/datalake-handler/feeder/src/main/java/org/onap/datalake/feeder/controller/DbController.java index f177a9ac..9fa8f490 100644 --- a/components/datalake-handler/feeder/src/main/java/org/onap/datalake/feeder/controller/DbController.java +++ b/components/datalake-handler/feeder/src/main/java/org/onap/datalake/feeder/controller/DbController.java @@ -61,7 +61,6 @@ public class DbController { @GetMapping("") @ResponseBody @ApiOperation(value="Gat all databases name") - //public Iterable<Db> list() throws IOException { public List<String> list() throws IOException { Iterable<Db> ret = dbRepository.findAll(); List<String> retString = new ArrayList<>(); @@ -112,7 +111,7 @@ public class DbController { newdb.setPass(dbConfig.getPassword()); newdb.setEncrypt(dbConfig.isEncrypt()); - if(!dbConfig.getName().equals("Elecsticsearch") || !dbConfig.getName().equals("Druid")) + if(!dbConfig.getName().equals("Elecsticsearch") || dbConfig.getName().equals("Druid")) { newdb.setDatabase(new String(dbConfig.getDatabase())); } @@ -134,10 +133,6 @@ public class DbController { @ResponseBody @ApiOperation(value="Get a database's details.") public Db getDb(@PathVariable("dbName") String dbName, HttpServletResponse response) throws IOException { - /*Db db = dbService.getDb(dbName); - if (db == null) { - sendError(response, 404, "Db not found: " + dbName); - }*/ Db db = dbRepository.findByName(dbName); if (db == null) { sendError(response, 404, "Db not found: " + dbName); @@ -171,21 +166,18 @@ public class DbController { @ResponseBody @ApiOperation(value="Get a database's all topics.") public Set<Topic> getDbTopics(@PathVariable("dbName") String dbName, HttpServletResponse response) throws IOException { - //Db db = dbService.getDb(dbName); Set<Topic> topics; try { Db db = dbRepository.findByName(dbName); topics = db.getTopics(); - }catch(Exception ex) - { + } catch(Exception ex) { sendError(response, 404, "DB: " + dbName + " or Topics not found"); - return null; + return Collections.emptySet(); } return topics; } - //Update Db @PutMapping("") @ResponseBody diff --git a/components/datalake-handler/feeder/src/main/java/org/onap/datalake/feeder/controller/FeederController.java b/components/datalake-handler/feeder/src/main/java/org/onap/datalake/feeder/controller/FeederController.java index 0a64ddb3..d9080ec0 100644 --- a/components/datalake-handler/feeder/src/main/java/org/onap/datalake/feeder/controller/FeederController.java +++ b/components/datalake-handler/feeder/src/main/java/org/onap/datalake/feeder/controller/FeederController.java @@ -92,7 +92,7 @@ public class FeederController { @ApiOperation(value="Retrieve feeder status.") public String status() { String status = "Feeder is running: "+pullService.isRunning(); - log.info("sending feeder status ...");//TODO we can send what topics are monitored, how many messages are sent, etc. + log.info("sending feeder status ..." + status);//TODO we can send what topics are monitored, how many messages are sent, etc. return "{\"version\": \""+config.getDatalakeVersion()+"\", \"running\": "+pullService.isRunning()+"}"; } diff --git a/components/datalake-handler/feeder/src/main/java/org/onap/datalake/feeder/controller/TopicController.java b/components/datalake-handler/feeder/src/main/java/org/onap/datalake/feeder/controller/TopicController.java index bb0de4b0..b59b2a7b 100644 --- a/components/datalake-handler/feeder/src/main/java/org/onap/datalake/feeder/controller/TopicController.java +++ b/components/datalake-handler/feeder/src/main/java/org/onap/datalake/feeder/controller/TopicController.java @@ -72,9 +72,6 @@ public class TopicController { private final Logger log = LoggerFactory.getLogger(this.getClass()); - //@Autowired - //private DmaapService dmaapService; - @Autowired private ApplicationContext context; diff --git a/components/datalake-handler/feeder/src/main/java/org/onap/datalake/feeder/domain/Kafka.java b/components/datalake-handler/feeder/src/main/java/org/onap/datalake/feeder/domain/Kafka.java index 7f7b59e8..de80db70 100644 --- a/components/datalake-handler/feeder/src/main/java/org/onap/datalake/feeder/domain/Kafka.java +++ b/components/datalake-handler/feeder/src/main/java/org/onap/datalake/feeder/domain/Kafka.java @@ -95,10 +95,6 @@ public class Kafka { @Column(name="`timeout_sec`", columnDefinition = "integer default 10") private Integer timeout; - //don't show this field in admin UI - //@Column(name="`check_topic_interval_sec`", columnDefinition = "integer default 10") -// private Integer checkTopicInterval; - @JsonBackReference @ManyToMany(fetch = FetchType.EAGER) @JoinTable( name = "map_kafka_topic", diff --git a/components/datalake-handler/feeder/src/test/java/org/onap/datalake/feeder/controller/DbControllerTest.java b/components/datalake-handler/feeder/src/test/java/org/onap/datalake/feeder/controller/DbControllerTest.java index 8c18c405..54f53877 100644 --- a/components/datalake-handler/feeder/src/test/java/org/onap/datalake/feeder/controller/DbControllerTest.java +++ b/components/datalake-handler/feeder/src/test/java/org/onap/datalake/feeder/controller/DbControllerTest.java @@ -45,6 +45,7 @@ import java.util.HashSet; import java.util.List; import java.util.Optional; import java.util.Set; +import java.util.Collections; import static org.junit.Assert.assertEquals; import static org.junit.Assert.assertNotEquals; @@ -159,7 +160,7 @@ public class DbControllerTest { db1.setTopics(topics); setAccessPrivateFields(dbController); Set<Topic> elecsticsearch = dbController.getDbTopics(dbName, httpServletResponse); - assertEquals(null, elecsticsearch); + assertEquals(Collections.emptySet(), elecsticsearch); when(dbRepository.findByName(dbName)).thenReturn(db1); elecsticsearch = dbController.getDbTopics(dbName, httpServletResponse); for (Topic anElecsticsearch : elecsticsearch) { |