}
private ValidationMessages restoreXmlModel(String xml, @Nullable final String languageKey) {
checkPermission();
ValidationMessages validationMessages = ValidationMessages.create();
Date updateDate = new Date(system2.now());
DbSession session = dbClient.openSession(false);
try {
List<CharacteristicDto> allCharacteristicDtos = restoreCharacteristics(characteristicsXMLImporter.importXML(xml), updateDate, session);
restoreRules(allCharacteristicDtos, rules(languageKey, session), rulesXMLImporter.importXML(xml, validationMessages), validationMessages, updateDate, session);
session.commit();
} catch (IllegalArgumentException e) {
LOG.debug("Error when restoring the model", e);
validationMessages.addErrorText(e.getMessage());
} finally {
MyBatis.closeQuietly(session);
}
return validationMessages;
}