try {
// disable the triggers to prevent unexpected extra db actions
// during import
TriggerHandler.getInstance().disable();
final XMLEntityConverter xec = XMLEntityConverter.newInstance();
xec.setClient(client);
xec.setOrganization(organization);
xec.setOptionClientImport(isClientImport);
xec.setOptionImportAuditInfo(importAuditInfo);
xec.getEntityResolver().setOptionCreateReferencedIfNotFound(createReferencesIfNotFound);
listNew = xec.getToInsert();
listChanged = xec.getToUpdate();
if (isClientImport) {
xec.setEntityResolver(ClientImportEntityResolver.getInstance());
}
xec.setImportProcessor(importProcessor);
xec.process(doc);
ir.setLogMessages(xec.getLogMessages());
ir.setErrorMessages(xec.getErrorMessages());
ir.setWarningMessages(xec.getWarningMessages());
if (ir.hasErrorOccured()) {
OBDal.getInstance().rollbackAndClose();
rolledBack = true;
return ir;
}
if (importProcessor != null) {
try {
importProcessor.process(xec.getToInsert(), xec.getToUpdate());
} catch (final Exception e) {
// note on purpose caught and set in ImportResult
e.printStackTrace(System.err);
ir.setException(e);
ir.setErrorMessages(e.getMessage());