Skip to content

Commit

Permalink
Xfix (#13841)
Browse files Browse the repository at this point in the history
* CAMEL-20667: Add ref error handler to model. camel-yaml-dsl: Avoid two kinds of error handler in the schema model.

* Fix unit test as the xml dumper may have changed recently

* Regen
  • Loading branch information
davsclaus authored Apr 17, 2024
1 parent c95c1eb commit 07a96ad
Show file tree
Hide file tree
Showing 14 changed files with 134 additions and 208 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
},
"properties": {
"id": { "index": 0, "kind": "attribute", "displayName": "Id", "required": false, "type": "string", "javaType": "java.lang.String", "deprecated": false, "autowired": false, "secret": false, "description": "The id of this node" },
"errorHandlerType": { "index": 1, "kind": "element", "displayName": "Error Handler Type", "required": true, "type": "object", "javaType": "org.apache.camel.ErrorHandlerFactory", "oneOf": [ "deadLetterChannel", "defaultErrorHandler", "jtaTransactionErrorHandler", "noErrorHandler", "springTransactionErrorHandler" ], "deprecated": false, "autowired": false, "secret": false, "description": "The specific error handler in use." }
"errorHandlerType": { "index": 1, "kind": "element", "displayName": "Error Handler Type", "required": true, "type": "object", "javaType": "org.apache.camel.ErrorHandlerFactory", "oneOf": [ "deadLetterChannel", "defaultErrorHandler", "jtaTransactionErrorHandler", "noErrorHandler", "refErrorHandler", "springTransactionErrorHandler" ], "deprecated": false, "autowired": false, "secret": false, "description": "The specific error handler in use." }
},
"exchangeProperties": {
"CamelExceptionCaught": { "index": 0, "kind": "exchangeProperty", "displayName": "Exception Caught", "label": "producer", "required": false, "javaType": "java.lang.Exception", "deprecated": false, "autowired": false, "secret": false, "description": "Stores the caught exception due to a processing error of the current Exchange" },
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5497,6 +5497,7 @@ Whether to auto startup components when enricher is starting up. Default value:
<xs:element ref="tns:deadLetterChannel"/>
<xs:element ref="tns:defaultErrorHandler"/>
<xs:element ref="tns:noErrorHandler"/>
<xs:element ref="tns:refErrorHandler"/>
<xs:element ref="tns:jtaTransactionErrorHandler"/>
<xs:element ref="tns:springTransactionErrorHandler"/>
</xs:choice>
Expand Down Expand Up @@ -5936,6 +5937,22 @@ Sets the reference of the instance of org.apache.camel.spi.ExchangeFormatter to
</xs:extension>
</xs:complexContent>
</xs:complexType>
<xs:complexType name="refErrorHandlerDefinition">
<xs:complexContent>
<xs:extension base="tns:baseErrorHandlerDefinition">
<xs:sequence/>
<xs:attribute name="ref" type="xs:string" use="required">
<xs:annotation>
<xs:documentation xml:lang="en">
<![CDATA[
References to an existing or custom error handler.
]]>
</xs:documentation>
</xs:annotation>
</xs:attribute>
</xs:extension>
</xs:complexContent>
</xs:complexType>
<xs:complexType name="jtaTransactionErrorHandlerDefinition">
<xs:complexContent>
<xs:extension base="tns:transactionErrorHandlerDefinition">
Expand Down Expand Up @@ -15205,22 +15222,6 @@ Set a reference to a custom Expression to use.
</xs:choice>
</xs:sequence>
</xs:complexType>
<xs:complexType name="refErrorHandlerDefinition">
<xs:complexContent>
<xs:extension base="tns:baseErrorHandlerDefinition">
<xs:sequence/>
<xs:attribute name="ref" type="xs:string" use="required">
<xs:annotation>
<xs:documentation xml:lang="en">
<![CDATA[
References to an existing or custom error handler.
]]>
</xs:documentation>
</xs:annotation>
</xs:attribute>
</xs:extension>
</xs:complexContent>
</xs:complexType>
<xs:complexType name="cSimpleExpression">
<xs:simpleContent>
<xs:extension base="tns:typedExpressionDefinition"/>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
},
"properties": {
"id": { "index": 0, "kind": "attribute", "displayName": "Id", "required": false, "type": "string", "javaType": "java.lang.String", "deprecated": false, "autowired": false, "secret": false, "description": "The id of this node" },
"errorHandlerType": { "index": 1, "kind": "element", "displayName": "Error Handler Type", "required": true, "type": "object", "javaType": "org.apache.camel.ErrorHandlerFactory", "oneOf": [ "deadLetterChannel", "defaultErrorHandler", "jtaTransactionErrorHandler", "noErrorHandler", "springTransactionErrorHandler" ], "deprecated": false, "autowired": false, "secret": false, "description": "The specific error handler in use." }
"errorHandlerType": { "index": 1, "kind": "element", "displayName": "Error Handler Type", "required": true, "type": "object", "javaType": "org.apache.camel.ErrorHandlerFactory", "oneOf": [ "deadLetterChannel", "defaultErrorHandler", "jtaTransactionErrorHandler", "noErrorHandler", "refErrorHandler", "springTransactionErrorHandler" ], "deprecated": false, "autowired": false, "secret": false, "description": "The specific error handler in use." }
},
"exchangeProperties": {
"CamelExceptionCaught": { "index": 0, "kind": "exchangeProperty", "displayName": "Exception Caught", "label": "producer", "required": false, "javaType": "java.lang.Exception", "deprecated": false, "autowired": false, "secret": false, "description": "Stores the caught exception due to a processing error of the current Exchange" },
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@
import org.apache.camel.model.errorhandler.DefaultErrorHandlerDefinition;
import org.apache.camel.model.errorhandler.JtaTransactionErrorHandlerDefinition;
import org.apache.camel.model.errorhandler.NoErrorHandlerDefinition;
import org.apache.camel.model.errorhandler.RefErrorHandlerDefinition;
import org.apache.camel.model.errorhandler.SpringTransactionErrorHandlerDefinition;
import org.apache.camel.spi.Metadata;

Expand All @@ -42,6 +43,7 @@ public class ErrorHandlerDefinition extends IdentifiedType {
@XmlElement(name = "deadLetterChannel", type = DeadLetterChannelDefinition.class),
@XmlElement(name = "defaultErrorHandler", type = DefaultErrorHandlerDefinition.class),
@XmlElement(name = "noErrorHandler", type = NoErrorHandlerDefinition.class),
@XmlElement(name = "refErrorHandler", type = RefErrorHandlerDefinition.class),
@XmlElement(name = "jtaTransactionErrorHandler", type = JtaTransactionErrorHandlerDefinition.class),
@XmlElement(name = "springTransactionErrorHandler", type = SpringTransactionErrorHandlerDefinition.class) })
private ErrorHandlerFactory errorHandlerType;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -43,13 +43,19 @@ public void testDumpModelAsXml() throws Exception {
NodeList nl = dom.getElementsByTagName("xpath");
assertEquals(2, nl.getLength());

Element n1 = (Element) nl.item(0);
String attributeFoo = n1.getAttribute("xmlns:foo");
String attributeFoo = dom.getDocumentElement().getAttribute("xmlns:foo");
if (attributeFoo.isEmpty()) {
Element n1 = (Element) nl.item(0);
attributeFoo = n1.getAttribute("xmlns:foo");
}
assertNotNull(attributeFoo);
assertEquals(URL_FOO, attributeFoo);

Element n2 = (Element) nl.item(1);
String attributeBar = n2.getAttribute("xmlns:bar");
String attributeBar = dom.getDocumentElement().getAttribute("xmlns:bar");
if (attributeBar.isEmpty()) {
Element n1 = (Element) nl.item(0);
attributeBar = n1.getAttribute("xmlns:bar");
}
assertNotNull(attributeBar);
assertEquals(URL_BAR, attributeBar);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -333,6 +333,7 @@ protected ErrorHandlerDefinition doParseErrorHandlerDefinition() throws IOExcept
case "deadLetterChannel": def.setErrorHandlerType(doParseDeadLetterChannelDefinition()); yield true;
case "defaultErrorHandler": def.setErrorHandlerType(doParseDefaultErrorHandlerDefinition()); yield true;
case "noErrorHandler": def.setErrorHandlerType(doParseNoErrorHandlerDefinition()); yield true;
case "refErrorHandler": def.setErrorHandlerType(doParseRefErrorHandlerDefinition()); yield true;
case "jtaTransactionErrorHandler": def.setErrorHandlerType(doParseJtaTransactionErrorHandlerDefinition()); yield true;
case "springTransactionErrorHandler": def.setErrorHandlerType(doParseSpringTransactionErrorHandlerDefinition()); yield true;
default: yield false;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -938,6 +938,7 @@ protected void doWriteErrorHandlerDefinition(String name, ErrorHandlerDefinition
case "DeadLetterChannelDefinition" -> doWriteDeadLetterChannelDefinition("deadLetterChannel", (DeadLetterChannelDefinition) v);
case "DefaultErrorHandlerDefinition" -> doWriteDefaultErrorHandlerDefinition("defaultErrorHandler", (DefaultErrorHandlerDefinition) v);
case "NoErrorHandlerDefinition" -> doWriteNoErrorHandlerDefinition("noErrorHandler", (NoErrorHandlerDefinition) v);
case "RefErrorHandlerDefinition" -> doWriteRefErrorHandlerDefinition("refErrorHandler", (RefErrorHandlerDefinition) v);
case "JtaTransactionErrorHandlerDefinition" -> doWriteJtaTransactionErrorHandlerDefinition("jtaTransactionErrorHandler", (JtaTransactionErrorHandlerDefinition) v);
case "SpringTransactionErrorHandlerDefinition" -> doWriteSpringTransactionErrorHandlerDefinition("springTransactionErrorHandler", (SpringTransactionErrorHandlerDefinition) v);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -938,6 +938,7 @@ protected void doWriteErrorHandlerDefinition(String name, ErrorHandlerDefinition
case "DeadLetterChannelDefinition" -> doWriteDeadLetterChannelDefinition("deadLetterChannel", (DeadLetterChannelDefinition) v);
case "DefaultErrorHandlerDefinition" -> doWriteDefaultErrorHandlerDefinition("defaultErrorHandler", (DefaultErrorHandlerDefinition) v);
case "NoErrorHandlerDefinition" -> doWriteNoErrorHandlerDefinition("noErrorHandler", (NoErrorHandlerDefinition) v);
case "RefErrorHandlerDefinition" -> doWriteRefErrorHandlerDefinition("refErrorHandler", (RefErrorHandlerDefinition) v);
case "JtaTransactionErrorHandlerDefinition" -> doWriteJtaTransactionErrorHandlerDefinition("jtaTransactionErrorHandler", (JtaTransactionErrorHandlerDefinition) v);
case "SpringTransactionErrorHandlerDefinition" -> doWriteSpringTransactionErrorHandlerDefinition("springTransactionErrorHandler", (SpringTransactionErrorHandlerDefinition) v);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5288,6 +5288,7 @@ protected boolean setProperty(EnrichDefinition target, String propertyKey,
@YamlProperty(name = "id", type = "string", description = "The id of this node", displayName = "Id"),
@YamlProperty(name = "jtaTransactionErrorHandler", type = "object:org.apache.camel.model.errorhandler.JtaTransactionErrorHandlerDefinition", oneOf = "errorHandlerType"),
@YamlProperty(name = "noErrorHandler", type = "object:org.apache.camel.model.errorhandler.NoErrorHandlerDefinition", oneOf = "errorHandlerType"),
@YamlProperty(name = "refErrorHandler", type = "object:org.apache.camel.model.errorhandler.RefErrorHandlerDefinition", oneOf = "errorHandlerType"),
@YamlProperty(name = "springTransactionErrorHandler", type = "object:org.apache.camel.model.errorhandler.SpringTransactionErrorHandlerDefinition", oneOf = "errorHandlerType")
}
)
Expand Down Expand Up @@ -5326,6 +5327,11 @@ protected boolean setProperty(ErrorHandlerDefinition target, String propertyKey,
target.setErrorHandlerType(val);
break;
}
case "refErrorHandler": {
org.apache.camel.model.errorhandler.RefErrorHandlerDefinition val = asType(node, org.apache.camel.model.errorhandler.RefErrorHandlerDefinition.class);
target.setErrorHandlerType(val);
break;
}
case "jtaTransactionErrorHandler": {
org.apache.camel.model.errorhandler.JtaTransactionErrorHandlerDefinition val = asType(node, org.apache.camel.model.errorhandler.JtaTransactionErrorHandlerDefinition.class);
target.setErrorHandlerType(val);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -86,10 +86,11 @@ public ConstructNode resolve(String id) {
//
case "beans":
return beansDeserializer;
case "errorHandler":
case "org.apache.camel.model.ErrorHandlerDefinition":
return new ErrorHandlerDeserializer();
case "org.apache.camel.ErrorHandlerFactory":
return new ErrorHandlerBuilderDeserializer();
case "errorHandler":
// must be a global error handler
return new ErrorHandlerDeserializer(true);
case "org.apache.camel.model.ProcessorDefinition":
return new ProcessorDefinitionDeserializer();
case "kamelet":
Expand Down

This file was deleted.

Loading

0 comments on commit 07a96ad

Please sign in to comment.