use of org.apache.camel.component.salesforce.api.dto.bulk.ContentType in project camel by apache.
the class BulkApiProcessor method processCreateBatch.
private void processCreateBatch(final Exchange exchange, final AsyncCallback callback) throws SalesforceException {
String jobId;
// since request is in the body, use headers or endpoint params
ContentType contentType = ContentType.fromValue(getParameter(CONTENT_TYPE, exchange, IGNORE_BODY, NOT_OPTIONAL));
jobId = getParameter(JOB_ID, exchange, IGNORE_BODY, NOT_OPTIONAL);
InputStream request;
try {
request = exchange.getIn().getMandatoryBody(InputStream.class);
} catch (CamelException e) {
String msg = "Error preparing batch request: " + e.getMessage();
throw new SalesforceException(msg, e);
}
bulkClient.createBatch(request, jobId, contentType, new BulkApiClient.BatchInfoResponseCallback() {
@Override
public void onResponse(BatchInfo batchInfo, SalesforceException ex) {
processResponse(exchange, batchInfo, ex, callback);
}
});
}
use of org.apache.camel.component.salesforce.api.dto.bulk.ContentType in project camel by apache.
the class BulkApiProcessor method processCreateBatchQuery.
private void processCreateBatchQuery(final Exchange exchange, final AsyncCallback callback) throws SalesforceException {
JobInfo jobBody;
String jobId;
ContentType contentType;
jobBody = exchange.getIn().getBody(JobInfo.class);
String soqlQuery;
if (jobBody != null) {
jobId = jobBody.getId();
contentType = jobBody.getContentType();
// use SOQL query from header or endpoint config
soqlQuery = getParameter(SOBJECT_QUERY, exchange, IGNORE_BODY, NOT_OPTIONAL);
} else {
jobId = getParameter(JOB_ID, exchange, IGNORE_BODY, NOT_OPTIONAL);
contentType = ContentType.fromValue(getParameter(CONTENT_TYPE, exchange, IGNORE_BODY, NOT_OPTIONAL));
// reuse SOBJECT_QUERY property
soqlQuery = getParameter(SOBJECT_QUERY, exchange, USE_BODY, NOT_OPTIONAL);
}
bulkClient.createBatchQuery(jobId, soqlQuery, contentType, new BulkApiClient.BatchInfoResponseCallback() {
@Override
public void onResponse(BatchInfo batchInfo, SalesforceException ex) {
processResponse(exchange, batchInfo, ex, callback);
}
});
}
Aggregations