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:35655, MOSIP:36406 - bug fixes. #923

Merged
merged 1 commit into from
Oct 9, 2024
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 @@ -553,22 +553,27 @@ public ResponseWrapperV2<DeviceDetailResponseDto> deactivateDevice(String device
throw new PartnerServiceException(ErrorCode.PARTNER_NOT_ACTIVE_EXCEPTION.getErrorCode(),
ErrorCode.PARTNER_NOT_ACTIVE_EXCEPTION.getErrorMessage());
}
// Deactivate only if the device is approved status and is_active true.
if (device.getApprovalStatus().equals(APPROVED) && device.getIsActive()) {
DeviceDetailResponseDto deviceDetailResponseDto = new DeviceDetailResponseDto();

device.setIsActive(false);
DeviceDetail updatedDetail = deviceDetailRepository.save(device);
deviceDetailResponseDto.setDeviceId(updatedDetail.getId());
deviceDetailResponseDto.setStatus(updatedDetail.getApprovalStatus());
deviceDetailResponseDto.setActive(updatedDetail.getIsActive());

responseWrapper.setResponse(deviceDetailResponseDto);
} else {
if (!device.getApprovalStatus().equals(APPROVED)) {
LOGGER.error("Unable to deactivate device with id {}", device.getId());
throw new PartnerServiceException(ErrorCode.DEVICE_NOT_APPROVED.getErrorCode(),
ErrorCode.DEVICE_NOT_APPROVED.getErrorMessage());
}
if (device.getApprovalStatus().equals(APPROVED) && !device.getIsActive()) {
LOGGER.error("Unable to deactivate device with id {}", device.getId());
throw new PartnerServiceException(ErrorCode.UNABLE_TO_DEACTIVATE_DEVICE.getErrorCode(),
ErrorCode.UNABLE_TO_DEACTIVATE_DEVICE.getErrorMessage());
throw new PartnerServiceException(ErrorCode.DEVICE_ALREADY_DEACTIVATED.getErrorCode(),
ErrorCode.DEVICE_ALREADY_DEACTIVATED.getErrorMessage());
}

DeviceDetailResponseDto deviceDetailResponseDto = new DeviceDetailResponseDto();

device.setIsActive(false);
DeviceDetail updatedDetail = deviceDetailRepository.save(device);
deviceDetailResponseDto.setDeviceId(updatedDetail.getId());
deviceDetailResponseDto.setStatus(updatedDetail.getApprovalStatus());
deviceDetailResponseDto.setActive(updatedDetail.getIsActive());

responseWrapper.setResponse(deviceDetailResponseDto);

} catch (PartnerServiceException ex) {
LOGGER.info("sessionId", "idType", "id", "In deactivateDevice method of DeviceDetailServiceImpl - " + ex.getMessage());
responseWrapper.setErrors(MultiPartnerUtil.setErrorResponse(ex.getErrorCode(), ex.getErrorText()));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -535,22 +535,25 @@ public ResponseWrapperV2<FtmDetailResponseDto> deactivateFtm(String ftmId) {
FTPChipDetail ftm = ftmChipDetail.get();
Partner partnerDetails = getAssociatedPartner(partnerList, ftm, userId);
checkIfPartnerIsNotActive(partnerDetails);
// Deactivate only if the FTM is approved status and is_active true.
if (ftm.getApprovalStatus().equals(APPROVED) && ftm.isActive()) {
FtmDetailResponseDto ftmDetailResponseDto = new FtmDetailResponseDto();

ftm.setActive(false);
FTPChipDetail updatedDetail = ftpChipDetailRepository.save(ftm);
ftmDetailResponseDto.setFtmId(updatedDetail.getFtpChipDetailId());
ftmDetailResponseDto.setStatus(updatedDetail.getApprovalStatus());
ftmDetailResponseDto.setActive(updatedDetail.isActive());

responseWrapper.setResponse(ftmDetailResponseDto);
} else {
if (!ftm.getApprovalStatus().equals(APPROVED)) {
LOGGER.error("Unable to deactivate FTM with id {}", ftm.getFtpChipDetailId());
throw new PartnerServiceException(ErrorCode.UNABLE_TO_DEACTIVATE_FTM.getErrorCode(),
ErrorCode.UNABLE_TO_DEACTIVATE_FTM.getErrorMessage());
throw new PartnerServiceException(ErrorCode.FTM_NOT_APPROVED.getErrorCode(),
ErrorCode.FTM_NOT_APPROVED.getErrorMessage());
}
if (ftm.getApprovalStatus().equals(APPROVED) && !ftm.isActive()) {
LOGGER.error("Unable to deactivate FTM with id {}", ftm.getFtpChipDetailId());
throw new PartnerServiceException(ErrorCode.FTM_ALREADY_DEACTIVATED.getErrorCode(),
ErrorCode.FTM_ALREADY_DEACTIVATED.getErrorMessage());
}
FtmDetailResponseDto ftmDetailResponseDto = new FtmDetailResponseDto();

ftm.setActive(false);
FTPChipDetail updatedDetail = ftpChipDetailRepository.save(ftm);
ftmDetailResponseDto.setFtmId(updatedDetail.getFtpChipDetailId());
ftmDetailResponseDto.setStatus(updatedDetail.getApprovalStatus());
ftmDetailResponseDto.setActive(updatedDetail.isActive());

responseWrapper.setResponse(ftmDetailResponseDto);
} catch (PartnerServiceException ex) {
LOGGER.info("sessionId", "idType", "id", "In deactivateFtm method of FTPChipDetailServiceImpl - " + ex.getMessage());
responseWrapper.setErrors(MultiPartnerUtil.setErrorResponse(ex.getErrorCode(), ex.getErrorText()));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -777,39 +777,42 @@ public ResponseWrapperV2<SbiDetailsResponseDto> deactivateSbi(String sbiId) {
throw new PartnerServiceException(ErrorCode.PARTNER_NOT_ACTIVE_EXCEPTION.getErrorCode(),
ErrorCode.PARTNER_NOT_ACTIVE_EXCEPTION.getErrorMessage());
}
// Deactivate only if the SBI is approved and is_active true.
if (sbi.getApprovalStatus().equals(APPROVED) && sbi.isActive()) {
// Deactivate approved devices
List <DeviceDetail> approvedDevices = deviceDetailRepository.findApprovedDevicesBySbiId(sbiId);
if (!approvedDevices.isEmpty()) {
for (DeviceDetail deviceDetail: approvedDevices) {
deviceDetail.setIsActive(false);
deviceDetailRepository.save(deviceDetail);
}
if (!sbi.getApprovalStatus().equals(APPROVED)) {
LOGGER.error("Unable to deactivate sbi with id {}", sbi.getId());
throw new PartnerServiceException(ErrorCode.SBI_NOT_APPROVED.getErrorCode(),
ErrorCode.SBI_NOT_APPROVED.getErrorMessage());
}
if (sbi.getApprovalStatus().equals(APPROVED) && !sbi.isActive()) {
LOGGER.error("Unable to deactivate sbi with id {}", sbi.getId());
throw new PartnerServiceException(ErrorCode.SBI_ALREADY_DEACTIVATED.getErrorCode(),
ErrorCode.SBI_ALREADY_DEACTIVATED.getErrorMessage());
}
// Deactivate approved devices
List<DeviceDetail> approvedDevices = deviceDetailRepository.findApprovedDevicesBySbiId(sbiId);
if (!approvedDevices.isEmpty()) {
for (DeviceDetail deviceDetail : approvedDevices) {
deviceDetail.setIsActive(false);
deviceDetailRepository.save(deviceDetail);
}
// Reject pending_approval devices
List <DeviceDetail> pendingApprovalDevices = deviceDetailRepository.findPendingApprovalDevicesBySbiId(sbiId);
if (!pendingApprovalDevices.isEmpty()) {
for (DeviceDetail deviceDetail: pendingApprovalDevices) {
deviceDetail.setApprovalStatus(REJECTED);
deviceDetailRepository.save(deviceDetail);
}
}
// Reject pending_approval devices
List<DeviceDetail> pendingApprovalDevices = deviceDetailRepository.findPendingApprovalDevicesBySbiId(sbiId);
if (!pendingApprovalDevices.isEmpty()) {
for (DeviceDetail deviceDetail : pendingApprovalDevices) {
deviceDetail.setApprovalStatus(REJECTED);
deviceDetailRepository.save(deviceDetail);
}
sbi.setActive(false);
SecureBiometricInterface updatedSbi = sbiRepository.save(sbi);
SbiDetailsResponseDto sbiDetailsResponseDto = new SbiDetailsResponseDto();
}
sbi.setActive(false);
SecureBiometricInterface updatedSbi = sbiRepository.save(sbi);
SbiDetailsResponseDto sbiDetailsResponseDto = new SbiDetailsResponseDto();

sbiDetailsResponseDto.setSbiId(updatedSbi.getId());
sbiDetailsResponseDto.setSbiVersion(updatedSbi.getSwVersion());
sbiDetailsResponseDto.setStatus(updatedSbi.getApprovalStatus());
sbiDetailsResponseDto.setActive(updatedSbi.isActive());
sbiDetailsResponseDto.setSbiId(updatedSbi.getId());
sbiDetailsResponseDto.setSbiVersion(updatedSbi.getSwVersion());
sbiDetailsResponseDto.setStatus(updatedSbi.getApprovalStatus());
sbiDetailsResponseDto.setActive(updatedSbi.isActive());

responseWrapper.setResponse(sbiDetailsResponseDto);
} else {
LOGGER.error("Unable to deactivate sbi with id {}", sbi.getId());
throw new PartnerServiceException(ErrorCode.UNABLE_TO_DEACTIVATE_SBI.getErrorCode(),
ErrorCode.UNABLE_TO_DEACTIVATE_SBI.getErrorMessage());
}
responseWrapper.setResponse(sbiDetailsResponseDto);
} catch (PartnerServiceException ex) {
LOGGER.info("sessionId", "idType", "id", "In deactivateSbi method of SecureBiometricInterfaceServiceImpl - " + ex.getMessage());
responseWrapper.setErrors(MultiPartnerUtil.setErrorResponse(ex.getErrorCode(), ex.getErrorText()));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -115,23 +115,26 @@ public enum ErrorCode {
APPROVE_OR_REJECT_DEVICE_WITH_SBI_MAPPING_ERROR("PMS_DEVICE_ERROR_011", "Error while approving or rejecting device for Sbi Mapping."),
SBI_DEVICE_MAPPING_NOT_EXISTS("PMS_DEVICE_ERROR_012","SBI and Device mapping does not exists."),
INVALID_DEVICE_ID("PMS_DEVICE_ERROR_013", "Device Id is invalid"),
UNABLE_TO_DEACTIVATE_DEVICE("PMS_DEVICE_ERROR_014", "The device can only be deactivated if it is approved and has not been previously deactivated."),
DEVICE_ALREADY_DEACTIVATED("PMS_DEVICE_ERROR_014", "The selected device has been already deactivated."),
DEACTIVATE_DEVICE_ERROR("PMS_DEVICE_ERROR_015", "Error while deactivating the device"),
DEVICE_NOT_ASSOCIATED_WITH_USER("PMS_DEVICE_ERROR_016", "Device is not associated with user."),
INVALID_SBI_ID("PMS_DEVICE_ERROR_017", "SBI Id is invalid"),
DEACTIVATE_SBI_ERROR("PMS_DEVICE_ERROR_018", "Error while deactivating the SBI"),
SBI_NOT_ASSOCIATED_WITH_USER("PMS_DEVICE_ERROR_019", "SBI is not associated with user."),
UNABLE_TO_DEACTIVATE_SBI("PMS_DEVICE_ERROR_020", "SBI can only be deactivated if it is approved and has not been previously deactivated."),
SBI_ALREADY_DEACTIVATED("PMS_DEVICE_ERROR_020", "The selected SBI is already deactivated."),
SBI_EXPIRED("PMS_DEVICE_ERROR_021", "SBI for which device is being added is expired"),
SBI_NOT_APPROVED("PMS_DEVICE_ERROR_022", "The selected SBI is not in an approved status."),
DEVICE_NOT_APPROVED("PMS_DEVICE_ERROR_023", "The selected Device is not in an approved status."),
FTM_CHIP_DETAILS_LIST_FETCH_ERROR("PMS_FTM_ERROR_001", "Error while fetching the FTM chip details"),
APPROVED_FTM_PROVIDER_IDS_FETCH_ERROR("PMS_FTM_ERROR_002", "Unable to fetch approved FTM provider Ids."),
DEACTIVATE_FTM_ERROR("PMS_FTM_ERROR_003", "Error while deactivating the FTM"),
INVALID_FTM_ID("PMS_FTM_ERROR_004", "FTM Id is invalid"),
FTM_NOT_EXISTS("PMS_FTM_ERROR_005", "FTM Details do not exists."),
FTM_NOT_ASSOCIATED_WITH_USER("PMS_FTM_ERROR_006", "FTM is not associated with user."),
UNABLE_TO_DEACTIVATE_FTM("PMS_FTM_ERROR_007", "The selected FTM must be active and approved"),
FTM_ALREADY_DEACTIVATED("PMS_FTM_ERROR_007", "The selected FTM is already deactivated."),
DOWNLOAD_ORIGINAL_FTM_CERTIFICATE_ERROR("PMS_FTM_ERROR_008", "The selected FTM must be pending_approval or approved"),
UNABLE_TO_DOWNLOAD_ORIGINAL_FTM_CERTIFICATE("PMS_FTM_ERROR_009", "Unable to download original FTM certificate");
UNABLE_TO_DOWNLOAD_ORIGINAL_FTM_CERTIFICATE("PMS_FTM_ERROR_009", "Unable to download original FTM certificate"),
FTM_NOT_APPROVED("PMS_FTM_ERROR_010", "The selected FTM is not in an approved status.");
/**
* The error code.
*/
Expand Down
Loading