* Copyright (C) 2018 AT&T Intellectual Property. All rights
* reserved.
* ================================================================================
+ * Modifications Copyright (c) 2019 Samsung
+ * ================================================================================
* 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
* limitations under the License.
* ============LICENSE_END============================================
* ===================================================================
- * ECOMP is a trademark and service mark of AT&T Intellectual Property.
+ *
*/
package org.onap.clamp.clds.config.sdc;
-import com.att.eelf.configuration.EELFLogger;
-import com.att.eelf.configuration.EELFManager;
-import com.fasterxml.jackson.databind.JsonNode;
-import com.fasterxml.jackson.databind.ObjectMapper;
-
+import com.google.gson.JsonObject;
import java.io.IOException;
+import java.io.InputStreamReader;
+import java.nio.charset.StandardCharsets;
import java.util.HashMap;
import java.util.Map;
import javax.annotation.PostConstruct;
import org.onap.clamp.clds.exception.sdc.controller.SdcParametersException;
+import org.onap.clamp.clds.util.JsonUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.context.ApplicationContext;
*/
public class SdcControllersConfiguration {
- private static final EELFLogger logger = EELFManager.getInstance().getLogger(SdcControllersConfiguration.class);
- public static final String CONTROLLER_SUBTREE_KEY = "sdc-connections";
+ private static final String CONTROLLER_SUBTREE_KEY = "sdc-connections";
@Autowired
protected ApplicationContext appContext;
/**
/**
* The root of the JSON.
*/
- private JsonNode jsonRootNode;
+ private JsonObject jsonRootNode;
+ /**
+ * Loads configuration from SDC controller config file.
+ *
+ * @throws IOException IO Exception
+ */
@PostConstruct
public void loadConfiguration() throws IOException {
Resource resource = appContext.getResource(sdcControllerFile);
// Try to load json tree
- jsonRootNode = new ObjectMapper().readValue(resource.getInputStream(), JsonNode.class);
+ jsonRootNode = JsonUtils.GSON.fromJson(new InputStreamReader(
+ resource.getInputStream(), StandardCharsets.UTF_8),
+ JsonObject.class);
}
public SdcSingleControllerConfiguration getSdcSingleControllerConfiguration(String controllerName) {
public Map<String, SdcSingleControllerConfiguration> getAllDefinedControllers() {
Map<String, SdcSingleControllerConfiguration> result = new HashMap<>();
if (jsonRootNode.get(CONTROLLER_SUBTREE_KEY) != null) {
- jsonRootNode.get(CONTROLLER_SUBTREE_KEY).fields().forEachRemaining(entry -> result.put(entry.getKey(),
- new SdcSingleControllerConfiguration(entry.getValue(), entry.getKey())));
+ jsonRootNode.get(CONTROLLER_SUBTREE_KEY).getAsJsonObject().entrySet().forEach(
+ entry -> result.put(entry.getKey(),
+ new SdcSingleControllerConfiguration(entry.getValue().getAsJsonObject(), entry.getKey())));
} else {
throw new SdcParametersException(
CONTROLLER_SUBTREE_KEY + " key not found in the file: " + sdcControllerFile);