use of org.apache.camel.component.salesforce.api.SalesforceException in project camel by apache.
the class BulkApiProcessor method processGetQueryResult.
private void processGetQueryResult(final Exchange exchange, final AsyncCallback callback) throws SalesforceException {
String jobId;
BatchInfo batchBody;
String batchId;
batchBody = exchange.getIn().getBody(BatchInfo.class);
String resultId;
if (batchBody != null) {
jobId = batchBody.getJobId();
batchId = batchBody.getId();
resultId = getParameter(RESULT_ID, exchange, IGNORE_BODY, NOT_OPTIONAL);
} else {
jobId = getParameter(JOB_ID, exchange, IGNORE_BODY, NOT_OPTIONAL);
batchId = getParameter(BATCH_ID, exchange, IGNORE_BODY, NOT_OPTIONAL);
resultId = getParameter(RESULT_ID, exchange, USE_BODY, NOT_OPTIONAL);
}
bulkClient.getQueryResult(jobId, batchId, resultId, new BulkApiClient.StreamResponseCallback() {
@Override
public void onResponse(InputStream inputStream, SalesforceException ex) {
StreamCache body = null;
if (inputStream != null) {
// ensures the connection is read
try {
body = StreamCacheConverter.convertToStreamCache(inputStream, exchange);
} catch (IOException e) {
String msg = "Error retrieving query result: " + e.getMessage();
ex = new SalesforceException(msg, e);
} finally {
// close the input stream to release the Http connection
try {
inputStream.close();
} catch (IOException e) {
// ignore
}
}
}
processResponse(exchange, body, ex, callback);
}
});
}
use of org.apache.camel.component.salesforce.api.SalesforceException in project camel by apache.
the class BulkApiProcessor method processGetRequest.
private void processGetRequest(final Exchange exchange, final AsyncCallback callback) throws SalesforceException {
String jobId;
BatchInfo batchBody;
String batchId;
batchBody = exchange.getIn().getBody(BatchInfo.class);
if (batchBody != null) {
jobId = batchBody.getJobId();
batchId = batchBody.getId();
} else {
jobId = getParameter(JOB_ID, exchange, IGNORE_BODY, NOT_OPTIONAL);
batchId = getParameter(BATCH_ID, exchange, USE_BODY, NOT_OPTIONAL);
}
bulkClient.getRequest(jobId, batchId, new BulkApiClient.StreamResponseCallback() {
@Override
public void onResponse(InputStream inputStream, SalesforceException ex) {
// read the request stream into a StreamCache temp file
// ensures the connection is read
StreamCache body = null;
if (inputStream != null) {
try {
body = StreamCacheConverter.convertToStreamCache(inputStream, exchange);
} catch (IOException e) {
String msg = "Error retrieving batch request: " + e.getMessage();
ex = new SalesforceException(msg, e);
} finally {
// close the input stream to release the Http connection
try {
inputStream.close();
} catch (IOException ignore) {
}
}
}
processResponse(exchange, body, ex, callback);
}
});
}
use of org.apache.camel.component.salesforce.api.SalesforceException in project camel by apache.
the class BulkApiProcessor method processGetBatch.
private void processGetBatch(final Exchange exchange, final AsyncCallback callback) throws SalesforceException {
String jobId;
BatchInfo batchBody = exchange.getIn().getBody(BatchInfo.class);
String batchId;
if (batchBody != null) {
jobId = batchBody.getJobId();
batchId = batchBody.getId();
} else {
jobId = getParameter(JOB_ID, exchange, IGNORE_BODY, NOT_OPTIONAL);
batchId = getParameter(BATCH_ID, exchange, USE_BODY, NOT_OPTIONAL);
}
bulkClient.getBatch(jobId, batchId, new BulkApiClient.BatchInfoResponseCallback() {
@Override
public void onResponse(BatchInfo batchInfo, SalesforceException ex) {
processResponse(exchange, batchInfo, ex, callback);
}
});
}
use of org.apache.camel.component.salesforce.api.SalesforceException in project camel by apache.
the class BulkApiProcessor method processCreateJob.
private void processCreateJob(final Exchange exchange, final AsyncCallback callback) throws InvalidPayloadException {
JobInfo jobBody = exchange.getIn().getMandatoryBody(JobInfo.class);
bulkClient.createJob(jobBody, new BulkApiClient.JobInfoResponseCallback() {
@Override
public void onResponse(JobInfo jobInfo, SalesforceException ex) {
processResponse(exchange, jobInfo, ex, callback);
}
});
}
use of org.apache.camel.component.salesforce.api.SalesforceException in project camel by apache.
the class BulkApiProcessor method processAbortJob.
private void processAbortJob(final Exchange exchange, final AsyncCallback callback) throws SalesforceException {
JobInfo jobBody;
String jobId;
jobBody = exchange.getIn().getBody(JobInfo.class);
if (jobBody != null) {
jobId = jobBody.getId();
} else {
jobId = getParameter(JOB_ID, exchange, USE_BODY, NOT_OPTIONAL);
}
bulkClient.abortJob(jobId, new BulkApiClient.JobInfoResponseCallback() {
@Override
public void onResponse(JobInfo jobInfo, SalesforceException ex) {
processResponse(exchange, jobInfo, ex, callback);
}
});
}
Aggregations