diff --git a/src/spd-notification-worker/src/main/java/ca/bc/gov/open/pssg/rsbc/spd/notification/worker/OutputNotificationConsumer.java b/src/spd-notification-worker/src/main/java/ca/bc/gov/open/pssg/rsbc/spd/notification/worker/OutputNotificationConsumer.java index 36596a8a..21270347 100644 --- a/src/spd-notification-worker/src/main/java/ca/bc/gov/open/pssg/rsbc/spd/notification/worker/OutputNotificationConsumer.java +++ b/src/spd-notification-worker/src/main/java/ca/bc/gov/open/pssg/rsbc/spd/notification/worker/OutputNotificationConsumer.java @@ -10,6 +10,7 @@ import ca.bc.gov.open.pssg.rsbc.dps.spd.notification.worker.generated.models.Data; import ca.bc.gov.open.pssg.rsbc.figaro.ords.client.document.*; import org.apache.commons.io.IOUtils; +import org.apache.commons.lang3.StringUtils; import org.slf4j.Logger; import org.slf4j.LoggerFactory; import org.slf4j.MDC; @@ -37,7 +38,7 @@ public class OutputNotificationConsumer { private static final int SUCCESS_CODE = 0; private static final String DPS_FILE_ID_KEY = "dps.fileId"; private static final String DPS_BUSINESS_AREA_CD_KEY = "dps.businessAreaCd"; -; + private static final String DEFAULT_VALUE = "0"; private final FileService fileService; private final SftpProperties sftpProperties; @@ -100,9 +101,8 @@ public void receiveMessage(OutputNotificationMessage message) { .withApplicationPaymentId(documentData.getPvApplicationPaymentId()) .withApplicationIncompleteReason(documentData.getPvApplicationIncompleteReason()) .withApplicationValidateUsername(documentData.getPvValidationUser()) - // ?? document is not referenced ? .withApplicationDocumentGuid(documentResponse.getGuid()) - .withApplPartyId(documentData.getPnApplPartyId()) + .withApplPartyId(defaultValue(documentData.getPnApplPartyId())) .withApplSurname(documentData.getPvApplSurname()) .withApplFirstName(documentData.getPvApplFirstName()) .withApplSecondName(documentData.getPvApplSecondName()) @@ -126,15 +126,18 @@ public void receiveMessage(OutputNotificationMessage message) { .withApplDriversLicence(documentData.getPvApplDriversLicence()) .withApplPhoneNumber(documentData.getPvApplPhoneNumber()) .withApplEmailAddress(documentData.getPvApplEmailAddress()) - .withApplOrgPartyId(documentData.getPnOrgPartyId()) - .withApplOrgFacilityPartyId(documentData.getPnOrgFacilityPartyId()) + .withApplOrgPartyId(defaultValue(documentData.getPnOrgPartyId())) + .withApplOrgFacilityPartyId(defaultValue(documentData.getPnOrgFacilityPartyId())) .withApplOrgFacilityName(documentData.getPvOrgFacilityName()) - .withApplOrgContactPartyId(documentData.getPnOrgContactPartyId()) + .withApplOrgContactPartyId(defaultValue(documentData.getPnOrgContactPartyId())) .build(); + logger.debug("figaro request: {}"); + DpsDataIntoFigaroResponse figaroResponse = documentService.dpsDataIntoFigaro(dpsDataIntoFigaroRequestBody); + if (figaroResponse.getRespCode() == SUCCESS_CODE) { logger.info("success: {} with {}", figaroResponse, fileInfo); fileService.moveFilesToArchive(fileInfo); @@ -189,4 +192,10 @@ private void signalSuccess(OutputNotificationMessage message) { NotificationService.notify(success); } + + private String defaultValue(String value) { + if(StringUtils.isBlank(value)) return DEFAULT_VALUE; + return value; + } + }