You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@camel.apache.org by or...@apache.org on 2022/06/19 12:54:19 UTC

[camel] 18/21: (chores) camel-servicenow: removed unused code and parameters

This is an automated email from the ASF dual-hosted git repository.

orpiske pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/camel.git

commit b5690258e33395bb62926551353f48897e9a6e7d
Author: Otavio Rodolfo Piske <an...@gmail.com>
AuthorDate: Sun Jun 19 11:44:55 2022 +0200

    (chores) camel-servicenow: removed unused code and parameters
---
 .../org/apache/camel/component/servicenow/servicenow.json  |  2 +-
 .../camel/component/servicenow/ServiceNowClient.java       | 14 ++++++--------
 .../releases/fuji/FujiServiceNowAggregateProcessor.java    |  4 ++--
 .../releases/fuji/FujiServiceNowImportSetProcessor.java    |  4 ++--
 .../releases/fuji/FujiServiceNowTableProcessor.java        |  8 ++++----
 5 files changed, 15 insertions(+), 17 deletions(-)

diff --git a/components/camel-servicenow/camel-servicenow-component/src/generated/resources/org/apache/camel/component/servicenow/servicenow.json b/components/camel-servicenow/camel-servicenow-component/src/generated/resources/org/apache/camel/component/servicenow/servicenow.json
index 854b35f37e6..e8c20c570c7 100644
--- a/components/camel-servicenow/camel-servicenow-component/src/generated/resources/org/apache/camel/component/servicenow/servicenow.json
+++ b/components/camel-servicenow/camel-servicenow-component/src/generated/resources/org/apache/camel/component/servicenow/servicenow.json
@@ -150,6 +150,7 @@
     "includeScores": { "kind": "parameter", "displayName": "Include Scores", "group": "producer", "label": "", "required": false, "type": "boolean", "javaType": "java.lang.Boolean", "deprecated": false, "autowired": false, "secret": false, "configurationClass": "org.apache.camel.component.servicenow.ServiceNowConfiguration", "configurationField": "configuration", "description": "Set this parameter to true to return all scores for a scorecard. If a value is not specified, this parameter d [...]
     "inputDisplayValue": { "kind": "parameter", "displayName": "Input Display Value", "group": "producer", "label": "", "required": false, "type": "boolean", "javaType": "java.lang.Boolean", "deprecated": false, "autowired": false, "secret": false, "configurationClass": "org.apache.camel.component.servicenow.ServiceNowConfiguration", "configurationField": "configuration", "description": "True to set raw value of input fields (default: false)" },
     "key": { "kind": "parameter", "displayName": "Key", "group": "producer", "label": "", "required": false, "type": "boolean", "javaType": "java.lang.Boolean", "deprecated": false, "autowired": false, "secret": false, "configurationClass": "org.apache.camel.component.servicenow.ServiceNowConfiguration", "configurationField": "configuration", "description": "Set this parameter to true to return only scorecards for key indicators." },
+    "lazyStartProducer": { "kind": "parameter", "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 during sta [...]
     "models": { "kind": "parameter", "displayName": "Models", "group": "producer", "label": "", "required": false, "type": "object", "javaType": "java.util.Map<java.lang.String, java.lang.Class<java.lang.Object>>", "prefix": "model.", "multiValue": true, "deprecated": false, "autowired": false, "secret": false, "configurationClass": "org.apache.camel.component.servicenow.ServiceNowConfiguration", "configurationField": "configuration", "description": "Defines both request and response models" },
     "perPage": { "kind": "parameter", "displayName": "Per Page", "group": "producer", "label": "", "required": false, "type": "integer", "javaType": "java.lang.Integer", "deprecated": false, "autowired": false, "secret": false, "defaultValue": "10", "configurationClass": "org.apache.camel.component.servicenow.ServiceNowConfiguration", "configurationField": "configuration", "description": "Enter the maximum number of scorecards each query can return. By default this value is 10, and the m [...]
     "release": { "kind": "parameter", "displayName": "Release", "group": "producer", "label": "", "required": false, "type": "object", "javaType": "org.apache.camel.component.servicenow.ServiceNowRelease", "enum": [ "FUJI", "GENEVA", "HELSINKI" ], "deprecated": false, "autowired": false, "secret": false, "defaultValue": "HELSINKI", "configurationClass": "org.apache.camel.component.servicenow.ServiceNowConfiguration", "configurationField": "configuration", "description": "The ServiceNow r [...]
@@ -163,7 +164,6 @@
     "table": { "kind": "parameter", "displayName": "Table", "group": "producer", "label": "", "required": false, "type": "string", "javaType": "java.lang.String", "deprecated": false, "autowired": false, "secret": false, "configurationClass": "org.apache.camel.component.servicenow.ServiceNowConfiguration", "configurationField": "configuration", "description": "The default table, can be overridden by header CamelServiceNowTable" },
     "target": { "kind": "parameter", "displayName": "Target", "group": "producer", "label": "", "required": false, "type": "boolean", "javaType": "java.lang.Boolean", "deprecated": false, "autowired": false, "secret": false, "configurationClass": "org.apache.camel.component.servicenow.ServiceNowConfiguration", "configurationField": "configuration", "description": "Set this parameter to true to return only scorecards that have a target." },
     "topLevelOnly": { "kind": "parameter", "displayName": "Top Level Only", "group": "producer", "label": "", "required": false, "type": "boolean", "javaType": "java.lang.Boolean", "deprecated": false, "autowired": false, "secret": false, "configurationClass": "org.apache.camel.component.servicenow.ServiceNowConfiguration", "configurationField": "configuration", "description": "Gets only those categories whose parent is a catalog." },
-    "lazyStartProducer": { "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 producer may other [...]
     "apiVersion": { "kind": "parameter", "displayName": "Api Version", "group": "advanced", "label": "advanced", "required": false, "type": "string", "javaType": "java.lang.String", "deprecated": false, "autowired": false, "secret": false, "configurationClass": "org.apache.camel.component.servicenow.ServiceNowConfiguration", "configurationField": "configuration", "description": "The ServiceNow REST API version, default latest" },
     "dateFormat": { "kind": "parameter", "displayName": "Date Format", "group": "advanced", "label": "advanced", "required": false, "type": "string", "javaType": "java.lang.String", "deprecated": false, "autowired": false, "secret": false, "defaultValue": "yyyy-MM-dd", "configurationClass": "org.apache.camel.component.servicenow.ServiceNowConfiguration", "configurationField": "configuration", "description": "The date format used for Json serialization\/deserialization" },
     "dateTimeFormat": { "kind": "parameter", "displayName": "Date Time Format", "group": "advanced", "label": "advanced", "required": false, "type": "string", "javaType": "java.lang.String", "deprecated": false, "autowired": false, "secret": false, "defaultValue": "yyyy-MM-dd HH:mm:ss", "configurationClass": "org.apache.camel.component.servicenow.ServiceNowConfiguration", "configurationField": "configuration", "description": "The date-time format used for Json serialization\/deserialization" },
diff --git a/components/camel-servicenow/camel-servicenow-component/src/main/java/org/apache/camel/component/servicenow/ServiceNowClient.java b/components/camel-servicenow/camel-servicenow-component/src/main/java/org/apache/camel/component/servicenow/ServiceNowClient.java
index 27164af9182..4a652c8a62e 100644
--- a/components/camel-servicenow/camel-servicenow-component/src/main/java/org/apache/camel/component/servicenow/ServiceNowClient.java
+++ b/components/camel-servicenow/camel-servicenow-component/src/main/java/org/apache/camel/component/servicenow/ServiceNowClient.java
@@ -45,12 +45,10 @@ import org.slf4j.LoggerFactory;
 public final class ServiceNowClient {
     private static final Logger LOGGER = LoggerFactory.getLogger(ServiceNowClient.class);
 
-    private final CamelContext camelContext;
     private final ServiceNowConfiguration configuration;
     private final WebClient client;
 
     public ServiceNowClient(CamelContext camelContext, ServiceNowConfiguration configuration) {
-        this.camelContext = camelContext;
         this.configuration = configuration;
         this.client = WebClient.create(
                 configuration.getApiUrl(),
@@ -59,10 +57,10 @@ public final class ServiceNowClient {
                         new JacksonJsonProvider(configuration.getOrCreateMapper())),
                 true);
 
-        configureRequestContext(camelContext, configuration, client);
+        configureRequestContext(client);
         configureTls(camelContext, configuration, client);
-        configureHttpClientPolicy(camelContext, configuration, client);
-        configureProxyAuthorizationPolicy(camelContext, configuration, client);
+        configureHttpClientPolicy(configuration, client);
+        configureProxyAuthorizationPolicy(configuration, client);
     }
 
     public ServiceNowClient types(MediaType type) {
@@ -206,7 +204,7 @@ public final class ServiceNowClient {
     }
 
     private static void configureRequestContext(
-            CamelContext context, ServiceNowConfiguration configuration, WebClient client) {
+            WebClient client) {
 
         WebClient.getConfig(client)
                 .getRequestContext()
@@ -236,7 +234,7 @@ public final class ServiceNowClient {
     }
 
     private static void configureHttpClientPolicy(
-            CamelContext context, ServiceNowConfiguration configuration, WebClient client) {
+            ServiceNowConfiguration configuration, WebClient client) {
 
         HTTPClientPolicy httpPolicy = configuration.getHttpClientPolicy();
         if (httpPolicy == null) {
@@ -256,7 +254,7 @@ public final class ServiceNowClient {
     }
 
     private static void configureProxyAuthorizationPolicy(
-            CamelContext context, ServiceNowConfiguration configuration, WebClient client) {
+            ServiceNowConfiguration configuration, WebClient client) {
 
         ProxyAuthorizationPolicy proxyPolicy = configuration.getProxyAuthorizationPolicy();
         if (proxyPolicy == null) {
diff --git a/components/camel-servicenow/camel-servicenow-component/src/main/java/org/apache/camel/component/servicenow/releases/fuji/FujiServiceNowAggregateProcessor.java b/components/camel-servicenow/camel-servicenow-component/src/main/java/org/apache/camel/component/servicenow/releases/fuji/FujiServiceNowAggregateProcessor.java
index 2a3b0491fd5..1c76326f94d 100644
--- a/components/camel-servicenow/camel-servicenow-component/src/main/java/org/apache/camel/component/servicenow/releases/fuji/FujiServiceNowAggregateProcessor.java
+++ b/components/camel-servicenow/camel-servicenow-component/src/main/java/org/apache/camel/component/servicenow/releases/fuji/FujiServiceNowAggregateProcessor.java
@@ -40,7 +40,7 @@ class FujiServiceNowAggregateProcessor extends FujiServiceNowProcessor {
             throws Exception {
         Response response;
         if (ObjectHelper.equal(ServiceNowConstants.ACTION_RETRIEVE, action, true)) {
-            response = retrieveStats(exchange.getIn(), requestModel, responseModel, tableName);
+            response = retrieveStats(exchange.getIn(), responseModel, tableName);
         } else {
             throw new IllegalArgumentException("Unknown action " + action);
         }
@@ -48,7 +48,7 @@ class FujiServiceNowAggregateProcessor extends FujiServiceNowProcessor {
         setBodyAndHeaders(exchange.getIn(), responseModel, response);
     }
 
-    private Response retrieveStats(Message in, Class<?> requestModel, Class<?> responseModel, String tableName)
+    private Response retrieveStats(Message in, Class<?> responseModel, String tableName)
             throws Exception {
         final String apiVersion = getApiVersion(in);
 
diff --git a/components/camel-servicenow/camel-servicenow-component/src/main/java/org/apache/camel/component/servicenow/releases/fuji/FujiServiceNowImportSetProcessor.java b/components/camel-servicenow/camel-servicenow-component/src/main/java/org/apache/camel/component/servicenow/releases/fuji/FujiServiceNowImportSetProcessor.java
index fb43991afd6..61666c0eff7 100644
--- a/components/camel-servicenow/camel-servicenow-component/src/main/java/org/apache/camel/component/servicenow/releases/fuji/FujiServiceNowImportSetProcessor.java
+++ b/components/camel-servicenow/camel-servicenow-component/src/main/java/org/apache/camel/component/servicenow/releases/fuji/FujiServiceNowImportSetProcessor.java
@@ -39,7 +39,7 @@ class FujiServiceNowImportSetProcessor extends FujiServiceNowProcessor {
             throws Exception {
         Response response;
         if (ObjectHelper.equal(ServiceNowConstants.ACTION_RETRIEVE, action, true)) {
-            response = retrieveRecord(exchange.getIn(), requestModel, responseModel, apiVersion, tableName, sysId);
+            response = retrieveRecord(responseModel, apiVersion, tableName, sysId);
         } else if (ObjectHelper.equal(ServiceNowConstants.ACTION_CREATE, action, true)) {
             response = createRecord(exchange.getIn(), requestModel, responseModel, apiVersion, tableName);
         } else {
@@ -54,7 +54,7 @@ class FujiServiceNowImportSetProcessor extends FujiServiceNowProcessor {
      * https://instance.service-now.com/api/now/import/{tableName}/{sys_id}
      */
     private Response retrieveRecord(
-            Message in, Class<?> requestModel, Class<?> responseModel, String apiVersion, String tableName, String sysId)
+            Class<?> responseModel, String apiVersion, String tableName, String sysId)
             throws Exception {
         return client.reset()
                 .types(MediaType.APPLICATION_JSON_TYPE)
diff --git a/components/camel-servicenow/camel-servicenow-component/src/main/java/org/apache/camel/component/servicenow/releases/fuji/FujiServiceNowTableProcessor.java b/components/camel-servicenow/camel-servicenow-component/src/main/java/org/apache/camel/component/servicenow/releases/fuji/FujiServiceNowTableProcessor.java
index 4ff845e8d0c..eee60d3766c 100644
--- a/components/camel-servicenow/camel-servicenow-component/src/main/java/org/apache/camel/component/servicenow/releases/fuji/FujiServiceNowTableProcessor.java
+++ b/components/camel-servicenow/camel-servicenow-component/src/main/java/org/apache/camel/component/servicenow/releases/fuji/FujiServiceNowTableProcessor.java
@@ -39,13 +39,13 @@ class FujiServiceNowTableProcessor extends FujiServiceNowProcessor {
             throws Exception {
         Response response;
         if (ObjectHelper.equal(ServiceNowConstants.ACTION_RETRIEVE, action, true)) {
-            response = retrieveRecord(exchange.getIn(), requestModel, responseModel, apiVersion, tableName, sysId);
+            response = retrieveRecord(exchange.getIn(), responseModel, apiVersion, tableName, sysId);
         } else if (ObjectHelper.equal(ServiceNowConstants.ACTION_CREATE, action, true)) {
             response = createRecord(exchange.getIn(), requestModel, responseModel, apiVersion, tableName);
         } else if (ObjectHelper.equal(ServiceNowConstants.ACTION_MODIFY, action, true)) {
             response = modifyRecord(exchange.getIn(), requestModel, responseModel, apiVersion, tableName, sysId);
         } else if (ObjectHelper.equal(ServiceNowConstants.ACTION_DELETE, action, true)) {
-            response = deleteRecord(exchange.getIn(), requestModel, responseModel, apiVersion, tableName, sysId);
+            response = deleteRecord(responseModel, apiVersion, tableName, sysId);
         } else if (ObjectHelper.equal(ServiceNowConstants.ACTION_UPDATE, action, true)) {
             response = updateRecord(exchange.getIn(), requestModel, responseModel, apiVersion, tableName, sysId);
         } else {
@@ -61,7 +61,7 @@ class FujiServiceNowTableProcessor extends FujiServiceNowProcessor {
      * https://instance.service-now.com/api/now/table/{tableName}/{sys_id}
      */
     private Response retrieveRecord(
-            Message in, Class<?> requestModel, Class<?> responseModel, String apiVersion, String tableName, String sysId)
+            Message in, Class<?> responseModel, String apiVersion, String tableName, String sysId)
             throws Exception {
         return ObjectHelper.isEmpty(sysId)
                 ? client.reset()
@@ -147,7 +147,7 @@ class FujiServiceNowTableProcessor extends FujiServiceNowProcessor {
      * https://instance.service-now.com/api/now/table/{tableName}/{sys_id}
      */
     private Response deleteRecord(
-            Message in, Class<?> requestModel, Class<?> responseModel, String apiVersion, String tableName, String sysId)
+            Class<?> responseModel, String apiVersion, String tableName, String sysId)
             throws Exception {
         return client.reset()
                 .types(MediaType.APPLICATION_JSON_TYPE)