Skip to content

Commit

Permalink
[MOSIP-29852]Update InfraProviderServiceImpl.java
Browse files Browse the repository at this point in the history
Signed-off-by: Balaji Alluru <[email protected]>
Signed-off-by: Balaji <[email protected]>
Signed-off-by: kameshsr <[email protected]>
  • Loading branch information
balaji-alluru authored and kameshsr committed Jun 7, 2024
1 parent d9a1cc0 commit 45c9449
Showing 1 changed file with 24 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -274,7 +274,30 @@ public MISPLicenseResponseDto regenerateKey(String mispId) {
response.setLicenseKeyExpiry(newLicenseKey.getValidToDate());
response.setLicenseKeyStatus("Active");
response.setProviderId(mispId);
notify(MapperUtils.mapDataToPublishDto(newLicenseKey), EventType.MISP_LICENSE_UPDATED);
List<PartnerPolicyRequest> approvedPolicyMappedReq = partnerPolicyRequestRepository.findByPartnerId(mispId);
Optional<AuthPolicy> mispPolicyFromDb = Optional.empty();
if(!approvedPolicyMappedReq.isEmpty()) {
if(!approvedPolicyMappedReq.stream().allMatch(p->p.getStatusCode().equalsIgnoreCase(APPROVED_STATUS))){
throw new MISPServiceException(MISPErrorMessages.MISP_POLICY_NOT_APPROVED.getErrorCode(),
MISPErrorMessages.MISP_POLICY_NOT_APPROVED.getErrorMessage());
}

mispPolicyFromDb = authPolicyRepository.findById(approvedPolicyMappedReq.get(0).getPolicyId());
if(mispPolicyFromDb.isEmpty()) {
throw new MISPServiceException(MISPErrorMessages.MISP_POLICY_NOT_EXISTS.getErrorCode(),
MISPErrorMessages.MISP_POLICY_NOT_EXISTS.getErrorMessage());
}
}

String policyId = mispPolicyFromDb.isPresent()?mispPolicyFromDb.get().getId():null;
if(mispPolicyFromDb.isPresent()) {
notify(MapperUtils.mapDataToPublishDto(newLicenseKey), MapperUtils.mapPolicyToPublishDto(mispPolicyFromDb.get(),
getPolicyObject(mispPolicyFromDb.get().getPolicyFileId())), EventType.MISP_LICENSE_UPDATED);
}
else {
notify(MapperUtils.mapDataToPublishDto(newLicenseKey), EventType.MISP_LICENSE_UPDATED);
}

}

if (licenseKey.getIsActive() && licenseKey.getValidToDate().isAfter(LocalDateTime.now())) {
Expand Down

0 comments on commit 45c9449

Please sign in to comment.