summaryrefslogtreecommitdiffstats
path: root/artifactbroker/reception/src/main
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 /artifactbroker/reception/src/main
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>
Diffstat (limited to 'artifactbroker/reception/src/main')
-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
11 files changed, 899 insertions, 0 deletions
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;
+ }
+}