Skip to content
Open
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 @@ -29,6 +29,7 @@
import org.apache.camel.spi.Metadata;
import org.apache.camel.spi.annotations.Component;
import org.apache.camel.support.DefaultComponent;
import org.apache.camel.util.ObjectHelper;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

Expand Down Expand Up @@ -83,6 +84,15 @@ protected void doStart() throws Exception {
@Override
protected Endpoint createEndpoint(String uri, String remaining, Map<String, Object> parameters) throws Exception {
DoclingConfiguration config = this.configuration.copy();
// operationId (e.g. docling:CONVERT_TO_MARKDOWN) selects the operation; applied before
// setProperties() below so an explicit ?operation=... parameter still takes precedence.
if (ObjectHelper.isNotEmpty(remaining)) {
try {
config.setOperation(DoclingOperations.valueOf(remaining));
} catch (IllegalArgumentException e) {
// not a recognized operation name - leave the configured/default operation as-is
}
}
DoclingEndpoint endpoint = new DoclingEndpoint(uri, this, remaining, config);
setProperties(endpoint, parameters);
return endpoint;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,27 @@ public void testCreateEndpointWithParameters() throws Exception {
assertEquals("es", doclingEndpoint.getConfiguration().getOcrLanguage());
}

@Test
public void testOperationIdSelectsOperation() throws Exception {
Endpoint endpoint = context.getEndpoint("docling:EXTRACT_STRUCTURED_DATA");
assertNotNull(endpoint);
assertTrue(endpoint instanceof DoclingEndpoint);

DoclingEndpoint doclingEndpoint = (DoclingEndpoint) endpoint;
assertEquals("EXTRACT_STRUCTURED_DATA", doclingEndpoint.getOperationId());
assertEquals(DoclingOperations.EXTRACT_STRUCTURED_DATA, doclingEndpoint.getConfiguration().getOperation());
}

@Test
public void testExplicitOperationParameterOverridesOperationId() throws Exception {
// a recognized operationId must still be overridable via an explicit "operation" parameter
Endpoint endpoint = context.getEndpoint("docling:CONVERT_TO_MARKDOWN?operation=EXTRACT_TEXT");
assertNotNull(endpoint);

DoclingEndpoint doclingEndpoint = (DoclingEndpoint) endpoint;
assertEquals(DoclingOperations.EXTRACT_TEXT, doclingEndpoint.getConfiguration().getOperation());
}

@Test
public void testProducerCreation() throws Exception {
DoclingEndpoint endpoint = (DoclingEndpoint) context.getEndpoint("docling:convert");
Expand Down