Search in sources :

Example 6 with UnexpectedErrorFault

use of com.sforce.soap.partner.fault.UnexpectedErrorFault in project teiid by teiid.

the class SalesforceConnectionImpl method getUpdated.

public UpdatedResult getUpdated(String objectType, Calendar startDate, Calendar endDate) throws ResourceException {
    GetUpdatedResult updated;
    try {
        updated = partnerConnection.getUpdated(objectType, startDate, endDate);
    } catch (InvalidSObjectFault e) {
        throw new ResourceException(e);
    } catch (UnexpectedErrorFault e) {
        throw new ResourceException(e);
    } catch (ConnectionException e) {
        throw new ResourceException(e);
    }
    UpdatedResult result = new UpdatedResult();
    result.setLatestDateCovered(updated.getLatestDateCovered());
    result.setIDs(Arrays.asList(updated.getIds()));
    return result;
}
Also used : InvalidSObjectFault(com.sforce.soap.partner.fault.InvalidSObjectFault) UpdatedResult(org.teiid.translator.salesforce.execution.UpdatedResult) ResourceException(javax.resource.ResourceException) UnexpectedErrorFault(com.sforce.soap.partner.fault.UnexpectedErrorFault) ConnectionException(com.sforce.ws.ConnectionException)

Example 7 with UnexpectedErrorFault

use of com.sforce.soap.partner.fault.UnexpectedErrorFault in project teiid by teiid.

the class SalesforceConnectionImpl method upsert.

public int upsert(DataPayload data) throws ResourceException {
    SObject toCreate = new SObject();
    toCreate.setType(data.getType());
    for (DataPayload.Field field : data.getMessageElements()) {
        toCreate.addField(field.name, field.value);
    }
    SObject[] objects = new SObject[] { toCreate };
    UpsertResult[] results;
    try {
        results = partnerConnection.upsert(ID_FIELD_NAME, objects);
    } catch (InvalidFieldFault e) {
        throw new ResourceException(e);
    } catch (InvalidSObjectFault e) {
        throw new ResourceException(e);
    } catch (InvalidIdFault e) {
        throw new ResourceException(e);
    } catch (UnexpectedErrorFault e) {
        throw new ResourceException(e);
    } catch (ConnectionException e) {
        throw new ResourceException(e);
    }
    for (UpsertResult result : results) {
        if (!result.isSuccess()) {
            throw new ResourceException(result.getErrors()[0].getMessage());
        }
    }
    return results.length;
}
Also used : InvalidFieldFault(com.sforce.soap.partner.fault.InvalidFieldFault) InvalidSObjectFault(com.sforce.soap.partner.fault.InvalidSObjectFault) SObject(com.sforce.soap.partner.sobject.SObject) DataPayload(org.teiid.translator.salesforce.execution.DataPayload) ResourceException(javax.resource.ResourceException) UnexpectedErrorFault(com.sforce.soap.partner.fault.UnexpectedErrorFault) InvalidIdFault(com.sforce.soap.partner.fault.InvalidIdFault) ConnectionException(com.sforce.ws.ConnectionException)

Example 8 with UnexpectedErrorFault

use of com.sforce.soap.partner.fault.UnexpectedErrorFault in project teiid by teiid.

the class SalesforceConnectionImpl method query.

public QueryResult query(String queryString, int batchSize, boolean queryAll) throws ResourceException {
    if (batchSize > 2000) {
        batchSize = 2000;
        // $NON-NLS-1$
        LogManager.logDetail(LogConstants.CTX_CONNECTOR, "reduced.batch.size");
    }
    QueryResult qr = null;
    partnerConnection.setQueryOptions(batchSize);
    try {
        if (queryAll) {
            qr = partnerConnection.queryAll(queryString);
        } else {
            partnerConnection.setMruHeader(false);
            qr = partnerConnection.query(queryString);
        }
    } catch (InvalidFieldFault e) {
        throw new ResourceException(e);
    } catch (MalformedQueryFault e) {
        throw new ResourceException(e);
    } catch (InvalidSObjectFault e) {
        throw new ResourceException(e);
    } catch (InvalidIdFault e) {
        throw new ResourceException(e);
    } catch (UnexpectedErrorFault e) {
        throw new ResourceException(e);
    } catch (InvalidQueryLocatorFault e) {
        throw new ResourceException(e);
    } catch (ConnectionException e) {
        throw new ResourceException(e);
    } finally {
        partnerConnection.clearMruHeader();
        partnerConnection.clearQueryOptions();
    }
    return qr;
}
Also used : InvalidFieldFault(com.sforce.soap.partner.fault.InvalidFieldFault) InvalidSObjectFault(com.sforce.soap.partner.fault.InvalidSObjectFault) InvalidQueryLocatorFault(com.sforce.soap.partner.fault.InvalidQueryLocatorFault) ResourceException(javax.resource.ResourceException) UnexpectedErrorFault(com.sforce.soap.partner.fault.UnexpectedErrorFault) MalformedQueryFault(com.sforce.soap.partner.fault.MalformedQueryFault) InvalidIdFault(com.sforce.soap.partner.fault.InvalidIdFault) ConnectionException(com.sforce.ws.ConnectionException)

Aggregations

UnexpectedErrorFault (com.sforce.soap.partner.fault.UnexpectedErrorFault)8 ConnectionException (com.sforce.ws.ConnectionException)8 ResourceException (javax.resource.ResourceException)8 InvalidSObjectFault (com.sforce.soap.partner.fault.InvalidSObjectFault)6 InvalidFieldFault (com.sforce.soap.partner.fault.InvalidFieldFault)5 InvalidIdFault (com.sforce.soap.partner.fault.InvalidIdFault)4 SObject (com.sforce.soap.partner.sobject.SObject)3 DataPayload (org.teiid.translator.salesforce.execution.DataPayload)3 InvalidQueryLocatorFault (com.sforce.soap.partner.fault.InvalidQueryLocatorFault)2 ArrayList (java.util.ArrayList)2 Error (com.sforce.soap.partner.Error)1 MalformedQueryFault (com.sforce.soap.partner.fault.MalformedQueryFault)1 DeletedObject (org.teiid.translator.salesforce.execution.DeletedObject)1 DeletedResult (org.teiid.translator.salesforce.execution.DeletedResult)1 UpdatedResult (org.teiid.translator.salesforce.execution.UpdatedResult)1