This is an automated email from the ASF dual-hosted git repository. davsclaus pushed a commit to branch main in repository https://gitbox.apache.org/repos/asf/camel.git
The following commit(s) were added to refs/heads/main by this push: new 9a02c8fa2f6 CAMEL-22019: camel-smb: Expose UncPath for backwardcompatibility 9a02c8fa2f6 is described below commit 9a02c8fa2f687d4ae3f2f53f2a8b307849514981 Author: Claus Ibsen <claus.ib...@gmail.com> AuthorDate: Fri Apr 25 09:33:30 2025 +0200 CAMEL-22019: camel-smb: Expose UncPath for backwardcompatibility --- .../resources/org/apache/camel/catalog/components/smb.json | 3 ++- .../META-INF/org/apache/camel/component/smb/smb.json | 3 ++- components/camel-smb/src/main/docs/smb-component.adoc | 2 ++ .../java/org/apache/camel/component/smb/SmbConstants.java | 2 ++ .../java/org/apache/camel/component/smb/SmbOperations.java | 5 +++++ .../java/org/apache/camel/component/smb/SmbComponentIT.java | 3 ++- .../builder/endpoint/dsl/SmbEndpointBuilderFactory.java | 12 ++++++++++++ 7 files changed, 27 insertions(+), 3 deletions(-) diff --git a/catalog/camel-catalog/src/generated/resources/org/apache/camel/catalog/components/smb.json b/catalog/camel-catalog/src/generated/resources/org/apache/camel/catalog/components/smb.json index aad41b0e5bb..3f242e27660 100644 --- a/catalog/camel-catalog/src/generated/resources/org/apache/camel/catalog/components/smb.json +++ b/catalog/camel-catalog/src/generated/resources/org/apache/camel/catalog/components/smb.json @@ -46,7 +46,8 @@ "CamelFileHost": { "index": 12, "kind": "header", "displayName": "", "group": "consumer", "label": "consumer", "required": false, "javaType": "String", "deprecated": false, "deprecationNote": "", "autowired": false, "secret": false, "description": "The remote hostname.", "constantName": "org.apache.camel.component.smb.SmbConstants#FILE_HOST" }, "CamelSmbFileInputStream": { "index": 13, "kind": "header", "displayName": "", "group": "consumer", "label": "consumer", "required": false, "javaType": "java.io.InputStream", "deprecated": false, "deprecationNote": "", "autowired": false, "secret": false, "description": "The remote file input stream.", "constantName": "org.apache.camel.component.smb.SmbConstants#SMB_FILE_INPUT_STREAM" }, "CamelFileLocalWorkPath": { "index": 14, "kind": "header", "displayName": "", "group": "common", "label": "", "required": false, "javaType": "String", "deprecated": false, "deprecationNote": "", "autowired": false, "secret": false, "description": "Path to the local work file, if local work directory is used.", "constantName": "org.apache.camel.component.smb.SmbConstants#FILE_LOCAL_WORK_PATH" }, - "CamelSmbFileExists": { "index": 15, "kind": "header", "displayName": "", "group": "producer", "label": "producer", "required": false, "javaType": "org.apache.camel.component.file.GenericFileExist", "enum": [ "Override", "Append", "Fail", "Ignore", "Move", "TryRename" ], "deprecated": true, "deprecationNote": "", "autowired": false, "secret": false, "description": "The expected behavior if the file already exists.", "constantName": "org.apache.camel.component.smb.SmbConstants#SMB_FIL [...] + "CamelSmbFileExists": { "index": 15, "kind": "header", "displayName": "", "group": "producer", "label": "producer", "required": false, "javaType": "org.apache.camel.component.file.GenericFileExist", "enum": [ "Override", "Append", "Fail", "Ignore", "Move", "TryRename" ], "deprecated": true, "deprecationNote": "", "autowired": false, "secret": false, "description": "The expected behavior if the file already exists.", "constantName": "org.apache.camel.component.smb.SmbConstants#SMB_FIL [...] + "CamelSmbUncPath": { "index": 16, "kind": "header", "displayName": "", "group": "consumer", "label": "consumer", "required": false, "javaType": "String", "deprecated": false, "deprecationNote": "", "autowired": false, "secret": false, "description": "UNC path to the retrieved file", "constantName": "org.apache.camel.component.smb.SmbConstants#SMB_UNC_PATH" } }, "properties": { "hostname": { "index": 0, "kind": "path", "displayName": "Hostname", "group": "common", "label": "", "required": true, "type": "string", "javaType": "java.lang.String", "deprecated": false, "deprecationNote": "", "autowired": false, "secret": false, "configurationClass": "org.apache.camel.component.smb.SmbConfiguration", "configurationField": "configuration", "description": "The share hostname or IP address" }, diff --git a/components/camel-smb/src/generated/resources/META-INF/org/apache/camel/component/smb/smb.json b/components/camel-smb/src/generated/resources/META-INF/org/apache/camel/component/smb/smb.json index aad41b0e5bb..3f242e27660 100644 --- a/components/camel-smb/src/generated/resources/META-INF/org/apache/camel/component/smb/smb.json +++ b/components/camel-smb/src/generated/resources/META-INF/org/apache/camel/component/smb/smb.json @@ -46,7 +46,8 @@ "CamelFileHost": { "index": 12, "kind": "header", "displayName": "", "group": "consumer", "label": "consumer", "required": false, "javaType": "String", "deprecated": false, "deprecationNote": "", "autowired": false, "secret": false, "description": "The remote hostname.", "constantName": "org.apache.camel.component.smb.SmbConstants#FILE_HOST" }, "CamelSmbFileInputStream": { "index": 13, "kind": "header", "displayName": "", "group": "consumer", "label": "consumer", "required": false, "javaType": "java.io.InputStream", "deprecated": false, "deprecationNote": "", "autowired": false, "secret": false, "description": "The remote file input stream.", "constantName": "org.apache.camel.component.smb.SmbConstants#SMB_FILE_INPUT_STREAM" }, "CamelFileLocalWorkPath": { "index": 14, "kind": "header", "displayName": "", "group": "common", "label": "", "required": false, "javaType": "String", "deprecated": false, "deprecationNote": "", "autowired": false, "secret": false, "description": "Path to the local work file, if local work directory is used.", "constantName": "org.apache.camel.component.smb.SmbConstants#FILE_LOCAL_WORK_PATH" }, - "CamelSmbFileExists": { "index": 15, "kind": "header", "displayName": "", "group": "producer", "label": "producer", "required": false, "javaType": "org.apache.camel.component.file.GenericFileExist", "enum": [ "Override", "Append", "Fail", "Ignore", "Move", "TryRename" ], "deprecated": true, "deprecationNote": "", "autowired": false, "secret": false, "description": "The expected behavior if the file already exists.", "constantName": "org.apache.camel.component.smb.SmbConstants#SMB_FIL [...] + "CamelSmbFileExists": { "index": 15, "kind": "header", "displayName": "", "group": "producer", "label": "producer", "required": false, "javaType": "org.apache.camel.component.file.GenericFileExist", "enum": [ "Override", "Append", "Fail", "Ignore", "Move", "TryRename" ], "deprecated": true, "deprecationNote": "", "autowired": false, "secret": false, "description": "The expected behavior if the file already exists.", "constantName": "org.apache.camel.component.smb.SmbConstants#SMB_FIL [...] + "CamelSmbUncPath": { "index": 16, "kind": "header", "displayName": "", "group": "consumer", "label": "consumer", "required": false, "javaType": "String", "deprecated": false, "deprecationNote": "", "autowired": false, "secret": false, "description": "UNC path to the retrieved file", "constantName": "org.apache.camel.component.smb.SmbConstants#SMB_UNC_PATH" } }, "properties": { "hostname": { "index": 0, "kind": "path", "displayName": "Hostname", "group": "common", "label": "", "required": true, "type": "string", "javaType": "java.lang.String", "deprecated": false, "deprecationNote": "", "autowired": false, "secret": false, "configurationClass": "org.apache.camel.component.smb.SmbConfiguration", "configurationField": "configuration", "description": "The share hostname or IP address" }, diff --git a/components/camel-smb/src/main/docs/smb-component.adoc b/components/camel-smb/src/main/docs/smb-component.adoc index 97a08949a08..6b351270799 100644 --- a/components/camel-smb/src/main/docs/smb-component.adoc +++ b/components/camel-smb/src/main/docs/smb-component.adoc @@ -101,6 +101,8 @@ public void configure() { Beware that the File object provided is not a `java.io.File` instance, but, instead a `org.apache.camel.component.smb.SmbFile` instance that extends Camel's `GenericFile`. Relying on the underlying implementation may make your code more susceptible to problems between version upgrades of the library used to implement this component. + +To maintain backward compatibility, a new Camel Header `CamelSmbUncPath` has been introduced that provides the full absolute path when a File is consumed from the SMB server. ==== diff --git a/components/camel-smb/src/main/java/org/apache/camel/component/smb/SmbConstants.java b/components/camel-smb/src/main/java/org/apache/camel/component/smb/SmbConstants.java index b3d10f388b0..6a6abc590eb 100644 --- a/components/camel-smb/src/main/java/org/apache/camel/component/smb/SmbConstants.java +++ b/components/camel-smb/src/main/java/org/apache/camel/component/smb/SmbConstants.java @@ -81,4 +81,6 @@ public class SmbConstants { javaType = "org.apache.camel.component.file.GenericFileExist") @Deprecated public static final String SMB_FILE_EXISTS = "CamelSmbFileExists"; + @Metadata(label = "consumer", description = "UNC path to the retrieved file", javaType = "String") + public static final String SMB_UNC_PATH = "CamelSmbUncPath"; } diff --git a/components/camel-smb/src/main/java/org/apache/camel/component/smb/SmbOperations.java b/components/camel-smb/src/main/java/org/apache/camel/component/smb/SmbOperations.java index 28ef8efbd24..333d28b0092 100644 --- a/components/camel-smb/src/main/java/org/apache/camel/component/smb/SmbOperations.java +++ b/components/camel-smb/src/main/java/org/apache/camel/component/smb/SmbOperations.java @@ -240,6 +240,8 @@ public class SmbOperations implements SmbFileOperations { throw new GenericFileOperationFailedException(e.getMessage(), e); } } + + exchange.getIn().setHeader(SmbConstants.SMB_UNC_PATH, shareFile.getUncPath()); } return true; } @@ -291,6 +293,8 @@ public class SmbOperations implements SmbFileOperations { // store content as a file in the local work directory in the temp handle java.nio.file.Files.copy(is, temp.toPath(), StandardCopyOption.REPLACE_EXISTING); } + + exchange.getIn().setHeader(SmbConstants.SMB_UNC_PATH, shareFile.getUncPath()); } } catch (IOException e) { @@ -508,6 +512,7 @@ public class SmbOperations implements SmbFileOperations { SMB2ShareAccess.ALL, SMB2CreateDisposition.FILE_OPEN, null); InputStream is = shareFile.getInputStream(); exchange.getIn().setHeader(SmbComponent.SMB_FILE_INPUT_STREAM, is); + exchange.getIn().setHeader(SmbConstants.SMB_UNC_PATH, shareFile.getUncPath()); return is; } diff --git a/components/camel-smb/src/test/java/org/apache/camel/component/smb/SmbComponentIT.java b/components/camel-smb/src/test/java/org/apache/camel/component/smb/SmbComponentIT.java index 6d3e02cc8c2..c2d4b34c8da 100644 --- a/components/camel-smb/src/test/java/org/apache/camel/component/smb/SmbComponentIT.java +++ b/components/camel-smb/src/test/java/org/apache/camel/component/smb/SmbComponentIT.java @@ -48,6 +48,7 @@ public class SmbComponentIT extends CamelTestSupport { public void testSmbRead() throws Exception { MockEndpoint mock = getMockEndpoint("mock:result"); mock.expectedMessageCount(100); + mock.allMessages().header(SmbConstants.SMB_UNC_PATH).startsWith("\\\\localhost\\data-rw\\"); mock.assertIsSatisfied(); } @@ -55,7 +56,7 @@ public class SmbComponentIT extends CamelTestSupport { @Test public void testSmbSendFile() throws Exception { mockResultEndpoint.expectedMinimumMessageCount(1); - Exchange exchange = template.request("direct:smbSendFile", null); + template.request("direct:smbSendFile", null); MockEndpoint.assertIsSatisfied(context); } diff --git a/dsl/camel-endpointdsl/src/generated/java/org/apache/camel/builder/endpoint/dsl/SmbEndpointBuilderFactory.java b/dsl/camel-endpointdsl/src/generated/java/org/apache/camel/builder/endpoint/dsl/SmbEndpointBuilderFactory.java index 3718d0077a4..04d92079573 100644 --- a/dsl/camel-endpointdsl/src/generated/java/org/apache/camel/builder/endpoint/dsl/SmbEndpointBuilderFactory.java +++ b/dsl/camel-endpointdsl/src/generated/java/org/apache/camel/builder/endpoint/dsl/SmbEndpointBuilderFactory.java @@ -3909,6 +3909,18 @@ public interface SmbEndpointBuilderFactory { public String smbFileExists() { return "CamelSmbFileExists"; } + /** + * UNC path to the retrieved file. + * + * The option is a: {@code String} type. + * + * Group: consumer + * + * @return the name of the header {@code SmbUncPath}. + */ + public String smbUncPath() { + return "CamelSmbUncPath"; + } } static SmbEndpointBuilder endpointBuilder(String componentName, String path) { class SmbEndpointBuilderImpl extends AbstractEndpointBuilder implements SmbEndpointBuilder, AdvancedSmbEndpointBuilder {