[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[libeufin] branch master updated: Helper function.
From: |
gnunet |
Subject: |
[libeufin] branch master updated: Helper function. |
Date: |
Wed, 25 Mar 2020 20:01:41 +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 ce9962f Helper function.
ce9962f is described below
commit ce9962fb1743c1570568f806fa94af0f9613e1f4
Author: Marcello Stanisci <address@hidden>
AuthorDate: Wed Mar 25 20:00:55 2020 +0100
Helper function.
Unzip data and loop over it calling a lambda function
for each entry.
---
nexus/src/main/kotlin/tech/libeufin/nexus/DB.kt | 12 +++---------
nexus/src/main/kotlin/tech/libeufin/nexus/Main.kt | 5 +++--
util/src/main/kotlin/zip.kt | 10 +++++++++-
3 files changed, 15 insertions(+), 12 deletions(-)
diff --git a/nexus/src/main/kotlin/tech/libeufin/nexus/DB.kt
b/nexus/src/main/kotlin/tech/libeufin/nexus/DB.kt
index 5ad345a..c0552ac 100644
--- a/nexus/src/main/kotlin/tech/libeufin/nexus/DB.kt
+++ b/nexus/src/main/kotlin/tech/libeufin/nexus/DB.kt
@@ -16,18 +16,12 @@ const val ID_MAX_LENGTH = 50
object EbicsRawBankTransactionsTable : IdTable<Long>() {
override val id = EbicsSubscribersTable.long("id").entityId().primaryKey()
val nexusSubscriber = reference("subscriber", EbicsSubscribersTable)
- /**
- * How did we learn about this transaction? C52 / C53 / C54
- */
+ // How did we learn about this transaction? C52 / C53 / C54
val sourceType = text("sourceType")
val sourceFileName = text("sourceFileName")
- /**
- * "Subject" of the SEPA transaction
- */
+ // "Subject" of the SEPA transaction
val unstructuredRemittanceInformation =
text("unstructuredRemittanceInformation")
- /**
- * Is it a credit or debit transaction?
- */
+ // Debit or credit
val transactionType = text("transactionType")
val currency = text("currency")
val amount = text("amount")
diff --git a/nexus/src/main/kotlin/tech/libeufin/nexus/Main.kt
b/nexus/src/main/kotlin/tech/libeufin/nexus/Main.kt
index 0fe67d4..15d6f43 100644
--- a/nexus/src/main/kotlin/tech/libeufin/nexus/Main.kt
+++ b/nexus/src/main/kotlin/tech/libeufin/nexus/Main.kt
@@ -624,6 +624,7 @@ fun main() {
post("/ebics/subscribers/{id}/collect-transactions-c52") {
// FIXME(florian): Download C52 and store the result in the
right database table
+
}
post("/ebics/subscribers/{id}/collect-transactions-c53") {
@@ -647,7 +648,7 @@ fun main() {
when (response) {
is EbicsDownloadSuccessResult -> {
call.respondText(
- response.orderData.unzipWithLoop(),
+ response.orderData.prettyPrintUnzip(),
ContentType.Text.Plain,
HttpStatusCode.OK
)
@@ -670,7 +671,7 @@ fun main() {
when (response) {
is EbicsDownloadSuccessResult -> {
call.respondText(
- unzipOrderData(response.orderData),
+ response.orderData.prettyPrintUnzip(),
ContentType.Text.Plain,
HttpStatusCode.OK
)
diff --git a/util/src/main/kotlin/zip.kt b/util/src/main/kotlin/zip.kt
index 5ea789c..0c6d739 100644
--- a/util/src/main/kotlin/zip.kt
+++ b/util/src/main/kotlin/zip.kt
@@ -25,7 +25,7 @@ fun ByteArray.zip(): ByteArray {
return baos.toByteArray()
}
-fun ByteArray.unzipWithLoop(): String {
+fun ByteArray.prettyPrintUnzip(): String {
val mem = SeekableInMemoryByteChannel(this)
val zipFile = ZipFile(mem)
val s = java.lang.StringBuilder()
@@ -35,4 +35,12 @@ fun ByteArray.unzipWithLoop(): String {
s.append("\n")
}
return s.toString()
+}
+
+fun ByteArray.unzipWithLoop(process: (String) -> Unit) {
+ val mem = SeekableInMemoryByteChannel(this)
+ val zipFile = ZipFile(mem)
+ zipFile.getEntriesInPhysicalOrder().iterator().forEach {
+
process(zipFile.getInputStream(it).readAllBytes().toString(Charsets.UTF_8))
+ }
}
\ No newline at end of file
--
To stop receiving notification emails like this one, please contact
address@hidden.
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [libeufin] branch master updated: Helper function.,
gnunet <=