Search in sources :

Example 1 with UnexpectedErrorFault

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

the class SalesforceConnectionImpl method getDeleted.

public DeletedResult getDeleted(String objectName, Calendar startCalendar, Calendar endCalendar) throws ResourceException {
    GetDeletedResult deleted;
    try {
        deleted = partnerConnection.getDeleted(objectName, startCalendar, endCalendar);
    } catch (InvalidSObjectFault e) {
        throw new ResourceException(e);
    } catch (UnexpectedErrorFault e) {
        throw new ResourceException(e);
    } catch (ConnectionException e) {
        throw new ResourceException(e);
    }
    DeletedResult result = new DeletedResult();
    result.setLatestDateCovered(deleted.getLatestDateCovered());
    result.setEarliestDateAvailable(deleted.getEarliestDateAvailable());
    DeletedRecord[] records = deleted.getDeletedRecords();
    List<DeletedObject> resultRecords = new ArrayList<DeletedObject>();
    if (records != null) {
        for (DeletedRecord record : records) {
            DeletedObject object = new DeletedObject();
            object.setID(record.getId());
            object.setDeletedDate(record.getDeletedDate());
            resultRecords.add(object);
        }
    }
    result.setResultRecords(resultRecords);
    return result;
}
Also used : InvalidSObjectFault(com.sforce.soap.partner.fault.InvalidSObjectFault) DeletedResult(org.teiid.translator.salesforce.execution.DeletedResult) ArrayList(java.util.ArrayList) ResourceException(javax.resource.ResourceException) UnexpectedErrorFault(com.sforce.soap.partner.fault.UnexpectedErrorFault) ConnectionException(com.sforce.ws.ConnectionException) DeletedObject(org.teiid.translator.salesforce.execution.DeletedObject)

Example 2 with UnexpectedErrorFault

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

the class SalesforceConnectionImpl method queryMore.

public QueryResult queryMore(String queryLocator, int batchSize) throws ResourceException {
    if (batchSize > 2000) {
        batchSize = 2000;
        // $NON-NLS-1$
        LogManager.logDetail(LogConstants.CTX_CONNECTOR, "reduced.batch.size");
    }
    partnerConnection.setQueryOptions(batchSize);
    try {
        return partnerConnection.queryMore(queryLocator);
    } catch (InvalidFieldFault 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.clearQueryOptions();
    }
}
Also used : InvalidFieldFault(com.sforce.soap.partner.fault.InvalidFieldFault) InvalidQueryLocatorFault(com.sforce.soap.partner.fault.InvalidQueryLocatorFault) ResourceException(javax.resource.ResourceException) UnexpectedErrorFault(com.sforce.soap.partner.fault.UnexpectedErrorFault) ConnectionException(com.sforce.ws.ConnectionException)

Example 3 with UnexpectedErrorFault

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

the class SalesforceConnectionImpl method delete.

public int delete(String[] ids) throws ResourceException {
    DeleteResult[] results = null;
    try {
        results = partnerConnection.delete(ids);
    } catch (UnexpectedErrorFault e) {
        throw new ResourceException(e);
    } catch (ConnectionException e) {
        throw new ResourceException(e);
    }
    boolean allGood = true;
    StringBuffer errorMessages = new StringBuffer();
    for (int i = 0; i < results.length; i++) {
        DeleteResult result = results[i];
        if (!result.isSuccess()) {
            if (allGood) {
                // $NON-NLS-1$
                errorMessages.append("Error(s) executing DELETE: ");
                allGood = false;
            }
            Error[] errors = result.getErrors();
            if (null != errors && errors.length > 0) {
                for (int x = 0; x < errors.length; x++) {
                    Error error = errors[x];
                    errorMessages.append(error.getMessage()).append(';');
                }
            }
        }
    }
    if (!allGood) {
        throw new ResourceException(errorMessages.toString());
    }
    return results.length;
}
Also used : Error(com.sforce.soap.partner.Error) UnexpectedErrorFault(com.sforce.soap.partner.fault.UnexpectedErrorFault) ResourceException(javax.resource.ResourceException) ConnectionException(com.sforce.ws.ConnectionException)

Example 4 with UnexpectedErrorFault

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

the class SalesforceConnectionImpl method create.

public int create(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 };
    SaveResult[] result;
    try {
        result = partnerConnection.create(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);
    }
    return analyzeResult(result);
}
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 5 with UnexpectedErrorFault

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

the class SalesforceConnectionImpl method update.

public int update(List<DataPayload> updateDataList) throws ResourceException {
    List<SObject> params = new ArrayList<SObject>(updateDataList.size());
    for (int i = 0; i < updateDataList.size(); i++) {
        DataPayload data = updateDataList.get(i);
        SObject toCreate = new SObject();
        toCreate.setType(data.getType());
        toCreate.setId(data.getID());
        for (DataPayload.Field field : data.getMessageElements()) {
            toCreate.addField(field.name, field.value);
        }
        params.add(i, toCreate);
    }
    SaveResult[] result;
    try {
        result = partnerConnection.update(params.toArray(new SObject[params.size()]));
    } 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);
    }
    return analyzeResult(result);
}
Also used : InvalidSObjectFault(com.sforce.soap.partner.fault.InvalidSObjectFault) ArrayList(java.util.ArrayList) UnexpectedErrorFault(com.sforce.soap.partner.fault.UnexpectedErrorFault) InvalidFieldFault(com.sforce.soap.partner.fault.InvalidFieldFault) SObject(com.sforce.soap.partner.sobject.SObject) DataPayload(org.teiid.translator.salesforce.execution.DataPayload) ResourceException(javax.resource.ResourceException) 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