libeufin

Integration and sandbox testing for FinTech APIs and data formats
Log | Files | Refs | Submodules | README | LICENSE

commit 51ec1715b78c510cd455dc13243b81e28f67c0ff
parent 3393f292128483eca70b69869e2d872826dd169c
Author: Florian Dold <florian.dold@gmail.com>
Date:   Mon, 30 Sep 2019 08:34:17 +0200

style fixes

Diffstat:
A.idea/dictionaries/dold.xml | 11+++++++++++
M.idea/gradle.xml | 1+
Msrc/main/kotlin/Main.kt | 38+++++++++++++++++++++-----------------
Msrc/main/kotlin/tech/libeufin/XMLTransform.kt | 68++++++++++++++++++++++++++++++++++++++++++++++----------------------
4 files changed, 79 insertions(+), 39 deletions(-)

diff --git a/.idea/dictionaries/dold.xml b/.idea/dictionaries/dold.xml @@ -0,0 +1,10 @@ +<component name="ProjectDictionaryState"> + <dictionary name="dold"> + <words> + <w>affero</w> + <w>dold</w> + <w>ebics</w> + <w>stanisci</w> + </words> + </dictionary> +</component> +\ No newline at end of file diff --git a/.idea/gradle.xml b/.idea/gradle.xml @@ -1,5 +1,6 @@ <?xml version="1.0" encoding="UTF-8"?> <project version="4"> + <component name="GradleMigrationSettings" migrationVersion="1" /> <component name="GradleSettings"> <option name="linkedExternalProjectsSettings"> <GradleProjectSettings> diff --git a/src/main/kotlin/Main.kt b/src/main/kotlin/Main.kt @@ -1,42 +1,46 @@ -/** - * This file is part of LIBEUFIN. +/* + * This file is part of LibEuFin. * Copyright (C) 2019 Stanisci and Dold. - * LIBEUFIN is free software; you can redistribute it and/or modify + * 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 + * 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 + * License along with LibEuFin; see the file COPYING. If not, see * <http://www.gnu.org/licenses/> */ package tech.libeufin -import io.ktor.gson.* -import io.ktor.application.* +import io.ktor.application.call +import io.ktor.application.install import io.ktor.features.CallLogging -import io.ktor.http.* +import io.ktor.features.ContentNegotiation +import io.ktor.gson.gson +import io.ktor.http.ContentType +import io.ktor.http.HttpStatusCode import io.ktor.request.receive import io.ktor.request.receiveText -import io.ktor.response.* -import io.ktor.routing.* -import io.ktor.server.engine.* -import io.ktor.server.netty.* +import io.ktor.response.respond +import io.ktor.response.respondText +import io.ktor.routing.get +import io.ktor.routing.post +import io.ktor.routing.routing +import io.ktor.server.engine.embeddedServer +import io.ktor.server.netty.Netty +import org.jetbrains.exposed.sql.transactions.transaction import org.w3c.dom.Document import tech.libeufin.messages.HEVResponseDataType -import javax.xml.bind.JAXBElement -import io.ktor.features.* -import org.jetbrains.exposed.sql.transactions.transaction import tech.libeufin.tech.libeufin.* -import java.lang.NumberFormatException -import java.text.* +import java.text.DateFormat +import javax.xml.bind.JAXBElement fun main() { diff --git a/src/main/kotlin/tech/libeufin/XMLTransform.kt b/src/main/kotlin/tech/libeufin/XMLTransform.kt @@ -1,28 +1,51 @@ +/* + * This file is part of LibEuFin. + * Copyright (C) 2019 Stanisci and Dold. + + * 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/> + */ + package tech.libeufin; -import org.xml.sax.InputSource; -import org.xml.sax.SAXException; - -import java.io.*; -import javax.xml.XMLConstants; -import javax.xml.bind.JAXBContext; -import javax.xml.bind.JAXBElement; -import javax.xml.bind.JAXBException; -import javax.xml.bind.Marshaller; -import javax.xml.parsers.ParserConfigurationException; -import javax.xml.transform.*; -import javax.xml.transform.dom.DOMSource; -import javax.xml.transform.stream.StreamResult; -import javax.xml.transform.stream.StreamSource; -import javax.xml.validation.*; // has SchemaFactory() -import javax.xml.parsers.DocumentBuilderFactory; -import org.w3c.dom.Document; +import org.w3c.dom.Document +import org.xml.sax.InputSource +import org.xml.sax.SAXException +import java.io.ByteArrayInputStream +import java.io.IOException +import java.io.InputStream +import java.io.StringWriter +import javax.xml.XMLConstants +import javax.xml.bind.JAXBContext +import javax.xml.bind.JAXBElement +import javax.xml.bind.JAXBException +import javax.xml.bind.Marshaller +import javax.xml.parsers.DocumentBuilderFactory +import javax.xml.parsers.ParserConfigurationException +import javax.xml.transform.OutputKeys +import javax.xml.transform.TransformerConfigurationException +import javax.xml.transform.TransformerException +import javax.xml.transform.TransformerFactory +import javax.xml.transform.dom.DOMSource +import javax.xml.transform.stream.StreamResult +import javax.xml.transform.stream.StreamSource +import javax.xml.validation.SchemaFactory /** * This class takes care of importing XSDs and validate * XMLs against those. */ - class XMLTransform { /** @@ -31,7 +54,8 @@ class XMLTransform { private val bundle = { val classLoader = ClassLoader.getSystemClassLoader() val ebicsHevPath = classLoader.getResourceAsStream("ebics_hev.xsd") - val schemas = arrayOf(StreamSource(ebicsHevPath) + val schemas = arrayOf( + StreamSource(ebicsHevPath) // other StreamSources for other schemas here .. ) @@ -98,7 +122,7 @@ class XMLTransform { */ fun validateFromString(xmlString: String): Boolean { val xmlInputStream: InputStream = ByteArrayInputStream(xmlString.toByteArray()) - var xmlSource = StreamSource(xmlInputStream) + val xmlSource = StreamSource(xmlInputStream) return this.validate(xmlSource) } @@ -166,10 +190,10 @@ class XMLTransform { /** * Extract String from JAXB. * - * @param object the JAXB instance + * @param obj the JAXB instance * @return String representation of @a object, or null if errors occur */ - fun <T>getStringFromJaxb(obj: JAXBElement<T>): String? { + fun <T> getStringFromJaxb(obj: JAXBElement<T>): String? { val sw = StringWriter() try {