commit c98ef14e575b971fde2c762aa88524ac6053ce73
parent f85b0139e15df8ef3a13ff0e28ca9287f2bcc80d
Author: Marcello Stanisci <stanisci.m@gmail.com>
Date: Tue, 5 Nov 2019 23:31:43 +0100
make systemID nullable + catch != 200 responses (nexus)
Diffstat:
2 files changed, 25 insertions(+), 8 deletions(-)
diff --git a/nexus/src/main/kotlin/DB.kt b/nexus/src/main/kotlin/DB.kt
@@ -13,7 +13,7 @@ object EbicsSubscribersTable: IntIdTable() {
val hostID = text("hostID")
val partnerID = text("partnerID")
val userID = text("userID")
- val systemID = text("systemID")
+ val systemID = text("systemID").nullable()
val signaturePrivateKey = blob("signaturePrivateKey")
val encryptionPrivateKey = blob("encryptionPrivateKey")
val authenticationPrivateKey = blob("authenticationPrivateKey")
diff --git a/nexus/src/main/kotlin/Main.kt b/nexus/src/main/kotlin/Main.kt
@@ -66,7 +66,6 @@ fun testData() {
ebicsURL = "http://localhost:5000/ebicsweb"
userID = "USER1"
partnerID = "PARTNER1"
- systemID = "SYSTEM1"
hostID = "host01"
signaturePrivateKey = SerialBlob(pairA.private.encoded)
@@ -224,12 +223,30 @@ fun main() {
}
logger.info("POSTing to ${url}")
- val response = client.post<EbicsKeyManagementResponse>(
- urlString = url,
- block = {
- body = XMLUtil.convertJaxbToString(iniRequest)
- }
- )
+
+ val response = try {
+ client.post<String>(
+ urlString = url,
+ block = {
+ body = XMLUtil.convertJaxbToString(iniRequest)
+ }
+ )
+ } catch (e: Exception) {
+ e.printStackTrace()
+
+ call.respond(
+ HttpStatusCode.OK,
+ NexusError("Exception thrown by HTTP client (likely server responded != 200).")
+ )
+ return@post
+ }
+
+ /**
+ * TODO: check response status code,
+ * and act accordingly when it differs from 200.
+ */
+
+ // works: val responseJaxb = XMLUtil.convertStringToJaxb<EbicsKeyManagementResponse>(response)
call.respond(
HttpStatusCode.OK,