summaryrefslogtreecommitdiffstats
path: root/plugins
diff options
context:
space:
mode:
Diffstat (limited to 'plugins')
-rw-r--r--plugins/reception-plugins/pom.xml21
-rw-r--r--plugins/reception-plugins/src/main/java/org/onap/policy/distribution/reception/handling/sdc/PSSDConfiguration.java127
-rw-r--r--plugins/reception-plugins/src/main/java/org/onap/policy/distribution/reception/handling/sdc/PSSDConfigurationParametersGroup.java199
-rw-r--r--plugins/reception-plugins/src/test/java/org/onap/policy/distribution/reception/handling/sdc/PSSDConfigurationTest.java79
-rw-r--r--plugins/reception-plugins/src/test/resources/handling-sdc.json26
-rw-r--r--plugins/reception-plugins/src/test/resources/handling-sdcInvalid.json26
6 files changed, 478 insertions, 0 deletions
diff --git a/plugins/reception-plugins/pom.xml b/plugins/reception-plugins/pom.xml
index 3ac93083..a44ff777 100644
--- a/plugins/reception-plugins/pom.xml
+++ b/plugins/reception-plugins/pom.xml
@@ -36,5 +36,26 @@
<artifactId>reception</artifactId>
<version>${project.version}</version>
</dependency>
+ <dependency>
+ <groupId>org.onap.sdc.sdc-tosca</groupId>
+ <artifactId>sdc-tosca</artifactId>
+ <version>1.3.0</version>
+ </dependency>
+ <dependency>
+ <groupId>org.onap.sdc.sdc-distribution-client</groupId>
+ <artifactId>sdc-distribution-client</artifactId>
+ <version>1.3.0</version>
+ <exclusions>
+ <exclusion>
+ <groupId>org.slf4j</groupId>
+ <artifactId>slf4j-log4j12</artifactId>
+ </exclusion>
+ </exclusions>
+ </dependency>
+ <dependency>
+ <groupId>org.onap.policy.common</groupId>
+ <artifactId>common-parameters</artifactId>
+ <version>1.3.0-SNAPSHOT</version>
+ </dependency>
</dependencies>
</project>
diff --git a/plugins/reception-plugins/src/main/java/org/onap/policy/distribution/reception/handling/sdc/PSSDConfiguration.java b/plugins/reception-plugins/src/main/java/org/onap/policy/distribution/reception/handling/sdc/PSSDConfiguration.java
new file mode 100644
index 00000000..5f74e2b2
--- /dev/null
+++ b/plugins/reception-plugins/src/main/java/org/onap/policy/distribution/reception/handling/sdc/PSSDConfiguration.java
@@ -0,0 +1,127 @@
+/*-
+ * ============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.handling.sdc;
+
+import java.io.File;
+import java.util.ArrayList;
+import java.util.List;
+import java.util.Properties;
+import org.onap.sdc.api.consumer.IConfiguration;
+
+/**
+ * Properties for the handling Sdc
+ *
+ */
+public class PSSDConfiguration implements IConfiguration {
+
+ // Configuration file structure
+
+ // Configuration file properties
+ private PSSDConfigurationParametersGroup configParameters=null;
+
+ /**
+ * Original constructor
+ *
+ * @param configParameters properties needed to be configured for the model loader
+ */
+ public PSSDConfiguration(PSSDConfigurationParametersGroup configParameters) {
+ this.configParameters = configParameters;
+
+ }
+
+
+ @Override
+ public String getAsdcAddress() {
+ return configParameters.getAsdcAddress();
+ }
+
+ @Override
+ public List<String> getMsgBusAddress() {
+ return configParameters.getMsgBusAddress();
+ }
+
+ @Override
+ public String getUser() {
+ return configParameters.getUser();
+ }
+
+ @Override
+ public String getPassword() {
+ return configParameters.getPassword();
+ }
+
+ @Override
+ public int getPollingInterval() {
+ return configParameters.getPollingInterval();
+ }
+
+ @Override
+ public int getPollingTimeout() {
+ return configParameters.getPollingTimeout();
+ }
+
+ @Override
+ public List<String> getRelevantArtifactTypes() {
+ return configParameters.getArtifactTypes();
+ }
+
+ @Override
+ public String getConsumerGroup() {
+ return configParameters.getConsumerGroup();
+ }
+
+ @Override
+ public String getEnvironmentName() {
+ return configParameters.getEnvironmentName();
+ }
+
+ @Override
+ public String getConsumerID() {
+ return configParameters.getConsumerID();
+ }
+
+ @Override
+ public String getKeyStorePassword() {
+ return configParameters.getKeyStorePassword();
+ }
+
+ @Override
+ public String getKeyStorePath() {
+ return configParameters.getKeyStorePath();
+ }
+
+ @Override
+ public boolean activateServerTLSAuth() {
+ return configParameters.activateServerTLSAuth();
+ }
+
+ @Override
+ public boolean isFilterInEmptyResources() {
+ return configParameters.isFilterInEmptyResources();
+ }
+
+ @Override
+ public Boolean isUseHttpsWithDmaap() {
+ return configParameters.isUseHttpsWithDmaap();
+ }
+
+
+}
diff --git a/plugins/reception-plugins/src/main/java/org/onap/policy/distribution/reception/handling/sdc/PSSDConfigurationParametersGroup.java b/plugins/reception-plugins/src/main/java/org/onap/policy/distribution/reception/handling/sdc/PSSDConfigurationParametersGroup.java
new file mode 100644
index 00000000..da603359
--- /dev/null
+++ b/plugins/reception-plugins/src/main/java/org/onap/policy/distribution/reception/handling/sdc/PSSDConfigurationParametersGroup.java
@@ -0,0 +1,199 @@
+/*-
+ * ============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.handling.sdc;
+import java.util.List;
+import java.io.FileReader;
+import java.io.IOException;
+
+import com.google.gson.Gson;
+import com.google.gson.GsonBuilder;
+
+import org.onap.policy.common.parameters.GroupValidationResult;
+import org.onap.policy.common.parameters.ParameterConstants;
+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;
+
+ 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() {
+ GroupValidationResult validationResult = new GroupValidationResult(this);
+
+ if (name == null || name.trim().length() == 0) {
+ validationResult.setResult("name", ValidationStatus.INVALID, "name must be a non-blank string");
+ }
+
+ 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(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(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;
+ }
+
+}
+
diff --git a/plugins/reception-plugins/src/test/java/org/onap/policy/distribution/reception/handling/sdc/PSSDConfigurationTest.java b/plugins/reception-plugins/src/test/java/org/onap/policy/distribution/reception/handling/sdc/PSSDConfigurationTest.java
new file mode 100644
index 00000000..bcb7ac80
--- /dev/null
+++ b/plugins/reception-plugins/src/test/java/org/onap/policy/distribution/reception/handling/sdc/PSSDConfigurationTest.java
@@ -0,0 +1,79 @@
+/*-
+ * ============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.handling.sdc;
+
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertFalse;
+import static org.junit.Assert.assertTrue;
+import static org.junit.Assert.fail;
+
+import com.google.gson.Gson;
+import com.google.gson.GsonBuilder;
+
+import java.io.File;
+import java.io.FileReader;
+import java.io.IOException;
+import org.junit.Test;
+import org.onap.policy.common.parameters.GroupValidationResult;
+
+/*-
+ * Tests for PSSDConfiguration class
+ *
+ */
+public class PSSDConfigurationTest {
+
+ @Test
+ public void testPSSDConfigurationParametersGroup() throws IOException {
+ PSSDConfigurationParametersGroup configParameters = null;
+ try {
+ final Gson gson = new GsonBuilder().create();
+ configParameters =
+ gson.fromJson(new FileReader("src/test/resources/handling-sdc.json"),
+ PSSDConfigurationParametersGroup.class);
+ } catch (final Exception e) {
+ fail("test should not thrown an exception here: " + e.getMessage());
+ }
+ final GroupValidationResult validationResult = configParameters.validate();
+ assertTrue(validationResult.isValid());
+ assertEquals("parameterConfig1", configParameters.getName());
+
+ PSSDConfiguration config = new PSSDConfiguration(configParameters);
+ assertEquals(20, config.getPollingInterval());
+ assertEquals(30,config.getPollingTimeout());
+ }
+
+ @Test
+ public void testInvalidPSSDConfigurationParametersGroup() throws IOException {
+ PSSDConfigurationParametersGroup configParameters = null;
+ try {
+ final Gson gson = new GsonBuilder().create();
+ configParameters =
+ gson.fromJson(new FileReader("src/test/resources/handling-sdcInvalid.json"),
+ PSSDConfigurationParametersGroup.class);
+ } catch (final Exception e) {
+ fail("test should not thrown an exception here: " + e.getMessage());
+ }
+ final GroupValidationResult validationResult = configParameters.validate();
+ assertFalse(validationResult.isValid());
+ assertEquals("parameterConfig1", configParameters.getName());
+
+ }
+}
diff --git a/plugins/reception-plugins/src/test/resources/handling-sdc.json b/plugins/reception-plugins/src/test/resources/handling-sdc.json
new file mode 100644
index 00000000..c1ca23aa
--- /dev/null
+++ b/plugins/reception-plugins/src/test/resources/handling-sdc.json
@@ -0,0 +1,26 @@
+{
+ "name" : "parameterConfig1",
+ "asdcAddress": "localhost",
+ "messageBusAddress": [
+ "a.com",
+ "b.com",
+ "c.com"
+ ],
+ "user": "tbdsdc-1480",
+ "password": "tbdsdc-1480",
+ "pollingInterval":20,
+ "pollingTimeout":30,
+ "consumerId": "policy-id",
+ "artifactTypes": [
+ "TOSCA_CSAR",
+ "HEAT"
+ ],
+ "consumerGroup": "policy-group",
+ "environmentName": "environmentName",
+ "keystorePath": "null",
+ "keystorePassword": "null",
+ "activeserverTlsAuth": false,
+ "isFilterinEmptyResources": true,
+ "isUseHttpsWithDmaap": false
+}
+
diff --git a/plugins/reception-plugins/src/test/resources/handling-sdcInvalid.json b/plugins/reception-plugins/src/test/resources/handling-sdcInvalid.json
new file mode 100644
index 00000000..ababea48
--- /dev/null
+++ b/plugins/reception-plugins/src/test/resources/handling-sdcInvalid.json
@@ -0,0 +1,26 @@
+{
+ "name" : "parameterConfig1",
+ "asdcAddress": "localhost",
+ "messageBusAddress": [
+ "a.com",
+ "b.com",
+ "c.com"
+ ],
+ "user": "tbdsdc-1480",
+ "password": "tbdsdc-1480",
+ "pollingInterval":-1,
+ "pollingTimeout":-2,
+ "consumerId": "policy-id",
+ "artifactTypes": [
+ "TOSCA_CSAR",
+ "HEAT"
+ ],
+ "consumerGroup": "policy-group",
+ "environmentName": "environmentName",
+ "keystorePath": "null",
+ "keystorePassword": "null",
+ "activeserverTlsAuth": false,
+ "isFilterinEmptyResources": true,
+ "isUseHttpsWithDmaap": false
+}
+