Skip to content

Commit 54fb748

Browse files
NIAD-3369: Update XmlBeans to version 4.0.0 (#348)
* Update Schema JAR file to one having been built using XmlBeans `4.0.0`. * Update XML validator to use the base exception type of `XmlException` rather than `XmlValidationExceptions` as this is what is now used in `4.0.0`. * Update build.gradle to use the latest version of the `iucds-schema`. * Fix minor language errors in the validator which are producing warnings now.
1 parent 031aa67 commit 54fb748

File tree

4 files changed

+6
-7
lines changed

4 files changed

+6
-7
lines changed

service/build.gradle

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -32,8 +32,8 @@ dependencies {
3232
implementation 'org.apache.qpid:qpid-jms-client:2.6.1'
3333
implementation 'org.springframework:spring-jms'
3434
implementation 'ca.uhn.hapi.fhir:hapi-fhir-structures-dstu3:8.2.1'
35-
implementation 'uk.nhs.connect.iucds:iucds-schema:3.0.RC1.2'
36-
implementation 'org.apache.xmlbeans:xmlbeans:3.1.0'
35+
implementation 'uk.nhs.connect.iucds:iucds-schema:4.0.RC1.0'
36+
implementation 'org.apache.xmlbeans:xmlbeans:4.0.0'
3737
implementation 'com.rabbitmq.jms:rabbitmq-jms:3.4.0'
3838

3939
testImplementation 'org.mockito:mockito-core:5.18.0'
-4.99 MB
Binary file not shown.
5.06 MB
Binary file not shown.

service/src/main/java/uk/nhs/adaptors/oneoneone/xml/XmlValidator.java

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,26 +1,25 @@
11
package uk.nhs.adaptors.oneoneone.xml;
22

3-
import static java.util.stream.Collectors.toList;
4-
53
import static org.apache.logging.log4j.util.Strings.join;
64

75
import java.util.ArrayList;
6+
import java.util.Collection;
87
import java.util.List;
98

9+
import org.apache.xmlbeans.XmlError;
1010
import org.apache.xmlbeans.XmlException;
1111
import org.apache.xmlbeans.XmlObject;
1212
import org.apache.xmlbeans.XmlOptions;
13-
import org.apache.xmlbeans.XmlValidationError;
1413

1514
public final class XmlValidator {
1615
public static void validate(XmlObject xmlObject) throws XmlException {
17-
List<XmlValidationError> errors = new ArrayList<>();
16+
Collection<XmlError> errors = new ArrayList<>();
1817
XmlOptions xmlOptions = new XmlOptions();
1918
xmlOptions.setErrorListener(errors);
2019
xmlObject.validate(xmlOptions);
2120

2221
if (!errors.isEmpty()) {
23-
List<String> messages = errors.stream().map(it -> it.getMessage()).collect(toList());
22+
List<String> messages = errors.stream().map(XmlError::getMessage).toList();
2423
throw new XmlException(join(messages, '\n'));
2524
}
2625
}

0 commit comments

Comments
 (0)