You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@hop.apache.org by ha...@apache.org on 2026/03/19 10:49:09 UTC

(hop) branch main updated: added api version option in Salesforce connection metadata type. #6561 (#6830)

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

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


The following commit(s) were added to refs/heads/main by this push:
     new d1ef93d8f1 added api version option in Salesforce connection metadata type. #6561 (#6830)
d1ef93d8f1 is described below

commit d1ef93d8f17c87f9a18d73e60f7f6979522b43b4
Author: Bart Maertens <ba...@know.bi>
AuthorDate: Thu Mar 19 10:49:05 2026 +0000

    added api version option in Salesforce connection metadata type. #6561 (#6830)
---
 .../metadata/salesforce/SalesforceConnection.java  | 20 +++++++++--
 .../salesforce/SalesforceConnectionEditor.java     | 40 +++++++++++++++++++++-
 .../salesforce/SalesforceConnection.java           | 14 +++++---
 .../salesforce/messages/messages_en_US.properties  |  4 +++
 4 files changed, 71 insertions(+), 7 deletions(-)

diff --git a/plugins/tech/salesforce/src/main/java/org/apache/hop/metadata/salesforce/SalesforceConnection.java b/plugins/tech/salesforce/src/main/java/org/apache/hop/metadata/salesforce/SalesforceConnection.java
index aa9f083a0f..0fc3894c60 100644
--- a/plugins/tech/salesforce/src/main/java/org/apache/hop/metadata/salesforce/SalesforceConnection.java
+++ b/plugins/tech/salesforce/src/main/java/org/apache/hop/metadata/salesforce/SalesforceConnection.java
@@ -93,6 +93,9 @@ public class SalesforceConnection extends HopMetadataBase implements IHopMetadat
   @HopMetadataProperty(key = "oauth_jwt_token_endpoint", injectionKey = "OAUTH_JWT_TOKEN_ENDPOINT")
   private String oauthJwtTokenEndpoint = "https://login.salesforce.com";
 
+  @HopMetadataProperty(key = "oauth_api_version", injectionKey = "OAUTH_API_VERSION")
+  private String oauthApiVersion = "64.0";
+
   public SalesforceConnection() {
     super();
   }
@@ -158,6 +161,8 @@ public class SalesforceConnection extends HopMetadataBase implements IHopMetadat
         connection.setOauthRefreshToken(refreshToken);
       }
 
+      connection.setApiVersion(variables.resolve(this.oauthApiVersion));
+
       return connection;
     } else if (isOAuthJwtAuthentication()) {
       // Resolve OAuth JWT variables
@@ -167,8 +172,11 @@ public class SalesforceConnection extends HopMetadataBase implements IHopMetadat
           org.apache.hop.core.util.Utils.resolvePassword(variables, this.oauthJwtPrivateKey);
       String jwtTokenEndpoint = variables.resolve(this.oauthJwtTokenEndpoint);
 
-      return org.apache.hop.pipeline.transforms.salesforce.SalesforceConnection.createJwtConnection(
-          log, jwtUsername, jwtConsumerKey, jwtPrivateKey, jwtTokenEndpoint);
+      org.apache.hop.pipeline.transforms.salesforce.SalesforceConnection jwtConnection =
+          org.apache.hop.pipeline.transforms.salesforce.SalesforceConnection.createJwtConnection(
+              log, jwtUsername, jwtConsumerKey, jwtPrivateKey, jwtTokenEndpoint);
+      jwtConnection.setApiVersion(variables.resolve(this.oauthApiVersion));
+      return jwtConnection;
     } else {
       // Resolve username/password variables
       String url = variables.resolve(this.targetUrl);
@@ -337,6 +345,14 @@ public class SalesforceConnection extends HopMetadataBase implements IHopMetadat
     this.oauthJwtTokenEndpoint = oauthJwtTokenEndpoint;
   }
 
+  public String getOauthApiVersion() {
+    return oauthApiVersion;
+  }
+
+  public void setOauthApiVersion(String oauthApiVersion) {
+    this.oauthApiVersion = oauthApiVersion;
+  }
+
   /**
    * Validate that the private key is in an acceptable format for security
    *
diff --git a/plugins/tech/salesforce/src/main/java/org/apache/hop/metadata/salesforce/SalesforceConnectionEditor.java b/plugins/tech/salesforce/src/main/java/org/apache/hop/metadata/salesforce/SalesforceConnectionEditor.java
index 5d7b86d666..96d4d57def 100644
--- a/plugins/tech/salesforce/src/main/java/org/apache/hop/metadata/salesforce/SalesforceConnectionEditor.java
+++ b/plugins/tech/salesforce/src/main/java/org/apache/hop/metadata/salesforce/SalesforceConnectionEditor.java
@@ -80,6 +80,7 @@ public class SalesforceConnectionEditor extends MetadataEditor<SalesforceConnect
   private PasswordTextVar wOAuthRefreshToken;
   private Button wOAuthAuthorize;
   private Button wOAuthExchange;
+  private LabelTextVar wOAuthApiVersion;
 
   // OAuth JWT Group
   private Group wOAuthJwtGroup;
@@ -87,6 +88,7 @@ public class SalesforceConnectionEditor extends MetadataEditor<SalesforceConnect
   private TextVar wOAuthJwtConsumerKey;
   private PasswordTextVar wOAuthJwtPrivateKey;
   private TextVar wOAuthJwtTokenEndpoint;
+  private LabelTextVar wOAuthJwtApiVersion;
 
   // Test button
   private Button wTest;
@@ -392,6 +394,20 @@ public class SalesforceConnectionEditor extends MetadataEditor<SalesforceConnect
     wOAuthExchange.setLayoutData(fdOAuthExchange);
     wOAuthExchange.addListener(SWT.Selection, e -> exchangeCodeForTokens());
 
+    // OAuth API Version
+    wOAuthApiVersion =
+        new LabelTextVar(
+            variables,
+            wOAuthGroup,
+            BaseMessages.getString(PKG, "SalesforceConnectionEditor.OAuthApiVersion"),
+            BaseMessages.getString(PKG, "SalesforceConnectionEditor.OAuthApiVersion.Tooltip"));
+    PropsUi.setLook(wOAuthApiVersion);
+    FormData fdOAuthApiVersion = new FormData();
+    fdOAuthApiVersion.left = new FormAttachment(0, 0);
+    fdOAuthApiVersion.top = new FormAttachment(wOAuthExchange, margin);
+    fdOAuthApiVersion.right = new FormAttachment(100, 0);
+    wOAuthApiVersion.setLayoutData(fdOAuthApiVersion);
+
     FormData fdOAuthGroup = new FormData();
     fdOAuthGroup.left = new FormAttachment(0, 0);
     fdOAuthGroup.right = new FormAttachment(100, 0);
@@ -524,6 +540,20 @@ public class SalesforceConnectionEditor extends MetadataEditor<SalesforceConnect
     fdOAuthJwtTokenEndpoint.right = new FormAttachment(100, 0);
     wOAuthJwtTokenEndpoint.setLayoutData(fdOAuthJwtTokenEndpoint);
 
+    // OAuth JWT API Version
+    wOAuthJwtApiVersion =
+        new LabelTextVar(
+            variables,
+            wOAuthJwtGroup,
+            BaseMessages.getString(PKG, "SalesforceConnectionEditor.OAuthApiVersion"),
+            BaseMessages.getString(PKG, "SalesforceConnectionEditor.OAuthApiVersion.Tooltip"));
+    PropsUi.setLook(wOAuthJwtApiVersion);
+    FormData fdOAuthJwtApiVersion = new FormData();
+    fdOAuthJwtApiVersion.left = new FormAttachment(0, 0);
+    fdOAuthJwtApiVersion.top = new FormAttachment(wOAuthJwtTokenEndpoint, margin);
+    fdOAuthJwtApiVersion.right = new FormAttachment(100, 0);
+    wOAuthJwtApiVersion.setLayoutData(fdOAuthJwtApiVersion);
+
     FormData fdOAuthJwtGroup = new FormData();
     fdOAuthJwtGroup.left = new FormAttachment(0, 0);
     fdOAuthJwtGroup.right = new FormAttachment(100, 0);
@@ -569,10 +599,12 @@ public class SalesforceConnectionEditor extends MetadataEditor<SalesforceConnect
       wOAuthInstanceUrl.getTextWidget(),
       wOAuthAccessToken.getTextWidget(),
       wOAuthRefreshToken.getTextWidget(),
+      wOAuthApiVersion.getTextWidget(),
       wOAuthJwtUsername,
       wOAuthJwtConsumerKey,
       wOAuthJwtPrivateKey.getTextWidget(),
-      wOAuthJwtTokenEndpoint
+      wOAuthJwtTokenEndpoint,
+      wOAuthJwtApiVersion.getTextWidget()
     };
     for (Control control : controls) {
       control.addListener(SWT.Modify, e -> setChanged());
@@ -1157,6 +1189,10 @@ public class SalesforceConnectionEditor extends MetadataEditor<SalesforceConnect
     wOAuthJwtTokenEndpoint.setText(
         Const.NVL(metadata.getOauthJwtTokenEndpoint(), "https://login.salesforce.com"));
 
+    String apiVersion = Const.NVL(metadata.getOauthApiVersion(), "64.0");
+    wOAuthApiVersion.setText(apiVersion);
+    wOAuthJwtApiVersion.setText(apiVersion);
+
     // Update UI and force layout refresh
     updateAuthenticationUI();
 
@@ -1181,8 +1217,10 @@ public class SalesforceConnectionEditor extends MetadataEditor<SalesforceConnect
     int selectedIndex = wAuthType.getSelectionIndex();
     if (selectedIndex == 1) {
       connection.setAuthenticationType("OAUTH");
+      connection.setOauthApiVersion(wOAuthApiVersion.getText());
     } else if (selectedIndex == 2) {
       connection.setAuthenticationType("OAUTH_JWT");
+      connection.setOauthApiVersion(wOAuthJwtApiVersion.getText());
     } else {
       connection.setAuthenticationType("USERNAME_PASSWORD");
     }
diff --git a/plugins/tech/salesforce/src/main/java/org/apache/hop/pipeline/transforms/salesforce/SalesforceConnection.java b/plugins/tech/salesforce/src/main/java/org/apache/hop/pipeline/transforms/salesforce/SalesforceConnection.java
index 7f5c08f4d6..9c55e279ac 100644
--- a/plugins/tech/salesforce/src/main/java/org/apache/hop/pipeline/transforms/salesforce/SalesforceConnection.java
+++ b/plugins/tech/salesforce/src/main/java/org/apache/hop/pipeline/transforms/salesforce/SalesforceConnection.java
@@ -95,6 +95,7 @@ public class SalesforceConnection {
   private String oauthRefreshToken;
   private String oauthInstanceUrl;
   private String oauthJwtPrivateKey;
+  private String apiVersion = "64.0";
   private String sql;
   private Date serverTimestamp;
   private QueryResult qr;
@@ -327,6 +328,11 @@ public class SalesforceConnection {
     this.useCompression = useCompression;
   }
 
+  private String getSoapApiPath() {
+    String v = Utils.isEmpty(apiVersion) ? "64.0" : apiVersion;
+    return "/services/Soap/u/" + v;
+  }
+
   public boolean isOAuthAuthentication() {
     return "OAUTH".equalsIgnoreCase(authenticationType);
   }
@@ -547,8 +553,8 @@ public class SalesforceConnection {
 
       // For OAuth, we need to create a proper SOAP binding with OAuth authentication
       ConnectorConfig config = new ConnectorConfig();
-      config.setAuthEndpoint(getOauthInstanceUrl() + SERVICES_SOAP_U_64_0);
-      config.setServiceEndpoint(getOauthInstanceUrl() + SERVICES_SOAP_U_64_0);
+      config.setAuthEndpoint(getOauthInstanceUrl() + getSoapApiPath());
+      config.setServiceEndpoint(getOauthInstanceUrl() + getSoapApiPath());
       config.setManualLogin(true);
 
       // Set OAuth session ID (access token) for authentication
@@ -601,8 +607,8 @@ public class SalesforceConnection {
 
       // Create SOAP binding with JWT-acquired access token
       ConnectorConfig config = new ConnectorConfig();
-      config.setAuthEndpoint(instanceUrl + SERVICES_SOAP_U_64_0);
-      config.setServiceEndpoint(instanceUrl + SERVICES_SOAP_U_64_0);
+      config.setAuthEndpoint(instanceUrl + getSoapApiPath());
+      config.setServiceEndpoint(instanceUrl + getSoapApiPath());
       config.setManualLogin(true);
       config.setSessionId(accessToken);
       config.setCompression(isUsingCompression());
diff --git a/plugins/tech/salesforce/src/main/resources/org/apache/hop/metadata/salesforce/messages/messages_en_US.properties b/plugins/tech/salesforce/src/main/resources/org/apache/hop/metadata/salesforce/messages/messages_en_US.properties
index cd72f132c8..2a50925859 100644
--- a/plugins/tech/salesforce/src/main/resources/org/apache/hop/metadata/salesforce/messages/messages_en_US.properties
+++ b/plugins/tech/salesforce/src/main/resources/org/apache/hop/metadata/salesforce/messages/messages_en_US.properties
@@ -71,6 +71,10 @@ SalesforceConnectionEditor.OAuthJwtLoadKey.Error=Error loading private key from
 SalesforceConnectionEditor.OAuthJwtTokenEndpoint=Token Endpoint
 SalesforceConnectionEditor.OAuthJwtTokenEndpoint.Tooltip=Salesforce token endpoint (https://login.salesforce.com or https://test.salesforce.com for sandbox)
 
+# API Version (OAuth and OAuth JWT)
+SalesforceConnectionEditor.OAuthApiVersion=API Version
+SalesforceConnectionEditor.OAuthApiVersion.Tooltip=Salesforce API version for the SOAP endpoint (e.g., 64.0)
+
 # Buttons
 SalesforceConnectionEditor.OAuthAuthorize=Authorize
 SalesforceConnectionEditor.OAuthAuthorize.Tooltip=Start OAuth authorization flow