newdb.setName(dbConfig.getName());
newdb.setHost(dbConfig.getHost());
newdb.setPort(dbConfig.getPort());
+ newdb.setEnabled(dbConfig.isEnabled());
newdb.setLogin(dbConfig.getLogin());
newdb.setPass(dbConfig.getPassword());
newdb.setEncrypt(false);
- if(dbConfig.getName().equals("Elecsticsearch") || dbConfig.getName().equals("Druid"))
+ if(!dbConfig.getName().equals("Elecsticsearch") || !dbConfig.getName().equals("Druid"))
{
newdb.setDatabase(new String(dbConfig.getDatabase()));
}
return null;
}
+ if(!dbName.equals(dbConfig.getName()))
+ {
+ sendError(response, 400, "Mismatch DB name.");
+ return null;
+ }
+
Db oldDb = dbService.getDb(dbConfig.getName());
if (oldDb == null) {
sendError(response, 404, "Db not found: " + dbConfig.getName());
oldDb.setName(dbConfig.getName());
oldDb.setHost(dbConfig.getHost());
oldDb.setPort(dbConfig.getPort());
+ oldDb.setEnabled(dbConfig.isEnabled());
oldDb.setLogin(dbConfig.getLogin());
oldDb.setPass(dbConfig.getPassword());
oldDb.setEncrypt(false);
- if(oldDb.getName().equals("Elecsticsearch") || oldDb.getName().equals("Druid"))
+ if(!oldDb.getName().equals("Elecsticsearch") || !oldDb.getName().equals("Druid"))
{
oldDb.setDatabase(dbConfig.getDatabase());
}
{
dbConfigMsg.setName(db.getName());
dbConfigMsg.setHost(db.getHost());
+ dbConfigMsg.setEnabled(db.isEnabled());
dbConfigMsg.setPort(db.getPort());
+ dbConfigMsg.setLogin(db.getLogin());
+ dbConfigMsg.setDatabase(db.getDatabase());
+
+
}
private void sendError(HttpServletResponse response, int sc, String msg) throws IOException {
}
}
+ @DeleteMapping("/{topicName}")
+ @ResponseBody
+ @ApiOperation(value="Update a topic.")
+ public void deleteTopic(@PathVariable("topicName") String topicName, HttpServletResponse response) throws IOException
+ {
+ Topic oldTopic = topicService.getTopic(topicName);
+ if (oldTopic == null) {
+ sendError(response, 404, "Topic not found "+topicName);
+ } else {
+ Set<Db> dbRelation = oldTopic.getDbs();
+ dbRelation.clear();
+ topicRepository.save(oldTopic);
+ topicRepository.delete(oldTopic);
+ response.setStatus(204);
+ }
+ }
+
private PostReturnBody<TopicConfig> mkPostReturnBody(int statusCode, Topic topic)
{
PostReturnBody<TopicConfig> retBody = new PostReturnBody<>();