summaryrefslogtreecommitdiffstats
path: root/reception
diff options
context:
space:
mode:
authorliboNet <libo.zhu@intel.com>2018-08-18 03:15:59 +0800
committerliboNet <libo.zhu@intel.com>2018-08-22 09:57:45 +0800
commit742c4b2ed82860e2a74f3db3b2048173fbc530d8 (patch)
treec663025f715682863056730c7dbccd8fd522ded7 /reception
parent612196451afe9b16b8914858dd58f3bb0dae8579 (diff)
integrate PSSDConfiguration to distribution
* Integrate the PSSDConfiguration to distribution config parameter. * Moved related PSSDConfigurationParameterGroup classes from "handling" to "parameters" to avoid specified sdc dependency. * Modify all the test case since the distribution config parameter has been changed, update CommonTestData to wrap it. * Add neccessnary SDC handling exceptions which to be used for SDC handler integration. * update the PSSDCOnfiguraitonParameterGroup to add UUID to the setName function to generate unique name for each instance. * use builder to create PSSDConfigurationParametersGroup instead of using many parameters Change-Id: I3c78bc2a51ebc84761bc9458096d6ffa18070b47 Issue-ID: POLICY-956 Signed-off-by: liboNet <libo.zhu@intel.com>
Diffstat (limited to 'reception')
-rw-r--r--reception/src/main/java/org/onap/policy/distribution/reception/parameters/PSSDConfigurationParametersGroup.java293
-rw-r--r--reception/src/main/java/org/onap/policy/distribution/reception/parameters/ReceptionHandlerParameters.java16
2 files changed, 307 insertions, 2 deletions
diff --git a/reception/src/main/java/org/onap/policy/distribution/reception/parameters/PSSDConfigurationParametersGroup.java b/reception/src/main/java/org/onap/policy/distribution/reception/parameters/PSSDConfigurationParametersGroup.java
new file mode 100644
index 00000000..52e0988a
--- /dev/null
+++ b/reception/src/main/java/org/onap/policy/distribution/reception/parameters/PSSDConfigurationParametersGroup.java
@@ -0,0 +1,293 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * Copyright (C) 2018 Intel. 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.
+ * 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.reception.parameters;
+
+import java.io.FileReader;
+import java.io.IOException;
+import java.util.ArrayList;
+import java.util.List;
+import java.util.UUID;
+
+import org.onap.policy.common.parameters.GroupValidationResult;
+import org.onap.policy.common.parameters.ParameterGroup;
+import org.onap.policy.common.parameters.ValidationStatus;
+
+/**
+ * This class handles reading, parsing and validating of the Policy SDC Service Distribution parameters from Json
+ * format, which strictly adheres to the interface:IConfiguration, defined by SDC SDK.
+ */
+public class PSSDConfigurationParametersGroup implements ParameterGroup {
+
+ // Policy SDC Service Distribution specified field.
+ private String name;
+
+ // Interface of IConfiguration item
+ private String asdcAddress;
+ private List<String> messageBusAddress;
+ private String user;
+ private String password;
+ private int pollingInterval;
+ private int pollingTimeout;
+ private String consumerId;
+ private List<String> artifactTypes;
+ private String consumerGroup;
+ private String environmentName;
+ private String keystorePath;
+ private String keystorePassword;
+ private boolean activeserverTlsAuth;
+ private boolean isFilterinEmptyResources;
+ private Boolean isUseHttpsWithDmaap;
+
+ /**
+ *Inner static class is to used as a Builder
+ *
+ */
+ public static class PSSDConfigurationBuilder {
+ private String asdcAddress;
+ private List<String> messageBusAddress;
+ private String user;
+ private String password;
+ private int pollingInterval;
+ private int pollingTimeout;
+ private String consumerId;
+ private List<String> artifactTypes;
+ private String consumerGroup;
+ private String environmentName;
+ private String keystorePath;
+ private String keystorePassword;
+ private boolean activeserverTlsAuth;
+ private boolean isFilterinEmptyResources;
+ private Boolean isUseHttpsWithDmaap;
+
+ public PSSDConfigurationBuilder setAsdcAddress(String val)
+ { asdcAddress = val; return this; }
+ public PSSDConfigurationBuilder setMessageBusAddress(List<String> val)
+ { messageBusAddress = val; return this; }
+ public PSSDConfigurationBuilder setUser(String val)
+ { user = val; return this; }
+ public PSSDConfigurationBuilder setPassword(String val)
+ { password = val; return this; }
+ public PSSDConfigurationBuilder setPollingInterval(int val)
+ { pollingInterval = val; return this; }
+ public PSSDConfigurationBuilder setPollingTimeout(int val)
+ { pollingTimeout = val; return this; }
+ public PSSDConfigurationBuilder setConsumerId(String val)
+ { consumerId = val; return this; }
+ public PSSDConfigurationBuilder setArtifactTypes(List<String> val)
+ { artifactTypes = val; return this; }
+ public PSSDConfigurationBuilder setConsumerGroup(String val)
+ { consumerGroup = val; return this; }
+ public PSSDConfigurationBuilder setEnvironmentName(String val)
+ { environmentName = val; return this; }
+ public PSSDConfigurationBuilder setKeystorePath(String val)
+ { keystorePath = val; return this; }
+ public PSSDConfigurationBuilder setKeystorePassword(String val)
+ { keystorePassword = val; return this; }
+ public PSSDConfigurationBuilder setActiveserverTlsAuth(boolean val)
+ { activeserverTlsAuth = val; return this; }
+ public PSSDConfigurationBuilder setIsFilterinEmptyResources(boolean val)
+ { isFilterinEmptyResources = val; return this; }
+ public PSSDConfigurationBuilder setIsUseHttpsWithDmaap(Boolean val)
+ { isUseHttpsWithDmaap = val; return this; }
+
+
+ /**
+ * it is to create a new PSSDConfigurationParametersGroup instance.
+ */
+ public PSSDConfigurationParametersGroup build() {
+ return new PSSDConfigurationParametersGroup(this);
+ }
+ }
+
+ /**
+ * The constructor for instantiating PSSDConfigurationParametersGroup it is a private
+ * so that it could ONLY be instantiated by PSSDConfigurationBuilder
+ *
+ * @param builder stores all the values used by PSSDConfigurationParametersGroup
+ */
+ private PSSDConfigurationParametersGroup(PSSDConfigurationBuilder builder) {
+ asdcAddress = builder.asdcAddress;
+ messageBusAddress = builder.messageBusAddress;
+ user = builder.user;
+ password = builder.password;
+ pollingInterval = builder.pollingInterval;
+ pollingTimeout = builder.pollingTimeout;
+ consumerId = builder.consumerId;
+ artifactTypes = builder.artifactTypes;
+ consumerGroup = builder.consumerGroup;
+ environmentName = builder.environmentName;
+ keystorePath = builder.keystorePath;
+ keystorePassword = builder.keystorePassword;
+ activeserverTlsAuth = builder.activeserverTlsAuth;
+ isFilterinEmptyResources = builder.isFilterinEmptyResources;
+ isUseHttpsWithDmaap = builder.isUseHttpsWithDmaap;
+
+ }
+
+ public String getAsdcAddress() {
+ return asdcAddress;
+ }
+
+ public List<String> getMsgBusAddress() {
+ return messageBusAddress;
+ }
+
+ public String getUser() {
+ return user;
+ }
+
+ public String getPassword() {
+ return password;
+ }
+
+ public int getPollingInterval() {
+ return pollingInterval;
+ }
+
+ public int getPollingTimeout() {
+ return pollingTimeout;
+ }
+
+ public String getConsumerID() {
+ return consumerId;
+ }
+
+ public List<String> getArtifactTypes() {
+ return artifactTypes;
+ }
+
+ public String getConsumerGroup() {
+ return consumerGroup;
+ }
+
+ public String getEnvironmentName() {
+ return environmentName;
+ }
+
+ public String getKeyStorePassword() {
+ return keystorePassword;
+ }
+
+ public String getKeyStorePath() {
+ return keystorePath;
+ }
+
+ public boolean activateServerTLSAuth() {
+ return activeserverTlsAuth;
+ }
+
+ public boolean isFilterInEmptyResources() {
+ return isFilterinEmptyResources;
+ }
+
+ public Boolean isUseHttpsWithDmaap() {
+ return isUseHttpsWithDmaap;
+ }
+
+ @Override
+ public String toString() {
+ return "name =" + name + ",TestParameters:[asdcAddress = " + asdcAddress + ", messageBusAddress = "
+ + messageBusAddress + ", user = " + user + "]";
+ }
+
+ @Override
+ public String getName() {
+ return name ;
+ }
+
+ @Override
+ public GroupValidationResult validate() {
+ final GroupValidationResult validationResult = new GroupValidationResult(this);
+
+ if (asdcAddress == null || asdcAddress.trim().length() == 0) {
+ validationResult.setResult("asdcAddress", ValidationStatus.INVALID,
+ "asdcAddress must be a non-blank string");
+ }
+
+ if (user == null || user.trim().length() == 0) {
+ validationResult.setResult("user", ValidationStatus.INVALID, "user must be a non-blank string");
+ }
+
+ if (consumerId == null || consumerId.trim().length() == 0) {
+ validationResult.setResult("consumerId", ValidationStatus.INVALID, "consumerId must be a non-blank string");
+ }
+
+ if (consumerGroup == null || consumerGroup.trim().length() == 0) {
+ validationResult.setResult("consumerGroup", ValidationStatus.INVALID,
+ "consumerGroup must be a non-blank string");
+ }
+
+ if (keystorePath == null || keystorePath.trim().length() == 0) {
+ validationResult.setResult("keystorePath", ValidationStatus.INVALID,
+ "keystorePath must be a non-blank string");
+ }
+
+ if (keystorePassword == null || keystorePassword.trim().length() == 0) {
+ validationResult.setResult("keystorePassword", ValidationStatus.INVALID,
+ "keystorePassword must be a non-blank string");
+ }
+
+ if (messageBusAddress == null) {
+ validationResult.setResult("messageBusAddress", ValidationStatus.INVALID,
+ "messageBusAddress must be a list of non-blank string");
+ } else {
+ for (final String temp : messageBusAddress) {
+ if (temp.trim().length() == 0) {
+ validationResult.setResult("messageBusAddress", ValidationStatus.INVALID,
+ "the string of messageBusAddress must be a non-blank string");
+ }
+ }
+ }
+
+ if (artifactTypes == null) {
+ validationResult.setResult("artifactTypes", ValidationStatus.INVALID,
+ "artifactTypes must be a list of non-blank string");
+ } else {
+ for (final String temp : artifactTypes) {
+ if (temp.trim().length() == 0) {
+ validationResult.setResult("artifactTypes", ValidationStatus.INVALID,
+ "the string of artifactTypes must be a non-blank string");
+ }
+ }
+ }
+
+ if (pollingInterval <= 0) {
+ validationResult.setResult("pollingInterval", ValidationStatus.INVALID,
+ "pollingInterval must be a positive integer");
+ }
+
+ if (pollingTimeout <= 0) {
+ validationResult.setResult("pollingTimeout", ValidationStatus.INVALID,
+ "pollingTimeout must be a positive integer");
+ }
+
+ return validationResult;
+ }
+
+ /**
+ * Set the name of this group.
+ *
+ * @param name the name to set.
+ */
+ public void setName(final String name) {
+ this.name = name + "_" + UUID.randomUUID().toString();
+ }
+}
+
diff --git a/reception/src/main/java/org/onap/policy/distribution/reception/parameters/ReceptionHandlerParameters.java b/reception/src/main/java/org/onap/policy/distribution/reception/parameters/ReceptionHandlerParameters.java
index 974436aa..93a02b3b 100644
--- a/reception/src/main/java/org/onap/policy/distribution/reception/parameters/ReceptionHandlerParameters.java
+++ b/reception/src/main/java/org/onap/policy/distribution/reception/parameters/ReceptionHandlerParameters.java
@@ -38,6 +38,7 @@ public class ReceptionHandlerParameters implements ParameterGroup {
private String name;
private String receptionHandlerType;
private String receptionHandlerClassName;
+ private PSSDConfigurationParametersGroup pssdConfiguration;
private PluginHandlerParameters pluginHandlerParameters;
/**
@@ -47,10 +48,12 @@ public class ReceptionHandlerParameters implements ParameterGroup {
* @param receptionHandlerClassName the reception handler class name
* @param pluginHandlerParameters the plugin handler parameters
*/
- public ReceptionHandlerParameters(final String receptionHandlerType, final String receptionHandlerClassName,
- final PluginHandlerParameters pluginHandlerParameters) {
+ public ReceptionHandlerParameters(final String receptionHandlerType, final String receptionHandlerClassName,
+ final PSSDConfigurationParametersGroup pssdConfiguration,
+ final PluginHandlerParameters pluginHandlerParameters) {
this.receptionHandlerType = receptionHandlerType;
this.receptionHandlerClassName = receptionHandlerClassName;
+ this.pssdConfiguration = pssdConfiguration;
this.pluginHandlerParameters = pluginHandlerParameters;
}
@@ -73,6 +76,15 @@ public class ReceptionHandlerParameters implements ParameterGroup {
}
/**
+ * Return the PSSDConfigurationParametersGroup of this ReceptionHandlerParameters instance.
+ *
+ * @return the PSSDConfigurationParametersGroup
+ */
+ public PSSDConfigurationParametersGroup getPSSDConfigurationParametersGroup() {
+ return pssdConfiguration;
+ }
+
+ /**
* Return the pluginHandlerParameters of this ReceptionHandlerParameters instance.
*
* @return the pluginHandlerParameters