Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Java21] #10

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down
Original file line number Diff line number Diff line change
@@ -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 = "";
}
Original file line number Diff line number Diff line change
Expand Up @@ -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";
Expand All @@ -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";
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -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")
Expand All @@ -57,7 +60,7 @@ public class AppointmentController {
@ApiResponse(responseCode = "404", description = "Not Found", content = @Content(schema = @Schema(hidden = true))) })
public ResponseEntity<MainResponseDTO<AvailabilityDto>> 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));
}

Expand All @@ -73,7 +76,7 @@ public ResponseEntity<MainResponseDTO<BookingStatusDTO>> bookAppoinment(
@PathVariable("preRegistrationId") String preRegistrationId,
@Validated @RequestBody(required = true) MainRequestDTO<BookingRequestDTO> 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));
}
Expand All @@ -88,7 +91,8 @@ public ResponseEntity<MainResponseDTO<BookingStatusDTO>> bookAppoinment(
@ApiResponse(responseCode = "404", description = "Not Found", content = @Content(schema = @Schema(hidden = true))) })
public ResponseEntity<MainResponseDTO<BookingRegistrationDTO>> 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));
}

Expand All @@ -102,7 +106,8 @@ public ResponseEntity<MainResponseDTO<BookingRegistrationDTO>> getAppointments(
@ApiResponse(responseCode = "404", description = "Not Found", content = @Content(schema = @Schema(hidden = true))) })
public ResponseEntity<MainResponseDTO<CancelBookingResponseDTO>> 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));
}

Expand All @@ -116,7 +121,8 @@ public ResponseEntity<MainResponseDTO<CancelBookingResponseDTO>> cancelBook(
@ApiResponse(responseCode = "404", description = "Not Found", content = @Content(schema = @Schema(hidden = true))) })
public ResponseEntity<MainResponseDTO<CancelBookingResponseDTO>> 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));
}

Expand All @@ -129,7 +135,7 @@ public ResponseEntity<MainResponseDTO<CancelBookingResponseDTO>> internalCancelB
@ApiResponse(responseCode = "403", description = "Forbidden", content = @Content(schema = @Schema(hidden = true))), })
public ResponseEntity<MainResponseDTO<DeleteBookingDTO>> 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));
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -313,8 +313,9 @@ public ResponseEntity<MainResponseDTO<Map<String, String>>> getUpdatedDateTimeBy
@ApiResponse(responseCode = "404", description = "Not Found", content = @Content(schema = @Schema(hidden = true))) })
public ResponseEntity<MainResponseDTO<?>> 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));
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -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.
*
Expand Down Expand Up @@ -81,11 +85,11 @@ public ResponseEntity<MainResponseDTO<DocumentResponseDTO>> 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));
Expand Down Expand Up @@ -116,7 +120,7 @@ public ResponseEntity<MainResponseDTO<DocumentResponseDTO>> 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)
Expand All @@ -140,7 +144,7 @@ public ResponseEntity<MainResponseDTO<DocumentResponseDTO>> copyDocument(
@ApiResponse(responseCode = "404", description = "Not Found", content = @Content(schema = @Schema(hidden = true))) })
public ResponseEntity<MainResponseDTO<DocumentsMetaData>> 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)
Expand All @@ -166,7 +170,7 @@ public ResponseEntity<MainResponseDTO<DocumentsMetaData>> getAllDocumentforPreid
public ResponseEntity<MainResponseDTO<DocumentDTO>> 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)
Expand All @@ -181,7 +185,6 @@ public ResponseEntity<MainResponseDTO<DocumentDTO>> 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)
Expand All @@ -193,7 +196,7 @@ public ResponseEntity<MainResponseDTO<DocumentDTO>> getDocumentforDocId(
public ResponseEntity<MainResponseDTO<DocumentDeleteResponseDTO>> 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));
Expand All @@ -216,7 +219,7 @@ public ResponseEntity<MainResponseDTO<DocumentDeleteResponseDTO>> deleteDocument
@ApiResponse(responseCode = "403", description = "Forbidden", content = @Content(schema = @Schema(hidden = true))), })
public ResponseEntity<MainResponseDTO<DocumentDeleteResponseDTO>> 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));
Expand All @@ -237,7 +240,7 @@ public ResponseEntity<MainResponseDTO<String>> 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)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down Expand Up @@ -79,7 +83,7 @@ public void initBinder(WebDataBinder binder) {
@ApiResponse(responseCode = "404", description = "Not Found", content = @Content(schema = @Schema(hidden = true))) })
public ResponseEntity<MainResponseDTO<QRCodeResponseDTO>> generateQRCode(
@Validated @RequestBody MainRequestDTO<String> 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);
Expand Down
Original file line number Diff line number Diff line change
@@ -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;

Expand Down Expand Up @@ -117,7 +121,6 @@ public void initBinder(WebDataBinder binder) {
public ResponseEntity<MainResponseDTO<AuthNResponse>> sendOTP(
@Validated @RequestBody MainRequestDTO<OtpRequestDTO> userOtpRequest,
@ApiParam(hidden = true) Errors errors) {

loginValidator.validateId(SENDOTP, userOtpRequest.getId(), errors);
DataValidationUtil.validate(errors, SENDOTP);
if (!allowSendOtpApi)
Expand Down Expand Up @@ -146,7 +149,6 @@ public ResponseEntity<MainResponseDTO<AuthNResponse>> sendOTP(
public ResponseEntity<MainResponseDTO<AuthNResponse>> sendOTPWithLangCode(
@Validated @RequestBody MainRequestDTO<OTPWithLangCodeDTO> userOtpRequest,
@ApiParam(hidden = true) Errors errors) {

loginValidator.validateId(SENDOTP, userOtpRequest.getId(), errors);
DataValidationUtil.validate(errors, SENDOTP);
MainRequestDTO<OtpRequestDTO> MainRequestDTO = new MainRequestDTO<>();
Expand Down Expand Up @@ -178,7 +180,7 @@ public ResponseEntity<MainResponseDTO<AuthNResponse>> validateWithUserIdOtp(
@Validated @RequestBody MainRequestDTO<User> 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<AuthNResponse> responseBody = loginService.validateWithUserIdOtp(userIdOtpRequest);
Expand Down
Original file line number Diff line number Diff line change
@@ -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;
Expand Down Expand Up @@ -78,7 +82,7 @@ public void initBinder(WebDataBinder binder) {
public ResponseEntity<MainResponseDTO<ApplicationResponseDTO>> addLostUinApplication(
@Validated @RequestBody(required = true) MainRequestDTO<ApplicationRequestDTO> 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);
Expand All @@ -102,7 +106,7 @@ public ResponseEntity<MainResponseDTO<ApplicationResponseDTO>> addLostUinApplica
@ApiResponse(responseCode = "403", description = "Forbidden", content = @Content(schema = @Schema(hidden = true))), })
public ResponseEntity<MainResponseDTO<DeleteApplicationDTO>> 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()));
Expand Down
Loading
Loading