Permalink
Browse files

RHBPMS-4480 - Improve ExtensibleXmlParser logging - adding parent nod…

…e lookup (#857)
1 parent c9f0167 commit 426d8d5dfecab44dd983d5cfbfb60a14b567ba7f @tsurdilo tsurdilo committed on GitHub May 26, 2017
@@ -20,6 +20,7 @@
import java.io.InputStream;
import java.util.HashSet;
import java.util.List;
+import java.util.LinkedList;
import org.custommonkey.xmlunit.Diff;
import org.custommonkey.xmlunit.Difference;
@@ -110,8 +111,8 @@ public void testInvalidXML() throws Exception, SAXException {
modules.addSemanticModule(new BPMNDISemanticModule());
XmlProcessReader processReader = new XmlProcessReader(modules, getClass().getClassLoader()) {
@Override
- protected String processParserMessage(Object parent, org.xml.sax.Attributes attr, String errorMessage) {
- setErrorMessage(super.processParserMessage(parent, attr, errorMessage));
+ protected String processParserMessage(LinkedList<Object> parents, org.xml.sax.Attributes attr, String errorMessage) {
+ setErrorMessage(super.processParserMessage(parents, attr, errorMessage));
return errorMessage;
}
};
@@ -125,6 +126,26 @@ protected String processParserMessage(Object parent, org.xml.sax.Attributes attr
}
+ public void testInvalidXMLInCompositeNode() throws Exception, SAXException {
+ SemanticModules modules = new SemanticModules();
+ modules.addSemanticModule(new BPMNSemanticModule());
+ modules.addSemanticModule(new BPMNDISemanticModule());
+ XmlProcessReader processReader = new XmlProcessReader(modules, getClass().getClassLoader()) {
+ @Override
+ protected String processParserMessage(LinkedList<Object> parents, org.xml.sax.Attributes attr, String errorMessage) {
+ setErrorMessage(super.processParserMessage(parents, attr, errorMessage));
+ return errorMessage;
+ }
+ };
+
+ processReader.read(BPMN2XMLTest.class.getResourceAsStream("/BPMN2-XMLProcessWithErrorInCompositeNode.bpmn2"));
+
+ assertNotNull(getErrorMessage());
+ assertEquals("Process Info: id:abc.abc, pkg:org.drools.bpmn2, name:abc, version:1.0 \n" +
+ "Node Info: id:_47489F3D-FEBD-4452-B62E-B04EF191C6C3 name: \n" +
+ "Parser message: (null: 24, 185): cvc-complex-type.2.4.a: Invalid content was found starting with element 'bpmn2:subProcess'. One of '{\"http://www.omg.org/spec/BPMN/20100524/MODEL\":artifact}' is expected.", getErrorMessage());
+ }
+
private void setErrorMessage(String errorMessage) {
this.errorMessage = errorMessage;
}
@@ -0,0 +1,199 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<bpmn2:definitions xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://www.omg.org/bpmn20" xmlns:bpmn2="http://www.omg.org/spec/BPMN/20100524/MODEL" xmlns:bpmndi="http://www.omg.org/spec/BPMN/20100524/DI" xmlns:bpsim="http://www.bpsim.org/schemas/1.0" xmlns:color="http://www.omg.org/spec/BPMN/non-normative/color" xmlns:dc="http://www.omg.org/spec/DD/20100524/DC" xmlns:di="http://www.omg.org/spec/DD/20100524/DI" xmlns:drools="http://www.jboss.org/drools" id="_BjDVMEFnEeetmJsIiDm5dA" xsi:schemaLocation="http://www.omg.org/spec/BPMN/20100524/MODEL BPMN20.xsd http://www.jboss.org/drools drools.xsd http://www.bpsim.org/schemas/1.0 bpsim.xsd" exporter="jBPM Designer" exporterVersion="6.2.0" expressionLanguage="http://www.mvel.org/2.0" targetNamespace="http://www.omg.org/bpmn20" typeLanguage="http://www.java.com/javaTypes">
+ <bpmn2:process id="abc.abc" drools:version="1.0" name="abc" isExecutable="true">
+ <bpmn2:subProcess id="_7E65957E-7BFD-4B01-9294-07E64E630197" drools:selectable="true" color:background-color="#fafad2" color:border-color="#000000" color:color="#000000" name="">
+ <bpmn2:extensionElements>
+ <drools:metaData name="elementname">
+ <drools:metaValue><![CDATA[]]></drools:metaValue>
+ </drools:metaData>
+ </bpmn2:extensionElements>
+ <bpmn2:incoming>_F64F3ACD-DE34-4D25-9BC7-0A4AC10AC015</bpmn2:incoming>
+ <bpmn2:outgoing>_089EA416-3ABB-4263-BC8A-90AE7293D45C</bpmn2:outgoing>
+ <bpmn2:ioSpecification id="_BjDVMUFnEeetmJsIiDm5dA">
+ <bpmn2:inputSet id="_BjDVMkFnEeetmJsIiDm5dA"/>
+ <bpmn2:outputSet id="_BjDVM0FnEeetmJsIiDm5dA"/>
+ </bpmn2:ioSpecification>
+ <bpmn2:textAnnotation id="_56E12D3A-ECE6-4543-BB95-5117C110192D" drools:selectable="true" color:background-color="" color:border-color="#000000" color:color="#000000">
+ <bpmn2:extensionElements>
+ <drools:metaData name="elementname">
+ <drools:metaValue><![CDATA[myTaskText]]></drools:metaValue>
+ </drools:metaData>
+ </bpmn2:extensionElements>
+ <bpmn2:text>myTaskText</bpmn2:text>
+ </bpmn2:textAnnotation>
+ <bpmn2:subProcess id="_47489F3D-FEBD-4452-B62E-B04EF191C6C3" drools:selectable="true" color:background-color="#fafad2" color:border-color="#000000" color:color="#000000" name="">
+ <bpmn2:extensionElements>
+ <drools:metaData name="elementname">
+ <drools:metaValue><![CDATA[]]></drools:metaValue>
+ </drools:metaData>
+ </bpmn2:extensionElements>
+ <bpmn2:ioSpecification id="_BjDVNEFnEeetmJsIiDm5dA">
+ <bpmn2:inputSet id="_BjDVNUFnEeetmJsIiDm5dA"/>
+ <bpmn2:outputSet id="_BjDVNkFnEeetmJsIiDm5dA"/>
+ </bpmn2:ioSpecification>
+ <bpmn2:userTask id="_2ECFE3B1-C1A8-49BD-A992-135E8DC97202" drools:selectable="true" drools:scriptFormat="http://www.java.com/java" color:background-color="#fafad2" color:border-color="#000000" color:color="#000000" name="myTask">
+ <bpmn2:extensionElements>
+ <drools:metaData name="elementname">
+ <drools:metaValue><![CDATA[myTask]]></drools:metaValue>
+ </drools:metaData>
+ </bpmn2:extensionElements>
+ <bpmn2:ioSpecification id="_BjDVN0FnEeetmJsIiDm5dA">
+ <bpmn2:dataInput id="_2ECFE3B1-C1A8-49BD-A992-135E8DC97202_SkippableInputX" name="Skippable"/>
+ <bpmn2:inputSet id="_BjDVOEFnEeetmJsIiDm5dA">
+ <bpmn2:dataInputRefs>_2ECFE3B1-C1A8-49BD-A992-135E8DC97202_SkippableInputX</bpmn2:dataInputRefs>
+ </bpmn2:inputSet>
+ <bpmn2:outputSet id="_BjDVOUFnEeetmJsIiDm5dA"/>
+ </bpmn2:ioSpecification>
+ <bpmn2:dataInputAssociation id="_BjDVOkFnEeetmJsIiDm5dA">
+ <bpmn2:targetRef>_2ECFE3B1-C1A8-49BD-A992-135E8DC97202_SkippableInputX</bpmn2:targetRef>
+ <bpmn2:assignment id="_BjDVO0FnEeetmJsIiDm5dA">
+ <bpmn2:from xsi:type="bpmn2:tFormalExpression" id="_BjDVPEFnEeetmJsIiDm5dA">true</bpmn2:from>
+ <bpmn2:to xsi:type="bpmn2:tFormalExpression" id="_BjDVPUFnEeetmJsIiDm5dA">_2ECFE3B1-C1A8-49BD-A992-135E8DC97202_SkippableInputX</bpmn2:to>
+ </bpmn2:assignment>
+ </bpmn2:dataInputAssociation>
+ </bpmn2:userTask>
+ </bpmn2:subProcess>
+ </bpmn2:subProcess>
+ <bpmn2:startEvent id="_4A6EFEC3-B8B9-4B0E-8970-8D0D6CC61A16" drools:selectable="true" color:background-color="#9acd32" color:border-color="#000000" color:color="#000000" name="">
+ <bpmn2:extensionElements>
+ <drools:metaData name="elementname">
+ <drools:metaValue><![CDATA[]]></drools:metaValue>
+ </drools:metaData>
+ </bpmn2:extensionElements>
+ <bpmn2:outgoing>_F64F3ACD-DE34-4D25-9BC7-0A4AC10AC015</bpmn2:outgoing>
+ </bpmn2:startEvent>
+ <bpmn2:sequenceFlow id="_F64F3ACD-DE34-4D25-9BC7-0A4AC10AC015" drools:selectable="true" color:background-color="#000000" color:border-color="#000000" color:color="#000000" sourceRef="_4A6EFEC3-B8B9-4B0E-8970-8D0D6CC61A16" targetRef="_7E65957E-7BFD-4B01-9294-07E64E630197"/>
+ <bpmn2:endEvent id="_BE386B85-8904-4416-8975-BC25E1584A26" drools:selectable="true" color:background-color="#ff6347" color:border-color="#000000" color:color="#000000" name="">
+ <bpmn2:extensionElements>
+ <drools:metaData name="elementname">
+ <drools:metaValue><![CDATA[]]></drools:metaValue>
+ </drools:metaData>
+ </bpmn2:extensionElements>
+ <bpmn2:incoming>_089EA416-3ABB-4263-BC8A-90AE7293D45C</bpmn2:incoming>
+ </bpmn2:endEvent>
+ <bpmn2:sequenceFlow id="_089EA416-3ABB-4263-BC8A-90AE7293D45C" drools:selectable="true" color:background-color="#000000" color:border-color="#000000" color:color="#000000" sourceRef="_7E65957E-7BFD-4B01-9294-07E64E630197" targetRef="_BE386B85-8904-4416-8975-BC25E1584A26"/>
+ <bpmn2:association id="_E41B0963-C4E5-4C9F-88B4-8AD4FFF3DEB1" drools:selectable="true" drools:type="none" color:background-color="" color:border-color="#000000" color:color="" sourceRef="_2ECFE3B1-C1A8-49BD-A992-135E8DC97202" targetRef="_56E12D3A-ECE6-4543-BB95-5117C110192D"/>
+ </bpmn2:process>
+ <bpmndi:BPMNDiagram id="_BjDVPkFnEeetmJsIiDm5dA">
+ <bpmndi:BPMNPlane id="_BjDVP0FnEeetmJsIiDm5dA" bpmnElement="abc.abc">
+ <bpmndi:BPMNShape id="_BjDVQEFnEeetmJsIiDm5dA" bpmnElement="_7E65957E-7BFD-4B01-9294-07E64E630197">
+ <dc:Bounds height="261.0" width="635.0" x="135.0" y="60.0"/>
+ </bpmndi:BPMNShape>
+ <bpmndi:BPMNShape id="_BjDVQUFnEeetmJsIiDm5dA" bpmnElement="_47489F3D-FEBD-4452-B62E-B04EF191C6C3">
+ <dc:Bounds height="201.0" width="262.0" x="330.0" y="96.0"/>
+ </bpmndi:BPMNShape>
+ <bpmndi:BPMNShape id="_BjDVQkFnEeetmJsIiDm5dA" bpmnElement="_2ECFE3B1-C1A8-49BD-A992-135E8DC97202">
+ <dc:Bounds height="80.0" width="100.0" x="359.0" y="181.0"/>
+ </bpmndi:BPMNShape>
+ <bpmndi:BPMNShape id="_BjDVQ0FnEeetmJsIiDm5dA" bpmnElement="_56E12D3A-ECE6-4543-BB95-5117C110192D">
+ <dc:Bounds height="50.0" width="100.0" x="465.0" y="111.0"/>
+ </bpmndi:BPMNShape>
+ <bpmndi:BPMNShape id="_BjDVREFnEeetmJsIiDm5dA" bpmnElement="_4A6EFEC3-B8B9-4B0E-8970-8D0D6CC61A16">
+ <dc:Bounds height="30.0" width="30.0" x="38.0" y="188.0"/>
+ </bpmndi:BPMNShape>
+ <bpmndi:BPMNShape id="_BjDVRUFnEeetmJsIiDm5dA" bpmnElement="_BE386B85-8904-4416-8975-BC25E1584A26">
+ <dc:Bounds height="28.0" width="28.0" x="815.0" y="176.0"/>
+ </bpmndi:BPMNShape>
+ <bpmndi:BPMNEdge id="_BjDVRkFnEeetmJsIiDm5dA" bpmnElement="_F64F3ACD-DE34-4D25-9BC7-0A4AC10AC015" sourceElement="_BjDVREFnEeetmJsIiDm5dA" targetElement="_BjDVQEFnEeetmJsIiDm5dA">
+ <di:waypoint xsi:type="dc:Point" x="53.0" y="203.0"/>
+ <di:waypoint xsi:type="dc:Point" x="452.5" y="190.5"/>
+ </bpmndi:BPMNEdge>
+ <bpmndi:BPMNEdge id="_BjDVR0FnEeetmJsIiDm5dA" bpmnElement="_089EA416-3ABB-4263-BC8A-90AE7293D45C" sourceElement="_BjDVQEFnEeetmJsIiDm5dA" targetElement="_BjDVRUFnEeetmJsIiDm5dA">
+ <di:waypoint xsi:type="dc:Point" x="452.5" y="190.5"/>
+ <di:waypoint xsi:type="dc:Point" x="829.0" y="190.0"/>
+ </bpmndi:BPMNEdge>
+ <bpmndi:BPMNEdge id="_BjDVSEFnEeetmJsIiDm5dA" bpmnElement="_E41B0963-C4E5-4C9F-88B4-8AD4FFF3DEB1">
+ <di:waypoint xsi:type="dc:Point" x="79.0" y="125.0"/>
+ <di:waypoint xsi:type="dc:Point" x="185.0" y="40.0"/>
+ </bpmndi:BPMNEdge>
+ </bpmndi:BPMNPlane>
+ </bpmndi:BPMNDiagram>
+ <bpmn2:relationship id="_BjDVSUFnEeetmJsIiDm5dA" type="BPSimData">
+ <bpmn2:extensionElements>
+ <bpsim:BPSimData>
+ <bpsim:Scenario xsi:type="bpsim:Scenario" id="default" name="Simulationscenario">
+ <bpsim:ScenarioParameters xsi:type="bpsim:ScenarioParameters" baseTimeUnit="min"/>
+ <bpsim:ElementParameters xsi:type="bpsim:ElementParameters" elementRef="_2ECFE3B1-C1A8-49BD-A992-135E8DC97202" id="_BjDVSkFnEeetmJsIiDm5dA">
+ <bpsim:TimeParameters xsi:type="bpsim:TimeParameters">
+ <bpsim:ProcessingTime xsi:type="bpsim:Parameter">
+ <bpsim:UniformDistribution max="10.0" min="5.0"/>
+ </bpsim:ProcessingTime>
+ </bpsim:TimeParameters>
+ <bpsim:ResourceParameters xsi:type="bpsim:ResourceParameters">
+ <bpsim:Availability xsi:type="bpsim:Parameter">
+ <bpsim:FloatingParameter value="8.0"/>
+ </bpsim:Availability>
+ <bpsim:Quantity xsi:type="bpsim:Parameter">
+ <bpsim:FloatingParameter value="1.0"/>
+ </bpsim:Quantity>
+ </bpsim:ResourceParameters>
+ <bpsim:CostParameters xsi:type="bpsim:CostParameters">
+ <bpsim:UnitCost xsi:type="bpsim:Parameter">
+ <bpsim:FloatingParameter value="0.0"/>
+ </bpsim:UnitCost>
+ </bpsim:CostParameters>
+ </bpsim:ElementParameters>
+ <bpsim:ElementParameters xsi:type="bpsim:ElementParameters" elementRef="_4A6EFEC3-B8B9-4B0E-8970-8D0D6CC61A16" id="_BjDVS0FnEeetmJsIiDm5dA">
+ <bpsim:TimeParameters xsi:type="bpsim:TimeParameters">
+ <bpsim:ProcessingTime xsi:type="bpsim:Parameter">
+ <bpsim:UniformDistribution max="10.0" min="5.0"/>
+ </bpsim:ProcessingTime>
+ </bpsim:TimeParameters>
+ <bpsim:ControlParameters xsi:type="bpsim:ControlParameters">
+ <bpsim:Probability xsi:type="bpsim:Parameter">
+ <bpsim:FloatingParameter value="100.0"/>
+ </bpsim:Probability>
+ </bpsim:ControlParameters>
+ </bpsim:ElementParameters>
+ <bpsim:ElementParameters xsi:type="bpsim:ElementParameters" elementRef="_F64F3ACD-DE34-4D25-9BC7-0A4AC10AC015" id="_BjDVTEFnEeetmJsIiDm5dA">
+ <bpsim:ControlParameters xsi:type="bpsim:ControlParameters">
+ <bpsim:Probability xsi:type="bpsim:Parameter">
+ <bpsim:FloatingParameter value="100.0"/>
+ </bpsim:Probability>
+ </bpsim:ControlParameters>
+ </bpsim:ElementParameters>
+ <bpsim:ElementParameters xsi:type="bpsim:ElementParameters" elementRef="_089EA416-3ABB-4263-BC8A-90AE7293D45C" id="_BjD8QEFnEeetmJsIiDm5dA">
+ <bpsim:ControlParameters xsi:type="bpsim:ControlParameters">
+ <bpsim:Probability xsi:type="bpsim:Parameter">
+ <bpsim:FloatingParameter value="100.0"/>
+ </bpsim:Probability>
+ </bpsim:ControlParameters>
+ </bpsim:ElementParameters>
+ <bpsim:ElementParameters xsi:type="bpsim:ElementParameters" elementRef="_47489F3D-FEBD-4452-B62E-B04EF191C6C3" id="_BjD8QUFnEeetmJsIiDm5dA">
+ <bpsim:TimeParameters xsi:type="bpsim:TimeParameters">
+ <bpsim:ProcessingTime xsi:type="bpsim:Parameter">
+ <bpsim:UniformDistribution max="10.0" min="5.0"/>
+ </bpsim:ProcessingTime>
+ </bpsim:TimeParameters>
+ <bpsim:CostParameters xsi:type="bpsim:CostParameters">
+ <bpsim:UnitCost xsi:type="bpsim:Parameter">
+ <bpsim:FloatingParameter value="0.0"/>
+ </bpsim:UnitCost>
+ </bpsim:CostParameters>
+ </bpsim:ElementParameters>
+ <bpsim:ElementParameters xsi:type="bpsim:ElementParameters" elementRef="_BE386B85-8904-4416-8975-BC25E1584A26" id="_BjD8QkFnEeetmJsIiDm5dA">
+ <bpsim:TimeParameters xsi:type="bpsim:TimeParameters">
+ <bpsim:ProcessingTime xsi:type="bpsim:Parameter">
+ <bpsim:UniformDistribution max="10.0" min="5.0"/>
+ </bpsim:ProcessingTime>
+ </bpsim:TimeParameters>
+ </bpsim:ElementParameters>
+ <bpsim:ElementParameters xsi:type="bpsim:ElementParameters" elementRef="_7E65957E-7BFD-4B01-9294-07E64E630197" id="_BjD8Q0FnEeetmJsIiDm5dA">
+ <bpsim:TimeParameters xsi:type="bpsim:TimeParameters">
+ <bpsim:ProcessingTime xsi:type="bpsim:Parameter">
+ <bpsim:UniformDistribution max="10.0" min="5.0"/>
+ </bpsim:ProcessingTime>
+ </bpsim:TimeParameters>
+ <bpsim:CostParameters xsi:type="bpsim:CostParameters">
+ <bpsim:UnitCost xsi:type="bpsim:Parameter">
+ <bpsim:FloatingParameter value="0.0"/>
+ </bpsim:UnitCost>
+ </bpsim:CostParameters>
+ </bpsim:ElementParameters>
+ </bpsim:Scenario>
+ </bpsim:BPSimData>
+ </bpmn2:extensionElements>
+ <bpmn2:source>_BjDVMEFnEeetmJsIiDm5dA</bpmn2:source>
+ <bpmn2:target>_BjDVMEFnEeetmJsIiDm5dA</bpmn2:target>
+ </bpmn2:relationship>
+</bpmn2:definitions>
@@ -19,6 +19,7 @@
import java.io.InputStream;
import java.io.Reader;
import java.util.List;
+import java.util.LinkedList;
import java.text.MessageFormat;
import javax.xml.parsers.SAXParser;
@@ -52,7 +53,7 @@ public XmlProcessReader(final SemanticModules modules, ClassLoader classLoader,
this.parser = new ExtensibleXmlParser() {
@Override
protected String buildPrintMessage(final SAXParseException x) {
- return processParserMessage(super.getParent(), super.getAttrs(), super.buildPrintMessage(x));
+ return processParserMessage(super.getParents(), super.getAttrs(), super.buildPrintMessage(x));
}
};
@@ -118,18 +119,20 @@ public ProcessBuildData getProcessBuildData() {
return (ProcessBuildData) this.parser.getData();
}
- protected String processParserMessage(Object parent, Attributes attr, String errorMessage) {
+ protected String processParserMessage(LinkedList<Object> parents, Attributes attr, String errorMessage) {
String nodeId = (attr == null || attr.getValue("id") == null) ? "" : attr.getValue("id");
String nodeName = (attr == null || attr.getValue("name") == null) ? "" : attr.getValue("name");
- if(parent != null && parent instanceof RuleFlowProcess) {
- RuleFlowProcess process = ((RuleFlowProcess) parent);
- return messageWithProcessInfo.format(new Object[] {process.getId(),
- process.getPackageName(),
- process.getName(),
- process.getVersion(), nodeId, nodeName, errorMessage});
- } else {
- return message.format(new Object[] {nodeId, nodeName, errorMessage});
+ for(Object parent : parents) {
+ if(parent != null && parent instanceof RuleFlowProcess) {
+ RuleFlowProcess process = ((RuleFlowProcess) parent);
+ return messageWithProcessInfo.format(new Object[] {process.getId(),
+ process.getPackageName(),
+ process.getName(),
+ process.getVersion(), nodeId, nodeName, errorMessage});
+ }
}
+
+ return message.format(new Object[] {nodeId, nodeName, errorMessage});
}
}

0 comments on commit 426d8d5

Please sign in to comment.