In the code mentioned below,
String additionalAttributes = new ObjectMapper().writeValueAsString(retrieveAttributes(requestApplication));
"additionalAttributes" is giving me first json response and sessionValidationResponse is giving me another json response, please note that both are having different return types(String and SessionValidationResponse ) how do I merge these responses to send a single json response
public SessionValidationResponse checkToken(String tokenId) throws RuntimeException {
System.out.println(" \n \n \n Enter in checkToken method");
System.out.println("Received Token ID: " + tokenId);
if (null != tokenId && tokenId != "") {
try {
String filepath = "session_validation.json";
String requestApplication = "myVf";
String additionalAttributes = new ObjectMapper().writeValueAsString(retrieveAttributes(requestApplication));
System.out.println("additionalAttributes: " +additionalAttributes);
try {
SessionValidationResponse sessionValidationResponse = jsonFileReader.read(filepath, new TypeReference<SessionValidationResponse>() {
});
sessionValidationResponse.setToken(createToken(sessionValidationResponse.getUserName(), new Date(), Calendar.getInstance().getTime()));
return sessionValidationResponse;
} catch (Exception e) {
throw new RuntimeException();
}
} catch (SignatureException e) {
throw new InvalidTokenException(new Exception(INVALID_TOKEN));
} catch (ExpiredJwtException e) {
throw new TokenExpirationException(new Exception(TOKEN_EXPIRED));
} catch (JsonProcessingException e) {
e.printStackTrace();
}
} else {
throw new TokenEmptyException(new Exception(TOKEN_NOT_FOUND));
}
return null;
}
Response of String type: {"status":"ACTIVE","msisdn":"45695","UT_MOBILE":"4258963144","gender":"MALE"}
Response of SessionValidationResponse type
{
"valid": true,
"uid": "demo",
"userName": "ABC",
"token": "randomToken",
"msisdn": "9949999499"
}