Search in sources :

Example 1 with EncryptionService

use of org.kuali.rice.core.api.encryption.EncryptionService in project cu-kfs by CU-CommunityApps.

the class TransactionRowPrintProcessor method processTaxRows.

@Override
void processTaxRows(ResultSet rs, T summary) throws SQLException, IOException {
    // Perform initialization as needed.
    TransactionDetailRow detailRow = summary.transactionDetailRow;
    Pattern whitespacePattern = Pattern.compile("\\p{Space}");
    EncryptionService encryptionService = CoreApiServiceLocator.getEncryptionService();
    rsTransactionDetail = rs;
    if (summary.scrubbedOutput) {
        ssnP.value = CUTaxConstants.MASKED_VALUE_9_CHARS;
    }
    LOG.info("Starting raw transaction row printing to file...");
    // Print the header.
    resetBuffer(HEADER_BUFFER_INDEX);
    appendPieces(HEADER_BUFFER_INDEX);
    writeBufferToOutput(HEADER_BUFFER_INDEX, 0);
    // Print the data for each row to the file.
    while (rsTransactionDetail.next()) {
        // Prepare the tax number.
        if (!summary.scrubbedOutput) {
            try {
                ssnP.value = encryptionService.decrypt(rsTransactionDetail.getString(detailRow.vendorTaxNumber.index));
            } catch (GeneralSecurityException e) {
                throw new RuntimeException(e);
            }
        }
        // Prepare the whitespace-replaced-with-spaces DV check stub text.
        dvCheckStubTextP.value = rsTransactionDetail.getString(detailRow.dvCheckStubText.index);
        if (StringUtils.isNotBlank(dvCheckStubTextP.value)) {
            dvCheckStubTextP.value = whitespacePattern.matcher(dvCheckStubTextP.value).replaceAll(KRADConstants.BLANK_SPACE);
        }
        // Do the printing.
        resetBuffer(DETAIL_ROW_BUFFER_INDEX);
        appendPieces(DETAIL_ROW_BUFFER_INDEX);
        writeBufferToOutput(DETAIL_ROW_BUFFER_INDEX, 0);
    }
    LOG.info("Finished raw transaction row printing to file.");
}
Also used : Pattern(java.util.regex.Pattern) EncryptionService(org.kuali.rice.core.api.encryption.EncryptionService) GeneralSecurityException(java.security.GeneralSecurityException) TransactionDetailRow(edu.cornell.kfs.tax.dataaccess.impl.TaxTableRow.TransactionDetailRow)

Aggregations

TransactionDetailRow (edu.cornell.kfs.tax.dataaccess.impl.TaxTableRow.TransactionDetailRow)1 GeneralSecurityException (java.security.GeneralSecurityException)1 Pattern (java.util.regex.Pattern)1 EncryptionService (org.kuali.rice.core.api.encryption.EncryptionService)1