summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorRama-Huawei <rama.subba.reddy.s@huawei.com>2019-09-10 16:21:18 +0530
committerVijay Venkatesh Kumar <vv770d@att.com>2019-09-10 13:46:13 +0000
commit9fed0b36e89a08c9dead91d4fbf0c5176079d96d (patch)
treea22dcea4596cc484c8261de10731a42856b8ee85
parent772edf562676075f0662d14f0bdaf573da3f6568 (diff)
Defined a constant for this literal "Db not found"
Removed the declaration of thrown exception, as it can't be thrown from method's body Issue-ID: DCAEGEN2-1468 Signed-off-by: Rama-Huawei <rama.subba.reddy.s@huawei.com> Change-Id: I341b5ea67dd643503fee9077a7073aeb8adbc15a
-rw-r--r--components/datalake-handler/feeder/src/main/java/org/onap/datalake/feeder/controller/DbController.java9
1 files changed, 5 insertions, 4 deletions
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 cff29596..2d130b83 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
@@ -55,6 +55,7 @@ import io.swagger.annotations.ApiOperation;
public class DbController {
private final Logger log = LoggerFactory.getLogger(this.getClass());
+ private static final String DB_NOT_FOUND = "Db not found: ";
@Autowired
private DbRepository dbRepository;
@@ -66,7 +67,7 @@ public class DbController {
@GetMapping("")
@ResponseBody
@ApiOperation(value="Gat all databases name")
- public List<String> list() throws IOException {
+ public List<String> list() {
Iterable<Db> ret = dbRepository.findAll();
List<String> retString = new ArrayList<>();
for(Db db : ret)
@@ -141,7 +142,7 @@ public class DbController {
public Db getDb(@PathVariable("dbName") String dbName, HttpServletResponse response) throws IOException {
Db db = dbRepository.findByName(dbName);
if (db == null) {
- sendError(response, 404, "Db not found: " + dbName);
+ sendError(response, 404, DB_NOT_FOUND + dbName);
}
return db;
}
@@ -157,7 +158,7 @@ public class DbController {
Db delDb = dbRepository.findByName(dbName);
if (delDb == null) {
- sendError(response, 404, "Db not found: " + dbName);
+ sendError(response, 404, DB_NOT_FOUND + dbName);
return;
}
Set<Topic> topicRelation = delDb.getTopics();
@@ -197,7 +198,7 @@ public class DbController {
Db oldDb = dbRepository.findById(dbConfig.getId()).get();
if (oldDb == null) {
- sendError(response, 404, "Db not found: " + dbConfig.getName());
+ sendError(response, 404, DB_NOT_FOUND + dbConfig.getName());
return null;
} else {
oldDb.setHost(dbConfig.getHost());