aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorefiacor <fiachra.corcoran@est.tech>2022-11-08 10:26:11 +0000
committerefiacor <fiachra.corcoran@est.tech>2022-11-08 10:28:21 +0000
commit117237ac7b65395e0f29b6cead9f6ffec2e7dc0f (patch)
treef5a0819a0a1c493e8486e5901ddfa300aaacb111 /src
parent59b12dd8dc8b86d6ecdfb3d51ca141a0c3e58c36 (diff)
[SDC-DIST] Upgrade sdc-distro-client to v 2.0.0
Signed-off-by: efiacor <fiachra.corcoran@est.tech> Issue-ID: DMAAP-1800 Change-Id: Idcfa147dd07a18953972b85f38ec2d46ba3fc009
Diffstat (limited to 'src')
-rw-r--r--src/main/java/org/onap/aai/modelloader/config/ModelLoaderConfig.java63
-rw-r--r--src/main/java/org/onap/aai/modelloader/service/ModelLoaderService.java17
-rw-r--r--src/test/java/org/onap/aai/modelloader/config/TestModelLoaderConfig.java13
-rw-r--r--src/test/java/org/onap/aai/modelloader/service/TestModelLoaderServiceWithSdc.java2
-rw-r--r--src/test/resources/model-loader-empty-auth-password.properties1
-rw-r--r--src/test/resources/model-loader-no-auth-password.properties1
-rw-r--r--src/test/resources/model-loader.properties1
-rw-r--r--src/test/resources/sdc_test/model-loader.properties1
8 files changed, 46 insertions, 53 deletions
diff --git a/src/main/java/org/onap/aai/modelloader/config/ModelLoaderConfig.java b/src/main/java/org/onap/aai/modelloader/config/ModelLoaderConfig.java
index f8c5d23..77693bc 100644
--- a/src/main/java/org/onap/aai/modelloader/config/ModelLoaderConfig.java
+++ b/src/main/java/org/onap/aai/modelloader/config/ModelLoaderConfig.java
@@ -31,6 +31,7 @@ import java.util.Properties;
import org.apache.commons.lang3.StringUtils;
import org.eclipse.jetty.util.security.Password;
import org.onap.sdc.api.consumer.IConfiguration;
+import org.springframework.core.env.Environment;
/**
* Properties for the Model Loader
@@ -72,11 +73,10 @@ public class ModelLoaderConfig implements IConfiguration {
protected static final String PROP_ML_DISTRIBUTION_POLLING_TIMEOUT = PREFIX_DISTRIBUTION_CLIENT + "POLLING_TIMEOUT";
protected static final String PROP_ML_DISTRIBUTION_USER = PREFIX_DISTRIBUTION_CLIENT + "USER";
protected static final String PROP_ML_DISTRIBUTION_ARTIFACT_TYPES = PREFIX_DISTRIBUTION_CLIENT + "ARTIFACT_TYPES";
- protected static final String PROP_ML_DISTRIBUTION_MSG_BUS_ADDRESSES =
- PREFIX_DISTRIBUTION_CLIENT + "MSG_BUS_ADDRESSES";
- protected static final String PROP_ML_DISTRIBUTION_HTTPS_WITH_DMAAP =
- PREFIX_DISTRIBUTION_CLIENT + "USE_HTTPS_WITH_DMAAP";
-
+ protected static final String PROP_ML_DISTRIBUTION_HTTP_PROXY_HOST = PREFIX_DISTRIBUTION_CLIENT + "HTTP_PROXY_HOST";
+ protected static final String PROP_ML_DISTRIBUTION_HTTP_PROXY_PORT = PREFIX_DISTRIBUTION_CLIENT + "HTTP_PROXY_PORT";
+ protected static final String PROP_ML_DISTRIBUTION_HTTPS_PROXY_HOST = PREFIX_DISTRIBUTION_CLIENT + "HTTPS_PROXY_HOST";
+ protected static final String PROP_ML_DISTRIBUTION_HTTPS_PROXY_PORT = PREFIX_DISTRIBUTION_CLIENT + "HTTPS_PROXY_PORT";
protected static final String PROP_AAI_BASE_URL = PREFIX_AAI + "BASE_URL";
protected static final String PROP_AAI_KEYSTORE_FILE = PREFIX_AAI + SUFFIX_KEYSTORE_FILE;
protected static final String PROP_AAI_KEYSTORE_PASSWORD = PREFIX_AAI + SUFFIX_KEYSTORE_PASS;
@@ -101,8 +101,7 @@ public class ModelLoaderConfig implements IConfiguration {
private static String configHome;
private Properties modelLoaderProperties = null;
private String certLocation = ".";
- private List<String> artifactTypes = new ArrayList<>();
- private List<String> msgBusAddrs = new ArrayList<>();
+ private final List<String> artifactTypes = new ArrayList<>();
private String modelVersion = null;
public ModelLoaderConfig(Properties configProperties) {
@@ -126,12 +125,6 @@ public class ModelLoaderConfig implements IConfiguration {
if (types != null) {
artifactTypes.addAll(Arrays.asList(types.split(",")));
}
-
- // Get list of message bus addresses
- String addresses = get(PROP_ML_DISTRIBUTION_MSG_BUS_ADDRESSES);
- if (addresses != null) {
- msgBusAddrs.addAll(Arrays.asList(addresses.split(",")));
- }
}
public static void setConfigHome(String configHome) {
@@ -149,7 +142,7 @@ public class ModelLoaderConfig implements IConfiguration {
}
@Override
- public String getAsdcAddress() {
+ public String getSdcAddress() {
return get(PROP_ML_DISTRIBUTION_ASDC_ADDRESS);
}
@@ -219,14 +212,23 @@ public class ModelLoaderConfig implements IConfiguration {
}
@Override
- public Boolean isUseHttpsWithDmaap() {
- String useHTTPS = get(PROP_ML_DISTRIBUTION_HTTPS_WITH_DMAAP);
- return useHTTPS != null && Boolean.valueOf(useHTTPS);
+ public String getHttpProxyHost() {
+ return getPropertyOrNull(PROP_ML_DISTRIBUTION_HTTP_PROXY_HOST);
+ }
+
+ @Override
+ public int getHttpProxyPort() {
+ return getIntegerPropertyOrZero(PROP_ML_DISTRIBUTION_HTTP_PROXY_PORT);
}
@Override
- public List<String> getMsgBusAddress() {
- return msgBusAddrs;
+ public String getHttpsProxyHost() {
+ return getPropertyOrNull(PROP_ML_DISTRIBUTION_HTTPS_PROXY_HOST);
+ }
+
+ @Override
+ public int getHttpsProxyPort() {
+ return getIntegerPropertyOrZero(PROP_ML_DISTRIBUTION_HTTPS_PROXY_PORT);
}
public String getAaiKeyStorePath() {
@@ -376,4 +378,27 @@ public class ModelLoaderConfig implements IConfiguration {
}
return value;
}
+
+ public String getPropertyOrNull(String propertyName) {
+ String value = modelLoaderProperties.getProperty(propertyName);
+ if (value == null || "NULL".equals(value) || value.isEmpty()) {
+ return null;
+ } else {
+ return value;
+ }
+ }
+
+ public int getIntegerPropertyOrZero(String propertyName) {
+ String property = modelLoaderProperties.getProperty(propertyName);
+ if (property == null || "NULL".equals(property) || property.isEmpty()) {
+ return 0;
+ } else {
+ try {
+ return Integer.parseInt(property);
+ } catch (NumberFormatException e) {
+ return 0;
+ }
+ }
+ }
+
}
diff --git a/src/main/java/org/onap/aai/modelloader/service/ModelLoaderService.java b/src/main/java/org/onap/aai/modelloader/service/ModelLoaderService.java
index 22f7671..dc17dfe 100644
--- a/src/main/java/org/onap/aai/modelloader/service/ModelLoaderService.java
+++ b/src/main/java/org/onap/aai/modelloader/service/ModelLoaderService.java
@@ -63,7 +63,7 @@ import org.springframework.web.bind.annotation.RestController;
@RequestMapping("/services/model-loader/v1/model-service")
public class ModelLoaderService implements ModelLoaderInterface {
- private static Logger logger = LoggerFactory.getInstance().getLogger(ModelLoaderService.class.getName());
+ private static final Logger logger = LoggerFactory.getInstance().getLogger(ModelLoaderService.class.getName());
@Value("${CONFIG_HOME}")
private String configDir;
@@ -84,21 +84,6 @@ public class ModelLoaderService implements ModelLoaderInterface {
try (InputStream configInputStream = Files.newInputStream(Paths.get(configDir, "model-loader.properties"))) {
configProperties.load(configInputStream);
config = new ModelLoaderConfig(configProperties);
-
- // Set the truststore for SDC Client to connect to Dmaap central bus if applicable (as in case of TI)
- if (Boolean.TRUE.equals(config.isUseHttpsWithDmaap())) {
- String trustStorePath = config.getKeyStorePath();
- String trustStorePassword = config.getKeyStorePassword();
- if (trustStorePath != null && Paths.get(trustStorePath).toFile().isFile() && trustStorePassword != null
- && !trustStorePassword.isEmpty()) {
- System.setProperty("javax.net.ssl.trustStore", trustStorePath);
- System.setProperty("javax.net.ssl.trustStorePassword", trustStorePassword);
- } else {
- throw new IllegalArgumentException("Model Loader property ml.distribution.KEYSTORE_FILE "
- + "or ml.distribution.KEYSTORE_PASSWORD not set or invalid");
- }
- }
-
if (!config.getASDCConnectionDisabled()) {
initSdcClient();
}
diff --git a/src/test/java/org/onap/aai/modelloader/config/TestModelLoaderConfig.java b/src/test/java/org/onap/aai/modelloader/config/TestModelLoaderConfig.java
index 5243ac5..e19b1e2 100644
--- a/src/test/java/org/onap/aai/modelloader/config/TestModelLoaderConfig.java
+++ b/src/test/java/org/onap/aai/modelloader/config/TestModelLoaderConfig.java
@@ -60,19 +60,6 @@ public class TestModelLoaderConfig {
}
@Test
- public void testMsgBusAddrs() {
- Properties props = new Properties();
- props.setProperty("ml.distribution.MSG_BUS_ADDRESSES", "host1.onap.com:3904,host2.onap.com:3904");
- ModelLoaderConfig config = new ModelLoaderConfig(props, null);
-
- List<String> addrs = config.getMsgBusAddress();
-
- assertEquals(2, addrs.size());
- assertEquals(0, addrs.get(0).compareToIgnoreCase("host1.onap.com:3904"));
- assertEquals(0, addrs.get(1).compareToIgnoreCase("host2.onap.com:3904"));
- }
-
- @Test
public void testDecryptPassword() {
String password = "youshallnotpass";
ModelLoaderConfig config =
diff --git a/src/test/java/org/onap/aai/modelloader/service/TestModelLoaderServiceWithSdc.java b/src/test/java/org/onap/aai/modelloader/service/TestModelLoaderServiceWithSdc.java
index ff0614b..d23b3ef 100644
--- a/src/test/java/org/onap/aai/modelloader/service/TestModelLoaderServiceWithSdc.java
+++ b/src/test/java/org/onap/aai/modelloader/service/TestModelLoaderServiceWithSdc.java
@@ -41,7 +41,7 @@ import org.springframework.test.context.junit4.SpringRunner;
*/
@RunWith(SpringRunner.class)
@SpringBootTest(classes = {ModelLoaderService.class, HttpsBabelServiceClientFactory.class})
-@TestPropertySource(properties = {"CONFIG_HOME=src/test/resources/sdc_test",})
+@TestPropertySource(properties = {"CONFIG_HOME=src/test/resources",})
public class TestModelLoaderServiceWithSdc {
@Autowired
diff --git a/src/test/resources/model-loader-empty-auth-password.properties b/src/test/resources/model-loader-empty-auth-password.properties
index fabd855..0724a13 100644
--- a/src/test/resources/model-loader-empty-auth-password.properties
+++ b/src/test/resources/model-loader-empty-auth-password.properties
@@ -1,7 +1,6 @@
# Model Loader Distribution Client Configuration
ml.distribution.ACTIVE_SERVER_TLS_AUTH=false
ml.distribution.ASDC_ADDRESS=localhost:8443
-ml.distribution.MSG_BUS_ADDRESSES=localhost
ml.distribution.CONSUMER_GROUP=aai-ml-group-test
ml.distribution.CONSUMER_ID=aai-ml-id-test
ml.distribution.ENVIRONMENT_NAME=env
diff --git a/src/test/resources/model-loader-no-auth-password.properties b/src/test/resources/model-loader-no-auth-password.properties
index 96b24c8..b0ecf2b 100644
--- a/src/test/resources/model-loader-no-auth-password.properties
+++ b/src/test/resources/model-loader-no-auth-password.properties
@@ -1,7 +1,6 @@
# Model Loader Distribution Client Configuration
ml.distribution.ACTIVE_SERVER_TLS_AUTH=false
ml.distribution.ASDC_ADDRESS=localhost:8443
-ml.distribution.MSG_BUS_ADDRESSES=localhost
ml.distribution.CONSUMER_GROUP=aai-ml-group-test
ml.distribution.CONSUMER_ID=aai-ml-id-test
ml.distribution.ENVIRONMENT_NAME=env
diff --git a/src/test/resources/model-loader.properties b/src/test/resources/model-loader.properties
index 3ba1519..51a38c5 100644
--- a/src/test/resources/model-loader.properties
+++ b/src/test/resources/model-loader.properties
@@ -1,7 +1,6 @@
# Model Loader Distribution Client Configuration
ml.distribution.ACTIVE_SERVER_TLS_AUTH=false
ml.distribution.ASDC_ADDRESS=localhost:8443
-ml.distribution.MSG_BUS_ADDRESSES=localhost
ml.distribution.CONSUMER_GROUP=aai-ml-group-test
ml.distribution.CONSUMER_ID=aai-ml-id-test
ml.distribution.ENVIRONMENT_NAME=env
diff --git a/src/test/resources/sdc_test/model-loader.properties b/src/test/resources/sdc_test/model-loader.properties
index ee5c0ed..958931f 100644
--- a/src/test/resources/sdc_test/model-loader.properties
+++ b/src/test/resources/sdc_test/model-loader.properties
@@ -1,7 +1,6 @@
# Model Loader Distribution Client Configuration
ml.distribution.ACTIVE_SERVER_TLS_AUTH=false
ml.distribution.ASDC_ADDRESS=localhost:8443
-ml.distribution.MSG_BUS_ADDRESSES=localhost
ml.distribution.CONSUMER_GROUP=aai-ml-group-test
ml.distribution.CONSUMER_ID=aai-ml-id-test
ml.distribution.ENVIRONMENT_NAME=env