use of edu.cornell.kfs.fp.batch.CreateAccountingDocumentReportItem in project cu-kfs by CU-CommunityApps.
the class CreateAccountingDocumentServiceImpl method processAccountingDocumentFromXml.
protected void processAccountingDocumentFromXml(String fileName) {
CreateAccountingDocumentReportItem reportItem = new CreateAccountingDocumentReportItem(fileName);
try {
LOG.info("processAccountingDocumentFromXml: Started processing accounting document XML file: " + fileName);
byte[] fileData = safelyLoadFileBytes(fileName);
AccountingXmlDocumentListWrapper accountingXmlDocuments = (AccountingXmlDocumentListWrapper) batchInputFileService.parse(accountingDocumentBatchInputFileType, fileData);
int documentCount = accountingXmlDocuments.getDocuments().size();
LOG.info("processAccountingDocumentFromXml: Found " + documentCount + " documents to process from file: " + fileName);
reportItem.setXmlSuccessfullyLoaded(true);
reportItem.setNumberOfDocumentInFile(documentCount);
reportItem.setReportEmailAddress(accountingXmlDocuments.getReportEmail());
reportItem.setFileOverview(accountingXmlDocuments.getOverview());
accountingXmlDocuments.getDocuments().stream().forEach(xmlDocument -> processAccountingDocumentEntryFromXml(xmlDocument, reportItem));
LOG.info("processAccountingDocumentFromXml: Finished processing accounting document XML file: " + fileName);
} catch (Exception e) {
reportItem.setXmlSuccessfullyLoaded(false);
String reportErrorMessage = configurationService.getPropertyValueAsString(CuFPKeyConstants.REPORT_CREATE_ACCOUNTING_DOCUMENT_XML_PROCESSING_ERROR) + KFSConstants.BLANK_SPACE + e.getMessage();
reportItem.setReportItemMessage(reportErrorMessage);
LOG.error("processAccountingDocumentFromXml: Error processing accounting document XML file", e);
} finally {
removeDoneFileQuietly(fileName);
createAndEmailReport(reportItem);
}
}
Aggregations