Skip to content

Commit a5bf1b0

Browse files
MOSIP-21009:Added the sonar bug fixes
1 parent c1e0080 commit a5bf1b0

2 files changed

Lines changed: 18 additions & 9 deletions

File tree

admin/admin-service/src/main/java/io/mosip/admin/packetstatusupdater/util/RestClient.java

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -204,9 +204,14 @@ public <T> T getApi(String url,
204204
try {
205205
ResponseEntity responseEntity= (ResponseEntity) restTemplate
206206
.exchange(url, HttpMethod.GET, setRequestHeader(null, null), responseType);
207-
if(url.contains("datashare") && responseEntity.getHeaders().getContentType().equals(MediaType.APPLICATION_JSON)){
208-
throw new MasterDataServiceException(ApplicantDetailErrorCode.DATA_SHARE_EXPIRED_EXCEPTION.getErrorCode(),
209-
ApplicantDetailErrorCode.DATA_SHARE_EXPIRED_EXCEPTION.getErrorMessage());
207+
MediaType contentType = responseEntity.getHeaders().getContentType();
208+
if (url.contains("datashare")) {
209+
if (contentType == null) {
210+
throw new NullPointerException("Content type is null");
211+
} else if (contentType.equals(MediaType.APPLICATION_JSON)) {
212+
throw new MasterDataServiceException(ApplicantDetailErrorCode.DATA_SHARE_EXPIRED_EXCEPTION.getErrorCode(),
213+
ApplicantDetailErrorCode.DATA_SHARE_EXPIRED_EXCEPTION.getErrorMessage());
214+
}
210215
}
211216
result= (T) responseEntity.getBody();
212217
} catch (Exception e) {

admin/admin-service/src/main/java/io/mosip/admin/service/impl/ApplicantDetailServiceImpl.java

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -110,12 +110,16 @@ public ApplicantDetailsDto getApplicantDetails(String rid) throws Exception {
110110
JSONObject mapperIdentity=utility.getJSONObject(idenitityJsonObject,IDENTITY);
111111
List<String> mapperJsonKeys = new ArrayList<>(mapperIdentity.keySet());
112112
for(String valueObj: applicantDetails){
113-
if(valueObj!=null && !valueObj.equalsIgnoreCase(ApplicantPhoto)){
114-
LinkedHashMap<String, String> jsonObject = utility.getJSONValue(mapperIdentity, valueObj);
115-
String value = jsonObject.get(VALUE);
116-
applicantDataMap.put(value,identityObj.get(value).toString());
117-
} else if (valueObj.equalsIgnoreCase(ApplicantPhoto)) {
118-
getImageData(documents,applicantDataMap);
113+
if(valueObj!=null) {
114+
if (!valueObj.equalsIgnoreCase(ApplicantPhoto)) {
115+
LinkedHashMap<String, String> jsonObject = utility.getJSONValue(mapperIdentity, valueObj);
116+
String value = jsonObject.get(VALUE);
117+
applicantDataMap.put(value, identityObj.get(value).toString());
118+
} else {
119+
getImageData(documents, applicantDataMap);
120+
}
121+
} else {
122+
throw new NullPointerException("valueObj is null");
119123
}
120124
}
121125
saveApplicantLoginDetails();

0 commit comments

Comments
 (0)