Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -106,8 +106,8 @@ public void setUriAsParameters(boolean uriAsParameters) {
}

public void startElement(String name) throws IOException {
if ("routes".equals(name) || "dataFormats".equals(name)) {
// special for routes or dataFormats
if ("routes".equals(name) || "rests".equals(name) || "routeConfigurations".equals(name)
|| "dataFormats".equals(name)) {
routesIsRoot = true;
return;
}
Expand Down Expand Up @@ -138,8 +138,8 @@ public void endExpressionElement(String name) throws IOException {
}

public void endElement(String name) throws IOException {
if ("routes".equals(name) || "dataFormats".equals(name)) {
// we are done
if ("routes".equals(name) || "rests".equals(name) || "routeConfigurations".equals(name)
|| "dataFormats".equals(name)) {
writer.write(toYaml());
return;
}
Expand Down Expand Up @@ -228,6 +228,10 @@ public void endElement(String name) throws IOException {
&& ("batchConfig".equals(name) || "streamConfig".equals(name))) {
// special for resequence
setMetadata(parent, "resequenceConfig", last);
} else if ("circuitBreaker".equals(parent.getName())
&& ("resilience4jConfiguration".equals(name)
|| "faultToleranceConfiguration".equals(name))) {
setMetadata(parent, name, last);
} else if (parent.isOutput()) {
List<EipModel> list = (List<EipModel>) parent.getMetadata().get("_output");
if (list == null) {
Expand Down Expand Up @@ -368,6 +372,21 @@ private void doAsNode(EipModel model, EipNode node) {
if (!jo.isEmpty()) {
node.addProperty(config.getName(), jo);
}
} else if ("circuitBreaker".equals(node.getName())
&& ("resilience4jConfiguration".equals(key)
|| "faultToleranceConfiguration".equals(key))) {
EipModel config = (EipModel) entry.getValue();
JsonObject jo = new JsonObject();
for (var o : config.getOptions()) {
String n = o.getName();
Object v = config.getMetadata().get(n);
if (v != null) {
jo.put(n, v);
}
}
if (!jo.isEmpty()) {
node.addProperty(config.getName(), jo);
}
} else if ("choice".equals(node.getName()) && "otherwise".equals(key)) {
EipModel other = (EipModel) entry.getValue();
node.addOutput(asNode(other));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@

import org.apache.camel.dsl.jbang.core.commands.CamelCommand;
import org.apache.camel.dsl.jbang.core.commands.CamelJBangMain;
import org.apache.camel.dsl.jbang.core.commands.MavenResolverMixin;
import org.apache.camel.dsl.jbang.core.commands.Run;
import org.apache.camel.dsl.jbang.core.common.CamelJBangConstants;
import org.apache.camel.dsl.jbang.core.common.CommandLineHelper;
Expand All @@ -41,6 +42,9 @@ public class YamlNormalizeCommand extends CamelCommand {

private static final String IGNORE_FILE = "application";

@CommandLine.Mixin
MavenResolverMixin mavenResolver;

@CommandLine.Option(names = { "--output" },
description = "File or directory to write normalized output. If not specified, output is printed to console.")
private String output;
Expand Down Expand Up @@ -86,6 +90,7 @@ protected void doAddInitialProperty(KameletMain main) {
main.addInitialProperty("camel.language.bean.validate", "false");
}
};
run.mavenResolver = mavenResolver;
run.files = matched;
run.executionLimitOptions.maxSeconds = 1;
Integer exit = run.runTransform(true);
Expand Down