This is an automated email from the ASF dual-hosted git repository. orpiske pushed a commit to branch main in repository https://gitbox.apache.org/repos/asf/camel.git
commit 44c2167fd36dd88211c9c4321347e6c875993d16 Author: Tom Cunningham <tcunn...@redhat.com> AuthorDate: Wed Jun 12 13:51:53 2024 -0400 Refresh camel-smb --- .../org/apache/camel/catalog/components/smb.json | 60 +- .../apache/camel/catalog/schemas/camel-spring.xsd | 50 +- components/camel-smb/pom.xml | 5 + .../component/smb/SmbComponentConfigurer.java | 6 + .../camel/component/smb/SmbEndpointConfigurer.java | 18 + .../camel/component/smb/SmbEndpointUriFactory.java | 5 +- .../org/apache/camel/component/smb/smb.json | 60 +- .../camel-smb/src/main/docs/smb-component.adoc | 2 +- .../camel/component/smb/SmbConfiguration.java | 31 + .../apache/camel/component/smb/SmbConstants.java | 25 + .../apache/camel/component/smb/SmbEndpoint.java | 3 +- .../apache/camel/component/smb/SmbProducer.java | 239 ++++++++ .../apache/camel/component/smb/SmbComponentIT.java | 16 + .../component/dsl/SmbComponentBuilderFactory.java | 26 + .../endpoint/dsl/SmbEndpointBuilderFactory.java | 626 ++++++++++++++++++--- .../apache/camel/kotlin/components/SmbUriDsl.kt | 59 +- 16 files changed, 1050 insertions(+), 181 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 3f9a64b3769..f51cf35fb33 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 @@ -17,46 +17,50 @@ "syntax": "smb:hostname:port\/shareName", "async": false, "api": false, - "consumerOnly": true, + "consumerOnly": false, "producerOnly": false, "lenientProperties": false, "remote": true }, "componentProperties": { "bridgeErrorHandler": { "index": 0, "kind": "property", "displayName": "Bridge Error Handler", "group": "consumer", "label": "consumer", "required": false, "type": "boolean", "javaType": "boolean", "deprecated": false, "autowired": false, "secret": false, "defaultValue": false, "description": "Allows for bridging the consumer to the Camel routing Error Handler, which mean any exceptions (if possible) occurred while the Camel consumer is trying to pickup incoming messages, or the like [...] - "autowiredEnabled": { "index": 1, "kind": "property", "displayName": "Autowired Enabled", "group": "advanced", "label": "advanced", "required": false, "type": "boolean", "javaType": "boolean", "deprecated": false, "autowired": false, "secret": false, "defaultValue": true, "description": "Whether autowiring is enabled. This is used for automatic autowiring options (the option must be marked as autowired) by looking up in the registry to find if there is a single instance of matching t [...] + "lazyStartProducer": { "index": 1, "kind": "property", "displayName": "Lazy Start Producer", "group": "producer", "label": "producer", "required": false, "type": "boolean", "javaType": "boolean", "deprecated": false, "autowired": false, "secret": false, "defaultValue": false, "description": "Whether the producer should be started lazy (on the first message). By starting lazy you can use this to allow CamelContext and routes to startup in situations where a producer may otherwise fail [...] + "autowiredEnabled": { "index": 2, "kind": "property", "displayName": "Autowired Enabled", "group": "advanced", "label": "advanced", "required": false, "type": "boolean", "javaType": "boolean", "deprecated": false, "autowired": false, "secret": false, "defaultValue": true, "description": "Whether autowiring is enabled. This is used for automatic autowiring options (the option must be marked as autowired) by looking up in the registry to find if there is a single instance of matching t [...] }, "properties": { - "hostname": { "index": 0, "kind": "path", "displayName": "Hostname", "group": "consumer", "label": "", "required": true, "type": "string", "javaType": "java.lang.String", "deprecated": false, "deprecationNote": "", "autowired": false, "secret": false, "description": "The share hostname or IP address" }, - "port": { "index": 1, "kind": "path", "displayName": "Port", "group": "consumer", "label": "", "required": false, "type": "integer", "javaType": "int", "deprecated": false, "autowired": false, "secret": false, "defaultValue": 445, "description": "The share port number" }, - "shareName": { "index": 2, "kind": "path", "displayName": "Share Name", "group": "consumer", "label": "", "required": true, "type": "string", "javaType": "java.lang.String", "deprecated": false, "deprecationNote": "", "autowired": false, "secret": false, "description": "The name of the share to connect to." }, - "path": { "index": 3, "kind": "parameter", "displayName": "Path", "group": "consumer", "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 path, within the share, to consume the files from" }, - "recursive": { "index": 4, "kind": "parameter", "displayName": "Recursive", "group": "consumer", "label": "consumer", "required": false, "type": "boolean", "javaType": "boolean", "deprecated": false, "autowired": false, "secret": false, "defaultValue": false, "configurationClass": "org.apache.camel.component.smb.SmbConfiguration", "configurationField": "configuration", "description": "If a directory, will look for files in all the sub-directories as well." }, - "searchPattern": { "index": 5, "kind": "parameter", "displayName": "Search Pattern", "group": "consumer", "label": "", "required": false, "type": "string", "javaType": "java.lang.String", "deprecated": false, "autowired": false, "secret": false, "defaultValue": "*.txt", "configurationClass": "org.apache.camel.component.smb.SmbConfiguration", "configurationField": "configuration", "description": "The search pattern used to list the files" }, + "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, "description": "The share hostname or IP address" }, + "port": { "index": 1, "kind": "path", "displayName": "Port", "group": "common", "label": "", "required": false, "type": "integer", "javaType": "int", "deprecated": false, "autowired": false, "secret": false, "defaultValue": 445, "description": "The share port number" }, + "shareName": { "index": 2, "kind": "path", "displayName": "Share Name", "group": "common", "label": "", "required": true, "type": "string", "javaType": "java.lang.String", "deprecated": false, "deprecationNote": "", "autowired": false, "secret": false, "description": "The name of the share to connect to." }, + "path": { "index": 3, "kind": "parameter", "displayName": "Path", "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 path, within the share, to consume the files from" }, + "searchPattern": { "index": 4, "kind": "parameter", "displayName": "Search Pattern", "group": "common", "label": "", "required": false, "type": "string", "javaType": "java.lang.String", "deprecated": false, "autowired": false, "secret": false, "defaultValue": "*.txt", "configurationClass": "org.apache.camel.component.smb.SmbConfiguration", "configurationField": "configuration", "description": "The search pattern used to list the files" }, + "recursive": { "index": 5, "kind": "parameter", "displayName": "Recursive", "group": "consumer", "label": "consumer", "required": false, "type": "boolean", "javaType": "boolean", "deprecated": false, "autowired": false, "secret": false, "defaultValue": false, "configurationClass": "org.apache.camel.component.smb.SmbConfiguration", "configurationField": "configuration", "description": "If a directory, will look for files in all the sub-directories as well." }, "sendEmptyMessageWhenIdle": { "index": 6, "kind": "parameter", "displayName": "Send Empty Message When Idle", "group": "consumer", "label": "consumer", "required": false, "type": "boolean", "javaType": "boolean", "deprecated": false, "autowired": false, "secret": false, "defaultValue": false, "description": "If the polling consumer did not poll any files, you can enable this option to send an empty message (no body) instead." }, "bridgeErrorHandler": { "index": 7, "kind": "parameter", "displayName": "Bridge Error Handler", "group": "consumer (advanced)", "label": "consumer,advanced", "required": false, "type": "boolean", "javaType": "boolean", "deprecated": false, "autowired": false, "secret": false, "defaultValue": false, "description": "Allows for bridging the consumer to the Camel routing Error Handler, which mean any exceptions (if possible) occurred while the Camel consumer is trying to pickup incoming [...] "exceptionHandler": { "index": 8, "kind": "parameter", "displayName": "Exception Handler", "group": "consumer (advanced)", "label": "consumer,advanced", "required": false, "type": "object", "javaType": "org.apache.camel.spi.ExceptionHandler", "optionalPrefix": "consumer.", "deprecated": false, "autowired": false, "secret": false, "description": "To let the consumer use a custom ExceptionHandler. Notice if the option bridgeErrorHandler is enabled then this option is not in use. By def [...] "exchangePattern": { "index": 9, "kind": "parameter", "displayName": "Exchange Pattern", "group": "consumer (advanced)", "label": "consumer,advanced", "required": false, "type": "object", "javaType": "org.apache.camel.ExchangePattern", "enum": [ "InOnly", "InOut" ], "deprecated": false, "autowired": false, "secret": false, "description": "Sets the exchange pattern when the consumer creates an exchange." }, "pollStrategy": { "index": 10, "kind": "parameter", "displayName": "Poll Strategy", "group": "consumer (advanced)", "label": "consumer,advanced", "required": false, "type": "object", "javaType": "org.apache.camel.spi.PollingConsumerPollStrategy", "deprecated": false, "autowired": false, "secret": false, "description": "A pluggable org.apache.camel.PollingConsumerPollingStrategy allowing you to provide your custom implementation to control error handling usually occurred during the po [...] - "idempotentRepository": { "index": 11, "kind": "parameter", "displayName": "Idempotent Repository", "group": "advanced", "label": "advanced", "required": false, "type": "object", "javaType": "org.apache.camel.spi.IdempotentRepository", "deprecated": false, "autowired": false, "secret": false, "configurationClass": "org.apache.camel.component.smb.SmbConfiguration", "configurationField": "configuration", "description": "A pluggable repository org.apache.camel.spi.IdempotentRepository w [...] - "smbConfig": { "index": 12, "kind": "parameter", "displayName": "Smb Config", "group": "advanced", "label": "advanced", "required": false, "type": "object", "javaType": "com.hierynomus.smbj.SmbConfig", "deprecated": false, "deprecationNote": "", "autowired": true, "secret": false, "configurationClass": "org.apache.camel.component.smb.SmbConfiguration", "configurationField": "configuration", "description": "An optional SMB client configuration, can be used to configure client specific [...] - "smbIoBean": { "index": 13, "kind": "parameter", "displayName": "Smb Io Bean", "group": "advanced", "label": "advanced", "required": false, "type": "object", "javaType": "org.apache.camel.component.smb.SmbIOBean", "deprecated": false, "autowired": false, "secret": false, "configurationClass": "org.apache.camel.component.smb.SmbConfiguration", "configurationField": "configuration", "description": "An optional SMB I\/O bean to use to setup the file access attributes when reading\/writi [...] - "backoffErrorThreshold": { "index": 14, "kind": "parameter", "displayName": "Backoff Error Threshold", "group": "scheduler", "label": "consumer,scheduler", "required": false, "type": "integer", "javaType": "int", "deprecated": false, "autowired": false, "secret": false, "description": "The number of subsequent error polls (failed due some error) that should happen before the backoffMultipler should kick-in." }, - "backoffIdleThreshold": { "index": 15, "kind": "parameter", "displayName": "Backoff Idle Threshold", "group": "scheduler", "label": "consumer,scheduler", "required": false, "type": "integer", "javaType": "int", "deprecated": false, "autowired": false, "secret": false, "description": "The number of subsequent idle polls that should happen before the backoffMultipler should kick-in." }, - "backoffMultiplier": { "index": 16, "kind": "parameter", "displayName": "Backoff Multiplier", "group": "scheduler", "label": "consumer,scheduler", "required": false, "type": "integer", "javaType": "int", "deprecated": false, "autowired": false, "secret": false, "description": "To let the scheduled polling consumer backoff if there has been a number of subsequent idles\/errors in a row. The multiplier is then the number of polls that will be skipped before the next actual attempt is h [...] - "delay": { "index": 17, "kind": "parameter", "displayName": "Delay", "group": "scheduler", "label": "consumer,scheduler", "required": false, "type": "integer", "javaType": "long", "deprecated": false, "autowired": false, "secret": false, "defaultValue": 500, "description": "Milliseconds before the next poll." }, - "greedy": { "index": 18, "kind": "parameter", "displayName": "Greedy", "group": "scheduler", "label": "consumer,scheduler", "required": false, "type": "boolean", "javaType": "boolean", "deprecated": false, "autowired": false, "secret": false, "defaultValue": false, "description": "If greedy is enabled, then the ScheduledPollConsumer will run immediately again, if the previous run polled 1 or more messages." }, - "initialDelay": { "index": 19, "kind": "parameter", "displayName": "Initial Delay", "group": "scheduler", "label": "consumer,scheduler", "required": false, "type": "integer", "javaType": "long", "deprecated": false, "autowired": false, "secret": false, "defaultValue": 1000, "description": "Milliseconds before the first poll starts." }, - "repeatCount": { "index": 20, "kind": "parameter", "displayName": "Repeat Count", "group": "scheduler", "label": "consumer,scheduler", "required": false, "type": "integer", "javaType": "long", "deprecated": false, "autowired": false, "secret": false, "defaultValue": 0, "description": "Specifies a maximum limit of number of fires. So if you set it to 1, the scheduler will only fire once. If you set it to 5, it will only fire five times. A value of zero or negative means fire forever." }, - "runLoggingLevel": { "index": 21, "kind": "parameter", "displayName": "Run Logging Level", "group": "scheduler", "label": "consumer,scheduler", "required": false, "type": "object", "javaType": "org.apache.camel.LoggingLevel", "enum": [ "TRACE", "DEBUG", "INFO", "WARN", "ERROR", "OFF" ], "deprecated": false, "autowired": false, "secret": false, "defaultValue": "TRACE", "description": "The consumer logs a start\/complete log line when it polls. This option allows you to configure the l [...] - "scheduledExecutorService": { "index": 22, "kind": "parameter", "displayName": "Scheduled Executor Service", "group": "scheduler", "label": "consumer,scheduler", "required": false, "type": "object", "javaType": "java.util.concurrent.ScheduledExecutorService", "deprecated": false, "autowired": false, "secret": false, "description": "Allows for configuring a custom\/shared thread pool to use for the consumer. By default each consumer has its own single threaded thread pool." }, - "scheduler": { "index": 23, "kind": "parameter", "displayName": "Scheduler", "group": "scheduler", "label": "consumer,scheduler", "required": false, "type": "object", "javaType": "java.lang.Object", "deprecated": false, "autowired": false, "secret": false, "defaultValue": "none", "description": "To use a cron scheduler from either camel-spring or camel-quartz component. Use value spring or quartz for built in scheduler" }, - "schedulerProperties": { "index": 24, "kind": "parameter", "displayName": "Scheduler Properties", "group": "scheduler", "label": "consumer,scheduler", "required": false, "type": "object", "javaType": "java.util.Map<java.lang.String, java.lang.Object>", "prefix": "scheduler.", "multiValue": true, "deprecated": false, "autowired": false, "secret": false, "description": "To configure additional properties when using a custom scheduler or any of the Quartz, Spring based scheduler." }, - "startScheduler": { "index": 25, "kind": "parameter", "displayName": "Start Scheduler", "group": "scheduler", "label": "consumer,scheduler", "required": false, "type": "boolean", "javaType": "boolean", "deprecated": false, "autowired": false, "secret": false, "defaultValue": true, "description": "Whether the scheduler should be auto started." }, - "timeUnit": { "index": 26, "kind": "parameter", "displayName": "Time Unit", "group": "scheduler", "label": "consumer,scheduler", "required": false, "type": "object", "javaType": "java.util.concurrent.TimeUnit", "enum": [ "NANOSECONDS", "MICROSECONDS", "MILLISECONDS", "SECONDS", "MINUTES", "HOURS", "DAYS" ], "deprecated": false, "autowired": false, "secret": false, "defaultValue": "MILLISECONDS", "description": "Time unit for initialDelay and delay options." }, - "useFixedDelay": { "index": 27, "kind": "parameter", "displayName": "Use Fixed Delay", "group": "scheduler", "label": "consumer,scheduler", "required": false, "type": "boolean", "javaType": "boolean", "deprecated": false, "autowired": false, "secret": false, "defaultValue": true, "description": "Controls if fixed delay or fixed rate is used. See ScheduledExecutorService in JDK for details." }, - "domain": { "index": 28, "kind": "parameter", "displayName": "Domain", "group": "security", "label": "security", "required": false, "type": "string", "javaType": "java.lang.String", "deprecated": false, "autowired": false, "secret": false, "configurationClass": "org.apache.camel.component.smb.SmbConfiguration", "configurationField": "configuration", "description": "The user domain" }, - "password": { "index": 29, "kind": "parameter", "displayName": "Password", "group": "security", "label": "security", "required": false, "type": "string", "javaType": "java.lang.String", "deprecated": false, "autowired": false, "secret": true, "configurationClass": "org.apache.camel.component.smb.SmbConfiguration", "configurationField": "configuration", "description": "The password to access the share" }, - "username": { "index": 30, "kind": "parameter", "displayName": "Username", "group": "security", "label": "security", "required": false, "type": "string", "javaType": "java.lang.String", "deprecated": false, "autowired": false, "secret": true, "configurationClass": "org.apache.camel.component.smb.SmbConfiguration", "configurationField": "configuration", "description": "The username required to access the share" } + "autoCreate": { "index": 11, "kind": "parameter", "displayName": "Auto Create", "group": "producer", "label": "producer", "required": false, "type": "boolean", "javaType": "boolean", "deprecated": false, "deprecationNote": "", "autowired": false, "secret": false, "defaultValue": false, "configurationClass": "org.apache.camel.component.smb.SmbConfiguration", "configurationField": "configuration", "description": "Whether to create parent directory if it does not exist" }, + "fileExist": { "index": 12, "kind": "parameter", "displayName": "File Exist", "group": "producer", "label": "producer", "required": false, "type": "object", "javaType": "org.apache.camel.component.file.GenericFileExist", "enum": [ "Override", "Append", "Fail", "Ignore", "Move", "TryRename" ], "deprecated": false, "deprecationNote": "", "autowired": false, "secret": false, "defaultValue": "Ignore", "configurationClass": "org.apache.camel.component.smb.SmbConfiguration", "configuration [...] + "lazyStartProducer": { "index": 13, "kind": "parameter", "displayName": "Lazy Start Producer", "group": "producer (advanced)", "label": "producer,advanced", "required": false, "type": "boolean", "javaType": "boolean", "deprecated": false, "autowired": false, "secret": false, "defaultValue": false, "description": "Whether the producer should be started lazy (on the first message). By starting lazy you can use this to allow CamelContext and routes to startup in situations where a produ [...] + "idempotentRepository": { "index": 14, "kind": "parameter", "displayName": "Idempotent Repository", "group": "advanced", "label": "advanced", "required": false, "type": "object", "javaType": "org.apache.camel.spi.IdempotentRepository", "deprecated": false, "autowired": false, "secret": false, "configurationClass": "org.apache.camel.component.smb.SmbConfiguration", "configurationField": "configuration", "description": "A pluggable repository org.apache.camel.spi.IdempotentRepository w [...] + "smbConfig": { "index": 15, "kind": "parameter", "displayName": "Smb Config", "group": "advanced", "label": "advanced", "required": false, "type": "object", "javaType": "com.hierynomus.smbj.SmbConfig", "deprecated": false, "deprecationNote": "", "autowired": true, "secret": false, "configurationClass": "org.apache.camel.component.smb.SmbConfiguration", "configurationField": "configuration", "description": "An optional SMB client configuration, can be used to configure client specific [...] + "smbIoBean": { "index": 16, "kind": "parameter", "displayName": "Smb Io Bean", "group": "advanced", "label": "advanced", "required": false, "type": "object", "javaType": "org.apache.camel.component.smb.SmbIOBean", "deprecated": false, "autowired": false, "secret": false, "configurationClass": "org.apache.camel.component.smb.SmbConfiguration", "configurationField": "configuration", "description": "An optional SMB I\/O bean to use to setup the file access attributes when reading\/writi [...] + "backoffErrorThreshold": { "index": 17, "kind": "parameter", "displayName": "Backoff Error Threshold", "group": "scheduler", "label": "consumer,scheduler", "required": false, "type": "integer", "javaType": "int", "deprecated": false, "autowired": false, "secret": false, "description": "The number of subsequent error polls (failed due some error) that should happen before the backoffMultipler should kick-in." }, + "backoffIdleThreshold": { "index": 18, "kind": "parameter", "displayName": "Backoff Idle Threshold", "group": "scheduler", "label": "consumer,scheduler", "required": false, "type": "integer", "javaType": "int", "deprecated": false, "autowired": false, "secret": false, "description": "The number of subsequent idle polls that should happen before the backoffMultipler should kick-in." }, + "backoffMultiplier": { "index": 19, "kind": "parameter", "displayName": "Backoff Multiplier", "group": "scheduler", "label": "consumer,scheduler", "required": false, "type": "integer", "javaType": "int", "deprecated": false, "autowired": false, "secret": false, "description": "To let the scheduled polling consumer backoff if there has been a number of subsequent idles\/errors in a row. The multiplier is then the number of polls that will be skipped before the next actual attempt is h [...] + "delay": { "index": 20, "kind": "parameter", "displayName": "Delay", "group": "scheduler", "label": "consumer,scheduler", "required": false, "type": "integer", "javaType": "long", "deprecated": false, "autowired": false, "secret": false, "defaultValue": 500, "description": "Milliseconds before the next poll." }, + "greedy": { "index": 21, "kind": "parameter", "displayName": "Greedy", "group": "scheduler", "label": "consumer,scheduler", "required": false, "type": "boolean", "javaType": "boolean", "deprecated": false, "autowired": false, "secret": false, "defaultValue": false, "description": "If greedy is enabled, then the ScheduledPollConsumer will run immediately again, if the previous run polled 1 or more messages." }, + "initialDelay": { "index": 22, "kind": "parameter", "displayName": "Initial Delay", "group": "scheduler", "label": "consumer,scheduler", "required": false, "type": "integer", "javaType": "long", "deprecated": false, "autowired": false, "secret": false, "defaultValue": 1000, "description": "Milliseconds before the first poll starts." }, + "repeatCount": { "index": 23, "kind": "parameter", "displayName": "Repeat Count", "group": "scheduler", "label": "consumer,scheduler", "required": false, "type": "integer", "javaType": "long", "deprecated": false, "autowired": false, "secret": false, "defaultValue": 0, "description": "Specifies a maximum limit of number of fires. So if you set it to 1, the scheduler will only fire once. If you set it to 5, it will only fire five times. A value of zero or negative means fire forever." }, + "runLoggingLevel": { "index": 24, "kind": "parameter", "displayName": "Run Logging Level", "group": "scheduler", "label": "consumer,scheduler", "required": false, "type": "object", "javaType": "org.apache.camel.LoggingLevel", "enum": [ "TRACE", "DEBUG", "INFO", "WARN", "ERROR", "OFF" ], "deprecated": false, "autowired": false, "secret": false, "defaultValue": "TRACE", "description": "The consumer logs a start\/complete log line when it polls. This option allows you to configure the l [...] + "scheduledExecutorService": { "index": 25, "kind": "parameter", "displayName": "Scheduled Executor Service", "group": "scheduler", "label": "consumer,scheduler", "required": false, "type": "object", "javaType": "java.util.concurrent.ScheduledExecutorService", "deprecated": false, "autowired": false, "secret": false, "description": "Allows for configuring a custom\/shared thread pool to use for the consumer. By default each consumer has its own single threaded thread pool." }, + "scheduler": { "index": 26, "kind": "parameter", "displayName": "Scheduler", "group": "scheduler", "label": "consumer,scheduler", "required": false, "type": "object", "javaType": "java.lang.Object", "deprecated": false, "autowired": false, "secret": false, "defaultValue": "none", "description": "To use a cron scheduler from either camel-spring or camel-quartz component. Use value spring or quartz for built in scheduler" }, + "schedulerProperties": { "index": 27, "kind": "parameter", "displayName": "Scheduler Properties", "group": "scheduler", "label": "consumer,scheduler", "required": false, "type": "object", "javaType": "java.util.Map<java.lang.String, java.lang.Object>", "prefix": "scheduler.", "multiValue": true, "deprecated": false, "autowired": false, "secret": false, "description": "To configure additional properties when using a custom scheduler or any of the Quartz, Spring based scheduler." }, + "startScheduler": { "index": 28, "kind": "parameter", "displayName": "Start Scheduler", "group": "scheduler", "label": "consumer,scheduler", "required": false, "type": "boolean", "javaType": "boolean", "deprecated": false, "autowired": false, "secret": false, "defaultValue": true, "description": "Whether the scheduler should be auto started." }, + "timeUnit": { "index": 29, "kind": "parameter", "displayName": "Time Unit", "group": "scheduler", "label": "consumer,scheduler", "required": false, "type": "object", "javaType": "java.util.concurrent.TimeUnit", "enum": [ "NANOSECONDS", "MICROSECONDS", "MILLISECONDS", "SECONDS", "MINUTES", "HOURS", "DAYS" ], "deprecated": false, "autowired": false, "secret": false, "defaultValue": "MILLISECONDS", "description": "Time unit for initialDelay and delay options." }, + "useFixedDelay": { "index": 30, "kind": "parameter", "displayName": "Use Fixed Delay", "group": "scheduler", "label": "consumer,scheduler", "required": false, "type": "boolean", "javaType": "boolean", "deprecated": false, "autowired": false, "secret": false, "defaultValue": true, "description": "Controls if fixed delay or fixed rate is used. See ScheduledExecutorService in JDK for details." }, + "domain": { "index": 31, "kind": "parameter", "displayName": "Domain", "group": "security", "label": "security", "required": false, "type": "string", "javaType": "java.lang.String", "deprecated": false, "autowired": false, "secret": false, "configurationClass": "org.apache.camel.component.smb.SmbConfiguration", "configurationField": "configuration", "description": "The user domain" }, + "password": { "index": 32, "kind": "parameter", "displayName": "Password", "group": "security", "label": "security", "required": false, "type": "string", "javaType": "java.lang.String", "deprecated": false, "autowired": false, "secret": true, "configurationClass": "org.apache.camel.component.smb.SmbConfiguration", "configurationField": "configuration", "description": "The password to access the share" }, + "username": { "index": 33, "kind": "parameter", "displayName": "Username", "group": "security", "label": "security", "required": false, "type": "string", "javaType": "java.lang.String", "deprecated": false, "autowired": false, "secret": true, "configurationClass": "org.apache.camel.component.smb.SmbConfiguration", "configurationField": "configuration", "description": "The username required to access the share" } } } diff --git a/catalog/camel-catalog/src/generated/resources/org/apache/camel/catalog/schemas/camel-spring.xsd b/catalog/camel-catalog/src/generated/resources/org/apache/camel/catalog/schemas/camel-spring.xsd index e92a71aeca2..ece74309fe5 100644 --- a/catalog/camel-catalog/src/generated/resources/org/apache/camel/catalog/schemas/camel-spring.xsd +++ b/catalog/camel-catalog/src/generated/resources/org/apache/camel/catalog/schemas/camel-spring.xsd @@ -75,7 +75,7 @@ Configures batch-processing resequence eip. <xs:annotation> <xs:documentation xml:lang="en"> <![CDATA[ -Calls a Java bean +Define custom beans that can be used in your Camel routes and in general. ]]> </xs:documentation> </xs:annotation> @@ -3973,50 +3973,10 @@ Enables random backoff. Default value: false <xs:complexContent> <xs:extension base="tns:noOutputDefinition"> <xs:sequence/> - <xs:attribute name="ref" type="xs:string"> - <xs:annotation> - <xs:documentation xml:lang="en"> -<![CDATA[ -Sets a reference to an existing bean to use, which is looked up from the registry. -]]> - </xs:documentation> - </xs:annotation> - </xs:attribute> - <xs:attribute name="method" type="xs:string"> - <xs:annotation> - <xs:documentation xml:lang="en"> -<![CDATA[ -Sets the method name on the bean to use. -]]> - </xs:documentation> - </xs:annotation> - </xs:attribute> - <xs:attribute name="beanType" type="xs:string"> - <xs:annotation> - <xs:documentation xml:lang="en"> -<![CDATA[ -Sets the class name (fully qualified) of the bean to use. -]]> - </xs:documentation> - </xs:annotation> - </xs:attribute> - <xs:attribute name="scope" type="xs:string"> - <xs:annotation> - <xs:documentation xml:lang="en"> -<![CDATA[ -Scope of bean. When using singleton scope (default) the bean is created or looked up only once and reused for the -lifetime of the endpoint. The bean should be thread-safe in case concurrent threads is calling the bean at the same -time. When using request scope the bean is created or looked up once per request (exchange). This can be used if you -want to store state on a bean while processing a request and you want to call the same bean instance multiple times -while processing the request. The bean does not have to be thread-safe as the instance is only called from the same -request. When using prototype scope, then the bean will be looked up or created per call. However in case of lookup then -this is delegated to the bean registry such as Spring or CDI (if in use), which depends on their configuration can act -as either singleton or prototype scope. So when using prototype scope then this depends on the bean registry -implementation. Default value: Singleton -]]> - </xs:documentation> - </xs:annotation> - </xs:attribute> + <xs:attribute name="ref" type="xs:string"/> + <xs:attribute name="method" type="xs:string"/> + <xs:attribute name="beanType" type="xs:string"/> + <xs:attribute name="scope" type="xs:string"/> </xs:extension> </xs:complexContent> </xs:complexType> diff --git a/components/camel-smb/pom.xml b/components/camel-smb/pom.xml index c16f659609c..bcef90dd83f 100644 --- a/components/camel-smb/pom.xml +++ b/components/camel-smb/pom.xml @@ -41,6 +41,11 @@ <artifactId>camel-support</artifactId> </dependency> + <dependency> + <groupId>org.apache.camel</groupId> + <artifactId>camel-file</artifactId> + </dependency> + <!-- CIFS --> <dependency> <groupId>com.hierynomus</groupId> diff --git a/components/camel-smb/src/generated/java/org/apache/camel/component/smb/SmbComponentConfigurer.java b/components/camel-smb/src/generated/java/org/apache/camel/component/smb/SmbComponentConfigurer.java index c3d968c7b6d..42dd38d1bed 100644 --- a/components/camel-smb/src/generated/java/org/apache/camel/component/smb/SmbComponentConfigurer.java +++ b/components/camel-smb/src/generated/java/org/apache/camel/component/smb/SmbComponentConfigurer.java @@ -27,6 +27,8 @@ public class SmbComponentConfigurer extends PropertyConfigurerSupport implements case "autowiredEnabled": target.setAutowiredEnabled(property(camelContext, boolean.class, value)); return true; case "bridgeerrorhandler": case "bridgeErrorHandler": target.setBridgeErrorHandler(property(camelContext, boolean.class, value)); return true; + case "lazystartproducer": + case "lazyStartProducer": target.setLazyStartProducer(property(camelContext, boolean.class, value)); return true; default: return false; } } @@ -38,6 +40,8 @@ public class SmbComponentConfigurer extends PropertyConfigurerSupport implements case "autowiredEnabled": return boolean.class; case "bridgeerrorhandler": case "bridgeErrorHandler": return boolean.class; + case "lazystartproducer": + case "lazyStartProducer": return boolean.class; default: return null; } } @@ -50,6 +54,8 @@ public class SmbComponentConfigurer extends PropertyConfigurerSupport implements case "autowiredEnabled": return target.isAutowiredEnabled(); case "bridgeerrorhandler": case "bridgeErrorHandler": return target.isBridgeErrorHandler(); + case "lazystartproducer": + case "lazyStartProducer": return target.isLazyStartProducer(); default: return null; } } diff --git a/components/camel-smb/src/generated/java/org/apache/camel/component/smb/SmbEndpointConfigurer.java b/components/camel-smb/src/generated/java/org/apache/camel/component/smb/SmbEndpointConfigurer.java index aeb1be73cfb..fcdafb1a741 100644 --- a/components/camel-smb/src/generated/java/org/apache/camel/component/smb/SmbEndpointConfigurer.java +++ b/components/camel-smb/src/generated/java/org/apache/camel/component/smb/SmbEndpointConfigurer.java @@ -23,6 +23,8 @@ public class SmbEndpointConfigurer extends PropertyConfigurerSupport implements public boolean configure(CamelContext camelContext, Object obj, String name, Object value, boolean ignoreCase) { SmbEndpoint target = (SmbEndpoint) obj; switch (ignoreCase ? name.toLowerCase() : name) { + case "autocreate": + case "autoCreate": target.getConfiguration().setAutoCreate(property(camelContext, boolean.class, value)); return true; case "backofferrorthreshold": case "backoffErrorThreshold": target.setBackoffErrorThreshold(property(camelContext, int.class, value)); return true; case "backoffidlethreshold": @@ -37,11 +39,15 @@ public class SmbEndpointConfigurer extends PropertyConfigurerSupport implements case "exceptionHandler": target.setExceptionHandler(property(camelContext, org.apache.camel.spi.ExceptionHandler.class, value)); return true; case "exchangepattern": case "exchangePattern": target.setExchangePattern(property(camelContext, org.apache.camel.ExchangePattern.class, value)); return true; + case "fileexist": + case "fileExist": target.getConfiguration().setFileExist(property(camelContext, org.apache.camel.component.file.GenericFileExist.class, value)); return true; case "greedy": target.setGreedy(property(camelContext, boolean.class, value)); return true; case "idempotentrepository": case "idempotentRepository": target.getConfiguration().setIdempotentRepository(property(camelContext, org.apache.camel.spi.IdempotentRepository.class, value)); return true; case "initialdelay": case "initialDelay": target.setInitialDelay(property(camelContext, long.class, value)); return true; + case "lazystartproducer": + case "lazyStartProducer": target.setLazyStartProducer(property(camelContext, boolean.class, value)); return true; case "password": target.getConfiguration().setPassword(property(camelContext, java.lang.String.class, value)); return true; case "path": target.getConfiguration().setPath(property(camelContext, java.lang.String.class, value)); return true; case "pollstrategy": @@ -83,6 +89,8 @@ public class SmbEndpointConfigurer extends PropertyConfigurerSupport implements @Override public Class<?> getOptionType(String name, boolean ignoreCase) { switch (ignoreCase ? name.toLowerCase() : name) { + case "autocreate": + case "autoCreate": return boolean.class; case "backofferrorthreshold": case "backoffErrorThreshold": return int.class; case "backoffidlethreshold": @@ -97,11 +105,15 @@ public class SmbEndpointConfigurer extends PropertyConfigurerSupport implements case "exceptionHandler": return org.apache.camel.spi.ExceptionHandler.class; case "exchangepattern": case "exchangePattern": return org.apache.camel.ExchangePattern.class; + case "fileexist": + case "fileExist": return org.apache.camel.component.file.GenericFileExist.class; case "greedy": return boolean.class; case "idempotentrepository": case "idempotentRepository": return org.apache.camel.spi.IdempotentRepository.class; case "initialdelay": case "initialDelay": return long.class; + case "lazystartproducer": + case "lazyStartProducer": return boolean.class; case "password": return java.lang.String.class; case "path": return java.lang.String.class; case "pollstrategy": @@ -139,6 +151,8 @@ public class SmbEndpointConfigurer extends PropertyConfigurerSupport implements public Object getOptionValue(Object obj, String name, boolean ignoreCase) { SmbEndpoint target = (SmbEndpoint) obj; switch (ignoreCase ? name.toLowerCase() : name) { + case "autocreate": + case "autoCreate": return target.getConfiguration().isAutoCreate(); case "backofferrorthreshold": case "backoffErrorThreshold": return target.getBackoffErrorThreshold(); case "backoffidlethreshold": @@ -153,11 +167,15 @@ public class SmbEndpointConfigurer extends PropertyConfigurerSupport implements case "exceptionHandler": return target.getExceptionHandler(); case "exchangepattern": case "exchangePattern": return target.getExchangePattern(); + case "fileexist": + case "fileExist": return target.getConfiguration().getFileExist(); case "greedy": return target.isGreedy(); case "idempotentrepository": case "idempotentRepository": return target.getConfiguration().getIdempotentRepository(); case "initialdelay": case "initialDelay": return target.getInitialDelay(); + case "lazystartproducer": + case "lazyStartProducer": return target.isLazyStartProducer(); case "password": return target.getConfiguration().getPassword(); case "path": return target.getConfiguration().getPath(); case "pollstrategy": diff --git a/components/camel-smb/src/generated/java/org/apache/camel/component/smb/SmbEndpointUriFactory.java b/components/camel-smb/src/generated/java/org/apache/camel/component/smb/SmbEndpointUriFactory.java index c2ee12bd139..d7987a8c2a2 100644 --- a/components/camel-smb/src/generated/java/org/apache/camel/component/smb/SmbEndpointUriFactory.java +++ b/components/camel-smb/src/generated/java/org/apache/camel/component/smb/SmbEndpointUriFactory.java @@ -23,7 +23,8 @@ public class SmbEndpointUriFactory extends org.apache.camel.support.component.En private static final Set<String> SECRET_PROPERTY_NAMES; private static final Set<String> MULTI_VALUE_PREFIXES; static { - Set<String> props = new HashSet<>(31); + Set<String> props = new HashSet<>(34); + props.add("autoCreate"); props.add("backoffErrorThreshold"); props.add("backoffIdleThreshold"); props.add("backoffMultiplier"); @@ -32,10 +33,12 @@ public class SmbEndpointUriFactory extends org.apache.camel.support.component.En props.add("domain"); props.add("exceptionHandler"); props.add("exchangePattern"); + props.add("fileExist"); props.add("greedy"); props.add("hostname"); props.add("idempotentRepository"); props.add("initialDelay"); + props.add("lazyStartProducer"); props.add("password"); props.add("path"); props.add("pollStrategy"); 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 3f9a64b3769..f51cf35fb33 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 @@ -17,46 +17,50 @@ "syntax": "smb:hostname:port\/shareName", "async": false, "api": false, - "consumerOnly": true, + "consumerOnly": false, "producerOnly": false, "lenientProperties": false, "remote": true }, "componentProperties": { "bridgeErrorHandler": { "index": 0, "kind": "property", "displayName": "Bridge Error Handler", "group": "consumer", "label": "consumer", "required": false, "type": "boolean", "javaType": "boolean", "deprecated": false, "autowired": false, "secret": false, "defaultValue": false, "description": "Allows for bridging the consumer to the Camel routing Error Handler, which mean any exceptions (if possible) occurred while the Camel consumer is trying to pickup incoming messages, or the like [...] - "autowiredEnabled": { "index": 1, "kind": "property", "displayName": "Autowired Enabled", "group": "advanced", "label": "advanced", "required": false, "type": "boolean", "javaType": "boolean", "deprecated": false, "autowired": false, "secret": false, "defaultValue": true, "description": "Whether autowiring is enabled. This is used for automatic autowiring options (the option must be marked as autowired) by looking up in the registry to find if there is a single instance of matching t [...] + "lazyStartProducer": { "index": 1, "kind": "property", "displayName": "Lazy Start Producer", "group": "producer", "label": "producer", "required": false, "type": "boolean", "javaType": "boolean", "deprecated": false, "autowired": false, "secret": false, "defaultValue": false, "description": "Whether the producer should be started lazy (on the first message). By starting lazy you can use this to allow CamelContext and routes to startup in situations where a producer may otherwise fail [...] + "autowiredEnabled": { "index": 2, "kind": "property", "displayName": "Autowired Enabled", "group": "advanced", "label": "advanced", "required": false, "type": "boolean", "javaType": "boolean", "deprecated": false, "autowired": false, "secret": false, "defaultValue": true, "description": "Whether autowiring is enabled. This is used for automatic autowiring options (the option must be marked as autowired) by looking up in the registry to find if there is a single instance of matching t [...] }, "properties": { - "hostname": { "index": 0, "kind": "path", "displayName": "Hostname", "group": "consumer", "label": "", "required": true, "type": "string", "javaType": "java.lang.String", "deprecated": false, "deprecationNote": "", "autowired": false, "secret": false, "description": "The share hostname or IP address" }, - "port": { "index": 1, "kind": "path", "displayName": "Port", "group": "consumer", "label": "", "required": false, "type": "integer", "javaType": "int", "deprecated": false, "autowired": false, "secret": false, "defaultValue": 445, "description": "The share port number" }, - "shareName": { "index": 2, "kind": "path", "displayName": "Share Name", "group": "consumer", "label": "", "required": true, "type": "string", "javaType": "java.lang.String", "deprecated": false, "deprecationNote": "", "autowired": false, "secret": false, "description": "The name of the share to connect to." }, - "path": { "index": 3, "kind": "parameter", "displayName": "Path", "group": "consumer", "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 path, within the share, to consume the files from" }, - "recursive": { "index": 4, "kind": "parameter", "displayName": "Recursive", "group": "consumer", "label": "consumer", "required": false, "type": "boolean", "javaType": "boolean", "deprecated": false, "autowired": false, "secret": false, "defaultValue": false, "configurationClass": "org.apache.camel.component.smb.SmbConfiguration", "configurationField": "configuration", "description": "If a directory, will look for files in all the sub-directories as well." }, - "searchPattern": { "index": 5, "kind": "parameter", "displayName": "Search Pattern", "group": "consumer", "label": "", "required": false, "type": "string", "javaType": "java.lang.String", "deprecated": false, "autowired": false, "secret": false, "defaultValue": "*.txt", "configurationClass": "org.apache.camel.component.smb.SmbConfiguration", "configurationField": "configuration", "description": "The search pattern used to list the files" }, + "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, "description": "The share hostname or IP address" }, + "port": { "index": 1, "kind": "path", "displayName": "Port", "group": "common", "label": "", "required": false, "type": "integer", "javaType": "int", "deprecated": false, "autowired": false, "secret": false, "defaultValue": 445, "description": "The share port number" }, + "shareName": { "index": 2, "kind": "path", "displayName": "Share Name", "group": "common", "label": "", "required": true, "type": "string", "javaType": "java.lang.String", "deprecated": false, "deprecationNote": "", "autowired": false, "secret": false, "description": "The name of the share to connect to." }, + "path": { "index": 3, "kind": "parameter", "displayName": "Path", "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 path, within the share, to consume the files from" }, + "searchPattern": { "index": 4, "kind": "parameter", "displayName": "Search Pattern", "group": "common", "label": "", "required": false, "type": "string", "javaType": "java.lang.String", "deprecated": false, "autowired": false, "secret": false, "defaultValue": "*.txt", "configurationClass": "org.apache.camel.component.smb.SmbConfiguration", "configurationField": "configuration", "description": "The search pattern used to list the files" }, + "recursive": { "index": 5, "kind": "parameter", "displayName": "Recursive", "group": "consumer", "label": "consumer", "required": false, "type": "boolean", "javaType": "boolean", "deprecated": false, "autowired": false, "secret": false, "defaultValue": false, "configurationClass": "org.apache.camel.component.smb.SmbConfiguration", "configurationField": "configuration", "description": "If a directory, will look for files in all the sub-directories as well." }, "sendEmptyMessageWhenIdle": { "index": 6, "kind": "parameter", "displayName": "Send Empty Message When Idle", "group": "consumer", "label": "consumer", "required": false, "type": "boolean", "javaType": "boolean", "deprecated": false, "autowired": false, "secret": false, "defaultValue": false, "description": "If the polling consumer did not poll any files, you can enable this option to send an empty message (no body) instead." }, "bridgeErrorHandler": { "index": 7, "kind": "parameter", "displayName": "Bridge Error Handler", "group": "consumer (advanced)", "label": "consumer,advanced", "required": false, "type": "boolean", "javaType": "boolean", "deprecated": false, "autowired": false, "secret": false, "defaultValue": false, "description": "Allows for bridging the consumer to the Camel routing Error Handler, which mean any exceptions (if possible) occurred while the Camel consumer is trying to pickup incoming [...] "exceptionHandler": { "index": 8, "kind": "parameter", "displayName": "Exception Handler", "group": "consumer (advanced)", "label": "consumer,advanced", "required": false, "type": "object", "javaType": "org.apache.camel.spi.ExceptionHandler", "optionalPrefix": "consumer.", "deprecated": false, "autowired": false, "secret": false, "description": "To let the consumer use a custom ExceptionHandler. Notice if the option bridgeErrorHandler is enabled then this option is not in use. By def [...] "exchangePattern": { "index": 9, "kind": "parameter", "displayName": "Exchange Pattern", "group": "consumer (advanced)", "label": "consumer,advanced", "required": false, "type": "object", "javaType": "org.apache.camel.ExchangePattern", "enum": [ "InOnly", "InOut" ], "deprecated": false, "autowired": false, "secret": false, "description": "Sets the exchange pattern when the consumer creates an exchange." }, "pollStrategy": { "index": 10, "kind": "parameter", "displayName": "Poll Strategy", "group": "consumer (advanced)", "label": "consumer,advanced", "required": false, "type": "object", "javaType": "org.apache.camel.spi.PollingConsumerPollStrategy", "deprecated": false, "autowired": false, "secret": false, "description": "A pluggable org.apache.camel.PollingConsumerPollingStrategy allowing you to provide your custom implementation to control error handling usually occurred during the po [...] - "idempotentRepository": { "index": 11, "kind": "parameter", "displayName": "Idempotent Repository", "group": "advanced", "label": "advanced", "required": false, "type": "object", "javaType": "org.apache.camel.spi.IdempotentRepository", "deprecated": false, "autowired": false, "secret": false, "configurationClass": "org.apache.camel.component.smb.SmbConfiguration", "configurationField": "configuration", "description": "A pluggable repository org.apache.camel.spi.IdempotentRepository w [...] - "smbConfig": { "index": 12, "kind": "parameter", "displayName": "Smb Config", "group": "advanced", "label": "advanced", "required": false, "type": "object", "javaType": "com.hierynomus.smbj.SmbConfig", "deprecated": false, "deprecationNote": "", "autowired": true, "secret": false, "configurationClass": "org.apache.camel.component.smb.SmbConfiguration", "configurationField": "configuration", "description": "An optional SMB client configuration, can be used to configure client specific [...] - "smbIoBean": { "index": 13, "kind": "parameter", "displayName": "Smb Io Bean", "group": "advanced", "label": "advanced", "required": false, "type": "object", "javaType": "org.apache.camel.component.smb.SmbIOBean", "deprecated": false, "autowired": false, "secret": false, "configurationClass": "org.apache.camel.component.smb.SmbConfiguration", "configurationField": "configuration", "description": "An optional SMB I\/O bean to use to setup the file access attributes when reading\/writi [...] - "backoffErrorThreshold": { "index": 14, "kind": "parameter", "displayName": "Backoff Error Threshold", "group": "scheduler", "label": "consumer,scheduler", "required": false, "type": "integer", "javaType": "int", "deprecated": false, "autowired": false, "secret": false, "description": "The number of subsequent error polls (failed due some error) that should happen before the backoffMultipler should kick-in." }, - "backoffIdleThreshold": { "index": 15, "kind": "parameter", "displayName": "Backoff Idle Threshold", "group": "scheduler", "label": "consumer,scheduler", "required": false, "type": "integer", "javaType": "int", "deprecated": false, "autowired": false, "secret": false, "description": "The number of subsequent idle polls that should happen before the backoffMultipler should kick-in." }, - "backoffMultiplier": { "index": 16, "kind": "parameter", "displayName": "Backoff Multiplier", "group": "scheduler", "label": "consumer,scheduler", "required": false, "type": "integer", "javaType": "int", "deprecated": false, "autowired": false, "secret": false, "description": "To let the scheduled polling consumer backoff if there has been a number of subsequent idles\/errors in a row. The multiplier is then the number of polls that will be skipped before the next actual attempt is h [...] - "delay": { "index": 17, "kind": "parameter", "displayName": "Delay", "group": "scheduler", "label": "consumer,scheduler", "required": false, "type": "integer", "javaType": "long", "deprecated": false, "autowired": false, "secret": false, "defaultValue": 500, "description": "Milliseconds before the next poll." }, - "greedy": { "index": 18, "kind": "parameter", "displayName": "Greedy", "group": "scheduler", "label": "consumer,scheduler", "required": false, "type": "boolean", "javaType": "boolean", "deprecated": false, "autowired": false, "secret": false, "defaultValue": false, "description": "If greedy is enabled, then the ScheduledPollConsumer will run immediately again, if the previous run polled 1 or more messages." }, - "initialDelay": { "index": 19, "kind": "parameter", "displayName": "Initial Delay", "group": "scheduler", "label": "consumer,scheduler", "required": false, "type": "integer", "javaType": "long", "deprecated": false, "autowired": false, "secret": false, "defaultValue": 1000, "description": "Milliseconds before the first poll starts." }, - "repeatCount": { "index": 20, "kind": "parameter", "displayName": "Repeat Count", "group": "scheduler", "label": "consumer,scheduler", "required": false, "type": "integer", "javaType": "long", "deprecated": false, "autowired": false, "secret": false, "defaultValue": 0, "description": "Specifies a maximum limit of number of fires. So if you set it to 1, the scheduler will only fire once. If you set it to 5, it will only fire five times. A value of zero or negative means fire forever." }, - "runLoggingLevel": { "index": 21, "kind": "parameter", "displayName": "Run Logging Level", "group": "scheduler", "label": "consumer,scheduler", "required": false, "type": "object", "javaType": "org.apache.camel.LoggingLevel", "enum": [ "TRACE", "DEBUG", "INFO", "WARN", "ERROR", "OFF" ], "deprecated": false, "autowired": false, "secret": false, "defaultValue": "TRACE", "description": "The consumer logs a start\/complete log line when it polls. This option allows you to configure the l [...] - "scheduledExecutorService": { "index": 22, "kind": "parameter", "displayName": "Scheduled Executor Service", "group": "scheduler", "label": "consumer,scheduler", "required": false, "type": "object", "javaType": "java.util.concurrent.ScheduledExecutorService", "deprecated": false, "autowired": false, "secret": false, "description": "Allows for configuring a custom\/shared thread pool to use for the consumer. By default each consumer has its own single threaded thread pool." }, - "scheduler": { "index": 23, "kind": "parameter", "displayName": "Scheduler", "group": "scheduler", "label": "consumer,scheduler", "required": false, "type": "object", "javaType": "java.lang.Object", "deprecated": false, "autowired": false, "secret": false, "defaultValue": "none", "description": "To use a cron scheduler from either camel-spring or camel-quartz component. Use value spring or quartz for built in scheduler" }, - "schedulerProperties": { "index": 24, "kind": "parameter", "displayName": "Scheduler Properties", "group": "scheduler", "label": "consumer,scheduler", "required": false, "type": "object", "javaType": "java.util.Map<java.lang.String, java.lang.Object>", "prefix": "scheduler.", "multiValue": true, "deprecated": false, "autowired": false, "secret": false, "description": "To configure additional properties when using a custom scheduler or any of the Quartz, Spring based scheduler." }, - "startScheduler": { "index": 25, "kind": "parameter", "displayName": "Start Scheduler", "group": "scheduler", "label": "consumer,scheduler", "required": false, "type": "boolean", "javaType": "boolean", "deprecated": false, "autowired": false, "secret": false, "defaultValue": true, "description": "Whether the scheduler should be auto started." }, - "timeUnit": { "index": 26, "kind": "parameter", "displayName": "Time Unit", "group": "scheduler", "label": "consumer,scheduler", "required": false, "type": "object", "javaType": "java.util.concurrent.TimeUnit", "enum": [ "NANOSECONDS", "MICROSECONDS", "MILLISECONDS", "SECONDS", "MINUTES", "HOURS", "DAYS" ], "deprecated": false, "autowired": false, "secret": false, "defaultValue": "MILLISECONDS", "description": "Time unit for initialDelay and delay options." }, - "useFixedDelay": { "index": 27, "kind": "parameter", "displayName": "Use Fixed Delay", "group": "scheduler", "label": "consumer,scheduler", "required": false, "type": "boolean", "javaType": "boolean", "deprecated": false, "autowired": false, "secret": false, "defaultValue": true, "description": "Controls if fixed delay or fixed rate is used. See ScheduledExecutorService in JDK for details." }, - "domain": { "index": 28, "kind": "parameter", "displayName": "Domain", "group": "security", "label": "security", "required": false, "type": "string", "javaType": "java.lang.String", "deprecated": false, "autowired": false, "secret": false, "configurationClass": "org.apache.camel.component.smb.SmbConfiguration", "configurationField": "configuration", "description": "The user domain" }, - "password": { "index": 29, "kind": "parameter", "displayName": "Password", "group": "security", "label": "security", "required": false, "type": "string", "javaType": "java.lang.String", "deprecated": false, "autowired": false, "secret": true, "configurationClass": "org.apache.camel.component.smb.SmbConfiguration", "configurationField": "configuration", "description": "The password to access the share" }, - "username": { "index": 30, "kind": "parameter", "displayName": "Username", "group": "security", "label": "security", "required": false, "type": "string", "javaType": "java.lang.String", "deprecated": false, "autowired": false, "secret": true, "configurationClass": "org.apache.camel.component.smb.SmbConfiguration", "configurationField": "configuration", "description": "The username required to access the share" } + "autoCreate": { "index": 11, "kind": "parameter", "displayName": "Auto Create", "group": "producer", "label": "producer", "required": false, "type": "boolean", "javaType": "boolean", "deprecated": false, "deprecationNote": "", "autowired": false, "secret": false, "defaultValue": false, "configurationClass": "org.apache.camel.component.smb.SmbConfiguration", "configurationField": "configuration", "description": "Whether to create parent directory if it does not exist" }, + "fileExist": { "index": 12, "kind": "parameter", "displayName": "File Exist", "group": "producer", "label": "producer", "required": false, "type": "object", "javaType": "org.apache.camel.component.file.GenericFileExist", "enum": [ "Override", "Append", "Fail", "Ignore", "Move", "TryRename" ], "deprecated": false, "deprecationNote": "", "autowired": false, "secret": false, "defaultValue": "Ignore", "configurationClass": "org.apache.camel.component.smb.SmbConfiguration", "configuration [...] + "lazyStartProducer": { "index": 13, "kind": "parameter", "displayName": "Lazy Start Producer", "group": "producer (advanced)", "label": "producer,advanced", "required": false, "type": "boolean", "javaType": "boolean", "deprecated": false, "autowired": false, "secret": false, "defaultValue": false, "description": "Whether the producer should be started lazy (on the first message). By starting lazy you can use this to allow CamelContext and routes to startup in situations where a produ [...] + "idempotentRepository": { "index": 14, "kind": "parameter", "displayName": "Idempotent Repository", "group": "advanced", "label": "advanced", "required": false, "type": "object", "javaType": "org.apache.camel.spi.IdempotentRepository", "deprecated": false, "autowired": false, "secret": false, "configurationClass": "org.apache.camel.component.smb.SmbConfiguration", "configurationField": "configuration", "description": "A pluggable repository org.apache.camel.spi.IdempotentRepository w [...] + "smbConfig": { "index": 15, "kind": "parameter", "displayName": "Smb Config", "group": "advanced", "label": "advanced", "required": false, "type": "object", "javaType": "com.hierynomus.smbj.SmbConfig", "deprecated": false, "deprecationNote": "", "autowired": true, "secret": false, "configurationClass": "org.apache.camel.component.smb.SmbConfiguration", "configurationField": "configuration", "description": "An optional SMB client configuration, can be used to configure client specific [...] + "smbIoBean": { "index": 16, "kind": "parameter", "displayName": "Smb Io Bean", "group": "advanced", "label": "advanced", "required": false, "type": "object", "javaType": "org.apache.camel.component.smb.SmbIOBean", "deprecated": false, "autowired": false, "secret": false, "configurationClass": "org.apache.camel.component.smb.SmbConfiguration", "configurationField": "configuration", "description": "An optional SMB I\/O bean to use to setup the file access attributes when reading\/writi [...] + "backoffErrorThreshold": { "index": 17, "kind": "parameter", "displayName": "Backoff Error Threshold", "group": "scheduler", "label": "consumer,scheduler", "required": false, "type": "integer", "javaType": "int", "deprecated": false, "autowired": false, "secret": false, "description": "The number of subsequent error polls (failed due some error) that should happen before the backoffMultipler should kick-in." }, + "backoffIdleThreshold": { "index": 18, "kind": "parameter", "displayName": "Backoff Idle Threshold", "group": "scheduler", "label": "consumer,scheduler", "required": false, "type": "integer", "javaType": "int", "deprecated": false, "autowired": false, "secret": false, "description": "The number of subsequent idle polls that should happen before the backoffMultipler should kick-in." }, + "backoffMultiplier": { "index": 19, "kind": "parameter", "displayName": "Backoff Multiplier", "group": "scheduler", "label": "consumer,scheduler", "required": false, "type": "integer", "javaType": "int", "deprecated": false, "autowired": false, "secret": false, "description": "To let the scheduled polling consumer backoff if there has been a number of subsequent idles\/errors in a row. The multiplier is then the number of polls that will be skipped before the next actual attempt is h [...] + "delay": { "index": 20, "kind": "parameter", "displayName": "Delay", "group": "scheduler", "label": "consumer,scheduler", "required": false, "type": "integer", "javaType": "long", "deprecated": false, "autowired": false, "secret": false, "defaultValue": 500, "description": "Milliseconds before the next poll." }, + "greedy": { "index": 21, "kind": "parameter", "displayName": "Greedy", "group": "scheduler", "label": "consumer,scheduler", "required": false, "type": "boolean", "javaType": "boolean", "deprecated": false, "autowired": false, "secret": false, "defaultValue": false, "description": "If greedy is enabled, then the ScheduledPollConsumer will run immediately again, if the previous run polled 1 or more messages." }, + "initialDelay": { "index": 22, "kind": "parameter", "displayName": "Initial Delay", "group": "scheduler", "label": "consumer,scheduler", "required": false, "type": "integer", "javaType": "long", "deprecated": false, "autowired": false, "secret": false, "defaultValue": 1000, "description": "Milliseconds before the first poll starts." }, + "repeatCount": { "index": 23, "kind": "parameter", "displayName": "Repeat Count", "group": "scheduler", "label": "consumer,scheduler", "required": false, "type": "integer", "javaType": "long", "deprecated": false, "autowired": false, "secret": false, "defaultValue": 0, "description": "Specifies a maximum limit of number of fires. So if you set it to 1, the scheduler will only fire once. If you set it to 5, it will only fire five times. A value of zero or negative means fire forever." }, + "runLoggingLevel": { "index": 24, "kind": "parameter", "displayName": "Run Logging Level", "group": "scheduler", "label": "consumer,scheduler", "required": false, "type": "object", "javaType": "org.apache.camel.LoggingLevel", "enum": [ "TRACE", "DEBUG", "INFO", "WARN", "ERROR", "OFF" ], "deprecated": false, "autowired": false, "secret": false, "defaultValue": "TRACE", "description": "The consumer logs a start\/complete log line when it polls. This option allows you to configure the l [...] + "scheduledExecutorService": { "index": 25, "kind": "parameter", "displayName": "Scheduled Executor Service", "group": "scheduler", "label": "consumer,scheduler", "required": false, "type": "object", "javaType": "java.util.concurrent.ScheduledExecutorService", "deprecated": false, "autowired": false, "secret": false, "description": "Allows for configuring a custom\/shared thread pool to use for the consumer. By default each consumer has its own single threaded thread pool." }, + "scheduler": { "index": 26, "kind": "parameter", "displayName": "Scheduler", "group": "scheduler", "label": "consumer,scheduler", "required": false, "type": "object", "javaType": "java.lang.Object", "deprecated": false, "autowired": false, "secret": false, "defaultValue": "none", "description": "To use a cron scheduler from either camel-spring or camel-quartz component. Use value spring or quartz for built in scheduler" }, + "schedulerProperties": { "index": 27, "kind": "parameter", "displayName": "Scheduler Properties", "group": "scheduler", "label": "consumer,scheduler", "required": false, "type": "object", "javaType": "java.util.Map<java.lang.String, java.lang.Object>", "prefix": "scheduler.", "multiValue": true, "deprecated": false, "autowired": false, "secret": false, "description": "To configure additional properties when using a custom scheduler or any of the Quartz, Spring based scheduler." }, + "startScheduler": { "index": 28, "kind": "parameter", "displayName": "Start Scheduler", "group": "scheduler", "label": "consumer,scheduler", "required": false, "type": "boolean", "javaType": "boolean", "deprecated": false, "autowired": false, "secret": false, "defaultValue": true, "description": "Whether the scheduler should be auto started." }, + "timeUnit": { "index": 29, "kind": "parameter", "displayName": "Time Unit", "group": "scheduler", "label": "consumer,scheduler", "required": false, "type": "object", "javaType": "java.util.concurrent.TimeUnit", "enum": [ "NANOSECONDS", "MICROSECONDS", "MILLISECONDS", "SECONDS", "MINUTES", "HOURS", "DAYS" ], "deprecated": false, "autowired": false, "secret": false, "defaultValue": "MILLISECONDS", "description": "Time unit for initialDelay and delay options." }, + "useFixedDelay": { "index": 30, "kind": "parameter", "displayName": "Use Fixed Delay", "group": "scheduler", "label": "consumer,scheduler", "required": false, "type": "boolean", "javaType": "boolean", "deprecated": false, "autowired": false, "secret": false, "defaultValue": true, "description": "Controls if fixed delay or fixed rate is used. See ScheduledExecutorService in JDK for details." }, + "domain": { "index": 31, "kind": "parameter", "displayName": "Domain", "group": "security", "label": "security", "required": false, "type": "string", "javaType": "java.lang.String", "deprecated": false, "autowired": false, "secret": false, "configurationClass": "org.apache.camel.component.smb.SmbConfiguration", "configurationField": "configuration", "description": "The user domain" }, + "password": { "index": 32, "kind": "parameter", "displayName": "Password", "group": "security", "label": "security", "required": false, "type": "string", "javaType": "java.lang.String", "deprecated": false, "autowired": false, "secret": true, "configurationClass": "org.apache.camel.component.smb.SmbConfiguration", "configurationField": "configuration", "description": "The password to access the share" }, + "username": { "index": 33, "kind": "parameter", "displayName": "Username", "group": "security", "label": "security", "required": false, "type": "string", "javaType": "java.lang.String", "deprecated": false, "autowired": false, "secret": true, "configurationClass": "org.apache.camel.component.smb.SmbConfiguration", "configurationField": "configuration", "description": "The username required to access the share" } } } diff --git a/components/camel-smb/src/main/docs/smb-component.adoc b/components/camel-smb/src/main/docs/smb-component.adoc index b52387b8ee0..642d2cb5fad 100644 --- a/components/camel-smb/src/main/docs/smb-component.adoc +++ b/components/camel-smb/src/main/docs/smb-component.adoc @@ -6,7 +6,7 @@ :since: 4.3 :supportlevel: Stable :tabs-sync-option: -:component-header: Only consumer is supported +:component-header: Both producer and consumer are supported //Manually maintained attributes :camel-spring-boot-name: smb diff --git a/components/camel-smb/src/main/java/org/apache/camel/component/smb/SmbConfiguration.java b/components/camel-smb/src/main/java/org/apache/camel/component/smb/SmbConfiguration.java index eb239b21fe3..9c0725ba97d 100644 --- a/components/camel-smb/src/main/java/org/apache/camel/component/smb/SmbConfiguration.java +++ b/components/camel-smb/src/main/java/org/apache/camel/component/smb/SmbConfiguration.java @@ -17,6 +17,7 @@ package org.apache.camel.component.smb; import com.hierynomus.smbj.SmbConfig; +import org.apache.camel.component.file.GenericFileExist; import org.apache.camel.spi.IdempotentRepository; import org.apache.camel.spi.Metadata; import org.apache.camel.spi.UriParam; @@ -28,6 +29,16 @@ public class SmbConfiguration { protected static final int DEFAULT_IDEMPOTENT_CACHE_SIZE = 1000; + @Metadata(required = false) + @UriParam(label = "producer", description = "What action to take if the SMB file already exists", + defaultValue = "Ignore", enums = "Override,Append,Fail,Ignore,Move,TryRename") + private GenericFileExist fileExist; + + @Metadata(required = false, defaultValue = "false") + @UriParam(label = "producer", description = "Whether to create parent directory if it does not exist", + defaultValue = "false") + private boolean autoCreate; + @Metadata(required = true) @UriParam(description = "The path, within the share, to consume the files from") private String path; @@ -130,4 +141,24 @@ public class SmbConfiguration { public void setSmbConfig(SmbConfig smbConfig) { this.smbConfig = smbConfig; } + + public GenericFileExist getFileExist() { + return fileExist; + } + + public void setFileExist(GenericFileExist fileExist) { + this.fileExist = fileExist; + } + + public boolean isAutoCreate() { + return autoCreate; + } + + public void setAutoCreate(String autoCreate) { + this.autoCreate = Boolean.valueOf(autoCreate); + } + + public void setAutoCreate(boolean autoCreate) { + this.autoCreate = autoCreate; + } } 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 new file mode 100644 index 00000000000..0d3fd613e7a --- /dev/null +++ b/components/camel-smb/src/main/java/org/apache/camel/component/smb/SmbConstants.java @@ -0,0 +1,25 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.apache.camel.component.smb; + +import org.apache.camel.spi.Metadata; + +public interface SmbConstants { + @Metadata(label = "producer", description = "The expected behavior if the file already exists.", + javaType = "org.apache.camel.component.file.GenericFileExist") + String SMB_FILE_EXISTS = "CamelSmbFileExists"; +} diff --git a/components/camel-smb/src/main/java/org/apache/camel/component/smb/SmbEndpoint.java b/components/camel-smb/src/main/java/org/apache/camel/component/smb/SmbEndpoint.java index c77c3851ae0..b985a81dc79 100644 --- a/components/camel-smb/src/main/java/org/apache/camel/component/smb/SmbEndpoint.java +++ b/components/camel-smb/src/main/java/org/apache/camel/component/smb/SmbEndpoint.java @@ -33,7 +33,6 @@ import org.apache.camel.support.ScheduledPollEndpoint; * Receive files from SMB (Server Message Block) shares. */ @UriEndpoint(firstVersion = "4.3.0", scheme = "smb", title = "SMB", syntax = "smb:hostname:port/shareName", - consumerOnly = true, category = { Category.FILE }) public class SmbEndpoint extends ScheduledPollEndpoint implements EndpointServiceLocation { @@ -80,7 +79,7 @@ public class SmbEndpoint extends ScheduledPollEndpoint implements EndpointServic @Override public Producer createProducer() { - throw new UnsupportedOperationException("SMB producer is not supported."); + return new SmbProducer(this); } @Override diff --git a/components/camel-smb/src/main/java/org/apache/camel/component/smb/SmbProducer.java b/components/camel-smb/src/main/java/org/apache/camel/component/smb/SmbProducer.java new file mode 100644 index 00000000000..0762698a77f --- /dev/null +++ b/components/camel-smb/src/main/java/org/apache/camel/component/smb/SmbProducer.java @@ -0,0 +1,239 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package org.apache.camel.component.smb; + +import java.io.IOException; +import java.io.InputStream; +import java.util.Arrays; +import java.util.HashSet; + +import com.hierynomus.msdtyp.AccessMask; +import com.hierynomus.msfscc.FileAttributes; +import com.hierynomus.mssmb2.SMB2CreateDisposition; +import com.hierynomus.mssmb2.SMB2CreateOptions; +import com.hierynomus.mssmb2.SMB2ShareAccess; +import com.hierynomus.smbj.SMBClient; +import com.hierynomus.smbj.auth.AuthenticationContext; +import com.hierynomus.smbj.connection.Connection; +import com.hierynomus.smbj.session.Session; +import com.hierynomus.smbj.share.DiskShare; +import com.hierynomus.smbj.share.File; +import com.hierynomus.smbj.utils.SmbFiles; +import org.apache.camel.Exchange; +import org.apache.camel.RuntimeCamelException; +import org.apache.camel.component.file.GenericFileExist; +import org.apache.camel.support.DefaultProducer; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + +import static org.apache.camel.util.ObjectHelper.isEmpty; + +/** + * SMB file producer + */ +public class SmbProducer extends DefaultProducer { + private static final Logger LOGGER = LoggerFactory.getLogger(SmbProducer.class); + + private boolean loggedIn; + private Session session; + private final SMBClient smbClient; + + protected SmbProducer(final SmbEndpoint endpoint) { + super(endpoint); + + if (getEndpoint().getConfiguration().getSmbConfig() != null) { + smbClient = new SMBClient(getEndpoint().getConfiguration().getSmbConfig()); + } else { + smbClient = new SMBClient(); + } + } + + @Override + protected void doStop() throws Exception { + LOGGER.debug("Producer SMB client stopped"); + super.doStop(); + } + + @Override + protected void doStart() throws Exception { + LOGGER.debug("Producer SMB client started"); + + super.doStart(); + } + + /* + * Normalize changes separators for smb + */ + public String normalize(String file) { + String result = file.replace('\\', '/'); + LOGGER.debug("Normalize path {} to {}", file, result); + return result; + } + + protected void connectIfNecessary(Exchange exchange) throws IOException { + Connection connection = smbClient.connect(getEndpoint().getHostname(), getEndpoint().getPort()); + + if (!loggedIn) { + LOGGER.debug("Not already connected/logged in. Connecting to: {}", getEndpoint()); + + AuthenticationContext ac = new AuthenticationContext( + getEndpoint().getConfiguration().getUsername(), + getEndpoint().getConfiguration().getPassword().toCharArray(), + getEndpoint().getConfiguration().getDomain()); + session = connection.authenticate(ac); + + LOGGER.debug("Connected and logged in to: {}", getEndpoint()); + } + } + + public void disconnect() throws IOException { + loggedIn = false; + LOGGER.debug("Disconnecting from: {}", getEndpoint()); + + session.close(); + + session = null; + } + + public void createDirectory(DiskShare share, java.io.File file) { + String parentDir = file.getParent(); + SmbConfiguration configuration = getEndpoint().getConfiguration(); + + boolean dirExists = share.folderExists(parentDir); + if (!dirExists && configuration.isAutoCreate()) { + SmbFiles files = new SmbFiles(); + files.mkdirs(share, normalize(parentDir)); + } + + if (!dirExists) { + throw new RuntimeCamelException("Directory " + parentDir + " does not exist on share " + share.toString()); + } + } + + private GenericFileExist determineFileExist(Exchange exchange) { + GenericFileExist gfe = exchange.getIn().getHeader(SmbConstants.SMB_FILE_EXISTS, GenericFileExist.class); + if (isEmpty(gfe)) { + gfe = getEndpoint().getConfiguration().getFileExist(); + } + + gfe = (gfe == null) ? GenericFileExist.Fail : gfe; + + return gfe; + } + + private void doFail(String path) { + throw new RuntimeCamelException("File " + path + " already exists, cannot create"); + } + + private void doIgnore(String path) { + // ignore but indicate that the file was written + LOGGER.debug("An existing file already exists: {}. Ignore and do not override it.", path); + } + + private void removeFile(DiskShare share, java.io.File file) { + LOGGER.debug("An existing file already exists: {}. Removing it.", file.getName()); + share.rm(file.getPath()); + } + + @Override + public void process(final Exchange exchange) { + String fileName = exchange.getIn().getHeader(Exchange.FILE_NAME, String.class); + + SmbConfiguration configuration = getEndpoint().getConfiguration(); + String path = (configuration.getPath() == null) ? "" : configuration.getPath(); + + LOGGER.debug("storeFile() fileName [" + fileName + "]"); + + try { + connectIfNecessary(exchange); + + java.io.File file = new java.io.File(path + java.io.File.separator + fileName); + + DiskShare share = (DiskShare) session.connectShare(getEndpoint().getShareName()); + createDirectory(share, file); + + GenericFileExist gfe = determineFileExist(exchange); + + SMB2CreateDisposition scd = SMB2CreateDisposition.FILE_OPEN; + HashSet<AccessMask> accessMask = new HashSet<AccessMask>(Arrays.asList(AccessMask.GENERIC_ALL)); + HashSet<SMB2CreateOptions> createOptions = new HashSet<>(Arrays.asList(SMB2CreateOptions.FILE_DIRECTORY_FILE)); + HashSet<FileAttributes> fileAttributes + = new HashSet<FileAttributes>(Arrays.asList(FileAttributes.FILE_ATTRIBUTE_NORMAL)); + + // File existence modes + switch (gfe) { + case Override: + scd = SMB2CreateDisposition.FILE_OVERWRITE_IF; + break; + case Fail: + scd = SMB2CreateDisposition.FILE_CREATE; + if (share.fileExists(file.getPath())) { + doFail(file.getPath()); + } + break; + case Append: + scd = SMB2CreateDisposition.FILE_OPEN_IF; + accessMask = new HashSet<AccessMask>(Arrays.asList(AccessMask.FILE_WRITE_DATA)); + break; + case Ignore: + if (share.fileExists(file.getPath())) { + doIgnore(file.getPath()); + return; + } + break; + case Move: + throw new UnsupportedOperationException("Move is not implemented for this producer at the moment"); + case TryRename: + throw new UnsupportedOperationException("TryRename is not implemented for this producer at the moment"); + } + + File shareFile = share.openFile(file.getPath(), + accessMask, + fileAttributes, + SMB2ShareAccess.ALL, + scd, + createOptions); + + InputStream is = (exchange.getMessage(InputStream.class) == null) + ? exchange.getMessage().getBody(InputStream.class) : exchange.getMessage(InputStream.class); + + // In order to provide append option, we need to use offset / write with shareFile rather + // than with outputstream + int buffer = 2048; + long fileOffset = 0; + + byte[] byteBuffer = new byte[buffer]; + int length = 0; + while ((length = is.read(byteBuffer)) > 0) { + fileOffset = share.getFileInformation(file.getPath()) + .getStandardInformation().getEndOfFile(); + shareFile.write(byteBuffer, fileOffset, 0, length); + } + shareFile.flush(); + shareFile.close(); + + } catch (IOException ioe) { + throw new RuntimeCamelException(ioe); + } + } + + @Override + public SmbEndpoint getEndpoint() { + return (SmbEndpoint) super.getEndpoint(); + } +} 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 ed39e0a24f6..7d1eba98679 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 @@ -22,6 +22,7 @@ import java.util.concurrent.TimeUnit; import com.hierynomus.smbj.SmbConfig; import com.hierynomus.smbj.share.File; +import org.apache.camel.EndpointInject; import org.apache.camel.Exchange; import org.apache.camel.builder.RouteBuilder; import org.apache.camel.component.mock.MockEndpoint; @@ -39,6 +40,9 @@ public class SmbComponentIT extends CamelTestSupport { @RegisterExtension public static SmbService service = SmbServiceFactory.createService(); + @EndpointInject("mock:result") + protected MockEndpoint mockResultEndpoint; + @Test public void testSmbRead() throws Exception { MockEndpoint mock = getMockEndpoint("mock:result"); @@ -47,6 +51,13 @@ public class SmbComponentIT extends CamelTestSupport { mock.assertIsSatisfied(); } + @Test + public void testSmbSendFile() throws Exception { + mockResultEndpoint.expectedMinimumMessageCount(1); + Exchange exchange = template.request("direct:smbSendFile", null); + MockEndpoint.assertIsSatisfied(context); + } + @Override protected RouteBuilder createRouteBuilder() throws Exception { return new RouteBuilder() { @@ -70,6 +81,11 @@ public class SmbComponentIT extends CamelTestSupport { service.userName(), service.password()) .process(this::process) .to("mock:result"); + + fromF("direct:smbSendFile") + .to("smb:%s/%s?username=%s&password=%s&path=/&smbConfig=#smbConfig") + .to("mock:result"); + } }; } diff --git a/dsl/camel-componentdsl/src/generated/java/org/apache/camel/builder/component/dsl/SmbComponentBuilderFactory.java b/dsl/camel-componentdsl/src/generated/java/org/apache/camel/builder/component/dsl/SmbComponentBuilderFactory.java index 18b001c2783..2cff6f76f08 100644 --- a/dsl/camel-componentdsl/src/generated/java/org/apache/camel/builder/component/dsl/SmbComponentBuilderFactory.java +++ b/dsl/camel-componentdsl/src/generated/java/org/apache/camel/builder/component/dsl/SmbComponentBuilderFactory.java @@ -79,6 +79,31 @@ public interface SmbComponentBuilderFactory { } + /** + * Whether the producer should be started lazy (on the first message). + * By starting lazy you can use this to allow CamelContext and routes to + * startup in situations where a producer may otherwise fail during + * starting and cause the route to fail being started. By deferring this + * startup to be lazy then the startup failure can be handled during + * routing messages via Camel's routing error handlers. Beware that when + * the first message is processed then creating and starting the + * producer may take a little time and prolong the total processing time + * of the processing. + * + * The option is a: <code>boolean</code> type. + * + * Default: false + * Group: producer + * + * @param lazyStartProducer the value to set + * @return the dsl builder + */ + default SmbComponentBuilder lazyStartProducer(boolean lazyStartProducer) { + doSetProperty("lazyStartProducer", lazyStartProducer); + return this; + } + + /** * Whether autowiring is enabled. This is used for automatic autowiring * options (the option must be marked as autowired) by looking up in the @@ -115,6 +140,7 @@ public interface SmbComponentBuilderFactory { Object value) { switch (name) { case "bridgeErrorHandler": ((SmbComponent) component).setBridgeErrorHandler((boolean) value); return true; + case "lazyStartProducer": ((SmbComponent) component).setLazyStartProducer((boolean) value); return true; case "autowiredEnabled": ((SmbComponent) component).setAutowiredEnabled((boolean) value); return true; default: return false; } 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 5d831f857ff..5d303e5539b 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 @@ -35,51 +35,49 @@ import org.apache.camel.builder.endpoint.AbstractEndpointBuilder; public interface SmbEndpointBuilderFactory { /** - * Builder for endpoint for the SMB component. + * Builder for endpoint consumers for the SMB component. */ - public interface SmbEndpointBuilder + public interface SmbEndpointConsumerBuilder extends EndpointConsumerBuilder { - default AdvancedSmbEndpointBuilder advanced() { - return (AdvancedSmbEndpointBuilder) this; + default AdvancedSmbEndpointConsumerBuilder advanced() { + return (AdvancedSmbEndpointConsumerBuilder) this; } - /** * The path, within the share, to consume the files from. * * The option is a: <code>java.lang.String</code> type. * * Required: true - * Group: consumer + * Group: common * * @param path the value to set * @return the dsl builder */ - default SmbEndpointBuilder path(String path) { + default SmbEndpointConsumerBuilder path(String path) { doSetProperty("path", path); return this; } /** - * If a directory, will look for files in all the sub-directories as - * well. + * The search pattern used to list the files. * - * The option is a: <code>boolean</code> type. + * The option is a: <code>java.lang.String</code> type. * - * Default: false - * Group: consumer + * Default: *.txt + * Group: common * - * @param recursive the value to set + * @param searchPattern the value to set * @return the dsl builder */ - default SmbEndpointBuilder recursive(boolean recursive) { - doSetProperty("recursive", recursive); + default SmbEndpointConsumerBuilder searchPattern(String searchPattern) { + doSetProperty("searchPattern", searchPattern); return this; } /** * If a directory, will look for files in all the sub-directories as * well. * - * The option will be converted to a <code>boolean</code> type. + * The option is a: <code>boolean</code> type. * * Default: false * Group: consumer @@ -87,23 +85,24 @@ public interface SmbEndpointBuilderFactory { * @param recursive the value to set * @return the dsl builder */ - default SmbEndpointBuilder recursive(String recursive) { + default SmbEndpointConsumerBuilder recursive(boolean recursive) { doSetProperty("recursive", recursive); return this; } /** - * The search pattern used to list the files. + * If a directory, will look for files in all the sub-directories as + * well. * - * The option is a: <code>java.lang.String</code> type. + * The option will be converted to a <code>boolean</code> type. * - * Default: *.txt + * Default: false * Group: consumer * - * @param searchPattern the value to set + * @param recursive the value to set * @return the dsl builder */ - default SmbEndpointBuilder searchPattern(String searchPattern) { - doSetProperty("searchPattern", searchPattern); + default SmbEndpointConsumerBuilder recursive(String recursive) { + doSetProperty("recursive", recursive); return this; } /** @@ -118,7 +117,7 @@ public interface SmbEndpointBuilderFactory { * @param sendEmptyMessageWhenIdle the value to set * @return the dsl builder */ - default SmbEndpointBuilder sendEmptyMessageWhenIdle(boolean sendEmptyMessageWhenIdle) { + default SmbEndpointConsumerBuilder sendEmptyMessageWhenIdle(boolean sendEmptyMessageWhenIdle) { doSetProperty("sendEmptyMessageWhenIdle", sendEmptyMessageWhenIdle); return this; } @@ -134,7 +133,7 @@ public interface SmbEndpointBuilderFactory { * @param sendEmptyMessageWhenIdle the value to set * @return the dsl builder */ - default SmbEndpointBuilder sendEmptyMessageWhenIdle(String sendEmptyMessageWhenIdle) { + default SmbEndpointConsumerBuilder sendEmptyMessageWhenIdle(String sendEmptyMessageWhenIdle) { doSetProperty("sendEmptyMessageWhenIdle", sendEmptyMessageWhenIdle); return this; } @@ -149,7 +148,7 @@ public interface SmbEndpointBuilderFactory { * @param backoffErrorThreshold the value to set * @return the dsl builder */ - default SmbEndpointBuilder backoffErrorThreshold(int backoffErrorThreshold) { + default SmbEndpointConsumerBuilder backoffErrorThreshold(int backoffErrorThreshold) { doSetProperty("backoffErrorThreshold", backoffErrorThreshold); return this; } @@ -164,7 +163,7 @@ public interface SmbEndpointBuilderFactory { * @param backoffErrorThreshold the value to set * @return the dsl builder */ - default SmbEndpointBuilder backoffErrorThreshold(String backoffErrorThreshold) { + default SmbEndpointConsumerBuilder backoffErrorThreshold(String backoffErrorThreshold) { doSetProperty("backoffErrorThreshold", backoffErrorThreshold); return this; } @@ -179,7 +178,7 @@ public interface SmbEndpointBuilderFactory { * @param backoffIdleThreshold the value to set * @return the dsl builder */ - default SmbEndpointBuilder backoffIdleThreshold(int backoffIdleThreshold) { + default SmbEndpointConsumerBuilder backoffIdleThreshold(int backoffIdleThreshold) { doSetProperty("backoffIdleThreshold", backoffIdleThreshold); return this; } @@ -194,7 +193,7 @@ public interface SmbEndpointBuilderFactory { * @param backoffIdleThreshold the value to set * @return the dsl builder */ - default SmbEndpointBuilder backoffIdleThreshold(String backoffIdleThreshold) { + default SmbEndpointConsumerBuilder backoffIdleThreshold(String backoffIdleThreshold) { doSetProperty("backoffIdleThreshold", backoffIdleThreshold); return this; } @@ -213,7 +212,7 @@ public interface SmbEndpointBuilderFactory { * @param backoffMultiplier the value to set * @return the dsl builder */ - default SmbEndpointBuilder backoffMultiplier(int backoffMultiplier) { + default SmbEndpointConsumerBuilder backoffMultiplier(int backoffMultiplier) { doSetProperty("backoffMultiplier", backoffMultiplier); return this; } @@ -232,7 +231,7 @@ public interface SmbEndpointBuilderFactory { * @param backoffMultiplier the value to set * @return the dsl builder */ - default SmbEndpointBuilder backoffMultiplier(String backoffMultiplier) { + default SmbEndpointConsumerBuilder backoffMultiplier(String backoffMultiplier) { doSetProperty("backoffMultiplier", backoffMultiplier); return this; } @@ -247,7 +246,7 @@ public interface SmbEndpointBuilderFactory { * @param delay the value to set * @return the dsl builder */ - default SmbEndpointBuilder delay(long delay) { + default SmbEndpointConsumerBuilder delay(long delay) { doSetProperty("delay", delay); return this; } @@ -262,7 +261,7 @@ public interface SmbEndpointBuilderFactory { * @param delay the value to set * @return the dsl builder */ - default SmbEndpointBuilder delay(String delay) { + default SmbEndpointConsumerBuilder delay(String delay) { doSetProperty("delay", delay); return this; } @@ -278,7 +277,7 @@ public interface SmbEndpointBuilderFactory { * @param greedy the value to set * @return the dsl builder */ - default SmbEndpointBuilder greedy(boolean greedy) { + default SmbEndpointConsumerBuilder greedy(boolean greedy) { doSetProperty("greedy", greedy); return this; } @@ -294,7 +293,7 @@ public interface SmbEndpointBuilderFactory { * @param greedy the value to set * @return the dsl builder */ - default SmbEndpointBuilder greedy(String greedy) { + default SmbEndpointConsumerBuilder greedy(String greedy) { doSetProperty("greedy", greedy); return this; } @@ -309,7 +308,7 @@ public interface SmbEndpointBuilderFactory { * @param initialDelay the value to set * @return the dsl builder */ - default SmbEndpointBuilder initialDelay(long initialDelay) { + default SmbEndpointConsumerBuilder initialDelay(long initialDelay) { doSetProperty("initialDelay", initialDelay); return this; } @@ -324,7 +323,7 @@ public interface SmbEndpointBuilderFactory { * @param initialDelay the value to set * @return the dsl builder */ - default SmbEndpointBuilder initialDelay(String initialDelay) { + default SmbEndpointConsumerBuilder initialDelay(String initialDelay) { doSetProperty("initialDelay", initialDelay); return this; } @@ -341,7 +340,7 @@ public interface SmbEndpointBuilderFactory { * @param repeatCount the value to set * @return the dsl builder */ - default SmbEndpointBuilder repeatCount(long repeatCount) { + default SmbEndpointConsumerBuilder repeatCount(long repeatCount) { doSetProperty("repeatCount", repeatCount); return this; } @@ -358,7 +357,7 @@ public interface SmbEndpointBuilderFactory { * @param repeatCount the value to set * @return the dsl builder */ - default SmbEndpointBuilder repeatCount(String repeatCount) { + default SmbEndpointConsumerBuilder repeatCount(String repeatCount) { doSetProperty("repeatCount", repeatCount); return this; } @@ -374,7 +373,7 @@ public interface SmbEndpointBuilderFactory { * @param runLoggingLevel the value to set * @return the dsl builder */ - default SmbEndpointBuilder runLoggingLevel(org.apache.camel.LoggingLevel runLoggingLevel) { + default SmbEndpointConsumerBuilder runLoggingLevel(org.apache.camel.LoggingLevel runLoggingLevel) { doSetProperty("runLoggingLevel", runLoggingLevel); return this; } @@ -391,7 +390,7 @@ public interface SmbEndpointBuilderFactory { * @param runLoggingLevel the value to set * @return the dsl builder */ - default SmbEndpointBuilder runLoggingLevel(String runLoggingLevel) { + default SmbEndpointConsumerBuilder runLoggingLevel(String runLoggingLevel) { doSetProperty("runLoggingLevel", runLoggingLevel); return this; } @@ -408,7 +407,7 @@ public interface SmbEndpointBuilderFactory { * @param scheduledExecutorService the value to set * @return the dsl builder */ - default SmbEndpointBuilder scheduledExecutorService(ScheduledExecutorService scheduledExecutorService) { + default SmbEndpointConsumerBuilder scheduledExecutorService(ScheduledExecutorService scheduledExecutorService) { doSetProperty("scheduledExecutorService", scheduledExecutorService); return this; } @@ -425,7 +424,7 @@ public interface SmbEndpointBuilderFactory { * @param scheduledExecutorService the value to set * @return the dsl builder */ - default SmbEndpointBuilder scheduledExecutorService(String scheduledExecutorService) { + default SmbEndpointConsumerBuilder scheduledExecutorService(String scheduledExecutorService) { doSetProperty("scheduledExecutorService", scheduledExecutorService); return this; } @@ -441,7 +440,7 @@ public interface SmbEndpointBuilderFactory { * @param scheduler the value to set * @return the dsl builder */ - default SmbEndpointBuilder scheduler(Object scheduler) { + default SmbEndpointConsumerBuilder scheduler(Object scheduler) { doSetProperty("scheduler", scheduler); return this; } @@ -457,7 +456,7 @@ public interface SmbEndpointBuilderFactory { * @param scheduler the value to set * @return the dsl builder */ - default SmbEndpointBuilder scheduler(String scheduler) { + default SmbEndpointConsumerBuilder scheduler(String scheduler) { doSetProperty("scheduler", scheduler); return this; } @@ -477,7 +476,7 @@ public interface SmbEndpointBuilderFactory { * @param value the option value * @return the dsl builder */ - default SmbEndpointBuilder schedulerProperties(String key, Object value) { + default SmbEndpointConsumerBuilder schedulerProperties(String key, Object value) { doSetMultiValueProperty("schedulerProperties", "scheduler." + key, value); return this; } @@ -496,7 +495,7 @@ public interface SmbEndpointBuilderFactory { * @param values the values * @return the dsl builder */ - default SmbEndpointBuilder schedulerProperties(Map values) { + default SmbEndpointConsumerBuilder schedulerProperties(Map values) { doSetMultiValueProperties("schedulerProperties", "scheduler.", values); return this; } @@ -511,7 +510,7 @@ public interface SmbEndpointBuilderFactory { * @param startScheduler the value to set * @return the dsl builder */ - default SmbEndpointBuilder startScheduler(boolean startScheduler) { + default SmbEndpointConsumerBuilder startScheduler(boolean startScheduler) { doSetProperty("startScheduler", startScheduler); return this; } @@ -526,7 +525,7 @@ public interface SmbEndpointBuilderFactory { * @param startScheduler the value to set * @return the dsl builder */ - default SmbEndpointBuilder startScheduler(String startScheduler) { + default SmbEndpointConsumerBuilder startScheduler(String startScheduler) { doSetProperty("startScheduler", startScheduler); return this; } @@ -541,7 +540,7 @@ public interface SmbEndpointBuilderFactory { * @param timeUnit the value to set * @return the dsl builder */ - default SmbEndpointBuilder timeUnit(TimeUnit timeUnit) { + default SmbEndpointConsumerBuilder timeUnit(TimeUnit timeUnit) { doSetProperty("timeUnit", timeUnit); return this; } @@ -557,7 +556,7 @@ public interface SmbEndpointBuilderFactory { * @param timeUnit the value to set * @return the dsl builder */ - default SmbEndpointBuilder timeUnit(String timeUnit) { + default SmbEndpointConsumerBuilder timeUnit(String timeUnit) { doSetProperty("timeUnit", timeUnit); return this; } @@ -573,7 +572,7 @@ public interface SmbEndpointBuilderFactory { * @param useFixedDelay the value to set * @return the dsl builder */ - default SmbEndpointBuilder useFixedDelay(boolean useFixedDelay) { + default SmbEndpointConsumerBuilder useFixedDelay(boolean useFixedDelay) { doSetProperty("useFixedDelay", useFixedDelay); return this; } @@ -589,7 +588,7 @@ public interface SmbEndpointBuilderFactory { * @param useFixedDelay the value to set * @return the dsl builder */ - default SmbEndpointBuilder useFixedDelay(String useFixedDelay) { + default SmbEndpointConsumerBuilder useFixedDelay(String useFixedDelay) { doSetProperty("useFixedDelay", useFixedDelay); return this; } @@ -603,7 +602,7 @@ public interface SmbEndpointBuilderFactory { * @param domain the value to set * @return the dsl builder */ - default SmbEndpointBuilder domain(String domain) { + default SmbEndpointConsumerBuilder domain(String domain) { doSetProperty("domain", domain); return this; } @@ -617,7 +616,7 @@ public interface SmbEndpointBuilderFactory { * @param password the value to set * @return the dsl builder */ - default SmbEndpointBuilder password(String password) { + default SmbEndpointConsumerBuilder password(String password) { doSetProperty("password", password); return this; } @@ -631,22 +630,21 @@ public interface SmbEndpointBuilderFactory { * @param username the value to set * @return the dsl builder */ - default SmbEndpointBuilder username(String username) { + default SmbEndpointConsumerBuilder username(String username) { doSetProperty("username", username); return this; } } /** - * Advanced builder for endpoint for the SMB component. + * Advanced builder for endpoint consumers for the SMB component. */ - public interface AdvancedSmbEndpointBuilder + public interface AdvancedSmbEndpointConsumerBuilder extends EndpointConsumerBuilder { - default SmbEndpointBuilder basic() { - return (SmbEndpointBuilder) this; + default SmbEndpointConsumerBuilder basic() { + return (SmbEndpointConsumerBuilder) this; } - /** * Allows for bridging the consumer to the Camel routing Error Handler, * which mean any exceptions (if possible) occurred while the Camel @@ -669,7 +667,7 @@ public interface SmbEndpointBuilderFactory { * @param bridgeErrorHandler the value to set * @return the dsl builder */ - default AdvancedSmbEndpointBuilder bridgeErrorHandler(boolean bridgeErrorHandler) { + default AdvancedSmbEndpointConsumerBuilder bridgeErrorHandler(boolean bridgeErrorHandler) { doSetProperty("bridgeErrorHandler", bridgeErrorHandler); return this; } @@ -695,7 +693,7 @@ public interface SmbEndpointBuilderFactory { * @param bridgeErrorHandler the value to set * @return the dsl builder */ - default AdvancedSmbEndpointBuilder bridgeErrorHandler(String bridgeErrorHandler) { + default AdvancedSmbEndpointConsumerBuilder bridgeErrorHandler(String bridgeErrorHandler) { doSetProperty("bridgeErrorHandler", bridgeErrorHandler); return this; } @@ -713,7 +711,7 @@ public interface SmbEndpointBuilderFactory { * @param exceptionHandler the value to set * @return the dsl builder */ - default AdvancedSmbEndpointBuilder exceptionHandler(org.apache.camel.spi.ExceptionHandler exceptionHandler) { + default AdvancedSmbEndpointConsumerBuilder exceptionHandler(org.apache.camel.spi.ExceptionHandler exceptionHandler) { doSetProperty("exceptionHandler", exceptionHandler); return this; } @@ -731,7 +729,7 @@ public interface SmbEndpointBuilderFactory { * @param exceptionHandler the value to set * @return the dsl builder */ - default AdvancedSmbEndpointBuilder exceptionHandler(String exceptionHandler) { + default AdvancedSmbEndpointConsumerBuilder exceptionHandler(String exceptionHandler) { doSetProperty("exceptionHandler", exceptionHandler); return this; } @@ -745,7 +743,7 @@ public interface SmbEndpointBuilderFactory { * @param exchangePattern the value to set * @return the dsl builder */ - default AdvancedSmbEndpointBuilder exchangePattern(org.apache.camel.ExchangePattern exchangePattern) { + default AdvancedSmbEndpointConsumerBuilder exchangePattern(org.apache.camel.ExchangePattern exchangePattern) { doSetProperty("exchangePattern", exchangePattern); return this; } @@ -760,7 +758,7 @@ public interface SmbEndpointBuilderFactory { * @param exchangePattern the value to set * @return the dsl builder */ - default AdvancedSmbEndpointBuilder exchangePattern(String exchangePattern) { + default AdvancedSmbEndpointConsumerBuilder exchangePattern(String exchangePattern) { doSetProperty("exchangePattern", exchangePattern); return this; } @@ -778,7 +776,7 @@ public interface SmbEndpointBuilderFactory { * @param pollStrategy the value to set * @return the dsl builder */ - default AdvancedSmbEndpointBuilder pollStrategy(org.apache.camel.spi.PollingConsumerPollStrategy pollStrategy) { + default AdvancedSmbEndpointConsumerBuilder pollStrategy(org.apache.camel.spi.PollingConsumerPollStrategy pollStrategy) { doSetProperty("pollStrategy", pollStrategy); return this; } @@ -796,10 +794,500 @@ public interface SmbEndpointBuilderFactory { * @param pollStrategy the value to set * @return the dsl builder */ - default AdvancedSmbEndpointBuilder pollStrategy(String pollStrategy) { + default AdvancedSmbEndpointConsumerBuilder pollStrategy(String pollStrategy) { doSetProperty("pollStrategy", pollStrategy); return this; } + /** + * A pluggable repository org.apache.camel.spi.IdempotentRepository + * which by default use MemoryIdempotentRepository if none is specified. + * + * The option is a: + * <code>org.apache.camel.spi.IdempotentRepository</code> type. + * + * Group: advanced + * + * @param idempotentRepository the value to set + * @return the dsl builder + */ + default AdvancedSmbEndpointConsumerBuilder idempotentRepository(org.apache.camel.spi.IdempotentRepository idempotentRepository) { + doSetProperty("idempotentRepository", idempotentRepository); + return this; + } + /** + * A pluggable repository org.apache.camel.spi.IdempotentRepository + * which by default use MemoryIdempotentRepository if none is specified. + * + * The option will be converted to a + * <code>org.apache.camel.spi.IdempotentRepository</code> type. + * + * Group: advanced + * + * @param idempotentRepository the value to set + * @return the dsl builder + */ + default AdvancedSmbEndpointConsumerBuilder idempotentRepository(String idempotentRepository) { + doSetProperty("idempotentRepository", idempotentRepository); + return this; + } + /** + * An optional SMB client configuration, can be used to configure client + * specific configurations, like timeouts. + * + * The option is a: <code>com.hierynomus.smbj.SmbConfig</code> type. + * + * Group: advanced + * + * @param smbConfig the value to set + * @return the dsl builder + */ + default AdvancedSmbEndpointConsumerBuilder smbConfig(com.hierynomus.smbj.SmbConfig smbConfig) { + doSetProperty("smbConfig", smbConfig); + return this; + } + /** + * An optional SMB client configuration, can be used to configure client + * specific configurations, like timeouts. + * + * The option will be converted to a + * <code>com.hierynomus.smbj.SmbConfig</code> type. + * + * Group: advanced + * + * @param smbConfig the value to set + * @return the dsl builder + */ + default AdvancedSmbEndpointConsumerBuilder smbConfig(String smbConfig) { + doSetProperty("smbConfig", smbConfig); + return this; + } + /** + * An optional SMB I/O bean to use to setup the file access attributes + * when reading/writing a file. + * + * The option is a: + * <code>org.apache.camel.component.smb.SmbIOBean</code> type. + * + * Group: advanced + * + * @param smbIoBean the value to set + * @return the dsl builder + */ + default AdvancedSmbEndpointConsumerBuilder smbIoBean(org.apache.camel.component.smb.SmbIOBean smbIoBean) { + doSetProperty("smbIoBean", smbIoBean); + return this; + } + /** + * An optional SMB I/O bean to use to setup the file access attributes + * when reading/writing a file. + * + * The option will be converted to a + * <code>org.apache.camel.component.smb.SmbIOBean</code> type. + * + * Group: advanced + * + * @param smbIoBean the value to set + * @return the dsl builder + */ + default AdvancedSmbEndpointConsumerBuilder smbIoBean(String smbIoBean) { + doSetProperty("smbIoBean", smbIoBean); + return this; + } + } + + /** + * Builder for endpoint producers for the SMB component. + */ + public interface SmbEndpointProducerBuilder + extends + EndpointProducerBuilder { + default AdvancedSmbEndpointProducerBuilder advanced() { + return (AdvancedSmbEndpointProducerBuilder) this; + } + + /** + * The path, within the share, to consume the files from. + * + * The option is a: <code>java.lang.String</code> type. + * + * Required: true + * Group: common + * + * @param path the value to set + * @return the dsl builder + */ + default SmbEndpointProducerBuilder path(String path) { + doSetProperty("path", path); + return this; + } + /** + * The search pattern used to list the files. + * + * The option is a: <code>java.lang.String</code> type. + * + * Default: *.txt + * Group: common + * + * @param searchPattern the value to set + * @return the dsl builder + */ + default SmbEndpointProducerBuilder searchPattern(String searchPattern) { + doSetProperty("searchPattern", searchPattern); + return this; + } + /** + * Whether to create parent directory if it does not exist. + * + * The option is a: <code>boolean</code> type. + * + * Default: false + * Group: producer + * + * @param autoCreate the value to set + * @return the dsl builder + */ + default SmbEndpointProducerBuilder autoCreate(boolean autoCreate) { + doSetProperty("autoCreate", autoCreate); + return this; + } + /** + * Whether to create parent directory if it does not exist. + * + * The option will be converted to a <code>boolean</code> type. + * + * Default: false + * Group: producer + * + * @param autoCreate the value to set + * @return the dsl builder + */ + default SmbEndpointProducerBuilder autoCreate(String autoCreate) { + doSetProperty("autoCreate", autoCreate); + return this; + } + /** + * What action to take if the SMB file already exists. + * + * The option is a: + * <code>org.apache.camel.component.file.GenericFileExist</code> type. + * + * Default: Ignore + * Group: producer + * + * @param fileExist the value to set + * @return the dsl builder + */ + default SmbEndpointProducerBuilder fileExist(org.apache.camel.component.file.GenericFileExist fileExist) { + doSetProperty("fileExist", fileExist); + return this; + } + /** + * What action to take if the SMB file already exists. + * + * The option will be converted to a + * <code>org.apache.camel.component.file.GenericFileExist</code> type. + * + * Default: Ignore + * Group: producer + * + * @param fileExist the value to set + * @return the dsl builder + */ + default SmbEndpointProducerBuilder fileExist(String fileExist) { + doSetProperty("fileExist", fileExist); + return this; + } + /** + * The user domain. + * + * The option is a: <code>java.lang.String</code> type. + * + * Group: security + * + * @param domain the value to set + * @return the dsl builder + */ + default SmbEndpointProducerBuilder domain(String domain) { + doSetProperty("domain", domain); + return this; + } + /** + * The password to access the share. + * + * The option is a: <code>java.lang.String</code> type. + * + * Group: security + * + * @param password the value to set + * @return the dsl builder + */ + default SmbEndpointProducerBuilder password(String password) { + doSetProperty("password", password); + return this; + } + /** + * The username required to access the share. + * + * The option is a: <code>java.lang.String</code> type. + * + * Group: security + * + * @param username the value to set + * @return the dsl builder + */ + default SmbEndpointProducerBuilder username(String username) { + doSetProperty("username", username); + return this; + } + } + + /** + * Advanced builder for endpoint producers for the SMB component. + */ + public interface AdvancedSmbEndpointProducerBuilder extends EndpointProducerBuilder { + default SmbEndpointProducerBuilder basic() { + return (SmbEndpointProducerBuilder) this; + } + + /** + * Whether the producer should be started lazy (on the first message). + * By starting lazy you can use this to allow CamelContext and routes to + * startup in situations where a producer may otherwise fail during + * starting and cause the route to fail being started. By deferring this + * startup to be lazy then the startup failure can be handled during + * routing messages via Camel's routing error handlers. Beware that when + * the first message is processed then creating and starting the + * producer may take a little time and prolong the total processing time + * of the processing. + * + * The option is a: <code>boolean</code> type. + * + * Default: false + * Group: producer (advanced) + * + * @param lazyStartProducer the value to set + * @return the dsl builder + */ + default AdvancedSmbEndpointProducerBuilder lazyStartProducer(boolean lazyStartProducer) { + doSetProperty("lazyStartProducer", lazyStartProducer); + return this; + } + /** + * Whether the producer should be started lazy (on the first message). + * By starting lazy you can use this to allow CamelContext and routes to + * startup in situations where a producer may otherwise fail during + * starting and cause the route to fail being started. By deferring this + * startup to be lazy then the startup failure can be handled during + * routing messages via Camel's routing error handlers. Beware that when + * the first message is processed then creating and starting the + * producer may take a little time and prolong the total processing time + * of the processing. + * + * The option will be converted to a <code>boolean</code> type. + * + * Default: false + * Group: producer (advanced) + * + * @param lazyStartProducer the value to set + * @return the dsl builder + */ + default AdvancedSmbEndpointProducerBuilder lazyStartProducer(String lazyStartProducer) { + doSetProperty("lazyStartProducer", lazyStartProducer); + return this; + } + /** + * A pluggable repository org.apache.camel.spi.IdempotentRepository + * which by default use MemoryIdempotentRepository if none is specified. + * + * The option is a: + * <code>org.apache.camel.spi.IdempotentRepository</code> type. + * + * Group: advanced + * + * @param idempotentRepository the value to set + * @return the dsl builder + */ + default AdvancedSmbEndpointProducerBuilder idempotentRepository(org.apache.camel.spi.IdempotentRepository idempotentRepository) { + doSetProperty("idempotentRepository", idempotentRepository); + return this; + } + /** + * A pluggable repository org.apache.camel.spi.IdempotentRepository + * which by default use MemoryIdempotentRepository if none is specified. + * + * The option will be converted to a + * <code>org.apache.camel.spi.IdempotentRepository</code> type. + * + * Group: advanced + * + * @param idempotentRepository the value to set + * @return the dsl builder + */ + default AdvancedSmbEndpointProducerBuilder idempotentRepository(String idempotentRepository) { + doSetProperty("idempotentRepository", idempotentRepository); + return this; + } + /** + * An optional SMB client configuration, can be used to configure client + * specific configurations, like timeouts. + * + * The option is a: <code>com.hierynomus.smbj.SmbConfig</code> type. + * + * Group: advanced + * + * @param smbConfig the value to set + * @return the dsl builder + */ + default AdvancedSmbEndpointProducerBuilder smbConfig(com.hierynomus.smbj.SmbConfig smbConfig) { + doSetProperty("smbConfig", smbConfig); + return this; + } + /** + * An optional SMB client configuration, can be used to configure client + * specific configurations, like timeouts. + * + * The option will be converted to a + * <code>com.hierynomus.smbj.SmbConfig</code> type. + * + * Group: advanced + * + * @param smbConfig the value to set + * @return the dsl builder + */ + default AdvancedSmbEndpointProducerBuilder smbConfig(String smbConfig) { + doSetProperty("smbConfig", smbConfig); + return this; + } + /** + * An optional SMB I/O bean to use to setup the file access attributes + * when reading/writing a file. + * + * The option is a: + * <code>org.apache.camel.component.smb.SmbIOBean</code> type. + * + * Group: advanced + * + * @param smbIoBean the value to set + * @return the dsl builder + */ + default AdvancedSmbEndpointProducerBuilder smbIoBean(org.apache.camel.component.smb.SmbIOBean smbIoBean) { + doSetProperty("smbIoBean", smbIoBean); + return this; + } + /** + * An optional SMB I/O bean to use to setup the file access attributes + * when reading/writing a file. + * + * The option will be converted to a + * <code>org.apache.camel.component.smb.SmbIOBean</code> type. + * + * Group: advanced + * + * @param smbIoBean the value to set + * @return the dsl builder + */ + default AdvancedSmbEndpointProducerBuilder smbIoBean(String smbIoBean) { + doSetProperty("smbIoBean", smbIoBean); + return this; + } + } + + /** + * Builder for endpoint for the SMB component. + */ + public interface SmbEndpointBuilder + extends + SmbEndpointConsumerBuilder, + SmbEndpointProducerBuilder { + default AdvancedSmbEndpointBuilder advanced() { + return (AdvancedSmbEndpointBuilder) this; + } + + /** + * The path, within the share, to consume the files from. + * + * The option is a: <code>java.lang.String</code> type. + * + * Required: true + * Group: common + * + * @param path the value to set + * @return the dsl builder + */ + default SmbEndpointBuilder path(String path) { + doSetProperty("path", path); + return this; + } + /** + * The search pattern used to list the files. + * + * The option is a: <code>java.lang.String</code> type. + * + * Default: *.txt + * Group: common + * + * @param searchPattern the value to set + * @return the dsl builder + */ + default SmbEndpointBuilder searchPattern(String searchPattern) { + doSetProperty("searchPattern", searchPattern); + return this; + } + /** + * The user domain. + * + * The option is a: <code>java.lang.String</code> type. + * + * Group: security + * + * @param domain the value to set + * @return the dsl builder + */ + default SmbEndpointBuilder domain(String domain) { + doSetProperty("domain", domain); + return this; + } + /** + * The password to access the share. + * + * The option is a: <code>java.lang.String</code> type. + * + * Group: security + * + * @param password the value to set + * @return the dsl builder + */ + default SmbEndpointBuilder password(String password) { + doSetProperty("password", password); + return this; + } + /** + * The username required to access the share. + * + * The option is a: <code>java.lang.String</code> type. + * + * Group: security + * + * @param username the value to set + * @return the dsl builder + */ + default SmbEndpointBuilder username(String username) { + doSetProperty("username", username); + return this; + } + } + + /** + * Advanced builder for endpoint for the SMB component. + */ + public interface AdvancedSmbEndpointBuilder + extends + AdvancedSmbEndpointConsumerBuilder, + AdvancedSmbEndpointProducerBuilder { + default SmbEndpointBuilder basic() { + return (SmbEndpointBuilder) this; + } + /** * A pluggable repository org.apache.camel.spi.IdempotentRepository * which by default use MemoryIdempotentRepository if none is specified. diff --git a/dsl/camel-kotlin-api/src/generated/kotlin/org/apache/camel/kotlin/components/SmbUriDsl.kt b/dsl/camel-kotlin-api/src/generated/kotlin/org/apache/camel/kotlin/components/SmbUriDsl.kt index 744e32cf899..ae59ba7eb67 100644 --- a/dsl/camel-kotlin-api/src/generated/kotlin/org/apache/camel/kotlin/components/SmbUriDsl.kt +++ b/dsl/camel-kotlin-api/src/generated/kotlin/org/apache/camel/kotlin/components/SmbUriDsl.kt @@ -86,6 +86,13 @@ public class SmbUriDsl( it.property("path", path) } + /** + * The search pattern used to list the files + */ + public fun searchPattern(searchPattern: String) { + it.property("searchPattern", searchPattern) + } + /** * If a directory, will look for files in all the sub-directories as well. */ @@ -100,13 +107,6 @@ public class SmbUriDsl( it.property("recursive", recursive.toString()) } - /** - * The search pattern used to list the files - */ - public fun searchPattern(searchPattern: String) { - it.property("searchPattern", searchPattern) - } - /** * If the polling consumer did not poll any files, you can enable this option to send an empty * message (no body) instead. @@ -178,6 +178,51 @@ public class SmbUriDsl( it.property("pollStrategy", pollStrategy) } + /** + * Whether to create parent directory if it does not exist + */ + public fun autoCreate(autoCreate: String) { + it.property("autoCreate", autoCreate) + } + + /** + * Whether to create parent directory if it does not exist + */ + public fun autoCreate(autoCreate: Boolean) { + it.property("autoCreate", autoCreate.toString()) + } + + /** + * What action to take if the SMB file already exists + */ + public fun fileExist(fileExist: String) { + it.property("fileExist", fileExist) + } + + /** + * Whether the producer should be started lazy (on the first message). By starting lazy you can + * use this to allow CamelContext and routes to startup in situations where a producer may otherwise + * fail during starting and cause the route to fail being started. By deferring this startup to be + * lazy then the startup failure can be handled during routing messages via Camel's routing error + * handlers. Beware that when the first message is processed then creating and starting the producer + * may take a little time and prolong the total processing time of the processing. + */ + public fun lazyStartProducer(lazyStartProducer: String) { + it.property("lazyStartProducer", lazyStartProducer) + } + + /** + * Whether the producer should be started lazy (on the first message). By starting lazy you can + * use this to allow CamelContext and routes to startup in situations where a producer may otherwise + * fail during starting and cause the route to fail being started. By deferring this startup to be + * lazy then the startup failure can be handled during routing messages via Camel's routing error + * handlers. Beware that when the first message is processed then creating and starting the producer + * may take a little time and prolong the total processing time of the processing. + */ + public fun lazyStartProducer(lazyStartProducer: Boolean) { + it.property("lazyStartProducer", lazyStartProducer.toString()) + } + /** * A pluggable repository org.apache.camel.spi.IdempotentRepository which by default use * MemoryIdempotentRepository if none is specified.