You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@camel.apache.org by "apupier (via GitHub)" <gi...@apache.org> on 2026/01/22 15:48:09 UTC

[PR] Support extract metadata for camel docling in native [camel-quarkus]

apupier opened a new pull request, #8197:
URL: https://github.com/apache/camel-quarkus/pull/8197

   it has a very limited scope, it requires
   https://issues.apache.org/jira/browse/CAMEL-22888 to be able to test more
   
   <!-- Uncomment and fill this section if your PR is not trivial
   [ ] An issue should be filed for the change unless this is a trivial change (fixing a typo or similar). One issue should ideally be fixed by not more than one commit and the other way round, each commit should fix just one issue, without pulling in other changes.
   [ ] Each commit in the pull request should have a meaningful and properly spelled subject line and body. Copying the title of the associated issue is typically enough. Please include the issue number in the commit message prefixed by #.
   [ ] The pull request description should explain what the pull request does, how, and why. If the info is available in the associated issue or some other external document, a link is enough.
   [ ] Phrases like Fix #<issueNumber> or Fixes #<issueNumber> will auto-close the named issue upon merging the pull request. Using them is typically a good idea.
   [ ] Please run mvn process-resources -Pformat (and amend the changes if necessary) before sending the pull request.
   [ ] Contributor guide is your good friend: https://camel.apache.org/camel-quarkus/latest/contributor-guide.html
   -->


-- 
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: commits-unsubscribe@camel.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] Support extract metadata for camel docling in native [camel-quarkus]

Posted by "apupier (via GitHub)" <gi...@apache.org>.
apupier commented on code in PR #8197:
URL: https://github.com/apache/camel-quarkus/pull/8197#discussion_r2721012265


##########
extensions/docling/deployment/src/main/java/org/apache/camel/quarkus/component/docling/deployment/DoclingProcessor.java:
##########
@@ -73,5 +74,7 @@ void registerForReflection(
         reflectiveClass.produce(ReflectiveClassBuildItem.builder(doclingCoreBuilderClasses.toArray(new String[0]))
                 .methods(true)
                 .build());
+
+        reflectiveClass.produce(ReflectiveClassBuildItem.builder(DocumentMetadata.class).constructors().methods(true).build());

Review Comment:
   I registered for reflection only the test side then



-- 
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: commits-unsubscribe@camel.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] Support extract metadata for camel docling in native [camel-quarkus]

Posted by "apupier (via GitHub)" <gi...@apache.org>.
apupier commented on code in PR #8197:
URL: https://github.com/apache/camel-quarkus/pull/8197#discussion_r2720331402


##########
integration-tests/docling/src/main/java/org/apache/camel/quarkus/component/docling/it/DoclingResource.java:
##########
@@ -206,13 +210,38 @@ public Response extractMetadata(String documentContent) throws IOException {
         java.nio.file.Path tempFile = Files.createTempFile("docling-test", ".md");
         Files.writeString(tempFile, documentContent);
         try {
-            String result = producerTemplate.requestBody("direct:extractMetadata", tempFile.toString(), String.class);
-            return Response.ok(result).build();
+            DocumentMetadata result = producerTemplate.requestBody("direct:extractMetadata", tempFile.toString(),
+                    DocumentMetadata.class);
+            ObjectWriter ow = new ObjectMapper().writer().withDefaultPrettyPrinter();
+            String json = ow.writeValueAsString(result);
+            return Response.ok(json).build();

Review Comment:
   when adding quarkus-resteast-jackson or quarkus-resteasy-jsonb, I got this error at compilation:
   ```
   java.lang.RuntimeException: io.quarkus.builder.BuildException: Build failure: Build failed due to errors
   	[error]: Build step io.quarkus.arc.deployment.ArcProcessor#validate threw an exception: jakarta.enterprise.inject.spi.DeploymentException: Found 2 deployment problems: 
   [1] Unsatisfied dependency for type org.apache.camel.CamelContext and qualifiers [@Default]
   	- injection target: org.apache.camel.quarkus.component.docling.it.DoclingResource#context
   	- declared on CLASS bean [types=[java.lang.Object, org.apache.camel.quarkus.component.docling.it.DoclingResource], qualifiers=[@Any, @Default], target=org.apache.camel.quarkus.component.docling.it.DoclingResource]
   [2] Unsatisfied dependency for type org.apache.camel.ProducerTemplate and qualifiers [@Default]
   	- injection target: org.apache.camel.quarkus.component.docling.it.DoclingResource#producerTemplate
   	- declared on CLASS bean [types=[java.lang.Object, org.apache.camel.quarkus.component.docling.it.DoclingResource], qualifiers=[@Any, @Default], target=org.apache.camel.quarkus.component.docling.it.DoclingResource]
   ```



-- 
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: commits-unsubscribe@camel.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] Support extract metadata for camel docling in native [camel-quarkus]

Posted by "apupier (via GitHub)" <gi...@apache.org>.
apupier commented on code in PR #8197:
URL: https://github.com/apache/camel-quarkus/pull/8197#discussion_r2717607835


##########
extensions/docling/deployment/src/main/java/org/apache/camel/quarkus/component/docling/deployment/DoclingProcessor.java:
##########
@@ -73,5 +74,7 @@ void registerForReflection(
         reflectiveClass.produce(ReflectiveClassBuildItem.builder(doclingCoreBuilderClasses.toArray(new String[0]))
                 .methods(true)
                 .build());
+
+        reflectiveClass.produce(ReflectiveClassBuildItem.builder(DocumentMetadata.class).constructors().methods(true).build());

Review Comment:
   I think it is because I request a DocumentMetadata.class as output type of the producerTemplate.requestBody https://github.com/apache/camel-quarkus/pull/8197/files#diff-d6794a6a6cc2c6724d73ed97f0f830c8f7527d08968a193abee6ed89042f7442R213
   
   so technically in the test but I think that if someone is trying to use DocumentMetdata directly they will have to register it.
   
   What do you think?
   



-- 
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: commits-unsubscribe@camel.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] Support extract metadata for camel docling in native [camel-quarkus]

Posted by "apupier (via GitHub)" <gi...@apache.org>.
apupier commented on code in PR #8197:
URL: https://github.com/apache/camel-quarkus/pull/8197#discussion_r2721011030


##########
integration-tests/docling/src/main/java/org/apache/camel/quarkus/component/docling/it/DoclingResource.java:
##########
@@ -206,13 +210,38 @@ public Response extractMetadata(String documentContent) throws IOException {
         java.nio.file.Path tempFile = Files.createTempFile("docling-test", ".md");
         Files.writeString(tempFile, documentContent);
         try {
-            String result = producerTemplate.requestBody("direct:extractMetadata", tempFile.toString(), String.class);
-            return Response.ok(result).build();
+            DocumentMetadata result = producerTemplate.requestBody("direct:extractMetadata", tempFile.toString(),
+                    DocumentMetadata.class);
+            ObjectWriter ow = new ObjectMapper().writer().withDefaultPrettyPrinter();
+            String json = ow.writeValueAsString(result);
+            return Response.ok(json).build();

Review Comment:
   working fine after full rebuild



-- 
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: commits-unsubscribe@camel.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] Support extract metadata for camel docling in native [camel-quarkus]

Posted by "apupier (via GitHub)" <gi...@apache.org>.
apupier commented on code in PR #8197:
URL: https://github.com/apache/camel-quarkus/pull/8197#discussion_r2721010311


##########
integration-tests/docling/src/test/java/org/apache/camel/quarkus/component/docling/it/DoclingTest.java:
##########
@@ -127,12 +133,62 @@ public void extractText() {
                 .post("/docling/extract/text")
                 .then()
                 .statusCode(200)
-                .body(not(emptyString()));
+                .body(containsString(testContent));
     }
 
     @Test
-    public void extractMetadata() {
-        String testContent = "# Test Document\nSome content for metadata extraction.";
+    void extractMetadataFromPdf() {
+        RestAssured.given()
+                .when()
+                .post("/docling/metadata/extract/pdf")
+                .then()
+                .statusCode(200)
+                .body(new BaseMatcher<String>() {
+
+                    private DocumentMetadata documentMetadata;
+
+                    @Override
+                    public boolean matches(Object actual) {
+                        ObjectMapper mapper = new ObjectMapper();
+                        try {
+                            documentMetadata = mapper.readValue((String) actual, DocumentMetadata.class);
+                            return documentMetadata.getFileName().startsWith("docling-test")
+                                    && documentMetadata.getFilePath().contains("docling-test");
+                            // TODO: improve test by checking other metadatas when https://issues.apache.org/jira/browse/CAMEL-22888 is fixed
+                        } catch (JsonProcessingException e) {
+                            e.printStackTrace();
+                            return false;
+                        }
+                    }
+
+                    @Override
+                    public void describeTo(Description description) {
+                        if (documentMetadata != null) {
+                            description.appendText(documentMetadata.toString());
+                        } else {
+                            description.appendText("Wasn't able to parse the answer");
+                        }
+                    }
+                });

Review Comment:
   a lot easier effectively, we lost the type-safe side but a lot more concise. thanks



-- 
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: commits-unsubscribe@camel.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] Support extract metadata for camel docling in native [camel-quarkus]

Posted by "jamesnetherton (via GitHub)" <gi...@apache.org>.
jamesnetherton commented on code in PR #8197:
URL: https://github.com/apache/camel-quarkus/pull/8197#discussion_r2717549981


##########
extensions/docling/deployment/src/main/java/org/apache/camel/quarkus/component/docling/deployment/DoclingProcessor.java:
##########
@@ -73,5 +74,7 @@ void registerForReflection(
         reflectiveClass.produce(ReflectiveClassBuildItem.builder(doclingCoreBuilderClasses.toArray(new String[0]))
                 .methods(true)
                 .build());
+
+        reflectiveClass.produce(ReflectiveClassBuildItem.builder(DocumentMetadata.class).constructors().methods(true).build());

Review Comment:
   Just to clarify - are we registering `DocumentMetadata` because something in Camel or elsewhere does reflective operations on it?
   
   Or are we only adding it because it's used with `ObjectMapper` in the tests?



##########
integration-tests/docling/src/test/java/org/apache/camel/quarkus/component/docling/it/DoclingTest.java:
##########
@@ -127,12 +133,62 @@ public void extractText() {
                 .post("/docling/extract/text")
                 .then()
                 .statusCode(200)
-                .body(not(emptyString()));
+                .body(containsString(testContent));
     }
 
     @Test
-    public void extractMetadata() {
-        String testContent = "# Test Document\nSome content for metadata extraction.";
+    void extractMetadataFromPdf() {
+        RestAssured.given()
+                .when()
+                .post("/docling/metadata/extract/pdf")
+                .then()
+                .statusCode(200)
+                .body(new BaseMatcher<String>() {
+
+                    private DocumentMetadata documentMetadata;
+
+                    @Override
+                    public boolean matches(Object actual) {
+                        ObjectMapper mapper = new ObjectMapper();
+                        try {
+                            documentMetadata = mapper.readValue((String) actual, DocumentMetadata.class);
+                            return documentMetadata.getFileName().startsWith("docling-test")
+                                    && documentMetadata.getFilePath().contains("docling-test");
+                            // TODO: improve test by checking other metadatas when https://issues.apache.org/jira/browse/CAMEL-22888 is fixed
+                        } catch (JsonProcessingException e) {
+                            e.printStackTrace();
+                            return false;
+                        }
+                    }
+
+                    @Override
+                    public void describeTo(Description description) {
+                        if (documentMetadata != null) {
+                            description.appendText(documentMetadata.toString());
+                        } else {
+                            description.appendText("Wasn't able to parse the answer");
+                        }
+                    }
+                });

Review Comment:
   If you just want to do assertions on a JSON response. There is a much easier way:
   
   https://github.com/rest-assured/rest-assured/wiki/usage#example-1---json
   
   



##########
integration-tests/docling/src/test/java/org/apache/camel/quarkus/component/docling/it/DoclingTest.java:
##########
@@ -141,7 +197,33 @@ public void extractMetadata() {
                 .post("/docling/metadata/extract")
                 .then()
                 .statusCode(200)
-                .body(not(emptyString()));
+                .body(new BaseMatcher<String>() {
+
+                    private DocumentMetadata documentMetadata;
+
+                    @Override
+                    public boolean matches(Object actual) {
+                        ObjectMapper mapper = new ObjectMapper();
+                        try {
+                            documentMetadata = mapper.readValue((String) actual, DocumentMetadata.class);
+                            return documentMetadata.getFileName().startsWith("docling-test")
+                                    && documentMetadata.getFilePath().contains("docling-test");

Review Comment:
   See previous comment about JSON response matching.



##########
integration-tests/docling/src/main/java/org/apache/camel/quarkus/component/docling/it/DoclingResource.java:
##########
@@ -206,13 +210,38 @@ public Response extractMetadata(String documentContent) throws IOException {
         java.nio.file.Path tempFile = Files.createTempFile("docling-test", ".md");
         Files.writeString(tempFile, documentContent);
         try {
-            String result = producerTemplate.requestBody("direct:extractMetadata", tempFile.toString(), String.class);
-            return Response.ok(result).build();
+            DocumentMetadata result = producerTemplate.requestBody("direct:extractMetadata", tempFile.toString(),
+                    DocumentMetadata.class);
+            ObjectWriter ow = new ObjectMapper().writer().withDefaultPrettyPrinter();
+            String json = ow.writeValueAsString(result);
+            return Response.ok(json).build();

Review Comment:
   I you use `quarkus-resteasy-jackson` or `quarkus-resteasy-jsonb`, you can set the `Response` entity to `result` and it'll get serialized to JSON automatically. Thus no need for `ObjectMapper`.
   
   Same for `extractMetadataFromPdf `.



-- 
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: commits-unsubscribe@camel.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] Support extract metadata for camel docling in native [camel-quarkus]

Posted by "apupier (via GitHub)" <gi...@apache.org>.
apupier commented on code in PR #8197:
URL: https://github.com/apache/camel-quarkus/pull/8197#discussion_r2720360889


##########
integration-tests/docling/src/main/java/org/apache/camel/quarkus/component/docling/it/DoclingResource.java:
##########
@@ -206,13 +210,38 @@ public Response extractMetadata(String documentContent) throws IOException {
         java.nio.file.Path tempFile = Files.createTempFile("docling-test", ".md");
         Files.writeString(tempFile, documentContent);
         try {
-            String result = producerTemplate.requestBody("direct:extractMetadata", tempFile.toString(), String.class);
-            return Response.ok(result).build();
+            DocumentMetadata result = producerTemplate.requestBody("direct:extractMetadata", tempFile.toString(),
+                    DocumentMetadata.class);
+            ObjectWriter ow = new ObjectMapper().writer().withDefaultPrettyPrinter();
+            String json = ow.writeValueAsString(result);
+            return Response.ok(json).build();

Review Comment:
   rerverted these changes and still got this compilation error. rebuilding everything, i guess there is something not clean in my environment oO



-- 
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: commits-unsubscribe@camel.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] Support extract metadata for camel docling in native [camel-quarkus]

Posted by "apupier (via GitHub)" <gi...@apache.org>.
apupier merged PR #8197:
URL: https://github.com/apache/camel-quarkus/pull/8197


-- 
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: commits-unsubscribe@camel.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] Support extract metadata for camel docling in native [camel-quarkus]

Posted by "jamesnetherton (via GitHub)" <gi...@apache.org>.
jamesnetherton commented on code in PR #8197:
URL: https://github.com/apache/camel-quarkus/pull/8197#discussion_r2717824809


##########
extensions/docling/deployment/src/main/java/org/apache/camel/quarkus/component/docling/deployment/DoclingProcessor.java:
##########
@@ -73,5 +74,7 @@ void registerForReflection(
         reflectiveClass.produce(ReflectiveClassBuildItem.builder(doclingCoreBuilderClasses.toArray(new String[0]))
                 .methods(true)
                 .build());
+
+        reflectiveClass.produce(ReflectiveClassBuildItem.builder(DocumentMetadata.class).constructors().methods(true).build());

Review Comment:
   I've not tried it, but I don't think that leads to reflection being used. I think it just casts the result to the type you provide.
   
   From what I can see in `DoclingProducer`, it's using `new DocumentMetadata()`, so there's no reflection involved.



-- 
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: commits-unsubscribe@camel.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org