use of org.apache.camel.component.salesforce.api.dto.bulk.JobInfo in project camel by apache.
the class BulkApiProcessor method processGetJob.
private void processGetJob(final Exchange exchange, final AsyncCallback callback) throws SalesforceException {
JobInfo jobBody;
jobBody = exchange.getIn().getBody(JobInfo.class);
String jobId;
if (jobBody != null) {
jobId = jobBody.getId();
} else {
jobId = getParameter(JOB_ID, exchange, USE_BODY, NOT_OPTIONAL);
}
bulkClient.getJob(jobId, new BulkApiClient.JobInfoResponseCallback() {
@Override
public void onResponse(JobInfo jobInfo, SalesforceException ex) {
processResponse(exchange, jobInfo, ex, callback);
}
});
}
use of org.apache.camel.component.salesforce.api.dto.bulk.JobInfo in project camel by apache.
the class BulkApiProcessor method processGetAllBatches.
private void processGetAllBatches(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.getAllBatches(jobId, new BulkApiClient.BatchInfoListResponseCallback() {
@Override
public void onResponse(List<BatchInfo> batchInfoList, SalesforceException ex) {
processResponse(exchange, batchInfoList, ex, callback);
}
});
}
use of org.apache.camel.component.salesforce.api.dto.bulk.JobInfo in project camel by apache.
the class DefaultBulkApiClient method getJob.
@Override
public void getJob(String jobId, final JobInfoResponseCallback callback) {
final Request get = getRequest(HttpMethod.GET, jobUrl(jobId));
// make the call and parse the result
doHttpRequest(get, new ClientResponseCallback() {
@Override
public void onResponse(InputStream response, SalesforceException ex) {
JobInfo value = null;
try {
value = unmarshalResponse(response, get, JobInfo.class);
} catch (SalesforceException e) {
ex = e;
}
callback.onResponse(value, ex);
}
});
}
use of org.apache.camel.component.salesforce.api.dto.bulk.JobInfo in project camel by apache.
the class DefaultBulkApiClient method abortJob.
@Override
public void abortJob(String jobId, final JobInfoResponseCallback callback) {
final JobInfo request = new JobInfo();
request.setState(JobStateEnum.ABORTED);
final Request post = getRequest(HttpMethod.POST, jobUrl(jobId));
try {
marshalRequest(objectFactory.createJobInfo(request), post, APPLICATION_XML_UTF8);
} catch (SalesforceException e) {
callback.onResponse(null, e);
return;
}
// make the call and parse the result
doHttpRequest(post, new ClientResponseCallback() {
@Override
public void onResponse(InputStream response, SalesforceException ex) {
JobInfo value = null;
try {
value = unmarshalResponse(response, post, JobInfo.class);
} catch (SalesforceException e) {
ex = e;
}
callback.onResponse(value, ex);
}
});
}
use of org.apache.camel.component.salesforce.api.dto.bulk.JobInfo in project camel by apache.
the class DefaultBulkApiClient method createJob.
@Override
public void createJob(JobInfo request, final JobInfoResponseCallback callback) {
// clear system fields if set
sanitizeJobRequest(request);
final Request post = getRequest(HttpMethod.POST, jobUrl(null));
try {
marshalRequest(objectFactory.createJobInfo(request), post, APPLICATION_XML_UTF8);
} catch (SalesforceException e) {
callback.onResponse(null, e);
return;
}
// make the call and parse the result in callback
doHttpRequest(post, new ClientResponseCallback() {
@Override
public void onResponse(InputStream response, SalesforceException ex) {
JobInfo value = null;
if (response != null) {
try {
value = unmarshalResponse(response, post, JobInfo.class);
} catch (SalesforceException e) {
ex = e;
}
}
callback.onResponse(value, ex);
}
});
}
Aggregations