summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--components/datalake-handler/feeder/src/main/java/org/onap/datalake/feeder/config/SwaggerConfig.java4
-rw-r--r--components/datalake-handler/feeder/src/main/java/org/onap/datalake/feeder/controller/KafkaController.java13
-rw-r--r--components/datalake-handler/feeder/src/main/java/org/onap/datalake/feeder/controller/TopicController.java20
-rw-r--r--components/datalake-handler/feeder/src/main/java/org/onap/datalake/feeder/repository/TopicRepository.java2
-rw-r--r--components/datalake-handler/feeder/src/main/java/org/onap/datalake/feeder/service/TopicService.java4
-rw-r--r--components/datalake-handler/feeder/src/test/java/org/onap/datalake/feeder/controller/TopicControllerTest.java4
6 files changed, 37 insertions, 10 deletions
diff --git a/components/datalake-handler/feeder/src/main/java/org/onap/datalake/feeder/config/SwaggerConfig.java b/components/datalake-handler/feeder/src/main/java/org/onap/datalake/feeder/config/SwaggerConfig.java
index dcf00a90..a9038bfe 100644
--- a/components/datalake-handler/feeder/src/main/java/org/onap/datalake/feeder/config/SwaggerConfig.java
+++ b/components/datalake-handler/feeder/src/main/java/org/onap/datalake/feeder/config/SwaggerConfig.java
@@ -55,6 +55,6 @@ public class SwaggerConfig {
// Only select apis that matches the given Predicates.
private Predicate<String> paths() {
// Match all paths except /error
- return Predicates.or(PathSelectors.regex("/dbs.*"), PathSelectors.regex("/topics.*"), PathSelectors.regex("/feeder.*"));
+ return Predicates.or(PathSelectors.regex("/dbs.*"), PathSelectors.regex("/topics.*"), PathSelectors.regex("/feeder.*"), PathSelectors.regex("/kafkas.*"));
}
-} \ No newline at end of file
+}
diff --git a/components/datalake-handler/feeder/src/main/java/org/onap/datalake/feeder/controller/KafkaController.java b/components/datalake-handler/feeder/src/main/java/org/onap/datalake/feeder/controller/KafkaController.java
index 8d1bf316..41995e04 100644
--- a/components/datalake-handler/feeder/src/main/java/org/onap/datalake/feeder/controller/KafkaController.java
+++ b/components/datalake-handler/feeder/src/main/java/org/onap/datalake/feeder/controller/KafkaController.java
@@ -36,6 +36,7 @@ import org.springframework.web.bind.annotation.*;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;
import java.util.List;
+import java.util.ArrayList;
/**
* This controller manages kafka settings
@@ -129,7 +130,17 @@ public class KafkaController {
@GetMapping("")
@ResponseBody
- @ApiOperation(value="List all Kafkas")
+ @ApiOperation(value="List all Kafka id")
+ public List<Integer> list() {
+ Iterable<Kafka> ret = kafkaRepository.findAll();
+ List<Integer> retString = new ArrayList<>();
+ for (Kafka k : ret)
+ {
+ retString.add(k.getId());
+ }
+ return retString;
+ }
+
public List<KafkaConfig> queryAllKafka(){
return kafkaService.getAllKafka();
}
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 b59b2a7b..2500075b 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
@@ -93,16 +93,28 @@ public class TopicController {
return dmaapService.getTopics();
}
+ @GetMapping("/default")
+ @ResponseBody
+ @ApiOperation(value = "Get default topic configuration.")
+ public TopicConfig getDefaultConfig(HttpServletResponse response) throws IOException {
+ Topic topic = topicService.getDefaultTopicFromFeeder();
+ if(topic == null) {
+ sendError(response, 404, "Topic not found");
+ return null;
+ }
+ return topic.getTopicConfig();
+ }
+
@GetMapping("")
@ResponseBody
- @ApiOperation(value="List all topic names in database")
- public List<String> list() {
+ @ApiOperation(value="List all topic id in database")
+ public List<Integer> list() {
Iterable<Topic> ret = topicRepository.findAll();
- List<String> retString = new ArrayList<>();
+ List<Integer> retString = new ArrayList<>();
for(Topic item : ret)
{
if(!topicService.isDefaultTopic(item))
- retString.add(item.getName());
+ retString.add(item.getId());
}
return retString;
}
diff --git a/components/datalake-handler/feeder/src/main/java/org/onap/datalake/feeder/repository/TopicRepository.java b/components/datalake-handler/feeder/src/main/java/org/onap/datalake/feeder/repository/TopicRepository.java
index 8f72dfed..5dcee9e1 100644
--- a/components/datalake-handler/feeder/src/main/java/org/onap/datalake/feeder/repository/TopicRepository.java
+++ b/components/datalake-handler/feeder/src/main/java/org/onap/datalake/feeder/repository/TopicRepository.java
@@ -32,5 +32,5 @@ import org.springframework.data.repository.CrudRepository;
*/
public interface TopicRepository extends CrudRepository<Topic, Integer> {
- //List<Topic> findByTopicName(String topicStr);
+ Topic findByTopicName_Id(String topicName);
}
diff --git a/components/datalake-handler/feeder/src/main/java/org/onap/datalake/feeder/service/TopicService.java b/components/datalake-handler/feeder/src/main/java/org/onap/datalake/feeder/service/TopicService.java
index 043cc653..e13a5d60 100644
--- a/components/datalake-handler/feeder/src/main/java/org/onap/datalake/feeder/service/TopicService.java
+++ b/components/datalake-handler/feeder/src/main/java/org/onap/datalake/feeder/service/TopicService.java
@@ -119,6 +119,10 @@ public class TopicService {
return ret.isPresent() ? ret.get() : null;
}
+ public Topic getDefaultTopicFromFeeder() {
+ return topicRepository.findByTopicName_Id(config.getDefaultTopicName());
+ }
+
public Topic getDefaultTopic(Kafka kafka) {
return findTopics(kafka, config.getDefaultTopicName()).get(0);
}
diff --git a/components/datalake-handler/feeder/src/test/java/org/onap/datalake/feeder/controller/TopicControllerTest.java b/components/datalake-handler/feeder/src/test/java/org/onap/datalake/feeder/controller/TopicControllerTest.java
index 1a866bd1..988010ec 100644
--- a/components/datalake-handler/feeder/src/test/java/org/onap/datalake/feeder/controller/TopicControllerTest.java
+++ b/components/datalake-handler/feeder/src/test/java/org/onap/datalake/feeder/controller/TopicControllerTest.java
@@ -163,8 +163,8 @@ public class TopicControllerTest {
topics.add(TestUtil.newTopic(DEFAULT_TOPIC_NAME));
when(topicRepository.findAll()).thenReturn(topics);
- List<String> strings = topicController.list();
- for (String topic : strings) {
+ List<Integer> ids = topicController.list();
+ for (Integer topic : ids) {
System.out.println(topic);
}
}