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-35895,MOSIP-35655 - updated error messages. #897

Closed
wants to merge 1 commit into from
Closed
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 @@ -545,22 +545,26 @@ 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.getIsActive()){
LOGGER.error("Unable to deactivate device with id {}", device.getId());
throw new PartnerServiceException(ErrorCode.DEVICE_ALREADY_DEACTIVATED.getErrorCode(),
ErrorCode.DEVICE_ALREADY_DEACTIVATED.getErrorMessage());
}
if (!device.getApprovalStatus().equals(APPROVED)){
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_NOT_APPROVED.getErrorCode(),
ErrorCode.DEVICE_NOT_APPROVED.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 @@ -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.isActive()){
LOGGER.error("Unable to deactivate sbi with id {}", sbi.getId());
throw new PartnerServiceException(ErrorCode.SBI_ALREADY_DEACTIVATED.getErrorCode(),
ErrorCode.SBI_ALREADY_DEACTIVATED.getErrorMessage());
}
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());
}
// 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
@@ -1,7 +1,7 @@
package io.mosip.pms.device.constant;

public enum FoundationalTrustProviderErrorMessages {
FTP_PROVIDER_NOT_EXISTS("PMP_AUT_030","ftp provider not exists."),
FTP_PROVIDER_NOT_EXISTS("PMP_AUT_030","The FTP provider is either inactive or does not exist."),
FTP_CHIP_ID_NOT_EXISTS("PMP_AUT_031","ftp chip id not exists."),
FTP_PROVIDER_MAKE_MODEL_EXISTS("PMP_AUT_032","FTM Chip details already exists for the same make and model"),
FTP_CERT_NOT_UPLOADED("PMP_AUT_033","Certificate is not uploaded."),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -115,14 +115,16 @@ 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 selected device must be active and approved"),
DEVICE_ALREADY_DEACTIVATED("PMS_DEVICE_ERROR_014", "The selected device is 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", "The selected SBI must be active and approved"),
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"),
DEVICE_NOT_APPROVED("PMS_DEVICE_ERROR_022", "The selected device must have an approved status in order to be deactivated."),
SBI_NOT_APPROVED("PMS_DEVICE_ERROR_023", "The selected SBI must have an approved status in order to be deactivated."),
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"),
Expand Down
Loading