use of org.apache.camel.component.salesforce.api.dto.bulk.BatchInfo 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.dto.bulk.BatchInfo 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.dto.bulk.BatchInfo 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);
}
});
}
Aggregations