use of org.apache.camel.component.salesforce.api.SalesforceException in project camel by apache.
the class DefaultAnalyticsApiClient method getReportInstances.
@Override
public void getReportInstances(String reportId, final ReportInstanceListResponseCallback callback) {
final Request request = getRequest(HttpMethod.GET, reportInstancesUrl(reportId));
doHttpRequest(request, new ClientResponseCallback() {
@Override
public void onResponse(InputStream response, SalesforceException ex) {
List<ReportInstance> reportInstances = null;
if (response != null) {
try {
reportInstances = unmarshalResponse(response, request, TypeReferences.REPORT_INSTANCE_LIST_TYPE);
} catch (SalesforceException e) {
ex = e;
}
}
callback.onResponse(reportInstances, ex);
}
});
}
use of org.apache.camel.component.salesforce.api.SalesforceException in project camel by apache.
the class DefaultAnalyticsApiClient method executeAsyncReport.
@Override
public void executeAsyncReport(String reportId, Boolean includeDetails, ReportMetadata reportMetadata, final ReportInstanceResponseCallback callback) {
final Request request = getRequest(HttpMethod.POST, reportInstancesUrl(reportId, includeDetails));
// set POST data
if (reportMetadata != null) {
try {
// wrap reportMetadata in a map
final HashMap<String, Object> input = new HashMap<String, Object>();
input.put("reportMetadata", reportMetadata);
marshalRequest(input, request);
} catch (SalesforceException e) {
callback.onResponse(null, e);
return;
}
}
doHttpRequest(request, new ClientResponseCallback() {
@Override
public void onResponse(InputStream response, SalesforceException ex) {
ReportInstance reportInstance = null;
try {
reportInstance = unmarshalResponse(response, request, ReportInstance.class);
} catch (SalesforceException e) {
ex = e;
}
callback.onResponse(reportInstance, ex);
}
});
}
use of org.apache.camel.component.salesforce.api.SalesforceException in project camel by apache.
the class DefaultBulkApiClient method getQueryResult.
@Override
public void getQueryResult(String jobId, String batchId, String resultId, final StreamResponseCallback callback) {
final Request get = getRequest(HttpMethod.GET, batchResultUrl(jobId, batchId, resultId));
// make the call and parse 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 marshalRequest.
private void marshalRequest(Object input, Request request, String contentType) throws SalesforceException {
try {
Marshaller marshaller = context.createMarshaller();
ByteArrayOutputStream byteStream = new ByteArrayOutputStream();
marshaller.marshal(input, byteStream);
request.content(new BytesContentProvider(contentType, byteStream.toByteArray()));
} catch (JAXBException e) {
throw new SalesforceException(String.format("Error marshaling request for {%s:%s} : %s", request.getMethod(), request.getURI(), e.getMessage()), e);
} catch (IllegalArgumentException e) {
throw new SalesforceException(String.format("Error marshaling request 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 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);
}
});
}
Aggregations