use of com.sforce.soap.partner.fault.InvalidSObjectFault 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;
}
use of com.sforce.soap.partner.fault.InvalidSObjectFault 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);
}
use of com.sforce.soap.partner.fault.InvalidSObjectFault 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);
}
use of com.sforce.soap.partner.fault.InvalidSObjectFault 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;
}
use of com.sforce.soap.partner.fault.InvalidSObjectFault 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;
}
Aggregations