Skip to content

Java 8 maintenance #159

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

Open
wants to merge 3 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
The table of contents is too big for display.
Diff view
Diff view
  •  
  •  
  •  
The diff you're trying to view is too large. We only load the first 3000 changed files.
50 changes: 19 additions & 31 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,36 +1,35 @@
# Prowide ISO 20022 - CHANGELOG

#### 10.2.7 - SNAPSHOT
#### 9.5.7 - SNAPSHOT
* Enhanced the MX parser log verbosity when parsing malformed content
* Added new logic to MxNode to removing all leaves with empty attributes and empty content

#### 10.2.6 - January 2025
#### 9.5.6 - January 2025
* Changed the `MxParseUtils` findByTags and findByPath methods to return the element values instead of the XML stream object

#### 10.2.5 - January 2025
#### 9.5.5 - January 2025
* (PW-2113) `MxParseUtils` added a method to extract the enclosed MT from a multi-format MX message
* (PW-2113) `MxParseUtils` added methods to extract comments from XML string
* Added new SettlementInfo class, and added MxParseUtils#getSettlementInfo to extract it from a raw MX message.
* Moved and enhanced the MxSwiftMessage#findElement to support multiple element's path
* Moved and enhanced the MxSwiftMessage#findElement to support multiple element's path
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🧹 Nitpick (assertive)

Fix trailing whitespace in changelog.

There's a trailing space at the end of line 14 which should be removed.

-  * Moved and enhanced the MxSwiftMessage#findElement to support multiple element's path 
+  * Moved and enhanced the MxSwiftMessage#findElement to support multiple element's path
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
* Moved and enhanced the MxSwiftMessage#findElement to support multiple element's path
* Moved and enhanced the MxSwiftMessage#findElement to support multiple element's path
🧰 Tools
🪛 markdownlint-cli2 (0.17.2)

14-14: Unordered list indentation
Expected: 0; Actual: 2

(MD007, ul-indent)


14-14: Trailing spaces
Expected: 0 or 2; Actual: 1

(MD009, no-trailing-spaces)

* Update apache-commons-lang3 from 3.14.0 to 3.17.0 fixing derived apache-text dependency vulnerabilities
* Gradle wrapper update to 8.12

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🧹 Nitpick (assertive)

Fix trailing whitespace in changelog.

There's a trailing space at the end of line 17 which should be removed.

-  * Gradle wrapper update to 8.12
- 
+  * Gradle wrapper update to 8.12
+

Committable suggestion skipped: line range outside the PR's diff.

🧰 Tools
🪛 markdownlint-cli2 (0.17.2)

17-17: Trailing spaces
Expected: 0 or 2; Actual: 1

(MD009, no-trailing-spaces)

#### 9.5.4 - August 2024
* (PW-1958) Fixed the `DefaultMxMetadataStrategy` NPE issue when the amount values are null

#### 10.2.4 - November 2024
* (GH-118) Added `toJsonV9` and `fromJsonV9` in the `AbstractMX` to handle retro-compatibility with Java 8 DateTime elements in JSON serialization

#### 10.2.3 - August 2024

#### 10.2.2 - August 2024
#### 9.5.3 - August 2024
* (PW-1947) Updated MX model with latest SWIFT SRU2024 schema update, including new messages such as trck.001.001.03
* (PW-1933) Fix backward compatibility issue on DateTime fields when doing JSON to model conversion (thanks @elominp)
* (PW-1875) Fixed the `ZuluDateTimeAdapter` to convert the datetime to UTC offset if needed
* Add support for Business Application Header version head.001.001.04

#### 10.2.1 - June 2024
#### 9.5.2 - June 2024
* (PW-1875) Fixed the `ZuluDateTimeAdapter` to convert the datetime to UTC offset if needed

#### 9.5.1 - June 2024
* Enhanced the AppHdrFactory to honor the business service set in the parameter MxId
* Enhanced the MxParseUtils#identifyMessage to set the business service in the MxId when present

#### 10.2.0 - May 2024
#### 9.5.0 - May 2024
* SWIFT Standard release update 2024 (live 16 November 2024)
* Yearly revision of deprecation phase (see https://dev.prowidesoftware.com/SRU2024/getting-started/deprecation/)
* Added message categories for File Management (cafm), Fraud Reporting and Disposition (cafm), Network Management (canm), and Settlement Reporting (casr)
Expand All @@ -40,37 +39,26 @@
* Dependency update: commons-lang3 -> 3.14.0
* Dependency update: gson -> 2.11.0

#### 10.1.6 - May 2024
#### 9.4.5 - May 2024
* (PW-1875) Changed the BusinessApplicationHeaderV01 marshaller to always use Zulu timezone with "Z" indicator

#### 10.1.5 - April 2024
* Update jaxb dependency from com.sun.xml.bind:jaxb-impl:4.0.2 to 4.0.5 containing several jaxb bugfixes

#### 10.1.4 - January 2024

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🧹 Nitpick (assertive)

Fix trailing whitespace in changelog.

There's a trailing space at the end of line 44 which should be removed.

-  * (PW-1875) Changed the BusinessApplicationHeaderV01 marshaller to always use Zulu timezone with "Z" indicator
- 
+  * (PW-1875) Changed the BusinessApplicationHeaderV01 marshaller to always use Zulu timezone with "Z" indicator
+

Committable suggestion skipped: line range outside the PR's diff.

🧰 Tools
🪛 markdownlint-cli2 (0.17.2)

44-44: Trailing spaces
Expected: 0 or 2; Actual: 1

(MD009, no-trailing-spaces)

#### 9.4.4 - January 2024
* Enhanced the identifier extraction of the MxSwiftMessage to use the AppHdr when the Document namespace is missing
* Enhanced the generic AbstractMX#parse to detect the message type from the AppHdr when the Document namespace is missing
* Added default metadata extraction implementation for pacs and camt amounts and value dates
* Added default methods for sender, receiver, and identifier extraction to the MxSwiftMessage.
* Replaced the DistinguishedName parse logic with proprietary util class from the Prowide Core library

#### 10.1.3 - August 2023
* (PW-1566) Fixed manipulation of nanoseconds in the OffsetTime and OffsetDateTime adapters
#### 9.4.3 - August 2023
* Enhanced metadata extraction for xsys messages getting sender/receiver BICs from the RequestHeader element
* Make the message metadata extraction lenient, by fixing the XML instruction of the payload when it contains invalid case

#### 10.1.2 - August 2023
#### 9.4.2 - July 2023
* Added new utility class SupplementaryDataUtils to facilitate "SplmtryData" extraction from MX messages

#### 10.1.1 - July 2023
#### 9.4.1 - June 2023
* (PW-1392) Fixed the default escape handler when serializing model objects into XML, that was duplicated quote characters in the output

#### 10.1.0 - June 2023
* Migration to Java 11
* Migration to Jakarta EE 10
* XmlGregorianCalendar was replaced model-wide by the new java.time classes
* Fixed AppHdrFactory creation to use UTC in the header default creation date time
* Fixed the business application header V01 serialization to use Zulu time indicator instead of +00:00 offset

#### 9.4.0 - May 2023
* SWIFT Standard release update 2023 (live 19 November 2023)
* Yearly revision of deprecation phase (see https://dev.prowidesoftware.com/SRU2022/getting-started/deprecation/)
Expand Down
59 changes: 26 additions & 33 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,9 @@ buildscript {
}
dependencies {
classpath 'ru.vyarus:gradle-quality-plugin:5.0.0'
classpath 'pl.allegro.tech.build:axion-release-plugin:1.15.1'
classpath 'pl.allegro.tech.build:axion-release-plugin:1.13.6'
classpath 'io.github.gradle-nexus:publish-plugin:2.0.0'
classpath 'com.diffplug.spotless:spotless-plugin-gradle:6.23.3'
classpath 'com.diffplug.spotless:spotless-plugin-gradle:6.13.0' // above this version requires Java 11
}
}
apply plugin: 'pl.allegro.tech.build.axion-release'
Expand All @@ -24,7 +24,7 @@ group 'com.prowidesoftware'

project.ext {
SRU = 'SRU2024'
prowideCoreVersion = 'SRU2024-10.2.5'
prowideCoreVersion = 'SRU2024-9.5.5'
}

scmVersion {
Expand All @@ -41,7 +41,7 @@ allprojects {
options.encoding = 'UTF-8'
java {
toolchain {
languageVersion.set(JavaLanguageVersion.of(11))
languageVersion.set(JavaLanguageVersion.of(8))
}
}
doLast {
Expand Down Expand Up @@ -72,11 +72,7 @@ allprojects {
}
}

sourceSets.named('main') {
java {
setSrcDirs(['src/main/java', 'src/generated/java'])
}
}
sourceSets.main.java.srcDirs = ['src/main/java', 'src/generated/java']

tasks.withType(Jar) {
manifest.attributes(
Expand All @@ -87,8 +83,8 @@ allprojects {
'Implementation-Version': project.version,
'Implementation-Vendor': 'www.prowidesoftware.com',
'Built-OS': System.getProperty('os.name'),
'Source-Compatibility': JavaVersion.VERSION_11,
'Target-Compatibility': JavaVersion.VERSION_11,
'Source-Compatibility': project.sourceCompatibility,
'Target-Compatibility': project.targetCompatibility,
'Built-Date': new Date().format("yyyy-MM-dd"),
'Automatic-Module-Name': 'com.prowidesoftware.iso20022'
)
Expand All @@ -103,9 +99,6 @@ subprojects {
dependencies {
implementation 'org.apache.commons:commons-lang3:3.17.0'
implementation 'com.google.code.gson:gson:2.11.0'
implementation 'com.sun.xml.bind:jaxb-impl:4.0.5'
// bind-api is included transitively by jaxb-impl
// implementation 'jakarta.xml.bind:jakarta.xml.bind-api:4.0.2'
}

tasks.withType(Jar) {
Expand All @@ -126,14 +119,8 @@ configure(subprojects.findAll {it.name.endsWith('-mx')}) {
dependencies {
api project(':iso20022-core')
implementation project(specificTypesProject)

implementation 'org.apache.commons:commons-lang3:3.17.0'
implementation 'com.google.code.gson:gson:2.11.0'

implementation 'com.sun.xml.bind:jaxb-impl:4.0.5'
// bind-api is included transitively by jaxb-impl
// implementation 'jakarta.xml.bind:jakarta.xml.bind-api:4.0.2'

compileOnly 'javax.persistence:javax.persistence-api:2.2'
}
}
Expand All @@ -153,10 +140,16 @@ project(':iso20022-core') {
implementation 'org.apache.commons:commons-lang3:3.17.0'
implementation 'com.google.code.gson:gson:2.11.0'

compileOnly 'jakarta.persistence:jakarta.persistence-api:3.1.0'
compileOnly 'jakarta.validation:jakarta.validation-api:3.0.2'
compileOnly 'javax.persistence:javax.persistence-api:2.2'
compileOnly 'javax.validation:validation-api:2.0.1.Final'

testImplementation 'jakarta.persistence:jakarta.persistence-api:3.1.0'
// to avoid potential differences in JAXB implementations when testing in different environments
testImplementation 'javax.xml.bind:jaxb-api:2.3.1'
testImplementation 'com.sun.xml.bind:jaxb-impl:2.3.3'
testImplementation 'com.sun.xml.bind:jaxb-core:2.3.0.1'
testImplementation 'javax.activation:activation:1.1.1'

testImplementation 'javax.persistence:javax.persistence-api:2.2'
testImplementation 'org.junit.jupiter:junit-jupiter:5.11.4'
testImplementation 'com.google.guava:guava:33.4.0-jre'
testImplementation 'org.assertj:assertj-core:3.27.2'
Expand Down Expand Up @@ -208,11 +201,7 @@ jar {
archivesBaseName = 'pw-iso20022'
subprojects.each { subproject ->
from subproject.configurations.archives.allArtifacts.files.collect {
// filter out any artifacts that are not jars
if (it.name.endsWith('.jar')) {
println "Adding ${it.name} to fat jar"
zipTree(it)
}
zipTree(it)
}
}
duplicatesStrategy = DuplicatesStrategy.EXCLUDE
Expand Down Expand Up @@ -331,11 +320,9 @@ artifacts {
// declared dependencies for pom generation
dependencies {
// included build (keep in sync with the latest Prowide Core version)
api "com.prowidesoftware:pw-swift-core:${prowideCoreVersion}"

// jaxb is required because it is no longer included in the JDK
// bind-api is included transitively by jaxb-impl
implementation 'com.sun.xml.bind:jaxb-impl:4.0.5'
api "com.prowidesoftware:pw-swift-core:${prowideCoreVersion}"
implementation 'org.apache.commons:commons-lang3:3.17.0'
implementation 'com.google.code.gson:gson:2.11.0'
}

// repo for publishing
Expand Down Expand Up @@ -481,6 +468,12 @@ tasks.withType(Test) {
}
}

task('testOn11', type: Test) {
javaLauncher = javaToolchains.launcherFor {
languageVersion = JavaLanguageVersion.of(11)
}
}

task('testOn17', type: Test) {
javaLauncher = javaToolchains.launcherFor {
languageVersion = JavaLanguageVersion.of(17)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,12 +18,12 @@
import com.google.gson.Gson;
import com.google.gson.GsonBuilder;
import com.prowidesoftware.swift.model.mx.*;
import jakarta.persistence.*;
import java.io.File;
import java.io.IOException;
import java.io.InputStream;
import java.util.Objects;
import java.util.Optional;
import javax.persistence.*;
import org.apache.commons.lang3.StringUtils;

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,19 +25,16 @@
import com.prowidesoftware.swift.model.MessageStandardType;
import com.prowidesoftware.swift.model.MxId;
import com.prowidesoftware.swift.model.mt.AbstractMT;
import com.prowidesoftware.swift.model.mx.adapters.*;
import com.prowidesoftware.swift.model.mx.adapters.v9.V9DateTimeJsonAdapter;
import com.prowidesoftware.swift.utils.Lib;
import jakarta.xml.bind.JAXBContext;
import jakarta.xml.bind.annotation.XmlTransient;
import java.io.*;
import java.nio.charset.StandardCharsets;
import java.time.*;
import java.util.ArrayList;
import java.util.List;
import java.util.Objects;
import java.util.logging.Level;
import java.util.logging.Logger;
import javax.xml.bind.JAXBContext;
import javax.xml.bind.annotation.XmlTransient;
import javax.xml.datatype.XMLGregorianCalendar;
import javax.xml.transform.Source;
import javax.xml.transform.dom.DOMResult;
Expand Down Expand Up @@ -203,7 +200,11 @@ public static AbstractMX parse(final String xml, MxId id, final MxReadConfigurat
* @since 7.10.3
*/
protected static <T> T fromJson(String json, Class<T> classOfT) {
final Gson gson = getGsonBuilderWithV10Adapters();
final Gson gson = new GsonBuilder()
.registerTypeAdapter(AbstractMX.class, new AbstractMXAdapter())
.registerTypeAdapter(XMLGregorianCalendar.class, new XMLGregorianCalendarAdapter())
.registerTypeAdapter(AppHdr.class, new AppHdrAdapter())
.create();
return gson.fromJson(json, classOfT);
}

Expand All @@ -215,41 +216,11 @@ protected static <T> T fromJson(String json, Class<T> classOfT) {
* @since 7.10.3
*/
public static AbstractMX fromJson(String json) {
final Gson gson = getGsonBuilderWithV10Adapters();
return gson.fromJson(json, AbstractMX.class);
}

/**
* Deserializes the given JSON string into an object of the specified class, using version 9 (Java 8) adapters.
*
* <p>This method ensures compatibility by checking for date-time fields stored in JSON as
* {@link XMLGregorianCalendar} based json elements and converting them into {@link OffsetDateTime}. The Gson
* adapters (version 9) manage both Java 8 and Java 11 formats.
*
* @param <T> the type of the object to be deserialized
* @param json a JSON representation of the object
* @param classOfT the class of the object to be deserialized
* @return a deserialized instance of the specified class, or null if the JSON string cannot be parsed.
* @since 10.1.8
*/
protected static <T> T fromJsonV9(String json, Class<T> classOfT) {
final Gson gson = getGsonBuilderWithV9Adapters();
return gson.fromJson(json, classOfT);
}

/**
* Deserializes the given JSON string into a specific MX message object, using version 9 (Java 8) adapters.
*
* <p>This method ensures compatibility with older versions by converting
* {@link XMLGregorianCalendar} based json elements in JSON to {@link OffsetDateTime} if needed. The
* deserialization uses custom adapters (version 9) that handle both formats for date-time fields.
*
* @param json a JSON representation of an MX message
* @return a deserialized instance of {@link AbstractMX}, or null if the JSON string cannot be parsed.
* @since 10.1.8
*/
public static AbstractMX fromJsonV9(String json) {
final Gson gson = getGsonBuilderWithV9Adapters();
final Gson gson = new GsonBuilder()
.registerTypeAdapter(AbstractMX.class, new AbstractMXAdapter())
.registerTypeAdapter(XMLGregorianCalendar.class, new XMLGregorianCalendarAdapter())
.registerTypeAdapter(AppHdr.class, new AppHdrAdapter())
.create();
return gson.fromJson(json, AbstractMX.class);
}

Expand Down Expand Up @@ -589,49 +560,14 @@ public Element element(JAXBContext inputContext) {
*/
@Override
public String toJson() {
// we use AbstractMX and not this.getClass() in order to force usage of the adapter
final Gson gson = getGsonBuilderWithV10Adapters();
return gson.toJson(this, AbstractMX.class);
}

/**
* Serializes this MX message into its JSON representation, using version 9 (Java 8) adapters.
*
* <p>This method ensures that when serializing to JSON, {@link OffsetDateTime} fields can be converted
* back into {@link XMLGregorianCalendar} based json element format for compatibility with older systems that still use the Java 8 format.
*
* @return a JSON representation of the MX message, compatible with Java 8
* @since 10.1.8
*/
public String toJsonV9() {
final Gson gson = getGsonBuilderWithV9Adapters();
return gson.toJson(this, AbstractMX.class);
}

private static GsonBuilder getGsonBuilderWithCustomAdapters() {
return new GsonBuilder()
final Gson gson = new GsonBuilder()
.registerTypeAdapter(AbstractMX.class, new AbstractMXAdapter())
.registerTypeAdapter(OffsetTime.class, new OffsetTimeJsonAdapter())
.registerTypeAdapter(LocalDate.class, new LocalDateJsonAdapter())
.registerTypeAdapter(Year.class, new YearJsonAdapter())
.registerTypeAdapter(YearMonth.class, new YearMonthJsonAdapter())
.registerTypeAdapter(AppHdr.class, new AppHdrAdapter());
}

private static Gson getGsonBuilderWithV9Adapters() {
final Gson gson = getGsonBuilderWithCustomAdapters()
.registerTypeAdapter(OffsetDateTime.class, new V9DateTimeJsonAdapter())
.registerTypeHierarchyAdapter(XMLGregorianCalendar.class, new XMLGregorianCalendarAdapter())
.registerTypeAdapter(AppHdr.class, new AppHdrAdapter())
.setPrettyPrinting()
.create();
return gson;
}

private static Gson getGsonBuilderWithV10Adapters() {
final Gson gson = getGsonBuilderWithCustomAdapters()
.registerTypeAdapter(OffsetDateTime.class, new OffsetDateTimeJsonAdapter())
.setPrettyPrinting()
.create();
return gson;
// we use AbstractMX and not this.getClass() in order to force usage of the adapter
return gson.toJson(this, AbstractMX.class);
}

/**
Expand Down
Loading