Skip to content

Commit

Permalink
added default error handler and redelivery policy components
Browse files Browse the repository at this point in the history
  • Loading branch information
jorgecastro05 committed Sep 16, 2021
1 parent dff6042 commit 2e5fc79
Show file tree
Hide file tree
Showing 7 changed files with 37 additions and 5 deletions.
Binary file removed dist/camel-xml2dsl-0.0.13.tar.gz
Binary file not shown.
Binary file added dist/camel-xml2dsl-0.0.14.tar.gz
Binary file not shown.
Binary file removed dist/camel_xml2dsl-0.0.13-py3-none-any.whl
Binary file not shown.
Binary file added dist/camel_xml2dsl-0.0.14-py3-none-any.whl
Binary file not shown.
2 changes: 1 addition & 1 deletion setup.cfg
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[metadata]
name = camel-xml2dsl
version = 0.0.13
version = 0.0.14
author = Jorge Castro
author_email = jorgecastro05@hotmail.com
description = xml definition to dsl definition routes
Expand Down
2 changes: 1 addition & 1 deletion src/camel_xml2dsl.egg-info/PKG-INFO
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
Metadata-Version: 2.1
Name: camel-xml2dsl
Version: 0.0.13
Version: 0.0.14
Summary: xml definition to dsl definition routes
Home-page: https://github.com/jorgecastro05/script-aro.git
Author: Jorge Castro
Expand Down
38 changes: 35 additions & 3 deletions src/xml2dsl/xml2dsl.py
Original file line number Diff line number Diff line change
Expand Up @@ -89,6 +89,26 @@ def recipientList_def(self, node):
recipient_def += ".end() // end recipientList"
return recipient_def

def errorHandler_def(self, node):
if node.attrib['type'] == "DefaultErrorHandler":
return "\ndefaultErrorHandler().setRedeliveryPolicy(policy);"

def redeliveryPolicyProfile_def(self, node):
policy_def = "\nRedeliveryPolicy policy = new RedeliveryPolicy()"
if "maximumRedeliveries" in node.attrib:
policy_def += ".maximumRedeliveries("+ node.attrib["maximumRedeliveries"]+")"
if "retryAttemptedLogLevel" in node.attrib:
policy_def += ".retryAttemptedLogLevel(LoggingLevel." + node.attrib["retryAttemptedLogLevel"] +")"
if "redeliveryDelay" in node.attrib:
policy_def += ".redeliveryDelay("+ node.attrib["redeliveryDelay"] +")"
if "logRetryAttempted" in node.attrib:
policy_def += ".logRetryAttempted("+node.attrib["logRetryAttempted"] +")"
if "logRetryStackTrace" in node.attrib:
policy_def += ".logRetryStackTrace("+node.attrib["logRetryStackTrace"]+")"
policy_def += ";"
return policy_def


def onException_def(self, node):
exceptions = []
for exception in node.findall("camel:exception", ns):
Expand All @@ -113,6 +133,8 @@ def onException_def(self, node):
redeliveryPolicy.attrib['retriesExhaustedLogLevel'] + \
')' if 'retriesExhaustedLogLevel' in redeliveryPolicy.attrib else ""
node.remove(redeliveryPolicy)
if "redeliveryPolicyRef" in node.attrib:
onException_def += ".redeliveryPolicy(policy)"
onException_def += self.analyze_node(node)
onException_def += "\n.end();\n"
return onException_def
Expand All @@ -134,7 +156,7 @@ def log_def(self, node):
if 'loggingLevel' in node.attrib:
return '\n.log(LoggingLevel.' + node.attrib['loggingLevel'] + ', "' + node.attrib['message'] + '")'
else:
return '\n.log(' + node.attrib['message'] + '")'
return '\n.log("' + node.attrib['message'] + '")'

def choice_def(self, node):
choice_def = '\n.choice() //' + str(node.sourceline)
Expand All @@ -153,10 +175,14 @@ def otherwise_def(self, node):
return '\n.otherwise()' + self.analyze_node(node)

def simple_def(self, node):
simple_def = ""
if node.text is not None:
return 'simple("' + node.text + '")'
simple_def = 'simple("' + node.text + '")'
else:
return 'simple("")'
simple_def = 'simple("")'
if "resultType" in node.attrib:
simple_def += ".resultType("+ node.attrib["resultType"]+".class)"
return simple_def

def constant_def(self, node):
return 'constant("' + node.text + '")'
Expand Down Expand Up @@ -307,6 +333,12 @@ def threadPoolProfile_def(self, node):
profileDef += '\nprofile.setRejectedPolicy(ThreadPoolRejectedPolicy.Abort);'
return profileDef


# Text deprecated processor for camel deprecated endpoints and features
# TODO: code
def deprecatedProcessor(text):
return text

if __name__ == "__main__":
converter = Converter()
converter.xml_to_dsl()
Expand Down

0 comments on commit 2e5fc79

Please sign in to comment.