本文整理汇总了Java中com.sforce.soap.partner.Connector类的典型用法代码示例。如果您正苦于以下问题:Java Connector类的具体用法?Java Connector怎么用?Java Connector使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
Connector类属于com.sforce.soap.partner包,在下文中一共展示了Connector类的16个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的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);
}
}
开发者ID:springml,项目名称:salesforce-wave-api,代码行数:18,代码来源:SFConfig.java
示例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;
}
开发者ID:forcedotcom,项目名称:ApexUnit,代码行数:21,代码来源:ConnectionHandler.java
示例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);
}
开发者ID:OpenBD,项目名称:openbd-core,代码行数:30,代码来源:SalesForceBaseFunction.java
示例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;
}
}
开发者ID:sunand85,项目名称:DF14_Demo,代码行数:30,代码来源:SFDCUtil.java
示例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;
}
开发者ID:financialforcedev,项目名称:object-model-tool,代码行数:27,代码来源:ApiLoginModel.java
示例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;
}
}
开发者ID:apache,项目名称:metamodel,代码行数:19,代码来源:SalesforceTestCase.java
示例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;
}
开发者ID:streamsets,项目名称:datacollector,代码行数:16,代码来源:ForceSource.java
示例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;
}
开发者ID:streamsets,项目名称:datacollector,代码行数:14,代码来源:ForceLookupProcessor.java
示例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;
}
开发者ID:streamsets,项目名称:datacollector,代码行数:14,代码来源:WaveAnalyticsTarget.java
示例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;
}
开发者ID:streamsets,项目名称:datacollector,代码行数:40,代码来源:WaveAnalyticsTarget.java
示例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();
}
开发者ID:sunand85,项目名称:DF14_Demo,代码行数:13,代码来源:SFDCConnection.java
示例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");
}
}
开发者ID:apache,项目名称:metamodel,代码行数:16,代码来源:SalesforceDataContext.java
示例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 );
}
开发者ID:pentaho,项目名称:pentaho-kettle,代码行数:16,代码来源:SalesforceConnectionTest.java
示例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();
}
开发者ID:tzmfreedom,项目名称:embulk-output-salesforce,代码行数:46,代码来源:SalesforceOutputPlugin.java
示例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;
}
开发者ID:streamsets,项目名称:datacollector,代码行数:78,代码来源:ForceTarget.java
示例16: SMAConnection
import com.sforce.soap.partner.Connector; //导入依赖的package包/类
/**
* Constructor that sets up the connection to a Salesforce organization
*
* @param username
* @param password
* @param securityToken
* @param server
* @param pollWaitString
* @param maxPollString
* @param proxyServer
* @param proxyUser
* @param proxyPort
* @param proxyPass
* @throws Exception
*/
public SMAConnection(String username,
String password,
String securityToken,
String server,
String pollWaitString,
String maxPollString,
String proxyServer,
String proxyUser,
String proxyPass,
Integer proxyPort) throws Exception
{
System.setProperty("https.protocols", "TLSv1,TLSv1.1,TLSv1.2");
API_VERSION = Double.valueOf(SMAMetadataTypes.getAPIVersion());
this.pollWaitString = pollWaitString;
this.maxPollString = maxPollString;
String endpoint = server + "/services/Soap/u/" + String.valueOf(API_VERSION);
initConfig.setUsername(username);
initConfig.setPassword(password + securityToken);
initConfig.setAuthEndpoint(endpoint);
initConfig.setServiceEndpoint(endpoint);
initConfig.setManualLogin(true);
//Proxy support
if (!proxyServer.isEmpty()) {
initConfig.setProxy(proxyServer, proxyPort);
if (!proxyPass.isEmpty()) {
initConfig.setProxyUsername(proxyUser);
initConfig.setProxyPassword(proxyPass);
}
}
partnerConnection = Connector.newConnection(initConfig);
LoginResult loginResult = new LoginResult();
loginResult = partnerConnection.login(initConfig.getUsername(), initConfig.getPassword());
metadataConfig.setServiceEndpoint(loginResult.getMetadataServerUrl());
metadataConfig.setSessionId(loginResult.getSessionId());
metadataConfig.setProxy(initConfig.getProxy());
metadataConfig.setProxyUsername(initConfig.getProxyUsername());
metadataConfig.setProxyPassword(initConfig.getProxyPassword());
metadataConnection = new MetadataConnection(metadataConfig);
}
开发者ID:aesanch2,项目名称:salesforce-migration-assistant,代码行数:65,代码来源:SMAConnection.java
注:本文中的com.sforce.soap.partner.Connector类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论