use of org.kuali.kfs.krad.exception.ValidationException in project cu-kfs by CU-CommunityApps.
the class CorporateBilledCorporatePaidCreateDocumentServiceImpl method routeProcurementCardDocuments.
@Override
public boolean routeProcurementCardDocuments() {
LOG.debug("routeProcurementCardDocuments() started");
Collection<CorporateBilledCorporatePaidDocument> cbcpDocumentList = retrieveCorporateBilledCorporatePaidDocuments(KewApiConstants.ROUTE_HEADER_SAVED_CD);
LOG.info("routeProcurementCardDocuments() Number of CBCP documents to Route: " + cbcpDocumentList.size());
Map<String, String> documentErrors = new HashMap<String, String>();
List<String> successfulDocuments = new ArrayList<String>();
for (CorporateBilledCorporatePaidDocument cbcpDocument : cbcpDocumentList) {
try {
LOG.info("routeProcurementCardDocuments() Routing CBCP document # " + cbcpDocument.getDocumentNumber() + ".");
documentService.prepareWorkflowDocument(cbcpDocument);
documentService.routeDocument(cbcpDocument, "CBCP document automatically routed", new ArrayList<AdHocRouteRecipient>());
successfulDocuments.add(cbcpDocument.getDocumentNumber());
} catch (WorkflowException we) {
documentErrors.put(cbcpDocument.getDocumentNumber(), "Workflow error: " + we.getMessage());
GlobalVariables.getMessageMap().clearErrorMessages();
LOG.error("routeProcurementCardDocuments, workflow error routing document # " + cbcpDocument.getDocumentNumber() + " " + we.getMessage(), we);
} catch (ValidationException ve) {
documentErrors.put(cbcpDocument.getDocumentNumber(), corporateBilledCorporatePaidRouteStepReportService.buildValidationErrorMessage(ve));
GlobalVariables.getMessageMap().clearErrorMessages();
LOG.error("routeProcurementCardDocuments, Error routing document # " + cbcpDocument.getDocumentNumber() + " " + ve.getMessage(), ve);
}
}
createAndEmailReport(cbcpDocumentList, documentErrors, successfulDocuments);
return true;
}
use of org.kuali.kfs.krad.exception.ValidationException in project cu-kfs by CU-CommunityApps.
the class CreateAccountingDocumentServiceImpl method processAccountingDocumentEntryFromXml.
protected void processAccountingDocumentEntryFromXml(AccountingXmlDocumentEntry accountingXmlDocument, CreateAccountingDocumentReportItem reportItem) {
GlobalVariables.getMessageMap().clearErrorMessages();
CreateAccountingDocumentReportItemDetail detail = new CreateAccountingDocumentReportItemDetail();
detail.setIndexNumber(accountingXmlDocument.getIndex().intValue());
detail.setDocumentType(accountingXmlDocument.getDocumentTypeCode());
detail.setDocumentDescription(accountingXmlDocument.getDescription());
detail.setDocumentExplanation(accountingXmlDocument.getExplanation());
try {
LOG.info("processAccountingDocumentEntryFromXml: Started processing accounting document of type: " + accountingXmlDocument.getDocumentTypeCode());
String documentGeneratorBeanName = CuFPConstants.ACCOUNTING_DOCUMENT_GENERATOR_BEAN_PREFIX + accountingXmlDocument.getDocumentTypeCode();
AccountingDocumentGenerator<? extends AccountingDocument> documentGenerator = findDocumentGenerator(documentGeneratorBeanName);
AccountingDocument document = documentGenerator.createDocument(this::getNewDocument, accountingXmlDocument);
document = (AccountingDocument) documentService.routeDocument(document, CuFPConstants.ACCOUNTING_DOCUMENT_XML_ROUTE_ANNOTATION, getAllAdHocRecipients(document));
LOG.info("processAccountingDocumentEntryFromXml: Finished processing and routing accounting document " + document.getDocumentNumber() + " of type: " + accountingXmlDocument.getDocumentTypeCode());
detail.setSuccessfullyRouted(true);
detail.setDocumentNumber(document.getDocumentNumber());
reportItem.getDocumentsSuccessfullyRouted().add(detail);
} catch (Exception e) {
detail.setSuccessfullyRouted(false);
if (e instanceof ValidationException) {
String errorMessage = buildValidationErrorMessage((ValidationException) e);
LOG.error("processAccountingDocumentEntryFromXml: Could not route accounting document - " + errorMessage);
detail.setErrorMessage(errorMessage);
} else {
LOG.error("processAccountingDocumentEntryFromXml: Error processing accounting XML document", e);
detail.setErrorMessage("Non validation error: " + e.getMessage());
}
reportItem.getDocumentsInError().add(detail);
} finally {
GlobalVariables.getMessageMap().clearErrorMessages();
}
}
use of org.kuali.kfs.krad.exception.ValidationException in project cu-kfs by CU-CommunityApps.
the class PreEncumbranceDocument method processExplicitGeneralLedgerPendingEntry.
/**
* This method processes all necessary information to build an explicit general ledger entry, and then adds that to the
* document.
*
* @param accountingDocument
* @param sequenceHelper
* @param accountingLine
* @param explicitEntry
* @return boolean True if the explicit entry generation was successful, false otherwise.
*/
@Override
protected void processExplicitGeneralLedgerPendingEntry(GeneralLedgerPendingEntrySequenceHelper sequenceHelper, GeneralLedgerPendingEntrySourceDetail glpeSourceDetail, GeneralLedgerPendingEntry explicitEntry) {
if (glpeSourceDetail instanceof PreEncumbranceSourceAccountingLine) {
int rowId = ((AccountingLine) glpeSourceDetail).getSequenceNumber() - 1;
PreEncumbranceSourceAccountingLine pesal = (PreEncumbranceSourceAccountingLine) glpeSourceDetail;
if (ObjectUtils.isNotNull(pesal.getAutoDisEncumberType())) {
if (ObjectUtils.isNull(pesal.getStartDate()) || ObjectUtils.isNull(pesal.getPartialTransactionCount()) || ObjectUtils.isNull(pesal.getPartialAmount())) {
throw new ValidationException("Insufficient information for GLPE generation");
}
Date generatedEndDate = PreEncumbranceAccountingLineUtil.generateEndDate(pesal.getStartDate(), Integer.parseInt(pesal.getPartialTransactionCount()), pesal.getAutoDisEncumberType());
pesal.setEndDate(generatedEndDate);
TreeMap<Date, KualiDecimal> datesAndAmounts = PreEncumbranceAccountingLineUtil.generateDatesAndAmounts(pesal.getAutoDisEncumberType(), pesal.getStartDate(), pesal.getEndDate(), Integer.parseInt(pesal.getPartialTransactionCount()), pesal.getAmount(), pesal.getPartialAmount(), rowId);
Iterator<Date> it = datesAndAmounts.keySet().iterator();
boolean isErrorCorrection = false;
Date today = new Date(Calendar.getInstance().getTimeInMillis());
if (pesal.getAmount().isNegative()) {
// we are doing error correction
LOG.info("Error correction!");
isErrorCorrection = true;
}
while (it.hasNext()) {
Date revDate = it.next();
if (isErrorCorrection && revDate.before(today)) {
break;
}
KualiDecimal partialAmount = datesAndAmounts.get(revDate);
GeneralLedgerPendingEntry explicitPartialEntry = new GeneralLedgerPendingEntry();
SpringContext.getBean(GeneralLedgerPendingEntryService.class).populateExplicitGeneralLedgerPendingEntry(this, glpeSourceDetail, sequenceHelper, explicitPartialEntry);
explicitPartialEntry.setFinancialDocumentReversalDate(revDate);
explicitPartialEntry.setTransactionLedgerEntryAmount(isErrorCorrection ? partialAmount.negated() : partialAmount);
customizeExplicitGeneralLedgerPendingEntry(glpeSourceDetail, explicitPartialEntry);
addPendingEntry(explicitPartialEntry);
sequenceHelper.increment();
GeneralLedgerPendingEntry offsetEntry = new GeneralLedgerPendingEntry(explicitPartialEntry);
processOffsetGeneralLedgerPendingEntry(sequenceHelper, glpeSourceDetail, explicitPartialEntry, offsetEntry);
sequenceHelper.increment();
}
// no need to do the following stuff, as we're generating a bunch of custom GL pending entries above
return;
}
}
// populate the explicit entry
SpringContext.getBean(GeneralLedgerPendingEntryService.class).populateExplicitGeneralLedgerPendingEntry(this, glpeSourceDetail, sequenceHelper, explicitEntry);
// hook for children documents to implement document specific GLPE field mappings
customizeExplicitGeneralLedgerPendingEntry(glpeSourceDetail, explicitEntry);
addPendingEntry(explicitEntry);
sequenceHelper.increment();
// handle the offset entry
GeneralLedgerPendingEntry offsetEntry = new GeneralLedgerPendingEntry(explicitEntry);
boolean success = processOffsetGeneralLedgerPendingEntry(sequenceHelper, glpeSourceDetail, explicitEntry, offsetEntry);
}
use of org.kuali.kfs.krad.exception.ValidationException in project cu-kfs by CU-CommunityApps.
the class WebUtils method getMultipartParameters.
public static void getMultipartParameters(HttpServletRequest request, ActionServletWrapper servletWrapper, ActionForm form, ActionMapping mapping) {
Map params = new HashMap();
try {
CommonsMultipartRequestHandler multipartHandler = new CommonsMultipartRequestHandler();
if (multipartHandler != null) {
// Set servlet and mapping info
if (servletWrapper != null) {
// from pojoformbase
// servlet only affects tempdir on local disk
servletWrapper.setServletFor(multipartHandler);
}
multipartHandler.setMapping((ActionMapping) request.getAttribute(Globals.MAPPING_KEY));
// Initialize multipart request class handler
multipartHandler.handleRequest(request);
Collection<FormFile> files = multipartHandler.getFileElements().values();
Enumeration keys = multipartHandler.getFileElements().keys();
while (keys.hasMoreElements()) {
Object key = keys.nextElement();
FormFile file = (FormFile) multipartHandler.getFileElements().get(key);
long maxSize = WebUtils.getMaxUploadSize(form);
if (LOG.isDebugEnabled()) {
LOG.debug(file.getFileSize());
}
if (maxSize > 0 && Long.parseLong(file.getFileSize() + "") > maxSize) {
GlobalVariables.getMessageMap().putError(key.toString(), RiceKeyConstants.ERROR_UPLOADFILE_SIZE, new String[] { file.getFileName(), Long.toString(maxSize) });
}
}
// get file elements for kualirequestprocessor
if (servletWrapper == null) {
request.setAttribute(KRADConstants.UPLOADED_FILE_REQUEST_ATTRIBUTE_KEY, getFileParametersForMultipartRequest(request, multipartHandler));
}
}
} catch (ServletException e) {
throw new ValidationException("unable to handle multipart request " + e.getMessage(), e);
}
}
use of org.kuali.kfs.krad.exception.ValidationException in project cu-kfs by CU-CommunityApps.
the class PaymentWorksDataProcessingIntoKfsServiceImpl method kfsVendorMaintenanceDocumentValidated.
private boolean kfsVendorMaintenanceDocumentValidated(MaintenanceDocument vendorMaintenceDoc, PaymentWorksNewVendorRequestsBatchReportData reportData, PaymentWorksVendor pmwVendor) {
boolean documentValidated = false;
try {
vendorMaintenceDoc.validateBusinessRules(new RouteDocumentEvent(vendorMaintenceDoc));
LOG.info("kfsVendorMaintenanceDocumentValidated: vendorMaintenceDoc validate.");
documentValidated = true;
} catch (ValidationException ve) {
List<String> validationErrors = convertReportDataValidationErrors(GlobalVariables.getMessageMap().getErrorMessages());
captureKfsProcessingErrorsForVendor(pmwVendor, reportData, validationErrors);
LOG.error("kfsVendorMaintenanceDocumentValidated: eDoc validation error(s): " + validationErrors.toString());
LOG.error("kfsVendorMaintenanceDocumentValidated: eDoc validation exception caught: " + ve.getMessage());
} finally {
GlobalVariables.getMessageMap().clearErrorMessages();
}
return documentValidated;
}
Aggregations