[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.
- [GNUnet-SVN] [taler-libeufin] 05/25: Copyright header., (continued)
- [GNUnet-SVN] [taler-libeufin] 05/25: Copyright header., gnunet, 2019/09/20
- [GNUnet-SVN] [taler-libeufin] 01/25: Import initial project structure., gnunet, 2019/09/20
- [GNUnet-SVN] [taler-libeufin] 10/25: fix resource loading, gnunet, 2019/09/20
- [GNUnet-SVN] [taler-libeufin] 03/25: AGPL license, gnunet, 2019/09/20
- [GNUnet-SVN] [taler-libeufin] 12/25: Local test of XML validation., gnunet, 2019/09/20
- [GNUnet-SVN] [taler-libeufin] 11/25: import sample hev, gnunet, 2019/09/20
- [GNUnet-SVN] [taler-libeufin] 14/25: Test with XML imported from string., gnunet, 2019/09/20
- [GNUnet-SVN] [taler-libeufin] 13/25: fix test, gnunet, 2019/09/20
- [GNUnet-SVN] [taler-libeufin] 15/25: Abstracting string conversion to "stream"., gnunet, 2019/09/20
- [GNUnet-SVN] [taler-libeufin] 16/25: Introducing the converters:, gnunet, 2019/09/20
- [GNUnet-SVN] [taler-libeufin] 20/25: Server responds with ebicsHEVResponse.,
gnunet <=
- [GNUnet-SVN] [taler-libeufin] 18/25: method to get (XML) strings from JAXB objects., gnunet, 2019/09/20
- [GNUnet-SVN] [taler-libeufin] 23/25: Translating getLogger() into Kotlin., gnunet, 2019/09/20
- [GNUnet-SVN] [taler-libeufin] 19/25: Importing JAXB scaffolding to reflect ebics "hev" types., gnunet, 2019/09/20
- [GNUnet-SVN] [taler-libeufin] 21/25: Fix resource loading from JAR., gnunet, 2019/09/20
- [GNUnet-SVN] [taler-libeufin] 25/25: Finish translating Java into Kotlin., gnunet, 2019/09/20
- [GNUnet-SVN] [taler-libeufin] 17/25: Check if the message can be handled by the server., gnunet, 2019/09/20
- [GNUnet-SVN] [taler-libeufin] 24/25: Move XMLManagement.java to Kotlin., gnunet, 2019/09/20
- [GNUnet-SVN] [taler-libeufin] 22/25: Complete initial setup (#5888)., gnunet, 2019/09/20