diff --git a/dsl-antlr/pom.xml b/dsl-antlr/pom.xml index 545c1e07..30907cd8 100644 --- a/dsl-antlr/pom.xml +++ b/dsl-antlr/pom.xml @@ -5,7 +5,7 @@ parent io.fixprotocol.orchestra - 1.7.3 + 1.7.4-SNAPSHOT 4.0.0 dsl-antlr diff --git a/interfaces-util/pom.xml b/interfaces-util/pom.xml index 6b950f04..5a68a5ca 100644 --- a/interfaces-util/pom.xml +++ b/interfaces-util/pom.xml @@ -5,7 +5,7 @@ io.fixprotocol.orchestra parent - 1.7.3 + 1.7.4-SNAPSHOT interfaces-util ${project.groupId}:${project.artifactId} diff --git a/interfaces/pom.xml b/interfaces/pom.xml index adf039fd..7455107d 100644 --- a/interfaces/pom.xml +++ b/interfaces/pom.xml @@ -5,7 +5,7 @@ io.fixprotocol.orchestra parent - 1.7.3 + 1.7.4-SNAPSHOT interfaces ${project.groupId}:${project.artifactId} diff --git a/message-model/pom.xml b/message-model/pom.xml index fcaf016f..127b05a6 100644 --- a/message-model/pom.xml +++ b/message-model/pom.xml @@ -5,7 +5,7 @@ io.fixprotocol.orchestra parent - 1.7.3 + 1.7.4-SNAPSHOT message-model ${project.groupId}:${project.artifactId} diff --git a/orchestra-common/pom.xml b/orchestra-common/pom.xml index c95119d2..40185727 100644 --- a/orchestra-common/pom.xml +++ b/orchestra-common/pom.xml @@ -5,7 +5,7 @@ io.fixprotocol.orchestra parent - 1.7.3 + 1.7.4-SNAPSHOT orchestra-common ${project.groupId}:${project.artifactId} diff --git a/orchestra2doc/pom.xml b/orchestra2doc/pom.xml index 4cbb10b2..758df738 100644 --- a/orchestra2doc/pom.xml +++ b/orchestra2doc/pom.xml @@ -5,7 +5,7 @@ io.fixprotocol.orchestra parent - 1.7.3 + 1.7.4-SNAPSHOT orchestra2doc Generates humanly readable documentation diff --git a/pom.xml b/pom.xml index 38eb4714..a64d6cb9 100644 --- a/pom.xml +++ b/pom.xml @@ -5,7 +5,7 @@ 4.0.0 io.fixprotocol.orchestra parent - 1.7.3 + 1.7.4-SNAPSHOT pom ${project.groupId}:${project.artifactId} Parent project for FIX Orchestra @@ -64,10 +64,10 @@ UTF-8 - 4.9.2 + 4.9.3 11 1.4 - 5.8.0 + 5.8.1 2.14.1 10.6 1.7.22 diff --git a/repository-util/pom.xml b/repository-util/pom.xml index d9d9dbee..1c49b0cf 100644 --- a/repository-util/pom.xml +++ b/repository-util/pom.xml @@ -5,7 +5,7 @@ io.fixprotocol.orchestra parent - 1.7.3 + 1.7.4-SNAPSHOT repository-util ${project.groupId}:${project.artifactId} diff --git a/repository-util/src/main/java/io/fixprotocol/orchestra/repository/BasicRepositoryValidator.java b/repository-util/src/main/java/io/fixprotocol/orchestra/repository/BasicRepositoryValidator.java index 261a216b..7dd7db9a 100644 --- a/repository-util/src/main/java/io/fixprotocol/orchestra/repository/BasicRepositoryValidator.java +++ b/repository-util/src/main/java/io/fixprotocol/orchestra/repository/BasicRepositoryValidator.java @@ -4,8 +4,10 @@ import java.io.IOException; import java.io.InputStream; import java.net.URL; +import java.util.HashSet; import java.util.Iterator; import java.util.Objects; +import java.util.Set; import java.util.function.Predicate; import javax.xml.XMLConstants; import javax.xml.namespace.NamespaceContext; @@ -110,6 +112,7 @@ public Iterator getPrefixes(String arg0) { private final EventListener eventLogger; private int fatalErrors = 0; private int warnings = 0; + private Set deprecatedFieldTags = new HashSet<>(); public BasicRepositoryValidator(EventListener eventLogger) { this.eventLogger = eventLogger; @@ -153,6 +156,7 @@ public boolean validate(InputStream inputStream) { Document xmlDocument; try { xmlDocument = validateSchema(inputStream, errorHandler); + // must validate fields first because it collects deprecated fields validateFields(xmlDocument); validateCodesets(xmlDocument); validateComponents(xmlDocument); @@ -283,11 +287,13 @@ protected void validateComponents(Document xmlDocument) { warning("RepositoryValidator: component abbrName {0} is invalid (id={1})", abbrName, id); } - if (element.getAttribute("deprecated").length() > 0 - || element.getAttribute("deprecatedEP").length() > 0) { + final boolean isDeprecated = element.getAttribute("deprecated").length() > 0 + || element.getAttribute("deprecatedEP").length() > 0; + if (isDeprecated) { warning("RepositoryValidator: component {0} (id={1}) is deprecated", name, id); } + validateMembers(node, name, id); } } } catch (final XPathExpressionException e) { @@ -295,6 +301,32 @@ protected void validateComponents(Document xmlDocument) { } } + private void validateMembers(Node parentNode, String parentName, String parentId) { + final XPath xPath = XPathFactory.newInstance().newXPath(); + xPath.setNamespaceContext(nsContext); + final String expression = "fixr:fieldRef"; + try { + final NodeList nodeList = + (NodeList) xPath.compile(expression).evaluate(parentNode, XPathConstants.NODESET); + for (int i = 0; i < nodeList.getLength(); i++) { + final Node node = nodeList.item(i); + final short nodeType = node.getNodeType(); + if (nodeType == Node.ELEMENT_NODE) { + final Element element = (Element) node; + final String id = element.getAttribute("id"); + final boolean isDeprecated = element.getAttribute("deprecated").length() > 0 + || element.getAttribute("deprecatedEP").length() > 0; + if (!isDeprecated && this.deprecatedFieldTags.contains(id)) { + warning("RepositoryValidator: {0} has deprecated field id={1} as member", + parentName, id); + } + } + } + } catch (final XPathExpressionException e) { + fatalError("Failed to locate members; {}", e.getMessage()); + } + } + protected void validateDocumentation(Document xmlDocument) { final XPath xPath = XPathFactory.newInstance().newXPath(); xPath.setNamespaceContext(nsContext); @@ -382,8 +414,10 @@ protected void validateFields(Document xmlDocument) { if (abbrName.length() > 0 && !isValidName.test(abbrName)) { warning("RepositoryValidator: field abbrName {0} is invalid (id={1})", abbrName, id); } - if (element.getAttribute("deprecated").length() > 0 - || element.getAttribute("deprecatedEP").length() > 0) { + final boolean isDeprecated = element.getAttribute("deprecated").length() > 0 + || element.getAttribute("deprecatedEP").length() > 0; + if (isDeprecated) { + this.deprecatedFieldTags.add(id); warning("RepositoryValidator: field {0}({1}) is deprecated", name, id); } @@ -416,11 +450,13 @@ protected void validateGroups(Document xmlDocument) { if (abbrName.length() > 0 && !isValidName.test(abbrName)) { warning("RepositoryValidator: group abbrName {0} is invalid (id={1})", abbrName, id); } - if (element.getAttribute("deprecated").length() > 0 - || element.getAttribute("deprecatedEP").length() > 0) { + final boolean isDeprecated = element.getAttribute("deprecated").length() > 0 + || element.getAttribute("deprecatedEP").length() > 0; + if (isDeprecated) { warning("RepositoryValidator: group {0} (id={1}) is deprecated", name, id); } + validateMembers(node, name, id); } } } catch (final XPathExpressionException e) { @@ -449,11 +485,17 @@ protected void validateMessages(Document xmlDocument) { if (abbrName.length() > 0 && !isValidName.test(abbrName)) { warning("RepositoryValidator: message abbrName {0} is invalid (id={1})", abbrName, id); } - if (element.getAttribute("deprecated").length() > 0 - || element.getAttribute("deprecatedEP").length() > 0) { + final boolean isDeprecated = element.getAttribute("deprecated").length() > 0 + || element.getAttribute("deprecatedEP").length() > 0; + if (isDeprecated) { warning("RepositoryValidator: message {0} (id={1}) is deprecated", name, id); } + NodeList children = element.getElementsByTagName("fixr:structure"); + Node structureNode = children.item(0); + if (structureNode != null) { + validateMembers(structureNode, name, id); + } } } } catch (final XPathExpressionException e) { diff --git a/repository-util/src/main/resources/xsl/unified2orchestra.xslt b/repository-util/src/main/resources/xsl/unified2orchestra.xslt index d0b7c221..effcc7fe 100644 --- a/repository-util/src/main/resources/xsl/unified2orchestra.xslt +++ b/repository-util/src/main/resources/xsl/unified2orchestra.xslt @@ -1,5 +1,5 @@ - + diff --git a/repository/pom.xml b/repository/pom.xml index f57fbc7c..afae50c5 100644 --- a/repository/pom.xml +++ b/repository/pom.xml @@ -6,7 +6,7 @@ io.fixprotocol.orchestra parent - 1.7.3 + 1.7.4-SNAPSHOT repository ${project.groupId}:${project.artifactId} diff --git a/repository2010/pom.xml b/repository2010/pom.xml index 68cc6196..02dfc106 100644 --- a/repository2010/pom.xml +++ b/repository2010/pom.xml @@ -7,7 +7,7 @@ io.fixprotocol.orchestra parent - 1.7.3 + 1.7.4-SNAPSHOT repository2010 ${project.groupId}:${project.artifactId}