Skip to content

Commit

Permalink
Update InfraProviderServiceImpl.java
Browse files Browse the repository at this point in the history
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 0584cb2 commit 66ddf57
Showing 1 changed file with 5 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -266,7 +266,8 @@ public MISPLicenseResponseDto regenerateKey(String mispId) {
MISPErrorMessages.MISP_LICENSE_KEY_NOT_ASSOCIATED_MISP_ID.getErrorMessage());
}
List<PartnerPolicyRequest> approvedPolicyMappedReq = partnerPolicyRequestRepository.findByPartnerId(mispId);
String policyId = (!approvedPolicyMappedReq.isEmpty() && !approvedPolicyMappedReq.get(0).getPolicyId().isBlank())?approvedPolicyMappedReq.get(0).getPolicyId():null;
PartnerPolicyRequest mispPolicy= approvedPolicyMappedReq.get(0);
String policyId = (!approvedPolicyMappedReq.isEmpty() && !mispPolicy.getPolicyId().isBlank())?mispPolicy.getPolicyId():null;
MISPLicenseResponseDto response = new MISPLicenseResponseDto();
if (mispValidLicenses.isEmpty()) {
MISPLicenseEntity newLicenseKey = generateLicense(mispId, policyId);
Expand All @@ -277,12 +278,12 @@ public MISPLicenseResponseDto regenerateKey(String mispId) {

Optional<AuthPolicy> mispPolicyFromDb = Optional.empty();
if(!approvedPolicyMappedReq.isEmpty()) {
if(!approvedPolicyMappedReq.stream().allMatch(p->p.getStatusCode().equalsIgnoreCase(APPROVED_STATUS))){
if(!mispPolicy.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());
mispPolicyFromDb = authPolicyRepository.findById(mispPolicy.getPolicyId());
if(mispPolicyFromDb.isEmpty()) {
throw new MISPServiceException(MISPErrorMessages.MISP_POLICY_NOT_EXISTS.getErrorCode(),
MISPErrorMessages.MISP_POLICY_NOT_EXISTS.getErrorMessage());
Expand All @@ -296,7 +297,6 @@ public MISPLicenseResponseDto regenerateKey(String mispId) {
else {
notify(MapperUtils.mapDataToPublishDto(newLicenseKey), EventType.MISP_LICENSE_UPDATED);
}

}
else {
response.setLicenseKey(mispValidLicenses.get(0).getLicenseKey());
Expand Down Expand Up @@ -394,4 +394,4 @@ public void validateLoggedInUserAuthorization(String loggedInUserId) {
ErrorCode.LOGGEDIN_USER_NOT_AUTHORIZED.getErrorMessage());
}
}
}
}

0 comments on commit 66ddf57

Please sign in to comment.