From a216c5c42e167f85c724a0da4ac4d216792652b6 Mon Sep 17 00:00:00 2001 From: smirnovaae Date: Wed, 24 Apr 2024 10:23:04 -0700 Subject: [PATCH] Add printing out trailer line to logs --- .../AttributionDataShareHelper.java | 5 +++-- .../java/gov/cms/ab2d/optout/OptOutProcessor.java | 15 ++++++++++----- 2 files changed, 13 insertions(+), 7 deletions(-) diff --git a/attribution-data-file-share/src/main/java/gov/cms/ab2d/attributionDataShare/AttributionDataShareHelper.java b/attribution-data-file-share/src/main/java/gov/cms/ab2d/attributionDataShare/AttributionDataShareHelper.java index efc6442..a74bf97 100644 --- a/attribution-data-file-share/src/main/java/gov/cms/ab2d/attributionDataShare/AttributionDataShareHelper.java +++ b/attribution-data-file-share/src/main/java/gov/cms/ab2d/attributionDataShare/AttributionDataShareHelper.java @@ -45,8 +45,9 @@ void copyDataToFile(Connection connection) { writer.newLine(); records++; } - writer.write(AB2D_TRAILER_REQ + date + String.format("%010d", records)); - + String lastLine = AB2D_TRAILER_REQ + date + String.format("%010d", records); + writer.write(lastLine); + logger.log("File trailer: " + lastLine); } catch (SQLException | IOException ex) { String errorMessage = "An error occurred while exporting data to a file. "; logger.log(errorMessage + ex.getMessage()); diff --git a/optout/src/main/java/gov/cms/ab2d/optout/OptOutProcessor.java b/optout/src/main/java/gov/cms/ab2d/optout/OptOutProcessor.java index c7b147e..6740faa 100644 --- a/optout/src/main/java/gov/cms/ab2d/optout/OptOutProcessor.java +++ b/optout/src/main/java/gov/cms/ab2d/optout/OptOutProcessor.java @@ -108,9 +108,10 @@ public void updateOptOut() { } public String createResponseContent() { var date = new SimpleDateFormat(EFFECTIVE_DATE_PATTERN).format(new Date()); - var responseContent = new StringBuilder(); - responseContent.append(AB2D_HEADER_CONF).append(date); - responseContent.append(LINE_SEPARATOR); + var responseContent = new StringBuilder() + .append(AB2D_HEADER_CONF) + .append(date) + .append(LINE_SEPARATOR); var recordStatus = getRecordStatus(); var effectiveDate = getEffectiveDate(date); @@ -121,8 +122,12 @@ public String createResponseContent() { .append(recordStatus) .append(LINE_SEPARATOR); } - responseContent.append(AB2D_TRAILER_CONF).append(date).append(String.format("%010d", optOutInformationList.size())); - + var lastLine = new StringBuilder() + .append(AB2D_TRAILER_CONF) + .append(date) + .append(String.format("%010d", optOutInformationList.size())); + responseContent.append(lastLine); + logger.log("File trailer: " + lastLine); return responseContent.toString(); }