import com.att.eelf.configuration.EELFLogger;
import com.att.eelf.configuration.EELFManager;
-import com.fasterxml.jackson.databind.JsonNode;
+import com.google.gson.JsonObject;
import java.security.GeneralSecurityException;
import java.util.ArrayList;
import java.util.Arrays;
/**
* The root of the JSON.
*/
- private JsonNode jsonRootNode;
+ private JsonObject jsonRootNode;
// All keys that can be present in the JSON
public static final String CONSUMER_GROUP_ATTRIBUTE_NAME = "consumerGroup";
public static final String CONSUMER_ID_ATTRIBUTE_NAME = "consumerId";
public static final String TOSCA_CSAR = "TOSCA_CSAR";
public static final String VF_MODULES_METADATA = "VF_MODULES_METADATA";
private static final String[] SUPPORTED_ARTIFACT_TYPES = {
- HEAT, HEAT_ARTIFACT, HEAT_ENV, HEAT_NESTED, HEAT_NET, HEAT_VOL, OTHER, TOSCA_CSAR, VF_MODULES_METADATA
+ TOSCA_CSAR, VF_MODULES_METADATA
};
public static final List<String> SUPPORTED_ARTIFACT_TYPES_LIST = Collections
.unmodifiableList(Arrays.asList(SUPPORTED_ARTIFACT_TYPES));
* This constructor builds a SdcSingleControllerConfiguration from the
* corresponding json.
*
- * @param jsonRootNode
+ * @param jsonNode
* The JSON node
* @param controllerName
* The controller name that must appear in the JSON
*/
- public SdcSingleControllerConfiguration(JsonNode jsonNode, String controllerName) {
+ public SdcSingleControllerConfiguration(JsonObject jsonNode, String controllerName) {
jsonRootNode = jsonNode;
setSdcControllerName(controllerName);
testAllRequiredParameters();
return sdcControllerName;
}
+ /**
+ * Sets SDC controller name.
+ *
+ * @param controllerName SDC controller name
+ */
public void setSdcControllerName(String controllerName) {
this.sdcControllerName = controllerName;
errorMessageKeyNotFound = " parameter cannot be found in config file for controller name" + sdcControllerName;
private String getStringConfig(String key) {
if (jsonRootNode != null && jsonRootNode.get(key) != null) {
- String config = jsonRootNode.get(key).asText();
+ String config = jsonRootNode.get(key).getAsString();
return config.isEmpty() ? null : config;
}
return null;
private Integer getIntConfig(String key) {
if (jsonRootNode != null && jsonRootNode.get(key) != null) {
- return jsonRootNode.get(key).asInt();
+ return jsonRootNode.get(key).getAsInt();
} else {
return 0;
}
private String getEncryptedStringConfig(String key) throws GeneralSecurityException, DecoderException {
if (jsonRootNode != null && jsonRootNode.get(key) != null) {
- return jsonRootNode.get(key).asText().isEmpty() ? null
- : CryptoUtils.decrypt(jsonRootNode.get(key).asText());
+ return jsonRootNode.get(key).getAsString().isEmpty() ? null
+ : CryptoUtils.decrypt(jsonRootNode.get(key).getAsString());
}
return null;
}
@Override
public String getConsumerGroup() {
if (jsonRootNode != null && jsonRootNode.get(CONSUMER_GROUP_ATTRIBUTE_NAME) != null) {
- String config = jsonRootNode.get(CONSUMER_GROUP_ATTRIBUTE_NAME).asText();
+ String config = jsonRootNode.get(CONSUMER_GROUP_ATTRIBUTE_NAME).getAsString();
return "NULL".equals(config) || config.isEmpty() ? null : config;
}
return null;
@Override
public boolean activateServerTLSAuth() {
- if (jsonRootNode != null && jsonRootNode.get(ACTIVATE_SERVER_TLS_AUTH) != null) {
- return jsonRootNode.get(ACTIVATE_SERVER_TLS_AUTH).asBoolean(false);
+ if (jsonRootNode != null && jsonRootNode.get(ACTIVATE_SERVER_TLS_AUTH) != null
+ && jsonRootNode.get(ACTIVATE_SERVER_TLS_AUTH).isJsonPrimitive()) {
+ return jsonRootNode.get(ACTIVATE_SERVER_TLS_AUTH).getAsBoolean();
} else {
return false;
}
throw new SdcParametersException("Json is null for controller " + this.getSdcControllerName());
}
if (this.getConsumerGroup() == null && (jsonRootNode.get(CONSUMER_GROUP_ATTRIBUTE_NAME) == null
- || !"NULL".equals(jsonRootNode.get(CONSUMER_GROUP_ATTRIBUTE_NAME).asText()))) {
+ || !"NULL".equals(jsonRootNode.get(CONSUMER_GROUP_ATTRIBUTE_NAME).getAsString()))) {
throw new SdcParametersException(CONSUMER_GROUP_ATTRIBUTE_NAME + errorMessageKeyNotFound);
}
if (this.getConsumerID() == null || this.getConsumerID().isEmpty()) {
public List<String> getMsgBusAddress() {
List<String> addressesList = new ArrayList<>();
if (jsonRootNode != null && jsonRootNode.get(MESSAGE_BUS_ADDRESSES) != null) {
- jsonRootNode.get(MESSAGE_BUS_ADDRESSES).forEach(k -> addressesList.add(k.asText()));
+ jsonRootNode.get(MESSAGE_BUS_ADDRESSES).getAsJsonArray().forEach(k -> addressesList.add(k.getAsString()));
return addressesList;
} else {
return addressesList;