Updated code for visura response and added logs for better tracking.

This commit is contained in:
rajesh
2025-06-05 16:33:54 +05:30
parent b02417cd00
commit f380aee919

View File

@@ -772,19 +772,28 @@ public class AppointmentDao {
public AppointmentLoginResponse parseVisuraResponse(String jsonResponse) { public AppointmentLoginResponse parseVisuraResponse(String jsonResponse) {
try { try {
// Log full raw JSON for debug purposes
log.info("Raw Visura JSON Response: {}", jsonResponse);
ObjectMapper objectMapper = new ObjectMapper(); ObjectMapper objectMapper = new ObjectMapper();
JsonNode rootNode = objectMapper.readTree(jsonResponse); JsonNode rootNode = objectMapper.readTree(jsonResponse);
JsonNode dataNode = rootNode.get(GepafinConstant.DATA_STRING); JsonNode dataNode = rootNode.get(GepafinConstant.DATA_STRING);
if (dataNode != null) { if (dataNode != null && dataNode.isObject()) {
AppointmentLoginResponse response = new AppointmentLoginResponse(); AppointmentLoginResponse response = new AppointmentLoginResponse();
response.setIdVisura(normalizeNullValue(dataNode.get(GepafinConstant.ID_VISURA_STRING).asText())); JsonNode idVisuraNode = dataNode.get(GepafinConstant.ID_VISURA_STRING);
response.setNdg(normalizeNullValue(dataNode.get(GepafinConstant.NDG_STRING).asText())); JsonNode ndgNode = dataNode.get(GepafinConstant.NDG_STRING);
if (idVisuraNode == null || ndgNode == null) {
log.error("Missing expected fields in 'data' node. JSON: {}", dataNode);
}
response.setIdVisura(normalizeNullValue(idVisuraNode != null ? idVisuraNode.asText() : null));
response.setNdg(normalizeNullValue(ndgNode != null ? ndgNode.asText() : null));
return response; return response;
} else { } else {
throw new RuntimeException("Invalid JSON structure: Missing 'data' node."); System.err.println("Invalid JSON: 'data' node is missing or not an object.");
throw new RuntimeException("Invalid JSON structure: Missing or malformed 'data' node.");
} }
} catch (Exception e) { } catch (Exception e) {
System.err.println("Exception while parsing Visura response: " + e.getMessage());
throw new RuntimeException("Failed to parse response: " + e.getMessage(), e); throw new RuntimeException("Failed to parse response: " + e.getMessage(), e);
} }
} }