gnunet-svn
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[GNUnet-SVN] [taler-libeufin] 20/25: Server responds with ebicsHEVRespon


From: gnunet
Subject: [GNUnet-SVN] [taler-libeufin] 20/25: Server responds with ebicsHEVResponse.
Date: Fri, 20 Sep 2019 19:32:58 +0200

This is an automated email from the git hooks/post-receive script.

marcello pushed a commit to branch master
in repository libeufin.

commit f3165ef8b0ef399b3278f7aa332983151936e481
Author: Marcello Stanisci <address@hidden>
AuthorDate: Wed Sep 18 16:13:22 2019 +0200

    Server responds with ebicsHEVResponse.
---
 src/main/kotlin/Main.kt | 33 +++++++++++++++++++++++----------
 1 file changed, 23 insertions(+), 10 deletions(-)

diff --git a/src/main/kotlin/Main.kt b/src/main/kotlin/Main.kt
index 7516cdd..456438c 100644
--- a/src/main/kotlin/Main.kt
+++ b/src/main/kotlin/Main.kt
@@ -21,6 +21,7 @@ package tech.libeufin
 
 import io.ktor.application.*
 import io.ktor.http.*
+import io.ktor.http.content.TextContent
 import io.ktor.request.receiveText
 import io.ktor.response.*
 import io.ktor.routing.*
@@ -30,6 +31,7 @@ import tech.libeufin.XMLManagement;
 import java.io.ByteArrayInputStream
 import java.io.InputStream
 import org.w3c.dom.Document;
+import tech.libeufin.messages.HEVResponse
 import kotlin.reflect.jvm.internal.impl.load.kotlin.JvmType
 
 fun main(args: Array<String>) {
@@ -43,10 +45,12 @@ fun main(args: Array<String>) {
                 val body: String = call.receiveText()
                 println("Body: $body")
                 val isValid = xmlProcess.validate(body)
-                call.response.header("Content-Type", "application/xml")
 
                 if (!isValid) {
-                    call.respond(HttpStatusCode(400, "Invalid request"));
+                    System.out.println("Invalid request received")
+                    call.respondText(contentType = ContentType.Application.Xml,
+                                     status = HttpStatusCode.BadRequest) {"Bad 
request"};
+                    return@post
                 }
 
                 val bodyDocument = XMLManagement.parseStringIntoDom(body)
@@ -54,18 +58,27 @@ fun main(args: Array<String>) {
                 {
                     /* Should never happen.  */
                     System.out.println("A valid document failed to parse into 
DOM!")
-                    call.respond(HttpStatusCode(500, "Internal server error"));
+                    call.respondText(contentType = ContentType.Application.Xml,
+                        status = HttpStatusCode.InternalServerError) 
{"Internal server error"};
+                    return@post
                 }
 
-                /* FIXME: Check if that's a known type! */
-                if (true) {
-                    /* Log to console and return "unknown type" */
-                    System.out.println("Unknown message, just logging it!")
-                    call.respond(HttpStatusCode(400, "Not found"));
-                }
+                if ("ebicsHEVRequest" == bodyDocument.documentElement.tagName)
+                {
+                    /* known type, and already valid here! */
+                    val hevResponse: HEVResponse = HEVResponse("rc", "rt")
+                    val responseText: String = 
XMLManagement.getStringFromJaxb(hevResponse.makeHEVResponse())
 
-                /* Generate response here.  */
+                    call.respondText(contentType = ContentType.Application.Xml,
+                        status = HttpStatusCode.OK) {responseText};
+                    return@post
+                }
 
+                /* Log to console and return "unknown type" */
+                System.out.println("Unknown message, just logging it!")
+                call.respondText(contentType = ContentType.Application.Xml,
+                    status = HttpStatusCode.NotFound) {"Not found"};
+                return@post
 
             }
         }

-- 
To stop receiving notification emails like this one, please contact
address@hidden.



reply via email to

[Prev in Thread] Current Thread [Next in Thread]