diff options
author | Eylon Malin <eylon.malin@intl.att.com> | 2019-09-12 14:25:32 +0300 |
---|---|---|
committer | Eylon Malin <eylon.malin@intl.att.com> | 2019-09-12 14:25:32 +0300 |
commit | 2609cc76f0565466667fff8ae4d0707b94993877 (patch) | |
tree | e52f013baf27979dd8f0eb0d98bf6ff0c2cbb57f /vid-app-common/src/main/java/org/onap/vid/client/SyncRestClient.java | |
parent | 079dfc9647074f7e40c8b5fe3eac5bd2b50ade0c (diff) |
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 <eylon.malin@intl.att.com>
Change-Id: Ie00dce0ec9b366515c5e40d9f37b9e64a2ceb357
Diffstat (limited to 'vid-app-common/src/main/java/org/onap/vid/client/SyncRestClient.java')
-rw-r--r-- | vid-app-common/src/main/java/org/onap/vid/client/SyncRestClient.java | 25 |
1 files changed, 3 insertions, 22 deletions
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> T readValue(String value, Class<T> 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() { |