From 0838f41d1a70c8379240e55ac735b3fbf1425c25 Mon Sep 17 00:00:00 2001 From: Neha Farheen Date: Tue, 6 Feb 2024 16:08:44 +0530 Subject: [PATCH] MOSIP-30687 partner data changed Signed-off-by: Neha Farheen --- .../impl/OndemandTemplateEventPublisher.java | 31 ++++++++++--------- 1 file changed, 17 insertions(+), 14 deletions(-) diff --git a/authentication/authentication-common/src/main/java/io/mosip/authentication/common/service/websub/impl/OndemandTemplateEventPublisher.java b/authentication/authentication-common/src/main/java/io/mosip/authentication/common/service/websub/impl/OndemandTemplateEventPublisher.java index 1d2818747bf..3296187aafd 100644 --- a/authentication/authentication-common/src/main/java/io/mosip/authentication/common/service/websub/impl/OndemandTemplateEventPublisher.java +++ b/authentication/authentication-common/src/main/java/io/mosip/authentication/common/service/websub/impl/OndemandTemplateEventPublisher.java @@ -122,22 +122,25 @@ public void notify(BaseRequestDTO baserequestdto, String headerSignature, Option private void sendEvents(BaseRequestDTO baserequestdto, String headerSignature, Optional partner, IdAuthenticationBusinessException e, Map metadata) { + logger.info("Inside sendEvents ondemand extraction"); logger.info("Inside partner data to get certificate for ondemand extraction encryption"); Optional partnerDataCert = partnerDataRepo.findByPartnerId(partnerId); - logger.info("End process to get partner data certificate for ondemand extraction encryption"); - logger.info("Inside sendEvents ondemand extraction"); - Map eventData = new HashMap<>(); - eventData.put(ERROR_CODE, e.getErrorCode()); - eventData.put(ERROR_MESSAGE, e.getErrorText()); - eventData.put(REQUESTDATETIME, DateUtils.formatToISOString(DateUtils.getUTCCurrentDateTime())); - eventData.put(INDIVIDUAL_ID, encryptIndividualId(baserequestdto.getIndividualId(), - partnerDataCert.get().getCertificateData())); - eventData.put(AUTH_PARTNER_ID, partner.get().getPartnerId()); - eventData.put(INDIVIDUAL_ID_TYPE, baserequestdto.getIndividualIdType()); - eventData.put(ENTITY_NAME, partner.get().getPartnerName()); - eventData.put(REQUEST_SIGNATURE, headerSignature); - EventModel eventModel = createEventModel(onDemadTemplateExtractionTopic, eventData); - publishEvent(eventModel); + if (partnerDataCert.isEmpty()) { + logger.info("Partner is not configured for on demand extraction."); + } else { + Map eventData = new HashMap<>(); + eventData.put(ERROR_CODE, e.getErrorCode()); + eventData.put(ERROR_MESSAGE, e.getErrorText()); + eventData.put(REQUESTDATETIME, DateUtils.formatToISOString(DateUtils.getUTCCurrentDateTime())); + eventData.put(INDIVIDUAL_ID, + encryptIndividualId(baserequestdto.getIndividualId(), partnerDataCert.get().getCertificateData())); + eventData.put(AUTH_PARTNER_ID, partner.get().getPartnerId()); + eventData.put(INDIVIDUAL_ID_TYPE, baserequestdto.getIndividualIdType()); + eventData.put(ENTITY_NAME, partner.get().getPartnerName()); + eventData.put(REQUEST_SIGNATURE, headerSignature); + EventModel eventModel = createEventModel(onDemadTemplateExtractionTopic, eventData); + publishEvent(eventModel); + } } private EventModel createEventModel(String topic, Map eventData) {