Search in sources :

Example 1 with JobInfo

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);
        }
    });
}
Also used : SalesforceException(org.apache.camel.component.salesforce.api.SalesforceException) JobInfo(org.apache.camel.component.salesforce.api.dto.bulk.JobInfo) DefaultBulkApiClient(org.apache.camel.component.salesforce.internal.client.DefaultBulkApiClient) BulkApiClient(org.apache.camel.component.salesforce.internal.client.BulkApiClient)

Example 2 with JobInfo

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);
        }
    });
}
Also used : SalesforceException(org.apache.camel.component.salesforce.api.SalesforceException) JobInfo(org.apache.camel.component.salesforce.api.dto.bulk.JobInfo) DefaultBulkApiClient(org.apache.camel.component.salesforce.internal.client.DefaultBulkApiClient) BulkApiClient(org.apache.camel.component.salesforce.internal.client.BulkApiClient) BatchInfo(org.apache.camel.component.salesforce.api.dto.bulk.BatchInfo)

Example 3 with JobInfo

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);
        }
    });
}
Also used : SalesforceException(org.apache.camel.component.salesforce.api.SalesforceException) JobInfo(org.apache.camel.component.salesforce.api.dto.bulk.JobInfo) InputStream(java.io.InputStream) Request(org.eclipse.jetty.client.api.Request)

Example 4 with JobInfo

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);
        }
    });
}
Also used : SalesforceException(org.apache.camel.component.salesforce.api.SalesforceException) JobInfo(org.apache.camel.component.salesforce.api.dto.bulk.JobInfo) InputStream(java.io.InputStream) Request(org.eclipse.jetty.client.api.Request)

Example 5 with JobInfo

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);
        }
    });
}
Also used : SalesforceException(org.apache.camel.component.salesforce.api.SalesforceException) JobInfo(org.apache.camel.component.salesforce.api.dto.bulk.JobInfo) InputStream(java.io.InputStream) Request(org.eclipse.jetty.client.api.Request)

Aggregations

JobInfo (org.apache.camel.component.salesforce.api.dto.bulk.JobInfo)14 SalesforceException (org.apache.camel.component.salesforce.api.SalesforceException)10 InputStream (java.io.InputStream)6 BulkApiClient (org.apache.camel.component.salesforce.internal.client.BulkApiClient)6 DefaultBulkApiClient (org.apache.camel.component.salesforce.internal.client.DefaultBulkApiClient)6 Request (org.eclipse.jetty.client.api.Request)5 BatchInfo (org.apache.camel.component.salesforce.api.dto.bulk.BatchInfo)4 Merchandise__c (org.apache.camel.component.salesforce.dto.generated.Merchandise__c)4 ContentType (org.apache.camel.component.salesforce.api.dto.bulk.ContentType)2 Test (org.junit.Test)2 Theory (org.junit.experimental.theories.Theory)2 ParallelParameterized (com.googlecode.junittoolbox.ParallelParameterized)1 IOException (java.io.IOException)1 ArrayList (java.util.ArrayList)1 HashMap (java.util.HashMap)1 List (java.util.List)1 Collectors (java.util.stream.Collectors)1 JobStateEnum (org.apache.camel.component.salesforce.api.dto.bulk.JobStateEnum)1 OperationEnum (org.apache.camel.component.salesforce.api.dto.bulk.OperationEnum)1 SSLContextParameters (org.apache.camel.util.jsse.SSLContextParameters)1