aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJim Hahn <jrh3@att.com>2021-07-22 15:23:37 +0000
committerGerrit Code Review <gerrit@onap.org>2021-07-22 15:23:37 +0000
commit81371839bd42ee2c54a072614e0da8d057032beb (patch)
tree997fd58bbb406d351e15b5e6863ad67e53d8ed8f
parentfdb749f777927106cd01510374bc13487a40fe90 (diff)
parentcbb065aa43db6a1552aeb51bbb8b1020333a7aba (diff)
Merge "Revert "Use new RestClientParameters class in distribution""
-rw-r--r--forwarding/src/main/java/org/onap/policy/distribution/forwarding/PolicyForwarder.java5
-rw-r--r--packages/policy-distribution-tarball/src/main/resources/etc/defaultConfig.json9
-rw-r--r--packages/policy-distribution-tarball/src/main/resources/etc/s3pConfig.json7
-rw-r--r--plugins/forwarding-plugins/src/main/java/org/onap/policy/distribution/forwarding/lifecycle/api/LifecycleApiForwarderParameters.java7
-rw-r--r--plugins/forwarding-plugins/src/main/java/org/onap/policy/distribution/forwarding/lifecycle/api/LifecycleApiParameters.java48
-rw-r--r--plugins/forwarding-plugins/src/main/java/org/onap/policy/distribution/forwarding/lifecycle/api/LifecycleApiPolicyForwarder.java21
-rw-r--r--plugins/forwarding-plugins/src/test/java/org/onap/policy/distribution/forwarding/lifecycle/api/LifecycleApiForwarderParametersTest.java13
-rw-r--r--plugins/forwarding-plugins/src/test/resources/parameters/LifecycleApiPolicyForwarderParameters.json9
-rw-r--r--plugins/forwarding-plugins/src/test/resources/parameters/LifecycleApiPolicyForwarderParametersInvalid.json9
-rw-r--r--reception/src/main/java/org/onap/policy/distribution/reception/handling/PluginHandler.java3
-rw-r--r--testsuites/stability/src/main/resources/distributionsetup/distribution/etc/defaultConfig.json7
11 files changed, 85 insertions, 53 deletions
diff --git a/forwarding/src/main/java/org/onap/policy/distribution/forwarding/PolicyForwarder.java b/forwarding/src/main/java/org/onap/policy/distribution/forwarding/PolicyForwarder.java
index e4fba0ae..3059f2f0 100644
--- a/forwarding/src/main/java/org/onap/policy/distribution/forwarding/PolicyForwarder.java
+++ b/forwarding/src/main/java/org/onap/policy/distribution/forwarding/PolicyForwarder.java
@@ -1,7 +1,6 @@
/*-
* ============LICENSE_START=======================================================
* Copyright (C) 2018 Ericsson. All rights reserved.
- * Modifications Copyright (C) 2021 AT&T Intellectual Property. 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.
@@ -22,7 +21,6 @@
package org.onap.policy.distribution.forwarding;
import java.util.Collection;
-import org.onap.policy.common.endpoints.http.client.HttpClientConfigException;
import org.onap.policy.models.tosca.authorative.concepts.ToscaEntity;
/**
@@ -42,9 +40,8 @@ public interface PolicyForwarder {
*
* @param parameterGroupName the name of the parameter group which contains the configuration
* for the policy forwarder
- * @throws HttpClientConfigException if an exception occurs
*/
- void configure(String parameterGroupName) throws HttpClientConfigException;
+ void configure(String parameterGroupName);
/**
* Forward the given policies.
diff --git a/packages/policy-distribution-tarball/src/main/resources/etc/defaultConfig.json b/packages/policy-distribution-tarball/src/main/resources/etc/defaultConfig.json
index 36bec4c0..f5fe30d5 100644
--- a/packages/policy-distribution-tarball/src/main/resources/etc/defaultConfig.json
+++ b/packages/policy-distribution-tarball/src/main/resources/etc/defaultConfig.json
@@ -71,21 +71,20 @@
"parameterClassName": "org.onap.policy.distribution.forwarding.lifecycle.api.LifecycleApiForwarderParameters",
"parameters": {
"apiParameters": {
- "hostname": "policy-api",
+ "hostName": "policy-api",
"port": 6969,
- "useHttps": true,
"userName": "healthcheck",
"password": "zb!XztG34"
},
"papParameters": {
- "hostname": "policy-pap",
+ "hostName": "policy-pap",
"port": 6969,
- "useHttps": true,
"userName": "healthcheck",
"password": "zb!XztG34"
},
+ "isHttps": true,
"deployPolicies": true
}
}
}
-}
+} \ No newline at end of file
diff --git a/packages/policy-distribution-tarball/src/main/resources/etc/s3pConfig.json b/packages/policy-distribution-tarball/src/main/resources/etc/s3pConfig.json
index b2970e73..4589fddc 100644
--- a/packages/policy-distribution-tarball/src/main/resources/etc/s3pConfig.json
+++ b/packages/policy-distribution-tarball/src/main/resources/etc/s3pConfig.json
@@ -51,19 +51,18 @@
"parameterClassName": "org.onap.policy.distribution.forwarding.lifecycle.api.LifecycleApiForwarderParameters",
"parameters": {
"apiParameters": {
- "hostname": "policy-api",
+ "hostName": "policy-api",
"port": 6969,
- "useHttps": true,
"userName": "healthcheck",
"password": "zb!XztG34"
},
"papParameters": {
- "hostname": "policy-pap",
+ "hostName": "policy-pap",
"port": 6969,
- "useHttps": true,
"userName": "healthcheck",
"password": "zb!XztG34"
},
+ "isHttps": true,
"deployPolicies": true
}
}
diff --git a/plugins/forwarding-plugins/src/main/java/org/onap/policy/distribution/forwarding/lifecycle/api/LifecycleApiForwarderParameters.java b/plugins/forwarding-plugins/src/main/java/org/onap/policy/distribution/forwarding/lifecycle/api/LifecycleApiForwarderParameters.java
index 060be1ad..c266a1ba 100644
--- a/plugins/forwarding-plugins/src/main/java/org/onap/policy/distribution/forwarding/lifecycle/api/LifecycleApiForwarderParameters.java
+++ b/plugins/forwarding-plugins/src/main/java/org/onap/policy/distribution/forwarding/lifecycle/api/LifecycleApiForwarderParameters.java
@@ -22,7 +22,6 @@
package org.onap.policy.distribution.forwarding.lifecycle.api;
import lombok.Getter;
-import org.onap.policy.common.endpoints.parameters.RestClientParameters;
import org.onap.policy.common.parameters.annotations.NotBlank;
import org.onap.policy.common.parameters.annotations.NotNull;
import org.onap.policy.common.parameters.annotations.Valid;
@@ -39,8 +38,10 @@ import org.onap.policy.distribution.main.parameters.PolicyForwarderConfiguration
public class LifecycleApiForwarderParameters extends PolicyForwarderConfigurationParameterGroup {
public static final String POLICY_FORWARDER_PLUGIN_CLASS = LifecycleApiPolicyForwarder.class.getName();
- private @Valid RestClientParameters apiParameters;
- private @Valid RestClientParameters papParameters;
+ private @Valid LifecycleApiParameters apiParameters;
+ private @Valid LifecycleApiParameters papParameters;
+ private boolean isHttps;
+ private boolean allowSelfSignedCerts;
private boolean deployPolicies = true;
public LifecycleApiForwarderParameters() {
diff --git a/plugins/forwarding-plugins/src/main/java/org/onap/policy/distribution/forwarding/lifecycle/api/LifecycleApiParameters.java b/plugins/forwarding-plugins/src/main/java/org/onap/policy/distribution/forwarding/lifecycle/api/LifecycleApiParameters.java
new file mode 100644
index 00000000..46a7b082
--- /dev/null
+++ b/plugins/forwarding-plugins/src/main/java/org/onap/policy/distribution/forwarding/lifecycle/api/LifecycleApiParameters.java
@@ -0,0 +1,48 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * Copyright (C) 2019 Nordix Foundation.
+ * ================================================================================
+ * 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.
+ *
+ * SPDX-License-Identifier: Apache-2.0
+ * ============LICENSE_END=========================================================
+ */
+
+package org.onap.policy.distribution.forwarding.lifecycle.api;
+
+import lombok.Getter;
+import org.onap.policy.common.parameters.annotations.Min;
+import org.onap.policy.common.parameters.annotations.NotBlank;
+import org.onap.policy.common.parameters.annotations.NotNull;
+import org.onap.policy.distribution.main.parameters.PolicyForwarderConfigurationParameterGroup;
+
+/**
+ * Holds the parameters for the {@link LifecycleApiPolicyForwarder}.
+ *
+ * @author Ram Krishna Verma (ram.krishna.verma@est.tech)
+ */
+@Getter
+@NotNull
+@NotBlank
+public class LifecycleApiParameters extends PolicyForwarderConfigurationParameterGroup {
+
+ private String hostName;
+ @Min(value = 1)
+ private int port;
+ private String userName;
+ private String password;
+
+ public LifecycleApiParameters() {
+ super(LifecycleApiParameters.class.getSimpleName());
+ }
+}
diff --git a/plugins/forwarding-plugins/src/main/java/org/onap/policy/distribution/forwarding/lifecycle/api/LifecycleApiPolicyForwarder.java b/plugins/forwarding-plugins/src/main/java/org/onap/policy/distribution/forwarding/lifecycle/api/LifecycleApiPolicyForwarder.java
index 2983c5ef..b6f41fbf 100644
--- a/plugins/forwarding-plugins/src/main/java/org/onap/policy/distribution/forwarding/lifecycle/api/LifecycleApiPolicyForwarder.java
+++ b/plugins/forwarding-plugins/src/main/java/org/onap/policy/distribution/forwarding/lifecycle/api/LifecycleApiPolicyForwarder.java
@@ -31,6 +31,7 @@ import javax.ws.rs.client.Entity;
import javax.ws.rs.core.HttpHeaders;
import javax.ws.rs.core.MediaType;
import javax.ws.rs.core.Response;
+import org.onap.policy.common.endpoints.event.comm.bus.internal.BusTopicParams;
import org.onap.policy.common.endpoints.http.client.HttpClient;
import org.onap.policy.common.endpoints.http.client.HttpClientConfigException;
import org.onap.policy.common.endpoints.http.client.HttpClientFactoryInstance;
@@ -56,23 +57,14 @@ public class LifecycleApiPolicyForwarder implements PolicyForwarder {
private static final String DEPLOY_POLICY_URI = "/policy/pap/v1/pdps/policies";
private static final String CREATE_POLICY_TYPE_URI = "/policy/api/v1/policytypes/";
private static final Logger LOGGER = LoggerFactory.getLogger(LifecycleApiPolicyForwarder.class);
-
private LifecycleApiForwarderParameters forwarderParameters;
- private HttpClient apiClient;
- private HttpClient papClient;
/**
* {@inheritDoc}.
*/
@Override
- public void configure(final String parameterGroupName) throws HttpClientConfigException {
+ public void configure(final String parameterGroupName) {
forwarderParameters = ParameterService.get(parameterGroupName);
-
- forwarderParameters.getApiParameters().setClientName("policy-api");
- forwarderParameters.getPapParameters().setClientName("policy-pap");
-
- apiClient = HttpClientFactoryInstance.getClientFactory().build(forwarderParameters.getApiParameters());
- papClient = HttpClientFactoryInstance.getClientFactory().build(forwarderParameters.getPapParameters());
}
/**
@@ -164,7 +156,14 @@ public class LifecycleApiPolicyForwarder implements PolicyForwarder {
}
private HttpClient getHttpClient(final boolean wantApi) throws HttpClientConfigException {
- return (wantApi ? apiClient : papClient);
+ final boolean https = forwarderParameters.isHttps();
+ final LifecycleApiParameters parameters =
+ (wantApi ? forwarderParameters.getApiParameters() : forwarderParameters.getPapParameters());
+ final BusTopicParams params = BusTopicParams.builder().clientName("Policy Distribution").useHttps(https)
+ .hostname(parameters.getHostName()).port(parameters.getPort()).userName(parameters.getUserName())
+ .password(parameters.getPassword()).allowSelfSignedCerts(forwarderParameters.isAllowSelfSignedCerts())
+ .build();
+ return HttpClientFactoryInstance.getClientFactory().build(params);
}
}
diff --git a/plugins/forwarding-plugins/src/test/java/org/onap/policy/distribution/forwarding/lifecycle/api/LifecycleApiForwarderParametersTest.java b/plugins/forwarding-plugins/src/test/java/org/onap/policy/distribution/forwarding/lifecycle/api/LifecycleApiForwarderParametersTest.java
index 50520d84..0f010bfc 100644
--- a/plugins/forwarding-plugins/src/test/java/org/onap/policy/distribution/forwarding/lifecycle/api/LifecycleApiForwarderParametersTest.java
+++ b/plugins/forwarding-plugins/src/test/java/org/onap/policy/distribution/forwarding/lifecycle/api/LifecycleApiForwarderParametersTest.java
@@ -1,7 +1,6 @@
/*-
* ============LICENSE_START=======================================================
* Copyright (C) 2019 Nordix Foundation.
- * Modifications Copyright (C) 2021 AT&T Intellectual Property. 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.
@@ -21,7 +20,6 @@
package org.onap.policy.distribution.forwarding.lifecycle.api;
-import static org.assertj.core.api.Assertions.assertThat;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertFalse;
import static org.junit.Assert.assertTrue;
@@ -54,24 +52,19 @@ public class LifecycleApiForwarderParametersTest {
"src/test/resources/parameters/LifecycleApiPolicyForwarderParameters.json",
LifecycleApiForwarderParameters.class);
- configurationParameters.getApiParameters().setClientName("api");
- configurationParameters.getPapParameters().setClientName("pap");
-
assertEquals(LifecycleApiForwarderParameters.class.getSimpleName(),
configurationParameters.getName());
+ assertFalse(configurationParameters.isHttps());
assertTrue(configurationParameters.isDeployPolicies());
- assertEquals(POLICY_API_HOST_NAME, configurationParameters.getApiParameters().getHostname());
+ assertEquals(POLICY_API_HOST_NAME, configurationParameters.getApiParameters().getHostName());
assertEquals(POLICY_API_PORT, configurationParameters.getApiParameters().getPort());
- assertFalse(configurationParameters.getApiParameters().isUseHttps());
assertEquals(POLICY_API_USER, configurationParameters.getApiParameters().getUserName());
assertEquals(POLICY_API_PASSWORD, configurationParameters.getApiParameters().getPassword());
- assertEquals(POLICY_PAP_HOST_NAME, configurationParameters.getPapParameters().getHostname());
+ assertEquals(POLICY_PAP_HOST_NAME, configurationParameters.getPapParameters().getHostName());
assertEquals(POLICY_PAP_PORT, configurationParameters.getPapParameters().getPort());
- assertFalse(configurationParameters.getPapParameters().isUseHttps());
assertEquals(POLICY_PAP_USER, configurationParameters.getPapParameters().getUserName());
assertEquals(POLICY_PAP_PASSWORD, configurationParameters.getPapParameters().getPassword());
- assertThat(configurationParameters.validate().getResult()).isNull();
assertEquals(ValidationStatus.CLEAN, configurationParameters.validate().getStatus());
}
diff --git a/plugins/forwarding-plugins/src/test/resources/parameters/LifecycleApiPolicyForwarderParameters.json b/plugins/forwarding-plugins/src/test/resources/parameters/LifecycleApiPolicyForwarderParameters.json
index 5bb9b65b..0791e1ae 100644
--- a/plugins/forwarding-plugins/src/test/resources/parameters/LifecycleApiPolicyForwarderParameters.json
+++ b/plugins/forwarding-plugins/src/test/resources/parameters/LifecycleApiPolicyForwarderParameters.json
@@ -1,17 +1,16 @@
{
"apiParameters": {
- "hostname": "0.0.0.0",
+ "hostName": "0.0.0.0",
"port": 6969,
- "useHttps": false,
"userName": "healthcheck",
"password": "zb!XztG34"
},
"papParameters": {
- "hostname": "0.0.0.0",
+ "hostName": "0.0.0.0",
"port": 6969,
- "useHttps": false,
"userName": "healthcheck",
"password": "zb!XztG34"
},
+ "isHttps": false,
"deployPolicies": true
-}
+} \ No newline at end of file
diff --git a/plugins/forwarding-plugins/src/test/resources/parameters/LifecycleApiPolicyForwarderParametersInvalid.json b/plugins/forwarding-plugins/src/test/resources/parameters/LifecycleApiPolicyForwarderParametersInvalid.json
index 93cb0dd3..ca0558a6 100644
--- a/plugins/forwarding-plugins/src/test/resources/parameters/LifecycleApiPolicyForwarderParametersInvalid.json
+++ b/plugins/forwarding-plugins/src/test/resources/parameters/LifecycleApiPolicyForwarderParametersInvalid.json
@@ -1,17 +1,16 @@
{
"apiParameters": {
- "hostname": "",
+ "hostName": "",
"port": -1,
- "useHttps": false,
"userName": "healthcheck",
"password": "zb!XztG34"
},
"papParameters": {
- "hostname": "",
+ "hostName": "",
"port": -2,
- "useHttps": false,
"userName": "healthcheck",
"password": "zb!XztG34"
},
+ "isHttps": false,
"deployPolicies": true
-}
+} \ No newline at end of file
diff --git a/reception/src/main/java/org/onap/policy/distribution/reception/handling/PluginHandler.java b/reception/src/main/java/org/onap/policy/distribution/reception/handling/PluginHandler.java
index ecd40e92..c2ea8009 100644
--- a/reception/src/main/java/org/onap/policy/distribution/reception/handling/PluginHandler.java
+++ b/reception/src/main/java/org/onap/policy/distribution/reception/handling/PluginHandler.java
@@ -26,7 +26,6 @@ import java.lang.reflect.InvocationTargetException;
import java.util.ArrayList;
import java.util.Collection;
import java.util.Map;
-import org.onap.policy.common.endpoints.http.client.HttpClientConfigException;
import org.onap.policy.common.parameters.ParameterService;
import org.onap.policy.distribution.forwarding.PolicyForwarder;
import org.onap.policy.distribution.forwarding.parameters.PolicyForwarderParameters;
@@ -121,7 +120,7 @@ public class PluginHandler {
policyForwarders.add(policyForwarder);
} catch (final ClassNotFoundException | InstantiationException | IllegalAccessException
| IllegalArgumentException | InvocationTargetException | NoSuchMethodException
- | SecurityException | HttpClientConfigException exp) {
+ | SecurityException exp) {
throw new PluginInitializationException(exp.getMessage(), exp.getCause());
}
}
diff --git a/testsuites/stability/src/main/resources/distributionsetup/distribution/etc/defaultConfig.json b/testsuites/stability/src/main/resources/distributionsetup/distribution/etc/defaultConfig.json
index 7273cbc7..98a135ce 100644
--- a/testsuites/stability/src/main/resources/distributionsetup/distribution/etc/defaultConfig.json
+++ b/testsuites/stability/src/main/resources/distributionsetup/distribution/etc/defaultConfig.json
@@ -53,19 +53,18 @@
"parameterClassName": "org.onap.policy.distribution.forwarding.lifecycle.api.LifecycleApiForwarderParameters",
"parameters": {
"apiParameters": {
- "hostname": "policy-api",
+ "hostName": "policy-api",
"port": 6969,
- "useHttps": true,
"userName": "healthcheck",
"password": "zb!XztG34"
},
"papParameters": {
- "hostname": "policy-pap",
+ "hostName": "policy-pap",
"port": 7000,
- "useHttps": true,
"userName": "healthcheck",
"password": "zb!XztG34"
},
+ "isHttps": true,
"deployPolicies": true
}
}