diff --git a/pre-registration/pre-registration-application-service/src/main/java/io/mosip/preregistration/application/config/ApplicationEventListerner.java b/pre-registration/pre-registration-application-service/src/main/java/io/mosip/preregistration/application/config/ApplicationEventListerner.java index 29e4f804b95..56d2d03f7a1 100644 --- a/pre-registration/pre-registration-application-service/src/main/java/io/mosip/preregistration/application/config/ApplicationEventListerner.java +++ b/pre-registration/pre-registration-application-service/src/main/java/io/mosip/preregistration/application/config/ApplicationEventListerner.java @@ -11,9 +11,9 @@ import io.mosip.preregistration.application.service.LoginService; import io.mosip.preregistration.core.config.LoggerConfiguration; -import static io.mosip.preregistration.application.constant.PreRegLoginConstant.LOGGER_SESSIONID; -import static io.mosip.preregistration.application.constant.PreRegLoginConstant.LOGGER_IDTYPE; -import static io.mosip.preregistration.application.constant.PreRegLoginConstant.LOGGER_ID; +import static io.mosip.preregistration.application.constant.PreRegApplicationConstant.LOGGER_SESSIONID; +import static io.mosip.preregistration.application.constant.PreRegApplicationConstant.LOGGER_IDTYPE; +import static io.mosip.preregistration.application.constant.PreRegApplicationConstant.LOGGER_ID; @Configuration public class ApplicationEventListerner { diff --git a/pre-registration/pre-registration-application-service/src/main/java/io/mosip/preregistration/application/constant/PreRegApplicationConstant.java b/pre-registration/pre-registration-application-service/src/main/java/io/mosip/preregistration/application/constant/PreRegApplicationConstant.java new file mode 100644 index 00000000000..b6040587905 --- /dev/null +++ b/pre-registration/pre-registration-application-service/src/main/java/io/mosip/preregistration/application/constant/PreRegApplicationConstant.java @@ -0,0 +1,11 @@ +package io.mosip.preregistration.application.constant; + +public class PreRegApplicationConstant { + private PreRegApplicationConstant() { + throw new IllegalStateException("PreRegApplicationConstant class"); + } + + public static final String LOGGER_SESSIONID = "PRE-REGISTRATION"; + public static final String LOGGER_IDTYPE = "APPLICATION SERVICE"; + public static final String LOGGER_ID = ""; +} \ No newline at end of file diff --git a/pre-registration/pre-registration-application-service/src/main/java/io/mosip/preregistration/application/constant/PreRegLoginConstant.java b/pre-registration/pre-registration-application-service/src/main/java/io/mosip/preregistration/application/constant/PreRegLoginConstant.java index e51d5ff3759..3c62fe5b7a4 100644 --- a/pre-registration/pre-registration-application-service/src/main/java/io/mosip/preregistration/application/constant/PreRegLoginConstant.java +++ b/pre-registration/pre-registration-application-service/src/main/java/io/mosip/preregistration/application/constant/PreRegLoginConstant.java @@ -4,10 +4,6 @@ public class PreRegLoginConstant { private PreRegLoginConstant() { throw new IllegalStateException("PreRegLoginConstant class"); } - - public static final String LOGGER_SESSIONID = "PRE-REGISTRATION"; - public static final String LOGGER_IDTYPE = "APPLICATION SERVICE"; - public static final String LOGGER_ID = ""; public static final String OTP_SMS_TEMPLATE = "pre.reg.login.otp.sms.template"; public static final String OTP_SUBJECT_TEMPLATE = "pre.reg.login.otp.mail.subject.template"; @@ -32,4 +28,4 @@ private PreRegLoginConstant() { public static final String VALIDATE_ERROR_MESSAGE = "Validation can't be performed against this key. Generate OTP first."; public static final String VALIDATE_ERROR_CODE = "KER-OTV-005"; public static final String MOSIP_PRIMARY_LANGUAGE = "mosip.primary-language"; -} +} \ No newline at end of file diff --git a/pre-registration/pre-registration-application-service/src/main/java/io/mosip/preregistration/application/controller/AppointmentController.java b/pre-registration/pre-registration-application-service/src/main/java/io/mosip/preregistration/application/controller/AppointmentController.java index f2381e0e659..ef30bb4f403 100644 --- a/pre-registration/pre-registration-application-service/src/main/java/io/mosip/preregistration/application/controller/AppointmentController.java +++ b/pre-registration/pre-registration-application-service/src/main/java/io/mosip/preregistration/application/controller/AppointmentController.java @@ -37,6 +37,9 @@ import io.swagger.v3.oas.annotations.responses.ApiResponse; import io.swagger.v3.oas.annotations.responses.ApiResponses; import io.swagger.v3.oas.annotations.tags.Tag; +import static io.mosip.preregistration.application.constant.PreRegApplicationConstant.LOGGER_SESSIONID; +import static io.mosip.preregistration.application.constant.PreRegApplicationConstant.LOGGER_IDTYPE; +import static io.mosip.preregistration.application.constant.PreRegApplicationConstant.LOGGER_ID; @RestController @Tag(name = "appointment-controller", description = "Appointment Controller") @@ -57,7 +60,7 @@ public class AppointmentController { @ApiResponse(responseCode = "404", description = "Not Found", content = @Content(schema = @Schema(hidden = true))) }) public ResponseEntity> getAvailability( @PathVariable("registrationCenterId") String registrationCenterId) { - log.info("fetch availablity for regID: {}", registrationCenterId); + log.info(LOGGER_SESSIONID, LOGGER_IDTYPE, LOGGER_ID, "fetch availablity for regID: " + registrationCenterId); return ResponseEntity.status(HttpStatus.OK).body(appointmentService.getSlotAvailablity(registrationCenterId)); } @@ -73,7 +76,7 @@ public ResponseEntity> bookAppoinment( @PathVariable("preRegistrationId") String preRegistrationId, @Validated @RequestBody(required = true) MainRequestDTO bookingDTO, @ApiParam(hidden = true) Errors errors, @RequestHeader(value = "User-Agent") String userAgent) { - log.info("Book an appointment for preRegId: {}", preRegistrationId); + log.info(LOGGER_SESSIONID, LOGGER_IDTYPE, LOGGER_ID, "Book an appointment for preRegId: " + preRegistrationId); return ResponseEntity.status(HttpStatus.OK) .body(appointmentService.makeAppointment(bookingDTO, preRegistrationId, userAgent)); } @@ -88,7 +91,8 @@ public ResponseEntity> bookAppoinment( @ApiResponse(responseCode = "404", description = "Not Found", content = @Content(schema = @Schema(hidden = true))) }) public ResponseEntity> getAppointments( @PathVariable("preRegistrationId") String preRegistrationId) { - log.info("To fetch appointment details for preRegID: {}", preRegistrationId); + log.info(LOGGER_SESSIONID, LOGGER_IDTYPE, LOGGER_ID, + "To fetch appointment details for preRegID: " + preRegistrationId); return ResponseEntity.status(HttpStatus.OK).body(appointmentService.getAppointmentDetails(preRegistrationId)); } @@ -102,7 +106,8 @@ public ResponseEntity> getAppointments( @ApiResponse(responseCode = "404", description = "Not Found", content = @Content(schema = @Schema(hidden = true))) }) public ResponseEntity> cancelBook( @PathVariable("preRegistrationId") String preRegistrationId) { - log.info("Cancel the appointment for preRegId :{} ", preRegistrationId); + log.info(LOGGER_SESSIONID, LOGGER_IDTYPE, LOGGER_ID, + "Cancel the appointment for preRegId : " + preRegistrationId); return ResponseEntity.status(HttpStatus.OK).body(appointmentService.cancelAppointment(preRegistrationId)); } @@ -116,7 +121,8 @@ public ResponseEntity> cancelBook( @ApiResponse(responseCode = "404", description = "Not Found", content = @Content(schema = @Schema(hidden = true))) }) public ResponseEntity> internalCancelBook( @PathVariable("preRegistrationId") String preRegistrationId) { - log.info("Cancel the appointment for preRegId called internally :{} ", preRegistrationId); + log.info(LOGGER_SESSIONID, LOGGER_IDTYPE, LOGGER_ID, + "Cancel the appointment for preRegId called internally :" + preRegistrationId); return ResponseEntity.status(HttpStatus.OK).body(appointmentService.cancelAppointment(preRegistrationId)); } @@ -129,7 +135,7 @@ public ResponseEntity> internalCancelB @ApiResponse(responseCode = "403", description = "Forbidden", content = @Content(schema = @Schema(hidden = true))), }) public ResponseEntity> discardIndividual( @RequestParam(value = "preRegistrationId") String preId) { - log.info("Delete booking with preId: {}", preId); + log.info(LOGGER_SESSIONID, LOGGER_IDTYPE, LOGGER_ID, "Delete booking with preId: " + preId); return ResponseEntity.status(HttpStatus.OK) .body(appointmentService.deleteBookingAndUpdateApplicationStatus(preId)); } diff --git a/pre-registration/pre-registration-application-service/src/main/java/io/mosip/preregistration/application/controller/DemographicController.java b/pre-registration/pre-registration-application-service/src/main/java/io/mosip/preregistration/application/controller/DemographicController.java index a9a0f97cab4..2f37d12948f 100644 --- a/pre-registration/pre-registration-application-service/src/main/java/io/mosip/preregistration/application/controller/DemographicController.java +++ b/pre-registration/pre-registration-application-service/src/main/java/io/mosip/preregistration/application/controller/DemographicController.java @@ -49,9 +49,9 @@ import io.swagger.v3.oas.annotations.tags.Tag; import jakarta.servlet.http.HttpServletRequest; -import static io.mosip.preregistration.application.constant.PreRegLoginConstant.LOGGER_SESSIONID; -import static io.mosip.preregistration.application.constant.PreRegLoginConstant.LOGGER_IDTYPE; -import static io.mosip.preregistration.application.constant.PreRegLoginConstant.LOGGER_ID; +import static io.mosip.preregistration.application.constant.PreRegApplicationConstant.LOGGER_SESSIONID; +import static io.mosip.preregistration.application.constant.PreRegApplicationConstant.LOGGER_IDTYPE; +import static io.mosip.preregistration.application.constant.PreRegApplicationConstant.LOGGER_ID; /** * This class provides different API's to perform operations on @@ -313,8 +313,9 @@ public ResponseEntity>> getUpdatedDateTimeBy @ApiResponse(responseCode = "404", description = "Not Found", content = @Content(schema = @Schema(hidden = true))) }) public ResponseEntity> getPreRegDemographicAndDocumentData( @PathVariable("preregistrationId") String preregistrationId) { - log.info(LOGGER_SESSIONID, LOGGER_IDTYPE, LOGGER_ID, "In demographic controller to getFullPreRegApplication " + preregistrationId); + log.info(LOGGER_SESSIONID, LOGGER_IDTYPE, LOGGER_ID, + "In demographic controller to getFullPreRegApplication " + preregistrationId); return ResponseEntity.status(HttpStatus.OK) .body(preRegistrationService.getPregistrationInfo(preregistrationId)); } -} +} \ No newline at end of file diff --git a/pre-registration/pre-registration-application-service/src/main/java/io/mosip/preregistration/application/controller/DocumentController.java b/pre-registration/pre-registration-application-service/src/main/java/io/mosip/preregistration/application/controller/DocumentController.java index 5f3edc9f229..d48c866bd95 100644 --- a/pre-registration/pre-registration-application-service/src/main/java/io/mosip/preregistration/application/controller/DocumentController.java +++ b/pre-registration/pre-registration-application-service/src/main/java/io/mosip/preregistration/application/controller/DocumentController.java @@ -36,6 +36,10 @@ import io.swagger.v3.oas.annotations.tags.Tag; import jakarta.validation.Valid; +import static io.mosip.preregistration.application.constant.PreRegApplicationConstant.LOGGER_SESSIONID; +import static io.mosip.preregistration.application.constant.PreRegApplicationConstant.LOGGER_IDTYPE; +import static io.mosip.preregistration.application.constant.PreRegApplicationConstant.LOGGER_ID; + /** * This class provides different API's to perform operations on Document upload. * @@ -81,11 +85,11 @@ public ResponseEntity> fileUpload( @PathVariable(value = "preRegistrationId") String preRegistrationId, @RequestPart(value = "Document request", required = true) String reqDto, @RequestPart(value = "file", required = true) MultipartFile file) { - log.debug("sessionId", "idType", "id", "In doc controller "); - log.debug("sessionId", "idType", "id", "Pre-id " + preRegistrationId); - log.info("sessionId", "idType", "id", - "In fileUpload method of document controller to upload the document for request " + reqDto.toString()); - log.info("sessionId", "idType", "id", "iN Controller v2"); + log.debug(LOGGER_SESSIONID, LOGGER_IDTYPE, LOGGER_ID, "In doc controller "); + log.debug(LOGGER_SESSIONID, LOGGER_IDTYPE, LOGGER_ID, "Pre-id " + preRegistrationId); + log.info(LOGGER_SESSIONID, LOGGER_IDTYPE, LOGGER_ID, + "In fileUpload method of document controller to upload the document for request " + reqDto); + log.info(LOGGER_SESSIONID, LOGGER_IDTYPE, LOGGER_ID, "iN Controller v2"); return ResponseEntity.status(HttpStatus.OK) .body(documentUploadService.uploadDocument(file, reqDto, preRegistrationId)); @@ -116,7 +120,7 @@ public ResponseEntity> copyDocument( @Valid @RequestParam(required = true) String catCode, @Valid @RequestParam(required = true) String sourcePreId) { - log.info("sessionId", "idType", "id", + log.info(LOGGER_SESSIONID, LOGGER_IDTYPE, LOGGER_ID, "In copyDocument method of document controller to copy the document for request " + catCode + "," + sourcePreId + "," + preRegistrationId); return ResponseEntity.status(HttpStatus.OK) @@ -140,7 +144,7 @@ public ResponseEntity> copyDocument( @ApiResponse(responseCode = "404", description = "Not Found", content = @Content(schema = @Schema(hidden = true))) }) public ResponseEntity> getAllDocumentforPreid( @Valid @PathVariable(required = true) String preRegistrationId) { - log.info("sessionId", "idType", "id", + log.info(LOGGER_SESSIONID, LOGGER_IDTYPE, LOGGER_ID, "In getAllDocumentforPreid method of document controller to get all the document for pre_registration_id " + preRegistrationId); return ResponseEntity.status(HttpStatus.OK) @@ -166,7 +170,7 @@ public ResponseEntity> getAllDocumentforPreid public ResponseEntity> getDocumentforDocId( @Valid @PathVariable(required = true) String documentId, @Valid @RequestParam(required = true, value = "preRegistrationId") String preRegistrationId) { - log.info("sessionId", "idType", "id", + log.info(LOGGER_SESSIONID, LOGGER_IDTYPE, LOGGER_ID, "In getAllDocumentforDocId method of document controller to get all the document for documentId " + documentId); return ResponseEntity.status(HttpStatus.OK) @@ -181,7 +185,6 @@ public ResponseEntity> getDocumentforDocId( * @param preRegistrationId pass the preRegistratoinId * @return response in a format specified in API document */ - // @PreAuthorize("hasAnyRole('INDIVIDUAL')") @PreAuthorize("hasAnyRole(@authorizedRoles.getDeletedocumentsdocumentid())") @DeleteMapping(path = "/documents/{documentId}", produces = MediaType.APPLICATION_JSON_VALUE) @@ -193,7 +196,7 @@ public ResponseEntity> getDocumentforDocId( public ResponseEntity> deleteDocument( @Valid @PathVariable(required = true) String documentId, @Valid @RequestParam(required = true, value = "preRegistrationId") String preRegistrationId) { - log.info("sessionId", "idType", "id", + log.info(LOGGER_SESSIONID, LOGGER_IDTYPE, LOGGER_ID, "In deleteDocument method of document controller to delete the document for documentId " + documentId); return ResponseEntity.status(HttpStatus.OK) .body(documentUploadService.deleteDocument(documentId, preRegistrationId)); @@ -216,7 +219,7 @@ public ResponseEntity> deleteDocument @ApiResponse(responseCode = "403", description = "Forbidden", content = @Content(schema = @Schema(hidden = true))), }) public ResponseEntity> deleteAllByPreId( @Valid @PathVariable(required = true) String preRegistrationId) { - log.info("sessionId", "idType", "id", + log.info(LOGGER_SESSIONID, LOGGER_IDTYPE, LOGGER_ID, "In deleteDocument method of document controller to delete all the document for preId " + preRegistrationId); return ResponseEntity.status(HttpStatus.OK).body(documentUploadService.deleteAllByPreId(preRegistrationId)); @@ -237,7 +240,7 @@ public ResponseEntity> updateDocRefId( @Valid @PathVariable(required = true) String documentId, @Valid @RequestParam(required = true, value = "preRegistrationId") String preRegistrationId, @Valid @RequestParam(required = true, value = "refNumber") String refNumebr) { - log.info("sessionId", "idType", "id", + log.info(LOGGER_SESSIONID, LOGGER_IDTYPE, LOGGER_ID, "In updateDocRefId method of document controller to update the docRefId for documentId " + documentId + "preregistrationId " + preRegistrationId + "DocRefId " + refNumebr); return ResponseEntity.status(HttpStatus.OK) diff --git a/pre-registration/pre-registration-application-service/src/main/java/io/mosip/preregistration/application/controller/GenerateQRcodeController.java b/pre-registration/pre-registration-application-service/src/main/java/io/mosip/preregistration/application/controller/GenerateQRcodeController.java index 32add8bc81b..1718797fe53 100644 --- a/pre-registration/pre-registration-application-service/src/main/java/io/mosip/preregistration/application/controller/GenerateQRcodeController.java +++ b/pre-registration/pre-registration-application-service/src/main/java/io/mosip/preregistration/application/controller/GenerateQRcodeController.java @@ -30,6 +30,10 @@ import io.swagger.v3.oas.annotations.responses.ApiResponses; import io.swagger.v3.oas.annotations.tags.Tag; +import static io.mosip.preregistration.application.constant.PreRegApplicationConstant.LOGGER_SESSIONID; +import static io.mosip.preregistration.application.constant.PreRegApplicationConstant.LOGGER_IDTYPE; +import static io.mosip.preregistration.application.constant.PreRegApplicationConstant.LOGGER_ID; + /** * This class provides API's to generate the QR code operations on * pre-registration. @@ -79,7 +83,7 @@ public void initBinder(WebDataBinder binder) { @ApiResponse(responseCode = "404", description = "Not Found", content = @Content(schema = @Schema(hidden = true))) }) public ResponseEntity> generateQRCode( @Validated @RequestBody MainRequestDTO data, @ApiParam(hidden = true) Errors errors) { - log.info("sessionId", "idType", "id", + log.info(LOGGER_SESSIONID, LOGGER_IDTYPE, LOGGER_ID, "In generateQRCode controller for generateQRCode generation with request " + data); requestValidator.validateId(QRCODE, data.getId(), errors); DataValidationUtil.validate(errors, QRCODE); diff --git a/pre-registration/pre-registration-application-service/src/main/java/io/mosip/preregistration/application/controller/LoginController.java b/pre-registration/pre-registration-application-service/src/main/java/io/mosip/preregistration/application/controller/LoginController.java index c2cdb1501af..831faec2129 100644 --- a/pre-registration/pre-registration-application-service/src/main/java/io/mosip/preregistration/application/controller/LoginController.java +++ b/pre-registration/pre-registration-application-service/src/main/java/io/mosip/preregistration/application/controller/LoginController.java @@ -1,5 +1,9 @@ package io.mosip.preregistration.application.controller; +import static io.mosip.preregistration.application.constant.PreRegApplicationConstant.LOGGER_ID; +import static io.mosip.preregistration.application.constant.PreRegApplicationConstant.LOGGER_IDTYPE; +import static io.mosip.preregistration.application.constant.PreRegApplicationConstant.LOGGER_SESSIONID; + import java.util.Map; import java.util.Objects; @@ -117,7 +121,6 @@ public void initBinder(WebDataBinder binder) { public ResponseEntity> sendOTP( @Validated @RequestBody MainRequestDTO userOtpRequest, @ApiParam(hidden = true) Errors errors) { - loginValidator.validateId(SENDOTP, userOtpRequest.getId(), errors); DataValidationUtil.validate(errors, SENDOTP); if (!allowSendOtpApi) @@ -146,7 +149,6 @@ public ResponseEntity> sendOTP( public ResponseEntity> sendOTPWithLangCode( @Validated @RequestBody MainRequestDTO userOtpRequest, @ApiParam(hidden = true) Errors errors) { - loginValidator.validateId(SENDOTP, userOtpRequest.getId(), errors); DataValidationUtil.validate(errors, SENDOTP); MainRequestDTO MainRequestDTO = new MainRequestDTO<>(); @@ -178,7 +180,7 @@ public ResponseEntity> validateWithUserIdOtp( @Validated @RequestBody MainRequestDTO userIdOtpRequest, @ApiParam(hidden = true) Errors errors, HttpServletResponse res, HttpServletRequest req) { - log.debug("User ID: {}", userIdOtpRequest.getRequest().getUserId()); + log.debug(LOGGER_SESSIONID, LOGGER_IDTYPE, LOGGER_ID, "User ID: "+ userIdOtpRequest.getRequest().getUserId()); loginValidator.validateId(VALIDATEOTP, userIdOtpRequest.getId(), errors); DataValidationUtil.validate(errors, VALIDATEOTP); MainResponseDTO responseBody = loginService.validateWithUserIdOtp(userIdOtpRequest); diff --git a/pre-registration/pre-registration-application-service/src/main/java/io/mosip/preregistration/application/controller/LostUINController.java b/pre-registration/pre-registration-application-service/src/main/java/io/mosip/preregistration/application/controller/LostUINController.java index 7977e151f16..49c52aa1804 100644 --- a/pre-registration/pre-registration-application-service/src/main/java/io/mosip/preregistration/application/controller/LostUINController.java +++ b/pre-registration/pre-registration-application-service/src/main/java/io/mosip/preregistration/application/controller/LostUINController.java @@ -1,5 +1,9 @@ package io.mosip.preregistration.application.controller; +import static io.mosip.preregistration.application.constant.PreRegApplicationConstant.LOGGER_SESSIONID; +import static io.mosip.preregistration.application.constant.PreRegApplicationConstant.LOGGER_IDTYPE; +import static io.mosip.preregistration.application.constant.PreRegApplicationConstant.LOGGER_ID; + import org.springframework.beans.factory.annotation.Autowired; import org.springframework.http.HttpStatus; import org.springframework.http.MediaType; @@ -78,7 +82,7 @@ public void initBinder(WebDataBinder binder) { public ResponseEntity> addLostUinApplication( @Validated @RequestBody(required = true) MainRequestDTO jsonObject, @ApiParam(hidden = true) Errors errors) { - log.info("sessionId", "idType", "id", + log.info(LOGGER_SESSIONID, LOGGER_IDTYPE, LOGGER_ID, "In pre-registration LostUINController for createNewApplication with json object" + jsonObject); requestValidator.validateId(LOST_UIN_CREATE_ID, jsonObject.getId(), errors); DataValidationUtil.validate(errors, LOST_UIN_CREATE_ID); @@ -102,7 +106,7 @@ public ResponseEntity> addLostUinApplica @ApiResponse(responseCode = "403", description = "Forbidden", content = @Content(schema = @Schema(hidden = true))), }) public ResponseEntity> deleteLostUinApplication( @PathVariable("applicationId") String applicationId) { - log.info("sessionId", "idType", "id", + log.info(LOGGER_SESSIONID, LOGGER_IDTYPE, LOGGER_ID, "In pre-registration LostUINController for deleteApplication with preId " + applicationId); return ResponseEntity.status(HttpStatus.OK).body(applicationService.deleteLostOrUpdateApplication(applicationId, BookingTypeCodes.LOST_FORGOTTEN_UIN.toString())); diff --git a/pre-registration/pre-registration-application-service/src/main/java/io/mosip/preregistration/application/controller/NotificationController.java b/pre-registration/pre-registration-application-service/src/main/java/io/mosip/preregistration/application/controller/NotificationController.java index 464b97020c6..ae53e479d87 100644 --- a/pre-registration/pre-registration-application-service/src/main/java/io/mosip/preregistration/application/controller/NotificationController.java +++ b/pre-registration/pre-registration-application-service/src/main/java/io/mosip/preregistration/application/controller/NotificationController.java @@ -1,5 +1,9 @@ package io.mosip.preregistration.application.controller; +import static io.mosip.preregistration.application.constant.PreRegApplicationConstant.LOGGER_SESSIONID; +import static io.mosip.preregistration.application.constant.PreRegApplicationConstant.LOGGER_IDTYPE; +import static io.mosip.preregistration.application.constant.PreRegApplicationConstant.LOGGER_ID; + import jakarta.servlet.http.HttpServletRequest; import io.swagger.v3.oas.annotations.media.Content; @@ -63,9 +67,9 @@ public ResponseEntity> sendNotification @RequestPart(value = "NotificationRequestDTO", required = true) String jsonbObject, @RequestPart(value = "langCode", required = true) String langCode, @RequestPart(value = "attachment", required = false) MultipartFile file, HttpServletRequest res) { - log.info("sessionId", "idType", "id", + log.info(LOGGER_SESSIONID, LOGGER_IDTYPE, LOGGER_ID, "In notification controller for send notification with request notification dto " + jsonbObject); - log.debug("sessionId", "idType", "id", res.getHeader("Cookie")); + log.debug(LOGGER_SESSIONID, LOGGER_IDTYPE, LOGGER_ID, res.getHeader("Cookie")); return new ResponseEntity<>(notificationService.sendNotification(jsonbObject, langCode, file, false), HttpStatus.OK); } @@ -91,9 +95,9 @@ public ResponseEntity> sendNotification @RequestPart(value = "NotificationRequestDTO", required = true) String jsonbObject, @RequestPart(value = "langCode", required = false) String langCode, @RequestPart(value = "attachment", required = false) MultipartFile file, HttpServletRequest res) { - log.info("sessionId", "idType", "id", + log.info(LOGGER_SESSIONID, LOGGER_IDTYPE, LOGGER_ID, "In notification controller for send notification with request notification dto " + jsonbObject); - log.debug("sessionId", "idType", "id", res.getHeader("Cookie")); + log.debug(LOGGER_SESSIONID, LOGGER_IDTYPE, LOGGER_ID, res.getHeader("Cookie")); return new ResponseEntity<>(notificationService.sendNotification(jsonbObject, langCode, file, true), HttpStatus.OK); } @@ -119,10 +123,10 @@ public ResponseEntity> sendNotification @RequestPart(value = "NotificationRequestDTO", required = true) String jsonbObject, @RequestPart(value = "langCode", required = false) String langCode, @RequestPart(value = "attachment", required = false) MultipartFile file, HttpServletRequest res) { - log.info("sessionId", "idType", "id", + log.info(LOGGER_SESSIONID, LOGGER_IDTYPE, LOGGER_ID, "In notification controller for sendNotificationsInternal() with request notification dto " + jsonbObject); - log.debug("sessionId", "idType", "id", res.getHeader("Cookie")); + log.debug(LOGGER_SESSIONID, LOGGER_IDTYPE, LOGGER_ID, res.getHeader("Cookie")); return new ResponseEntity<>(notificationService.sendNotification(jsonbObject, langCode, file, false), HttpStatus.OK); } diff --git a/pre-registration/pre-registration-application-service/src/main/java/io/mosip/preregistration/application/controller/ProxyMasterdataController.java b/pre-registration/pre-registration-application-service/src/main/java/io/mosip/preregistration/application/controller/ProxyMasterdataController.java index abea0926a30..d8b42e7d303 100644 --- a/pre-registration/pre-registration-application-service/src/main/java/io/mosip/preregistration/application/controller/ProxyMasterdataController.java +++ b/pre-registration/pre-registration-application-service/src/main/java/io/mosip/preregistration/application/controller/ProxyMasterdataController.java @@ -1,5 +1,9 @@ package io.mosip.preregistration.application.controller; +import static io.mosip.preregistration.application.constant.PreRegApplicationConstant.LOGGER_SESSIONID; +import static io.mosip.preregistration.application.constant.PreRegApplicationConstant.LOGGER_IDTYPE; +import static io.mosip.preregistration.application.constant.PreRegApplicationConstant.LOGGER_ID; + import org.springframework.beans.factory.annotation.Autowired; import org.springframework.http.HttpStatus; import org.springframework.http.MediaType; @@ -37,7 +41,7 @@ public class ProxyMasterdataController { @ApiResponse(responseCode = "404", description = "Not Found", content = @Content(schema = @Schema(hidden = true))) }) public ResponseEntity masterDataGetProxyController(@RequestBody(required = false) String body, HttpServletRequest request) { - log.info("sessionId", "idType", "id", + log.info(LOGGER_SESSIONID, LOGGER_IDTYPE, LOGGER_ID, "In masterDataGetProxyController method with request url: " + request.getRequestURI()); return ResponseEntity.status(HttpStatus.OK).body(service.getMasterDataResponse(body, request)); } @@ -50,7 +54,7 @@ public ResponseEntity masterDataGetProxyController(@RequestBody(required = fa @ApiResponse(responseCode = "404", description = "Not Found", content = @Content(schema = @Schema(hidden = true))) }) public ResponseEntity masterDataPostProxyController(@RequestBody(required = false) String body, HttpServletRequest request) { - log.info("sessionId", "idType", "id", + log.info(LOGGER_SESSIONID, LOGGER_IDTYPE, LOGGER_ID, "In masterDataPostProxyController method with request url" + request.getRequestURI()); return ResponseEntity.status(HttpStatus.OK).body(service.getMasterDataResponse(body, request)); } diff --git a/pre-registration/pre-registration-application-service/src/main/java/io/mosip/preregistration/application/controller/UISpecificationController.java b/pre-registration/pre-registration-application-service/src/main/java/io/mosip/preregistration/application/controller/UISpecificationController.java index 50f3191d62e..58db440e3b1 100644 --- a/pre-registration/pre-registration-application-service/src/main/java/io/mosip/preregistration/application/controller/UISpecificationController.java +++ b/pre-registration/pre-registration-application-service/src/main/java/io/mosip/preregistration/application/controller/UISpecificationController.java @@ -1,5 +1,9 @@ package io.mosip.preregistration.application.controller; +import static io.mosip.preregistration.application.constant.PreRegApplicationConstant.LOGGER_ID; +import static io.mosip.preregistration.application.constant.PreRegApplicationConstant.LOGGER_IDTYPE; +import static io.mosip.preregistration.application.constant.PreRegApplicationConstant.LOGGER_SESSIONID; + import org.springframework.beans.factory.annotation.Autowired; import org.springframework.http.HttpStatus; import org.springframework.http.ResponseEntity; @@ -42,8 +46,8 @@ public class UISpecificationController { public ResponseEntity> getLatestPublishedSchema( @RequestParam(name = "version", defaultValue = "0", required = false) @ApiParam(value = "version", defaultValue = "0") double version, @RequestParam(name = "identitySchemaVersion", defaultValue = "0", required = false) @ApiParam(value = "version", defaultValue = "0") double identitySchemaVersion) { - log.info("In UISpecification Controller to getLatestPublishedSchema"); - log.info("version {} identitySchemaVersion {}", version, identitySchemaVersion); + log.info(LOGGER_SESSIONID, LOGGER_IDTYPE, LOGGER_ID,"In UISpecification Controller to getLatestPublishedSchema"); + log.info(LOGGER_SESSIONID, LOGGER_IDTYPE, LOGGER_ID, "version {" + version + "} identitySchemaVersion {" + identitySchemaVersion + "}"); return ResponseEntity.status(HttpStatus.OK).body(uiSpecService.getLatestUISpec(version, identitySchemaVersion)); } @@ -58,7 +62,7 @@ public ResponseEntity> getLatestPublishedSche public ResponseEntity>> getAllPublishedSchema( @RequestParam(name = "pageNumber", defaultValue = "0") @ApiParam(value = "page number", defaultValue = "0") int pageNumber, @RequestParam(name = "pageSize", defaultValue = "10") @ApiParam(value = "page size", defaultValue = "10") int pageSize) { - log.info("In UISpecification Controller to getAllPublishedSchema"); + log.info(LOGGER_SESSIONID, LOGGER_IDTYPE, LOGGER_ID, "In UISpecification Controller to getAllPublishedSchema"); return ResponseEntity.status(HttpStatus.OK).body(uiSpecService.getAllUISpec(pageNumber, pageSize)); } } \ No newline at end of file diff --git a/pre-registration/pre-registration-application-service/src/main/java/io/mosip/preregistration/application/controller/UpdateRegistrationController.java b/pre-registration/pre-registration-application-service/src/main/java/io/mosip/preregistration/application/controller/UpdateRegistrationController.java index 3480e24e3b5..4bb2b0515bb 100644 --- a/pre-registration/pre-registration-application-service/src/main/java/io/mosip/preregistration/application/controller/UpdateRegistrationController.java +++ b/pre-registration/pre-registration-application-service/src/main/java/io/mosip/preregistration/application/controller/UpdateRegistrationController.java @@ -1,5 +1,9 @@ package io.mosip.preregistration.application.controller; +import static io.mosip.preregistration.application.constant.PreRegApplicationConstant.LOGGER_SESSIONID; +import static io.mosip.preregistration.application.constant.PreRegApplicationConstant.LOGGER_IDTYPE; +import static io.mosip.preregistration.application.constant.PreRegApplicationConstant.LOGGER_ID; + import org.springframework.beans.factory.annotation.Autowired; import org.springframework.http.HttpStatus; import org.springframework.http.MediaType; @@ -79,7 +83,7 @@ public void initBinder(WebDataBinder binder) { public ResponseEntity> addUpdateRegistration( @Validated @RequestBody(required = true) MainRequestDTO jsonObject, @ApiParam(hidden = true) Errors errors) { - log.info("sessionId", "idType", "id", + log.info(LOGGER_SESSIONID, LOGGER_IDTYPE, LOGGER_ID, "In pre-registration UpdateRegistrationController for createNewApplication with json object" + jsonObject); requestValidator.validateId(UPDATE_REGISTRATION_CREATE_ID, jsonObject.getId(), errors); @@ -104,7 +108,7 @@ public ResponseEntity> addUpdateRegistra @ApiResponse(responseCode = "403", description = "Forbidden", content = @Content(schema = @Schema(hidden = true))), }) public ResponseEntity> deleteUpdateRegistration( @PathVariable("applicationId") String applicationId) { - log.info("sessionId", "idType", "id", + log.info(LOGGER_SESSIONID, LOGGER_IDTYPE, LOGGER_ID, "In pre-registration LostUINController for deleteApplication with preId " + applicationId); return ResponseEntity.status(HttpStatus.OK).body(applicationService.deleteLostOrUpdateApplication(applicationId, diff --git a/pre-registration/pre-registration-application-service/src/main/java/io/mosip/preregistration/application/dto/DocumentResponseDTO.java b/pre-registration/pre-registration-application-service/src/main/java/io/mosip/preregistration/application/dto/DocumentResponseDTO.java index 9ba43891825..20a9bd1689d 100644 --- a/pre-registration/pre-registration-application-service/src/main/java/io/mosip/preregistration/application/dto/DocumentResponseDTO.java +++ b/pre-registration/pre-registration-application-service/src/main/java/io/mosip/preregistration/application/dto/DocumentResponseDTO.java @@ -6,8 +6,6 @@ import java.io.Serializable; -import com.fasterxml.jackson.annotation.JsonProperty; - import lombok.Getter; import lombok.NoArgsConstructor; import lombok.Setter; diff --git a/pre-registration/pre-registration-application-service/src/main/java/io/mosip/preregistration/application/dto/OTPGenerateRequestDTO.java b/pre-registration/pre-registration-application-service/src/main/java/io/mosip/preregistration/application/dto/OTPGenerateRequestDTO.java index eb8ea5eee28..8041dc77996 100644 --- a/pre-registration/pre-registration-application-service/src/main/java/io/mosip/preregistration/application/dto/OTPGenerateRequestDTO.java +++ b/pre-registration/pre-registration-application-service/src/main/java/io/mosip/preregistration/application/dto/OTPGenerateRequestDTO.java @@ -6,12 +6,9 @@ import com.fasterxml.jackson.annotation.JsonFormat; -import lombok.AccessLevel; import lombok.AllArgsConstructor; import lombok.Data; -import lombok.Getter; import lombok.NoArgsConstructor; -import lombok.Setter; @Data @NoArgsConstructor diff --git a/pre-registration/pre-registration-application-service/src/main/java/io/mosip/preregistration/application/dto/UISpecMetaDataDTO.java b/pre-registration/pre-registration-application-service/src/main/java/io/mosip/preregistration/application/dto/UISpecMetaDataDTO.java index b3239b8c8e2..ead69e08f84 100644 --- a/pre-registration/pre-registration-application-service/src/main/java/io/mosip/preregistration/application/dto/UISpecMetaDataDTO.java +++ b/pre-registration/pre-registration-application-service/src/main/java/io/mosip/preregistration/application/dto/UISpecMetaDataDTO.java @@ -3,7 +3,6 @@ import java.time.LocalDateTime; import com.fasterxml.jackson.databind.JsonNode; -import org.json.simple.JSONObject; import lombok.Data; diff --git a/pre-registration/pre-registration-application-service/src/main/java/io/mosip/preregistration/application/dto/UISpecResponseDTO.java b/pre-registration/pre-registration-application-service/src/main/java/io/mosip/preregistration/application/dto/UISpecResponseDTO.java index e7b7b63d5bd..29ff7405e4b 100644 --- a/pre-registration/pre-registration-application-service/src/main/java/io/mosip/preregistration/application/dto/UISpecResponseDTO.java +++ b/pre-registration/pre-registration-application-service/src/main/java/io/mosip/preregistration/application/dto/UISpecResponseDTO.java @@ -3,8 +3,6 @@ import java.time.LocalDateTime; import java.util.List; -import com.fasterxml.jackson.annotation.JsonIgnore; - import lombok.Data; @Data diff --git a/pre-registration/pre-registration-application-service/src/main/java/io/mosip/preregistration/application/repository/DocumentDAO.java b/pre-registration/pre-registration-application-service/src/main/java/io/mosip/preregistration/application/repository/DocumentDAO.java index 3500488dee5..212bdfe2e4e 100644 --- a/pre-registration/pre-registration-application-service/src/main/java/io/mosip/preregistration/application/repository/DocumentDAO.java +++ b/pre-registration/pre-registration-application-service/src/main/java/io/mosip/preregistration/application/repository/DocumentDAO.java @@ -1,22 +1,27 @@ package io.mosip.preregistration.application.repository; +import static io.mosip.preregistration.application.constant.PreRegApplicationConstant.LOGGER_ID; +import static io.mosip.preregistration.application.constant.PreRegApplicationConstant.LOGGER_IDTYPE; +import static io.mosip.preregistration.application.constant.PreRegApplicationConstant.LOGGER_SESSIONID; + import java.util.List; +import org.apache.commons.lang.exception.ExceptionUtils; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Qualifier; import org.springframework.stereotype.Component; import io.mosip.kernel.core.dataaccess.exception.DataAccessLayerException; import io.mosip.kernel.core.logger.spi.Logger; -import io.mosip.preregistration.core.common.entity.DemographicEntity; -import io.mosip.preregistration.core.common.entity.DocumentEntity; -import io.mosip.preregistration.core.config.LoggerConfiguration; -import io.mosip.preregistration.core.exception.TableNotAccessibleException; import io.mosip.preregistration.application.code.DocumentStatusMessages; import io.mosip.preregistration.application.errorcodes.DocumentErrorCodes; import io.mosip.preregistration.application.errorcodes.DocumentErrorMessages; import io.mosip.preregistration.application.exception.DocumentNotFoundException; import io.mosip.preregistration.application.service.util.DocumentServiceUtil; +import io.mosip.preregistration.core.common.entity.DemographicEntity; +import io.mosip.preregistration.core.common.entity.DocumentEntity; +import io.mosip.preregistration.core.config.LoggerConfiguration; +import io.mosip.preregistration.core.exception.TableNotAccessibleException; /** * @author Kishan Rathore @@ -48,7 +53,7 @@ public List findBypreregId(String preId) { DocumentStatusMessages.DOCUMENT_IS_MISSING.getMessage()); } } catch (DataAccessLayerException ex) { - log.error("sessionId", "idType", "id", "In findBydocumentId method of DocumnetDAO - " + ex); + log.error(LOGGER_SESSIONID, LOGGER_IDTYPE, LOGGER_ID, "In findBydocumentId method of DocumnetDAO - " + ExceptionUtils.getFullStackTrace(ex)); throw new TableNotAccessibleException(DocumentErrorCodes.PRG_PAM_DOC_012.toString(), DocumentErrorMessages.DOCUMENT_TABLE_NOTACCESSIBLE.getMessage(), ex.getCause()); } @@ -64,7 +69,7 @@ public DocumentEntity findBydocumentId(String documentId) { DocumentStatusMessages.DOCUMENT_IS_MISSING.getMessage()); } } catch (DataAccessLayerException ex) { - log.error("sessionId", "idType", "id", "In findBydocumentId method of DocumnetDAO - " + ex); + log.error(LOGGER_SESSIONID, LOGGER_IDTYPE, LOGGER_ID, "In findBydocumentId method of DocumnetDAO - " + ExceptionUtils.getFullStackTrace(ex)); throw new TableNotAccessibleException(DocumentErrorCodes.PRG_PAM_DOC_012.toString(), DocumentErrorMessages.DOCUMENT_TABLE_NOTACCESSIBLE.getMessage(), ex.getCause()); } @@ -76,7 +81,8 @@ public DocumentEntity findSingleDocument(String preId, String catCode) { try { entity = documentRepository.findSingleDocument(preId, catCode); } catch (DataAccessLayerException ex) { - log.error("sessionId", "idType", "id", "In findSingleDocument method of DocumnetDAO - " + ex); + log.error(LOGGER_SESSIONID, LOGGER_IDTYPE, LOGGER_ID, + "In findSingleDocument method of DocumnetDAO - " + ExceptionUtils.getFullStackTrace(ex)); throw new TableNotAccessibleException(DocumentErrorCodes.PRG_PAM_DOC_012.toString(), DocumentErrorMessages.DOCUMENT_TABLE_NOTACCESSIBLE.getMessage(), ex.getCause()); } @@ -88,7 +94,8 @@ public int deleteAllBydocumentId(String documentId) { try { return documentRepository.deleteAllBydocumentId(documentId); } catch (DataAccessLayerException ex) { - log.error("sessionId", "idType", "id", "In deleteAllBydocumentId method of DocumnetDAO - " + ex); + log.error(LOGGER_SESSIONID, LOGGER_IDTYPE, LOGGER_ID, + "In deleteAllBydocumentId method of DocumnetDAO - " + ExceptionUtils.getFullStackTrace(ex)); throw new TableNotAccessibleException(DocumentErrorCodes.PRG_PAM_DOC_012.toString(), DocumentErrorMessages.DOCUMENT_TABLE_NOTACCESSIBLE.getMessage(), ex.getCause()); } @@ -98,7 +105,8 @@ public int deleteAllBypreregId(String preregId) { try { return documentRepository.deleteAllByDemographicEntityPreRegistrationId(preregId); } catch (DataAccessLayerException ex) { - log.error("sessionId", "idType", "id", "In deleteAllBypreregId method of DocumnetDAO - " + ex); + log.error(LOGGER_SESSIONID, LOGGER_IDTYPE, LOGGER_ID, + "In deleteAllBypreregId method of DocumnetDAO - " + ExceptionUtils.getFullStackTrace(ex)); throw new TableNotAccessibleException(DocumentErrorCodes.PRG_PAM_DOC_012.toString(), DocumentErrorMessages.DOCUMENT_TABLE_NOTACCESSIBLE.getMessage(), ex.getCause()); } @@ -112,7 +120,7 @@ public DocumentEntity saveDocument(DocumentEntity entity) { try { return documentRepository.save(entity); } catch (DataAccessLayerException ex) { - log.error("sessionId", "idType", "id", "In saveDocument method of DocumnetDAO - " + ex); + log.error(LOGGER_SESSIONID, LOGGER_IDTYPE, LOGGER_ID, "In saveDocument method of DocumnetDAO - " + ExceptionUtils.getFullStackTrace(ex)); throw new TableNotAccessibleException(DocumentErrorCodes.PRG_PAM_DOC_012.toString(), DocumentErrorMessages.DOCUMENT_TABLE_NOTACCESSIBLE.getMessage(), ex.getCause()); } @@ -122,7 +130,7 @@ public DocumentEntity updateDocument(DocumentEntity entity) { try { return documentRepository.update(entity); } catch (DataAccessLayerException ex) { - log.error("sessionId", "idType", "id", "In updateDocument method of DocumnetDAO - " + ex); + log.error(LOGGER_SESSIONID, LOGGER_IDTYPE, LOGGER_ID, "In updateDocument method of DocumnetDAO - " + ExceptionUtils.getFullStackTrace(ex)); throw new TableNotAccessibleException(DocumentErrorCodes.PRG_PAM_DOC_012.toString(), DocumentErrorMessages.DOCUMENT_TABLE_NOTACCESSIBLE.getMessage(), ex.getCause()); } @@ -132,10 +140,10 @@ public DemographicEntity getDemographicEntityForPrid(String prid) { try { return documentRepository.getDemographicEntityForPreRegistrationId(prid); } catch (DataAccessLayerException ex) { - log.error("sessionId", "idType", "id", "In getDemographicEntityForPrid method of DocumnetDAO - " + ex); + log.error(LOGGER_SESSIONID, LOGGER_IDTYPE, LOGGER_ID, + "In getDemographicEntityForPrid method of DocumnetDAO - " + ExceptionUtils.getFullStackTrace(ex)); throw new TableNotAccessibleException(DocumentErrorCodes.PRG_PAM_DOC_012.toString(), DocumentErrorMessages.DOCUMENT_TABLE_NOTACCESSIBLE.getMessage(), ex.getCause()); } } - -} +} \ No newline at end of file diff --git a/pre-registration/pre-registration-application-service/src/main/java/io/mosip/preregistration/application/service/ApplicationService.java b/pre-registration/pre-registration-application-service/src/main/java/io/mosip/preregistration/application/service/ApplicationService.java index 52c4fdc5609..04b76640442 100644 --- a/pre-registration/pre-registration-application-service/src/main/java/io/mosip/preregistration/application/service/ApplicationService.java +++ b/pre-registration/pre-registration-application-service/src/main/java/io/mosip/preregistration/application/service/ApplicationService.java @@ -1,5 +1,9 @@ package io.mosip.preregistration.application.service; +import static io.mosip.preregistration.application.constant.PreRegApplicationConstant.LOGGER_SESSIONID; +import static io.mosip.preregistration.application.constant.PreRegApplicationConstant.LOGGER_IDTYPE; +import static io.mosip.preregistration.application.constant.PreRegApplicationConstant.LOGGER_ID; + import java.time.LocalDate; import java.time.LocalDateTime; import java.time.format.DateTimeFormatter; @@ -133,7 +137,7 @@ public AuthUserDetails authUserDetails() { } public MainResponseDTO saveUIEventAudit(UIAuditRequest auditRequest) { - log.info("In saveUIEventAudit method"); + log.info(LOGGER_SESSIONID, LOGGER_IDTYPE, LOGGER_ID, "In saveUIEventAudit method"); MainResponseDTO response = new MainResponseDTO(); response.setResponsetime(DateTimeFormatter.ofPattern(mosipDateTimeFormat).format(LocalDateTime.now())); response.setVersion(version); @@ -148,12 +152,12 @@ public MainResponseDTO saveUIEventAudit(UIAuditRequest auditRequest) { .concat("Consent_Text: " + HMACUtils2.digestAsPlainText(template.getBytes())); auditRequest.setDescription(hashedDescription); AuditRequestDto auditRequestDto = setAuditValues(auditRequest); - log.info("In saveUIEventAudit method saving audit details {}", auditRequestDto); + log.info(LOGGER_SESSIONID, LOGGER_IDTYPE, LOGGER_ID, "In saveUIEventAudit method saving audit details "+ auditRequestDto); auditUtil.saveAuditDetails(auditRequestDto); - log.info("Request audit logged successfully"); + log.info(LOGGER_SESSIONID, LOGGER_IDTYPE, LOGGER_ID, "Request audit logged successfully"); response.setResponse("Audit Logged Successfully"); } catch (Exception ex) { - log.error("Exception error occured while saving audit Request {}", ex); + log.error(LOGGER_SESSIONID, LOGGER_IDTYPE, LOGGER_ID, "Exception error occured while saving audit Request ", ex); throw new AuditFailedException(ApplicationErrorCodes.PRG_APP_007.getCode(), ApplicationErrorMessages.AUDIT_FAILED.getMessage()); } @@ -287,18 +291,18 @@ public MainResponseDTO> getBookingsForRegCent @Override public MainResponseDTO addLostOrUpdateApplication( MainRequestDTO request, String bookingType) { - log.info("sessionId", "idType", "id", "In addLostOrUpdateApplication method of pre-registration service "); - log.info("sessionId", "idType", "id", + log.info(LOGGER_SESSIONID, LOGGER_IDTYPE, LOGGER_ID, "In addLostOrUpdateApplication method of pre-registration service "); + log.info(LOGGER_SESSIONID, LOGGER_IDTYPE, LOGGER_ID, "Add Application start time : " + DateUtils.getUTCCurrentDateTimeString()); MainResponseDTO mainResponseDTO = null; boolean isSuccess = false; try { - log.info("sessionId", "idType", "id", "bookingType : " + bookingType); + log.info(LOGGER_SESSIONID, LOGGER_IDTYPE, LOGGER_ID, "bookingType : " + bookingType); mainResponseDTO = (MainResponseDTO) serviceUtil.getMainResponseDto(request); ApplicationRequestDTO applicationRequest = request.getRequest(); validationUtil.langvalidation(applicationRequest.getLangCode()); String applicationId = serviceUtil.generateId(); - log.info("sessionId", "idType", "id", "applicationId : " + applicationId); + log.info(LOGGER_SESSIONID, LOGGER_IDTYPE, LOGGER_ID, "applicationId : " + applicationId); ApplicationEntity applicationEntity = serviceUtil.saveAndUpdateApplicationEntity(applicationId, bookingType, ApplicationStatusCode.SUBMITTED.getApplicationStatusCode(), StatusCodes.PENDING_APPOINTMENT.getCode(), authUserDetails().getUserId()); @@ -315,17 +319,17 @@ public MainResponseDTO addLostOrUpdateApplication( appplicationResponse.setUpdatedDateTime(serviceUtil.getLocalDateString(applicationEntity.getUpdDtime())); mainResponseDTO.setResponse(appplicationResponse); mainResponseDTO.setResponsetime(serviceUtil.getCurrentResponseTime()); - log.info("sessionId", "idType", "id", + log.info(LOGGER_SESSIONID, LOGGER_IDTYPE, LOGGER_ID, "Add Application n end time : " + DateUtils.getUTCCurrentDateTimeString()); } catch (HttpServerErrorException | HttpClientErrorException e) { - log.error("sessionId", "idType", "id", ExceptionUtils.getStackTrace(e)); - log.error("sessionId", "idType", "id", + log.error(LOGGER_SESSIONID, LOGGER_IDTYPE, LOGGER_ID, ExceptionUtils.getStackTrace(e)); + log.error(LOGGER_SESSIONID, LOGGER_IDTYPE, LOGGER_ID, "In pre-registration service of addLostOrUpdateApplication - " + e.getResponseBodyAsString()); List errorList = ExceptionUtils.getServiceErrorList(e.getResponseBodyAsString()); new DemographicExceptionCatcher().handle(new DemographicServiceException(errorList, null), mainResponseDTO); } catch (Exception ex) { - log.error("sessionId", "idType", "id", ExceptionUtils.getStackTrace(ex)); - log.error("sessionId", "idType", "id", + log.error(LOGGER_SESSIONID, LOGGER_IDTYPE, LOGGER_ID, ExceptionUtils.getStackTrace(ex)); + log.error(LOGGER_SESSIONID, LOGGER_IDTYPE, LOGGER_ID, "In pre-registration service of addLostOrUpdateApplication- " + ex.getMessage()); new DemographicExceptionCatcher().handle(ex, mainResponseDTO); } finally { @@ -380,7 +384,7 @@ public void createAuditValues(String eventId, String eventName, String eventType @Override public MainResponseDTO deleteLostOrUpdateApplication(String applicationId, String bookingType) { - log.info("sessionId", "idType", "id", "In deleteLostOrUpdateApplication method of pre-registration service "); + log.info(LOGGER_SESSIONID, LOGGER_IDTYPE, LOGGER_ID, "In deleteLostOrUpdateApplication method of pre-registration service "); MainResponseDTO response = new MainResponseDTO<>(); DeleteApplicationDTO deleteDto = new DeleteApplicationDTO(); Map requestParamMap = new HashMap<>(); @@ -422,8 +426,8 @@ public MainResponseDTO deleteLostOrUpdateApplication(Strin } isDeleteSuccess = true; } catch (Exception ex) { - log.error("sessionId", "idType", "id", ExceptionUtils.getStackTrace(ex)); - log.error("sessionId", "idType", "id", + log.error(LOGGER_SESSIONID, LOGGER_IDTYPE, LOGGER_ID, ExceptionUtils.getStackTrace(ex)); + log.error(LOGGER_SESSIONID, LOGGER_IDTYPE, LOGGER_ID, "In pre-registration deleteLostOrUpdateApplication service- " + ex.getMessage()); new DemographicExceptionCatcher().handle(ex, response); } finally { @@ -461,12 +465,13 @@ public MainResponseDTO getAllApplicationsForUser() { response.setResponsetime(DateTimeFormatter.ofPattern(mosipDateTimeFormat).format(LocalDateTime.now())); try { List applicationEntities = applicationRepository.findByCreatedBy(userId); - log.info("Number of applications found for the current user: {}", applicationEntities.size()); + log.info(LOGGER_SESSIONID, LOGGER_IDTYPE, LOGGER_ID, "Number of applications found for the current user: "+ applicationEntities.size()); applicationsListDTO.setAllApplications(applicationEntities); response.setResponse(applicationsListDTO); } catch (Exception ex) { - log.error("Error while Getting the Applications for the userId: {} ", userId); - log.error("Exception trace", ex); + log.error(LOGGER_SESSIONID, LOGGER_IDTYPE, LOGGER_ID, "Error while Getting the Applications for the userId : " + userId); + log.error(LOGGER_SESSIONID, LOGGER_IDTYPE, LOGGER_ID, + "Error while Getting the Applications for the userId- " + ExceptionUtils.getStackTrace(ex)); new DemographicExceptionCatcher().handle(ex, response); } return response; @@ -498,11 +503,12 @@ public MainResponseDTO getApplicationStatus(String applicationId) { } userValidation(applicationEntity); applicationBookingStatus= applicationEntity.getBookingStatusCode(); - log.info("Application STATUS : {} for the Application Id: {}", applicationBookingStatus, applicationId); + log.info(LOGGER_SESSIONID, LOGGER_IDTYPE, LOGGER_ID, "Application STATUS : {" + applicationBookingStatus + "} for the Application Id: {"+ applicationId +"}"); response.setResponse(applicationBookingStatus); } catch (Exception ex) { - log.error("Error while Getting the Application Info for applicationId ", applicationId); - log.error("Exception trace", ex); + log.error(LOGGER_SESSIONID, LOGGER_IDTYPE, LOGGER_ID, "Error while Getting the Application Info for applicationId: " + applicationId); + log.error(LOGGER_SESSIONID, LOGGER_IDTYPE, LOGGER_ID, + "Error while Getting the Application Info for applicationId- " + ExceptionUtils.getStackTrace(ex)); new DemographicExceptionCatcher().handle(ex, response); } return response; @@ -512,14 +518,13 @@ private void userValidation(ApplicationEntity applicationEntity) { String authUserId = authUserDetails().getUserId(); List list = listAuth(authUserDetails().getAuthorities()); if (list.contains("ROLE_INDIVIDUAL")) { - log.info("sessionId", "idType", "id", "In userValidation method of ApplicationService with applicationId " + log.info(LOGGER_SESSIONID, LOGGER_IDTYPE, LOGGER_ID, "In userValidation method of ApplicationService with applicationId " + applicationEntity.getApplicationId() + " and userID " + authUserId); if (!authUserDetails().getUserId().trim().equals(applicationEntity.getCrBy().trim())) { throw new PreIdInvalidForUserIdException(ApplicationErrorCodes.PRG_APP_015.getCode(), ApplicationErrorMessages.INVALID_APPLICATION_ID_FOR_USER.getMessage()); } - } - + } } /** @@ -560,13 +565,13 @@ public MainResponseDTO getAllApplicationsForUserForBookingT } List applicationEntities = applicationRepository.findByCreatedByBookingType(userId, type.toUpperCase()); - log.info("Number of applications found for the current user: {} and booking type: {}", - applicationEntities.size(), type); + log.info(LOGGER_SESSIONID, LOGGER_IDTYPE, LOGGER_ID, "Number of applications found for the current user: {" + applicationEntities.size() + "} and booking type: {" + type + "}"); applicationsListDTO.setAllApplications(applicationEntities); response.setResponse(applicationsListDTO); } catch (Exception ex) { - log.error("Error while Getting the Applications for the userId: {} ", userId); - log.error("Exception trace", ex); + log.error(LOGGER_SESSIONID, LOGGER_IDTYPE, LOGGER_ID, "Error while Getting the Application Info for userId: " + userId); + log.error(LOGGER_SESSIONID, LOGGER_IDTYPE, LOGGER_ID, + "Error while Getting the Application Info for userId- " + ExceptionUtils.getStackTrace(ex)); new DemographicExceptionCatcher().handle(ex, response); } return response; diff --git a/pre-registration/pre-registration-application-service/src/main/java/io/mosip/preregistration/application/service/AppointmentServiceImpl.java b/pre-registration/pre-registration-application-service/src/main/java/io/mosip/preregistration/application/service/AppointmentServiceImpl.java index 4c8d37c5276..069a8553b74 100644 --- a/pre-registration/pre-registration-application-service/src/main/java/io/mosip/preregistration/application/service/AppointmentServiceImpl.java +++ b/pre-registration/pre-registration-application-service/src/main/java/io/mosip/preregistration/application/service/AppointmentServiceImpl.java @@ -1,5 +1,9 @@ package io.mosip.preregistration.application.service; +import static io.mosip.preregistration.application.constant.PreRegApplicationConstant.LOGGER_ID; +import static io.mosip.preregistration.application.constant.PreRegApplicationConstant.LOGGER_IDTYPE; +import static io.mosip.preregistration.application.constant.PreRegApplicationConstant.LOGGER_SESSIONID; + import java.time.LocalDate; import java.time.LocalDateTime; import java.time.LocalTime; @@ -57,16 +61,16 @@ public class AppointmentServiceImpl implements AppointmentService { @Autowired private DemographicService demographicService; - + @Autowired private DocumentService documentService; - + /** * Autowired reference for {@link #AnonymousProfileUtil} */ @Autowired AnonymousProfileUtil anonymousProfileUtil; - + @Value("${version}") private String version; @@ -90,7 +94,7 @@ public class AppointmentServiceImpl implements AppointmentService { @Autowired private ApplicationRepostiory applicationRepostiory; - + @Autowired private DocumentDAO documentDAO; @@ -107,16 +111,16 @@ public MainResponseDTO getSlotAvailablity(String registrationCe .setResponsetime(DateTimeFormatter.ofPattern(mosipDateTimeFormat).format(LocalDateTime.now())); availablityResponse.setVersion(version); try { - log.info("In appointment service to get slots availablity"); + log.info(LOGGER_SESSIONID, LOGGER_IDTYPE, LOGGER_ID, "In appointment service to get slots availablity"); availablityResponse.setResponse(appointmentUtils.getSlotAvailablityByRegCenterId(registrationCenterId)); } catch (AppointmentExecption ex) { - log.error("Exception has occured while fetching the slots availablity for a regCenterId {} ex: {}", - registrationCenterId, ex); + log.error(LOGGER_SESSIONID, LOGGER_IDTYPE, LOGGER_ID, + "Exception has occured while fetching the slots availablity for a regCenterId {" + + registrationCenterId + "} ex: " + ExceptionUtils.getStackTrace(ex)); availablityResponse.setErrors(setErrors(ex)); } return availablityResponse; - } @Override @@ -127,30 +131,34 @@ public MainResponseDTO getAppointmentDetails(String preR appointmentDetailsResponse .setResponsetime(DateTimeFormatter.ofPattern(mosipDateTimeFormat).format(LocalDateTime.now())); try { - log.info("In appointment service to get appointment details"); - //first check if the applicationId/preRegistrationId belongs to the logged in user or not + log.info(LOGGER_SESSIONID, LOGGER_IDTYPE, LOGGER_ID, "In appointment service to get appointment details"); + // first check if the applicationId/preRegistrationId belongs to the logged in + // user or not userValidation(preRegistrationId); BookingRegistrationDTO bookingrespose = appointmentUtils.fetchAppointmentDetails(preRegistrationId); appointmentDetailsResponse.setResponse(bookingrespose); - + } catch (AppointmentExecption ex) { - log.error("Exception has occurred while fetching appointment details:", ex); + log.error(LOGGER_SESSIONID, LOGGER_IDTYPE, LOGGER_ID, + "Exception has occurred while fetching appointment details:" + ExceptionUtils.getStackTrace(ex)); appointmentDetailsResponse.setErrors(setErrors(ex)); } return appointmentDetailsResponse; } - + private void userValidation(String applicationId) { String authUserId = authUserDetails().getUserId(); List list = listAuth(authUserDetails().getAuthorities()); if (list.contains("ROLE_INDIVIDUAL")) { - log.info("sessionId", "idType", "id", "In userValidation method of AppointmentService with applicationId " - + applicationId + " and userID " + authUserId); + log.info(LOGGER_SESSIONID, LOGGER_IDTYPE, LOGGER_ID, + "In userValidation method of AppointmentService with applicationId " + applicationId + + " and userID " + authUserId); ApplicationEntity applicationEntity = null; try { applicationEntity = applicationRepostiory.findByApplicationId(applicationId); } catch (Exception ex) { - log.error("Invaid applicationId/Not Record Found for the ID", applicationId); + log.error(LOGGER_SESSIONID, LOGGER_IDTYPE, LOGGER_ID, + "Invaid applicationId/Not Record Found for the ID : " + applicationId); throw new AppointmentExecption(ApplicationErrorCodes.PRG_APP_013.getCode(), ApplicationErrorMessages.NO_RECORD_FOUND.getMessage()); } @@ -160,7 +168,7 @@ private void userValidation(String applicationId) { } } } - + /** * This method is used to get the list of authorization role * @@ -175,40 +183,43 @@ private List listAuth(Collection collection) } return listWORole; } - + @Override public MainResponseDTO makeAppointment(MainRequestDTO bookingDTO, String preRegistrationId, String userAgent) { - MainResponseDTO bookAppointmentResponse = new MainResponseDTO(); + MainResponseDTO bookAppointmentResponse = new MainResponseDTO<>(); bookAppointmentResponse.setId(appointmentBookId); bookAppointmentResponse.setVersion(version); bookAppointmentResponse .setResponsetime(DateTimeFormatter.ofPattern(mosipDateTimeFormat).format(LocalDateTime.now())); try { - log.info("In appointment service to make an appointment for ID : {}", preRegistrationId); - //first check if the applicationId/preRegistrationId belongs to the logged in user or not + log.info(LOGGER_SESSIONID, LOGGER_IDTYPE, LOGGER_ID, + "In appointment service to make an appointment for ID : " + preRegistrationId); + // first check if the applicationId/preRegistrationId belongs to the logged in + // user or not userValidation(preRegistrationId); BookingStatusDTO bookingResponse = appointmentUtils.makeAppointment(bookingDTO, preRegistrationId); if (bookingResponse.getBookingMessage() != null || !bookingResponse.getBookingMessage().isBlank()) { - log.info( - "In appointment booked successfully , updating the applications and demographic tables for ID:{}", - preRegistrationId); - ApplicationEntity applicationEntity = this.updateApplicationEntity(preRegistrationId, bookingDTO.getRequest(), StatusCodes.BOOKED.getCode()); + log.info(LOGGER_SESSIONID, LOGGER_IDTYPE, LOGGER_ID, + "In appointment booked successfully , updating the applications and demographic tables for ID: " + + preRegistrationId); + ApplicationEntity applicationEntity = this.updateApplicationEntity(preRegistrationId, + bookingDTO.getRequest(), StatusCodes.BOOKED.getCode()); if (applicationEntity.getBookingType().equals(BookingTypeCodes.NEW_PREREGISTRATION.toString())) { createAnonymousProfile(userAgent, preRegistrationId, bookingDTO.getRequest()); this.demographicService.updatePreRegistrationStatus(preRegistrationId, StatusCodes.BOOKED.getCode(), - authUserDetails().getUserId()); + authUserDetails().getUserId()); } bookAppointmentResponse.setResponse(bookingResponse); } } catch (AppointmentExecption ex) { - log.error("Exception has occurred while booking appointment : ", ex); + log.error(LOGGER_SESSIONID, LOGGER_IDTYPE, LOGGER_ID, + "Exception has occurred while booking appointment : " + ExceptionUtils.getStackTrace(ex)); bookAppointmentResponse.setErrors(setErrors(ex)); } return bookAppointmentResponse; } - @Override public MainResponseDTO deleteBooking(String preRegistrationId) { MainResponseDTO deleteResponse = new MainResponseDTO(); @@ -216,81 +227,88 @@ public MainResponseDTO deleteBooking(String preRegistrationId) deleteResponse.setVersion(version); deleteResponse.setResponsetime(DateTimeFormatter.ofPattern(mosipDateTimeFormat).format(LocalDateTime.now())); try { - log.info("Deleting appointment for ID:{}", preRegistrationId); - //first check if the applicationId/preRegistrationId belongs to the logged in user or not + log.info(LOGGER_SESSIONID, LOGGER_IDTYPE, LOGGER_ID, "Deleting appointment for ID: " + preRegistrationId); + // first check if the applicationId/preRegistrationId belongs to the logged in + // user or not userValidation(preRegistrationId); DeleteBookingDTO res = appointmentUtils.deleteBooking(preRegistrationId); if (res != null && (res.getDeletedBy() != null && res.getDeletedDateTime() != null && res.getPreRegistrationId() != null)) { - log.info( - "In appointment deleted successfully for ID:{}, updating the applications and demographic tables", - preRegistrationId); + log.info(LOGGER_SESSIONID, LOGGER_IDTYPE, LOGGER_ID, "In appointment deleted successfully for ID:{" + + preRegistrationId + "}, updating the applications and demographic tables"); this.updateApplicationEntity(preRegistrationId, null, null); deleteResponse.setResponse(res); } } catch (AppointmentExecption ex) { - log.error("Exception has occured while deleting an appointment : {}", ex); + log.error(LOGGER_SESSIONID, LOGGER_IDTYPE, LOGGER_ID, + "Exception has occured while deleting an appointment : " + ExceptionUtils.getStackTrace(ex)); deleteResponse.setErrors(setErrors(ex)); } return deleteResponse; } - - @Override + + @Override public MainResponseDTO deleteBookingAndUpdateApplicationStatus(String preRegistrationId) { - MainResponseDTO deleteResponse = new MainResponseDTO(); + MainResponseDTO deleteResponse = new MainResponseDTO<>(); deleteResponse.setId(appointmentDeletelId); deleteResponse.setVersion(version); deleteResponse.setResponsetime(DateTimeFormatter.ofPattern(mosipDateTimeFormat).format(LocalDateTime.now())); try { - log.info("Deleting appointment for ID:{}", preRegistrationId); - //first check if the applicationId/preRegistrationId belongs to the logged in user or not + log.info(LOGGER_SESSIONID, LOGGER_IDTYPE, LOGGER_ID, "Deleting appointment for ID: " + preRegistrationId); + // first check if the applicationId/preRegistrationId belongs to the logged in + // user or not userValidation(preRegistrationId); DeleteBookingDTO res = appointmentUtils.deleteBooking(preRegistrationId); if (res != null && (res.getDeletedBy() != null && res.getDeletedDateTime() != null && res.getPreRegistrationId() != null)) { - log.info( - "In appointment deleted successfully for ID:{}, updating the applications and demographic tables", - preRegistrationId); - ApplicationEntity applicationEntity = this.updateApplicationEntity(preRegistrationId, null, StatusCodes.CANCELLED.getCode()); - if (applicationEntity.getBookingType().equals(BookingTypeCodes.NEW_PREREGISTRATION.toString())) { - this.demographicService.updatePreRegistrationStatus(preRegistrationId, StatusCodes.CANCELLED.getCode(), - authUserDetails().getUserId()); + log.info(LOGGER_SESSIONID, LOGGER_IDTYPE, LOGGER_ID, "In appointment deleted successfully for ID:{ " + + preRegistrationId + " }, updating the applications and demographic tables"); + ApplicationEntity applicationEntity = this.updateApplicationEntity(preRegistrationId, null, + StatusCodes.CANCELLED.getCode()); + if (applicationEntity.getBookingType().equals(BookingTypeCodes.NEW_PREREGISTRATION.toString())) { + this.demographicService.updatePreRegistrationStatus(preRegistrationId, + StatusCodes.CANCELLED.getCode(), authUserDetails().getUserId()); } deleteResponse.setResponse(res); } } catch (AppointmentExecption ex) { - log.error("Exception has occured while deleting an appointment : {}", ex); + log.error(LOGGER_SESSIONID, LOGGER_IDTYPE, LOGGER_ID, + "Exception has occured while deleting an appointment : " + ExceptionUtils.getStackTrace(ex)); deleteResponse.setErrors(setErrors(ex)); } return deleteResponse; - } + } @Override public MainResponseDTO cancelAppointment(String preRegistrationId) { - MainResponseDTO cancelResponse = new MainResponseDTO(); + MainResponseDTO cancelResponse = new MainResponseDTO<>(); cancelResponse.setId(appointmentCancelId); cancelResponse.setVersion(version); cancelResponse.setResponsetime(DateTimeFormatter.ofPattern(mosipDateTimeFormat).format(LocalDateTime.now())); try { - log.info("Cancelling appointment for ID:{}", preRegistrationId); - //first check if the applicationId/preRegistrationId belongs to the logged in user or not - userValidation(preRegistrationId); + log.info(LOGGER_SESSIONID, LOGGER_IDTYPE, LOGGER_ID, "Cancelling appointment for ID: " + preRegistrationId); + // first check if the applicationId/preRegistrationId belongs to the logged in + // user or not + userValidation(preRegistrationId); CancelBookingResponseDTO response = appointmentUtils.cancelAppointment(preRegistrationId); if (response != null && (response.getMessage() != null && response.getTransactionId() != null)) { - log.info("In appointment cancelled successfully , updating the applications and demographic tables", + log.info(LOGGER_SESSIONID, LOGGER_IDTYPE, LOGGER_ID, + "In appointment cancelled successfully , updating the applications and demographic tables", preRegistrationId); - ApplicationEntity applicationEntity = this.updateApplicationEntity(preRegistrationId, null, StatusCodes.CANCELLED.getCode()); - if (applicationEntity.getBookingType().equals(BookingTypeCodes.NEW_PREREGISTRATION.toString())) { - this.demographicService.updatePreRegistrationStatus(preRegistrationId, StatusCodes.CANCELLED.getCode(), - authUserDetails().getUserId()); + ApplicationEntity applicationEntity = this.updateApplicationEntity(preRegistrationId, null, + StatusCodes.CANCELLED.getCode()); + if (applicationEntity.getBookingType().equals(BookingTypeCodes.NEW_PREREGISTRATION.toString())) { + this.demographicService.updatePreRegistrationStatus(preRegistrationId, + StatusCodes.CANCELLED.getCode(), authUserDetails().getUserId()); } cancelResponse.setResponse(response); } } catch (AppointmentExecption ex) { - log.error("Exception has occured while cancelling an appointment : {}", ex); + log.error(LOGGER_SESSIONID, LOGGER_IDTYPE, LOGGER_ID, + "Exception has occured while cancelling an appointment : " + ExceptionUtils.getStackTrace(ex)); cancelResponse.setErrors(setErrors(ex)); } @@ -298,7 +316,7 @@ public MainResponseDTO cancelAppointment(String preReg } @Override - public MainResponseDTO makeMultiAppointment(MainRequestDTO bookingRequest, + public MainResponseDTO makeMultiAppointment(MainRequestDTO bookingRequest, String userAgent) { MainResponseDTO multiBookingResponse = new MainResponseDTO(); multiBookingResponse.setId(appointmentBookId); @@ -306,13 +324,14 @@ public MainResponseDTO makeMultiAppointment(MainRequestDTO { String preRegistrationId = action.getPreRegistrationId(); userValidation(preRegistrationId); }); BookingStatus bookingStatus = appointmentUtils.multiAppointmentBooking(bookingRequest); - if (bookingStatus != null && bookingStatus.getBookingStatusResponse().size() > 0) { + if (bookingStatus != null && !bookingStatus.getBookingStatusResponse().isEmpty()) { bookingRequest.getRequest().getBookingRequest().stream().forEach(action -> { String preRegistrationId = action.getPreRegistrationId(); @@ -321,24 +340,26 @@ public MainResponseDTO makeMultiAppointment(MainRequestDTO setErrors(AppointmentExecption ex) { - List explist = new ArrayList(); + List explist = new ArrayList<>(); ExceptionJSONInfoDTO exception = new ExceptionJSONInfoDTO(); exception.setErrorCode(ex.getErrorCode()); exception.setMessage(ex.getErrorMessage()); explist.add(exception); return explist; - } - -} +} \ No newline at end of file diff --git a/pre-registration/pre-registration-application-service/src/main/java/io/mosip/preregistration/application/service/DemographicService.java b/pre-registration/pre-registration-application-service/src/main/java/io/mosip/preregistration/application/service/DemographicService.java index 9a87396f57b..176f1dadd40 100644 --- a/pre-registration/pre-registration-application-service/src/main/java/io/mosip/preregistration/application/service/DemographicService.java +++ b/pre-registration/pre-registration-application-service/src/main/java/io/mosip/preregistration/application/service/DemographicService.java @@ -1,5 +1,9 @@ package io.mosip.preregistration.application.service; +import static io.mosip.preregistration.application.constant.PreRegApplicationConstant.LOGGER_SESSIONID; +import static io.mosip.preregistration.application.constant.PreRegApplicationConstant.LOGGER_IDTYPE; +import static io.mosip.preregistration.application.constant.PreRegApplicationConstant.LOGGER_ID; + import java.io.IOException; import java.time.LocalDateTime; import java.time.format.DateTimeFormatter; @@ -118,7 +122,7 @@ public class DemographicService implements DemographicServiceIntf { */ @Autowired private DemographicRepository demographicRepository; - + /** * Autowired reference for {@link #DemographicServiceUtil} */ @@ -136,7 +140,7 @@ public class DemographicService implements DemographicServiceIntf { @Autowired CommonServiceUtil commonServiceUtil; - + /** * Autowired reference for {@link #AuditLogUtil} */ @@ -231,7 +235,7 @@ public class DemographicService implements DemographicServiceIntf { @Autowired CryptoUtil cryptoUtil; - + @Value("${mosip.utc-datetime-pattern}") private String mosipDateTimeFormat; @@ -280,21 +284,22 @@ public AuthUserDetails authUserDetails() { @Override public MainResponseDTO addPreRegistration( MainRequestDTO request) { - log.info("sessionId", "idType", "id", "In addPreRegistration method of pre-registration service "); - log.info("sessionId", "idType", "id", + log.info(LOGGER_SESSIONID, LOGGER_IDTYPE, LOGGER_ID, + "In addPreRegistration method of pre-registration service "); + log.info(LOGGER_SESSIONID, LOGGER_IDTYPE, LOGGER_ID, "Pre Registration start time : " + DateUtils.getUTCCurrentDateTimeString()); MainResponseDTO mainResponseDTO = null; boolean isSuccess = false; try { - log.info("sessionId", "idType", "id", "Get Schema from syncdata called"); + log.info(LOGGER_SESSIONID, LOGGER_IDTYPE, LOGGER_ID, "Get Schema from syncdata called"); IdSchemaDto idSchema = serviceUtil.getSchema(); - log.info("sessionId", "idType", "id", "Get Schema from syncdata successful"); + log.info(LOGGER_SESSIONID, LOGGER_IDTYPE, LOGGER_ID, "Get Schema from syncdata successful"); mainResponseDTO = (MainResponseDTO) serviceUtil.getMainResponseDto(request); DemographicRequestDTO demographicRequest = request.getRequest(); validationUtil.langvalidation(demographicRequest.getLangCode()); - log.info("sessionId", "idType", "id", + log.info(LOGGER_SESSIONID, LOGGER_IDTYPE, LOGGER_ID, "JSON validator start time : " + DateUtils.getUTCCurrentDateTimeString()); List identityKeys = convertSchemaJsonToArray(idSchema.getSchemaJson()); @@ -311,12 +316,12 @@ public MainResponseDTO addPreRegistration( jsonValidator.validateIdObject(idSchema.getSchemaJson(), constructedObject, requiredFields); - log.info("sessionId", "idType", "id", + log.info(LOGGER_SESSIONID, LOGGER_IDTYPE, LOGGER_ID, "JSON validator end time : " + DateUtils.getUTCCurrentDateTimeString()); - log.info("sessionId", "idType", "id", + log.info(LOGGER_SESSIONID, LOGGER_IDTYPE, LOGGER_ID, "Pre ID generation start time : " + DateUtils.getUTCCurrentDateTimeString()); String preId = serviceUtil.generateId(); - log.info("sessionId", "idType", "id", + log.info(LOGGER_SESSIONID, LOGGER_IDTYPE, LOGGER_ID, "Pre ID generation end time : " + DateUtils.getUTCCurrentDateTimeString()); DemographicEntity demographicEntity = demographicRepository @@ -328,17 +333,17 @@ public MainResponseDTO addPreRegistration( mainResponseDTO.setResponse(res); isSuccess = true; mainResponseDTO.setResponsetime(serviceUtil.getCurrentResponseTime()); - log.info("sessionId", "idType", "id", + log.info(LOGGER_SESSIONID, LOGGER_IDTYPE, LOGGER_ID, "Pre Registration end time : " + DateUtils.getUTCCurrentDateTimeString()); } catch (HttpServerErrorException | HttpClientErrorException e) { - log.error("sessionId", "idType", "id", ExceptionUtils.getStackTrace(e)); - log.error("sessionId", "idType", "id", + log.error(LOGGER_SESSIONID, LOGGER_IDTYPE, LOGGER_ID, ExceptionUtils.getStackTrace(e)); + log.error(LOGGER_SESSIONID, LOGGER_IDTYPE, LOGGER_ID, "In pre-registration service of addPreRegistration- " + e.getResponseBodyAsString()); List errorList = ExceptionUtils.getServiceErrorList(e.getResponseBodyAsString()); new DemographicExceptionCatcher().handle(new DemographicServiceException(errorList, null), mainResponseDTO); } catch (Exception ex) { - log.error("sessionId", "idType", "id", ExceptionUtils.getStackTrace(ex)); - log.error("sessionId", "idType", "id", + log.error(LOGGER_SESSIONID, LOGGER_IDTYPE, LOGGER_ID, ExceptionUtils.getStackTrace(ex)); + log.error(LOGGER_SESSIONID, LOGGER_IDTYPE, LOGGER_ID, "In pre-registration service of addPreRegistration- " + ex.getMessage()); new DemographicExceptionCatcher().handle(ex, mainResponseDTO); @@ -356,10 +361,8 @@ public MainResponseDTO addPreRegistration( } } return mainResponseDTO; - } - /* * This method is used to update the demographic data by PreId * @@ -382,27 +385,27 @@ public MainResponseDTO addPreRegistration( @Override public MainResponseDTO updatePreRegistration( MainRequestDTO request, String preRegistrationId, String userId) { - log.info("sessionId", "idType", "id", "In updatePreRegistration method of pre-registration service "); - log.info("sessionId", "idType", "id", + log.info(LOGGER_SESSIONID, LOGGER_IDTYPE, LOGGER_ID, "In updatePreRegistration method of pre-registration service "); + log.info(LOGGER_SESSIONID, LOGGER_IDTYPE, LOGGER_ID, "Pre Registration start time : " + DateUtils.getUTCCurrentDateTimeString()); MainResponseDTO mainResponseDTO = null; mainResponseDTO = (MainResponseDTO) serviceUtil.getMainResponseDto(request); boolean isSuccess = false; try { - log.info("sessionId", "idType", "id", "Get Schema from syncdata called"); + log.info(LOGGER_SESSIONID, LOGGER_IDTYPE, LOGGER_ID, "Get Schema from syncdata called"); IdSchemaDto idSchema = serviceUtil.getSchema(); - log.info("sessionId", "idType", "id", "Get Schema from syncdata successful"); + log.info(LOGGER_SESSIONID, LOGGER_IDTYPE, LOGGER_ID, "Get Schema from syncdata successful"); validationUtil.langvalidation(request.getRequest().getLangCode()); Map requestParamMap = new HashMap<>(); requestParamMap.put(DemographicRequestCodes.PRE_REGISTRAION_ID.getCode(), preRegistrationId); if (validationUtil.requstParamValidator(requestParamMap)) { DemographicRequestDTO demographicRequest = request.getRequest(); - log.info("sessionId", "idType", "id", + log.info(LOGGER_SESSIONID, LOGGER_IDTYPE, LOGGER_ID, "JSON validator start time : " + DateUtils.getUTCCurrentDateTimeString()); List identityKeys = convertSchemaJsonToArray(idSchema.getSchemaJson()); - log.info("IDENTITY KEYS: {}", identityKeys); + log.info(LOGGER_SESSIONID, LOGGER_IDTYPE, LOGGER_ID,"IDENTITY KEYS: " + identityKeys.toString()); List requiredFields = demographicRequest.getRequiredFields().stream() .filter(field -> identityKeys.contains(field)).collect(Collectors.toList()); @@ -410,10 +413,10 @@ public MainResponseDTO updatePreRegistration( JSONObject constructedObject = serviceUtil.constructNewDemographicRequest(identityKeys, demographicRequest.getDemographicDetails()); - log.debug("Constructed Object {}", constructedObject); + log.debug(LOGGER_SESSIONID, LOGGER_IDTYPE, LOGGER_ID, "Constructed Object ", constructedObject.toString()); jsonValidator.validateIdObject(idSchema.getSchemaJson(), constructedObject, requiredFields); - log.info("sessionId", "idType", "id", + log.info(LOGGER_SESSIONID, LOGGER_IDTYPE, LOGGER_ID, "JSON validator end time : " + DateUtils.getUTCCurrentDateTimeString()); DemographicEntity demographicEntity = demographicRepository.findBypreRegistrationId(preRegistrationId); if (!serviceUtil.isNull(demographicEntity)) { @@ -434,17 +437,17 @@ public MainResponseDTO updatePreRegistration( mainResponseDTO.setResponse(res); } isSuccess = true; - log.info("sessionId", "idType", "id", + log.info(LOGGER_SESSIONID, LOGGER_IDTYPE, LOGGER_ID, "Pre Registration end time : " + DateUtils.getUTCCurrentDateTimeString()); } catch (HttpServerErrorException | HttpClientErrorException e) { - log.error("sessionId", "idType", "id", ExceptionUtils.getStackTrace(e)); - log.error("sessionId", "idType", "id", + log.error(LOGGER_SESSIONID, LOGGER_IDTYPE, LOGGER_ID, ExceptionUtils.getStackTrace(e)); + log.error(LOGGER_SESSIONID, LOGGER_IDTYPE, LOGGER_ID, "In pre-registration service of addPreRegistration- " + e.getResponseBodyAsString()); List errorList = ExceptionUtils.getServiceErrorList(e.getResponseBodyAsString()); new DemographicExceptionCatcher().handle(new DemographicServiceException(errorList, null), mainResponseDTO); } catch (Exception ex) { - log.error("sessionId", "idType", "id", ExceptionUtils.getStackTrace(ex)); - log.error("sessionId", "idType", "id", + log.error(LOGGER_SESSIONID, LOGGER_IDTYPE, LOGGER_ID, ExceptionUtils.getStackTrace(ex)); + log.error(LOGGER_SESSIONID, LOGGER_IDTYPE, LOGGER_ID, "In pre-registration service of updatePreRegistration- " + ex.getMessage()); new DemographicExceptionCatcher().handle(ex, mainResponseDTO); @@ -472,7 +475,7 @@ public MainResponseDTO updatePreRegistration( */ @Override public MainResponseDTO getAllApplicationDetails(String userId, String pageIdx) { - log.info("sessionId", "idType", "id", "In getAllApplicationDetails method of pre-registration service "); + log.info(LOGGER_SESSIONID, LOGGER_IDTYPE, LOGGER_ID, "In getAllApplicationDetails method of pre-registration service "); MainResponseDTO response = new MainResponseDTO<>(); Map requestParamMap = new HashMap<>(); DemographicMetadataDTO demographicMetadataDTO = new DemographicMetadataDTO(); @@ -482,11 +485,11 @@ public MainResponseDTO getAllApplicationDetails(String u try { requestParamMap.put(DemographicRequestCodes.USER_ID.getCode(), userId); if (validationUtil.requstParamValidator(requestParamMap)) { - log.info("sessionId", "idType", "id", + log.info(LOGGER_SESSIONID, LOGGER_IDTYPE, LOGGER_ID, "get demographic details start time : " + DateUtils.getUTCCurrentDateTimeString()); List demographicEntities = demographicRepository.findByCreatedBy(userId, StatusCodes.CONSUMED.getCode()); - log.info("sessionId", "idType", "id", + log.info(LOGGER_SESSIONID, LOGGER_IDTYPE, LOGGER_ID, "get demographic details end time : " + DateUtils.getUTCCurrentDateTimeString()); if (!serviceUtil.isNull(demographicEntities)) { /* @@ -503,14 +506,14 @@ public MainResponseDTO getAllApplicationDetails(String u * Fetch all the pageable records for the user with respect to page index and * page size */ - log.info("sessionId", "idType", "id", + log.info(LOGGER_SESSIONID, LOGGER_IDTYPE, LOGGER_ID, "pagination start time : " + DateUtils.getUTCCurrentDateTimeString()); @SuppressWarnings("static-access") Page demographicEntityPage = demographicRepository .findByCreatedByOrderByCreateDateTime(userId, StatusCodes.CONSUMED.getCode(), PageRequest.of(serviceUtil.parsePageIndex(pageIdx), serviceUtil.parsePageSize(pageSize))); - log.info("sessionId", "idType", "id", + log.info(LOGGER_SESSIONID, LOGGER_IDTYPE, LOGGER_ID, "pagination end time : " + DateUtils.getUTCCurrentDateTimeString()); if (!serviceUtil.isNull(demographicEntityPage) && !serviceUtil.isNull(demographicEntityPage.getContent())) { @@ -533,8 +536,8 @@ public MainResponseDTO getAllApplicationDetails(String u } isRetrieveSuccess = true; } catch (RuntimeException | JsonProcessingException | ParseException | IOException ex) { - log.error("sessionId", "idType", "id", ExceptionUtils.getStackTrace(ex)); - log.error("sessionId", "idType", "id", + log.error(LOGGER_SESSIONID, LOGGER_IDTYPE, LOGGER_ID, ExceptionUtils.getStackTrace(ex)); + log.error(LOGGER_SESSIONID, LOGGER_IDTYPE, LOGGER_ID, "In getAllApplicationDetails method of pre-registration service - " + ex.getMessage()); new DemographicExceptionCatcher().handle(ex, response); } finally { @@ -559,18 +562,18 @@ private void prepareDemographicResponse(DemographicMetadataDTO demographicMetada throws ParseException, EncryptionFailedException, IOException, JsonProcessingException { List viewList = new ArrayList<>(); long start = System.currentTimeMillis(); - log.info("sessionId", "idType", "id", "for loop start time : " + DateUtils.getUTCCurrentDateTimeString()); + log.info(LOGGER_SESSIONID, LOGGER_IDTYPE, LOGGER_ID, "for loop start time : " + DateUtils.getUTCCurrentDateTimeString()); JSONParser jsonParser = new JSONParser(); for (DemographicEntity demographicEntity : demographicEntities) { - log.info("sessionId", "idType", "id", "decryption start time : " + DateUtils.getUTCCurrentDateTimeString()); + log.info(LOGGER_SESSIONID, LOGGER_IDTYPE, LOGGER_ID, "decryption start time : " + DateUtils.getUTCCurrentDateTimeString()); byte[] decryptedString = cryptoUtil.decrypt(demographicEntity.getApplicantDetailJson(), DateUtils.getUTCCurrentDateTime()); - log.info("sessionId", "idType", "id", "decryption end time : " + DateUtils.getUTCCurrentDateTimeString()); - log.info("sessionId", "idType", "id", + log.info(LOGGER_SESSIONID, LOGGER_IDTYPE, LOGGER_ID, "decryption end time : " + DateUtils.getUTCCurrentDateTimeString()); + log.info(LOGGER_SESSIONID, LOGGER_IDTYPE, LOGGER_ID, "get document metadata start time : " + DateUtils.getUTCCurrentDateTimeString()); JSONObject documentJsonObject = getDocumentMetadata(demographicEntity, DemographicRequestCodes.POA.getCode()); - log.info("sessionId", "idType", "id", + log.info(LOGGER_SESSIONID, LOGGER_IDTYPE, LOGGER_ID, "get document metadata end time : " + DateUtils.getUTCCurrentDateTimeString()); JSONObject jsonObj = (JSONObject) jsonParser.parse(new String(decryptedString)); @@ -591,22 +594,21 @@ private void prepareDemographicResponse(DemographicMetadataDTO demographicMetada viewDto.setStatusCode(demographicEntity.getStatusCode()); viewDto.setDemographicMetadata(demographicMetadata); viewDto.setDataCaptureLanguage(dataCaptureLang); - log.info("sessionId", "idType", "id", + log.info(LOGGER_SESSIONID, LOGGER_IDTYPE, LOGGER_ID, "get booking details start time : " + DateUtils.getUTCCurrentDateTimeString()); BookingRegistrationDTO bookingRegistrationDTO = getAppointmentData(demographicEntity); - log.info("sessionId", "idType", "id", + log.info(LOGGER_SESSIONID, LOGGER_IDTYPE, LOGGER_ID, "get booking details end time : " + DateUtils.getUTCCurrentDateTimeString()); viewDto.setBookingMetadata(bookingRegistrationDTO); viewList.add(viewDto); } - log.info("sessionId", "idType", "id", "for loop end time : " + DateUtils.getUTCCurrentDateTimeString()); + log.info(LOGGER_SESSIONID, LOGGER_IDTYPE, LOGGER_ID, "for loop end time : " + DateUtils.getUTCCurrentDateTimeString()); long end = System.currentTimeMillis(); - log.info("sessionId", "idType", "id", "for loop total time : " + (end - start)); + log.info(LOGGER_SESSIONID, LOGGER_IDTYPE, LOGGER_ID, "for loop total time : " + (end - start)); demographicMetadataDTO.setBasicDetails(viewList); } private BookingRegistrationDTO getAppointmentData(DemographicEntity demographicEntity) { - if (!serviceUtil.isNull(demographicEntity.getPreRegistrationId())) { ApplicationEntity applicationEntity = serviceUtil .findApplicationById(demographicEntity.getPreRegistrationId()); @@ -621,7 +623,6 @@ private BookingRegistrationDTO getAppointmentData(DemographicEntity demographicE } } return null; - } /* @@ -632,7 +633,7 @@ private BookingRegistrationDTO getAppointmentData(DemographicEntity demographicE */ @Override public MainResponseDTO getApplicationStatus(String preRegId, String userId) { - log.info("sessionId", "idType", "id", "In getApplicationStatus method of pre-registration service "); + log.info(LOGGER_SESSIONID, LOGGER_IDTYPE, LOGGER_ID, "In getApplicationStatus method of pre-registration service "); return commonServiceUtil.getApplicationStatus(preRegId, userId); } @@ -644,7 +645,7 @@ public MainResponseDTO getApplicationStatus(String pre */ @Override public MainResponseDTO deleteIndividual(String preregId, String userId) { - log.info("sessionId", "idType", "id", "In deleteIndividual method of pre-registration service "); + log.info(LOGGER_SESSIONID, LOGGER_IDTYPE, LOGGER_ID, "In deleteIndividual method of pre-registration service "); MainResponseDTO response = new MainResponseDTO<>(); DeletePreRegistartionDTO deleteDto = new DeletePreRegistartionDTO(); Map requestParamMap = new HashMap<>(); @@ -690,8 +691,8 @@ public MainResponseDTO deleteIndividual(String preregI } } catch (Exception ex) { - log.error("sessionId", "idType", "id", ExceptionUtils.getStackTrace(ex)); - log.error("sessionId", "idType", "id", "In pre-registration deleteIndividual service- " + ex.getMessage()); + log.error(LOGGER_SESSIONID, LOGGER_IDTYPE, LOGGER_ID, ExceptionUtils.getStackTrace(ex)); + log.error(LOGGER_SESSIONID, LOGGER_IDTYPE, LOGGER_ID, "In pre-registration deleteIndividual service- " + ex.getMessage()); new DemographicExceptionCatcher().handle(ex, response); } finally { response.setResponsetime(serviceUtil.getCurrentResponseTime()); @@ -719,7 +720,7 @@ public MainResponseDTO deleteIndividual(String preregI */ @Override public MainResponseDTO getDemographicData(String preRegId) { - log.info("sessionId", "idType", "id", "In getDemographicData method of pre-registration service "); + log.info(LOGGER_SESSIONID, LOGGER_IDTYPE, LOGGER_ID, "In getDemographicData method of pre-registration service "); return commonServiceUtil.getDemographicData(preRegId); } @@ -732,7 +733,7 @@ public MainResponseDTO getDemographicData(String preRegI */ @Override public MainResponseDTO updatePreRegistrationStatus(String preRegId, String status, String userId) { - log.info("sessionId", "idType", "id", "In updatePreRegistrationStatus method of pre-registration service "); + log.info(LOGGER_SESSIONID, LOGGER_IDTYPE, LOGGER_ID, "In updatePreRegistrationStatus method of pre-registration service "); return commonServiceUtil.updatePreRegistrationStatus(preRegId, status, userId); } @@ -759,7 +760,7 @@ public boolean isupdateStausToPendingAppointmentValid(DemographicEntity demograp * */ private void getDocumentServiceToDeleteAllByPreId(String preregId) { - log.info("sessionId", "idType", "id", + log.info(LOGGER_SESSIONID, LOGGER_IDTYPE, LOGGER_ID, "In callDocumentServiceToDeleteAllByPreId method of pre-registration service "); try { documentServiceImpl.deleteAllByPreId(preregId); @@ -797,7 +798,7 @@ public void setAuditValues(String eventId, String eventName, String eventType, S } private void getBookingServiceToDeleteAllByPreId(String preregId) throws Exception { - log.info("sessionId", "idType", "id", + log.info(LOGGER_SESSIONID, LOGGER_IDTYPE, LOGGER_ID, "In callBookingServiceToDeleteAllByPreId method of pre-registration service "); MainResponseDTO deleteBooking = null; @@ -818,7 +819,7 @@ private void getBookingServiceToDeleteAllByPreId(String preregId) throws Excepti @Override public MainResponseDTO> getUpdatedDateTimeForPreIds( PreRegIdsByRegCenterIdDTO preRegIdsByRegCenterIdDTO) { - log.info("sessionId", "idType", "id", + log.info(LOGGER_SESSIONID, LOGGER_IDTYPE, LOGGER_ID, "In getUpdatedDateTimeForPreIds method of pre-registration service " + preRegIdsByRegCenterIdDTO); MainResponseDTO> mainResponseDTO = new MainResponseDTO<>(); mainResponseDTO.setResponsetime(serviceUtil.getCurrentResponseTime()); @@ -855,8 +856,8 @@ public MainResponseDTO> getUpdatedDateTimeForPreIds( mainResponseDTO.setResponse(preIdMap); } catch (Exception ex) { - log.error("sessionId", "idType", "id", ExceptionUtils.getStackTrace(ex)); - log.error("sessionId", "idType", "id", + log.error(LOGGER_SESSIONID, LOGGER_IDTYPE, LOGGER_ID, ExceptionUtils.getStackTrace(ex)); + log.error(LOGGER_SESSIONID, LOGGER_IDTYPE, LOGGER_ID, "In getUpdatedDateTimeForPreIds method of pre-registration service- " + ex.getMessage()); new DemographicExceptionCatcher().handle(ex, mainResponseDTO); } @@ -865,7 +866,7 @@ public MainResponseDTO> getUpdatedDateTimeForPreIds( } public void userValidation(String authUserId, String preregUserId) { - log.info("sessionId", "idType", "id", "In getDemographicData method of userValidation with priid " + log.info(LOGGER_SESSIONID, LOGGER_IDTYPE, LOGGER_ID, "In getDemographicData method of userValidation with priid " + preregUserId + " and userID " + authUserId); if (!authUserId.trim().equals(preregUserId.trim())) { throw new PreIdInvalidForUserIdException(DemographicErrorCodes.PRG_PAM_APP_017.getCode(), @@ -899,8 +900,8 @@ public DemographicIdentityRequestDTO getPreregistrationIdentityJson() { try { return objectMapper.readValue(getIdentityJsonString, DemographicIdentityRequestDTO.class); } catch (IOException ex) { - log.error("sessionId", "idType", "id", ExceptionUtils.getStackTrace(ex)); - log.error("sessionId", "idType", "id", + log.error(LOGGER_SESSIONID, LOGGER_IDTYPE, LOGGER_ID, ExceptionUtils.getStackTrace(ex)); + log.error(LOGGER_SESSIONID, LOGGER_IDTYPE, LOGGER_ID, "In pre-registration service util of getPreregistrationIdentityJson- " + ex.getMessage()); } return null; @@ -927,7 +928,7 @@ private List convertSchemaJsonToArray(String schemaJson) { return idschemaAttributes; } - + public MainResponseDTO getPregistrationInfo(String prid) { log.info("In getPregistrationInfo method of DemographicService for prid {}", prid); MainResponseDTO response = new MainResponseDTO<>(); diff --git a/pre-registration/pre-registration-application-service/src/main/java/io/mosip/preregistration/application/service/DemographicServiceIntf.java b/pre-registration/pre-registration-application-service/src/main/java/io/mosip/preregistration/application/service/DemographicServiceIntf.java index 955c451bc77..81ee4d47dd4 100644 --- a/pre-registration/pre-registration-application-service/src/main/java/io/mosip/preregistration/application/service/DemographicServiceIntf.java +++ b/pre-registration/pre-registration-application-service/src/main/java/io/mosip/preregistration/application/service/DemographicServiceIntf.java @@ -9,7 +9,6 @@ import io.mosip.preregistration.application.dto.DemographicMetadataDTO; import io.mosip.preregistration.application.dto.DemographicRequestDTO; import io.mosip.preregistration.application.dto.DemographicUpdateResponseDTO; -import io.mosip.preregistration.application.dto.SchemaResponseDto; import io.mosip.preregistration.core.common.dto.DemographicResponseDTO; import io.mosip.preregistration.core.common.dto.MainRequestDTO; import io.mosip.preregistration.core.common.dto.MainResponseDTO; diff --git a/pre-registration/pre-registration-application-service/src/main/java/io/mosip/preregistration/application/service/DocumentService.java b/pre-registration/pre-registration-application-service/src/main/java/io/mosip/preregistration/application/service/DocumentService.java index 67a274e2909..ec1e6c1eb69 100644 --- a/pre-registration/pre-registration-application-service/src/main/java/io/mosip/preregistration/application/service/DocumentService.java +++ b/pre-registration/pre-registration-application-service/src/main/java/io/mosip/preregistration/application/service/DocumentService.java @@ -1,5 +1,9 @@ package io.mosip.preregistration.application.service; +import static io.mosip.preregistration.application.constant.PreRegApplicationConstant.LOGGER_ID; +import static io.mosip.preregistration.application.constant.PreRegApplicationConstant.LOGGER_IDTYPE; +import static io.mosip.preregistration.application.constant.PreRegApplicationConstant.LOGGER_SESSIONID; + import java.io.ByteArrayInputStream; import java.io.IOException; import java.io.InputStream; @@ -204,15 +208,16 @@ public AuthUserDetails authUserDetails() { @Transactional(propagation = Propagation.REQUIRES_NEW, rollbackFor = Exception.class) public MainResponseDTO uploadDocument(MultipartFile file, String documentJsonString, String preRegistrationId) { - - log.info("In uploadDocument method of document service with document string {}", documentJsonString); + log.info(LOGGER_SESSIONID, LOGGER_IDTYPE, LOGGER_ID, + "In uploadDocument method of document service with document string " + documentJsonString); MainResponseDTO responseDto = new MainResponseDTO<>(); MainRequestDTO docReqDto = null; boolean isUploadSuccess = false; responseDto.setId(uploadId); responseDto.setVersion(ver); try { - log.info("calling serviceUtil createUploadDto preRegistrationId {}", preRegistrationId); + log.info(LOGGER_SESSIONID, LOGGER_IDTYPE, LOGGER_ID, + "calling serviceUtil createUploadDto preRegistrationId " + preRegistrationId); docReqDto = serviceUtil.createUploadDto(documentJsonString, preRegistrationId); responseDto.setId(docReqDto.getId()); responseDto.setVersion(docReqDto.getVersion()); @@ -224,7 +229,7 @@ public MainResponseDTO uploadDocument(MultipartFile file, S if (serviceUtil.fileSizeCheck(file.getSize()) && serviceUtil.fileExtensionCheck(file)) { serviceUtil.isValidRequest(docReqDto.getRequest(), preRegistrationId); validationUtil.langvalidation(docReqDto.getRequest().getLangCode()); - log.info("calling validationUtil.validateDocuments preRegistrationId {}", preRegistrationId); + log.info(LOGGER_SESSIONID, LOGGER_IDTYPE, LOGGER_ID, "calling validationUtil.validateDocuments preRegistrationId "+ preRegistrationId); validationUtil.validateDocuments(docReqDto.getRequest().getLangCode(), docReqDto.getRequest().getDocCatCode(), docReqDto.getRequest().getDocTypCode(), preRegistrationId); @@ -235,8 +240,8 @@ public MainResponseDTO uploadDocument(MultipartFile file, S isUploadSuccess = true; responseDto.setResponsetime(serviceUtil.getCurrentResponseTime()); } catch (Exception ex) { - log.error("Exception", ExceptionUtils.getStackTrace(ex)); - log.error("In uploadDoucment method of document service - ", ex.getMessage()); + log.error(LOGGER_SESSIONID, LOGGER_IDTYPE, LOGGER_ID, "Exception "+ ExceptionUtils.getStackTrace(ex)); + log.error(LOGGER_SESSIONID, LOGGER_IDTYPE, LOGGER_ID, "In uploadDoucment method of document service - "+ ex.getMessage()); new DocumentExceptionCatcher().handle(ex, responseDto); } finally { @@ -371,8 +376,8 @@ public MainResponseDTO copyDocument(String catCode, String isCopySuccess = true; } catch (Exception ex) { - log.error("Exception", ExceptionUtils.getStackTrace(ex)); - log.error("In copyDoucment method of document service - ", ex.getMessage()); + log.error(LOGGER_SESSIONID, LOGGER_IDTYPE, LOGGER_ID, "Exception "+ ExceptionUtils.getStackTrace(ex)); + log.error(LOGGER_SESSIONID, LOGGER_IDTYPE, LOGGER_ID, "In copyDoucment method of document service - "+ ex.getMessage()); new DocumentExceptionCatcher().handle(ex, responseDto); } finally { if (isCopySuccess) { @@ -445,8 +450,8 @@ public MainResponseDTO getAllDocumentForPreId(String preId) { isRetrieveSuccess = true; } catch (Exception ex) { - log.error("Exception ", ExceptionUtils.getStackTrace(ex)); - log.error("In getAllDocumentForPreId method of document service - ", ex.getMessage()); + log.error(LOGGER_SESSIONID, LOGGER_IDTYPE, LOGGER_ID, "Exception "+ ExceptionUtils.getStackTrace(ex)); + log.error(LOGGER_SESSIONID, LOGGER_IDTYPE, LOGGER_ID, "In getAllDocumentForPreId method of document service - "+ ex.getMessage()); if (ex instanceof DocumentNotFoundException || ex instanceof RecordNotFoundException) { isDocNotFound = true; new DocumentExceptionCatcher().handle(ex, responseDto); @@ -510,7 +515,7 @@ public MainResponseDTO getDocumentForDocId(String docId, String pre docDto.setDocument(cryptoUtil.decrypt(cephBytes, documentEntity.getEncryptedDateTime())); responseDto.setResponse(docDto); } else { - log.error("In dtoSetter method of document service - ", + log.error(LOGGER_SESSIONID, LOGGER_IDTYPE, LOGGER_ID, "In dtoSetter method of document service - "+ io.mosip.preregistration.core.errorcodes.ErrorMessages.HASHING_FAILED.name()); throw new HashingException( io.mosip.preregistration.core.errorcodes.ErrorCodes.PRG_CORE_REQ_010.name(), @@ -521,8 +526,8 @@ public MainResponseDTO getDocumentForDocId(String docId, String pre isRetrieveSuccess = true; } catch (Exception ex) { - log.error("Exception ", ExceptionUtils.getStackTrace(ex)); - log.error("In getAllDocumentForPreId method of document service - ", ex.getMessage()); + log.error(LOGGER_SESSIONID, LOGGER_IDTYPE, LOGGER_ID, "Exception "+ ExceptionUtils.getStackTrace(ex)); + log.error(LOGGER_SESSIONID, LOGGER_IDTYPE, LOGGER_ID, "In getAllDocumentForPreId method of document service - "+ ex.getMessage()); if (ex instanceof DocumentNotFoundException) isDocNotFound = true; new DocumentExceptionCatcher().handle(ex, responseDto); @@ -560,8 +565,7 @@ public DocumentsMetaData createDocumentResponse(List entityList) List allDocRes = new ArrayList<>(); DocumentsMetaData documentsMetaData = new DocumentsMetaData(); for (DocumentEntity doc : entityList) { - - log.info("Demographic preid: {}", doc.getDemographicEntity().getPreRegistrationId()); + log.info(LOGGER_SESSIONID, LOGGER_IDTYPE, LOGGER_ID, "Demographic preid: "+ doc.getDemographicEntity().getPreRegistrationId()); DocumentMultipartResponseDTO allDocDto = new DocumentMultipartResponseDTO(); allDocDto.setDocCatCode(doc.getDocCatCode()); @@ -626,7 +630,7 @@ public MainResponseDTO deleteDocument(String document else if (isMandatoryDocumentDeleted(demographicEntity, documentEntity.getDocCatCode())) { //if one of the mandatory doc is deleted // then set the status from Pending Appointment to Application Incomplete - log.info("mandatory document deleted"); + log.info(LOGGER_SESSIONID, LOGGER_IDTYPE, LOGGER_ID, "mandatory document deleted"); serviceUtil.updateApplicationStatusToIncomplete(demographicEntity); } } @@ -643,8 +647,8 @@ else if (isMandatoryDocumentDeleted(demographicEntity, documentEntity.getDocCatC isRetrieveSuccess = true; } catch (Exception ex) { - log.error("sessionId", "idType", "id", ExceptionUtils.getStackTrace(ex)); - log.error("sessionId", "idType", "id", "In deleteDocument method of document service - " + ex.getMessage()); + log.error(LOGGER_SESSIONID, LOGGER_IDTYPE, LOGGER_ID, ExceptionUtils.getStackTrace(ex)); + log.error(LOGGER_SESSIONID, LOGGER_IDTYPE, LOGGER_ID, "In deleteDocument method of document service - " + ex.getMessage()); if (ex instanceof DocumentNotFoundException) isDocNotFound = true; new DocumentExceptionCatcher().handle(ex, delResponseDto); @@ -670,14 +674,15 @@ else if (isMandatoryDocumentDeleted(demographicEntity, documentEntity.getDocCatC return delResponseDto; } - private boolean isMandatoryDocumentDeleted(DemographicEntity demographicEntity, String docCateCodeOfDoc) throws ParseException { - + private boolean isMandatoryDocumentDeleted(DemographicEntity demographicEntity, String docCateCodeOfDoc) + throws ParseException { + List mandatoryDocs = serviceUtil.validMandatoryDocuments(demographicEntity); - log.info("mandatory documents for user {} ----> {}", demographicEntity.getPreRegistrationId(), mandatoryDocs); - List filteredMandatoryDocs = mandatoryDocs.stream().filter(doc -> doc.equalsIgnoreCase(docCateCodeOfDoc)) - .collect(Collectors.toList()); - if (filteredMandatoryDocs.size() > 0) { - log.info("Mandatory document Deleted {}", docCateCodeOfDoc); + log.info(LOGGER_SESSIONID, LOGGER_IDTYPE, LOGGER_ID, "mandatory documents for user {" + demographicEntity.getPreRegistrationId() + "} ----> {" + mandatoryDocs.toString() + "}"); + List filteredMandatoryDocs = mandatoryDocs.stream() + .filter(doc -> doc.equalsIgnoreCase(docCateCodeOfDoc)).collect(Collectors.toList()); + if (!filteredMandatoryDocs.isEmpty()) { + log.info(LOGGER_SESSIONID, LOGGER_IDTYPE, LOGGER_ID, "Mandatory document Deleted {}", docCateCodeOfDoc); return true; } return false; @@ -710,8 +715,8 @@ public MainResponseDTO deleteAllByPreId(String prereg isDeleteSuccess = true; } catch (Exception ex) { - log.error("In deleteAllByPreId method of document service - ", ExceptionUtils.getStackTrace(ex)); - log.error("In deleteAllByPreId method of document service - ", ex.getMessage()); + log.error(LOGGER_SESSIONID, LOGGER_IDTYPE, LOGGER_ID, "In deleteAllByPreId method of document service - "+ ExceptionUtils.getStackTrace(ex)); + log.error(LOGGER_SESSIONID, LOGGER_IDTYPE, LOGGER_ID, "In deleteAllByPreId method of document service - "+ ex.getMessage()); if (ex instanceof DocumentNotFoundException) isDocNotFound = true; new DocumentExceptionCatcher().handle(ex, deleteRes); @@ -738,7 +743,7 @@ public MainResponseDTO deleteAllByPreId(String prereg } public DocumentDeleteResponseDTO deleteFile(List documentEntityList, String preregId) { - log.info("In pre-registration service inside delete File for preregid {} ", preregId); + log.info(LOGGER_SESSIONID, LOGGER_IDTYPE, LOGGER_ID, "In pre-registration service inside delete File for preregid "+ preregId); DocumentDeleteResponseDTO deleteDTO = new DocumentDeleteResponseDTO(); if (documnetDAO.deleteAllBypreregId(preregId) >= 0) { for (DocumentEntity documentEntity : documentEntityList) { @@ -826,8 +831,8 @@ public MainResponseDTO updateDocRefId(String documentId, String preId, S DocumentErrorMessages.INVALID_DOCUMENT_ID.getMessage()); } } catch (Exception ex) { - log.error("Exception", ExceptionUtils.getStackTrace(ex)); - log.error("In updatePreRegistrationStatus method of pre-registration service- ", ex.getMessage()); + log.error(LOGGER_SESSIONID, LOGGER_IDTYPE, LOGGER_ID, "Exception "+ ExceptionUtils.getStackTrace(ex)); + log.error(LOGGER_SESSIONID, LOGGER_IDTYPE, LOGGER_ID, "In updatePreRegistrationStatus method of pre-registration service- "+ ex.getMessage()); new DocumentExceptionCatcher().handle(ex, response); } diff --git a/pre-registration/pre-registration-application-service/src/main/java/io/mosip/preregistration/application/service/GenerateQRcodeService.java b/pre-registration/pre-registration-application-service/src/main/java/io/mosip/preregistration/application/service/GenerateQRcodeService.java index 9e75c7901f6..b85b26b0dd6 100644 --- a/pre-registration/pre-registration-application-service/src/main/java/io/mosip/preregistration/application/service/GenerateQRcodeService.java +++ b/pre-registration/pre-registration-application-service/src/main/java/io/mosip/preregistration/application/service/GenerateQRcodeService.java @@ -1,5 +1,9 @@ package io.mosip.preregistration.application.service; +import static io.mosip.preregistration.application.constant.PreRegApplicationConstant.LOGGER_SESSIONID; +import static io.mosip.preregistration.application.constant.PreRegApplicationConstant.LOGGER_IDTYPE; +import static io.mosip.preregistration.application.constant.PreRegApplicationConstant.LOGGER_ID; + import java.util.HashMap; import java.util.Map; @@ -62,7 +66,6 @@ public class GenerateQRcodeService { public void setupBookingService() { requiredRequestMap.put("version", version); requiredRequestMap.put("id", id); - } /** @@ -74,7 +77,7 @@ public void setupBookingService() { public MainResponseDTO generateQRCode(MainRequestDTO data) { byte[] qrCode = null; - log.info("sessionId", "idType", "id", "In generateQRCode service of generateQRCode "); + log.info(LOGGER_SESSIONID, LOGGER_IDTYPE, LOGGER_ID, "In generateQRCode service of generateQRCode "); QRCodeResponseDTO responsedto = null; MainResponseDTO response = new MainResponseDTO<>(); @@ -98,12 +101,11 @@ public MainResponseDTO generateQRCode(MainRequestDTO response.setResponsetime(serviceUtil.getCurrentResponseTime()); } catch (Exception ex) { - log.error("sessionId", "idType", "id", ExceptionUtils.getStackTrace(ex)); - log.error("sessionId", "idType", "id", "In generateQRCode service of generateQRCode " + ex.getMessage()); + log.error(LOGGER_SESSIONID, LOGGER_IDTYPE, LOGGER_ID, ExceptionUtils.getStackTrace(ex)); + log.error(LOGGER_SESSIONID, LOGGER_IDTYPE, LOGGER_ID, "In generateQRCode service of generateQRCode " + ex.getMessage()); new QRcodeExceptionCatcher().handle(ex, response); } return response; } - -} +} \ No newline at end of file diff --git a/pre-registration/pre-registration-application-service/src/main/java/io/mosip/preregistration/application/service/LoginService.java b/pre-registration/pre-registration-application-service/src/main/java/io/mosip/preregistration/application/service/LoginService.java index 72f12152883..b96d3993767 100644 --- a/pre-registration/pre-registration-application-service/src/main/java/io/mosip/preregistration/application/service/LoginService.java +++ b/pre-registration/pre-registration-application-service/src/main/java/io/mosip/preregistration/application/service/LoginService.java @@ -1,5 +1,9 @@ package io.mosip.preregistration.application.service; +import static io.mosip.preregistration.application.constant.PreRegApplicationConstant.LOGGER_ID; +import static io.mosip.preregistration.application.constant.PreRegApplicationConstant.LOGGER_IDTYPE; +import static io.mosip.preregistration.application.constant.PreRegApplicationConstant.LOGGER_SESSIONID; + import java.time.Instant; import java.time.LocalDateTime; import java.util.ArrayList; @@ -18,6 +22,7 @@ import java.util.Objects; import org.apache.commons.lang.StringUtils; +import org.apache.commons.lang.exception.ExceptionUtils; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Value; import org.springframework.cache.annotation.Cacheable; @@ -69,7 +74,6 @@ public class LoginService { @Autowired private LoginCommonUtil loginCommonUtil; - @Value("${ui.config.params}") private String uiConfigParams; @@ -126,7 +130,8 @@ public class LoginService { OTPManager otpmanager; @Autowired - private Environment env; + private Environment env; + /** * It will fetch otp from Kernel auth service and send to the userId provided * @@ -144,7 +149,8 @@ public MainResponseDTO sendOTP(MainRequestDTO user try { response = (MainResponseDTO) loginCommonUtil.getMainResponseDto(userOtpRequest); - log.info("Response after loginCommonUtil {}", response); + log.info(LOGGER_SESSIONID, LOGGER_IDTYPE, LOGGER_ID, + "Response after loginCommonUtil " + response.toString()); userid = userOtpRequest.getRequest().getUserId(); otpChannel = loginCommonUtil.validateUserId(userid); @@ -191,8 +197,8 @@ public MainResponseDTO sendOTP(MainRequestDTO user public MainResponseDTO validateCaptchaAndSendOtp( MainRequestDTO request) { - log.info("In validateCaptchaAndSendOtp method with userId and langCode{}", request.getRequest().getUserId(), - request.getRequest().getUserId()); + log.info(LOGGER_SESSIONID, LOGGER_IDTYPE, LOGGER_ID, "In validateCaptchaAndSendOtp method with userId " + + request.getRequest().getUserId() + "and langCode " + request.getRequest().getUserId()); MainResponseDTO response = (MainResponseDTO) loginCommonUtil .getMainResponseDto(request); @@ -227,11 +233,10 @@ public MainResponseDTO validateCaptchaAndSendOtp( response.setResponse(authRes); } catch (PreRegLoginException ex) { - - log.error("In validateCaptchaAndSendOtp method of login service- ", ex); + log.error(LOGGER_SESSIONID, LOGGER_IDTYPE, LOGGER_ID, "In validateCaptchaAndSendOtp method of login service- " + ExceptionUtils.getFullStackTrace(ex)); new LoginExceptionCatcher().handle(ex, "sendOtp", response); } catch (Exception ex) { - log.error("In validateCaptchaAndSendOtp method of login service- ", ex); + log.error(LOGGER_SESSIONID, LOGGER_IDTYPE, LOGGER_ID, "In validateCaptchaAndSendOtp method of login service- " + ExceptionUtils.getFullStackTrace(ex)); new LoginExceptionCatcher().handle(ex, "sendOtp", response); } response.setResponsetime(LocalDateTime.now().toString()); @@ -271,10 +276,10 @@ public MainResponseDTO validateWithUserIdOtp(MainRequestDTO response.setResponse(authresponse); isSuccess = true; } catch (PreRegLoginException ex) { - log.error("In calluserIdOtp method of login service- ", ex); + log.error(LOGGER_SESSIONID, LOGGER_IDTYPE, LOGGER_ID, "In calluserIdOtp method of login service- " + ExceptionUtils.getFullStackTrace(ex)); new LoginExceptionCatcher().handle(ex, "userIdOtp", response); } catch (RuntimeException ex) { - log.error("In calluserIdOtp method of login service- ", ex); + log.error(LOGGER_SESSIONID, LOGGER_IDTYPE, LOGGER_ID, "In calluserIdOtp method of login service- " + ExceptionUtils.getFullStackTrace(ex)); new LoginExceptionCatcher().handle(ex, "userIdOtp", response); } finally { response.setResponsetime(GenericUtil.getCurrentResponseTime()); @@ -320,16 +325,15 @@ public MainResponseDTO invalidateToken(String token) { userId = clamis.getBody().get("userId").toString(); response.setResponse("Loggedout successfully"); isSuccess = true; - } catch (JwtException e) { - log.error("JwtException, logout failed :", e); - MainResponseDTO res = new MainResponseDTO(); + } catch (JwtException ex) { + log.error(LOGGER_SESSIONID, LOGGER_IDTYPE, LOGGER_ID, "JwtException, logout failed " + ExceptionUtils.getFullStackTrace(ex)); + MainResponseDTO res = new MainResponseDTO<>(); res.setResponse("Failed to invalidate the auth token"); - new LoginExceptionCatcher().handle(e, "invalidateToken", res); + new LoginExceptionCatcher().handle(ex, "invalidateToken", res); } catch (Exception ex) { log.error("In call invalidateToken method of login service- ", ex); new LoginExceptionCatcher().handle(ex, "invalidateToken", response); } finally { - System.out.println(response); response.setResponsetime(GenericUtil.getCurrentResponseTime()); if (isSuccess) { @@ -370,9 +374,9 @@ public void setAuditValues(String eventId, String eventName, String eventType, S auditRequestDto.setModuleName(AuditLogVariables.AUTHENTICATION_SERVICE.toString()); auditLogUtil.saveAuditDetails(auditRequestDto); } catch (LoginServiceException ex) { - log.error("In setAuditvalue of login service:", StringUtils.join(ex.getValidationErrorList(), ",")); + log.error(LOGGER_SESSIONID, LOGGER_IDTYPE, LOGGER_ID, "In setAuditvalue of login service: " + StringUtils.join(ex.getValidationErrorList(), ",")); } catch (Exception ex) { - log.error("In setAuditvalue of login service:", ex); + log.error(LOGGER_SESSIONID, LOGGER_IDTYPE, LOGGER_ID, "In setAuditvalue of login service: " + ExceptionUtils.getFullStackTrace(ex)); } } @@ -391,13 +395,13 @@ public MainResponseDTO> getConfig() { try { loginCommonUtil.validateLanguageProperties(responseParamsMap); String[] uiParams = uiConfigParams.split(","); - for (String uiParam: uiParams) { + for (String uiParam : uiParams) { if (env.getProperty(uiParam) != null) { responseParamsMap.put(uiParam, env.getProperty(uiParam)); } - } + } } catch (Exception ex) { - log.error("In login service of getConfig ", ex); + log.error(LOGGER_SESSIONID, LOGGER_IDTYPE, LOGGER_ID, "In login service of getConfig " + ExceptionUtils.getFullStackTrace(ex)); new LoginExceptionCatcher().handle(ex, "config", res); } res.setResponse(responseParamsMap); @@ -407,7 +411,7 @@ public MainResponseDTO> getConfig() { private String generateJWTToken(String userId, String issuerUrl, String jwtTokenExpiryTime) { log.info("In generateJWTToken method of loginservice:{} {}", userId, issuerUrl); - Map claims = new HashMap(); + Map claims = new HashMap<>(); claims.put("userId", userId); claims.put("scope", jwtScope); claims.put("user_name", userId); @@ -420,13 +424,13 @@ private String generateJWTToken(String userId, String issuerUrl, String jwtToken .setExpiration(Date.from(Instant.now().plusSeconds(Integer.parseInt(jwtTokenExpiryTime)))) .setAudience(jwtAudience).signWith(SignatureAlgorithm.HS256, TextCodec.BASE64.decode(jwtSecret)) .compact(); - log.info("Auth token generarted"); + log.info(LOGGER_SESSIONID, LOGGER_IDTYPE, LOGGER_ID, "Auth token generarted"); } else { jws = Jwts.builder().setClaims(claims).setIssuer(issuerUrl).setIssuedAt(Date.from(Instant.now())) .setSubject(userId).setExpiration(Date.from(Instant.now().plusSeconds(Integer.parseInt("0")))) .setAudience(jwtAudience).signWith(SignatureAlgorithm.HS256, TextCodec.BASE64.decode(jwtSecret)) .compact(); - log.info("Auth token generarted:"); + log.info(LOGGER_SESSIONID, LOGGER_IDTYPE, LOGGER_ID, "Auth token generarted:"); } return jws; @@ -445,11 +449,11 @@ public String getLogoutToken(String token) { Jws clamis = Jwts.parser().setSigningKey(secret).parseClaimsJws(jwtToken); userId = clamis.getBody().get("userId").toString(); issuer = clamis.getBody().getIssuer(); - } catch (JwtException e) { - log.error("Failed to generate logout token:", e); + } catch (JwtException ex) { + log.error(LOGGER_SESSIONID, LOGGER_IDTYPE, LOGGER_ID, "Failed to generate logout token:" + ExceptionUtils.getFullStackTrace(ex)); MainResponseDTO res = new MainResponseDTO(); res.setResponse("Failed to generate logout token"); - new LoginExceptionCatcher().handle(e, "invalidateToken", res); + new LoginExceptionCatcher().handle(ex, "invalidateToken", res); } return this.generateJWTToken(userId, issuer, null); } diff --git a/pre-registration/pre-registration-application-service/src/main/java/io/mosip/preregistration/application/service/NotificationService.java b/pre-registration/pre-registration-application-service/src/main/java/io/mosip/preregistration/application/service/NotificationService.java index ad2febfd238..1e79264e988 100644 --- a/pre-registration/pre-registration-application-service/src/main/java/io/mosip/preregistration/application/service/NotificationService.java +++ b/pre-registration/pre-registration-application-service/src/main/java/io/mosip/preregistration/application/service/NotificationService.java @@ -1,5 +1,9 @@ package io.mosip.preregistration.application.service; +import static io.mosip.preregistration.application.constant.PreRegApplicationConstant.LOGGER_ID; +import static io.mosip.preregistration.application.constant.PreRegApplicationConstant.LOGGER_IDTYPE; +import static io.mosip.preregistration.application.constant.PreRegApplicationConstant.LOGGER_SESSIONID; + import java.io.IOException; import java.time.LocalTime; import java.time.format.DateTimeFormatter; @@ -8,14 +12,6 @@ import java.util.List; import java.util.Map; -import jakarta.annotation.PostConstruct; - -import com.fasterxml.jackson.databind.JsonNode; -import com.fasterxml.jackson.databind.ObjectMapper; -import com.fasterxml.jackson.databind.json.JsonMapper; -import com.fasterxml.jackson.datatype.jsr310.JavaTimeModule; -import com.fasterxml.jackson.module.afterburner.AfterburnerModule; - import org.json.JSONException; import org.json.simple.parser.ParseException; import org.springframework.beans.factory.annotation.Autowired; @@ -25,6 +21,12 @@ import org.springframework.web.client.RestClientException; import org.springframework.web.multipart.MultipartFile; +import com.fasterxml.jackson.databind.JsonNode; +import com.fasterxml.jackson.databind.ObjectMapper; +import com.fasterxml.jackson.databind.json.JsonMapper; +import com.fasterxml.jackson.datatype.jsr310.JavaTimeModule; +import com.fasterxml.jackson.module.afterburner.AfterburnerModule; + import io.mosip.kernel.core.authmanager.authadapter.model.AuthUserDetails; import io.mosip.kernel.core.exception.ExceptionUtils; import io.mosip.kernel.core.logger.spi.Logger; @@ -55,6 +57,7 @@ import io.mosip.preregistration.core.util.AuditLogUtil; import io.mosip.preregistration.core.util.NotificationUtil; import io.mosip.preregistration.core.util.ValidationUtil; +import jakarta.annotation.PostConstruct; /** * The service class contans all the method for notification. @@ -81,10 +84,10 @@ public class NotificationService { @Autowired private DemographicServiceIntf demographicServiceIntf; - + @Autowired private ApplicationServiceIntf applicationServiceIntf; - + /** * Reference for ${appointmentResourse.url} from property file */ @@ -167,7 +170,7 @@ public MainResponseDTO sendNotification(String jsonStri response = new MainResponseDTO<>(); NotificationResponseDTO notificationResponse = new NotificationResponseDTO(); - log.info("sessionId", "idType", "id", "In notification service of sendNotification with request " + jsonString + log.info(LOGGER_SESSIONID, LOGGER_IDTYPE, LOGGER_ID, "In notification service of sendNotification with request " + jsonString + " and langCode " + langCode); requiredRequestMap.put("id", Id); response.setId(Id); @@ -186,7 +189,7 @@ public MainResponseDTO sendNotification(String jsonStri String bookingType = appEntity.getResponse().getBookingType(); MainResponseDTO demoDetail = notificationDtoValidation(bookingType, notificationDto); if (notificationDto.isAdditionalRecipient()) { - log.info("sessionId", "idType", "id", + log.info(LOGGER_SESSIONID, LOGGER_IDTYPE, LOGGER_ID, "In notification service of sendNotification if additionalRecipient is" + notificationDto.isAdditionalRecipient()); if (notificationDto.getMobNum() != null && !notificationDto.getMobNum().isEmpty()) { @@ -218,7 +221,7 @@ public MainResponseDTO sendNotification(String jsonStri } notificationResponse.setMessage(NotificationRequestCodes.MESSAGE.getCode()); } else { - log.info("sessionId", "idType", "id", + log.info(LOGGER_SESSIONID, LOGGER_IDTYPE, LOGGER_ID, "In notification service of sendNotification if additionalRecipient is" + notificationDto.isAdditionalRecipient()); resp = getDemographicDetailsWithPreId(bookingType, demoDetail, appEntity, notificationDto, langCode, file); @@ -232,8 +235,8 @@ public MainResponseDTO sendNotification(String jsonStri | io.mosip.kernel.core.util.exception.JsonParseException | io.mosip.kernel.core.util.exception.JsonMappingException | io.mosip.kernel.core.exception.IOException | JSONException | java.text.ParseException ex) { - log.error("sessionId", "idType", "id", ExceptionUtils.getStackTrace(ex)); - log.error("sessionId", "idType", "id", "In notification service of sendNotification " + ex.getMessage()); + log.error(LOGGER_SESSIONID, LOGGER_IDTYPE, LOGGER_ID, ExceptionUtils.getStackTrace(ex)); + log.error(LOGGER_SESSIONID, LOGGER_IDTYPE, LOGGER_ID, "In notification service of sendNotification " + ex.getMessage()); new NotificationExceptionCatcher().handle(ex, response); } finally { response.setResponsetime(validationUtil.getCurrentResponseTime()); @@ -262,10 +265,11 @@ public MainResponseDTO sendNotification(String jsonStri * @return * @throws IOException */ - private String getDemographicDetailsWithPreId(String bookingType, MainResponseDTO responseEntity, - MainResponseDTO appEntity, NotificationDTO notificationDto, String langCode, MultipartFile file) throws IOException { + private String getDemographicDetailsWithPreId(String bookingType, + MainResponseDTO responseEntity, MainResponseDTO appEntity, + NotificationDTO notificationDto, String langCode, MultipartFile file) throws IOException { try { - List> langaueNamePairs = new ArrayList>(); + List> langaueNamePairs = new ArrayList>(); if (BookingTypeCodes.NEW_PREREGISTRATION.toString().equals(bookingType)) { ObjectMapper objectMapper = new ObjectMapper(); objectMapper = JsonMapper.builder().addModule(new AfterburnerModule()).build(); @@ -273,9 +277,9 @@ private String getDemographicDetailsWithPreId(String bookingType, MainResponseDT JsonNode responseNode = objectMapper .readTree(responseEntity.getResponse().getDemographicDetails().toJSONString()); - + responseNode = responseNode.get(identity); - + JsonNode arrayNode = responseNode.get(fullName); KeyValuePairDto langaueNamePair = null; if (arrayNode.isArray()) { @@ -285,12 +289,12 @@ private String getDemographicDetailsWithPreId(String bookingType, MainResponseDT langaueNamePair.setValue(jsonNode.get("value").asText().trim()); langaueNamePairs.add(langaueNamePair); } - } + } notificationDto.setFullName(langaueNamePairs); if (responseNode.get(email) != null) { String emailId = responseNode.get(email).asText(); notificationDto.setEmailID(emailId); - notificationUtil.notify(NotificationRequestCodes.EMAIL.getCode(), notificationDto, file, + notificationUtil.notify(NotificationRequestCodes.EMAIL.getCode(), notificationDto, file, appEntity.getResponse().getBookingType()); } if (responseNode.get(phone) != null) { @@ -298,16 +302,17 @@ private String getDemographicDetailsWithPreId(String bookingType, MainResponseDT notificationDto.setMobNum(phoneNumber); notificationUtil.notify(NotificationRequestCodes.SMS.getCode(), notificationDto, file, appEntity.getResponse().getBookingType()); - + } if (responseNode.get(email) == null && responseNode.get(phone) == null) { - log.info("sessionId", "idType", "id", + log.info(LOGGER_SESSIONID, LOGGER_IDTYPE, LOGGER_ID, "In notification service of sendNotification failed to send Email and sms request "); } } else { - //handle notifications for other booking types like LOST_FORGOTTEN_UIN, MISCELLANEOUS_PURPOSE etc + // handle notifications for other booking types like LOST_FORGOTTEN_UIN, + // MISCELLANEOUS_PURPOSE etc if (notificationDto.getName() == null) { - //in case name is null, set applicationId as name + // in case name is null, set applicationId as name String applicationId = appEntity.getResponse().getApplicationId(); notificationDto.setName(applicationId); } @@ -325,33 +330,32 @@ private String getDemographicDetailsWithPreId(String bookingType, MainResponseDT notificationUtil.notify(NotificationRequestCodes.SMS.getCode(), notificationDto, file, appEntity.getResponse().getBookingType()); } - if (notificationDto.getEmailID() == null && notificationDto.getMobNum() == null ) { - //in case both email id and mob num are null, send details to contact info + if (notificationDto.getEmailID() == null && notificationDto.getMobNum() == null) { + // in case both email id and mob num are null, send details to contact info String createdById = appEntity.getResponse().getContactInfo(); if (createdById != null) { if (validationUtil.emailValidator(createdById)) { notificationDto.setEmailID(createdById); notificationUtil.notify(NotificationRequestCodes.EMAIL.getCode(), notificationDto, file, appEntity.getResponse().getBookingType()); - } - else if (validationUtil.phoneValidator(createdById)) { + } else if (validationUtil.phoneValidator(createdById)) { notificationDto.setMobNum(createdById); notificationUtil.notify(NotificationRequestCodes.SMS.getCode(), notificationDto, file, appEntity.getResponse().getBookingType()); } else { - log.info("sessionId", "idType", "id", - "In notification service of sendNotification failed to send Email and sms request "); + log.info(LOGGER_SESSIONID, LOGGER_IDTYPE, LOGGER_ID, + "In notification service of sendNotification failed to send Email and sms request "); } } else { - log.info("sessionId", "idType", "id", - "In notification service of sendNotification failed to send Email and sms request "); + log.info(LOGGER_SESSIONID, LOGGER_IDTYPE, LOGGER_ID, + "In notification service of sendNotification failed to send Email and sms request "); } } } return NotificationRequestCodes.MESSAGE.getCode(); } catch (RestClientException ex) { - log.error("sessionId", "idType", "id", ExceptionUtils.getStackTrace(ex)); - log.error("sessionId", "idType", "id", + log.error(LOGGER_SESSIONID, LOGGER_IDTYPE, LOGGER_ID, ExceptionUtils.getStackTrace(ex)); + log.error(LOGGER_SESSIONID, LOGGER_IDTYPE, LOGGER_ID, "In getDemographicDetailsWithPreId method of notification service - " + ex.getMessage()); throw new RestCallException(NotificationErrorCodes.PRG_PAM_ACK_011.getCode(), NotificationErrorMessages.DEMOGRAPHIC_CALL_FAILED.getMessage()); @@ -387,13 +391,14 @@ public MainResponseDTO notificationDtoValidation(String MainResponseDTO demoDetail = null; if (BookingTypeCodes.NEW_PREREGISTRATION.toString().equals(bookingType)) { demoDetail = getDemographicDetails(dto); - } + } if (!dto.getIsBatch()) { BookingRegistrationDTO bookingDTO = getAppointmentDetailsRestService(dto.getPreRegistrationId()); String registrationCenterId = bookingDTO.getRegistrationCenterId(); String time = LocalTime.parse(bookingDTO.getSlotFromTime(), DateTimeFormatter.ofPattern("HH:mm")) .format(DateTimeFormatter.ofPattern("hh:mm a")); - log.info("sessionId", "idType", "id", "In notificationDtoValidation with bookingDTO " + bookingDTO); + log.info(LOGGER_SESSIONID, LOGGER_IDTYPE, LOGGER_ID, + "In notificationDtoValidation with bookingDTO " + bookingDTO); if (dto.getAppointmentDate() != null && !dto.getAppointmentDate().trim().equals("")) { if (bookingDTO.getRegDate().equals(dto.getAppointmentDate())) { if (dto.getAppointmentTime() != null && !dto.getAppointmentTime().trim().equals("")) { @@ -419,7 +424,8 @@ public MainResponseDTO notificationDtoValidation(String throw new MandatoryFieldException(NotificationErrorCodes.PRG_PAM_ACK_002.getCode(), NotificationErrorMessages.INCORRECT_MANDATORY_FIELDS.getMessage(), response); } - dto = serviceUtil.modifyCenterNameAndAddress(dto, registrationCenterId, dto.getLanguageCode().split(",")[0]); + dto = serviceUtil.modifyCenterNameAndAddress(dto, registrationCenterId, + dto.getLanguageCode().split(",")[0]); } return demoDetail; } @@ -440,15 +446,16 @@ public MainResponseDTO getDemographicDetails(Notificatio ObjectMapper objectMapper = new ObjectMapper(); objectMapper = JsonMapper.builder().addModule(new AfterburnerModule()).build(); objectMapper.registerModule(new JavaTimeModule()); - + if (responseEntity.getErrors() != null) { throw new DemographicDetailsNotFoundException(responseEntity.getErrors(), response); } - JsonNode responseNode = objectMapper.readTree(responseEntity.getResponse().getDemographicDetails().toJSONString()); + JsonNode responseNode = objectMapper + .readTree(responseEntity.getResponse().getDemographicDetails().toJSONString()); responseNode = responseNode.get(identity); if (!notificationDto.isAdditionalRecipient()) { if (notificationDto.getMobNum() != null || notificationDto.getEmailID() != null) { - log.error("sessionId", "idType", "id", + log.error(LOGGER_SESSIONID, LOGGER_IDTYPE, LOGGER_ID, "Not considering the requested mobilenumber/email since additional recipient is false "); } } @@ -483,7 +490,8 @@ public MainResponseDTO getDemographicDetails(Notificatio * */ public BookingRegistrationDTO getAppointmentDetailsRestService(String preId) { - log.info("sessionId", "idType", "id", "In getAppointmentDetailsRestService method of notification service "); + log.info(LOGGER_SESSIONID, LOGGER_IDTYPE, LOGGER_ID, + "In getAppointmentDetailsRestService method of notification service "); BookingRegistrationDTO bookingRegistrationDTO = null; MainResponseDTO respEntity = notificationUtil.getAppointmentDetails(preId); diff --git a/pre-registration/pre-registration-application-service/src/main/java/io/mosip/preregistration/application/service/OTPManager.java b/pre-registration/pre-registration-application-service/src/main/java/io/mosip/preregistration/application/service/OTPManager.java index 5bc53dd8d45..8fd505b4c83 100644 --- a/pre-registration/pre-registration-application-service/src/main/java/io/mosip/preregistration/application/service/OTPManager.java +++ b/pre-registration/pre-registration-application-service/src/main/java/io/mosip/preregistration/application/service/OTPManager.java @@ -1,5 +1,9 @@ package io.mosip.preregistration.application.service; +import static io.mosip.preregistration.application.constant.PreRegApplicationConstant.LOGGER_ID; +import static io.mosip.preregistration.application.constant.PreRegApplicationConstant.LOGGER_IDTYPE; +import static io.mosip.preregistration.application.constant.PreRegApplicationConstant.LOGGER_SESSIONID; + import java.io.IOException; import java.security.NoSuchAlgorithmException; import java.time.LocalDateTime; @@ -8,13 +12,10 @@ import java.util.Arrays; import java.util.HashMap; import java.util.Map; -import java.util.Objects; import java.util.UUID; import javax.xml.bind.DatatypeConverter; -import org.json.simple.JSONObject; -import org.json.simple.JSONValue; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Qualifier; import org.springframework.beans.factory.annotation.Value; @@ -58,7 +59,7 @@ public class OTPManager { /** The Constant USER_BLOCKED. */ private static final String USER_BLOCKED = "USER_BLOCKED"; - + /** The Constant OTP_ATTEMPT_EXCEEDED. */ private static final String OTP_ATTEMPT_EXCEEDED = "OTP_ATTEMPT_EXCEEDED"; @@ -73,7 +74,7 @@ public class OTPManager { @Value("${sendOtp.resource.url}") private String sendOtpResourceUrl; - + @Value("${pre.reg.login.otp.validation-attempt-threshold}") private int otpValidationThreshold; @@ -111,25 +112,26 @@ public class OTPManager { */ public boolean sendOtp(MainRequestDTO requestDTO, String channelType, String language) throws PreRegLoginException, IOException { - logger.info("sessionId", "idType", "id", "In sendOtp method of otpmanager service "); + logger.info(LOGGER_SESSIONID, LOGGER_IDTYPE, LOGGER_ID, "In sendOtp method of otpmanager service "); String userId = requestDTO.getRequest().getUserId(); String refId = hash(userId); if ((otpRepo.checkotpsent(refId, PreRegLoginConstant.ACTIVE_STATUS, DateUtils.getUTCCurrentDateTime()) > 0)) { - logger.error(PreRegLoginConstant.SESSION_ID, this.getClass().getSimpleName(), + logger.error(LOGGER_SESSIONID, this.getClass().getSimpleName(), PreRegLoginErrorConstants.OTP_ALREADY_SENT.getErrorCode(), OTP_ALREADY_SENT); throw new PreRegLoginException(PreRegLoginErrorConstants.OTP_ALREADY_SENT.getErrorCode(), PreRegLoginErrorConstants.OTP_ALREADY_SENT.getErrorMessage()); } String otp = generateOTP(requestDTO); - logger.info("sessionId", "idType", "id", "In generateOTP method of otpmanager service OTP generated"); + logger.info(LOGGER_SESSIONID, LOGGER_IDTYPE, LOGGER_ID, + "In generateOTP method of otpmanager service OTP generated"); String otpHash = digestAsPlainText( (userId + environment.getProperty(PreRegLoginConstant.KEY_SPLITTER) + otp).getBytes()); if (otpRepo.existsByOtpHashAndStatusCode(otpHash, PreRegLoginConstant.ACTIVE_STATUS)) { - OtpTransaction otpTxn = otpRepo.findTopByOtpHashAndStatusCode(otpHash, PreRegLoginConstant.ACTIVE_STATUS); + OtpTransaction otpTxn = otpRepo.findTopByOtpHashAndStatusCode(otpHash, PreRegLoginConstant.ACTIVE_STATUS); otpTxn.setOtpHash(otpHash); otpTxn.setUpdBy(environment.getProperty(PreRegLoginConstant.MOSIP_PRE_REG_CLIENTID)); otpTxn.setUpdDTimes(DateUtils.getUTCCurrentDateTime()); @@ -167,12 +169,12 @@ public boolean sendOtp(MainRequestDTO requestDTO, String channelT mp.put("time", timeFormatter.format(dateTime)); if (channelType.equalsIgnoreCase(PreRegLoginConstant.PHONE_NUMBER)) { - logger.info("sessionId", "idType", "id", + logger.info(LOGGER_SESSIONID, LOGGER_IDTYPE, LOGGER_ID, "In generateOTP method of otpmanager service invoking sms notification"); notification.invokeSmsNotification(mp, userId, requestDTO, language); } if (channelType.equalsIgnoreCase(PreRegLoginConstant.EMAIL)) { - logger.info("sessionId", "idType", "id", + logger.info(LOGGER_SESSIONID, LOGGER_IDTYPE, LOGGER_ID, "In generateOTP method of otpmanager service invoking email notification"); notification.invokeEmailNotification(mp, userId, requestDTO, language); } @@ -180,7 +182,7 @@ public boolean sendOtp(MainRequestDTO requestDTO, String channelT } private String generateOTP(MainRequestDTO requestDTO) throws PreRegLoginException { - logger.info("sessionId", "idType", "id", "In generateOTP method of otpmanager service "); + logger.info(LOGGER_SESSIONID, LOGGER_IDTYPE, LOGGER_ID, "In generateOTP method of otpmanager service "); try { OTPGenerateRequestDTO otpRequestDTO = new OTPGenerateRequestDTO(); otpRequestDTO.setId(requestDTO.getId()); @@ -205,7 +207,7 @@ private String generateOTP(MainRequestDTO requestDTO) throws PreR Map res = response.getResponse(); if (res != null) { if (res.get("status").equals(USER_BLOCKED)) { - logger.error(PreRegLoginConstant.SESSION_ID, this.getClass().getSimpleName(), + logger.error(LOGGER_SESSIONID, LOGGER_IDTYPE, LOGGER_ID, this.getClass().getSimpleName(), PreRegLoginErrorConstants.BLOCKED_OTP_VALIDATE.getErrorCode(), USER_BLOCKED); throw new PreRegLoginException(PreRegLoginErrorConstants.BLOCKED_OTP_VALIDATE.getErrorCode(), PreRegLoginErrorConstants.BLOCKED_OTP_VALIDATE.getErrorMessage()); @@ -216,12 +218,12 @@ private String generateOTP(MainRequestDTO requestDTO) throws PreR } return otp; } catch (PreRegLoginException e) { - logger.error(PreRegLoginConstant.SESSION_ID, this.getClass().getSimpleName(), "generateOTP", + logger.error(LOGGER_SESSIONID, LOGGER_IDTYPE, LOGGER_ID, this.getClass().getSimpleName(), "generateOTP", e.getMessage()); throw new PreRegLoginException(PreRegLoginErrorConstants.UNABLE_TO_PROCESS.getErrorCode(), PreRegLoginErrorConstants.UNABLE_TO_PROCESS.getErrorMessage()); } catch (Exception e) { - logger.error(PreRegLoginConstant.SESSION_ID, this.getClass().getSimpleName(), + logger.error(LOGGER_SESSIONID, LOGGER_IDTYPE, LOGGER_ID, this.getClass().getSimpleName(), PreRegLoginErrorConstants.SERVER_ERROR.getErrorCode(), PreRegLoginErrorConstants.SERVER_ERROR.getErrorMessage()); throw new PreRegLoginException(PreRegLoginErrorConstants.SERVER_ERROR.getErrorCode(), @@ -238,7 +240,7 @@ private String generateOTP(MainRequestDTO requestDTO) throws PreR * @throws PreRegLoginException the id authentication business exception */ public boolean validateOtp(String otp, String userId) throws PreRegLoginException { - logger.info("sessionId", "idType", "id", "In validateOtp method of otpmanager service "); + logger.info(LOGGER_SESSIONID, LOGGER_IDTYPE, LOGGER_ID, "In validateOtp method of otpmanager service "); String otpHash; String refId = hash(userId); otpHash = digestAsPlainText( @@ -255,7 +257,7 @@ public boolean validateOtp(String otp, String userId) throws PreRegLoginExceptio if (otpTn.getValidationRetryCount() > otpValidationThreshold) { otpTn.setStatusCode(PreRegLoginConstant.USED_STATUS); otpRepo.save(otpTn); - logger.error(PreRegLoginConstant.SESSION_ID, this.getClass().getSimpleName(), + logger.error(LOGGER_SESSIONID, LOGGER_IDTYPE, LOGGER_ID, this.getClass().getSimpleName(), PreRegLoginErrorConstants.OTP_ATTEMPT_EXCEEDED.getErrorCode(), OTP_ATTEMPT_EXCEEDED); throw new PreRegLoginException(PreRegLoginErrorConstants.OTP_ATTEMPT_EXCEEDED.getErrorCode(), PreRegLoginErrorConstants.OTP_ATTEMPT_EXCEEDED.getErrorMessage()); @@ -267,7 +269,7 @@ public boolean validateOtp(String otp, String userId) throws PreRegLoginExceptio otpTxn.setStatusCode(PreRegLoginConstant.USED_STATUS); otpRepo.save(otpTxn); if (!(otpTxn.getExpiryDtimes().isAfter(DateUtils.getUTCCurrentDateTime()))) { - logger.error(PreRegLoginConstant.SESSION_ID, this.getClass().getSimpleName(), + logger.error(LOGGER_SESSIONID, this.getClass().getSimpleName(), PreRegLoginErrorConstants.EXPIRED_OTP.getErrorCode(), OTP_EXPIRED); throw new PreRegLoginException(PreRegLoginErrorConstants.EXPIRED_OTP.getErrorCode(), PreRegLoginErrorConstants.EXPIRED_OTP.getErrorMessage()); @@ -279,14 +281,14 @@ private static String digestAsPlainText(byte[] data) { return DatatypeConverter.printHexBinary(data).toUpperCase(); } - private String hash(String id) throws PreRegLoginException { - String idHash = null; - try { - idHash = HMACUtils2.digestAsPlainText(id.getBytes()); - } catch (NoSuchAlgorithmException e) { - throw new PreRegLoginException(PreRegLoginErrorConstants.UNABLE_TO_PROCESS.getErrorCode(), e.getMessage()); - } - return idHash; - } + private String hash(String id) throws PreRegLoginException { + String idHash = null; + try { + idHash = HMACUtils2.digestAsPlainText(id.getBytes()); + } catch (NoSuchAlgorithmException e) { + throw new PreRegLoginException(PreRegLoginErrorConstants.UNABLE_TO_PROCESS.getErrorCode(), e.getMessage()); + } + return idHash; + } } \ No newline at end of file diff --git a/pre-registration/pre-registration-application-service/src/main/java/io/mosip/preregistration/application/service/ProxyMasterDataService.java b/pre-registration/pre-registration-application-service/src/main/java/io/mosip/preregistration/application/service/ProxyMasterDataService.java index 7b95c133a52..3e34718124d 100644 --- a/pre-registration/pre-registration-application-service/src/main/java/io/mosip/preregistration/application/service/ProxyMasterDataService.java +++ b/pre-registration/pre-registration-application-service/src/main/java/io/mosip/preregistration/application/service/ProxyMasterDataService.java @@ -2,6 +2,10 @@ import jakarta.servlet.http.HttpServletRequest; +import static io.mosip.preregistration.application.constant.PreRegApplicationConstant.LOGGER_ID; +import static io.mosip.preregistration.application.constant.PreRegApplicationConstant.LOGGER_IDTYPE; +import static io.mosip.preregistration.application.constant.PreRegApplicationConstant.LOGGER_SESSIONID; + import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Service; @@ -11,17 +15,14 @@ @Service public class ProxyMasterDataService { - @Autowired private ProxyMasterdataServiceUtil util; private Logger log = LoggerConfiguration.logConfig(ProxyMasterDataService.class); public Object getMasterDataResponse(String body, HttpServletRequest request) { - log.info("In getMasterDataResponse of proxymasterdataservice"); + log.info(LOGGER_SESSIONID, LOGGER_IDTYPE, LOGGER_ID, "In getMasterDataResponse of proxymasterdataservice"); return util.masterDataRestCall(util.getUrl(request), body, util.getHttpMethodType(request)); - } - -} +} \ No newline at end of file diff --git a/pre-registration/pre-registration-application-service/src/main/java/io/mosip/preregistration/application/service/TransliterationService.java b/pre-registration/pre-registration-application-service/src/main/java/io/mosip/preregistration/application/service/TransliterationService.java index 51d1ad79698..1b3040324eb 100644 --- a/pre-registration/pre-registration-application-service/src/main/java/io/mosip/preregistration/application/service/TransliterationService.java +++ b/pre-registration/pre-registration-application-service/src/main/java/io/mosip/preregistration/application/service/TransliterationService.java @@ -4,12 +4,16 @@ */ package io.mosip.preregistration.application.service; +import static io.mosip.preregistration.application.constant.PreRegApplicationConstant.LOGGER_ID; +import static io.mosip.preregistration.application.constant.PreRegApplicationConstant.LOGGER_IDTYPE; +import static io.mosip.preregistration.application.constant.PreRegApplicationConstant.LOGGER_SESSIONID; + import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Service; - import io.mosip.kernel.core.logger.spi.Logger; import io.mosip.preregistration.core.config.LoggerConfiguration; +import net.logstash.logback.encoder.org.apache.commons.lang3.exception.ExceptionUtils; import io.mosip.kernel.core.transliteration.spi.Transliteration; import io.mosip.preregistration.application.dto.TransliterationRequestDTO; import io.mosip.preregistration.application.dto.TransliterationResponseDTO; @@ -70,10 +74,11 @@ public MainResponseDTO translitratorService( TransliterationErrorMessage.INCORRECT_MANDATORY_FIELDS.getMessage(), responseDTO); } } catch (Exception e) { - log.error("Failed to transliterate >>", e); + log.error(LOGGER_SESSIONID, LOGGER_IDTYPE, LOGGER_ID, + "Failed to transliterate " + ExceptionUtils.getMessage(e)); throw new UnSupportedLanguageException(TransliterationErrorCodes.PRG_TRL_APP_002.getCode(), TransliterationErrorMessage.UNSUPPORTED_LANGUAGE.getMessage(), responseDTO); } return responseDTO; } -} +} \ No newline at end of file diff --git a/pre-registration/pre-registration-application-service/src/main/java/io/mosip/preregistration/application/service/UISpecService.java b/pre-registration/pre-registration-application-service/src/main/java/io/mosip/preregistration/application/service/UISpecService.java index 949a74877a6..b221208fcd6 100644 --- a/pre-registration/pre-registration-application-service/src/main/java/io/mosip/preregistration/application/service/UISpecService.java +++ b/pre-registration/pre-registration-application-service/src/main/java/io/mosip/preregistration/application/service/UISpecService.java @@ -1,5 +1,9 @@ package io.mosip.preregistration.application.service; +import static io.mosip.preregistration.application.constant.PreRegApplicationConstant.LOGGER_ID; +import static io.mosip.preregistration.application.constant.PreRegApplicationConstant.LOGGER_IDTYPE; +import static io.mosip.preregistration.application.constant.PreRegApplicationConstant.LOGGER_SESSIONID; + import java.time.LocalDateTime; import java.time.format.DateTimeFormatter; import java.util.ArrayList; @@ -7,6 +11,7 @@ import java.util.List; import java.util.stream.Collectors; +import org.apache.commons.lang.exception.ExceptionUtils; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Value; import org.springframework.stereotype.Service; @@ -23,7 +28,6 @@ @Service public class UISpecService { - @Value("${version}") private String version; @@ -48,17 +52,18 @@ public class UISpecService { public MainResponseDTO getLatestUISpec(double version, double identitySchemaVersion) { log.info("In UISpec service getUIspec method"); - MainResponseDTO response = new MainResponseDTO(); + MainResponseDTO response = new MainResponseDTO<>(); response.setVersion(this.version); response.setResponsetime(DateTimeFormatter.ofPattern(mosipDateTimeFormat).format(LocalDateTime.now())); try { - log.info("fetching the UiSpec version {} and identitySchemaVersion {}", version, identitySchemaVersion); + log.info(LOGGER_SESSIONID, LOGGER_IDTYPE, LOGGER_ID, + "fetching the UiSpec version {} and identitySchemaVersion {}", version, identitySchemaVersion); List uiSchema = serviceUtil.getUISchema(version, identitySchemaVersion); List fetchedSchema = prepareResponse(uiSchema); response.setResponse(getLatestPublishedSchema(fetchedSchema)); } catch (UISpecException ex) { - log.error("Exception occured while fetching the UiSpec"); - List explist = new ArrayList(); + log.error(LOGGER_SESSIONID, LOGGER_IDTYPE, LOGGER_ID, "Exception occured while fetching the UiSpec"); + List explist = new ArrayList<>(); ExceptionJSONInfoDTO exception = new ExceptionJSONInfoDTO(); exception.setErrorCode(ex.getErrorCode()); exception.setMessage(ex.getMessage()); @@ -75,9 +80,9 @@ public MainResponseDTO> getAllUISpec(int pageNumber, response.setVersion(this.version); response.setResponsetime(DateTimeFormatter.ofPattern(mosipDateTimeFormat).format(LocalDateTime.now())); try { - log.info("fetching the All published UiSpec"); + log.info(LOGGER_SESSIONID, LOGGER_IDTYPE, LOGGER_ID, "fetching the All published UiSpec"); PageDTO res = serviceUtil.getAllUISchema(pageNumber, pageSize); - PageDTO fetchedSchema = new PageDTO(); + PageDTO fetchedSchema = new PageDTO<>(); fetchedSchema.setData(filterPreRegSpec(res.getData())); fetchedSchema.setPageNo(res.getPageNo()); fetchedSchema.setPageSize(res.getPageSize()); @@ -86,12 +91,12 @@ public MainResponseDTO> getAllUISpec(int pageNumber, fetchedSchema.setSort(res.getSort()); response.setResponse(fetchedSchema); } catch (UISpecException ex) { - log.error("Exception occured while fetching all the UiSpec"); - List explist = new ArrayList(); + log.error(LOGGER_SESSIONID, LOGGER_IDTYPE, LOGGER_ID, "Exception occured while fetching all the UiSpec"); + List explist = new ArrayList<>(); ExceptionJSONInfoDTO exception = new ExceptionJSONInfoDTO(); exception.setErrorCode(ex.getErrorCode()); exception.setMessage(ex.getMessage()); - log.error("Exception {}", exception); + log.error(LOGGER_SESSIONID, LOGGER_IDTYPE, LOGGER_ID, "Exception " + ExceptionUtils.getFullStackTrace(ex)); explist.add(exception); response.setErrors(explist); } @@ -126,7 +131,7 @@ private UISpecMetaDataDTO getLatestPublishedSchema(List fetch } private List filterPreRegSpec(List data) { - List filteredData = new ArrayList(); + List filteredData = new ArrayList<>(); data.forEach(spec -> { if (spec.getDomain().equals(domain)) { filteredData.add(spec); @@ -134,5 +139,4 @@ private List filterPreRegSpec(List data) { }); return prepareResponse(filteredData); } - -} +} \ No newline at end of file diff --git a/pre-registration/pre-registration-application-service/src/main/java/io/mosip/preregistration/application/service/util/AppointmentUtil.java b/pre-registration/pre-registration-application-service/src/main/java/io/mosip/preregistration/application/service/util/AppointmentUtil.java index 4db95530a54..980f1e83d5e 100644 --- a/pre-registration/pre-registration-application-service/src/main/java/io/mosip/preregistration/application/service/util/AppointmentUtil.java +++ b/pre-registration/pre-registration-application-service/src/main/java/io/mosip/preregistration/application/service/util/AppointmentUtil.java @@ -1,5 +1,9 @@ package io.mosip.preregistration.application.service.util; +import static io.mosip.preregistration.application.constant.PreRegApplicationConstant.LOGGER_ID; +import static io.mosip.preregistration.application.constant.PreRegApplicationConstant.LOGGER_IDTYPE; +import static io.mosip.preregistration.application.constant.PreRegApplicationConstant.LOGGER_SESSIONID; + import java.util.LinkedHashMap; import java.util.Map; @@ -70,7 +74,7 @@ public AvailabilityDto getSlotAvailablityByRegCenterId(String regCenterId) { ResponseEntity> responseEntity = null; try { - log.info("Fetching slots availablity for url : {}", constructedAvailablityUrl); + log.info(LOGGER_SESSIONID, LOGGER_IDTYPE, LOGGER_ID, "Fetching slots availablity for url : "+ constructedAvailablityUrl); responseEntity = restTemplate.exchange(constructedAvailablityUrl, HttpMethod.GET, entity, new ParameterizedTypeReference>() { }); @@ -83,8 +87,8 @@ public AvailabilityDto getSlotAvailablityByRegCenterId(String regCenterId) { response.setResponse(body.getResponse()); } } catch (RestClientException ex) { - log.error("Error while fetching availablity for regCenterID:{}", regCenterId); - log.error(ERROR_TRACE, ExceptionUtils.getStackTrace(ex)); + log.error(LOGGER_SESSIONID, LOGGER_IDTYPE, LOGGER_ID, "Error while fetching availablity for regCenterID: "+ regCenterId); + log.error(LOGGER_SESSIONID, LOGGER_IDTYPE, LOGGER_ID, ExceptionUtils.getStackTrace(ex)); throw new AppointmentExecption(AppointmentErrorCodes.FAILED_TO_FETCH_AVAILABLITY.getCode(), AppointmentErrorCodes.FAILED_TO_FETCH_AVAILABLITY.getMessage()); } @@ -107,7 +111,7 @@ public BookingStatusDTO makeAppointment(MainRequestDTO bookin ResponseEntity> responseEntity = null; - log.info("making an appointment rest call for url : {}", constructedAppointmentUrl); + log.info(LOGGER_SESSIONID, LOGGER_IDTYPE, LOGGER_ID, "making an appointment rest call for url : "+ constructedAppointmentUrl); try { responseEntity = restTemplate.exchange(constructedAppointmentUrl, HttpMethod.POST, entity, @@ -124,8 +128,8 @@ public BookingStatusDTO makeAppointment(MainRequestDTO bookin } } catch (RestClientException ex) { - log.error("Error while booking an appointment for preRegistrationId:{}", preRegistrationId); - log.error(ERROR_TRACE, ExceptionUtils.getStackTrace(ex)); + log.error(LOGGER_SESSIONID, LOGGER_IDTYPE, LOGGER_ID, "Error while booking an appointment for preRegistrationId:"+ preRegistrationId); + log.error(LOGGER_SESSIONID, LOGGER_IDTYPE, LOGGER_ID, ExceptionUtils.getStackTrace(ex)); throw new AppointmentExecption(AppointmentErrorCodes.BOOKING_FAILED.getCode(), AppointmentErrorCodes.BOOKING_FAILED.getMessage()); } @@ -146,10 +150,9 @@ public BookingRegistrationDTO fetchAppointmentDetails(String preRegistrationId) ResponseEntity> responseEntity = null; - log.info("Fetching appointment details rest call for url : {}", constructedAppointmentUrl); + log.info(LOGGER_SESSIONID, LOGGER_IDTYPE, LOGGER_ID, "Fetching appointment details rest call for url : "+ constructedAppointmentUrl); try { - responseEntity = restTemplate.exchange(constructedAppointmentUrl, HttpMethod.GET, entity, new ParameterizedTypeReference>() { }); @@ -163,8 +166,8 @@ public BookingRegistrationDTO fetchAppointmentDetails(String preRegistrationId) response.setResponse(body.getResponse()); } } catch (RestClientException ex) { - log.error("Error while fetching appointment details for preRegistrationId:{}", preRegistrationId); - log.error(ERROR_TRACE, ExceptionUtils.getStackTrace(ex)); + log.error(LOGGER_SESSIONID, LOGGER_IDTYPE, LOGGER_ID, "Error while fetching appointment details for preRegistrationId:" + preRegistrationId); + log.error(LOGGER_SESSIONID, LOGGER_IDTYPE, LOGGER_ID, ExceptionUtils.getStackTrace(ex)); throw new AppointmentExecption(AppointmentErrorCodes.FAILED_TO_FETCH_APPOINTMENT_DETAILS.getCode(), AppointmentErrorCodes.FAILED_TO_FETCH_APPOINTMENT_DETAILS.getMessage()); } @@ -186,7 +189,7 @@ public DeleteBookingDTO deleteBooking(String preRegId) { HttpEntity entity = new HttpEntity<>(headers); - log.info("Delete an appointment rest call for url : {}", constructedAppointmentUrl); + log.info(LOGGER_SESSIONID, LOGGER_IDTYPE, LOGGER_ID, "Delete an appointment rest call for url : "+ constructedAppointmentUrl); responseEntity = restTemplate.exchange(constructedAppointmentUrl, HttpMethod.DELETE, entity, new ParameterizedTypeReference>() { @@ -202,7 +205,7 @@ public DeleteBookingDTO deleteBooking(String preRegId) { } } catch (RestClientException ex) { - log.error("Booking RestCall Exception " + ExceptionUtils.getStackTrace(ex)); + log.error(LOGGER_SESSIONID, LOGGER_IDTYPE, LOGGER_ID, "Booking RestCall Exception " + ExceptionUtils.getStackTrace(ex)); throw new AppointmentExecption(AppointmentErrorCodes.FAILED_TO_DELETE_APPOINTMENT.getCode(), AppointmentErrorCodes.FAILED_TO_DELETE_APPOINTMENT.getMessage()); } @@ -225,7 +228,7 @@ public CancelBookingResponseDTO cancelAppointment(String preRegistrationId) { ResponseEntity> responseEntity = null; - log.info("Cancel an appointment rest call for url : {}", constructedAppointmentUrl); + log.info(LOGGER_SESSIONID, LOGGER_IDTYPE, LOGGER_ID, "Cancel an appointment rest call for url : "+ constructedAppointmentUrl); try { responseEntity = restTemplate.exchange(constructedAppointmentUrl, HttpMethod.PUT, entity, @@ -241,8 +244,8 @@ public CancelBookingResponseDTO cancelAppointment(String preRegistrationId) { response.setResponse(body.getResponse()); } } catch (RestClientException ex) { - log.error("Error while Cancelling an appointment for preRegistrationId:{}", preRegistrationId); - log.error(ERROR_TRACE, ExceptionUtils.getStackTrace(ex)); + log.error(LOGGER_SESSIONID, LOGGER_IDTYPE, LOGGER_ID, "Error while Cancelling an appointment for preRegistrationId: "+ preRegistrationId); + log.error(LOGGER_SESSIONID, LOGGER_IDTYPE, LOGGER_ID, ExceptionUtils.getStackTrace(ex)); throw new AppointmentExecption(AppointmentErrorCodes.CANCEL_APPOINTMENT_FAILED.getCode(), AppointmentErrorCodes.CANCEL_APPOINTMENT_FAILED.getMessage()); } @@ -260,7 +263,7 @@ public BookingStatus multiAppointmentBooking(MainRequestDTO ResponseEntity> responseEntity = null; - log.info("Multi Booking appointment rest call for url : {}", constructedAppointmentUrl); + log.info(LOGGER_SESSIONID, LOGGER_IDTYPE, LOGGER_ID, "Multi Booking appointment rest call for url : "+ constructedAppointmentUrl); try { responseEntity = restTemplate.exchange(constructedAppointmentUrl, HttpMethod.POST, entity, @@ -276,7 +279,7 @@ public BookingStatus multiAppointmentBooking(MainRequestDTO response.setResponse(body.getResponse()); } } catch (RestClientException ex) { - log.error(ERROR_TRACE, ExceptionUtils.getStackTrace(ex)); + log.error(LOGGER_SESSIONID, LOGGER_IDTYPE, LOGGER_ID, ExceptionUtils.getStackTrace(ex)); throw new AppointmentExecption(AppointmentErrorCodes.MULTI_BOOKING_FAILED.getCode(), AppointmentErrorCodes.MULTI_BOOKING_FAILED.getMessage()); } diff --git a/pre-registration/pre-registration-application-service/src/main/java/io/mosip/preregistration/application/service/util/CommonServiceUtil.java b/pre-registration/pre-registration-application-service/src/main/java/io/mosip/preregistration/application/service/util/CommonServiceUtil.java index e1429700094..c5d335304b9 100644 --- a/pre-registration/pre-registration-application-service/src/main/java/io/mosip/preregistration/application/service/util/CommonServiceUtil.java +++ b/pre-registration/pre-registration-application-service/src/main/java/io/mosip/preregistration/application/service/util/CommonServiceUtil.java @@ -1,5 +1,9 @@ package io.mosip.preregistration.application.service.util; +import static io.mosip.preregistration.application.constant.PreRegApplicationConstant.LOGGER_SESSIONID; +import static io.mosip.preregistration.application.constant.PreRegApplicationConstant.LOGGER_IDTYPE; +import static io.mosip.preregistration.application.constant.PreRegApplicationConstant.LOGGER_ID; + import java.time.LocalDateTime; import java.time.format.DateTimeFormatter; import java.util.ArrayList; @@ -79,7 +83,7 @@ public class CommonServiceUtil { */ @Value("${mosip.preregistration.demographic.retrieve.status.id}") private String retrieveStatusId; - + /** * Reference for ${ver} from property file */ @@ -122,12 +126,12 @@ public MainResponseDTO getDemographicData(String preRegI DemographicEntity demographicEntity = demographicRepository.findBypreRegistrationId(preRegId); if (demographicEntity != null) { List list = listAuth(authUserDetails().getAuthorities()); - log.info("sessionId", "idType", "id", - "In getDemographicData method of pre-registration service with list " + list); + log.info(LOGGER_SESSIONID, LOGGER_IDTYPE, LOGGER_ID, + "In getDemographicData method of pre-registration service with list " + list.toString()); if (list.contains("ROLE_INDIVIDUAL")) { userValidation(authUserDetails().getUserId(), demographicEntity.getCreatedBy()); } - + String hashString = HashUtill.hashUtill(demographicEntity.getApplicantDetailJson()); if (HashUtill.isHashEqual(demographicEntity.getDemogDetailHash().getBytes(), hashString.getBytes())) { @@ -145,8 +149,8 @@ public MainResponseDTO getDemographicData(String preRegI } } } catch (Exception ex) { - log.error("sessionId", "idType", "id", ExceptionUtils.getStackTrace(ex)); - log.error("sessionId", "idType", "id", + log.error(LOGGER_SESSIONID, LOGGER_IDTYPE, LOGGER_ID, ExceptionUtils.getStackTrace(ex)); + log.error(LOGGER_SESSIONID, LOGGER_IDTYPE, LOGGER_ID, "In getDemographicData of pre-registration service- " + ex.getMessage()); new DemographicExceptionCatcher().handle(ex, response); } @@ -156,7 +160,7 @@ public MainResponseDTO getDemographicData(String preRegI } public String getCurrentResponseTime() { - log.info("sessionId", "idType", "id", "In getCurrentResponseTime method of document service util"); + log.info(LOGGER_SESSIONID, LOGGER_IDTYPE, LOGGER_ID, "In getCurrentResponseTime method of document service util"); return DateUtils.formatDate(new Date(System.currentTimeMillis()), utcDateTimePattern); } @@ -165,8 +169,9 @@ public AuthUserDetails authUserDetails() { } public void userValidation(String authUserId, String preregUserId) { - log.info("sessionId", "idType", "id", "In getDemographicData method of userValidation with priid " - + preregUserId + " and userID " + authUserId); + log.info(LOGGER_SESSIONID, LOGGER_IDTYPE, LOGGER_ID, + "In getDemographicData method of userValidation with priid " + preregUserId + " and userID " + + authUserId); if (!authUserId.trim().equals(preregUserId.trim())) { throw new PreIdInvalidForUserIdException(DemographicErrorCodes.PRG_PAM_APP_017.getCode(), DemographicErrorMessages.INVALID_PREID_FOR_USER.getMessage()); @@ -174,7 +179,8 @@ public void userValidation(String authUserId, String preregUserId) { } public DemographicResponseDTO setterForCreateDTO(DemographicEntity demographicEntity) { - log.info("sessionId", "idType", "id", "In setterForCreateDTO method of pre-registration service util"); + log.info(LOGGER_SESSIONID, LOGGER_IDTYPE, LOGGER_ID, + "In setterForCreateDTO method of pre-registration service util"); JSONParser jsonParser = new JSONParser(); DemographicResponseDTO createDto = new DemographicResponseDTO(); try { @@ -188,14 +194,14 @@ public DemographicResponseDTO setterForCreateDTO(DemographicEntity demographicEn createDto.setUpdatedBy(demographicEntity.getUpdatedBy()); createDto.setUpdatedDateTime(getLocalDateString(demographicEntity.getUpdateDateTime())); } catch (ParseException ex) { - log.error("sessionId", "idType", "id", ExceptionUtils.getStackTrace(ex)); - log.error("sessionId", "idType", "id", + log.error(LOGGER_SESSIONID, LOGGER_IDTYPE, LOGGER_ID, ExceptionUtils.getStackTrace(ex)); + log.error(LOGGER_SESSIONID, LOGGER_IDTYPE, LOGGER_ID, "In setterForCreateDTO method of pre-registration service- " + ex.getMessage()); throw new JsonParseException(DemographicErrorCodes.PRG_PAM_APP_007.getCode(), DemographicErrorMessages.JSON_PARSING_FAILED.getMessage(), ex.getCause()); } catch (EncryptionFailedException ex) { - log.error("sessionId", "idType", "id", ExceptionUtils.getStackTrace(ex)); - log.error("sessionId", "idType", "id", + log.error(LOGGER_SESSIONID, LOGGER_IDTYPE, LOGGER_ID, ExceptionUtils.getStackTrace(ex)); + log.error(LOGGER_SESSIONID, LOGGER_IDTYPE, LOGGER_ID, "In setterForCreateDTO method of pre-registration service- " + ex.getMessage()); throw ex; } @@ -243,7 +249,8 @@ public List validMandatoryDocumentsForApplicant(DemographicEntity demogr } public MainResponseDTO updatePreRegistrationStatus(String preRegId, String status, String userId) { - log.info("sessionId", "idType", "id", "In updatePreRegistrationStatus method of pre-registration service "); + log.info(LOGGER_SESSIONID, LOGGER_IDTYPE, LOGGER_ID, + "In updatePreRegistrationStatus method of pre-registration service "); MainResponseDTO response = new MainResponseDTO<>(); Map requestParamMap = new HashMap<>(); response.setResponsetime(getCurrentResponseTime()); @@ -259,16 +266,16 @@ public MainResponseDTO updatePreRegistrationStatus(String preRegId, Stri } } catch (RecordFailedToUpdateException | RecordNotFoundException ex) { response.setResponse("STATUS_NOT_UPDATED_SUCESSFULLY"); - log.error("sessionId", "idType", "id", ExceptionUtils.getStackTrace(ex)); - log.error("sessionId", "idType", "id", + log.error(LOGGER_SESSIONID, LOGGER_IDTYPE, LOGGER_ID, ExceptionUtils.getStackTrace(ex)); + log.error(LOGGER_SESSIONID, LOGGER_IDTYPE, LOGGER_ID, "Error in updatePreRegistrationStatus method of pre-registration service- " + ex.getMessage()); ExceptionJSONInfoDTO errorDetails = new ExceptionJSONInfoDTO(ex.getErrorCode(), ex.getErrorText()); List errorList = new ArrayList<>(); errorList.add(errorDetails); response.setErrors(errorList); } catch (Exception ex) { - log.error("sessionId", "idType", "id", ExceptionUtils.getStackTrace(ex)); - log.error("sessionId", "idType", "id", + log.error(LOGGER_SESSIONID, LOGGER_IDTYPE, LOGGER_ID, ExceptionUtils.getStackTrace(ex)); + log.error(LOGGER_SESSIONID, LOGGER_IDTYPE, LOGGER_ID, "Error in updatePreRegistrationStatus method of pre-registration service- " + ex.getMessage()); new DemographicExceptionCatcher().handle(ex, response); } @@ -276,7 +283,8 @@ public MainResponseDTO updatePreRegistrationStatus(String preRegId, Stri } public MainResponseDTO getApplicationStatus(String preRegId, String userId) { - log.info("sessionId", "idType", "id", "In getApplicationStatus method of pre-registration service "); + log.info(LOGGER_SESSIONID, LOGGER_IDTYPE, LOGGER_ID, + "In getApplicationStatus method of pre-registration service "); PreRegistartionStatusDTO statusdto = new PreRegistartionStatusDTO(); MainResponseDTO response = new MainResponseDTO<>(); Map requestParamMap = new HashMap<>(); @@ -313,14 +321,14 @@ public MainResponseDTO getApplicationStatus(String pre } } } catch (Exception ex) { - log.error("sessionId", "idType", "id", ExceptionUtils.getStackTrace(ex)); - log.error("sessionId", "idType", "id", + log.error(LOGGER_SESSIONID, LOGGER_IDTYPE, LOGGER_ID, ExceptionUtils.getStackTrace(ex)); + log.error(LOGGER_SESSIONID, LOGGER_IDTYPE, LOGGER_ID, "In getApplicationStatus method of pre-registration service - " + ex.getMessage()); new DemographicExceptionCatcher().handle(ex, response); } return response; } - + public void statusCheck(DemographicEntity demographicEntity, String status, String userId) { if (demographicEntity != null) { if (demographicServiceUtil.isStatusValid(status)) { @@ -349,9 +357,11 @@ public void statusCheck(DemographicEntity demographicEntity, String status, Stri } else { String prid = demographicEntity.getPreRegistrationId(); demographicServiceUtil.updateApplicationStatus(prid, status, userId); - log.info("Application booking status updated succesfully --> {}", status); + log.info(LOGGER_SESSIONID, LOGGER_IDTYPE, LOGGER_ID, + "Application booking status updated succesfully --> " + status); demographicRepository.update(demographicEntity); - log.info("demographic booking status updated succesfully --> {}", status); + log.info(LOGGER_SESSIONID, LOGGER_IDTYPE, LOGGER_ID, + "demographic booking status updated succesfully -->" + status); } } else { @@ -369,19 +379,19 @@ public boolean isupdateStausToPendingAppointmentValid(DemographicEntity demograp try { List validMandatoryDocForApplicant = validMandatoryDocumentsForApplicant(demographicEntity); - log.info("valid mandatory Docs category for applicant-->{}", validMandatoryDocForApplicant); + log.info(LOGGER_SESSIONID, LOGGER_IDTYPE, LOGGER_ID, + "valid mandatory Docs category for applicant-->" + validMandatoryDocForApplicant); List uploadedDocs = demographicEntity.getDocumentEntity().stream().map(doc -> doc.getDocCatCode()) .collect(Collectors.toList()); - log.info("uploaded Docs category --> {}", uploadedDocs); + log.info(LOGGER_SESSIONID, LOGGER_IDTYPE, LOGGER_ID, + "uploaded Docs category --> {}" + uploadedDocs.toString()); isValid = compareUploadedDocListAndValidMandatoryDocList(uploadedDocs, validMandatoryDocForApplicant); - } catch (Exception ex) { - - log.error("Exception Docs category -->", ex); + log.error(LOGGER_SESSIONID, LOGGER_IDTYPE, LOGGER_ID, "Exception Docs category -->", + ExceptionUtils.getStackTrace(ex)); throw new DemographicServiceException(((DemographicServiceException) ex).getErrorCode(), ((DemographicServiceException) ex).getErrorText()); - } return isValid; } diff --git a/pre-registration/pre-registration-application-service/src/main/java/io/mosip/preregistration/application/service/util/DemographicServiceUtil.java b/pre-registration/pre-registration-application-service/src/main/java/io/mosip/preregistration/application/service/util/DemographicServiceUtil.java index 40d02ebfa3a..6d17813fd31 100644 --- a/pre-registration/pre-registration-application-service/src/main/java/io/mosip/preregistration/application/service/util/DemographicServiceUtil.java +++ b/pre-registration/pre-registration-application-service/src/main/java/io/mosip/preregistration/application/service/util/DemographicServiceUtil.java @@ -99,6 +99,10 @@ import io.mosip.preregistration.demographic.exception.system.SystemIllegalArgumentException; import jakarta.annotation.PostConstruct; +import static io.mosip.preregistration.application.constant.PreRegApplicationConstant.LOGGER_SESSIONID; +import static io.mosip.preregistration.application.constant.PreRegApplicationConstant.LOGGER_IDTYPE; +import static io.mosip.preregistration.application.constant.PreRegApplicationConstant.LOGGER_ID; + /** * This class provides the utility methods for DemographicService * @@ -157,11 +161,11 @@ public class DemographicServiceUtil { private ObjectMapper mapper; @PostConstruct - public void init() { + public void init() { mapper = JsonMapper.builder().addModule(new AfterburnerModule()).build(); mapper.registerModule(new JavaTimeModule()); } - + /** * This setter method is used to assign the initial demographic entity values to * the createDTO @@ -170,7 +174,8 @@ public void init() { * @return createDTO with the values */ public DemographicResponseDTO setterForCreateDTO(DemographicEntity demographicEntity) { - log.info("sessionId", "idType", "id", "In setterForCreateDTO method of pre-registration service util"); + log.info(LOGGER_SESSIONID, LOGGER_IDTYPE, LOGGER_ID, + "In setterForCreateDTO method of pre-registration service util"); JSONParser jsonParser = new JSONParser(); DemographicResponseDTO createDto = new DemographicResponseDTO(); try { @@ -184,14 +189,14 @@ public DemographicResponseDTO setterForCreateDTO(DemographicEntity demographicEn createDto.setUpdatedBy(demographicEntity.getUpdatedBy()); createDto.setUpdatedDateTime(getLocalDateString(demographicEntity.getUpdateDateTime())); } catch (ParseException ex) { - log.error("sessionId", "idType", "id", ExceptionUtils.getStackTrace(ex)); - log.error("sessionId", "idType", "id", + log.error(LOGGER_SESSIONID, LOGGER_IDTYPE, LOGGER_ID, ExceptionUtils.getStackTrace(ex)); + log.error(LOGGER_SESSIONID, LOGGER_IDTYPE, LOGGER_ID, "In setterForCreateDTO method of pre-registration service- " + ex.getMessage()); throw new JsonParseException(DemographicErrorCodes.PRG_PAM_APP_007.getCode(), DemographicErrorMessages.JSON_PARSING_FAILED.getMessage(), ex.getCause()); } catch (EncryptionFailedException ex) { - log.error("sessionId", "idType", "id", ExceptionUtils.getStackTrace(ex)); - log.error("sessionId", "idType", "id", + log.error(LOGGER_SESSIONID, LOGGER_IDTYPE, LOGGER_ID, ExceptionUtils.getStackTrace(ex)); + log.error(LOGGER_SESSIONID, LOGGER_IDTYPE, LOGGER_ID, "In setterForCreateDTO method of pre-registration service- " + ex.getMessage()); throw ex; } @@ -207,7 +212,8 @@ public DemographicResponseDTO setterForCreateDTO(DemographicEntity demographicEn */ public DemographicCreateResponseDTO setterForCreatePreRegistration(DemographicEntity demographicEntity, JSONObject requestJson) { - log.info("sessionId", "idType", "id", "In setterForCreateDTO method of pre-registration service util"); + log.info(LOGGER_SESSIONID, LOGGER_IDTYPE, LOGGER_ID, + "In setterForCreateDTO method of pre-registration service util"); DemographicCreateResponseDTO createDto = new DemographicCreateResponseDTO(); try { createDto.setPreRegistrationId(demographicEntity.getPreRegistrationId()); @@ -216,8 +222,8 @@ public DemographicCreateResponseDTO setterForCreatePreRegistration(DemographicEn createDto.setLangCode(demographicEntity.getLangCode()); createDto.setCreatedDateTime(getLocalDateString(demographicEntity.getCreateDateTime())); } catch (EncryptionFailedException ex) { - log.debug("sessionId", "idType", "id", ExceptionUtils.getStackTrace(ex)); - log.error("sessionId", "idType", "id", + log.debug(LOGGER_SESSIONID, LOGGER_IDTYPE, LOGGER_ID, ExceptionUtils.getStackTrace(ex)); + log.error(LOGGER_SESSIONID, LOGGER_IDTYPE, LOGGER_ID, "In setterForCreateDTO method of pre-registration service- " + ex.getMessage()); throw ex; } @@ -232,7 +238,8 @@ public DemographicCreateResponseDTO setterForCreatePreRegistration(DemographicEn * @return createDTO with the values */ public DemographicUpdateResponseDTO setterForUpdatePreRegistration(DemographicEntity demographicEntity) { - log.info("sessionId", "idType", "id", "In setterForCreateDTO method of pre-registration service util"); + log.info(LOGGER_SESSIONID, LOGGER_IDTYPE, LOGGER_ID, + "In setterForCreateDTO method of pre-registration service util"); JSONParser jsonParser = new JSONParser(); DemographicUpdateResponseDTO createDto = new DemographicUpdateResponseDTO(); try { @@ -243,14 +250,14 @@ public DemographicUpdateResponseDTO setterForUpdatePreRegistration(DemographicEn createDto.setLangCode(demographicEntity.getLangCode()); createDto.setUpdatedDateTime(getLocalDateString(demographicEntity.getCreateDateTime())); } catch (ParseException ex) { - log.error("sessionId", "idType", "id", ExceptionUtils.getStackTrace(ex)); - log.error("sessionId", "idType", "id", + log.error(LOGGER_SESSIONID, LOGGER_IDTYPE, LOGGER_ID, ExceptionUtils.getStackTrace(ex)); + log.error(LOGGER_SESSIONID, LOGGER_IDTYPE, LOGGER_ID, "In setterForCreateDTO method of pre-registration service- " + ex.getMessage()); throw new JsonParseException(DemographicErrorCodes.PRG_PAM_APP_007.getCode(), DemographicErrorMessages.JSON_PARSING_FAILED.getMessage(), ex.getCause()); } catch (EncryptionFailedException ex) { - log.error("sessionId", "idType", "id", ExceptionUtils.getStackTrace(ex)); - log.error("sessionId", "idType", "id", + log.error(LOGGER_SESSIONID, LOGGER_IDTYPE, LOGGER_ID, ExceptionUtils.getStackTrace(ex)); + log.error(LOGGER_SESSIONID, LOGGER_IDTYPE, LOGGER_ID, "In setterForCreateDTO method of pre-registration service- " + ex.getMessage()); throw ex; } @@ -270,26 +277,31 @@ public DemographicUpdateResponseDTO setterForUpdatePreRegistration(DemographicEn public DemographicEntity prepareDemographicEntityForCreate(DemographicRequestDTO demographicRequest, String statuscode, String userId, String preRegistrationId) { - log.info("sessionId", "idType", "id", "In prepareDemographicEntity method of pre-registration service util"); + log.info(LOGGER_SESSIONID, LOGGER_IDTYPE, LOGGER_ID, + "In prepareDemographicEntity method of pre-registration service util"); DemographicEntity demographicEntity = new DemographicEntity(); saveAndUpdateApplicationEntity(preRegistrationId, BookingTypeCodes.NEW_PREREGISTRATION.getBookingTypeCode(), ApplicationStatusCode.DRAFT.getApplicationStatusCode(), StatusCodes.APPLICATION_INCOMPLETE.getCode(), userId); demographicEntity.setPreRegistrationId(preRegistrationId); LocalDateTime encryptionDateTime = DateUtils.getUTCCurrentDateTime(); - log.info("sessionId", "idType", "id", "Encryption start time : " + DateUtils.getUTCCurrentDateTimeString()); + log.info(LOGGER_SESSIONID, LOGGER_IDTYPE, LOGGER_ID, + "Encryption start time : " + DateUtils.getUTCCurrentDateTimeString()); byte[] encryptedDemographicDetails = cryptoUtil .encrypt(demographicRequest.getDemographicDetails().toJSONString().getBytes(), encryptionDateTime); - log.info("sessionId", "idType", "id", "Encryption end time : " + DateUtils.getUTCCurrentDateTimeString()); + log.info(LOGGER_SESSIONID, LOGGER_IDTYPE, LOGGER_ID, + "Encryption end time : " + DateUtils.getUTCCurrentDateTimeString()); demographicEntity.setApplicantDetailJson(encryptedDemographicDetails); demographicEntity.setLangCode(demographicRequest.getLangCode()); demographicEntity.setCrAppuserId(userId); demographicEntity.setCreatedBy(userId); demographicEntity.setCreateDateTime(LocalDateTime.now(ZoneId.of("UTC"))); demographicEntity.setStatusCode(statuscode); - log.info("sessionId", "idType", "id", "Hashing start time : " + DateUtils.getUTCCurrentDateTimeString()); + log.info(LOGGER_SESSIONID, LOGGER_IDTYPE, LOGGER_ID, + "Hashing start time : " + DateUtils.getUTCCurrentDateTimeString()); demographicEntity.setDemogDetailHash(HashUtill.hashUtill(demographicEntity.getApplicantDetailJson())); - log.info("sessionId", "idType", "id", "Hashing end time : " + DateUtils.getUTCCurrentDateTimeString()); + log.info(LOGGER_SESSIONID, LOGGER_IDTYPE, LOGGER_ID, + "Hashing end time : " + DateUtils.getUTCCurrentDateTimeString()); demographicEntity.setUpdatedBy(userId); demographicEntity.setUpdateDateTime(LocalDateTime.now(ZoneId.of("UTC"))); demographicEntity.setEncryptedDateTime(encryptionDateTime); @@ -308,23 +320,28 @@ public DemographicEntity prepareDemographicEntityForCreate(DemographicRequestDTO public DemographicEntity prepareDemographicEntityForUpdate(DemographicEntity demographicEntity, DemographicRequestDTO demographicRequest, String statuscode, String userId, String preRegistrationId) throws EncryptionFailedException { - log.info("sessionId", "idType", "id", "In prepareDemographicEntity method of pre-registration service util"); + log.info(LOGGER_SESSIONID, LOGGER_IDTYPE, LOGGER_ID, + "In prepareDemographicEntity method of pre-registration service util"); ApplicationEntity applicationEntity = findApplicationById(preRegistrationId); saveAndUpdateApplicationEntity(preRegistrationId, applicationEntity.getBookingType(), applicationEntity.getApplicationStatusCode(), applicationEntity.getBookingStatusCode(), applicationEntity.getCrBy()); demographicEntity.setPreRegistrationId(preRegistrationId); LocalDateTime encryptionDateTime = DateUtils.getUTCCurrentDateTime(); - log.info("sessionId", "idType", "id", "Encryption start time : " + DateUtils.getUTCCurrentDateTimeString()); + log.info(LOGGER_SESSIONID, LOGGER_IDTYPE, LOGGER_ID, + "Encryption start time : " + DateUtils.getUTCCurrentDateTimeString()); byte[] encryptedDemographicDetails = cryptoUtil .encrypt(demographicRequest.getDemographicDetails().toJSONString().getBytes(), encryptionDateTime); - log.info("sessionId", "idType", "id", "Encryption end time : " + DateUtils.getUTCCurrentDateTimeString()); + log.info(LOGGER_SESSIONID, LOGGER_IDTYPE, LOGGER_ID, + "Encryption end time : " + DateUtils.getUTCCurrentDateTimeString()); demographicEntity.setApplicantDetailJson(encryptedDemographicDetails); demographicEntity.setLangCode(demographicRequest.getLangCode()); demographicEntity.setStatusCode(statuscode); - log.info("sessionId", "idType", "id", "Hashing start time : " + DateUtils.getUTCCurrentDateTimeString()); + log.info(LOGGER_SESSIONID, LOGGER_IDTYPE, LOGGER_ID, + "Hashing start time : " + DateUtils.getUTCCurrentDateTimeString()); demographicEntity.setDemogDetailHash(HashUtill.hashUtill(demographicEntity.getApplicantDetailJson())); - log.info("sessionId", "idType", "id", "Hashing end time : " + DateUtils.getUTCCurrentDateTimeString()); + log.info(LOGGER_SESSIONID, LOGGER_IDTYPE, LOGGER_ID, + "Hashing end time : " + DateUtils.getUTCCurrentDateTimeString()); demographicEntity.setUpdateDateTime(LocalDateTime.now(ZoneId.of("UTC"))); demographicEntity.setEncryptedDateTime(encryptionDateTime); return demographicEntity; @@ -339,7 +356,7 @@ public DemographicEntity prepareDemographicEntityForUpdate(DemographicEntity dem */ public Map prepareRequestMap(MainRequestDTO requestDto) { - log.info("sessionId", "idType", "id", "In prepareRequestMap method of Login Service Util"); + log.info(LOGGER_SESSIONID, LOGGER_IDTYPE, LOGGER_ID, "In prepareRequestMap method of Login Service Util"); Map requestMap = new HashMap<>(); requestMap.put("id", requestDto.getId()); requestMap.put("version", requestDto.getVersion()); @@ -366,7 +383,8 @@ public Map prepareRequestMap(MainRequestDTO requestDto) { */ public JSONArray getValueFromIdentity(byte[] demographicData, String identityKey) throws ParseException, org.json.simple.parser.ParseException { - log.info("sessionId", "idType", "id", "In getValueFromIdentity method of pre-registration service util "); + log.info(LOGGER_SESSIONID, LOGGER_IDTYPE, LOGGER_ID, + "In getValueFromIdentity method of pre-registration service util "); JSONParser jsonParser = new JSONParser(); JSONObject jsonObj = (JSONObject) jsonParser.parse(new String(demographicData)); JSONObject identityObj = (JSONObject) jsonObj.get(DemographicRequestCodes.IDENTITY.getCode()); @@ -386,7 +404,7 @@ public JSONArray getValueFromIdentity(byte[] demographicData, String identityKey */ public String getIdJSONValue(String demographicData, String value) throws ParseException { - log.info("sessionId", "idType", "id", + log.info(LOGGER_SESSIONID, LOGGER_IDTYPE, LOGGER_ID, "In getValueFromIdentity method of pe-registration service util to get getIdJSONValue "); JSONParser jsonParser = new JSONParser(); @@ -426,7 +444,8 @@ public boolean isNull(Object key) { * @return true or false */ public boolean checkStatusForDeletion(String statusCode) { - log.info("sessionId", "idType", "id", "In checkStatusForDeletion method of pre-registration service util "); + log.info(LOGGER_SESSIONID, LOGGER_IDTYPE, LOGGER_ID, + "In checkStatusForDeletion method of pre-registration service util "); if (!statusCode.equals(StatusCodes.EXPIRED.getCode())) { return true; @@ -441,12 +460,13 @@ public String getCurrentResponseTime() { } public Date getDateFromString(String date) { - log.info("sessionId", "idType", "id", "In getDateFromString method of pre-registration service util "); + log.info(LOGGER_SESSIONID, LOGGER_IDTYPE, LOGGER_ID, + "In getDateFromString method of pre-registration service util "); try { return new SimpleDateFormat(utcDateTimePattern).parse(date); } catch (java.text.ParseException ex) { - log.error("sessionId", "idType", "id", ExceptionUtils.getStackTrace(ex)); - log.error("sessionId", "idType", "id", + log.error(LOGGER_SESSIONID, LOGGER_IDTYPE, LOGGER_ID, ExceptionUtils.getStackTrace(ex)); + log.error(LOGGER_SESSIONID, LOGGER_IDTYPE, LOGGER_ID, "In getDateFromString method of pre-registration service- " + ex.getCause()); throw new DateParseException(DemographicErrorCodes.PRG_PAM_APP_011.getCode(), DemographicErrorMessages.UNSUPPORTED_DATE_FORMAT.getMessage(), ex.getCause()); @@ -472,7 +492,7 @@ public boolean isStatusValid(String status) { * @return MainResponseDTO */ public MainResponseDTO getMainResponseDto(MainRequestDTO mainRequestDto) { - log.info("sessionId", "idType", "id", "In getMainResponseDTO method of Login Common Util"); + log.info(LOGGER_SESSIONID, LOGGER_IDTYPE, LOGGER_ID, "In getMainResponseDTO method of Login Common Util"); MainResponseDTO response = new MainResponseDTO<>(); response.setId(mainRequestDto.getId()); response.setVersion(mainRequestDto.getVersion()); @@ -515,11 +535,12 @@ public String getJson(String filename) { .append(configLabel + "/").append(filename); // uriBuilder.append( // "http://104.211.212.28:51000/preregistration/dev/master/PreRegistrationIdentitiyMapping.json"); - log.info("sessionId", "idType", "id", " URL in demographic service util of getJson " + uriBuilder); + log.info(LOGGER_SESSIONID, LOGGER_IDTYPE, LOGGER_ID, + " URL in demographic service util of getJson " + uriBuilder); return restTemplate.getForObject(uriBuilder.toString(), String.class); } catch (Exception ex) { - log.error("sessionId", "idType", "id", ExceptionUtils.getStackTrace(ex)); - log.error("sessionId", "idType", "id", + log.error(LOGGER_SESSIONID, LOGGER_IDTYPE, LOGGER_ID, ExceptionUtils.getStackTrace(ex)); + log.error(LOGGER_SESSIONID, LOGGER_IDTYPE, LOGGER_ID, "In pre-registration service util of getPreregistrationIdentityJson- " + ex.getMessage()); throw new SystemFileIOException(DemographicErrorCodes.PRG_PAM_APP_018.getCode(), DemographicErrorMessages.UBALE_TO_READ_IDENTITY_JSON.getMessage(), null); @@ -534,10 +555,11 @@ public String generateId() { headers.setContentType(MediaType.APPLICATION_JSON); HttpEntity> entity = new HttpEntity<>(headers); String uriBuilder = regbuilder.build().encode().toUriString(); - log.info("sessionId", "idType", "id", + log.info(LOGGER_SESSIONID, LOGGER_IDTYPE, LOGGER_ID, "In callRegCenterDateRestService method of Booking Service URL- " + uriBuilder); - ResponseEntity> responseEntity = selfTokenrestTemplate.exchange(uriBuilder, - HttpMethod.GET, entity, new ParameterizedTypeReference>() { + ResponseEntity> responseEntity = selfTokenrestTemplate.exchange( + uriBuilder, HttpMethod.GET, entity, + new ParameterizedTypeReference>() { }); ResponseWrapper body = responseEntity.getBody(); if (body != null) { @@ -555,8 +577,8 @@ public String generateId() { } } catch (RestClientException ex) { - log.error("sessionId", "idType", "id", ExceptionUtils.getStackTrace(ex)); - log.error("sessionId", "idType", "id", + log.error(LOGGER_SESSIONID, LOGGER_IDTYPE, LOGGER_ID, ExceptionUtils.getStackTrace(ex)); + log.error(LOGGER_SESSIONID, LOGGER_IDTYPE, LOGGER_ID, "In callRegCenterDateRestService method of Booking Service Util for HttpClientErrorException- " + ex.getMessage()); throw new RestCallException(DemographicErrorCodes.PRG_PAM_APP_020.getCode(), @@ -586,7 +608,7 @@ public IdSchemaDto getSchema() { } response = body.getResponse(); } - + if (response == null) { throw new RestCallException(DemographicErrorCodes.PRG_PAM_APP_020.getCode(), DemographicErrorMessages.ID_SCHEMA_FETCH_FAILED.getMessage()); @@ -605,7 +627,7 @@ public ResponseEntity callAuthService(String url, HttpMethod httpMethodType, Map headersMap, Class responseClass) { ResponseEntity response = null; try { - log.info("sessionId", "idType", "id", "In getResponseEntity method of Login Common Util"); + log.info(LOGGER_SESSIONID, LOGGER_IDTYPE, LOGGER_ID, "In getResponseEntity method of Login Common Util"); HttpHeaders headers = new HttpHeaders(); headers.setContentType(mediaType); HttpEntity request = null; @@ -617,10 +639,11 @@ public ResponseEntity callAuthService(String url, HttpMethod httpMethodType, } else { request = new HttpEntity<>(headers); } - log.info("sessionId", "idType", "id", "In call to kernel rest service :" + url); + log.info(LOGGER_SESSIONID, LOGGER_IDTYPE, LOGGER_ID, "In call to kernel rest service :" + url); response = restTemplate.exchange(url, httpMethodType, request, responseClass); } catch (RestClientException ex) { - log.error("sessionId", "idType", "id", "Kernel rest call exception " + ExceptionUtils.getStackTrace(ex)); + log.error(LOGGER_SESSIONID, LOGGER_IDTYPE, LOGGER_ID, + "Kernel rest call exception " + ExceptionUtils.getStackTrace(ex)); throw new RestClientException("rest call failed"); } return response; @@ -642,7 +665,8 @@ public JSONObject constructNewDemographicRequest(List identityKeys, JSON List demographicKeys = Arrays.asList( ((HashMap) demographicDetails.get(DemographicRequestCodes.IDENTITY.getCode())).keySet().toArray()); - log.debug("IdentitySchemakeys: {} and PreRegIdentitykeys: {}", identityKeys, demographicKeys); + log.debug(LOGGER_SESSIONID, LOGGER_IDTYPE, LOGGER_ID, "IdentitySchemakeys: {" + identityKeys.toString() + + "} and PreRegIdentitykeys: {" + demographicKeys.toString() + "}"); JSONObject demographicJson = new JSONObject(); @@ -661,7 +685,8 @@ public JSONObject constructNewDemographicRequest(List identityKeys, JSON public ApplicationEntity saveAndUpdateApplicationEntity(String preId, String bookingTypeCode, String applicationStatusCode, String bookingStatusCode, String userId) { - log.info("Creating/Updating an applications in applications table with ID: {}", preId); + log.info(LOGGER_SESSIONID, LOGGER_IDTYPE, LOGGER_ID, + "Creating/Updating an applications in applications table with ID: " + preId); ApplicationEntity applicationEntity = new ApplicationEntity(); applicationEntity.setApplicationId(preId); applicationEntity.setApplicationStatusCode(applicationStatusCode); @@ -675,8 +700,9 @@ public ApplicationEntity saveAndUpdateApplicationEntity(String preId, String boo try { applicationEntity = applicationRepostiory.save(applicationEntity); } catch (Exception ex) { - log.error("Error while persisting applications entity"); - log.error("Excepction {}", ex); + log.debug(LOGGER_SESSIONID, LOGGER_IDTYPE, LOGGER_ID, ExceptionUtils.getStackTrace(ex)); + log.error(LOGGER_SESSIONID, LOGGER_IDTYPE, LOGGER_ID, + "Error while persisting applications entity -" + ex.getMessage()); throw new RecordFailedToUpdateException(ApplicationErrorCodes.PRG_APP_009.getCode(), ApplicationErrorMessages.FAILED_TO_UPDATE_APPLICATIONS.getMessage()); } @@ -684,8 +710,9 @@ public ApplicationEntity saveAndUpdateApplicationEntity(String preId, String boo } public void updateApplicationStatus(String applicationId, String status, String userId) { - log.info("Updating applications status in applications table with statuscode: {} for applicationId: {}", status, - applicationId); + log.info(LOGGER_SESSIONID, LOGGER_IDTYPE, LOGGER_ID, + "Updating applications status in applications table with statuscode: {" + status + + "} for applicationId: {" + applicationId + "}"); try { ApplicationEntity applicationEntity = findApplicationById(applicationId); applicationEntity.setBookingStatusCode(status); @@ -696,16 +723,16 @@ public void updateApplicationStatus(String applicationId, String status, String } applicationRepostiory.update(applicationEntity); } catch (Exception ex) { - log.info("Error while updating status for applications"); - log.info("Excepction {}", ex); + log.debug(LOGGER_SESSIONID, LOGGER_IDTYPE, LOGGER_ID, ExceptionUtils.getStackTrace(ex)); + log.error(LOGGER_SESSIONID, LOGGER_IDTYPE, LOGGER_ID, + "Error while updating status for applications -" + ex.getMessage()); throw new RecordFailedToUpdateException(ApplicationErrorCodes.PRG_APP_010.getCode(), ApplicationErrorMessages.STATUS_UPDATE_FOR_APPLICATIONS_FAILED.getMessage()); } - } public ApplicationEntity findApplicationById(String applicationId) { - log.info("Fetching applications entry for applicationID: {}", applicationId); + log.info(LOGGER_SESSIONID, LOGGER_IDTYPE, LOGGER_ID,"Fetching applications entry for applicationID: "+ applicationId); ApplicationEntity applicationEntity = null; try { applicationEntity = applicationRepostiory.findByApplicationId(applicationId); @@ -721,7 +748,7 @@ public ApplicationEntity findApplicationById(String applicationId) { } public void deleteApplicationFromApplications(String applicationId) { - log.info("Deleting applications entry for applicationID: {}", applicationId); + log.info(LOGGER_SESSIONID, LOGGER_IDTYPE, LOGGER_ID,"Deleting applications entry for applicationID: "+ applicationId); try { applicationRepostiory.deleteById(applicationId); } catch (DatabaseOperationException e) { @@ -733,7 +760,7 @@ public void deleteApplicationFromApplications(String applicationId) { @SuppressWarnings({ "unchecked", "rawtypes" }) public Set getDataCaptureLaanguage(JSONObject jsonObject) { - log.info("In getDataCaputureLanguage method"); + log.info(LOGGER_SESSIONID, LOGGER_IDTYPE, LOGGER_ID, "In getDataCaputureLanguage method"); Set dataCaptureLang = null; @@ -741,7 +768,7 @@ public Set getDataCaptureLaanguage(JSONObject jsonObject) { .asList(((HashMap) jsonObject.get(DemographicRequestCodes.IDENTITY.getCode())).keySet().toArray()); for (Object key : demographicKeys) { - log.info("key--->{}", key); + log.info(LOGGER_SESSIONID, LOGGER_IDTYPE, LOGGER_ID,"key--->"+ key); Object demograhicObject = ((HashMap) jsonObject.get(DemographicRequestCodes.IDENTITY.getCode())).get(key); @@ -760,7 +787,6 @@ public Set getDataCaptureLaanguage(JSONObject jsonObject) { }).collect(Collectors.toSet()); break; - } } return dataCaptureLang; @@ -784,7 +810,6 @@ public ApplicantTypeRequestDTO createApplicantTypeRequest(DemographicEntity demo attribute.setAttribute((String) key); attribute.setValue(((HashMap) jsonObject.get(DemographicRequestCodes.IDENTITY.getCode())).get(key)); attributeList.add(attribute); - } attributes.setAttributes(attributeList); @@ -795,7 +820,7 @@ public ApplicantTypeRequestDTO createApplicantTypeRequest(DemographicEntity demo public String getApplicantypeCode(ApplicantTypeRequestDTO applicantTypeRequest) { - log.info("In getApplicantypeCode method "); + log.info(LOGGER_SESSIONID, LOGGER_IDTYPE, LOGGER_ID,"In getApplicantypeCode method "); String applicantTypeCode = null; try { UriComponentsBuilder regbuilder = UriComponentsBuilder @@ -807,8 +832,8 @@ public String getApplicantypeCode(ApplicantTypeRequestDTO applicantTypeRequest) HttpEntity> entity = new HttpEntity<>(request, headers); String uriBuilder = regbuilder.build().encode().toUriString(); - ResponseEntity> responseEntity = selfTokenrestTemplate.exchange(uriBuilder, - HttpMethod.POST, entity, + ResponseEntity> responseEntity = selfTokenrestTemplate.exchange( + uriBuilder, HttpMethod.POST, entity, new ParameterizedTypeReference>() { }); @@ -819,13 +844,15 @@ public String getApplicantypeCode(ApplicantTypeRequestDTO applicantTypeRequest) body.getErrors().get(0).getMessage()); } ApplicantTypeResponseDTO applicantTypeResponseDTO = body.getResponse(); - if (applicantTypeResponseDTO != null && applicantTypeResponseDTO.getApplicantType() != null) { - applicantTypeCode = applicantTypeResponseDTO.getApplicantType().getApplicantTypeCode(); + if (applicantTypeResponseDTO != null && applicantTypeResponseDTO.getApplicantType() != null) { + applicantTypeCode = applicantTypeResponseDTO.getApplicantType().getApplicantTypeCode(); } } - + } catch (RestClientException ex) { - log.error("restcall failed to get applicanttype", ex); + log.debug(LOGGER_SESSIONID, LOGGER_IDTYPE, LOGGER_ID, ExceptionUtils.getStackTrace(ex)); + log.error(LOGGER_SESSIONID, LOGGER_IDTYPE, LOGGER_ID, + "restcall failed to get applicanttype -" + ex.getMessage()); throw new MasterDataException(DemographicErrorCodes.PRG_PAM_APP_020.getCode(), DemographicErrorMessages.MASTERDATA_RESTCALL_FAIL.getMessage()); } @@ -835,7 +862,7 @@ public String getApplicantypeCode(ApplicantTypeRequestDTO applicantTypeRequest) @SuppressWarnings({ "rawtypes" }) public ApplicantValidDocumentDto getDocCatAndTypeForApplicantCode(String applicantTypeCode, String langCode) { ResponseWrapper response = new ResponseWrapper<>(); - log.info("In getDocCatAndTypeForApplicantCode method "); + log.info(LOGGER_SESSIONID, LOGGER_IDTYPE, LOGGER_ID, "In getDocCatAndTypeForApplicantCode method "); ResponseEntity> responseEntity = null; try { UriComponentsBuilder regbuilder = UriComponentsBuilder.fromHttpUrl( @@ -861,7 +888,9 @@ public ApplicantValidDocumentDto getDocCatAndTypeForApplicantCode(String applica } } catch (RestClientException ex) { - log.error("restcall failed to get documentcategories for applicanttype code", ex); + log.debug(LOGGER_SESSIONID, LOGGER_IDTYPE, LOGGER_ID, ExceptionUtils.getStackTrace(ex)); + log.error(LOGGER_SESSIONID, LOGGER_IDTYPE, LOGGER_ID, + "restcall failed to get documentcategories for applicanttype code -" + ex.getMessage()); throw new MasterDataException(DemographicErrorCodes.PRG_PAM_APP_020.getCode(), DemographicErrorMessages.MASTERDATA_RESTCALL_FAIL.getMessage()); } @@ -881,5 +910,4 @@ public Set getMandatoryDocCatogery() { return mandatoryDocs; } - -} +} \ No newline at end of file diff --git a/pre-registration/pre-registration-application-service/src/main/java/io/mosip/preregistration/application/service/util/DocumentServiceUtil.java b/pre-registration/pre-registration-application-service/src/main/java/io/mosip/preregistration/application/service/util/DocumentServiceUtil.java index 6554e8c92e0..5dc16841f99 100644 --- a/pre-registration/pre-registration-application-service/src/main/java/io/mosip/preregistration/application/service/util/DocumentServiceUtil.java +++ b/pre-registration/pre-registration-application-service/src/main/java/io/mosip/preregistration/application/service/util/DocumentServiceUtil.java @@ -4,6 +4,10 @@ */ package io.mosip.preregistration.application.service.util; +import static io.mosip.preregistration.application.constant.PreRegApplicationConstant.LOGGER_ID; +import static io.mosip.preregistration.application.constant.PreRegApplicationConstant.LOGGER_IDTYPE; +import static io.mosip.preregistration.application.constant.PreRegApplicationConstant.LOGGER_SESSIONID; + import java.io.InputStream; import java.text.ParseException; import java.text.SimpleDateFormat; @@ -128,7 +132,7 @@ public class DocumentServiceUtil { */ public MainRequestDTO createUploadDto(String documentJsonString, String preRegistrationId) throws JSONException, JsonParseException, JsonMappingException, IOException, ParseException { - log.info("sessionId", "idType", "id", "In createUploadDto method of document service util"); + log.info(LOGGER_SESSIONID, LOGGER_IDTYPE, LOGGER_ID, "In createUploadDto method of document service util"); MainRequestDTO uploadReqDto = new MainRequestDTO<>(); JSONObject documentData = new JSONObject(documentJsonString); JSONObject docDTOData = (JSONObject) documentData.get("request"); @@ -154,7 +158,7 @@ public MainRequestDTO createUploadDto(String documentJsonStr */ public DocumentEntity dtoToEntity(MultipartFile file, DocumentRequestDTO dto, String userId, String preRegistrationId, DocumentEntity getentity) { - log.info("sessionId", "idType", "id", "In dtoToEntity method of document service util"); + log.info(LOGGER_SESSIONID, LOGGER_IDTYPE, LOGGER_ID, "In dtoToEntity method of document service util"); DocumentEntity documentEntity = new DocumentEntity(); documentEntity.setDocumentId(UUIDGeneratorUtil.generateId()); documentEntity.setDocId(preRegistrationId + "/" + dto.getDocCatCode() + "_" + documentEntity.getDocumentId()); @@ -182,7 +186,7 @@ public DocumentEntity dtoToEntity(MultipartFile file, DocumentRequestDTO dto, St * @return true if key is null, else false */ public boolean isNull(Object key) { - log.info("sessionId", "idType", "id", "In isNull method of document service util"); + log.info(LOGGER_SESSIONID, LOGGER_IDTYPE, LOGGER_ID, "In isNull method of document service util"); if (key instanceof String) { if (key.equals("")) return true; @@ -201,34 +205,35 @@ public boolean isNull(Object key) { * @return maximum file size defined. */ public long getMaxFileSize() { - log.info("sessionId", "idType", "id", "In getMaxFileSize method of document service util"); + log.info(LOGGER_SESSIONID, LOGGER_IDTYPE, LOGGER_ID, "In getMaxFileSize method of document service util"); return Math.multiplyExact(this.maxFileSize, Math.multiplyExact(1024, 1024)); } /** * @return defined document extension. *//* - * public String getFileExtension() { log.info("sessionId", "idType", "id", - * "In getFileExtension method of document service util"); return + * public String getFileExtension() { log.info(LOGGER_SESSIONID, LOGGER_IDTYPE, + * LOGGER_ID "In getFileExtension method of document service util"); return * this.fileExtension; } */ public String getCurrentResponseTime() { - log.info("sessionId", "idType", "id", "In getCurrentResponseTime method of document service util"); + log.info(LOGGER_SESSIONID, LOGGER_IDTYPE, LOGGER_ID, + "In getCurrentResponseTime method of document service util"); return DateUtils.formatDate(new Date(System.currentTimeMillis()), utcDateTimePattern); } public String getDateString(Date date) { - log.info("sessionId", "idType", "id", "In getDateString method of document service util"); + log.info(LOGGER_SESSIONID, LOGGER_IDTYPE, LOGGER_ID, "In getDateString method of document service util"); return DateUtils.formatDate(date, utcDateTimePattern); } public Integer parseDocumentId(String documentId) { - log.info("sessionId", "idType", "id", "In parseDocumentId method of document service util"); + log.info(LOGGER_SESSIONID, LOGGER_IDTYPE, LOGGER_ID, "In parseDocumentId method of document service util"); try { return Integer.parseInt(documentId); } catch (NumberFormatException ex) { - log.error("sessionId", "idType", "id", + log.error(LOGGER_SESSIONID, LOGGER_IDTYPE, LOGGER_ID, "In parseDocumentId method of document service util- " + ex.getMessage()); throw new InvalidDocumentIdExcepion(DocumentErrorCodes.PRG_PAM_DOC_019.toString(), @@ -237,7 +242,7 @@ public Integer parseDocumentId(String documentId) { } public boolean isValidCatCode(String catCode) { - log.info("sessionId", "idType", "id", "In isValidCatCode method of document service util"); + log.info(LOGGER_SESSIONID, LOGGER_IDTYPE, LOGGER_ID, "In isValidCatCode method of document service util"); if (catCode.equals("POA")) { return true; } else { @@ -249,7 +254,7 @@ public boolean isValidCatCode(String catCode) { public DocumentEntity documentEntitySetter(String destinationPreId, DocumentEntity sourceEntity, DocumentEntity destEntity) throws java.io.IOException { - log.info("sessionId", "idType", "id", "In documentEntitySetter method of document service util"); + log.info(LOGGER_SESSIONID, LOGGER_IDTYPE, LOGGER_ID, "In documentEntitySetter method of document service util"); DocumentEntity copyDocumentEntity = new DocumentEntity(); if (destEntity != null) { copyDocumentEntity.setDocumentId(destEntity.getDocumentId()); @@ -286,7 +291,7 @@ public DocumentEntity documentEntitySetter(String destinationPreId, DocumentEnti * @return true if file size is within the limit, else false */ public boolean fileSizeCheck(long uploadedFileSize) { - log.info("sessionId", "idType", "id", "In fileSizeCheck method of document service util"); + log.info(LOGGER_SESSIONID, LOGGER_IDTYPE, LOGGER_ID, "In fileSizeCheck method of document service util"); long maxAllowedSize = getMaxFileSize(); if (uploadedFileSize < maxAllowedSize) { return true; @@ -303,7 +308,7 @@ public boolean fileSizeCheck(long uploadedFileSize) { * @throws DocumentNotValidException if uploaded document is not valid */ public boolean fileExtensionCheck(MultipartFile file) { - log.info("sessionId", "idType", "id", "In fileExtensionCheck method of document service util"); + log.info(LOGGER_SESSIONID, LOGGER_IDTYPE, LOGGER_ID, "In fileExtensionCheck method of document service util"); // List fileExtensionList = // Arrays.asList(fileExtension.split("\\s*,\\s*")); List fileExtensionList = Arrays.asList(fileExtension.split(",")); @@ -324,7 +329,7 @@ public boolean fileExtensionCheck(MultipartFile file) { * @return boolean */ public boolean isValidRequest(DocumentRequestDTO documentDto, String preRegistrationId) { - log.info("sessionId", "idType", "id", "In isValidRequest method of document service util"); + log.info(LOGGER_SESSIONID, LOGGER_IDTYPE, LOGGER_ID, "In isValidRequest method of document service util"); if (isNull(preRegistrationId)) { throw new InvalidRequestException(DocumentErrorCodes.PRG_PAM_DOC_018.toString(), DocumentErrorMessages.INVALID_PRE_ID.getMessage(), null); @@ -341,22 +346,24 @@ public boolean isValidRequest(DocumentRequestDTO documentDto, String preRegistra */ public void virusScanCheck(MultipartFile file) throws java.io.IOException { try { - log.info("sessionId", "idType", "id", "In isVirusScanSuccess method of document service util"); + log.info(LOGGER_SESSIONID, LOGGER_IDTYPE, LOGGER_ID, + "In isVirusScanSuccess method of document service util"); Boolean scanSuccess = virusScan.scanDocument(file.getBytes()); if (!scanSuccess) { throw new VirusScannerException(DocumentErrorCodes.PRG_PAM_DOC_010.toString(), DocumentErrorMessages.DOCUMENT_FAILED_IN_VIRUS_SCAN.getMessage()); } } catch (VirusScannerException e) { - log.error("sessionId", "idType", "id", ExceptionUtils.getStackTrace(e)); - log.error("sessionId", "idType", "id", e.getMessage()); + log.error(LOGGER_SESSIONID, LOGGER_IDTYPE, LOGGER_ID, ExceptionUtils.getStackTrace(e)); + log.error(LOGGER_SESSIONID, LOGGER_IDTYPE, LOGGER_ID, e.getMessage()); throw new VirusScannerException(DocumentErrorCodes.PRG_PAM_DOC_010.toString(), DocumentErrorMessages.DOCUMENT_FAILED_IN_VIRUS_SCAN.getMessage()); } } public DemographicResponseDTO getPreRegInfoRestService(String preId) { - log.info("sessionId", "idType", "id", "In callGetPreRegInfoRestService method of document service util"); + log.info(LOGGER_SESSIONID, LOGGER_IDTYPE, LOGGER_ID, + "In callGetPreRegInfoRestService method of document service util"); MainResponseDTO getDemographicData = commonServiceUtil.getDemographicData(preId); if (getDemographicData.getErrors() != null) { @@ -370,10 +377,11 @@ public boolean isMandatoryDocumentDeleted(DemographicEntity demographicEntity) throws org.json.simple.parser.ParseException { List availableDocuments = demographicEntity.getDocumentEntity().stream().map(doc -> doc.getDocCatCode()) .collect(Collectors.toList()); - log.info("uploaded documents for user {} ----> {}", demographicEntity.getPreRegistrationId(), - availableDocuments); + log.info(LOGGER_SESSIONID, LOGGER_IDTYPE, LOGGER_ID, "uploaded documents for user {" + + demographicEntity.getPreRegistrationId() + "} ----> {" + availableDocuments + "}"); List mandatoryDoc = validMandatoryDocuments(demographicEntity); - log.info("mandatory documents for user {} ----> {}", demographicEntity.getPreRegistrationId(), mandatoryDoc); + log.info(LOGGER_SESSIONID, LOGGER_IDTYPE, LOGGER_ID, "mandatory documents for user {" + + demographicEntity.getPreRegistrationId() + "} ----> {" + mandatoryDoc + "}"); return compareUploadedDocListAndValidMandatoryDocList(availableDocuments, mandatoryDoc); } @@ -402,4 +410,4 @@ public void updateApplicationStatusToIncomplete(DemographicEntity demographicEnt commonServiceUtil.updatePreRegistrationStatus(demographicEntity.getPreRegistrationId(), StatusCodes.APPLICATION_INCOMPLETE.getCode(), demographicEntity.getCreatedBy()); } -} +} \ No newline at end of file diff --git a/pre-registration/pre-registration-application-service/src/main/java/io/mosip/preregistration/application/service/util/NotificationServiceUtil.java b/pre-registration/pre-registration-application-service/src/main/java/io/mosip/preregistration/application/service/util/NotificationServiceUtil.java index 7428208256d..96bdc23cce5 100644 --- a/pre-registration/pre-registration-application-service/src/main/java/io/mosip/preregistration/application/service/util/NotificationServiceUtil.java +++ b/pre-registration/pre-registration-application-service/src/main/java/io/mosip/preregistration/application/service/util/NotificationServiceUtil.java @@ -1,5 +1,9 @@ package io.mosip.preregistration.application.service.util; +import static io.mosip.preregistration.application.constant.PreRegApplicationConstant.LOGGER_ID; +import static io.mosip.preregistration.application.constant.PreRegApplicationConstant.LOGGER_IDTYPE; +import static io.mosip.preregistration.application.constant.PreRegApplicationConstant.LOGGER_SESSIONID; + import java.io.ByteArrayInputStream; import java.io.IOException; import java.io.InputStream; @@ -121,13 +125,13 @@ public MainRequestDTO createNotificationDetails(String jsonStri throws JsonParseException, JsonMappingException, io.mosip.kernel.core.exception.IOException, JSONException, ParseException, com.fasterxml.jackson.core.JsonParseException, com.fasterxml.jackson.databind.JsonMappingException, IOException { - log.info("sessionId", "idType", "id", + log.info(LOGGER_SESSIONID, LOGGER_IDTYPE, LOGGER_ID, "In createUploadDto method of notification service util with body " + jsonString); MainRequestDTO notificationReqDto = new MainRequestDTO<>(); JSONObject notificationData = new JSONObject(jsonString); JSONObject notificationDtoData = (JSONObject) notificationData.get("request"); NotificationDTO notificationDto = null; - List> langaueNamePairs = new ArrayList>(); + List> langaueNamePairs = new ArrayList>(); if (isLatest) { HashMap result = objectMapper.readValue(notificationDtoData.toString(), HashMap.class); KeyValuePairDto langaueNamePair = null; @@ -182,7 +186,8 @@ public MainRequestDTO createNotificationDetails(String jsonStri public void invokeSmsNotification(Map values, String userId, MainRequestDTO requestDTO, String langCode) throws PreRegLoginException, IOException { - log.info("sessionId", "idType", "id", "In invokeSmsNotification method of notification service util"); + log.info(LOGGER_SESSIONID, LOGGER_IDTYPE, LOGGER_ID, + "In invokeSmsNotification method of notification service util"); String otpSmsTemplate = environment.getProperty(PreRegLoginConstant.OTP_SMS_TEMPLATE); String smsTemplate = applyTemplate(values, otpSmsTemplate, langCode); sendSmsNotification(userId, smsTemplate, requestDTO); @@ -201,9 +206,10 @@ public void invokeSmsNotification(Map values, String userId, MainRequestDTO requestDTO, String langCode) throws PreRegLoginException, IOException { - log.info("sessionId", "idType", "id", "In invokeEmailNotification method of notification service util"); + public void invokeEmailNotification(Map values, String userId, MainRequestDTO requestDTO, + String langCode) throws PreRegLoginException, IOException { + log.info(LOGGER_SESSIONID, LOGGER_IDTYPE, LOGGER_ID, + "In invokeEmailNotification method of notification service util"); String otpContentTemaplate = environment.getProperty(PreRegLoginConstant.OTP_CONTENT_TEMPLATE); String otpSubjectTemplate = environment.getProperty(PreRegLoginConstant.OTP_SUBJECT_TEMPLATE); String mailSubject = applyTemplate(values, otpSubjectTemplate, langCode); @@ -218,8 +224,8 @@ public void invokeEmailNotification(Map values, String userId, * @param message the message * @throws PreRegLoginException */ - public void sendSmsNotification(String notificationMobileNo, String message, MainRequestDTO requestDTO) - throws PreRegLoginException { + public void sendSmsNotification(String notificationMobileNo, String message, + MainRequestDTO requestDTO) throws PreRegLoginException { try { PreRegSmsRequestDto preRegSmsRequestDto = new PreRegSmsRequestDto(); SMSRequestDTO smsRequestDto = new SMSRequestDTO(); @@ -260,7 +266,7 @@ public void sendSmsNotification(String notificationMobileNo, String message, Mai * @param mailContent the mail content * @throws PreRegLoginException */ - public void sendEmailNotification(String emailId, String mailSubject, String mailContent, + public void sendEmailNotification(String emailId, String mailSubject, String mailContent, MainRequestDTO requestDTO) throws PreRegLoginException { try { PreRegMailRequestDto mailRequestDto = new PreRegMailRequestDto(); @@ -283,18 +289,15 @@ public void sendEmailNotification(String emailId, String mailSubject, String mai PreRegSmsResponseDto response = restTemplate.exchange(environment.getProperty("mail-notification.rest.uri"), HttpMethod.POST, entity1, PreRegSmsResponseDto.class).getBody(); - + if (response != null && response.getResponse() != null) { if (!response.getResponse().getStatus().equalsIgnoreCase(PreRegLoginConstant.SUCCESS)) throw new PreRegLoginException(PreRegLoginErrorConstants.DATA_VALIDATION_FAILED.getErrorCode(), PreRegLoginErrorConstants.DATA_VALIDATION_FAILED.getErrorMessage()); - } - } catch (PreRegLoginException e) { - - log.error(PreRegLoginConstant.SESSION_ID, "Inside Mail Notification >>>>>", e.getErrorCode(), - e.getErrorText()); + log.error(LOGGER_SESSIONID, LOGGER_IDTYPE, LOGGER_ID, + "Inside Mail Notification >>>>>" + e.getErrorCode() + e.getErrorText()); throw new PreRegLoginException(PreRegLoginErrorConstants.DATA_VALIDATION_FAILED.getErrorCode(), PreRegLoginErrorConstants.DATA_VALIDATION_FAILED.getErrorMessage()); } @@ -312,10 +315,10 @@ public void sendEmailNotification(String emailId, String mailSubject, String mai * occurred. */ - public String applyTemplate(Map mp, String templateName, String langCode) - - throws PreRegLoginException, IOException { - log.info("In applyTemplate of NotificationServiceUtil for templateName {} and values {}", templateName, mp); + public String applyTemplate(Map mp, String templateName, String langCode) throws PreRegLoginException, IOException { + log.info(LOGGER_SESSIONID, LOGGER_IDTYPE, LOGGER_ID, + "In applyTemplate of NotificationServiceUtil for templateName {" + templateName + "} and values {" + mp + + "}"); Objects.requireNonNull(templateName); Objects.requireNonNull(mp); StringWriter writer = new StringWriter(); @@ -340,7 +343,8 @@ public String applyTemplate(Map mp, String templateName, String langCode) * exception */ public String fetchTemplate(String templateName, String langCode) throws PreRegLoginException { - log.info("In fetchTemplate of NotificationServiceUtil for templateName {}", templateName); + log.info(LOGGER_SESSIONID, LOGGER_IDTYPE, LOGGER_ID, + "In fetchTemplate of NotificationServiceUtil for templateName : " + templateName); Map params = new HashMap<>(); params.put(LANG_CODE, langCode); params.put(TEMPLATE_TYPE_CODE, templateName); @@ -384,13 +388,14 @@ public String fetchTemplate(String templateName, String langCode) throws PreRegL return Optional.ofNullable(masterDataMap.get(params.get(LANG_CODE))).map(map -> map.get(templateName)) .orElse(""); - } @SuppressWarnings("null") public NotificationDTO modifyCenterNameAndAddress(NotificationDTO notificationDto, String registrationCenterId, String langCode) { - log.info("In modifyCenterNameAndAddress of NotificationServiceUtil for registrationCenterId {}", registrationCenterId); + log.info(LOGGER_SESSIONID, LOGGER_IDTYPE, LOGGER_ID, + "In modifyCenterNameAndAddress of NotificationServiceUtil for registrationCenterId " + + registrationCenterId); if (notificationDto != null) { List> centerName = notificationDto.getRegistrationCenterName(); List> address = notificationDto.getAddress(); @@ -405,14 +410,13 @@ public NotificationDTO modifyCenterNameAndAddress(NotificationDTO notificationDt regCenterLangCode); if (centerDto != null) { if (firstRegCenterLangCode == null) { - firstRegCenterLangCode = regCenterLangCode; + firstRegCenterLangCode = regCenterLangCode; } regCentersMap.put(regCenterLangCode, centerDto); } else { - centerDto = getNotificationCenterAddressDTO(registrationCenterId, - "all"); + centerDto = getNotificationCenterAddressDTO(registrationCenterId, "all"); if (firstRegCenterLangCode == null) { - firstRegCenterLangCode = regCenterLangCode; + firstRegCenterLangCode = regCenterLangCode; } regCentersMap.put(regCenterLangCode, centerDto); } @@ -437,8 +441,8 @@ public NotificationDTO modifyCenterNameAndAddress(NotificationDTO notificationDt sb.append(" ").append(centerDto.getAddressLine2()).append(" ").append(centerDto.getAddressLine3()); regCenterDetailsAddress.setValue(sb.toString()); address.add(regCenterDetailsAddress); - } - + } + // for (KeyValuePairDto key : notificationDto.getFullName()) { // RegistrationCenterDto centerDto = getNotificationCenterAddressDTO(registrationCenterId, // (String) key.getKey()); @@ -461,7 +465,7 @@ public NotificationDTO modifyCenterNameAndAddress(NotificationDTO notificationDt notificationDto.setRegistrationCenterName(centerName); notificationDto.setAddress(address); } - //System.out.println("NotificationDto: " + notificationDto); + // System.out.println("NotificationDto: " + notificationDto); return notificationDto; } @@ -473,28 +477,28 @@ public ResponseWrapper getRegistrationCenter(Stri // String url = "https://dev.mosip.net/v1/masterdata/registrationcenters/10001/eng" String url = centerDetailUri + "/" + registrationCenterId + "/" + langCode; try { - log.info("sessionId", "idType", "id", "In Registration method of RegistrationCenterController" + url); + log.info(LOGGER_SESSIONID, LOGGER_IDTYPE, LOGGER_ID, "In Registration method of RegistrationCenterController" + url); HttpHeaders headers = new HttpHeaders(); headers.setContentType(MediaType.APPLICATION_JSON); HttpEntity entity = new HttpEntity<>(headers); - log.debug("sessionId", "idType", "id", entity.toString()); + log.debug(LOGGER_SESSIONID, LOGGER_IDTYPE, LOGGER_ID, entity.toString()); responseEntity = restTemplate.exchange(url, HttpMethod.GET, entity, new ParameterizedTypeReference>() { }); - log.debug("sessionId", "idType", "id", responseEntity.toString()); + log.debug(LOGGER_SESSIONID, LOGGER_IDTYPE, LOGGER_ID, responseEntity.toString()); ResponseWrapper body = responseEntity.getBody(); if (body != null) { if (body.getErrors() != null && !body.getErrors().isEmpty()) { - log.error("sessionId", "idType", "id", body.getErrors().toString()); + log.error(LOGGER_SESSIONID, LOGGER_IDTYPE, LOGGER_ID, body.getErrors().toString()); response.setErrors(body.getErrors()); } else { response.setResponse(body.getResponse()); } } - log.info("sessionId", "idType", "id", "In call to registrationcenter rest service :" + url); + log.info(LOGGER_SESSIONID, LOGGER_IDTYPE, LOGGER_ID, "In call to registrationcenter rest service :" + url); } catch (Exception ex) { - log.debug("sessionId", "idType", "id", "Registration Center Details" + ExceptionUtils.getStackTrace(ex)); + log.debug(LOGGER_SESSIONID, LOGGER_IDTYPE, LOGGER_ID, "Registration Center Details" + ExceptionUtils.getStackTrace(ex)); throw new RestClientException("Rest call failed"); } return response; @@ -513,5 +517,4 @@ public RegistrationCenterDto getNotificationCenterAddressDTO(String registration } return centerDto; } - -} +} \ No newline at end of file diff --git a/pre-registration/pre-registration-application-service/src/main/java/io/mosip/preregistration/application/service/util/TransliterationServiceUtil.java b/pre-registration/pre-registration-application-service/src/main/java/io/mosip/preregistration/application/service/util/TransliterationServiceUtil.java index 2ece3d6573f..b54b000e7bf 100644 --- a/pre-registration/pre-registration-application-service/src/main/java/io/mosip/preregistration/application/service/util/TransliterationServiceUtil.java +++ b/pre-registration/pre-registration-application-service/src/main/java/io/mosip/preregistration/application/service/util/TransliterationServiceUtil.java @@ -9,7 +9,6 @@ import java.util.Date; import java.util.HashMap; import java.util.HashSet; -import java.util.List; import java.util.Map; import java.util.Set; @@ -17,10 +16,10 @@ import org.springframework.stereotype.Component; import io.mosip.kernel.core.util.DateUtils; -import io.mosip.preregistration.core.common.dto.MainRequestDTO; import io.mosip.preregistration.application.code.TransliterationRequestCodes; import io.mosip.preregistration.application.dto.TransliterationRequestDTO; import io.mosip.preregistration.application.dto.TransliterationResponseDTO; +import io.mosip.preregistration.core.common.dto.MainRequestDTO; /** * This class provides the utility methods for Transliteration application. @@ -114,5 +113,4 @@ public boolean supportedLanguageCheck(TransliterationRequestDTO dto) { } return supportedLang.contains(dto.getFromFieldLang()) && supportedLang.contains(dto.getToFieldLang()); } - -} +} \ No newline at end of file diff --git a/pre-registration/pre-registration-application-service/src/main/java/io/mosip/preregistration/application/service/util/UISpecServiceUtil.java b/pre-registration/pre-registration-application-service/src/main/java/io/mosip/preregistration/application/service/util/UISpecServiceUtil.java index 6b0d201f773..d7d88c29ebd 100644 --- a/pre-registration/pre-registration-application-service/src/main/java/io/mosip/preregistration/application/service/util/UISpecServiceUtil.java +++ b/pre-registration/pre-registration-application-service/src/main/java/io/mosip/preregistration/application/service/util/UISpecServiceUtil.java @@ -1,8 +1,13 @@ package io.mosip.preregistration.application.service.util; +import static io.mosip.preregistration.application.constant.PreRegApplicationConstant.LOGGER_ID; +import static io.mosip.preregistration.application.constant.PreRegApplicationConstant.LOGGER_IDTYPE; +import static io.mosip.preregistration.application.constant.PreRegApplicationConstant.LOGGER_SESSIONID; + import java.util.List; import java.util.Objects; +import org.apache.commons.lang3.exception.ExceptionUtils; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Qualifier; import org.springframework.beans.factory.annotation.Value; @@ -47,12 +52,12 @@ public class UISpecServiceUtil { private final String domain = "pre-registration"; public List getUISchema(Double version, Double idSchemaVersion) { - log.info("In UISpec serviceutil getUIschema method"); + log.info(LOGGER_SESSIONID, LOGGER_IDTYPE, LOGGER_ID, "In UISpec serviceutil getUIschema method"); List response = null; ResponseEntity>> responseEntity = null; ResponseWrapper> body = null; try { - log.info("Calling masterdata service to get ui spec"); + log.info(LOGGER_SESSIONID, LOGGER_IDTYPE, LOGGER_ID, "Calling masterdata service to get ui spec"); UriComponentsBuilder regbuilder = UriComponentsBuilder .fromHttpUrl(materdataResourceUrl + "/uispec/" + domain + "/latest"); @@ -66,7 +71,8 @@ public List getUISchema(Double version, Double idSchemaVersio headers.setContentType(MediaType.APPLICATION_JSON); HttpEntity entity = new HttpEntity<>(headers); - log.info("masterdata service to get ui spec uri {} ", uriBuilder); + log.info(LOGGER_SESSIONID, LOGGER_IDTYPE, LOGGER_ID, + "masterdata service to get ui spec uri " + uriBuilder); responseEntity = restTemplate.exchange(uriBuilder, HttpMethod.GET, entity, new ParameterizedTypeReference>>() { @@ -75,44 +81,45 @@ public List getUISchema(Double version, Double idSchemaVersio body = responseEntity.getBody(); if (body != null) { if (body.getErrors() != null && !body.getErrors().isEmpty()) { - log.info("error while fetching uispec {}", body.getErrors()); + log.info(LOGGER_SESSIONID, LOGGER_IDTYPE, LOGGER_ID, + "error while fetching uispec " + body.getErrors().toString()); throw new RestCallException(body.getErrors().get(0).getErrorCode(), body.getErrors().get(0).getMessage()); } response = body.getResponse(); } - - log.info("ui spec response {}", response); + + log.info(LOGGER_SESSIONID, LOGGER_IDTYPE, LOGGER_ID, "ui spec response " + response); if (Objects.isNull(response)) { throw new UISpecException(ApplicationErrorCodes.PRG_APP_003.getCode(), ApplicationErrorMessages.UNABLE_TO_FETCH_THE_UI_SPEC.getMessage()); } } catch (RestClientException ex) { - log.error("error while fetching uispec {}", ex); + log.debug(LOGGER_SESSIONID, LOGGER_IDTYPE, LOGGER_ID, + "error while fetching uispec " + ExceptionUtils.getStackTrace(ex)); throw new UISpecException(ApplicationErrorCodes.PRG_APP_003.getCode(), ApplicationErrorMessages.UNABLE_TO_FETCH_THE_UI_SPEC.getMessage()); } catch (Exception ex) { - log.error("error while fetching uispec {}", ex); + log.debug(LOGGER_SESSIONID, LOGGER_IDTYPE, LOGGER_ID, + "error while fetching uispec " + ExceptionUtils.getStackTrace(ex)); if (body != null && body.getErrors() != null && !body.getErrors().isEmpty()) { - throw new UISpecException(body.getErrors().get(0).getErrorCode(), - body.getErrors().get(0).getMessage()); + throw new UISpecException(body.getErrors().get(0).getErrorCode(), body.getErrors().get(0).getMessage()); } else { throw new UISpecException(ApplicationErrorCodes.PRG_APP_003.getCode(), ApplicationErrorMessages.UNABLE_TO_FETCH_THE_UI_SPEC.getMessage()); } } return response; - } public PageDTO getAllUISchema(int pageNumber, int pageSize) { - log.info("In UISpec serviceutil getAllUISchema method"); + log.info(LOGGER_SESSIONID, LOGGER_IDTYPE, LOGGER_ID, "In UISpec serviceutil getAllUISchema method"); PageDTO response = null; ResponseEntity>> responseEntity = null; ResponseWrapper> body = null; try { - log.info("Calling masterdata service to get ui spec"); + log.info(LOGGER_SESSIONID, LOGGER_IDTYPE, LOGGER_ID, "Calling masterdata service to get ui spec"); UriComponentsBuilder regbuilder = UriComponentsBuilder.fromHttpUrl(materdataResourceUrl + "/uispec/all"); MultiValueMap params = new LinkedMultiValueMap<>(); @@ -125,7 +132,8 @@ public PageDTO getAllUISchema(int pageNumber, int pageSize) { headers.setContentType(MediaType.APPLICATION_JSON); HttpEntity entity = new HttpEntity<>(headers); - log.info("masterdata service to get ui spec uri {} ", uriBuilder); + log.info(LOGGER_SESSIONID, LOGGER_IDTYPE, LOGGER_ID, + "masterdata service to get ui spec uri " + uriBuilder); responseEntity = restTemplate.exchange(uriBuilder, HttpMethod.GET, entity, new ParameterizedTypeReference>>() { @@ -134,35 +142,35 @@ public PageDTO getAllUISchema(int pageNumber, int pageSize) { body = responseEntity.getBody(); if (body != null) { if (body.getErrors() != null && !body.getErrors().isEmpty()) { - log.info("error while fetching uispec {}", body.getErrors()); + log.info(LOGGER_SESSIONID, LOGGER_IDTYPE, LOGGER_ID, "error while fetching uispec ", + body.getErrors().toString()); throw new RestCallException(body.getErrors().get(0).getErrorCode(), body.getErrors().get(0).getMessage()); } response = body.getResponse(); } - log.info("uispec resposne {}", response); + log.info(LOGGER_SESSIONID, LOGGER_IDTYPE, LOGGER_ID, "uispec resposne " + response); if (Objects.isNull(response)) { throw new UISpecException(ApplicationErrorCodes.PRG_APP_003.getCode(), ApplicationErrorMessages.UNABLE_TO_FETCH_THE_UI_SPEC.getMessage()); } } catch (RestClientException ex) { - log.error("error while fetching uispec {}", ex); + log.debug(LOGGER_SESSIONID, LOGGER_IDTYPE, LOGGER_ID, + "error while fetching uispec " + ExceptionUtils.getStackTrace(ex)); throw new UISpecException(ApplicationErrorCodes.PRG_APP_003.getCode(), ApplicationErrorMessages.UNABLE_TO_FETCH_THE_UI_SPEC.getMessage()); } catch (Exception ex) { - log.error("error while fetching uispec {}", ex); + log.debug(LOGGER_SESSIONID, LOGGER_IDTYPE, LOGGER_ID, + "error while fetching uispec " + ExceptionUtils.getStackTrace(ex)); if (body != null && body.getErrors() != null && !body.getErrors().isEmpty()) { - throw new UISpecException(body.getErrors().get(0).getErrorCode(), - body.getErrors().get(0).getMessage()); + throw new UISpecException(body.getErrors().get(0).getErrorCode(), body.getErrors().get(0).getMessage()); } else { throw new UISpecException(ApplicationErrorCodes.PRG_APP_003.getCode(), ApplicationErrorMessages.UNABLE_TO_FETCH_THE_UI_SPEC.getMessage()); } } return response; - } - -} +} \ No newline at end of file diff --git a/pre-registration/pre-registration-application-service/src/main/java/io/mosip/preregistration/application/util/LoginCommonUtil.java b/pre-registration/pre-registration-application-service/src/main/java/io/mosip/preregistration/application/util/LoginCommonUtil.java index b912d3a5d9a..310e13354fa 100644 --- a/pre-registration/pre-registration-application-service/src/main/java/io/mosip/preregistration/application/util/LoginCommonUtil.java +++ b/pre-registration/pre-registration-application-service/src/main/java/io/mosip/preregistration/application/util/LoginCommonUtil.java @@ -1,7 +1,10 @@ package io.mosip.preregistration.application.util; +import static io.mosip.preregistration.application.constant.PreRegApplicationConstant.LOGGER_ID; +import static io.mosip.preregistration.application.constant.PreRegApplicationConstant.LOGGER_IDTYPE; +import static io.mosip.preregistration.application.constant.PreRegApplicationConstant.LOGGER_SESSIONID; + import java.io.IOException; -import java.io.StringReader; import java.security.KeyManagementException; import java.security.KeyStoreException; import java.security.NoSuchAlgorithmException; @@ -14,11 +17,10 @@ import java.util.HashMap; import java.util.List; import java.util.Map; -import java.util.Map.Entry; import java.util.Objects; -import java.util.Properties; import java.util.stream.Collectors; +import org.apache.commons.lang3.exception.ExceptionUtils; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Qualifier; import org.springframework.beans.factory.annotation.Value; @@ -108,7 +110,7 @@ public class LoginCommonUtil { @Value("${mosip.preregistration.captcha.id.validate}") private String captchaRequestId; - + private static final String MOSIP_MANDATORY_LANGUAGE = "mosip.mandatory-languages"; private static final String MOSIP_OPTIONAL_LANGUAGE = "mosip.optional-languages"; private static final String MOSIP_MIN_LANGUAGE_COUNT = "mosip.min-languages.count"; @@ -121,7 +123,7 @@ public class LoginCommonUtil { * @return MainResponseDTO */ public MainResponseDTO getMainResponseDto(MainRequestDTO mainRequestDto) { - log.info("In getMainResponseDTO method of Login Common Util"); + log.info(LOGGER_SESSIONID, LOGGER_IDTYPE, LOGGER_ID, "In getMainResponseDTO method of Login Common Util"); MainResponseDTO response = new MainResponseDTO<>(); response.setId(mainRequestDto.getId()); response.setVersion(mainRequestDto.getVersion()); @@ -148,7 +150,7 @@ public ResponseEntity callAuthService(String url, HttpMethod httpMethodType, Map headersMap, Class responseClass) { ResponseEntity response = null; try { - log.info("In getResponseEntity method of Login Common Util"); + log.info(LOGGER_SESSIONID, LOGGER_IDTYPE, LOGGER_ID, "In getResponseEntity method of Login Common Util"); HttpHeaders headers = new HttpHeaders(); headers.setContentType(mediaType); HttpEntity request = null; @@ -160,14 +162,14 @@ public ResponseEntity callAuthService(String url, HttpMethod httpMethodType, } else { request = new HttpEntity<>(headers); } - log.info("In call to kernel rest service :{}", url); + log.info(LOGGER_SESSIONID, LOGGER_IDTYPE, LOGGER_ID, "In call to kernel rest service :{}" + url); response = restTemplate.exchange(url, httpMethodType, request, responseClass); } catch (RestClientException ex) { - log.debug("Kernel rest call exception ", ex); + log.error(LOGGER_SESSIONID, LOGGER_IDTYPE, LOGGER_ID, + "Kernel rest call exception " + ExceptionUtils.getStackTrace(ex)); throw new RestClientException("rest call failed"); } return response; - } /** @@ -178,7 +180,8 @@ public ResponseEntity callAuthService(String url, HttpMethod httpMethodType, * @return List */ public List validateUserId(String userId) { - log.info("In validateUserIdandLangCode method of Login Common Util"); + log.info(LOGGER_SESSIONID, LOGGER_IDTYPE, LOGGER_ID, + "In validateUserIdandLangCode method of Login Common Util"); List list = new ArrayList<>(); if (userId == null || userId.isEmpty()) { throw new InvalidRequestException(LoginErrorCodes.PRG_AUTH_008.getCode(), @@ -202,7 +205,7 @@ public List validateUserId(String userId) { * @param user */ public void validateOtpAndUserid(User user) { - log.info("In validateOtpAndUserid method of Login Common Util"); + log.info(LOGGER_SESSIONID, LOGGER_IDTYPE, LOGGER_ID, "In validateOtpAndUserid method of Login Common Util"); if (user.getUserId() == null) { throw new InvalidRequestException(LoginErrorCodes.PRG_AUTH_008.getCode(), LoginErrorMessages.INVALID_REQUEST_USERID.getMessage(), null); @@ -225,7 +228,6 @@ public ResponseWrapper requestBodyExchange(String serviceResponseBody) throws } catch (IOException e) { throw new ParseResponseException(LoginErrorCodes.PRG_AUTH_011.getCode(), LoginErrorMessages.ERROR_WHILE_PARSING.getMessage(), null); - } } @@ -245,7 +247,6 @@ public Object requestBodyExchangeObject(String serviceResponseBody, Class res } catch (IOException e) { throw new ParseResponseException(LoginErrorCodes.PRG_AUTH_011.getCode(), LoginErrorMessages.ERROR_WHILE_PARSING.getMessage(), null); - } } @@ -259,7 +260,6 @@ public String responseToString(Object response) { try { return objectMapper.writeValueAsString(response); } catch (JsonProcessingException e) { - throw new ParseResponseException("", "", null); } } @@ -271,7 +271,7 @@ public String responseToString(Object response) { * @return */ public Map createRequestMap(MainRequestDTO requestDto) { - log.info("In prepareRequestMap method of Login Service Util"); + log.info(LOGGER_SESSIONID, LOGGER_IDTYPE, LOGGER_ID, "In prepareRequestMap method of Login Service Util"); Map requestMap = new HashMap<>(); requestMap.put("id", requestDto.getId()); requestMap.put("version", requestDto.getVersion()); @@ -302,7 +302,8 @@ public String getUserDetailsFromToken(Map authHeader) { public void validateLanguageProperties(Map responseParamsMap) { try { - log.info("In validateLanguageProperties method of logincommon util"); + log.info(LOGGER_SESSIONID, LOGGER_IDTYPE, LOGGER_ID, + "In validateLanguageProperties method of logincommon util"); List mandatoryLanguages = Arrays.asList(env.getProperty(MOSIP_MANDATORY_LANGUAGE).split(",")) .stream().distinct().collect(Collectors.toList()); @@ -370,10 +371,9 @@ public void validateLanguageProperties(Map responseParamsMap) { mandatoryLanguages.stream().map(lang -> String.valueOf(lang)).collect(Collectors.joining(","))); responseParamsMap.put(MOSIP_OPTIONAL_LANGUAGE, optionalLanguages.stream().map(lang -> String.valueOf(lang)).collect(Collectors.joining(","))); - } catch ( - - Exception e) { - log.error("Exception in validateLanguageProperties of logincommonutil ", e); + } catch (Exception ex) { + log.error(LOGGER_SESSIONID, LOGGER_IDTYPE, LOGGER_ID, + "Exception in validateLanguageProperties of logincommonutil ", ExceptionUtils.getStackTrace(ex)); throw new LanguagePropertiesException(LoginErrorCodes.PRG_AUTH_015.getCode(), LoginErrorMessages.LANGUAGE_PROPERTIES_NOT_FOUND.getMessage()); } @@ -400,14 +400,13 @@ Integer tryParsePropertiesToInteger(String prop) { log.info("{} specified is invaild overriding to default value : 1", prop); return 1; } - } } public CaptchaResposneDTO validateCaptchaToken(String captchaToken) { MainResponseDTO response = new MainResponseDTO<>(); if (captchaToken == null || captchaToken.isBlank()) { - log.error("Validating Captcha token is null or blank"); + log.error(LOGGER_SESSIONID, LOGGER_IDTYPE, LOGGER_ID, "Validating Captcha token is null or blank"); throw new PreRegLoginException(PreRegLoginErrorConstants.CAPTCHA_ERROR.getErrorCode(), PreRegLoginErrorConstants.CAPTCHA_ERROR.getErrorMessage()); } @@ -425,7 +424,8 @@ public CaptchaResposneDTO validateCaptchaToken(String captchaToken) { HttpEntity entity = new HttpEntity<>(captchaRequest, header); ResponseEntity> responseEntity = null; try { - log.debug("Calling captcha service to validate token {}", captchaRequest); + log.debug(LOGGER_SESSIONID, LOGGER_IDTYPE, LOGGER_ID, "Calling captcha service to validate token ", + captchaRequest); responseEntity = restTemplate.exchange(captchaUrl, HttpMethod.POST, entity, new ParameterizedTypeReference>() { @@ -439,16 +439,16 @@ public CaptchaResposneDTO validateCaptchaToken(String captchaToken) { } else { response.setResponse(body.getResponse()); } - + } } catch (RestClientException ex) { - log.error("Error while Calling captcha service to validate token {}", ex); + log.error(LOGGER_SESSIONID, LOGGER_IDTYPE, LOGGER_ID, + "Error while Calling captcha service to validate token " + ExceptionUtils.getStackTrace(ex)); throw new PreRegLoginException(PreRegLoginErrorConstants.CAPTCHA_SEVER_ERROR.getErrorCode(), PreRegLoginErrorConstants.CAPTCHA_SEVER_ERROR.getErrorMessage()); } return response.getResponse(); - } public String sendOtpJwtToken(String userId) { @@ -456,5 +456,4 @@ public String sendOtpJwtToken(String userId) { .setExpiration(Date.from(Instant.now().plusSeconds(otpExpiryTime))).setAudience(jwtAudience).toString(); } - -} +} \ No newline at end of file diff --git a/pre-registration/pre-registration-application-service/src/main/java/io/mosip/preregistration/application/util/ProxyMasterdataServiceUtil.java b/pre-registration/pre-registration-application-service/src/main/java/io/mosip/preregistration/application/util/ProxyMasterdataServiceUtil.java index 9fe36254063..55d2777162d 100644 --- a/pre-registration/pre-registration-application-service/src/main/java/io/mosip/preregistration/application/util/ProxyMasterdataServiceUtil.java +++ b/pre-registration/pre-registration-application-service/src/main/java/io/mosip/preregistration/application/util/ProxyMasterdataServiceUtil.java @@ -1,7 +1,12 @@ package io.mosip.preregistration.application.util; +import static io.mosip.preregistration.application.constant.PreRegApplicationConstant.LOGGER_ID; +import static io.mosip.preregistration.application.constant.PreRegApplicationConstant.LOGGER_IDTYPE; +import static io.mosip.preregistration.application.constant.PreRegApplicationConstant.LOGGER_SESSIONID; + import java.net.URI; import java.net.URLDecoder; +import java.text.MessageFormat; import jakarta.servlet.http.HttpServletRequest; @@ -35,14 +40,13 @@ public class ProxyMasterdataServiceUtil { @Qualifier("selfTokenRestTemplate") @Autowired private RestTemplate restTemplate; - private Logger log = LoggerConfiguration.logConfig(ProxyMasterdataServiceUtil.class); @SuppressWarnings("deprecation") public URI getUrl(HttpServletRequest request) { - log.info("sessionId", "idType", "id", "In getUrl method of proxyMasterDataServiceUtil"); + log.info(LOGGER_SESSIONID, LOGGER_IDTYPE, LOGGER_ID, "In getUrl method of proxyMasterDataServiceUtil"); String query = request.getQueryString(); String requestUrl = request.getRequestURI(); @@ -54,24 +58,24 @@ public URI getUrl(HttpServletRequest request) { url = baseUrl + "/" + version + requestUrl.replace(request.getContextPath() + "/proxy", "").strip().toString(); uri = UriComponentsBuilder.fromHttpUrl(url).query(decodedQuery).build().toUri(); - log.info("sessionId", "idType", "id", " Requested Url is: " + uri); + log.info(LOGGER_SESSIONID, LOGGER_IDTYPE, LOGGER_ID, " Requested Url is: " + uri); } else { url = baseUrl + "/" + version + requestUrl.replace(request.getContextPath() + "/proxy", "").strip().toString(); uri = UriComponentsBuilder.fromHttpUrl(url).build().toUri(); - log.info("sessionId", "idType", "id", " Requested Url is: " + uri); + log.info(LOGGER_SESSIONID, LOGGER_IDTYPE, LOGGER_ID, " Requested Url is: " + uri); } return uri; } public HttpMethod getHttpMethodType(HttpServletRequest request) { - - log.info("sessionId", "idType", "id", "In getHttpMethodType method of proxyMasterDataServiceUtil"); + log.info(LOGGER_SESSIONID, LOGGER_IDTYPE, LOGGER_ID, + "In getHttpMethodType method of proxyMasterDataServiceUtil"); HttpMethod httpMethod = null; - log.info("sessionId", "idType", "id", " Request Method Type: " + request.getMethod()); + log.info(LOGGER_SESSIONID, LOGGER_IDTYPE, LOGGER_ID, " Request Method Type: " + request.getMethod()); switch (request.getMethod()) { case "GET": @@ -91,41 +95,28 @@ public HttpMethod getHttpMethodType(HttpServletRequest request) { break; } return httpMethod; - } - - - @Cacheable(value = "masterdata-cache", key = "'MasterdataCache'+#uri" , condition = "!#uri.toString().contains('getApplicantType')" ) + @Cacheable(value = "masterdata-cache", key = "'MasterdataCache'+#uri", condition = "!#uri.toString().contains('getApplicantType')") public Object masterDataRestCall(URI uri, String body, HttpMethod methodType) { - - log.info("In masterDataRestCall method with request url {} body : {}", uri, body); - + log.info(LOGGER_SESSIONID, LOGGER_IDTYPE, LOGGER_ID, MessageFormat.format("In masterDataRestCall method with request url {0} body : {1}", uri, body)); + ResponseEntity response = null; HttpHeaders headers = new HttpHeaders(); headers.setContentType(MediaType.APPLICATION_JSON); HttpEntity entity = new HttpEntity<>(body, headers); - - log.info("sessionId", "idType", "id", "httpEntity " + entity); + log.info(LOGGER_SESSIONID, LOGGER_IDTYPE, LOGGER_ID, "httpEntity " + entity); try { - response = restTemplate.exchange(uri, methodType, entity, String.class); - - log.info("Proxy MasterData Call response for " + uri + response.getBody()); - + log.info(LOGGER_SESSIONID, LOGGER_IDTYPE, LOGGER_ID, "Proxy MasterData Call response for " + uri + response.getBody()); } catch (Exception e) { - - log.error("Proxy MasterData Call Exception response for url {} ", uri, ExceptionUtils.getStackTrace(e)); - + log.error(LOGGER_SESSIONID, LOGGER_IDTYPE, LOGGER_ID, "Proxy MasterData Call Exception response for url "+ uri + " Error:" + ExceptionUtils.getStackTrace(e)); throw new MasterDataException("PRG_MSD_APP_001", "Failed to fetch masterdata information"); - } return response.getBody(); - } - -} +} \ No newline at end of file diff --git a/pre-registration/pre-registration-application-service/src/test/java/io/mosip/preregistration/application/service/ApplicationServiceTest.java b/pre-registration/pre-registration-application-service/src/test/java/io/mosip/preregistration/application/service/ApplicationServiceTest.java index 16f9b00e513..5c707a71985 100644 --- a/pre-registration/pre-registration-application-service/src/test/java/io/mosip/preregistration/application/service/ApplicationServiceTest.java +++ b/pre-registration/pre-registration-application-service/src/test/java/io/mosip/preregistration/application/service/ApplicationServiceTest.java @@ -7,9 +7,7 @@ import java.time.LocalTime; import java.time.ZoneId; import java.util.ArrayList; -import java.util.HashMap; import java.util.List; -import java.util.Map; import org.junit.Assert; import org.junit.Before; diff --git a/pre-registration/pre-registration-application-service/src/test/java/io/mosip/preregistration/application/service/DocumentServiceTest.java b/pre-registration/pre-registration-application-service/src/test/java/io/mosip/preregistration/application/service/DocumentServiceTest.java index bb30f04948a..4a26216e28c 100644 --- a/pre-registration/pre-registration-application-service/src/test/java/io/mosip/preregistration/application/service/DocumentServiceTest.java +++ b/pre-registration/pre-registration-application-service/src/test/java/io/mosip/preregistration/application/service/DocumentServiceTest.java @@ -29,7 +29,6 @@ import org.mockito.Mock; import org.mockito.Mockito; import org.mockito.MockitoAnnotations; -import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Value; import org.springframework.boot.test.context.SpringBootTest; import org.springframework.mock.web.MockMultipartFile; @@ -177,7 +176,6 @@ public void setUp() throws URISyntaxException, FileNotFoundException, java.io.IO ReflectionTestUtils.setField(documentUploadService, "objectStoreAccountName", "abcd"); multipartFile = new MockMultipartFile("file", "Doc.pdf", "mixed/multipart", new FileInputStream(file)); - } @Test diff --git a/pre-registration/pre-registration-application-service/src/test/java/io/mosip/preregistration/application/service/LoginServiceTest.java b/pre-registration/pre-registration-application-service/src/test/java/io/mosip/preregistration/application/service/LoginServiceTest.java index 111ac85f149..0b09be62588 100644 --- a/pre-registration/pre-registration-application-service/src/test/java/io/mosip/preregistration/application/service/LoginServiceTest.java +++ b/pre-registration/pre-registration-application-service/src/test/java/io/mosip/preregistration/application/service/LoginServiceTest.java @@ -8,7 +8,6 @@ import java.util.HashMap; import java.util.List; import java.util.Map; -import java.util.Properties; import org.junit.Before; import org.junit.Test; @@ -18,25 +17,19 @@ import org.mockito.Mock; import org.mockito.Mockito; import org.mockito.MockitoAnnotations; -import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Value; import org.springframework.boot.test.context.SpringBootTest; import org.springframework.core.env.Environment; import org.springframework.http.HttpHeaders; -import org.springframework.http.HttpStatus; import org.springframework.http.ResponseEntity; import org.springframework.test.context.ContextConfiguration; import org.springframework.test.util.ReflectionTestUtils; -import org.springframework.web.client.HttpClientErrorException; import io.mosip.preregistration.application.dto.CaptchaResposneDTO; import io.mosip.preregistration.application.dto.OTPRequestWithLangCodeAndCaptchaToken; import io.mosip.preregistration.application.dto.OtpRequestDTO; import io.mosip.preregistration.application.dto.OtpUser; import io.mosip.preregistration.application.dto.User; -import io.mosip.preregistration.application.errorcodes.LoginErrorCodes; -import io.mosip.preregistration.application.errorcodes.LoginErrorMessages; -import io.mosip.preregistration.application.exception.ConfigFileNotFoundException; import io.mosip.preregistration.application.exception.InvalidOtpOrUseridException; import io.mosip.preregistration.application.exception.InvalidateTokenException; import io.mosip.preregistration.application.exception.SendOtpFailedException; @@ -135,9 +128,9 @@ public class LoginServiceTest { @Value("${prereg.auth.jwt.secret}") private String jwtSecret; - + @Mock - private Environment env; + private Environment env; MainRequestDTO request = new MainRequestDTO(); @@ -152,8 +145,8 @@ public void setUp() { // ReflectionTestUtils.setField(spyAuthService, "uiConfigParams", "abcd"); // ReflectionTestUtils.setField(this, "uiConfigParams", "abcd"); ReflectionTestUtils.setField(authService, "uiConfigParams", uiConfigParams); - //ReflectionTestUtils.setField(authService, "globalFileName", "abcd"); - //ReflectionTestUtils.setField(authService, "preRegFileName", "abcd"); + // ReflectionTestUtils.setField(authService, "globalFileName", "abcd"); + // ReflectionTestUtils.setField(authService, "preRegFileName", "abcd"); ReflectionTestUtils.setField(authService, "configId", "mosip.preregistration.login.id.config"); ReflectionTestUtils.setField(authService, "jwtTokenExpiryTime", "1800"); ReflectionTestUtils.setField(authService, "jwtAudience", "adad"); @@ -234,7 +227,6 @@ public void setAuditValuesTest() { "userName"); Mockito.verify(spyAuthService, Mockito.times(1)).setAuditValues("eventId", "eventName", "eventType", "description", "idType", "userId", "userName"); - } @Test @@ -258,10 +250,8 @@ public void setAuditValuesTestLoginException() { "userName"); Mockito.verify(spyAuthService, Mockito.times(1)).setAuditValues("eventId", "eventName", "eventType", "description", "idType", "userId", "userName"); - } - @Test public void validateWithUserIdOtp() { list.add("Token"); diff --git a/pre-registration/pre-registration-application-service/src/test/java/io/mosip/preregistration/application/service/OTPManagerTest.java b/pre-registration/pre-registration-application-service/src/test/java/io/mosip/preregistration/application/service/OTPManagerTest.java index cb8d238f0d1..b29a3c3e7bf 100644 --- a/pre-registration/pre-registration-application-service/src/test/java/io/mosip/preregistration/application/service/OTPManagerTest.java +++ b/pre-registration/pre-registration-application-service/src/test/java/io/mosip/preregistration/application/service/OTPManagerTest.java @@ -1,6 +1,5 @@ package io.mosip.preregistration.application.service; -import static org.junit.Assert.assertFalse; import static org.junit.Assert.assertTrue; import java.io.IOException; @@ -38,7 +37,6 @@ import io.mosip.preregistration.application.repository.OtpTxnRepository; import io.mosip.preregistration.application.service.util.NotificationServiceUtil; import io.mosip.preregistration.core.common.dto.MainRequestDTO; -import junit.framework.Assert; @RunWith(JUnit4.class) @SpringBootTest @@ -273,7 +271,7 @@ public void testsendOtpSuccessEmail() throws IOException { // headers.setContentType(MediaType.APPLICATION_JSON); // headers.setAccept(Arrays.asList(MediaType.APPLICATION_JSON)); // JSONObject jsonObject = new JSONObject(); -// jsonObject.put("id", tokenUrl); +// jsonObject.put(LOGGER_ID tokenUrl); // jsonObject.put("metadata", new JSONObject()); // JSONObject jsonObject1 = new JSONObject(); // jsonObject1.put("clientId", clientId); diff --git a/pre-registration/pre-registration-application-service/src/test/java/io/mosip/preregistration/application/test/controller/LoginControllerTest.java b/pre-registration/pre-registration-application-service/src/test/java/io/mosip/preregistration/application/test/controller/LoginControllerTest.java index c42393c03c0..6b50f078663 100644 --- a/pre-registration/pre-registration-application-service/src/test/java/io/mosip/preregistration/application/test/controller/LoginControllerTest.java +++ b/pre-registration/pre-registration-application-service/src/test/java/io/mosip/preregistration/application/test/controller/LoginControllerTest.java @@ -36,7 +36,6 @@ import io.mosip.preregistration.application.dto.OTPRequestWithLangCodeAndCaptchaToken; import io.mosip.preregistration.application.dto.OTPWithLangCodeDTO; import io.mosip.preregistration.application.dto.User; -import io.mosip.preregistration.application.exception.DeprecatedException; import io.mosip.preregistration.application.service.LoginService; import io.mosip.preregistration.application.util.LoginCommonUtil; import io.mosip.preregistration.core.common.dto.AuthNResponse; diff --git a/pre-registration/pre-registration-application-service/src/test/java/io/mosip/preregistration/application/test/controller/ProxyMasterdataControllerTest.java b/pre-registration/pre-registration-application-service/src/test/java/io/mosip/preregistration/application/test/controller/ProxyMasterdataControllerTest.java index 2b7b0f7ceb8..5c6a5cfe590 100644 --- a/pre-registration/pre-registration-application-service/src/test/java/io/mosip/preregistration/application/test/controller/ProxyMasterdataControllerTest.java +++ b/pre-registration/pre-registration-application-service/src/test/java/io/mosip/preregistration/application/test/controller/ProxyMasterdataControllerTest.java @@ -19,7 +19,6 @@ import org.springframework.http.ResponseEntity; import org.springframework.security.test.context.support.WithMockUser; import org.springframework.test.context.junit4.SpringJUnit4ClassRunner; -import org.springframework.test.context.junit4.SpringRunner; import org.springframework.test.web.servlet.MockMvc; import org.springframework.test.web.servlet.RequestBuilder; import org.springframework.test.web.servlet.request.MockMvcRequestBuilders; diff --git a/pre-registration/pre-registration-application-service/src/test/java/io/mosip/preregistration/application/test/exception/TranslitrationExceptionTest.java b/pre-registration/pre-registration-application-service/src/test/java/io/mosip/preregistration/application/test/exception/TranslitrationExceptionTest.java index 76cf62681ae..0f959683be7 100644 --- a/pre-registration/pre-registration-application-service/src/test/java/io/mosip/preregistration/application/test/exception/TranslitrationExceptionTest.java +++ b/pre-registration/pre-registration-application-service/src/test/java/io/mosip/preregistration/application/test/exception/TranslitrationExceptionTest.java @@ -23,7 +23,6 @@ import io.mosip.preregistration.application.service.TransliterationService; import io.mosip.preregistration.application.service.util.TransliterationServiceUtil; import io.mosip.preregistration.core.common.dto.MainRequestDTO; -import io.mosip.preregistration.core.exception.InvalidRequestParameterException; import io.mosip.preregistration.core.util.RequestValidator; /** diff --git a/pre-registration/pre-registration-application-service/src/test/java/io/mosip/preregistration/application/test/service/AppointmentServiceTest.java b/pre-registration/pre-registration-application-service/src/test/java/io/mosip/preregistration/application/test/service/AppointmentServiceTest.java index 48e86455517..50b8f4ca754 100644 --- a/pre-registration/pre-registration-application-service/src/test/java/io/mosip/preregistration/application/test/service/AppointmentServiceTest.java +++ b/pre-registration/pre-registration-application-service/src/test/java/io/mosip/preregistration/application/test/service/AppointmentServiceTest.java @@ -4,13 +4,10 @@ import java.time.LocalDate; import java.time.LocalDateTime; -import java.time.LocalTime; -import java.time.format.DateTimeFormatter; import java.util.ArrayList; import java.util.Date; import java.util.List; -import org.json.simple.JSONObject; import org.junit.Assert; import org.junit.Before; import org.junit.Test; @@ -28,7 +25,6 @@ import org.springframework.test.context.junit4.SpringRunner; import org.springframework.test.util.ReflectionTestUtils; -import io.mosip.analytics.event.anonymous.exception.AnonymousProfileException; import io.mosip.analytics.event.anonymous.util.AnonymousProfileUtil; import io.mosip.kernel.core.authmanager.authadapter.model.AuthUserDetails; import io.mosip.preregistration.application.repository.ApplicationRepostiory; @@ -38,14 +34,10 @@ import io.mosip.preregistration.application.service.DocumentService; import io.mosip.preregistration.application.service.util.AppointmentUtil; import io.mosip.preregistration.booking.dto.AvailabilityDto; -import io.mosip.preregistration.booking.dto.BookingRequestDTO; -import io.mosip.preregistration.booking.dto.BookingStatusDTO; import io.mosip.preregistration.booking.dto.DateTimeDto; import io.mosip.preregistration.core.common.dto.BookingRegistrationDTO; import io.mosip.preregistration.core.common.dto.CancelBookingResponseDTO; import io.mosip.preregistration.core.common.dto.DeleteBookingDTO; -import io.mosip.preregistration.core.common.dto.DemographicResponseDTO; -import io.mosip.preregistration.core.common.dto.MainRequestDTO; import io.mosip.preregistration.core.common.dto.MainResponseDTO; import io.mosip.preregistration.core.common.entity.ApplicationEntity; diff --git a/pre-registration/pre-registration-application-service/src/test/java/io/mosip/preregistration/application/test/service/DemographicServiceTest.java b/pre-registration/pre-registration-application-service/src/test/java/io/mosip/preregistration/application/test/service/DemographicServiceTest.java index d3ffba673ff..0a936ff1657 100644 --- a/pre-registration/pre-registration-application-service/src/test/java/io/mosip/preregistration/application/test/service/DemographicServiceTest.java +++ b/pre-registration/pre-registration-application-service/src/test/java/io/mosip/preregistration/application/test/service/DemographicServiceTest.java @@ -425,7 +425,7 @@ //// public void successSaveImplTest() throws Exception { //// //// byte[] encryptedDemographicDetails = jsonTestObject.toJSONString().getBytes();// { 1, 0, 1, 0, 1, 0 }; -//// requestMap.put("id", createId); +//// requestMap.put(LOGGER_ID createId); //// Mockito.when(serviceUtil.prepareRequestMap(request)).thenReturn(requestMap); //// Mockito.when(cryptoUtil.encrypt(Mockito.any(), Mockito.any())).thenReturn(encryptedDemographicDetails); //// PridFetchResponseDto dto=new PridFetchResponseDto(); @@ -472,7 +472,7 @@ //// byte[] encryptedDemographicDetails = jsonTestObject.toJSONString().getBytes();// { 1, 0, 1, 0, 1, 0 }; //// HttpServerErrorException errorException = new HttpServerErrorException(HttpStatus.BAD_GATEWAY, "httpError"); //// -//// requestMap.put("id", createId); +//// requestMap.put(LOGGER_ID createId); //// Mockito.when(serviceUtil.prepareRequestMap(request)).thenReturn(requestMap); //// Mockito.when(cryptoUtil.encrypt(Mockito.any(), Mockito.any())).thenReturn(encryptedDemographicDetails); //// @@ -519,7 +519,7 @@ //// DataAccessLayerException exception = new DataAccessLayerException(ErrorCodes.PRG_PAM_APP_002.toString(), //// ErrorMessages.PRE_REGISTRATION_TABLE_NOT_ACCESSIBLE.toString(), null); //// byte[] encryptedDemographicDetails = jsonTestObject.toJSONString().getBytes();// { 1, 0, 1, 0, 1, 0 }; -//// requestMap.put("id", createId); +//// requestMap.put(LOGGER_ID createId); //// Mockito.when(serviceUtil.prepareRequestMap(request)).thenReturn(requestMap); //// Mockito.when(cryptoUtil.encrypt(Mockito.any(), Mockito.any())).thenReturn(encryptedDemographicDetails); // @@ -547,7 +547,7 @@ // @Test // public void successUpdateTest() throws Exception { // byte[] encryptedDemographicDetails = jsonTestObject.toJSONString().getBytes();// { 1, 0, 1, 0, 1, 0 }; -// requestMap.put("id", updateId); +// requestMap.put(LOGGER_ID updateId); // request.setId(updateId); // Mockito.when(serviceUtil.prepareRequestMap(request)).thenReturn(requestMap); // Mockito.when(cryptoUtil.encrypt(Mockito.any(), Mockito.any())).thenReturn(encryptedDemographicDetails); @@ -573,7 +573,7 @@ // * updateFailureCheck() throws Exception { HttpRequestException exception = new // * HttpRequestException(ErrorCodes.PRG_PAM_APP_007.name(), // * ErrorMessages.JSON_PARSING_FAILED.name()); byte[] encryptedDemographicDetails -// * = { 1, 0, 1, 0, 1, 0 }; requestMap.put("id", updateId); +// * = { 1, 0, 1, 0, 1, 0 }; requestMap.put(LOGGER_ID updateId); // * request.setId(updateId); // * Mockito.when(serviceUtil.prepareRequestMap(request)).thenReturn(requestMap); // * Mockito.when(cryptoUtil.encrypt(Mockito.any(), @@ -660,7 +660,7 @@ //// public void invalidUserTest() throws FileNotFoundException, IOException, org.json.simple.parser.ParseException, //// IdObjectIOException, IdObjectValidationFailedException, InvalidIdSchemaException { //// byte[] encryptedDemographicDetails = jsonTestObject.toJSONString().getBytes();// { 1, 0, 1, 0, 1, 0 }; -//// requestMap.put("id", updateId); +//// requestMap.put(LOGGER_ID updateId); //// request.setId(updateId); //// Mockito.when(serviceUtil.prepareRequestMap(request)).thenReturn(requestMap); //// Mockito.when(cryptoUtil.encrypt(Mockito.any(), Mockito.any())).thenReturn(encryptedDemographicDetails); @@ -687,7 +687,7 @@ //// org.json.simple.parser.ParseException, IdObjectIOException, IdObjectValidationFailedException, InvalidIdSchemaException { //// HttpServerErrorException errorException = new HttpServerErrorException(HttpStatus.BAD_GATEWAY, "httpError"); //// byte[] encryptedDemographicDetails = jsonTestObject.toJSONString().getBytes();// { 1, 0, 1, 0, 1, 0 }; -//// requestMap.put("id", updateId); +//// requestMap.put(LOGGER_ID updateId); //// request.setId(updateId); //// Mockito.when(serviceUtil.prepareRequestMap(request)).thenReturn(requestMap); //// Mockito.when(cryptoUtil.encrypt(Mockito.any(), Mockito.any())).thenReturn(encryptedDemographicDetails); @@ -1334,7 +1334,7 @@ // @Test // public void updateByPreIdTest() { // Mockito.when(demographicRepository.findBypreRegistrationId("98746563542672")).thenReturn(preRegistrationEntity); -// requestMap.put("id", createId); +// requestMap.put(LOGGER_ID createId); // request.setId(updateId); // Mockito.when(serviceUtil.prepareRequestMap(request)).thenReturn(requestMap); // createPreRegistrationDTO = new DemographicRequestDTO(); @@ -1394,7 +1394,7 @@ //// @Test(expected = RecordNotFoundException.class) //// public void RecordNotFoundExceptionTest() { //// Mockito.when(demographicRepository.findBypreRegistrationId("98746563542672")).thenReturn(null); -//// requestMap.put("id", createId); +//// requestMap.put(LOGGER_ID createId); //// request.setId(updateId); //// Mockito.when(serviceUtil.prepareRequestMap(request)).thenReturn(requestMap); //// createPreRegistrationDTO = new DemographicRequestDTO(); diff --git a/pre-registration/pre-registration-application-service/src/test/java/io/mosip/preregistration/application/test/service/GenerateQRcodeServiceTest.java b/pre-registration/pre-registration-application-service/src/test/java/io/mosip/preregistration/application/test/service/GenerateQRcodeServiceTest.java index abe178d06f7..88bbfc7d1cc 100644 --- a/pre-registration/pre-registration-application-service/src/test/java/io/mosip/preregistration/application/test/service/GenerateQRcodeServiceTest.java +++ b/pre-registration/pre-registration-application-service/src/test/java/io/mosip/preregistration/application/test/service/GenerateQRcodeServiceTest.java @@ -1,6 +1,5 @@ package io.mosip.preregistration.application.test.service; -import static org.junit.Assert.assertEquals; import static org.junit.Assert.assertTrue; import java.sql.Timestamp; @@ -17,6 +16,7 @@ import org.mockito.InjectMocks; import org.mockito.Mock; import org.mockito.Mockito; +import org.mockito.MockitoAnnotations; import org.springframework.beans.factory.annotation.Value; import org.springframework.boot.test.context.SpringBootTest; import org.springframework.test.util.ReflectionTestUtils; @@ -24,7 +24,6 @@ import com.fasterxml.jackson.core.JsonProcessingException; import com.fasterxml.jackson.databind.ObjectMapper; -import org.mockito.MockitoAnnotations; import io.mosip.kernel.core.qrcodegenerator.exception.QrcodeGenerationException; import io.mosip.kernel.core.qrcodegenerator.spi.QrCodeGenerator; import io.mosip.kernel.qrcode.generator.zxing.constant.QrVersion; @@ -35,7 +34,6 @@ import io.mosip.preregistration.core.common.dto.MainResponseDTO; import io.mosip.preregistration.core.common.dto.NotificationDTO; import io.mosip.preregistration.core.common.dto.NotificationResponseDTO; -import io.mosip.preregistration.core.errorcodes.ErrorMessages; import io.mosip.preregistration.core.exception.InvalidRequestException; import io.mosip.preregistration.core.util.ValidationUtil; diff --git a/pre-registration/pre-registration-application-service/src/test/java/io/mosip/preregistration/application/test/service/TransliterationServiceTest.java b/pre-registration/pre-registration-application-service/src/test/java/io/mosip/preregistration/application/test/service/TransliterationServiceTest.java index f6bef501e15..8804cf5e5fc 100644 --- a/pre-registration/pre-registration-application-service/src/test/java/io/mosip/preregistration/application/test/service/TransliterationServiceTest.java +++ b/pre-registration/pre-registration-application-service/src/test/java/io/mosip/preregistration/application/test/service/TransliterationServiceTest.java @@ -7,7 +7,6 @@ import static org.junit.Assert.assertEquals; -import org.springframework.test.context.ContextConfiguration; import java.sql.Timestamp; import java.util.Date; import java.util.HashMap; @@ -18,30 +17,25 @@ import org.junit.Test; import org.junit.runner.RunWith; import org.junit.runners.JUnit4; +import org.mockito.InjectMocks; +import org.mockito.Mock; import org.mockito.Mockito; -import org.springframework.beans.factory.annotation.Autowired; +import org.mockito.MockitoAnnotations; import org.springframework.beans.factory.annotation.Value; import org.springframework.boot.test.context.SpringBootTest; -import org.springframework.boot.test.mock.mockito.MockBean; -import org.springframework.test.context.junit4.SpringRunner; +import org.springframework.test.context.ContextConfiguration; -import org.mockito.MockitoAnnotations; -import org.mockito.Mock; -import org.mockito.InjectMocks; +import io.mosip.kernel.core.transliteration.spi.Transliteration; import io.mosip.kernel.core.util.DateUtils; import io.mosip.preregistration.application.dto.TransliterationRequestDTO; import io.mosip.preregistration.application.dto.TransliterationResponseDTO; import io.mosip.preregistration.application.entity.LanguageIdEntity; -import io.mosip.preregistration.application.exception.MandatoryFieldRequiredException; import io.mosip.preregistration.application.exception.UnSupportedLanguageException; import io.mosip.preregistration.application.repository.LanguageIdRepository; -import io.mosip.preregistration.application.service.AppointmentServiceImpl; import io.mosip.preregistration.application.service.TransliterationService; import io.mosip.preregistration.application.service.util.TransliterationServiceUtil; import io.mosip.preregistration.core.common.dto.MainRequestDTO; import io.mosip.preregistration.core.common.dto.MainResponseDTO; -import io.mosip.kernel.core.transliteration.spi.Transliteration; -import org.junit.runners.JUnit4; @RunWith(JUnit4.class) @SpringBootTest diff --git a/pre-registration/pre-registration-application-service/src/test/java/io/mosip/preregistration/application/test/service/util/UISpecUtilTest.java b/pre-registration/pre-registration-application-service/src/test/java/io/mosip/preregistration/application/test/service/util/UISpecUtilTest.java index a9a83937067..bf2e9a255e0 100644 --- a/pre-registration/pre-registration-application-service/src/test/java/io/mosip/preregistration/application/test/service/util/UISpecUtilTest.java +++ b/pre-registration/pre-registration-application-service/src/test/java/io/mosip/preregistration/application/test/service/util/UISpecUtilTest.java @@ -1,14 +1,11 @@ package io.mosip.preregistration.application.test.service.util; -import static org.junit.Assert.assertNotNull; - import java.util.ArrayList; import java.util.List; import org.junit.Test; import org.junit.runner.RunWith; import org.mockito.Mockito; -import org.springframework.beans.factory.annotation.Autowired; import org.springframework.boot.test.mock.mockito.MockBean; import org.springframework.test.context.ContextConfiguration; import org.springframework.test.context.junit4.SpringRunner; diff --git a/pre-registration/pre-registration-batchjob/src/main/java/io/mosip/preregistration/batchjob/entity/RegistrationBookingEntityConsumed.java b/pre-registration/pre-registration-batchjob/src/main/java/io/mosip/preregistration/batchjob/entity/RegistrationBookingEntityConsumed.java index 0cccf347918..f8d686b5e75 100644 --- a/pre-registration/pre-registration-batchjob/src/main/java/io/mosip/preregistration/batchjob/entity/RegistrationBookingEntityConsumed.java +++ b/pre-registration/pre-registration-batchjob/src/main/java/io/mosip/preregistration/batchjob/entity/RegistrationBookingEntityConsumed.java @@ -10,11 +10,9 @@ import java.time.LocalTime; import jakarta.persistence.Column; -import jakarta.persistence.Embedded; import jakarta.persistence.Entity; import jakarta.persistence.Id; import jakarta.persistence.Table; - import lombok.Setter; /** diff --git a/pre-registration/pre-registration-batchjob/src/main/java/io/mosip/preregistration/batchjob/exception/util/BatchServiceExceptionCatcher.java b/pre-registration/pre-registration-batchjob/src/main/java/io/mosip/preregistration/batchjob/exception/util/BatchServiceExceptionCatcher.java index 28c0fd60fc1..e31905c0518 100644 --- a/pre-registration/pre-registration-batchjob/src/main/java/io/mosip/preregistration/batchjob/exception/util/BatchServiceExceptionCatcher.java +++ b/pre-registration/pre-registration-batchjob/src/main/java/io/mosip/preregistration/batchjob/exception/util/BatchServiceExceptionCatcher.java @@ -5,7 +5,6 @@ package io.mosip.preregistration.batchjob.exception.util; import io.mosip.kernel.core.dataaccess.exception.DataAccessLayerException; -import io.mosip.kernel.core.exception.BaseUncheckedException; import io.mosip.preregistration.batchjob.exception.NoPreIdAvailableException; import io.mosip.preregistration.batchjob.exception.NoValidPreIdFoundException; import io.mosip.preregistration.batchjob.exception.RestCallException; diff --git a/pre-registration/pre-registration-batchjob/src/main/java/io/mosip/preregistration/batchjob/impl/SlotAvailabilityGenerator.java b/pre-registration/pre-registration-batchjob/src/main/java/io/mosip/preregistration/batchjob/impl/SlotAvailabilityGenerator.java index d9f4f44cf99..aefa7930892 100644 --- a/pre-registration/pre-registration-batchjob/src/main/java/io/mosip/preregistration/batchjob/impl/SlotAvailabilityGenerator.java +++ b/pre-registration/pre-registration-batchjob/src/main/java/io/mosip/preregistration/batchjob/impl/SlotAvailabilityGenerator.java @@ -6,7 +6,6 @@ import java.time.LocalTime; import java.time.Period; import java.time.format.DateTimeFormatter; -import java.time.temporal.TemporalAmount; import java.util.ArrayList; import java.util.HashMap; import java.util.List; diff --git a/pre-registration/pre-registration-batchjob/src/main/java/io/mosip/preregistration/batchjob/repository/RegAppointmentRepository.java b/pre-registration/pre-registration-batchjob/src/main/java/io/mosip/preregistration/batchjob/repository/RegAppointmentRepository.java index 7d69289b900..8bdab0ae7f0 100644 --- a/pre-registration/pre-registration-batchjob/src/main/java/io/mosip/preregistration/batchjob/repository/RegAppointmentRepository.java +++ b/pre-registration/pre-registration-batchjob/src/main/java/io/mosip/preregistration/batchjob/repository/RegAppointmentRepository.java @@ -5,7 +5,6 @@ package io.mosip.preregistration.batchjob.repository; import java.time.LocalDate; -import java.time.LocalDateTime; import java.time.LocalTime; import java.util.List; diff --git a/pre-registration/pre-registration-batchjob/src/main/java/io/mosip/preregistration/batchjob/repository/utils/BatchJpaRepositoryImpl.java b/pre-registration/pre-registration-batchjob/src/main/java/io/mosip/preregistration/batchjob/repository/utils/BatchJpaRepositoryImpl.java index 82475c05eba..59b88f87aaf 100644 --- a/pre-registration/pre-registration-batchjob/src/main/java/io/mosip/preregistration/batchjob/repository/utils/BatchJpaRepositoryImpl.java +++ b/pre-registration/pre-registration-batchjob/src/main/java/io/mosip/preregistration/batchjob/repository/utils/BatchJpaRepositoryImpl.java @@ -1,5 +1,9 @@ package io.mosip.preregistration.batchjob.repository.utils; +import static io.mosip.preregistration.core.constant.PreRegCoreConstant.LOGGER_SESSIONID; +import static io.mosip.preregistration.core.constant.PreRegCoreConstant.LOGGER_IDTYPE; +import static io.mosip.preregistration.core.constant.PreRegCoreConstant.LOGGER_ID; + import java.time.LocalDate; import java.time.LocalTime; import java.util.List; @@ -110,7 +114,7 @@ public DemographicEntity getApplicantDemographicDetails(String preRegId) { entity = demographicRepository.findBypreRegistrationId(preRegId); if (entity == null) { processedPreIdRepository.deleteBypreRegistrationId(preRegId); - log.info("sessionId", "idType", "id", "Deleted Invalid Pre-Registration ID"); + log.info(LOGGER_SESSIONID, LOGGER_IDTYPE, LOGGER_ID, "Deleted Invalid Pre-Registration ID"); } demographicRepository.flush(); } catch (DataAccessLayerException e) { @@ -161,7 +165,8 @@ public ApplicationEntity getBookedApplicantEntityDetails(String applicationID) { ApplicationEntity entity = null; try { - entity = applicationRepository.findByApplicationIdAndBookingStatusCode(applicationID, StatusCodes.BOOKED.getCode()); + entity = applicationRepository.findByApplicationIdAndBookingStatusCode(applicationID, + StatusCodes.BOOKED.getCode()); } catch (DataAccessLayerException e) { throw new NoPreIdAvailableException(ErrorCodes.PRG_PAM_BAT_001.getCode(), ErrorMessages.NO_PRE_REGISTRATION_ID_FOUND_TO_UPDATE_STATUS.getMessage()); @@ -186,7 +191,7 @@ public RegistrationBookingEntity getRegistrationAppointmentDetails(String applic } return entity; } - + public List getAllRegistrationAppointmentDetails(LocalDate bookingDate) { try { List entity = regAppointmentRepository.findByBookingPKBookingDate(bookingDate); @@ -206,7 +211,7 @@ public List getAllConsumedPreIds(String statusComment) { try { entityList = processedPreIdRepository.findBystatusComments(statusComment); if (entityList == null || entityList.isEmpty()) { - log.info("sessionId", "idType", "id", + log.info(LOGGER_SESSIONID, LOGGER_IDTYPE, LOGGER_ID, "There are currently no Pre-Registration-Ids to update status to consumed"); throw new NoPreIdAvailableException(ErrorCodes.PRG_PAM_BAT_001.getCode(), ErrorMessages.NO_PRE_REGISTRATION_ID_FOUND_TO_UPDATE_STATUS.getMessage()); @@ -225,9 +230,9 @@ public List getAllConsumedPreIds(String statusComment) { */ public List getAllOldDateBooking() { try { - List entityList = regAppointmentRepository.findByRegDateBetween(StatusCodes.BOOKED.getCode(), - LocalDate.now()); - return entityList; + List entityList = regAppointmentRepository + .findByRegDateBetween(StatusCodes.BOOKED.getCode(), LocalDate.now()); + return entityList; } catch (DataAccessLayerException e) { throw new TableNotAccessibleException(ErrorCodes.PRG_PAM_BAT_005.getCode(), ErrorMessages.REG_APPOINTMENT_TABLE_NOT_ACCESSIBLE.getMessage()); @@ -260,7 +265,8 @@ public ProcessedPreRegEntity updateProcessedList(ProcessedPreRegEntity entity) { public void deleteDemographic(DemographicEntity demographicEntity) { try { demographicRepository.delete(demographicEntity); - log.info("sessionId", "idType", "id", "In deleteDemographic to delete consumed demographic details"); + log.info(LOGGER_SESSIONID, LOGGER_IDTYPE, LOGGER_ID, + "In deleteDemographic to delete consumed demographic details"); } catch (DataAccessLayerException e) { throw new TableNotAccessibleException(ErrorCodes.PRG_PAM_BAT_004.getCode(), @@ -273,7 +279,8 @@ public void deleteDocument(List documentEntity) { try { documentEntity.forEach(iterate -> { documentRespository.delete(iterate); - log.info("sessionId", "idType", "id", "In deleteDocument to delete consumed demographic details"); + log.info(LOGGER_SESSIONID, LOGGER_IDTYPE, LOGGER_ID, + "In deleteDocument to delete consumed demographic details"); }); } catch (Exception e) { @@ -296,18 +303,20 @@ public void deleteApplicantDocument(DocumentEntity documentEntity) { public void deleteBooking(RegistrationBookingEntity bookingEntity) { try { regAppointmentRepository.delete(bookingEntity); - log.info("sessionId", "idType", "id", "In deleteBooking to delete consumed demographic details"); + log.info(LOGGER_SESSIONID, LOGGER_IDTYPE, LOGGER_ID, + "In deleteBooking to delete consumed demographic details"); } catch (DataAccessLayerException e) { throw new TableNotAccessibleException(ErrorCodes.PRG_PAM_BAT_005.getCode(), ErrorMessages.REG_APPOINTMENT_TABLE_NOT_ACCESSIBLE.getMessage()); } } - + /** Deleting Booking details the consumed demographic data. */ public void deleteApplications(ApplicationEntity applicationEntity) { try { applicationRepository.delete(applicationEntity); - log.info("sessionId", "idType", "id", "In deleteapplications to delete consumed demographic details"); + log.info(LOGGER_SESSIONID, LOGGER_IDTYPE, LOGGER_ID, + "In deleteapplications to delete consumed demographic details"); } catch (DataAccessLayerException e) { throw new TableNotAccessibleException(ErrorCodes.PRG_PAM_BAT_019.getCode(), ErrorMessages.APPLICATIONS_TABLE_NOT_ACCESSIBLE.getMessage()); @@ -321,7 +330,8 @@ public void deleteApplications(ApplicationEntity applicationEntity) { public boolean updateConsumedBooking(RegistrationBookingEntityConsumed bookingEntityConsumed) { try { appointmentConsumedRepository.save(bookingEntityConsumed); - log.info("sessionId", "idType", "id", "In updateConsumedBooking to update reg_appointment_consumed"); + log.info(LOGGER_SESSIONID, LOGGER_IDTYPE, LOGGER_ID, + "In updateConsumedBooking to update reg_appointment_consumed"); return true; } catch (DataAccessLayerException e) { throw new TableNotAccessibleException(ErrorCodes.PRG_PAM_BAT_008.getCode(), @@ -336,7 +346,7 @@ public boolean updateConsumedBooking(RegistrationBookingEntityConsumed bookingEn public boolean updateConsumedDemographic(DemographicEntityConsumed entityConsumed) { try { demographicConsumedRepository.save(entityConsumed); - log.info("sessionId", "idType", "id", + log.info(LOGGER_SESSIONID, LOGGER_IDTYPE, LOGGER_ID, "In updateConsumedDemographic to update applicant_demographic_consumed"); return true; } catch (DataAccessLayerException e) { @@ -352,7 +362,8 @@ public boolean updateConsumedDemographic(DemographicEntityConsumed entityConsume public boolean updateConsumedDocument(DocumentEntityConsumed entityConsumed) { try { documentConsumedRepository.save(entityConsumed); - log.info("sessionId", "idType", "id", "In updateConsumedDemographic to update applicant_document_consumed"); + log.info(LOGGER_SESSIONID, LOGGER_IDTYPE, LOGGER_ID, + "In updateConsumedDemographic to update applicant_document_consumed"); return true; } catch (DataAccessLayerException e) { throw new TableNotAccessibleException(ErrorCodes.PRG_PAM_BAT_010.getCode(), @@ -541,5 +552,4 @@ public void flushAvailability() { log.info("Flushing Availability..."); availabilityRepository.flush(); } - -} +} \ No newline at end of file diff --git a/pre-registration/pre-registration-batchjob/src/main/java/io/mosip/preregistration/batchjob/utils/AvailabilityUtil.java b/pre-registration/pre-registration-batchjob/src/main/java/io/mosip/preregistration/batchjob/utils/AvailabilityUtil.java index 20845a1d6b4..cdc3025d2b1 100644 --- a/pre-registration/pre-registration-batchjob/src/main/java/io/mosip/preregistration/batchjob/utils/AvailabilityUtil.java +++ b/pre-registration/pre-registration-batchjob/src/main/java/io/mosip/preregistration/batchjob/utils/AvailabilityUtil.java @@ -1,20 +1,18 @@ package io.mosip.preregistration.batchjob.utils; +import static io.mosip.preregistration.core.constant.PreRegCoreConstant.LOGGER_ID; +import static io.mosip.preregistration.core.constant.PreRegCoreConstant.LOGGER_IDTYPE; +import static io.mosip.preregistration.core.constant.PreRegCoreConstant.LOGGER_SESSIONID; + import java.time.LocalDate; import java.time.LocalTime; import java.time.format.DateTimeFormatter; -import java.time.format.TextStyle; import java.util.ArrayList; import java.util.Date; import java.util.HashMap; import java.util.List; -import java.util.Locale; import java.util.Map; import java.util.TimeZone; -import java.util.stream.Collectors; -import java.util.stream.Stream; - -import jakarta.annotation.PostConstruct; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Value; @@ -74,6 +72,7 @@ import io.mosip.preregistration.core.config.LoggerConfiguration; import io.mosip.preregistration.core.exception.NotificationException; import io.mosip.preregistration.core.util.AuditLogUtil; +import jakarta.annotation.PostConstruct; /** * @author Rajath Kr @@ -156,7 +155,7 @@ public class AvailabilityUtil { RestTemplate restTemplate; private String langCode; - + /** * ObjectMapper global object creation */ @@ -168,13 +167,13 @@ private void setup() { : optionalLangCodes.split(",")[0]; mapper = JsonMapper.builder().addModule(new AfterburnerModule()).build(); mapper.registerModule(new JavaTimeModule()); - + } private Logger log = LoggerConfiguration.logConfig(AvailabilityUtil.class); public MainResponseDTO addAvailability(HttpHeaders headers) { - log.info("sessionId", "idType", "id", "In addAvailability method of AvailabilityUtil"); + log.info(LOGGER_SESSIONID, LOGGER_IDTYPE, LOGGER_ID, "In addAvailability method of AvailabilityUtil"); MainResponseDTO response = new MainResponseDTO<>(); response.setId(idUrlSync); response.setVersion(versionUrl); @@ -210,9 +209,10 @@ public MainResponseDTO addAvailability(HttpHeaders headers) { for (int i = 0; i < regBookingEntityList.size(); i++) { RegistrationBookingEntity bookingEntity = regBookingEntityList.get(i); String preRegId = bookingEntity.getPreregistrationId(); - ApplicationEntity applicationEntity = batchServiceDAO.getApplicantEntityDetails(preRegId); + ApplicationEntity applicationEntity = batchServiceDAO + .getApplicantEntityDetails(preRegId); if (applicationEntity.getBookingStatusCode().equals(StatusCodes.BOOKED.getCode())) { - if (cancelBooking(preRegId, headers, cancelFailedList)) { + if (cancelBooking(preRegId, headers, cancelFailedList)) { sendNotification(bookingEntity, headers, notificationFailedList); } } @@ -253,9 +253,11 @@ public MainResponseDTO addAvailability(HttpHeaders headers) { for (int i = 0; i < regBookingEntityList.size(); i++) { RegistrationBookingEntity bookingEntity = regBookingEntityList.get(i); String preRegId = bookingEntity.getPreregistrationId(); - ApplicationEntity applicationEntity = batchServiceDAO.getApplicantEntityDetails(preRegId); - if (applicationEntity.getBookingStatusCode().equals(StatusCodes.BOOKED.getCode())) { - if (cancelBooking(preRegId, headers, cancelFailedList)) { + ApplicationEntity applicationEntity = batchServiceDAO + .getApplicantEntityDetails(preRegId); + if (applicationEntity.getBookingStatusCode() + .equals(StatusCodes.BOOKED.getCode())) { + if (cancelBooking(preRegId, headers, cancelFailedList)) { sendNotification(bookingEntity, headers, notificationFailedList); } } @@ -279,9 +281,11 @@ public MainResponseDTO addAvailability(HttpHeaders headers) { for (int i = 0; i < regBookingEntityList.size(); i++) { RegistrationBookingEntity bookingEntity = regBookingEntityList.get(i); String preRegId = bookingEntity.getPreregistrationId(); - ApplicationEntity applicationEntity = batchServiceDAO.getApplicantEntityDetails(preRegId); - if (applicationEntity.getBookingStatusCode().equals(StatusCodes.BOOKED.getCode())) { - if (cancelBooking(preRegId, headers, cancelFailedList)) { + ApplicationEntity applicationEntity = batchServiceDAO + .getApplicantEntityDetails(preRegId); + if (applicationEntity.getBookingStatusCode() + .equals(StatusCodes.BOOKED.getCode())) { + if (cancelBooking(preRegId, headers, cancelFailedList)) { sendNotification(bookingEntity, headers, notificationFailedList); } } @@ -312,9 +316,11 @@ public MainResponseDTO addAvailability(HttpHeaders headers) { for (int i = 0; i < regBookingEntityList.size(); i++) { RegistrationBookingEntity bookingEntity = regBookingEntityList.get(i); String preRegId = bookingEntity.getPreregistrationId(); - ApplicationEntity applicationEntity = batchServiceDAO.getApplicantEntityDetails(preRegId); - if (applicationEntity.getBookingStatusCode().equals(StatusCodes.BOOKED.getCode())) { - if (cancelBooking(preRegId, headers, cancelFailedList)) { + ApplicationEntity applicationEntity = batchServiceDAO + .getApplicantEntityDetails(preRegId); + if (applicationEntity.getBookingStatusCode() + .equals(StatusCodes.BOOKED.getCode())) { + if (cancelBooking(preRegId, headers, cancelFailedList)) { sendNotification(bookingEntity, headers, notificationFailedList); } } @@ -337,9 +343,11 @@ public MainResponseDTO addAvailability(HttpHeaders headers) { for (int i = 0; i < regBookingEntityList.size(); i++) { RegistrationBookingEntity bookingEntity = regBookingEntityList.get(i); String preRegId = bookingEntity.getPreregistrationId(); - ApplicationEntity applicationEntity = batchServiceDAO.getApplicantEntityDetails(preRegId); - if (applicationEntity.getBookingStatusCode().equals(StatusCodes.BOOKED.getCode())) { - if (cancelBooking(preRegId, headers, cancelFailedList)) { + ApplicationEntity applicationEntity = batchServiceDAO + .getApplicantEntityDetails(preRegId); + if (applicationEntity.getBookingStatusCode() + .equals(StatusCodes.BOOKED.getCode())) { + if (cancelBooking(preRegId, headers, cancelFailedList)) { sendNotification(bookingEntity, headers, notificationFailedList); } } @@ -356,7 +364,7 @@ public MainResponseDTO addAvailability(HttpHeaders headers) { } } } catch (Throwable ex) { - log.error("sessionId", "idType", "id", + log.error(LOGGER_SESSIONID, LOGGER_IDTYPE, LOGGER_ID, "In addAvailability method reg center loop AvailabilityUtil- " + ex.getMessage()); } @@ -369,9 +377,9 @@ public MainResponseDTO addAvailability(HttpHeaders headers) { for (int j = 0; j < entityList.size(); j++) { RegistrationBookingEntity bookingEntity = entityList.get(j); String preRegId = bookingEntity.getPreregistrationId(); - ApplicationEntity applicationEntity = batchServiceDAO.getApplicantEntityDetails(preRegId); + ApplicationEntity applicationEntity = batchServiceDAO.getApplicantEntityDetails(preRegId); if (applicationEntity.getBookingStatusCode().equals(StatusCodes.BOOKED.getCode())) { - if (cancelBooking(preRegId, headers, cancelFailedList)) { + if (cancelBooking(preRegId, headers, cancelFailedList)) { sendNotification(bookingEntity, headers, notificationFailedList); } } @@ -383,13 +391,18 @@ public MainResponseDTO addAvailability(HttpHeaders headers) { } isSaveSuccess = true; } catch (Exception ex) { - log.error("sessionId", "idType", "id", "In addAvailability method of AvailabilityUtil- " + ex.getMessage()); + log.error(LOGGER_SESSIONID, LOGGER_IDTYPE, LOGGER_ID, + "In addAvailability method of AvailabilityUtil- " + ex.getMessage()); new BatchServiceExceptionCatcher().handle(ex); } finally { - log.info("sessionId", "idType", "id", "cancel appointment failed for - " + cancelFailedList.size()); - cancelFailedList.forEach((id) -> log.error("sessionId", "idType", "id", "cancel booking failed for ", id)); - log.info("sessionId", "idType", "id", "cancel notifications failed for - " + notificationFailedList.size()); - notificationFailedList.forEach((id) -> log.error("sessionId", "idType", "id", "cancel booking notification failed for ", id)); + log.info(LOGGER_SESSIONID, LOGGER_IDTYPE, LOGGER_ID, + "cancel appointment failed for - " + cancelFailedList.size()); + cancelFailedList.forEach( + (id) -> log.error(LOGGER_SESSIONID, LOGGER_IDTYPE, LOGGER_ID, "cancel booking failed for ", id)); + log.info(LOGGER_SESSIONID, LOGGER_IDTYPE, LOGGER_ID, + "cancel notifications failed for - " + notificationFailedList.size()); + notificationFailedList.forEach((id) -> log.error(LOGGER_SESSIONID, LOGGER_IDTYPE, LOGGER_ID, + "cancel booking notification failed for ", id)); response.setResponsetime(getCurrentResponseTime()); if (isSaveSuccess) { setAuditValues(EventId.PRE_407.toString(), EventName.PERSIST.toString(), EventType.SYSTEM.toString(), @@ -401,7 +414,7 @@ public MainResponseDTO addAvailability(HttpHeaders headers) { headers); } } - log.info("sessionId", "idType", "id", "Completed addAvailability"); + log.info(LOGGER_SESSIONID, LOGGER_IDTYPE, LOGGER_ID, "Completed addAvailability"); response.setResponsetime(getCurrentResponseTime()); response.setResponse("MASTER_DATA_SYNCED_SUCCESSFULLY"); return response; @@ -409,14 +422,16 @@ public MainResponseDTO addAvailability(HttpHeaders headers) { private boolean cancelBooking(String preRegistrationId, HttpHeaders headers, List cancelFailedList) { - log.info("sessionId", "idType", "id", "In cancelBooking method of Availability Util: " + preRegistrationId); + log.info(LOGGER_SESSIONID, LOGGER_IDTYPE, LOGGER_ID, + "In cancelBooking method of Availability Util: " + preRegistrationId); try { Map params = new HashMap<>(); params.put("preRegistrationId", preRegistrationId); UriComponentsBuilder builder = UriComponentsBuilder.fromHttpUrl(cancelResourceUrl); String uriBuilder = builder.buildAndExpand(params).encode().toUriString(); - log.info("sessionId", "idType", "id", "In cancelBooking method of Availability Util URL- " + uriBuilder); - HttpEntity> httpEntity = new HttpEntity<>(headers); + log.info(LOGGER_SESSIONID, LOGGER_IDTYPE, LOGGER_ID, + "In cancelBooking method of Availability Util URL- " + uriBuilder); + HttpEntity> httpEntity = new HttpEntity<>(headers); ResponseEntity> respEntity = restTemplate.exchange(uriBuilder, HttpMethod.PUT, httpEntity, new ParameterizedTypeReference>() { @@ -430,9 +445,9 @@ private boolean cancelBooking(String preRegistrationId, HttpHeaders headers, Lis } } } - } + } } catch (Exception ex) { - log.error("sessionId", "idType", "id", + log.error(LOGGER_SESSIONID, LOGGER_IDTYPE, LOGGER_ID, "Exception in cancelBooking method of Availability Util - ", ex); cancelFailedList.add(preRegistrationId); return false; @@ -446,13 +461,14 @@ private boolean cancelBooking(String preRegistrationId, HttpHeaders headers, Lis * @return List of RegistrationCenterDto */ public List getRegCenterMasterData(HttpHeaders headers) { - log.info("sessionId", "idType", "id", "In callRegCenterDateRestService method of AvailabilityUtil"); + log.info(LOGGER_SESSIONID, LOGGER_IDTYPE, LOGGER_ID, + "In callRegCenterDateRestService method of AvailabilityUtil"); List regCenter = null; try { UriComponentsBuilder regbuilder = UriComponentsBuilder.fromHttpUrl(regCenterUrl); HttpEntity> entity = new HttpEntity<>(headers); String uriBuilder = regbuilder.build().encode().toUriString(); - log.info("sessionId", "idType", "id", + log.info(LOGGER_SESSIONID, LOGGER_IDTYPE, LOGGER_ID, "In callRegCenterDateRestService method of Booking Service URL- " + uriBuilder); ResponseEntity> responseEntity = restTemplate.exchange( uriBuilder, HttpMethod.GET, entity, @@ -465,7 +481,7 @@ public List getRegCenterMasterData(HttpHeaders headers) { body.getErrors().get(0).getMessage()); } if (body.getResponse() != null) { - regCenter = body.getResponse().getRegistrationCenters(); + regCenter = body.getResponse().getRegistrationCenters(); } } if (regCenter == null || regCenter.isEmpty()) { @@ -474,7 +490,7 @@ public List getRegCenterMasterData(HttpHeaders headers) { } } catch (HttpClientErrorException ex) { - log.error("sessionId", "idType", "id", + log.error(LOGGER_SESSIONID, LOGGER_IDTYPE, LOGGER_ID, "In callRegCenterDateRestService method of Booking Service Util for HttpClientErrorException- " + ex.getMessage()); throw new RestCallException(ErrorCodes.PRG_PAM_BAT_011.getCode(), @@ -490,7 +506,7 @@ public List getRegCenterMasterData(HttpHeaders headers) { * @return List of string */ public List getHolidayListMasterData(RegistrationCenterDto regDto, HttpHeaders headers) { - log.info("sessionId", "idType", "id", + log.info(LOGGER_SESSIONID, LOGGER_IDTYPE, LOGGER_ID, "In callGetHolidayListRestService method of AvailabilityUtil for regcenter: " + regDto.getId()); List holidaylist = null; try { @@ -500,7 +516,7 @@ public List getHolidayListMasterData(RegistrationCenterDto regDto, HttpH UriComponentsBuilder builder1 = UriComponentsBuilder.fromHttpUrl(holidayUrl); HttpEntity> httpHolidayEntity = new HttpEntity<>(headers); String uriBuilder = builder1.build().encode().toUriString(); - log.info("sessionId", "idType", "id", + log.info(LOGGER_SESSIONID, LOGGER_IDTYPE, LOGGER_ID, "In callGetHolidayListRestService method of Booking Service URL- " + uriBuilder); /** Rest call to master for regular holidays. */ ResponseEntity> responseEntity1 = restTemplate.exchange( @@ -519,13 +535,11 @@ public List getHolidayListMasterData(RegistrationCenterDto regDto, HttpH for (HolidayDto holiday : body1.getResponse().getHolidays()) { holidaylist.add(holiday.getHolidayDate()); } - } + } } - /** Rest call to master for exceptional holidays. */ - String exceptionalHolidayUrl = exceptionalHolidayListUrl + regDto.getId() + "/" - + regDto.getLangCode(); + String exceptionalHolidayUrl = exceptionalHolidayListUrl + regDto.getId() + "/" + regDto.getLangCode(); UriComponentsBuilder builder2 = UriComponentsBuilder.fromHttpUrl(exceptionalHolidayUrl); HttpEntity> httpExceptionalHolidayEntity = new HttpEntity<>( headers); @@ -537,23 +551,20 @@ public List getHolidayListMasterData(RegistrationCenterDto regDto, HttpH ResponseWrapper body2 = responseEntity2.getBody(); if (body2 != null) { if (body2.getErrors() != null && !body2.getErrors().isEmpty()) { - log.error("sessionId", "idType", "id", + log.error(LOGGER_SESSIONID, LOGGER_IDTYPE, LOGGER_ID, "In get exceptional holiday fetch call of Booking Service Util for HttpClientErrorException- " - + body2.getErrors().get(0).getErrorCode() - + body2.getErrors().get(0).getMessage()); + + body2.getErrors().get(0).getErrorCode() + body2.getErrors().get(0).getMessage()); } if (body2.getResponse() != null && body2.getResponse().getExceptionalHolidayList() != null && !body2.getResponse().getExceptionalHolidayList().isEmpty()) { - for (ExceptionalHolidayDto exceptionalHoliday : body2.getResponse() - .getExceptionalHolidayList()) { + for (ExceptionalHolidayDto exceptionalHoliday : body2.getResponse().getExceptionalHolidayList()) { holidaylist.add(exceptionalHoliday.getHolidayDate().toString()); } - } + } } - /** Rest call to master for working holidays. */ - String workingDayUrl = workingDayListUrl + regDto.getId() + "/" + regDto.getLangCode(); + String workingDayUrl = workingDayListUrl + regDto.getId() + "/" + regDto.getLangCode(); UriComponentsBuilder builder3 = UriComponentsBuilder.fromHttpUrl(workingDayUrl); HttpEntity> httpWorkingDayEntity = new HttpEntity<>(headers); String uriBuilder3 = builder3.build().encode().toUriString(); @@ -568,30 +579,29 @@ public List getHolidayListMasterData(RegistrationCenterDto regDto, HttpH throw new NoRecordFoundException(body3.getErrors().get(0).getErrorCode(), body3.getErrors().get(0).getMessage()); } - + } - + // Code to retrive date of days and add it to holidays. - /* if (responseEntity3.getBody().getResponse().getWeekdays() != null) { - List workingDays = responseEntity3.getBody().getResponse().getWeekdays().stream() - .filter(regCenterWorkingDays -> regCenterWorkingDays.isWorking()) - .flatMap(wd -> Stream.of(wd.getName())).collect(Collectors.toList()); - log.info("WorkingDays >>> {}", workingDays); - log.info("Weekdays Response {}", responseEntity3.getBody().getResponse().getWeekdays()); - List nonWorkingDays = responseEntity3.getBody().getResponse().getWeekdays().stream() - .filter(regCenterWorkingDays -> !regCenterWorkingDays.isWorking()) - .flatMap(wd -> Stream.of(wd.getName())).collect(Collectors.toList()); - log.info("nonWorkingDays >>> {}", nonWorkingDays); - for (String nonWorkingDay : nonWorkingDays) { - for (LocalDate date = LocalDate.now(); date - .isBefore(LocalDate.now().plusDays(syncDays)); date = date.plusDays(1)) { - if (nonWorkingDay.equalsIgnoreCase(date.getDayOfWeek() - .getDisplayName(TextStyle.SHORT, new Locale(langCode.substring(0, 2))).toString())) { - holidaylist.add(date.toString()); - } - } - } - } */ + /* + * if (responseEntity3.getBody().getResponse().getWeekdays() != null) { + * List workingDays = + * responseEntity3.getBody().getResponse().getWeekdays().stream() + * .filter(regCenterWorkingDays -> regCenterWorkingDays.isWorking()) .flatMap(wd + * -> Stream.of(wd.getName())).collect(Collectors.toList()); + * log.info("WorkingDays >>> {}", workingDays); log.info("Weekdays Response {}", + * responseEntity3.getBody().getResponse().getWeekdays()); List + * nonWorkingDays = + * responseEntity3.getBody().getResponse().getWeekdays().stream() + * .filter(regCenterWorkingDays -> !regCenterWorkingDays.isWorking()) + * .flatMap(wd -> Stream.of(wd.getName())).collect(Collectors.toList()); + * log.info("nonWorkingDays >>> {}", nonWorkingDays); for (String nonWorkingDay + * : nonWorkingDays) { for (LocalDate date = LocalDate.now(); date + * .isBefore(LocalDate.now().plusDays(syncDays)); date = date.plusDays(1)) { if + * (nonWorkingDay.equalsIgnoreCase(date.getDayOfWeek() + * .getDisplayName(TextStyle.SHORT, new Locale(langCode.substring(0, + * 2))).toString())) { holidaylist.add(date.toString()); } } } } + */ /* * if (!responseEntity3.getBody().getResponse().getWorkingdays().isEmpty()) { @@ -605,7 +615,7 @@ public List getHolidayListMasterData(RegistrationCenterDto regDto, HttpH */ } catch (HttpClientErrorException ex) { - log.error("sessionId", "idType", "id", + log.error(LOGGER_SESSIONID, LOGGER_IDTYPE, LOGGER_ID, "In callGetHolidayListRestService method of Booking Service Util for HttpClientErrorException- " + ex.getMessage()); throw ex; @@ -623,7 +633,7 @@ public List getHolidayListMasterData(RegistrationCenterDto regDto, HttpH * @param batchServiceDAO */ public void timeSlotCalculator(RegistrationCenterDto regDto, List holidaylist, LocalDate sDate) { - log.info("sessionId", "idType", "id", + log.info(LOGGER_SESSIONID, LOGGER_IDTYPE, LOGGER_ID, "In timeSlotCalculator method of AvailabilityUtil for " + regDto + " on date " + sDate); if (holidaylist.contains(sDate.toString())) { LocalTime localTime = LocalTime.MIDNIGHT; @@ -679,7 +689,7 @@ public void timeSlotCalculator(RegistrationCenterDto regDto, List holida private void workingHoursCalculator(LocalTime fromTime, LocalTime toTime, RegistrationCenterDto regDto, LocalDate forDate) { - log.info("sessionId", "idType", "id", "In workingHoursCalculator method of Availability Util"); + log.info(LOGGER_SESSIONID, LOGGER_IDTYPE, LOGGER_ID, "In workingHoursCalculator method of Availability Util"); int window = (toTime.getHour() * 60 + toTime.getMinute() - fromTime.getHour() * 60 + fromTime.getMinute()) / (regDto.getPerKioskProcessTime().getHour() * 60 + regDto.getPerKioskProcessTime().getMinute()); int extraTime = (toTime.getHour() * 60 + toTime.getMinute() - fromTime.getHour() * 60 + fromTime.getMinute()) @@ -701,7 +711,7 @@ private void workingHoursCalculator(LocalTime fromTime, LocalTime toTime, Regist private void saveAvailability(RegistrationCenterDto regDto, LocalDate date, LocalTime currentTime, LocalTime toTime) { - log.info("sessionId", "idType", "id", "In saveAvailability method of Availability Util"); + log.info(LOGGER_SESSIONID, LOGGER_IDTYPE, LOGGER_ID, "In saveAvailability method of Availability Util"); AvailibityEntity avaEntity = new AvailibityEntity(); avaEntity.setRegDate(date); avaEntity.setRegcntrId(regDto.getId()); @@ -746,23 +756,22 @@ public boolean isNull(Object key) { * @throws JsonProcessingException */ public boolean sendNotification(RegistrationBookingEntity registrationBookingEntity, HttpHeaders headers, - List notificationsFailedList) - throws JsonProcessingException { + List notificationsFailedList) throws JsonProcessingException { try { - log.info("sessionId", "idType", "id", "In sendNotification method of AvailabilityUtil"); - NotificationDTO notification = new NotificationDTO(); - notification.setAppointmentDate(registrationBookingEntity.getRegDate().toString()); - notification.setPreRegistrationId(registrationBookingEntity.getPreregistrationId()); - String time = LocalTime - .parse(registrationBookingEntity.getSlotFromTime().toString(), DateTimeFormatter.ofPattern("HH:mm")) - .format(DateTimeFormatter.ofPattern("hh:mm a")); - notification.setAppointmentTime(time); - notification.setAdditionalRecipient(false); - notification.setIsBatch(true); - emailNotification(notification, langCode, headers); + log.info(LOGGER_SESSIONID, LOGGER_IDTYPE, LOGGER_ID, "In sendNotification method of AvailabilityUtil"); + NotificationDTO notification = new NotificationDTO(); + notification.setAppointmentDate(registrationBookingEntity.getRegDate().toString()); + notification.setPreRegistrationId(registrationBookingEntity.getPreregistrationId()); + String time = LocalTime + .parse(registrationBookingEntity.getSlotFromTime().toString(), DateTimeFormatter.ofPattern("HH:mm")) + .format(DateTimeFormatter.ofPattern("hh:mm a")); + notification.setAppointmentTime(time); + notification.setAdditionalRecipient(false); + notification.setIsBatch(true); + emailNotification(notification, langCode, headers); } catch (Exception ex) { log.error("Exception in cancel ", ex); - log.error("sessionId", "idType", "id", + log.error(LOGGER_SESSIONID, LOGGER_IDTYPE, LOGGER_ID, "Exception in sendNotification method of Availability Util - ", ex); notificationsFailedList.add(registrationBookingEntity.getPreregistrationId()); return false; @@ -793,9 +802,9 @@ public void emailNotification(NotificationDTO notificationDTO, String langCode, headers.setContentType(MediaType.MULTIPART_FORM_DATA); HttpEntity> httpEntity = new HttpEntity>( map, headers); - log.info("sessionId", "idType", "id", + log.info(LOGGER_SESSIONID, LOGGER_IDTYPE, LOGGER_ID, "In emailNotification method of NotificationUtil service emailResourseUrl: " + emailResourseUrl); - + ResponseEntity> respEntity = restTemplate.exchange( emailResourseUrl, HttpMethod.POST, httpEntity, new ParameterizedTypeReference>() { @@ -808,11 +817,10 @@ public void emailNotification(NotificationDTO notificationDTO, String langCode, throw new NotificationException(validationErrorList, null); } } - } - - + } + } catch (Exception ex) { - log.error("sessionId", "idType", "id", + log.error(LOGGER_SESSIONID, LOGGER_IDTYPE, LOGGER_ID, "Exception in emailNotification method of Booking Service Util for HttpClientErrorException- ", ex); throw new RestCallException(ErrorCodes.PRG_PAM_BAT_012.getCode(), ErrorMessages.NOTIFICATION_CALL_FAILED.getMessage()); @@ -821,7 +829,7 @@ public void emailNotification(NotificationDTO notificationDTO, String langCode, } public String getCurrentResponseTime() { - log.info("sessionId", "idType", "id", "In getCurrentResponseTime method of AvailabilityUtil"); + log.info(LOGGER_SESSIONID, LOGGER_IDTYPE, LOGGER_ID, "In getCurrentResponseTime method of AvailabilityUtil"); return DateUtils.formatDate(new Date(System.currentTimeMillis()), utcDateTimePattern); } diff --git a/pre-registration/pre-registration-captcha-service/src/main/java/io/mosip/preregistration/captcha/controller/CaptchaController.java b/pre-registration/pre-registration-captcha-service/src/main/java/io/mosip/preregistration/captcha/controller/CaptchaController.java index 1c598f682a6..8a9d45301ca 100644 --- a/pre-registration/pre-registration-captcha-service/src/main/java/io/mosip/preregistration/captcha/controller/CaptchaController.java +++ b/pre-registration/pre-registration-captcha-service/src/main/java/io/mosip/preregistration/captcha/controller/CaptchaController.java @@ -1,5 +1,9 @@ package io.mosip.preregistration.captcha.controller; +import static io.mosip.preregistration.core.constant.PreRegCoreConstant.LOGGER_ID; +import static io.mosip.preregistration.core.constant.PreRegCoreConstant.LOGGER_IDTYPE; +import static io.mosip.preregistration.core.constant.PreRegCoreConstant.LOGGER_SESSIONID; + import org.springframework.beans.factory.annotation.Autowired; import org.springframework.http.HttpStatus; import org.springframework.http.MediaType; @@ -55,7 +59,7 @@ public void initBinder(WebDataBinder binder) { @ApiResponse(responseCode = "404", description = "Not Found", content = @Content(schema = @Schema(hidden = true))) }) public ResponseEntity validateCaptcha(@Validated @RequestBody MainRequestDTO captchaRequest, @ApiParam(hidden = true) Errors errors) { - log.info("sessionId", "idType", "id", + log.info(LOGGER_SESSIONID, LOGGER_IDTYPE, LOGGER_ID, "In pre-registration captcha controller to validate the recaptcha token" + captchaRequest); requestValidator.validateId(VALIDATE, captchaRequest.getId(), errors); DataValidationUtil.validate(errors, VALIDATE); diff --git a/pre-registration/pre-registration-captcha-service/src/main/java/io/mosip/preregistration/captcha/dto/CaptchaRequestDTO.java b/pre-registration/pre-registration-captcha-service/src/main/java/io/mosip/preregistration/captcha/dto/CaptchaRequestDTO.java index 2b7d1697671..992cf8bc6c1 100644 --- a/pre-registration/pre-registration-captcha-service/src/main/java/io/mosip/preregistration/captcha/dto/CaptchaRequestDTO.java +++ b/pre-registration/pre-registration-captcha-service/src/main/java/io/mosip/preregistration/captcha/dto/CaptchaRequestDTO.java @@ -2,8 +2,6 @@ import java.io.Serializable; -import jakarta.validation.constraints.NotNull; - import lombok.Data; @Data diff --git a/pre-registration/pre-registration-captcha-service/src/main/java/io/mosip/preregistration/captcha/exception/InvalidRequestCaptchaException.java b/pre-registration/pre-registration-captcha-service/src/main/java/io/mosip/preregistration/captcha/exception/InvalidRequestCaptchaException.java index 3ebee00402b..98d0d30806e 100644 --- a/pre-registration/pre-registration-captcha-service/src/main/java/io/mosip/preregistration/captcha/exception/InvalidRequestCaptchaException.java +++ b/pre-registration/pre-registration-captcha-service/src/main/java/io/mosip/preregistration/captcha/exception/InvalidRequestCaptchaException.java @@ -1,7 +1,6 @@ package io.mosip.preregistration.captcha.exception; import io.mosip.kernel.core.exception.BaseUncheckedException; -import io.mosip.preregistration.core.common.dto.MainResponseDTO; public class InvalidRequestCaptchaException extends BaseUncheckedException { diff --git a/pre-registration/pre-registration-captcha-service/src/main/java/io/mosip/preregistration/captcha/serviceimpl/CaptchaServiceImpl.java b/pre-registration/pre-registration-captcha-service/src/main/java/io/mosip/preregistration/captcha/serviceimpl/CaptchaServiceImpl.java index 8e85c04a9ce..c04eb77e91f 100644 --- a/pre-registration/pre-registration-captcha-service/src/main/java/io/mosip/preregistration/captcha/serviceimpl/CaptchaServiceImpl.java +++ b/pre-registration/pre-registration-captcha-service/src/main/java/io/mosip/preregistration/captcha/serviceimpl/CaptchaServiceImpl.java @@ -1,5 +1,9 @@ package io.mosip.preregistration.captcha.serviceimpl; +import static io.mosip.preregistration.core.constant.PreRegCoreConstant.LOGGER_ID; +import static io.mosip.preregistration.core.constant.PreRegCoreConstant.LOGGER_IDTYPE; +import static io.mosip.preregistration.core.constant.PreRegCoreConstant.LOGGER_SESSIONID; + import java.util.ArrayList; import java.util.Date; import java.util.List; @@ -51,9 +55,9 @@ public class CaptchaServiceImpl implements CaptchaService { @Override public Object validateCaptcha(Object captchaRequest) { - - log.info("sessionId", "idType", "id", "In pre-registration captcha service to validate the token request" - + ((CaptchaRequestDTO) captchaRequest).getCaptchaToken()); + log.info(LOGGER_SESSIONID, LOGGER_IDTYPE, LOGGER_ID, + "In pre-registration captcha service to validate the token request" + + ((CaptchaRequestDTO) captchaRequest).getCaptchaToken()); validateCaptchaRequest((CaptchaRequestDTO) captchaRequest); @@ -66,27 +70,27 @@ public Object validateCaptcha(Object captchaRequest) { GoogleCaptchaDTO captchaResponse = null; try { - log.info("sessionId", "idType", "id", + log.info(LOGGER_SESSIONID, LOGGER_IDTYPE, LOGGER_ID, "In pre-registration captcha service try block to validate the token request via a google verify site rest call" + ((CaptchaRequestDTO) captchaRequest).getCaptchaToken() + " " + recaptchaVerifyUrl); - + captchaResponse = this.restTemplate.postForObject(recaptchaVerifyUrl, param, GoogleCaptchaDTO.class); if (captchaResponse != null) { - log.debug("sessionId", "idType", "id", captchaResponse.toString()); + log.debug(LOGGER_SESSIONID, LOGGER_IDTYPE, LOGGER_ID, captchaResponse.toString()); } } catch (RestClientException ex) { - log.error("sessionId", "idType", "id", + log.error(LOGGER_SESSIONID, LOGGER_IDTYPE, LOGGER_ID, "In pre-registration captcha service to validate the token request via a google verify site rest call has failed --->" + ((CaptchaRequestDTO) captchaRequest).getCaptchaToken() + " " + recaptchaVerifyUrl + " " + ex); - if (captchaResponse != null && captchaResponse.getErrorCodes() !=null) { - throw new CaptchaException(captchaResponse.getErrorCodes().get(0).getErrorCode(), - captchaResponse.getErrorCodes().get(0).getMessage()); + if (captchaResponse != null && captchaResponse.getErrorCodes() != null) { + throw new CaptchaException(captchaResponse.getErrorCodes().get(0).getErrorCode(), + captchaResponse.getErrorCodes().get(0).getMessage()); } } - if (captchaResponse!=null && captchaResponse.isSuccess()) { - log.info("sessionId", "idType", "id", + if (captchaResponse != null && captchaResponse.isSuccess()) { + log.info(LOGGER_SESSIONID, LOGGER_IDTYPE, LOGGER_ID, "In pre-registration captcha service token request has been successfully verified --->" + captchaResponse.isSuccess()); mainResponse.setId(mosipcaptchaValidateId); @@ -98,7 +102,7 @@ public Object validateCaptcha(Object captchaRequest) { mainResponse.setResponse(response); } else { if (captchaResponse != null) { - log.error("sessionId", "idType", "id", + log.error(LOGGER_SESSIONID, LOGGER_IDTYPE, LOGGER_ID, "In pre-registration captcha service token request has failed --->" + captchaResponse.isSuccess()); } @@ -114,13 +118,11 @@ public Object validateCaptcha(Object captchaRequest) { } return mainResponse; - } private void validateCaptchaRequest(CaptchaRequestDTO captchaRequest) { - - if (captchaRequest.getCaptchaToken() == null || captchaRequest.getCaptchaToken().trim().length() == 0) { - log.debug("sessionId", "idType", "id", captchaRequest.toString()); + if (captchaRequest.getCaptchaToken() == null || captchaRequest.getCaptchaToken().trim().length() == 0) { + log.debug(LOGGER_SESSIONID, LOGGER_IDTYPE, LOGGER_ID, captchaRequest.toString()); throw new InvalidRequestCaptchaException(CaptchaErrorCode.INVALID_CAPTCHA_REQUEST.getErrorCode(), CaptchaErrorCode.INVALID_CAPTCHA_REQUEST.getErrorMessage()); } @@ -130,5 +132,4 @@ private String getCurrentResponseTime() { String dateTimeFormat = "yyyy-MM-dd'T'HH:mm:ss.SSS'Z'"; return DateUtils.formatDate(new Date(System.currentTimeMillis()), dateTimeFormat); } - -} +} \ No newline at end of file diff --git a/pre-registration/pre-registration-core/src/main/java/io/mosip/analytics/event/anonymous/service/AnonymousProfileService.java b/pre-registration/pre-registration-core/src/main/java/io/mosip/analytics/event/anonymous/service/AnonymousProfileService.java index fbea8fde061..f915d708220 100644 --- a/pre-registration/pre-registration-core/src/main/java/io/mosip/analytics/event/anonymous/service/AnonymousProfileService.java +++ b/pre-registration/pre-registration-core/src/main/java/io/mosip/analytics/event/anonymous/service/AnonymousProfileService.java @@ -1,5 +1,9 @@ package io.mosip.analytics.event.anonymous.service; +import static io.mosip.preregistration.core.constant.PreRegCoreConstant.LOGGER_ID; +import static io.mosip.preregistration.core.constant.PreRegCoreConstant.LOGGER_IDTYPE; +import static io.mosip.preregistration.core.constant.PreRegCoreConstant.LOGGER_SESSIONID; + import java.time.LocalDateTime; import java.time.ZoneId; import java.time.format.DateTimeFormatter; @@ -62,8 +66,8 @@ public AuthUserDetails authUserDetails() { */ @Override public AnonymousProfileResponseDTO saveAnonymousProfile(AnonymousProfileRequestDTO requestDto) { - log.info("sessionId", "idType", "id", "In saveAnonymousProfile() method of AnonymousProfileService"); - log.info("sessionId", "idType", "id", + log.info(LOGGER_SESSIONID, LOGGER_IDTYPE, LOGGER_ID, "In saveAnonymousProfile() method of AnonymousProfileService"); + log.info(LOGGER_SESSIONID, LOGGER_IDTYPE, LOGGER_ID, "Pre Registration start time : " + DateUtils.getUTCCurrentDateTimeString()); AnonymousProfileResponseDTO responseDto = new AnonymousProfileResponseDTO(); try { @@ -83,15 +87,14 @@ public AnonymousProfileResponseDTO saveAnonymousProfile(AnonymousProfileRequestD responseDto.setCreatedDateTime(getLocalDateString(responseEntity.getCreateDateTime())); responseDto.setUpdatedBy(responseEntity.getUpdatedBy()); responseDto.setUpdatedDateTime(getLocalDateString(responseEntity.getUpdateDateTime())); - log.info("sessionId", "idType", "id", + log.info(LOGGER_SESSIONID, LOGGER_IDTYPE, LOGGER_ID, "Pre Registration end time : " + DateUtils.getUTCCurrentDateTimeString()); } catch (Exception exception) { - log.error("sessionId", "idType", "id", ExceptionUtils.getStackTrace(exception)); - log.error("sessionId", "idType", "id", + log.error(LOGGER_SESSIONID, LOGGER_IDTYPE, LOGGER_ID, ExceptionUtils.getStackTrace(exception)); + log.error(LOGGER_SESSIONID, LOGGER_IDTYPE, LOGGER_ID, "In saveAnonymousProfile() method of AnonymousProfileService - " + exception.getMessage()); } return responseDto; - } public String getLocalDateString(LocalDateTime date) { @@ -100,5 +103,4 @@ public String getLocalDateString(LocalDateTime date) { DateTimeFormatter dateTimeFormatter = DateTimeFormatter.ofPattern(utcDateTimePattern); return date.format(dateTimeFormatter); } - -} +} \ No newline at end of file diff --git a/pre-registration/pre-registration-core/src/main/java/io/mosip/analytics/event/anonymous/util/AnonymousProfileUtil.java b/pre-registration/pre-registration-core/src/main/java/io/mosip/analytics/event/anonymous/util/AnonymousProfileUtil.java index c88b493a75e..8405842e54c 100644 --- a/pre-registration/pre-registration-core/src/main/java/io/mosip/analytics/event/anonymous/util/AnonymousProfileUtil.java +++ b/pre-registration/pre-registration-core/src/main/java/io/mosip/analytics/event/anonymous/util/AnonymousProfileUtil.java @@ -1,5 +1,9 @@ package io.mosip.analytics.event.anonymous.util; +import static io.mosip.preregistration.core.constant.PreRegCoreConstant.LOGGER_ID; +import static io.mosip.preregistration.core.constant.PreRegCoreConstant.LOGGER_IDTYPE; +import static io.mosip.preregistration.core.constant.PreRegCoreConstant.LOGGER_SESSIONID; + import java.io.IOException; import java.time.LocalDate; import java.time.LocalDateTime; @@ -138,11 +142,12 @@ public String getJsonFile(String filename) { StringBuilder uriBuilder = new StringBuilder(); uriBuilder.append(configServerUri + "/").append(configAppName + "/").append(configProfile + "/") .append(configLabel + "/").append(filename); - log.info("sessionId", "idType", "id", " URL in getJsonFile() method of AnonymousProfileUtil " + uriBuilder); + log.info(LOGGER_SESSIONID, LOGGER_IDTYPE, LOGGER_ID, + " URL in getJsonFile() method of AnonymousProfileUtil " + uriBuilder); return restTemplate.getForObject(uriBuilder.toString(), String.class); } catch (Exception ex) { - log.error("sessionId", "idType", "id", ExceptionUtils.getStackTrace(ex)); - log.error("sessionId", "idType", "id", + log.error(LOGGER_SESSIONID, LOGGER_IDTYPE, LOGGER_ID, ExceptionUtils.getStackTrace(ex)); + log.error(LOGGER_SESSIONID, LOGGER_IDTYPE, LOGGER_ID, "In getIdentityMapping() method of AnonymousProfileUtil - " + ex.getMessage()); } return null; @@ -159,16 +164,16 @@ public String getJsonFile(String filename) { */ public void saveAnonymousProfile(DemographicResponseDTO demographicData, DocumentsMetaData documentsData, BookingRegistrationDTO bookingData, BrowserInfoDTO browserData) throws AnonymousProfileException { - log.info("sessionId", "idType", "id", + log.info(LOGGER_SESSIONID, LOGGER_IDTYPE, LOGGER_ID, "The demographicData in saveAnonymousProfile() method of AnonymousProfileUtil service - " + demographicData); - log.info("sessionId", "idType", "id", + log.info(LOGGER_SESSIONID, LOGGER_IDTYPE, LOGGER_ID, "The documentsData in saveAnonymousProfile() method of AnonymousProfileUtil service - " + documentsData); - log.info("sessionId", "idType", "id", + log.info(LOGGER_SESSIONID, LOGGER_IDTYPE, LOGGER_ID, "The bookingData in saveAnonymousProfile() method of AnonymousProfileUtil service - " + bookingData); try { - DemographicIdentityRequestDTO identityDto = populateIdentityMappingDto(); + DemographicIdentityRequestDTO identityDto = populateIdentityMappingDto(); if (!isNull(identityDto) && !isNull(identityDto.getIdentity()) && !isNull(demographicData)) { Identity identityMapping = identityDto.getIdentity(); JsonNode identityData = objectMapper.readTree(demographicData.getDemographicDetails().toJSONString()); @@ -177,8 +182,8 @@ public void saveAnonymousProfile(DemographicResponseDTO demographicData, Documen registrationProfile.setProcessName(PREREGISTRATION_APP_NAME); registrationProfile.setProcessStage(PREREGISTRATION_APP_NAME); registrationProfile.setDate(LocalDateTime.now(ZoneId.of("UTC"))); - registrationProfile.setYearOfBirth(extractYear( - getValueFromDemographicData(identityMapping.getDob().getValue(), identityData))); + registrationProfile.setYearOfBirth( + extractYear(getValueFromDemographicData(identityMapping.getDob().getValue(), identityData))); registrationProfile .setGender(getValueFromDemographicData(identityMapping.getGender().getValue(), identityData)); registrationProfile.setPreferredLanguage(demographicData.getLangCode()); @@ -201,8 +206,8 @@ public void saveAnonymousProfile(DemographicResponseDTO demographicData, Documen } } catch (Exception ex) { - log.error("sessionId", "idType", "id", ExceptionUtils.getStackTrace(ex)); - log.error("sessionId", "idType", "id", + log.error(LOGGER_SESSIONID, LOGGER_IDTYPE, LOGGER_ID, ExceptionUtils.getStackTrace(ex)); + log.error(LOGGER_SESSIONID, LOGGER_IDTYPE, LOGGER_ID, "Exception in saveAnonymousProfile() method of AnonymousProfileUtil - " + ex.getMessage()); throw new AnonymousProfileException(AnonymousProfileErrorCodes.PRG_ANO_001.getCode(), AnonymousProfileErrorMessages.UNABLE_TO_SAVE_ANONYMOUS_PROFILE.getMessage()); @@ -219,8 +224,8 @@ private DemographicIdentityRequestDTO populateIdentityMappingDto() { try { return objectMapper.readValue(identityMappingJsonString, DemographicIdentityRequestDTO.class); } catch (IOException ex) { - log.error("sessionId", "idType", "id", ExceptionUtils.getStackTrace(ex)); - log.error("sessionId", "idType", "id", + log.error(LOGGER_SESSIONID, LOGGER_IDTYPE, LOGGER_ID, ExceptionUtils.getStackTrace(ex)); + log.error(LOGGER_SESSIONID, LOGGER_IDTYPE, LOGGER_ID, "In getIdentityMapping() method of AnonymousProfileUtil - " + ex.getMessage()); } return null; @@ -313,7 +318,7 @@ private List getDocumentTypesList(DocumentsMetaData documentsMetaData) { * @return true if key not null and return false if key is null. */ private boolean isNull(Object key) { - log.info("sessionId", "idType", "id", "In isNull method of datasync service util"); + log.info(LOGGER_SESSIONID, LOGGER_IDTYPE, LOGGER_ID, "In isNull method of datasync service util"); if (key instanceof String) { if (key.equals(BLANK_STRING)) return true; diff --git a/pre-registration/pre-registration-core/src/main/java/io/mosip/preregistration/core/constant/PreRegCoreConstant.java b/pre-registration/pre-registration-core/src/main/java/io/mosip/preregistration/core/constant/PreRegCoreConstant.java new file mode 100644 index 00000000000..0df284b70bc --- /dev/null +++ b/pre-registration/pre-registration-core/src/main/java/io/mosip/preregistration/core/constant/PreRegCoreConstant.java @@ -0,0 +1,11 @@ +package io.mosip.preregistration.core.constant; + +public class PreRegCoreConstant { + private PreRegCoreConstant() { + throw new IllegalStateException("PreRegCoreConstant class"); + } + + public static final String LOGGER_SESSIONID = "PRE-REGISTRATION"; + public static final String LOGGER_IDTYPE = "CORE SERVICE"; + public static final String LOGGER_ID = ""; +} \ No newline at end of file diff --git a/pre-registration/pre-registration-core/src/main/java/io/mosip/preregistration/core/util/AuditLogUtil.java b/pre-registration/pre-registration-core/src/main/java/io/mosip/preregistration/core/util/AuditLogUtil.java index 879374337b7..4714abb3a24 100644 --- a/pre-registration/pre-registration-core/src/main/java/io/mosip/preregistration/core/util/AuditLogUtil.java +++ b/pre-registration/pre-registration-core/src/main/java/io/mosip/preregistration/core/util/AuditLogUtil.java @@ -1,5 +1,9 @@ package io.mosip.preregistration.core.util; +import static io.mosip.preregistration.core.constant.PreRegCoreConstant.LOGGER_ID; +import static io.mosip.preregistration.core.constant.PreRegCoreConstant.LOGGER_IDTYPE; +import static io.mosip.preregistration.core.constant.PreRegCoreConstant.LOGGER_SESSIONID; + import java.io.IOException; import java.net.InetAddress; import java.net.UnknownHostException; @@ -111,7 +115,7 @@ public String getServerName() { } public void saveAuditDetails(AuditRequestDto auditRequestDto) { - log.info("sessionId", "idType", "id", + log.info(LOGGER_SESSIONID, LOGGER_IDTYPE, LOGGER_ID, "In saveAuditDetails method of AugitLogUtil service - " + auditRequestDto); auditRequestDto.setActionTimeStamp(LocalDateTime.now(ZoneId.of("UTC"))); @@ -134,7 +138,7 @@ public void saveAuditDetails(AuditRequestDto auditRequestDto) { } public boolean callAuditManager(AuditRequestDto auditRequestDto) { - log.info("sessionId", "idType", "id", + log.info(LOGGER_SESSIONID, LOGGER_IDTYPE, LOGGER_ID, "In callAuditManager method of AugitLogUtil service - " + auditRequestDto); boolean auditFlag = false; @@ -147,7 +151,7 @@ public boolean callAuditManager(AuditRequestDto auditRequestDto) { HttpEntity> requestEntity = new HttpEntity<>(requestKernel, headers); String uriBuilder = builder.build().encode(StandardCharsets.UTF_8).toUriString(); - log.info("sessionId", "idType", "id", + log.info(LOGGER_SESSIONID, LOGGER_IDTYPE, LOGGER_ID, "In callAuditManager method of AugitLogUtil service auditUrl: " + uriBuilder); ResponseEntity responseEntity2 = restTemplate.exchange(uriBuilder, HttpMethod.POST, requestEntity, new ParameterizedTypeReference() { @@ -157,8 +161,8 @@ public boolean callAuditManager(AuditRequestDto auditRequestDto) { responseToString(response.getResponse()), AuditResponseDto.class); auditFlag = responseDTO.isStatus(); } catch (HttpClientErrorException ex) { - log.debug("sessionId", "idType", "id", ExceptionUtils.getStackTrace(ex)); - log.error("sessionId", "idType", "id", + log.debug(LOGGER_SESSIONID, LOGGER_IDTYPE, LOGGER_ID, ExceptionUtils.getStackTrace(ex)); + log.error(LOGGER_SESSIONID, LOGGER_IDTYPE, LOGGER_ID, "In callAuditManager method of AugitLogUtil Util for HttpClientErrorException- " + ex.getResponseBodyAsString()); } @@ -191,7 +195,7 @@ private Object requestBodyExchangeObject(String serviceResponseBody, Class re objectMapper.enable(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES); return objectMapper.readValue(serviceResponseBody, responseClass); } catch (IOException e) { - log.debug("sessionId", "idType", "id", ExceptionUtils.getStackTrace(e)); + log.debug(LOGGER_SESSIONID, LOGGER_IDTYPE, LOGGER_ID, ExceptionUtils.getStackTrace(e)); throw new ParseResponseException(ErrorCodes.PRG_CORE_REQ_021.getCode(), ErrorMessages.ERROR_WHILE_PARSING.getMessage(), null); @@ -206,7 +210,7 @@ private Object requestBodyExchangeObject(String serviceResponseBody, Class re * @return */ public void saveAuditDetails(AuditRequestDto auditRequestDto, HttpHeaders header) { - log.info("sessionId", "idType", "id", + log.info(LOGGER_SESSIONID, LOGGER_IDTYPE, LOGGER_ID, "In saveAuditDetails method of AugitLogUtil service - " + auditRequestDto); auditRequestDto.setActionTimeStamp(LocalDateTime.now(ZoneId.of("UTC"))); @@ -228,7 +232,6 @@ public void saveAuditDetails(AuditRequestDto auditRequestDto, HttpHeaders header callAuditManager(auditRequestDto, header); } - /** * For Auditing Login Services * @@ -237,7 +240,7 @@ public void saveAuditDetails(AuditRequestDto auditRequestDto, HttpHeaders header * @return */ public boolean callAuditManager(AuditRequestDto auditRequestDto, HttpHeaders headers) { - log.info("sessionId", "idType", "id", + log.info(LOGGER_SESSIONID, LOGGER_IDTYPE, LOGGER_ID, "In callAuditManager method of AugitLogUtil service - " + auditRequestDto); boolean auditFlag = false; @@ -248,7 +251,7 @@ public boolean callAuditManager(AuditRequestDto auditRequestDto, HttpHeaders hea HttpEntity> requestEntity = new HttpEntity<>(requestKernel, headers); String uriBuilder = builder.build().encode(StandardCharsets.UTF_8).toUriString(); - log.info("sessionId", "idType", "id", + log.info(LOGGER_SESSIONID, LOGGER_IDTYPE, LOGGER_ID, "In callAuditManager method of AugitLogUtil service auditUrl: " + uriBuilder); ResponseEntity> responseEntity2 = restTemplate.exchange(uriBuilder, HttpMethod.POST, requestEntity, @@ -259,11 +262,10 @@ public boolean callAuditManager(AuditRequestDto auditRequestDto, HttpHeaders hea auditFlag = body.getResponse().isStatus(); } } catch (HttpClientErrorException ex) { - log.error("sessionId", "idType", "id", + log.error(LOGGER_SESSIONID, LOGGER_IDTYPE, LOGGER_ID, "In callAuditManager method of AugitLogUtil Util for HttpClientErrorException- " + ex.getResponseBodyAsString()); } return auditFlag; } - -} +} \ No newline at end of file diff --git a/pre-registration/pre-registration-core/src/main/java/io/mosip/preregistration/core/util/CryptoUtil.java b/pre-registration/pre-registration-core/src/main/java/io/mosip/preregistration/core/util/CryptoUtil.java index 08b1801087f..27de71672b6 100644 --- a/pre-registration/pre-registration-core/src/main/java/io/mosip/preregistration/core/util/CryptoUtil.java +++ b/pre-registration/pre-registration-core/src/main/java/io/mosip/preregistration/core/util/CryptoUtil.java @@ -1,5 +1,9 @@ package io.mosip.preregistration.core.util; +import static io.mosip.preregistration.core.constant.PreRegCoreConstant.LOGGER_ID; +import static io.mosip.preregistration.core.constant.PreRegCoreConstant.LOGGER_IDTYPE; +import static io.mosip.preregistration.core.constant.PreRegCoreConstant.LOGGER_SESSIONID; + import java.nio.charset.StandardCharsets; import java.time.LocalDateTime; @@ -44,19 +48,18 @@ public class CryptoUtil { @Value("${cryptoResource.url}") public String cryptoResourceUrl; - + @Value("${preregistration.crypto.applicationId}") public String cryptoApplcationId; - + @Value("${preregistration.crypto.referenceId}") public String cryptoReferenceId; - + @Value("${preregistration.crypto.PrependThumbprint}") public boolean cryptoPrependThumbprint; - public byte[] encrypt(byte[] originalInput, LocalDateTime localDateTime) { - log.info("sessionId", "idType", "id", "In encrypt method of CryptoUtil service "); + log.info(LOGGER_SESSIONID, LOGGER_IDTYPE, LOGGER_ID, "In encrypt method of CryptoUtil service "); ResponseEntity> response = null; byte[] encryptedBytes = null; @@ -73,12 +76,12 @@ public byte[] encrypt(byte[] originalInput, LocalDateTime localDateTime) { HttpHeaders headers = new HttpHeaders(); headers.setContentType(MediaType.APPLICATION_JSON); HttpEntity> request = new HttpEntity<>(requestKernel, headers); - log.info("sessionId", "idType", "id", + log.info(LOGGER_SESSIONID, LOGGER_IDTYPE, LOGGER_ID, "In encrypt method of CryptoUtil service cryptoResourceUrl: " + cryptoResourceUrl + "/encrypt"); response = restTemplate.exchange(cryptoResourceUrl + "/encrypt", HttpMethod.POST, request, new ParameterizedTypeReference>() { }); - log.info("sessionId", "idType", "id", "encrypt response of " + response); + log.info(LOGGER_SESSIONID, LOGGER_IDTYPE, LOGGER_ID, "encrypt response of " + response); ResponseWrapper body = response.getBody(); if (body != null) { if (!(body.getErrors() == null || body.getErrors().isEmpty())) { @@ -89,8 +92,8 @@ public byte[] encrypt(byte[] originalInput, LocalDateTime localDateTime) { } } } catch (Exception ex) { - log.debug("sessionId", "idType", "id", ExceptionUtils.getStackTrace(ex)); - log.error("sessionId", "idType", "id", + log.debug(LOGGER_SESSIONID, LOGGER_IDTYPE, LOGGER_ID, ExceptionUtils.getStackTrace(ex)); + log.error(LOGGER_SESSIONID, LOGGER_IDTYPE, LOGGER_ID, "In encrypt method of CryptoUtil Util for Exception- " + ex.getMessage()); throw ex; } @@ -99,7 +102,7 @@ public byte[] encrypt(byte[] originalInput, LocalDateTime localDateTime) { } public byte[] decrypt(byte[] originalInput, LocalDateTime localDateTime) { - log.info("sessionId", "idType", "id", "In decrypt method of CryptoUtil service "); + log.info(LOGGER_SESSIONID, LOGGER_IDTYPE, LOGGER_ID, "In decrypt method of CryptoUtil service "); ResponseEntity> response = null; byte[] decodedBytes = null; try { @@ -117,7 +120,7 @@ public byte[] decrypt(byte[] originalInput, LocalDateTime localDateTime) { headers.setContentType(MediaType.APPLICATION_JSON); HttpEntity> request = new HttpEntity<>(requestKernel, headers); - log.info("sessionId", "idType", "id", + log.info(LOGGER_SESSIONID, LOGGER_IDTYPE, LOGGER_ID, "In decrypt method of CryptoUtil service cryptoResourceUrl: " + cryptoResourceUrl + "/decrypt"); response = restTemplate.exchange(cryptoResourceUrl + "/decrypt", HttpMethod.POST, request, new ParameterizedTypeReference>() { @@ -132,13 +135,11 @@ public byte[] decrypt(byte[] originalInput, LocalDateTime localDateTime) { } } } catch (Exception ex) { - log.debug("sessionId", "idType", "id", ExceptionUtils.getStackTrace(ex)); - log.error("sessionId", "idType", "id", + log.debug(LOGGER_SESSIONID, LOGGER_IDTYPE, LOGGER_ID, ExceptionUtils.getStackTrace(ex)); + log.error(LOGGER_SESSIONID, LOGGER_IDTYPE, LOGGER_ID, "In decrypt method of CryptoUtil Util for Exception- " + ex.getMessage()); throw ex; } return decodedBytes; - } - -} +} \ No newline at end of file diff --git a/pre-registration/pre-registration-core/src/main/java/io/mosip/preregistration/core/util/NotificationUtil.java b/pre-registration/pre-registration-core/src/main/java/io/mosip/preregistration/core/util/NotificationUtil.java index 6f5aaa12b7f..0aa9043cf0f 100644 --- a/pre-registration/pre-registration-core/src/main/java/io/mosip/preregistration/core/util/NotificationUtil.java +++ b/pre-registration/pre-registration-core/src/main/java/io/mosip/preregistration/core/util/NotificationUtil.java @@ -1,5 +1,9 @@ package io.mosip.preregistration.core.util; +import static io.mosip.preregistration.core.constant.PreRegCoreConstant.LOGGER_ID; +import static io.mosip.preregistration.core.constant.PreRegCoreConstant.LOGGER_IDTYPE; +import static io.mosip.preregistration.core.constant.PreRegCoreConstant.LOGGER_SESSIONID; + import java.io.IOException; import java.util.Date; @@ -80,7 +84,8 @@ public class NotificationUtil { public MainResponseDTO notify(String notificationType, NotificationDTO acknowledgementDTO, MultipartFile file, String bookingType) throws IOException { - log.info("sessionId", "idType", "id", "In notify method of NotificationUtil service:" + notificationType); + log.info(LOGGER_SESSIONID, LOGGER_IDTYPE, LOGGER_ID, + "In notify method of NotificationUtil service:" + notificationType); MainResponseDTO response = new MainResponseDTO<>(); if (notificationType.equals(RequestCodes.SMS)) { @@ -103,7 +108,7 @@ public MainResponseDTO notify(String notificationType, */ public MainResponseDTO emailNotification(String bookingType, NotificationDTO acknowledgementDTO, MultipartFile file) throws IOException { - log.info("sessionId", "idType", "id", "In emailNotification method of NotificationUtil service"); + log.info(LOGGER_SESSIONID, LOGGER_IDTYPE, LOGGER_ID, "In emailNotification method of NotificationUtil service"); HttpEntity doc = null; String fileText = null; if (file != null) { @@ -148,7 +153,7 @@ public MainResponseDTO emailNotification(String booking } emailMap.add("mailTo", acknowledgementDTO.getEmailID()); HttpEntity> httpEntity = new HttpEntity<>(emailMap, headers); - log.info("sessionId", "idType", "id", + log.info(LOGGER_SESSIONID, LOGGER_IDTYPE, LOGGER_ID, "In emailNotification method of NotificationUtil service emailResourseUrl: " + emailResourseUrl); try { resp = restTemplate.exchange(emailResourseUrl, HttpMethod.POST, httpEntity, @@ -180,7 +185,7 @@ public MainResponseDTO emailNotification(String booking */ public String getEmailSubject(String bookingType, NotificationDTO acknowledgementDTO, String templateTypeCode) throws IOException { - log.info("sessionId", "idType", "id", "In getEmailSubject method of NotificationUtil service"); + log.info(LOGGER_SESSIONID, LOGGER_IDTYPE, LOGGER_ID, "In getEmailSubject method of NotificationUtil service"); String emailSubject = ""; int noOfLang = acknowledgementDTO.getFullName().size(); for (KeyValuePairDto keyValuePair : acknowledgementDTO.getFullName()) { @@ -204,7 +209,7 @@ public String getEmailSubject(String bookingType, NotificationDTO acknowledgemen */ public MainResponseDTO smsNotification(String bookingType, NotificationDTO acknowledgementDTO) throws IOException { - log.info("sessionId", "idType", "id", "In smsNotification method of NotificationUtil service"); + log.info(LOGGER_SESSIONID, LOGGER_IDTYPE, LOGGER_ID, "In smsNotification method of NotificationUtil service"); MainResponseDTO response = new MainResponseDTO<>(); ResponseEntity> resp = null; String mergeTemplate = null; @@ -235,7 +240,7 @@ public MainResponseDTO smsNotification(String bookingTy headers.setContentType(MediaType.APPLICATION_JSON); HttpEntity> httpEntity = new HttpEntity<>(req, headers); - log.info("sessionId", "idType", "id", + log.info(LOGGER_SESSIONID, LOGGER_IDTYPE, LOGGER_ID, "In smsNotification method of NotificationUtil service smsResourseUrl: " + smsResourseUrl); resp = restTemplate.exchange(smsResourseUrl, HttpMethod.POST, httpEntity, new ParameterizedTypeReference>() { @@ -257,34 +262,37 @@ public MainResponseDTO getAppointmentDetails(String preR ResponseEntity> responseEntity = null; String url = getAppointmentResourseUrl + "/appointment/" + preRegId; try { - log.info("sessionId", "idType", "id", "In callBookingService method of DemographicServiceUtil" + url); + log.info(LOGGER_SESSIONID, LOGGER_IDTYPE, LOGGER_ID, + "In callBookingService method of DemographicServiceUtil" + url); HttpHeaders headers = new HttpHeaders(); headers.setContentType(MediaType.APPLICATION_JSON); HttpEntity entity = new HttpEntity<>(headers); - log.debug("sessionId", "idType", "id", entity.toString()); + log.debug(LOGGER_SESSIONID, LOGGER_IDTYPE, LOGGER_ID, entity.toString()); responseEntity = restTemplate.exchange(url, HttpMethod.GET, entity, new ParameterizedTypeReference>() { }); - log.debug("sessionId", "idType", "id", responseEntity.toString()); + log.debug(LOGGER_SESSIONID, LOGGER_IDTYPE, LOGGER_ID, responseEntity.toString()); MainResponseDTO body = responseEntity.getBody(); if (body != null) { if (body.getErrors() != null && !body.getErrors().isEmpty()) { - log.error("sessionId", "idType", "id", body.getErrors().toString()); + log.error(LOGGER_SESSIONID, LOGGER_IDTYPE, LOGGER_ID, body.getErrors().toString()); response.setErrors(body.getErrors()); } else { response.setResponse(body.getResponse()); } } - log.info("sessionId", "idType", "id", "In call to booking rest service :" + url); + log.info(LOGGER_SESSIONID, LOGGER_IDTYPE, LOGGER_ID, "In call to booking rest service :" + url); } catch (Exception ex) { - log.debug("sessionId", "idType", "id", "Booking rest call exception " + ExceptionUtils.getStackTrace(ex)); + log.debug(LOGGER_SESSIONID, LOGGER_IDTYPE, LOGGER_ID, + "Booking rest call exception " + ExceptionUtils.getStackTrace(ex)); throw new RestClientException("Rest call failed"); } return response; } public String getCurrentResponseTime() { - log.info("sessionId", "idType", "id", "In getCurrentResponseTime method of NotificationUtil service"); + log.info(LOGGER_SESSIONID, LOGGER_IDTYPE, LOGGER_ID, + "In getCurrentResponseTime method of NotificationUtil service"); return DateUtils.formatDate(new Date(System.currentTimeMillis()), dateTimeFormat); } -} +} \ No newline at end of file diff --git a/pre-registration/pre-registration-core/src/main/java/io/mosip/preregistration/core/util/TemplateUtil.java b/pre-registration/pre-registration-core/src/main/java/io/mosip/preregistration/core/util/TemplateUtil.java index 6dff1838455..b38bc6d4c04 100644 --- a/pre-registration/pre-registration-core/src/main/java/io/mosip/preregistration/core/util/TemplateUtil.java +++ b/pre-registration/pre-registration-core/src/main/java/io/mosip/preregistration/core/util/TemplateUtil.java @@ -1,5 +1,9 @@ package io.mosip.preregistration.core.util; +import static io.mosip.preregistration.core.constant.PreRegCoreConstant.LOGGER_ID; +import static io.mosip.preregistration.core.constant.PreRegCoreConstant.LOGGER_IDTYPE; +import static io.mosip.preregistration.core.constant.PreRegCoreConstant.LOGGER_SESSIONID; + import java.io.ByteArrayInputStream; import java.io.IOException; import java.io.InputStream; @@ -83,7 +87,8 @@ public String getTemplate(Object langCode, String templatetypecode) { String url = resourceUrl + "/" + (String) langCode + "/" + templatetypecode; HttpHeaders headers = new HttpHeaders(); HttpEntity> httpEntity = new HttpEntity<>(headers); - log.info("sessionId", "idType", "id", "In getTemplate method of TemplateUtil service url: " + url); + log.info(LOGGER_SESSIONID, LOGGER_IDTYPE, LOGGER_ID, + "In getTemplate method of TemplateUtil service url: " + url); ResponseEntity> respEntity = restTemplate.exchange(url, HttpMethod.GET, httpEntity, new ParameterizedTypeReference>() { }); @@ -104,9 +109,9 @@ public String getTemplate(Object langCode, String templatetypecode) { * @return * @throws IOException */ - public String templateMerge(String bookingType, String fileText, NotificationDTO acknowledgementDTO, String langCode) - throws IOException { - log.info("sessionId", "idType", "id", "In templateMerge method of TemplateUtil service "); + public String templateMerge(String bookingType, String fileText, NotificationDTO acknowledgementDTO, + String langCode) throws IOException { + log.info(LOGGER_SESSIONID, LOGGER_IDTYPE, LOGGER_ID, "In templateMerge method of TemplateUtil service "); String mergeTemplate = null; Map map = mapSetting(bookingType, langCode, acknowledgementDTO); InputStream templateInputStream = new ByteArrayInputStream(fileText.getBytes(Charset.forName("UTF-8"))); @@ -126,7 +131,8 @@ public String templateMerge(String bookingType, String fileText, NotificationDTO */ public Map mapSetting(String bookingType, String langCode, NotificationDTO acknowledgementDTO) { Map responseMap = new HashMap<>(); - log.info("sessionId", "idType", "id", "In mapSetting method of TemplateUtil service {}", acknowledgementDTO); + log.info(LOGGER_SESSIONID, LOGGER_IDTYPE, LOGGER_ID, "In mapSetting method of TemplateUtil service {}", + acknowledgementDTO); DateTimeFormatter dateFormate = DateTimeFormatter.ofPattern("dd MMM yyyy"); DateTimeFormatter timeFormate = DateTimeFormatter.ofPattern("h:mma"); diff --git a/pre-registration/pre-registration-core/src/main/java/io/mosip/preregistration/core/util/ValidationUtil.java b/pre-registration/pre-registration-core/src/main/java/io/mosip/preregistration/core/util/ValidationUtil.java index 92a2dffb0c7..027b050048c 100644 --- a/pre-registration/pre-registration-core/src/main/java/io/mosip/preregistration/core/util/ValidationUtil.java +++ b/pre-registration/pre-registration-core/src/main/java/io/mosip/preregistration/core/util/ValidationUtil.java @@ -1,5 +1,9 @@ package io.mosip.preregistration.core.util; +import static io.mosip.preregistration.core.constant.PreRegCoreConstant.LOGGER_ID; +import static io.mosip.preregistration.core.constant.PreRegCoreConstant.LOGGER_IDTYPE; +import static io.mosip.preregistration.core.constant.PreRegCoreConstant.LOGGER_SESSIONID; + import java.text.SimpleDateFormat; import java.time.LocalDate; import java.time.LocalDateTime; @@ -100,7 +104,7 @@ public boolean idValidation(String value, String regex) { private static final String NAME = "name"; public boolean requestValidator(MainRequestDTO mainRequest) { - log.info("sessionId", "idType", "id", + log.info(LOGGER_SESSIONID, LOGGER_IDTYPE, LOGGER_ID, "In requestValidator method of pre-registration core with mainRequest " + mainRequest); if (mainRequest.getId() == null) { throw new InvalidRequestException(ErrorCodes.PRG_CORE_REQ_001.getCode(), @@ -120,8 +124,8 @@ public boolean requestValidator(MainRequestDTO mainRequest) { public boolean requestValidator(Map requestMap, Map requiredRequestMap) { - log.debug("sessionId", "idType", "id", "In requestValidator"); - log.info("sessionId", "idType", "id", "In requestValidator method of pre-registration core with requestMap " + log.debug(LOGGER_SESSIONID, LOGGER_IDTYPE, LOGGER_ID, "In requestValidator"); + log.info(LOGGER_SESSIONID, LOGGER_IDTYPE, LOGGER_ID, "In requestValidator method of pre-registration core with requestMap " + requestMap + " againt requiredRequestMap " + requiredRequestMap); for (String key : requestMap.keySet()) { if (key.equals(RequestCodes.ID) && (requestMap.get(RequestCodes.ID) == null @@ -161,7 +165,7 @@ public boolean requestValidator(Map requestMap, Map requestMap) { - log.info("sessionId", "idType", "id", + log.info(LOGGER_SESSIONID, LOGGER_IDTYPE, LOGGER_ID, "In requstParamValidator method of pre-registration core with requestMap " + requestMap); for (String key : requestMap.keySet()) { if (key.equals(RequestCodes.USER_ID) && (requestMap.get(RequestCodes.USER_ID) == null @@ -260,11 +264,11 @@ public boolean validateDocuments(String langCode, String catCode, String typeCod if (validDocsMap.containsKey(catCode)) { List docTypes = (List) validDocsMap.get(catCode); if (docTypes.contains(typeCode)) { - log.debug("sessionId", "idType", "id", + log.debug(LOGGER_SESSIONID, LOGGER_IDTYPE, LOGGER_ID, "inside validateDocuments inside second if preRegistrationId " + preRegistrationId); return true; } else { - log.debug("sessionId", "idType", "id", + log.debug(LOGGER_SESSIONID, LOGGER_IDTYPE, LOGGER_ID, "inside validateDocuments inside else preRegistrationId " + preRegistrationId); throw new InvalidRequestException(ErrorCodes.PRG_CORE_REQ_017.toString(), ErrorMessages.INVALID_DOC_TYPE_CODE.getMessage() + " " + validDocsMap + " catcode " + catCode @@ -272,7 +276,7 @@ public boolean validateDocuments(String langCode, String catCode, String typeCod null); } } else { - log.debug("sessionId", "idType", "id", + log.debug(LOGGER_SESSIONID, LOGGER_IDTYPE, LOGGER_ID, "inside validateDocuments inside second else preRegistrationId " + preRegistrationId); throw new InvalidRequestException(ErrorCodes.PRG_CORE_REQ_018.toString(), ErrorMessages.INVALID_DOC_CAT_CODE.getMessage() + " " + validDocsMap + " langCode " + langCode, @@ -302,15 +306,15 @@ public Map getDocumentTypeNameByTypeCode(String langCode, String } public static boolean parseDate(String reqDate, String format) { - log.info("sessionId", "idType", "id", "In parseDate method of core validation util"); + log.info(LOGGER_SESSIONID, LOGGER_IDTYPE, LOGGER_ID, "In parseDate method of core validation util"); try { SimpleDateFormat sdf = new SimpleDateFormat(format); sdf.setLenient(false); sdf.parse(reqDate); LocalDate.parse(reqDate); } catch (Exception e) { - log.debug("sessionId", "idType", "id", ExceptionUtils.getStackTrace(e)); - log.error("sessionId", "idType", "id", "In parseDate method of core validation util - " + e.getMessage()); + log.debug(LOGGER_SESSIONID, LOGGER_IDTYPE, LOGGER_ID, ExceptionUtils.getStackTrace(e)); + log.error(LOGGER_SESSIONID, LOGGER_IDTYPE, LOGGER_ID, "In parseDate method of core validation util - " + e.getMessage()); return false; } return true; @@ -335,9 +339,9 @@ public void getAllDocCategoriesAndTypes() { ResponseWrapper> body = response.getBody(); if (body != null) { if (body.getErrors() != null && !body.getErrors().isEmpty()) { - log.debug("sessionId", "idType", "id", + log.debug(LOGGER_SESSIONID, LOGGER_IDTYPE, LOGGER_ID, "inside getAllDocCategories inside else preRegistrationId "); - log.debug("sessionId", "idType", "id", " cat code" + body.getErrors().toString()); + log.debug(LOGGER_SESSIONID, LOGGER_IDTYPE, LOGGER_ID, " cat code" + body.getErrors().toString()); throw new MasterDataNotAvailableException(body.getErrors().get(0).getErrorCode(), body.getErrors().get(0).getMessage()); } @@ -352,16 +356,16 @@ public void getAllDocCategoriesAndTypes() { } while (pageNo != totalPage); log.info("validDocsMap {}", validDocsMap); } catch (RestClientException e) { - log.debug("sessionId", "idType", "id", "inside getAllDocCategories inside catch preRegistrationId "); - log.debug("sessionId", "idType", "id", "---- " + ExceptionUtils.getStackTrace(e)); - log.error("sessionId", "idType", "id", "---- docCatMap " + validDocsMap + ExceptionUtils.getStackTrace(e)); + log.debug(LOGGER_SESSIONID, LOGGER_IDTYPE, LOGGER_ID, "inside getAllDocCategories inside catch preRegistrationId "); + log.debug(LOGGER_SESSIONID, LOGGER_IDTYPE, LOGGER_ID, "---- " + ExceptionUtils.getStackTrace(e)); + log.error(LOGGER_SESSIONID, LOGGER_IDTYPE, LOGGER_ID, "---- docCatMap " + validDocsMap + ExceptionUtils.getStackTrace(e)); throw new MasterDataNotAvailableException(ErrorCodes.PRG_CORE_REQ_022.toString(), ErrorMessages.MASTERDATA_SERVICE_CALL_FAIL.toString(), e.getCause()); } } public Map prepareRequestMap(MainRequestDTO requestDto) { - log.info("sessionId", "idType", "id", "In prepareRequestMap method of Login Service Util"); + log.info(LOGGER_SESSIONID, LOGGER_IDTYPE, LOGGER_ID, "In prepareRequestMap method of Login Service Util"); Map requestMap = new HashMap<>(); requestMap.put("id", requestDto.getId()); requestMap.put("version", requestDto.getVersion()); diff --git a/pre-registration/pre-registration-datasync-service/src/main/java/io/mosip/preregistration/datasync/config/ResponseBodyAdviceConfig.java b/pre-registration/pre-registration-datasync-service/src/main/java/io/mosip/preregistration/datasync/config/ResponseBodyAdviceConfig.java index 0a6f04fc201..e21b02b2aed 100644 --- a/pre-registration/pre-registration-datasync-service/src/main/java/io/mosip/preregistration/datasync/config/ResponseBodyAdviceConfig.java +++ b/pre-registration/pre-registration-datasync-service/src/main/java/io/mosip/preregistration/datasync/config/ResponseBodyAdviceConfig.java @@ -14,9 +14,7 @@ import com.fasterxml.jackson.databind.ObjectMapper; import io.mosip.kernel.core.util.DateUtils; -import io.mosip.kernel.signature.dto.SignResponseDto; import io.mosip.preregistration.core.common.dto.MainResponseDTO; -import io.mosip.preregistration.core.exception.PreRegistrationException; import io.mosip.preregistration.core.util.ResponseFilter; import io.mosip.preregistration.datasync.errorcodes.ErrorCodes; import io.mosip.preregistration.datasync.errorcodes.ErrorMessages; diff --git a/pre-registration/pre-registration-datasync-service/src/main/java/io/mosip/preregistration/datasync/controller/DataSyncController.java b/pre-registration/pre-registration-datasync-service/src/main/java/io/mosip/preregistration/datasync/controller/DataSyncController.java index 029af9f81d2..e01347304ce 100644 --- a/pre-registration/pre-registration-datasync-service/src/main/java/io/mosip/preregistration/datasync/controller/DataSyncController.java +++ b/pre-registration/pre-registration-datasync-service/src/main/java/io/mosip/preregistration/datasync/controller/DataSyncController.java @@ -2,6 +2,10 @@ import jakarta.validation.constraints.NotNull; +import static io.mosip.preregistration.core.constant.PreRegCoreConstant.LOGGER_ID; +import static io.mosip.preregistration.core.constant.PreRegCoreConstant.LOGGER_IDTYPE; +import static io.mosip.preregistration.core.constant.PreRegCoreConstant.LOGGER_SESSIONID; + import org.springframework.beans.factory.annotation.Autowired; import org.springframework.http.HttpStatus; import org.springframework.http.MediaType; @@ -69,7 +73,7 @@ public class DataSyncController { @ApiResponse(responseCode = "404", description = "Not Found", content = @Content(schema = @Schema(hidden = true))) }) public ResponseEntity> retrieveAllPreRegids( @RequestBody(required = true) MainRequestDTO dataSyncDto) { - log.info("sessionId", "idType", "id", + log.info(LOGGER_SESSIONID, LOGGER_IDTYPE, LOGGER_ID, "In Datasync controller for retreiving all the pre-registrations for object " + dataSyncDto); return ResponseEntity.status(HttpStatus.OK).body(dataSyncService.retrieveAllPreRegIds(dataSyncDto)); } @@ -93,7 +97,7 @@ public ResponseEntity> retrieveAllPreRegi @ApiResponse(responseCode = "404", description = "Not Found", content = @Content(schema = @Schema(hidden = true))) }) public ResponseEntity> retrieveAllAppointmentsSyncV2( @RequestBody(required = true) MainRequestDTO dataSyncDto) { - log.info("sessionId", "idType", "id", + log.info(LOGGER_SESSIONID, LOGGER_IDTYPE, LOGGER_ID, "In Datasync controller for retreiving all the appointments for " + dataSyncDto); return ResponseEntity.status(HttpStatus.OK).body(dataSyncService.retrieveAllAppointmentsSyncV2(dataSyncDto)); } @@ -116,7 +120,7 @@ public ResponseEntity> retrieveAllAppointmentsS @ApiResponse(responseCode = "404", description = "Not Found", content = @Content(schema = @Schema(hidden = true))) }) public ResponseEntity> retrievePreRegistrations( @PathVariable(required = true, value = "preRegistrationId") String preRegistrationId) { - log.info("sessionId", "idType", "id", + log.info(LOGGER_SESSIONID, LOGGER_IDTYPE, LOGGER_ID, "In Datasync controller for retreiving pre-registration data with preRegId " + preRegistrationId); return ResponseEntity.status(HttpStatus.OK).body(dataSyncService.getPreRegistrationData(preRegistrationId)); } @@ -135,7 +139,7 @@ public ResponseEntity> retrievePreRegistration public ResponseEntity> retrievePreRegistrations( @PathVariable(required = true, value = "preRegistrationId") String preRegistrationId, @PathVariable(required = true, value = "machineId") String machineId) { - log.info("sessionId", "idType", "id", + log.info(LOGGER_SESSIONID, LOGGER_IDTYPE, LOGGER_ID, "In Datasync controller for retreiving pre-registration data with preRegId and machineId " + preRegistrationId + " " + machineId); return ResponseEntity.status(HttpStatus.OK) @@ -161,7 +165,7 @@ public ResponseEntity> retrievePreRegistration @ApiResponse(responseCode = "404", description = "Not Found", content = @Content(schema = @Schema(hidden = true))) }) public ResponseEntity> storeConsumedPreRegistrationsIds( @NotNull @RequestBody(required = true) MainRequestDTO consumedData) { - log.info("sessionId", "idType", "id", + log.info(LOGGER_SESSIONID, LOGGER_IDTYPE, LOGGER_ID, "In Datasync controller for storing the consumed preregistration with object" + consumedData); return ResponseEntity.status(HttpStatus.OK).body(dataSyncService.storeConsumedPreRegistrations(consumedData)); } diff --git a/pre-registration/pre-registration-datasync-service/src/main/java/io/mosip/preregistration/datasync/entity/DemographicEntityConsumed.java b/pre-registration/pre-registration-datasync-service/src/main/java/io/mosip/preregistration/datasync/entity/DemographicEntityConsumed.java index 333131b9ca7..73e6a51339a 100644 --- a/pre-registration/pre-registration-datasync-service/src/main/java/io/mosip/preregistration/datasync/entity/DemographicEntityConsumed.java +++ b/pre-registration/pre-registration-datasync-service/src/main/java/io/mosip/preregistration/datasync/entity/DemographicEntityConsumed.java @@ -6,17 +6,12 @@ import java.io.Serializable; import java.time.LocalDateTime; -import java.util.List; import org.springframework.stereotype.Component; -import io.mosip.preregistration.core.common.entity.DocumentEntity; -import jakarta.persistence.CascadeType; import jakarta.persistence.Column; import jakarta.persistence.Entity; -import jakarta.persistence.FetchType; import jakarta.persistence.Id; -import jakarta.persistence.OneToMany; import jakarta.persistence.Table; import lombok.NoArgsConstructor; import lombok.Setter; diff --git a/pre-registration/pre-registration-datasync-service/src/main/java/io/mosip/preregistration/datasync/service/DataSyncService.java b/pre-registration/pre-registration-datasync-service/src/main/java/io/mosip/preregistration/datasync/service/DataSyncService.java index 9b9a64f80a6..c666b35ed2c 100644 --- a/pre-registration/pre-registration-datasync-service/src/main/java/io/mosip/preregistration/datasync/service/DataSyncService.java +++ b/pre-registration/pre-registration-datasync-service/src/main/java/io/mosip/preregistration/datasync/service/DataSyncService.java @@ -1,17 +1,18 @@ package io.mosip.preregistration.datasync.service; +import static io.mosip.preregistration.core.constant.PreRegCoreConstant.LOGGER_ID; +import static io.mosip.preregistration.core.constant.PreRegCoreConstant.LOGGER_IDTYPE; +import static io.mosip.preregistration.core.constant.PreRegCoreConstant.LOGGER_SESSIONID; + import java.time.LocalDate; import java.time.LocalTime; import java.time.format.DateTimeFormatter; -import java.time.format.DateTimeParseException; import java.util.ArrayList; import java.util.HashMap; import java.util.List; import java.util.Map; import java.util.Map.Entry; -import jakarta.annotation.PostConstruct; - import org.apache.commons.lang3.exception.ExceptionUtils; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Value; @@ -40,10 +41,10 @@ import io.mosip.preregistration.core.config.LoggerConfiguration; import io.mosip.preregistration.core.util.AuditLogUtil; import io.mosip.preregistration.core.util.ValidationUtil; -import io.mosip.preregistration.datasync.dto.ApplicationDetailResponseDTO; import io.mosip.preregistration.datasync.dto.ApplicationDTO; -import io.mosip.preregistration.datasync.dto.ApplicationsDTO; +import io.mosip.preregistration.datasync.dto.ApplicationDetailResponseDTO; import io.mosip.preregistration.datasync.dto.ApplicationInfoMetadataDTO; +import io.mosip.preregistration.datasync.dto.ApplicationsDTO; import io.mosip.preregistration.datasync.dto.DataSyncRequestDTO; import io.mosip.preregistration.datasync.dto.PreRegArchiveDTO; import io.mosip.preregistration.datasync.dto.PreRegistrationIdsDTO; @@ -51,6 +52,7 @@ import io.mosip.preregistration.datasync.dto.ReverseDatasyncReponseDTO; import io.mosip.preregistration.datasync.exception.util.DataSyncExceptionCatcher; import io.mosip.preregistration.datasync.service.util.DataSyncServiceUtil; +import jakarta.annotation.PostConstruct; /** * This class provides different service to perform operation for datasync @@ -81,13 +83,13 @@ public class DataSyncService { */ @Autowired AuditLogUtil auditLogUtil; - + /** * Autowired reference for {@link #AnonymousProfileUtil} */ @Autowired AnonymousProfileUtil anonymousProfileUtil; - + /** * This method acts as a post constructor to initialize the required request * parameters. @@ -144,7 +146,7 @@ public MainResponseDTO retrieveAllPreRegIds( MainRequestDTO dataSyncRequest) { PreRegistrationIdsDTO preRegistrationIdsDTO = null; MainResponseDTO responseDto = new MainResponseDTO<>(); - log.info("sessionId", "idType", "id", "In retrieveAllPreRegIds method of datasync service "); + log.info(LOGGER_SESSIONID, LOGGER_IDTYPE, LOGGER_ID, "In retrieveAllPreRegIds method of datasync service "); boolean isRetrieveAllSuccess = false; responseDto.setId(fetchAllId); responseDto.setVersion(version); @@ -171,8 +173,8 @@ public MainResponseDTO retrieveAllPreRegIds( } catch ( Exception ex) { - log.debug("sessionId", "idType", "id", ExceptionUtils.getStackTrace(ex)); - log.error("sessionId", "idType", "id", + log.debug(LOGGER_SESSIONID, LOGGER_IDTYPE, LOGGER_ID, ExceptionUtils.getStackTrace(ex)); + log.error(LOGGER_SESSIONID, LOGGER_IDTYPE, LOGGER_ID, "In retrieveAllPreRegIds method of datasync service - " + ex.getMessage()); new DataSyncExceptionCatcher().handle(ex, responseDto); } finally { @@ -190,7 +192,7 @@ public MainResponseDTO retrieveAllPreRegIds( } return responseDto; } - + /** * This method is use to retrieve all appointments for a registration center id, * booked between a from date and to date @@ -202,7 +204,8 @@ public MainResponseDTO retrieveAllAppointmentsSyncV2( MainRequestDTO dataSyncRequest) { MainResponseDTO responseDto = new MainResponseDTO<>(); - log.info("sessionId", "idType", "id", "In retrieveAllAppointmentsSyncV2 method of datasync service "); + log.info(LOGGER_SESSIONID, LOGGER_IDTYPE, LOGGER_ID, + "In retrieveAllAppointmentsSyncV2 method of datasync service "); boolean isRetrieveAllSuccess = false; responseDto.setId(fetchAllId); responseDto.setVersion(version); @@ -215,10 +218,9 @@ public MainResponseDTO retrieveAllAppointmentsSyncV2( if (serviceUtil.isNull(dataSyncRequestDTO.getToDate())) { dataSyncRequestDTO.setToDate(dataSyncRequestDTO.getFromDate()); } - List applicationsList = new ArrayList(); + List applicationsList = new ArrayList(); List applicationDetailResponseList = serviceUtil - .getAllBookedApplicationIds(dataSyncRequestDTO.getFromDate(), - dataSyncRequestDTO.getToDate(), + .getAllBookedApplicationIds(dataSyncRequestDTO.getFromDate(), dataSyncRequestDTO.getToDate(), dataSyncRequestDTO.getRegistrationCenterId()); for (ApplicationDetailResponseDTO applicationDetails : applicationDetailResponseList) { ApplicationDTO application = new ApplicationDTO(); @@ -237,8 +239,8 @@ public MainResponseDTO retrieveAllAppointmentsSyncV2( } catch ( Exception ex) { - log.debug("sessionId", "idType", "id", ExceptionUtils.getStackTrace(ex)); - log.error("sessionId", "idType", "id", + log.debug(LOGGER_SESSIONID, LOGGER_IDTYPE, LOGGER_ID, ExceptionUtils.getStackTrace(ex)); + log.error(LOGGER_SESSIONID, LOGGER_IDTYPE, LOGGER_ID, "In retrieveAllAppointmentsSyncV2 method of datasync service - " + ex.getMessage()); new DataSyncExceptionCatcher().handle(ex, responseDto); } finally { @@ -280,11 +282,12 @@ private Map getIdsWithTime(BookingDataByRegIdDto preRegIdsDTO) { private String getUTCTimeStamp(Map value) { String timestamp = null; for (Entry v : value.entrySet()) { - timestamp = v.getKey().atTime(v.getValue().getFromTime()).format(DateTimeFormatter.ofPattern(UTC_DATETIME_PATTERN)); + timestamp = v.getKey().atTime(v.getValue().getFromTime()) + .format(DateTimeFormatter.ofPattern(UTC_DATETIME_PATTERN)); } return timestamp; } - + /** * Assuming one pre-reg id will have one appointTime and single time slot * @@ -298,7 +301,7 @@ private String getUTCTimeStamp(String appointmentDt, String fromTime) { LocalTime fromLocalTime = LocalTime.parse(fromTime); timestamp = appDate.atTime(fromLocalTime).format(DateTimeFormatter.ofPattern(UTC_DATETIME_PATTERN)); } catch (Exception ex) { - log.error("sessionId", "idType", "id", ExceptionUtils.getStackTrace(ex)); + log.error(LOGGER_SESSIONID, LOGGER_IDTYPE, LOGGER_ID, ExceptionUtils.getStackTrace(ex)); return null; } return timestamp; @@ -313,7 +316,7 @@ private String getUTCTimeStamp(String appointmentDt, String fromTime) { public MainResponseDTO getPreRegistrationData(String preId) { MainResponseDTO responseDto = new MainResponseDTO<>(); PreRegArchiveDTO preRegArchiveDTO = null; - log.info("sessionId", "idType", "id", "In getPreRegistrationData method of datasync service "); + log.info(LOGGER_SESSIONID, LOGGER_IDTYPE, LOGGER_ID, "In getPreRegistrationData method of datasync service "); boolean isRetrieveSuccess = false; responseDto.setId(fetchId); responseDto.setVersion(version); @@ -327,8 +330,8 @@ public MainResponseDTO getPreRegistrationData(String preId) { responseDto.setResponse(preRegArchiveDTO); isRetrieveSuccess = true; } catch (Exception ex) { - log.debug("sessionId", "idType", "id", ExceptionUtils.getStackTrace(ex)); - log.error("sessionId", "idType", "id", + log.debug(LOGGER_SESSIONID, LOGGER_IDTYPE, LOGGER_ID, ExceptionUtils.getStackTrace(ex)); + log.error(LOGGER_SESSIONID, LOGGER_IDTYPE, LOGGER_ID, "In getPreRegistrationData method of datasync service - " + ex.getMessage()); new DataSyncExceptionCatcher().handle(ex, responseDto); } finally { @@ -355,7 +358,7 @@ public MainResponseDTO getPreRegistrationData(String preId) { public MainResponseDTO fetchPreRegistrationData(String preId, String machineId) { MainResponseDTO responseDto = new MainResponseDTO<>(); PreRegArchiveDTO preRegArchiveDTO = null; - log.info("sessionId", "idType", "id", "In fetchPreRegistrationData method of datasync service "); + log.info(LOGGER_SESSIONID, LOGGER_IDTYPE, LOGGER_ID, "In fetchPreRegistrationData method of datasync service "); boolean isRetrieveSuccess = false; responseDto.setId(fetchId); responseDto.setVersion(version); @@ -373,7 +376,8 @@ public MainResponseDTO fetchPreRegistrationData(String preId, responseDto.setResponsetime(serviceUtil.getCurrentResponseTime()); responseDto.setResponse(preRegArchiveDTO); isRetrieveSuccess = true; - // insert the anonymous profile only if the appointment is being prefetched for the first time + // insert the anonymous profile only if the appointment is being prefetched for + // the first time if (!preRegistrationDTO.getStatusCode().equals(StatusCodes.BOOKED.getCode()) && !preRegistrationDTO.getStatusCode().equals(StatusCodes.PREFETCHED.getCode()) && !preRegistrationDTO.getStatusCode().equals(StatusCodes.EXPIRED.getCode()) @@ -385,10 +389,11 @@ public MainResponseDTO fetchPreRegistrationData(String preId, serviceUtil.updateApplicationStatusToPreFectched(preId); } } catch (AnonymousProfileException apex) { - log.debug("sessionId", "idType", "id" + ExceptionUtils.getStackTrace(apex)); - log.error("Unable to save AnonymousProfile in getPreRegistrationData method of datasync service -" + apex.getMessage()); + log.debug(LOGGER_SESSIONID, LOGGER_IDTYPE, "id" + ExceptionUtils.getStackTrace(apex)); + log.error("Unable to save AnonymousProfile in getPreRegistrationData method of datasync service -" + + apex.getMessage()); } catch (Exception ex) { - log.debug("sessionId", "idType", "id" + ExceptionUtils.getStackTrace(ex)); + log.debug(LOGGER_SESSIONID, LOGGER_IDTYPE, "id" + ExceptionUtils.getStackTrace(ex)); log.error("In getPreRegistrationData method of datasync service -" + ex.getMessage()); new DataSyncExceptionCatcher().handle(ex, responseDto); } finally { @@ -417,7 +422,8 @@ public MainResponseDTO storeConsumedPreRegistrations( MainRequestDTO reverseDataSyncRequest) { MainResponseDTO responseDto = new MainResponseDTO<>(); ReverseDatasyncReponseDTO reverseDatasyncReponse = null; - log.info("sessionId", "idType", "id", "In storeConsumedPreRegistrations method of datasync service "); + log.info(LOGGER_SESSIONID, LOGGER_IDTYPE, LOGGER_ID, + "In storeConsumedPreRegistrations method of datasync service "); boolean isSaveSuccess = false; responseDto.setId(storeId); responseDto.setVersion(version); @@ -436,8 +442,8 @@ public MainResponseDTO storeConsumedPreRegistrations( } isSaveSuccess = true; } catch (Exception ex) { - log.debug("sessionId", "idType", "id", ExceptionUtils.getStackTrace(ex)); - log.error("sessionId", "idType", "id", + log.debug(LOGGER_SESSIONID, LOGGER_IDTYPE, LOGGER_ID, ExceptionUtils.getStackTrace(ex)); + log.error(LOGGER_SESSIONID, LOGGER_IDTYPE, LOGGER_ID, "In storeConsumedPreRegistrations method of datasync service - " + ex.getMessage()); new DataSyncExceptionCatcher().handle(ex, responseDto); diff --git a/pre-registration/pre-registration-datasync-service/src/main/java/io/mosip/preregistration/datasync/service/util/DataSyncServiceUtil.java b/pre-registration/pre-registration-datasync-service/src/main/java/io/mosip/preregistration/datasync/service/util/DataSyncServiceUtil.java index 018a080f56e..1694e196481 100644 --- a/pre-registration/pre-registration-datasync-service/src/main/java/io/mosip/preregistration/datasync/service/util/DataSyncServiceUtil.java +++ b/pre-registration/pre-registration-datasync-service/src/main/java/io/mosip/preregistration/datasync/service/util/DataSyncServiceUtil.java @@ -1,6 +1,10 @@ package io.mosip.preregistration.datasync.service.util; +import static io.mosip.preregistration.core.constant.PreRegCoreConstant.LOGGER_ID; +import static io.mosip.preregistration.core.constant.PreRegCoreConstant.LOGGER_IDTYPE; +import static io.mosip.preregistration.core.constant.PreRegCoreConstant.LOGGER_SESSIONID; + import java.io.ByteArrayOutputStream; import java.io.IOException; import java.net.URI; @@ -17,8 +21,6 @@ import java.util.zip.ZipEntry; import java.util.zip.ZipOutputStream; -import jakarta.annotation.PostConstruct; - import org.apache.commons.lang3.exception.ExceptionUtils; import org.json.simple.JSONObject; import org.json.simple.parser.JSONParser; @@ -98,6 +100,7 @@ import io.mosip.preregistration.datasync.repository.DemographicConsumedRepository; import io.mosip.preregistration.datasync.repository.InterfaceDataSyncRepo; import io.mosip.preregistration.datasync.repository.ProcessedDataSyncRepo; +import jakarta.annotation.PostConstruct; /** * This class is used to define Error codes for data sync and reverse data sync @@ -235,7 +238,7 @@ public void init() { * @return true or false */ public boolean validateDataSyncRequest(DataSyncRequestDTO dataSyncRequest, MainResponseDTO mainResponseDTO) { - log.info("sessionId", "idType", "id", "In validateDataSyncRequest method of datasync service util"); + log.info(LOGGER_SESSIONID, LOGGER_IDTYPE, LOGGER_ID, "In validateDataSyncRequest method of datasync service util"); String regId = dataSyncRequest.getRegistrationCenterId(); String fromDate = dataSyncRequest.getFromDate(); String format = "yyyy-MM-dd"; @@ -273,7 +276,7 @@ public boolean validateDataSyncRequest(DataSyncRequestDTO dataSyncRequest, MainR */ public boolean validateReverseDataSyncRequest(ReverseDataSyncRequestDTO reverseDataSyncRequest, MainResponseDTO mainResponseDTO) { - log.info("sessionId", "idType", "id", + log.info(LOGGER_SESSIONID, LOGGER_IDTYPE, LOGGER_ID, "In validateReverseDataSyncRequest sync preregids" + reverseDataSyncRequest.getPreRegistrationIds()); List preRegIdsList = reverseDataSyncRequest.getPreRegistrationIds(); if (preRegIdsList == null || isNull(preRegIdsList)) { @@ -294,7 +297,7 @@ public boolean validateReverseDataSyncRequest(ReverseDataSyncRequestDTO reverseD */ public BookingDataByRegIdDto getBookedPreIdsByDateAndRegCenterIdRestService(String fromDate, String toDate, String regCenterId) { - log.info("sessionId", "idType", "id", "In callGetPreIdsRestService method of datasync service util"); + log.info(LOGGER_SESSIONID, LOGGER_IDTYPE, LOGGER_ID, "In callGetPreIdsRestService method of datasync service util"); BookingDataByRegIdDto preRegIdsByRegCenterIdResponseDTO = null; try { Map params = new HashMap<>(); @@ -309,7 +312,7 @@ public BookingDataByRegIdDto getBookedPreIdsByDateAndRegCenterIdRestService(Stri headers.setContentType(MediaType.APPLICATION_JSON); HttpEntity> httpEntity = new HttpEntity<>(headers); String uriBuilder = builder.build().encode(StandardCharsets.UTF_8).toUriString(); - log.info("sessionId", "idType", "id", "In callGetPreIdsRestService method URL- " + uriBuilder); + log.info(LOGGER_SESSIONID, LOGGER_IDTYPE, LOGGER_ID, "In callGetPreIdsRestService method URL- " + uriBuilder); ResponseEntity> respEntity = selfTokenRestTemplate.exchange(uriBuilder, HttpMethod.GET, httpEntity, new ParameterizedTypeReference>() { @@ -329,8 +332,8 @@ public BookingDataByRegIdDto getBookedPreIdsByDateAndRegCenterIdRestService(Stri } } } catch (RestClientException ex) { - log.debug("sessionId", "idType", "id", ExceptionUtils.getStackTrace(ex)); - log.error("sessionId", "idType", "id", + log.debug(LOGGER_SESSIONID, LOGGER_IDTYPE, LOGGER_ID, ExceptionUtils.getStackTrace(ex)); + log.error(LOGGER_SESSIONID, LOGGER_IDTYPE, LOGGER_ID, "In callGetPreIdsRestService method of datasync service util - " + ex.getMessage()); throw new RecordNotFoundForDateRange(ErrorCodes.PRG_DATA_SYNC_016.getCode(), ErrorMessages.BOOKING_NOT_FOUND.getMessage(), null); @@ -348,7 +351,7 @@ public BookingDataByRegIdDto getBookedPreIdsByDateAndRegCenterIdRestService(Stri * @return List */ public List getAllBookedApplicationIds(String fromDate,String toDate, String regCenterId) { - log.info("sessionId", "idType", "id", "In getAllBookedApplicationIds method of datasync service util"); + log.info(LOGGER_SESSIONID, LOGGER_IDTYPE, LOGGER_ID, "In getAllBookedApplicationIds method of datasync service util"); List applicationDetailResponseList = new ArrayList(); try { UriComponentsBuilder builder = UriComponentsBuilder @@ -366,7 +369,7 @@ public List getAllBookedApplicationIds(String from headers.setContentType(MediaType.APPLICATION_JSON); HttpEntity>> httpEntity = new HttpEntity<>(headers); String uriBuilder = builderFull.build().encode(StandardCharsets.UTF_8).toUriString(); - log.info("sessionId", "idType", "id", "In getAllBookedApplicationIds method URL- " + uriBuilder); + log.info(LOGGER_SESSIONID, LOGGER_IDTYPE, LOGGER_ID, "In getAllBookedApplicationIds method URL- " + uriBuilder); ResponseEntity>> respEntity = selfTokenRestTemplate .exchange(uriBuilder, HttpMethod.GET, httpEntity, new ParameterizedTypeReference>>() { @@ -385,8 +388,8 @@ public List getAllBookedApplicationIds(String from } } } catch (RestClientException ex) { - log.debug("sessionId", "idType", "id", ExceptionUtils.getStackTrace(ex)); - log.error("sessionId", "idType", "id", + log.debug(LOGGER_SESSIONID, LOGGER_IDTYPE, LOGGER_ID, ExceptionUtils.getStackTrace(ex)); + log.error(LOGGER_SESSIONID, LOGGER_IDTYPE, LOGGER_ID, "In getAllBookedApplicationIds method of datasync service util - " + ex.getMessage()); throw new RecordNotFoundForDateRange(ErrorCodes.PRG_DATA_SYNC_016.getCode(), ErrorMessages.BOOKING_NOT_FOUND.getMessage(), null); @@ -403,7 +406,7 @@ public List getAllBookedApplicationIds(String from * @return responsestatusDto */ public DocumentsMetaData getDocDetails(String preId) { - log.info("sessionId", "idType", "id", "In callGetDocDetailsRestService method of datasync service util"); + log.info(LOGGER_SESSIONID, LOGGER_IDTYPE, LOGGER_ID, "In callGetDocDetailsRestService method of datasync service util"); DocumentsMetaData responsestatusDto = new DocumentsMetaData(); try { Map params = new HashMap<>(); @@ -415,14 +418,14 @@ public DocumentsMetaData getDocDetails(String preId) { HttpEntity> httpEntity = new HttpEntity<>(headers); String uriBuilder = builder.build().encode().toUriString(); uriBuilder += "{preRegistrationId}"; - log.info("sessionId", "idType", "id", "In callGetDocRestService method URL- " + uriBuilder); + log.info(LOGGER_SESSIONID, LOGGER_IDTYPE, LOGGER_ID, "In callGetDocRestService method URL- " + uriBuilder); ResponseEntity> respEntity = selfTokenRestTemplate.exchange(uriBuilder, HttpMethod.GET, httpEntity, new ParameterizedTypeReference>() { }, params); MainResponseDTO body = respEntity.getBody(); if (body != null) { if (body.getErrors() != null) { - log.info("sessionId", "idType", "id", + log.info(LOGGER_SESSIONID, LOGGER_IDTYPE, LOGGER_ID, "In callGetDocRestService method of datasync service util - Document not found for the pre_registration_id"); } else { Object obj = body.getResponse(); @@ -430,8 +433,8 @@ public DocumentsMetaData getDocDetails(String preId) { } } } catch (RestClientException ex) { - log.debug("sessionId", "idType", "id", ExceptionUtils.getStackTrace(ex)); - log.error("sessionId", "idType", "id", + log.debug(LOGGER_SESSIONID, LOGGER_IDTYPE, LOGGER_ID, ExceptionUtils.getStackTrace(ex)); + log.error(LOGGER_SESSIONID, LOGGER_IDTYPE, LOGGER_ID, "In callGetDocRestService method of datasync service util - " + ex.getMessage()); throw new DocumentGetDetailsException(ErrorCodes.PRG_DATA_SYNC_006.getCode(), @@ -449,7 +452,7 @@ public DocumentsMetaData getDocDetails(String preId) { * @return responsestatusDto */ public DocumentDTO getDocBytesDetails(String docId, String preId) { - log.info("sessionId", "idType", "id", "In callGetBytesDocRestService method of datasync service util"); + log.info(LOGGER_SESSIONID, LOGGER_IDTYPE, LOGGER_ID, "In callGetBytesDocRestService method of datasync service util"); DocumentDTO responsestatusDto = new DocumentDTO(); try { Map params = new HashMap<>(); @@ -463,14 +466,14 @@ public DocumentDTO getDocBytesDetails(String docId, String preId) { headers.setContentType(MediaType.APPLICATION_JSON); HttpEntity> httpEntity = new HttpEntity<>(headers); String uriBuilder = builder.build().encode().toUriString(); - log.info("sessionId", "idType", "id", "In callGetBytesDocRestService method URL- " + uriBuilder); + log.info(LOGGER_SESSIONID, LOGGER_IDTYPE, LOGGER_ID, "In callGetBytesDocRestService method URL- " + uriBuilder); ResponseEntity> respEntity = selfTokenRestTemplate.exchange(uriBuilder, HttpMethod.GET, httpEntity, new ParameterizedTypeReference>() { }, params); MainResponseDTO body = respEntity.getBody(); if (body != null) { if (body.getErrors() != null) { - log.info("sessionId", "idType", "id", + log.info(LOGGER_SESSIONID, LOGGER_IDTYPE, LOGGER_ID, "In callGetBytesDocRestService method of datasync service util - Document not found for the documentId"); } else { Object obj = body.getResponse(); @@ -478,8 +481,8 @@ public DocumentDTO getDocBytesDetails(String docId, String preId) { } } } catch (RestClientException ex) { - log.debug("sessionId", "idType", "id", ExceptionUtils.getStackTrace(ex)); - log.error("sessionId", "idType", "id", + log.debug(LOGGER_SESSIONID, LOGGER_IDTYPE, LOGGER_ID, ExceptionUtils.getStackTrace(ex)); + log.error(LOGGER_SESSIONID, LOGGER_IDTYPE, LOGGER_ID, "In callGetBytesDocRestService method of datasync service util - " + ex.getMessage()); throw new DocumentGetDetailsException(ErrorCodes.PRG_DATA_SYNC_006.getCode(), @@ -496,7 +499,7 @@ public DocumentDTO getDocBytesDetails(String docId, String preId) { * @return responsestatusDto */ public DemographicResponseDTO getPreRegistrationData(String preId) { - log.info("sessionId", "idType", "id", "In callGetPreRegInfoRestService method of datasync service util"); + log.info(LOGGER_SESSIONID, LOGGER_IDTYPE, LOGGER_ID, "In callGetPreRegInfoRestService method of datasync service util"); DemographicResponseDTO responsestatusDto = new DemographicResponseDTO(); try { Map params = new HashMap<>(); @@ -508,7 +511,7 @@ public DemographicResponseDTO getPreRegistrationData(String preId) { HttpEntity> httpEntity = new HttpEntity<>(headers); String uriBuilder = builder.build().encode().toUriString(); uriBuilder += "{preRegistrationId}"; - log.info("sessionId", "idType", "id", "In callGetPreRegInfoRestService method URL- " + uriBuilder); + log.info(LOGGER_SESSIONID, LOGGER_IDTYPE, LOGGER_ID, "In callGetPreRegInfoRestService method URL- " + uriBuilder); ResponseEntity> respEntity = selfTokenRestTemplate.exchange(uriBuilder, HttpMethod.GET, httpEntity, new ParameterizedTypeReference>() { @@ -527,8 +530,8 @@ public DemographicResponseDTO getPreRegistrationData(String preId) { } } } catch (RestClientException ex) { - log.debug("sessionId", "idType", "id", ExceptionUtils.getStackTrace(ex)); - log.error("sessionId", "idType", "id", + log.debug(LOGGER_SESSIONID, LOGGER_IDTYPE, LOGGER_ID, ExceptionUtils.getStackTrace(ex)); + log.error(LOGGER_SESSIONID, LOGGER_IDTYPE, LOGGER_ID, "In callGetPreRegInfoRestService method of datasync service util - " + ex.getMessage()); throw new DemographicGetDetailsException(ErrorCodes.PRG_DATA_SYNC_007.getCode(), @@ -546,7 +549,7 @@ public DemographicResponseDTO getPreRegistrationData(String preId) { * */ public BookingRegistrationDTO getAppointmentDetails(String preId) { - log.info("sessionId", "idType", "id", + log.info(LOGGER_SESSIONID, LOGGER_IDTYPE, LOGGER_ID, "In callGetAppointmentDetailsRestService method of datasync service util"); BookingRegistrationDTO bookingRegistrationDTO = null; try { @@ -558,7 +561,7 @@ public BookingRegistrationDTO getAppointmentDetails(String preId) { HttpEntity> httpEntity = new HttpEntity<>(headers); String uriBuilder = builder.build().encode().toUriString(); uriBuilder += "{preRegistrationId}"; - log.info("sessionId", "idType", "id", "In callGetAppointmentDetailsRestService method URL- " + uriBuilder); + log.info(LOGGER_SESSIONID, LOGGER_IDTYPE, LOGGER_ID, "In callGetAppointmentDetailsRestService method URL- " + uriBuilder); ResponseEntity> respEntity = selfTokenRestTemplate.exchange(uriBuilder, HttpMethod.GET, httpEntity, new ParameterizedTypeReference>() { @@ -581,8 +584,8 @@ public BookingRegistrationDTO getAppointmentDetails(String preId) { } } } catch (RestClientException ex) { - log.debug("sessionId", "idType", "id", ExceptionUtils.getStackTrace(ex)); - log.error("sessionId", "idType", "id", + log.debug(LOGGER_SESSIONID, LOGGER_IDTYPE, LOGGER_ID, ExceptionUtils.getStackTrace(ex)); + log.error(LOGGER_SESSIONID, LOGGER_IDTYPE, LOGGER_ID, "In callGetAppointmentDetailsRestService method of datasync service util - " + ex.getMessage()); throw new DemographicGetDetailsException(ErrorCodes.PRG_DATA_SYNC_016.getCode(), ErrorMessages.BOOKING_NOT_FOUND.getMessage(), null); @@ -600,7 +603,7 @@ public BookingRegistrationDTO getAppointmentDetails(String preId) { */ public PreRegArchiveDTO preparePreRegArchiveDTO(DemographicResponseDTO preRegistrationDTO, BookingRegistrationDTO bookingRegistrationDTO) { - log.info("sessionId", "idType", "id", "In preparePreRegArchiveDTO method of datasync service util"); + log.info(LOGGER_SESSIONID, LOGGER_IDTYPE, LOGGER_ID, "In preparePreRegArchiveDTO method of datasync service util"); PreRegArchiveDTO preRegArchiveDTO = new PreRegArchiveDTO(); preRegArchiveDTO.setPreRegistrationId(preRegistrationDTO.getPreRegistrationId()); if (!Objects.isNull(bookingRegistrationDTO)) { @@ -622,7 +625,7 @@ public PreRegArchiveDTO preparePreRegArchiveDTO(DemographicResponseDTO preRegist */ public JSONObject getIdJSONValue(String demographicData) throws ParseException { - log.info("sessionId", "idType", "id", + log.info(LOGGER_SESSIONID, LOGGER_IDTYPE, LOGGER_ID, "In getIdJSONValue method of datasync service util to get getIdJSONValue "); JSONParser jsonParser = new JSONParser(); JSONObject jsonObj = (JSONObject) jsonParser.parse(demographicData); @@ -640,7 +643,7 @@ public JSONObject getIdJSONValue(String demographicData) throws ParseException { */ public PreRegArchiveDTO archivingFiles(DemographicResponseDTO preRegistrationDTO, BookingRegistrationDTO bookingRegistrationDTO, DocumentsMetaData documentEntityList, String machineId) { - log.info("sessionId", "idType", "id", "In archivingFiles method of datasync service util"); + log.info(LOGGER_SESSIONID, LOGGER_IDTYPE, LOGGER_ID, "In archivingFiles method of datasync service util"); PreRegArchiveDTO preRegArchiveDTO = null; try { preRegArchiveDTO = preparePreRegArchiveDTO(preRegistrationDTO, bookingRegistrationDTO); @@ -651,7 +654,7 @@ public PreRegArchiveDTO archivingFiles(DemographicResponseDTO preRegistrationDTO .jsonStringToJavaMap(JsonUtils.javaObjectToJsonString(identityJson)); Map finalMap = prepareIdentityMap(documentEntityList, inputFile, identityMap, preRegistrationDTO.getPreRegistrationId()); - log.info("sessionId", "idType", "id", + log.info(LOGGER_SESSIONID, LOGGER_IDTYPE, LOGGER_ID, "In archivingFiles method of datasync service util, Json file content - " + new JSONObject(finalMap).toJSONString()); String encryptionPublickey = getEncryptionKey(machineId); @@ -660,8 +663,8 @@ public PreRegArchiveDTO archivingFiles(DemographicResponseDTO preRegistrationDTO preRegArchiveDTO.setFileName(preRegistrationDTO.getPreRegistrationId()); } catch (Exception ex) { - log.error("sessionId", "idType", "id", ExceptionUtils.getStackTrace(ex)); - log.error("sessionId", "idType", "id", + log.error(LOGGER_SESSIONID, LOGGER_IDTYPE, LOGGER_ID, ExceptionUtils.getStackTrace(ex)); + log.error(LOGGER_SESSIONID, LOGGER_IDTYPE, LOGGER_ID, "In archivingFiles method of datasync service util - " + ex.getMessage()); throw new ZipFileCreationException(ErrorCodes.PRG_DATA_SYNC_005.getCode(), ErrorMessages.FAILED_TO_CREATE_A_ZIP_FILE.getMessage(), null); @@ -723,8 +726,8 @@ private Map prepareDocumentMetaData(DocumentMultipartResponseDTO return JsonUtils.jsonStringToJavaMap(JsonUtils.javaObjectToJsonString(documentMetaDataDTO)); } catch (JsonParseException | JsonMappingException | io.mosip.kernel.core.exception.IOException | JsonProcessingException ex) { - log.debug("sessionId", "idType", "id", ExceptionUtils.getStackTrace(ex)); - log.error("sessionId", "idType", "id", + log.debug(LOGGER_SESSIONID, LOGGER_IDTYPE, LOGGER_ID, ExceptionUtils.getStackTrace(ex)); + log.error(LOGGER_SESSIONID, LOGGER_IDTYPE, LOGGER_ID, "In prepareDocumentMetaData method of datasync service util for JSONException - " + ex.getMessage()); } @@ -762,7 +765,7 @@ public String getFileNameWithoutFormat(String fileName) { * @return byteArray */ private static byte[] getCompressed(Map inputFIle) { - log.info("sessionId", "idType", "id", "In getCompressed method of datasync service util"); + log.info(LOGGER_SESSIONID, LOGGER_IDTYPE, LOGGER_ID, "In getCompressed method of datasync service util"); byte[] byteArray = null; try { ByteArrayOutputStream byteArrayOutputStream = new ByteArrayOutputStream(); @@ -774,8 +777,8 @@ private static byte[] getCompressed(Map inputFIle) { zipOutputStream.close(); byteArray = byteArrayOutputStream.toByteArray(); } catch (IOException ex) { - log.debug("sessionId", "idType", "id", ExceptionUtils.getStackTrace(ex)); - log.error("sessionId", "idType", "id", + log.debug(LOGGER_SESSIONID, LOGGER_IDTYPE, LOGGER_ID, ExceptionUtils.getStackTrace(ex)); + log.error(LOGGER_SESSIONID, LOGGER_IDTYPE, LOGGER_ID, "In getCompressed method of datasync service util for FileNotFoundException - " + ex.getMessage()); throw new SystemFileIOException(ErrorCodes.PRG_DATA_SYNC_014.getCode(), ErrorMessages.FILE_IO_EXCEPTION.getMessage(), null); @@ -791,15 +794,15 @@ private static byte[] getCompressed(Map inputFIle) { * @param zipOutputStream */ private static void zipping(String fileName, byte[] fileToZip, ZipOutputStream zipOutputStream) { - log.info("sessionId", "idType", "id", "In zipping method of datasync service util"); + log.info(LOGGER_SESSIONID, LOGGER_IDTYPE, LOGGER_ID, "In zipping method of datasync service util"); try { ZipEntry entry = new ZipEntry(fileName); zipOutputStream.putNextEntry(entry); zipOutputStream.write(fileToZip); zipOutputStream.flush(); } catch (IOException ex) { - log.debug("sessionId", "idType", "id", ExceptionUtils.getStackTrace(ex)); - log.error("sessionId", "idType", "id", + log.debug(LOGGER_SESSIONID, LOGGER_IDTYPE, LOGGER_ID, ExceptionUtils.getStackTrace(ex)); + log.error(LOGGER_SESSIONID, LOGGER_IDTYPE, LOGGER_ID, "In zipping method of datasync service util for IOException - " + ex.getMessage()); throw new SystemFileIOException(ErrorCodes.PRG_DATA_SYNC_014.getCode(), ErrorMessages.FILE_IO_EXCEPTION.getMessage(), null); @@ -813,7 +816,7 @@ private static void zipping(String fileName, byte[] fileToZip, ZipOutputStream z * @return true if key not null and return false if key is null. */ public boolean isNull(Object key) { - log.info("sessionId", "idType", "id", "In isNull method of datasync service util"); + log.info(LOGGER_SESSIONID, LOGGER_IDTYPE, LOGGER_ID, "In isNull method of datasync service util"); if (key instanceof String) { if (key.equals("")) return true; @@ -828,7 +831,7 @@ public boolean isNull(Object key) { } public Map getPreregistrationUpdatedTime(PreRegIdsByRegCenterIdDTO preRegIdsDTO) { - log.info("sessionId", "idType", "id", + log.info(LOGGER_SESSIONID, LOGGER_IDTYPE, LOGGER_ID, "In callGetPreRegInfoRestService method of datasync service util " + preRegIdsDTO); Map response = null; try { @@ -857,8 +860,8 @@ public Map getPreregistrationUpdatedTime(PreRegIdsByRegCenterIdD } } } catch (RestClientException ex) { - log.debug("sessionId", "idType", "id", ExceptionUtils.getStackTrace(ex)); - log.error("sessionId", "idType", "id", + log.debug(LOGGER_SESSIONID, LOGGER_IDTYPE, LOGGER_ID, ExceptionUtils.getStackTrace(ex)); + log.error(LOGGER_SESSIONID, LOGGER_IDTYPE, LOGGER_ID, "In callGetUpdatedTimeRestService method of datasync service util - " + ex.getMessage()); throw new DemographicGetDetailsException(ErrorCodes.PRG_DATA_SYNC_007.getCode(), @@ -868,7 +871,7 @@ public Map getPreregistrationUpdatedTime(PreRegIdsByRegCenterIdD } public PreRegistrationIdsDTO getLastUpdateTimeStamp(PreRegIdsByRegCenterIdDTO preRegIdsDTO) { - log.info("sessionId", "idType", "id", "In getLastUpdateTimeStamp method of datasync service util"); + log.info(LOGGER_SESSIONID, LOGGER_IDTYPE, LOGGER_ID, "In getLastUpdateTimeStamp method of datasync service util"); PreRegistrationIdsDTO preRegistrationIdsDTO = new PreRegistrationIdsDTO(); Map preRegMap = getPreregistrationUpdatedTime(preRegIdsDTO); preRegistrationIdsDTO.setCountOfPreRegIds(String.valueOf(preRegMap.size())); @@ -879,7 +882,7 @@ public PreRegistrationIdsDTO getLastUpdateTimeStamp(PreRegIdsByRegCenterIdDTO pr public ReverseDatasyncReponseDTO reverseDateSyncSave(Date reqDateTime, ReverseDataSyncRequestDTO request, String userId) { - log.info("sessionId", "idType", "id", "In reverseDateSyncSave method of datasync service util"); + log.info(LOGGER_SESSIONID, LOGGER_IDTYPE, LOGGER_ID, "In reverseDateSyncSave method of datasync service util"); List entityList = new ArrayList<>(); List processedEntityList = new ArrayList<>(); List preIdLists = request.getPreRegistrationIds(); @@ -918,7 +921,7 @@ public ReverseDatasyncReponseDTO reverseDateSyncSave(Date reqDateTime, ReverseDa public ReverseDatasyncReponseDTO storeReverseDataSync(List entityList, List processedEntityList) { - log.info("sessionId", "idType", "id", "In storeReverseDataSync method of datasync service util"); + log.info(LOGGER_SESSIONID, LOGGER_IDTYPE, LOGGER_ID, "In storeReverseDataSync method of datasync service util"); int savedListSize = 0; List preIds = new ArrayList<>(); ReverseDatasyncReponseDTO reponseDTO = new ReverseDatasyncReponseDTO(); @@ -939,8 +942,8 @@ public ReverseDatasyncReponseDTO storeReverseDataSync(List prepareRequestMap(MainRequestDTO requestDto) { - log.info("sessionId", "idType", "id", "In prepareRequestMap method of datasync service util"); + log.info(LOGGER_SESSIONID, LOGGER_IDTYPE, LOGGER_ID, "In prepareRequestMap method of datasync service util"); Map requestMap = new HashMap<>(); requestMap.put("id", requestDto.getId()); requestMap.put("version", requestDto.getVersion()); @@ -983,7 +986,7 @@ public String getFileFormat(String fileName) { } public String getEncryptionKey(String machineId) { - log.info("sessionId", "idType", "id", "In callGetMachinePublickey method of datasync service util"); + log.info(LOGGER_SESSIONID, LOGGER_IDTYPE, LOGGER_ID, "In callGetMachinePublickey method of datasync service util"); String encryptionPublickey = null; try { if (machineId != null) { @@ -993,7 +996,7 @@ public String getEncryptionKey(String machineId) { headers.setContentType(MediaType.APPLICATION_JSON); HttpEntity> httpEntity = new HttpEntity<>(headers); String uriBuilder = builder.build().encode().toUriString(); - log.info("sessionId", "idType", "id", "In callGetMachinePublickey method URL-{} " + uriBuilder); + log.info(LOGGER_SESSIONID, LOGGER_IDTYPE, LOGGER_ID, "In callGetMachinePublickey method URL-{} " + uriBuilder); ResponseEntity> respEntity = selfTokenRestTemplate.exchange(uriBuilder, HttpMethod.GET, httpEntity, new ParameterizedTypeReference>() { @@ -1001,7 +1004,7 @@ public String getEncryptionKey(String machineId) { MainResponseDTO body = respEntity.getBody(); if (body != null) { if (body.getErrors() != null) { - log.info("sessionId", "idType", "id", + log.info(LOGGER_SESSIONID, LOGGER_IDTYPE, LOGGER_ID, "In callGetMachinePublickey method of datasync service util - unable to get envryption publickey for the machineID"); } else { if (body.getResponse() != null) { @@ -1013,7 +1016,7 @@ public String getEncryptionKey(String machineId) { } catch (RestClientException ex) { log.debug("{}", ExceptionUtils.getStackTrace(ex)); - log.error("sessionId", "idType", "id", + log.error(LOGGER_SESSIONID, LOGGER_IDTYPE, LOGGER_ID, "In callGetMachinePublickey method of datasync service util - {}" + ex.getMessage()); throw new ZipFileCreationException(ErrorCodes.PRG_DATA_SYNC_018.getCode(),