Skip to content

Commit

Permalink
MOSIP-21674 Added getRidStatus method in utility.
Browse files Browse the repository at this point in the history
  • Loading branch information
kameshsr committed Dec 15, 2022
1 parent fbe3949 commit 8e56187
Show file tree
Hide file tree
Showing 2 changed files with 46 additions and 31 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,7 @@ public enum ApiName {
GENDER_TYPE_BY_LANGCODE,
GET_RID_BY_INDIVIDUAL_ID,
PDFSIGN,
PARTNER_DETAILS_NEW_URL;
PARTNER_DETAILS_NEW_URL,
GET_RID_STATUS;

}
Original file line number Diff line number Diff line change
@@ -1,35 +1,9 @@
package io.mosip.resident.util;

import java.io.IOException;
import java.net.InetAddress;
import java.net.UnknownHostException;
import java.time.LocalDateTime;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.Optional;
import java.util.UUID;

import javax.annotation.PostConstruct;

import io.mosip.kernel.core.http.ResponseWrapper;
import io.mosip.resident.exception.IndividualIdNotFoundException;
import org.assertj.core.util.Lists;
import org.json.simple.JSONObject;
import org.json.simple.parser.JSONParser;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Qualifier;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.core.env.Environment;
import org.springframework.http.MediaType;
import org.springframework.stereotype.Component;
import org.springframework.web.client.RestTemplate;

import com.fasterxml.jackson.databind.ObjectMapper;

import io.mosip.kernel.core.exception.ExceptionUtils;
import io.mosip.kernel.core.exception.ServiceError;
import io.mosip.kernel.core.http.ResponseWrapper;
import io.mosip.kernel.core.logger.spi.Logger;
import io.mosip.kernel.core.util.DateUtils;
import io.mosip.kernel.core.util.StringUtils;
Expand All @@ -39,16 +13,34 @@
import io.mosip.resident.constant.MappingJsonConstants;
import io.mosip.resident.constant.RegistrationConstants;
import io.mosip.resident.constant.ResidentErrorCode;
import io.mosip.resident.dto.IdRequestDto;
import io.mosip.resident.dto.IdResponseDTO;
import io.mosip.resident.dto.IdResponseDTO1;
import io.mosip.resident.dto.RequestDto1;
import io.mosip.resident.dto.VidResponseDTO1;
import io.mosip.resident.exception.ApisResourceAccessException;
import io.mosip.resident.exception.IdRepoAppException;
import io.mosip.resident.exception.IndividualIdNotFoundException;
import io.mosip.resident.exception.ResidentServiceCheckedException;
import io.mosip.resident.exception.VidCreationException;
import lombok.Data;
import org.assertj.core.util.Lists;
import org.json.simple.JSONObject;
import org.json.simple.parser.JSONParser;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Qualifier;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.core.env.Environment;
import org.springframework.stereotype.Component;
import org.springframework.web.client.RestTemplate;

import javax.annotation.PostConstruct;
import java.io.IOException;
import java.net.InetAddress;
import java.net.UnknownHostException;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.Optional;
import java.util.UUID;

/**
* The Class Utilities.
Expand Down Expand Up @@ -233,6 +225,28 @@ public String getRidByIndividualId(String individualId) throws ApisResourceAcces
return rid;
}

public String getRidStatus(String rid) throws ApisResourceAccessException {
logger.debug(LoggerFileConstant.SESSIONID.toString(), LoggerFileConstant.REGISTRATIONID.toString(), "",
"Utilities::getRidStatus():: entry");
Map<String, String> pathsegments = new HashMap<String, String>();
pathsegments.put("rid", rid);
logger.debug(LoggerFileConstant.SESSIONID.toString(), LoggerFileConstant.REGISTRATIONID.toString(), "",
"Stage::methodname():: RETRIEVEIUINBYVID GET service call Started");

ResponseWrapper<?> response = (ResponseWrapper<?>) residentServiceRestClient.getApi(ApiName.GET_RID_STATUS,
pathsegments, ResponseWrapper.class);
logger.debug(LoggerFileConstant.SESSIONID.toString(), LoggerFileConstant.UIN.toString(), "",
"Utilities::getRidByIndividualId():: GET_RID_BY_INDIVIDUAL_ID GET service call ended successfully");

if (!response.getErrors().isEmpty()) {
throw new IndividualIdNotFoundException("Individual ID not found exception");

} else {
rid = (String) response.getResponse();
}
return rid;
}

public String getJson(String configServerFileStorageURL, String uri) {
if (StringUtils.isBlank(regProcessorIdentityJson)) {
return residentRestTemplate.getForObject(configServerFileStorageURL + uri, String.class);
Expand Down

0 comments on commit 8e56187

Please sign in to comment.