Skip to content

Commit

Permalink
TEIID-5082 fixing the default url and adding a version check
Browse files Browse the repository at this point in the history
  • Loading branch information
shawkins committed Sep 27, 2017
1 parent 797369e commit 301299c
Show file tree
Hide file tree
Showing 5 changed files with 22 additions and 5 deletions.
Expand Up @@ -22,12 +22,15 @@
package org.teiid.resource.adapter.salesforce;

import javax.resource.ResourceException;
import javax.security.auth.Subject;

import org.teiid.core.TeiidRuntimeException;
import org.teiid.logging.LogConstants;
import org.teiid.logging.LogManager;
import org.teiid.resource.spi.BasicConnectionFactory;
import org.teiid.resource.spi.BasicManagedConnectionFactory;
import org.teiid.resource.spi.ConnectionContext;
import org.teiid.translator.salesforce.SalesForcePlugin;

import com.sforce.soap.partner.Connector;


public class SalesForceManagedConnectionFactory extends BasicManagedConnectionFactory {
Expand All @@ -46,6 +49,8 @@ public class SalesForceManagedConnectionFactory extends BasicManagedConnectionFa
private String configProperties;
private String configFile; // path to the "jbossws-cxf.xml" file

private boolean warned;

public String getUsername() {
return username;
}
Expand Down Expand Up @@ -169,5 +174,14 @@ && checkEquals(this.proxyUsername, other.proxyUsername)
&& checkEquals(this.proxyPassword, other.proxyPassword)
&& checkEquals(this.configProperties, other.configProperties);
}
public void checkVersion(String apiVersion) {
if (!warned) {
warned = true;
String javaApiVersion = Connector.END_POINT.substring(Connector.END_POINT.lastIndexOf('/') + 1, Connector.END_POINT.length());
if (!javaApiVersion.equals(apiVersion)) {
LogManager.logWarning(LogConstants.CTX_CONNECTOR, SalesForcePlugin.Util.gs(SalesForcePlugin.Event.TEIID13009, apiVersion, javaApiVersion));
}
}
}

}
Expand Up @@ -165,6 +165,7 @@ private void login(SalesForceManagedConnectionFactory mcf) throws ResourceExcept
int index = endpoint.indexOf("Soap/u/"); //$NON-NLS-1$
int endIndex = endpoint.indexOf('/', index+7);
apiVersion = endpoint.substring(index+7,endIndex);
mcf.checkVersion(apiVersion);
String bulkEndpoint = endpoint.substring(0, endpoint.indexOf("Soap/"))+ "async/" + apiVersion;//$NON-NLS-1$ //$NON-NLS-2$
config.setRestEndpoint(bulkEndpoint);
// This value identifies Teiid as a SF certified solution.
Expand Down
Expand Up @@ -56,7 +56,7 @@
<description>{$display:"Salesforce URL",$description:"URL for connecting to Salesforce",$advanced:"true"}</description>
<config-property-name>URL</config-property-name>
<config-property-type>java.lang.String</config-property-type>
<config-property-value>https://www.salesforce.com/services/Soap/u/34.0</config-property-value>
<config-property-value>https://www.salesforce.com/services/Soap/u/22.0</config-property-value>
</config-property>

<config-property>
Expand Down
Expand Up @@ -49,6 +49,7 @@ public static enum Event implements BundleUtil.Event{
TEIID13005,
TEIID13006,
TEIID13007,
TEIID13008,
TEIID13008,
TEIID13009,
}
}
Expand Up @@ -43,4 +43,5 @@ TEIID13004=The query is missing type, id and attribute values.
TEIID13005=The attribute count does not match with the value parameters supplied.
TEIID13006=columns.size and values.size are not the same
TEIID13007=Only literal values are supported in the insert, expressions are not allowed.
TEIID13008=The delete criteria is not a CompareCriteria
TEIID13008=The delete criteria is not a CompareCriteria
TEIID13009=Accessing remote API version {0} with Java API version {1} may not be compatible.

0 comments on commit 301299c

Please sign in to comment.