本文整理汇总了Java中com.sforce.soap.partner.Connector类的典型用法代码示例。如果您正苦于以下问题:Java Connector类的具体用法?Java Connector怎么用?Java Connector使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
Connector类属于com.sforce.soap.partner包,在下文中一共展示了Connector类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: createPartnerConnection
import com.sforce.soap.partner.Connector; //导入依赖的package包/类
private PartnerConnection createPartnerConnection() throws Exception {
ConnectorConfig config = new ConnectorConfig();
LOG.debug("Connecting SF Partner Connection using " + username);
config.setUsername(username);
config.setPassword(password);
String authEndpoint = getAuthEndpoint(loginURL);
LOG.info("loginURL : " + authEndpoint);
config.setAuthEndpoint(authEndpoint);
config.setServiceEndpoint(authEndpoint);
try {
return Connector.newConnection(config);
} catch (ConnectionException ce) {
LOG.error("Exception while creating connection", ce);
throw new Exception(ce);
}
}
示例2: createConnection
import com.sforce.soap.partner.Connector; //导入依赖的package包/类
private PartnerConnection createConnection() {
if (connection == null) {
PartnerConnectionConnectorConfig pcConnectorConfig = new PartnerConnectionConnectorConfig();
ConnectorConfig config = pcConnectorConfig.createConfig();
LOG.debug("creating connection for : " + CommandLineArguments.getUsername() + " "
+ CommandLineArguments.getOrgUrl() + " "
+ config.getUsername() + " " + config.getAuthEndpoint());
try {
connection = Connector.newConnection(config);
setSessionIdFromConnectorConfig(config);
LOG.debug("Partner Connection established with the org!! \n SESSION ID IN createPartnerConn: "
+ sessionIdFromConnectorConfig);
} catch (ConnectionException connEx) {
ApexUnitUtils.shutDownWithDebugLog(connEx, ConnectionHandler
.logConnectionException(connEx, connection));
}
}
return connection;
}
示例3: getConnection
import com.sforce.soap.partner.Connector; //导入依赖的package包/类
/**
* Ges the Connection to SalesForce using the WSC wrapper
*
* @param _session
* @param argStruct
* @return
* @throws cfmRunTimeException
* @throws ConnectionException
*/
protected PartnerConnection getConnection(cfSession _session, cfArgStructData argStruct) throws cfmRunTimeException, ConnectionException {
String email = getNamedStringParam(argStruct, "email", null );
if ( email == null )
throwException( _session, "email was not properly defined" );
String passwordtoken = getNamedStringParam(argStruct, "passwordtoken", null );
if ( passwordtoken == null )
throwException( _session, "passwordtoken was not properly defined" );
// Make the connection to SalesForce
ConnectorConfig config = new ConnectorConfig();
config.setUsername(email);
config.setPassword(passwordtoken);
int timeout = getNamedIntParam(argStruct, "timeout", -1 );
if ( timeout > 0 )
config.setReadTimeout(timeout);
return Connector.newConnection(config);
}
示例4: fetchSFDCinfo
import com.sforce.soap.partner.Connector; //导入依赖的package包/类
/**
* Fetching the Salesforce UserInfo along with session id.
* @return
*/
public static SFDCInfo fetchSFDCinfo() {
App.logInfo("Fetching SalesForce Data");
if(App.sfdcInfo.getSessionId() != null) return App.sfdcInfo;
try {
ConnectorConfig config = new ConnectorConfig();
config.setUsername(App.getUserName());
config.setPassword(App.getUserPassword() + App.getSecurityToken());
config.setAuthEndpoint(App.getPartnerUrl());
partnerConnection = Connector.newConnection(config);
GetUserInfoResult userInfo = partnerConnection.getUserInfo();
App.sfdcInfo.setOrg(userInfo.getOrganizationId());
App.sfdcInfo.setUserId(userInfo.getUserId());
App.sfdcInfo.setSessionId(config.getSessionId());
String sept = config.getServiceEndpoint();
sept = sept.substring(0, sept.indexOf(".com") + 4);
App.sfdcInfo.setEndpoint(sept);
App.logInfo("SDCF Info:\n" + App.sfdcInfo.toString());
return App.sfdcInfo;
} catch (ConnectionException ce) {
ce.printStackTrace();
return null;
}
}
示例5: login
import com.sforce.soap.partner.Connector; //导入依赖的package包/类
/**
* Method to login to an org with just a username and password.
*
* @param username the org username.
* @param password the org password.
* @return LoginResult a class that can be used to get a session token.
* @throws LoginException
*/
public LoginResult login(String username, String password) throws ApiLoginException {
if (this.res != null && username.equals(lastuser)){
return this.res;
}
LoginResult loginResult = null;
try{
PartnerConnection partnerConnection = Connector.newConnection(partnerConfig);
loginResult = partnerConnection.login(username, password);
} catch (Exception e){
throw new ApiLoginException(e);
}
this.res = loginResult;
this.lastuser = username;
return loginResult;
}
示例6: setUp
import com.sforce.soap.partner.Connector; //导入依赖的package包/类
@Override
protected void setUp() throws Exception {
super.setUp();
Properties properties = new Properties();
File file = new File(getPropertyFilePath());
if (file.exists()) {
properties.load(new FileReader(file));
_username = properties.getProperty("salesforce.username");
_password = properties.getProperty("salesforce.password");
_securityToken = properties.getProperty("salesforce.securityToken");
_endpoint = properties.getProperty("salesforce.endpoint", Connector.END_POINT);
_configured = (_username != null && !_username.isEmpty());
} else {
_configured = false;
}
}
示例7: renewSession
import com.sforce.soap.partner.Connector; //导入依赖的package包/类
@Override
public SessionRenewalHeader renewSession(ConnectorConfig config) throws ConnectionException {
LOG.info("Renewing Salesforce session");
try {
partnerConnection = Connector.newConnection(ForceUtils.getPartnerConfig(conf, new ForceSessionRenewer()));
} catch (StageException e) {
throw new ConnectionException("Can't create partner config", e);
}
SessionRenewalHeader header = new SessionRenewalHeader();
header.name = new QName("urn:enterprise.soap.sforce.com", "SessionHeader");
header.headerElement = partnerConnection.getSessionHeader();
return header;
}
示例8: renewSession
import com.sforce.soap.partner.Connector; //导入依赖的package包/类
@Override
public SessionRenewalHeader renewSession(ConnectorConfig config) throws ConnectionException {
try {
partnerConnection = Connector.newConnection(ForceUtils.getPartnerConfig(conf, new ForceSessionRenewer()));
} catch (StageException e) {
throw new ConnectionException("Can't create partner config", e);
}
SessionRenewalHeader header = new SessionRenewalHeader();
header.name = new QName("urn:enterprise.soap.sforce.com", "SessionHeader");
header.headerElement = partnerConnection.getSessionHeader();
return header;
}
示例9: renewSession
import com.sforce.soap.partner.Connector; //导入依赖的package包/类
@Override
public SessionRenewalHeader renewSession(ConnectorConfig config) throws ConnectionException {
try {
connection = Connector.newConnection(ForceUtils.getPartnerConfig(conf, new WaveSessionRenewer()));
} catch (StageException e) {
throw new ConnectionException("Can't create partner config", e);
}
SessionRenewalHeader header = new SessionRenewalHeader();
header.name = new QName("urn:enterprise.soap.sforce.com", "SessionHeader");
header.headerElement = connection.getSessionHeader();
return header;
}
示例10: init
import com.sforce.soap.partner.Connector; //导入依赖的package包/类
/**
* {@inheritDoc}
*/
@Override
protected List<ConfigIssue> init() {
// Validate configuration values and open any required resources.
List<ConfigIssue> issues = super.init();
Optional
.ofNullable(conf.init(getContext(), CONF_PREFIX ))
.ifPresent(issues::addAll);
try {
ConnectorConfig partnerConfig = ForceUtils.getPartnerConfig(conf, new WaveSessionRenewer());
connection = Connector.newConnection(partnerConfig);
LOG.info("Successfully authenticated as {}", conf.username);
if (conf.mutualAuth.useMutualAuth) {
ForceUtils.setupMutualAuth(partnerConfig, conf.mutualAuth);
}
String soapEndpoint = connection.getConfig().getServiceEndpoint();
restEndpoint = soapEndpoint.substring(0, soapEndpoint.indexOf("services/Soap/"));
httpClient = new HttpClient(ForceUtils.makeSslContextFactory(conf));
if (conf.useProxy) {
ForceUtils.setProxy(httpClient, conf);
}
httpClient.start();
} catch (Exception e) {
LOG.error("Exception during init()", e);
issues.add(getContext().createConfigIssue(Groups.FORCE.name(),
ForceConfigBean.CONF_PREFIX + "authEndpoint",
Errors.WAVE_00,
ForceUtils.getExceptionCode(e) + ", " + ForceUtils.getExceptionMessage(e)
));
}
// If issues is not empty, the UI will inform the user of each configuration issue in the list.
return issues;
}
示例11: loginToSalesforce
import com.sforce.soap.partner.Connector; //导入依赖的package包/类
private static LoginResult loginToSalesforce() throws ConnectionException {
if(App.sfdcInfo.getLoginResult() == null) {
ConnectorConfig config = new ConnectorConfig();
config.setAuthEndpoint(App.getPartnerUrl());
config.setUsername(App.getUserName());
config.setPassword(App.getUserPassword() + App.getSecurityToken());
partnerConnection = Connector.newConnection(config);
return partnerConnection.login(App.getUserName(), App.getUserPassword() + App.getSecurityToken());
}
else
return App.sfdcInfo.getLoginResult();
}
示例12: SalesforceDataContext
import com.sforce.soap.partner.Connector; //导入依赖的package包/类
public SalesforceDataContext(String endpoint, String username, String password, String securityToken) {
super(false);
try {
final ConnectorConfig config = new ConnectorConfig();
config.setUsername(username);
config.setPassword(securityToken == null ? password : password + securityToken);
if (endpoint != null) {
config.setAuthEndpoint(endpoint);
config.setServiceEndpoint(endpoint);
}
_connection = Connector.newConnection(config);
} catch (ConnectionException e) {
throw SalesforceUtils.wrapException(e, "Failed to log in to Salesforce service");
}
}
示例13: testCreateBinding
import com.sforce.soap.partner.Connector; //导入依赖的package包/类
@Test
public void testCreateBinding() throws KettleException, ConnectionException {
SalesforceConnection conn = new SalesforceConnection( null, "http://localhost:1234", "aUser", "aPass" );
ConnectorConfig config = new ConnectorConfig();
config.setAuthEndpoint( Connector.END_POINT );
config.setManualLogin( true ); // Required to prevent connection attempt during test
assertNull( conn.getBinding() );
conn.createBinding( config );
PartnerConnection binding1 = conn.getBinding();
conn.createBinding( config );
PartnerConnection binding2 = conn.getBinding();
assertSame( binding1, binding2 );
}
示例14: transaction
import com.sforce.soap.partner.Connector; //导入依赖的package包/类
@Override
public ConfigDiff transaction(ConfigSource config,
Schema schema, int taskCount,
OutputPlugin.Control control)
{
PluginTask task = config.loadConfig(PluginTask.class);
logger = Exec.getLogger(getClass());
if (task.getResultDir().isPresent() && task.getResultDir().get() != null) {
File resultDir = new File(task.getResultDir().get());
if (!resultDir.exists() || !resultDir.isDirectory()) {
logger.error("{} is not exist or is not directory.", task.getResultDir().get());
throw new RuntimeException(task.getResultDir().get() + " is not exist or is not directory.");
}
}
final String username = task.getUsername();
final String password = task.getPassword();
final String loginEndpoint = task.getLoginEndpoint().get();
try {
if (client == null) {
ConnectorConfig connectorConfig = new ConnectorConfig();
connectorConfig.setUsername(username);
connectorConfig.setPassword(password);
connectorConfig.setAuthEndpoint(loginEndpoint + "/services/Soap/u/" +task.getVersion().get() + "/");
client = Connector.newConnection(connectorConfig);
GetUserInfoResult userInfo = client.getUserInfo();
logger.info("login successful with {}", userInfo.getUserName());
externalIdToObjectNameMap = new HashMap<>();
DescribeSObjectResult describeResult = client.describeSObject(task.getSObject());
for (Field field : describeResult.getFields()) {
if (field.getType() == FieldType.reference) {
externalIdToObjectNameMap.put(field.getRelationshipName(), field.getReferenceTo()[0]);
}
}
}
} catch(ConnectionException ex) {
logger.error("Login error. Please check your credentials.");
throw new RuntimeException(ex);
}
control.run(task.dump());
return Exec.newConfigDiff();
}
示例15: init
import com.sforce.soap.partner.Connector; //导入依赖的package包/类
/**
* {@inheritDoc}
*/
@Override
protected List<ConfigIssue> init() {
// Validate configuration values and open any required resources.
List<ConfigIssue> issues = super.init();
Target.Context context = getContext();
Optional
.ofNullable(conf.init(context, CONF_PREFIX))
.ifPresent(issues::addAll);
errorRecordHandler = new DefaultErrorRecordHandler(context);
sObjectNameVars = getContext().createELVars();
sObjectNameEval = context.createELEval(SOBJECT_NAME);
ELUtils.validateExpression(sObjectNameEval,
sObjectNameVars,
conf.sObjectNameTemplate,
context,
Groups.FORCE.getLabel(),
SOBJECT_NAME,
Errors.FORCE_12,
String.class,
issues
);
externalIdFieldVars = getContext().createELVars();
externalIdFieldEval = context.createELEval(EXTERNAL_ID_NAME);
ELUtils.validateExpression(externalIdFieldEval,
externalIdFieldVars,
conf.externalIdField,
context,
Groups.FORCE.getLabel(),
EXTERNAL_ID_NAME,
Errors.FORCE_24,
String.class,
issues
);
if (issues.isEmpty()) {
fieldMappings = new TreeMap<>();
for (ForceFieldMapping mapping : conf.fieldMapping) {
// SDC-7446 Allow colon as well as period as field separator
String salesforceField = conf.useBulkAPI
? mapping.salesforceField.replace(':', '.')
: mapping.salesforceField;
fieldMappings.put(salesforceField, mapping.sdcField);
}
try {
ConnectorConfig partnerConfig = ForceUtils.getPartnerConfig(conf, new ForceSessionRenewer());
partnerConnection = Connector.newConnection(partnerConfig);
if (conf.mutualAuth.useMutualAuth) {
ForceUtils.setupMutualAuth(partnerConfig, conf.mutualAuth);
}
bulkConnection = ForceUtils.getBulkConnection(partnerConfig, conf);
LOG.info("Successfully authenticated as {}", conf.username);
} catch (ConnectionException | AsyncApiException | StageException | URISyntaxException ce) {
LOG.error("Can't connect to SalesForce", ce);
issues.add(getContext().createConfigIssue(Groups.FORCE.name(),
"connectorConfig",
Errors.FORCE_00,
ForceUtils.getExceptionCode(ce) + ", " + ForceUtils.getExceptionMessage(ce)
));
}
if (conf.useBulkAPI) {
writer = new ForceBulkWriter(fieldMappings, bulkConnection, getContext());
} else {
writer = new ForceSoapWriter(fieldMappings, partnerConnection);
}
}
// If issues is not empty, the UI will inform the user of each configuration issue in the list.
return issues;
}