* ============LICENSE_START=======================================================
* org.onap.aai
* ================================================================================
- * Copyright © 2017-2018 AT&T Intellectual Property. All rights reserved.
- * Copyright © 2017-2018 European Software Marketing Ltd.
+ * Copyright (c) 2017-2018 AT&T Intellectual Property. All rights reserved.
+ * Copyright (c) 2017-2019 European Software Marketing Ltd.
* ================================================================================
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* limitations under the License.
* ============LICENSE_END=========================================================
*/
+
package org.onap.aai.modelloader.config;
import java.io.File;
import java.nio.file.Path;
import java.nio.file.Paths;
import java.util.ArrayList;
+import java.util.Arrays;
import java.util.List;
import java.util.Properties;
-
import org.apache.commons.lang3.StringUtils;
import org.eclipse.jetty.util.security.Password;
import org.onap.sdc.api.consumer.IConfiguration;
protected static final String PROP_ML_DISTRIBUTION_ASDC_CONNECTION_DISABLED =
PREFIX_DISTRIBUTION_CLIENT + "ASDC_CONNECTION_DISABLE";
protected static final String PROP_ML_DISTRIBUTION_ASDC_ADDRESS = PREFIX_DISTRIBUTION_CLIENT + "ASDC_ADDRESS";
+ protected static final String PROP_ML_DISTRIBUTION_ASDC_USE_HTTPS = PREFIX_DISTRIBUTION_CLIENT + "ASDC_USE_HTTPS";
protected static final String PROP_ML_DISTRIBUTION_CONSUMER_GROUP = PREFIX_DISTRIBUTION_CLIENT + "CONSUMER_GROUP";
protected static final String PROP_ML_DISTRIBUTION_CONSUMER_ID = PREFIX_DISTRIBUTION_CLIENT + "CONSUMER_ID";
protected static final String PROP_ML_DISTRIBUTION_ENVIRONMENT_NAME =
private static String configHome;
private Properties modelLoaderProperties = null;
private String certLocation = ".";
- private List<String> artifactTypes = null;
- private List<String> msgBusAddrs = null;
+ private List<String> artifactTypes = new ArrayList<>();
+ private List<String> msgBusAddrs = new ArrayList<>();
private String modelVersion = null;
public ModelLoaderConfig(Properties configProperties) {
* Original constructor
*
* @param modelLoaderProperties
- * properties needed to be configured for the model loader
+ * properties needed to be configured for the model loader
* @param certLocation
- * location of the certificate
+ * location of the certificate
*/
public ModelLoaderConfig(Properties modelLoaderProperties, String certLocation) {
this.modelLoaderProperties = modelLoaderProperties;
this.certLocation = certLocation;
- // Get list of artifacts
- artifactTypes = new ArrayList<>();
- if (get(PROP_ML_DISTRIBUTION_ARTIFACT_TYPES) != null) {
- String[] artTypeList = get(PROP_ML_DISTRIBUTION_ARTIFACT_TYPES).split(",");
- for (String artType : artTypeList) {
- artifactTypes.add(artType);
- }
+ // Get list of artifact types
+ String types = get(PROP_ML_DISTRIBUTION_ARTIFACT_TYPES);
+ if (types != null) {
+ artifactTypes.addAll(Arrays.asList(types.split(",")));
}
// Get list of message bus addresses
- msgBusAddrs = new ArrayList<>();
- if (get(PROP_ML_DISTRIBUTION_MSG_BUS_ADDRESSES) != null) {
- String[] msgBusList = get(PROP_ML_DISTRIBUTION_MSG_BUS_ADDRESSES).split(",");
- for (String addr : msgBusList) {
- msgBusAddrs.add(addr);
- }
+ String addresses = get(PROP_ML_DISTRIBUTION_MSG_BUS_ADDRESSES);
+ if (addresses != null) {
+ msgBusAddrs.addAll(Arrays.asList(addresses.split(",")));
}
}
@Override
public boolean activateServerTLSAuth() {
String value = get(PROP_ML_DISTRIBUTION_ACTIVE_SERVER_TLS_AUTH);
- return value != null && Boolean.parseBoolean(value);
+ return Boolean.parseBoolean(value);
}
@Override
return get(PROP_ML_DISTRIBUTION_ASDC_ADDRESS);
}
+ @Override
+ public Boolean isUseHttpsWithSDC() {
+ /* if PROP_ML_DISTRIBUTION_ASDC_USE_HTTPS is null, https will be used, as before */
+ String value = get(PROP_ML_DISTRIBUTION_ASDC_USE_HTTPS);
+ if (value == null) {
+ return true;
+ }
+ return Boolean.parseBoolean(value);
+ }
+
@Override
public String getConsumerGroup() {
return get(PROP_ML_DISTRIBUTION_CONSUMER_GROUP);
public String getAaiModelUrl(String version) {
setModelVersion(version);
- return updatePropertyOXMVersion(modelLoaderProperties, PROP_AAI_MODEL_RESOURCE_URL, version);
+ return updatePropertyOXMVersion(PROP_AAI_MODEL_RESOURCE_URL, version);
}
public String getAaiNamedQueryUrl(String version) {
- return updatePropertyOXMVersion(modelLoaderProperties, PROP_AAI_NAMED_QUERY_RESOURCE_URL, version);
+ return updatePropertyOXMVersion(PROP_AAI_NAMED_QUERY_RESOURCE_URL, version);
}
public String getAaiVnfImageUrl() {
- return updatePropertyOXMVersion(modelLoaderProperties, PROP_AAI_VNF_IMAGE_RESOURCE_URL, getModelVersion());
+ return updatePropertyOXMVersion(PROP_AAI_VNF_IMAGE_RESOURCE_URL, getModelVersion());
}
public String getAaiAuthenticationUser() {
}
/**
- * @return a String value of the defined property with the oxm version
+ * Read the value of the property and replace any wildcard OXM version "v*" with the supplied default OXM version
+ *
+ * @param propertyName
+ * the name of the property storing the OXM version (possibly containing v*)
+ * @param version
+ * the default OXM version
+ * @return the String value of the defined property (with any wildcard OXM version defaulted)
*/
- private String updatePropertyOXMVersion(Properties modelLoaderProperties, String propertyName, String version) {
- if (version != null)
- return get(propertyName).replace("v*", version);
- else
- return get(propertyName);
+ private String updatePropertyOXMVersion(String propertyName, String version) {
+ String value = get(propertyName);
+ if (version != null && value != null) {
+ value = value.replace("v*", version);
+ }
+ return value;
}
/**
public boolean getASDCConnectionDisabled() {
String propValue = get(PROP_ML_DISTRIBUTION_ASDC_CONNECTION_DISABLED);
return propValue != null && "true".equalsIgnoreCase(propValue);
-
}
private String getDeobfuscatedValue(String property) {
- if (property.startsWith("OBF:")) {
+ if (property != null && property.startsWith("OBF:")) {
return Password.deobfuscate(property);
}
-
- // Property is not obfuscated
return property;
}
private String get(String key) {
String value = modelLoaderProperties.getProperty(key);
- if(value!= null && value.startsWith("ENV:")) {
+ if (value != null && value.startsWith("ENV:")) {
value = System.getenv(StringUtils.removeStart(value, "ENV:"));
}
return value;