aboutsummaryrefslogtreecommitdiffstats
path: root/adapters/etsi-sol003-adapter/etsi-sol003-adapter-common/src/main/java/org
diff options
context:
space:
mode:
authorwaqas.ikram <waqas.ikram@est.tech>2020-05-29 17:08:54 +0100
committerwaqas.ikram <waqas.ikram@est.tech>2020-05-29 17:10:16 +0100
commitdf74daf492f6c7293ff3b31b0aa99342a8e0295b (patch)
treebb99b2fb7c076f2a09315680b5f4b97ab83ec622 /adapters/etsi-sol003-adapter/etsi-sol003-adapter-common/src/main/java/org
parent40a3997517147e638a7e87a8cad668db154414a7 (diff)
SOL003 Adapter removing duplicate code
Change-Id: Ibf6f2163516b852318b94510a793e25306a638b9 Issue-ID: SO-2771 Signed-off-by: waqas.ikram <waqas.ikram@est.tech>
Diffstat (limited to 'adapters/etsi-sol003-adapter/etsi-sol003-adapter-common/src/main/java/org')
-rw-r--r--adapters/etsi-sol003-adapter/etsi-sol003-adapter-common/src/main/java/org/onap/so/adapters/etsi/sol003/adapter/common/configuration/AbstractServiceProviderConfiguration.java50
1 files changed, 50 insertions, 0 deletions
diff --git a/adapters/etsi-sol003-adapter/etsi-sol003-adapter-common/src/main/java/org/onap/so/adapters/etsi/sol003/adapter/common/configuration/AbstractServiceProviderConfiguration.java b/adapters/etsi-sol003-adapter/etsi-sol003-adapter-common/src/main/java/org/onap/so/adapters/etsi/sol003/adapter/common/configuration/AbstractServiceProviderConfiguration.java
new file mode 100644
index 0000000000..6161fa60f9
--- /dev/null
+++ b/adapters/etsi-sol003-adapter/etsi-sol003-adapter-common/src/main/java/org/onap/so/adapters/etsi/sol003/adapter/common/configuration/AbstractServiceProviderConfiguration.java
@@ -0,0 +1,50 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * Copyright (C) 2020 Ericsson. 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.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ * SPDX-License-Identifier: Apache-2.0
+ * ============LICENSE_END=========================================================
+ */
+package org.onap.so.adapters.etsi.sol003.adapter.common.configuration;
+
+import java.util.Iterator;
+import org.springframework.http.converter.HttpMessageConverter;
+import org.springframework.http.converter.json.GsonHttpMessageConverter;
+import org.springframework.http.converter.json.MappingJackson2HttpMessageConverter;
+import org.springframework.web.client.RestTemplate;
+import com.google.gson.Gson;
+
+/**
+ * A base class that can be extended by classes for configuring HttpRestServiceProvider classes. Provides common methods
+ * that will be useful to some such classes.
+ *
+ * @author gareth.roper@est.tech
+ * @author Waqas Ikram (waqas.ikram@est.tech)
+ */
+public abstract class AbstractServiceProviderConfiguration {
+
+ public void setGsonMessageConverter(final RestTemplate restTemplate) {
+ final Iterator<HttpMessageConverter<?>> iterator = restTemplate.getMessageConverters().iterator();
+ while (iterator.hasNext()) {
+ if (iterator.next() instanceof MappingJackson2HttpMessageConverter) {
+ iterator.remove();
+ }
+ }
+ restTemplate.getMessageConverters().add(new GsonHttpMessageConverter(getGson()));
+ }
+
+ protected abstract Gson getGson();
+
+}