gnunet-svn
[Top][All Lists]
Advanced

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

[libeufin] branch master updated (d6f9f6c -> d61420e)


From: gnunet
Subject: [libeufin] branch master updated (d6f9f6c -> d61420e)
Date: Fri, 22 Jan 2021 17:41:44 +0100

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

dold pushed a change to branch master
in repository libeufin.

    from d6f9f6c  don't clutter source tree
     new 401c7ce  address warnings
     new 0b403bb  address deprecation warning
     new d61420e  version bump

The 3 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:
 build-system/taler-build-scripts                   |  2 +-
 build.gradle                                       |  2 +-
 nexus/build.gradle                                 |  1 -
 .../libeufin/nexus/{Errors.kt => JsonLiterals.kt}  | 32 +++++++++++------
 .../tech/libeufin/nexus/bankaccount/BankAccount.kt |  8 +++--
 .../kotlin/tech/libeufin/nexus/ebics/EbicsNexus.kt |  2 +-
 .../tech/libeufin/nexus/server/NexusServer.kt      | 40 +++++++---------------
 parsing-tests/samples                              |  2 +-
 sandbox/build.gradle                               |  4 +--
 .../src/main/kotlin/tech/libeufin/sandbox/Main.kt  |  7 ++--
 util/build.gradle                                  |  3 +-
 11 files changed, 52 insertions(+), 51 deletions(-)
 copy nexus/src/main/kotlin/tech/libeufin/nexus/{Errors.kt => JsonLiterals.kt} 
(54%)

diff --git a/build-system/taler-build-scripts b/build-system/taler-build-scripts
index e08ea37..47f14fc 160000
--- a/build-system/taler-build-scripts
+++ b/build-system/taler-build-scripts
@@ -1 +1 @@
-Subproject commit e08ea37979dcc17ac8e0987251771d771503cb56
+Subproject commit 47f14fcf1d03d9dad1bae59987488ea05ecd307b
diff --git a/build.gradle b/build.gradle
index 6ded440..236ea3f 100644
--- a/build.gradle
+++ b/build.gradle
@@ -24,7 +24,7 @@ idea {
     }
 }
 
-setVersion("0.0.1-dev.1")
+setVersion("0.0.1-dev.2")
 
 task versionFile() {
     new File("${projectDir}/util/src/main/resources", "version.txt").text = 
getRootProject().version
diff --git a/nexus/build.gradle b/nexus/build.gradle
index 271b51f..9ee86df 100644
--- a/nexus/build.gradle
+++ b/nexus/build.gradle
@@ -37,7 +37,6 @@ apply plugin: 'kotlin-kapt'
 
 sourceCompatibility = '11'
 targetCompatibility = '11'
-version = '0.0.1'
 
 compileKotlin {
     kotlinOptions {
diff --git a/nexus/src/main/kotlin/tech/libeufin/nexus/Errors.kt 
b/nexus/src/main/kotlin/tech/libeufin/nexus/JsonLiterals.kt
similarity index 54%
copy from nexus/src/main/kotlin/tech/libeufin/nexus/Errors.kt
copy to nexus/src/main/kotlin/tech/libeufin/nexus/JsonLiterals.kt
index d7f04e7..cd89e01 100644
--- a/nexus/src/main/kotlin/tech/libeufin/nexus/Errors.kt
+++ b/nexus/src/main/kotlin/tech/libeufin/nexus/JsonLiterals.kt
@@ -1,17 +1,17 @@
 /*
  * This file is part of LibEuFin.
- * Copyright (C) 2020 Taler Systems S.A.
- *
+ * Copyright (C) 2021 Taler Systems S.A.
+
  * LibEuFin is free software; you can redistribute it and/or modify
  * it under the terms of the GNU Affero General Public License as
  * published by the Free Software Foundation; either version 3, or
  * (at your option) any later version.
- *
+
  * LibEuFin is distributed in the hope that it will be useful, but
  * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
  * or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU Affero General
  * Public License for more details.
- *
+
  * You should have received a copy of the GNU Affero General Public
  * License along with LibEuFin; see the file COPYING.  If not, see
  * <http://www.gnu.org/licenses/>
@@ -19,12 +19,24 @@
 
 package tech.libeufin.nexus
 
-import io.ktor.http.HttpStatusCode
+import com.fasterxml.jackson.databind.node.ObjectNode
+import com.fasterxml.jackson.module.kotlin.jacksonObjectMapper
 
-data class NexusError(val statusCode: HttpStatusCode, val reason: String) :
-    Exception("$reason (HTTP status $statusCode)")
+class JsonObjectMaker(val obj: ObjectNode) {
+    fun prop(key: String, value: String?) {
+        obj.put(key, value)
+    }
+    fun prop(key: String, value: Long?) {
+        obj.put(key, value)
+    }
+    fun prop(key: String, value: Int?) {
+        obj.put(key, value)
+    }
+}
 
-fun NexusAssert(condition: Boolean, errorMsg: String): Boolean {
-    if (! condition) throw NexusError(HttpStatusCode.InternalServerError, 
errorMsg)
-    return true
+fun makeJsonObject(f: JsonObjectMaker.() -> Unit): ObjectNode {
+    val mapper = jacksonObjectMapper()
+    val obj = mapper.createObjectNode()
+    f(JsonObjectMaker(obj))
+    return obj
 }
\ No newline at end of file
diff --git 
a/nexus/src/main/kotlin/tech/libeufin/nexus/bankaccount/BankAccount.kt 
b/nexus/src/main/kotlin/tech/libeufin/nexus/bankaccount/BankAccount.kt
index 3d86449..8222355 100644
--- a/nexus/src/main/kotlin/tech/libeufin/nexus/bankaccount/BankAccount.kt
+++ b/nexus/src/main/kotlin/tech/libeufin/nexus/bankaccount/BankAccount.kt
@@ -83,9 +83,13 @@ suspend fun submitAllPaymentInitiations(httpClient: 
HttpClient, accountid: Strin
     logger.debug("auto-submitter started")
     val workQueue = mutableListOf<Submission>()
     transaction {
-        val account = NexusBankAccountEntity.findByName(accountid)
+        val account = NexusBankAccountEntity.findByName(accountid) ?: throw 
NexusError(
+            HttpStatusCode.NotFound,
+            "account not found"
+        )
         PaymentInitiationEntity.find {
-            PaymentInitiationsTable.submitted eq false
+            (PaymentInitiationsTable.submitted eq false) and (
+                    PaymentInitiationsTable.bankAccount eq account.id)
         }.forEach {
             val defaultBankConnectionId = 
it.bankAccount.defaultBankConnection?.id ?: throw NexusError(
                 HttpStatusCode.BadRequest,
diff --git a/nexus/src/main/kotlin/tech/libeufin/nexus/ebics/EbicsNexus.kt 
b/nexus/src/main/kotlin/tech/libeufin/nexus/ebics/EbicsNexus.kt
index 2f2791b..50e13fe 100644
--- a/nexus/src/main/kotlin/tech/libeufin/nexus/ebics/EbicsNexus.kt
+++ b/nexus/src/main/kotlin/tech/libeufin/nexus/ebics/EbicsNexus.kt
@@ -97,7 +97,7 @@ suspend fun fetchEbicsBySpec(
     val specs = mutableListOf<EbicsFetchSpec>()
 
     fun addForLevel(l: FetchLevel, p: EbicsOrderParams) {
-        when (fetchSpec.level) {
+        when (l) {
             FetchLevel.ALL -> {
                 specs.add(EbicsFetchSpec("C52", p))
                 specs.add(EbicsFetchSpec("C53", p))
diff --git a/nexus/src/main/kotlin/tech/libeufin/nexus/server/NexusServer.kt 
b/nexus/src/main/kotlin/tech/libeufin/nexus/server/NexusServer.kt
index 7d4e368..9e2fab7 100644
--- a/nexus/src/main/kotlin/tech/libeufin/nexus/server/NexusServer.kt
+++ b/nexus/src/main/kotlin/tech/libeufin/nexus/server/NexusServer.kt
@@ -42,15 +42,9 @@ import io.ktor.util.*
 import io.ktor.util.pipeline.*
 import io.ktor.utils.io.*
 import org.jetbrains.exposed.sql.and
-import org.jetbrains.exposed.sql.select
 import org.jetbrains.exposed.sql.transactions.transaction
 import org.slf4j.event.Level
 import tech.libeufin.nexus.*
-import tech.libeufin.nexus.OfferedBankAccountsTable.accountHolder
-import tech.libeufin.nexus.OfferedBankAccountsTable.bankCode
-import tech.libeufin.nexus.OfferedBankAccountsTable.iban
-import tech.libeufin.nexus.OfferedBankAccountsTable.imported
-import tech.libeufin.nexus.OfferedBankAccountsTable.offeredAccountId
 import tech.libeufin.nexus.bankaccount.*
 import tech.libeufin.nexus.ebics.*
 import tech.libeufin.nexus.iso20022.CamtBankAccountEntry
@@ -139,7 +133,7 @@ fun requireValidResourceName(name: String): String {
 
 suspend inline fun <reified T : Any> ApplicationCall.receiveJson(): T {
     try {
-        return this.receive<T>()
+        return this.receive()
     } catch (e: MissingKotlinParameterException) {
         throw NexusError(HttpStatusCode.BadRequest, "Missing value for 
${e.pathReference}")
     } catch (e: MismatchedInputException) {
@@ -256,8 +250,8 @@ fun serverMain(dbName: String, host: String, port: Int) {
         routing {
             get("/config") {
                 call.respond(
-                    object {
-                        val version = getVersion()
+                    makeJsonObject {
+                        prop("version", getVersion())
                     }
                 )
                 return@get
@@ -304,7 +298,7 @@ fun serverMain(dbName: String, host: String, port: Int) {
                     when (req.action) {
                         PermissionChangeAction.GRANT -> {
                             if (existingPerm == null) {
-                                NexusPermissionEntity.new() {
+                                NexusPermissionEntity.new {
                                     subjectType = req.permission.subjectType
                                     subjectId = req.permission.subjectId
                                     resourceType = req.permission.resourceType
@@ -422,7 +416,6 @@ fun serverMain(dbName: String, host: String, port: Int) {
                         t.put("type", it.taskType)
                         t.set<JsonNode>("params", 
jacksonObjectMapper().readTree(it.taskParams))
                     }
-                    Unit
                 }
                 call.respond(resp)
                 return@get
@@ -434,7 +427,7 @@ fun serverMain(dbName: String, host: String, port: Int) {
                 val accountId = ensureNonNull(call.parameters["accountid"])
                 transaction {
                     authenticateRequest(call.request)
-                    val bankAccount = 
NexusBankAccountEntity.findByName(accountId)
+                    NexusBankAccountEntity.findByName(accountId)
                         ?: throw NexusError(HttpStatusCode.NotFound, "unknown 
bank account")
                     try {
                         NexusCron.parser.parse(schedSpec.cronspec)
@@ -444,9 +437,8 @@ fun serverMain(dbName: String, host: String, port: Int) {
                     // sanity checks.
                     when (schedSpec.type) {
                         "fetch" -> {
-                            val fetchSpec =
-                                
jacksonObjectMapper().treeToValue(schedSpec.params, FetchSpecJson::class.java)
-                                    ?: throw 
NexusError(HttpStatusCode.BadRequest, "bad fetch spec")
+                            
jacksonObjectMapper().treeToValue(schedSpec.params, FetchSpecJson::class.java)
+                                ?: throw NexusError(HttpStatusCode.BadRequest, 
"bad fetch spec")
                         }
                         "submit" -> {
                         }
@@ -526,15 +518,14 @@ fun serverMain(dbName: String, host: String, port: Int) {
                 requireSuperuser(call.request)
                 val accountId = ensureNonNull(call.parameters["accountid"])
                 val res = transaction {
-                    val user = authenticateRequest(call.request)
                     val bankAccount = 
NexusBankAccountEntity.findByName(accountId)
                     if (bankAccount == null) {
                         throw NexusError(HttpStatusCode.NotFound, "unknown 
bank account")
                     }
                     val holderEnc = 
URLEncoder.encode(bankAccount.accountHolder, "UTF-8")
-                    return@transaction object {
-                        val defaultBankConnection = 
bankAccount.defaultBankConnection?.id?.value
-                        val accountPaytoUri = 
"payto://iban/${bankAccount.iban}?receiver-name=$holderEnc"
+                    return@transaction makeJsonObject {
+                        prop("defaultBankConnection", 
bankAccount.defaultBankConnection?.id?.value)
+                        prop("accountPaytoUri", 
"payto://iban/${bankAccount.iban}?receiver-name=$holderEnc")
                     }
                 }
                 call.respond(res)
@@ -598,7 +589,6 @@ fun serverMain(dbName: String, host: String, port: Int) {
             get("/bank-accounts/{accountid}/payment-initiations/{uuid}") {
                 requireSuperuser(call.request)
                 val res = transaction {
-                    val user = authenticateRequest(call.request)
                     val paymentInitiation = 
getPaymentInitiation(ensureLong(call.parameters["uuid"]))
                     return@transaction object {
                         val paymentInitiation = paymentInitiation
@@ -669,7 +659,6 @@ fun serverMain(dbName: String, host: String, port: Int) {
                         "Account id missing"
                     )
                 }
-                val user = transaction { authenticateRequest(call.request) }
                 val fetchSpec = if (call.request.hasBody()) {
                     call.receive<FetchSpecJson>()
                 } else {
@@ -679,8 +668,8 @@ fun serverMain(dbName: String, host: String, port: Int) {
                     )
                 }
                 val newTransactions = fetchBankAccountTransactions(client, 
fetchSpec, accountid)
-                call.respond(object {
-                    val newTransactions = newTransactions
+                call.respond(makeJsonObject {
+                    prop("newTransactions", newTransactions)
                 })
                 return@post
             }
@@ -689,8 +678,6 @@ fun serverMain(dbName: String, host: String, port: Int) {
             get("/bank-accounts/{accountid}/transactions") {
                 requireSuperuser(call.request)
                 val bankAccountId = expectNonNull(call.parameters["accountid"])
-                val start = call.request.queryParameters["start"]
-                val end = call.request.queryParameters["end"]
                 val ret = Transactions()
                 transaction {
                     authenticateRequest(call.request)
@@ -794,7 +781,6 @@ fun serverMain(dbName: String, host: String, port: Int) {
             get("/bank-connections/{connectionName}") {
                 requireSuperuser(call.request)
                 val resp = transaction {
-                    val user = authenticateRequest(call.request)
                     val conn = requireBankConnection(call, "connectionName")
                     when (conn.type) {
                         "ebics" -> {
@@ -905,7 +891,7 @@ fun serverMain(dbName: String, host: String, port: Int) {
                 val fcid = ensureNonNull(call.parameters["fcid"])
                 val ret = transaction {
                     val f = FacadeEntity.findByName(fcid) ?: throw NexusError(
-                        HttpStatusCode.NotFound, "Facade ${fcid} does not 
exist"
+                        HttpStatusCode.NotFound, "Facade $fcid does not exist"
                     )
                     FacadeShowInfo(
                         name = f.facadeName,
diff --git a/parsing-tests/samples b/parsing-tests/samples
index 63f075c..4e36caa 160000
--- a/parsing-tests/samples
+++ b/parsing-tests/samples
@@ -1 +1 @@
-Subproject commit 63f075c6f61173f4ee68c39b30d860fd20a299dc
+Subproject commit 4e36caa0b9557d7446488d7eec7c80e6f1e554ac
diff --git a/sandbox/build.gradle b/sandbox/build.gradle
index 3ad7ffe..b7ab223 100644
--- a/sandbox/build.gradle
+++ b/sandbox/build.gradle
@@ -7,7 +7,7 @@ plugins {
 
 sourceCompatibility = "11"
 targetCompatibility = "11"
-version '1.0-snapshot'
+version = rootProject.version
 
 compileKotlin {
     kotlinOptions {
@@ -84,4 +84,4 @@ jar {
     manifest {
         attributes "Main-Class": "tech.libeufin.sandbox.MainKt"
     }
-}
\ No newline at end of file
+}
diff --git a/sandbox/src/main/kotlin/tech/libeufin/sandbox/Main.kt 
b/sandbox/src/main/kotlin/tech/libeufin/sandbox/Main.kt
index 5418a93..4941d81 100644
--- a/sandbox/src/main/kotlin/tech/libeufin/sandbox/Main.kt
+++ b/sandbox/src/main/kotlin/tech/libeufin/sandbox/Main.kt
@@ -26,8 +26,6 @@ import io.ktor.application.install
 import io.ktor.features.CallLogging
 import io.ktor.features.ContentNegotiation
 import io.ktor.features.StatusPages
-import io.ktor.http.ContentType
-import io.ktor.http.HttpStatusCode
 import io.ktor.response.respond
 import io.ktor.response.respondText
 import io.ktor.routing.get
@@ -52,7 +50,6 @@ import com.fasterxml.jackson.core.util.DefaultIndenter
 import com.fasterxml.jackson.core.util.DefaultPrettyPrinter
 import com.fasterxml.jackson.databind.SerializationFeature
 import com.fasterxml.jackson.module.kotlin.KotlinModule
-import io.ktor.http.toHttpDateString
 import org.jetbrains.exposed.sql.statements.api.ExposedBlob
 import java.time.Instant
 import com.github.ajalt.clikt.core.CliktCommand
@@ -64,7 +61,9 @@ import com.github.ajalt.clikt.parameters.options.option
 import com.github.ajalt.clikt.parameters.options.versionOption
 import com.github.ajalt.clikt.parameters.types.int
 import execThrowableOrTerminate
+import io.ktor.http.*
 import io.ktor.request.*
+import io.ktor.util.date.*
 import 
tech.libeufin.sandbox.BankAccountTransactionsTable.accountServicerReference
 import tech.libeufin.sandbox.BankAccountTransactionsTable.amount
 import tech.libeufin.sandbox.BankAccountTransactionsTable.creditorBic
@@ -413,7 +412,7 @@ fun serverMain(dbName: String, port: Int) {
                                         paymentInformationId = it[pmtInfId],
                                         debtorIban = it[debtorIban],
                                         subject = 
it[BankAccountTransactionsTable.subject],
-                                        date = it[date].toHttpDateString(),
+                                        date = GMTDate(it[date]).toHttpDate(),
                                         amount = it[amount],
                                         creditorBic = it[creditorBic],
                                         creditorName = it[creditorName],
diff --git a/util/build.gradle b/util/build.gradle
index 67a0b9a..72f90c0 100644
--- a/util/build.gradle
+++ b/util/build.gradle
@@ -7,7 +7,8 @@ plugins {
 
 sourceCompatibility = "11"
 targetCompatibility = "11"
-version '1.0-snapshot'
+
+version = rootProject.version
 
 compileKotlin {
 

-- 
To stop receiving notification emails like this one, please contact
gnunet@gnunet.org.



reply via email to

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