Change method names into meaningfull names

pull/423/head
Rajitha Kumara 5 months ago
parent 665b013a96
commit 1352168d5e

@ -112,7 +112,7 @@ public class HandlerUtil {
HandlerConstants.INTERNAL_ERROR_CODE)); HandlerConstants.INTERNAL_ERROR_CODE));
return handlerResponse; return handlerResponse;
} }
JsonNode responseData = getResponseData(responseEntity); JsonNode responseData = getResponseDataAsJsonNode(responseEntity);
if (statusCode == HttpStatus.SC_OK || statusCode == HttpStatus.SC_CREATED) { if (statusCode == HttpStatus.SC_OK || statusCode == HttpStatus.SC_CREATED) {
handlerResponse.setCode(statusCode); handlerResponse.setCode(statusCode);
handlerResponse.setData(responseData); handlerResponse.setData(responseData);
@ -756,12 +756,12 @@ public class HandlerUtil {
* @return {@link JsonNode} consists with response data content * @return {@link JsonNode} consists with response data content
* @throws IOException Throws when IO exception encountered * @throws IOException Throws when IO exception encountered
*/ */
public static JsonNode getResponseData(HttpEntity responseEntity) throws IOException { public static JsonNode getResponseDataAsJsonNode(HttpEntity responseEntity) throws IOException {
JsonFactory jsonFactory = new JsonFactory(); JsonFactory jsonFactory = new JsonFactory();
ObjectMapper objectMapper = new ObjectMapper(jsonFactory); ObjectMapper objectMapper = new ObjectMapper(jsonFactory);
JsonNode finalNode; JsonNode finalNode;
try (InputStream inputStream = responseEntity.getContent()) { try (InputStream inputStream = responseEntity.getContent()) {
String content = getResponseAsString(inputStream); String content = getResponseDataAsString(inputStream);
try { try {
finalNode = objectMapper.readTree(content); finalNode = objectMapper.readTree(content);
} catch (JsonProcessingException e) { } catch (JsonProcessingException e) {
@ -779,7 +779,7 @@ public class HandlerUtil {
* @return String content of the incoming response * @return String content of the incoming response
* @throws IOException Throws when IO exception encountered * @throws IOException Throws when IO exception encountered
*/ */
public static String getResponseAsString(InputStream inputStream) throws IOException { public static String getResponseDataAsString(InputStream inputStream) throws IOException {
char []buffer = new char[8192]; char []buffer = new char[8192];
StringBuilder stringBuilder = new StringBuilder(); StringBuilder stringBuilder = new StringBuilder();
try (Reader reader = new InputStreamReader(inputStream, StandardCharsets.UTF_8)) { try (Reader reader = new InputStreamReader(inputStream, StandardCharsets.UTF_8)) {

Loading…
Cancel
Save