• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

Java AsyncApiException类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了Java中com.sforce.async.AsyncApiException的典型用法代码示例。如果您正苦于以下问题:Java AsyncApiException类的具体用法?Java AsyncApiException怎么用?Java AsyncApiException使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。



AsyncApiException类属于com.sforce.async包,在下文中一共展示了AsyncApiException类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Java代码示例。

示例1: createRemoteSite

import com.sforce.async.AsyncApiException; //导入依赖的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());
        }
    }
}
 
开发者ID:forcedotcom,项目名称:scmt-server,代码行数:22,代码来源:SalesforceService.java


示例2: upsertData

import com.sforce.async.AsyncApiException; //导入依赖的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;
}
 
开发者ID:forcedotcom,项目名称:scmt-server,代码行数:27,代码来源:SalesforceService.java


示例3: getBulkResults

import com.sforce.async.AsyncApiException; //导入依赖的package包/类
@Override
public BatchResult[] getBulkResults(JobInfo job, List<String> ids) throws ResourceException {
	try {
		JobInfo info = this.bulkConnection.getJobStatus(job.getId());
		if (info.getNumberBatchesTotal() != info.getNumberBatchesFailed() + info.getNumberBatchesCompleted()) {
			//TODO: this should be configurable
			throw new DataNotAvailableException(500);
		}
		BatchResult[] results = new BatchResult[ids.size()];
		for (int i = 0; i < ids.size(); i++) {
			results[i] = this.bulkConnection.getBatchResult(job.getId(), ids.get(i));	
		}
		return results;
	} catch (AsyncApiException e) {
		throw new ResourceException(e);
	}
}
 
开发者ID:kenweezy,项目名称:teiid,代码行数:18,代码来源:SalesforceConnectionImpl.java


示例4: SalesforceBulkWrapper

import com.sforce.async.AsyncApiException; //导入依赖的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;
}
 
开发者ID:mikoto2000,项目名称:embulk-input-salesforce_bulk,代码行数:22,代码来源:SalesforceBulkWrapper.java


示例5: createBulkConnection

import com.sforce.async.AsyncApiException; //导入依赖的package包/类
private BulkConnection createBulkConnection(ConnectorConfig partnerConfig)
        throws AsyncApiException {

    ConnectorConfig config = new ConnectorConfig();
    config.setSessionId(partnerConfig.getSessionId());

    String soapEndpoint = partnerConfig.getServiceEndpoint();
    String restEndpoint = soapEndpoint.substring(
            0, soapEndpoint.indexOf("Soap/")) + "async/" + API_VERSION;
    config.setRestEndpoint(restEndpoint);
    config.setCompression(isCompression);

    config.setTraceMessage(false);

    return new BulkConnection(config);
}
 
开发者ID:mikoto2000,项目名称:embulk-input-salesforce_bulk,代码行数:17,代码来源:SalesforceBulkWrapper.java


示例6: createJob

import com.sforce.async.AsyncApiException; //导入依赖的package包/类
private JobInfo createJob(String sobjectType, BulkConnection connection)
        throws AsyncApiException {
  JobInfo job = new JobInfo();
  job.setObject(sobjectType);
  job.setOperation(conf.queryAll ? OperationEnum.queryAll : OperationEnum.query);
  job.setContentType(ContentType.CSV);
  if (conf.usePKChunking) {
    String headerValue = CHUNK_SIZE + "=" + conf.chunkSize;
    if (!StringUtils.isEmpty(conf.startId)) {
      headerValue += "; " + START_ROW + "=" + conf.startId;
    }
    connection.addHeader(SFORCE_ENABLE_PKCHUNKING, headerValue);
  }
  job = connection.createJob(job);
  return job;
}
 
开发者ID:streamsets,项目名称:datacollector,代码行数:17,代码来源:ForceSource.java


示例7: awaitCompletion

import com.sforce.async.AsyncApiException; //导入依赖的package包/类
private void awaitCompletion(JobBatches jb)
    throws AsyncApiException {
  long sleepTime = 0L;
  Set<String> incomplete = new HashSet<>();
  for (BatchInfo bi : jb.batchInfoList) {
    incomplete.add(bi.getId());
  }
  while (!incomplete.isEmpty()) {
    try {
      Thread.sleep(sleepTime);
    } catch (InterruptedException e) {}
    LOG.info("Awaiting Bulk API results... {}", incomplete.size());
    sleepTime = 1000L;
    BatchInfo[] statusList =
        bulkConnection.getBatchInfoList(jb.job.getId()).getBatchInfo();
    for (BatchInfo b : statusList) {
      if (b.getState() == BatchStateEnum.Completed
          || b.getState() == BatchStateEnum.Failed) {
        if (incomplete.remove(b.getId())) {
          LOG.info("Batch status: {}", b);
        }
      }
    }
  }
}
 
开发者ID:streamsets,项目名称:datacollector,代码行数:26,代码来源:ForceBulkWriter.java


示例8: awaitCompletion

import com.sforce.async.AsyncApiException; //导入依赖的package包/类
/**
 * Wait for a job to complete by polling the Bulk API.
 *
 * @throws AsyncApiException
 * @throws ConnectionException
 */
private void awaitCompletion() throws AsyncApiException, ConnectionException {
    long sleepTime = 0L;
    Set<String> incomplete = new HashSet<String>();
    for (BatchInfo bi : batchInfoList) {
        incomplete.add(bi.getId());
    }
    while (!incomplete.isEmpty()) {
        try {
            Thread.sleep(sleepTime);
        } catch (InterruptedException e) {
        }
        sleepTime = awaitTime;
        BatchInfo[] statusList = getBatchInfoList(job.getId()).getBatchInfo();
        for (BatchInfo b : statusList) {
            if (b.getState() == BatchStateEnum.Completed || b.getState() == BatchStateEnum.Failed) {
                incomplete.remove(b.getId());
            }
        }
    }
}
 
开发者ID:Talend,项目名称:components,代码行数:27,代码来源:SalesforceBulkRuntime.java


示例9: createJob

import com.sforce.async.AsyncApiException; //导入依赖的package包/类
protected JobInfo createJob(JobInfo job) throws AsyncApiException, ConnectionException {
    try {
        if (0 != chunkSize) {
            // Enabling PK chunking by setting header and chunk size.
            bulkConnection.addHeader(PK_CHUNKING_HEADER_NAME, CHUNK_SIZE_PROPERTY_NAME + chunkSize);
        }
        return bulkConnection.createJob(job);
    } catch (AsyncApiException sfException) {
        if (AsyncExceptionCode.InvalidSessionId.equals(sfException.getExceptionCode())) {
            SalesforceRuntimeCommon.renewSession(bulkConnection.getConfig());
            return createJob(job);
        }
        throw sfException;
    } finally {
        if (0 != chunkSize) {
            // Need to disable PK chunking after job was created.
            bulkConnection.addHeader(PK_CHUNKING_HEADER_NAME, Boolean.FALSE.toString());
        }
    }
}
 
开发者ID:Talend,项目名称:components,代码行数:21,代码来源:SalesforceBulkRuntime.java


示例10: bulkExecute

import com.sforce.async.AsyncApiException; //导入依赖的package包/类
public void bulkExecute(RuntimeContainer container) {
    TSalesforceBulkExecProperties sprops = (TSalesforceBulkExecProperties) properties;
    try {
        SalesforceBulkRuntime bulkRuntime = new SalesforceBulkRuntime(connect(container).bulkConnection);
        bulkRuntime.setConcurrencyMode(sprops.bulkProperties.concurrencyMode.getValue());
        bulkRuntime.setAwaitTime(sprops.bulkProperties.waitTimeCheckBatchState.getValue());
        // We only support CSV file for bulk output
        bulkRuntime.executeBulk(sprops.module.moduleName.getStringValue(), sprops.outputAction.getValue(),
                sprops.upsertKeyColumn.getStringValue(), "csv", sprops.bulkFilePath.getStringValue(),
                sprops.bulkProperties.bytesToCommit.getValue(), sprops.bulkProperties.rowsToCommit.getValue());
        // count results
        for (int i = 0; i < bulkRuntime.getBatchCount(); i++) {
            for (BulkResult result : bulkRuntime.getBatchLog(i)) {
                dataCount++;
                if ("true".equalsIgnoreCase(String.valueOf(result.getValue("Success")))) {
                    successCount++;
                } else {
                    rejectCount++;
                }
            }
        }
        bulkRuntime.close();
    } catch (IOException | AsyncApiException | ConnectionException e) {
        throw new ComponentException(e);
    }
}
 
开发者ID:Talend,项目名称:components,代码行数:27,代码来源:SalesforceBulkExecRuntime.java


示例11: retrieveNextResultSet

import com.sforce.async.AsyncApiException; //导入依赖的package包/类
private boolean retrieveNextResultSet() throws IOException {
    while (bulkRuntime.hasNextResultId()) {
        String resultId = bulkRuntime.nextResultId();
        if (null != resultId) {
            try {
                // Get a new result set
                bulkResultSet = bulkRuntime.getQueryResultSet(resultId);
            } catch (AsyncApiException | ConnectionException e) {
                throw new IOException(e);
            }

            currentRecord = bulkResultSet.next();
            // If currentRecord is null, we need to check if resultId set has more entries.
            if (null != currentRecord) {
                // New result set available to retrieve
                dataCount++;
                return true;
            }
        }
    }
    return false;
}
 
开发者ID:Talend,项目名称:components,代码行数:23,代码来源:SalesforceBulkQueryInputReader.java


示例12: advance

import com.sforce.async.AsyncApiException; //导入依赖的package包/类
@Override
public boolean advance() throws IOException {
    if (++resultIndex >= currentBatchResult.size()) {
        if (++batchIndex >= bulkRuntime.getBatchCount()) {
            return false;
        } else {
            try {
                currentBatchResult = bulkRuntime.getBatchLog(batchIndex);
                resultIndex = 0;
                boolean isAdvanced = currentBatchResult.size() > 0;
                if (isAdvanced) {
                    countData();
                }
                return isAdvanced;
            } catch (AsyncApiException | ConnectionException e) {
                throw new IOException(e);
            }
        }
    }
    countData();
    return true;
}
 
开发者ID:Talend,项目名称:components,代码行数:23,代码来源:SalesforceBulkExecReader.java


示例13: createMetadataConnection

import com.sforce.async.AsyncApiException; //导入依赖的package包/类
private void createMetadataConnection()
    throws ConnectionException, AsyncApiException
{
    Utils.log("SalesforceService::createMetadataConnection() entered");
    // check if connection has already been created
    if (getMetadataConnection() != null)
    {
        // connection already created
        return;
    }

    ConnectorConfig config = getConnectorConfig(getServerUrl(), getSessionId());
    config.setServiceEndpoint(getMetadataUrl());

    // check if tracing is enabled
    if (getenv(SALESFORCE_TRACE_METADATA) != null && getenv(SALESFORCE_TRACE_METADATA).equalsIgnoreCase("1"))
    {
        // set this to true to see HTTP requests and responses on stdout
        config.setTraceMessage(true);
        config.setPrettyPrintXml(true);

        // this should only be false when doing debugging.
        config.setCompression(false);
    }

    setMetadataConnection(new MetadataConnection(config));

    // allow partial success
    getMetadataConnection().setAllOrNoneHeader(false);

    // print the endpoint
    Utils.log(
        "\n\tSession ID:            " + getSessionId() +
        "\n\tEndpoint:              " + getServerUrl() +
        "\n\tConnection Session ID: " + _mConn.getConfig().getSessionId() +
        "\n\tAuth Endpoint:         " + _mConn.getConfig().getAuthEndpoint());
}
 
开发者ID:forcedotcom,项目名称:scmt-server,代码行数:38,代码来源:SalesforceService.java


示例14: createBulkConnection

import com.sforce.async.AsyncApiException; //导入依赖的package包/类
private void createBulkConnection() throws AsyncApiException
{
    // check if connection has already been created
    if (getBulkConnection() != null)
    {
        // connection already created
        return;
    }

    // print the info we will use to build the connection
    Utils.log("SalesforceService::createBulkConnection() entered" + "\n\tSession ID:    " + getSessionId()
        + "\n\tBulk Endpoint: " + getBulkEndpoint());

    // create partner connector configuration
    ConnectorConfig bulkConfig = getConnectorConfig(getServerUrl(), getSessionId());
    bulkConfig.setSessionId(getSessionId());
    bulkConfig.setRestEndpoint(getBulkEndpoint());
    bulkConfig.setCompression(true);

    // check if tracing is enabled
    if (getenv(SALESFORCE_TRACE_BULK) != null && getenv(SALESFORCE_TRACE_BULK).equalsIgnoreCase("1"))
    {
        // set this to true to see HTTP requests and responses on stdout
        bulkConfig.setTraceMessage(true);
        bulkConfig.setPrettyPrintXml(true);

        // this should only be false when doing debugging.
        bulkConfig.setCompression(false);
    }

    setBulkConnection(new BulkConnection(bulkConfig));
}
 
开发者ID:forcedotcom,项目名称:scmt-server,代码行数:33,代码来源:SalesforceService.java


示例15: createBulkJob

import com.sforce.async.AsyncApiException; //导入依赖的package包/类
public String createBulkJob(String sobjectType, String upsertField,
    OperationEnum op) throws AsyncApiException
{
    Utils.log("[BULK] Creating Bulk Job:" + "\n\tObject:       [" + sobjectType + "]" + "\n\tUnique Field: ["
        + upsertField + "]" + "\n\tOperation:    [" + op + "]");

    // create a connection
    createBulkConnection();

    // create batch job
    JobInfo job = new JobInfo();
    job.setObject(sobjectType);
    job.setOperation(op);
    job.setConcurrencyMode(ConcurrencyMode.Serial);
    // JSON available in Spring '16
    job.setContentType(ContentType.JSON);
    if (upsertField != null)
    {
        job.setExternalIdFieldName(upsertField);
    }

    // create the job
    job = _bConn.createJob(job);

    Utils.log("Job created: " + job.getId());
    return job.getId();
}
 
开发者ID:forcedotcom,项目名称:scmt-server,代码行数:28,代码来源:SalesforceService.java


示例16: addBatchToJob

import com.sforce.async.AsyncApiException; //导入依赖的package包/类
public void addBatchToJob(String jobId, List<Map<String, Object>> records)
    throws UnsupportedEncodingException, AsyncApiException
{
    Utils.log("[BULK] Adding [" + records.size() + "] records to job [" + jobId + "].");

    // convert the records into a byte stream
    ByteArrayInputStream jsonStream = new ByteArrayInputStream(JsonUtil.toJson(records).getBytes("UTF-8"));

    JobInfo job = new JobInfo();
    job.setId(jobId);
    job.setContentType(ContentType.JSON);

    // submit a batch to the job
    _bConn.createBatchFromStream(job, jsonStream);
}
 
开发者ID:forcedotcom,项目名称:scmt-server,代码行数:16,代码来源:SalesforceService.java


示例17: closeBulkJob

import com.sforce.async.AsyncApiException; //导入依赖的package包/类
public void closeBulkJob(String jobId) throws AsyncApiException
{
    Utils.log("[BULK] Closing Bulk Job: [" + jobId + "]");

    JobInfo job = new JobInfo();
    job.setId(jobId);
    job.setState(JobStateEnum.Closed);
    job.setContentType(ContentType.JSON);
    // _bConn.updateJob(job, ContentType.JSON);

    // unclear if I can use this
    _bConn.closeJob(jobId);
}
 
开发者ID:forcedotcom,项目名称:scmt-server,代码行数:14,代码来源:SalesforceService.java


示例18: createNewJob

import com.sforce.async.AsyncApiException; //导入依赖的package包/类
public boolean createNewJob(String jobId) throws AsyncApiException
{
    JobInfo job = _bConn.getJobStatus(jobId, ContentType.JSON);
    Utils.log("[BULK] Getting Bulk Job Status: [" + jobId + "]");
    Calendar cal = job.getCreatedDate();

    // If current time is more than the time since the job was created, true
    return ((System.currentTimeMillis() - cal.getTime().getTime()) > SalesforceConstants.JOB_LIFE);
}
 
开发者ID:forcedotcom,项目名称:scmt-server,代码行数:10,代码来源:SalesforceService.java


示例19: createBulkJob

import com.sforce.async.AsyncApiException; //导入依赖的package包/类
@Override
public JobInfo createBulkJob(String objectName) throws ResourceException {
       try {
		JobInfo job = new JobInfo();
		job.setObject(objectName);
		job.setOperation(OperationEnum.insert);
		job.setContentType(ContentType.XML);
		return this.bulkConnection.createJob(job);
	} catch (AsyncApiException e) {
		throw new ResourceException(e);
	}
}
 
开发者ID:kenweezy,项目名称:teiid,代码行数:13,代码来源:SalesforceConnectionImpl.java


示例20: addBatch

import com.sforce.async.AsyncApiException; //导入依赖的package包/类
@Override
public String addBatch(List<com.sforce.async.SObject> payload, JobInfo job) throws ResourceException {
	try {
		BatchRequest request = this.bulkConnection.createBatch(job);
		request.addSObjects(payload.toArray(new com.sforce.async.SObject[payload.size()]));
		return request.completeRequest().getId();
	} catch (AsyncApiException e) {
		throw new ResourceException(e);
	}
}
 
开发者ID:kenweezy,项目名称:teiid,代码行数:11,代码来源:SalesforceConnectionImpl.java



注:本文中的com.sforce.async.AsyncApiException类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Java VirtualEthernetCardDistributedVirtualPortBackingInfo类代码示例发布时间:2022-05-23
下一篇:
Java NioServerBossPool类代码示例发布时间:2022-05-23
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap