arguments = method.getArguments();
-
- for (int i = 0; i < arguments.size(); i++) {
- Expression argument = arguments.get(i);
- if (argument instanceof J.Literal
- && ((J.Literal) argument).getType().getClassName().equals("java.lang.String")
- && findMethodPattern
- .matcher((String) (((J.Literal) method.getArguments().get(i)).getValue()))
- .find()) {
-
- String uriWithMethod = (String) (((J.Literal) method.getArguments().get(i)).getValue());
-
- String uriWithoutMethod = uriWithMethod.split("=")[0];
-
- String methodNameAndArgs = uriWithMethod.split("=")[1];
-
- //method without any args, we can simply return the mi in that case.
- if(!methodNameAndArgs.contains("(") && !methodNameAndArgs.contains(")")) {
- return mi;
- }
-
- String methodName = extractMethodName(methodNameAndArgs);
-
- String actualArgs = methodNameAndArgs.substring(
- methodNameAndArgs.indexOf("(") + 1,
- methodNameAndArgs.indexOf(")"));
-
- String updatedArg = uriWithoutMethod + "=" + methodName + "(" + updateMethodArgument(actualArgs)
- + ")";
-
- doAfterVisit(new ChangeLiteral<>(argument, p -> updatedArg));
-
- return mi;
-
- }
-
- }
-
- }
-
- return mi;
- }
-
- });
-
- }
-
- private String extractMethodName(String methodCallString) {
- // Regular expression to match the method call pattern
- Pattern pattern = Pattern.compile("^([a-zA-Z_$][a-zA-Z0-9_$]*)\\(.+\\)$");
- Matcher matcher = pattern.matcher(methodCallString);
-
- // Check if the string matches the method call pattern
- if (matcher.matches()) {
- // Extract the method name from the matched group
- String methodName = matcher.group(1);
- return methodName;
- } else {
- // Return null if the string doesn't match the method call pattern
- return null;
- }
- }
-
- private String updateMethodArgument(String argument) {
-
- Pattern identifierPattern = Pattern.compile("^[a-zA-Z_$][a-zA-Z0-9_$]*$");
- Pattern fullyQualifiedPattern = Pattern
- .compile("^([a-zA-Z_$][a-zA-Z0-9_$]*\\.)*[a-zA-Z_$][a-zA-Z0-9_$]*$");
-
- String updatedArgs = Arrays.asList(argument.split(",")).stream().map(arg -> {
- if (arg.endsWith(".class")) {
- return arg;
- }
-
- if (Arrays.asList(primitive).contains(arg.trim())) {
- return arg + ".class";
- }
-
- Matcher fullyQualifiedMatcher = fullyQualifiedPattern.matcher(arg);
- if (!fullyQualifiedMatcher.matches()) {
- return arg;
- }
-
- String[] parts = arg.split("\\.");
-
- for (String part : parts) {
- Matcher identifierMatcher = identifierPattern.matcher(part);
- if (!identifierMatcher.matches()) {
- return arg;
- }
- }
-
- return arg + ".class";
-
- }).collect(Collectors.joining(","));
-
- return updatedArgs;
-
- }
-
-}
diff --git a/recipes/src/main/java/io/quarkus/updates/camel/camel40/java/CamelEIPRecipe.java b/recipes/src/main/java/io/quarkus/updates/camel/camel40/java/CamelEIPRecipe.java
deleted file mode 100644
index a8b4bcce4a..0000000000
--- a/recipes/src/main/java/io/quarkus/updates/camel/camel40/java/CamelEIPRecipe.java
+++ /dev/null
@@ -1,44 +0,0 @@
-package io.quarkus.updates.camel.camel40.java;
-
-import io.quarkus.updates.camel.RecipesUtil;
-import org.openrewrite.ExecutionContext;
-import org.openrewrite.Recipe;
-import org.openrewrite.TreeVisitor;
-import org.openrewrite.java.AddImport;
-import org.openrewrite.java.tree.J;
-
-import io.quarkus.updates.camel.AbstractCamelQuarkusJavaVisitor;
-
-public class CamelEIPRecipe extends Recipe {
-
- @Override
- public String getDisplayName() {
- return "Replaces removed method camel EIP";
- }
-
- @Override
- public String getDescription() {
- return "The InOnly and InOut EIPs have been removed. Instead, use 'SetExchangePattern' or 'To' where you can specify the exchange pattern to use.";
- }
-
- @Override
- public TreeVisitor, ExecutionContext> getVisitor() {
- return RecipesUtil.newVisitor(new AbstractCamelQuarkusJavaVisitor() {
-
- @Override
- protected J.MethodInvocation doVisitMethodInvocation(J.MethodInvocation method, ExecutionContext context) {
- J.MethodInvocation mi = super.doVisitMethodInvocation(method, context);
-
- if (mi.getSimpleName().equals("inOut") || mi.getSimpleName().equals("inOnly")) {
- String name = mi.getSimpleName().substring(0, 1).toUpperCase() + mi.getSimpleName().substring(1);
- mi = mi.withName(mi.getName().withSimpleName("setExchangePattern(ExchangePattern."+name+").to"));
- doAfterVisit(new AddImport<>("org.apache.camel.ExchangePattern", null, false));
- }
- return mi;
- }
-
- });
-
- }
-
-}
diff --git a/recipes/src/main/java/io/quarkus/updates/camel/camel40/java/CamelHttpRecipe.java b/recipes/src/main/java/io/quarkus/updates/camel/camel40/java/CamelHttpRecipe.java
deleted file mode 100644
index 1a28471f3f..0000000000
--- a/recipes/src/main/java/io/quarkus/updates/camel/camel40/java/CamelHttpRecipe.java
+++ /dev/null
@@ -1,115 +0,0 @@
-package io.quarkus.updates.camel.camel40.java;
-
-import io.quarkus.updates.camel.RecipesUtil;
-import lombok.EqualsAndHashCode;
-import lombok.Value;
-
-import org.openrewrite.ExecutionContext;
-import org.openrewrite.Recipe;
-import org.openrewrite.TreeVisitor;
-import org.openrewrite.internal.lang.Nullable;
-import org.openrewrite.java.ChangeType;
-import org.openrewrite.java.JavaTemplate;
-import org.openrewrite.java.tree.J;
-
-import io.quarkus.updates.camel.AbstractCamelQuarkusJavaVisitor;
-
-@EqualsAndHashCode(callSuper = true)
-@Value
-public class CamelHttpRecipe extends Recipe {
-
- private static final String SET_CREDENTIALS = "org.apache.http.impl.client.BasicCredentialsProvider setCredentials(..)";
- private static final String SCOPE_ANY = "AuthScope.ANY";
-
- @Override
- public String getDisplayName() {
- return "Camel Http Extension changes";
- }
-
- @Override
- public String getDescription() {
- return "Camel Http Extension changes.";
- }
-
- @Override
- public TreeVisitor, ExecutionContext> getVisitor() {
-
-
- return RecipesUtil.newVisitor("org.apache.http..*", new AbstractCamelQuarkusJavaVisitor() {
- @Override
- protected J.Import doVisitImport(J.Import _import, ExecutionContext context) {
- doAfterVisit(
- new ChangeType("org.apache.http.HttpHost",
- "org.apache.hc.core5.http.HttpHost", true).getVisitor());
- doAfterVisit(
- new ChangeType(
- "org.apache.http.client.protocol.HttpClientContext",
- "org.apache.hc.client5.http.protocol.HttpClientContext", true).getVisitor());
- doAfterVisit(
- new ChangeType(
- "org.apache.http.protocol.HttpContext",
- "org.apache.hc.core5.http.protocol.HttpContext", true).getVisitor());
- doAfterVisit(
- new ChangeType(
- "org.apache.http.impl.auth.BasicScheme",
- "org.apache.hc.client5.http.impl.auth.BasicScheme", true).getVisitor());
- doAfterVisit(
- new ChangeType(
- "org.apache.http.impl.client.BasicAuthCache",
- "org.apache.hc.client5.http.impl.auth.BasicAuthCache", true).getVisitor());
- doAfterVisit(
- new ChangeType(
- "org.apache.http.impl.client.BasicCredentialsProvider",
- "org.apache.hc.client5.http.impl.auth.BasicCredentialsProvider", true).getVisitor());
- doAfterVisit(
- new ChangeType(
- "org.apache.http.auth.AuthScope",
- "org.apache.hc.client5.http.auth.AuthScope", true).getVisitor());
- doAfterVisit(
- new ChangeType(
- "org.apache.http.auth.UsernamePasswordCredentials",
- "org.apache.hc.client5.http.auth.UsernamePasswordCredentials", true).getVisitor());
- doAfterVisit(
- new ChangeType(
- "org.apache.http.conn.ssl.NoopHostnameVerifier",
- "org.apache.hc.client5.http.conn.ssl.NoopHostnameVerifier", true).getVisitor());
-
- return super.doVisitImport(_import, context);
- }
-
- @Override
- protected J.FieldAccess doVisitFieldAccess(J.FieldAccess fieldAccess, ExecutionContext context) {
- J.FieldAccess f = super.doVisitFieldAccess(fieldAccess, context);
-
- //The component has been upgraded to use Apache HttpComponents v5
- //AuthScope.ANY -> new AuthScope(null, -1)
- if("ANY".equals(f.getSimpleName()) && "org.apache.http.auth.AuthScope".equals(f.getType().toString())) {
- JavaTemplate.Builder templateBuilder = JavaTemplate.builder( "new AuthScope(null, -1)");
- J.NewClass nc = templateBuilder.build().apply(updateCursor(fieldAccess),
- f.getCoordinates().replace())
- .withPrefix(f.getPrefix()
- );
- getCursor().putMessage("authScopeNewClass", nc);
- }
- return f;
- }
-
-
- @Override
- public @Nullable J postVisit(J tree, ExecutionContext context) {
- J j = super.postVisit(tree, context);
-
- //use a new class instead of original element
- J.NewClass newClass = getCursor().getMessage("authScopeNewClass");
- if(newClass != null) {
- maybeAddImport("org.apache.hc.client5.http.auth.AuthScope", null, false);
- return newClass;
- }
-
- return j;
- }
-
- });
- }
-
-}
\ No newline at end of file
diff --git a/recipes/src/main/java/io/quarkus/updates/camel/camel40/xml/CircuitBreakerXmlDslRecipe.java b/recipes/src/main/java/io/quarkus/updates/camel/camel40/xml/CircuitBreakerXmlDslRecipe.java
deleted file mode 100644
index 21b904fe2b..0000000000
--- a/recipes/src/main/java/io/quarkus/updates/camel/camel40/xml/CircuitBreakerXmlDslRecipe.java
+++ /dev/null
@@ -1,127 +0,0 @@
-package io.quarkus.updates.camel.camel40.xml;
-
-import io.quarkus.updates.camel.AbstractCamelQuarkusXmlVisitor;
-import org.openrewrite.ExecutionContext;
-import org.openrewrite.Recipe;
-import org.openrewrite.Tree;
-import org.openrewrite.TreeVisitor;
-import org.openrewrite.internal.ListUtils;
-import org.openrewrite.marker.Markers;
-import org.openrewrite.xml.XPathMatcher;
-import org.openrewrite.xml.XmlIsoVisitor;
-import org.openrewrite.xml.tree.Xml;
-
-import java.util.LinkedHashMap;
-import java.util.List;
-import java.util.Map;
-import java.util.stream.Collectors;
-import java.util.stream.Stream;
-
-/**
- *
- * Camel Migration guide
- *
- * The following options in camel-resilience4j was mistakenly not defined as attributes:
- *
- * - bulkheadEnabled
- * - bulkheadMaxConcurrentCalls
- * - bulkheadMaxWaitDuration
- * - timeoutEnabled
- * - timeoutExecutorService
- * - timeoutDuration
- * - timeoutCancelRunningFuture
- *
- *
- * These options were not exposed in YAML DSL, and in XML DSL you need to migrate from:
- *
- *
- * <circuitBreaker>
- * <resilience4jConfiguration>
- * <timeoutEnabled>true</timeoutEnabled>
- * <timeoutDuration>2000</timeoutDuration>
- * </resilience4jConfiguration>
- * ...
- * </circuitBreaker>
- * </pre>
- *
- * To use attributes instead:
- *
- *
- * <circuitBreaker>
- * <resilience4jConfiguration timeoutEnabled="true" timeoutDuration="2000"/>
- * ...
- * </circuitBreaker>
- *
- */
-public class CircuitBreakerXmlDslRecipe extends Recipe {
-
- private final static String RESILIENCE4J_XPATH = "*/circuitBreaker/resilience4jConfiguration";
- private static final XPathMatcher RESILIENCE4J_MATCHER = new XPathMatcher(RESILIENCE4J_XPATH);
-
- private static final Map ATTRIBUTE_MATCHERS = Stream.of(
- "bulkheadEnabled",
- "bulkheadMaxConcurrentCalls",
- "bulkheadMaxWaitDuration",
- "timeoutEnabled",
- "timeoutExecutorService",
- "timeoutDuration",
- "timeoutCancelRunningFuture")
- .collect(Collectors.toMap(
- k -> k,
- k -> new XPathMatcher(RESILIENCE4J_XPATH + "/" + k),
- (v1, v2) -> v1 //conflict can not happen
- ));
-
- @Override
- public String getDisplayName() {
- return "Camel XMl DSL Circuit Breaker changes";
- }
-
- @Override
- public String getDescription() {
- return "Apache Camel XML DSL Circuit Breaker migration from version 3.20 or higher to 4.0.";
- }
-
- @Override
- public TreeVisitor, ExecutionContext> getVisitor() {
- return new AbstractCamelQuarkusXmlVisitor() {
-
- @Override
- public Xml.Tag doVisitTag(final Xml.Tag tag, final ExecutionContext ctx) {
- Xml.Tag t = super.doVisitTag(tag, ctx);
-
- if (RESILIENCE4J_MATCHER.matches(getCursor())) {
- Map values = ctx.pollMessage(RESILIENCE4J_XPATH);
-
- if (values != null && !values.isEmpty()) {
- //create list of values
- List toAdd = values.entrySet().stream()
- .map(e -> autoFormat(new Xml.Attribute(Tree.randomId(), "", Markers.EMPTY,
- new Xml.Ident(Tree.randomId(), "", Markers.EMPTY, e.getKey()),
- "",
- autoFormat(new Xml.Attribute.Value(Tree.randomId(), "", Markers.EMPTY,
- Xml.Attribute.Value.Quote.Double,
- e.getValue()), ctx)), ctx))
- .collect(Collectors.toList());
-
- return t.withAttributes(ListUtils.concatAll(t.getAttributes(), toAdd));
- }
- }
-
- for(Map.Entry entry : ATTRIBUTE_MATCHERS.entrySet()) {
- if (entry.getValue().matches(getCursor())) {
- if(t.getValue().isPresent() && !t.getValue().get().isEmpty()) {
- Map values = ctx.getMessage(RESILIENCE4J_XPATH, new LinkedHashMap<>());
- values.put(entry.getKey(), t.getValue().get());
- ctx.putMessage(RESILIENCE4J_XPATH, values);
- }
- //skip tag
- return null;
- }
- }
-
- return t;
- }
- };
- }
-}
diff --git a/recipes/src/main/java/io/quarkus/updates/camel/camel40/xml/XmlDslRecipe.java b/recipes/src/main/java/io/quarkus/updates/camel/camel40/xml/XmlDslRecipe.java
deleted file mode 100644
index a80e9b446f..0000000000
--- a/recipes/src/main/java/io/quarkus/updates/camel/camel40/xml/XmlDslRecipe.java
+++ /dev/null
@@ -1,83 +0,0 @@
-package io.quarkus.updates.camel.camel40.xml;
-
-import io.quarkus.updates.camel.AbstractCamelQuarkusXmlVisitor;
-import org.openrewrite.ExecutionContext;
-import org.openrewrite.Recipe;
-import org.openrewrite.Tree;
-import org.openrewrite.TreeVisitor;
-import org.openrewrite.internal.ListUtils;
-import org.openrewrite.marker.Markers;
-import org.openrewrite.xml.XPathMatcher;
-import org.openrewrite.xml.XmlIsoVisitor;
-import org.openrewrite.xml.tree.Xml;
-
-/**
- *
- * Camel Migration guide
- *
- * The to set a description on a route or node, has been changed from an element to an attribute.
- *
- * Before:
- *
- * <route id="myRoute">
- * <description>Something that this route do</description>
- * <from uri="kafka:cheese"/>
- * ...
- * </route>
- *
- * After:
- *
- * <route id="myRoute" description="Something that this route do">
- * <from uri="kafka:cheese"/>
- * ...
- * </route>
- *
- */
-public class XmlDslRecipe extends Recipe {
-
- private static final XPathMatcher ROUTE_DESCRIPTION_XPATH_MATCHER = new XPathMatcher("/routes/route/description");
- private static final XPathMatcher ROUTE_XPATH_MATCHER = new XPathMatcher("/routes/route");
-
- @Override
- public String getDisplayName() {
- return "Camel XMl DSL changes";
- }
-
- @Override
- public String getDescription() {
- return "Apache Camel XML DSL migration from version 3.20 or higher to 4.0.";
- }
-
- @Override
- public TreeVisitor, ExecutionContext> getVisitor() {
- return new AbstractCamelQuarkusXmlVisitor() {
-
- @Override
- public Xml.Tag doVisitTag(final Xml.Tag tag, final ExecutionContext ctx) {
- Xml.Tag t = super.doVisitTag(tag, ctx);
-
-
- if (ROUTE_XPATH_MATCHER.matches(getCursor())) {
- String d = ctx.pollMessage("description");
- if(d != null) {
- return t.withAttributes(ListUtils.concat(t.getAttributes(), autoFormat(new Xml.Attribute(Tree.randomId(), "", Markers.EMPTY,
- new Xml.Ident(Tree.randomId(), "", Markers.EMPTY, "description"),
- "",
- autoFormat(new Xml.Attribute.Value(Tree.randomId(), "", Markers.EMPTY,
- Xml.Attribute.Value.Quote.Double,
- d), ctx)), ctx)));
- }
- }
- if (ROUTE_DESCRIPTION_XPATH_MATCHER.matches(getCursor())) {
- //save description into context for parent
- t.getValue().ifPresent(s -> ctx.putMessage("description", s));
- //skip tag
- return null;
-
- }
-
- return t;
- }
- };
- }
-}
diff --git a/recipes/src/main/java/io/quarkus/updates/camel/camel40/yaml/CamelQuarkusYamlRouteConfigurationSequenceRecipe.java b/recipes/src/main/java/io/quarkus/updates/camel/camel40/yaml/CamelQuarkusYamlRouteConfigurationSequenceRecipe.java
deleted file mode 100644
index b3ad29d33d..0000000000
--- a/recipes/src/main/java/io/quarkus/updates/camel/camel40/yaml/CamelQuarkusYamlRouteConfigurationSequenceRecipe.java
+++ /dev/null
@@ -1,108 +0,0 @@
-package io.quarkus.updates.camel.camel40.yaml;
-
-import io.quarkus.updates.camel.AbstractCamelQuarkusYamlVisitor;
-import lombok.EqualsAndHashCode;
-import lombok.Value;
-import org.openrewrite.ExecutionContext;
-import org.openrewrite.Recipe;
-import org.openrewrite.TreeVisitor;
-import org.openrewrite.yaml.JsonPathMatcher;
-import org.openrewrite.yaml.format.IndentsVisitor;
-import org.openrewrite.yaml.style.IndentsStyle;
-import org.openrewrite.yaml.tree.Yaml;
-
-import java.util.ArrayList;
-import java.util.List;
-import java.util.stream.Collectors;
-
-import static org.openrewrite.Tree.randomId;
-
-/**
- * Camel API changes requires several changes in YAML route definition.
- * Route-configuration children sequence is replaced with mappingEntry (with special migration of "on-exception")
- */
-@EqualsAndHashCode(callSuper = true)
-@Value
-public class CamelQuarkusYamlRouteConfigurationSequenceRecipe extends Recipe {
-
- private static JsonPathMatcher MATCHER_ROUTE_CONFIGURATION = new JsonPathMatcher("$.route-configuration");
- private static JsonPathMatcher MATCHER_ROUTE_CONFIGURATION_ON_EXCEPTION = new JsonPathMatcher("$.route-configuration.on-exception");
-
- @Override
- public String getDisplayName() {
- return "Camel Yaml changes regarding route-configuration children";
- }
-
- @Override
- public String getDescription() {
- return "Camel YAML changes. route-configuration children sequence is replaced with mappingEntry (with special migration of \"on-exception\").";
- }
-
- @Override
- public TreeVisitor, ExecutionContext> getVisitor() {
-
- return new AbstractCamelQuarkusYamlVisitor() {
-
- private Yaml.Sequence sequenceToReplace;
- private boolean indentRegistered = false;
-
- @Override
- protected void clearLocalCache() {
- sequenceToReplace = null;
- }
-
- @Override
- public Yaml.Sequence doVisitSequence(Yaml.Sequence sequence, ExecutionContext context) {
- Yaml.Sequence s = super.doVisitSequence(sequence, context);
-
- //if there is a sequence in a route-configuration, it has to be replaced with mapping
- if (new JsonPathMatcher("$.route-configuration").matches(getCursor().getParent())) {
- this.sequenceToReplace = s;
- }
- return s;
- }
-
- @Override
- public Yaml.Mapping.Entry doVisitMappingEntry(Yaml.Mapping.Entry entry, ExecutionContext context) {
- Yaml.Mapping.Entry e = super.doVisitMappingEntry(entry, context);
-
- //if current mapping contains an entry with sequence belonging to route-configuration, remove the sequence
- if (e.getValue() == sequenceToReplace) {
- List entries = new ArrayList<>();
- for (Yaml.Sequence.Entry sEntry : sequenceToReplace.getEntries()) {
-
- if (sEntry.getBlock() instanceof Yaml.Mapping) {
- ((Yaml.Mapping) sEntry.getBlock()).getEntries().forEach(y -> {
- //if entry is on-exception from the route-configuration sequence, it has to be handled differently
- if ("on-exception".equals(y.getKey().getValue())) {
- Yaml.Sequence newSequence = sequenceToReplace.copyPaste();
- //keep only on-exception item
- List filteredEntries = newSequence.getEntries().stream()
- .filter(se -> ((Yaml.Mapping) se.getBlock()).getEntries().stream()
- .filter(me -> "on-exception".equals(me.getKey().getValue())).findFirst().isPresent())
- .collect(Collectors.toList());
-
- entries.add(y.withValue(newSequence.withEntries(filteredEntries)).withPrefix("\n"));
- } else {
- entries.add(y.withPrefix("\n"));
- }
- });
- }
- }
- Yaml.Mapping.Entry resultr = e.withValue(new Yaml.Mapping(randomId(), sequenceToReplace.getMarkers(), sequenceToReplace.getOpeningBracketPrefix(), entries, null, null));
-
- if(!indentRegistered) {
- indentRegistered = true;
- //TODO might probably change indent in original file, may this happen?
- doAfterVisit(new IndentsVisitor(new IndentsStyle(2), null));
- }
-
- return resultr;
- }
- return e;
- }
- };
- }
-
-}
-
diff --git a/recipes/src/main/java/io/quarkus/updates/camel/camel40/yaml/CamelQuarkusYamlStepsInFromRecipe.java b/recipes/src/main/java/io/quarkus/updates/camel/camel40/yaml/CamelQuarkusYamlStepsInFromRecipe.java
deleted file mode 100644
index 261ee4f0eb..0000000000
--- a/recipes/src/main/java/io/quarkus/updates/camel/camel40/yaml/CamelQuarkusYamlStepsInFromRecipe.java
+++ /dev/null
@@ -1,128 +0,0 @@
-package io.quarkus.updates.camel.camel40.yaml;
-
-import io.quarkus.updates.camel.AbstractCamelQuarkusYamlVisitor;
-import io.quarkus.updates.camel.RecipesUtil;
-import lombok.EqualsAndHashCode;
-import lombok.Value;
-import org.openrewrite.ExecutionContext;
-import org.openrewrite.Recipe;
-import org.openrewrite.TreeVisitor;
-import org.openrewrite.yaml.JsonPathMatcher;
-import org.openrewrite.yaml.YamlIsoVisitor;
-import org.openrewrite.yaml.format.IndentsVisitor;
-import org.openrewrite.yaml.style.IndentsStyle;
-import org.openrewrite.yaml.tree.Yaml;
-
-import java.util.ArrayList;
-import java.util.List;
-
-/**
- * Fixes following yaml change.
- *
- * The backwards compatible mode Camel 3.14 or older, which allowed to have steps as child to route has been removed.
- *
- * The old syntax:
- *
- *
- * - route:
- * from:
- * uri: "direct:info"
- * steps:
- * - log: "message"
- *
- * should be changed to:
- *
- * - route:
- * from:
- * uri: "direct:info"
- * steps:
- * - log: "message"
- *
- */
-@EqualsAndHashCode(callSuper = true)
-@Value
-public class CamelQuarkusYamlStepsInFromRecipe extends Recipe {
-
- private static String[] PATHS_TO_PRE_CHECK = new String[] {"route.from"};
- private static JsonPathMatcher MATCHER_WITHOUT_ROUTE = new JsonPathMatcher("$.steps");
- private static JsonPathMatcher MATCHER_WITH_ROUTE = new JsonPathMatcher("$.route.steps");
-
-
- @Override
- public String getDisplayName() {
- return "Camel Yaml steps not allowed as route child";
- }
-
- @Override
- public String getDescription() {
- return "The YAML DSL backwards compatible mode in Camel 3.14 or older, which allowed 'steps' to be defined as a child of 'route' has been removed.";
- }
-
-
- @Override
- public TreeVisitor, ExecutionContext> getVisitor() {
-
- return new AbstractCamelQuarkusYamlVisitor() {
- //both variables has to be set to null, to mark the migration done
- Yaml.Mapping from = null;
- Yaml.Mapping.Entry steps = null;
-
- @Override
- protected void clearLocalCache() {
- //do nothing
- }
-
- @Override
- public Yaml.Mapping.Entry doVisitMappingEntry(Yaml.Mapping.Entry entry, ExecutionContext context) {
- Yaml.Mapping.Entry e = super.doVisitMappingEntry(entry, context);
-
- if(steps == null && (MATCHER_WITH_ROUTE.matches(getCursor()) || MATCHER_WITHOUT_ROUTE.matches(getCursor()))) {
- steps = e;
- if(from != null) {
- moveSteps();
- }
- return null;
- }
- return e;
-
- }
-
- @Override
- public Yaml.Mapping doVisitMapping(Yaml.Mapping mapping, ExecutionContext context) {
- Yaml.Mapping m = super.doVisitMapping(mapping, context);
-
- String prop = RecipesUtil.getProperty(getCursor());
- if(("route.from".equals(prop) || "from".equals(prop)) && from == null) {
- from = m;
- if(steps != null) {
- moveSteps();
- }
- }
-
- return m;
- }
-
- private void moveSteps() {
- doAfterVisit(new YamlIsoVisitor() {
-
- @Override
- public Yaml.Mapping visitMapping(Yaml.Mapping mapping, ExecutionContext c) {
- Yaml.Mapping m = super.visitMapping(mapping, c);
-
- if(m == from) {
- List entries = new ArrayList<>(m.getEntries());
- entries.add(steps.copyPaste().withPrefix("\n"));
- m = m.withEntries(entries);
- }
-
- return m;
- }});
-
- //TODO might probably change indent in original file, may this happen?
- doAfterVisit(new IndentsVisitor(new IndentsStyle(2), null));
- }
- };
- }
-
-}
-
diff --git a/recipes/src/main/java/io/quarkus/updates/camel/camel41/CamelCoreRecipe.java b/recipes/src/main/java/io/quarkus/updates/camel/camel41/CamelCoreRecipe.java
deleted file mode 100644
index 39829c75be..0000000000
--- a/recipes/src/main/java/io/quarkus/updates/camel/camel41/CamelCoreRecipe.java
+++ /dev/null
@@ -1,58 +0,0 @@
-package io.quarkus.updates.camel.camel41;
-
-import io.quarkus.updates.camel.AbstractCamelQuarkusJavaVisitor;
-import io.quarkus.updates.camel.RecipesUtil;
-import lombok.EqualsAndHashCode;
-import lombok.Value;
-import org.openrewrite.ExecutionContext;
-import org.openrewrite.Recipe;
-import org.openrewrite.TreeVisitor;
-import org.openrewrite.java.tree.Expression;
-import org.openrewrite.java.tree.J;
-import org.openrewrite.java.tree.JavaType;
-
-import java.util.regex.Pattern;
-
-/**
- * Recipe migrating changes between Camel 4.3 to 4.4, for more details see the
- * documentation.
- */
-@EqualsAndHashCode(callSuper = true)
-@Value
-public class CamelCoreRecipe extends Recipe {
-
- private static final String M_TO = "org.apache.camel.model.ProcessorDefinition to(..)";
- private static final String M_FROM = "org.apache.camel.model.ProcessorDefinition from(..)";
- private static final String AWS2_URL_WITH_QUEUE_REGEXP = "(aws2-sns://[a-zA-z]+?.*)queueUrl=https://(.+)";
- private static final Pattern AWS2_URL_WITH_QUEUE_URL = Pattern.compile(AWS2_URL_WITH_QUEUE_REGEXP);
-
- @Override
- public String getDisplayName() {
- return "Camel Core changes";
- }
-
- @Override
- public String getDescription() {
- return "Apache Camel Core migration from version 4.0 to 4.1.";
- }
-
-
- @Override
- public TreeVisitor, ExecutionContext> getVisitor() {
-
- return RecipesUtil.newVisitor(new AbstractCamelQuarkusJavaVisitor() {
- @Override
- public J.Literal visitLiteral(J.Literal literal, ExecutionContext context) {
- J.Literal l = super.visitLiteral(literal, context);
-
- //is it possible to precondition that aws2 is present?
- if(JavaType.Primitive.String.equals(l.getType()) && AWS2_URL_WITH_QUEUE_URL.matcher((String)l.getValue()).matches()) {
- String newUrl = ((String) l.getValue()).replaceFirst(AWS2_URL_WITH_QUEUE_REGEXP, "$1queueArn=arn:aws:sqs:$2");
- l = RecipesUtil.createStringLiteral(newUrl);
- }
-
- return l;
- }
- });
- }
-}
\ No newline at end of file
diff --git a/recipes/src/main/java/io/quarkus/updates/camel/camel41/XmlDslRecipe.java b/recipes/src/main/java/io/quarkus/updates/camel/camel41/XmlDslRecipe.java
deleted file mode 100644
index d5f79c24f4..0000000000
--- a/recipes/src/main/java/io/quarkus/updates/camel/camel41/XmlDslRecipe.java
+++ /dev/null
@@ -1,90 +0,0 @@
-package io.quarkus.updates.camel.camel41;
-
-import io.quarkus.updates.camel.AbstractCamelQuarkusXmlVisitor;
-import org.openrewrite.ExecutionContext;
-import org.openrewrite.Recipe;
-import org.openrewrite.Tree;
-import org.openrewrite.TreeVisitor;
-import org.openrewrite.internal.ListUtils;
-import org.openrewrite.marker.Markers;
-import org.openrewrite.xml.XPathMatcher;
-import org.openrewrite.xml.XmlIsoVisitor;
-import org.openrewrite.xml.tree.Xml;
-
-import java.util.ArrayList;
-import java.util.List;
-import java.util.Optional;
-import java.util.stream.Collectors;
-
-/**
- *
- * Camel Migration guide
- *
- *
- * Before:
- *
- * <bean name="myBean" type="groovy" beanType="com.foo.MyBean">
- * <script>
- * <!-- groovy code here to create the bean -->
- * </script>
- * </bean>
- *
- * After:
- *
- * <bean name="myBean" type="com.foo.MyBean"
- * scriptLanguage="groovy">
- * <script>
- * <!-- groovy code here to create the bean -->
- * </script>
- * </bean>
- *
- */
-public class XmlDslRecipe extends Recipe {
-
- private static final XPathMatcher XML_BEAN_MATCHER = new XPathMatcher("*/bean");
-
- @Override
- public String getDisplayName() {
- return "Camel XMl DSL changes";
- }
-
- @Override
- public String getDescription() {
- return "Apache Camel XML DSL migration from version 4.0 to 4.1.";
- }
-
- @Override
- public TreeVisitor, ExecutionContext> getVisitor() {
- return new AbstractCamelQuarkusXmlVisitor() {
-
- @Override
- public Xml.Tag doVisitTag(final Xml.Tag tag, final ExecutionContext ctx) {
- Xml.Tag t = super.doVisitTag(tag, ctx);
-
- if (XML_BEAN_MATCHER.matches(getCursor()) && t.getChild("script").isPresent()) {
- //type ans beanType has to be present in the attributes
- //and their values has to be gathered
- Optional typeAttr = t.getAttributes().stream().filter(a -> "type".equals(a.getKeyAsString())).findAny();
- Optional beanTypeAttr = t.getAttributes().stream().filter(a -> "beanType".equals(a.getKeyAsString())).findAny();
- //if values are not empty, migrate tag
- if(typeAttr.isPresent() && !typeAttr.get().getValueAsString().isEmpty() && beanTypeAttr.isPresent() && !beanTypeAttr.get().getValueAsString().isEmpty()) {
- // gather attributes
- List attrs = new ArrayList<>(t.getAttributes());
- attrs.remove(typeAttr.get());
- attrs.remove(beanTypeAttr.get());
-
- //migrate values
- Xml.Attribute.Value tmp = typeAttr.get().getValue();
- attrs.add(typeAttr.get().withValue(beanTypeAttr.get().getValue()));
- attrs.add(beanTypeAttr.get().withKey(new Xml.Ident(Tree.randomId(), "", Markers.EMPTY, "scriptLanguage")).withValue(tmp));
-
- t = t.withAttributes(attrs);
- }
-
- }
-
- return t;
- }
- };
- }
-}
diff --git a/recipes/src/main/java/io/quarkus/updates/camel/camel41/YamlDslRecipe.java b/recipes/src/main/java/io/quarkus/updates/camel/camel41/YamlDslRecipe.java
deleted file mode 100644
index d344348ab1..0000000000
--- a/recipes/src/main/java/io/quarkus/updates/camel/camel41/YamlDslRecipe.java
+++ /dev/null
@@ -1,104 +0,0 @@
-package io.quarkus.updates.camel.camel41;
-
-import io.quarkus.updates.camel.AbstractCamelQuarkusYamlVisitor;
-import lombok.EqualsAndHashCode;
-import lombok.Value;
-import org.openrewrite.Cursor;
-import org.openrewrite.ExecutionContext;
-import org.openrewrite.Recipe;
-import org.openrewrite.TreeVisitor;
-import org.openrewrite.yaml.JsonPathMatcher;
-import org.openrewrite.yaml.tree.Yaml;
-
-import java.util.List;
-import java.util.Optional;
-
-/**
- * Fixes following yaml change.
- *
- * When creating beans from an inlined script.
- * The name of the script was defined in type, but has been changed to a new scriptLanguage attribute.
- * And beanType has been removed as you must use type instead.
- *
- * The old syntax:
- *
- *
- * - beans:
- * - name: "myClient"
- * beanType: "com.foo.MyBean"
- * type: "groovy"
- * script: |
- * # groovy script here
- *
- * should be changed to:
- *
- * - beans:
- * - name: "myClient"
- * type: "com.foo.MyBean"
- * scriptLanguage: "groovy"
- * script: |
- * # groovy script here
- *
- */
-@EqualsAndHashCode(callSuper = true)
-@Value
-public class YamlDslRecipe extends Recipe {
-
- private static JsonPathMatcher MATCHER_WITHOUT_ROUTE = new JsonPathMatcher("$.beans");
-
- @Override
- public String getDisplayName() {
- return "Changes for creation of inlined beans.";
- }
-
- @Override
- public String getDescription() {
- return "If inlined bean is created, parameters `type` and `beanType` has bean changed.";
- }
-
- @Override
- public TreeVisitor, ExecutionContext> getVisitor() {
-
- return new AbstractCamelQuarkusYamlVisitor() {
-
- @Override
- protected void clearLocalCache() {
- //nothing to do
- }
-
- @Override
- public Yaml.Mapping.Entry doVisitMappingEntry(Yaml.Mapping.Entry entry, ExecutionContext ctx) {
- Yaml.Mapping.Entry e = super.doVisitMappingEntry(entry, ctx);
-
- //getCursor().getParent() is mapping with 4 entries -> I can check the siblings
- //parent(4) is beans
- Cursor parent4 = getCursor().getParent(4);
- //check that this mapping entry is currently under "beans" sequence
- //parent(2) has to be mapping (represents the bean)
- if (parent4 != null && parent4.getParent() != null && MATCHER_WITHOUT_ROUTE.matches(parent4) && getCursor().getParent().getValue() instanceof Yaml.Mapping) {
- //get entries
- Yaml.Mapping m = getCursor().getParent().getValue();
- List entries = m.getEntries();
- Optional typeEntry = entries.stream().filter(me -> "type".equals(me.getKey().getValue())).findAny();
- Optional beanTypeEntry = entries.stream().filter(me -> "beanType".equals(me.getKey().getValue())).findAny();
-
- if (typeEntry.isPresent() && typeEntry.get().getValue() instanceof Yaml.Scalar && !((Yaml.Scalar) typeEntry.get().getValue()).getValue().isEmpty()
- && beanTypeEntry.isPresent() && beanTypeEntry.get().getValue() instanceof Yaml.Scalar && !((Yaml.Scalar) beanTypeEntry.get().getValue()).getValue().isEmpty()) {
-
- //modify the current entry
- if ("type".equals(e.getKey().getValue())) {
- return e.withKey(((Yaml.Scalar) entry.getKey().copyPaste()).withValue("scriptLanguage"));
- }
- if ("beanType".equals(e.getKey().getValue())) {
- return e.withKey(((Yaml.Scalar) entry.getKey().copyPaste()).withValue("type"));
- }
- }
- }
-
- return e;
- }
- };
- }
-
-}
-
diff --git a/recipes/src/main/java/io/quarkus/updates/camel/camel42/CamelSagaRecipe.java b/recipes/src/main/java/io/quarkus/updates/camel/camel42/CamelSagaRecipe.java
deleted file mode 100644
index 4ff1bb0885..0000000000
--- a/recipes/src/main/java/io/quarkus/updates/camel/camel42/CamelSagaRecipe.java
+++ /dev/null
@@ -1,62 +0,0 @@
-package io.quarkus.updates.camel.camel42;
-
-import io.quarkus.updates.camel.AbstractCamelQuarkusJavaVisitor;
-import io.quarkus.updates.camel.RecipesUtil;
-import lombok.EqualsAndHashCode;
-import lombok.Value;
-import org.openrewrite.ExecutionContext;
-import org.openrewrite.Recipe;
-import org.openrewrite.TreeVisitor;
-import org.openrewrite.java.tree.Expression;
-import org.openrewrite.java.tree.J;
-import org.openrewrite.java.tree.JavaType;
-import org.openrewrite.java.tree.Space;
-
-import java.util.Collections;
-import java.util.regex.Pattern;
-
-/**
- * Recipe migrating changes between Camel 4.3 to 4.4, for more details see the
- * documentation.
- */
-@EqualsAndHashCode(callSuper = true)
-@Value
-public class CamelSagaRecipe extends Recipe {
-
- private static final String M_NEW_SAGA = "org.apache.camel.saga.InMemorySagaService newSaga()";
- private static final String M_SAGA_COORDINATOR_COMPENSATE = "org.apache.camel.saga.CamelSagaCoordinator compensate()";
- private static final String M_SAGA_COORDINATOR_COMPLETE = "org.apache.camel.saga.CamelSagaCoordinator complete()";
-
- @Override
- public String getDisplayName() {
- return "Camel Core changes";
- }
-
- @Override
- public String getDescription() {
- return "Apache Camel Core migration from version 4.0 to 4.1.";
- }
-
-
- @Override
- public TreeVisitor, ExecutionContext> getVisitor() {
-
- return RecipesUtil.newVisitor(new AbstractCamelQuarkusJavaVisitor() {
- @Override
- protected J.MethodInvocation doVisitMethodInvocation(J.MethodInvocation method, ExecutionContext context) {
- J.MethodInvocation mi = super.doVisitMethodInvocation(method, context);
-
- if ((getMethodMatcher(M_NEW_SAGA).matches(mi, false)
- || getMethodMatcher(M_SAGA_COORDINATOR_COMPENSATE).matches(mi, false)
- || getMethodMatcher(M_SAGA_COORDINATOR_COMPLETE).matches(mi, false))
- && RecipesUtil.methodInvocationAreArgumentEmpty(mi)) {
- J.Identifier type = RecipesUtil.createIdentifier(Space.EMPTY, "Exchange", "import org.apache.camel.Exchange");
- J.TypeCast cp = (J.TypeCast) RecipesUtil.createTypeCast(type, RecipesUtil.createNullExpression());
- mi = mi.withArguments(Collections.singletonList(cp.withComments(Collections.singletonList(RecipesUtil.createMultinlineComment("Exchange parameter was added.")))));
- }
-
- return mi;
- }
- });
- }
-}
\ No newline at end of file
diff --git a/recipes/src/main/java/io/quarkus/updates/camel/camel43/CamelResequenceEIPXmlRecipe.java b/recipes/src/main/java/io/quarkus/updates/camel/camel43/CamelResequenceEIPXmlRecipe.java
deleted file mode 100644
index de69e53722..0000000000
--- a/recipes/src/main/java/io/quarkus/updates/camel/camel43/CamelResequenceEIPXmlRecipe.java
+++ /dev/null
@@ -1,69 +0,0 @@
-package io.quarkus.updates.camel.camel43;
-
-import org.openrewrite.ExecutionContext;
-import org.openrewrite.Recipe;
-import org.openrewrite.TreeVisitor;
-import org.openrewrite.xml.XPathMatcher;
-import org.openrewrite.xml.XmlIsoVisitor;
-import org.openrewrite.xml.tree.Xml;
-
-/**
- * The configuration for batch and stream has been renamed from batch-config to batchConfig and stream-config to streamConfig.
- *
- * For example before:
- *
- * <resequence>
- * <stream-config timeout="1000" deliveryAttemptInterval="10"/>
- * <simple>${header.seqnum}</simple>
- * <to uri="mock:result" />
- * </resequence>
- *
- *
- *
- * And now after:
- *
- * <resequence>
- * <streamConfig timeout="1000" deliveryAttemptInterval="10"/>
- * <simple>${header.seqnum}</simple>
- * <to uri="mock:result" />
- * </resequence>
- *
- *
- *
- * See the documentation
- */
-public class CamelResequenceEIPXmlRecipe extends Recipe {
-
- private static final XPathMatcher XML_RESEQUENCE_STREAM_CONFIG_MATCHER = new XPathMatcher("*/route/resequence/stream-config");
- private static final XPathMatcher XML_RESEQUENCE_BATCH_CONFIG_MATCHER = new XPathMatcher("*/route/resequence/batch-config");
-
- @Override
- public String getDisplayName() {
- return "Camel Resequence DSL changes";
- }
-
- @Override
- public String getDescription() {
- return "Batch and stream attributes were renamed in Resequence EIP XML DSL.";
- }
-
- @Override
- public TreeVisitor, ExecutionContext> getVisitor() {
- return new XmlIsoVisitor<>() {
-
- @Override
- public Xml.Tag visitTag(final Xml.Tag tag, final ExecutionContext ctx) {
- Xml.Tag t = super.visitTag(tag, ctx);
-
- if (XML_RESEQUENCE_STREAM_CONFIG_MATCHER.matches(getCursor()) ) {
- t = t.withName("streamConfig");
- }
- else if (XML_RESEQUENCE_BATCH_CONFIG_MATCHER.matches(getCursor()) ) {
- t = t.withName("batchConfig");
- }
-
- return t;
- }
- };
- }
-}
diff --git a/recipes/src/main/java/io/quarkus/updates/camel/camel43/CamelThrottleEIPRecipe.java b/recipes/src/main/java/io/quarkus/updates/camel/camel43/CamelThrottleEIPRecipe.java
deleted file mode 100644
index 549f133fcb..0000000000
--- a/recipes/src/main/java/io/quarkus/updates/camel/camel43/CamelThrottleEIPRecipe.java
+++ /dev/null
@@ -1,63 +0,0 @@
-package io.quarkus.updates.camel.camel43;
-
-import io.quarkus.updates.camel.AbstractCamelQuarkusJavaVisitor;
-import io.quarkus.updates.camel.RecipesUtil;
-import lombok.EqualsAndHashCode;
-import lombok.Value;
-import org.openrewrite.ExecutionContext;
-import org.openrewrite.Recipe;
-import org.openrewrite.TreeVisitor;
-import org.openrewrite.java.tree.J;
-import org.openrewrite.java.tree.Space;
-
-import java.util.Collections;
-
-/**
- * Recipe migrating changes between Camel 4.3 to 4.4, for more details see the
- * documentation.
- */
-@EqualsAndHashCode(callSuper = true)
-@Value
-public class CamelThrottleEIPRecipe extends Recipe {
-
- private static final String M_THROTTLE_PRIMITIVE = "org.apache.camel.model.ProcessorDefinition throttle(long)";
- private static final String M_THROTTLE_TIME_PERIOD_MILLIS_PRIMITIVE = "org.apache.camel.model.ThrottleDefinition timePeriodMillis(long)";
- private static String WARNING_COMMENT = " Throttle now uses the number of concurrent requests as the throttling measure instead of the number of requests per period.";
-
- @Override
- public String getDisplayName() {
- return "Camel Core changes";
- }
-
- @Override
- public String getDescription() {
- return "Apache Camel Core migration from version 4.0 to 4.1.";
- }
-
-
- @Override
- public TreeVisitor, ExecutionContext> getVisitor() {
-
- return RecipesUtil.newVisitor(new AbstractCamelQuarkusJavaVisitor() {
- @Override
- protected J.MethodInvocation doVisitMethodInvocation(J.MethodInvocation method, ExecutionContext context) {
- J.MethodInvocation mi = super.doVisitMethodInvocation(method, context);
-
- if (getMethodMatcher(M_THROTTLE_PRIMITIVE).matches(mi, false)
- && !RecipesUtil.isCommentBeforeElement(mi, WARNING_COMMENT)) {
- mi = mi.withComments(Collections.singletonList(RecipesUtil.createMultinlineComment(WARNING_COMMENT)));
- getCursor().putMessage("throttle-migrated", true);
- }
- else if (getMethodMatcher(M_THROTTLE_TIME_PERIOD_MILLIS_PRIMITIVE).matches(mi, false)) {
- if(mi.getSelect() instanceof J.MethodInvocation) {
- return (J.MethodInvocation)mi.getSelect();
- } else {
- return null;
- }
- }
-
- return mi;
- }
- });
- }
-}
\ No newline at end of file
diff --git a/recipes/src/main/java/io/quarkus/updates/camel/camel44/CamelCoreRecipe.java b/recipes/src/main/java/io/quarkus/updates/camel/camel44/CamelCoreRecipe.java
deleted file mode 100644
index fe3c21abc3..0000000000
--- a/recipes/src/main/java/io/quarkus/updates/camel/camel44/CamelCoreRecipe.java
+++ /dev/null
@@ -1,111 +0,0 @@
-package io.quarkus.updates.camel.camel44;
-
-import io.quarkus.updates.camel.AbstractCamelQuarkusJavaVisitor;
-import io.quarkus.updates.camel.RecipesUtil;
-import lombok.EqualsAndHashCode;
-import lombok.Value;
-import org.openrewrite.ExecutionContext;
-import org.openrewrite.Recipe;
-import org.openrewrite.TreeVisitor;
-import org.openrewrite.java.tree.Expression;
-import org.openrewrite.java.tree.J;
-import org.openrewrite.java.tree.Space;
-
-import java.util.ArrayList;
-import java.util.Collections;
-import java.util.List;
-
-/**
- * Recipe migrating changes between Camel 4.3 to 4.4, for more details see the
- * documentation.
- */
-@EqualsAndHashCode(callSuper = true)
-@Value
-public class CamelCoreRecipe extends Recipe {
-
- private static final String M_EXCHANGE_GET_CREATED = "org.apache.camel.Exchange getCreated()";
- private static final String M_PROPERTIES_LOOKUP_LOOKUP = "org.apache.camel.component.properties.PropertiesLookup lookup(java.lang.String)";
- private static final String M_EXPRESSION_CAUSE_JSONPATH1 = "org.apache.camel.builder.ExpressionClause jsonpath(java.lang.String, boolean, java.lang.Class, java.lang.String)";
- private static final String M_EXPRESSION_CAUSE_JSONPATH2 = "org.apache.camel.builder.ExpressionClause jsonpathWriteAsString(java.lang.String, boolean, java.lang.String)";
- private static final String M_EXPRESSION_CAUSE_XPATH1 = "org.apache.camel.builder.ExpressionClause xpath(java.lang.String, java.lang.String)";
- private static final String M_EXPRESSION_CAUSE_XPATH2 = "org.apache.camel.builder.ExpressionClause xpath(java.lang.String, java.lang.Class, java.lang.String)";
- private static final String M_EXPRESSION_CAUSE_XPATH3 = "org.apache.camel.builder.ExpressionClause xpath(java.lang.String, java.lang.Class, org.apache.camel.support.builder.Namespaces, java.lang.String)";
- private static final String M_EXPRESSION_CAUSE_TOKENIZE1 = "org.apache.camel.builder.ExpressionClause tokenize(java.lang.String, boolean, int, java.lang.String, boolean)";
- private static final String M_EXPRESSION_CAUSE_TOKENIZE2 = "org.apache.camel.builder.ExpressionClause tokenize(java.lang.String, java.lang.String)";
- private static final String M_EXPRESSION_CAUSE_TOKENIZE3 = "org.apache.camel.builder.ExpressionClause tokenize(java.lang.String, java.lang.String, boolean)";
- private static final String M_EXPRESSION_CAUSE_XQUERY1 = "org.apache.camel.builder.ExpressionClause xquery(java.lang.String, java.lang.String)";
- private static final String M_EXPRESSION_CAUSE_XQUERY2 = "org.apache.camel.builder.ExpressionClause xquery(java.lang.String, java.lang.Class, java.lang.String)";
- private static final String M_EXPRESSION_CAUSE_XQUERY3 = "org.apache.camel.builder.ExpressionClause xquery(java.lang.String, java.lang.Class, boolean, java.lang.String)";
- private static final String CONST_STOP_WATCH_LONG01 = "org.apache.camel.util.StopWatch (long)";
- private static final String CONST_STOP_WATCH_LONG02 = "org.apache.camel.util.StopWatch (java.lang.Long)";
-
- @Override
- public String getDisplayName() {
- return "Camel Core changes";
- }
-
- @Override
- public String getDescription() {
- return "Apache Camel Core migration from version 4.3 to 4.4.";
- }
-
- @Override
- public TreeVisitor, ExecutionContext> getVisitor() {
-
- return RecipesUtil.newVisitor(new AbstractCamelQuarkusJavaVisitor() {
-
- @Override
- protected J.MethodInvocation doVisitMethodInvocation(J.MethodInvocation method, ExecutionContext context) {
- J.MethodInvocation mi = super.doVisitMethodInvocation(method, context);
-
- if (getMethodMatcher(M_EXCHANGE_GET_CREATED).matches(mi, false)) {
- //add call to getClock before call of getCreated
- mi = mi.withName(mi.getName().withSimpleName("getClock().getCreated"));
- }
- else if (getMethodMatcher(M_PROPERTIES_LOOKUP_LOOKUP).matches(mi, false)
- && mi.getArguments().size() == 1) { //without the condition, the recipes is applied again
- //add default value null
- List arguments = new ArrayList<>(mi.getArguments());
- arguments.add(RecipesUtil.createNullExpression());
- mi = mi.withArguments(arguments);
- }
- else if(getMethodMatcher(M_EXPRESSION_CAUSE_JSONPATH1).matches(mi,false) ||
- getMethodMatcher(M_EXPRESSION_CAUSE_JSONPATH2).matches(mi,false) ||
- getMethodMatcher(M_EXPRESSION_CAUSE_TOKENIZE1).matches(mi,false) ||
- getMethodMatcher(M_EXPRESSION_CAUSE_TOKENIZE2).matches(mi,false) ||
- getMethodMatcher(M_EXPRESSION_CAUSE_TOKENIZE3).matches(mi,false) ||
- getMethodMatcher(M_EXPRESSION_CAUSE_XPATH1).matches(mi,false) ||
- getMethodMatcher(M_EXPRESSION_CAUSE_XPATH2).matches(mi,false) ||
- getMethodMatcher(M_EXPRESSION_CAUSE_XPATH3).matches(mi,false) ||
- getMethodMatcher(M_EXPRESSION_CAUSE_XQUERY1).matches(mi,false) ||
- getMethodMatcher(M_EXPRESSION_CAUSE_XQUERY2).matches(mi,false) ||
- getMethodMatcher(M_EXPRESSION_CAUSE_XQUERY3).matches(mi,false)) {
- mi = mi.withName(RecipesUtil.createIdentifier(Space.EMPTY, "removed_" + mi.getSimpleName(), mi.getType().toString()))
- .withComments(Collections.singletonList(RecipesUtil.createMultinlineComment(
- "Some Java DSL for tokenize, xmlTokenize, xpath, xquery and jsonpath has been removed as part of making the DSL model consistent.\n" +
- "See https://camel.apache.org/manual/camel-4x-upgrade-guide-4_4.html#_camel_core for more details.\n")));
- }
-
- return mi;
- }
-
- @Override
- protected J.NewClass doVisitNewClass(J.NewClass newClass, ExecutionContext context) {
- J.NewClass nc = super.doVisitNewClass(newClass, context);
-
-
- //can not use org.openrewrite.java.DeleteMethodArgument, because it doesn't modify calls of constructors
- if ((getMethodMatcher(CONST_STOP_WATCH_LONG01).matches(nc) || getMethodMatcher(CONST_STOP_WATCH_LONG02).matches(nc))
- && nc.getArguments().size() == 1) { //without the condition, the recipes is applied againorg.openrewrite.properties.ChangePropertyKey
- nc = nc.withArguments(Collections.emptyList()).
- withComments(Collections.singletonList(RecipesUtil.createMultinlineComment(
- "Removed the deprecated constructor from the internal class org.apache.camel.util.StopWatch.\n" +
- "Users of this class are advised to use the default constructor if necessary.Changed exception thrown from IOException to Exception.\n")));
-
- }
-
- return nc;
- }
- });
- }
-}
\ No newline at end of file
diff --git a/recipes/src/main/java/io/quarkus/updates/camel/customRecipes/ChangePropertyKeyWithCaseChange.java b/recipes/src/main/java/io/quarkus/updates/camel/customRecipes/ChangePropertyKeyWithCaseChange.java
deleted file mode 100644
index 67b32be8e9..0000000000
--- a/recipes/src/main/java/io/quarkus/updates/camel/customRecipes/ChangePropertyKeyWithCaseChange.java
+++ /dev/null
@@ -1,57 +0,0 @@
-package io.quarkus.updates.camel.customRecipes;
-
-import lombok.EqualsAndHashCode;
-import lombok.Value;
-import org.openrewrite.ExecutionContext;
-import org.openrewrite.Option;
-import org.openrewrite.Recipe;
-import org.openrewrite.TreeVisitor;
-import org.openrewrite.properties.PropertiesVisitor;
-import org.openrewrite.properties.tree.Properties;
-
-/**
- * Replaces prefix with the new one and changes the suffix tp start with lower case
- */
-@Value
-@EqualsAndHashCode(callSuper = false)
-public class ChangePropertyKeyWithCaseChange extends Recipe {
-
- @Option(displayName = "Old property key",
- description = "The property key to rename.")
- String oldPropertyKey;
-
- @Option(displayName = "New prefix before any group",
- description = "The prefix to be replaced with.")
- String newPrefix;
-
- @Override
- public String getDisplayName() {
- return "Change prefix of property with Camel case";
- }
-
- @Override
- public String getDescription() {
- return "Change prefix of property with Camel case";
- }
-
- @Override
- public PropertiesVisitor getVisitor() {
- return new PropertiesVisitor<>() {
- @Override
- public Properties visitEntry(Properties.Entry entry, ExecutionContext p) {
- if (entry.getKey().matches(oldPropertyKey)) {
- entry = entry.withKey(getKey(entry))
- .withPrefix(entry.getPrefix());
- }
- return super.visitEntry(entry, p);
- }
-
- //replace key
- private String getKey(Properties.Entry entry) {
- return newPrefix + entry.getKey().replaceFirst(oldPropertyKey, "$1").substring(0,1).toLowerCase()
- + entry.getKey().replaceFirst(oldPropertyKey, "$1").substring(1);
-
- }
- };
- }
-}
diff --git a/recipes/src/main/java/io/quarkus/updates/camel/customRecipes/MoveGetterToPluginHelper.java b/recipes/src/main/java/io/quarkus/updates/camel/customRecipes/MoveGetterToPluginHelper.java
deleted file mode 100644
index 0c3bf74e23..0000000000
--- a/recipes/src/main/java/io/quarkus/updates/camel/customRecipes/MoveGetterToPluginHelper.java
+++ /dev/null
@@ -1,83 +0,0 @@
-package io.quarkus.updates.camel.customRecipes;
-
-import io.quarkus.updates.camel.AbstractCamelQuarkusJavaVisitor;
-import io.quarkus.updates.camel.RecipesUtil;
-import lombok.EqualsAndHashCode;
-import lombok.Value;
-import org.openrewrite.ExecutionContext;
-import org.openrewrite.Option;
-import org.openrewrite.Recipe;
-import org.openrewrite.TreeVisitor;
-import org.openrewrite.java.AddImport;
-import org.openrewrite.java.JavaTemplate;
-import org.openrewrite.java.tree.J;
-
-import java.util.regex.Pattern;
-
-/**
- * Replaces prefix with the new one and changes the suffix tp start with lower case
- */
-@Value
-@EqualsAndHashCode(callSuper = false)
-public class MoveGetterToPluginHelper extends Recipe {
-
- private static final String MATCHER_GET_NAME_RESOLVER = "org.apache.camel.ExtendedCamelContext getComponentNameResolver()";
- private static final String MATCHER_GET_MODEL_JAXB_CONTEXT_FACTORY = "org.apache.camel.ExtendedCamelContext getModelJAXBContextFactory()";
- private static final String MATCHER_GET_MODEL_TO_XML_DUMPER = "org.apache.camel.ExtendedCamelContext getModelToXMLDumper()";
- private static final Pattern EXTERNAL_CONTEXT_TYPE = Pattern.compile("org.apache.camel.ExtendedCamelContext");
- private static final String MATCHER_CONTEXT_GET_EXT = "org.apache.camel.CamelContext getExtension(java.lang.Class)";
-
- @Option(displayName = "Method name",
- description = "Name of the method on external camel context.")
- String oldMethodName;
-
- @Override
- public String getDisplayName() {
- return "Move getter from context to PluginHelper.";
- }
-
- @Override
- public String getDescription() {
- return "Move getter from context to PluginHelper";
- }
-
- @Override
- public TreeVisitor, ExecutionContext> getVisitor() {
- return RecipesUtil.newVisitor(new AbstractCamelQuarkusJavaVisitor() {
- @Override
- protected J.MethodInvocation doVisitMethodInvocation(J.MethodInvocation method, ExecutionContext context) {
- J.MethodInvocation mi = super.doVisitMethodInvocation(method, context);
-
- // extendedContext.getModelJAXBContextFactory() -> PluginHelper.getModelJAXBContextFactory(extendedContext)
- if (getMethodMatcher(getOldMethodMatcher()).matches(mi, false)) {
- if (mi.getSelect() instanceof J.MethodInvocation && getMethodMatcher(MATCHER_CONTEXT_GET_EXT).matches(((J.MethodInvocation) mi.getSelect()).getMethodType())) {
- J.MethodInvocation innerInvocation = (J.MethodInvocation) mi.getSelect();
- mi = JavaTemplate.builder(getNewMethodFromContext())
- //.contextSensitive()
- .build()
- .apply(getCursor(), mi.getCoordinates().replace(), innerInvocation.getSelect());
- doAfterVisit(new AddImport<>("org.apache.camel.support.PluginHelper", null, false));
- } else if (mi.getSelect().getType().isAssignableFrom(EXTERNAL_CONTEXT_TYPE)) {
- mi = JavaTemplate.builder(getNewMethodFromExternalContextContext())
- //.contextSensitive()
- .build()
- .apply(getCursor(), mi.getCoordinates().replace(), mi.getSelect());
- doAfterVisit(new AddImport<>("org.apache.camel.support.PluginHelper", null, false));
- }
- }
-
- return mi;
- }
-
- private String getOldMethodMatcher() {
- return "org.apache.camel.ExtendedCamelContext " + oldMethodName + "()";
- }
- private String getNewMethodFromContext() {
- return "PluginHelper." + oldMethodName + "(#{any(org.apache.camel.CamelContext)})";
- }
- private String getNewMethodFromExternalContextContext() {
- return "PluginHelper." + oldMethodName + "(#{any(org.apache.camel.ExtendedCamelContext)})";
- }
- });
- }
-}
diff --git a/recipes/src/main/resources/quarkus-updates/org.apache.camel.quarkus/camel-quarkus/3.8.yaml b/recipes/src/main/resources/quarkus-updates/org.apache.camel.quarkus/camel-quarkus/3.8.yaml
index c452eed082..34bcbce2c0 100644
--- a/recipes/src/main/resources/quarkus-updates/org.apache.camel.quarkus/camel-quarkus/3.8.yaml
+++ b/recipes/src/main/resources/quarkus-updates/org.apache.camel.quarkus/camel-quarkus/3.8.yaml
@@ -27,95 +27,5 @@ name: io.quarkus.updates.camel.camel44.CamelQuarkusMigrationRecipe
displayName: Migrates `camel 4.0` application to `camel 4.4`
description: Migrates `camel 4.0` quarkus application to `camel 4.4`.
recipeList:
- # to camel 4.1
- - io.quarkus.updates.camel.camel41.CamelCoreRecipe
- - io.quarkus.updates.camel.camel41.XmlDslRecipe
- - io.quarkus.updates.camel.camel41.YamlDslRecipe
- - io.quarkus.updates.camel.camel41.TracingTag
- # to camel 4.2
- - io.quarkus.updates.camel.camel42.CamelMainDebugger
- - io.quarkus.updates.camel.camel42.CamelSagaRecipe
- # to camel 4.3
- - io.quarkus.updates.camel.camel43.StateRepository
- - io.quarkus.updates.camel.camel43.CamelResequenceEIPXmlRecipe
- - io.quarkus.updates.camel.camel43.CamelThrottleEIPRecipe
- - io.quarkus.updates.camel.camel43.KafkaMetadata
- # to camel 4.4
- - io.quarkus.updates.camel.camel44.CamelCoreRecipe
- - io.quarkus.updates.camel.camel44.RouteControllerProperties
- - io.quarkus.updates.camel.camel44.DefaultJsonSchemaLoader
----
-#https://camel.apache.org/manual/camel-4x-upgrade-guide-4_1.html#_camel_tracing
-type: specs.openrewrite.org/v1beta/recipe
-name: io.quarkus.updates.camel.camel41.TracingTag
-displayName: Tag Enum has been deprecated
-description: The Tag Enum containing constants for tagging spans has been deprecated. Instead, use constants from the TagConstants.
-recipeList:
- - org.openrewrite.java.ChangeType:
- oldFullyQualifiedTypeName: org.apache.camel.tracing.Tag
- newFullyQualifiedTypeName: org.apache.camel.tracing.TagConstants
----
-#https://camel.apache.org/manual/camel-4x-upgrade-guide-4_2.html#_camel_main
-type: specs.openrewrite.org/v1beta/recipe
-name: io.quarkus.updates.camel.camel42.CamelMainDebugger
-displayName: The option camel.main.debugger has been renamed
-description: The option camel.main.debugger has been renamed to camel.debug.enabled.
-recipeList:
- - org.openrewrite.properties.ChangePropertyKey:
- oldPropertyKey: (.*)camel.main.debugger
- newPropertyKey: $1camel.debug.enabled
- regex: true
----
-#https://camel.apache.org/manual/camel-4x-upgrade-guide-4_3.html#_camel_core
-type: specs.openrewrite.org/v1beta/recipe
-name: io.quarkus.updates.camel.camel43.StateRepository
-displayName: MemoryStateRepository and FileStateRepository were moved to another package and library
-description: Moved classes MemoryStateRepository and FileStateRepositor from camel-base-engine to camel-support.
-recipeList:
- - org.openrewrite.java.ChangeType:
- oldFullyQualifiedTypeName: org.apache.camel.impl.engine.MemoryStateRepository
- newFullyQualifiedTypeName: org.apache.camel.support.processor.state.MemoryStateRepository
- - org.openrewrite.java.ChangeType:
- oldFullyQualifiedTypeName: org.apache.camel.impl.engine.FileStateRepository
- newFullyQualifiedTypeName: org.apache.camel.support.processor.state.FileStateRepository
----
-#https://camel.apache.org/manual/camel-4x-upgrade-guide-4_3.html#_camel_kafka_2
-type: specs.openrewrite.org/v1beta/recipe
-name: io.quarkus.updates.camel.camel43.KafkaMetadata
-displayName: The header name for the List metadata has changed
-description: The header name for the List metadata has changed also the dsl method for metadata changed.
-recipeList:
- - org.openrewrite.java.ChangeMethodName:
- methodPattern: org.apache.camel.builder.endpoint.dsl.KafkaEndpointBuilderFactory$KafkaHeaderNameBuilder orgApacheKafkaClientsProducerRecordmetadata()
- newMethodName: kafkaRecordMeta
- - org.openrewrite.java.ReplaceConstantWithAnotherConstant:
- existingFullyQualifiedConstantName: org.apache.camel.component.kafka.KafkaConstants.KAFKA_RECORDMETA
- fullyQualifiedConstantName: org.apache.camel.component.kafka.KafkaConstants.KAFKA_RECORD_META
----
-#https://camel.apache.org/manual/camel-4x-upgrade-guide-4_4.html#_camel_json_validator
-type: specs.openrewrite.org/v1beta/recipe
-name: io.quarkus.updates.camel.camel44.DefaultJsonSchemaLoader
-displayName: Replace deprecated DefaultJsonSchemaLoader with DefaultJsonUriSchemaLoader
-description: Replaces deprecated class with its successor.
-recipeList:
- - org.openrewrite.java.ChangeType:
- oldFullyQualifiedTypeName: org.apache.camel.component.jsonvalidator.DefaultJsonSchemaLoader
- newFullyQualifiedTypeName: org.apache.camel.component.jsonvalidator.DefaultJsonUriSchemaLoader
----
-#https://camel.apache.org/manual/camel-4x-upgrade-guide-4_4.html#_camel_main
-type: specs.openrewrite.org/v1beta/recipe
-name: io.quarkus.updates.camel.camel44.RouteControllerProperties
-displayName: Replace 'camel.main.routeController' with `camel.routecontroller'
-recipeList:
- - org.openrewrite.properties.ChangePropertyKey:
- oldPropertyKey: camel.main.routeControllerSuperviseEnabled
- newPropertyKey: camel.routeController.enabled
- - org.openrewrite.properties.ChangePropertyKey:
- oldPropertyKey: camel.main.route-controller-supervise-enabled
- newPropertyKey: camel.routeController.enabled
- - io.quarkus.updates.camel.customRecipes.ChangePropertyKeyWithCaseChange:
- oldPropertyKey: camel.main.routeController(.*)
- newPrefix: camel.routeController.
- - io.quarkus.updates.camel.customRecipes.ChangePropertyKeyWithCaseChange:
- oldPropertyKey: camel.main.route-controller-(.*)
- newPrefix: camel.routeController.
+# use the recipe from camel standalone migration
+ - org.apache.camel.updates.camel44.CamelMigrationRecipe
\ No newline at end of file
diff --git a/recipes/src/main/resources/quarkus-updates/org.apache.camel.quarkus/camel-quarkus/3alpha.yaml b/recipes/src/main/resources/quarkus-updates/org.apache.camel.quarkus/camel-quarkus/3alpha.yaml
index c93006c1b8..33acd10ab6 100644
--- a/recipes/src/main/resources/quarkus-updates/org.apache.camel.quarkus/camel-quarkus/3alpha.yaml
+++ b/recipes/src/main/resources/quarkus-updates/org.apache.camel.quarkus/camel-quarkus/3alpha.yaml
@@ -35,24 +35,8 @@ name: io.quarkus.updates.camel.camel40.CamelQuarkusMigrationRecipe
displayName: Migrate `camel3` application to `camel4.`
description: Migrate `camel3` quarkus application to `camel4` quarkus.
recipeList:
- - io.quarkus.updates.camel.camel40.xml.XmlDslRecipe
- - io.quarkus.updates.camel.camel40.xml.CircuitBreakerXmlDslRecipe
- - io.quarkus.updates.camel.camel40.yaml.CamelQuarkusYamlRouteConfigurationSequenceRecipe
- - io.quarkus.updates.camel.camel40.yaml.CamelQuarkusYamlStepsInFromRecipe
- - io.quarkus.updates.camel.camel40.java.CamelAPIsRecipe
- - io.quarkus.updates.camel.camel40.java.CamelEIPRecipe
- - io.quarkus.updates.camel.camel40.java.CamelBeanRecipe
- - io.quarkus.updates.camel.camel40.java.CamelHttpRecipe
- - io.quarkus.updates.camel.camel40.UsePluginHelperForContextGetters
----
-type: specs.openrewrite.org/v1beta/recipe
-name: org.openrewrite.java.camel.migrate.ChangeTypes
-displayName: Migrate moved types between Came 3.x and Camel 4.x
-description: Change type of classes related to change of API.
-recipeList:
- - org.openrewrite.java.ChangeType:
- oldFullyQualifiedTypeName: org.apache.camel.support.IntrospectionSupport
- newFullyQualifiedTypeName: org.apache.camel.impl.engine.IntrospectionSupport
+ # use the recipe from camel standalone migration
+ - org.apache.camel.updates.camel40.CamelMigrationRecipe
---
type: specs.openrewrite.org/v1beta/recipe
name: org.openrewrite.java.camel.migrate.removedExtensions
@@ -135,53 +119,3 @@ recipeList:
- org.openrewrite.maven.RemoveDependency:
groupId: org.apache.camel.quarkus
artifactId: camel-quarkus-xstream
----
-type: specs.openrewrite.org/v1beta/recipe
-name: org.openrewrite.java.camel.migrate.ChangePropertyValue
-displayName: Camel API changes in application.properties
-description: Apache Camel API migration from version 3.20 or higher to 4.0. Removal of deprecated APIs, which could be part of the application.properties.
-#todo would be better to put a comment about changed property and its alternative, once the openrewrite recipe allows that
-recipeList:
- - org.openrewrite.properties.ChangePropertyValue:
- propertyKey: camel.threadpool.rejectedPolicy
- newValue: "Abort #DiscardOldest has been removed, consider Abort"
- oldValue: DiscardOldest
- - org.openrewrite.properties.ChangePropertyValue:
- propertyKey: camel.threadpool.rejectedPolicy
- newValue: "Abort #Discard has been removed, consider Abort"
- oldValue: Discard
----
-type: specs.openrewrite.org/v1beta/recipe
-name: org.openrewrite.java.camel.migrate.ChangeManagedChoiceMBeanMethodName
-displayName: Change of method names brought by Camel JMX API changes
-description: MBeans now use a consistent method name of `extendedInformation`.
-recipeList:
- - org.openrewrite.java.ChangeMethodName:
- methodPattern: org.apache.camel.api.management.mbean.ManagedChoiceMBean choiceStatistics()
- newMethodName: extendedInformation
- matchOverrides: null
- ignoreDefinition: null
----
-type: specs.openrewrite.org/v1beta/recipe
-name: org.openrewrite.java.camel.migrate.ChangeManagedFailoverLoadBalancerMBeanMethodName
-displayName: Change of method names brought by Camel JMX API changes
-description: MBeans now use a consistent method name of `extendedInformation`.
-recipeList:
- - org.openrewrite.java.ChangeMethodName:
- methodPattern: org.apache.camel.api.management.mbean.ManagedFailoverLoadBalancerMBean exceptionStatistics()
- newMethodName: extendedInformation
- matchOverrides: null
- ignoreDefinition: null
----
-type: specs.openrewrite.org/v1beta/recipe
-name: io.quarkus.updates.camel.camel40.UsePluginHelperForContextGetters
-displayName: Replace context.getExtension(ExtendedCamelContext.class).get* with PluginHelper.get*(context)
-recipeList:
- - io.quarkus.updates.camel.customRecipes.MoveGetterToPluginHelper:
- oldMethodName: getComponentNameResolver
- - io.quarkus.updates.camel.customRecipes.MoveGetterToPluginHelper:
- oldMethodName: getModelJAXBContextFactory
- - io.quarkus.updates.camel.customRecipes.MoveGetterToPluginHelper:
- oldMethodName: getModelToXMLDumper
- - io.quarkus.updates.camel.customRecipes.MoveGetterToPluginHelper:
- oldMethodName: getRoutesLoader
\ No newline at end of file