JiriOndrusek commented on code in PR #125:
URL: 
https://github.com/apache/camel-upgrade-recipes/pull/125#discussion_r3851888987


##########
camel-spring-boot-upgrade-recipes/src/main/resources/META-INF/rewrite/4.22.yaml:
##########
@@ -35,4 +36,18 @@ recipeList:
       oldArtifactId: camel-spring-ai-tools-starter
       newGroupId: org.apache.camel.springboot
       newArtifactId: camel-ai-tool-starter
-      newVersion: 4.22.0
+      newVersion: @camel-spring-boot-version@
+---
+## 
https://github.com/apache/camel/blob/main/docs/user-manual/modules/ROOT/pages/camel-4x-upgrade-guide-4_22.adoc#camel-langchain4j-tools-deprecated
+type: specs.openrewrite.org/v1beta/recipe
+name: org.apache.camel.upgrade.camel422.migrateAiToolStarterDependency
+displayName: Use camel-ai-tool-starter instead of camel-ai-tool
+description: Replaces the plain camel-ai-tool dependency with 
camel-ai-tool-starter, so that a Spring Boot application gets the component 
auto-configuration. The plain artifact is what the Camel recipe adds when 
migrating langchain4j-tools routes; duplicates are removed when the starter is 
already declared.
+recipeList:
+  - org.openrewrite.maven.ChangeDependencyGroupIdAndArtifactId:
+      oldGroupId: org.apache.camel
+      oldArtifactId: camel-ai-tool
+      newGroupId: org.apache.camel.springboot
+      newArtifactId: camel-ai-tool-starter
+      newVersion: @camel-spring-boot-version@
+  - org.openrewrite.maven.RemoveDuplicateDependencies

Review Comment:
   Ungated swap puts the starter into non-Boot modules of multi-module builds 
(suggest gating on `org.springframework.boot:*`), and 
`RemoveDuplicateDependencies` dedupes the whole pom, not just the ai-tool pair.



##########
camel-upgrade-recipes/src/main/java/org/apache/camel/upgrade/camel418_3/RenameHeaderInXmlDsl.java:
##########
@@ -87,27 +101,54 @@ public Xml.Tag doVisitTag(Xml.Tag tag, ExecutionContext 
ctx) {
 
             // Check if this is a setHeader, header, or removeHeader tag
             String tagName = t.getName();
-            if ("setHeader".equals(tagName) || "header".equals(tagName) || 
"removeHeader".equals(tagName)) {
-                // Look for the "name" attribute with oldHeaderName value
-                return t.withAttributes(ListUtils.map(t.getAttributes(), attr 
-> {
-                    if ("name".equals(attr.getKeyAsString()) &&
-                        oldHeaderName.equals(attr.getValueAsString())) {
-                        // Replace with new header name
-                        return attr.withValue(
-                            new Xml.Attribute.Value(
-                                attr.getValue().getId(),
-                                "",
-                                Markers.EMPTY,
-                                attr.getValue().getQuote(),
-                                newHeaderName
-                            )
-                        );
-                    }
+            boolean headerTag = "setHeader".equals(tagName) || 
"header".equals(tagName) || "removeHeader".equals(tagName);
+
+            t = t.withAttributes(ListUtils.map(t.getAttributes(), attr -> {
+                String value = attr.getValueAsString();
+                if (value == null) {
                     return attr;
-                }));
+                }
+
+                // The "name" attribute of a header element holds the header 
name itself
+                if (headerTag && "name".equals(attr.getKeyAsString()) && 
oldHeaderName.equals(value)) {
+                    return withValue(attr, newHeaderName);
+                }
+
+                // Any other attribute may carry a Simple expression, e.g. 
<log message="${header.x}"/>

Review Comment:
   No Camel-file precondition (Java has `UsesType`, YAML has 
`camelYamlDslPrecondition`) — `${header.x}` now gets rewritten in any XML, 
incl. Spring placeholders like `<property value="${header.operation}"/>`. 
Please gate on a Camel root element and add a non-Camel-XML negative test.



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to