This is an automated email from the ASF dual-hosted git repository. davsclaus pushed a commit to branch main in repository https://gitbox.apache.org/repos/asf/camel.git
The following commit(s) were added to refs/heads/main by this push: new 8d716d2a6ed Update to latest version of dhis2-java-sdk; support PAT authentication; add async param to resourceTables/analytics (#13007) 8d716d2a6ed is described below commit 8d716d2a6ed40ecc3052b96e008c6f744f746c8f Author: Claude Mamo <823038+claudem...@users.noreply.github.com> AuthorDate: Mon Feb 5 16:44:23 2024 +0100 Update to latest version of dhis2-java-sdk; support PAT authentication; add async param to resourceTables/analytics (#13007) * chore: update to latest version of dhis2-java-sdk feat: support PAT authentication; add async param to resourceTables/analytics docs: update examples to use DHIS2 v40; provide better descriptions in Dhis2Configuration * test: add test coverage for async param * fix: commit missing change * refactor: rename `pat` to `personalAccessToken` * fix: commit missing change * fix: correct error message test: add coverage for Dhis2Component * fix: commit changed file --- .../org/apache/camel/catalog/components/dhis2.json | 22 +++--- .../apache/camel/catalog/main/sensitive-keys.json | 1 + .../apache/camel/component/dhis2/api/Dhis2Get.java | 12 ++-- .../component/dhis2/api/Dhis2ResourceTables.java | 22 +++--- .../component/dhis2/api/Dhis2DeleteTestCase.java | 5 ++ .../component/dhis2/api/Dhis2GetTestCase.java | 78 +++++++++++++++++++++- .../component/dhis2/api/Dhis2PostTestCase.java | 5 ++ .../component/dhis2/api/Dhis2PutTestCase.java | 5 ++ ...tCase.java => Dhis2ResourceTablesTestCase.java} | 30 +++++---- .../camel-dhis2/camel-dhis2-component/pom.xml | 1 + .../component/dhis2/Dhis2ComponentConfigurer.java | 7 ++ .../dhis2/Dhis2ConfigurationConfigurer.java | 6 ++ ...Dhis2DeleteEndpointConfigurationConfigurer.java | 7 ++ .../component/dhis2/Dhis2EndpointConfigurer.java | 7 ++ .../component/dhis2/Dhis2EndpointUriFactory.java | 7 +- .../dhis2/Dhis2GetEndpointConfiguration.java | 8 +-- .../Dhis2GetEndpointConfigurationConfigurer.java | 15 ++++- .../Dhis2PostEndpointConfigurationConfigurer.java | 7 ++ .../Dhis2PutEndpointConfigurationConfigurer.java | 7 ++ .../Dhis2ResourceTablesEndpointConfiguration.java | 13 +++- ...ourceTablesEndpointConfigurationConfigurer.java | 14 ++++ .../dhis2/internal/Dhis2ApiCollection.java | 2 +- .../dhis2/internal/Dhis2GetApiMethod.java | 4 +- .../internal/Dhis2ResourceTablesApiMethod.java | 3 +- .../org/apache/camel/component/dhis2/dhis2.json | 22 +++--- .../src/main/docs/dhis2-component.adoc | 62 ++++++++--------- .../camel/component/dhis2/Dhis2Component.java | 23 ++++++- .../camel/component/dhis2/Dhis2Configuration.java | 19 +++++- .../component/dhis2/AbstractDhis2TestSupport.java | 9 ++- .../component/dhis2/Dhis2ComponentTestCase.java | 41 ++++++++++++ .../camel/component/dhis2/Dhis2DeleteIT.java | 8 +-- .../apache/camel/component/dhis2/Dhis2GetIT.java | 11 ++- .../apache/camel/component/dhis2/Dhis2PostIT.java | 2 +- .../apache/camel/component/dhis2/Dhis2PutIT.java | 2 +- .../apache/camel/component/dhis2/Environment.java | 38 +++++++++-- components/camel-dhis2/pom.xml | 4 +- .../java/org/apache/camel/util/SensitiveUtils.java | 2 + 37 files changed, 404 insertions(+), 127 deletions(-) diff --git a/catalog/camel-catalog/src/generated/resources/org/apache/camel/catalog/components/dhis2.json b/catalog/camel-catalog/src/generated/resources/org/apache/camel/catalog/components/dhis2.json index f75cb3e8b04..a8517e50b3e 100644 --- a/catalog/camel-catalog/src/generated/resources/org/apache/camel/catalog/components/dhis2.json +++ b/catalog/camel-catalog/src/generated/resources/org/apache/camel/catalog/components/dhis2.json @@ -28,10 +28,11 @@ "bridgeErrorHandler": { "index": 1, "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 [...] "lazyStartProducer": { "index": 2, "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": 3, "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 [...] - "client": { "index": 4, "kind": "property", "displayName": "Client", "group": "advanced", "label": "advanced", "required": false, "type": "object", "javaType": "org.hisp.dhis.integration.sdk.api.Dhis2Client", "deprecated": false, "autowired": false, "secret": false, "configurationClass": "org.apache.camel.component.dhis2.Dhis2Configuration", "configurationField": "configuration", "description": "References a user-defined org.hisp.dhis.integration.sdk.api.Dhis2Client" }, + "client": { "index": 4, "kind": "property", "displayName": "Client", "group": "advanced", "label": "advanced", "required": false, "type": "object", "javaType": "org.hisp.dhis.integration.sdk.api.Dhis2Client", "deprecated": false, "autowired": false, "secret": false, "configurationClass": "org.apache.camel.component.dhis2.Dhis2Configuration", "configurationField": "configuration", "description": "References a user-defined org.hisp.dhis.integration.sdk.api.Dhis2Client. This option is m [...] "configuration": { "index": 5, "kind": "property", "displayName": "Configuration", "group": "advanced", "label": "advanced", "required": false, "type": "object", "javaType": "org.apache.camel.component.dhis2.Dhis2Configuration", "deprecated": false, "autowired": false, "secret": false, "description": "To use the shared configuration" }, - "password": { "index": 6, "kind": "property", "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.dhis2.Dhis2Configuration", "configurationField": "configuration", "description": "DHIS2 account password for accessing the DHIS2 API" }, - "username": { "index": 7, "kind": "property", "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.dhis2.Dhis2Configuration", "configurationField": "configuration", "description": "DHIS2 account username for accessing the DHIS2 API" } + "password": { "index": 6, "kind": "property", "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.dhis2.Dhis2Configuration", "configurationField": "configuration", "description": "Password of the DHIS2 username" }, + "personalAccessToken": { "index": 7, "kind": "property", "displayName": "Personal Access Token", "group": "security", "label": "security", "required": false, "type": "string", "javaType": "java.lang.String", "deprecated": false, "autowired": false, "secret": true, "configurationClass": "org.apache.camel.component.dhis2.Dhis2Configuration", "configurationField": "configuration", "description": "Personal access token to authenticate with DHIS2. This option is mutually exclusive to user [...] + "username": { "index": 8, "kind": "property", "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.dhis2.Dhis2Configuration", "configurationField": "configuration", "description": "Username of the DHIS2 user to operate as" } }, "properties": { "apiName": { "index": 0, "kind": "path", "displayName": "Api Name", "group": "common", "label": "", "required": true, "type": "object", "javaType": "org.apache.camel.component.dhis2.internal.Dhis2ApiName", "enum": [ "POST", "RESOURCE_TABLES", "GET", "DELETE", "PUT" ], "deprecated": false, "deprecationNote": "", "autowired": false, "secret": false, "configurationClass": "org.apache.camel.component.dhis2.Dhis2Configuration", "configurationField": "configuration", "description": "API op [...] @@ -44,7 +45,7 @@ "exchangePattern": { "index": 7, "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": 8, "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 pol [...] "lazyStartProducer": { "index": 9, "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 produc [...] - "client": { "index": 10, "kind": "parameter", "displayName": "Client", "group": "advanced", "label": "advanced", "required": false, "type": "object", "javaType": "org.hisp.dhis.integration.sdk.api.Dhis2Client", "deprecated": false, "autowired": false, "secret": false, "configurationClass": "org.apache.camel.component.dhis2.Dhis2Configuration", "configurationField": "configuration", "description": "References a user-defined org.hisp.dhis.integration.sdk.api.Dhis2Client" }, + "client": { "index": 10, "kind": "parameter", "displayName": "Client", "group": "advanced", "label": "advanced", "required": false, "type": "object", "javaType": "org.hisp.dhis.integration.sdk.api.Dhis2Client", "deprecated": false, "autowired": false, "secret": false, "configurationClass": "org.apache.camel.component.dhis2.Dhis2Configuration", "configurationField": "configuration", "description": "References a user-defined org.hisp.dhis.integration.sdk.api.Dhis2Client. This option is [...] "backoffErrorThreshold": { "index": 11, "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": 12, "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": 13, "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 [...] @@ -59,21 +60,22 @@ "startScheduler": { "index": 22, "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": 23, "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": 24, "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." }, - "password": { "index": 25, "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.dhis2.Dhis2Configuration", "configurationField": "configuration", "description": "DHIS2 account password for accessing the DHIS2 API" }, - "username": { "index": 26, "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.dhis2.Dhis2Configuration", "configurationField": "configuration", "description": "DHIS2 account username for accessing the DHIS2 API" } + "password": { "index": 25, "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.dhis2.Dhis2Configuration", "configurationField": "configuration", "description": "Password of the DHIS2 username" }, + "personalAccessToken": { "index": 26, "kind": "parameter", "displayName": "Personal Access Token", "group": "security", "label": "security", "required": false, "type": "string", "javaType": "java.lang.String", "deprecated": false, "autowired": false, "secret": true, "configurationClass": "org.apache.camel.component.dhis2.Dhis2Configuration", "configurationField": "configuration", "description": "Personal access token to authenticate with DHIS2. This option is mutually exclusive to us [...] + "username": { "index": 27, "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.dhis2.Dhis2Configuration", "configurationField": "configuration", "description": "Username of the DHIS2 user to operate as" } }, "apis": { "delete": { "consumerOnly": false, "producerOnly": false, "description": "", "methods": { "resource": { "description": "", "signatures": [ "java.io.InputStream resource(String path, Object resource, java.util.Map<String, Object> queryParams)" ] } } }, - "get": { "consumerOnly": false, "producerOnly": false, "description": "", "methods": { "collection": { "description": "", "signatures": [ "java.util.Iterator<org.apache.camel.component.dhis2.api.Dhis2Resource> collection(String path, String arrayName, Boolean paging, String fields, String filter, org.apache.camel.component.dhis2.api.RootJunctionEnum rootJunction, java.util.Map<String, Object> queryParams)" ] }, "resource": { "description": "", "signatures": [ "java.io.InputStream res [...] + "get": { "consumerOnly": false, "producerOnly": false, "description": "", "methods": { "collection": { "description": "", "signatures": [ "java.util.Iterator<org.apache.camel.component.dhis2.api.Dhis2Resource> collection(String path, String arrayName, Boolean paging, String fields, java.util.List<String> filter, org.apache.camel.component.dhis2.api.RootJunctionEnum rootJunction, java.util.Map<String, Object> queryParams)" ] }, "resource": { "description": "", "signatures": [ "java.io [...] "post": { "consumerOnly": false, "producerOnly": false, "description": "", "methods": { "resource": { "description": "", "signatures": [ "java.io.InputStream resource(String path, Object resource, java.util.Map<String, Object> queryParams)" ] } } }, "put": { "consumerOnly": false, "producerOnly": false, "description": "", "methods": { "resource": { "description": "", "signatures": [ "java.io.InputStream resource(String path, Object resource, java.util.Map<String, Object> queryParams)" ] } } }, - "resourceTables": { "consumerOnly": false, "producerOnly": false, "description": "", "methods": { "analytics": { "description": "", "signatures": [ "void analytics(Boolean skipAggregate, Boolean skipEvents, Integer lastYears, Integer interval)" ] } } } + "resourceTables": { "consumerOnly": false, "producerOnly": false, "description": "", "methods": { "analytics": { "description": "", "signatures": [ "void analytics(Boolean skipAggregate, Boolean skipEvents, Integer lastYears, Integer interval, Boolean async)" ] } } } }, "apiProperties": { "delete": { "methods": { "resource": { "properties": { "path": { "index": 0, "kind": "parameter", "displayName": "Path", "group": "common", "label": "", "required": false, "type": "string", "javaType": "java.lang.String", "deprecated": false, "autowired": false, "secret": false, "description": "", "optional": false }, "queryParams": { "index": 1, "kind": "parameter", "displayName": "Query Params", "group": "common", "label": "", "required": false, "type": "object", "javaType": "java. [...] - "get": { "methods": { "collection": { "properties": { "arrayName": { "index": 0, "kind": "parameter", "displayName": "Array Name", "group": "common", "label": "", "required": false, "type": "string", "javaType": "java.lang.String", "deprecated": false, "autowired": false, "secret": false, "description": "", "optional": false }, "fields": { "index": 1, "kind": "parameter", "displayName": "Fields", "group": "common", "label": "", "required": false, "type": "string", "javaType": "java.l [...] + "get": { "methods": { "collection": { "properties": { "arrayName": { "index": 0, "kind": "parameter", "displayName": "Array Name", "group": "common", "label": "", "required": false, "type": "string", "javaType": "java.lang.String", "deprecated": false, "autowired": false, "secret": false, "description": "", "optional": false }, "fields": { "index": 1, "kind": "parameter", "displayName": "Fields", "group": "common", "label": "", "required": false, "type": "string", "javaType": "java.l [...] "post": { "methods": { "resource": { "properties": { "path": { "index": 0, "kind": "parameter", "displayName": "Path", "group": "common", "label": "", "required": false, "type": "string", "javaType": "java.lang.String", "deprecated": false, "autowired": false, "secret": false, "description": "", "optional": false }, "queryParams": { "index": 1, "kind": "parameter", "displayName": "Query Params", "group": "common", "label": "", "required": false, "type": "object", "javaType": "java.ut [...] "put": { "methods": { "resource": { "properties": { "path": { "index": 0, "kind": "parameter", "displayName": "Path", "group": "common", "label": "", "required": false, "type": "string", "javaType": "java.lang.String", "deprecated": false, "autowired": false, "secret": false, "description": "", "optional": false }, "queryParams": { "index": 1, "kind": "parameter", "displayName": "Query Params", "group": "common", "label": "", "required": false, "type": "object", "javaType": "java.uti [...] - "resourceTables": { "methods": { "analytics": { "properties": { "interval": { "index": 0, "kind": "parameter", "displayName": "Interval", "group": "common", "label": "", "required": false, "type": "integer", "javaType": "java.lang.Integer", "deprecated": false, "autowired": false, "secret": false, "description": "", "optional": true }, "lastYears": { "index": 1, "kind": "parameter", "displayName": "Last Years", "group": "common", "label": "", "required": false, "type": "integer", "ja [...] + "resourceTables": { "methods": { "analytics": { "properties": { "async": { "index": 0, "kind": "parameter", "displayName": "Async", "group": "common", "label": "", "required": false, "type": "boolean", "javaType": "java.lang.Boolean", "deprecated": false, "autowired": false, "secret": false, "description": "", "optional": true }, "interval": { "index": 1, "kind": "parameter", "displayName": "Interval", "group": "common", "label": "", "required": false, "type": "integer", "javaType": [...] } } diff --git a/catalog/camel-catalog/src/generated/resources/org/apache/camel/catalog/main/sensitive-keys.json b/catalog/camel-catalog/src/generated/resources/org/apache/camel/catalog/main/sensitive-keys.json index 723f300dc0a..8c6be52fd38 100644 --- a/catalog/camel-catalog/src/generated/resources/org/apache/camel/catalog/main/sensitive-keys.json +++ b/catalog/camel-catalog/src/generated/resources/org/apache/camel/catalog/main/sensitive-keys.json @@ -34,6 +34,7 @@ "passcode", "passphrase", "password", + "personalaccesstoken", "privatekey", "privatekeyfile", "privatekeyname", diff --git a/components/camel-dhis2/camel-dhis2-api/src/main/java/org/apache/camel/component/dhis2/api/Dhis2Get.java b/components/camel-dhis2/camel-dhis2-api/src/main/java/org/apache/camel/component/dhis2/api/Dhis2Get.java index 6103359c71f..d2b17ceebea 100644 --- a/components/camel-dhis2/camel-dhis2-api/src/main/java/org/apache/camel/component/dhis2/api/Dhis2Get.java +++ b/components/camel-dhis2/camel-dhis2-api/src/main/java/org/apache/camel/component/dhis2/api/Dhis2Get.java @@ -33,7 +33,7 @@ public class Dhis2Get { } public InputStream resource( - String path, String fields, String filter, RootJunctionEnum rootJunction, + String path, String fields, List<String> filter, RootJunctionEnum rootJunction, Map<String, Object> queryParams) { GetOperation getOperation = newGetOperation(path, fields, filter, rootJunction, queryParams); @@ -41,15 +41,17 @@ public class Dhis2Get { } protected GetOperation newGetOperation( - String path, String fields, String filter, RootJunctionEnum rootJunction, + String path, String fields, List<String> filters, RootJunctionEnum rootJunction, Map<String, Object> queryParams) { GetOperation getOperation = dhis2Client.get(path); if (fields != null) { getOperation.withFields(fields); } - if (filter != null) { - getOperation.withFilter(filter); + if (filters != null) { + for (String filter : filters) { + getOperation.withFilter(filter); + } } if (rootJunction != null) { @@ -76,7 +78,7 @@ public class Dhis2Get { } public Iterator<Dhis2Resource> collection( - String path, String arrayName, Boolean paging, String fields, String filter, + String path, String arrayName, Boolean paging, String fields, List<String> filter, RootJunctionEnum rootJunction, Map<String, Object> queryParams) { GetOperation getOperation = newGetOperation(path, fields, filter, rootJunction, queryParams); diff --git a/components/camel-dhis2/camel-dhis2-api/src/main/java/org/apache/camel/component/dhis2/api/Dhis2ResourceTables.java b/components/camel-dhis2/camel-dhis2-api/src/main/java/org/apache/camel/component/dhis2/api/Dhis2ResourceTables.java index db5e8b71980..72632d6f77d 100644 --- a/components/camel-dhis2/camel-dhis2-api/src/main/java/org/apache/camel/component/dhis2/api/Dhis2ResourceTables.java +++ b/components/camel-dhis2/camel-dhis2-api/src/main/java/org/apache/camel/component/dhis2/api/Dhis2ResourceTables.java @@ -19,6 +19,7 @@ package org.apache.camel.component.dhis2.api; import java.util.Map; import java.util.Objects; +import org.apache.camel.RuntimeCamelException; import org.hisp.dhis.integration.sdk.api.Dhis2Client; import org.hisp.dhis.integration.sdk.api.operation.PostOperation; @@ -29,7 +30,7 @@ public class Dhis2ResourceTables { this.dhis2Client = dhis2Client; } - public void analytics(Boolean skipAggregate, Boolean skipEvents, Integer lastYears, Integer interval) { + public void analytics(Boolean skipAggregate, Boolean skipEvents, Integer lastYears, Integer interval, Boolean async) { PostOperation postOperation = dhis2Client.post("resourceTables/analytics"); if (skipEvents != null) { postOperation.withParameter("skipEvents", String.valueOf(skipEvents)); @@ -44,24 +45,23 @@ public class Dhis2ResourceTables { Map<String, Object> webMessage = postOperation.transfer().returnAs(Map.class); String taskId = (String) ((Map<String, Object>) webMessage.get("response")).get("id"); - Map<String, Object> notification = null; - while (notification == null || !(Boolean) notification.get("completed")) { - try { - Thread.sleep(Objects.requireNonNullElse(interval, 30000)); - + if (async == null || !async) { + Map<String, Object> notification = null; + while (notification == null || !(Boolean) notification.get("completed")) { + try { + Thread.sleep(Objects.requireNonNullElse(interval, 30000)); + } catch (InterruptedException e) { + throw new RuntimeCamelException(e); + } Iterable<Map> notifications = dhis2Client.get("system/tasks/ANALYTICS_TABLE/{taskId}", taskId).withoutPaging().transfer().returnAs(Map.class); if (notifications.iterator().hasNext()) { notification = notifications.iterator().next(); if (notification.get("level").equals("ERROR")) { - throw new RuntimeException("Analytics failed => " + notification); + throw new RuntimeCamelException("Analytics failed => " + notification); } } - } catch (InterruptedException e) { - Thread.currentThread().interrupt(); } - } } - } diff --git a/components/camel-dhis2/camel-dhis2-api/src/test/java/org/apache/camel/component/dhis2/api/Dhis2DeleteTestCase.java b/components/camel-dhis2/camel-dhis2-api/src/test/java/org/apache/camel/component/dhis2/api/Dhis2DeleteTestCase.java index 4a79565809f..f16a4fe0afd 100644 --- a/components/camel-dhis2/camel-dhis2-api/src/test/java/org/apache/camel/component/dhis2/api/Dhis2DeleteTestCase.java +++ b/components/camel-dhis2/camel-dhis2-api/src/test/java/org/apache/camel/component/dhis2/api/Dhis2DeleteTestCase.java @@ -60,6 +60,11 @@ public class Dhis2DeleteTestCase { public void close() { } + + @Override + public String getUrl() { + return ""; + } }); } diff --git a/components/camel-dhis2/camel-dhis2-api/src/test/java/org/apache/camel/component/dhis2/api/Dhis2GetTestCase.java b/components/camel-dhis2/camel-dhis2-api/src/test/java/org/apache/camel/component/dhis2/api/Dhis2GetTestCase.java index 9cb958021bf..49ab4f29423 100644 --- a/components/camel-dhis2/camel-dhis2-api/src/test/java/org/apache/camel/component/dhis2/api/Dhis2GetTestCase.java +++ b/components/camel-dhis2/camel-dhis2-api/src/test/java/org/apache/camel/component/dhis2/api/Dhis2GetTestCase.java @@ -72,6 +72,11 @@ public class Dhis2GetTestCase { public void close() { } + + @Override + public String getUrl() { + return ""; + } }; when(getOperation.withParameter(any(), any())).thenReturn(getOperation); when(getOperation.transfer()).thenReturn(dhis2Response); @@ -97,6 +102,11 @@ public class Dhis2GetTestCase { public void close() { } + + @Override + public String getUrl() { + return ""; + } }; when(getOperation.withParameter(any(), any())).thenReturn(getOperation); when(getOperation.transfer()).thenReturn(dhis2Response); @@ -122,6 +132,11 @@ public class Dhis2GetTestCase { public void close() { } + + @Override + public String getUrl() { + return ""; + } }; when(getOperation.withParameter(any(), any())).thenReturn(getOperation); when(getOperation.transfer()).thenReturn(dhis2Response); @@ -147,6 +162,11 @@ public class Dhis2GetTestCase { public void close() { } + + @Override + public String getUrl() { + return ""; + } }; when(getOperation.withParameter(any(), any())).thenReturn(getOperation); when(getOperation.transfer()).thenReturn(dhis2Response); @@ -160,7 +180,7 @@ public class Dhis2GetTestCase { Dhis2Response dhis2Response = new Dhis2Response() { @Override public <T> T returnAs(Class<T> responseType) { - Page page = new Page(); + Page page = new Page(1, 50); page.setAdditionalProperty("bunnies", new ArrayList<>()); return (T) page; @@ -176,6 +196,11 @@ public class Dhis2GetTestCase { throws IOException { } + + @Override + public String getUrl() { + return ""; + } }; when(getOperation.withParameter(any(), any())).thenReturn(getOperation); when(getOperation.withParameter(any(), any())).thenReturn(getOperation); @@ -207,6 +232,11 @@ public class Dhis2GetTestCase { throws IOException { } + + @Override + public String getUrl() { + return ""; + } }; when(getOperation.withParameter(any(), any())).thenReturn(getOperation); when(getOperation.withParameter(any(), any())).thenReturn(getOperation); @@ -237,6 +267,11 @@ public class Dhis2GetTestCase { public void close() { } + + @Override + public String getUrl() { + return ""; + } }; when(getOperation.withParameter(any(), any())).thenReturn(getOperation); when(getOperation.transfer()).thenReturn(dhis2Response); @@ -267,6 +302,11 @@ public class Dhis2GetTestCase { public void close() { } + + @Override + public String getUrl() { + return ""; + } }; when(getOperation.withParameter(any(), any())).thenReturn(getOperation); when(getOperation.transfer()).thenReturn(dhis2Response); @@ -277,4 +317,40 @@ public class Dhis2GetTestCase { dhis2Get.collection("bunnies", "bunnies", null, null, null, RootJunctionEnum.AND, null); verify(getOperation, times(1)).withAndRootJunction(); } + + @Test + public void testCollectionGivenMultipleFilters() { + Dhis2Response dhis2Response = new Dhis2Response() { + public <T> T returnAs(Class<T> responseType) { + return (T) Map.of("bunnies", new ArrayList<>()); + } + + @Override + public InputStream read() { + return new ByteArrayInputStream(new byte[] {}); + } + + @Override + public void close() { + + } + + @Override + public String getUrl() { + return ""; + } + }; + when(getOperation.withParameter(any(), any())).thenReturn(getOperation); + when(getOperation.transfer()).thenReturn(dhis2Response); + when(getOperation.withoutPaging()).thenReturn( + new DefaultSimpleCollectOperation( + "https://play.dhis2.org/2.39.0.1", "", null, + new JacksonConverterFactory(), getOperation)); + + Dhis2Get dhis2Get = new Dhis2Get(dhis2Client); + dhis2Get.collection("bunnies", "bunnies", null, null, List.of("id:in:[id1,id2]", "code:eq:code1"), null, null); + verify(getOperation, times(1)).withFilter("id:in:[id1,id2]"); + verify(getOperation, times(1)).withFilter("code:eq:code1"); + } + } diff --git a/components/camel-dhis2/camel-dhis2-api/src/test/java/org/apache/camel/component/dhis2/api/Dhis2PostTestCase.java b/components/camel-dhis2/camel-dhis2-api/src/test/java/org/apache/camel/component/dhis2/api/Dhis2PostTestCase.java index f01d1390e91..e92f242edfb 100644 --- a/components/camel-dhis2/camel-dhis2-api/src/test/java/org/apache/camel/component/dhis2/api/Dhis2PostTestCase.java +++ b/components/camel-dhis2/camel-dhis2-api/src/test/java/org/apache/camel/component/dhis2/api/Dhis2PostTestCase.java @@ -60,6 +60,11 @@ public class Dhis2PostTestCase { public void close() { } + + @Override + public String getUrl() { + return ""; + } }); } diff --git a/components/camel-dhis2/camel-dhis2-api/src/test/java/org/apache/camel/component/dhis2/api/Dhis2PutTestCase.java b/components/camel-dhis2/camel-dhis2-api/src/test/java/org/apache/camel/component/dhis2/api/Dhis2PutTestCase.java index 4db76f0d6a7..192f7f32ce9 100644 --- a/components/camel-dhis2/camel-dhis2-api/src/test/java/org/apache/camel/component/dhis2/api/Dhis2PutTestCase.java +++ b/components/camel-dhis2/camel-dhis2-api/src/test/java/org/apache/camel/component/dhis2/api/Dhis2PutTestCase.java @@ -60,6 +60,11 @@ public class Dhis2PutTestCase { public void close() { } + + @Override + public String getUrl() { + return ""; + } }); } diff --git a/components/camel-dhis2/camel-dhis2-api/src/test/java/org/apache/camel/component/dhis2/api/Dhis2PostTestCase.java b/components/camel-dhis2/camel-dhis2-api/src/test/java/org/apache/camel/component/dhis2/api/Dhis2ResourceTablesTestCase.java similarity index 72% copy from components/camel-dhis2/camel-dhis2-api/src/test/java/org/apache/camel/component/dhis2/api/Dhis2PostTestCase.java copy to components/camel-dhis2/camel-dhis2-api/src/test/java/org/apache/camel/component/dhis2/api/Dhis2ResourceTablesTestCase.java index f01d1390e91..4c65215232f 100644 --- a/components/camel-dhis2/camel-dhis2-api/src/test/java/org/apache/camel/component/dhis2/api/Dhis2PostTestCase.java +++ b/components/camel-dhis2/camel-dhis2-api/src/test/java/org/apache/camel/component/dhis2/api/Dhis2ResourceTablesTestCase.java @@ -18,14 +18,16 @@ package org.apache.camel.component.dhis2.api; import java.io.ByteArrayInputStream; import java.io.InputStream; -import java.util.List; import java.util.Map; +import java.util.UUID; +import java.util.concurrent.ThreadLocalRandom; import org.hisp.dhis.integration.sdk.api.Dhis2Client; import org.hisp.dhis.integration.sdk.api.Dhis2Response; import org.hisp.dhis.integration.sdk.api.operation.PostOperation; import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.Timeout; import org.junit.jupiter.api.extension.ExtendWith; import org.mockito.Mock; import org.mockito.junit.jupiter.MockitoExtension; @@ -34,7 +36,8 @@ import static org.mockito.ArgumentMatchers.any; import static org.mockito.Mockito.when; @ExtendWith(MockitoExtension.class) -public class Dhis2PostTestCase { +public class Dhis2ResourceTablesTestCase { + @Mock private Dhis2Client dhis2Client; @@ -48,30 +51,31 @@ public class Dhis2PostTestCase { when(postOperation.transfer()).thenReturn(new Dhis2Response() { @Override public <T> T returnAs(Class<T> responseType) { - return null; + return (T) Map.of("response", Map.of("id", UUID.randomUUID().toString())); } @Override public InputStream read() { - return new ByteArrayInputStream(new byte[] {}); + return new ByteArrayInputStream(new byte[]{}); } @Override public void close() { } - }); - } - @Test - public void testResourceGivenMapOfListsQueryParams() { - Dhis2Post dhis2Post = new Dhis2Post(dhis2Client); - dhis2Post.resource(null, null, Map.of("foo", List.of("bar"))); + @Override + public String getUrl() { + return ""; + } + }); } @Test - public void testResourceGivenMapOfStringsQueryParams() { - Dhis2Post dhis2Post = new Dhis2Post(dhis2Client); - dhis2Post.resource(null, null, Map.of("foo", "bar")); + @Timeout(5) + public void testAnalyticsDoesNotBlockGivenAsyncIsTrue() { + Dhis2ResourceTables dhis2ResourceTables = new Dhis2ResourceTables(dhis2Client); + dhis2ResourceTables.analytics(ThreadLocalRandom.current().nextBoolean(), ThreadLocalRandom.current().nextBoolean(), + ThreadLocalRandom.current().nextInt(), ThreadLocalRandom.current().nextInt(), true); } } diff --git a/components/camel-dhis2/camel-dhis2-component/pom.xml b/components/camel-dhis2/camel-dhis2-component/pom.xml index e32139d8b01..9a78a49703f 100644 --- a/components/camel-dhis2/camel-dhis2-component/pom.xml +++ b/components/camel-dhis2/camel-dhis2-component/pom.xml @@ -102,6 +102,7 @@ <nullableOption>skipAggregate</nullableOption> <nullableOption>lastYears</nullableOption> <nullableOption>interval</nullableOption> + <nullableOption>async</nullableOption> </nullableOptions> </api> <api> diff --git a/components/camel-dhis2/camel-dhis2-component/src/generated/java/org/apache/camel/component/dhis2/Dhis2ComponentConfigurer.java b/components/camel-dhis2/camel-dhis2-component/src/generated/java/org/apache/camel/component/dhis2/Dhis2ComponentConfigurer.java index 284353477e8..e12b2799ead 100644 --- a/components/camel-dhis2/camel-dhis2-component/src/generated/java/org/apache/camel/component/dhis2/Dhis2ComponentConfigurer.java +++ b/components/camel-dhis2/camel-dhis2-component/src/generated/java/org/apache/camel/component/dhis2/Dhis2ComponentConfigurer.java @@ -27,6 +27,7 @@ public class Dhis2ComponentConfigurer extends PropertyConfigurerSupport implemen map.put("client", org.hisp.dhis.integration.sdk.api.Dhis2Client.class); map.put("configuration", org.apache.camel.component.dhis2.Dhis2Configuration.class); map.put("password", java.lang.String.class); + map.put("personalAccessToken", java.lang.String.class); map.put("username", java.lang.String.class); ALL_OPTIONS = map; } @@ -53,6 +54,8 @@ public class Dhis2ComponentConfigurer extends PropertyConfigurerSupport implemen case "lazystartproducer": case "lazyStartProducer": target.setLazyStartProducer(property(camelContext, boolean.class, value)); return true; case "password": getOrCreateConfiguration(target).setPassword(property(camelContext, java.lang.String.class, value)); return true; + case "personalaccesstoken": + case "personalAccessToken": getOrCreateConfiguration(target).setPersonalAccessToken(property(camelContext, java.lang.String.class, value)); return true; case "username": getOrCreateConfiguration(target).setUsername(property(camelContext, java.lang.String.class, value)); return true; default: return false; } @@ -77,6 +80,8 @@ public class Dhis2ComponentConfigurer extends PropertyConfigurerSupport implemen case "lazystartproducer": case "lazyStartProducer": return boolean.class; case "password": return java.lang.String.class; + case "personalaccesstoken": + case "personalAccessToken": return java.lang.String.class; case "username": return java.lang.String.class; default: return null; } @@ -97,6 +102,8 @@ public class Dhis2ComponentConfigurer extends PropertyConfigurerSupport implemen case "lazystartproducer": case "lazyStartProducer": return target.isLazyStartProducer(); case "password": return getOrCreateConfiguration(target).getPassword(); + case "personalaccesstoken": + case "personalAccessToken": return getOrCreateConfiguration(target).getPersonalAccessToken(); case "username": return getOrCreateConfiguration(target).getUsername(); default: return null; } diff --git a/components/camel-dhis2/camel-dhis2-component/src/generated/java/org/apache/camel/component/dhis2/Dhis2ConfigurationConfigurer.java b/components/camel-dhis2/camel-dhis2-component/src/generated/java/org/apache/camel/component/dhis2/Dhis2ConfigurationConfigurer.java index 97835515369..96210f06446 100644 --- a/components/camel-dhis2/camel-dhis2-component/src/generated/java/org/apache/camel/component/dhis2/Dhis2ConfigurationConfigurer.java +++ b/components/camel-dhis2/camel-dhis2-component/src/generated/java/org/apache/camel/component/dhis2/Dhis2ConfigurationConfigurer.java @@ -31,6 +31,8 @@ public class Dhis2ConfigurationConfigurer extends org.apache.camel.support.compo case "MethodName": target.setMethodName(property(camelContext, java.lang.String.class, value)); return true; case "password": case "Password": target.setPassword(property(camelContext, java.lang.String.class, value)); return true; + case "personalaccesstoken": + case "PersonalAccessToken": target.setPersonalAccessToken(property(camelContext, java.lang.String.class, value)); return true; case "username": case "Username": target.setUsername(property(camelContext, java.lang.String.class, value)); return true; default: return false; @@ -50,6 +52,8 @@ public class Dhis2ConfigurationConfigurer extends org.apache.camel.support.compo case "MethodName": return java.lang.String.class; case "password": case "Password": return java.lang.String.class; + case "personalaccesstoken": + case "PersonalAccessToken": return java.lang.String.class; case "username": case "Username": return java.lang.String.class; default: return null; @@ -70,6 +74,8 @@ public class Dhis2ConfigurationConfigurer extends org.apache.camel.support.compo case "MethodName": return target.getMethodName(); case "password": case "Password": return target.getPassword(); + case "personalaccesstoken": + case "PersonalAccessToken": return target.getPersonalAccessToken(); case "username": case "Username": return target.getUsername(); default: return null; diff --git a/components/camel-dhis2/camel-dhis2-component/src/generated/java/org/apache/camel/component/dhis2/Dhis2DeleteEndpointConfigurationConfigurer.java b/components/camel-dhis2/camel-dhis2-component/src/generated/java/org/apache/camel/component/dhis2/Dhis2DeleteEndpointConfigurationConfigurer.java index 4d833792ba1..63285c7ee60 100644 --- a/components/camel-dhis2/camel-dhis2-component/src/generated/java/org/apache/camel/component/dhis2/Dhis2DeleteEndpointConfigurationConfigurer.java +++ b/components/camel-dhis2/camel-dhis2-component/src/generated/java/org/apache/camel/component/dhis2/Dhis2DeleteEndpointConfigurationConfigurer.java @@ -26,6 +26,7 @@ public class Dhis2DeleteEndpointConfigurationConfigurer extends org.apache.camel map.put("MethodName", java.lang.String.class); map.put("Password", java.lang.String.class); map.put("Path", java.lang.String.class); + map.put("PersonalAccessToken", java.lang.String.class); map.put("QueryParams", java.util.Map.class); map.put("Resource", java.lang.Object.class); map.put("Username", java.lang.String.class); @@ -48,6 +49,8 @@ public class Dhis2DeleteEndpointConfigurationConfigurer extends org.apache.camel case "Password": target.setPassword(property(camelContext, java.lang.String.class, value)); return true; case "path": case "Path": target.setPath(property(camelContext, java.lang.String.class, value)); return true; + case "personalaccesstoken": + case "PersonalAccessToken": target.setPersonalAccessToken(property(camelContext, java.lang.String.class, value)); return true; case "queryparams": case "QueryParams": target.setQueryParams(property(camelContext, java.util.Map.class, value)); return true; case "resource": @@ -78,6 +81,8 @@ public class Dhis2DeleteEndpointConfigurationConfigurer extends org.apache.camel case "Password": return java.lang.String.class; case "path": case "Path": return java.lang.String.class; + case "personalaccesstoken": + case "PersonalAccessToken": return java.lang.String.class; case "queryparams": case "QueryParams": return java.util.Map.class; case "resource": @@ -104,6 +109,8 @@ public class Dhis2DeleteEndpointConfigurationConfigurer extends org.apache.camel case "Password": return target.getPassword(); case "path": case "Path": return target.getPath(); + case "personalaccesstoken": + case "PersonalAccessToken": return target.getPersonalAccessToken(); case "queryparams": case "QueryParams": return target.getQueryParams(); case "resource": diff --git a/components/camel-dhis2/camel-dhis2-component/src/generated/java/org/apache/camel/component/dhis2/Dhis2EndpointConfigurer.java b/components/camel-dhis2/camel-dhis2-component/src/generated/java/org/apache/camel/component/dhis2/Dhis2EndpointConfigurer.java index 7e312c97ed5..b02e455c752 100644 --- a/components/camel-dhis2/camel-dhis2-component/src/generated/java/org/apache/camel/component/dhis2/Dhis2EndpointConfigurer.java +++ b/components/camel-dhis2/camel-dhis2-component/src/generated/java/org/apache/camel/component/dhis2/Dhis2EndpointConfigurer.java @@ -46,6 +46,7 @@ public class Dhis2EndpointConfigurer extends PropertyConfigurerSupport implement map.put("timeUnit", java.util.concurrent.TimeUnit.class); map.put("useFixedDelay", boolean.class); map.put("password", java.lang.String.class); + map.put("personalAccessToken", java.lang.String.class); map.put("username", java.lang.String.class); ALL_OPTIONS = map; } @@ -78,6 +79,8 @@ public class Dhis2EndpointConfigurer extends PropertyConfigurerSupport implement 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 "personalaccesstoken": + case "personalAccessToken": target.getConfiguration().setPersonalAccessToken(property(camelContext, java.lang.String.class, value)); return true; case "pollstrategy": case "pollStrategy": target.setPollStrategy(property(camelContext, org.apache.camel.spi.PollingConsumerPollStrategy.class, value)); return true; case "repeatcount": @@ -134,6 +137,8 @@ public class Dhis2EndpointConfigurer extends PropertyConfigurerSupport implement case "lazystartproducer": case "lazyStartProducer": return boolean.class; case "password": return java.lang.String.class; + case "personalaccesstoken": + case "personalAccessToken": return java.lang.String.class; case "pollstrategy": case "pollStrategy": return org.apache.camel.spi.PollingConsumerPollStrategy.class; case "repeatcount": @@ -186,6 +191,8 @@ public class Dhis2EndpointConfigurer extends PropertyConfigurerSupport implement case "lazystartproducer": case "lazyStartProducer": return target.isLazyStartProducer(); case "password": return target.getConfiguration().getPassword(); + case "personalaccesstoken": + case "personalAccessToken": return target.getConfiguration().getPersonalAccessToken(); case "pollstrategy": case "pollStrategy": return target.getPollStrategy(); case "repeatcount": diff --git a/components/camel-dhis2/camel-dhis2-component/src/generated/java/org/apache/camel/component/dhis2/Dhis2EndpointUriFactory.java b/components/camel-dhis2/camel-dhis2-component/src/generated/java/org/apache/camel/component/dhis2/Dhis2EndpointUriFactory.java index 6883b987744..31f7a681a2d 100644 --- a/components/camel-dhis2/camel-dhis2-component/src/generated/java/org/apache/camel/component/dhis2/Dhis2EndpointUriFactory.java +++ b/components/camel-dhis2/camel-dhis2-component/src/generated/java/org/apache/camel/component/dhis2/Dhis2EndpointUriFactory.java @@ -21,9 +21,10 @@ public class Dhis2EndpointUriFactory extends org.apache.camel.support.component. private static final Set<String> SECRET_PROPERTY_NAMES; private static final Set<String> MULTI_VALUE_PREFIXES; static { - Set<String> props = new HashSet<>(39); + Set<String> props = new HashSet<>(41); props.add("apiName"); props.add("arrayName"); + props.add("async"); props.add("backoffErrorThreshold"); props.add("backoffIdleThreshold"); props.add("backoffMultiplier"); @@ -45,6 +46,7 @@ public class Dhis2EndpointUriFactory extends org.apache.camel.support.component. props.add("paging"); props.add("password"); props.add("path"); + props.add("personalAccessToken"); props.add("pollStrategy"); props.add("queryParams"); props.add("repeatCount"); @@ -62,8 +64,9 @@ public class Dhis2EndpointUriFactory extends org.apache.camel.support.component. props.add("useFixedDelay"); props.add("username"); PROPERTY_NAMES = Collections.unmodifiableSet(props); - Set<String> secretProps = new HashSet<>(2); + Set<String> secretProps = new HashSet<>(3); secretProps.add("password"); + secretProps.add("personalAccessToken"); secretProps.add("username"); SECRET_PROPERTY_NAMES = Collections.unmodifiableSet(secretProps); Set<String> prefixes = new HashSet<>(1); diff --git a/components/camel-dhis2/camel-dhis2-component/src/generated/java/org/apache/camel/component/dhis2/Dhis2GetEndpointConfiguration.java b/components/camel-dhis2/camel-dhis2-component/src/generated/java/org/apache/camel/component/dhis2/Dhis2GetEndpointConfiguration.java index f256c530f01..d0956ee7621 100644 --- a/components/camel-dhis2/camel-dhis2-component/src/generated/java/org/apache/camel/component/dhis2/Dhis2GetEndpointConfiguration.java +++ b/components/camel-dhis2/camel-dhis2-component/src/generated/java/org/apache/camel/component/dhis2/Dhis2GetEndpointConfiguration.java @@ -15,7 +15,7 @@ import org.apache.camel.spi.UriParams; */ @ApiParams(apiName = "get", description = "", - apiMethods = {@ApiMethod(methodName = "collection", signatures={"java.util.Iterator<org.apache.camel.component.dhis2.api.Dhis2Resource> collection(String path, String arrayName, Boolean paging, String fields, String filter, org.apache.camel.component.dhis2.api.RootJunctionEnum rootJunction, java.util.Map<String, Object> queryParams)"}), @ApiMethod(methodName = "resource", signatures={"java.io.InputStream resource(String path, String fields, String filter, org.apache.camel.comp [...] + apiMethods = {@ApiMethod(methodName = "collection", signatures={"java.util.Iterator<org.apache.camel.component.dhis2.api.Dhis2Resource> collection(String path, String arrayName, Boolean paging, String fields, java.util.List<String> filter, org.apache.camel.component.dhis2.api.RootJunctionEnum rootJunction, java.util.Map<String, Object> queryParams)"}), @ApiMethod(methodName = "resource", signatures={"java.io.InputStream resource(String path, String fields, java.util.List<Strin [...] @UriParams @Configurer(extended = true) public final class Dhis2GetEndpointConfiguration extends Dhis2Configuration { @@ -27,7 +27,7 @@ public final class Dhis2GetEndpointConfiguration extends Dhis2Configuration { private String fields; @UriParam @ApiParam(optional = true, apiMethods = {@ApiMethod(methodName = "collection"), @ApiMethod(methodName = "resource")}) - private String filter; + private java.util.List<String> filter; @UriParam @ApiParam(optional = true, apiMethods = {@ApiMethod(methodName = "collection")}) private Boolean paging; @@ -57,11 +57,11 @@ public final class Dhis2GetEndpointConfiguration extends Dhis2Configuration { this.fields = fields; } - public String getFilter() { + public java.util.List<String> getFilter() { return filter; } - public void setFilter(String filter) { + public void setFilter(java.util.List<String> filter) { this.filter = filter; } diff --git a/components/camel-dhis2/camel-dhis2-component/src/generated/java/org/apache/camel/component/dhis2/Dhis2GetEndpointConfigurationConfigurer.java b/components/camel-dhis2/camel-dhis2-component/src/generated/java/org/apache/camel/component/dhis2/Dhis2GetEndpointConfigurationConfigurer.java index e11ca4c17b4..ac7f7574b32 100644 --- a/components/camel-dhis2/camel-dhis2-component/src/generated/java/org/apache/camel/component/dhis2/Dhis2GetEndpointConfigurationConfigurer.java +++ b/components/camel-dhis2/camel-dhis2-component/src/generated/java/org/apache/camel/component/dhis2/Dhis2GetEndpointConfigurationConfigurer.java @@ -25,11 +25,12 @@ public class Dhis2GetEndpointConfigurationConfigurer extends org.apache.camel.su map.put("BaseApiUrl", java.lang.String.class); map.put("Client", org.hisp.dhis.integration.sdk.api.Dhis2Client.class); map.put("Fields", java.lang.String.class); - map.put("Filter", java.lang.String.class); + map.put("Filter", java.util.List.class); map.put("MethodName", java.lang.String.class); map.put("Paging", java.lang.Boolean.class); map.put("Password", java.lang.String.class); map.put("Path", java.lang.String.class); + map.put("PersonalAccessToken", java.lang.String.class); map.put("QueryParams", java.util.Map.class); map.put("RootJunction", org.apache.camel.component.dhis2.api.RootJunctionEnum.class); map.put("Username", java.lang.String.class); @@ -51,7 +52,7 @@ public class Dhis2GetEndpointConfigurationConfigurer extends org.apache.camel.su case "fields": case "Fields": target.setFields(property(camelContext, java.lang.String.class, value)); return true; case "filter": - case "Filter": target.setFilter(property(camelContext, java.lang.String.class, value)); return true; + case "Filter": target.setFilter(property(camelContext, java.util.List.class, value)); return true; case "methodname": case "MethodName": target.setMethodName(property(camelContext, java.lang.String.class, value)); return true; case "paging": @@ -60,6 +61,8 @@ public class Dhis2GetEndpointConfigurationConfigurer extends org.apache.camel.su case "Password": target.setPassword(property(camelContext, java.lang.String.class, value)); return true; case "path": case "Path": target.setPath(property(camelContext, java.lang.String.class, value)); return true; + case "personalaccesstoken": + case "PersonalAccessToken": target.setPersonalAccessToken(property(camelContext, java.lang.String.class, value)); return true; case "queryparams": case "QueryParams": target.setQueryParams(property(camelContext, java.util.Map.class, value)); return true; case "rootjunction": @@ -89,7 +92,7 @@ public class Dhis2GetEndpointConfigurationConfigurer extends org.apache.camel.su case "fields": case "Fields": return java.lang.String.class; case "filter": - case "Filter": return java.lang.String.class; + case "Filter": return java.util.List.class; case "methodname": case "MethodName": return java.lang.String.class; case "paging": @@ -98,6 +101,8 @@ public class Dhis2GetEndpointConfigurationConfigurer extends org.apache.camel.su case "Password": return java.lang.String.class; case "path": case "Path": return java.lang.String.class; + case "personalaccesstoken": + case "PersonalAccessToken": return java.lang.String.class; case "queryparams": case "QueryParams": return java.util.Map.class; case "rootjunction": @@ -132,6 +137,8 @@ public class Dhis2GetEndpointConfigurationConfigurer extends org.apache.camel.su case "Password": return target.getPassword(); case "path": case "Path": return target.getPath(); + case "personalaccesstoken": + case "PersonalAccessToken": return target.getPersonalAccessToken(); case "queryparams": case "QueryParams": return target.getQueryParams(); case "rootjunction": @@ -145,6 +152,8 @@ public class Dhis2GetEndpointConfigurationConfigurer extends org.apache.camel.su @Override public Object getCollectionValueType(Object target, String name, boolean ignoreCase) { switch (ignoreCase ? name.toLowerCase() : name) { + case "filter": + case "Filter": return java.lang.String.class; case "queryparams": case "QueryParams": return java.lang.Object.class; default: return null; diff --git a/components/camel-dhis2/camel-dhis2-component/src/generated/java/org/apache/camel/component/dhis2/Dhis2PostEndpointConfigurationConfigurer.java b/components/camel-dhis2/camel-dhis2-component/src/generated/java/org/apache/camel/component/dhis2/Dhis2PostEndpointConfigurationConfigurer.java index c56de14545d..053345a86f4 100644 --- a/components/camel-dhis2/camel-dhis2-component/src/generated/java/org/apache/camel/component/dhis2/Dhis2PostEndpointConfigurationConfigurer.java +++ b/components/camel-dhis2/camel-dhis2-component/src/generated/java/org/apache/camel/component/dhis2/Dhis2PostEndpointConfigurationConfigurer.java @@ -26,6 +26,7 @@ public class Dhis2PostEndpointConfigurationConfigurer extends org.apache.camel.s map.put("MethodName", java.lang.String.class); map.put("Password", java.lang.String.class); map.put("Path", java.lang.String.class); + map.put("PersonalAccessToken", java.lang.String.class); map.put("QueryParams", java.util.Map.class); map.put("Resource", java.lang.Object.class); map.put("Username", java.lang.String.class); @@ -48,6 +49,8 @@ public class Dhis2PostEndpointConfigurationConfigurer extends org.apache.camel.s case "Password": target.setPassword(property(camelContext, java.lang.String.class, value)); return true; case "path": case "Path": target.setPath(property(camelContext, java.lang.String.class, value)); return true; + case "personalaccesstoken": + case "PersonalAccessToken": target.setPersonalAccessToken(property(camelContext, java.lang.String.class, value)); return true; case "queryparams": case "QueryParams": target.setQueryParams(property(camelContext, java.util.Map.class, value)); return true; case "resource": @@ -78,6 +81,8 @@ public class Dhis2PostEndpointConfigurationConfigurer extends org.apache.camel.s case "Password": return java.lang.String.class; case "path": case "Path": return java.lang.String.class; + case "personalaccesstoken": + case "PersonalAccessToken": return java.lang.String.class; case "queryparams": case "QueryParams": return java.util.Map.class; case "resource": @@ -104,6 +109,8 @@ public class Dhis2PostEndpointConfigurationConfigurer extends org.apache.camel.s case "Password": return target.getPassword(); case "path": case "Path": return target.getPath(); + case "personalaccesstoken": + case "PersonalAccessToken": return target.getPersonalAccessToken(); case "queryparams": case "QueryParams": return target.getQueryParams(); case "resource": diff --git a/components/camel-dhis2/camel-dhis2-component/src/generated/java/org/apache/camel/component/dhis2/Dhis2PutEndpointConfigurationConfigurer.java b/components/camel-dhis2/camel-dhis2-component/src/generated/java/org/apache/camel/component/dhis2/Dhis2PutEndpointConfigurationConfigurer.java index 279be9a78ed..4db6d3da01b 100644 --- a/components/camel-dhis2/camel-dhis2-component/src/generated/java/org/apache/camel/component/dhis2/Dhis2PutEndpointConfigurationConfigurer.java +++ b/components/camel-dhis2/camel-dhis2-component/src/generated/java/org/apache/camel/component/dhis2/Dhis2PutEndpointConfigurationConfigurer.java @@ -26,6 +26,7 @@ public class Dhis2PutEndpointConfigurationConfigurer extends org.apache.camel.su map.put("MethodName", java.lang.String.class); map.put("Password", java.lang.String.class); map.put("Path", java.lang.String.class); + map.put("PersonalAccessToken", java.lang.String.class); map.put("QueryParams", java.util.Map.class); map.put("Resource", java.lang.Object.class); map.put("Username", java.lang.String.class); @@ -48,6 +49,8 @@ public class Dhis2PutEndpointConfigurationConfigurer extends org.apache.camel.su case "Password": target.setPassword(property(camelContext, java.lang.String.class, value)); return true; case "path": case "Path": target.setPath(property(camelContext, java.lang.String.class, value)); return true; + case "personalaccesstoken": + case "PersonalAccessToken": target.setPersonalAccessToken(property(camelContext, java.lang.String.class, value)); return true; case "queryparams": case "QueryParams": target.setQueryParams(property(camelContext, java.util.Map.class, value)); return true; case "resource": @@ -78,6 +81,8 @@ public class Dhis2PutEndpointConfigurationConfigurer extends org.apache.camel.su case "Password": return java.lang.String.class; case "path": case "Path": return java.lang.String.class; + case "personalaccesstoken": + case "PersonalAccessToken": return java.lang.String.class; case "queryparams": case "QueryParams": return java.util.Map.class; case "resource": @@ -104,6 +109,8 @@ public class Dhis2PutEndpointConfigurationConfigurer extends org.apache.camel.su case "Password": return target.getPassword(); case "path": case "Path": return target.getPath(); + case "personalaccesstoken": + case "PersonalAccessToken": return target.getPersonalAccessToken(); case "queryparams": case "QueryParams": return target.getQueryParams(); case "resource": diff --git a/components/camel-dhis2/camel-dhis2-component/src/generated/java/org/apache/camel/component/dhis2/Dhis2ResourceTablesEndpointConfiguration.java b/components/camel-dhis2/camel-dhis2-component/src/generated/java/org/apache/camel/component/dhis2/Dhis2ResourceTablesEndpointConfiguration.java index c07fa155b9c..c4a5ef30787 100644 --- a/components/camel-dhis2/camel-dhis2-component/src/generated/java/org/apache/camel/component/dhis2/Dhis2ResourceTablesEndpointConfiguration.java +++ b/components/camel-dhis2/camel-dhis2-component/src/generated/java/org/apache/camel/component/dhis2/Dhis2ResourceTablesEndpointConfiguration.java @@ -15,10 +15,13 @@ import org.apache.camel.spi.UriParams; */ @ApiParams(apiName = "resourceTables", description = "", - apiMethods = {@ApiMethod(methodName = "analytics", signatures={"void analytics(Boolean skipAggregate, Boolean skipEvents, Integer lastYears, Integer interval)"})}, aliases = {}) + apiMethods = {@ApiMethod(methodName = "analytics", signatures={"void analytics(Boolean skipAggregate, Boolean skipEvents, Integer lastYears, Integer interval, Boolean async)"})}, aliases = {}) @UriParams @Configurer(extended = true) public final class Dhis2ResourceTablesEndpointConfiguration extends Dhis2Configuration { + @UriParam + @ApiParam(optional = true, apiMethods = {@ApiMethod(methodName = "analytics")}) + private Boolean async; @UriParam @ApiParam(optional = true, apiMethods = {@ApiMethod(methodName = "analytics")}) private Integer interval; @@ -32,6 +35,14 @@ public final class Dhis2ResourceTablesEndpointConfiguration extends Dhis2Configu @ApiParam(optional = true, apiMethods = {@ApiMethod(methodName = "analytics")}) private Boolean skipEvents; + public Boolean getAsync() { + return async; + } + + public void setAsync(Boolean async) { + this.async = async; + } + public Integer getInterval() { return interval; } diff --git a/components/camel-dhis2/camel-dhis2-component/src/generated/java/org/apache/camel/component/dhis2/Dhis2ResourceTablesEndpointConfigurationConfigurer.java b/components/camel-dhis2/camel-dhis2-component/src/generated/java/org/apache/camel/component/dhis2/Dhis2ResourceTablesEndpointConfigurationConfigurer.java index 89e1b7b90eb..2f2dc26a466 100644 --- a/components/camel-dhis2/camel-dhis2-component/src/generated/java/org/apache/camel/component/dhis2/Dhis2ResourceTablesEndpointConfigurationConfigurer.java +++ b/components/camel-dhis2/camel-dhis2-component/src/generated/java/org/apache/camel/component/dhis2/Dhis2ResourceTablesEndpointConfigurationConfigurer.java @@ -21,12 +21,14 @@ public class Dhis2ResourceTablesEndpointConfigurationConfigurer extends org.apac static { Map<String, Object> map = new CaseInsensitiveMap(); map.put("ApiName", org.apache.camel.component.dhis2.internal.Dhis2ApiName.class); + map.put("Async", java.lang.Boolean.class); map.put("BaseApiUrl", java.lang.String.class); map.put("Client", org.hisp.dhis.integration.sdk.api.Dhis2Client.class); map.put("Interval", java.lang.Integer.class); map.put("LastYears", java.lang.Integer.class); map.put("MethodName", java.lang.String.class); map.put("Password", java.lang.String.class); + map.put("PersonalAccessToken", java.lang.String.class); map.put("SkipAggregate", java.lang.Boolean.class); map.put("SkipEvents", java.lang.Boolean.class); map.put("Username", java.lang.String.class); @@ -39,6 +41,8 @@ public class Dhis2ResourceTablesEndpointConfigurationConfigurer extends org.apac switch (ignoreCase ? name.toLowerCase() : name) { case "apiname": case "ApiName": target.setApiName(property(camelContext, org.apache.camel.component.dhis2.internal.Dhis2ApiName.class, value)); return true; + case "async": + case "Async": target.setAsync(property(camelContext, java.lang.Boolean.class, value)); return true; case "baseapiurl": case "BaseApiUrl": target.setBaseApiUrl(property(camelContext, java.lang.String.class, value)); return true; case "client": @@ -51,6 +55,8 @@ public class Dhis2ResourceTablesEndpointConfigurationConfigurer extends org.apac case "MethodName": target.setMethodName(property(camelContext, java.lang.String.class, value)); return true; case "password": case "Password": target.setPassword(property(camelContext, java.lang.String.class, value)); return true; + case "personalaccesstoken": + case "PersonalAccessToken": target.setPersonalAccessToken(property(camelContext, java.lang.String.class, value)); return true; case "skipaggregate": case "SkipAggregate": target.setSkipAggregate(property(camelContext, java.lang.Boolean.class, value)); return true; case "skipevents": @@ -71,6 +77,8 @@ public class Dhis2ResourceTablesEndpointConfigurationConfigurer extends org.apac switch (ignoreCase ? name.toLowerCase() : name) { case "apiname": case "ApiName": return org.apache.camel.component.dhis2.internal.Dhis2ApiName.class; + case "async": + case "Async": return java.lang.Boolean.class; case "baseapiurl": case "BaseApiUrl": return java.lang.String.class; case "client": @@ -83,6 +91,8 @@ public class Dhis2ResourceTablesEndpointConfigurationConfigurer extends org.apac case "MethodName": return java.lang.String.class; case "password": case "Password": return java.lang.String.class; + case "personalaccesstoken": + case "PersonalAccessToken": return java.lang.String.class; case "skipaggregate": case "SkipAggregate": return java.lang.Boolean.class; case "skipevents": @@ -99,6 +109,8 @@ public class Dhis2ResourceTablesEndpointConfigurationConfigurer extends org.apac switch (ignoreCase ? name.toLowerCase() : name) { case "apiname": case "ApiName": return target.getApiName(); + case "async": + case "Async": return target.getAsync(); case "baseapiurl": case "BaseApiUrl": return target.getBaseApiUrl(); case "client": @@ -111,6 +123,8 @@ public class Dhis2ResourceTablesEndpointConfigurationConfigurer extends org.apac case "MethodName": return target.getMethodName(); case "password": case "Password": return target.getPassword(); + case "personalaccesstoken": + case "PersonalAccessToken": return target.getPersonalAccessToken(); case "skipaggregate": case "SkipAggregate": return target.getSkipAggregate(); case "skipevents": diff --git a/components/camel-dhis2/camel-dhis2-component/src/generated/java/org/apache/camel/component/dhis2/internal/Dhis2ApiCollection.java b/components/camel-dhis2/camel-dhis2-component/src/generated/java/org/apache/camel/component/dhis2/internal/Dhis2ApiCollection.java index 47a39791123..74cde27fb87 100644 --- a/components/camel-dhis2/camel-dhis2-component/src/generated/java/org/apache/camel/component/dhis2/internal/Dhis2ApiCollection.java +++ b/components/camel-dhis2/camel-dhis2-component/src/generated/java/org/apache/camel/component/dhis2/internal/Dhis2ApiCollection.java @@ -40,7 +40,7 @@ public final class Dhis2ApiCollection extends ApiCollection<Dhis2ApiName, Dhis2C apiMethods.put(Dhis2PostApiMethod.class, Dhis2ApiName.POST); aliases.clear(); - nullableArgs = Arrays.asList("skipEvents", "skipAggregate", "lastYears", "interval"); + nullableArgs = Arrays.asList("skipEvents", "skipAggregate", "lastYears", "interval", "async"); apiHelpers.put(Dhis2ApiName.RESOURCE_TABLES, new ApiMethodHelper<>(Dhis2ResourceTablesApiMethod.class, aliases, nullableArgs)); apiMethods.put(Dhis2ResourceTablesApiMethod.class, Dhis2ApiName.RESOURCE_TABLES); diff --git a/components/camel-dhis2/camel-dhis2-component/src/generated/java/org/apache/camel/component/dhis2/internal/Dhis2GetApiMethod.java b/components/camel-dhis2/camel-dhis2-component/src/generated/java/org/apache/camel/component/dhis2/internal/Dhis2GetApiMethod.java index 2448902473b..9b622bcdb23 100644 --- a/components/camel-dhis2/camel-dhis2-component/src/generated/java/org/apache/camel/component/dhis2/internal/Dhis2GetApiMethod.java +++ b/components/camel-dhis2/camel-dhis2-component/src/generated/java/org/apache/camel/component/dhis2/internal/Dhis2GetApiMethod.java @@ -26,7 +26,7 @@ public enum Dhis2GetApiMethod implements ApiMethod { arg("arrayName", String.class), arg("paging", Boolean.class), arg("fields", String.class), - arg("filter", String.class), + arg("filter", java.util.List.class), arg("rootJunction", org.apache.camel.component.dhis2.api.RootJunctionEnum.class), arg("queryParams", java.util.Map.class)), @@ -35,7 +35,7 @@ public enum Dhis2GetApiMethod implements ApiMethod { "resource", arg("path", String.class), arg("fields", String.class), - arg("filter", String.class), + arg("filter", java.util.List.class), arg("rootJunction", org.apache.camel.component.dhis2.api.RootJunctionEnum.class), arg("queryParams", java.util.Map.class)); diff --git a/components/camel-dhis2/camel-dhis2-component/src/generated/java/org/apache/camel/component/dhis2/internal/Dhis2ResourceTablesApiMethod.java b/components/camel-dhis2/camel-dhis2-component/src/generated/java/org/apache/camel/component/dhis2/internal/Dhis2ResourceTablesApiMethod.java index 5781469edc2..496871d0fbb 100644 --- a/components/camel-dhis2/camel-dhis2-component/src/generated/java/org/apache/camel/component/dhis2/internal/Dhis2ResourceTablesApiMethod.java +++ b/components/camel-dhis2/camel-dhis2-component/src/generated/java/org/apache/camel/component/dhis2/internal/Dhis2ResourceTablesApiMethod.java @@ -25,7 +25,8 @@ public enum Dhis2ResourceTablesApiMethod implements ApiMethod { arg("skipAggregate", Boolean.class), arg("skipEvents", Boolean.class), arg("lastYears", Integer.class), - arg("interval", Integer.class)); + arg("interval", Integer.class), + arg("async", Boolean.class)); private final ApiMethod apiMethod; diff --git a/components/camel-dhis2/camel-dhis2-component/src/generated/resources/org/apache/camel/component/dhis2/dhis2.json b/components/camel-dhis2/camel-dhis2-component/src/generated/resources/org/apache/camel/component/dhis2/dhis2.json index f75cb3e8b04..a8517e50b3e 100644 --- a/components/camel-dhis2/camel-dhis2-component/src/generated/resources/org/apache/camel/component/dhis2/dhis2.json +++ b/components/camel-dhis2/camel-dhis2-component/src/generated/resources/org/apache/camel/component/dhis2/dhis2.json @@ -28,10 +28,11 @@ "bridgeErrorHandler": { "index": 1, "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 [...] "lazyStartProducer": { "index": 2, "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": 3, "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 [...] - "client": { "index": 4, "kind": "property", "displayName": "Client", "group": "advanced", "label": "advanced", "required": false, "type": "object", "javaType": "org.hisp.dhis.integration.sdk.api.Dhis2Client", "deprecated": false, "autowired": false, "secret": false, "configurationClass": "org.apache.camel.component.dhis2.Dhis2Configuration", "configurationField": "configuration", "description": "References a user-defined org.hisp.dhis.integration.sdk.api.Dhis2Client" }, + "client": { "index": 4, "kind": "property", "displayName": "Client", "group": "advanced", "label": "advanced", "required": false, "type": "object", "javaType": "org.hisp.dhis.integration.sdk.api.Dhis2Client", "deprecated": false, "autowired": false, "secret": false, "configurationClass": "org.apache.camel.component.dhis2.Dhis2Configuration", "configurationField": "configuration", "description": "References a user-defined org.hisp.dhis.integration.sdk.api.Dhis2Client. This option is m [...] "configuration": { "index": 5, "kind": "property", "displayName": "Configuration", "group": "advanced", "label": "advanced", "required": false, "type": "object", "javaType": "org.apache.camel.component.dhis2.Dhis2Configuration", "deprecated": false, "autowired": false, "secret": false, "description": "To use the shared configuration" }, - "password": { "index": 6, "kind": "property", "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.dhis2.Dhis2Configuration", "configurationField": "configuration", "description": "DHIS2 account password for accessing the DHIS2 API" }, - "username": { "index": 7, "kind": "property", "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.dhis2.Dhis2Configuration", "configurationField": "configuration", "description": "DHIS2 account username for accessing the DHIS2 API" } + "password": { "index": 6, "kind": "property", "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.dhis2.Dhis2Configuration", "configurationField": "configuration", "description": "Password of the DHIS2 username" }, + "personalAccessToken": { "index": 7, "kind": "property", "displayName": "Personal Access Token", "group": "security", "label": "security", "required": false, "type": "string", "javaType": "java.lang.String", "deprecated": false, "autowired": false, "secret": true, "configurationClass": "org.apache.camel.component.dhis2.Dhis2Configuration", "configurationField": "configuration", "description": "Personal access token to authenticate with DHIS2. This option is mutually exclusive to user [...] + "username": { "index": 8, "kind": "property", "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.dhis2.Dhis2Configuration", "configurationField": "configuration", "description": "Username of the DHIS2 user to operate as" } }, "properties": { "apiName": { "index": 0, "kind": "path", "displayName": "Api Name", "group": "common", "label": "", "required": true, "type": "object", "javaType": "org.apache.camel.component.dhis2.internal.Dhis2ApiName", "enum": [ "POST", "RESOURCE_TABLES", "GET", "DELETE", "PUT" ], "deprecated": false, "deprecationNote": "", "autowired": false, "secret": false, "configurationClass": "org.apache.camel.component.dhis2.Dhis2Configuration", "configurationField": "configuration", "description": "API op [...] @@ -44,7 +45,7 @@ "exchangePattern": { "index": 7, "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": 8, "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 pol [...] "lazyStartProducer": { "index": 9, "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 produc [...] - "client": { "index": 10, "kind": "parameter", "displayName": "Client", "group": "advanced", "label": "advanced", "required": false, "type": "object", "javaType": "org.hisp.dhis.integration.sdk.api.Dhis2Client", "deprecated": false, "autowired": false, "secret": false, "configurationClass": "org.apache.camel.component.dhis2.Dhis2Configuration", "configurationField": "configuration", "description": "References a user-defined org.hisp.dhis.integration.sdk.api.Dhis2Client" }, + "client": { "index": 10, "kind": "parameter", "displayName": "Client", "group": "advanced", "label": "advanced", "required": false, "type": "object", "javaType": "org.hisp.dhis.integration.sdk.api.Dhis2Client", "deprecated": false, "autowired": false, "secret": false, "configurationClass": "org.apache.camel.component.dhis2.Dhis2Configuration", "configurationField": "configuration", "description": "References a user-defined org.hisp.dhis.integration.sdk.api.Dhis2Client. This option is [...] "backoffErrorThreshold": { "index": 11, "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": 12, "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": 13, "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 [...] @@ -59,21 +60,22 @@ "startScheduler": { "index": 22, "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": 23, "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": 24, "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." }, - "password": { "index": 25, "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.dhis2.Dhis2Configuration", "configurationField": "configuration", "description": "DHIS2 account password for accessing the DHIS2 API" }, - "username": { "index": 26, "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.dhis2.Dhis2Configuration", "configurationField": "configuration", "description": "DHIS2 account username for accessing the DHIS2 API" } + "password": { "index": 25, "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.dhis2.Dhis2Configuration", "configurationField": "configuration", "description": "Password of the DHIS2 username" }, + "personalAccessToken": { "index": 26, "kind": "parameter", "displayName": "Personal Access Token", "group": "security", "label": "security", "required": false, "type": "string", "javaType": "java.lang.String", "deprecated": false, "autowired": false, "secret": true, "configurationClass": "org.apache.camel.component.dhis2.Dhis2Configuration", "configurationField": "configuration", "description": "Personal access token to authenticate with DHIS2. This option is mutually exclusive to us [...] + "username": { "index": 27, "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.dhis2.Dhis2Configuration", "configurationField": "configuration", "description": "Username of the DHIS2 user to operate as" } }, "apis": { "delete": { "consumerOnly": false, "producerOnly": false, "description": "", "methods": { "resource": { "description": "", "signatures": [ "java.io.InputStream resource(String path, Object resource, java.util.Map<String, Object> queryParams)" ] } } }, - "get": { "consumerOnly": false, "producerOnly": false, "description": "", "methods": { "collection": { "description": "", "signatures": [ "java.util.Iterator<org.apache.camel.component.dhis2.api.Dhis2Resource> collection(String path, String arrayName, Boolean paging, String fields, String filter, org.apache.camel.component.dhis2.api.RootJunctionEnum rootJunction, java.util.Map<String, Object> queryParams)" ] }, "resource": { "description": "", "signatures": [ "java.io.InputStream res [...] + "get": { "consumerOnly": false, "producerOnly": false, "description": "", "methods": { "collection": { "description": "", "signatures": [ "java.util.Iterator<org.apache.camel.component.dhis2.api.Dhis2Resource> collection(String path, String arrayName, Boolean paging, String fields, java.util.List<String> filter, org.apache.camel.component.dhis2.api.RootJunctionEnum rootJunction, java.util.Map<String, Object> queryParams)" ] }, "resource": { "description": "", "signatures": [ "java.io [...] "post": { "consumerOnly": false, "producerOnly": false, "description": "", "methods": { "resource": { "description": "", "signatures": [ "java.io.InputStream resource(String path, Object resource, java.util.Map<String, Object> queryParams)" ] } } }, "put": { "consumerOnly": false, "producerOnly": false, "description": "", "methods": { "resource": { "description": "", "signatures": [ "java.io.InputStream resource(String path, Object resource, java.util.Map<String, Object> queryParams)" ] } } }, - "resourceTables": { "consumerOnly": false, "producerOnly": false, "description": "", "methods": { "analytics": { "description": "", "signatures": [ "void analytics(Boolean skipAggregate, Boolean skipEvents, Integer lastYears, Integer interval)" ] } } } + "resourceTables": { "consumerOnly": false, "producerOnly": false, "description": "", "methods": { "analytics": { "description": "", "signatures": [ "void analytics(Boolean skipAggregate, Boolean skipEvents, Integer lastYears, Integer interval, Boolean async)" ] } } } }, "apiProperties": { "delete": { "methods": { "resource": { "properties": { "path": { "index": 0, "kind": "parameter", "displayName": "Path", "group": "common", "label": "", "required": false, "type": "string", "javaType": "java.lang.String", "deprecated": false, "autowired": false, "secret": false, "description": "", "optional": false }, "queryParams": { "index": 1, "kind": "parameter", "displayName": "Query Params", "group": "common", "label": "", "required": false, "type": "object", "javaType": "java. [...] - "get": { "methods": { "collection": { "properties": { "arrayName": { "index": 0, "kind": "parameter", "displayName": "Array Name", "group": "common", "label": "", "required": false, "type": "string", "javaType": "java.lang.String", "deprecated": false, "autowired": false, "secret": false, "description": "", "optional": false }, "fields": { "index": 1, "kind": "parameter", "displayName": "Fields", "group": "common", "label": "", "required": false, "type": "string", "javaType": "java.l [...] + "get": { "methods": { "collection": { "properties": { "arrayName": { "index": 0, "kind": "parameter", "displayName": "Array Name", "group": "common", "label": "", "required": false, "type": "string", "javaType": "java.lang.String", "deprecated": false, "autowired": false, "secret": false, "description": "", "optional": false }, "fields": { "index": 1, "kind": "parameter", "displayName": "Fields", "group": "common", "label": "", "required": false, "type": "string", "javaType": "java.l [...] "post": { "methods": { "resource": { "properties": { "path": { "index": 0, "kind": "parameter", "displayName": "Path", "group": "common", "label": "", "required": false, "type": "string", "javaType": "java.lang.String", "deprecated": false, "autowired": false, "secret": false, "description": "", "optional": false }, "queryParams": { "index": 1, "kind": "parameter", "displayName": "Query Params", "group": "common", "label": "", "required": false, "type": "object", "javaType": "java.ut [...] "put": { "methods": { "resource": { "properties": { "path": { "index": 0, "kind": "parameter", "displayName": "Path", "group": "common", "label": "", "required": false, "type": "string", "javaType": "java.lang.String", "deprecated": false, "autowired": false, "secret": false, "description": "", "optional": false }, "queryParams": { "index": 1, "kind": "parameter", "displayName": "Query Params", "group": "common", "label": "", "required": false, "type": "object", "javaType": "java.uti [...] - "resourceTables": { "methods": { "analytics": { "properties": { "interval": { "index": 0, "kind": "parameter", "displayName": "Interval", "group": "common", "label": "", "required": false, "type": "integer", "javaType": "java.lang.Integer", "deprecated": false, "autowired": false, "secret": false, "description": "", "optional": true }, "lastYears": { "index": 1, "kind": "parameter", "displayName": "Last Years", "group": "common", "label": "", "required": false, "type": "integer", "ja [...] + "resourceTables": { "methods": { "analytics": { "properties": { "async": { "index": 0, "kind": "parameter", "displayName": "Async", "group": "common", "label": "", "required": false, "type": "boolean", "javaType": "java.lang.Boolean", "deprecated": false, "autowired": false, "secret": false, "description": "", "optional": true }, "interval": { "index": 1, "kind": "parameter", "displayName": "Interval", "group": "common", "label": "", "required": false, "type": "integer", "javaType": [...] } } diff --git a/components/camel-dhis2/camel-dhis2-component/src/main/docs/dhis2-component.adoc b/components/camel-dhis2/camel-dhis2-component/src/main/docs/dhis2-component.adoc index b04a74f2c6c..3d86b18e0b3 100644 --- a/components/camel-dhis2/camel-dhis2-component/src/main/docs/dhis2-component.adoc +++ b/components/camel-dhis2/camel-dhis2-component/src/main/docs/dhis2-component.adoc @@ -54,15 +54,14 @@ include::partial$component-endpoint-options.adoc[] package org.camel.dhis2.example; import org.apache.camel.builder.RouteBuilder; -import org.hisp.dhis.api.model.v2_39_1.OrganisationUnit; public class MyRouteBuilder extends RouteBuilder { public void configure() { from("direct:getResource") - .to("dhis2://get/resource?path=organisationUnits/O6uvpzGd5pu&username=admin&password=district&baseApiUrl=https://play.dhis2.org/2.39.1/api") + .to("dhis2://get/resource?path=organisationUnits/O6uvpzGd5pu&username=admin&password=district&baseApiUrl=https://play.dhis2.org/40.2.2/api") .unmarshal() - .json(OrganisationUnit.class); + .json(org.hisp.dhis.api.model.v40_2_2.OrganisationUnit.class); } } @@ -75,17 +74,17 @@ public class MyRouteBuilder extends RouteBuilder { package org.camel.dhis2.example; import org.apache.camel.builder.RouteBuilder; -import org.hisp.dhis.api.model.v2_39_1.OrganisationUnit; public class MyRouteBuilder extends RouteBuilder { public void configure() { from("direct:getResource") - .to("dhis2://get/resource?path=organisationUnits/O6uvpzGd5pu&fields=code&username=admin&password=district&baseApiUrl=https://play.dhis2.org/2.39.1/api") + .to("dhis2://get/resource?path=organisationUnits/O6uvpzGd5pu&fields=code&username=admin&password=district&baseApiUrl=https://play.dhis2.org/40.2.2/api") .unmarshal() - .json(OrganisationUnit.class); + .json(org.hisp.dhis.api.model.v40_2_2.OrganisationUnit.class); } } + ---- * Fetch all organisation units: @@ -100,9 +99,9 @@ public class MyRouteBuilder extends RouteBuilder { public void configure() { from("direct:getCollection") - .to("dhis2://get/collection?path=organisationUnits&arrayName=organisationUnits&username=admin&password=district&baseApiUrl=https://play.dhis2.org/2.39.1/api") + .to("dhis2://get/collection?path=organisationUnits&arrayName=organisationUnits&username=admin&password=district&baseApiUrl=https://play.dhis2.org/40.2.2/api") .split().body() - .convertBodyTo(org.hisp.dhis.api.model.v2_39_1.OrganisationUnit.class).log("${body}"); + .convertBodyTo(org.hisp.dhis.api.model.v40_2_2.OrganisationUnit.class).log("${body}"); } } ---- @@ -119,9 +118,9 @@ public class MyRouteBuilder extends RouteBuilder { public void configure() { from("direct:getCollection") - .to("dhis2://get/collection?path=organisationUnits&fields=code&arrayName=organisationUnits&username=admin&password=district&baseApiUrl=https://play.dhis2.org/2.39.1/api") + .to("dhis2://get/collection?path=organisationUnits&fields=code&arrayName=organisationUnits&username=admin&password=district&baseApiUrl=https://play.dhis2.org/40.2.2/api") .split().body() - .convertBodyTo(org.hisp.dhis.api.model.v2_39_1.OrganisationUnit.class) + .convertBodyTo(org.hisp.dhis.api.model.v40_2_2.OrganisationUnit.class) .log("${body}"); } } @@ -139,9 +138,9 @@ public class MyRouteBuilder extends RouteBuilder { public void configure() { from("direct:getCollection") - .to("dhis2://get/collection?path=users&filter=phoneNumber:!null:&arrayName=users&username=admin&password=district&baseApiUrl=https://play.dhis2.org/2.39.1/api") + .to("dhis2://get/collection?path=users&filter=phoneNumber:!null:&arrayName=users&username=admin&password=district&baseApiUrl=https://play.dhis2.org/40.2.2/api") .split().body() - .convertBodyTo(org.hisp.dhis.api.model.v2_39_1.User.class) + .convertBodyTo(org.hisp.dhis.api.model.v40_2_2.User.class) .log("${body}"); } } @@ -155,10 +154,9 @@ package org.camel.dhis2.example; import org.apache.camel.LoggingLevel; import org.apache.camel.builder.RouteBuilder; -import org.hisp.dhis.api.model.v2_39_1.DataValueSet; -import org.hisp.dhis.api.model.v2_39_1.DataValue__1; -import org.hisp.dhis.api.model.v2_39_1.DescriptiveWebMessage; -import org.hisp.dhis.api.model.v2_39_1.ImportReportWebMessageResponse; +import org.hisp.dhis.api.model.v40_2_2.DataValueSet; +import org.hisp.dhis.api.model.v40_2_2.DataValue; +import org.hisp.dhis.api.model.v40_2_2.WebMessage; import org.hisp.dhis.integration.sdk.support.period.PeriodBuilder; import java.time.ZoneOffset; @@ -176,11 +174,11 @@ public class MyRouteBuilder extends RouteBuilder { .withOrgUnit("O6uvpzGd5pu") .withDataSet("lyLU2wR22tC").withPeriod(PeriodBuilder.monthOf(new Date(), -1)) .withDataValues( - List.of(new DataValue__1().withDataElement("aIJZ2d2QgVV").withValue("20")))) - .to("dhis2://post/resource?path=dataValueSets&username=admin&password=district&baseApiUrl=https://play.dhis2.org/2.39.1/api") - .unmarshal().json(ImportReportWebMessageResponse.class) + List.of(new DataValue().withDataElement("aIJZ2d2QgVV").withValue("20")))) + .to("dhis2://post/resource?path=dataValueSets&username=admin&password=district&baseApiUrl=https://play.dhis2.org/40.2.2/api") + .unmarshal().json(WebMessage.class) .choice() - .when(exchange -> !exchange.getMessage().getBody(ImportReportWebMessageResponse.class).getStatus().get().equals(DescriptiveWebMessage.Status.OK)) + .when(exchange -> !exchange.getMessage().getBody(WebMessage.class).getStatus().equals(WebMessage.StatusRef.OK)) .log(LoggingLevel.ERROR, "Import error from DHIS2 while saving data value set => ${body}") .end(); } @@ -195,9 +193,8 @@ package org.camel.dhis2.example; import org.apache.camel.LoggingLevel; import org.apache.camel.builder.RouteBuilder; -import org.hisp.dhis.api.model.v2_39_1.OrganisationUnit; -import org.hisp.dhis.api.model.v2_39_1.DescriptiveWebMessage; -import org.hisp.dhis.api.model.v2_39_1.ImportReportWebMessageResponse; +import org.hisp.dhis.api.model.v40_2_2.OrganisationUnit; +import org.hisp.dhis.api.model.v40_2_2.WebMessage; import org.hisp.dhis.integration.sdk.support.period.PeriodBuilder; import java.time.ZoneOffset; @@ -211,10 +208,10 @@ public class MyRouteBuilder extends RouteBuilder { public void configure() { from("direct:putResource") .setBody(exchange -> new OrganisationUnit().withName("Acme").withShortName("Acme").withOpeningDate(new Date())) - .to("dhis2://put/resource?path=organisationUnits/jUb8gELQApl&username=admin&password=district&baseApiUrl=https://play.dhis2.org/2.39.1/api") - .unmarshal().json(ImportReportWebMessageResponse.class) + .to("dhis2://put/resource?path=organisationUnits/jUb8gELQApl&username=admin&password=district&baseApiUrl=https://play.dhis2.org/40.2.2/api") + .unmarshal().json(WebMessage.class) .choice() - .when(exchange -> !exchange.getMessage().getBody(ImportReportWebMessageResponse.class).getStatus().get().equals(DescriptiveWebMessage.Status.OK)) + .when(exchange -> !exchange.getMessage().getBody(WebMessage.class).getStatus().equals(WebMessage.StatusRef.OK)) .log(LoggingLevel.ERROR, "Import error from DHIS2 while updating org unit => ${body}") .end(); } @@ -229,8 +226,7 @@ package org.camel.dhis2.example; import org.apache.camel.LoggingLevel; import org.apache.camel.builder.RouteBuilder; -import org.hisp.dhis.api.model.v2_39_1.DescriptiveWebMessage; -import org.hisp.dhis.api.model.v2_39_1.ImportReportWebMessageResponse; +import org.hisp.dhis.api.model.v40_2_2.WebMessage; import org.hisp.dhis.integration.sdk.support.period.PeriodBuilder; import java.time.ZoneOffset; @@ -243,10 +239,10 @@ public class MyRouteBuilder extends RouteBuilder { public void configure() { from("direct:deleteResource") - .to("dhis2://delete/resource?path=organisationUnits/jUb8gELQApl&username=admin&password=district&baseApiUrl=https://play.dhis2.org/2.39.1/api") - .unmarshal().json(ImportReportWebMessageResponse.class) + .to("dhis2://delete/resource?path=organisationUnits/jUb8gELQApl&username=admin&password=district&baseApiUrl=https://play.dhis2.org/40.2.2/api") + .unmarshal().json(WebMessage.class) .choice() - .when(exchange -> !exchange.getMessage().getBody(ImportReportWebMessageResponse.class).getStatus().get().equals(DescriptiveWebMessage.Status.OK)) + .when(exchange -> !exchange.getMessage().getBody(WebMessage.class).getStatus().equals(WebMessage.StatusRef.OK)) .log(LoggingLevel.ERROR, "Import error from DHIS2 while deleting org unit => ${body}") .end(); } @@ -265,7 +261,7 @@ public class MyRouteBuilder extends RouteBuilder { public void configure() { from("direct:resourceTablesAnalytics") - .to("dhis2://resourceTables/analytics?skipAggregate=false&skipEvents=true&lastYears=1&username=admin&password=district&baseApiUrl=https://play.dhis2.org/2.39.1/api"); + .to("dhis2://resourceTables/analytics?skipAggregate=false&skipEvents=true&lastYears=1&username=admin&password=district&baseApiUrl=https://play.dhis2.org/40.2.2/api"); } } ---- @@ -283,7 +279,7 @@ import org.hisp.dhis.integration.sdk.api.Dhis2Client; public class MyRouteBuilder extends RouteBuilder { public void configure() { - Dhis2Client dhis2Client = Dhis2ClientBuilder.newClient("https://play.dhis2.org/2.39.1/api", "admin", "district").build(); + Dhis2Client dhis2Client = Dhis2ClientBuilder.newClient("https://play.dhis2.org/40.2.2/api", "admin", "district").build(); getCamelContext().getRegistry().bind("dhis2Client", dhis2Client); from("direct:resourceTablesAnalytics") diff --git a/components/camel-dhis2/camel-dhis2-component/src/main/java/org/apache/camel/component/dhis2/Dhis2Component.java b/components/camel-dhis2/camel-dhis2-component/src/main/java/org/apache/camel/component/dhis2/Dhis2Component.java index bc06487f6b7..345e125fbb6 100644 --- a/components/camel-dhis2/camel-dhis2-component/src/main/java/org/apache/camel/component/dhis2/Dhis2Component.java +++ b/components/camel-dhis2/camel-dhis2-component/src/main/java/org/apache/camel/component/dhis2/Dhis2Component.java @@ -18,6 +18,7 @@ package org.apache.camel.component.dhis2; import org.apache.camel.CamelContext; import org.apache.camel.Endpoint; +import org.apache.camel.RuntimeCamelException; import org.apache.camel.component.dhis2.internal.Dhis2ApiCollection; import org.apache.camel.component.dhis2.internal.Dhis2ApiName; import org.apache.camel.spi.Metadata; @@ -75,12 +76,28 @@ public class Dhis2Component extends AbstractApiComponent<Dhis2ApiName, Dhis2Conf return this.dhis2Client; } else { if (endpointConfiguration.getClient() != null) { + if (endpointConfiguration.getBaseApiUrl() != null || endpointConfiguration.getPersonalAccessToken() != null + || endpointConfiguration.getUsername() != null || endpointConfiguration.getPassword() != null) { + throw new RuntimeCamelException( + "Bad DHIS2 endpoint configuration: client option is mutually exclusive to baseApiUrl, username, password, and personalAccessToken. Either set `client`, or `baseApiUrl` and `username` and `password`, or `baseApiUrl` and `personalAccessToken`"); + } + return endpointConfiguration.getClient(); } else { - return Dhis2ClientBuilder.newClient(endpointConfiguration.getBaseApiUrl(), - endpointConfiguration.getUsername(), endpointConfiguration.getPassword()).build(); + if (endpointConfiguration.getPersonalAccessToken() != null + && (endpointConfiguration.getUsername() != null || endpointConfiguration.getPassword() != null)) { + throw new RuntimeCamelException( + "Bad DHIS2 authentication configuration: Personal access token authentication and basic authentication are mutually exclusive. Either set `personalAccessToken` or both `username` and `password`"); + } + + if (endpointConfiguration.getPersonalAccessToken() != null) { + return Dhis2ClientBuilder.newClient(endpointConfiguration.getBaseApiUrl(), + endpointConfiguration.getPersonalAccessToken()).build(); + } else { + return Dhis2ClientBuilder.newClient(endpointConfiguration.getBaseApiUrl(), + endpointConfiguration.getUsername(), endpointConfiguration.getPassword()).build(); + } } } } - } diff --git a/components/camel-dhis2/camel-dhis2-component/src/main/java/org/apache/camel/component/dhis2/Dhis2Configuration.java b/components/camel-dhis2/camel-dhis2-component/src/main/java/org/apache/camel/component/dhis2/Dhis2Configuration.java index 72463618f57..5ae0d23ecce 100644 --- a/components/camel-dhis2/camel-dhis2-component/src/main/java/org/apache/camel/component/dhis2/Dhis2Configuration.java +++ b/components/camel-dhis2/camel-dhis2-component/src/main/java/org/apache/camel/component/dhis2/Dhis2Configuration.java @@ -30,12 +30,16 @@ public class Dhis2Configuration { @UriParam(description = "DHIS2 server base API URL (e.g., https://play.dhis2.org/2.39.1.1/api)") private String baseApiUrl; - @UriParam(description = "DHIS2 account username for accessing the DHIS2 API", secret = true, label = "security") + @UriParam(description = "Username of the DHIS2 user to operate as", secret = true, label = "security") private String username; - @UriParam(description = "DHIS2 account password for accessing the DHIS2 API", secret = true, label = "security") + @UriParam(description = "Password of the DHIS2 username", secret = true, label = "security") private String password; + @UriParam(description = "Personal access token to authenticate with DHIS2. This option is mutually exclusive to username and password", + secret = true, label = "security") + private String personalAccessToken; + @UriPath(description = "API operation (e.g., get)") @Metadata(required = true) private Dhis2ApiName apiName; @@ -44,7 +48,8 @@ public class Dhis2Configuration { @Metadata(required = true) private String methodName; - @UriParam(label = "advanced", description = "References a user-defined org.hisp.dhis.integration.sdk.api.Dhis2Client") + @UriParam(label = "advanced", + description = "References a user-defined org.hisp.dhis.integration.sdk.api.Dhis2Client. This option is mutually exclusive to the baseApiUrl, username, password, and personalAccessToken options") private Dhis2Client client; public String getBaseApiUrl() { @@ -83,6 +88,14 @@ public class Dhis2Configuration { return methodName; } + public String getPersonalAccessToken() { + return personalAccessToken; + } + + public void setPersonalAccessToken(String personalAccessToken) { + this.personalAccessToken = personalAccessToken; + } + public void setMethodName(String methodName) { this.methodName = methodName; } diff --git a/components/camel-dhis2/camel-dhis2-component/src/test/java/org/apache/camel/component/dhis2/AbstractDhis2TestSupport.java b/components/camel-dhis2/camel-dhis2-component/src/test/java/org/apache/camel/component/dhis2/AbstractDhis2TestSupport.java index 451308dd348..079111b7730 100644 --- a/components/camel-dhis2/camel-dhis2-component/src/test/java/org/apache/camel/component/dhis2/AbstractDhis2TestSupport.java +++ b/components/camel-dhis2/camel-dhis2-component/src/test/java/org/apache/camel/component/dhis2/AbstractDhis2TestSupport.java @@ -17,6 +17,7 @@ package org.apache.camel.component.dhis2; import java.util.Map; +import java.util.concurrent.ThreadLocalRandom; import org.apache.camel.CamelContext; import org.apache.camel.CamelExecutionException; @@ -41,8 +42,12 @@ abstract class AbstractDhis2TestSupport extends CamelTestSupport { final CamelContext context = super.createCamelContext(); Dhis2Configuration configuration = new Dhis2Configuration(); configuration.setBaseApiUrl(baseApiUrl); - configuration.setUsername(username); - configuration.setPassword(password); + if (ThreadLocalRandom.current().nextBoolean()) { + configuration.setUsername(username); + configuration.setPassword(password); + } else { + configuration.setPersonalAccessToken(Environment.PERSONAL_ACCESS_TOKEN); + } // add Dhis2Component to Camel context final Dhis2Component component = new Dhis2Component(context); diff --git a/components/camel-dhis2/camel-dhis2-component/src/test/java/org/apache/camel/component/dhis2/Dhis2ComponentTestCase.java b/components/camel-dhis2/camel-dhis2-component/src/test/java/org/apache/camel/component/dhis2/Dhis2ComponentTestCase.java new file mode 100644 index 00000000000..d5ddbcd997a --- /dev/null +++ b/components/camel-dhis2/camel-dhis2-component/src/test/java/org/apache/camel/component/dhis2/Dhis2ComponentTestCase.java @@ -0,0 +1,41 @@ +/* + * 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.dhis2; + +import org.apache.camel.RuntimeCamelException; +import org.hisp.dhis.integration.sdk.Dhis2ClientBuilder; +import org.junit.jupiter.api.Test; + +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.assertThrows; + +public class Dhis2ComponentTestCase { + @Test + public void testGetClientThrowsExceptionGivenDhis2ConfigurationWithDhis2ClientAndBaseApiUrl() { + Dhis2Configuration dhis2Configuration = new Dhis2Configuration(); + dhis2Configuration.setBaseApiUrl("https://play.dhis2.org/40.2.2/api"); + dhis2Configuration + .setClient(Dhis2ClientBuilder.newClient("https://play.dhis2.org/40.2.2/api", "admin", "district").build()); + + Dhis2Component dhis2Component = new Dhis2Component(); + RuntimeCamelException runtimeCamelException + = assertThrows(RuntimeCamelException.class, () -> dhis2Component.getClient(dhis2Configuration)); + assertEquals( + "Bad DHIS2 endpoint configuration: client option is mutually exclusive to baseApiUrl, username, password, and personalAccessToken. Either set `client`, or `baseApiUrl` and `username` and `password`, or `baseApiUrl` and `personalAccessToken`", + runtimeCamelException.getMessage()); + } +} diff --git a/components/camel-dhis2/camel-dhis2-component/src/test/java/org/apache/camel/component/dhis2/Dhis2DeleteIT.java b/components/camel-dhis2/camel-dhis2-component/src/test/java/org/apache/camel/component/dhis2/Dhis2DeleteIT.java index d9bcb32f362..78d4fe4708a 100644 --- a/components/camel-dhis2/camel-dhis2-component/src/test/java/org/apache/camel/component/dhis2/Dhis2DeleteIT.java +++ b/components/camel-dhis2/camel-dhis2-component/src/test/java/org/apache/camel/component/dhis2/Dhis2DeleteIT.java @@ -26,8 +26,8 @@ import java.util.Map; import org.apache.camel.builder.RouteBuilder; import org.apache.camel.component.dhis2.internal.Dhis2ApiCollection; import org.apache.camel.component.dhis2.internal.Dhis2DeleteApiMethod; -import org.hisp.dhis.api.model.v2_39_1.OrganisationUnit; -import org.hisp.dhis.api.model.v2_39_1.WebMessage; +import org.hisp.dhis.api.model.v40_2_2.OrganisationUnit; +import org.hisp.dhis.api.model.v40_2_2.WebMessage; import org.hisp.dhis.integration.sdk.api.RemoteDhis2ClientException; import org.junit.jupiter.api.Test; import org.slf4j.Logger; @@ -48,10 +48,10 @@ public class Dhis2DeleteIT extends AbstractDhis2TestSupport { @Test public void testResource() { - String orgUnitId = (String) ((Map<String, Object>) Environment.DHIS2_CLIENT.post("organisationUnits") + String orgUnitId = Environment.DHIS2_CLIENT.post("organisationUnits") .withResource(new OrganisationUnit().withName("Acme").withShortName("Acme").withOpeningDate(new Date())) .transfer() - .returnAs(WebMessage.class).getResponse().get()).get("uid"); + .returnAs(WebMessage.class).getResponse().get().get("uid"); final Map<String, Object> headers = new HashMap<>(); // parameter type is String diff --git a/components/camel-dhis2/camel-dhis2-component/src/test/java/org/apache/camel/component/dhis2/Dhis2GetIT.java b/components/camel-dhis2/camel-dhis2-component/src/test/java/org/apache/camel/component/dhis2/Dhis2GetIT.java index 9eface3e43b..907145c9233 100644 --- a/components/camel-dhis2/camel-dhis2-component/src/test/java/org/apache/camel/component/dhis2/Dhis2GetIT.java +++ b/components/camel-dhis2/camel-dhis2-component/src/test/java/org/apache/camel/component/dhis2/Dhis2GetIT.java @@ -27,13 +27,13 @@ import org.apache.camel.builder.RouteBuilder; import org.apache.camel.component.dhis2.internal.Dhis2ApiCollection; import org.apache.camel.component.dhis2.internal.Dhis2GetApiMethod; import org.apache.camel.processor.aggregate.GroupedBodyAggregationStrategy; -import org.hisp.dhis.api.model.v2_39_1.OrganisationUnit; +import org.hisp.dhis.api.model.v40_2_2.OrganisationUnit; import org.junit.jupiter.api.Test; import org.slf4j.Logger; import org.slf4j.LoggerFactory; -import static org.junit.jupiter.api.Assertions.assertFalse; import static org.junit.jupiter.api.Assertions.assertNotNull; +import static org.junit.jupiter.api.Assertions.assertTrue; /** * Test class for {@link org.apache.camel.component.dhis2.api.Dhis2Get} APIs. @@ -55,11 +55,8 @@ public class Dhis2GetIT extends AbstractDhis2TestSupport { final List<OrganisationUnit> result = requestBodyAndHeaders("direct://COLLECTION", null, headers); - /* - * There is something incorrectly configured on these tests, causing it to return outdated data as more tests are executed, - * so, instead of checking for the expected size of 2, we just check if the result is not empty. - */ - assertFalse(result.isEmpty()); + LOG.debug("collection: {}", result); + assertTrue(result.size() >= 2); LOG.debug("collection: {}", result); } diff --git a/components/camel-dhis2/camel-dhis2-component/src/test/java/org/apache/camel/component/dhis2/Dhis2PostIT.java b/components/camel-dhis2/camel-dhis2-component/src/test/java/org/apache/camel/component/dhis2/Dhis2PostIT.java index 6526debc6f4..78c8b1aeb9e 100644 --- a/components/camel-dhis2/camel-dhis2-component/src/test/java/org/apache/camel/component/dhis2/Dhis2PostIT.java +++ b/components/camel-dhis2/camel-dhis2-component/src/test/java/org/apache/camel/component/dhis2/Dhis2PostIT.java @@ -26,7 +26,7 @@ import java.util.Map; import org.apache.camel.builder.RouteBuilder; import org.apache.camel.component.dhis2.internal.Dhis2ApiCollection; import org.apache.camel.component.dhis2.internal.Dhis2PostApiMethod; -import org.hisp.dhis.api.model.v2_39_1.OrganisationUnit; +import org.hisp.dhis.api.model.v40_2_2.OrganisationUnit; import org.junit.jupiter.api.Test; import org.slf4j.Logger; import org.slf4j.LoggerFactory; diff --git a/components/camel-dhis2/camel-dhis2-component/src/test/java/org/apache/camel/component/dhis2/Dhis2PutIT.java b/components/camel-dhis2/camel-dhis2-component/src/test/java/org/apache/camel/component/dhis2/Dhis2PutIT.java index 9b7faaa3f1a..dc68fc012de 100644 --- a/components/camel-dhis2/camel-dhis2-component/src/test/java/org/apache/camel/component/dhis2/Dhis2PutIT.java +++ b/components/camel-dhis2/camel-dhis2-component/src/test/java/org/apache/camel/component/dhis2/Dhis2PutIT.java @@ -27,7 +27,7 @@ import org.apache.camel.builder.RouteBuilder; import org.apache.camel.component.dhis2.internal.Dhis2ApiCollection; import org.apache.camel.component.dhis2.internal.Dhis2PutApiMethod; import org.apache.commons.lang3.RandomStringUtils; -import org.hisp.dhis.api.model.v2_39_1.OrganisationUnit; +import org.hisp.dhis.api.model.v40_2_2.OrganisationUnit; import org.junit.jupiter.api.Test; import org.slf4j.Logger; import org.slf4j.LoggerFactory; diff --git a/components/camel-dhis2/camel-dhis2-component/src/test/java/org/apache/camel/component/dhis2/Environment.java b/components/camel-dhis2/camel-dhis2-component/src/test/java/org/apache/camel/component/dhis2/Environment.java index 3584747bbee..06b8ea5a4ca 100644 --- a/components/camel-dhis2/camel-dhis2-component/src/test/java/org/apache/camel/component/dhis2/Environment.java +++ b/components/camel-dhis2/camel-dhis2-component/src/test/java/org/apache/camel/component/dhis2/Environment.java @@ -18,11 +18,13 @@ package org.apache.camel.component.dhis2; import java.time.Duration; import java.util.Date; +import java.util.List; import java.util.Map; -import org.hisp.dhis.api.model.v2_39_1.OrganisationUnit; -import org.hisp.dhis.api.model.v2_39_1.OrganisationUnitLevel; -import org.hisp.dhis.api.model.v2_39_1.WebMessage; +import org.hisp.dhis.api.model.v40_2_2.ApiToken; +import org.hisp.dhis.api.model.v40_2_2.OrganisationUnit; +import org.hisp.dhis.api.model.v40_2_2.OrganisationUnitLevel; +import org.hisp.dhis.api.model.v40_2_2.WebMessage; import org.hisp.dhis.integration.sdk.Dhis2ClientBuilder; import org.hisp.dhis.integration.sdk.api.Dhis2Client; import org.testcontainers.containers.BindMode; @@ -36,6 +38,8 @@ public final class Environment { public static final Dhis2Client DHIS2_CLIENT; + public static final String PERSONAL_ACCESS_TOKEN; + public static final String ORG_UNIT_ID_UNDER_TEST; private static final Network NETWORK = Network.newNetwork(); @@ -59,9 +63,9 @@ public final class Environment { POSTGRESQL_CONTAINER.start(); DHIS2_CONTAINER = new GenericContainer<>( - "dhis2/core:2.37.4-tomcat-8.5.34-jre8-alpine") + "dhis2/core:2.40.2.1") .dependsOn(POSTGRESQL_CONTAINER) - .withClasspathResourceMapping("dhis.conf", "/DHIS2_home/dhis.conf", BindMode.READ_ONLY) + .withClasspathResourceMapping("dhis.conf", "/opt/dhis2/dhis.conf", BindMode.READ_WRITE) .withNetwork(NETWORK).withExposedPorts(8080) .waitingFor( new HttpWaitStrategy().forStatusCode(200).withStartupTimeout(Duration.ofSeconds(360))) @@ -78,15 +82,35 @@ public final class Environment { ORG_UNIT_ID_UNDER_TEST = createOrgUnit("Acme"); createOrgUnitLevel(); addOrgUnitToUser(ORG_UNIT_ID_UNDER_TEST); + PERSONAL_ACCESS_TOKEN = createPersonalAccessToken(); + } + + private static String createPersonalAccessToken() { + return DHIS2_CLIENT + .post("apiToken") + .withResource( + new ApiToken() + .withAttributes( + List.of( + Map.of( + "type", + "MethodAllowedList", + "allowedMethods", + List.of("GET", "POST", "PUT", "PATCH", "DELETE")))) + .withExpire(Long.MAX_VALUE)) + .transfer() + .returnAs(WebMessage.class) + .getResponse() + .get().get("key"); } private static String createOrgUnit(String name) { OrganisationUnit organisationUnit = new OrganisationUnit().withName(name).withShortName(name) .withOpeningDate(new Date()); - return (String) ((Map<String, Object>) DHIS2_CLIENT.post("organisationUnits").withResource(organisationUnit) + return DHIS2_CLIENT.post("organisationUnits").withResource(organisationUnit) .transfer() - .returnAs(WebMessage.class).getResponse().get()).get("uid"); + .returnAs(WebMessage.class).getResponse().get().get("uid"); } private static void createOrgUnitLevel() { diff --git a/components/camel-dhis2/pom.xml b/components/camel-dhis2/pom.xml index 5e434702419..11ebe1e665c 100644 --- a/components/camel-dhis2/pom.xml +++ b/components/camel-dhis2/pom.xml @@ -34,7 +34,7 @@ <description>Camel DHIS2 Component</description> <properties> - <dhis2-java-sdk.version>2.1.0</dhis2-java-sdk.version> + <dhis2-java-sdk.version>3.0.0</dhis2-java-sdk.version> <!-- DHIS2 container is not available on these platforms --> <skipITs.ppc64le>true</skipITs.ppc64le> @@ -57,7 +57,7 @@ <groupId>org.hisp.dhis.integration.sdk</groupId> <artifactId>jackson-resource-model</artifactId> <version>${dhis2-java-sdk.version}</version> - <classifier>v2.39.1</classifier> + <classifier>v40.2.2</classifier> </dependency> <dependency> <groupId>org.apache.camel</groupId> diff --git a/core/camel-util/src/main/java/org/apache/camel/util/SensitiveUtils.java b/core/camel-util/src/main/java/org/apache/camel/util/SensitiveUtils.java index 384490f806b..cd8eab28a0e 100644 --- a/core/camel-util/src/main/java/org/apache/camel/util/SensitiveUtils.java +++ b/core/camel-util/src/main/java/org/apache/camel/util/SensitiveUtils.java @@ -63,6 +63,7 @@ public final class SensitiveUtils { "passcode", "passphrase", "password", + "personalaccesstoken", "privatekey", "privatekeyfile", "privatekeyname", @@ -140,6 +141,7 @@ public final class SensitiveUtils { + "|\\Qpasscode\\E" + "|\\Qpassphrase\\E" + "|\\Qpassword\\E" + + "|\\Qpersonalaccesstoken\\E" + "|\\Qprivatekey\\E" + "|\\Qprivatekeyfile\\E" + "|\\Qprivatekeyname\\E"