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;
@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)
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;
}
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();
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());