Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
… into MOSIP-21674

� Conflicts:
�	resident/resident-service/src/main/java/io/mosip/resident/constant/ApiName.java
  • Loading branch information
kameshsr committed Dec 19, 2022
2 parents 8e56187 + 0048dac commit 7711a9f
Show file tree
Hide file tree
Showing 63 changed files with 1,547 additions and 544 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
-- -------------------------------------------------------------------------------------------------
-- Database Name: resident_grievance_ticket
-- Release Version : 1.2.1
-- Purpose : Database scripts for Resident Service DB.
-- Create By : Kamesh Shekhar Prasad
-- Created Date : December-2022
--
-- Modified Date Modified By Comments / Remarks
-- --------------------------------------------------------------------------------------------------
--
-----------------------------------------------------------------------------------------------------

-- This Table is used to save the resident_grievance_ticket table values.
CREATE TABLE resident.resident_grievance_ticket(
id VARCHAR(64) NOT NULL,
eventId VARCHAR(64) NOT NULL,
name VARCHAR(256) NOT NULL,
emailId VARCHAR(128),
alternateEmailId VARCHAR(128),
phoneNo VARCHAR(64),
alternatePhoneNo VARCHAR(64),
message character varying(1024) NOT NULL,
hasAttachment boolean NOT NULL DEFAULT false,
status character varying(64) NOT NULL,
cr_by character varying(256) NOT NULL,
cr_dtimes timestamp NOT NULL,
upd_by character varying(256),
upd_dtimes timestamp,
is_deleted boolean NOT NULL DEFAULT false,
del_dtimes timestamp,
CONSTRAINT pk_resgrev_id PRIMARY KEY (id)
);

COMMENT ON TABLE resident.resident_grievance_ticket IS 'This Table is used to save the resident_grievance_ticket table values.';
COMMENT ON COLUMN resident.resident_grievance_ticket.id IS 'Unique Id.';
COMMENT ON COLUMN resident.resident_grievance_ticket.event_id IS 'Unique event id.';
COMMENT ON COLUMN resident.resident_grievance_ticket.emailId IS 'Unique email id.';
COMMENT ON COLUMN resident.resident_grievance_ticket.alternateEmailId IS 'Alternate email id.';
COMMENT ON COLUMN resident.resident_grievance_ticket.phoneNo IS 'Phone number.';
COMMENT ON COLUMN resident.resident_grievance_ticket.altrenatePhoneNo IS 'Alternate Phone number.';
COMMENT ON COLUMN resident.resident_grievance_ticket.message IS 'Message.';
COMMENT ON COLUMN resident.resident_grievance_ticket.status IS 'status.';
COMMENT ON COLUMN resident.resident_grievance_ticket.cr_by IS 'created by.';
COMMENT ON COLUMN resident.resident_grievance_ticket.cr_dtimes IS 'created date and time.';
COMMENT ON COLUMN resident.resident_grievance_ticket.upd_by IS 'updated by.';
COMMENT ON COLUMN resident.resident_grievance_ticket.upd_dtimes IS 'updated date and time.';
COMMENT ON COLUMN resident.resident_grievance_ticket.is_deleted IS 'is deleted.';
COMMENT ON COLUMN resident.resident_grievance_ticket.del_dtimes IS 'Deleted time-stamp.';

--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
50 changes: 50 additions & 0 deletions db_scripts/mosip_resident/ddl/resident_grievance_ticket.sql
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
-- -------------------------------------------------------------------------------------------------
-- Database Name: resident_grievance_ticket
-- Release Version : 1.2.1
-- Purpose : Database scripts for Resident Service DB.
-- Create By : Kamesh Shekhar Prasad
-- Created Date : December-2022
--
-- Modified Date Modified By Comments / Remarks
-- --------------------------------------------------------------------------------------------------
--
-----------------------------------------------------------------------------------------------------

-- This Table is used to save the resident_grievance_ticket table values.
CREATE TABLE resident.resident_grievance_ticket(
id VARCHAR(64) NOT NULL,
eventId VARCHAR(64) NOT NULL,
name VARCHAR(256) NOT NULL,
emailId VARCHAR(128),
alternateEmailId VARCHAR(128),
phoneNo VARCHAR(64),
alternatePhoneNo VARCHAR(64),
message character varying(1024) NOT NULL,
hasAttachment boolean NOT NULL DEFAULT false,
status character varying(64) NOT NULL,
cr_by character varying(256) NOT NULL,
cr_dtimes timestamp NOT NULL,
upd_by character varying(256),
upd_dtimes timestamp,
is_deleted boolean NOT NULL DEFAULT false,
del_dtimes timestamp,
CONSTRAINT pk_resgrev_id PRIMARY KEY (id)
);

COMMENT ON TABLE resident.resident_grievance_ticket IS 'This Table is used to save the resident_grievance_ticket table values.';
COMMENT ON COLUMN resident.resident_grievance_ticket.id IS 'Unique Id.';
COMMENT ON COLUMN resident.resident_grievance_ticket.event_id IS 'Unique event id.';
COMMENT ON COLUMN resident.resident_grievance_ticket.emailId IS 'Unique email id.';
COMMENT ON COLUMN resident.resident_grievance_ticket.alternateEmailId IS 'Alternate email id.';
COMMENT ON COLUMN resident.resident_grievance_ticket.phoneNo IS 'Phone number.';
COMMENT ON COLUMN resident.resident_grievance_ticket.altrenatePhoneNo IS 'Alternate Phone number.';
COMMENT ON COLUMN resident.resident_grievance_ticket.message IS 'Message.';
COMMENT ON COLUMN resident.resident_grievance_ticket.status IS 'status.';
COMMENT ON COLUMN resident.resident_grievance_ticket.cr_by IS 'created by.';
COMMENT ON COLUMN resident.resident_grievance_ticket.cr_dtimes IS 'created date and time.';
COMMENT ON COLUMN resident.resident_grievance_ticket.upd_by IS 'updated by.';
COMMENT ON COLUMN resident.resident_grievance_ticket.upd_dtimes IS 'updated date and time.';
COMMENT ON COLUMN resident.resident_grievance_ticket.is_deleted IS 'is deleted.';
COMMENT ON COLUMN resident.resident_grievance_ticket.del_dtimes IS 'Deleted time-stamp.';

--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,6 @@ public enum ApiName {
GET_RID_BY_INDIVIDUAL_ID,
PDFSIGN,
PARTNER_DETAILS_NEW_URL,
GET_RID_STATUS;
DOCUMENT_TYPE_BY_DOCUMENT_CATEGORY_AND_LANG_CODE;

}
Original file line number Diff line number Diff line change
@@ -1,14 +1,13 @@
package io.mosip.resident.constant;

import io.mosip.resident.dto.NotificationTemplateVariableDTO;
import io.mosip.resident.util.TemplateUtil;

import java.util.Collections;
import java.util.List;
import java.util.Map;
import java.util.Optional;
import java.util.function.BiFunction;

import io.mosip.resident.dto.NotificationTemplateVariableDTO;
import io.mosip.resident.util.TemplateUtil;

/**
* The Enum RequestType.
*
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -139,10 +139,21 @@ private ResidentConstants() {
public static final String UIN_CARD_NAMING_CONVENTION_PROPERTY = "mosip.resident.uin.card.name.convention";
public static final String VID_CARD_NAMING_CONVENTION_PROPERTY = "mosip.resident.vid.card.name.convention";
public static final String SUCCESS = "Success";
public static final String FAILED = "Failed";
public static final String NOT_AVAILABLE = "NA";
public static final String REGISTRATION_CENTRE_TEMPLATE_PROPERTY = "resident.template.registration.centers.list";
public static final String SUPPORTING_DOCS_TEMPLATE_PROPERTY = "resident.template.support-docs-list";
public static final String FROM_DATE_TIME = "fromDateTime";
public static final String TO_DATE_TIME = "toDateTime";
public static final String DOWNLOAD_SERVICE_HISTORY_FILE_NAME_CONVENTION_PROPERTY = "mosip.resident.download.service.history.file.name.convention";
public static final String GRIEVANCE_REQUEST_ID = "mosip.resident.grievance.ticket.request.id";
public static final String GRIEVANCE_REQUEST_VERSION = "mosip.resident.grievance.ticket.request.version";

public static final String NAME_FROM_PROFILE = "mosip.resident.name.token.claim-name";

public static final String EMAIL_FROM_PROFILE = "mosip.resident.email.token.claim-email";
public static final String PHONE_FROM_PROFILE = "mosip.resident.phone.token.claim-phone";

public static final String MESSAGE_CODE_MAXIMUM_LENGTH = "mosip.resident.message.code.maximum.length";

}
Original file line number Diff line number Diff line change
Expand Up @@ -111,7 +111,9 @@ public enum ResidentErrorCode {
REDIRECT_URL_NOT_FOUND("RES-SER-482","Redirect url not found."),
CARD_NOT_READY("RES_SER_509", "The card is not ready for download."),
OTP_REQUEST_FLOODED("RES_SER_510", "Innumerous OTP requests received"),
EID_NOT_BELONG_TO_SESSION("RES-SER-511", "The entered EID is not associated with the UIN/VID used to log in.");
EID_NOT_BELONG_TO_SESSION("RES-SER-511", "The entered EID is not associated with the UIN/VID used to log in."),
GRIEVANCE_TICKET_GENERATION_FAILED("RES-SER-512", "Unable to Generate Ticket of grievance"),
MISSING_INPUT_PARAMETER("RES-SER-414", "Missing input Parameter- ");

private final String errorCode;
private final String errorMessage;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,9 @@
*/

public enum ServiceType {
AUTHENTICATION_REQUEST(List.of(RequestType.AUTHENTICATION_REQUEST)),
AUTHENTICATION_REQUEST(List.of(RequestType.AUTHENTICATION_REQUEST, RequestType.SEND_OTP, RequestType.VALIDATE_OTP)),
SERVICE_REQUEST(List.of(RequestType.DOWNLOAD_PERSONALIZED_CARD, RequestType.ORDER_PHYSICAL_CARD,
RequestType.GET_MY_ID, RequestType.BOOK_AN_APPOINTMENT)),
RequestType.GET_MY_ID, RequestType.BOOK_AN_APPOINTMENT, RequestType.VID_CARD_DOWNLOAD)),
DATA_UPDATE_REQUEST(List.of(RequestType.UPDATE_MY_UIN)),
ID_MANAGEMENT_REQUEST(List.of(RequestType.GENERATE_VID, RequestType.REVOKE_VID,
RequestType.VALIDATE_OTP, RequestType.AUTH_TYPE_LOCK_UNLOCK)),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,16 +14,13 @@
import org.springframework.core.io.InputStreamResource;
import org.springframework.http.MediaType;
import org.springframework.http.ResponseEntity;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RestController;

import java.io.ByteArrayInputStream;
import java.io.IOException;

import static io.mosip.resident.constant.RegistrationConstants.UNDER_SCORE;

/**
* This class is used to create api for getting acknowledgement.
* @Author Kamesh Shekhar Prasad
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,11 +13,13 @@
import io.mosip.resident.service.DownloadCardService;
import io.mosip.resident.util.AuditUtil;
import io.mosip.resident.util.EventEnum;
import io.mosip.resident.util.Utilitiy;
import io.mosip.resident.validator.RequestValidator;
import io.swagger.v3.oas.annotations.tags.Tag;
import reactor.util.function.Tuple2;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.core.env.Environment;
import org.springframework.core.io.InputStreamResource;
import org.springframework.http.HttpStatus;
import org.springframework.http.MediaType;
Expand All @@ -31,6 +33,7 @@
import org.springframework.web.bind.annotation.RestController;

import java.io.ByteArrayInputStream;
import java.util.Objects;

/**
* @author Kamesh Shekhar Prasad
Expand All @@ -49,6 +52,12 @@ public class DownloadCardController {

@Autowired
DownloadCardService downloadCardService;

@Autowired
private Utilitiy utilitiy;

@Autowired
private Environment environment;

private static final Logger logger = LoggerConfiguration.logConfig(DownloadCardController.class);

Expand Down Expand Up @@ -77,21 +86,27 @@ public ResponseEntity<Object> downloadPersonalizedCard(@Validated @RequestBody M
logger.debug("DownloadCardController::downloadPersonalizedCard()::entry");
auditUtil.setAuditRequestDto(EventEnum.DOWNLOAD_PERSONALIZED_CARD);
requestValidator.validateDownloadPersonalizedCard(downloadPersonalizedCardMainRequestDTO);
byte[] pdfBytes = downloadCardService.downloadPersonalizedCard(downloadPersonalizedCardMainRequestDTO);
InputStreamResource resource = new InputStreamResource(new ByteArrayInputStream(pdfBytes));
if(pdfBytes.length==0){
Tuple2<byte[], String> tupleResponse = downloadCardService.downloadPersonalizedCard(downloadPersonalizedCardMainRequestDTO);
InputStreamResource resource = new InputStreamResource(new ByteArrayInputStream(tupleResponse.getT1()));
if(tupleResponse.getT1().length==0){
return new ResponseEntity<>(HttpStatus.BAD_REQUEST);
}
return ResponseEntity.ok().contentType(MediaType.parseMediaType("application/pdf"))
.header("Content-Disposition", "attachment; filename=\"" +
downloadCardService.getFileName() + ".pdf\"")
.header("Content-Disposition", "attachment; filename=\""
+ utilitiy.getFileName(tupleResponse.getT2(),
Objects.requireNonNull(this.environment.getProperty(
ResidentConstants.DOWNLOAD_PERSONALIZED_CARD_NAMING_CONVENTION_PROPERTY)))
+ ".pdf\"")
.header(ResidentConstants.EVENT_ID, tupleResponse.getT2())
.body(resource);
}

@GetMapping("/request-card/vid/{VID}")
public ResponseWrapper<VidDownloadCardResponseDto> requestVidCard(@PathVariable("VID") String vid) throws BaseCheckedException {
public ResponseEntity<Object> requestVidCard(@PathVariable("VID") String vid) throws BaseCheckedException {
requestValidator.validateDownloadCardVid(vid);
ResponseWrapper<VidDownloadCardResponseDto> downloadCardResponseDtoResponseWrapper = downloadCardService.getVidCardEventId(vid);
return downloadCardResponseDtoResponseWrapper;
Tuple2<ResponseWrapper<VidDownloadCardResponseDto>, String> tupleResponse = downloadCardService.getVidCardEventId(vid);
return ResponseEntity.ok()
.header(ResidentConstants.EVENT_ID, tupleResponse.getT2())
.body(tupleResponse.getT1());
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
package io.mosip.resident.controller;

import io.mosip.kernel.core.http.ResponseWrapper;
import io.mosip.kernel.core.logger.spi.Logger;
import io.mosip.resident.config.LoggerConfiguration;
import io.mosip.resident.dto.GrievanceRequestDTO;
import io.mosip.resident.dto.MainRequestDTO;
import io.mosip.resident.exception.ApisResourceAccessException;
import io.mosip.resident.exception.ResidentServiceCheckedException;
import io.mosip.resident.service.GrievanceService;
import io.mosip.resident.util.AuditUtil;
import io.mosip.resident.util.EventEnum;
import io.mosip.resident.validator.RequestValidator;
import io.swagger.v3.oas.annotations.tags.Tag;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RestController;

import java.io.IOException;

/**
* @author Kamesh Shekhar Prasad
* This class is used to generate ticket of grievance.
*/

@RestController
@Tag(name = "GrievanceController", description = "Grievance-Controller")
public class GrievanceController {

@Autowired
AuditUtil auditUtil;

@Autowired
RequestValidator requestValidator;

@Autowired
GrievanceService grievanceService;

private static final Logger logger = LoggerConfiguration.logConfig(GrievanceController.class);

@PostMapping("/grievance/ticket")
public ResponseWrapper<Object> grievanceTicket(@Validated @RequestBody MainRequestDTO<GrievanceRequestDTO>
grievanceRequestDTOMainRequestDTO) throws ResidentServiceCheckedException,
ApisResourceAccessException, IOException {
logger.debug("DownloadCardController::grievanceTicket()::entry");
auditUtil.setAuditRequestDto(EventEnum.GRIEVANCE_TICKET_REQUEST);
requestValidator.validateGrievanceRequestDto(grievanceRequestDTOMainRequestDTO);
return grievanceService.getGrievanceTicket(grievanceRequestDTOMainRequestDTO);
}
}
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package io.mosip.resident.controller;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RestController;
Expand Down Expand Up @@ -58,7 +59,7 @@ public class IdAuthController {
@ApiResponse(responseCode = "401", description = "Unauthorized", content = @Content(schema = @Schema(hidden = true))),
@ApiResponse(responseCode = "403", description = "Forbidden", content = @Content(schema = @Schema(hidden = true))),
@ApiResponse(responseCode = "404", description = "Not Found", content = @Content(schema = @Schema(hidden = true))) })
public ResponseWrapper<IdAuthResponseDto> validateOtp(@RequestBody RequestWrapper<IdAuthRequestDto> requestWrapper)
public ResponseEntity<Object> validateOtp(@RequestBody RequestWrapper<IdAuthRequestDto> requestWrapper)
throws OtpValidationFailedException {
logger.debug("IdAuthController::validateOtp()::entry");
auditUtil.setAuditRequestDto(EventEnum.getEventEnumWithValue(EventEnum.VALIDATE_OTP, requestWrapper.getRequest().getTransactionId(),
Expand All @@ -71,11 +72,12 @@ public ResponseWrapper<IdAuthResponseDto> validateOtp(@RequestBody RequestWrappe
ValidateOtpResponseDto validateOtpResponseDto = new ValidateOtpResponseDto();
validateOtpResponseDto.setAuthStatus(tupleResponse.getT1());
validateOtpResponseDto.setTransactionId(requestWrapper.getRequest().getTransactionId());
validateOtpResponseDto.setEventId(tupleResponse.getT2());
validateOtpResponseDto.setStatus(ResidentConstants.SUCCESS);
responseWrapper.setResponse(validateOtpResponseDto);
logger.debug("IdAuthController::validateOtp()::exit");
return responseWrapper;
return ResponseEntity.ok()
.header(ResidentConstants.EVENT_ID, tupleResponse.getT2())
.body(responseWrapper);
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ public class PinStatusController {
@PostMapping(path = "pinned/{eventId}")
public ResponseWrapper<ResponseDTO> pinStatus(@PathVariable("eventId") String eventId){
audit.setAuditRequestDto(EventEnum.getEventEnumWithValue(EventEnum.VALIDATE_REQUEST, "Pin Status API"));
requestValidator.validateIndividualId(eventId);
requestValidator.validateEventId(eventId);
audit.setAuditRequestDto(EventEnum.getEventEnumWithValue(EventEnum.PIN_STATUS, eventId));
return pinUnpinStatusService.pinStatus(eventId, true);
}
Expand All @@ -48,7 +48,7 @@ public ResponseWrapper<ResponseDTO> pinStatus(@PathVariable("eventId") String ev
@PostMapping(path = "unpinned/{eventId}")
public ResponseWrapper<ResponseDTO> unPinStatus(@PathVariable("eventId") String eventId){
audit.setAuditRequestDto(EventEnum.getEventEnumWithValue(EventEnum.VALIDATE_REQUEST, "Pin Status API"));
requestValidator.validateIndividualId(eventId);
requestValidator.validateEventId(eventId);
audit.setAuditRequestDto(EventEnum.getEventEnumWithValue(EventEnum.UN_PIN_STATUS, eventId));
return pinUnpinStatusService.pinStatus(eventId, false);
}
Expand Down
Loading

0 comments on commit 7711a9f

Please sign in to comment.