aboutsummaryrefslogtreecommitdiffstats
path: root/src/main/java/org/onap/dcae/configuration
diff options
context:
space:
mode:
Diffstat (limited to 'src/main/java/org/onap/dcae/configuration')
-rw-r--r--src/main/java/org/onap/dcae/configuration/ConfigFilesFacade.java130
-rw-r--r--src/main/java/org/onap/dcae/configuration/ConfigLoader.java99
-rw-r--r--src/main/java/org/onap/dcae/configuration/ConfigLoaderFactory.java37
-rw-r--r--src/main/java/org/onap/dcae/configuration/ConfigParsing.java57
-rw-r--r--src/main/java/org/onap/dcae/configuration/Conversions.java47
-rw-r--r--src/main/java/org/onap/dcae/configuration/cbs/CbsClientConfigurationResolver.java61
-rw-r--r--src/main/java/org/onap/dcae/configuration/cbs/CbsConfigResolver.java58
-rw-r--r--src/main/java/org/onap/dcae/configuration/cbs/CbsConfigResolverFactory.java31
8 files changed, 520 insertions, 0 deletions
diff --git a/src/main/java/org/onap/dcae/configuration/ConfigFilesFacade.java b/src/main/java/org/onap/dcae/configuration/ConfigFilesFacade.java
new file mode 100644
index 00000000..c0280c75
--- /dev/null
+++ b/src/main/java/org/onap/dcae/configuration/ConfigFilesFacade.java
@@ -0,0 +1,130 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * org.onap.dcaegen2.collectors.ves
+ * ================================================================================
+ * Copyright (C) 2017-2018 AT&T Intellectual Property. All rights reserved.
+ * Copyright (C) 2020 Nokia. 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.
+ * ============LICENSE_END=========================================================
+ */
+package org.onap.dcae.configuration;
+
+import static io.vavr.API.Try;
+import static org.onap.dcae.common.publishing.VavrUtils.enhanceError;
+import static org.onap.dcae.common.publishing.VavrUtils.f;
+import static org.onap.dcae.common.publishing.VavrUtils.logError;
+import static org.onap.dcae.configuration.Conversions.toList;
+
+import io.vavr.CheckedRunnable;
+import io.vavr.Tuple2;
+import io.vavr.collection.Map;
+import io.vavr.control.Try;
+import java.io.FileNotFoundException;
+import java.nio.charset.StandardCharsets;
+import java.nio.file.Files;
+import java.nio.file.Path;
+import org.apache.commons.configuration.ConfigurationException;
+import org.apache.commons.configuration.PropertiesConfiguration;
+import org.json.JSONObject;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+class ConfigFilesFacade {
+
+ private static final Logger log = LoggerFactory.getLogger(ConfigFilesFacade.class);
+
+ private final Path dMaaPConfigPath;
+ private final Path propertiesPath;
+
+ ConfigFilesFacade(Path propertiesPath, Path dMaaPConfigPath) {
+ this.propertiesPath = propertiesPath;
+ this.dMaaPConfigPath = dMaaPConfigPath;
+ }
+
+ Try<Map<String, String>> readCollectorProperties() {
+ log.info(f("Reading collector properties from path: '%s'", propertiesPath));
+ return Try(this::readProperties)
+ .map(prop -> toList(prop.getKeys()).toMap(k -> k, k -> (String) prop.getProperty(k)))
+ .mapFailure(enhanceError("Unable to read properties configuration from path '%s'", propertiesPath))
+ .onFailure(logError(log))
+ .peek(props -> log.info(f("Read following collector properties: '%s'", props)));
+ }
+
+ Try<JSONObject> readDMaaPConfiguration() {
+ log.info(f("Reading DMaaP configuration from file: '%s'", dMaaPConfigPath));
+ return readFile(dMaaPConfigPath)
+ .recover(FileNotFoundException.class, __ -> "{}")
+ .mapFailure(enhanceError("Unable to read DMaaP configuration from file '%s'", dMaaPConfigPath))
+ .flatMap(Conversions::toJson)
+ .onFailure(logError(log))
+ .peek(props -> log.info(f("Read following DMaaP properties: '%s'", props)));
+ }
+
+ Try<Void> writeDMaaPConfiguration(JSONObject dMaaPConfiguration) {
+ log.info(f("Writing DMaaP configuration '%s' into file '%s'", dMaaPConfiguration, dMaaPConfigPath));
+ return writeFile(dMaaPConfigPath, indentConfiguration(dMaaPConfiguration.toString()))
+ .mapFailure(enhanceError("Could not save new DMaaP configuration to path '%s'", dMaaPConfigPath))
+ .onFailure(logError(log))
+ .peek(__ -> log.info("Written successfully"));
+ }
+
+
+ Try<Void> writeProperties(Map<String, String> properties) {
+ log.info(f("Writing properties configuration '%s' into file '%s'", properties, propertiesPath));
+ return Try.run(saveProperties(properties))
+ .mapFailure(enhanceError("Could not save properties to path '%s'", properties))
+ .onFailure(logError(log))
+ .peek(__ -> log.info("Written successfully"));
+ }
+
+ private Try<String> readFile(Path path) {
+ return Try(() -> new String(Files.readAllBytes(path), StandardCharsets.UTF_8))
+ .mapFailure(enhanceError("Could not read content from path: '%s'", path));
+ }
+
+ private Try<Void> writeFile(Path path, String content) {
+ return Try.run(() -> Files.write(path, content.getBytes()))
+ .mapFailure(enhanceError("Could not write content to path: '%s'", path));
+ }
+
+ private PropertiesConfiguration readProperties() throws ConfigurationException {
+ PropertiesConfiguration propertiesConfiguration = new PropertiesConfiguration();
+ propertiesConfiguration.setDelimiterParsingDisabled(true);
+ propertiesConfiguration.load(propertiesPath.toFile());
+ return propertiesConfiguration;
+ }
+
+ private CheckedRunnable saveProperties(Map<String, String> properties) {
+ return () -> {
+ PropertiesConfiguration propertiesConfiguration = new PropertiesConfiguration(propertiesPath.toFile());
+ propertiesConfiguration.setEncoding(null);
+ for (Tuple2<String, String> property : properties) {
+ updateProperty(propertiesConfiguration, property);
+ }
+ propertiesConfiguration.save();
+ };
+ }
+
+ private void updateProperty(PropertiesConfiguration propertiesConfiguration, Tuple2<String, String> property) {
+ if (propertiesConfiguration.containsKey(property._1)) {
+ propertiesConfiguration.setProperty(property._1, property._2);
+ } else {
+ propertiesConfiguration.addProperty(property._1, property._2);
+ }
+ }
+
+ private String indentConfiguration(String configuration) {
+ return new JSONObject(configuration).toString(4);
+ }
+} \ No newline at end of file
diff --git a/src/main/java/org/onap/dcae/configuration/ConfigLoader.java b/src/main/java/org/onap/dcae/configuration/ConfigLoader.java
new file mode 100644
index 00000000..eaeb09e3
--- /dev/null
+++ b/src/main/java/org/onap/dcae/configuration/ConfigLoader.java
@@ -0,0 +1,99 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * org.onap.dcaegen2.collectors.ves
+ * ================================================================================
+ * Copyright (C) 2020 Nokia. 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.
+ * ============LICENSE_END=========================================================
+ */
+package org.onap.dcae.configuration;
+
+import io.vavr.collection.Map;
+import io.vavr.control.Option;
+import org.json.JSONObject;
+import org.onap.dcae.configuration.cbs.CbsConfigResolver;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+public class ConfigLoader {
+
+ private static final Logger log = LoggerFactory.getLogger(ConfigLoader.class);
+ private final ConfigFilesFacade configFilesFacade;
+ private final CbsConfigResolver cbsConfigResolver;
+ private final Runnable applicationRestarter;
+ private boolean isApplicationRestartNeeded;
+
+ ConfigLoader(ConfigFilesFacade configFilesFacade, CbsConfigResolver cbsConfigResolver, Runnable applicationRestarter) {
+ this.configFilesFacade = configFilesFacade;
+ this.cbsConfigResolver = cbsConfigResolver;
+ this.applicationRestarter = applicationRestarter;
+ this.isApplicationRestartNeeded = false;
+ }
+
+ public synchronized void updateConfig() {
+ Option<JSONObject> appConfig = cbsConfigResolver.getAppConfig();
+ appConfig.peek(this::handleUpdate).onEmpty(logSkipMessage());
+ }
+
+ private Runnable logSkipMessage() {
+ return () -> log.info("Skipping dynamic configuration");
+ }
+
+ private void handleUpdate(JSONObject appConfig) {
+ updatePropertiesIfChanged(appConfig);
+ updateDmaapConfigIfChanged(appConfig);
+ restartApplicationIfNeeded();
+ }
+
+ private void updatePropertiesIfChanged(JSONObject appConfig) {
+ Map<String, String> newProperties = ConfigParsing.getProperties(appConfig);
+ Map<String, String> oldProperties = configFilesFacade.readCollectorProperties().get();
+
+ if (!areCommonPropertiesSame(oldProperties, newProperties)) {
+ configFilesFacade.writeProperties(newProperties);
+ isApplicationRestartNeeded = true;
+ }
+ }
+
+ private boolean areCommonPropertiesSame(Map<String, String> oldProperties, Map<String, String> newProperties) {
+ Map<String, String> filteredOldProperties = filterIntersectingKeys(oldProperties, newProperties);
+ return filteredOldProperties.equals(newProperties);
+ }
+
+ private Map<String, String> filterIntersectingKeys(Map<String, String> primaryProperties,
+ Map<String, String> otherProperties) {
+ return primaryProperties.filterKeys(key -> containsKey(key, otherProperties));
+ }
+
+ private boolean containsKey(String key, Map<String, String> properties) {
+ return properties.keySet().contains(key);
+ }
+
+ private void updateDmaapConfigIfChanged(JSONObject appConfig) {
+ JSONObject oldDmaapConfig = configFilesFacade.readDMaaPConfiguration().get();
+ JSONObject newDmaapConfig = ConfigParsing.getDMaaPConfig(appConfig).get();
+
+ if (!oldDmaapConfig.similar(newDmaapConfig)) {
+ configFilesFacade.writeDMaaPConfiguration(newDmaapConfig);
+ isApplicationRestartNeeded = true;
+ }
+ }
+
+ private void restartApplicationIfNeeded() {
+ if (isApplicationRestartNeeded) {
+ applicationRestarter.run();
+ isApplicationRestartNeeded = false;
+ }
+ }
+} \ No newline at end of file
diff --git a/src/main/java/org/onap/dcae/configuration/ConfigLoaderFactory.java b/src/main/java/org/onap/dcae/configuration/ConfigLoaderFactory.java
new file mode 100644
index 00000000..e5ea3c59
--- /dev/null
+++ b/src/main/java/org/onap/dcae/configuration/ConfigLoaderFactory.java
@@ -0,0 +1,37 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * org.onap.dcaegen2.collectors.ves
+ * ================================================================================
+ * Copyright (C) 2020 Nokia. 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.
+ * ============LICENSE_END=========================================================
+ */
+package org.onap.dcae.configuration;
+
+import java.nio.file.Path;
+import org.onap.dcae.VesApplication;
+import org.onap.dcae.configuration.cbs.CbsConfigResolver;
+import org.onap.dcae.configuration.cbs.CbsConfigResolverFactory;
+
+public class ConfigLoaderFactory {
+
+ public static ConfigLoader create(Path propertiesFile, Path dmaapConfigFile) {
+ ConfigFilesFacade configFilesFacade = new ConfigFilesFacade(propertiesFile, dmaapConfigFile);
+ CbsConfigResolver cbsConfigResolver = new CbsConfigResolverFactory().create();
+ return new ConfigLoader(
+ configFilesFacade,
+ cbsConfigResolver,
+ VesApplication::restartApplication);
+ }
+} \ No newline at end of file
diff --git a/src/main/java/org/onap/dcae/configuration/ConfigParsing.java b/src/main/java/org/onap/dcae/configuration/ConfigParsing.java
new file mode 100644
index 00000000..13deff73
--- /dev/null
+++ b/src/main/java/org/onap/dcae/configuration/ConfigParsing.java
@@ -0,0 +1,57 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * org.onap.dcaegen2.collectors.ves
+ * ================================================================================
+ * Copyright (C) 2017-2018 AT&T Intellectual Property. All rights reserved.
+ * Copyright (C) 2020 Nokia. 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.
+ * ============LICENSE_END=========================================================
+ */
+package org.onap.dcae.configuration;
+
+import static io.vavr.API.Try;
+import static io.vavr.API.Tuple;
+import static org.onap.dcae.common.publishing.VavrUtils.f;
+import static org.onap.dcae.configuration.Conversions.toList;
+
+import io.vavr.collection.Map;
+import io.vavr.control.Option;
+import org.json.JSONObject;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+interface ConfigParsing {
+
+ Logger log = LoggerFactory.getLogger(ConfigParsing.class);
+
+ static Option<JSONObject> getDMaaPConfig(JSONObject configuration) {
+ log.info(f("Getting DMaaP configuration from app configuration: '%s'", configuration));
+ return toList(configuration.toMap().entrySet().iterator())
+ .filter(t -> t.getKey().startsWith("streams_publishes"))
+ .headOption()
+ .flatMap(e -> Try(() -> configuration.getJSONObject(e.getKey())).toOption())
+ .onEmpty(() -> log.warn(f("App configuration '%s' is missing DMaaP configuration ('streams_publishes' key) "
+ + "or DMaaP configuration is not a valid json document", configuration)))
+ .peek(dMaaPConf -> log.info(f("Found following DMaaP configuration: '%s'", dMaaPConf)));
+ }
+
+ static Map<String, String> getProperties(JSONObject configuration) {
+ log.info(f("Getting properties configuration from app configuration: '%s'", configuration));
+ Map<String, String> confEntries = toList(configuration.toMap().entrySet().iterator())
+ .toMap(e -> Tuple(e.getKey(), String.valueOf(e.getValue())))
+ .filterKeys(e -> !e.startsWith("streams_publishes"));
+ log.info(f("Found following app properties: '%s'", confEntries));
+ return confEntries;
+ }
+} \ No newline at end of file
diff --git a/src/main/java/org/onap/dcae/configuration/Conversions.java b/src/main/java/org/onap/dcae/configuration/Conversions.java
new file mode 100644
index 00000000..85c3f78d
--- /dev/null
+++ b/src/main/java/org/onap/dcae/configuration/Conversions.java
@@ -0,0 +1,47 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * org.onap.dcaegen2.collectors.ves
+ * ================================================================================
+ * Copyright (C) 2018,2020 Nokia. 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.
+ * ============LICENSE_END=========================================================
+ */
+package org.onap.dcae.configuration;
+
+import static org.onap.dcae.common.publishing.VavrUtils.enhanceError;
+
+import io.vavr.API;
+import io.vavr.collection.List;
+import io.vavr.control.Try;
+import java.util.Iterator;
+import java.util.Spliterator;
+import java.util.Spliterators;
+import java.util.stream.StreamSupport;
+import org.json.JSONObject;
+
+/**
+ * @author Pawel Szalapski (pawel.szalapski@nokia.com)
+ */
+interface Conversions {
+
+ static Try<JSONObject> toJson(String strBody) {
+ return API.Try(() -> new JSONObject(strBody))
+ .mapFailure(enhanceError("Value '%s' is not a valid JSON document", strBody));
+ }
+
+ static <T> List<T> toList(Iterator<T> iterator) {
+ return List
+ .ofAll(StreamSupport.stream(Spliterators.spliteratorUnknownSize(iterator, Spliterator.ORDERED), false));
+ }
+} \ No newline at end of file
diff --git a/src/main/java/org/onap/dcae/configuration/cbs/CbsClientConfigurationResolver.java b/src/main/java/org/onap/dcae/configuration/cbs/CbsClientConfigurationResolver.java
new file mode 100644
index 00000000..360e0a8f
--- /dev/null
+++ b/src/main/java/org/onap/dcae/configuration/cbs/CbsClientConfigurationResolver.java
@@ -0,0 +1,61 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * org.onap.dcaegen2.collectors.ves
+ * ================================================================================
+ * Copyright (C) 2020 Nokia. 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.
+ * ============LICENSE_END=========================================================
+ */
+package org.onap.dcae.configuration.cbs;
+
+import io.vavr.control.Option;
+import org.onap.dcaegen2.services.sdk.rest.services.cbs.client.model.CbsClientConfiguration;
+import org.onap.dcaegen2.services.sdk.rest.services.cbs.client.model.ImmutableCbsClientConfiguration;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+class CbsClientConfigurationResolver {
+
+ private static final Logger LOGGER = LoggerFactory.getLogger(CbsClientConfigurationResolver.class);
+
+ private final String defaultProtocol = "http";
+ private final String defaultHostname = "config-binding-service";
+ private final int defaultPort = 10000;
+ private final String defaultAppName = "dcae-ves-collector";
+
+ CbsClientConfiguration resolveCbsClientConfiguration() {
+ try {
+ return CbsClientConfiguration.fromEnvironment();
+ } catch (Exception e) {
+ LOGGER.warn("Failed resolving CBS client configuration from system environments: " + e);
+ }
+ LOGGER.info("Falling back to use default CBS client configuration properties");
+ return getFallbackConfiguration();
+ }
+
+ private ImmutableCbsClientConfiguration getFallbackConfiguration() {
+ LOGGER.info("Falling back to use default CBS client configuration");
+ return createCbsClientConfiguration(defaultProtocol, defaultHostname, defaultAppName, defaultPort);
+ }
+
+ private ImmutableCbsClientConfiguration createCbsClientConfiguration(String protocol, String hostname,
+ String appName, Integer port) {
+ return ImmutableCbsClientConfiguration.builder()
+ .protocol(protocol)
+ .hostname(hostname)
+ .port(port)
+ .appName(appName)
+ .build();
+ }
+} \ No newline at end of file
diff --git a/src/main/java/org/onap/dcae/configuration/cbs/CbsConfigResolver.java b/src/main/java/org/onap/dcae/configuration/cbs/CbsConfigResolver.java
new file mode 100644
index 00000000..5a66c294
--- /dev/null
+++ b/src/main/java/org/onap/dcae/configuration/cbs/CbsConfigResolver.java
@@ -0,0 +1,58 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * org.onap.dcaegen2.collectors.ves
+ * ================================================================================
+ * Copyright (C) 2020 Nokia. 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.
+ * ============LICENSE_END=========================================================
+ */
+package org.onap.dcae.configuration.cbs;
+
+import com.google.gson.JsonObject;
+import io.vavr.control.Option;
+import java.util.function.Consumer;
+import org.json.JSONObject;
+import org.onap.dcaegen2.services.sdk.rest.services.cbs.client.api.CbsClientFactory;
+import org.onap.dcaegen2.services.sdk.rest.services.cbs.client.api.CbsRequests;
+import org.onap.dcaegen2.services.sdk.rest.services.cbs.client.model.CbsClientConfiguration;
+import org.onap.dcaegen2.services.sdk.rest.services.cbs.client.model.CbsRequest;
+import org.onap.dcaegen2.services.sdk.rest.services.model.logging.RequestDiagnosticContext;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+
+
+public class CbsConfigResolver {
+
+ private static final Logger log = LoggerFactory.getLogger(CbsConfigResolver.class);
+
+ private final CbsClientConfiguration cbsClientConfiguration;
+ private final RequestDiagnosticContext diagnosticContext = RequestDiagnosticContext.create();
+ private final CbsRequest cbsConfigurationRequest = CbsRequests.getConfiguration(diagnosticContext);
+
+ CbsConfigResolver(CbsClientConfiguration cbsClientConfiguration) {
+ this.cbsClientConfiguration = cbsClientConfiguration;
+ }
+
+ public Option<JSONObject> getAppConfig() {
+ JsonObject emptyJson = new JsonObject();
+ JsonObject jsonObject = CbsClientFactory.createCbsClient(cbsClientConfiguration)
+ .flatMap(cbsClient -> cbsClient.get(cbsConfigurationRequest))
+ .doOnError(error -> log.warn("Failed to fetch configuration from CBS " + error.getMessage()))
+ .onErrorReturn(emptyJson)
+ .block();
+
+ return emptyJson.equals(jsonObject) ? Option.none() : Option.of(new JSONObject(jsonObject.toString()));
+ }
+} \ No newline at end of file
diff --git a/src/main/java/org/onap/dcae/configuration/cbs/CbsConfigResolverFactory.java b/src/main/java/org/onap/dcae/configuration/cbs/CbsConfigResolverFactory.java
new file mode 100644
index 00000000..aa3ee00f
--- /dev/null
+++ b/src/main/java/org/onap/dcae/configuration/cbs/CbsConfigResolverFactory.java
@@ -0,0 +1,31 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * org.onap.dcaegen2.collectors.ves
+ * ================================================================================
+ * Copyright (C) 2020 Nokia. 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.
+ * ============LICENSE_END=========================================================
+ */
+package org.onap.dcae.configuration.cbs;
+
+import org.onap.dcaegen2.services.sdk.rest.services.cbs.client.model.CbsClientConfiguration;
+
+public class CbsConfigResolverFactory {
+
+ public CbsConfigResolver create() {
+ CbsClientConfigurationResolver resolver = new CbsClientConfigurationResolver();
+ CbsClientConfiguration cbsClientConfiguration = resolver.resolveCbsClientConfiguration();
+ return new CbsConfigResolver(cbsClientConfiguration);
+ }
+} \ No newline at end of file