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

Mosip 24879 add event id in the response of the below stories #620

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
30 commits
Select commit Hold shift + click to select a range
9a1b152
added error for invalid user
Nov 28, 2022
7f3f731
resolved merge conflict
Nov 28, 2022
8477e16
added status in 2 apis
Nov 29, 2022
11ee99f
changed response of auth-lock-unlock api
Nov 29, 2022
4e7ca20
updated response of validate otp
Dec 5, 2022
076a93d
resolved merge conflict
Dec 5, 2022
3ed9af5
resolved merge conflict
Dec 5, 2022
b80c68b
added eventid and status in response
Dec 7, 2022
f9114c3
added eventId in response header for download eventid api
Dec 7, 2022
149fe35
fixed service history pdf file name
Dec 8, 2022
bbc24e7
added eventid in response of download card api
Dec 8, 2022
636cde8
Merge branch 'develop' of https://github.com/mosip/resident-services …
Dec 8, 2022
3bd3dd1
convert eventId to constant
Dec 12, 2022
865c327
resolved merge conflict
Dec 12, 2022
dbbb7ff
added eventId for error scenarios
Dec 14, 2022
acca9f6
resolved merge conflict
Dec 14, 2022
5676926
Merge branch 'develop' of https://github.com/mosip/resident-services …
Dec 14, 2022
788b9aa
fixed reliability bug
Dec 15, 2022
bd881a3
fixed response of share credential API
Dec 15, 2022
e202a8a
fixed test failure
Dec 15, 2022
a182937
updated response for auth lock unlock API
Dec 15, 2022
ace76d1
covered code for one method
Dec 15, 2022
000bd6b
updated response of request vid card
Dec 16, 2022
5b84ecd
resolved merge conflict
Dec 16, 2022
fb94d3b
Merge branch 'develop' of https://github.com/mosip/resident-services …
Dec 16, 2022
a126b3a
updated response of validate otp API
Dec 16, 2022
8c42c3b
Merge branch 'develop' of https://github.com/mosip/resident-services …
Dec 16, 2022
9361dd0
created contant for NA
Dec 16, 2022
6fa1c35
Merge branch 'develop' of https://github.com/mosip/resident-services …
Dec 16, 2022
9c0c9f8
updated response of generate and revoke vid
Dec 19, 2022
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 @@ -20,6 +20,7 @@
import io.mosip.kernel.core.logger.spi.Logger;
import io.mosip.kernel.core.util.DateUtils;
import io.mosip.resident.config.LoggerConfiguration;
import io.mosip.resident.constant.ResidentConstants;
import io.mosip.resident.constant.ResidentErrorCode;
import io.mosip.resident.dto.BaseVidRevokeRequestDTO;
import io.mosip.resident.dto.IVidRequestDto;
Expand Down Expand Up @@ -48,6 +49,7 @@
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 reactor.util.function.Tuple2;

/**
* Resident VID controller class.
Expand Down Expand Up @@ -159,10 +161,12 @@ private ResponseEntity<Object> generateVidV2Version(IVidRequestDto<?> requestDto
validator.validateVidCreateV2Request(requestDto, isOtpValidationRequired, residentIndividualId);
auditUtil.setAuditRequestDto(
EventEnum.getEventEnumWithValue(EventEnum.GENERATE_VID, residentIndividualId));
ResponseWrapper<VidResponseDto> vidResponseDto = residentVidService.generateVid(requestDto.getRequest(), residentIndividualId);
Tuple2<ResponseWrapper<VidResponseDto>, String> tupleResponse = residentVidService.generateVidV2(requestDto.getRequest(), residentIndividualId);
auditUtil.setAuditRequestDto(EventEnum.getEventEnumWithValue(EventEnum.GENERATE_VID_SUCCESS,
residentIndividualId));
return ResponseEntity.ok().body(vidResponseDto);
return ResponseEntity.ok()
.header(ResidentConstants.EVENT_ID, tupleResponse.getT2())
.body(tupleResponse.getT1());
}

@PatchMapping(path = "/vid/{vid}", consumes = MediaType.APPLICATION_JSON_VALUE, produces = MediaType.APPLICATION_JSON_VALUE)
Expand Down Expand Up @@ -237,14 +241,15 @@ private ResponseEntity<Object> revokeVidV2Version(RequestWrapper<? extends BaseV
requestDto.getRequest().setVidStatus(requestDto.getRequest().getVidStatus().toUpperCase());
auditUtil.setAuditRequestDto(
EventEnum.getEventEnumWithValue(EventEnum.REVOKE_VID, residentIndividualId));
ResponseWrapper<VidRevokeResponseDTO> vidResponseDto = residentVidService.revokeVid(requestDto.getRequest(),
Tuple2<ResponseWrapper<VidRevokeResponseDTO>, String> tupleResponse = residentVidService.revokeVidV2(requestDto.getRequest(),
vid, residentIndividualId);
auditUtil.setAuditRequestDto(EventEnum.getEventEnumWithValue(EventEnum.REVOKE_VID_SUCCESS,
residentIndividualId));
return ResponseEntity.ok().body(vidResponseDto);
return ResponseEntity.ok()
.header(ResidentConstants.EVENT_ID, tupleResponse.getT2())
.body(tupleResponse.getT1());
}


private String getResidentIndividualId() throws ApisResourceAccessException {
return identityServiceImpl.getResidentIndvidualId();
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@ public class GenerateVidResponseDto extends VidResponseDtoV2 {
*
*/
private static final long serialVersionUID = 5728940858748492895L;
private String eventId;
private String status;

}
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@ public class RevokeVidResponseDto extends VidRevokeResponseDTO {
*
*/
private static final long serialVersionUID = 1973880019812497700L;
private String eventId;
private String status;

}
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
import io.mosip.resident.exception.ApisResourceAccessException;
import io.mosip.resident.exception.OtpValidationFailedException;
import io.mosip.resident.exception.ResidentServiceCheckedException;
import reactor.util.function.Tuple2;

@Service
public interface ResidentVidService {
Expand All @@ -28,4 +29,11 @@ public interface ResidentVidService {

public Optional<String> getPerpatualVid(String uin) throws ResidentServiceCheckedException, ApisResourceAccessException;

public Tuple2<ResponseWrapper<VidResponseDto>, String> generateVidV2(BaseVidRequestDto requestDto,
String individualId) throws OtpValidationFailedException, ResidentServiceCheckedException;

public Tuple2<ResponseWrapper<VidRevokeResponseDTO>, String> revokeVidV2(BaseVidRevokeRequestDTO requestDto,
String vid, String indivudalId)
throws OtpValidationFailedException, ResidentServiceCheckedException, ApisResourceAccessException;

}
Original file line number Diff line number Diff line change
Expand Up @@ -134,6 +134,9 @@ public Tuple2<Boolean, String> validateOtpV1(String transactionId, String indivi
try {
response = internelOtpAuth(transactionId, individualId, otp);
residentTransactionEntity = updateResidentTransaction(response.getResponse().isAuthStatus(), transactionId, individualId);
if (residentTransactionEntity != null) {
eventId = residentTransactionEntity.getEventId();
}
} catch (ApisResourceAccessException | InvalidKeySpecException | NoSuchAlgorithmException | IOException
| JsonProcessingException | java.security.cert.CertificateException e) {
logger.error(LoggerFileConstant.SESSIONID.toString(), LoggerFileConstant.USERID.toString(), null,
Expand All @@ -146,9 +149,6 @@ public Tuple2<Boolean, String> validateOtpV1(String transactionId, String indivi
throw new OtpValidationFailedException(response.getErrors().get(0).getErrorMessage(),
Map.of(ResidentConstants.EVENT_ID, eventId));
}
if (residentTransactionEntity != null) {
eventId = residentTransactionEntity.getEventId();
}
return Tuples.of(response.getResponse().isAuthStatus(), eventId);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,8 @@
import io.mosip.resident.util.EventEnum;
import io.mosip.resident.util.ResidentServiceRestClient;
import io.mosip.resident.util.Utilitiy;
import reactor.util.function.Tuple2;
import reactor.util.function.Tuples;

@Component
public class ResidentVidServiceImpl implements ResidentVidService {
Expand Down Expand Up @@ -163,6 +165,12 @@ public class ResidentVidServiceImpl implements ResidentVidService {
@Override
public ResponseWrapper<VidResponseDto> generateVid(BaseVidRequestDto requestDto,
String individualId) throws OtpValidationFailedException, ResidentServiceCheckedException {
return generateVidV2(requestDto, individualId).getT1();
}

@Override
public Tuple2<ResponseWrapper<VidResponseDto>, String> generateVidV2(BaseVidRequestDto requestDto,
String individualId) throws OtpValidationFailedException, ResidentServiceCheckedException {
boolean isV2Request = requestDto instanceof VidRequestDtoV2;
ResponseWrapper<VidResponseDto> responseDto = new ResponseWrapper<>();
NotificationRequestDto notificationRequestDto = isV2Request? new NotificationRequestDtoV2() : new NotificationRequestDto();
Expand Down Expand Up @@ -192,10 +200,14 @@ public ResponseWrapper<VidResponseDto> generateVid(BaseVidRequestDto requestDto,
IdentityDTO identityDTO = identityServiceImpl.getIdentity(individualId);
String email = identityDTO.getEmail();
String phone = identityDTO.getPhone();
String eventId = ResidentConstants.NOT_AVAILABLE;
ResidentTransactionEntity residentTransactionEntity=null;
try {
if(Utilitiy.isSecureSession()){
residentTransactionEntity = createResidentTransactionEntity(requestDto);
if (residentTransactionEntity != null) {
eventId = residentTransactionEntity.getEventId();
}
}
String uin = identityDTO.getUIN();
// generate vid
Expand All @@ -213,7 +225,7 @@ public ResponseWrapper<VidResponseDto> generateVid(BaseVidRequestDto requestDto,
NotificationRequestDtoV2 notificationRequestDtoV2=(NotificationRequestDtoV2) notificationRequestDto;
notificationRequestDtoV2.setTemplateType(TemplateType.SUCCESS);
notificationRequestDtoV2.setRequestType(RequestType.GENERATE_VID);
notificationRequestDtoV2.setEventId(residentTransactionEntity.getEventId());
notificationRequestDtoV2.setEventId(eventId);

notificationResponseDTO=notificationService
.sendNotification(notificationRequestDto, vidRequestDtoV2.getChannels(), email, phone);
Expand All @@ -230,7 +242,6 @@ public ResponseWrapper<VidResponseDto> generateVid(BaseVidRequestDto requestDto,
vidResponseDto = generateVidResponseDto;
generateVidResponseDto.setMaskedEmail(notificationResponseDTO.getMaskedEmail());
generateVidResponseDto.setMaskedPhone(notificationResponseDTO.getMaskedPhone());
generateVidResponseDto.setEventId(residentTransactionEntity.getEventId());
generateVidResponseDto.setStatus(ResidentConstants.SUCCESS);
} else {
vidResponseDto = new VidResponseDto();
Expand All @@ -255,7 +266,7 @@ public ResponseWrapper<VidResponseDto> generateVid(BaseVidRequestDto requestDto,
NotificationRequestDtoV2 notificationRequestDtoV2=(NotificationRequestDtoV2) notificationRequestDto;
notificationRequestDtoV2.setTemplateType(TemplateType.FAILURE);
notificationRequestDtoV2.setRequestType(RequestType.GENERATE_VID);
notificationRequestDtoV2.setEventId(residentTransactionEntity.getEventId());
notificationRequestDtoV2.setEventId(eventId);

notificationService.sendNotification(notificationRequestDto, vidRequestDtoV2.getChannels(), email, phone);
} else {
Expand All @@ -276,7 +287,7 @@ public ResponseWrapper<VidResponseDto> generateVid(BaseVidRequestDto requestDto,
NotificationRequestDtoV2 notificationRequestDtoV2=(NotificationRequestDtoV2) notificationRequestDto;
notificationRequestDtoV2.setTemplateType(TemplateType.FAILURE);
notificationRequestDtoV2.setRequestType(RequestType.GENERATE_VID);
notificationRequestDtoV2.setEventId(residentTransactionEntity.getEventId());
notificationRequestDtoV2.setEventId(eventId);

notificationService.sendNotification(notificationRequestDto, vidRequestDtoV2.getChannels(), email, phone);
} else {
Expand All @@ -297,7 +308,7 @@ public ResponseWrapper<VidResponseDto> generateVid(BaseVidRequestDto requestDto,
NotificationRequestDtoV2 notificationRequestDtoV2=(NotificationRequestDtoV2) notificationRequestDto;
notificationRequestDtoV2.setTemplateType(TemplateType.FAILURE);
notificationRequestDtoV2.setRequestType(RequestType.GENERATE_VID);
notificationRequestDtoV2.setEventId(residentTransactionEntity.getEventId());
notificationRequestDtoV2.setEventId(eventId);

notificationService.sendNotification(notificationRequestDto, vidRequestDtoV2.getChannels(), email, phone);
} else {
Expand Down Expand Up @@ -329,7 +340,7 @@ public ResponseWrapper<VidResponseDto> generateVid(BaseVidRequestDto requestDto,
}
responseDto.setResponsetime(DateUtils.formatToISOString(DateUtils.getUTCCurrentDateTime()));

return responseDto;
return Tuples.of(responseDto, eventId);
}

private ResidentTransactionEntity createResidentTransactionEntity(BaseVidRequestDto requestDto) throws ApisResourceAccessException, ResidentServiceCheckedException {
Expand Down Expand Up @@ -397,6 +408,12 @@ private VidGeneratorResponseDto vidGenerator(BaseVidRequestDto requestDto, Strin
@Override
public ResponseWrapper<VidRevokeResponseDTO> revokeVid(BaseVidRevokeRequestDTO requestDto, String vid, String indivudalId)
throws OtpValidationFailedException, ResidentServiceCheckedException, ApisResourceAccessException {
return revokeVidV2(requestDto, vid, indivudalId).getT1();
}

@Override
public Tuple2<ResponseWrapper<VidRevokeResponseDTO>, String> revokeVidV2(BaseVidRevokeRequestDTO requestDto, String vid, String indivudalId)
throws OtpValidationFailedException, ResidentServiceCheckedException, ApisResourceAccessException {
boolean isV2Request = requestDto instanceof VidRevokeRequestDTOV2;
ResponseWrapper<VidRevokeResponseDTO> responseDto = new ResponseWrapper<>();
NotificationRequestDto notificationRequestDto = isV2Request? new NotificationRequestDtoV2() : new NotificationRequestDto();
Expand Down Expand Up @@ -426,9 +443,13 @@ public ResponseWrapper<VidRevokeResponseDTO> revokeVid(BaseVidRevokeRequestDTO r
}
}
}
String eventId = ResidentConstants.NOT_AVAILABLE;
ResidentTransactionEntity residentTransactionEntity = null;
if(Utilitiy.isSecureSession()) {
residentTransactionEntity = createResidentTransEntity(vid, indivudalId);
if (residentTransactionEntity != null) {
eventId = residentTransactionEntity.getEventId();
}
}
IdentityDTO identityDTO = identityServiceImpl.getIdentity(indivudalId);
String uin = identityDTO.getUIN();
Expand Down Expand Up @@ -472,7 +493,7 @@ public ResponseWrapper<VidRevokeResponseDTO> revokeVid(BaseVidRevokeRequestDTO r
NotificationRequestDtoV2 notificationRequestDtoV2=(NotificationRequestDtoV2) notificationRequestDto;
notificationRequestDtoV2.setTemplateType(TemplateType.SUCCESS);
notificationRequestDtoV2.setRequestType(RequestType.REVOKE_VID);
notificationRequestDtoV2.setEventId(residentTransactionEntity.getEventId());
notificationRequestDtoV2.setEventId(eventId);

notificationResponseDTO=notificationService.sendNotification(notificationRequestDto);
} else {
Expand All @@ -486,7 +507,6 @@ public ResponseWrapper<VidRevokeResponseDTO> revokeVid(BaseVidRevokeRequestDTO r
if(isV2Request) {
RevokeVidResponseDto revokeVidResponseDto = new RevokeVidResponseDto();
vidRevokeResponseDto = revokeVidResponseDto;
revokeVidResponseDto.setEventId(residentTransactionEntity.getEventId());
revokeVidResponseDto.setStatus(ResidentConstants.SUCCESS);
} else {
vidRevokeResponseDto = new VidRevokeResponseDTO();
Expand All @@ -506,7 +526,7 @@ public ResponseWrapper<VidRevokeResponseDTO> revokeVid(BaseVidRevokeRequestDTO r
NotificationRequestDtoV2 notificationRequestDtoV2=(NotificationRequestDtoV2) notificationRequestDto;
notificationRequestDtoV2.setTemplateType(TemplateType.FAILURE);
notificationRequestDtoV2.setRequestType(RequestType.REVOKE_VID);
notificationRequestDtoV2.setEventId(residentTransactionEntity.getEventId());
notificationRequestDtoV2.setEventId(eventId);

notificationService.sendNotification(notificationRequestDto);
} else {
Expand All @@ -526,7 +546,7 @@ public ResponseWrapper<VidRevokeResponseDTO> revokeVid(BaseVidRevokeRequestDTO r
NotificationRequestDtoV2 notificationRequestDtoV2=(NotificationRequestDtoV2) notificationRequestDto;
notificationRequestDtoV2.setTemplateType(TemplateType.FAILURE);
notificationRequestDtoV2.setRequestType(RequestType.REVOKE_VID);
notificationRequestDtoV2.setEventId(residentTransactionEntity.getEventId());
notificationRequestDtoV2.setEventId(eventId);

notificationService.sendNotification(notificationRequestDto);
} else {
Expand All @@ -546,7 +566,7 @@ public ResponseWrapper<VidRevokeResponseDTO> revokeVid(BaseVidRevokeRequestDTO r
NotificationRequestDtoV2 notificationRequestDtoV2=(NotificationRequestDtoV2) notificationRequestDto;
notificationRequestDtoV2.setTemplateType(TemplateType.FAILURE);
notificationRequestDtoV2.setRequestType(RequestType.REVOKE_VID);
notificationRequestDtoV2.setEventId(residentTransactionEntity.getEventId());
notificationRequestDtoV2.setEventId(eventId);

notificationService.sendNotification(notificationRequestDto);
} else {
Expand Down Expand Up @@ -578,7 +598,7 @@ public ResponseWrapper<VidRevokeResponseDTO> revokeVid(BaseVidRevokeRequestDTO r
}
responseDto.setResponsetime(DateUtils.formatToISOString(DateUtils.getUTCCurrentDateTime()));

return responseDto;
return Tuples.of(responseDto, eventId);
}

private ResidentTransactionEntity createResidentTransEntity(String vid, String indivudalId) throws ApisResourceAccessException, ResidentServiceCheckedException {
Expand Down