From 2609cc76f0565466667fff8ae4d0707b94993877 Mon Sep 17 00:00:00 2001 From: Eylon Malin Date: Thu, 12 Sep 2019 14:25:32 +0300 Subject: create JoshworksJacksonObjectMapper and use it everywhere needed Create class that implement joshworks object mapper that used jackson object mapper that support kotlin. Use it instead local anonymous classes where needed Issue-ID: VID-611 Signed-off-by: Eylon Malin Change-Id: Ie00dce0ec9b366515c5e40d9f37b9e64a2ceb357 --- .../java/org/onap/vid/client/SyncRestClient.java | 25 +++------------------- 1 file changed, 3 insertions(+), 22 deletions(-) (limited to 'vid-app-common/src/main/java/org/onap/vid/client/SyncRestClient.java') diff --git a/vid-app-common/src/main/java/org/onap/vid/client/SyncRestClient.java b/vid-app-common/src/main/java/org/onap/vid/client/SyncRestClient.java index 18f87223c..398d81dfb 100644 --- a/vid-app-common/src/main/java/org/onap/vid/client/SyncRestClient.java +++ b/vid-app-common/src/main/java/org/onap/vid/client/SyncRestClient.java @@ -3,6 +3,7 @@ * VID * ================================================================================ * Copyright (C) 2018 - 2019 Nokia. All rights reserved. + * Modifications Copyright (C) 2017 - 2019 AT&T Intellectual Property. All rights reserved. * ================================================================================ * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -20,8 +21,8 @@ package org.onap.vid.client; -import static org.apache.commons.lang3.StringUtils.isEmpty; import static org.onap.vid.client.UnirestPatchKt.patched; +import static org.onap.vid.utils.KotlinUtilsKt.JOSHWORKS_JACKSON_OBJECT_MAPPER; import com.att.eelf.configuration.EELFLogger; import io.joshworks.restclient.http.HttpResponse; @@ -183,27 +184,7 @@ public class SyncRestClient implements SyncRestClientInterface { } private ObjectMapper defaultObjectMapper() { - com.fasterxml.jackson.databind.ObjectMapper objectMapper = new com.fasterxml.jackson.databind.ObjectMapper(); - - return new ObjectMapper() { - @Override - public T readValue(String value, Class aClass) { - try { - return isEmpty(value) ? null : objectMapper.readValue(value, aClass); - } catch (IOException e) { - throw new SyncRestClientException("IOException while reading value", e); - } - } - - @Override - public String writeValue(Object value) { - try { - return objectMapper.writeValueAsString(value); - } catch (IOException e) { - throw new SyncRestClientException("IOException while writing value", e); - } - } - }; + return JOSHWORKS_JACKSON_OBJECT_MAPPER; } private CloseableHttpClient defaultHttpClient() { -- cgit 1.2.3-korg