gnunet-svn
[Top][All Lists]
Advanced

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

[libeufin] branch master updated: Nexus: unzip the C52 response.


From: gnunet
Subject: [libeufin] branch master updated: Nexus: unzip the C52 response.
Date: Tue, 17 Mar 2020 18:31:55 +0100

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

marcello pushed a commit to branch master
in repository libeufin.

The following commit(s) were added to refs/heads/master by this push:
     new 855350f  Nexus: unzip the C52 response.
855350f is described below

commit 855350fdc3ee3156a1110182fb004c63657ef1c1
Author: Marcello Stanisci <address@hidden>
AuthorDate: Tue Mar 17 18:31:14 2020 +0100

    Nexus: unzip the C52 response.
---
 nexus/src/main/kotlin/tech/libeufin/nexus/Helpers.kt | 14 ++++++++++++++
 nexus/src/main/kotlin/tech/libeufin/nexus/Main.kt    | 14 ++------------
 2 files changed, 16 insertions(+), 12 deletions(-)

diff --git a/nexus/src/main/kotlin/tech/libeufin/nexus/Helpers.kt 
b/nexus/src/main/kotlin/tech/libeufin/nexus/Helpers.kt
index 1f5f04d..f4f55bf 100644
--- a/nexus/src/main/kotlin/tech/libeufin/nexus/Helpers.kt
+++ b/nexus/src/main/kotlin/tech/libeufin/nexus/Helpers.kt
@@ -1,6 +1,8 @@
 package tech.libeufin.nexus
 
 import io.ktor.http.HttpStatusCode
+import org.apache.commons.compress.archivers.zip.ZipFile
+import org.apache.commons.compress.utils.SeekableInMemoryByteChannel
 
 /**
  * Inserts spaces every 2 characters, and a newline after 8 pairs.
@@ -27,3 +29,15 @@ fun chunkString(input: String): String {
 fun expectId(param: String?): String {
     return param ?: throw NexusError(HttpStatusCode.BadRequest, "Bad ID given")
 }
+
+fun unzipOrderData(od: ByteArray): String {
+    val mem = SeekableInMemoryByteChannel(od)
+    val zipFile = ZipFile(mem)
+    val s = java.lang.StringBuilder()
+    zipFile.getEntriesInPhysicalOrder().iterator().forEach { entry ->
+        s.append("<=== File ${entry.name} ===>\n")
+        
s.append(zipFile.getInputStream(entry).readAllBytes().toString(Charsets.UTF_8))
+        s.append("\n")
+    }
+    return s.toString()
+}
diff --git a/nexus/src/main/kotlin/tech/libeufin/nexus/Main.kt 
b/nexus/src/main/kotlin/tech/libeufin/nexus/Main.kt
index 64c476a..c474af6 100644
--- a/nexus/src/main/kotlin/tech/libeufin/nexus/Main.kt
+++ b/nexus/src/main/kotlin/tech/libeufin/nexus/Main.kt
@@ -604,7 +604,7 @@ fun main() {
                 when (response) {
                     is EbicsDownloadSuccessResult -> {
                         call.respondText(
-                            response.orderData.toString(Charsets.UTF_8),
+                            unzipOrderData(response.orderData),
                             ContentType.Text.Plain,
                             HttpStatusCode.OK
                         )
@@ -626,18 +626,8 @@ fun main() {
                 val response = doEbicsDownloadTransaction(client, 
subscriberData, "C53", orderParams)
                 when (response) {
                     is EbicsDownloadSuccessResult -> {
-                        val mem = 
SeekableInMemoryByteChannel(response.orderData)
-                        val zipFile = ZipFile(mem)
-
-                        val s = StringBuilder()
-
-                        zipFile.getEntriesInPhysicalOrder().iterator().forEach 
{ entry ->
-                            s.append("<=== File ${entry.name} ===>\n")
-                            
s.append(zipFile.getInputStream(entry).readAllBytes().toString(Charsets.UTF_8))
-                            s.append("\n")
-                        }
                         call.respondText(
-                            s.toString(),
+                            unzipOrderData(response.orderData),
                             ContentType.Text.Plain,
                             HttpStatusCode.OK
                         )

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



reply via email to

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