Defined a constant for this literal "Db not found" 34/95334/2
authorRama-Huawei <rama.subba.reddy.s@huawei.com>
Tue, 10 Sep 2019 10:51:18 +0000 (16:21 +0530)
committerVijay Venkatesh Kumar <vv770d@att.com>
Tue, 10 Sep 2019 13:46:13 +0000 (13:46 +0000)
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

components/datalake-handler/feeder/src/main/java/org/onap/datalake/feeder/controller/DbController.java

index cff2959..2d130b8 100644 (file)
@@ -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());