本文整理汇总了Java中com.sforce.ws.ConnectionException类的典型用法代码示例。如果您正苦于以下问题:Java ConnectionException类的具体用法?Java ConnectionException怎么用?Java ConnectionException使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
ConnectionException类属于com.sforce.ws包,在下文中一共展示了ConnectionException类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: testSalesForcePasswordExpired
import com.sforce.ws.ConnectionException; //导入依赖的package包/类
@Test(expected = ConnectionException.class)
public void testSalesForcePasswordExpired() throws ConnectionException {
SalesforceSourceOrSink salesforceSourceOrSink = new SalesforceSourceOrSink();
TSalesforceInputProperties properties = (TSalesforceInputProperties) new TSalesforceInputProperties(null).init();
salesforceSourceOrSink.initialize(null, properties);
ConnectorConfig config = new ConnectorConfig();
config.setUsername(StringUtils.strip(USER_ID_EXPIRED, "\""));
String password = StringUtils.strip(PASSWORD_EXPIRED, "\"");
String securityKey = StringUtils.strip(SECURITY_KEY_EXPIRED, "\"");
if (StringUtils.isNotEmpty(securityKey)) {
password = password + securityKey;
}
config.setPassword(password);
PartnerConnection connection = null;
try {
connection = salesforceSourceOrSink.doConnection(config, true);
} catch (LoginFault ex) {
Assert.fail("Must be an exception related to expired password, not the Login Fault.");
} finally {
if (null != connection) {
connection.logout();
}
}
}
示例2: createRemoteSite
import com.sforce.ws.ConnectionException; //导入依赖的package包/类
public void createRemoteSite(RemoteSite rs)
throws ConnectionException, DeployException, AsyncApiException, Exception {
createMetadataConnection();
RemoteSiteSetting rss = new RemoteSiteSetting();
rss.setFullName(rs.fullName);
rss.setUrl(rs.url);
rss.setDescription(rs.description);
rss.setIsActive(true);
rss.setDisableProtocolSecurity(false);
com.sforce.soap.metadata.SaveResult[] results = getMetadataConnection().createMetadata(new Metadata[] { rss });
for (com.sforce.soap.metadata.SaveResult r : results) {
if (r.isSuccess()) {
System.out.println("Created component: " + r.getFullName());
} else {
throw new Exception(r.getErrors()[0].getMessage());
}
}
}
示例3: upsertData
import com.sforce.ws.ConnectionException; //导入依赖的package包/类
public DeployResponse upsertData(String IdField, List<SObject> sobjects)
throws ConnectionException, DeployException, AsyncApiException
{
DeployResponse dr = new DeployResponse();
// ensure the partner connection has been initialized
createPartnerConnection();
// check if the SObject queue is empty
if (sobjects == null || sobjects.isEmpty())
{
Utils.log("An empty list of SObject was passed to upsertData()!");
}
else
{
Utils.log(String.format("Upserting %d records with Id field [%s].", +sobjects.size(), IdField));
// upsert the records
com.sforce.soap.partner.UpsertResult[] URs = _pConn.upsert(IdField,
sobjects.toArray(new SObject[] {}));
// process the results and log errors
dr = SalesforceService.handleUpsertResponse(dr, URs);
}
return dr;
}
示例4: listCustomMetadata
import com.sforce.ws.ConnectionException; //导入依赖的package包/类
public static ArrayList<String> listCustomMetadata() {
MetadataConnection metadataConnection = CredentialsManager.mdConnection;
ArrayList<String> customMetadataList = null;
try {
ListMetadataQuery query = new ListMetadataQuery();
query.setType("CustomObject");
//query.setFolder(null);
double asOfVersion = 38.0;
// Assuming that the SOAP binding has already been established.
FileProperties[] lmr = metadataConnection.listMetadata(
new ListMetadataQuery[] {query}, asOfVersion);
if (lmr != null) {
customMetadataList = new ArrayList<>();
for (FileProperties n : lmr) {
if(n.toString().contains("_mdt")) {
customMetadataList.add(n.getFullName().replace("__mdt", "").trim());
}
}
}
} catch (ConnectionException ce) {
ce.printStackTrace();
}
return customMetadataList;
}
示例5: login
import com.sforce.ws.ConnectionException; //导入依赖的package包/类
public static MetadataConnection login()
throws ConnectionException, IOException {
final JSONObject jsonObj = new JSONObject(CommonUtils.readAllLine(CREDENTIALS_FILE));
final String username = CommonUtils.getUsername(jsonObj);
final String password = CommonUtils.getPassword(jsonObj);
final String orgType = CommonUtils.getOrgType(jsonObj);
final Double apiVersion = CommonUtils.getApiVersion(jsonObj);
final String authEndPoint = CommonUtils.getAuthEndPoint(orgType, apiVersion);
final LoginResult loginResult = loginToSalesforce(username, password, authEndPoint);
System.out.println("userName: " + loginResult.getUserInfo().getUserName());
System.out.println("sessionId: " + loginResult.getSessionId());
final MetadataConnection metadataConnection = createMetadataConnection(loginResult);
return metadataConnection;
}
示例6: handleException
import com.sforce.ws.ConnectionException; //导入依赖的package包/类
protected void handleException(Exception e) throws BuildException {
String message = "";
if (e instanceof InvalidSObjectFault) {
message = e.getLocalizedMessage();
} else if (e instanceof ConnectionException) {
message = "Unable to connect to Salesforce";
} else {
message = e.getLocalizedMessage();
}
if (!getIgnoreErrors()) {
throw new BuildException(message, e);
} else {
error = true;
log("Ignored error: " + message);
}
}
示例7: execute
import com.sforce.ws.ConnectionException; //导入依赖的package包/类
@Override
public void execute() throws BuildException {
checkAttributes();
// prepare where clause
try {
SalesforceConfig conf = getConfig();
PartnerConnection connection = ConnectionFactory.getPartnerConnection(conf);
log(String.format("Getting RecordTypeId: %s.%s", object, developerName));
QueryResult result = connection.query(getCompiledQuery());
if (result.getSize() == 1) {
String value = (String) result.getRecords()[0].getField("Id");
getProject().setNewProperty(propertyRef, value);
} else {
throw new BuildException("Unable to find a unique result");
}
} catch (ConnectionException e) {
throw new BuildException(e.getLocalizedMessage());
}
}
示例8: execute
import com.sforce.ws.ConnectionException; //导入依赖的package包/类
@Override
public void execute() throws BuildException {
checkCronExpression();
checkScheduleName();
try {
SoapConnection tc = ConnectionFactory.getToolingConnection(getConfig());
String apexCode = String.format(SCHEDULE_APEX, className, className, scheduleName, cron);
executeApex(tc, apexCode);
log(String.format("%s has been scheduled",scheduleName));
} catch (ConnectionException e) {
handleException(e);
}
}
示例9: createPartnerConnection
import com.sforce.ws.ConnectionException; //导入依赖的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);
}
}
示例10: SalesforceBulkWrapper
import com.sforce.ws.ConnectionException; //导入依赖的package包/类
/**
* Constructor
*/
public SalesforceBulkWrapper(
String userName,
String password,
String authEndpointUrl,
boolean isCompression,
int pollingIntervalMillisecond,
boolean queryAll)
throws AsyncApiException, ConnectionException {
partnerConnection = createPartnerConnection(
authEndpointUrl,
userName,
password);
bulkConnection = createBulkConnection(partnerConnection.getConfig());
this.pollingIntervalMillisecond = pollingIntervalMillisecond;
this.queryAll = queryAll;
}
示例11: buildMetadataCacheFromFieldList
import com.sforce.ws.ConnectionException; //导入依赖的package包/类
public void buildMetadataCacheFromFieldList(PartnerConnection partnerConnection, String fieldList) throws StageException {
LOG.debug("Getting metadata for sobjectType {} - field list is {}", sobjectType, fieldList);
// We make a list of reference paths that are in the query
// Each path is a list of (SObjectName, FieldName) pairs
List<List<Pair<String, String>>> references = new LinkedList<>();
metadataCache = new LinkedHashMap<>();
for (String fieldName : fieldList.split("\\s*,\\s*")) {
String[] pathElements = fieldName.split("\\.");
// Handle references
extractReferences(references, pathElements);
}
try {
getAllReferences(partnerConnection, metadataCache, references, new String[]{sobjectType}, METADATA_DEPTH);
} catch (ConnectionException e) {
throw new StageException(Errors.FORCE_21, sobjectType, e);
}
}
示例12: openDataset
import com.sforce.ws.ConnectionException; //导入依赖的package包/类
private void openDataset() throws ConnectionException, StageException {
datasetName = conf.edgemartAliasPrefix;
if (conf.appendTimestamp) {
datasetName += "_" + System.currentTimeMillis();
}
SObject sobj = new SObject();
sobj.setType("InsightsExternalData");
sobj.setField("Format", "Csv");
sobj.setField("EdgemartAlias", datasetName);
sobj.setField("MetadataJson", conf.metadataJson.getBytes(StandardCharsets.UTF_8));
sobj.setField("Operation", conf.operation.getLabel());
sobj.setField("Action", "None");
if (!StringUtils.isEmpty(conf.edgemartContainer)) {
sobj.setField("EdgemartContainer", conf.edgemartContainer);
}
SaveResult[] results = connection.create(new SObject[]{sobj});
for (SaveResult sv : results) {
if (sv.isSuccess()) {
datasetID = sv.getId();
partNumber = 1;
LOG.info("Success creating InsightsExternalData: " + datasetID);
} else {
for (Error e : sv.getErrors()) {
throw new StageException(Errors.WAVE_01, e.getMessage());
}
}
}
}
示例13: create
import com.sforce.ws.ConnectionException; //导入依赖的package包/类
private void create(
SObject[] recordArray,
Map<SObject, Record> recordMap,
List<OnRecordErrorException> errorRecords
) throws ConnectionException {
LOG.info("Writing {} records to Salesforce", recordArray.length);
SaveResult[] saveResults = partnerConnection.create(recordArray);
LOG.info("{} records written to Salesforce", saveResults.length);
// check the returned results for any errors
for (int i = 0; i < saveResults.length; i++) {
if (!saveResults[i].isSuccess()) {
handleErrorRecord(recordArray[i], saveResults[i].getErrors(), recordMap, errorRecords);
}
}
}
示例14: update
import com.sforce.ws.ConnectionException; //导入依赖的package包/类
private void update(
SObject[] recordArray,
Map<SObject, Record> recordMap,
List<OnRecordErrorException> errorRecords
) throws ConnectionException {
LOG.info("Updating {} records in Salesforce", recordArray.length);
SaveResult[] saveResults = partnerConnection.update(recordArray);
LOG.info("{} records updated in Salesforce", saveResults.length);
// check the returned results for any errors
for (int i = 0; i < saveResults.length; i++) {
if (!saveResults[i].isSuccess()) {
handleErrorRecord(recordArray[i], saveResults[i].getErrors(), recordMap, errorRecords);
}
}
}
示例15: delete
import com.sforce.ws.ConnectionException; //导入依赖的package包/类
private void delete(
SObject[] recordArray,
Map<SObject, Record> recordMap,
List<OnRecordErrorException> errorRecords
) throws ConnectionException {
LOG.info("Deleting {} records in Salesforce", recordArray.length);
DeleteResult[] deleteResults = partnerConnection.delete(sObjectsToIds(recordArray));
LOG.info("{} records deleted from Salesforce", deleteResults.length);
// check the returned results for any errors
for (int i = 0; i < deleteResults.length; i++) {
if (!deleteResults[i].isSuccess()) {
handleErrorRecord(recordArray[i], deleteResults[i].getErrors(), recordMap, errorRecords);
}
}
}