├── .gitignore
├── README.md
├── pom.xml
└── src
└── main
└── java
└── com
└── paymentcomponents
└── swift
└── mx
├── BuildValidPacs002_12.java
├── ConvertMX2XML.java
├── Main.java
├── ParseAndValidateInvalidPacs002_12.java
├── ParseAndValidateValidPacs002_12.java
├── Utils.java
├── cbpr
└── ParseAndValidateCbprMessage.java
├── sepa
├── dias
│ └── ct
│ │ └── ParseAndValidateSepaDiasCtMessage.java
├── eba
│ └── ct
│ │ └── ParseAndValidateSepaEbaCtMessage.java
├── epc
│ └── ct
│ │ └── ParseAndValidateSepaEpcCtMessage.java
└── sibs
│ ├── ct
│ └── ParseAndValidateSepaSibsCtMessage.java
│ └── dd
│ └── ParseAndValidateSepaSibsDdMessage.java
└── target2
└── ParseAndValidateRtgsMessage.java
/.gitignore:
--------------------------------------------------------------------------------
1 | *.iml
2 | .idea/
3 | target/
--------------------------------------------------------------------------------
/pom.xml:
--------------------------------------------------------------------------------
1 |
2 |
5 | 4.0.0
6 |
7 | com.paymentcomponents
8 | demo-iso20022
9 | 1.0-SNAPSHOT
10 |
11 |
12 | 8
13 | 8
14 | 24.10.0
15 |
16 |
17 |
18 |
19 | paymentcomponents
20 | https://nexus.paymentcomponents.com/repository/public
21 |
22 |
23 |
24 |
25 |
26 | gr.datamation.mx
27 | mx
28 | ${mx.version}
29 | demo
30 |
31 |
32 |
33 | gr.datamation.mx
34 | mx
35 | ${mx.version}
36 | demo-rtgs
37 |
38 |
39 |
40 | gr.datamation.mx
41 | mx
42 | ${mx.version}
43 | demo-cbpr
44 |
45 |
46 |
47 | gr.datamation.mx
48 | mx
49 | ${mx.version}
50 | demo-sepa
51 |
52 |
53 |
54 |
55 | org.codehaus.mojo
56 | jaxb2-maven-plugin
57 | 2.5.0
58 |
59 |
60 |
61 |
--------------------------------------------------------------------------------
/src/main/java/com/paymentcomponents/swift/mx/BuildValidPacs002_12.java:
--------------------------------------------------------------------------------
1 | package com.paymentcomponents.swift.mx;
2 |
3 | import gr.datamation.mx.message.pacs.FIToFIPaymentStatusReport12;
4 | import gr.datamation.validation.error.ValidationErrorList;
5 | import xsd.pacs_002_001_12.GroupHeader101;
6 | import xsd.pacs_002_001_12.OriginalGroupHeader17;
7 |
8 | public class BuildValidPacs002_12 {
9 |
10 | public static void main(String... args) {
11 | execute();
12 | }
13 |
14 | public static void execute() {
15 | buildPacs002_method1();
16 | buildPacs002_method2();
17 | }
18 |
19 | public static void buildPacs002_method1() {
20 | try {
21 | System.out.println("Build pacs.002.001.12 using setElement()");
22 | FIToFIPaymentStatusReport12 messageObject = new FIToFIPaymentStatusReport12();
23 |
24 | // Set elements for GroupHeader
25 | messageObject.setElement("GrpHdr/MsgId", "MESSAGEID");
26 | messageObject.setElement("GrpHdr/CreDtTm", Utils.xmlGregorianCalendar());
27 |
28 | // Set elements for OriginalGroupInformation
29 | messageObject.setElement("OrgnlGrpInfAndSts[0]/OrgnlMsgId", "ORIGINALMESSAGEID");
30 | messageObject.setElement("OrgnlGrpInfAndSts[0]/OrgnlMsgNmId", "pacs.008.001");
31 | messageObject.setElement("OrgnlGrpInfAndSts[0]/GrpSts", "ACCP");
32 |
33 | //Use validate() to check the messageObject and validate the content
34 | //It returns a ValidationErrorList which contains any issue found during validation
35 | ValidationErrorList errorList = messageObject.validate();
36 | Utils.printValidMessageOrErrors(messageObject, errorList);
37 | } catch (Exception e) {
38 | e.printStackTrace();
39 | }
40 | }
41 |
42 | public static void buildPacs002_method2() {
43 | try {
44 | System.out.println("Build pacs.002.001.12 using message classes()");
45 | FIToFIPaymentStatusReport12 messageObject = new FIToFIPaymentStatusReport12();
46 |
47 | // Set elements for GroupHeader
48 | messageObject.getMessage().setGrpHdr(new GroupHeader101());
49 | messageObject.getMessage().getGrpHdr().setMsgId("MESSAGEID");
50 | messageObject.getMessage().getGrpHdr().setCreDtTm(Utils.xmlGregorianCalendar());
51 |
52 | // Set elements for OriginalGroupInformation
53 | messageObject.getMessage().getOrgnlGrpInfAndSts().add(new OriginalGroupHeader17());
54 | messageObject.getMessage().getOrgnlGrpInfAndSts().get(0).setOrgnlMsgId("ORIGINALMESSAGEID");
55 | messageObject.getMessage().getOrgnlGrpInfAndSts().get(0).setOrgnlMsgNmId("pacs.008.001");
56 | messageObject.getMessage().getOrgnlGrpInfAndSts().get(0).setGrpSts("ACCP");
57 |
58 | //Use validate() to check the messageObject and validate the content
59 | //It returns a ValidationErrorList which contains any issue found during validation
60 | ValidationErrorList errorList = messageObject.validate();
61 | Utils.printValidMessageOrErrors(messageObject, errorList);
62 | } catch (Exception e) {
63 | e.printStackTrace();
64 | }
65 | }
66 |
67 | }
68 |
--------------------------------------------------------------------------------
/src/main/java/com/paymentcomponents/swift/mx/ConvertMX2XML.java:
--------------------------------------------------------------------------------
1 | package com.paymentcomponents.swift.mx;
2 |
3 | import gr.datamation.mx.Message;
4 | import gr.datamation.mx.message.pacs.FIToFIPaymentStatusReport11;
5 |
6 | public class ConvertMX2XML {
7 |
8 | public static void main(String... args) {
9 | execute();
10 | }
11 |
12 | public static void execute() {
13 | //You have to initiate the message object using the suitable constructor.
14 | //In order to parse and validate a pacs.002.001.11 you need to use FIToFIPaymentStatusReport11
15 | //FIToFIPaymentStatusReport > matches the xml element
16 | //11 > the version of the pacs.002.001.VERSION which can be found in xmlns attribute of the xml
17 | Message messageObject = new FIToFIPaymentStatusReport11();
18 | try {
19 | //Use parseXML() to fill the messageObject the content of the message
20 | messageObject.parseXML(validPacs002String);
21 |
22 | //Use convertToXML() to get the message in text format (XML)
23 | String pacs002ToXml = messageObject.convertToXML();
24 | System.out.println(pacs002ToXml);
25 |
26 | } catch (Exception e) {
27 | e.printStackTrace();
28 | System.err.println("Message cannot be parsed");
29 | }
30 | }
31 |
32 | private static final String validPacs002String = "\n" +
33 | "\n" +
34 | " \n" +
35 | " \n" +
36 | " ABABUS23-STATUS-456/04\n" +
37 | " 2015-06-29T09:56:00\n" +
38 | " \n" +
39 | " \n" +
40 | " ABABUS23\n" +
41 | " \n" +
42 | " \n" +
43 | " \n" +
44 | " \n" +
45 | " AAAAUS29\n" +
46 | " \n" +
47 | " \n" +
48 | " \n" +
49 | " \n" +
50 | " AAAA100628-123v\n" +
51 | " pacs.003.001.08\n" +
52 | " 2015-06-28T10:05:00\n" +
53 | " \n" +
54 | " \n" +
55 | " AB/8568\n" +
56 | " VA060327/0123\n" +
57 | " AAAAUS29/100628/ad458\n" +
58 | " RJCT\n" +
59 | " \n" +
60 | " \n" +
61 | " \n" +
62 | " \n" +
63 | " ABABUS23\n" +
64 | " \n" +
65 | " \n" +
66 | " \n" +
67 | " \n" +
68 | " AM05\n" +
69 | " \n" +
70 | " \n" +
71 | " \n" +
72 | " 1025\n" +
73 | " 2015-06-28\n" +
74 | " 2015-07-13\n" +
75 | " \n" +
76 | " \n" +
77 | " VIRGAY123\n" +
78 | " \n" +
79 | " \n" +
80 | " \n" +
81 | " \n" +
82 | " Jones\n" +
83 | " \n" +
84 | " Hudson Street\n" +
85 | " 19\n" +
86 | " NJ 07302\n" +
87 | " Jersey City\n" +
88 | " US\n" +
89 | " \n" +
90 | " \n" +
91 | " \n" +
92 | " \n" +
93 | " \n" +
94 | " Virgay\n" +
95 | " \n" +
96 | " Virginia Lane\n" +
97 | " 36\n" +
98 | " NJ 07311\n" +
99 | " Jersey City\n" +
100 | " US\n" +
101 | " \n" +
102 | " \n" +
103 | " \n" +
104 | " \n" +
105 | " \n" +
106 | " \n" +
107 | "\n";
108 |
109 | }
110 |
--------------------------------------------------------------------------------
/src/main/java/com/paymentcomponents/swift/mx/Main.java:
--------------------------------------------------------------------------------
1 | package com.paymentcomponents.swift.mx;
2 |
3 | import com.paymentcomponents.swift.mx.cbpr.ParseAndValidateCbprMessage;
4 | import com.paymentcomponents.swift.mx.sepa.epc.ct.ParseAndValidateSepaEpcCtMessage;
5 | import com.paymentcomponents.swift.mx.target2.ParseAndValidateRtgsMessage;
6 |
7 | public class Main {
8 |
9 | public static void main(String[] args) {
10 | ParseAndValidateValidPacs002_12.execute();
11 | ParseAndValidateInvalidPacs002_12.execute();
12 | BuildValidPacs002_12.execute();
13 | ConvertMX2XML.execute();
14 | ParseAndValidateCbprMessage.execute();
15 | ParseAndValidateRtgsMessage.execute();
16 | ParseAndValidateSepaEpcCtMessage.execute();
17 | }
18 |
19 | }
20 |
--------------------------------------------------------------------------------
/src/main/java/com/paymentcomponents/swift/mx/ParseAndValidateInvalidPacs002_12.java:
--------------------------------------------------------------------------------
1 | package com.paymentcomponents.swift.mx;
2 |
3 | import gr.datamation.mx.message.pacs.FIToFIPaymentStatusReport12;
4 | import gr.datamation.validation.error.ValidationErrorList;
5 |
6 | import java.io.ByteArrayInputStream;
7 |
8 | public class ParseAndValidateInvalidPacs002_12 {
9 |
10 | public static void main(String... args) {
11 | execute();
12 | }
13 |
14 | public static void execute() {
15 | makeValidPacs002Invalid();
16 | parseInvalidPacs002();
17 | }
18 |
19 | public static void makeValidPacs002Invalid() {
20 | //You have to initiate the message object using the suitable constructor.
21 | //In order to parse and validate a pacs.002.001.12 you need to use FIToFIPaymentStatusReport12
22 | //FIToFIPaymentStatusReport > matches the xml element
23 | //12 > the version of the pacs.002.001.VERSION which can be found in xmlns attribute of the xml
24 | FIToFIPaymentStatusReport12 messageObject = new FIToFIPaymentStatusReport12();
25 | try {
26 | //Use validateXML() to validate the xml schema of the message
27 | ValidationErrorList errorList = messageObject.validateXML(new ByteArrayInputStream(validPacs002String.getBytes()));
28 | if (!errorList.isEmpty()) {
29 | Utils.printInvalidMessageErrors(errorList);
30 | return;
31 | }
32 | //Use parseXML() to fill the messageObject the content of the message
33 | messageObject.parseXML(validPacs002String);
34 | //Manually edit a value of the message that makes it invalid
35 | messageObject.getMessage().getGrpHdr().getInstgAgt().setFinInstnId(null);
36 | //Use validate() to check the messageObject and validate the content
37 | //It returns a ValidationErrorList which contains any issue found during validation
38 | errorList = messageObject.validate();
39 | Utils.printValidMessageOrErrors(messageObject, errorList);
40 | /* The following error message should be visible when running this example:
41 | Message is invalid, and the errors are the following:
42 | ERROR null cvc-complex-type.2.4.b: The content of element 'InstgAgt' is not complete. One of '{"urn:iso:std:iso:20022:tech:xsd:pacs.002.001.12":FinInstnId}' is expected. null (null)
43 | Error Code: null
44 | Error Description: cvc-complex-type.2.4.b: The content of element 'InstgAgt' is not complete. One of '{"urn:iso:std:iso:20022:tech:xsd:pacs.002.001.12":FinInstnId}' is expected.
45 | Line number in error inside the tag: 0
46 | */
47 | } catch (Exception e) {
48 | e.printStackTrace();
49 | System.err.println("Message cannot be parsed");
50 | }
51 | }
52 |
53 | public static void parseInvalidPacs002() {
54 | //You have to initiate the message object using the suitable constructor.
55 | //In order to parse and validate a pacs.002.001.12 you need to use FIToFIPaymentStatusReport12
56 | //FIToFIPaymentStatusReport > matches the xml element
57 | //12 > the version of the pacs.002.001.VERSION which can be found in xmlns attribute of the xml
58 | FIToFIPaymentStatusReport12 messageObject = new FIToFIPaymentStatusReport12();
59 | try {
60 | //Use parseXML() to fill the messageObject the content of the message
61 | messageObject.parseXML(invalidPacs002String);
62 | //Use validate() to check the messageObject and validate the content
63 | //It returns a ValidationErrorList which contains any issue found during validation
64 | ValidationErrorList errorList = messageObject.validate();
65 | Utils.printValidMessageOrErrors(messageObject, errorList);
66 | /* The following error message should be visible when running this example:
67 | Message is invalid, and the errors are the following:
68 | ERROR null cvc-complex-type.2.4.b: The content of element 'InstgAgt' is not complete. One of '{"urn:iso:std:iso:20022:tech:xsd:pacs.002.001.12":FinInstnId}' is expected. null (null)
69 | Error Code: null
70 | Error Description: cvc-complex-type.2.4.b: The content of element 'InstgAgt' is not complete. One of '{"urn:iso:std:iso:20022:tech:xsd:pacs.002.001.12":FinInstnId}' is expected.
71 | Line number in error inside the tag: 0
72 | */
73 | } catch (Exception e) {
74 | e.printStackTrace();
75 | System.err.println("Message cannot be parsed");
76 | }
77 | }
78 |
79 | private static final String validPacs002String = "\n" +
80 | "\n" +
81 | " \n" +
82 | " \n" +
83 | " ABABUS23-STATUS-456/04\n" +
84 | " 2015-06-29T09:56:00\n" +
85 | " \n" +
86 | " \n" +
87 | " ABABUS23\n" +
88 | " \n" +
89 | " \n" +
90 | " \n" +
91 | " \n" +
92 | " AAAAUS29\n" +
93 | " \n" +
94 | " \n" +
95 | " \n" +
96 | " \n" +
97 | " AAAA100628-123v\n" +
98 | " pacs.003.001.08\n" +
99 | " 2015-06-28T10:05:00\n" +
100 | " \n" +
101 | " \n" +
102 | " AB/8568\n" +
103 | " VA060327/0123\n" +
104 | " AAAAUS29/100628/ad458\n" +
105 | " RJCT\n" +
106 | " \n" +
107 | " \n" +
108 | " \n" +
109 | " \n" +
110 | " ABABUS23\n" +
111 | " \n" +
112 | " \n" +
113 | " \n" +
114 | " \n" +
115 | " AM05\n" +
116 | " \n" +
117 | " \n" +
118 | " \n" +
119 | " 1025\n" +
120 | " 2015-06-28\n" +
121 | " 2015-07-13\n" +
122 | " \n" +
123 | " \n" +
124 | " VIRGAY123\n" +
125 | " \n" +
126 | " \n" +
127 | " \n" +
128 | " \n" +
129 | " Jones\n" +
130 | " \n" +
131 | " Hudson Street\n" +
132 | " 19\n" +
133 | " NJ 07302\n" +
134 | " Jersey City\n" +
135 | " US\n" +
136 | " \n" +
137 | " \n" +
138 | " \n" +
139 | " \n" +
140 | " \n" +
141 | " Virgay\n" +
142 | " \n" +
143 | " Virginia Lane\n" +
144 | " 36\n" +
145 | " NJ 07311\n" +
146 | " Jersey City\n" +
147 | " US\n" +
148 | " \n" +
149 | " \n" +
150 | " \n" +
151 | " \n" +
152 | " \n" +
153 | " \n" +
154 | "\n";
155 |
156 | private static final String invalidPacs002String = "\n" +
157 | "\n" +
158 | " \n" +
159 | " \n" +
160 | " ABABUS23-STATUS-456/04\n" +
161 | " 2015-06-29T09:56:00\n" +
162 | " \n" +
163 | // " \n" +
164 | // " ABABUS23\n" +
165 | // " \n" +
166 | " \n" +
167 | " \n" +
168 | " \n" +
169 | " AAAAUS29\n" +
170 | " \n" +
171 | " \n" +
172 | " \n" +
173 | " \n" +
174 | " AAAA100628-123v\n" +
175 | " pacs.003.001.08\n" +
176 | " 2015-06-28T10:05:00\n" +
177 | " \n" +
178 | " \n" +
179 | " AB/8568\n" +
180 | " VA060327/0123\n" +
181 | " AAAAUS29/100628/ad458\n" +
182 | " RJCT\n" +
183 | " \n" +
184 | " \n" +
185 | " \n" +
186 | " \n" +
187 | " ABABUS23\n" +
188 | " \n" +
189 | " \n" +
190 | " \n" +
191 | " \n" +
192 | " AM05\n" +
193 | " \n" +
194 | " \n" +
195 | " \n" +
196 | " 1025\n" +
197 | " 2015-06-28\n" +
198 | " 2015-07-13\n" +
199 | " \n" +
200 | " \n" +
201 | " VIRGAY123\n" +
202 | " \n" +
203 | " \n" +
204 | " \n" +
205 | " \n" +
206 | " Jones\n" +
207 | " \n" +
208 | " Hudson Street\n" +
209 | " 19\n" +
210 | " NJ 07302\n" +
211 | " Jersey City\n" +
212 | " US\n" +
213 | " \n" +
214 | " \n" +
215 | " \n" +
216 | " \n" +
217 | " \n" +
218 | " Virgay\n" +
219 | " \n" +
220 | " Virginia Lane\n" +
221 | " 36\n" +
222 | " NJ 07311\n" +
223 | " Jersey City\n" +
224 | " US\n" +
225 | " \n" +
226 | " \n" +
227 | " \n" +
228 | " \n" +
229 | " \n" +
230 | " \n" +
231 | "\n";
232 |
233 | }
234 |
--------------------------------------------------------------------------------
/src/main/java/com/paymentcomponents/swift/mx/ParseAndValidateValidPacs002_12.java:
--------------------------------------------------------------------------------
1 | package com.paymentcomponents.swift.mx;
2 |
3 | import gr.datamation.mx.Message;
4 | import gr.datamation.mx.message.pacs.FIToFIPaymentStatusReport12;
5 | import gr.datamation.validation.error.ValidationErrorList;
6 |
7 | import java.io.ByteArrayInputStream;
8 |
9 | public class ParseAndValidateValidPacs002_12 {
10 |
11 | public static void main(String... args) {
12 | execute();
13 | }
14 |
15 | public static void execute() {
16 | //You have to initiate the message object using the suitable constructor.
17 | //In order to parse and validate a pacs.002.001.12 you need to use FIToFIPaymentStatusReport12
18 | //FIToFIPaymentStatusReport > matches the xml element
19 | //12 > the version of the pacs.002.001.VERSION which can be found in xmlns attribute of the xml
20 | Message messageObject = new FIToFIPaymentStatusReport12();
21 | try {
22 | //Use validateXML() to validate the xml schema of the message
23 | ValidationErrorList errorList = messageObject.validateXML(new ByteArrayInputStream(validPacs002String.getBytes()));
24 | if (!errorList.isEmpty()) {
25 | Utils.printInvalidMessageErrors(errorList);
26 | return;
27 | }
28 | //Use parseXML() to fill the messageObject the content of the message
29 | messageObject.parseXML(validPacs002String);
30 | //Use validate() to check the messageObject and validate the content
31 | //It returns a ValidationErrorList which contains any issue found during validation
32 | errorList = messageObject.validate();
33 | Utils.printValidMessageOrErrors(messageObject, errorList);
34 | } catch (Exception e) {
35 | e.printStackTrace();
36 | System.err.println("Message cannot be parsed");
37 | }
38 | }
39 |
40 | private static final String validPacs002String = "\n" +
41 | "\n" +
42 | " \n" +
43 | " \n" +
44 | " ABABUS23-STATUS-456/04\n" +
45 | " 2015-06-29T09:56:00\n" +
46 | " \n" +
47 | " \n" +
48 | " ABABUS23\n" +
49 | " \n" +
50 | " \n" +
51 | " \n" +
52 | " \n" +
53 | " AAAAUS29\n" +
54 | " \n" +
55 | " \n" +
56 | " \n" +
57 | " \n" +
58 | " AAAA100628-123v\n" +
59 | " pacs.003.001.09\n" +
60 | " 2015-06-28T10:05:00\n" +
61 | " \n" +
62 | " \n" +
63 | " AB/8568\n" +
64 | " VA060327/0123\n" +
65 | " AAAAUS29/100628/ad458\n" +
66 | " RJCT\n" +
67 | " \n" +
68 | " \n" +
69 | " \n" +
70 | " \n" +
71 | " ABABUS23\n" +
72 | " \n" +
73 | " \n" +
74 | " \n" +
75 | " \n" +
76 | " AM05\n" +
77 | " \n" +
78 | " \n" +
79 | " \n" +
80 | " 1025\n" +
81 | " 2015-06-28\n" +
82 | " 2015-07-13\n" +
83 | " \n" +
84 | " \n" +
85 | " VIRGAY123\n" +
86 | " \n" +
87 | " \n" +
88 | " \n" +
89 | " \n" +
90 | " Jones\n" +
91 | " \n" +
92 | " Hudson Street\n" +
93 | " 19\n" +
94 | " NJ 07302\n" +
95 | " Jersey City\n" +
96 | " US\n" +
97 | " \n" +
98 | " \n" +
99 | " \n" +
100 | " \n" +
101 | " \n" +
102 | " Virgay\n" +
103 | " \n" +
104 | " Virginia Lane\n" +
105 | " 36\n" +
106 | " NJ 07311\n" +
107 | " Jersey City\n" +
108 | " US\n" +
109 | " \n" +
110 | " \n" +
111 | " \n" +
112 | " \n" +
113 | " \n" +
114 | " \n" +
115 | "\n";
116 |
117 | }
118 |
--------------------------------------------------------------------------------
/src/main/java/com/paymentcomponents/swift/mx/Utils.java:
--------------------------------------------------------------------------------
1 | package com.paymentcomponents.swift.mx;
2 |
3 | import gr.datamation.mx.Message;
4 | import gr.datamation.validation.error.ValidationError;
5 | import gr.datamation.validation.error.ValidationErrorList;
6 |
7 | import javax.xml.bind.JAXBException;
8 | import javax.xml.datatype.DatatypeConfigurationException;
9 | import javax.xml.datatype.DatatypeFactory;
10 | import javax.xml.datatype.XMLGregorianCalendar;
11 | import java.io.UnsupportedEncodingException;
12 | import java.util.Date;
13 | import java.util.GregorianCalendar;
14 |
15 | public class Utils {
16 |
17 | public static void printValidMessageOrErrors(Message messageObject, ValidationErrorList validationErrorList) throws JAXBException, UnsupportedEncodingException {
18 | if (validationErrorList == null || validationErrorList.isEmpty()) {
19 | System.out.println("Message is valid");
20 | System.out.println(messageObject.convertToXML());
21 | } else {
22 | printInvalidMessageErrors(validationErrorList);
23 | }
24 | }
25 |
26 | public static void printInvalidMessageErrors(ValidationErrorList validationErrorList) {
27 | System.err.println("Message is invalid, and the errors are the following:");
28 | for (ValidationError error : validationErrorList) {
29 | System.err.println(error.toString());
30 | System.err.println(
31 | "Error Code: " + error.getErrorCode() + "\n" +
32 | "Error Description: " + error.getDescription() + "\n" +
33 | "Line number in error inside the tag: " + error.getLine() + "\n"
34 | );
35 | }
36 | }
37 |
38 | public static XMLGregorianCalendar xmlGregorianCalendar() {
39 | GregorianCalendar cal = new GregorianCalendar();
40 | cal.setTime(new Date());
41 | XMLGregorianCalendar xmlDate = null;
42 | try {
43 | xmlDate = DatatypeFactory.newInstance().newXMLGregorianCalendar(cal);
44 | } catch (DatatypeConfigurationException e) {
45 | e.printStackTrace();
46 | }
47 | return xmlDate;
48 | }
49 |
50 | }
51 |
--------------------------------------------------------------------------------
/src/main/java/com/paymentcomponents/swift/mx/cbpr/ParseAndValidateCbprMessage.java:
--------------------------------------------------------------------------------
1 | package com.paymentcomponents.swift.mx.cbpr;
2 |
3 | import gr.datamation.iso20022.cbpr.CbprMessage;
4 | import gr.datamation.mx.message.head.BusinessApplicationHeader02;
5 | import gr.datamation.mx.message.pacs.FinancialInstitutionCreditTransfer08;
6 | import gr.datamation.validation.error.ValidationError;
7 | import gr.datamation.validation.error.ValidationErrorList;
8 |
9 | import java.io.ByteArrayInputStream;
10 |
11 | public class ParseAndValidateCbprMessage {
12 |
13 | public static void main(String... args) {
14 | execute();
15 | }
16 |
17 | public static void execute() {
18 | constructCBPRMessage();
19 | parseAndValidateCBPRMessage();
20 | autoParseAndValidateCBPRMessage();
21 | }
22 |
23 | public static void constructCBPRMessage() {
24 | try {
25 | //Initialize the header object
26 | BusinessApplicationHeader02 businessApplicationHeader = new BusinessApplicationHeader02();
27 | businessApplicationHeader.parseXML(validCbprPacs009HeaderString);
28 |
29 | //Initialize the document object
30 | FinancialInstitutionCreditTransfer08 financialInstitutionCreditTransfer08 = new FinancialInstitutionCreditTransfer08();
31 | financialInstitutionCreditTransfer08.parseXML(validCbprPacs009DocumentString);
32 |
33 | //We fill the elements of the message object using setters
34 | //financialInstitutionCreditTransfer08.getMessage().setGrpHdr(new GroupHeader93());
35 | //financialInstitutionCreditTransfer08.getMessage().getGrpHdr().setMsgId("1234");
36 |
37 | //or setElement()
38 | //financialInstitutionCreditTransfer08.setElement("GrpHdr/MsgId", "1234");
39 |
40 | //Construct the CBPR message object using two separate objects, header, document
41 | CbprMessage cbprMessage = new CbprMessage<>(businessApplicationHeader, financialInstitutionCreditTransfer08);
42 |
43 | //Perform validation in both header and message object using cbprMessage
44 | //Use CbprMessage.CbprMsgType enumeration object to select the matching schema (check the table of supported CBPR messages below
45 | //CbprMessage.extractCbprMsgType() can also be used
46 | ValidationErrorList validationErrorList = cbprMessage.validate(CbprMessage.CbprMsgType.PACS_009_CORE);
47 |
48 | if (validationErrorList.isEmpty()) {
49 | System.out.println("Message is valid");
50 | System.out.println(cbprMessage.convertToXML()); //Get the generated xmls for head and document
51 | } else {
52 | handleValidationError(validationErrorList);
53 | }
54 | } catch (Exception e) {
55 | e.printStackTrace();
56 | System.err.println(e.getMessage());
57 | }
58 | }
59 |
60 | public static void parseAndValidateCBPRMessage() {
61 | try {
62 | //Initialize the cbprMessage
63 | CbprMessage cbprMessage = new CbprMessage<>(new BusinessApplicationHeader02(), new FinancialInstitutionCreditTransfer08());
64 | //Fill the cbprMessage with data from xml and validate CBPR+ against the xml schema
65 | ValidationErrorList validationErrorList = cbprMessage.autoParseAndValidateXml(new ByteArrayInputStream(validCbprPacs009String.getBytes()));
66 | if (!validationErrorList.isEmpty()) {
67 | handleValidationError(validationErrorList);
68 | return;
69 | }
70 |
71 | //Perform validation in both header and message object using cbprMessage
72 | //Use CbprMessage.CbprMsgType enumeration object to select the matching schema (check the table of supported CBPR messages below
73 | //CbprMessage.extractCbprMsgType() can also be used
74 | validationErrorList.addAll(cbprMessage.validate(CbprMessage.CbprMsgType.PACS_009_CORE));
75 |
76 | if (validationErrorList.isEmpty()) {
77 | System.out.println("Message is valid");
78 | System.out.println(cbprMessage.convertToXML()); //Get the generated xmls for head and document
79 | } else {
80 | handleValidationError(validationErrorList);
81 | }
82 |
83 | //Extract the header and the core message from cbprMessage object
84 | BusinessApplicationHeader02 businessApplicationHeader = cbprMessage.getAppHdr();
85 | FinancialInstitutionCreditTransfer08 financialInstitutionCreditTransfer08 = cbprMessage.getDocument();
86 |
87 | } catch (Exception e) {
88 | e.printStackTrace();
89 | System.err.println(e.getMessage());
90 | }
91 | }
92 |
93 | public static void autoParseAndValidateCBPRMessage() {
94 | try {
95 | //Initialize the cbprMessage
96 | CbprMessage cbprMessage = new CbprMessage<>();
97 | //Fill the cbprMessage with data from xml and validate CBPR+ against the xml schema
98 | ValidationErrorList validationErrorList = cbprMessage.autoParseAndValidateXml(new ByteArrayInputStream(validCbprPacs009String.getBytes()));
99 | if (!validationErrorList.isEmpty()) {
100 | handleValidationError(validationErrorList);
101 | return;
102 | }
103 |
104 | //Perform validation in both header and message object using cbprMessage
105 | validationErrorList.addAll(cbprMessage.autoValidate());
106 |
107 | if (validationErrorList.isEmpty()) {
108 | System.out.println("Message is valid");
109 | System.out.println(cbprMessage.convertToXML()); //Get the generated xmls for head and document
110 | } else {
111 | handleValidationError(validationErrorList);
112 | }
113 |
114 | //Extract the header and the core message from cbprMessage object
115 | BusinessApplicationHeader02 businessApplicationHeader = cbprMessage.getAppHdr();
116 | FinancialInstitutionCreditTransfer08 financialInstitutionCreditTransfer08 = cbprMessage.getDocument();
117 |
118 | } catch (Exception e) {
119 | e.printStackTrace();
120 | System.err.println(e.getMessage());
121 | }
122 | }
123 |
124 | private static void handleValidationError(ValidationErrorList validationErrorList) {
125 | System.err.println("Message is invalid, and the errors are the following:");
126 | for (ValidationError error : validationErrorList) {
127 | System.err.println(error.toString());
128 | System.err.println(
129 | "Error Code: " + error.getErrorCode() + "\n" +
130 | "Error Description: " + error.getDescription() + "\n" +
131 | "Line number in error inside the tag: " + error.getLine() + "\n"
132 | );
133 | }
134 | }
135 |
136 | private static final String validCbprPacs009String = "\n" +
137 | "\n" +
138 | " \n" +
139 | " \n" +
140 | " \n" +
141 | " BBBBUS33\n" +
142 | " \n" +
143 | " \n" +
144 | " \n" +
145 | " \n" +
146 | " \n" +
147 | " \n" +
148 | " CCCCJPJT\n" +
149 | " \n" +
150 | " \n" +
151 | " \n" +
152 | " BBBB/120928-FICT/JPY/430\n" +
153 | " pacs.009.001.08\n" +
154 | " swift.cbprplus.02\n" +
155 | " \n" +
156 | " string\n" +
157 | " string\n" +
158 | " \n" +
159 | " 2008-09-29T04:49:45+03:00\n" +
160 | " CODU\n" +
161 | " true\n" +
162 | " NORM\n" +
163 | " \n" +
164 | " \n" +
165 | " \n" +
166 | " \n" +
167 | " BBBBUS33\n" +
168 | " \n" +
169 | " \n" +
170 | " \n" +
171 | " \n" +
172 | " \n" +
173 | " \n" +
174 | " CCCCJPJT\n" +
175 | " \n" +
176 | " \n" +
177 | " \n" +
178 | " BBBB/120928-FICT/JPY/430\n" +
179 | " pacs.009.001.08\n" +
180 | " swift.cbprplus.02\n" +
181 | " 2014-06-09T18:15:04+03:00\n" +
182 | " COPY\n" +
183 | " NORM\n" +
184 | " \n" +
185 | "\n" +
186 | "\n" +
187 | "\n" +
188 | "\n" +
189 | " \n" +
190 | " \n" +
191 | " BBBB/120928-FICT/JPY/430\n" +
192 | " 2012-09-28T16:00:00+13:00\n" +
193 | " 1\n" +
194 | " \n" +
195 | " INDA\n" +
196 | " \n" +
197 | " \n" +
198 | " \n" +
199 | " ACCOUNTID\n" +
200 | " \n" +
201 | " \n" +
202 | " \n" +
203 | " \n" +
204 | " \n" +
205 | " \n" +
206 | " \n" +
207 | " BBBB/120928-FICT\n" +
208 | " ABC/4562/2012-09-08\n" +
209 | " BBBB/120928-CCT/123/1\n" +
210 | " 00000000-0000-4000-8000-000000000000\n" +
211 | " \n" +
212 | " \n" +
213 | " NORM\n" +
214 | " \n" +
215 | " 10000000\n" +
216 | " 2012-09-29\n" +
217 | " \n" +
218 | " 2012-09-28T16:00:00+13:00\n" +
219 | " \n" +
220 | " \n" +
221 | " 12:12:12+13:00\n" +
222 | " \n" +
223 | " \n" +
224 | " \n" +
225 | " TESTBICD\n" +
226 | " \n" +
227 | " \n" +
228 | " \n" +
229 | " \n" +
230 | " BBBBUS33\n" +
231 | " \n" +
232 | " \n" +
233 | " \n" +
234 | " \n" +
235 | " CCCCJPJT\n" +
236 | " \n" +
237 | " \n" +
238 | " \n" +
239 | " \n" +
240 | " INTERBIC\n" +
241 | " \n" +
242 | " \n" +
243 | " \n" +
244 | " \n" +
245 | " \n" +
246 | " INTERAGTACCT\n" +
247 | " \n" +
248 | " \n" +
249 | " \n" +
250 | " \n" +
251 | " \n" +
252 | " BBBBUS33\n" +
253 | " Debtor Name\n" +
254 | " \n" +
255 | " Address\n" +
256 | " \n" +
257 | " \n" +
258 | " \n" +
259 | " \n" +
260 | " \n" +
261 | " \n" +
262 | " DBTRACCT\n" +
263 | " \n" +
264 | " \n" +
265 | " \n" +
266 | " \n" +
267 | " \n" +
268 | " BBBBUS33\n" +
269 | " \n" +
270 | " \n" +
271 | " \n" +
272 | " \n" +
273 | " AAAAJPJT\n" +
274 | " \n" +
275 | " \n" +
276 | " \n" +
277 | " \n" +
278 | " \n" +
279 | " CDTRAGTACCT\n" +
280 | " \n" +
281 | " \n" +
282 | " \n" +
283 | " \n" +
284 | " \n" +
285 | " AAAAGB2L\n" +
286 | " \n" +
287 | " \n" +
288 | " \n" +
289 | " \n" +
290 | " \n" +
291 | " CDTRACCT\n" +
292 | " \n" +
293 | " \n" +
294 | " \n" +
295 | " \n" +
296 | " \n" +
297 | "";
298 |
299 | private static final String validCbprPacs009HeaderString = "\n" +
300 | "\n" +
301 | " \n" +
302 | " \n" +
303 | " \n" +
304 | " BBBBUS33\n" +
305 | " \n" +
306 | " \n" +
307 | " \n" +
308 | " \n" +
309 | " \n" +
310 | " \n" +
311 | " CCCCJPJT\n" +
312 | " \n" +
313 | " \n" +
314 | " \n" +
315 | " BBBB/120928-FICT/JPY/430\n" +
316 | " pacs.009.001.08\n" +
317 | " swift.cbprplus.02\n" +
318 | " \n" +
319 | " string\n" +
320 | " string\n" +
321 | " \n" +
322 | " 2008-09-29T04:49:45+03:00\n" +
323 | " CODU\n" +
324 | " true\n" +
325 | " NORM\n" +
326 | " \n" +
327 | " \n" +
328 | " \n" +
329 | " \n" +
330 | " BBBBUS33\n" +
331 | " \n" +
332 | " \n" +
333 | " \n" +
334 | " \n" +
335 | " \n" +
336 | " \n" +
337 | " CCCCJPJT\n" +
338 | " \n" +
339 | " \n" +
340 | " \n" +
341 | " BBBB/120928-FICT/JPY/430\n" +
342 | " pacs.009.001.08\n" +
343 | " swift.cbprplus.02\n" +
344 | " 2014-06-09T18:15:04+03:00\n" +
345 | " COPY\n" +
346 | " NORM\n" +
347 | " \n" +
348 | "";
349 |
350 | private static final String validCbprPacs009DocumentString = "\n" +
351 | "\n" +
352 | " \n" +
353 | " \n" +
354 | " BBBB/120928-FICT/JPY/430\n" +
355 | " 2012-09-28T16:00:00+13:00\n" +
356 | " 1\n" +
357 | " \n" +
358 | " INDA\n" +
359 | " \n" +
360 | " \n" +
361 | " \n" +
362 | " ACCOUNTID\n" +
363 | " \n" +
364 | " \n" +
365 | " \n" +
366 | " \n" +
367 | " \n" +
368 | " \n" +
369 | " \n" +
370 | " BBBB/120928-FICT\n" +
371 | " ABC/4562/2012-09-08\n" +
372 | " BBBB/120928-CCT/123/1\n" +
373 | " 00000000-0000-4000-8000-000000000000\n" +
374 | " \n" +
375 | " \n" +
376 | " NORM\n" +
377 | " \n" +
378 | " 10000000\n" +
379 | " 2012-09-29\n" +
380 | " \n" +
381 | " 2012-09-28T16:00:00+13:00\n" +
382 | " \n" +
383 | " \n" +
384 | " 12:12:12+13:00\n" +
385 | " \n" +
386 | " \n" +
387 | " \n" +
388 | " TESTBICD\n" +
389 | " \n" +
390 | " \n" +
391 | " \n" +
392 | " \n" +
393 | " BBBBUS33\n" +
394 | " \n" +
395 | " \n" +
396 | " \n" +
397 | " \n" +
398 | " CCCCJPJT\n" +
399 | " \n" +
400 | " \n" +
401 | " \n" +
402 | " \n" +
403 | " INTERBIC\n" +
404 | " \n" +
405 | " \n" +
406 | " \n" +
407 | " \n" +
408 | " \n" +
409 | " INTERAGTACCT\n" +
410 | " \n" +
411 | " \n" +
412 | " \n" +
413 | " \n" +
414 | " \n" +
415 | " BBBBUS33\n" +
416 | " Debtor Name\n" +
417 | " \n" +
418 | " Address\n" +
419 | " \n" +
420 | " \n" +
421 | " \n" +
422 | " \n" +
423 | " \n" +
424 | " \n" +
425 | " DBTRACCT\n" +
426 | " \n" +
427 | " \n" +
428 | " \n" +
429 | " \n" +
430 | " \n" +
431 | " BBBBUS33\n" +
432 | " \n" +
433 | " \n" +
434 | " \n" +
435 | " \n" +
436 | " AAAAJPJT\n" +
437 | " \n" +
438 | " \n" +
439 | " \n" +
440 | " \n" +
441 | " \n" +
442 | " CDTRAGTACCT\n" +
443 | " \n" +
444 | " \n" +
445 | " \n" +
446 | " \n" +
447 | " \n" +
448 | " AAAAGB2L\n" +
449 | " \n" +
450 | " \n" +
451 | " \n" +
452 | " \n" +
453 | " \n" +
454 | " CDTRACCT\n" +
455 | " \n" +
456 | " \n" +
457 | " \n" +
458 | " \n" +
459 | " \n" +
460 | "";
461 |
462 | }
--------------------------------------------------------------------------------
/src/main/java/com/paymentcomponents/swift/mx/sepa/dias/ct/ParseAndValidateSepaDiasCtMessage.java:
--------------------------------------------------------------------------------
1 | package com.paymentcomponents.swift.mx.sepa.dias.ct;
2 |
3 | //import gr.datamation.iso20022.sepa.dias.ct.headers.DiasSctFileHeader;
4 | import gr.datamation.iso20022.sepa.dias.ct.pacs.FIToFIPaymentStatusReport10BatchSepaDiasCt;
5 | import gr.datamation.validation.error.ValidationError;
6 | import gr.datamation.validation.error.ValidationErrorList;
7 |
8 | import java.io.ByteArrayInputStream;
9 |
10 | public class ParseAndValidateSepaDiasCtMessage {
11 |
12 | public static void main(String... args) {
13 | execute();
14 | }
15 |
16 | public static void execute() {
17 | constructSepaDiasCtMessage();
18 | parseAndValidateSepaDiasCtMessage();
19 | constructSepaDiasCtHeader();
20 | parseAndValidateSepaDiasCtHeader();
21 | }
22 |
23 | public static void constructSepaDiasCtMessage() {
24 | try {
25 | //Initialize the message object
26 | FIToFIPaymentStatusReport10BatchSepaDiasCt fIToFIPaymentStatusReport10 = new FIToFIPaymentStatusReport10BatchSepaDiasCt();
27 | //Optionally use an existing message if we do not want to create the object from scratch
28 | fIToFIPaymentStatusReport10.parseXML(validSepaDiasCtPacs002String);
29 |
30 | //We fill the elements of the message object using setters
31 | //fIToFIPaymentStatusReport10.getMessage().setGrpHdr(new GroupHeader91());
32 | //fIToFIPaymentStatusReport10.getMessage().getGrpHdr().setMsgId("1234");
33 |
34 | //or setElement()
35 | //fIToFIPaymentStatusReport10.setElement("GrpHdr/MsgId", "1234");
36 |
37 | //Perform validation
38 | ValidationErrorList validationErrorList = fIToFIPaymentStatusReport10.validate();
39 |
40 | if (validationErrorList.isEmpty()) {
41 | System.out.println("Message is valid");
42 | System.out.println(fIToFIPaymentStatusReport10.convertToXML()); //Get the generated xml
43 | } else {
44 | handleValidationError(validationErrorList);
45 | }
46 | } catch (Exception e) {
47 | e.printStackTrace();
48 | System.err.println(e.getMessage());
49 | }
50 | }
51 |
52 | public static void parseAndValidateSepaDiasCtMessage() {
53 | try {
54 | //Initialize the message object
55 | FIToFIPaymentStatusReport10BatchSepaDiasCt fIToFIPaymentStatusReport10 = new FIToFIPaymentStatusReport10BatchSepaDiasCt();
56 | //Validate against the xml schema
57 | ValidationErrorList validationErrorList = fIToFIPaymentStatusReport10.validateXML(new ByteArrayInputStream(validSepaDiasCtPacs002String.getBytes()));
58 | if (!validationErrorList.isEmpty()) {
59 | handleValidationError(validationErrorList);
60 | return;
61 | }
62 | //Fill the message with data from xml
63 | fIToFIPaymentStatusReport10.parseXML(validSepaDiasCtPacs002String);
64 | //Validate both the xml schema and rules
65 | validationErrorList.addAll(fIToFIPaymentStatusReport10.validate());
66 |
67 | if (validationErrorList.isEmpty()) {
68 | System.out.println("Message is valid");
69 | System.out.println(fIToFIPaymentStatusReport10.convertToXML()); //Get the generated xml
70 | } else {
71 | handleValidationError(validationErrorList);
72 | }
73 |
74 | } catch (Exception e) {
75 | e.printStackTrace();
76 | System.err.println(e.getMessage());
77 | }
78 | }
79 |
80 | //YOU NEED THE FULL VERSION TO RUN BELOW METHODS FOR HEADER
81 | public static void constructSepaDiasCtHeader() {
82 | // try {
83 | // //Initialize the message object
84 | // DiasSctFileHeader diasHeader = new DiasSctFileHeader();
85 | // //Optionally use an existing message if we do not want to create the object from scratch
86 | // diasHeader.parseXML(validSepaDiasCtHeaderString);
87 | //
88 | // //We fill the elements of the message object using setters
89 | // //diasHeader.getMessage().setFileCycleNo("123")
90 | //
91 | // //or setElement()
92 | //// diasHeader.setElement("FileCycleNo", "123");
93 | //
94 | //// In case we already have a message object, we can set it to the header
95 | // FIToFIPaymentStatusReport10BatchSepaDiasCt fIToFIPaymentStatusReport10 = new FIToFIPaymentStatusReport10BatchSepaDiasCt();
96 | // fIToFIPaymentStatusReport10.parseXML(validSepaDiasCtPacs002String);
97 | // diasHeader.getMessage().getFIToFIPmtStsRpt().add(fIToFIPaymentStatusReport10.getMessage());
98 | //
99 | // //Perform validation
100 | // ValidationErrorList validationErrorList = diasHeader.validate();
101 | //
102 | // if (validationErrorList.isEmpty()) {
103 | // System.out.println("Message is valid");
104 | // System.out.println(diasHeader.convertToXML()); //Get the generated xml
105 | // } else {
106 | // handleValidationError(validationErrorList);
107 | // }
108 | // } catch (Exception e) {
109 | // e.printStackTrace();
110 | // System.err.println(e.getMessage());
111 | // }
112 | }
113 | //
114 | public static void parseAndValidateSepaDiasCtHeader() {
115 | // try {
116 | // //Initialize the message object
117 | // DiasSctFileHeader diasHeader = new DiasSctFileHeader();
118 | // //Validate against the xml schema
119 | // ValidationErrorList validationErrorList = diasHeader.validateXML(new ByteArrayInputStream(validSepaDiasCtHeaderString.getBytes()));
120 | // if (!validationErrorList.isEmpty()) {
121 | // handleValidationError(validationErrorList);
122 | // return;
123 | // }
124 | // //Fill the message with data from xml
125 | // diasHeader.parseXML(validSepaDiasCtHeaderString);
126 | // //Validate both the xml schema and rules
127 | // validationErrorList.addAll(diasHeader.validate());
128 | //
129 | // if (validationErrorList.isEmpty()) {
130 | // System.out.println("Message is valid");
131 | // System.out.println(diasHeader.convertToXML()); //Get the generated xml
132 | // } else {
133 | // handleValidationError(validationErrorList);
134 | // }
135 | //
136 | // } catch (Exception e) {
137 | // e.printStackTrace();
138 | // System.err.println(e.getMessage());
139 | // }
140 | }
141 |
142 | private static void handleValidationError(ValidationErrorList validationErrorList) {
143 | System.err.println("Message is invalid, and the errors are the following:");
144 | for (ValidationError error : validationErrorList) {
145 | System.err.println(error.toString());
146 | System.err.println(
147 | "Error Code: " + error.getErrorCode() + "\n" +
148 | "Error Description: " + error.getDescription() + "\n" +
149 | "Line number in error inside the tag: " + error.getLine() + "\n"
150 | );
151 | }
152 | }
153 |
154 | private static final String validSepaDiasCtPacs002String = "\n" +
155 | "\n" +
156 | " \n" +
157 | " \n" +
158 | " FID0000000870542_MSG0\n" +
159 | " 2023-06-21T13:17:24.568+03:00\n" +
160 | " ABCDGRA0\n" +
161 | " \n" +
162 | " \n" +
163 | " 2023062101600002\n" +
164 | " pacs.008.001.08\n" +
165 | " \n" +
166 | " \n" +
167 | " 18170100000000\n" +
168 | " From016To014-Cred-rej\n" +
169 | " From016To014-Cred-rej\n" +
170 | " From016To014-Cred-rej\n" +
171 | " RJCT\n" +
172 | " \n" +
173 | " DIASGRA1\n" +
174 | " X010\n" +
175 | " Invalid ChargeBearer\n" +
176 | " \n" +
177 | " \n" +
178 | " 36.00\n" +
179 | " 2023-06-01\n" +
180 | " CLRG\n" +
181 | " SEPASCTCBLK\n" +
182 | " new message for ISO2019\n" +
183 | " Ultimate Debtor Test 1AX035662NIDN\n" +
184 | " Debtor Name 1GRAddress Line 1984510B3901DEA58OD34\n" +
185 | " GR0899999990000000000000001PERSIdentification\n" +
186 | " ABCDGRA09991\n" +
187 | " BCDAGRA0\n" +
188 | " Creditor Name 1GRCreditor Address Line 1CUST12345678\n" +
189 | " GR4999999990000000123456789\n" +
190 | " Ultimate Creditor Test 1146378691TXID\n" +
191 | " BENE\n" +
192 | " \n" +
193 | " \n" +
194 | " \n" +
195 | "";
196 |
197 |
198 | private static final String validSepaDiasCtHeaderString = "\n" +
199 | "\n" +
200 | " \n" +
201 | " DIASGRA1\n" +
202 | " BCDAGRA0\n" +
203 | " 0000000000870301\n" +
204 | " DCT\n" +
205 | " T\n" +
206 | " XCT\n" +
207 | " 1\n" +
208 | " \n" +
209 | " \n" +
210 | " \n" +
211 | " FID0000000870542_MSG0\n" +
212 | " 2023-06-21T13:17:24.568+03:00\n" +
213 | " ABCDGRA0\n" +
214 | " \n" +
215 | " \n" +
216 | " 2023062101600002\n" +
217 | " pacs.008.001.08\n" +
218 | " \n" +
219 | " \n" +
220 | " 18170100000000\n" +
221 | " From016To014-Cred-rej\n" +
222 | " From016To014-Cred-rej\n" +
223 | " From016To014-Cred-rej\n" +
224 | " RJCT\n" +
225 | " \n" +
226 | " DIASGRA1\n" +
227 | " X010\n" +
228 | " Invalid ChargeBearer\n" +
229 | " \n" +
230 | " \n" +
231 | " 36.00\n" +
232 | " 2023-06-01\n" +
233 | " CLRG\n" +
234 | " SEPASCTCBLK\n" +
235 | " new message for ISO2019\n" +
236 | " Ultimate Debtor Test 1AX035662NIDN\n" +
237 | " Debtor Name 1GRAddress Line 1984510B3901DEA58OD34\n" +
238 | " GR0899999990000000000000001PERSIdentification\n" +
239 | " ABCDGRA09991\n" +
240 | " BCDAGRA0\n" +
241 | " Creditor Name 1GRCreditor Address Line 1CUST12345678\n" +
242 | " GR4999999990000000123456789\n" +
243 | " Ultimate Creditor Test 1146378691TXID\n" +
244 | " BENE\n" +
245 | " \n" +
246 | " \n" +
247 | " ";
248 |
249 | }
--------------------------------------------------------------------------------
/src/main/java/com/paymentcomponents/swift/mx/sepa/eba/ct/ParseAndValidateSepaEbaCtMessage.java:
--------------------------------------------------------------------------------
1 | package com.paymentcomponents.swift.mx.sepa.eba.ct;
2 |
3 | import gr.datamation.iso20022.sepa.eba.ct.headers.CvfBulkCreditTransferSepaEbaCt;
4 | import gr.datamation.iso20022.sepa.eba.ct.pacs.FIToFIPaymentStatusReport10SepaEbaCt;
5 | import gr.datamation.validation.error.ValidationError;
6 | import gr.datamation.validation.error.ValidationErrorList;
7 |
8 | import java.io.ByteArrayInputStream;
9 |
10 | public class ParseAndValidateSepaEbaCtMessage {
11 |
12 | public static void main(String... args) {
13 | execute();
14 | }
15 |
16 | public static void execute() {
17 | constructSepaEbaCtMessage();
18 | parseAndValidateSepaEbaCtMessage();
19 | constructSepaEbaCtHeader();
20 | parseAndValidateSepaEbaCtHeader();
21 | }
22 |
23 | public static void constructSepaEbaCtMessage() {
24 | try {
25 | //Initialize the message object
26 | FIToFIPaymentStatusReport10SepaEbaCt fIToFIPaymentStatusReport10 = new FIToFIPaymentStatusReport10SepaEbaCt();
27 | //Optionally use an existing message if we do not want to create the object from scratch
28 | fIToFIPaymentStatusReport10.parseXML(validSepaEbaCtPacs002String);
29 |
30 | //We fill the elements of the message object using setters
31 | //fIToFIPaymentStatusReport10.getMessage().setGrpHdr(new SCTGroupHeader91());
32 | //fIToFIPaymentStatusReport10.getMessage().getGrpHdr().setMsgId("1234");
33 |
34 | //or setElement()
35 | //fIToFIPaymentStatusReport10.setElement("GrpHdr/MsgId", "1234");
36 |
37 | //Perform validation
38 | ValidationErrorList validationErrorList = fIToFIPaymentStatusReport10.validate();
39 |
40 | if (validationErrorList.isEmpty()) {
41 | System.out.println("Message is valid");
42 | System.out.println(fIToFIPaymentStatusReport10.convertToXML()); //Get the generated xml
43 | } else {
44 | handleValidationError(validationErrorList);
45 | }
46 | } catch (Exception e) {
47 | e.printStackTrace();
48 | System.err.println(e.getMessage());
49 | }
50 | }
51 |
52 | public static void parseAndValidateSepaEbaCtMessage() {
53 | try {
54 | //Initialize the message object
55 | FIToFIPaymentStatusReport10SepaEbaCt fIToFIPaymentStatusReport10 = new FIToFIPaymentStatusReport10SepaEbaCt();
56 | //Validate against the xml schema
57 | ValidationErrorList validationErrorList = fIToFIPaymentStatusReport10.validateXML(new ByteArrayInputStream(validSepaEbaCtPacs002String.getBytes()));
58 | if (!validationErrorList.isEmpty()) {
59 | handleValidationError(validationErrorList);
60 | return;
61 | }
62 | //Fill the message with data from xml
63 | fIToFIPaymentStatusReport10.parseXML(validSepaEbaCtPacs002String);
64 | //Validate both the xml schema and rules
65 | validationErrorList.addAll(fIToFIPaymentStatusReport10.validate());
66 |
67 | if (validationErrorList.isEmpty()) {
68 | System.out.println("Message is valid");
69 | System.out.println(fIToFIPaymentStatusReport10.convertToXML()); //Get the generated xml
70 | } else {
71 | handleValidationError(validationErrorList);
72 | }
73 |
74 | } catch (Exception e) {
75 | e.printStackTrace();
76 | System.err.println(e.getMessage());
77 | }
78 | }
79 |
80 | public static void constructSepaEbaCtHeader() {
81 | try {
82 | //Initialize the message object
83 | CvfBulkCreditTransferSepaEbaCt cvfHeader = new CvfBulkCreditTransferSepaEbaCt();
84 | //Optionally use an existing message if we do not want to create the object from scratch
85 | cvfHeader.parseXML(validSepaEbaCtCvfHeaderString);
86 |
87 | //We fill the elements of the message object using setters
88 | //cvfHeader.getMessage().setFileCycleNo("123")
89 |
90 | //or setElement()
91 | // cvfHeader.setElement("FileCycleNo", "123");
92 |
93 | // In case we already have a message object, we can set it to the header
94 | FIToFIPaymentStatusReport10SepaEbaCt fIToFIPaymentStatusReport10 = new FIToFIPaymentStatusReport10SepaEbaCt();
95 | fIToFIPaymentStatusReport10.parseXML(validSepaEbaCtPacs002String);
96 | cvfHeader.getMessage().getFIToFIPmtStsRptS2().add(fIToFIPaymentStatusReport10.getMessage());
97 |
98 | //Perform validation
99 | ValidationErrorList validationErrorList = cvfHeader.validate();
100 |
101 | if (validationErrorList.isEmpty()) {
102 | System.out.println("Message is valid");
103 | System.out.println(cvfHeader.convertToXML()); //Get the generated xml
104 | } else {
105 | handleValidationError(validationErrorList);
106 | }
107 | } catch (Exception e) {
108 | e.printStackTrace();
109 | System.err.println(e.getMessage());
110 | }
111 | }
112 |
113 | public static void parseAndValidateSepaEbaCtHeader() {
114 | try {
115 | //Initialize the message object
116 | CvfBulkCreditTransferSepaEbaCt cvfHeader = new CvfBulkCreditTransferSepaEbaCt();
117 | //Validate against the xml schema
118 | ValidationErrorList validationErrorList = cvfHeader.validateXML(new ByteArrayInputStream(validSepaEbaCtCvfHeaderString.getBytes()));
119 | if (!validationErrorList.isEmpty()) {
120 | handleValidationError(validationErrorList);
121 | return;
122 | }
123 | //Fill the message with data from xml
124 | cvfHeader.parseXML(validSepaEbaCtCvfHeaderString);
125 | //Validate both the xml schema and rules
126 | validationErrorList.addAll(cvfHeader.validate());
127 |
128 | if (validationErrorList.isEmpty()) {
129 | System.out.println("Message is valid");
130 | System.out.println(cvfHeader.convertToXML()); //Get the generated xml
131 | } else {
132 | handleValidationError(validationErrorList);
133 | }
134 |
135 | } catch (Exception e) {
136 | e.printStackTrace();
137 | System.err.println(e.getMessage());
138 | }
139 | }
140 |
141 | private static void handleValidationError(ValidationErrorList validationErrorList) {
142 | System.err.println("Message is invalid, and the errors are the following:");
143 | for (ValidationError error : validationErrorList) {
144 | System.err.println(error.toString());
145 | System.err.println(
146 | "Error Code: " + error.getErrorCode() + "\n" +
147 | "Error Description: " + error.getDescription() + "\n" +
148 | "Line number in error inside the tag: " + error.getLine() + "\n"
149 | );
150 | }
151 | }
152 |
153 | private static final String validSepaEbaCtPacs002String = "\n" +
154 | " \n" +
155 | " \n" +
156 | " SCTREJ200020190314300000000001\n" +
157 | " 2019-03-14T00:00:00\n" +
158 | " \n" +
159 | " \n" +
160 | " SSSSSS111120190313090033395001\n" +
161 | " pacs.008.001.02\n" +
162 | " 1\n" +
163 | " 1\n" +
164 | " PART\n" +
165 | " \n" +
166 | " \n" +
167 | " \n" +
168 | " \n" +
169 | " TESTBICB\n" +
170 | " \n" +
171 | " \n" +
172 | " \n" +
173 | " \n" +
174 | " AC01\n" +
175 | " \n" +
176 | " \n" +
177 | " \n" +
178 | " \n" +
179 | " 000R907330000001\n" +
180 | " b18332f58ca64ffd87ea9777b9edfba1\n" +
181 | " NOTPROVIDED\n" +
182 | " 111T9072000000000000000000000000006\n" +
183 | " str1\n" +
184 | " \n" +
185 | " \n" +
186 | " \n" +
187 | " \n" +
188 | " TESTBICB\n" +
189 | " \n" +
190 | " \n" +
191 | " \n" +
192 | " \n" +
193 | " AC01\n" +
194 | " \n" +
195 | " \n" +
196 | " \n" +
197 | " 9.95\n" +
198 | " 2015-09-28\n" +
199 | " \n" +
200 | " \n" +
201 | " TESTBICA\n" +
202 | " \n" +
203 | " \n" +
204 | " \n" +
205 | " \n" +
206 | " TESTBICB\n" +
207 | " \n" +
208 | " \n" +
209 | " \n" +
210 | " \n" +
211 | " \n" +
212 | "";
213 |
214 |
215 | private static final String validSepaEbaCtCvfHeaderString = "\n" +
216 | "\n" +
220 | " TESTBICB\n" +
221 | " TESTBICA\n" +
222 | " SCT\n" +
223 | " T\n" +
224 | " CVF\n" +
225 | " 2018111800000001\n" +
226 | " 2018-11-17T00:00:00\n" +
227 | " 123456\n" +
228 | " Fname\n" +
229 | " 2018-11-17T00:00:00\n" +
230 | " ASD\n" +
231 | " 2018-11-18\n" +
232 | " 01\n" +
233 | " \n" +
234 | " \n" +
235 | " SCTREJ200020190314300000000001\n" +
236 | " 2019-03-14T00:00:00\n" +
237 | " \n" +
238 | " \n" +
239 | " SSSSSS111120190313090033395001\n" +
240 | " pacs.008.001.02\n" +
241 | " 1\n" +
242 | " 1\n" +
243 | " PART\n" +
244 | " \n" +
245 | " \n" +
246 | " \n" +
247 | " \n" +
248 | " TESTBICB\n" +
249 | " \n" +
250 | " \n" +
251 | " \n" +
252 | " \n" +
253 | " AC01\n" +
254 | " \n" +
255 | " \n" +
256 | " \n" +
257 | " \n" +
258 | " 000R907330000001\n" +
259 | " b18332f58ca64ffd87ea9777b9edfba1\n" +
260 | " NOTPROVIDED\n" +
261 | " 111T9072000000000000000000000000006\n" +
262 | " str1\n" +
263 | " \n" +
264 | " \n" +
265 | " \n" +
266 | " \n" +
267 | " TESTBICB\n" +
268 | " \n" +
269 | " \n" +
270 | " \n" +
271 | " \n" +
272 | " AC01\n" +
273 | " \n" +
274 | " \n" +
275 | " \n" +
276 | " 9.95\n" +
277 | " 2015-09-28\n" +
278 | " \n" +
279 | " \n" +
280 | " TESTBICA\n" +
281 | " \n" +
282 | " \n" +
283 | " \n" +
284 | " \n" +
285 | " TESTBICB\n" +
286 | " \n" +
287 | " \n" +
288 | " \n" +
289 | " \n" +
290 | " \n" +
291 | "\n";
292 |
293 | }
--------------------------------------------------------------------------------
/src/main/java/com/paymentcomponents/swift/mx/sepa/epc/ct/ParseAndValidateSepaEpcCtMessage.java:
--------------------------------------------------------------------------------
1 | package com.paymentcomponents.swift.mx.sepa.epc.ct;
2 |
3 | import gr.datamation.iso20022.sepa.epc.ct.pacs.FIToFIPaymentStatusReport10SepaEpcCt;
4 | import gr.datamation.validation.error.ValidationError;
5 | import gr.datamation.validation.error.ValidationErrorList;
6 |
7 | import java.io.ByteArrayInputStream;
8 |
9 | public class ParseAndValidateSepaEpcCtMessage {
10 |
11 | public static void main(String... args) {
12 | execute();
13 | }
14 |
15 | public static void execute() {
16 | constructSepaEpcCtMessage();
17 | parseAndValidateSepaEpcCtMessage();
18 | }
19 |
20 | public static void constructSepaEpcCtMessage() {
21 | try {
22 | //Initialize the message object
23 | FIToFIPaymentStatusReport10SepaEpcCt fIToFIPaymentStatusReport10 = new FIToFIPaymentStatusReport10SepaEpcCt();
24 | //Optionally use an existing message if we do not want to create the object from scratch
25 | fIToFIPaymentStatusReport10.parseXML(validSepaEpcCtPacs002String);
26 |
27 | //We fill the elements of the message object using setters
28 | //fIToFIPaymentStatusReport10.getMessage().setGrpHdr(new GroupHeader93());
29 | //fIToFIPaymentStatusReport10.getMessage().getGrpHdr().setMsgId("1234");
30 |
31 | //or setElement()
32 | //fIToFIPaymentStatusReport10.setElement("GrpHdr/MsgId", "1234");
33 |
34 | //Perform validation
35 | ValidationErrorList validationErrorList = fIToFIPaymentStatusReport10.validate();
36 |
37 | if (validationErrorList.isEmpty()) {
38 | System.out.println("Message is valid");
39 | System.out.println(fIToFIPaymentStatusReport10.convertToXML()); //Get the generated xml
40 | } else {
41 | handleValidationError(validationErrorList);
42 | }
43 | } catch (Exception e) {
44 | e.printStackTrace();
45 | System.err.println(e.getMessage());
46 | }
47 | }
48 |
49 | public static void parseAndValidateSepaEpcCtMessage() {
50 | try {
51 | //Initialize the message object
52 | FIToFIPaymentStatusReport10SepaEpcCt fIToFIPaymentStatusReport10 = new FIToFIPaymentStatusReport10SepaEpcCt();
53 | //Validate against the xml schema
54 | ValidationErrorList validationErrorList = fIToFIPaymentStatusReport10.validateXML(new ByteArrayInputStream(validSepaEpcCtPacs002String.getBytes()));
55 | if (!validationErrorList.isEmpty()) {
56 | handleValidationError(validationErrorList);
57 | return;
58 | }
59 | //Fill the message with data from xml
60 | fIToFIPaymentStatusReport10.parseXML(validSepaEpcCtPacs002String);
61 | //Validate both the xml schema and rules
62 | validationErrorList.addAll(fIToFIPaymentStatusReport10.validate());
63 |
64 | if (validationErrorList.isEmpty()) {
65 | System.out.println("Message is valid");
66 | System.out.println(fIToFIPaymentStatusReport10.convertToXML()); //Get the generated xml
67 | } else {
68 | handleValidationError(validationErrorList);
69 | }
70 |
71 | } catch (Exception e) {
72 | e.printStackTrace();
73 | System.err.println(e.getMessage());
74 | }
75 | }
76 |
77 | private static void handleValidationError(ValidationErrorList validationErrorList) {
78 | System.err.println("Message is invalid, and the errors are the following:");
79 | for (ValidationError error : validationErrorList) {
80 | System.err.println(error.toString());
81 | System.err.println(
82 | "Error Code: " + error.getErrorCode() + "\n" +
83 | "Error Description: " + error.getDescription() + "\n" +
84 | "Line number in error inside the tag: " + error.getLine() + "\n"
85 | );
86 | }
87 | }
88 |
89 | private static final String validSepaEpcCtPacs002String = "\n" +
90 | "\n" +
91 | "\n" +
92 | " \n" +
93 | " \n" +
94 | " SCTREJ200020190314300000000001\n" +
95 | " 2019-03-14T00:00:00\n" +
96 | " \n" +
97 | " \n" +
98 | " TESTBICA\n" +
99 | " \n" +
100 | " \n" +
101 | " \n" +
102 | " \n" +
103 | " SSSSSS111120190313090033395001\n" +
104 | " pacs.008.001.02\n" +
105 | " PART\n" +
106 | " \n" +
107 | " \n" +
108 | " 000R907330000001\n" +
109 | " b18332f58ca64ffd87ea9777b9edfba1\n" +
110 | " NOTPROVIDED\n" +
111 | " 111T9072000000000000000000000000006\n" +
112 | " \n" +
113 | " \n" +
114 | " \n" +
115 | " \n" +
116 | " TESTBICB\n" +
117 | " \n" +
118 | " \n" +
119 | " \n" +
120 | " \n" +
121 | " AC01\n" +
122 | " \n" +
123 | " \n" +
124 | " \n" +
125 | " 9.95\n" +
126 | " \n" +
127 | " \n" +
128 | " Schneider\n" +
129 | " \n" +
130 | " Kuertman Strasse\n" +
131 | " 45\n" +
132 | " 50475\n" +
133 | " Koln\n" +
134 | " DE\n" +
135 | " \n" +
136 | " \n" +
137 | " \n" +
138 | " \n" +
139 | " \n" +
140 | " ES1011110001087939390799\n" +
141 | " \n" +
142 | " \n" +
143 | " \n" +
144 | " \n" +
145 | " TESTBICA\n" +
146 | " \n" +
147 | " \n" +
148 | " \n" +
149 | " \n" +
150 | " TESTBICB\n" +
151 | " \n" +
152 | " \n" +
153 | " \n" +
154 | " \n" +
155 | " Schneider\n" +
156 | " \n" +
157 | " Kuertman Strasse\n" +
158 | " 45\n" +
159 | " 50475\n" +
160 | " Koln\n" +
161 | " DE\n" +
162 | " \n" +
163 | " \n" +
164 | " \n" +
165 | " \n" +
166 | " \n" +
167 | " ES5410820934549505717622\n" +
168 | " \n" +
169 | " \n" +
170 | " \n" +
171 | " \n" +
172 | " \n" +
173 | "\n";
174 |
175 | }
--------------------------------------------------------------------------------
/src/main/java/com/paymentcomponents/swift/mx/sepa/sibs/ct/ParseAndValidateSepaSibsCtMessage.java:
--------------------------------------------------------------------------------
1 | package com.paymentcomponents.swift.mx.sepa.sibs.ct;
2 |
3 | import gr.datamation.iso20022.sepa.sibs.ct.headers.CvfBulkCreditTransferSepaSibsCt;
4 | import gr.datamation.iso20022.sepa.sibs.ct.pacs.FIToFIPaymentStatusReport10SepaSibsCt;
5 | import gr.datamation.validation.error.ValidationError;
6 | import gr.datamation.validation.error.ValidationErrorList;
7 |
8 | import java.io.ByteArrayInputStream;
9 |
10 | public class ParseAndValidateSepaSibsCtMessage {
11 |
12 | public static void main(String... args) {
13 | execute();
14 | }
15 | public static void execute() {
16 | constructSepaSibsCtMessage();
17 | parseAndValidateSepaSibsCtMessage();
18 | constructSepaSibsCtHeader();
19 | parseAndValidateSepaSibsCtHeader();
20 | }
21 |
22 | public static void constructSepaSibsCtMessage() {
23 | try {
24 | //Initialize the message object
25 | FIToFIPaymentStatusReport10SepaSibsCt fIToFIPaymentStatusReport10 = new FIToFIPaymentStatusReport10SepaSibsCt();
26 | //Optionally use an existing message if we do not want to create the object from scratch
27 | fIToFIPaymentStatusReport10.parseXML(validSepaSibsCtPacs002String);
28 |
29 | //We fill the elements with the message object using setters
30 | // fIToFIPaymentStatusReport10.getMessage().setGrpHdr(new SCTGroupHeader91());
31 | // fIToFIPaymentStatusReport10.getMessage().getGrpHdr().setMsgId("1234");
32 |
33 | //or setElement()
34 | //fIToFIPaymentStatusReport10.setElement("GrpHdr/MsgId", "1234");
35 |
36 | //Perform validation
37 | ValidationErrorList validationErrorList = fIToFIPaymentStatusReport10.validate();
38 |
39 | if (validationErrorList.isEmpty()) {
40 | System.out.println("Message is valid");
41 | System.out.println(fIToFIPaymentStatusReport10.convertToXML()); //Get the generated xml
42 | } else {
43 | handleValidationError(validationErrorList);
44 | }
45 | } catch (Exception e) {
46 | e.printStackTrace();
47 | System.err.println(e.getMessage());
48 | }
49 | }
50 |
51 | public static void parseAndValidateSepaSibsCtMessage() {
52 | try {
53 | //Initialize the message object
54 | FIToFIPaymentStatusReport10SepaSibsCt fIToFIPaymentStatusReport10 = new FIToFIPaymentStatusReport10SepaSibsCt();
55 | //Validate against the xml schema
56 | ValidationErrorList validationErrorList = fIToFIPaymentStatusReport10.validateXML(new ByteArrayInputStream(validSepaSibsCtPacs002String.getBytes()));
57 | if (!validationErrorList.isEmpty()) {
58 | handleValidationError(validationErrorList);
59 | return;
60 | }
61 | //Fill the message with data from xml
62 | fIToFIPaymentStatusReport10.parseXML(validSepaSibsCtPacs002String);
63 | //Validate both the xml schema and rules
64 | validationErrorList.addAll(fIToFIPaymentStatusReport10.validate());
65 |
66 | if (validationErrorList.isEmpty()) {
67 | System.out.println("Message is valid");
68 | System.out.println(fIToFIPaymentStatusReport10.convertToXML()); //Get the generated xml
69 | } else {
70 | handleValidationError(validationErrorList);
71 | }
72 |
73 | } catch (Exception e) {
74 | e.printStackTrace();
75 | System.err.println(e.getMessage());
76 | }
77 | }
78 |
79 | public static void constructSepaSibsCtHeader() {
80 | try {
81 | //Initialize the message object
82 | CvfBulkCreditTransferSepaSibsCt cvfHeader = new CvfBulkCreditTransferSepaSibsCt();
83 | //Optionally use an existing message if we do not want to create the object from scratch
84 | cvfHeader.parseXML(validSepaSibsCtCvfHeaderString);
85 |
86 | //We fill the elements with the message object using setters
87 | //cvfHeader.getMessage().setFileCycleNo("123")
88 |
89 | //or setElement()
90 | // cvfHeader.setElement("FileCycleNo", "123");
91 |
92 | // In case we already have a message object, we can set it to the header
93 | FIToFIPaymentStatusReport10SepaSibsCt fIToFIPaymentStatusReport10 = new FIToFIPaymentStatusReport10SepaSibsCt();
94 | fIToFIPaymentStatusReport10.parseXML(validSepaSibsCtPacs002String);
95 | cvfHeader.getMessage().getFIToFIPmtStsRptS2().add(fIToFIPaymentStatusReport10.getMessage());
96 |
97 | //Perform validation
98 | ValidationErrorList validationErrorList = cvfHeader.validate();
99 |
100 | if (validationErrorList.isEmpty()) {
101 | System.out.println("Message is valid");
102 | System.out.println(cvfHeader.convertToXML()); //Get the generated xml
103 | } else {
104 | handleValidationError(validationErrorList);
105 | }
106 | } catch (Exception e) {
107 | e.printStackTrace();
108 | System.err.println(e.getMessage());
109 | }
110 | }
111 |
112 | public static void parseAndValidateSepaSibsCtHeader() {
113 | try {
114 | //Initialize the message object
115 | CvfBulkCreditTransferSepaSibsCt cvfHeader = new CvfBulkCreditTransferSepaSibsCt();
116 | //Validate against the xml schema
117 | ValidationErrorList validationErrorList = cvfHeader.validateXML(new ByteArrayInputStream(validSepaSibsCtCvfHeaderString.getBytes()));
118 | if (!validationErrorList.isEmpty()) {
119 | handleValidationError(validationErrorList);
120 | return;
121 | }
122 | //Fill the message with data from xml
123 | cvfHeader.parseXML(validSepaSibsCtCvfHeaderString);
124 | //Validate both the xml schema and rules
125 | validationErrorList.addAll(cvfHeader.validate());
126 |
127 | if (validationErrorList.isEmpty()) {
128 | System.out.println("Message is valid");
129 | System.out.println(cvfHeader.convertToXML()); //Get the generated xml
130 | } else {
131 | handleValidationError(validationErrorList);
132 | }
133 |
134 | } catch (Exception e) {
135 | e.printStackTrace();
136 | System.err.println(e.getMessage());
137 | }
138 | }
139 |
140 | private static void handleValidationError(ValidationErrorList validationErrorList) {
141 | System.err.println("Message is invalid, and the errors are the following:");
142 | for (ValidationError error : validationErrorList) {
143 | System.err.println(error.toString());
144 | System.err.println(
145 | "Error Code: " + error.getErrorCode() + "\n" +
146 | "Error Description: " + error.getDescription() + "\n" +
147 | "Line number in error inside the tag: " + error.getLine() + "\n"
148 | );
149 | }
150 | }
151 |
152 | private static final String validSepaSibsCtPacs002String = "\n" +
153 | " \n" +
154 | " \n" +
155 | " SCTREJ200020190314300000000001\n" +
156 | " 2019-03-14T00:00:00\n" +
157 | " \n" +
158 | " \n" +
159 | " SSSSSS111120190313090033395001\n" +
160 | " pacs.008.001.02\n" +
161 | " 1\n" +
162 | " 1\n" +
163 | " PART\n" +
164 | " \n" +
165 | " \n" +
166 | " \n" +
167 | " \n" +
168 | " TESTBICB\n" +
169 | " \n" +
170 | " \n" +
171 | " \n" +
172 | " \n" +
173 | " AC01\n" +
174 | " \n" +
175 | " \n" +
176 | " \n" +
177 | " \n" +
178 | " 000R907330000001\n" +
179 | " b18332f58ca64ffd87ea9777b9edfba1\n" +
180 | " NOTPROVIDED\n" +
181 | " 111T9072000000000000000000000000006\n" +
182 | " str1\n" +
183 | " \n" +
184 | " \n" +
185 | " \n" +
186 | " \n" +
187 | " TESTBICB\n" +
188 | " \n" +
189 | " \n" +
190 | " \n" +
191 | " \n" +
192 | " AC01\n" +
193 | " \n" +
194 | " \n" +
195 | " \n" +
196 | " 9.95\n" +
197 | " 2015-09-28\n" +
198 | " \n" +
199 | " \n" +
200 | " TESTBICA\n" +
201 | " \n" +
202 | " \n" +
203 | " \n" +
204 | " \n" +
205 | " TESTBICB\n" +
206 | " \n" +
207 | " \n" +
208 | " \n" +
209 | " \n" +
210 | " \n" +
211 | "";
212 |
213 |
214 | private static final String validSepaSibsCtCvfHeaderString = "\n" +
215 | "\n" +
219 | " TESTBICB\n" +
220 | " TESTBICA\n" +
221 | " SCT\n" +
222 | " T\n" +
223 | " CVX\n" +
224 | " 2018111800000001\n" +
225 | " str\n" +
226 | " 2018-11-17T00:00:00\n" +
227 | " 123456\n" +
228 | " Fname\n" +
229 | " 2018-11-17T00:00:00\n" +
230 | " ASD\n" +
231 | " 2018-11-18\n" +
232 | " 01\n" +
233 | " \n" +
234 | " \n" +
235 | " SCTREJ200020190314300000000001\n" +
236 | " 2019-03-14T00:00:00\n" +
237 | " \n" +
238 | " \n" +
239 | " SSSSSS111120190313090033395001\n" +
240 | " pacs.008.001.02\n" +
241 | " 1\n" +
242 | " 1\n" +
243 | " PART\n" +
244 | " \n" +
245 | " \n" +
246 | " \n" +
247 | " \n" +
248 | " TESTBICB\n" +
249 | " \n" +
250 | " \n" +
251 | " \n" +
252 | " \n" +
253 | " AC01\n" +
254 | " \n" +
255 | " \n" +
256 | " \n" +
257 | " \n" +
258 | " 000R907330000001\n" +
259 | " b18332f58ca64ffd87ea9777b9edfba1\n" +
260 | " NOTPROVIDED\n" +
261 | " 111T9072000000000000000000000000006\n" +
262 | " str1\n" +
263 | " \n" +
264 | " \n" +
265 | " \n" +
266 | " \n" +
267 | " TESTBICB\n" +
268 | " \n" +
269 | " \n" +
270 | " \n" +
271 | " \n" +
272 | " AC01\n" +
273 | " \n" +
274 | " \n" +
275 | " \n" +
276 | " 9.95\n" +
277 | " 2015-09-28\n" +
278 | " \n" +
279 | " \n" +
280 | " TESTBICA\n" +
281 | " \n" +
282 | " \n" +
283 | " \n" +
284 | " \n" +
285 | " TESTBICB\n" +
286 | " \n" +
287 | " \n" +
288 | " \n" +
289 | " \n" +
290 | " \n" +
291 | "\n";
292 |
293 | }
--------------------------------------------------------------------------------
/src/main/java/com/paymentcomponents/swift/mx/sepa/sibs/dd/ParseAndValidateSepaSibsDdMessage.java:
--------------------------------------------------------------------------------
1 | package com.paymentcomponents.swift.mx.sepa.sibs.dd;
2 |
3 | import gr.datamation.iso20022.sepa.sibs.dd.headers.MPEDDCdfBulkDirectDebit;
4 | import gr.datamation.iso20022.sepa.sibs.dd.pacs.FIToFIPaymentStatusReport10S2SepaSibsDd;
5 | import gr.datamation.validation.error.ValidationError;
6 | import gr.datamation.validation.error.ValidationErrorList;
7 |
8 | import java.io.ByteArrayInputStream;
9 |
10 | public class ParseAndValidateSepaSibsDdMessage {
11 | public static void main(String... args) {
12 | execute();
13 | }
14 |
15 | public static void execute() {
16 | constructSepaSibsDdMessage();
17 | parseAndValidateSepaSibsDdMessage();
18 | constructSepaSibsDdHeader();
19 | parseAndValidateSepaSibsDdHeader();
20 | }
21 |
22 | public static void constructSepaSibsDdMessage() {
23 | try {
24 | //Initialize the message object
25 | FIToFIPaymentStatusReport10S2SepaSibsDd fIToFIPaymentStatusReport10 = new FIToFIPaymentStatusReport10S2SepaSibsDd();
26 | //Optionally use an existing message if we do not want to create the object from scratch
27 | fIToFIPaymentStatusReport10.parseXML(validSepaSibsDdPacs002String);
28 |
29 | //We fill the elements with the message object using setters
30 | // fIToFIPaymentStatusReport10.getMessage().setGrpHdr(new SDdGroupHeader91());
31 | // fIToFIPaymentStatusReport10.getMessage().getGrpHdr().setMsgId("1234");
32 |
33 | //or setElement()
34 | //fIToFIPaymentStatusReport10.setElement("GrpHdr/MsgId", "1234");
35 |
36 | //Perform validation
37 | ValidationErrorList validationErrorList = fIToFIPaymentStatusReport10.validate();
38 |
39 | if (validationErrorList.isEmpty()) {
40 | System.out.println("Message is valid");
41 | System.out.println(fIToFIPaymentStatusReport10.convertToXML()); //Get the generated xml
42 | } else {
43 | handleValidationError(validationErrorList);
44 | }
45 | } catch (Exception e) {
46 | e.printStackTrace();
47 | System.err.println(e.getMessage());
48 | }
49 | }
50 |
51 | public static void parseAndValidateSepaSibsDdMessage() {
52 | try {
53 | //Initialize the message object
54 | FIToFIPaymentStatusReport10S2SepaSibsDd fIToFIPaymentStatusReport10 = new FIToFIPaymentStatusReport10S2SepaSibsDd();
55 | //Validate against the xml schema
56 | ValidationErrorList validationErrorList = fIToFIPaymentStatusReport10.validateXML(new ByteArrayInputStream(validSepaSibsDdPacs002String.getBytes()));
57 | if (!validationErrorList.isEmpty()) {
58 | handleValidationError(validationErrorList);
59 | return;
60 | }
61 | //Fill the message with data from xml
62 | fIToFIPaymentStatusReport10.parseXML(validSepaSibsDdPacs002String);
63 | //Validate both the xml schema and rules
64 | validationErrorList.addAll(fIToFIPaymentStatusReport10.validate());
65 |
66 | if (validationErrorList.isEmpty()) {
67 | System.out.println("Message is valid");
68 | System.out.println(fIToFIPaymentStatusReport10.convertToXML()); //Get the generated xml
69 | } else {
70 | handleValidationError(validationErrorList);
71 | }
72 |
73 | } catch (Exception e) {
74 | e.printStackTrace();
75 | System.err.println(e.getMessage());
76 | }
77 | }
78 |
79 | public static void constructSepaSibsDdHeader() {
80 | try {
81 | //Initialize the message object
82 | MPEDDCdfBulkDirectDebit cvfHeader = new MPEDDCdfBulkDirectDebit();
83 | //Optionally use an existing message if we do not want to create the object from scratch
84 | cvfHeader.parseXML(validSepaSibsDdCdfHeaderString);
85 |
86 | //We fill the elements with the message object using setters
87 | //cvfHeader.getMessage().setFileCycleNo("123")
88 |
89 | //or setElement()
90 | // cvfHeader.setElement("FileCycleNo", "123");
91 |
92 | // In case we already have a message object, we can set it to the header
93 | FIToFIPaymentStatusReport10S2SepaSibsDd fIToFIPaymentStatusReport10 = new FIToFIPaymentStatusReport10S2SepaSibsDd();
94 | fIToFIPaymentStatusReport10.parseXML(validSepaSibsDdPacs002String);
95 | cvfHeader.getMessage().getFIToFIPmtStsRptS2().add(fIToFIPaymentStatusReport10.getMessage());
96 |
97 | //Perform validation
98 | ValidationErrorList validationErrorList = cvfHeader.validate();
99 |
100 | if (validationErrorList.isEmpty()) {
101 | System.out.println("Message is valid");
102 | System.out.println(cvfHeader.convertToXML()); //Get the generated xml
103 | } else {
104 | handleValidationError(validationErrorList);
105 | }
106 | } catch (Exception e) {
107 | e.printStackTrace();
108 | System.err.println(e.getMessage());
109 | }
110 | }
111 |
112 | public static void parseAndValidateSepaSibsDdHeader() {
113 | try {
114 | //Initialize the message object
115 | MPEDDCdfBulkDirectDebit cdfHeader = new MPEDDCdfBulkDirectDebit();
116 | //Validate against the xml schema
117 | ValidationErrorList validationErrorList = cdfHeader.validateXML(new ByteArrayInputStream(validSepaSibsDdCdfHeaderString.getBytes()));
118 | if (!validationErrorList.isEmpty()) {
119 | handleValidationError(validationErrorList);
120 | return;
121 | }
122 | //Fill the message with data from xml
123 | cdfHeader.parseXML(validSepaSibsDdCdfHeaderString);
124 | //Validate both the xml schema and rules
125 | validationErrorList.addAll(cdfHeader.validate());
126 |
127 | if (validationErrorList.isEmpty()) {
128 | System.out.println("Message is valid");
129 | System.out.println(cdfHeader.convertToXML()); //Get the generated xml
130 | } else {
131 | handleValidationError(validationErrorList);
132 | }
133 |
134 | } catch (Exception e) {
135 | e.printStackTrace();
136 | System.err.println(e.getMessage());
137 | }
138 | }
139 |
140 | private static void handleValidationError(ValidationErrorList validationErrorList) {
141 | System.err.println("Message is invalid, and the errors are the following:");
142 | for (ValidationError error : validationErrorList) {
143 | System.err.println(error.toString());
144 | System.err.println(
145 | "Error Code: " + error.getErrorCode() + "\n" +
146 | "Error Description: " + error.getDescription() + "\n" +
147 | "Line number in error inside the tag: " + error.getLine() + "\n"
148 | );
149 | }
150 | }
151 |
152 | private static final String validSepaSibsDdPacs002String = "\n" +
153 | " \n" +
154 | " \n" +
155 | " SCTREJ200020190314300000000001\n" +
156 | " 2019-03-14T00:00:00\n" +
157 | " \n" +
158 | " \n" +
159 | " SSSSSS111120190313090033395001\n" +
160 | " pacs.003.001.08\n" +
161 | " 1\n" +
162 | " 5.0\n" +
163 | " RJCT\n" +
164 | " \n" +
165 | " \n" +
166 | " \n" +
167 | " \n" +
168 | " TESTBICB\n" +
169 | " \n" +
170 | " \n" +
171 | " \n" +
172 | " \n" +
173 | " AC01\n" +
174 | " \n" +
175 | " \n" +
176 | " \n" +
177 | " \n" +
178 | " 000R907330000001\n" +
179 | " b18332f58ca64ffd87ea9777b9edfba1\n" +
180 | " NOTPROVIDED\n" +
181 | " 111T9072000000000000000000000000006\n" +
182 | " RJCT\n" +
183 | " \n" +
184 | " \n" +
185 | " \n" +
186 | " \n" +
187 | " TESTBICB\n" +
188 | " \n" +
189 | " \n" +
190 | " \n" +
191 | " \n" +
192 | " AC01\n" +
193 | " \n" +
194 | " \n" +
195 | " \n" +
196 | " 9.95\n" +
197 | " 2023-09-28\n" +
198 | " \n" +
199 | " \n" +
200 | " TESTBICA\n" +
201 | " \n" +
202 | " \n" +
203 | " \n" +
204 | " \n" +
205 | " TESTBICB\n" +
206 | " \n" +
207 | " \n" +
208 | " \n" +
209 | " \n" +
210 | " \n" +
211 | "";
212 |
213 | private static final String validSepaSibsDdCdfHeaderString = "\n" +
214 | "\n" +
215 | " TESTBICA\n" +
216 | " TESTBICB\n" +
217 | " ST2\n" +
218 | " B2B\n" +
219 | " T\n" +
220 | " CDX\n" +
221 | " string\n" +
222 | " 2011-10-24+03:00\n" +
223 | " 01\n" +
224 | " \n" +
225 | " \n" +
226 | " SCTREJ200020190314300000000001\n" +
227 | " 2019-03-14T00:00:00\n" +
228 | " \n" +
229 | " \n" +
230 | " SSSSSS111120190313090033395001\n" +
231 | " pacs.003.001.08\n" +
232 | " 1\n" +
233 | " 5.0\n" +
234 | " RJCT\n" +
235 | " \n" +
236 | " \n" +
237 | " \n" +
238 | " \n" +
239 | " TESTBICB\n" +
240 | " \n" +
241 | " \n" +
242 | " \n" +
243 | " \n" +
244 | " AC01\n" +
245 | " \n" +
246 | " \n" +
247 | " \n" +
248 | " \n" +
249 | " 000R907330000001\n" +
250 | " b18332f58ca64ffd87ea9777b9edfba1\n" +
251 | " NOTPROVIDED\n" +
252 | " 111T9072000000000000000000000000006\n" +
253 | " RJCT\n" +
254 | " \n" +
255 | " \n" +
256 | " \n" +
257 | " \n" +
258 | " TESTBICB\n" +
259 | " \n" +
260 | " \n" +
261 | " \n" +
262 | " \n" +
263 | " AC01\n" +
264 | " \n" +
265 | " \n" +
266 | " \n" +
267 | " 9.95\n" +
268 | " 2023-09-28\n" +
269 | " \n" +
270 | " \n" +
271 | " TESTBICA\n" +
272 | " \n" +
273 | " \n" +
274 | " \n" +
275 | " \n" +
276 | " TESTBICB\n" +
277 | " \n" +
278 | " \n" +
279 | " \n" +
280 | " \n" +
281 | " \n" +
282 | "";
283 | }
284 |
--------------------------------------------------------------------------------
/src/main/java/com/paymentcomponents/swift/mx/target2/ParseAndValidateRtgsMessage.java:
--------------------------------------------------------------------------------
1 | package com.paymentcomponents.swift.mx.target2;
2 |
3 | import gr.datamation.mx.Message;
4 | import gr.datamation.iso20022.target2.RtgsUtils;
5 | import gr.datamation.iso20022.target2.pacs.FinancialInstitutionCreditTransfer08Rtgs;
6 | import gr.datamation.validation.error.ValidationError;
7 | import gr.datamation.validation.error.ValidationErrorList;
8 |
9 | import java.io.ByteArrayInputStream;
10 |
11 | public class ParseAndValidateRtgsMessage {
12 |
13 | public static void main(String... args) {
14 | execute();
15 | }
16 |
17 | public static void execute() {
18 | constructRTGSMessage();
19 | parseAndValidateRTGSMessage();
20 | autoParseAndValidateRTGSMessage();
21 | }
22 |
23 | public static void constructRTGSMessage() {
24 | try {
25 | //Initialize the message object
26 | FinancialInstitutionCreditTransfer08Rtgs financialInstitutionCreditTransfer08 = new FinancialInstitutionCreditTransfer08Rtgs();
27 | //Optionally use an existing message if we do not want to create the object from scratch
28 | financialInstitutionCreditTransfer08.parseXML(validRtgsPacs009String);
29 |
30 | //We fill the elements of the message object using setters
31 | //financialInstitutionCreditTransfer08.getMessage().setGrpHdr(new GroupHeader93());
32 | //financialInstitutionCreditTransfer08.getMessage().getGrpHdr().setMsgId("1234");
33 |
34 | //or setElement()
35 | //financialInstitutionCreditTransfer08.setElement("GrpHdr/MsgId", "1234");
36 |
37 | //Perform validation
38 | ValidationErrorList validationErrorList = financialInstitutionCreditTransfer08.validate();
39 |
40 | if (validationErrorList.isEmpty()) {
41 | System.out.println("Message is valid");
42 | System.out.println(financialInstitutionCreditTransfer08.convertToXML()); //Get the generated xml
43 | } else {
44 | handleValidationError(validationErrorList);
45 | }
46 | } catch (Exception e) {
47 | e.printStackTrace();
48 | System.err.println(e.getMessage());
49 | }
50 | }
51 |
52 | public static void parseAndValidateRTGSMessage() {
53 | try {
54 | //Initialize the message object
55 | FinancialInstitutionCreditTransfer08Rtgs financialInstitutionCreditTransfer08 = new FinancialInstitutionCreditTransfer08Rtgs();
56 | //Validate against the xml schema
57 | ValidationErrorList validationErrorList = financialInstitutionCreditTransfer08.validateXML(new ByteArrayInputStream(validRtgsPacs009String.getBytes()));
58 | if (!validationErrorList.isEmpty()) {
59 | handleValidationError(validationErrorList);
60 | return;
61 | }
62 | //Fill the message with data from xml
63 | financialInstitutionCreditTransfer08.parseXML(validRtgsPacs009String);
64 | //Validate both the xml schema and rules
65 | validationErrorList.addAll(financialInstitutionCreditTransfer08.validate());
66 |
67 | if (validationErrorList.isEmpty()) {
68 | System.out.println("Message is valid");
69 | System.out.println(financialInstitutionCreditTransfer08.convertToXML()); //Get the generated xml
70 | } else {
71 | handleValidationError(validationErrorList);
72 | }
73 |
74 | } catch (Exception e) {
75 | e.printStackTrace();
76 | System.err.println(e.getMessage());
77 | }
78 | }
79 |
80 | public static void autoParseAndValidateRTGSMessage() {
81 | try {
82 | //Validate against the xml schema without knowing the message type
83 | ValidationErrorList validationErrorList = RtgsUtils.autoValidateXML(new ByteArrayInputStream(validRtgsPacs009String.getBytes()));
84 | if (!validationErrorList.isEmpty()) {
85 | handleValidationError(validationErrorList);
86 | return;
87 | }
88 | //Fill the message with data from xml without knowing the message type
89 | Message message = RtgsUtils.autoParseXML(validRtgsPacs009String);
90 | //Validate both the xml schema and rules
91 | validationErrorList.addAll(message.validate());
92 |
93 | if (validationErrorList.isEmpty()) {
94 | System.out.println("Message is valid");
95 | System.out.println(message.convertToXML()); //Get the generated xml
96 | } else {
97 | handleValidationError(validationErrorList);
98 | }
99 |
100 | } catch (Exception e) {
101 | e.printStackTrace();
102 | System.err.println(e.getMessage());
103 | }
104 | }
105 |
106 | private static void handleValidationError(ValidationErrorList validationErrorList) {
107 | System.err.println("Message is invalid, and the errors are the following:");
108 | for (ValidationError error : validationErrorList) {
109 | System.err.println(error.toString());
110 | System.err.println(
111 | "Error Code: " + error.getErrorCode() + "\n" +
112 | "Error Description: " + error.getDescription() + "\n" +
113 | "Line number in error inside the tag: " + error.getLine() + "\n"
114 | );
115 | }
116 | }
117 |
118 | private static final String validRtgsPacs009String = "\n" +
119 | "\n" +
120 | "\n" +
121 | " \n" +
122 | " \n" +
123 | " NONREF\n" +
124 | " 2019-10-07T13:45:00+00:00\n" +
125 | " 1\n" +
126 | " \n" +
127 | " CLRG\n" +
128 | " \n" +
129 | " TGT\n" +
130 | " \n" +
131 | " \n" +
132 | " \n" +
133 | " \n" +
134 | " \n" +
135 | " Inp009b028-InsId\n" +
136 | " Inp008b028-E2EId\n" +
137 | " e008b028-59c5-41e9-be4c-d45102fc201e\n" +
138 | " \n" +
139 | " 61250.00\n" +
140 | " 2019-10-07\n" +
141 | " \n" +
142 | " \n" +
143 | " PBBBDEFFXXX\n" +
144 | " \n" +
145 | " \n" +
146 | " \n" +
147 | " \n" +
148 | " PBAADEFFAC2\n" +
149 | " \n" +
150 | " \n" +
151 | " \n" +
152 | " \n" +
153 | " PBBBDEFFXXX\n" +
154 | " \n" +
155 | " \n" +
156 | " \n" +
157 | " \n" +
158 | " PBAADEFFAC2\n" +
159 | " \n" +
160 | " \n" +
161 | " \n" +
162 | " \n" +
163 | " Ultimate debtor name\n" +
164 | " \n" +
165 | " \n" +
166 | " ULTMDBTRBIC\n" +
167 | " \n" +
168 | " \n" +
169 | " \n" +
170 | " \n" +
171 | " Debit customer name\n" +
172 | " \n" +
173 | " Frankfurt\n" +
174 | " DE\n" +
175 | " \n" +
176 | " \n" +
177 | " \n" +
178 | " \n" +
179 | " PBBBDEFFXXX\n" +
180 | " \n" +
181 | " \n" +
182 | " \n" +
183 | " \n" +
184 | " PBAADEFFXXX\n" +
185 | " \n" +
186 | " \n" +
187 | " \n" +
188 | " Credit customer name\n" +
189 | " \n" +
190 | " Dusseldorf\n" +
191 | " DE\n" +
192 | " \n" +
193 | " \n" +
194 | " \n" +
195 | " Ultimate creditor name\n" +
196 | " \n" +
197 | " \n" +
198 | " ULTMCDTRBIC\n" +
199 | " \n" +
200 | " \n" +
201 | " \n" +
202 | " \n" +
203 | " \n" +
204 | " \n" +
205 | "\n";
206 |
207 | }
--------------------------------------------------------------------------------