Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

jakarta version, upgraded jaxb #75

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
49 changes: 24 additions & 25 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,6 @@
<name>${project.artifactId}</name>
<description>HBCI4j - Home Banking Computer Interface for Java</description>
<url>https://github.com/hbci4j/hbci4java</url>
<prerequisites>
<maven>3.3.9</maven>
</prerequisites>
<licenses>
<license>
<name>GNU Lesser General Public License</name>
Expand Down Expand Up @@ -40,7 +37,7 @@
<maven-deploy-plugin.version>2.8.2</maven-deploy-plugin.version>
<maven-javadoc-plugin.version>3.3.1</maven-javadoc-plugin.version>
<maven-source-plugin.version>3.2.1</maven-source-plugin.version>
<maven-compiler-plugin.version>3.8.1</maven-compiler-plugin.version>
<maven-compiler-plugin.version>3.10.1</maven-compiler-plugin.version>
<maven-surefire-plugin.version>2.22.2</maven-surefire-plugin.version>
<maven-release-plugin.version>2.5.3</maven-release-plugin.version>
<nexus-staging-maven-plugin.version>1.6.8</nexus-staging-maven-plugin.version>
Expand All @@ -51,7 +48,7 @@
<maven-resources-plugin.version>3.2.0</maven-resources-plugin.version>
<maven-site-plugin.version>3.10.0</maven-site-plugin.version>

<maven-jaxb2-plugin.version>0.14.0</maven-jaxb2-plugin.version>
<maven-jaxb2-plugin.version>0.15.1</maven-jaxb2-plugin.version>
<jaxb.packageName>org.kapott</jaxb.packageName>
</properties>
<distributionManagement>
Expand All @@ -67,9 +64,9 @@
<build>
<plugins>
<plugin>
<groupId>org.jvnet.jaxb2.maven2</groupId>
<artifactId>maven-jaxb22-plugin</artifactId>
<version>${maven-jaxb2-plugin.version}</version>
<groupId>com.helger.maven</groupId>
<artifactId>jaxb40-maven-plugin</artifactId>
<version>0.16.1</version>
<executions>
<!--
CAMT: Offizieller Download der Schema-Datei von https://www.iso20022.org/payments_messages.page
Expand Down Expand Up @@ -482,15 +479,15 @@
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-jar-plugin</artifactId>
<version>${maven-jar-plugin.version}</version>
<configuration>
<archive>
<manifest>
<addDefaultImplementationEntries>true</addDefaultImplementationEntries>
<addDefaultSpecificationEntries>true</addDefaultSpecificationEntries>
</manifest>
</archive>
</configuration>
</plugin>
<configuration>
<archive>
<manifest>
<addDefaultImplementationEntries>true</addDefaultImplementationEntries>
<addDefaultSpecificationEntries>true</addDefaultSpecificationEntries>
</manifest>
</archive>
</configuration>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-install-plugin</artifactId>
Expand Down Expand Up @@ -611,15 +608,17 @@
<version>4.13.2</version>
<scope>test</scope>
</dependency>

<dependency>
<groupId>jakarta.xml.bind</groupId>
<artifactId>jakarta.xml.bind-api</artifactId>
<version>4.0.0</version>
</dependency>

<dependency>
<groupId>javax.xml.bind</groupId>
<artifactId>jaxb-api</artifactId>
<version>2.3.1</version>
<groupId>org.glassfish.jaxb</groupId>
<artifactId>jaxb-runtime</artifactId>
<version>4.0.2</version>
</dependency>
<dependency>
<groupId>org.glassfish.jaxb</groupId>
<artifactId>jaxb-runtime</artifactId>
<version>2.3.1</version>
</dependency>
</dependencies>
</project>
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,6 @@
import java.util.logging.Logger;

import javax.xml.XMLConstants;
import javax.xml.bind.JAXBContext;
import javax.xml.bind.JAXBElement;
import javax.xml.bind.Marshaller;
import javax.xml.transform.Source;
import javax.xml.transform.stream.StreamSource;
import javax.xml.validation.Schema;
Expand All @@ -17,10 +14,14 @@
import org.kapott.hbci.exceptions.HBCI_Exception;
import org.kapott.hbci.sepa.SepaVersion;

import jakarta.xml.bind.JAXBContext;
import jakarta.xml.bind.JAXBElement;
import jakarta.xml.bind.Marshaller;

/**
* Abstrakte Basis-Implementierung der SEPA-Generatoren.
* @param <T> Die konkrete Struktur, aus der die Daten gelesen werden.
*
*
* WICHTIG: Diese Klasse sowie die Ableitungen sollten auch ohne initialisiertes HBCI-System
* funktionieren, um das XML ohne HBCI-Handler erstellen zu koennen. Daher sollte auf die
* Verwendung von "HBCIUtils" & Co verzichtet werden. Das ist auch der Grund, warum hier
Expand All @@ -38,17 +39,19 @@ public abstract class AbstractSEPAGenerator<T> implements ISEPAGenerator<T>
* @param validate true, wenn das erzeugte XML gegen das PAIN-Schema validiert werden soll.
* @throws Exception
*/
protected void marshal(JAXBElement e, OutputStream os, boolean validate) throws Exception
protected void marshal(final JAXBElement e, final OutputStream os, final boolean validate) throws Exception
{
JAXBContext jaxbContext = JAXBContext.newInstance(e.getDeclaredType());
Marshaller marshaller = jaxbContext.createMarshaller();

// Wir verwenden hier hart UTF-8. Siehe http://www.onlinebanking-forum.de/forum/topic.php?p=107420#real107420
marshaller.setProperty(Marshaller.JAXB_ENCODING, ENCODING);

// Siehe https://groups.google.com/d/msg/hbci4java/RYHCai_TzHM/72Bx51B9bXUJ
if (System.getProperty("sepa.pain.formatted","false").equalsIgnoreCase("true"))
{
marshaller.setProperty(Marshaller.JAXB_FORMATTED_OUTPUT, Boolean.TRUE);
}

SepaVersion version = this.getSepaVersion();
if (version != null)
Expand Down Expand Up @@ -77,11 +80,15 @@ protected void marshal(JAXBElement e, OutputStream os, boolean validate) throws
// Fallback auf File-Objekt
File f = new File(file);
if (f.isFile() && f.canRead())
{
source = new StreamSource(f);
}
}

if (source == null)
{
throw new HBCI_Exception("schema validation activated against " + file + " - but schema file could not be found");
}

LOG.fine("activating schema validation against " + file);
SchemaFactory schemaFactory = SchemaFactory.newInstance(XMLConstants.W3C_XML_SCHEMA_NS_URI);
Expand All @@ -93,7 +100,7 @@ protected void marshal(JAXBElement e, OutputStream os, boolean validate) throws

marshaller.marshal(e, os);
}

/**
* @see org.kapott.hbci.GV.generators.ISEPAGenerator#getSepaVersion()
*/
Expand Down
Loading