[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[libeufin] branch master updated (8cb9570 -> 8962558)
From: |
gnunet |
Subject: |
[libeufin] branch master updated (8cb9570 -> 8962558) |
Date: |
Wed, 22 Jan 2020 22:09:21 +0100 |
This is an automated email from the git hooks/post-receive script.
marcello pushed a change to branch master
in repository libeufin.
from 8cb9570 Main C52 handler calls history-helper.
new 674ff93 install requests logger
new 1d3c9aa make CLI send C52
new 5842398 Fixing C52 dates issue; request ends fine now.
new 8962558 Fix dates range.
The 4 revisions listed above as "new" are entirely new to this
repository and will be described in separate emails. The revisions
listed as "add" were already present in the repository and have only
been added to this reference.
Summary of changes:
nexus/src/main/kotlin/JSON.kt | 8 +++++---
nexus/src/main/kotlin/Main.kt | 16 ++++++++++++++--
.../tech/libeufin/sandbox/EbicsProtocolBackend.kt | 6 ++++--
.../src/main/kotlin/tech/libeufin/sandbox/Main.kt | 5 ++++-
sandbox/src/main/python/libeufin-cli | 20 ++++++++++++++++++++
util/src/main/kotlin/ebics_h004/EbicsRequest.kt | 19 ++++++++++++++-----
6 files changed, 61 insertions(+), 13 deletions(-)
diff --git a/nexus/src/main/kotlin/JSON.kt b/nexus/src/main/kotlin/JSON.kt
index 857e0d1..0140661 100644
--- a/nexus/src/main/kotlin/JSON.kt
+++ b/nexus/src/main/kotlin/JSON.kt
@@ -9,10 +9,12 @@ data class EbicsBackupRequest(
val passphrase: String
)
-
data class EbicsDateRange(
- val start: String, // ISO 8601 calendar date
- val end: String // ISO 8601 calendar date
+ /**
+ * ISO 8601 calendar dates: YEAR-MONTH(01-12)-DAY(1-31)
+ */
+ val start: String,
+ val end: String
)
/**
diff --git a/nexus/src/main/kotlin/Main.kt b/nexus/src/main/kotlin/Main.kt
index 5c410bf..d6911f5 100644
--- a/nexus/src/main/kotlin/Main.kt
+++ b/nexus/src/main/kotlin/Main.kt
@@ -25,6 +25,7 @@ import io.ktor.application.ApplicationCallPipeline
import io.ktor.application.call
import io.ktor.application.install
import io.ktor.client.*
+import io.ktor.features.CallLogging
import io.ktor.features.ContentNegotiation
import io.ktor.features.StatusPages
import io.ktor.gson.gson
@@ -41,6 +42,7 @@ import org.jetbrains.exposed.sql.transactions.transaction
import org.joda.time.DateTime
import org.slf4j.Logger
import org.slf4j.LoggerFactory
+import org.slf4j.event.Level
import tech.libeufin.util.ebics_h004.*
import tech.libeufin.util.*
import java.text.DateFormat
@@ -99,6 +101,12 @@ fun main() {
val server = embeddedServer(Netty, port = 5001) {
+ install(CallLogging) {
+ this.level = Level.DEBUG
+ this.logger = LOGGER
+
+ }
+
install(ContentNegotiation) {
moshi {
@@ -194,8 +202,6 @@ fun main() {
val endDate = DateTime.parse(body.end)
// will throw DateTimeParseException if strings are malformed.
-
-
val subscriberData = transaction {
containerInit(EbicsSubscriberEntity.findById(id) ?: throw
SubscriberNotFoundError(HttpStatusCode.NotFound))
}
@@ -212,6 +218,12 @@ fun main() {
),
subscriberData.customerAuthPriv
)
+
+ call.respondText(
+ "Nothing crashed!",
+ ContentType.Text.Plain,
+ HttpStatusCode.OK)
+ return@post
}
get("/ebics/subscribers/{id}/sendHtd") {
diff --git
a/sandbox/src/main/kotlin/tech/libeufin/sandbox/EbicsProtocolBackend.kt
b/sandbox/src/main/kotlin/tech/libeufin/sandbox/EbicsProtocolBackend.kt
index fa6608c..3f74d06 100644
--- a/sandbox/src/main/kotlin/tech/libeufin/sandbox/EbicsProtocolBackend.kt
+++ b/sandbox/src/main/kotlin/tech/libeufin/sandbox/EbicsProtocolBackend.kt
@@ -128,13 +128,15 @@ private fun iterHistory(customerId: Int, header:
EbicsRequest.Header, base: XmlE
extractHistoryForEach(
customerId,
try {
- (header.static.orderDetails?.orderParams as
EbicsRequest.StandardOrderParams).dateRange?.start.toString()
+ (header.static.orderDetails?.orderParams as
EbicsRequest.StandardOrderParams).dateRange!!.start.toString()
} catch (e: Exception) {
+ LOGGER.debug("Asked to iterate over history with NO start date;
default to now")
getGregorianDate().toString()
},
try {
- (header.static.orderDetails?.orderParams as
EbicsRequest.StandardOrderParams).dateRange?.end.toString()
+ (header.static.orderDetails?.orderParams as
EbicsRequest.StandardOrderParams).dateRange!!.end.toString()
} catch (e: Exception) {
+ LOGGER.debug("Asked to iterate over history with NO end date;
default to now")
getGregorianDate().toString()
}
) {
diff --git a/sandbox/src/main/kotlin/tech/libeufin/sandbox/Main.kt
b/sandbox/src/main/kotlin/tech/libeufin/sandbox/Main.kt
index 39f64ff..04bcb5d 100644
--- a/sandbox/src/main/kotlin/tech/libeufin/sandbox/Main.kt
+++ b/sandbox/src/main/kotlin/tech/libeufin/sandbox/Main.kt
@@ -170,13 +170,16 @@ fun sampleData() {
}
/**
- * Finds the history for a customer.
+ * Finds the history for a customer
*
* @param id the customer whose history must be returned. This
* id is local to the bank and is not reused/encoded into other
* EBICS id values.
+ * @param builder lambda function that will loop over all the results.
*/
fun extractHistoryForEach(id: Int, start: String?, end: String?, builder:
(BankTransactionEntity) -> Any) {
+
+ LOGGER.debug("Fetching history from $start to $end")
val s = if (start != null) DateTime.parse(start) else DateTime(0)
val e = if (end != null) DateTime.parse(end) else DateTime.now()
diff --git a/sandbox/src/main/python/libeufin-cli
b/sandbox/src/main/python/libeufin-cli
index 11fe518..b4ec5a4 100755
--- a/sandbox/src/main/python/libeufin-cli
+++ b/sandbox/src/main/python/libeufin-cli
@@ -129,6 +129,26 @@ def tst(obj, customer_id):
print(resp.content.decode("utf-8"))
+
+@ebics.command(help="send C52 message")
+@click.pass_obj
+@click.option(
+ "--customer-id",
+ help="numerical ID of the customer at the Nexus",
+ required=False,
+ default=1)
+def c52(obj, customer_id):
+
+ url = urljoin(obj["base_url"],
"/ebics/subscribers/{}/sendC52".format(customer_id))
+ try:
+ resp = post(url, json=dict(start="1970-01-01", end="2020-12-31"))
+ except Exception:
+ print("Could not reach the bank")
+ return
+
+ print(resp.content.decode("utf-8"))
+
+
@ebics.command(help="send INI message")
@click.pass_obj
@click.option(
diff --git a/util/src/main/kotlin/ebics_h004/EbicsRequest.kt
b/util/src/main/kotlin/ebics_h004/EbicsRequest.kt
index 52db653..45910e1 100644
--- a/util/src/main/kotlin/ebics_h004/EbicsRequest.kt
+++ b/util/src/main/kotlin/ebics_h004/EbicsRequest.kt
@@ -2,12 +2,15 @@ package tech.libeufin.util.ebics_h004
import org.apache.xml.security.binding.xmldsig.SignatureType
import tech.libeufin.util.CryptoUtil
+import tech.libeufin.util.LOGGER
+import tech.libeufin.util.XMLUtil
import java.math.BigInteger
import java.security.interfaces.RSAPublicKey
import javax.xml.bind.annotation.*
import javax.xml.bind.annotation.adapters.CollapsedStringAdapter
import javax.xml.bind.annotation.adapters.HexBinaryAdapter
import javax.xml.bind.annotation.adapters.XmlJavaTypeAdapter
+import javax.xml.datatype.DatatypeConstants
import javax.xml.datatype.XMLGregorianCalendar
@XmlAccessorType(XmlAccessType.NONE)
@@ -255,9 +258,11 @@ class EbicsRequest {
@XmlType(name = "", propOrder = ["start", "end"])
class DateRange {
@get:XmlElement(name = "Start")
+ @get:XmlSchemaType(name = "date")
lateinit var start: XMLGregorianCalendar
@get:XmlElement(name = "End")
+ @get:XmlSchemaType(name = "date")
lateinit var end: XMLGregorianCalendar
}
@@ -317,6 +322,12 @@ class EbicsRequest {
dateEnd: XMLGregorianCalendar
): EbicsRequest {
+ /**
+ * Make sure there is NO time portion.
+ */
+ dateStart.timezone = DatatypeConstants.FIELD_UNDEFINED
+ dateEnd.timezone = DatatypeConstants.FIELD_UNDEFINED
+
val tmp = createForDownloadInitializationPhase(
userId,
partnerId,
@@ -328,11 +339,9 @@ class EbicsRequest {
aOrderType
)
- (tmp.header.static.orderDetails?.orderParams as
StandardOrderParams).apply {
- dateRange?.apply {
- start = dateStart
- end = dateEnd
- }
+ (tmp.header.static.orderDetails?.orderParams as
StandardOrderParams).dateRange = DateRange().apply {
+ start = dateStart
+ end = dateEnd
}
return tmp
--
To stop receiving notification emails like this one, please contact
address@hidden.
- [libeufin] branch master updated (8cb9570 -> 8962558),
gnunet <=