summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorliboNet <libo.zhu@intel.com>2019-03-27 00:49:32 +0800
committerliboNet <libo.zhu@intel.com>2019-03-27 09:34:10 +0800
commitf0944b0dffa4904161cf40d5da13d5d2d34b0cbe (patch)
treedcb176160f96f35139cfc603db5cc36b755f3d60
parent7e291b8ebf625519d44c240cbee83521317d52ee (diff)
add SDC client and reception handle
. add reception framework wraps handle and subplug interface . add plugins include sdc handler now. . add forward acts the post interface for specified item like artifact . add model acts for the sepcifeid item like CSAR . update pom.xml and package/pom.xml to includes all submodules . Fix the compile issue by typo and change groupid to framework Change-Id: Idbff0ca612045c6ee52ba23cd305f2764c9600f8 Issue-ID: MULTICLOUD-514 Signed-off-by: liboNet <libo.zhu@intel.com>
-rw-r--r--artifactbroker/forwarding/pom.xml51
-rw-r--r--artifactbroker/forwarding/src/main/java/org/onap/policy/distribution/forwarding/ArtifactForwarder.java54
-rw-r--r--artifactbroker/forwarding/src/main/java/org/onap/policy/distribution/forwarding/ArtifactForwardingException.java49
-rw-r--r--artifactbroker/forwarding/src/main/java/org/onap/policy/distribution/forwarding/parameters/ArtifactForwarderParameters.java126
-rw-r--r--artifactbroker/forwarding/src/test/java/org/onap/policy/distribution/forwarding/PolicyDecodingExceptionTest.java44
-rw-r--r--artifactbroker/main/pom.xml2
-rw-r--r--artifactbroker/model/pom.xml32
-rw-r--r--artifactbroker/model/src/main/java/org/onap/policy/distribution/model/Csar.java43
-rw-r--r--artifactbroker/model/src/main/java/org/onap/policy/distribution/model/OptimizationPolicy.java122
-rw-r--r--artifactbroker/model/src/main/java/org/onap/policy/distribution/model/Policy.java42
-rw-r--r--artifactbroker/model/src/main/java/org/onap/policy/distribution/model/PolicyAsString.java70
-rw-r--r--artifactbroker/model/src/main/java/org/onap/policy/distribution/model/PolicyInput.java28
-rw-r--r--artifactbroker/model/src/main/java/org/onap/policy/distribution/model/Tosca.java43
-rw-r--r--artifactbroker/model/src/test/java/org/onap/policy/distribution/model/TestModels.java43
-rw-r--r--artifactbroker/packages/pom.xml20
-rw-r--r--artifactbroker/plugins/pom.xml37
-rw-r--r--artifactbroker/plugins/reception-plugins/pom.xml55
-rw-r--r--artifactbroker/plugins/reception-plugins/src/main/java/org/onap/policy/distribution/reception/handling/sdc/ComponentDoneStatusMessage.java74
-rw-r--r--artifactbroker/plugins/reception-plugins/src/main/java/org/onap/policy/distribution/reception/handling/sdc/ComponentDoneStatusMessageBuilder.java112
-rw-r--r--artifactbroker/plugins/reception-plugins/src/main/java/org/onap/policy/distribution/reception/handling/sdc/DistributionStatusMessage.java77
-rw-r--r--artifactbroker/plugins/reception-plugins/src/main/java/org/onap/policy/distribution/reception/handling/sdc/DistributionStatusMessageBuilder.java132
-rw-r--r--artifactbroker/plugins/reception-plugins/src/main/java/org/onap/policy/distribution/reception/handling/sdc/FileSystemReceptionHandler.java120
-rw-r--r--artifactbroker/plugins/reception-plugins/src/main/java/org/onap/policy/distribution/reception/handling/sdc/FileSystemReceptionHandlerConfigurationParameterBuilder.java52
-rw-r--r--artifactbroker/plugins/reception-plugins/src/main/java/org/onap/policy/distribution/reception/handling/sdc/FileSystemReceptionHandlerConfigurationParameterGroup.java84
-rw-r--r--artifactbroker/plugins/reception-plugins/src/main/java/org/onap/policy/distribution/reception/handling/sdc/SdcClientHandler.java76
-rw-r--r--artifactbroker/plugins/reception-plugins/src/main/java/org/onap/policy/distribution/reception/handling/sdc/SdcConfiguration.java117
-rw-r--r--artifactbroker/plugins/reception-plugins/src/main/java/org/onap/policy/distribution/reception/handling/sdc/SdcReceptionHandler.java382
-rw-r--r--artifactbroker/plugins/reception-plugins/src/main/java/org/onap/policy/distribution/reception/handling/sdc/SdcReceptionHandlerConfigurationParameterBuilder.java357
-rw-r--r--artifactbroker/plugins/reception-plugins/src/main/java/org/onap/policy/distribution/reception/handling/sdc/SdcReceptionHandlerConfigurationParameterGroup.java210
-rw-r--r--artifactbroker/plugins/reception-plugins/src/main/java/org/onap/policy/distribution/reception/handling/sdc/SdcReceptionHandlerStatus.java49
-rw-r--r--artifactbroker/plugins/reception-plugins/src/main/java/org/onap/policy/distribution/reception/handling/sdc/exceptions/ArtifactDownloadException.java53
-rw-r--r--artifactbroker/plugins/reception-plugins/src/main/java/org/onap/policy/distribution/reception/handling/sdc/exceptions/ArtifactInstallerException.java53
-rw-r--r--artifactbroker/plugins/reception-plugins/src/main/java/org/onap/policy/distribution/reception/handling/sdc/exceptions/PssdControllerException.java53
-rw-r--r--artifactbroker/plugins/reception-plugins/src/main/java/org/onap/policy/distribution/reception/handling/sdc/exceptions/PssdParametersException.java53
-rw-r--r--artifactbroker/plugins/reception-plugins/src/test/java/org/onap/policy/distribution/reception/handling/sdc/DummyArtifactForwarder.java72
-rw-r--r--artifactbroker/plugins/reception-plugins/src/test/java/org/onap/policy/distribution/reception/handling/sdc/DummyPolicy.java62
-rw-r--r--artifactbroker/plugins/reception-plugins/src/test/java/org/onap/policy/distribution/reception/handling/sdc/TestComponentDoneStatusMessage.java61
-rw-r--r--artifactbroker/plugins/reception-plugins/src/test/java/org/onap/policy/distribution/reception/handling/sdc/TestDistributionStatusMessage.java65
-rw-r--r--artifactbroker/plugins/reception-plugins/src/test/java/org/onap/policy/distribution/reception/handling/sdc/TestSdcReceptionHandlerConfigurationParameterGroup.java160
-rw-r--r--artifactbroker/plugins/reception-plugins/src/test/java/org/onap/policy/distribution/reception/handling/sdc/exceptions/ArtifactDownloadExceptionTest.java36
-rw-r--r--artifactbroker/plugins/reception-plugins/src/test/java/org/onap/policy/distribution/reception/handling/sdc/exceptions/ArtifactInstallerExceptionTest.java36
-rw-r--r--artifactbroker/plugins/reception-plugins/src/test/java/org/onap/policy/distribution/reception/handling/sdc/exceptions/PssdControllerExceptionTest.java36
-rw-r--r--artifactbroker/plugins/reception-plugins/src/test/java/org/onap/policy/distribution/reception/handling/sdc/exceptions/PssdParametersExceptionTest.java36
-rw-r--r--artifactbroker/plugins/reception-plugins/src/test/resources/handling-sdc.json27
-rw-r--r--artifactbroker/plugins/reception-plugins/src/test/resources/handling-sdcInvalid.json26
-rw-r--r--artifactbroker/pom.xml5
-rw-r--r--artifactbroker/reception/pom.xml45
-rw-r--r--artifactbroker/reception/src/main/java/org/onap/policy/distribution/reception/decoding/PluginInitializationException.java51
-rw-r--r--artifactbroker/reception/src/main/java/org/onap/policy/distribution/reception/decoding/PluginTerminationException.java51
-rw-r--r--artifactbroker/reception/src/main/java/org/onap/policy/distribution/reception/decoding/PolicyDecodingException.java49
-rw-r--r--artifactbroker/reception/src/main/java/org/onap/policy/distribution/reception/handling/AbstractReceptionHandler.java89
-rw-r--r--artifactbroker/reception/src/main/java/org/onap/policy/distribution/reception/handling/PluginHandler.java88
-rw-r--r--artifactbroker/reception/src/main/java/org/onap/policy/distribution/reception/handling/ReceptionHandler.java46
-rw-r--r--artifactbroker/reception/src/main/java/org/onap/policy/distribution/reception/parameters/PluginHandlerParameters.java94
-rw-r--r--artifactbroker/reception/src/main/java/org/onap/policy/distribution/reception/parameters/ReceptionHandlerConfigurationParameterGroup.java44
-rw-r--r--artifactbroker/reception/src/main/java/org/onap/policy/distribution/reception/parameters/ReceptionHandlerConfigurationParametersJsonAdapter.java80
-rw-r--r--artifactbroker/reception/src/main/java/org/onap/policy/distribution/reception/parameters/ReceptionHandlerParameters.java147
-rw-r--r--artifactbroker/reception/src/main/java/org/onap/policy/distribution/reception/statistics/DistributionStatisticsManager.java160
-rw-r--r--artifactbroker/reception/src/test/java/org/onap/policy/distribution/reception/decoding/PluginInitializationExceptionTest.java50
-rw-r--r--artifactbroker/reception/src/test/java/org/onap/policy/distribution/reception/decoding/PluginTerminationExceptionTest.java49
-rw-r--r--artifactbroker/reception/src/test/java/org/onap/policy/distribution/reception/decoding/PolicyDecodingExceptionTest.java43
-rw-r--r--artifactbroker/reception/src/test/java/org/onap/policy/distribution/reception/handling/DummyArtifactForwarder.java54
-rw-r--r--artifactbroker/reception/src/test/java/org/onap/policy/distribution/reception/handling/DummyReceptionHandler.java35
63 files changed, 4707 insertions, 5 deletions
diff --git a/artifactbroker/forwarding/pom.xml b/artifactbroker/forwarding/pom.xml
new file mode 100644
index 0000000..a56c313
--- /dev/null
+++ b/artifactbroker/forwarding/pom.xml
@@ -0,0 +1,51 @@
+<!--
+ ============LICENSE_START=======================================================
+ Copyright (C) 2018 Ericsson. 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=========================================================
+-->
+<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
+ <modelVersion>4.0.0</modelVersion>
+ <parent>
+ <groupId>org.onap.multicloud.framework</groupId>
+ <artifactId>multicloud-framework-artifactbroker</artifactId>
+ <version>1.3.0-SNAPSHOT</version>
+ </parent>
+
+ <artifactId>multicloud-framework-artifactbroker-forwarding</artifactId>
+
+ <name>${project.artifactId}</name>
+ <description>The module of Policy Distribution that forwards policies to other components.</description>
+
+ <dependencies>
+ <dependency>
+ <groupId>org.onap.multicloud.framework</groupId>
+ <artifactId>multicloud-framework-artifactbroker-model</artifactId>
+ <version>${project.version}</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>
+ </dependencies>
+</project>
diff --git a/artifactbroker/forwarding/src/main/java/org/onap/policy/distribution/forwarding/ArtifactForwarder.java b/artifactbroker/forwarding/src/main/java/org/onap/policy/distribution/forwarding/ArtifactForwarder.java
new file mode 100644
index 0000000..7e0d42b
--- /dev/null
+++ b/artifactbroker/forwarding/src/main/java/org/onap/policy/distribution/forwarding/ArtifactForwarder.java
@@ -0,0 +1,54 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * Copyright (C) 2018 Ericsson. 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.forwarding;
+
+import java.util.Collection;
+import org.onap.sdc.api.notification.IArtifactInfo;
+
+/**
+ * Forwards polices.
+ *
+ * <p>To create a Artifact forwarder a class implementing this interface must be created, along with a
+ * concrete sub class of ArtifactForwarderConfigurationParameterGroup to handle configuration
+ * parameters for the Artifact forwarder.
+ */
+public interface ArtifactForwarder {
+
+ /**
+ * Configure the Artifact forwarder.
+ *
+ * <p>This method will be invoked immediately after instantiation in order for the Artifact forwarder
+ * to configure itself.
+ *
+ * @param parameterGroupName the name of the parameter group which contains the configuration
+ * for the Artifact forwarder
+ */
+ void configure(String parameterGroupName);
+
+ /**
+ * Forward the given policies.
+ *
+ * @param policies the policies to forward
+ * @throws ArtifactForwardingException if an error occurs when forwarding the given Artifact
+ */
+ void forward(Collection<IArtifactInfo> artifacts) throws ArtifactForwardingException;
+
+}
diff --git a/artifactbroker/forwarding/src/main/java/org/onap/policy/distribution/forwarding/ArtifactForwardingException.java b/artifactbroker/forwarding/src/main/java/org/onap/policy/distribution/forwarding/ArtifactForwardingException.java
new file mode 100644
index 0000000..289e5b0
--- /dev/null
+++ b/artifactbroker/forwarding/src/main/java/org/onap/policy/distribution/forwarding/ArtifactForwardingException.java
@@ -0,0 +1,49 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * Copyright (C) 2018 Ericsson. 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.forwarding;
+
+/**
+ * An error has occured when forwarding a policy.
+ */
+public class ArtifactForwardingException extends Exception {
+
+ private static final long serialVersionUID = 3866850096319435806L;
+
+ /**
+ * Construct an instance with the given message.
+ *
+ * @param message the error message
+ */
+ public ArtifactForwardingException(String message) {
+ super(message);
+ }
+
+ /**
+ * Construct an instance with the given message and cause.
+ *
+ * @param message the error message
+ * @param cause the cause
+ */
+ public ArtifactForwardingException(String message, Throwable cause) {
+ super(message, cause);
+ }
+
+}
diff --git a/artifactbroker/forwarding/src/main/java/org/onap/policy/distribution/forwarding/parameters/ArtifactForwarderParameters.java b/artifactbroker/forwarding/src/main/java/org/onap/policy/distribution/forwarding/parameters/ArtifactForwarderParameters.java
new file mode 100644
index 0000000..6221b6e
--- /dev/null
+++ b/artifactbroker/forwarding/src/main/java/org/onap/policy/distribution/forwarding/parameters/ArtifactForwarderParameters.java
@@ -0,0 +1,126 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * Copyright (C) 2018 Ericsson. 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.forwarding.parameters;
+
+import org.onap.policy.common.logging.flexlogger.FlexLogger;
+import org.onap.policy.common.logging.flexlogger.Logger;
+import org.onap.policy.common.parameters.GroupValidationResult;
+import org.onap.policy.common.parameters.ParameterGroup;
+import org.onap.policy.common.parameters.ValidationStatus;
+
+/**
+ * Class to hold all the Artifact forwarder parameters.
+ *
+ * @author Ram Krishna Verma (ram.krishna.verma@ericsson.com)
+ */
+public class ArtifactForwarderParameters implements ParameterGroup {
+
+ private static final Logger LOGGER = FlexLogger.getLogger(ArtifactForwarderParameters.class);
+
+ private String forwarderType;
+ private String forwarderClassName;
+ private String forwarderConfigurationName;
+
+ /**
+ * Constructor for instantiating ArtifactForwarderParameters.
+ *
+ * @param forwarderType the Artifact forwarder type
+ * @param forwarderClassName the Artifact forwarder class name
+ * @param forwarderConfigurationName the name of the configuration for the Artifact forwarder
+ */
+ public ArtifactForwarderParameters(final String forwarderType, final String forwarderClassName,
+ final String forwarderConfigurationName) {
+ this.forwarderType = forwarderType;
+ this.forwarderClassName = forwarderClassName;
+ this.forwarderConfigurationName = forwarderConfigurationName;
+ }
+
+ /**
+ * Return the forwarderType of this ArtifactForwarderParameters instance.
+ *
+ * @return the forwarderType
+ */
+ public String getForwarderType() {
+ return forwarderType;
+ }
+
+ /**
+ * Return the forwarderClassName of this ArtifactForwarderParameters instance.
+ *
+ * @return the forwarderClassName
+ */
+ public String getForwarderClassName() {
+ return forwarderClassName;
+ }
+
+ /**
+ * Return the name of the forwarder configuration of this ArtifactForwarderParameters instance.
+ *
+ * @return the the name of the forwarder configuration
+ */
+ public String getForwarderConfigurationName() {
+ return forwarderConfigurationName;
+ }
+
+ /**
+ * {@inheritDoc}.
+ */
+ @Override
+ public String getName() {
+ return getForwarderType();
+ }
+
+ /**
+ * {@inheritDoc}.
+ */
+ @Override
+ public void setName(final String name) {
+ this.forwarderType = name;
+ }
+
+ /**
+ * {@inheritDoc}.
+ */
+ @Override
+ public GroupValidationResult validate() {
+ final GroupValidationResult validationResult = new GroupValidationResult(this);
+ if (forwarderType == null || forwarderType.trim().length() == 0) {
+ validationResult.setResult("forwarderType", ValidationStatus.INVALID, "must be a non-blank string");
+ }
+ if (forwarderClassName == null || forwarderClassName.trim().length() == 0) {
+ validationResult.setResult("forwarderClassName", ValidationStatus.INVALID,
+ "must be a non-blank string containing full class name of the forwarder");
+ } else {
+ validateArtifactForwarderClass(validationResult);
+ }
+ return validationResult;
+ }
+
+ private void validateArtifactForwarderClass(final GroupValidationResult validationResult) {
+ try {
+ Class.forName(forwarderClassName);
+ } catch (final ClassNotFoundException exp) {
+ LOGGER.trace("Artifact forwarder class not found in classpath", exp);
+ validationResult.setResult("forwarderClassName", ValidationStatus.INVALID,
+ "Artifact forwarder class not found in classpath");
+ }
+ }
+}
diff --git a/artifactbroker/forwarding/src/test/java/org/onap/policy/distribution/forwarding/PolicyDecodingExceptionTest.java b/artifactbroker/forwarding/src/test/java/org/onap/policy/distribution/forwarding/PolicyDecodingExceptionTest.java
new file mode 100644
index 0000000..6ba0ab0
--- /dev/null
+++ b/artifactbroker/forwarding/src/test/java/org/onap/policy/distribution/forwarding/PolicyDecodingExceptionTest.java
@@ -0,0 +1,44 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * Copyright (C) 2018 Ericsson. 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.forwarding;
+
+import static org.junit.Assert.assertEquals;
+
+import org.junit.Test;
+
+public class PolicyDecodingExceptionTest {
+
+ @Test
+ public void testPolicyDecodingExceptionString() {
+ final ArtifactForwardingException policyDecodingException = new ArtifactForwardingException("error message");
+ assertEquals("error message", policyDecodingException.getMessage());
+ }
+
+ @Test
+ public void testPolicyDecodingExceptionStringThrowable() {
+ final Exception cause = new IllegalArgumentException();
+ final ArtifactForwardingException policyDecodingException =
+ new ArtifactForwardingException("error message", cause);
+ assertEquals("error message", policyDecodingException.getMessage());
+ assertEquals(cause, policyDecodingException.getCause());
+ }
+
+}
diff --git a/artifactbroker/main/pom.xml b/artifactbroker/main/pom.xml
index 36ae6d9..db1c855 100644
--- a/artifactbroker/main/pom.xml
+++ b/artifactbroker/main/pom.xml
@@ -19,7 +19,7 @@
-->
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<parent>
- <groupId>org.onap.multicloud.framework.broker</groupId>
+ <groupId>org.onap.multicloud.framework</groupId>
<artifactId>multicloud-framework-artifactbroker</artifactId>
<version>1.3.0-SNAPSHOT</version>
</parent>
diff --git a/artifactbroker/model/pom.xml b/artifactbroker/model/pom.xml
new file mode 100644
index 0000000..21f0ba4
--- /dev/null
+++ b/artifactbroker/model/pom.xml
@@ -0,0 +1,32 @@
+<!--
+ ============LICENSE_START=======================================================
+ Copyright (C) 2018 Ericsson. 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=========================================================
+-->
+<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
+ <modelVersion>4.0.0</modelVersion>
+ <parent>
+ <groupId>org.onap.multicloud.framework</groupId>
+ <artifactId>multicloud-framework-artifactbroker</artifactId>
+ <version>1.3.0-SNAPSHOT</version>
+ </parent>
+
+ <artifactId>multicloud-framework-artifactbroker-model</artifactId>
+ <name>${project.artifactId}</name>
+ <description>[${project.parent.artifactId}] module provides the model for policy distribution</description>
+
+</project>
diff --git a/artifactbroker/model/src/main/java/org/onap/policy/distribution/model/Csar.java b/artifactbroker/model/src/main/java/org/onap/policy/distribution/model/Csar.java
new file mode 100644
index 0000000..df7eaf2
--- /dev/null
+++ b/artifactbroker/model/src/main/java/org/onap/policy/distribution/model/Csar.java
@@ -0,0 +1,43 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * Copyright (C) 2018 Ericsson. 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.model;
+
+/**
+ * Represents a CSAR file that a {@link Policy} can be decoded from.
+ */
+public class Csar implements PolicyInput {
+
+ private String csarFilePath;
+
+ public Csar(final String csarFilePath) {
+ this.csarFilePath = csarFilePath;
+ }
+
+ /**
+ * Get the path to the CSAR file.
+ *
+ * @return the path of the CSAR file
+ */
+ public String getCsarPath() {
+ return csarFilePath;
+ }
+
+}
diff --git a/artifactbroker/model/src/main/java/org/onap/policy/distribution/model/OptimizationPolicy.java b/artifactbroker/model/src/main/java/org/onap/policy/distribution/model/OptimizationPolicy.java
new file mode 100644
index 0000000..2ca3c94
--- /dev/null
+++ b/artifactbroker/model/src/main/java/org/onap/policy/distribution/model/OptimizationPolicy.java
@@ -0,0 +1,122 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * Copyright (C) 2018 Ericsson. 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.model;
+
+import java.util.Date;
+
+/**
+ * An optimization policy.
+ */
+public class OptimizationPolicy implements Policy {
+
+ private static final String OPTIMIZATION = "Optimization";
+ private String policyName;
+ private String policyDescription;
+ private String onapName;
+ private String configBody;
+ private String configBodyType;
+ private Date timetolive;
+ private String guard;
+ private String riskLevel;
+ private String riskType;
+
+ @Override
+ public String getPolicyName() {
+ return policyName;
+ }
+
+ @Override
+ public String getPolicyType() {
+ return OPTIMIZATION;
+ }
+
+ public void setPolicyName(final String policyName) {
+ this.policyName = policyName;
+ }
+
+ public String getPolicyDescription() {
+ return policyDescription;
+ }
+
+ public void setPolicyDescription(final String policyDescription) {
+ this.policyDescription = policyDescription;
+ }
+
+ public String getPolicyConfigType() {
+ return getPolicyType();
+ }
+
+ public String getOnapName() {
+ return onapName;
+ }
+
+ public void setOnapName(final String onapName) {
+ this.onapName = onapName;
+ }
+
+ public String getConfigBody() {
+ return configBody;
+ }
+
+ public void setConfigBody(final String configBody) {
+ this.configBody = configBody;
+ }
+
+ public String getConfigBodyType() {
+ return configBodyType;
+ }
+
+ public void setConfigBodyType(final String configBodyType) {
+ this.configBodyType = configBodyType;
+ }
+
+ public Date getTimetolive() {
+ return timetolive;
+ }
+
+ public void setTimetolive(final Date timetolive) {
+ this.timetolive = timetolive;
+ }
+
+ public String getGuard() {
+ return guard;
+ }
+
+ public void setGuard(final String guard) {
+ this.guard = guard;
+ }
+
+ public String getRiskLevel() {
+ return riskLevel;
+ }
+
+ public void setRiskLevel(final String riskLevel) {
+ this.riskLevel = riskLevel;
+ }
+
+ public String getRiskType() {
+ return riskType;
+ }
+
+ public void setRiskType(final String riskType) {
+ this.riskType = riskType;
+ }
+}
diff --git a/artifactbroker/model/src/main/java/org/onap/policy/distribution/model/Policy.java b/artifactbroker/model/src/main/java/org/onap/policy/distribution/model/Policy.java
new file mode 100644
index 0000000..02ac335
--- /dev/null
+++ b/artifactbroker/model/src/main/java/org/onap/policy/distribution/model/Policy.java
@@ -0,0 +1,42 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * Copyright (C) 2018 Ericsson. 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.model;
+
+/**
+ * A policy created .
+ */
+public interface Policy {
+
+ /**
+ * Get the name of the policy.
+ *
+ * @return the name of the policy
+ */
+ String getPolicyName();
+
+ /**
+ * Get the type of the policy.
+ *
+ * @return the type of the policy
+ */
+ String getPolicyType();
+
+}
diff --git a/artifactbroker/model/src/main/java/org/onap/policy/distribution/model/PolicyAsString.java b/artifactbroker/model/src/main/java/org/onap/policy/distribution/model/PolicyAsString.java
new file mode 100644
index 0000000..25bc412
--- /dev/null
+++ b/artifactbroker/model/src/main/java/org/onap/policy/distribution/model/PolicyAsString.java
@@ -0,0 +1,70 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * Copyright (C) 2018 Ericsson. 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.model;
+
+/**
+ * This class represents a policy .
+ *
+ * @author Ram Krishna Verma (ram.krishna.verma@ericsson.com)
+ */
+public class PolicyAsString implements Policy {
+ private String policyName;
+ private String policyType;
+ private String policy;
+
+ /**
+ * Constructor for creating instance of {@link PolicyAsString}.
+ *
+ * @param policyName the policy file name
+ * @param policyType the policy type
+ * @param policy the policy
+ */
+ public PolicyAsString(final String policyName, final String policyType, final String policy) {
+ this.policyName = policyName;
+ this.policyType = policyType;
+ this.policy = policy;
+ }
+
+ /**
+ * Returns the policy of this {@link PolicyAsString} instance.
+ *
+ * @return the policy
+ */
+ public String getPolicy() {
+ return policy;
+ }
+
+ /**
+ * {@inheritDoc}.
+ */
+ @Override
+ public String getPolicyName() {
+ return policyName;
+ }
+
+ /**
+ * {@inheritDoc}.
+ */
+ @Override
+ public String getPolicyType() {
+ return policyType;
+ }
+}
diff --git a/artifactbroker/model/src/main/java/org/onap/policy/distribution/model/PolicyInput.java b/artifactbroker/model/src/main/java/org/onap/policy/distribution/model/PolicyInput.java
new file mode 100644
index 0000000..1716503
--- /dev/null
+++ b/artifactbroker/model/src/main/java/org/onap/policy/distribution/model/PolicyInput.java
@@ -0,0 +1,28 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * Copyright (C) 2018 Ericsson. 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.model;
+
+/**
+ * An input that a {@link Policy} can be decoded from.
+ */
+public interface PolicyInput {
+
+}
diff --git a/artifactbroker/model/src/main/java/org/onap/policy/distribution/model/Tosca.java b/artifactbroker/model/src/main/java/org/onap/policy/distribution/model/Tosca.java
new file mode 100644
index 0000000..b7b14c4
--- /dev/null
+++ b/artifactbroker/model/src/main/java/org/onap/policy/distribution/model/Tosca.java
@@ -0,0 +1,43 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * Copyright (C) 2018 Ericsson. 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.model;
+
+/**
+ * Represents a TOSCA file that a {@link Policy} can be decoded from.
+ */
+public class Tosca implements PolicyInput {
+
+ private String toscaFilePath;
+
+ public Tosca(String toscaFilePath) {
+ this.toscaFilePath = toscaFilePath;
+ }
+
+ /**
+ * Get the path to the TOSCA file.
+ *
+ * @return the path of the TOSCA file
+ */
+ String getToscaFilePath() {
+ return toscaFilePath;
+ }
+
+}
diff --git a/artifactbroker/model/src/test/java/org/onap/policy/distribution/model/TestModels.java b/artifactbroker/model/src/test/java/org/onap/policy/distribution/model/TestModels.java
new file mode 100644
index 0000000..060ab36
--- /dev/null
+++ b/artifactbroker/model/src/test/java/org/onap/policy/distribution/model/TestModels.java
@@ -0,0 +1,43 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * Copyright (C) 2018 Ericsson. 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.model;
+
+import com.openpojo.reflection.filters.FilterPackageInfo;
+import com.openpojo.validation.Validator;
+import com.openpojo.validation.ValidatorBuilder;
+import com.openpojo.validation.test.impl.GetterTester;
+import com.openpojo.validation.test.impl.SetterTester;
+
+import org.junit.Test;
+
+/**
+ * Class to perform unit testing of all policy models.
+ *
+ * @author Ram Krishna Verma (ram.krishna.verma@ericsson.com)
+ */
+public class TestModels {
+
+ @Test
+ public void testAllModels() {
+ final Validator validator = ValidatorBuilder.create().with(new SetterTester()).with(new GetterTester()).build();
+ validator.validate(Policy.class.getPackage().getName(), new FilterPackageInfo());
+ }
+}
diff --git a/artifactbroker/packages/pom.xml b/artifactbroker/packages/pom.xml
index 29548b1..c371cad 100644
--- a/artifactbroker/packages/pom.xml
+++ b/artifactbroker/packages/pom.xml
@@ -22,7 +22,7 @@
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<parent>
- <groupId>org.onap.multicloud.framework.broker</groupId>
+ <groupId>org.onap.multicloud.framework</groupId>
<artifactId>multicloud-framework-artifactbroker</artifactId>
<version>1.3.0-SNAPSHOT</version>
</parent>
@@ -33,11 +33,25 @@
<dependencies>
<dependency>
- <groupId>org.onap.multicloud.framework.broker</groupId>
+ <groupId>org.onap.multicloud.framework</groupId>
<artifactId>multicloud-framework-artifactbroker-main</artifactId>
<version>${project.version}</version>
</dependency>
-
+ <dependency>
+ <groupId>org.onap.multicloud.framework</groupId>
+ <artifactId>multicloud-framework-artifactbroker-reception</artifactId>
+ <version>${project.version}</version>
+ </dependency>
+ <dependency>
+ <groupId>org.onap.multicloud.framework</groupId>
+ <artifactId>multicloud-framework-artifactbroker-forwarding</artifactId>
+ <version>${project.version}</version>
+ </dependency>
+ <dependency>
+ <groupId>org.onap.multicloud.framework</groupId>
+ <artifactId>multicloud-framework-artifactbroker-reception-plugins</artifactId>
+ <version>${project.version}</version>
+ </dependency>
</dependencies>
<build>
diff --git a/artifactbroker/plugins/pom.xml b/artifactbroker/plugins/pom.xml
new file mode 100644
index 0000000..68d0fea
--- /dev/null
+++ b/artifactbroker/plugins/pom.xml
@@ -0,0 +1,37 @@
+<!--
+ ============LICENSE_START=======================================================
+ Copyright (C) 2018 Ericsson. 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=========================================================
+-->
+<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
+ <modelVersion>4.0.0</modelVersion>
+ <parent>
+ <groupId>org.onap.multicloud.framework</groupId>
+ <artifactId>multicloud-framework-artifactbroker</artifactId>
+ <version>1.3.0-SNAPSHOT</version>
+ </parent>
+
+ <artifactId>multicloud-framework-artifactbroker-plugins</artifactId>
+
+ <name>${project.artifactId}</name>
+ <description>The module of Policy Distribution that holds plugins for custom policy reception and forwarding.</description>
+ <packaging>pom</packaging>
+
+ <modules>
+ <module>reception-plugins</module>
+ </modules>
+</project>
diff --git a/artifactbroker/plugins/reception-plugins/pom.xml b/artifactbroker/plugins/reception-plugins/pom.xml
new file mode 100644
index 0000000..d6a8ccc
--- /dev/null
+++ b/artifactbroker/plugins/reception-plugins/pom.xml
@@ -0,0 +1,55 @@
+<!--
+ ============LICENSE_START=======================================================
+ Copyright (C) 2018 Ericsson. 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=========================================================
+-->
+<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
+ <modelVersion>4.0.0</modelVersion>
+ <parent>
+ <groupId>org.onap.multicloud.framework</groupId>
+ <artifactId>multicloud-framework-artifactbroker-plugins</artifactId>
+ <version>1.3.0-SNAPSHOT</version>
+ </parent>
+
+ <artifactId>multicloud-framework-artifactbroker-reception-plugins</artifactId>
+ <name>${project.artifactId}</name>
+ <description>[${project.parent.artifactId}] module contains plugins for reception of policies.</description>
+
+ <dependencies>
+ <dependency>
+ <groupId>org.onap.multicloud.framework</groupId>
+ <artifactId>multicloud-framework-artifactbroker-reception</artifactId>
+ <version>${project.version}</version>
+ </dependency>
+ <dependency>
+ <groupId>org.onap.sdc.sdc-tosca</groupId>
+ <artifactId>sdc-tosca</artifactId>
+ <version>1.4.1</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>
+ </dependencies>
+</project>
diff --git a/artifactbroker/plugins/reception-plugins/src/main/java/org/onap/policy/distribution/reception/handling/sdc/ComponentDoneStatusMessage.java b/artifactbroker/plugins/reception-plugins/src/main/java/org/onap/policy/distribution/reception/handling/sdc/ComponentDoneStatusMessage.java
new file mode 100644
index 0000000..581681b
--- /dev/null
+++ b/artifactbroker/plugins/reception-plugins/src/main/java/org/onap/policy/distribution/reception/handling/sdc/ComponentDoneStatusMessage.java
@@ -0,0 +1,74 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * Copyright (C) 2018 Ericsson. 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 org.onap.sdc.api.consumer.IComponentDoneStatusMessage;
+import org.onap.sdc.utils.DistributionStatusEnum;
+
+/**
+ * This class represents the component done status of the distribution service.
+ *
+ * @author Ram Krishna Verma (ram.krishna.verma@ericsson.com)
+ */
+public class ComponentDoneStatusMessage implements IComponentDoneStatusMessage {
+
+ private String consumerId;
+ private String distributionId;
+ private DistributionStatusEnum distributionStatus;
+ private long timestamp;
+
+ /**
+ * Constructor for instantiating {@link ComponentDoneStatusMessage} class.
+ *
+ * @param messageBuilder the message builder
+ */
+ public ComponentDoneStatusMessage(final ComponentDoneStatusMessageBuilder messageBuilder) {
+ this.consumerId = messageBuilder.getConsumerId();
+ this.distributionId = messageBuilder.getDistributionId();
+ this.distributionStatus = messageBuilder.getDistributionStatus();
+ this.timestamp = messageBuilder.getTimestamp();
+ }
+
+ @Override
+ public DistributionStatusEnum getStatus() {
+ return distributionStatus;
+ }
+
+ @Override
+ public String getDistributionID() {
+ return distributionId;
+ }
+
+ @Override
+ public long getTimestamp() {
+ return timestamp;
+ }
+
+ @Override
+ public String getConsumerID() {
+ return consumerId;
+ }
+
+ @Override
+ public String getComponentName() {
+ return "POLICY";
+ }
+}
diff --git a/artifactbroker/plugins/reception-plugins/src/main/java/org/onap/policy/distribution/reception/handling/sdc/ComponentDoneStatusMessageBuilder.java b/artifactbroker/plugins/reception-plugins/src/main/java/org/onap/policy/distribution/reception/handling/sdc/ComponentDoneStatusMessageBuilder.java
new file mode 100644
index 0000000..567ae8d
--- /dev/null
+++ b/artifactbroker/plugins/reception-plugins/src/main/java/org/onap/policy/distribution/reception/handling/sdc/ComponentDoneStatusMessageBuilder.java
@@ -0,0 +1,112 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * Copyright (C) 2018 Ericsson. 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 org.onap.sdc.utils.DistributionStatusEnum;
+
+/**
+ * This class builds an instance of {@link ComponentDoneStatusMessage} class.
+ *
+ * @author Ram Krishna Verma (ram.krishna.verma@ericsson.com)
+ */
+public class ComponentDoneStatusMessageBuilder {
+
+ private String consumerId;
+ private String distributionId;
+ private DistributionStatusEnum distributionStatus;
+ private long timestamp;
+
+ /**
+ * Returns consumer id of this {@link ComponentDoneStatusMessageBuilder} instance.
+ *
+ * @return the consumerId
+ */
+ public String getConsumerId() {
+ return consumerId;
+ }
+
+ /**
+ * Returns distribution id of this {@link ComponentDoneStatusMessageBuilder} instance.
+ *
+ * @return the distributionId
+ */
+ public String getDistributionId() {
+ return distributionId;
+ }
+
+ /**
+ * Returns distribution status of this {@link ComponentDoneStatusMessageBuilder} instance.
+ *
+ * @return the distributionStatus
+ */
+ public DistributionStatusEnum getDistributionStatus() {
+ return distributionStatus;
+ }
+
+ /**
+ * Returns time of this {@link ComponentDoneStatusMessageBuilder} instance.
+ *
+ * @return the timestamp
+ */
+ public long getTimestamp() {
+ return timestamp;
+ }
+
+ /**
+ * Set consumer id url to this {@link ComponentDoneStatusMessageBuilder} instance.
+ *
+ * @param consumerId the consumerId to set
+ */
+ public ComponentDoneStatusMessageBuilder setConsumerId(final String consumerId) {
+ this.consumerId = consumerId;
+ return this;
+ }
+
+ /**
+ * Set distribution id to this {@link ComponentDoneStatusMessageBuilder} instance.
+ *
+ * @param distributionId the distributionId to set
+ */
+ public ComponentDoneStatusMessageBuilder setDistributionId(final String distributionId) {
+ this.distributionId = distributionId;
+ return this;
+ }
+
+ /**
+ * Set distribution status to this {@link ComponentDoneStatusMessageBuilder} instance.
+ *
+ * @param distributionStatus the distributionStatus to set
+ */
+ public ComponentDoneStatusMessageBuilder setDistributionStatus(final DistributionStatusEnum distributionStatus) {
+ this.distributionStatus = distributionStatus;
+ return this;
+ }
+
+ /**
+ * Set time to this {@link ComponentDoneStatusMessageBuilder} instance.
+ *
+ * @param timestamp the timestamp to set
+ */
+ public ComponentDoneStatusMessageBuilder setTimestamp(final long timestamp) {
+ this.timestamp = timestamp;
+ return this;
+ }
+}
diff --git a/artifactbroker/plugins/reception-plugins/src/main/java/org/onap/policy/distribution/reception/handling/sdc/DistributionStatusMessage.java b/artifactbroker/plugins/reception-plugins/src/main/java/org/onap/policy/distribution/reception/handling/sdc/DistributionStatusMessage.java
new file mode 100644
index 0000000..436c061
--- /dev/null
+++ b/artifactbroker/plugins/reception-plugins/src/main/java/org/onap/policy/distribution/reception/handling/sdc/DistributionStatusMessage.java
@@ -0,0 +1,77 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * Copyright (C) 2018 Ericsson. 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 org.onap.sdc.api.consumer.IDistributionStatusMessage;
+import org.onap.sdc.utils.DistributionStatusEnum;
+
+/**
+ * This class represents the distribution status of the distribution service.
+ *
+ * @author Ram Krishna Verma (ram.krishna.verma@ericsson.com)
+ */
+public class DistributionStatusMessage implements IDistributionStatusMessage {
+
+ private String artifactUrl;
+ private String consumerId;
+ private String distributionId;
+ private DistributionStatusEnum distributionStatus;
+ private long timestamp;
+
+ /**
+ * Constructor for instantiating {@link DistributionStatusMessage} class.
+ *
+ * @param messageBuilder the message builder
+ */
+ public DistributionStatusMessage(final DistributionStatusMessageBuilder messageBuilder) {
+ this.artifactUrl = messageBuilder.getArtifactUrl();
+ this.consumerId = messageBuilder.getConsumerId();
+ this.distributionId = messageBuilder.getDistributionId();
+ this.distributionStatus = messageBuilder.getDistributionStatus();
+ this.timestamp = messageBuilder.getTimestamp();
+ }
+
+ @Override
+ public String getArtifactURL() {
+ return artifactUrl;
+ }
+
+ @Override
+ public String getConsumerID() {
+ return consumerId;
+ }
+
+ @Override
+ public String getDistributionID() {
+ return distributionId;
+ }
+
+ @Override
+ public DistributionStatusEnum getStatus() {
+ return distributionStatus;
+ }
+
+ @Override
+ public long getTimestamp() {
+ return timestamp;
+ }
+
+}
diff --git a/artifactbroker/plugins/reception-plugins/src/main/java/org/onap/policy/distribution/reception/handling/sdc/DistributionStatusMessageBuilder.java b/artifactbroker/plugins/reception-plugins/src/main/java/org/onap/policy/distribution/reception/handling/sdc/DistributionStatusMessageBuilder.java
new file mode 100644
index 0000000..b83a768
--- /dev/null
+++ b/artifactbroker/plugins/reception-plugins/src/main/java/org/onap/policy/distribution/reception/handling/sdc/DistributionStatusMessageBuilder.java
@@ -0,0 +1,132 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * Copyright (C) 2018 Ericsson. 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 org.onap.sdc.utils.DistributionStatusEnum;
+
+/**
+ * This class builds an instance of {@link DistributionStatusMessage} class.
+ *
+ * @author Ram Krishna Verma (ram.krishna.verma@ericsson.com)
+ */
+public class DistributionStatusMessageBuilder {
+
+ private String artifactUrl;
+ private String consumerId;
+ private String distributionId;
+ private DistributionStatusEnum distributionStatus;
+ private long timestamp;
+
+ /**
+ * Returns artifact url of this {@link DistributionStatusMessageBuilder} instance.
+ *
+ * @return the artifactUrl
+ */
+ public String getArtifactUrl() {
+ return artifactUrl;
+ }
+
+ /**
+ * Returns consumer id of this {@link DistributionStatusMessageBuilder} instance.
+ *
+ * @return the consumerId
+ */
+ public String getConsumerId() {
+ return consumerId;
+ }
+
+ /**
+ * Returns distribution id of this {@link DistributionStatusMessageBuilder} instance.
+ *
+ * @return the distributionId
+ */
+ public String getDistributionId() {
+ return distributionId;
+ }
+
+ /**
+ * Returns distribution status of this {@link DistributionStatusMessageBuilder} instance.
+ *
+ * @return the distributionStatus
+ */
+ public DistributionStatusEnum getDistributionStatus() {
+ return distributionStatus;
+ }
+
+ /**
+ * Returns time of this {@link DistributionStatusMessageBuilder} instance.
+ *
+ * @return the timestamp
+ */
+ public long getTimestamp() {
+ return timestamp;
+ }
+
+ /**
+ * Set artifact url to this {@link DistributionStatusMessageBuilder} instance.
+ *
+ * @param artifactUrl the artifactUrl to set
+ */
+ public DistributionStatusMessageBuilder setArtifactUrl(final String artifactUrl) {
+ this.artifactUrl = artifactUrl;
+ return this;
+ }
+
+ /**
+ * Set consumer id url to this {@link DistributionStatusMessageBuilder} instance.
+ *
+ * @param consumerId the consumerId to set
+ */
+ public DistributionStatusMessageBuilder setConsumerId(final String consumerId) {
+ this.consumerId = consumerId;
+ return this;
+ }
+
+ /**
+ * Set distribution id to this {@link DistributionStatusMessageBuilder} instance.
+ *
+ * @param distributionId the distributionId to set
+ */
+ public DistributionStatusMessageBuilder setDistributionId(final String distributionId) {
+ this.distributionId = distributionId;
+ return this;
+ }
+
+ /**
+ * Set distribution status to this {@link DistributionStatusMessageBuilder} instance.
+ *
+ * @param distributionStatus the distributionStatus to set
+ */
+ public DistributionStatusMessageBuilder setDistributionStatus(final DistributionStatusEnum distributionStatus) {
+ this.distributionStatus = distributionStatus;
+ return this;
+ }
+
+ /**
+ * Set time to this {@link DistributionStatusMessageBuilder} instance.
+ *
+ * @param timestamp the timestamp to set
+ */
+ public DistributionStatusMessageBuilder setTimestamp(final long timestamp) {
+ this.timestamp = timestamp;
+ return this;
+ }
+}
diff --git a/artifactbroker/plugins/reception-plugins/src/main/java/org/onap/policy/distribution/reception/handling/sdc/FileSystemReceptionHandler.java b/artifactbroker/plugins/reception-plugins/src/main/java/org/onap/policy/distribution/reception/handling/sdc/FileSystemReceptionHandler.java
new file mode 100644
index 0000000..941cdd6
--- /dev/null
+++ b/artifactbroker/plugins/reception-plugins/src/main/java/org/onap/policy/distribution/reception/handling/sdc/FileSystemReceptionHandler.java
@@ -0,0 +1,120 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * Copyright (C) 2018 Intel Corp. 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 java.nio.file.StandardWatchEventKinds.ENTRY_CREATE;
+
+import java.io.File;
+import java.io.IOException;
+import java.nio.file.FileSystems;
+import java.nio.file.Path;
+import java.nio.file.Paths;
+import java.nio.file.WatchEvent;
+import java.nio.file.WatchKey;
+import java.nio.file.WatchService;
+
+import org.onap.policy.common.logging.flexlogger.FlexLogger;
+import org.onap.policy.common.logging.flexlogger.Logger;
+
+import org.onap.policy.common.parameters.ParameterService;
+import org.onap.policy.distribution.model.Csar;
+import org.onap.policy.distribution.reception.decoding.PolicyDecodingException;
+import org.onap.policy.distribution.reception.handling.AbstractReceptionHandler;
+
+/**
+ * Handles reception of inputs from File System which can be used to decode policies.
+ */
+public class FileSystemReceptionHandler extends AbstractReceptionHandler {
+ private boolean running = false;
+ private static final Logger LOGGER = FlexLogger.getLogger(FileSystemReceptionHandler.class);
+
+ @Override
+ protected void initializeReception(final String parameterGroupName) {
+ LOGGER.debug("FileSystemReceptionHandler init...");
+ try {
+ final FileSystemReceptionHandlerConfigurationParameterGroup handlerParameters =
+ ParameterService.get(parameterGroupName);
+ main(handlerParameters.getWatchPath());
+ } catch (final Exception ex) {
+ LOGGER.error(ex);
+ }
+ running = false;
+ LOGGER.debug("FileSystemReceptionHandler main loop exited...");
+ }
+
+ @Override
+ public void destroy() {
+ // Tear down subscription etc
+ running = false;
+ }
+
+ public boolean isRunning() {
+ return running;
+ }
+
+ /**
+ * Main entry point.
+ *
+ * @param watchPath Path to watch
+ */
+ public void main(String watchPath) throws IOException {
+ try (final WatchService watcher = FileSystems.getDefault().newWatchService()) {
+ final Path dir = Paths.get(watchPath);
+ dir.register(watcher, ENTRY_CREATE);
+ LOGGER.debug("Watch Service registered for dir: " + dir.getFileName());
+ startMainLoop(watcher, dir);
+ } catch (final InterruptedException ex) {
+ LOGGER.debug(ex);
+ Thread.currentThread().interrupt();
+ }
+ }
+
+ @SuppressWarnings("unchecked")
+ protected void startMainLoop(WatchService watcher, Path dir) throws InterruptedException {
+ WatchKey key;
+ running = true;
+ while (running) {
+ key = watcher.take();
+
+ for (final WatchEvent<?> event : key.pollEvents()) {
+ final WatchEvent<Path> ev = (WatchEvent<Path>) event;
+ final Path fileName = ev.context();
+ LOGGER.debug("new CSAR found: " + fileName);
+ createPolicyInputAndCallHandler(dir.toString() + File.separator + fileName.toString());
+ LOGGER.debug("CSAR complete: " + fileName);
+ }
+ final boolean valid = key.reset();
+ if (!valid) {
+ LOGGER.error("Watch key no longer valid!");
+ break;
+ }
+ }
+ }
+
+ protected void createPolicyInputAndCallHandler(final String fileName) {
+ try {
+ final Csar csarObject = new Csar(fileName);
+ inputReceived(csarObject);
+ } catch (final PolicyDecodingException ex) {
+ LOGGER.error(ex);
+ }
+ }
+}
diff --git a/artifactbroker/plugins/reception-plugins/src/main/java/org/onap/policy/distribution/reception/handling/sdc/FileSystemReceptionHandlerConfigurationParameterBuilder.java b/artifactbroker/plugins/reception-plugins/src/main/java/org/onap/policy/distribution/reception/handling/sdc/FileSystemReceptionHandlerConfigurationParameterBuilder.java
new file mode 100644
index 0000000..37a1698
--- /dev/null
+++ b/artifactbroker/plugins/reception-plugins/src/main/java/org/onap/policy/distribution/reception/handling/sdc/FileSystemReceptionHandlerConfigurationParameterBuilder.java
@@ -0,0 +1,52 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * Copyright (C) 2018 Intel Corp. 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;
+
+/**
+ * This class builds an instance of {@link FileSystemReceptionHandlerConfigurationParameterGroup} class.
+ *
+ */
+public class FileSystemReceptionHandlerConfigurationParameterBuilder {
+
+ private String watchPath;
+
+ /**
+ * Set watchPath to this {@link FileSystemReceptionHandlerConfigurationParameterBuilder} instance.
+ *
+ * @param watchPath the watchPath
+ */
+ public FileSystemReceptionHandlerConfigurationParameterBuilder setWatchPath(final String watchPath) {
+ this.watchPath = watchPath;
+ return this;
+ }
+
+
+ /**
+ * Returns the watchPath of this {@link FileSystemReceptionHandlerConfigurationParameterBuilder} instance.
+ *
+ * @return the watchPath
+ */
+ public String getWatchPath() {
+ return watchPath;
+ }
+}
+
+
diff --git a/artifactbroker/plugins/reception-plugins/src/main/java/org/onap/policy/distribution/reception/handling/sdc/FileSystemReceptionHandlerConfigurationParameterGroup.java b/artifactbroker/plugins/reception-plugins/src/main/java/org/onap/policy/distribution/reception/handling/sdc/FileSystemReceptionHandlerConfigurationParameterGroup.java
new file mode 100644
index 0000000..457cd5e
--- /dev/null
+++ b/artifactbroker/plugins/reception-plugins/src/main/java/org/onap/policy/distribution/reception/handling/sdc/FileSystemReceptionHandlerConfigurationParameterGroup.java
@@ -0,0 +1,84 @@
+/*-
+ * ============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 org.onap.policy.common.parameters.GroupValidationResult;
+import org.onap.policy.common.parameters.ValidationStatus;
+import org.onap.policy.distribution.reception.parameters.ReceptionHandlerConfigurationParameterGroup;
+
+/**
+ * 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 FileSystemReceptionHandlerConfigurationParameterGroup extends ReceptionHandlerConfigurationParameterGroup {
+
+ private String watchPath;
+
+ /**
+ * The constructor for instantiating {@link FileSystemReceptionHandlerConfigurationParameterGroup} class.
+ *
+ * @param builder the SDC configuration builder
+ */
+ public FileSystemReceptionHandlerConfigurationParameterGroup(
+ final FileSystemReceptionHandlerConfigurationParameterBuilder builder) {
+ watchPath = builder.getWatchPath();
+ }
+
+ public String getWatchPath() {
+ return watchPath;
+ }
+
+ /**
+ * {@inheritDoc}.
+ */
+ @Override
+ public GroupValidationResult validate() {
+ final GroupValidationResult validationResult = new GroupValidationResult(this);
+ validatePathElement(validationResult, watchPath, "watchPath");
+ return validationResult;
+ }
+
+
+ /**
+ * Validate the string element.
+ *
+ * @param validationResult the result object
+ * @param element the element to validate
+ * @param elementName the element name for error message
+ */
+ private void validatePathElement(final GroupValidationResult validationResult, final String element,
+ final String elementName) {
+ boolean valid = false;
+ if (element != null) {
+ File file = new File(element);
+ if (file.exists() && file.isDirectory()) {
+ valid = true;
+ }
+ }
+ if (!valid) {
+ validationResult.setResult(elementName, ValidationStatus.INVALID,
+ elementName + " must be a valid directory");
+ }
+ }
+}
+
diff --git a/artifactbroker/plugins/reception-plugins/src/main/java/org/onap/policy/distribution/reception/handling/sdc/SdcClientHandler.java b/artifactbroker/plugins/reception-plugins/src/main/java/org/onap/policy/distribution/reception/handling/sdc/SdcClientHandler.java
new file mode 100644
index 0000000..f69fb15
--- /dev/null
+++ b/artifactbroker/plugins/reception-plugins/src/main/java/org/onap/policy/distribution/reception/handling/sdc/SdcClientHandler.java
@@ -0,0 +1,76 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * Copyright (C) 2018 Ericsson. 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.Timer;
+import java.util.TimerTask;
+
+/**
+ * This class implements TimerTask for calling life cycle methods of SdcClient iteratively after specified interval
+ * until the operation is successful.
+ *
+ * @author Ram Krishna Verma (ram.krishna.verma@ericsson.com)
+ */
+public class SdcClientHandler extends TimerTask {
+
+ private SdcReceptionHandler sdcReceptionHandler;
+ private SdcClientOperationType operationType;
+ private Timer timer;
+
+ public enum SdcClientOperationType {
+ START, STOP
+ }
+
+ /**
+ * Constructs an instance of {@link SdcClientHandler} class.
+ *
+ * @param sdcReceptionHandler the sdcReceptionHandler
+ */
+ public SdcClientHandler(final SdcReceptionHandler sdcReceptionHandler, final SdcClientOperationType operationType,
+ final long retryDelay) {
+ this.sdcReceptionHandler = sdcReceptionHandler;
+ this.operationType = operationType;
+ timer = new Timer(false);
+ timer.scheduleAtFixedRate(this, 0, retryDelay * 1000L);
+ }
+
+ /**
+ * {@inheritDoc}.
+ */
+ @Override
+ public void run() {
+ if (SdcClientOperationType.START.equals(operationType)) {
+ sdcReceptionHandler.initializeSdcClient();
+ sdcReceptionHandler.startSdcClient();
+ } else {
+ sdcReceptionHandler.stopSdcClient();
+ }
+ }
+
+ /**
+ * {@inheritDoc}.
+ */
+ @Override
+ public boolean cancel() {
+ timer.cancel();
+ return true;
+ }
+}
diff --git a/artifactbroker/plugins/reception-plugins/src/main/java/org/onap/policy/distribution/reception/handling/sdc/SdcConfiguration.java b/artifactbroker/plugins/reception-plugins/src/main/java/org/onap/policy/distribution/reception/handling/sdc/SdcConfiguration.java
new file mode 100644
index 0000000..04c978b
--- /dev/null
+++ b/artifactbroker/plugins/reception-plugins/src/main/java/org/onap/policy/distribution/reception/handling/sdc/SdcConfiguration.java
@@ -0,0 +1,117 @@
+/*-
+ * ============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 org.onap.sdc.api.consumer.IConfiguration;
+
+/**
+ * This class represents the configurations needed for SDC Client.
+ *
+ */
+public class SdcConfiguration implements IConfiguration {
+
+ private SdcReceptionHandlerConfigurationParameterGroup configParameters = null;
+
+ /**
+ * Constructor for instantiating {@link SdcConfiguration}.
+ *
+ * @param configParameters the SDC Client configuration parameters
+ */
+ public SdcConfiguration(final SdcReceptionHandlerConfigurationParameterGroup configParameters) {
+ this.configParameters = configParameters;
+ }
+
+ @Override
+ public String getAsdcAddress() {
+ return configParameters.getAsdcAddress();
+ }
+
+ @Override
+ public List<String> getMsgBusAddress() {
+ return configParameters.getMessageBusAddress();
+ }
+
+ @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.isActiveServerTlsAuth();
+ }
+
+ @Override
+ public boolean isFilterInEmptyResources() {
+ return configParameters.isFilterInEmptyResources();
+ }
+
+ @Override
+ public Boolean isUseHttpsWithDmaap() {
+ return configParameters.isUseHttpsWithDmaap();
+ }
+}
diff --git a/artifactbroker/plugins/reception-plugins/src/main/java/org/onap/policy/distribution/reception/handling/sdc/SdcReceptionHandler.java b/artifactbroker/plugins/reception-plugins/src/main/java/org/onap/policy/distribution/reception/handling/sdc/SdcReceptionHandler.java
new file mode 100644
index 0000000..0d100f8
--- /dev/null
+++ b/artifactbroker/plugins/reception-plugins/src/main/java/org/onap/policy/distribution/reception/handling/sdc/SdcReceptionHandler.java
@@ -0,0 +1,382 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * Copyright (C) 2018 Ericsson. 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.io.FileOutputStream;
+import java.io.IOException;
+import java.nio.file.Files;
+import java.nio.file.Path;
+
+import org.onap.policy.common.logging.flexlogger.FlexLogger;
+import org.onap.policy.common.logging.flexlogger.Logger;
+import org.onap.policy.common.parameters.ParameterService;
+import org.onap.policy.distribution.model.Csar;
+import org.onap.policy.distribution.reception.decoding.PolicyDecodingException;
+import org.onap.policy.distribution.reception.handling.AbstractReceptionHandler;
+import org.onap.policy.distribution.reception.handling.sdc.SdcClientHandler.SdcClientOperationType;
+import org.onap.policy.distribution.reception.handling.sdc.exceptions.ArtifactDownloadException;
+import org.onap.policy.distribution.reception.statistics.DistributionStatisticsManager;
+import org.onap.sdc.api.IDistributionClient;
+import org.onap.sdc.api.consumer.IComponentDoneStatusMessage;
+import org.onap.sdc.api.consumer.IDistributionStatusMessage;
+import org.onap.sdc.api.consumer.INotificationCallback;
+import org.onap.sdc.api.notification.IArtifactInfo;
+import org.onap.sdc.api.notification.INotificationData;
+import org.onap.sdc.api.results.IDistributionClientDownloadResult;
+import org.onap.sdc.api.results.IDistributionClientResult;
+import org.onap.sdc.impl.DistributionClientFactory;
+import org.onap.sdc.utils.DistributionActionResultEnum;
+import org.onap.sdc.utils.DistributionStatusEnum;
+
+/**
+ * Handles reception of inputs from ONAP Service Design and Creation (SDC) from which policies may be decoded.
+ */
+public class SdcReceptionHandler extends AbstractReceptionHandler implements INotificationCallback {
+
+ private static final Logger LOGGER = FlexLogger.getLogger(SdcReceptionHandler.class);
+ private static final String SECONDS = "Seconds";
+
+ private SdcReceptionHandlerStatus sdcReceptionHandlerStatus = SdcReceptionHandlerStatus.STOPPED;
+ private IDistributionClient distributionClient;
+ private SdcConfiguration sdcConfig;
+ private volatile int nbOfNotificationsOngoing = 0;
+ private int retryDelay;
+ private SdcClientHandler sdcClientHandler;
+
+ private enum DistributionStatusType {
+ DOWNLOAD, DEPLOY
+ }
+
+ @Override
+ protected void initializeReception(final String parameterGroupName) {
+ final SdcReceptionHandlerConfigurationParameterGroup handlerParameters =
+ ParameterService.get(parameterGroupName);
+ retryDelay = handlerParameters.getRetryDelay() < 30 ? 30 : handlerParameters.getRetryDelay();
+ sdcConfig = new SdcConfiguration(handlerParameters);
+ distributionClient = createSdcDistributionClient();
+ sdcClientHandler = new SdcClientHandler(this, SdcClientOperationType.START, retryDelay);
+ }
+
+ @Override
+ public void destroy() {
+ if (distributionClient != null) {
+ sdcClientHandler = new SdcClientHandler(this, SdcClientOperationType.STOP, retryDelay);
+ }
+ }
+
+ @Override
+ public void activateCallback(final INotificationData notificationData) {
+ LOGGER.debug("Receieved the notification from SDC with ID: " + notificationData.getDistributionID());
+ changeSdcReceptionHandlerStatus(SdcReceptionHandlerStatus.BUSY);
+ processCsarServiceArtifacts(notificationData);
+ changeSdcReceptionHandlerStatus(SdcReceptionHandlerStatus.IDLE);
+ LOGGER.debug("Processed the notification from SDC with ID: " + notificationData.getDistributionID());
+ }
+
+ /**
+ * Method to change the status of this reception handler instance.
+ *
+ * @param newStatus the new status
+ */
+ private final synchronized void changeSdcReceptionHandlerStatus(final SdcReceptionHandlerStatus newStatus) {
+ switch (newStatus) {
+ case INIT:
+ case STOPPED:
+ sdcReceptionHandlerStatus = newStatus;
+ break;
+ case IDLE:
+ handleIdleStatusChange(newStatus);
+ break;
+ case BUSY:
+ ++nbOfNotificationsOngoing;
+ sdcReceptionHandlerStatus = newStatus;
+ break;
+ default:
+ break;
+ }
+ }
+
+ /**
+ * Creates an instance of {@link IDistributionClient} from {@link DistributionClientFactory}.
+ *
+ * @return the {@link IDistributionClient} instance
+ */
+ protected IDistributionClient createSdcDistributionClient() {
+ return DistributionClientFactory.createDistributionClient();
+ }
+
+ /**
+ * Method to initialize the SDC client.
+ *
+ */
+ protected void initializeSdcClient() {
+
+ LOGGER.debug("Initializing the SDC Client...");
+ if (sdcReceptionHandlerStatus != SdcReceptionHandlerStatus.STOPPED) {
+ LOGGER.error("The SDC Client is already initialized");
+ return;
+ }
+ final IDistributionClientResult clientResult = distributionClient.init(sdcConfig, this);
+ if (!clientResult.getDistributionActionResult().equals(DistributionActionResultEnum.SUCCESS)) {
+ LOGGER.error("SDC client initialization failed with reason:" + clientResult.getDistributionMessageResult()
+ + ". Initialization will be retried after " + retryDelay + SECONDS);
+ return;
+ }
+ LOGGER.debug("SDC Client is initialized successfully");
+ changeSdcReceptionHandlerStatus(SdcReceptionHandlerStatus.INIT);
+ }
+
+ /**
+ * Method to start the SDC client.
+ *
+ */
+ protected void startSdcClient() {
+
+ LOGGER.debug("Going to start the SDC Client...");
+ if (sdcReceptionHandlerStatus != SdcReceptionHandlerStatus.INIT) {
+ LOGGER.error("The SDC Client is not initialized");
+ return;
+ }
+ final IDistributionClientResult clientResult = distributionClient.start();
+ if (!clientResult.getDistributionActionResult().equals(DistributionActionResultEnum.SUCCESS)) {
+ LOGGER.error("SDC client start failed with reason:" + clientResult.getDistributionMessageResult()
+ + ". Start will be retried after " + retryDelay + SECONDS);
+ return;
+ }
+ LOGGER.debug("SDC Client is started successfully");
+ changeSdcReceptionHandlerStatus(SdcReceptionHandlerStatus.IDLE);
+ sdcClientHandler.cancel();
+ }
+
+ /**
+ * Method to stop the SDC client.
+ *
+ */
+ protected void stopSdcClient() {
+ LOGGER.debug("Going to stop the SDC Client...");
+ final IDistributionClientResult clientResult = distributionClient.stop();
+ if (!clientResult.getDistributionActionResult().equals(DistributionActionResultEnum.SUCCESS)) {
+ LOGGER.error("SDC client stop failed with reason:" + clientResult.getDistributionMessageResult()
+ + ". Stop will be retried after " + retryDelay + SECONDS);
+ return;
+ }
+ LOGGER.debug("SDC Client is stopped successfully");
+ changeSdcReceptionHandlerStatus(SdcReceptionHandlerStatus.STOPPED);
+ sdcClientHandler.cancel();
+ }
+
+ /**
+ * Method to process csar service artifacts from incoming SDC notification.
+ *
+ * @param notificationData the notification from SDC
+ */
+ public void processCsarServiceArtifacts(final INotificationData notificationData) {
+ boolean artifactsProcessedSuccessfully = true;
+ DistributionStatisticsManager.updateTotalDistributionCount();
+ for (final IArtifactInfo artifact : notificationData.getServiceArtifacts()) {
+ try {
+ final IDistributionClientDownloadResult resultArtifact =
+ downloadTheArtifact(artifact, notificationData);
+ final Path filePath = writeArtifactToFile(artifact, resultArtifact);
+ final Csar csarObject = new Csar(filePath.toString());
+ inputReceived(csarObject);
+ sendDistributionStatus(DistributionStatusType.DEPLOY, artifact.getArtifactURL(),
+ notificationData.getDistributionID(), DistributionStatusEnum.DEPLOY_OK, null);
+ deleteArtifactFile(filePath);
+ } catch (final ArtifactDownloadException | PolicyDecodingException exp) {
+ LOGGER.error("Failed to process csar service artifacts ", exp);
+ artifactsProcessedSuccessfully = false;
+ sendDistributionStatus(DistributionStatusType.DEPLOY, artifact.getArtifactURL(),
+ notificationData.getDistributionID(), DistributionStatusEnum.DEPLOY_ERROR,
+ "Failed to deploy the artifact due to: " + exp.getMessage());
+ }
+ }
+ if (artifactsProcessedSuccessfully) {
+ DistributionStatisticsManager.updateDistributionSuccessCount();
+ sendComponentDoneStatus(notificationData.getDistributionID(), DistributionStatusEnum.COMPONENT_DONE_OK,
+ null);
+ } else {
+ DistributionStatisticsManager.updateDistributionFailureCount();
+ sendComponentDoneStatus(notificationData.getDistributionID(), DistributionStatusEnum.COMPONENT_DONE_ERROR,
+ "Failed to process the artifact");
+ }
+ }
+
+ /**
+ * Method to download the distribution artifact.
+ *
+ * @param artifact the artifact
+ * @return the download result
+ * @throws ArtifactDownloadException if download fails
+ */
+ private IDistributionClientDownloadResult downloadTheArtifact(final IArtifactInfo artifact,
+ final INotificationData notificationData) throws ArtifactDownloadException {
+
+ DistributionStatisticsManager.updateTotalDownloadCount();
+ final IDistributionClientDownloadResult downloadResult = distributionClient.download(artifact);
+ if (!downloadResult.getDistributionActionResult().equals(DistributionActionResultEnum.SUCCESS)) {
+ DistributionStatisticsManager.updateDownloadFailureCount();
+ final String message = "Failed to download artifact with name: " + artifact.getArtifactName() + " due to: "
+ + downloadResult.getDistributionMessageResult();
+ LOGGER.error(message);
+ sendDistributionStatus(DistributionStatusType.DOWNLOAD, artifact.getArtifactURL(),
+ notificationData.getDistributionID(), DistributionStatusEnum.DOWNLOAD_ERROR, message);
+ throw new ArtifactDownloadException(message);
+ }
+ DistributionStatisticsManager.updateDownloadSuccessCount();
+ sendDistributionStatus(DistributionStatusType.DOWNLOAD, artifact.getArtifactURL(),
+ notificationData.getDistributionID(), DistributionStatusEnum.DOWNLOAD_OK, null);
+ return downloadResult;
+ }
+
+ /**
+ * Method to write the downloaded distribution artifact to local file system.
+ *
+ * @param artifact the notification artifact
+ * @param resultArtifact the download result artifact
+ * @return the local path of written file
+ * @throws ArtifactDownloadException if error occurs while writing the artifact
+ */
+ private Path writeArtifactToFile(final IArtifactInfo artifact,
+ final IDistributionClientDownloadResult resultArtifact) throws ArtifactDownloadException {
+ try {
+ final byte[] payloadBytes = resultArtifact.getArtifactPayload();
+ final File tempArtifactFile = File.createTempFile(artifact.getArtifactName(), ".csar");
+ try (FileOutputStream fileOutputStream = new FileOutputStream(tempArtifactFile)) {
+ fileOutputStream.write(payloadBytes, 0, payloadBytes.length);
+ return tempArtifactFile.toPath();
+ }
+ } catch (final Exception exp) {
+ final String message = "Failed to write artifact to local repository";
+ LOGGER.error(message, exp);
+ throw new ArtifactDownloadException(message, exp);
+ }
+ }
+
+ /**
+ * Method to delete the downloaded notification artifact from local file system.
+ *
+ * @param filePath the path of file
+ */
+ private void deleteArtifactFile(final Path filePath) {
+ try {
+ Files.deleteIfExists(filePath);
+ } catch (final IOException exp) {
+ LOGGER.error("Failed to delete the downloaded artifact file", exp);
+ }
+ }
+
+ /**
+ * Sends the distribution status to SDC using the input values.
+ *
+ * @param statusType the status type
+ * @param artifactUrl the artifact url
+ * @param distributionId the distribution id
+ * @param status the status
+ * @param errorReason the error reason
+ */
+ private void sendDistributionStatus(final DistributionStatusType statusType, final String artifactUrl,
+ final String distributionId, final DistributionStatusEnum status, final String errorReason) {
+
+ IDistributionClientResult clientResult;
+ final DistributionStatusMessageBuilder messageBuilder = new DistributionStatusMessageBuilder()
+ .setArtifactUrl(artifactUrl).setConsumerId(sdcConfig.getConsumerID()).setDistributionId(distributionId)
+ .setDistributionStatus(status).setTimestamp(System.currentTimeMillis());
+ final IDistributionStatusMessage message = new DistributionStatusMessage(messageBuilder);
+ if (DistributionStatusType.DOWNLOAD.equals(statusType)) {
+ if (errorReason != null) {
+ clientResult = distributionClient.sendDownloadStatus(message, errorReason);
+ } else {
+ clientResult = distributionClient.sendDownloadStatus(message);
+ }
+ } else {
+ if (errorReason != null) {
+ clientResult = distributionClient.sendDeploymentStatus(message, errorReason);
+ } else {
+ clientResult = distributionClient.sendDeploymentStatus(message);
+ }
+ }
+ final StringBuilder loggerMessage = new StringBuilder();
+ loggerMessage.append("distribution status to SDC with values - ").append("DistributionId")
+ .append(distributionId).append(" Artifact: ").append(artifactUrl).append(" StatusType: ")
+ .append(statusType.name()).append(" Status: ").append(status.name());
+ if (errorReason != null) {
+ loggerMessage.append(" ErrorReason: ").append(errorReason);
+ }
+ if (!clientResult.getDistributionActionResult().equals(DistributionActionResultEnum.SUCCESS)) {
+ loggerMessage.insert(0, "Failed sending ");
+ LOGGER.debug(loggerMessage);
+ } else {
+ loggerMessage.insert(0, "Successfully Sent ");
+ LOGGER.debug(loggerMessage);
+ }
+ }
+
+ /**
+ * Sends the component done status to SDC using the input values.
+ *
+ * @param distributionId the distribution Id
+ * @param status the distribution status
+ * @param errorReason the error reason
+ */
+ private void sendComponentDoneStatus(final String distributionId, final DistributionStatusEnum status,
+ final String errorReason) {
+ IDistributionClientResult clientResult;
+ final ComponentDoneStatusMessageBuilder messageBuilder = new ComponentDoneStatusMessageBuilder()
+ .setConsumerId(sdcConfig.getConsumerID()).setDistributionId(distributionId)
+ .setDistributionStatus(status).setTimestamp(System.currentTimeMillis());
+ final IComponentDoneStatusMessage message = new ComponentDoneStatusMessage(messageBuilder);
+ if (errorReason == null) {
+ clientResult = distributionClient.sendComponentDoneStatus(message);
+ } else {
+ clientResult = distributionClient.sendComponentDoneStatus(message, errorReason);
+ }
+
+ final StringBuilder loggerMessage = new StringBuilder();
+ loggerMessage.append("component done status to SDC with values - ").append("DistributionId")
+ .append(distributionId).append(" Status: ").append(status.name());
+ if (errorReason != null) {
+ loggerMessage.append(" ErrorReason: ").append(errorReason);
+ }
+ if (!clientResult.getDistributionActionResult().equals(DistributionActionResultEnum.SUCCESS)) {
+ loggerMessage.insert(0, "Failed sending ");
+ LOGGER.debug(loggerMessage);
+ } else {
+ loggerMessage.insert(0, "Successfully Sent ");
+ LOGGER.debug(loggerMessage);
+ }
+ }
+
+ /**
+ * Handle the status change of {@link SdcReceptionHandler} to Idle.
+ *
+ * @param newStatus the new status
+ */
+ private void handleIdleStatusChange(final SdcReceptionHandlerStatus newStatus) {
+ if (nbOfNotificationsOngoing > 1) {
+ --nbOfNotificationsOngoing;
+ } else {
+ nbOfNotificationsOngoing = 0;
+ sdcReceptionHandlerStatus = newStatus;
+ }
+ }
+}
diff --git a/artifactbroker/plugins/reception-plugins/src/main/java/org/onap/policy/distribution/reception/handling/sdc/SdcReceptionHandlerConfigurationParameterBuilder.java b/artifactbroker/plugins/reception-plugins/src/main/java/org/onap/policy/distribution/reception/handling/sdc/SdcReceptionHandlerConfigurationParameterBuilder.java
new file mode 100644
index 0000000..65305c1
--- /dev/null
+++ b/artifactbroker/plugins/reception-plugins/src/main/java/org/onap/policy/distribution/reception/handling/sdc/SdcReceptionHandlerConfigurationParameterBuilder.java
@@ -0,0 +1,357 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * Copyright (C) 2018 Ericsson. 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;
+
+/**
+ * This class builds an instance of {@link SdcReceptionHandlerConfigurationParameterGroup} class.
+ *
+ * @author Ram Krishna Verma (ram.krishna.verma@ericsson.com)
+ */
+public class SdcReceptionHandlerConfigurationParameterBuilder {
+
+ private boolean activeserverTlsAuth;
+ private boolean filterinEmptyResources;
+ private boolean useHttpsWithDmaap;
+ private int pollingTimeout;
+ private int pollingInterval;
+ private String user;
+ private String password;
+ private String consumerId;
+ private String consumerGroup;
+ private String asdcAddress;
+ private String environmentName;
+ private String keystorePath;
+ private String keystorePassword;
+ private List<String> messageBusAddress;
+ private List<String> artifactTypes;
+ private int retryDelay;
+
+ /**
+ * Set activeserverTlsAuth to this {@link SdcReceptionHandlerConfigurationParameterBuilder} instance.
+ *
+ * @param activeserverTlsAuth the activeserverTlsAuth
+ */
+ public SdcReceptionHandlerConfigurationParameterBuilder setActiveserverTlsAuth(final boolean activeserverTlsAuth) {
+ this.activeserverTlsAuth = activeserverTlsAuth;
+ return this;
+ }
+
+ /**
+ * Set filterinEmptyResources to this {@link SdcReceptionHandlerConfigurationParameterBuilder} instance.
+ *
+ * @param filterinEmptyResources the filterinEmptyResources
+ */
+ public SdcReceptionHandlerConfigurationParameterBuilder setFilterinEmptyResources(
+ final boolean filterinEmptyResources) {
+ this.filterinEmptyResources = filterinEmptyResources;
+ return this;
+ }
+
+ /**
+ * Set useHttpsWithDmaap to this {@link SdcReceptionHandlerConfigurationParameterBuilder} instance.
+ *
+ * @param useHttpsWithDmaap the useHttpsWithDmaap
+ */
+ public SdcReceptionHandlerConfigurationParameterBuilder setUseHttpsWithDmaap(final Boolean useHttpsWithDmaap) {
+ this.useHttpsWithDmaap = useHttpsWithDmaap;
+ return this;
+ }
+
+ /**
+ * Set pollingInterval to this {@link SdcReceptionHandlerConfigurationParameterBuilder} instance.
+ *
+ * @param pollingInterval the pollingInterval
+ */
+ public SdcReceptionHandlerConfigurationParameterBuilder setPollingInterval(final int pollingInterval) {
+ this.pollingInterval = pollingInterval;
+ return this;
+ }
+
+ /**
+ * Set pollingTimeout to this {@link SdcReceptionHandlerConfigurationParameterBuilder} instance.
+ *
+ * @param pollingTimeout the pollingTimeout
+ */
+ public SdcReceptionHandlerConfigurationParameterBuilder setPollingTimeout(final int pollingTimeout) {
+ this.pollingTimeout = pollingTimeout;
+ return this;
+ }
+
+ /**
+ * Set asdcAddress to this {@link SdcReceptionHandlerConfigurationParameterBuilder} instance.
+ *
+ * @param asdcAddress the asdcAddress
+ */
+ public SdcReceptionHandlerConfigurationParameterBuilder setAsdcAddress(final String asdcAddress) {
+ this.asdcAddress = asdcAddress;
+ return this;
+ }
+
+ /**
+ * Set user to this {@link SdcReceptionHandlerConfigurationParameterBuilder} instance.
+ *
+ * @param user the user
+ */
+ public SdcReceptionHandlerConfigurationParameterBuilder setUser(final String user) {
+ this.user = user;
+ return this;
+ }
+
+ /**
+ * Set password to this {@link SdcReceptionHandlerConfigurationParameterBuilder} instance.
+ *
+ * @param password the password
+ */
+ public SdcReceptionHandlerConfigurationParameterBuilder setPassword(final String password) {
+ this.password = password;
+ return this;
+ }
+
+ /**
+ * Set consumerId to this {@link SdcReceptionHandlerConfigurationParameterBuilder} instance.
+ *
+ * @param consumerId the consumerId
+ */
+ public SdcReceptionHandlerConfigurationParameterBuilder setConsumerId(final String consumerId) {
+ this.consumerId = consumerId;
+ return this;
+ }
+
+ /**
+ * Set consumerGroup to this {@link SdcReceptionHandlerConfigurationParameterBuilder} instance.
+ *
+ * @param consumerGroup the consumerGroup
+ */
+ public SdcReceptionHandlerConfigurationParameterBuilder setConsumerGroup(final String consumerGroup) {
+ this.consumerGroup = consumerGroup;
+ return this;
+ }
+
+ /**
+ * Set environmentName to this {@link SdcReceptionHandlerConfigurationParameterBuilder} instance.
+ *
+ * @param environmentName the environmentName
+ */
+ public SdcReceptionHandlerConfigurationParameterBuilder setEnvironmentName(final String environmentName) {
+ this.environmentName = environmentName;
+ return this;
+ }
+
+ /**
+ * Set keystorePath to this {@link SdcReceptionHandlerConfigurationParameterBuilder} instance.
+ *
+ * @param keystorePath the keystorePath
+ */
+ public SdcReceptionHandlerConfigurationParameterBuilder setKeystorePath(final String keystorePath) {
+ this.keystorePath = keystorePath;
+ return this;
+ }
+
+ /**
+ * Set keystorePassword to this {@link SdcReceptionHandlerConfigurationParameterBuilder} instance.
+ *
+ * @param keystorePassword the keystorePassword
+ */
+ public SdcReceptionHandlerConfigurationParameterBuilder setKeystorePassword(final String keystorePassword) {
+ this.keystorePassword = keystorePassword;
+ return this;
+ }
+
+ /**
+ * Set messageBusAddress to this {@link SdcReceptionHandlerConfigurationParameterBuilder} instance.
+ *
+ * @param messageBusAddress the messageBusAddress
+ */
+ public SdcReceptionHandlerConfigurationParameterBuilder setMessageBusAddress(final List<String> messageBusAddress) {
+ this.messageBusAddress = messageBusAddress;
+ return this;
+ }
+
+ /**
+ * Set artifactTypes to this {@link SdcReceptionHandlerConfigurationParameterBuilder} instance.
+ *
+ * @param artifactTypes the artifactTypes
+ */
+ public SdcReceptionHandlerConfigurationParameterBuilder setArtifactTypes(final List<String> artifactTypes) {
+ this.artifactTypes = artifactTypes;
+ return this;
+ }
+
+ /**
+ * Set retryDelay to this {@link SdcReceptionHandlerConfigurationParameterBuilder} instance.
+ *
+ * @param retryDelay the retryDelay
+ */
+ public SdcReceptionHandlerConfigurationParameterBuilder setRetryDelay(final int retryDelay) {
+ this.retryDelay = retryDelay;
+ return this;
+ }
+
+ /**
+ * Returns the active server TlsAuth of this {@link SdcReceptionHandlerConfigurationParameterBuilder} instance.
+ *
+ * @return the activeserverTlsAuth
+ */
+ public boolean isActiveserverTlsAuth() {
+ return activeserverTlsAuth;
+ }
+
+ /**
+ * Returns the isFilterinEmptyResources flag of this {@link SdcReceptionHandlerConfigurationParameterBuilder}
+ * instance.
+ *
+ * @return the isFilterinEmptyResources
+ */
+ public boolean isFilterinEmptyResources() {
+ return filterinEmptyResources;
+ }
+
+ /**
+ * Returns the isUseHttpsWithDmaap flag of this {@link SdcReceptionHandlerConfigurationParameterBuilder} instance.
+ *
+ * @return the isUseHttpsWithDmaap
+ */
+ public Boolean getIsUseHttpsWithDmaap() {
+ return useHttpsWithDmaap;
+ }
+
+ /**
+ * Returns the polling interval of this {@link SdcReceptionHandlerConfigurationParameterBuilder} instance.
+ *
+ * @return the pollingInterval
+ */
+ public int getPollingInterval() {
+ return pollingInterval;
+ }
+
+ /**
+ * Returns the polling timeout of this {@link SdcReceptionHandlerConfigurationParameterBuilder} instance.
+ *
+ * @return the pollingTimeout
+ */
+ public int getPollingTimeout() {
+ return pollingTimeout;
+ }
+
+ /**
+ * Returns the asdc address of this {@link SdcReceptionHandlerConfigurationParameterBuilder} instance.
+ *
+ * @return the asdcAddress
+ */
+ public String getAsdcAddress() {
+ return asdcAddress;
+ }
+
+ /**
+ * Returns the user of this {@link SdcReceptionHandlerConfigurationParameterBuilder} instance.
+ *
+ * @return the user
+ */
+ public String getUser() {
+ return user;
+ }
+
+ /**
+ * Returns the password of this {@link SdcReceptionHandlerConfigurationParameterBuilder} instance.
+ *
+ * @return the password
+ */
+ public String getPassword() {
+ return password;
+ }
+
+ /**
+ * Returns the consumer id of this {@link SdcReceptionHandlerConfigurationParameterBuilder} instance.
+ *
+ * @return the consumerId
+ */
+ public String getConsumerId() {
+ return consumerId;
+ }
+
+ /**
+ * Returns the consumer group of this {@link SdcReceptionHandlerConfigurationParameterBuilder} instance.
+ *
+ * @return the consumerGroup
+ */
+ public String getConsumerGroup() {
+ return consumerGroup;
+ }
+
+ /**
+ * Returns the environment name of this {@link SdcReceptionHandlerConfigurationParameterBuilder} instance.
+ *
+ * @return the environmentName
+ */
+ public String getEnvironmentName() {
+ return environmentName;
+ }
+
+ /**
+ * Returns the keystore path of this {@link SdcReceptionHandlerConfigurationParameterBuilder} instance.
+ *
+ * @return the keystorePath
+ */
+ public String getKeystorePath() {
+ return keystorePath;
+ }
+
+ /**
+ * Returns the keystore password of this {@link SdcReceptionHandlerConfigurationParameterBuilder} instance.
+ *
+ * @return the keystorePassword
+ */
+ public String getKeystorePassword() {
+ return keystorePassword;
+ }
+
+ /**
+ * Returns the message bus address of this {@link SdcReceptionHandlerConfigurationParameterBuilder} instance.
+ *
+ * @return the messageBusAddress
+ */
+ public List<String> getMessageBusAddress() {
+ return messageBusAddress;
+ }
+
+ /**
+ * Returns the artifact types of this {@link SdcReceptionHandlerConfigurationParameterBuilder} instance.
+ *
+ * @return the artifactTypes
+ */
+ public List<String> getArtifactTypes() {
+ return artifactTypes;
+ }
+
+ /**
+ * Returns the retryDelay of this {@link SdcReceptionHandlerConfigurationParameterBuilder} instance.
+ *
+ * @return the retryDelay
+ */
+ public int getRetryDelay() {
+ return retryDelay;
+ }
+
+}
+
+
diff --git a/artifactbroker/plugins/reception-plugins/src/main/java/org/onap/policy/distribution/reception/handling/sdc/SdcReceptionHandlerConfigurationParameterGroup.java b/artifactbroker/plugins/reception-plugins/src/main/java/org/onap/policy/distribution/reception/handling/sdc/SdcReceptionHandlerConfigurationParameterGroup.java
new file mode 100644
index 0000000..6746dc3
--- /dev/null
+++ b/artifactbroker/plugins/reception-plugins/src/main/java/org/onap/policy/distribution/reception/handling/sdc/SdcReceptionHandlerConfigurationParameterGroup.java
@@ -0,0 +1,210 @@
+/*-
+ * ============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 org.onap.policy.common.parameters.GroupValidationResult;
+import org.onap.policy.common.parameters.ValidationStatus;
+import org.onap.policy.common.utils.validation.ParameterValidationUtils;
+import org.onap.policy.distribution.reception.parameters.ReceptionHandlerConfigurationParameterGroup;
+
+/**
+ * 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 SdcReceptionHandlerConfigurationParameterGroup extends ReceptionHandlerConfigurationParameterGroup {
+
+ private String asdcAddress;
+ private List<String> messageBusAddress;
+ private String user;
+ private String password;
+ private int pollingInterval;
+ private int pollingTimeout;
+ private int retryDelay;
+ 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;
+
+ /**
+ * The constructor for instantiating {@link SdcReceptionHandlerConfigurationParameterGroup} class.
+ *
+ * @param builder the SDC configuration builder
+ */
+ public SdcReceptionHandlerConfigurationParameterGroup(
+ final SdcReceptionHandlerConfigurationParameterBuilder builder) {
+ asdcAddress = builder.getAsdcAddress();
+ messageBusAddress = builder.getMessageBusAddress();
+ user = builder.getUser();
+ password = builder.getPassword();
+ pollingInterval = builder.getPollingInterval();
+ pollingTimeout = builder.getPollingTimeout();
+ retryDelay = builder.getRetryDelay();
+ consumerId = builder.getConsumerId();
+ artifactTypes = builder.getArtifactTypes();
+ consumerGroup = builder.getConsumerGroup();
+ environmentName = builder.getEnvironmentName();
+ keyStorePath = builder.getKeystorePath();
+ keyStorePassword = builder.getKeystorePassword();
+ activeServerTlsAuth = builder.isActiveserverTlsAuth();
+ isFilterInEmptyResources = builder.isFilterinEmptyResources();
+ isUseHttpsWithDmaap = builder.getIsUseHttpsWithDmaap();
+
+ }
+
+ public String getAsdcAddress() {
+ return asdcAddress;
+ }
+
+ public List<String> getMessageBusAddress() {
+ return messageBusAddress;
+ }
+
+ public String getUser() {
+ return user;
+ }
+
+ public String getPassword() {
+ return password;
+ }
+
+ public int getPollingInterval() {
+ return pollingInterval;
+ }
+
+ public int getPollingTimeout() {
+ return pollingTimeout;
+ }
+
+ public int getRetryDelay() {
+ return retryDelay;
+ }
+
+ 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 boolean isActiveServerTlsAuth() {
+ return activeServerTlsAuth;
+ }
+
+ public String getKeyStorePath() {
+ return keyStorePath;
+ }
+
+ public boolean isFilterInEmptyResources() {
+ return isFilterInEmptyResources;
+ }
+
+ public boolean isUseHttpsWithDmaap() {
+ return isUseHttpsWithDmaap;
+ }
+
+ /**
+ * {@inheritDoc}.
+ */
+ @Override
+ public GroupValidationResult validate() {
+ final GroupValidationResult validationResult = new GroupValidationResult(this);
+ validateStringElement(validationResult, asdcAddress, "asdcAddress");
+ validateStringElement(validationResult, user, "user");
+ validateStringElement(validationResult, consumerId, "consumerId");
+ validateStringElement(validationResult, consumerGroup, "consumerGroup");
+ validateStringElement(validationResult, keyStorePath, "keyStorePath");
+ validateStringElement(validationResult, keyStorePassword, "keyStorePassword");
+ validateIntElement(validationResult, pollingInterval, "pollingInterval");
+ validateIntElement(validationResult, pollingTimeout, "pollingTimeout");
+ validateIntElement(validationResult, retryDelay, "retryDelay");
+ validateStringListElement(validationResult, messageBusAddress, "messageBusAddress");
+ validateStringListElement(validationResult, artifactTypes, "artifactTypes");
+ return validationResult;
+ }
+
+ /**
+ * Validate the integer Element.
+ *
+ * @param validationResult the result object
+ * @param element the element to validate
+ * @param elementName the element name for error message
+ */
+ private void validateIntElement(final GroupValidationResult validationResult, final int element,
+ final String elementName) {
+ if (!ParameterValidationUtils.validateIntParameter(element)) {
+ validationResult.setResult(elementName, ValidationStatus.INVALID,
+ elementName + " must be a positive integer");
+ }
+ }
+
+ /**
+ * Validate the String List Element.
+ *
+ * @param validationResult the result object
+ * @param element the element to validate
+ * @param elementName the element name for error message
+ */
+ private void validateStringListElement(final GroupValidationResult validationResult, final List<String> element,
+ final String elementName) {
+ for (final String temp : element) {
+ if (!ParameterValidationUtils.validateStringParameter(temp)) {
+ validationResult.setResult(elementName, ValidationStatus.INVALID,
+ "the string of " + elementName + "must be a non-blank string");
+ }
+ }
+ }
+
+ /**
+ * Validate the string element.
+ *
+ * @param validationResult the result object
+ * @param element the element to validate
+ * @param elementName the element name for error message
+ */
+ private void validateStringElement(final GroupValidationResult validationResult, final String element,
+ final String elementName) {
+ if (!ParameterValidationUtils.validateStringParameter(element)) {
+ validationResult.setResult(elementName, ValidationStatus.INVALID,
+ elementName + " must be a non-blank string");
+ }
+ }
+}
+
diff --git a/artifactbroker/plugins/reception-plugins/src/main/java/org/onap/policy/distribution/reception/handling/sdc/SdcReceptionHandlerStatus.java b/artifactbroker/plugins/reception-plugins/src/main/java/org/onap/policy/distribution/reception/handling/sdc/SdcReceptionHandlerStatus.java
new file mode 100644
index 0000000..d0e04c7
--- /dev/null
+++ b/artifactbroker/plugins/reception-plugins/src/main/java/org/onap/policy/distribution/reception/handling/sdc/SdcReceptionHandlerStatus.java
@@ -0,0 +1,49 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * Copyright (C) 2018 Ericsson. 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;
+
+/**
+ * Class to hold the possible values for status of {@link SdcReceptionHandler}.
+ *
+ * @author Ram Krishna Verma (ram.krishna.verma@ericsson.com)
+ */
+public enum SdcReceptionHandlerStatus {
+
+ /**
+ * The SdcReceptionHandler is not alive.
+ */
+ STOPPED,
+
+ /**
+ * The SdcReceptionHandler is initialized but not started yet.
+ */
+ INIT,
+
+ /**
+ * The SdcReceptionHandler is initialized, started & ready to handle incoming notifications.
+ */
+ IDLE,
+
+ /**
+ * The SdcReceptionHandler is currently busy in handling notifications.
+ */
+ BUSY
+}
diff --git a/artifactbroker/plugins/reception-plugins/src/main/java/org/onap/policy/distribution/reception/handling/sdc/exceptions/ArtifactDownloadException.java b/artifactbroker/plugins/reception-plugins/src/main/java/org/onap/policy/distribution/reception/handling/sdc/exceptions/ArtifactDownloadException.java
new file mode 100644
index 0000000..23409ea
--- /dev/null
+++ b/artifactbroker/plugins/reception-plugins/src/main/java/org/onap/policy/distribution/reception/handling/sdc/exceptions/ArtifactDownloadException.java
@@ -0,0 +1,53 @@
+/*-
+ * ============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.exceptions;
+
+/**
+ * Exception during download from Pssd.
+ */
+public class ArtifactDownloadException extends Exception {
+
+ /**
+ * serialization id.
+ */
+ private static final long serialVersionUID = -8507246953751956974L;
+
+ /**
+ * Constructor for creating PssdDownloadException using message.
+ *
+ * @param message The message to dump
+ */
+ public ArtifactDownloadException(final String message) {
+ super(message);
+
+ }
+
+ /**
+ * Constructor for creating PssdDownloadException using message and exception.
+ *
+ * @param message The message to dump
+ * @param ex the exception that caused this exception to be thrown
+ */
+ public ArtifactDownloadException(final String message, final Exception ex) {
+ super(message, ex);
+
+ }
+}
diff --git a/artifactbroker/plugins/reception-plugins/src/main/java/org/onap/policy/distribution/reception/handling/sdc/exceptions/ArtifactInstallerException.java b/artifactbroker/plugins/reception-plugins/src/main/java/org/onap/policy/distribution/reception/handling/sdc/exceptions/ArtifactInstallerException.java
new file mode 100644
index 0000000..19e711b
--- /dev/null
+++ b/artifactbroker/plugins/reception-plugins/src/main/java/org/onap/policy/distribution/reception/handling/sdc/exceptions/ArtifactInstallerException.java
@@ -0,0 +1,53 @@
+/*-
+ * ============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.exceptions;
+
+/**
+ * Exception during artifact installation.
+ */
+public class ArtifactInstallerException extends Exception {
+
+ /**
+ * serialization id.
+ */
+ private static final long serialVersionUID = -8507246953751956974L;
+
+ /**
+ * Constructor for creating ArtifactInstallerException using message.
+ *
+ * @param message The message to dump
+ */
+ public ArtifactInstallerException(final String message) {
+ super(message);
+
+ }
+
+ /**
+ * Constructor for creating ArtifactInstallerException using message and exception.
+ *
+ * @param message The message to dump
+ * @param ex the exception that caused this exception to be thrown
+ */
+ public ArtifactInstallerException(final String message, final Exception ex) {
+ super(message, ex);
+
+ }
+}
diff --git a/artifactbroker/plugins/reception-plugins/src/main/java/org/onap/policy/distribution/reception/handling/sdc/exceptions/PssdControllerException.java b/artifactbroker/plugins/reception-plugins/src/main/java/org/onap/policy/distribution/reception/handling/sdc/exceptions/PssdControllerException.java
new file mode 100644
index 0000000..0dd16d7
--- /dev/null
+++ b/artifactbroker/plugins/reception-plugins/src/main/java/org/onap/policy/distribution/reception/handling/sdc/exceptions/PssdControllerException.java
@@ -0,0 +1,53 @@
+/*-
+ * ============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.exceptions;
+
+/**
+ * Exception of the Pssd controller.
+ */
+public class PssdControllerException extends Exception {
+
+ /**
+ * serialization id.
+ */
+ private static final long serialVersionUID = -8507246953751956974L;
+
+ /**
+ * Constructor for creating PssdControllerException using message.
+ *
+ * @param message The message to dump
+ */
+ public PssdControllerException(final String message) {
+ super(message);
+
+ }
+
+ /**
+ * Constructor for creating PssdControllerException using message and exception.
+ *
+ * @param message The message to dump
+ * @param ex the exception that caused this exception to be thrown
+ */
+ public PssdControllerException(final String message, final Exception ex) {
+ super(message, ex);
+
+ }
+}
diff --git a/artifactbroker/plugins/reception-plugins/src/main/java/org/onap/policy/distribution/reception/handling/sdc/exceptions/PssdParametersException.java b/artifactbroker/plugins/reception-plugins/src/main/java/org/onap/policy/distribution/reception/handling/sdc/exceptions/PssdParametersException.java
new file mode 100644
index 0000000..e1cdf70
--- /dev/null
+++ b/artifactbroker/plugins/reception-plugins/src/main/java/org/onap/policy/distribution/reception/handling/sdc/exceptions/PssdParametersException.java
@@ -0,0 +1,53 @@
+/*-
+ * ============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.exceptions;
+
+/**
+ * Exception of the Pssd controller.
+ */
+public class PssdParametersException extends Exception {
+
+ /**
+ * serialization id.
+ */
+ private static final long serialVersionUID = -8507246953751956974L;
+
+ /**
+ * Constructor for creating PssdParametersException using message.
+ *
+ * @param message The message to dump
+ */
+ public PssdParametersException(final String message) {
+ super(message);
+
+ }
+
+ /**
+ * Constructor for creating PssdParametersException using message and exception.
+ *
+ * @param message The message to dump
+ * @param ex the exception that caused this exception to be thrown
+ */
+ public PssdParametersException(final String message, final Exception ex) {
+ super(message, ex);
+
+ }
+}
diff --git a/artifactbroker/plugins/reception-plugins/src/test/java/org/onap/policy/distribution/reception/handling/sdc/DummyArtifactForwarder.java b/artifactbroker/plugins/reception-plugins/src/test/java/org/onap/policy/distribution/reception/handling/sdc/DummyArtifactForwarder.java
new file mode 100644
index 0000000..445d47c
--- /dev/null
+++ b/artifactbroker/plugins/reception-plugins/src/test/java/org/onap/policy/distribution/reception/handling/sdc/DummyArtifactForwarder.java
@@ -0,0 +1,72 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * Copyright (C) 2018 Ericsson. 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.ArrayList;
+import java.util.Collection;
+
+import org.onap.policy.distribution.forwarding.ArtifactForwarder;
+import org.onap.policy.distribution.forwarding.ArtifactForwardingException;
+import org.onap.sdc.api.notification.IArtifactInfo;
+
+/**
+ * Class to create a dummy forwarder for test cases.
+ *
+ * @author Ram Krishna Verma (ram.krishna.verma@ericsson.com)
+ */
+public class DummyArtifactForwarder implements ArtifactForwarder {
+ private int numberOfPoliciesReceived = 0;
+ private Collection<IArtifactInfo> policiesReceived = new ArrayList<>();
+
+ /**
+ * {@inheritDoc}.
+ */
+ @Override
+ public void forward(final Collection<IArtifactInfo> policies) throws ArtifactForwardingException {
+ numberOfPoliciesReceived += policies.size();
+ policiesReceived.addAll(policies);
+ }
+
+ /**
+ * Returns the number of policies received by this forwarder.
+ *
+ * @return the integer value
+ */
+ public int getNumberOfPoliciesReceived() {
+ return numberOfPoliciesReceived;
+ }
+
+ /**
+ * Checks if the forwarder has received a policy with given policy type.
+ *
+ * @param policyType the policy type
+ * @return the boolean result
+ */
+ public boolean receivedPolicyWithGivenType(final String policyType) {
+ return true;
+ }
+
+ /**
+ * {@inheritDoc}.
+ */
+ @Override
+ public void configure(final String parameterGroupName) {}
+}
diff --git a/artifactbroker/plugins/reception-plugins/src/test/java/org/onap/policy/distribution/reception/handling/sdc/DummyPolicy.java b/artifactbroker/plugins/reception-plugins/src/test/java/org/onap/policy/distribution/reception/handling/sdc/DummyPolicy.java
new file mode 100644
index 0000000..f4c56ab
--- /dev/null
+++ b/artifactbroker/plugins/reception-plugins/src/test/java/org/onap/policy/distribution/reception/handling/sdc/DummyPolicy.java
@@ -0,0 +1,62 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * Copyright (C) 2018 Ericsson. 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 org.onap.policy.distribution.model.Policy;
+
+/**
+ * Class to create a dummy policy for test cases.
+ *
+ * @author Ram Krishna Verma (ram.krishna.verma@ericsson.com)
+ */
+public class DummyPolicy implements Policy {
+
+ private String policyName;
+ private String policyType;
+
+ /**
+ * Constructor for instantiating {@link DummyPolicy} class.
+ *
+ * @param policyName the policy name
+ * @param policyType the policy type
+ */
+ public DummyPolicy(final String policyName, final String policyType) {
+ super();
+ this.policyName = policyName;
+ this.policyType = policyType;
+ }
+
+ /**
+ * {@inheritDoc}.
+ */
+ @Override
+ public String getPolicyName() {
+ return policyName;
+ }
+
+ /**
+ * {@inheritDoc}.
+ */
+ @Override
+ public String getPolicyType() {
+ return policyType;
+ }
+}
diff --git a/artifactbroker/plugins/reception-plugins/src/test/java/org/onap/policy/distribution/reception/handling/sdc/TestComponentDoneStatusMessage.java b/artifactbroker/plugins/reception-plugins/src/test/java/org/onap/policy/distribution/reception/handling/sdc/TestComponentDoneStatusMessage.java
new file mode 100644
index 0000000..75e3224
--- /dev/null
+++ b/artifactbroker/plugins/reception-plugins/src/test/java/org/onap/policy/distribution/reception/handling/sdc/TestComponentDoneStatusMessage.java
@@ -0,0 +1,61 @@
+/*-
+ * ============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 org.junit.Test;
+import org.onap.sdc.utils.DistributionStatusEnum;
+
+public class TestComponentDoneStatusMessage {
+
+ @Test
+ public void testComponentDoneStatusMessage_Success() {
+ final String consumerId = "dummyId";
+ final String distributionId = "dummyDistribution";
+ final long timestamp = System.currentTimeMillis();
+ final ComponentDoneStatusMessageBuilder messageBuilder =
+ new ComponentDoneStatusMessageBuilder().setConsumerId(consumerId).setDistributionId(distributionId)
+ .setDistributionStatus(DistributionStatusEnum.COMPONENT_DONE_OK).setTimestamp(timestamp);
+ final ComponentDoneStatusMessage message = new ComponentDoneStatusMessage(messageBuilder);
+ assertEquals("POLICY", message.getComponentName());
+ assertEquals(consumerId, message.getConsumerID());
+ assertEquals(distributionId, message.getDistributionID());
+ assertEquals(DistributionStatusEnum.COMPONENT_DONE_OK, message.getStatus());
+ assertEquals(timestamp, message.getTimestamp());
+ }
+
+ @Test
+ public void testComponentDoneStatusMessage_Failure() {
+ final String consumerId = "dummyId";
+ final String distributionId = "dummyDistribution";
+ final long timestamp = System.currentTimeMillis();
+ final ComponentDoneStatusMessageBuilder messageBuilder =
+ new ComponentDoneStatusMessageBuilder().setConsumerId(consumerId).setDistributionId(distributionId)
+ .setDistributionStatus(DistributionStatusEnum.COMPONENT_DONE_ERROR).setTimestamp(timestamp);
+ final ComponentDoneStatusMessage message = new ComponentDoneStatusMessage(messageBuilder);
+ assertEquals("POLICY", message.getComponentName());
+ assertEquals(consumerId, message.getConsumerID());
+ assertEquals(distributionId, message.getDistributionID());
+ assertEquals(DistributionStatusEnum.COMPONENT_DONE_ERROR, message.getStatus());
+ assertEquals(timestamp, message.getTimestamp());
+ }
+}
diff --git a/artifactbroker/plugins/reception-plugins/src/test/java/org/onap/policy/distribution/reception/handling/sdc/TestDistributionStatusMessage.java b/artifactbroker/plugins/reception-plugins/src/test/java/org/onap/policy/distribution/reception/handling/sdc/TestDistributionStatusMessage.java
new file mode 100644
index 0000000..be12777
--- /dev/null
+++ b/artifactbroker/plugins/reception-plugins/src/test/java/org/onap/policy/distribution/reception/handling/sdc/TestDistributionStatusMessage.java
@@ -0,0 +1,65 @@
+/*-
+ * ============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 org.junit.Test;
+import org.onap.sdc.utils.DistributionStatusEnum;
+
+public class TestDistributionStatusMessage {
+
+ @Test
+ public void testDistributionStatusMessage_Download() {
+ final String artifactUrl = "http://dummyurl";
+ final String consumerId = "dummyId";
+ final String distributionId = "dummyDistribution";
+ final long timestamp = System.currentTimeMillis();
+
+ final DistributionStatusMessageBuilder messageBuilder = new DistributionStatusMessageBuilder()
+ .setArtifactUrl(artifactUrl).setConsumerId(consumerId).setDistributionId(distributionId)
+ .setDistributionStatus(DistributionStatusEnum.DOWNLOAD_OK).setTimestamp(timestamp);
+ final DistributionStatusMessage message = new DistributionStatusMessage(messageBuilder);
+ assertEquals(artifactUrl, message.getArtifactURL());
+ assertEquals(consumerId, message.getConsumerID());
+ assertEquals(distributionId, message.getDistributionID());
+ assertEquals(DistributionStatusEnum.DOWNLOAD_OK, message.getStatus());
+ assertEquals(timestamp, message.getTimestamp());
+ }
+
+ @Test
+ public void testDistributionStatusMessage_Deploy() {
+ final String artifactUrl = "http://dummyurl";
+ final String consumerId = "dummyId";
+ final String distributionId = "dummyDistribution";
+ final long timestamp = System.currentTimeMillis();
+
+ final DistributionStatusMessageBuilder messageBuilder = new DistributionStatusMessageBuilder()
+ .setArtifactUrl(artifactUrl).setConsumerId(consumerId).setDistributionId(distributionId)
+ .setDistributionStatus(DistributionStatusEnum.DEPLOY_OK).setTimestamp(timestamp);
+ final DistributionStatusMessage message = new DistributionStatusMessage(messageBuilder);
+ assertEquals(artifactUrl, message.getArtifactURL());
+ assertEquals(consumerId, message.getConsumerID());
+ assertEquals(distributionId, message.getDistributionID());
+ assertEquals(DistributionStatusEnum.DEPLOY_OK, message.getStatus());
+ assertEquals(timestamp, message.getTimestamp());
+ }
+}
diff --git a/artifactbroker/plugins/reception-plugins/src/test/java/org/onap/policy/distribution/reception/handling/sdc/TestSdcReceptionHandlerConfigurationParameterGroup.java b/artifactbroker/plugins/reception-plugins/src/test/java/org/onap/policy/distribution/reception/handling/sdc/TestSdcReceptionHandlerConfigurationParameterGroup.java
new file mode 100644
index 0000000..f9a65c5
--- /dev/null
+++ b/artifactbroker/plugins/reception-plugins/src/test/java/org/onap/policy/distribution/reception/handling/sdc/TestSdcReceptionHandlerConfigurationParameterGroup.java
@@ -0,0 +1,160 @@
+/*-
+ * ============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.FileReader;
+import java.io.IOException;
+import java.util.Arrays;
+
+import org.junit.Test;
+import org.onap.policy.common.parameters.GroupValidationResult;
+
+/**
+ * Class to perform unit test of {@link SdcConfiguration}.
+ *
+ */
+public class TestSdcReceptionHandlerConfigurationParameterGroup {
+
+ @Test
+ public void testSdcConfiguration() throws IOException {
+ SdcReceptionHandlerConfigurationParameterGroup configParameters = null;
+ try {
+ final Gson gson = new GsonBuilder().create();
+ configParameters = gson.fromJson(new FileReader("src/test/resources/handling-sdc.json"),
+ SdcReceptionHandlerConfigurationParameterGroup.class);
+ } catch (final Exception e) {
+ fail("test should not thrown an exception here: " + e.getMessage());
+ }
+ final GroupValidationResult validationResult = configParameters.validate();
+ assertTrue(validationResult.isValid());
+ final SdcConfiguration config = new SdcConfiguration(configParameters);
+ assertEquals(Arrays.asList("a.com", "b.com", "c.com"), config.getMsgBusAddress());
+ assertEquals(Arrays.asList("TOSCA_CSAR", "HEAT"), config.getRelevantArtifactTypes());
+ assertEquals("localhost", config.getAsdcAddress());
+ assertEquals("policy", config.getUser());
+ assertEquals("policy", config.getPassword());
+ assertEquals(20, config.getPollingInterval());
+ assertEquals(30, config.getPollingTimeout());
+ assertEquals("policy-id", config.getConsumerID());
+ assertEquals("policy-group", config.getConsumerGroup());
+ assertEquals("TEST", config.getEnvironmentName());
+ assertEquals("null", config.getKeyStorePath());
+ assertEquals("null", config.getKeyStorePassword());
+ assertEquals(false, config.activateServerTLSAuth());
+ assertEquals(true, config.isFilterInEmptyResources());
+ assertEquals(false, config.isUseHttpsWithDmaap());
+ }
+
+ @Test
+ public void testInvalidSdcConfiguration() throws IOException {
+ SdcReceptionHandlerConfigurationParameterGroup configParameters = null;
+ try {
+ final Gson gson = new GsonBuilder().create();
+ configParameters = gson.fromJson(new FileReader("src/test/resources/handling-sdcInvalid.json"),
+ SdcReceptionHandlerConfigurationParameterGroup.class);
+ } catch (final Exception e) {
+ fail("test should not thrown an exception here: " + e.getMessage());
+ }
+ final GroupValidationResult validationResult = configParameters.validate();
+ assertFalse(validationResult.isValid());
+ }
+
+ @Test
+ public void testSdcConfigurationBuilder() {
+
+ final SdcReceptionHandlerConfigurationParameterBuilder builder =
+ new SdcReceptionHandlerConfigurationParameterBuilder().setAsdcAddress("localhost")
+ .setConsumerGroup("policy-group").setConsumerId("policy-id").setEnvironmentName("TEST")
+ .setKeystorePassword("password").setKeystorePath("dummyPath").setPassword("policy")
+ .setPollingInterval(10).setPollingTimeout(20).setRetryDelay(30).setUser("policy")
+ .setUseHttpsWithDmaap(false).setActiveserverTlsAuth(false).setFilterinEmptyResources(true)
+ .setArtifactTypes(Arrays.asList("TOSCA_CSAR")).setMessageBusAddress(Arrays.asList("localhost"));
+ final SdcReceptionHandlerConfigurationParameterGroup configParameters =
+ new SdcReceptionHandlerConfigurationParameterGroup(builder);
+ configParameters.setName("SDCConfiguration");
+
+ assertEquals(Arrays.asList("localhost"), configParameters.getMessageBusAddress());
+ assertEquals(Arrays.asList("TOSCA_CSAR"), configParameters.getArtifactTypes());
+ assertEquals("localhost", configParameters.getAsdcAddress());
+ assertEquals("policy", configParameters.getUser());
+ assertEquals("policy", configParameters.getPassword());
+ assertEquals(10, configParameters.getPollingInterval());
+ assertEquals(20, configParameters.getPollingTimeout());
+ assertEquals(30, configParameters.getRetryDelay());
+ assertEquals("policy-id", configParameters.getConsumerId());
+ assertEquals("policy-group", configParameters.getConsumerGroup());
+ assertEquals("TEST", configParameters.getEnvironmentName());
+ assertEquals("dummyPath", configParameters.getKeyStorePath());
+ assertEquals("password", configParameters.getKeyStorePassword());
+ assertEquals(false, configParameters.isActiveServerTlsAuth());
+ assertEquals(true, configParameters.isFilterInEmptyResources());
+ assertEquals(false, configParameters.isUseHttpsWithDmaap());
+ }
+
+ @Test
+ public void testSdcConfigurationWithNullList() {
+
+ final SdcReceptionHandlerConfigurationParameterBuilder builder =
+ new SdcReceptionHandlerConfigurationParameterBuilder().setAsdcAddress("localhost")
+ .setConsumerGroup("policy-group").setConsumerId("policy-id").setEnvironmentName("TEST")
+ .setKeystorePassword("password").setKeystorePath("dummyPath").setPassword("policy")
+ .setPollingInterval(10).setPollingTimeout(20).setUser("policy").setUseHttpsWithDmaap(false)
+ .setActiveserverTlsAuth(false).setFilterinEmptyResources(true)
+ .setArtifactTypes(Arrays.asList("TOSCA_CSAR")).setMessageBusAddress(null);
+ final SdcReceptionHandlerConfigurationParameterGroup configParameters =
+ new SdcReceptionHandlerConfigurationParameterGroup(builder);
+ configParameters.setName("SDCConfiguration");
+
+ try {
+ configParameters.validate();
+ fail("Test must throw an exception");
+ } catch (final Exception exp) {
+ assertTrue(exp.getMessage().contains("collection parameter \"messageBusAddress\" is null"));
+ }
+ }
+
+ @Test
+ public void testSdcConfigurationWithEmptyStringList() {
+
+ final SdcReceptionHandlerConfigurationParameterBuilder builder =
+ new SdcReceptionHandlerConfigurationParameterBuilder().setAsdcAddress("localhost")
+ .setConsumerGroup("policy-group").setConsumerId("policy-id").setEnvironmentName("TEST")
+ .setKeystorePassword("password").setKeystorePath("dummyPath").setPassword("policy")
+ .setPollingInterval(10).setPollingTimeout(20).setUser("policy").setUseHttpsWithDmaap(false)
+ .setActiveserverTlsAuth(false).setFilterinEmptyResources(true)
+ .setArtifactTypes(Arrays.asList("")).setMessageBusAddress(Arrays.asList("localhost"));
+ final SdcReceptionHandlerConfigurationParameterGroup configParameters =
+ new SdcReceptionHandlerConfigurationParameterGroup(builder);
+ configParameters.setName("SDCConfiguration");
+
+ final GroupValidationResult validationResult = configParameters.validate();
+ assertFalse(validationResult.isValid());
+ assertTrue(validationResult.getResult().contains("must be a non-blank string"));
+ }
+}
diff --git a/artifactbroker/plugins/reception-plugins/src/test/java/org/onap/policy/distribution/reception/handling/sdc/exceptions/ArtifactDownloadExceptionTest.java b/artifactbroker/plugins/reception-plugins/src/test/java/org/onap/policy/distribution/reception/handling/sdc/exceptions/ArtifactDownloadExceptionTest.java
new file mode 100644
index 0000000..6d275f7
--- /dev/null
+++ b/artifactbroker/plugins/reception-plugins/src/test/java/org/onap/policy/distribution/reception/handling/sdc/exceptions/ArtifactDownloadExceptionTest.java
@@ -0,0 +1,36 @@
+/*-
+ * ============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.exceptions;
+
+import static org.junit.Assert.assertNotNull;
+
+import java.io.IOException;
+
+import org.junit.Test;
+
+public class ArtifactDownloadExceptionTest {
+
+ @Test
+ public void test() {
+ assertNotNull(new ArtifactDownloadException("Message"));
+ assertNotNull(new ArtifactDownloadException("Message", new IOException()));
+ }
+}
diff --git a/artifactbroker/plugins/reception-plugins/src/test/java/org/onap/policy/distribution/reception/handling/sdc/exceptions/ArtifactInstallerExceptionTest.java b/artifactbroker/plugins/reception-plugins/src/test/java/org/onap/policy/distribution/reception/handling/sdc/exceptions/ArtifactInstallerExceptionTest.java
new file mode 100644
index 0000000..6c524ff
--- /dev/null
+++ b/artifactbroker/plugins/reception-plugins/src/test/java/org/onap/policy/distribution/reception/handling/sdc/exceptions/ArtifactInstallerExceptionTest.java
@@ -0,0 +1,36 @@
+/*-
+ * ============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.exceptions;
+
+import static org.junit.Assert.assertNotNull;
+
+import java.io.IOException;
+
+import org.junit.Test;
+
+public class ArtifactInstallerExceptionTest {
+
+ @Test
+ public void test() {
+ assertNotNull(new ArtifactInstallerException("Message"));
+ assertNotNull(new ArtifactInstallerException("Message", new IOException()));
+ }
+}
diff --git a/artifactbroker/plugins/reception-plugins/src/test/java/org/onap/policy/distribution/reception/handling/sdc/exceptions/PssdControllerExceptionTest.java b/artifactbroker/plugins/reception-plugins/src/test/java/org/onap/policy/distribution/reception/handling/sdc/exceptions/PssdControllerExceptionTest.java
new file mode 100644
index 0000000..5f8e507
--- /dev/null
+++ b/artifactbroker/plugins/reception-plugins/src/test/java/org/onap/policy/distribution/reception/handling/sdc/exceptions/PssdControllerExceptionTest.java
@@ -0,0 +1,36 @@
+/*-
+ * ============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.exceptions;
+
+import static org.junit.Assert.assertNotNull;
+
+import java.io.IOException;
+
+import org.junit.Test;
+
+public class PssdControllerExceptionTest {
+
+ @Test
+ public void test() {
+ assertNotNull(new PssdControllerException("Message"));
+ assertNotNull(new PssdControllerException("Message", new IOException()));
+ }
+}
diff --git a/artifactbroker/plugins/reception-plugins/src/test/java/org/onap/policy/distribution/reception/handling/sdc/exceptions/PssdParametersExceptionTest.java b/artifactbroker/plugins/reception-plugins/src/test/java/org/onap/policy/distribution/reception/handling/sdc/exceptions/PssdParametersExceptionTest.java
new file mode 100644
index 0000000..7a1f551
--- /dev/null
+++ b/artifactbroker/plugins/reception-plugins/src/test/java/org/onap/policy/distribution/reception/handling/sdc/exceptions/PssdParametersExceptionTest.java
@@ -0,0 +1,36 @@
+/*-
+ * ============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.exceptions;
+
+import static org.junit.Assert.assertNotNull;
+
+import java.io.IOException;
+
+import org.junit.Test;
+
+public class PssdParametersExceptionTest {
+
+ @Test
+ public void test() {
+ assertNotNull(new PssdParametersException("Message"));
+ assertNotNull(new PssdParametersException("Message", new IOException()));
+ }
+}
diff --git a/artifactbroker/plugins/reception-plugins/src/test/resources/handling-sdc.json b/artifactbroker/plugins/reception-plugins/src/test/resources/handling-sdc.json
new file mode 100644
index 0000000..0bb936b
--- /dev/null
+++ b/artifactbroker/plugins/reception-plugins/src/test/resources/handling-sdc.json
@@ -0,0 +1,27 @@
+{
+ "name" : "parameterConfig1",
+ "asdcAddress": "localhost",
+ "messageBusAddress": [
+ "a.com",
+ "b.com",
+ "c.com"
+ ],
+ "user": "policy",
+ "password": "policy",
+ "pollingInterval":20,
+ "pollingTimeout":30,
+ "retryDelay":30,
+ "consumerId": "policy-id",
+ "artifactTypes": [
+ "TOSCA_CSAR",
+ "HEAT"
+ ],
+ "consumerGroup": "policy-group",
+ "environmentName": "TEST",
+ "keyStorePath": "null",
+ "keyStorePassword": "null",
+ "activeServerTlsAuth": false,
+ "isFilterInEmptyResources": true,
+ "isUseHttpsWithDmaap": false
+}
+
diff --git a/artifactbroker/plugins/reception-plugins/src/test/resources/handling-sdcInvalid.json b/artifactbroker/plugins/reception-plugins/src/test/resources/handling-sdcInvalid.json
new file mode 100644
index 0000000..803fc41
--- /dev/null
+++ b/artifactbroker/plugins/reception-plugins/src/test/resources/handling-sdcInvalid.json
@@ -0,0 +1,26 @@
+{
+ "name" : "parameterConfig1",
+ "asdcAddress": "",
+ "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
+}
+
diff --git a/artifactbroker/pom.xml b/artifactbroker/pom.xml
index 201a780..e28b656 100644
--- a/artifactbroker/pom.xml
+++ b/artifactbroker/pom.xml
@@ -22,7 +22,6 @@
<relativePath />
</parent>
<modelVersion>4.0.0</modelVersion>
- <groupId>org.onap.multicloud.framework.broker</groupId>
<artifactId>multicloud-framework-artifactbroker</artifactId>
<version>1.3.0-SNAPSHOT</version>
<packaging>pom</packaging>
@@ -39,7 +38,11 @@
</properties>
<modules>
+ <module>model</module>
<module>main</module>
+ <module>reception</module>
+ <module>forwarding</module>
+ <module>plugins</module>
<module>packages</module>
</modules>
<dependencies>
diff --git a/artifactbroker/reception/pom.xml b/artifactbroker/reception/pom.xml
new file mode 100644
index 0000000..b18838d
--- /dev/null
+++ b/artifactbroker/reception/pom.xml
@@ -0,0 +1,45 @@
+<!--
+ ============LICENSE_START=======================================================
+ Copyright (C) 2018 Ericsson. 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=========================================================
+-->
+<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
+ <modelVersion>4.0.0</modelVersion>
+ <parent>
+ <groupId>org.onap.multicloud.framework</groupId>
+ <artifactId>multicloud-framework-artifactbroker</artifactId>
+ <version>1.3.0-SNAPSHOT</version>
+ </parent>
+
+ <artifactId>multicloud-framework-artifactbroker-reception</artifactId>
+
+ <name>${project.artifactId}</name>
+ <description>The module of Policy Distribution that handles reception of policies from other systems.</description>
+
+ <dependencies>
+ <dependency>
+ <groupId>org.onap.multicloud.framework</groupId>
+ <artifactId>multicloud-framework-artifactbroker-model</artifactId>
+ <version>${project.version}</version>
+ </dependency>
+ <dependency>
+ <groupId>org.onap.multicloud.framework</groupId>
+ <artifactId>multicloud-framework-artifactbroker-forwarding</artifactId>
+ <version>${project.version}</version>
+ </dependency>
+ </dependencies>
+</project>
diff --git a/artifactbroker/reception/src/main/java/org/onap/policy/distribution/reception/decoding/PluginInitializationException.java b/artifactbroker/reception/src/main/java/org/onap/policy/distribution/reception/decoding/PluginInitializationException.java
new file mode 100644
index 0000000..4dd36a7
--- /dev/null
+++ b/artifactbroker/reception/src/main/java/org/onap/policy/distribution/reception/decoding/PluginInitializationException.java
@@ -0,0 +1,51 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * Copyright (C) 2018 Ericsson. 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.decoding;
+
+/**
+ * This exception will be called if an error occurs while initializing distribution plugins.
+ *
+ * @author Ram Krishna Verma (ram.krishna.verma@ericsson.com)
+ */
+public class PluginInitializationException extends Exception {
+
+ private static final long serialVersionUID = 3809376274411309160L;
+
+ /**
+ * Construct an instance with the given message.
+ *
+ * @param message the error message
+ */
+ public PluginInitializationException(final String message) {
+ super(message);
+ }
+
+ /**
+ * Construct an instance with the given message and cause.
+ *
+ * @param message the error message
+ * @param cause the cause
+ */
+ public PluginInitializationException(final String message, final Throwable cause) {
+ super(message, cause);
+ }
+
+}
diff --git a/artifactbroker/reception/src/main/java/org/onap/policy/distribution/reception/decoding/PluginTerminationException.java b/artifactbroker/reception/src/main/java/org/onap/policy/distribution/reception/decoding/PluginTerminationException.java
new file mode 100644
index 0000000..be9f51c
--- /dev/null
+++ b/artifactbroker/reception/src/main/java/org/onap/policy/distribution/reception/decoding/PluginTerminationException.java
@@ -0,0 +1,51 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * Copyright (C) 2018 Ericsson. 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.decoding;
+
+/**
+ * This exception will be called if an error occurs while terminating distribution plugins.
+ *
+ * @author Ram Krishna Verma (ram.krishna.verma@ericsson.com)
+ */
+public class PluginTerminationException extends Exception {
+
+ private static final long serialVersionUID = 3809376274411309160L;
+
+ /**
+ * Construct an instance with the given message.
+ *
+ * @param message the error message
+ */
+ public PluginTerminationException(final String message) {
+ super(message);
+ }
+
+ /**
+ * Construct an instance with the given message and cause.
+ *
+ * @param message the error message
+ * @param cause the cause
+ */
+ public PluginTerminationException(final String message, final Throwable cause) {
+ super(message, cause);
+ }
+
+}
diff --git a/artifactbroker/reception/src/main/java/org/onap/policy/distribution/reception/decoding/PolicyDecodingException.java b/artifactbroker/reception/src/main/java/org/onap/policy/distribution/reception/decoding/PolicyDecodingException.java
new file mode 100644
index 0000000..5f2923d
--- /dev/null
+++ b/artifactbroker/reception/src/main/java/org/onap/policy/distribution/reception/decoding/PolicyDecodingException.java
@@ -0,0 +1,49 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * Copyright (C) 2018 Ericsson. 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.decoding;
+
+/**
+ * An error has occured while decoding a policy.
+ */
+public class PolicyDecodingException extends Exception {
+
+ private static final long serialVersionUID = 3809376274411309160L;
+
+ /**
+ * Construct an instance with the given message.
+ *
+ * @param message the error message
+ */
+ public PolicyDecodingException(String message) {
+ super(message);
+ }
+
+ /**
+ * Construct an instance with the given message and cause.
+ *
+ * @param message the error message
+ * @param cause the cause
+ */
+ public PolicyDecodingException(String message, Throwable cause) {
+ super(message, cause);
+ }
+
+}
diff --git a/artifactbroker/reception/src/main/java/org/onap/policy/distribution/reception/handling/AbstractReceptionHandler.java b/artifactbroker/reception/src/main/java/org/onap/policy/distribution/reception/handling/AbstractReceptionHandler.java
new file mode 100644
index 0000000..7081dc7
--- /dev/null
+++ b/artifactbroker/reception/src/main/java/org/onap/policy/distribution/reception/handling/AbstractReceptionHandler.java
@@ -0,0 +1,89 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * Copyright (C) 2018 Ericsson. 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;
+
+import java.util.ArrayList;
+import java.util.Collection;
+
+import org.onap.policy.common.logging.flexlogger.FlexLogger;
+import org.onap.policy.common.logging.flexlogger.Logger;
+import org.onap.policy.common.parameters.ParameterService;
+import org.onap.policy.distribution.forwarding.ArtifactForwarder;
+import org.onap.policy.distribution.forwarding.ArtifactForwardingException;
+import org.onap.policy.distribution.model.PolicyInput;
+import org.onap.policy.distribution.reception.decoding.PluginInitializationException;
+import org.onap.policy.distribution.reception.decoding.PolicyDecodingException;
+import org.onap.policy.distribution.reception.parameters.ReceptionHandlerParameters;
+
+import org.onap.sdc.api.notification.IArtifactInfo;
+/**
+ * Base implementation of {@link ReceptionHandler}. All reception handlers should extend this base class by implementing
+ * the {@link #initializeReception(String)} method to perform the specific initialization required to receive inputs and
+ * by invoking {@link #inputReceived(PolicyInput)} when the reception handler receives input.
+ */
+public abstract class AbstractReceptionHandler implements ReceptionHandler {
+
+ private static final Logger LOGGER = FlexLogger.getLogger(AbstractReceptionHandler.class);
+
+ private PluginHandler pluginHandler;
+
+ /**
+ * {@inheritDoc}.
+ */
+ @Override
+ public void initialize(final String parameterGroupName) throws PluginInitializationException {
+ final ReceptionHandlerParameters receptionHandlerParameters = ParameterService.get(parameterGroupName);
+ pluginHandler = new PluginHandler(receptionHandlerParameters.getPluginHandlerParameters().getName());
+ initializeReception(receptionHandlerParameters.getReceptionHandlerConfigurationName());
+ }
+
+ /**
+ * Sub classes must implement this method to perform the specific initialization required to receive inputs, for
+ * example setting up subscriptions.
+ *
+ * @param parameterGroupName the parameter group name
+ * @throws PluginInitializationException if initialization of reception handler fails
+ */
+ protected abstract void initializeReception(String parameterGroupName) throws PluginInitializationException;
+
+ /**
+ * Handle input that has been received. The given input shall be decoded using the s configured
+ * for this reception handler and forwarded using the {@link ArtifactForwarder}s configured for this reception
+ * handler.
+ *
+ * @param policyInput the input that has been received
+ * @throws PolicyDecodingException if an error occurs in decoding a policy from the received input
+ */
+ protected void inputReceived(final PolicyInput policyInput) throws PolicyDecodingException {
+
+ final Collection<IArtifactInfo> policies = new ArrayList<>();
+
+ for (final ArtifactForwarder policyForwarder : pluginHandler.getArtifactForwarders()) {
+ try {
+ policyForwarder.forward(policies);
+ } catch (final ArtifactForwardingException policyForwardingException) {
+ LOGGER.error("Error when forwarding policies to " + policyForwarder, policyForwardingException);
+ }
+ }
+ }
+
+
+}
diff --git a/artifactbroker/reception/src/main/java/org/onap/policy/distribution/reception/handling/PluginHandler.java b/artifactbroker/reception/src/main/java/org/onap/policy/distribution/reception/handling/PluginHandler.java
new file mode 100644
index 0000000..e7e77ba
--- /dev/null
+++ b/artifactbroker/reception/src/main/java/org/onap/policy/distribution/reception/handling/PluginHandler.java
@@ -0,0 +1,88 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * Copyright (C) 2018 Ericsson. 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;
+
+import java.util.ArrayList;
+import java.util.Collection;
+import java.util.Map;
+
+import org.onap.policy.common.logging.flexlogger.FlexLogger;
+import org.onap.policy.common.logging.flexlogger.Logger;
+import org.onap.policy.common.parameters.ParameterService;
+import org.onap.policy.distribution.forwarding.ArtifactForwarder;
+import org.onap.policy.distribution.forwarding.parameters.ArtifactForwarderParameters;
+import org.onap.policy.distribution.reception.decoding.PluginInitializationException;
+import org.onap.policy.distribution.reception.parameters.PluginHandlerParameters;
+
+/**
+ * Handles the plugins to policy distribution.
+ */
+public class PluginHandler {
+
+ private static final Logger LOGGER = FlexLogger.getLogger(PluginHandler.class);
+
+ private Collection<ArtifactForwarder> artifactForwarders;
+
+ /**
+ * Create an instance to instantiate plugins based on the given parameter group.
+ *
+ * @param parameterGroupName the name of the parameter group
+ * @throws PluginInitializationException exception if it occurs
+ */
+ public PluginHandler(final String parameterGroupName) throws PluginInitializationException {
+ final PluginHandlerParameters params = ParameterService.get(parameterGroupName);
+ initArtifactForwarders(params.getArtifactForwarders());
+ }
+
+ /**
+ * Get the policy forwarders.
+ *
+ * @return the policy forwarders
+ */
+ public Collection<ArtifactForwarder> getArtifactForwarders() {
+ return artifactForwarders;
+ }
+
+ /**
+ * Initialize policy forwarders.
+ *
+ * @param artifactForwarderParameters exception if it occurs
+ * @throws PluginInitializationException exception if it occurs
+ */
+ @SuppressWarnings("unchecked")
+ private void initArtifactForwarders(final Map<String, ArtifactForwarderParameters> artifactForwarderParameters)
+ throws PluginInitializationException {
+ artifactForwarders = new ArrayList<>();
+ for (final ArtifactForwarderParameters forwarderParameters : artifactForwarderParameters.values()) {
+ try {
+ final Class<ArtifactForwarder> artifactForwarderClass =
+ (Class<ArtifactForwarder>) Class.forName(forwarderParameters.getForwarderClassName());
+ final ArtifactForwarder artifactForwarder = artifactForwarderClass.newInstance();
+ artifactForwarder.configure(forwarderParameters.getForwarderConfigurationName());
+ artifactForwarders.add(artifactForwarder);
+ } catch (final ClassNotFoundException | InstantiationException | IllegalAccessException exp) {
+ LOGGER.error("exception occured while initializing forwarders", exp);
+ throw new PluginInitializationException(exp.getMessage(), exp.getCause());
+ }
+ }
+ }
+
+}
diff --git a/artifactbroker/reception/src/main/java/org/onap/policy/distribution/reception/handling/ReceptionHandler.java b/artifactbroker/reception/src/main/java/org/onap/policy/distribution/reception/handling/ReceptionHandler.java
new file mode 100644
index 0000000..3678c69
--- /dev/null
+++ b/artifactbroker/reception/src/main/java/org/onap/policy/distribution/reception/handling/ReceptionHandler.java
@@ -0,0 +1,46 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * Copyright (C) 2018 Ericsson. 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;
+
+import org.onap.policy.distribution.reception.decoding.PluginInitializationException;
+import org.onap.policy.distribution.reception.decoding.PluginTerminationException;
+
+/**
+ * Handles input into Policy Distribution which may be decoded into a Policy.
+ */
+public interface ReceptionHandler {
+
+ /**
+ * Initialize the reception handler with the given parameters.
+ *
+ * @param parameterGroupName the name of the parameter group containing the configuration for the reception handler
+ * @throws PluginInitializationException exception if it occurs
+ */
+ void initialize(String parameterGroupName) throws PluginInitializationException;
+
+ /**
+ * Destroy the reception handler, removing any subscriptions and releasing all resources.
+ *
+ * @throws PluginTerminationException if it occurs
+ */
+ void destroy() throws PluginTerminationException;
+
+}
diff --git a/artifactbroker/reception/src/main/java/org/onap/policy/distribution/reception/parameters/PluginHandlerParameters.java b/artifactbroker/reception/src/main/java/org/onap/policy/distribution/reception/parameters/PluginHandlerParameters.java
new file mode 100644
index 0000000..70ab18e
--- /dev/null
+++ b/artifactbroker/reception/src/main/java/org/onap/policy/distribution/reception/parameters/PluginHandlerParameters.java
@@ -0,0 +1,94 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * Copyright (C) 2018 Ericsson. 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.util.Map;
+import java.util.Map.Entry;
+
+import org.onap.policy.common.parameters.GroupValidationResult;
+import org.onap.policy.common.parameters.ParameterGroup;
+import org.onap.policy.common.parameters.ValidationStatus;
+import org.onap.policy.distribution.forwarding.parameters.ArtifactForwarderParameters;
+
+/**
+ * Class to hold all the plugin handler parameters.
+ *
+ * @author Ram Krishna Verma (ram.krishna.verma@ericsson.com)
+ */
+public class PluginHandlerParameters implements ParameterGroup {
+
+ private static final String PLUGIN_HANDLER = "_PluginHandler";
+
+ private String name;
+ private Map<String, ArtifactForwarderParameters> artifactForwarders;
+
+ /**
+ * Constructor for instantiating PluginHandlerParameters.
+ *
+ * @param artifactForwarders the map of policy forwarders
+ */
+ public PluginHandlerParameters(
+ final Map<String, ArtifactForwarderParameters> artifactForwarders) {
+ this.artifactForwarders = artifactForwarders;
+ }
+
+ /**
+ * Return the artifactForwarders of this PluginHandlerParameters instance.
+ *
+ * @return the artifactForwarders
+ */
+ public Map<String, ArtifactForwarderParameters> getArtifactForwarders() {
+ return artifactForwarders;
+ }
+
+ @Override
+ public String getName() {
+ return name + PLUGIN_HANDLER;
+ }
+
+ /**
+ * Validate the plugin handler parameters.
+ *
+ */
+ @Override
+ public GroupValidationResult validate() {
+ final GroupValidationResult validationResult = new GroupValidationResult(this);
+ if (artifactForwarders == null || artifactForwarders.size() == 0) {
+ validationResult.setResult("artifactForwarders", ValidationStatus.INVALID,
+ "must have at least one policy forwarder");
+ } else {
+ for (final Entry<String, ArtifactForwarderParameters> nestedGroupEntry : artifactForwarders.entrySet()) {
+ validationResult.setResult("artifactForwarders", nestedGroupEntry.getKey(),
+ nestedGroupEntry.getValue().validate());
+ }
+ }
+ return validationResult;
+ }
+
+ /**
+ * Set the name of this group.
+ *
+ * @param name the name to set.
+ */
+ public void setName(final String name) {
+ this.name = name;
+ }
+}
diff --git a/artifactbroker/reception/src/main/java/org/onap/policy/distribution/reception/parameters/ReceptionHandlerConfigurationParameterGroup.java b/artifactbroker/reception/src/main/java/org/onap/policy/distribution/reception/parameters/ReceptionHandlerConfigurationParameterGroup.java
new file mode 100644
index 0000000..3fa877d
--- /dev/null
+++ b/artifactbroker/reception/src/main/java/org/onap/policy/distribution/reception/parameters/ReceptionHandlerConfigurationParameterGroup.java
@@ -0,0 +1,44 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * Copyright (C) 2018 Ericsson. 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 org.onap.policy.common.parameters.ParameterGroup;
+import org.onap.policy.distribution.reception.handling.ReceptionHandler;
+
+/**
+ * Base class of all {@link ParameterGroup} classes for configuration parameters for
+ * {@link ReceptionHandler} classes.
+ */
+public abstract class ReceptionHandlerConfigurationParameterGroup implements ParameterGroup {
+
+ private String name;
+
+ @Override
+ public String getName() {
+ return name;
+ }
+
+ @Override
+ public void setName(final String name) {
+ this.name = name;
+ }
+
+}
diff --git a/artifactbroker/reception/src/main/java/org/onap/policy/distribution/reception/parameters/ReceptionHandlerConfigurationParametersJsonAdapter.java b/artifactbroker/reception/src/main/java/org/onap/policy/distribution/reception/parameters/ReceptionHandlerConfigurationParametersJsonAdapter.java
new file mode 100644
index 0000000..0890a2a
--- /dev/null
+++ b/artifactbroker/reception/src/main/java/org/onap/policy/distribution/reception/parameters/ReceptionHandlerConfigurationParametersJsonAdapter.java
@@ -0,0 +1,80 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * Copyright (C) 2018 Ericsson. 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 com.google.gson.JsonDeserializationContext;
+import com.google.gson.JsonDeserializer;
+import com.google.gson.JsonElement;
+import com.google.gson.JsonObject;
+import com.google.gson.JsonPrimitive;
+import java.lang.reflect.Type;
+import org.slf4j.ext.XLogger;
+import org.slf4j.ext.XLoggerFactory;
+
+/**
+ * This class deserialises reception handler parameters from JSON.
+ */
+public class ReceptionHandlerConfigurationParametersJsonAdapter
+ implements JsonDeserializer<ReceptionHandlerConfigurationParameterGroup> {
+ private static final XLogger LOGGER =
+ XLoggerFactory.getXLogger(ReceptionHandlerConfigurationParametersJsonAdapter.class);
+
+ private static final String PARAMETER_CLASS_NAME = "parameterClassName";
+ private static final String RECEPTION_HANDLER_PARAMETERS = "parameters";
+
+ @Override
+ public ReceptionHandlerConfigurationParameterGroup deserialize(final JsonElement json, final Type typeOfT,
+ final JsonDeserializationContext context) {
+ final JsonObject jsonObject = json.getAsJsonObject();
+
+ final String receptionHandlerParameterClassName = getParameterGroupClassName(jsonObject);
+ Class<?> receptionHandlerParameterClass = getParameterGroupClass(receptionHandlerParameterClassName);
+
+ return context.deserialize(jsonObject.get(RECEPTION_HANDLER_PARAMETERS), receptionHandlerParameterClass);
+ }
+
+ private String getParameterGroupClassName(final JsonObject jsonObject) {
+ final JsonPrimitive classNameJsonPrimitive = ((JsonPrimitive) jsonObject.get(PARAMETER_CLASS_NAME));
+
+ if (classNameJsonPrimitive == null || classNameJsonPrimitive.getAsString().length() == 0) {
+ final String errorMessage = "parameter \"" + PARAMETER_CLASS_NAME + "\" value \""
+ + (classNameJsonPrimitive != null ? classNameJsonPrimitive.getAsString() : "null")
+ + "\" invalid in JSON file";
+ LOGGER.warn(errorMessage);
+ throw new IllegalArgumentException(errorMessage);
+ }
+ return classNameJsonPrimitive.getAsString().replaceAll("\\s+", "");
+ }
+
+ private Class<?> getParameterGroupClass(final String receptionHAndlerParameterClassName) {
+ Class<?> receptionHandlerParameterClass = null;
+ try {
+ receptionHandlerParameterClass = Class.forName(receptionHAndlerParameterClassName);
+ } catch (final ClassNotFoundException e) {
+ final String errorMessage = "parameter \"" + PARAMETER_CLASS_NAME + "\" value \""
+ + receptionHAndlerParameterClassName + "\", could not find class";
+ LOGGER.warn(errorMessage, e);
+ throw new IllegalArgumentException(errorMessage, e);
+ }
+ return receptionHandlerParameterClass;
+ }
+
+}
diff --git a/artifactbroker/reception/src/main/java/org/onap/policy/distribution/reception/parameters/ReceptionHandlerParameters.java b/artifactbroker/reception/src/main/java/org/onap/policy/distribution/reception/parameters/ReceptionHandlerParameters.java
new file mode 100644
index 0000000..3839c44
--- /dev/null
+++ b/artifactbroker/reception/src/main/java/org/onap/policy/distribution/reception/parameters/ReceptionHandlerParameters.java
@@ -0,0 +1,147 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * Copyright (C) 2018 Ericsson. 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 org.onap.policy.common.logging.flexlogger.FlexLogger;
+import org.onap.policy.common.logging.flexlogger.Logger;
+import org.onap.policy.common.parameters.GroupValidationResult;
+import org.onap.policy.common.parameters.ParameterGroup;
+import org.onap.policy.common.parameters.ValidationStatus;
+
+/**
+ * Class to hold all the reception handler parameters.
+ *
+ * @author Ram Krishna Verma (ram.krishna.verma@ericsson.com)
+ */
+public class ReceptionHandlerParameters implements ParameterGroup {
+
+ private static final Logger LOGGER = FlexLogger.getLogger(ReceptionHandlerParameters.class);
+
+ private String name;
+ private String receptionHandlerType;
+ private String receptionHandlerClassName;
+ private String receptionHandlerConfigurationName;
+ private PluginHandlerParameters pluginHandlerParameters;
+
+ /**
+ * Constructor for instantiating ReceptionHandlerParameters.
+ *
+ * @param receptionHandlerType the reception handler type
+ * @param receptionHandlerClassName the reception handler class name
+ * @param receptionHandlerConfigurationName the name of the configuration for the reception
+ * handler
+ * @param pluginHandlerParameters the plugin handler parameters
+ */
+ public ReceptionHandlerParameters(final String receptionHandlerType, final String receptionHandlerClassName,
+ final String receptionHandlerConfigurationName, final PluginHandlerParameters pluginHandlerParameters) {
+ this.receptionHandlerType = receptionHandlerType;
+ this.receptionHandlerClassName = receptionHandlerClassName;
+ this.receptionHandlerConfigurationName = receptionHandlerConfigurationName;
+ this.pluginHandlerParameters = pluginHandlerParameters;
+ }
+
+ /**
+ * Return the receptionHandlerType of this ReceptionHandlerParameters instance.
+ *
+ * @return the receptionHandlerType
+ */
+ public String getReceptionHandlerType() {
+ return receptionHandlerType;
+ }
+
+ /**
+ * Return the receptionHandlerClassName of this ReceptionHandlerParameters instance.
+ *
+ * @return the receptionHandlerClassName
+ */
+ public String getReceptionHandlerClassName() {
+ return receptionHandlerClassName;
+ }
+
+ /**
+ * Return the name of the reception handler configuration for this ReceptionHandlerParameters
+ * instance.
+ *
+ * @return the PssdConfigurationParametersGroup
+ */
+ public String getReceptionHandlerConfigurationName() {
+ return receptionHandlerConfigurationName;
+ }
+
+ /**
+ * Return the pluginHandlerParameters of this ReceptionHandlerParameters instance.
+ *
+ * @return the pluginHandlerParameters
+ */
+ public PluginHandlerParameters getPluginHandlerParameters() {
+ return pluginHandlerParameters;
+ }
+
+ @Override
+ public String getName() {
+ return name + "_" + receptionHandlerType;
+ }
+
+ /**
+ * Validate the reception handler parameters.
+ *
+ */
+ @Override
+ public GroupValidationResult validate() {
+ final GroupValidationResult validationResult = new GroupValidationResult(this);
+ if (receptionHandlerType == null || receptionHandlerType.trim().length() == 0) {
+ validationResult.setResult("receptionHandlerType", ValidationStatus.INVALID, "must be a non-blank string");
+ }
+ if (receptionHandlerClassName == null || receptionHandlerClassName.trim().length() == 0) {
+ validationResult.setResult("receptionHandlerClassName", ValidationStatus.INVALID,
+ "must be a non-blank string containing full class name of the reception handler");
+ } else {
+ validateReceptionHandlerClass(validationResult);
+ }
+ if (pluginHandlerParameters == null) {
+ validationResult.setResult("pluginHandlerParameters", ValidationStatus.INVALID,
+ "must have a plugin handler");
+ } else {
+ validationResult.setResult("pluginHandlerParameters", pluginHandlerParameters.validate());
+ }
+ return validationResult;
+ }
+
+ private void validateReceptionHandlerClass(final GroupValidationResult validationResult) {
+ try {
+ Class.forName(receptionHandlerClassName);
+ } catch (final ClassNotFoundException exp) {
+ LOGGER.error("reception handler class not found in classpath", exp);
+ validationResult.setResult("receptionHandlerClassName", ValidationStatus.INVALID,
+ "reception handler class not found in classpath");
+ }
+ }
+
+ /**
+ * Set the name of this group.
+ *
+ * @param name the name to set
+ */
+ @Override
+ public void setName(final String name) {
+ this.name = name;
+ }
+}
diff --git a/artifactbroker/reception/src/main/java/org/onap/policy/distribution/reception/statistics/DistributionStatisticsManager.java b/artifactbroker/reception/src/main/java/org/onap/policy/distribution/reception/statistics/DistributionStatisticsManager.java
new file mode 100644
index 0000000..3b66ee1
--- /dev/null
+++ b/artifactbroker/reception/src/main/java/org/onap/policy/distribution/reception/statistics/DistributionStatisticsManager.java
@@ -0,0 +1,160 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * Copyright (C) 2018 Ericsson. 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.statistics;
+
+/**
+ * Class to hold statistical data for distribution component.
+ *
+ * @author Ram Krishna Verma (ram.krishna.verma@ericsson.com)
+ */
+public class DistributionStatisticsManager {
+
+ private static long totalDistributionCount;
+ private static long distributionSuccessCount;
+ private static long distributionFailureCount;
+ private static long totalDownloadCount;
+ private static long downloadSuccessCount;
+ private static long downloadFailureCount;
+
+ private DistributionStatisticsManager() {
+ throw new IllegalStateException("Instantiation of the class is not allowed");
+ }
+
+ /**
+ * Method to update the total distribution count.
+ *
+ * @return the updated value of totalDistributionCount
+ */
+ public static long updateTotalDistributionCount() {
+ return ++totalDistributionCount;
+ }
+
+ /**
+ * Method to update the distribution success count.
+ *
+ * @return the updated value of distributionSuccessCount
+ */
+ public static long updateDistributionSuccessCount() {
+ return ++distributionSuccessCount;
+ }
+
+ /**
+ * Method to update the distribution failure count.
+ *
+ * @return the updated value of distributionFailureCount
+ */
+ public static long updateDistributionFailureCount() {
+ return ++distributionFailureCount;
+ }
+
+ /**
+ * Method to update the total download count.
+ *
+ * @return the updated value of totalDownloadCount
+ */
+ public static long updateTotalDownloadCount() {
+ return ++totalDownloadCount;
+ }
+
+ /**
+ * Method to update the download success count.
+ *
+ * @return the updated value of downloadSuccessCount
+ */
+ public static long updateDownloadSuccessCount() {
+ return ++downloadSuccessCount;
+ }
+
+ /**
+ * Method to update the download failure count.
+ *
+ * @return the updated value of downloadFailureCount
+ */
+ public static long updateDownloadFailureCount() {
+ return ++downloadFailureCount;
+ }
+
+ /**
+ * Returns the current value of totalDistributionCount.
+ *
+ * @return the totalDistributionCount
+ */
+ public static long getTotalDistributionCount() {
+ return totalDistributionCount;
+ }
+
+ /**
+ * Returns the current value of distributionSuccessCount.
+ *
+ * @return the distributionSuccessCount
+ */
+ public static long getDistributionSuccessCount() {
+ return distributionSuccessCount;
+ }
+
+ /**
+ * Returns the current value of distributionFailureCount.
+ *
+ * @return the distributionFailureCount
+ */
+ public static long getDistributionFailureCount() {
+ return distributionFailureCount;
+ }
+
+ /**
+ * Returns the current value of totalDownloadCount.
+ *
+ * @return the totalDownloadCount
+ */
+ public static long getTotalDownloadCount() {
+ return totalDownloadCount;
+ }
+
+ /**
+ * Returns the current value of downloadSuccessCount.
+ *
+ * @return the downloadSuccessCount
+ */
+ public static long getDownloadSuccessCount() {
+ return downloadSuccessCount;
+ }
+
+ /**
+ * Returns the current value of downloadFailureCount.
+ *
+ * @return the downloadFailureCount
+ */
+ public static long getDownloadFailureCount() {
+ return downloadFailureCount;
+ }
+
+ /**
+ * Reset all the statistics counts to 0.
+ */
+ public static void resetAllStatistics() {
+ totalDistributionCount = 0L;
+ distributionSuccessCount = 0L;
+ distributionFailureCount = 0L;
+ totalDownloadCount = 0L;
+ downloadSuccessCount = 0L;
+ downloadFailureCount = 0L;
+ }
+}
diff --git a/artifactbroker/reception/src/test/java/org/onap/policy/distribution/reception/decoding/PluginInitializationExceptionTest.java b/artifactbroker/reception/src/test/java/org/onap/policy/distribution/reception/decoding/PluginInitializationExceptionTest.java
new file mode 100644
index 0000000..b63e667
--- /dev/null
+++ b/artifactbroker/reception/src/test/java/org/onap/policy/distribution/reception/decoding/PluginInitializationExceptionTest.java
@@ -0,0 +1,50 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * Copyright (C) 2016-2018 Ericsson. 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.decoding;
+
+import static org.junit.Assert.assertEquals;
+
+import org.junit.Test;
+
+/**
+ * Class to perform unit test of {@link PluginInitializationException}.
+ *
+ * @author Ram Krishna Verma (ram.krishna.verma@ericsson.com)
+ */
+public class PluginInitializationExceptionTest {
+
+ @Test
+ public void testPluginInitializationExceptionString() {
+ final PluginInitializationException pluginInitializationException =
+ new PluginInitializationException("error message");
+ assertEquals("error message", pluginInitializationException.getMessage());
+ }
+
+ @Test
+ public void testPluginInitializationExceptionStringThrowable() {
+ final Exception cause = new IllegalArgumentException();
+ final PluginInitializationException pluginInitializationException =
+ new PluginInitializationException("error message", cause);
+ assertEquals("error message", pluginInitializationException.getMessage());
+ assertEquals(cause, pluginInitializationException.getCause());
+ }
+
+}
diff --git a/artifactbroker/reception/src/test/java/org/onap/policy/distribution/reception/decoding/PluginTerminationExceptionTest.java b/artifactbroker/reception/src/test/java/org/onap/policy/distribution/reception/decoding/PluginTerminationExceptionTest.java
new file mode 100644
index 0000000..c2fc6a9
--- /dev/null
+++ b/artifactbroker/reception/src/test/java/org/onap/policy/distribution/reception/decoding/PluginTerminationExceptionTest.java
@@ -0,0 +1,49 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * Copyright (C) 2016-2018 Ericsson. 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.decoding;
+
+import static org.junit.Assert.assertEquals;
+
+import org.junit.Test;
+
+/**
+ * Class to perform unit test of {@link PluginTerminationException}.
+ *
+ * @author Ram Krishna Verma (ram.krishna.verma@ericsson.com)
+ */
+public class PluginTerminationExceptionTest {
+
+ @Test
+ public void testPluginTerminationExceptionString() {
+ final PluginTerminationException pluginTerminationException = new PluginTerminationException("error message");
+ assertEquals("error message", pluginTerminationException.getMessage());
+ }
+
+ @Test
+ public void testPluginTerminationExceptionStringThrowable() {
+ final Exception cause = new IllegalArgumentException();
+ final PluginTerminationException pluginTerminationException = new PluginTerminationException("error message",
+ cause);
+ assertEquals("error message", pluginTerminationException.getMessage());
+ assertEquals(cause, pluginTerminationException.getCause());
+ }
+
+}
diff --git a/artifactbroker/reception/src/test/java/org/onap/policy/distribution/reception/decoding/PolicyDecodingExceptionTest.java b/artifactbroker/reception/src/test/java/org/onap/policy/distribution/reception/decoding/PolicyDecodingExceptionTest.java
new file mode 100644
index 0000000..a5bc072
--- /dev/null
+++ b/artifactbroker/reception/src/test/java/org/onap/policy/distribution/reception/decoding/PolicyDecodingExceptionTest.java
@@ -0,0 +1,43 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * Copyright (C) 2016-2018 Ericsson. 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.decoding;
+
+import static org.junit.Assert.assertEquals;
+
+import org.junit.Test;
+
+public class PolicyDecodingExceptionTest {
+
+ @Test
+ public void testPolicyDecodingExceptionString() {
+ final PolicyDecodingException policyDecodingException = new PolicyDecodingException("error message");
+ assertEquals("error message", policyDecodingException.getMessage());
+ }
+
+ @Test
+ public void testPolicyDecodingExceptionStringThrowable() {
+ final Exception cause = new IllegalArgumentException();
+ final PolicyDecodingException policyDecodingException = new PolicyDecodingException("error message", cause);
+ assertEquals("error message", policyDecodingException.getMessage());
+ assertEquals(cause, policyDecodingException.getCause());
+ }
+
+}
diff --git a/artifactbroker/reception/src/test/java/org/onap/policy/distribution/reception/handling/DummyArtifactForwarder.java b/artifactbroker/reception/src/test/java/org/onap/policy/distribution/reception/handling/DummyArtifactForwarder.java
new file mode 100644
index 0000000..5785927
--- /dev/null
+++ b/artifactbroker/reception/src/test/java/org/onap/policy/distribution/reception/handling/DummyArtifactForwarder.java
@@ -0,0 +1,54 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * Copyright (C) 2018 Ericsson. 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;
+
+import java.util.ArrayList;
+import java.util.Collection;
+import org.onap.policy.distribution.forwarding.ArtifactForwarder;
+import org.onap.policy.distribution.forwarding.ArtifactForwardingException;
+import org.onap.sdc.api.notification.IArtifactInfo;
+
+/**
+ * Class to create a dummy forwarder for test cases in AbstractReceptionHandlerTest.
+ *
+ * @author Ram Krishna Verma (ram.krishna.verma@ericsson.com)
+ */
+public class DummyArtifactForwarder implements ArtifactForwarder {
+ private int numberOfPoliciesReceived = 0;
+ private Collection<IArtifactInfo> policiesReceived = new ArrayList<>();
+
+ @Override
+ public void forward(final Collection<IArtifactInfo> policies) throws ArtifactForwardingException {
+ numberOfPoliciesReceived += policies.size();
+ policiesReceived.addAll(policies);
+ }
+
+ public int getNumberOfPoliciesReceived() {
+ return numberOfPoliciesReceived;
+ }
+
+ public boolean receivedPolicy(final IArtifactInfo policy) {
+ return policiesReceived.contains(policy);
+ }
+
+ @Override
+ public void configure(String parameterGroupName) {}
+}
diff --git a/artifactbroker/reception/src/test/java/org/onap/policy/distribution/reception/handling/DummyReceptionHandler.java b/artifactbroker/reception/src/test/java/org/onap/policy/distribution/reception/handling/DummyReceptionHandler.java
new file mode 100644
index 0000000..43596ff
--- /dev/null
+++ b/artifactbroker/reception/src/test/java/org/onap/policy/distribution/reception/handling/DummyReceptionHandler.java
@@ -0,0 +1,35 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * Copyright (C) 2018 Ericsson. 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;
+
+/**
+ * Class to create a dummy reception handler for test cases in AbstractReceptionHandlerTest.
+ *
+ * @author Ram Krishna Verma (ram.krishna.verma@ericsson.com)
+ */
+class DummyReceptionHandler extends AbstractReceptionHandler {
+
+ @Override
+ protected void initializeReception(final String parameterGroupName) {}
+
+ @Override
+ public void destroy() {}
+}