use of org.apache.camel.component.salesforce.api.SalesforceException in project camel by apache.
the class DefaultBulkApiClient method getQueryResultIds.
@Override
public void getQueryResultIds(String jobId, String batchId, final QueryResultIdsCallback callback) {
final Request get = getRequest(HttpMethod.GET, batchResultUrl(jobId, batchId, null));
// make the call and parse the result
doHttpRequest(get, new ClientResponseCallback() {
@Override
public void onResponse(InputStream response, SalesforceException ex) {
QueryResultList value = null;
try {
value = unmarshalResponse(response, get, QueryResultList.class);
} catch (SalesforceException e) {
ex = e;
}
callback.onResponse(value != null ? Collections.unmodifiableList(value.getResult()) : null, ex);
}
});
}
use of org.apache.camel.component.salesforce.api.SalesforceException in project camel by apache.
the class DefaultBulkApiClient method unmarshalResponse.
private <T> T unmarshalResponse(InputStream response, Request request, Class<T> resultClass) throws SalesforceException {
try {
Unmarshaller unmarshaller = context.createUnmarshaller();
JAXBElement<T> result = unmarshaller.unmarshal(new StreamSource(response), resultClass);
return result.getValue();
} catch (JAXBException e) {
throw new SalesforceException(String.format("Error unmarshaling response {%s:%s} : %s", request.getMethod(), request.getURI(), e.getMessage()), e);
} catch (IllegalArgumentException e) {
throw new SalesforceException(String.format("Error unmarshaling response for {%s:%s} : %s", request.getMethod(), request.getURI(), e.getMessage()), e);
}
}
use of org.apache.camel.component.salesforce.api.SalesforceException 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.SalesforceException in project camel by apache.
the class DefaultBulkApiClient method getResults.
@Override
public void getResults(String jobId, String batchId, final StreamResponseCallback callback) {
final Request get = getRequest(HttpMethod.GET, batchResultUrl(jobId, batchId, null));
// make the call and return the result
doHttpRequest(get, new ClientResponseCallback() {
@Override
public void onResponse(InputStream response, SalesforceException ex) {
callback.onResponse(response, ex);
}
});
}
use of org.apache.camel.component.salesforce.api.SalesforceException 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