WIP
[demos/kafka/wordcount] / src / main / java / de / juplo / kafka / sumup / gateway / ApplicationController.java
index 5fe69ad..3ae1552 100644 (file)
@@ -1,4 +1,4 @@
-package de.juplo.kafka.wordcount.recorder;
+package de.juplo.kafka.sumup.gateway;
 
 import org.apache.kafka.clients.producer.KafkaProducer;
 import org.apache.kafka.clients.producer.ProducerRecord;
@@ -15,13 +15,13 @@ import javax.validation.constraints.NotEmpty;
 
 
 @RestController
-public class RecorderController
+public class ApplicationController
 {
   private final String topic;
   private final KafkaProducer<String, String> producer;
 
 
-  public RecorderController(RecorderApplicationProperties properties, KafkaProducer<String,String> producer)
+  public ApplicationController(ApplicationProperties properties, KafkaProducer<String,String> producer)
   {
     this.topic = properties.getTopic();
     this.producer = producer;
@@ -34,7 +34,7 @@ public class RecorderController
           MimeTypeUtils.APPLICATION_JSON_VALUE
       },
       produces = MimeTypeUtils.APPLICATION_JSON_VALUE)
-  DeferredResult<ResponseEntity<RecordingResult>> speak(
+  DeferredResult<ResponseEntity<Result>> speak(
       @PathVariable
       @NotEmpty(message = "A username must be provided")
       String username,
@@ -42,7 +42,7 @@ public class RecorderController
       @NotEmpty(message = "The spoken sentence must not be empty!")
       String sentence)
   {
-    DeferredResult<ResponseEntity<RecordingResult>> result = new DeferredResult<>();
+    DeferredResult<ResponseEntity<Result>> result = new DeferredResult<>();
 
     ProducerRecord<String, String> record = new ProducerRecord<>(topic, username, sentence);
     producer.send(record, (metadata, exception) ->
@@ -50,7 +50,7 @@ public class RecorderController
       if (metadata != null)
       {
         result.setResult(
-            ResponseEntity.ok(RecordingResult.of(
+            ResponseEntity.ok(Result.of(
                 username,
                 sentence,
                 topic,
@@ -64,7 +64,7 @@ public class RecorderController
         result.setErrorResult(
             ResponseEntity
                 .internalServerError()
-                .body(RecordingResult.of(
+                .body(Result.of(
                     username,
                     sentence,
                     topic,