From c04dd4a6984734869ef6888f95d304d3d53c1923 Mon Sep 17 00:00:00 2001 From: ramverma Date: Tue, 6 Aug 2019 14:14:01 +0000 Subject: Changing parameters to use ParameterGroupImpl 1. Changing all the decoders & handlers parameters to use ParameterGroupImpl. 2. Fixed all the test cases. Issue-ID: POLICY-1890 Change-Id: I4a124c0acc650020977ac8e2cee143c72003973a Signed-off-by: ramverma --- ...coderCsarPdpxConfigurationParameterBuilder.java | 94 ------ ...DecoderCsarPdpxConfigurationParameterGroup.java | 85 +---- ...icyDecoderFileInCsarToPolicyParameterGroup.java | 40 +-- .../handling/file/FileSystemReceptionHandler.java | 15 +- ...eptionHandlerConfigurationParameterBuilder.java | 71 ---- ...eceptionHandlerConfigurationParameterGroup.java | 35 +- ...eptionHandlerConfigurationParameterBuilder.java | 357 --------------------- ...eceptionHandlerConfigurationParameterGroup.java | 168 +--------- 8 files changed, 51 insertions(+), 814 deletions(-) delete mode 100644 plugins/reception-plugins/src/main/java/org/onap/policy/distribution/reception/decoding/pdpx/PolicyDecoderCsarPdpxConfigurationParameterBuilder.java delete mode 100644 plugins/reception-plugins/src/main/java/org/onap/policy/distribution/reception/handling/file/FileSystemReceptionHandlerConfigurationParameterBuilder.java delete mode 100644 plugins/reception-plugins/src/main/java/org/onap/policy/distribution/reception/handling/sdc/SdcReceptionHandlerConfigurationParameterBuilder.java (limited to 'plugins/reception-plugins/src/main/java/org/onap') diff --git a/plugins/reception-plugins/src/main/java/org/onap/policy/distribution/reception/decoding/pdpx/PolicyDecoderCsarPdpxConfigurationParameterBuilder.java b/plugins/reception-plugins/src/main/java/org/onap/policy/distribution/reception/decoding/pdpx/PolicyDecoderCsarPdpxConfigurationParameterBuilder.java deleted file mode 100644 index 4c781030..00000000 --- a/plugins/reception-plugins/src/main/java/org/onap/policy/distribution/reception/decoding/pdpx/PolicyDecoderCsarPdpxConfigurationParameterBuilder.java +++ /dev/null @@ -1,94 +0,0 @@ -/*- - * ============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.pdpx; - -/** - * This class builds an instance of {@link PolicyDecodeCsarPdpxConfigurationParameterGroup} class. - */ -public class PolicyDecoderCsarPdpxConfigurationParameterBuilder { - - private String policyNamePrefix; - private String onapName; - private String version; - private String priority; - private String riskType; - private String riskLevel; - - public String getPolicyNamePrefix() { - return policyNamePrefix; - } - - public PolicyDecoderCsarPdpxConfigurationParameterBuilder setPolicyNamePrefix(final String policyNamePrefix) { - this.policyNamePrefix = policyNamePrefix; - return this; - } - - public String getOnapName() { - return onapName; - } - - public PolicyDecoderCsarPdpxConfigurationParameterBuilder setOnapName(final String onapName) { - this.onapName = onapName; - return this; - } - - public String getVersion() { - return version; - } - - public PolicyDecoderCsarPdpxConfigurationParameterBuilder setVersion(final String version) { - this.version = version; - return this; - } - - public String getPriority() { - return priority; - } - - public PolicyDecoderCsarPdpxConfigurationParameterBuilder setPriority(final String priority) { - this.priority = priority; - return this; - } - - public String getRiskType() { - return riskType; - } - - public PolicyDecoderCsarPdpxConfigurationParameterBuilder setRiskType(final String riskType) { - this.riskType = riskType; - return this; - } - - public String getRiskLevel() { - return riskLevel; - } - - public PolicyDecoderCsarPdpxConfigurationParameterBuilder setRiskLevel(final String riskLevel) { - this.riskLevel = riskLevel; - return this; - } - - public PolicyDecoderCsarPdpxConfigurationParameterGroup build() { - return new PolicyDecoderCsarPdpxConfigurationParameterGroup(this); - } -} - - diff --git a/plugins/reception-plugins/src/main/java/org/onap/policy/distribution/reception/decoding/pdpx/PolicyDecoderCsarPdpxConfigurationParameterGroup.java b/plugins/reception-plugins/src/main/java/org/onap/policy/distribution/reception/decoding/pdpx/PolicyDecoderCsarPdpxConfigurationParameterGroup.java index 26fd2a5a..f376c391 100644 --- a/plugins/reception-plugins/src/main/java/org/onap/policy/distribution/reception/decoding/pdpx/PolicyDecoderCsarPdpxConfigurationParameterGroup.java +++ b/plugins/reception-plugins/src/main/java/org/onap/policy/distribution/reception/decoding/pdpx/PolicyDecoderCsarPdpxConfigurationParameterGroup.java @@ -1,6 +1,7 @@ /*- * ============LICENSE_START======================================================= * Copyright (C) 2018 Intel. All rights reserved. + * Modifications Copyright (C) 2019 Nordix Foundation. * ================================================================================ * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -20,16 +21,18 @@ package org.onap.policy.distribution.reception.decoding.pdpx; -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.handling.sdc.SdcReceptionHandlerConfigurationParameterGroup; +import lombok.Getter; + +import org.onap.policy.common.parameters.annotations.NotBlank; +import org.onap.policy.common.parameters.annotations.NotNull; import org.onap.policy.distribution.reception.parameters.PolicyDecoderConfigurationParameterGroup; /** - * This class handles reading, parsing and validating of the paramaters for the - * {@link PolicyDecoderCsarPdpx}. + * This class handles reading, parsing and validating of the paramaters for the {@link PolicyDecoderCsarPdpx}. */ +@Getter +@NotNull +@NotBlank public class PolicyDecoderCsarPdpxConfigurationParameterGroup extends PolicyDecoderConfigurationParameterGroup { private String policyNamePrefix; @@ -39,74 +42,8 @@ public class PolicyDecoderCsarPdpxConfigurationParameterGroup extends PolicyDeco private String riskType; private String riskLevel; - /** - * The constructor for instantiating {@link SdcReceptionHandlerConfigurationParameterGroup} - * class. - * - * @param builder the SDC configuration builder - */ - public PolicyDecoderCsarPdpxConfigurationParameterGroup( - final PolicyDecoderCsarPdpxConfigurationParameterBuilder builder) { - policyNamePrefix = builder.getPolicyNamePrefix(); - onapName = builder.getOnapName(); - version = builder.getVersion(); - priority = builder.getPriority(); - riskType = builder.getRiskType(); - riskLevel = builder.getRiskLevel(); - } - - public String getPolicyNamePrefix() { - return policyNamePrefix; - } - - public String getOnapName() { - return onapName; - } - - public String getVersion() { - return version; - } - - public String getPriority() { - return priority; - } - - public String getRiskType() { - return riskType; - } - - public String getRiskLevel() { - return riskLevel; - } - - /** - * {@inheritDoc}. - */ - @Override - public GroupValidationResult validate() { - final GroupValidationResult validationResult = new GroupValidationResult(this); - validateStringElement(validationResult, policyNamePrefix, "policyNamePrefix"); - validateStringElement(validationResult, onapName, "onapName"); - validateStringElement(validationResult, version, "version"); - validateStringElement(validationResult, priority, "priority"); - validateStringElement(validationResult, riskType, "riskType"); - validateStringElement(validationResult, riskLevel, "riskLevel"); - 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 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"); - } + public PolicyDecoderCsarPdpxConfigurationParameterGroup() { + super(PolicyDecoderCsarPdpxConfigurationParameterGroup.class.getSimpleName()); } } diff --git a/plugins/reception-plugins/src/main/java/org/onap/policy/distribution/reception/decoding/policy/file/PolicyDecoderFileInCsarToPolicyParameterGroup.java b/plugins/reception-plugins/src/main/java/org/onap/policy/distribution/reception/decoding/policy/file/PolicyDecoderFileInCsarToPolicyParameterGroup.java index 1df563c3..7aff5b4c 100644 --- a/plugins/reception-plugins/src/main/java/org/onap/policy/distribution/reception/decoding/policy/file/PolicyDecoderFileInCsarToPolicyParameterGroup.java +++ b/plugins/reception-plugins/src/main/java/org/onap/policy/distribution/reception/decoding/policy/file/PolicyDecoderFileInCsarToPolicyParameterGroup.java @@ -1,6 +1,7 @@ /*- * ============LICENSE_START======================================================= * Copyright (C) 2018 Ericsson. All rights reserved. + * Modifications Copyright (C) 2019 Nordix Foundation. * ================================================================================ * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -20,9 +21,10 @@ package org.onap.policy.distribution.reception.decoding.policy.file; -import org.onap.policy.common.parameters.GroupValidationResult; -import org.onap.policy.common.parameters.ValidationStatus; -import org.onap.policy.common.utils.validation.ParameterValidationUtils; +import lombok.Getter; + +import org.onap.policy.common.parameters.annotations.NotBlank; +import org.onap.policy.common.parameters.annotations.NotNull; import org.onap.policy.distribution.reception.parameters.PolicyDecoderConfigurationParameterGroup; /** @@ -30,37 +32,15 @@ import org.onap.policy.distribution.reception.parameters.PolicyDecoderConfigurat * * @author Ram Krishna Verma (ram.krishna.verma@ericsson.com) */ +@Getter +@NotNull +@NotBlank public class PolicyDecoderFileInCsarToPolicyParameterGroup extends PolicyDecoderConfigurationParameterGroup { private String policyFileName; private String policyTypeFileName; - /** - * Constructor for instantiating {@link PolicyDecoderFileInCsarToPolicyParameterGroup} class. - * - * @param policyFileName the policy file name - * @param policyTypeFileName the policy type file name - */ - public PolicyDecoderFileInCsarToPolicyParameterGroup(final String policyFileName, final String policyTypeFileName) { - this.policyFileName = policyFileName; - this.policyTypeFileName = policyTypeFileName; - } - - public String getPolicyFileName() { - return policyFileName; - } - - public String getPolicyTypeFileName() { - return policyTypeFileName; - } - - @Override - public GroupValidationResult validate() { - final GroupValidationResult validationResult = new GroupValidationResult(this); - if (!ParameterValidationUtils.validateStringParameter(policyFileName)) { - validationResult.setResult("policyFileName", ValidationStatus.INVALID, - "must be a non-blank string containing the policy file name"); - } - return validationResult; + public PolicyDecoderFileInCsarToPolicyParameterGroup() { + super(PolicyDecoderFileInCsarToPolicyParameterGroup.class.getSimpleName()); } } diff --git a/plugins/reception-plugins/src/main/java/org/onap/policy/distribution/reception/handling/file/FileSystemReceptionHandler.java b/plugins/reception-plugins/src/main/java/org/onap/policy/distribution/reception/handling/file/FileSystemReceptionHandler.java index 77269bb0..47312e62 100644 --- a/plugins/reception-plugins/src/main/java/org/onap/policy/distribution/reception/handling/file/FileSystemReceptionHandler.java +++ b/plugins/reception-plugins/src/main/java/org/onap/policy/distribution/reception/handling/file/FileSystemReceptionHandler.java @@ -62,9 +62,8 @@ public class FileSystemReceptionHandler extends AbstractReceptionHandler { try { final FileSystemReceptionHandlerConfigurationParameterGroup handlerParameters = ParameterService.get(parameterGroupName); - final FileClientHandler fileClientHandler = new FileClientHandler(this, - handlerParameters.getWatchPath(), - handlerParameters.getMaxThread()); + final FileClientHandler fileClientHandler = + new FileClientHandler(this, handlerParameters.getWatchPath(), handlerParameters.getMaxThread()); final Thread fileWatcherThread = new Thread(fileClientHandler); fileWatcherThread.start(); } catch (final Exception ex) { @@ -114,10 +113,10 @@ public class FileSystemReceptionHandler extends AbstractReceptionHandler { * @param maxThread the max thread number * @throws InterruptedException if it occurs */ - protected void startWatchService(final WatchService watcher, - final Path dir, int maxThread) throws InterruptedException { + protected void startWatchService(final WatchService watcher, final Path dir, final int maxThread) + throws InterruptedException { WatchKey key; - ExecutorService pool = Executors.newFixedThreadPool(maxThread); + final ExecutorService pool = Executors.newFixedThreadPool(maxThread); try { running = true; @@ -135,7 +134,7 @@ public class FileSystemReceptionHandler extends AbstractReceptionHandler { } } - private void processFileEvents(Path dir, WatchKey key, ExecutorService pool) { + private void processFileEvents(final Path dir, final WatchKey key, final ExecutorService pool) { for (final WatchEvent event : key.pollEvents()) { @SuppressWarnings("unchecked") final WatchEvent ev = (WatchEvent) event; @@ -148,7 +147,7 @@ public class FileSystemReceptionHandler extends AbstractReceptionHandler { waitForFileToBeReady(fullFilePath); createPolicyInputAndCallHandler(fullFilePath); LOGGER.debug("CSAR complete: {}", fileName); - } catch (InterruptedException e) { + } catch (final InterruptedException e) { LOGGER.error("waitForFileToBeReady interrupted", e); Thread.currentThread().interrupt(); } diff --git a/plugins/reception-plugins/src/main/java/org/onap/policy/distribution/reception/handling/file/FileSystemReceptionHandlerConfigurationParameterBuilder.java b/plugins/reception-plugins/src/main/java/org/onap/policy/distribution/reception/handling/file/FileSystemReceptionHandlerConfigurationParameterBuilder.java deleted file mode 100644 index 415e0d94..00000000 --- a/plugins/reception-plugins/src/main/java/org/onap/policy/distribution/reception/handling/file/FileSystemReceptionHandlerConfigurationParameterBuilder.java +++ /dev/null @@ -1,71 +0,0 @@ -/*- - * ============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.file; - -/** - * This class builds an instance of {@link FileSystemReceptionHandlerConfigurationParameterGroup} class. - * - */ -public class FileSystemReceptionHandlerConfigurationParameterBuilder { - - private String watchPath; - private int maxThread = 1; - - /** - * Set watchPath to this {@link FileSystemReceptionHandlerConfigurationParameterBuilder} instance. - * - * @param watchPath the watchPath - */ - public FileSystemReceptionHandlerConfigurationParameterBuilder setWatchPath(final String watchPath) { - this.watchPath = watchPath; - return this; - } - - /** - * Set maxThread to this {@link FileSystemReceptionHandlerConfigurationParameterBuilder} instance. - * - * @param maxThread the max thread number in the thread pool - */ - public FileSystemReceptionHandlerConfigurationParameterBuilder setMaxThread(final int maxThread) { - this.maxThread = maxThread; - return this; - } - - /** - * Returns the watchPath of this {@link FileSystemReceptionHandlerConfigurationParameterBuilder} instance. - * - * @return the watchPath - */ - public String getWatchPath() { - return watchPath; - } - - /** - * Returns the maxThread of this {@link FileSystemReceptionHandlerConfigurationParameterBuilder} instance. - * - * @return the maxThread - */ - public int getMaxThread() { - return maxThread; - } -} - - diff --git a/plugins/reception-plugins/src/main/java/org/onap/policy/distribution/reception/handling/file/FileSystemReceptionHandlerConfigurationParameterGroup.java b/plugins/reception-plugins/src/main/java/org/onap/policy/distribution/reception/handling/file/FileSystemReceptionHandlerConfigurationParameterGroup.java index f9045816..a12130ea 100644 --- a/plugins/reception-plugins/src/main/java/org/onap/policy/distribution/reception/handling/file/FileSystemReceptionHandlerConfigurationParameterGroup.java +++ b/plugins/reception-plugins/src/main/java/org/onap/policy/distribution/reception/handling/file/FileSystemReceptionHandlerConfigurationParameterGroup.java @@ -1,6 +1,7 @@ /*- * ============LICENSE_START======================================================= * Copyright (C) 2018 Intel. All rights reserved. + * Modifications Copyright (C) 2019 Nordix Foundation. * ================================================================================ * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -22,37 +23,30 @@ package org.onap.policy.distribution.reception.handling.file; import java.io.File; +import lombok.Getter; +import lombok.Setter; + 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.common.parameters.annotations.NotBlank; +import org.onap.policy.common.parameters.annotations.NotNull; 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. */ +@Getter +@Setter +@NotNull +@NotBlank public class FileSystemReceptionHandlerConfigurationParameterGroup extends ReceptionHandlerConfigurationParameterGroup { private String watchPath; private int maxThread; - /** - * The constructor for instantiating {@link FileSystemReceptionHandlerConfigurationParameterGroup} class. - * - * @param builder the SDC configuration builder - */ - public FileSystemReceptionHandlerConfigurationParameterGroup( - final FileSystemReceptionHandlerConfigurationParameterBuilder builder) { - watchPath = builder.getWatchPath(); - maxThread = builder.getMaxThread(); - } - - public String getWatchPath() { - return watchPath; - } - - public int getMaxThread() { - return maxThread; + public FileSystemReceptionHandlerConfigurationParameterGroup() { + super(FileSystemReceptionHandlerConfigurationParameterGroup.class.getSimpleName()); } /** @@ -62,9 +56,6 @@ public class FileSystemReceptionHandlerConfigurationParameterGroup extends Recep public GroupValidationResult validate() { final GroupValidationResult validationResult = new GroupValidationResult(this); validatePathElement(validationResult, watchPath, "watchPath"); - if (!ParameterValidationUtils.validateIntParameter(maxThread)) { - validationResult.setResult("maxThread", ValidationStatus.INVALID, "must be a positive integer"); - } return validationResult; } @@ -80,7 +71,7 @@ public class FileSystemReceptionHandlerConfigurationParameterGroup extends Recep final String elementName) { boolean valid = false; if (element != null) { - File file = new File(element); + final File file = new File(element); if (file.exists() && file.isDirectory()) { valid = true; } diff --git a/plugins/reception-plugins/src/main/java/org/onap/policy/distribution/reception/handling/sdc/SdcReceptionHandlerConfigurationParameterBuilder.java b/plugins/reception-plugins/src/main/java/org/onap/policy/distribution/reception/handling/sdc/SdcReceptionHandlerConfigurationParameterBuilder.java deleted file mode 100644 index 65305c1c..00000000 --- a/plugins/reception-plugins/src/main/java/org/onap/policy/distribution/reception/handling/sdc/SdcReceptionHandlerConfigurationParameterBuilder.java +++ /dev/null @@ -1,357 +0,0 @@ -/*- - * ============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 messageBusAddress; - private List 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 messageBusAddress) { - this.messageBusAddress = messageBusAddress; - return this; - } - - /** - * Set artifactTypes to this {@link SdcReceptionHandlerConfigurationParameterBuilder} instance. - * - * @param artifactTypes the artifactTypes - */ - public SdcReceptionHandlerConfigurationParameterBuilder setArtifactTypes(final List 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 getMessageBusAddress() { - return messageBusAddress; - } - - /** - * Returns the artifact types of this {@link SdcReceptionHandlerConfigurationParameterBuilder} instance. - * - * @return the artifactTypes - */ - public List getArtifactTypes() { - return artifactTypes; - } - - /** - * Returns the retryDelay of this {@link SdcReceptionHandlerConfigurationParameterBuilder} instance. - * - * @return the retryDelay - */ - public int getRetryDelay() { - return retryDelay; - } - -} - - diff --git a/plugins/reception-plugins/src/main/java/org/onap/policy/distribution/reception/handling/sdc/SdcReceptionHandlerConfigurationParameterGroup.java b/plugins/reception-plugins/src/main/java/org/onap/policy/distribution/reception/handling/sdc/SdcReceptionHandlerConfigurationParameterGroup.java index 6746dc35..f9aed90b 100644 --- a/plugins/reception-plugins/src/main/java/org/onap/policy/distribution/reception/handling/sdc/SdcReceptionHandlerConfigurationParameterGroup.java +++ b/plugins/reception-plugins/src/main/java/org/onap/policy/distribution/reception/handling/sdc/SdcReceptionHandlerConfigurationParameterGroup.java @@ -1,6 +1,7 @@ /*- * ============LICENSE_START======================================================= * Copyright (C) 2018 Intel. All rights reserved. + * Modifications Copyright (C) 2019 Nordix Foundation. * ================================================================================ * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -22,15 +23,19 @@ 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 lombok.Getter; + +import org.onap.policy.common.parameters.annotations.NotBlank; +import org.onap.policy.common.parameters.annotations.NotNull; 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. */ +@Getter +@NotNull +@NotBlank public class SdcReceptionHandlerConfigurationParameterGroup extends ReceptionHandlerConfigurationParameterGroup { private String asdcAddress; @@ -50,161 +55,8 @@ public class SdcReceptionHandlerConfigurationParameterGroup extends ReceptionHan 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"); - } + public SdcReceptionHandlerConfigurationParameterGroup() { + super(SdcReceptionHandlerConfigurationParameterGroup.class.getSimpleName()); } } -- cgit 1.2.3-korg