From f0944b0dffa4904161cf40d5da13d5d2d34b0cbe Mon Sep 17 00:00:00 2001 From: liboNet Date: Wed, 27 Mar 2019 00:49:32 +0800 Subject: 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 --- ...eceptionHandlerConfigurationParameterGroup.java | 210 +++++++++++++++++++++ 1 file changed, 210 insertions(+) create mode 100644 artifactbroker/plugins/reception-plugins/src/main/java/org/onap/policy/distribution/reception/handling/sdc/SdcReceptionHandlerConfigurationParameterGroup.java (limited to 'artifactbroker/plugins/reception-plugins/src/main/java/org/onap/policy/distribution/reception/handling/sdc/SdcReceptionHandlerConfigurationParameterGroup.java') 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 messageBusAddress; + private String user; + private String password; + private int pollingInterval; + private int pollingTimeout; + private int retryDelay; + private String consumerId; + private List 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 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 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 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"); + } + } +} + -- cgit 1.2.3-korg