aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorramverma <ram.krishna.verma@ericsson.com>2018-09-09 14:24:10 +0100
committerramverma <ram.krishna.verma@ericsson.com>2018-09-09 21:30:40 +0100
commit0afa5b5791c0ac739b980cf53f77e11bc1d3a0da (patch)
tree1e8814f33d2ded011b47b36bc0d3a29f8f929b8e
parented51ed0f7f1f479e394634de9ffb0778de4ea307 (diff)
Fixing sonar bugs in distribution
Change-Id: I3ec5c73c54145b1ba9f637eaa95c843e25f46a10 Issue-ID: POLICY-1035 Signed-off-by: ramverma <ram.krishna.verma@ericsson.com>
-rw-r--r--plugins/forwarding-plugins/src/main/java/org/onap/policy/distribution/forwarding/xacml/pdp/XacmlPdpPolicyForwarderParameterGroup.java40
-rw-r--r--plugins/reception-plugins/src/main/java/org/onap/policy/distribution/reception/handling/sdc/SdcReceptionHandlerConfigurationParameterGroup.java199
-rw-r--r--reception/src/main/java/org/onap/policy/distribution/reception/handling/AbstractReceptionHandler.java24
-rw-r--r--reception/src/main/java/org/onap/policy/distribution/reception/handling/PluginHandler.java5
4 files changed, 133 insertions, 135 deletions
diff --git a/plugins/forwarding-plugins/src/main/java/org/onap/policy/distribution/forwarding/xacml/pdp/XacmlPdpPolicyForwarderParameterGroup.java b/plugins/forwarding-plugins/src/main/java/org/onap/policy/distribution/forwarding/xacml/pdp/XacmlPdpPolicyForwarderParameterGroup.java
index 0a789904..b4c50ff3 100644
--- a/plugins/forwarding-plugins/src/main/java/org/onap/policy/distribution/forwarding/xacml/pdp/XacmlPdpPolicyForwarderParameterGroup.java
+++ b/plugins/forwarding-plugins/src/main/java/org/onap/policy/distribution/forwarding/xacml/pdp/XacmlPdpPolicyForwarderParameterGroup.java
@@ -5,15 +5,15 @@
* 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=========================================================
*/
@@ -26,7 +26,7 @@ import org.onap.policy.common.utils.validation.ParameterValidationUtils;
import org.onap.policy.distribution.main.parameters.PolicyForwarderConfigurationParameterGroup;
/**
- * Holds the parameters for the{@link XacmlPdpPolicyForwarder}
+ * Holds the parameters for the{@link XacmlPdpPolicyForwarder}.
*/
public class XacmlPdpPolicyForwarderParameterGroup extends PolicyForwarderConfigurationParameterGroup {
public static final String POLICY_FORWARDER_PLUGIN_CLASS = XacmlPdpPolicyForwarder.class.getCanonicalName();
@@ -40,6 +40,22 @@ public class XacmlPdpPolicyForwarderParameterGroup extends PolicyForwarderConfig
private boolean isManaged;
private String pdpGroup;
+ /**
+ * Construct an instance.
+ *
+ * @param builder the builder create the instance from
+ */
+ private XacmlPdpPolicyForwarderParameterGroup(final XacmlPdpPolicyForwarderParameterGroupBuilder builder) {
+ this.useHttps = builder.useHttps;
+ this.hostname = builder.hostname;
+ this.port = builder.port;
+ this.userName = builder.userName;
+ this.password = builder.password;
+ this.clientAuth = builder.clientAuth;
+ this.isManaged = builder.isManaged;
+ this.pdpGroup = builder.pdpGroup;
+ }
+
public boolean isUseHttps() {
return useHttps;
}
@@ -133,22 +149,6 @@ public class XacmlPdpPolicyForwarderParameterGroup extends PolicyForwarderConfig
}
}
- /**
- * Construct an instance
- *
- * @param builder the builder create the instance from
- */
- private XacmlPdpPolicyForwarderParameterGroup(final XacmlPdpPolicyForwarderParameterGroupBuilder builder) {
- this.useHttps = builder.useHttps;
- this.hostname = builder.hostname;
- this.port = builder.port;
- this.userName = builder.userName;
- this.password = builder.password;
- this.clientAuth = builder.clientAuth;
- this.isManaged = builder.isManaged;
- this.pdpGroup = builder.pdpGroup;
- }
-
@Override
public GroupValidationResult validate() {
final GroupValidationResult validationResult = new GroupValidationResult(this);
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 ce925bb7..08fd707c 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
@@ -22,15 +22,15 @@ package org.onap.policy.distribution.reception.handling.sdc;
import java.util.List;
import java.util.UUID;
+
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.
+ * 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 {
@@ -52,6 +52,100 @@ public class SdcReceptionHandlerConfigurationParameterGroup extends ReceptionHan
private boolean isUseHttpsWithDmaap;
/**
+ * The constructor for instantiating {@link SdcReceptionHandlerConfigurationParameterGroup} class.
+ *
+ * @param builder the SDC configuration builder
+ */
+ private SdcReceptionHandlerConfigurationParameterGroup(final SdcConfigurationBuilder builder) {
+ asdcAddress = builder.asdcAddress;
+ messageBusAddress = builder.messageBusAddress;
+ user = builder.user;
+ password = builder.password;
+ pollingInterval = builder.pollingInterval;
+ pollingTimeout = builder.pollingTimeout;
+ consumerId = builder.consumerId;
+ artifactTypes = builder.artifactTypes;
+ consumerGroup = builder.consumerGroup;
+ environmentName = builder.environmentName;
+ keyStorePath = builder.keystorePath;
+ keyStorePassword = builder.keystorePassword;
+ activeServerTlsAuth = builder.activeserverTlsAuth;
+ isFilterInEmptyResources = builder.isFilterinEmptyResources;
+ isUseHttpsWithDmaap = builder.isUseHttpsWithDmaap;
+
+ }
+
+ 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 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;
+ }
+
+ /**
+ * Set the name of this group.
+ *
+ * @param name the name to set.
+ */
+ @Override
+ public void setName(final String name) {
+ super.setName(name + "_" + UUID.randomUUID().toString());
+ }
+
+ /**
* Inner static class is to used as a Builder.
*
*/
@@ -148,7 +242,7 @@ public class SdcReceptionHandlerConfigurationParameterGroup extends ReceptionHan
}
/**
- * Creates a new PssdConfigurationParametersGroup instance.
+ * Creates an instance of {@link SdcReceptionHandlerConfigurationParameterGroup}.
*/
public SdcReceptionHandlerConfigurationParameterGroup build() {
return new SdcReceptionHandlerConfigurationParameterGroup(this);
@@ -156,91 +250,6 @@ public class SdcReceptionHandlerConfigurationParameterGroup extends ReceptionHan
}
/**
- * The constructor for instantiating PssdConfigurationParametersGroup. It is kept private so
- * that it could only be called by PssdConfigurationBuilder.
- *
- * @param builder stores all the values used by PssdConfigurationParametersGroup
- */
- private SdcReceptionHandlerConfigurationParameterGroup(final SdcConfigurationBuilder builder) {
- asdcAddress = builder.asdcAddress;
- messageBusAddress = builder.messageBusAddress;
- user = builder.user;
- password = builder.password;
- pollingInterval = builder.pollingInterval;
- pollingTimeout = builder.pollingTimeout;
- consumerId = builder.consumerId;
- artifactTypes = builder.artifactTypes;
- consumerGroup = builder.consumerGroup;
- environmentName = builder.environmentName;
- keyStorePath = builder.keystorePath;
- keyStorePassword = builder.keystorePassword;
- activeServerTlsAuth = builder.activeserverTlsAuth;
- isFilterInEmptyResources = builder.isFilterinEmptyResources;
- isUseHttpsWithDmaap = builder.isUseHttpsWithDmaap;
-
- }
-
- 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 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
@@ -250,16 +259,6 @@ public class SdcReceptionHandlerConfigurationParameterGroup extends ReceptionHan
}
/**
- * Set the name of this group.
- *
- * @param name the name to set.
- */
- @Override
- public void setName(final String name) {
- super.setName(name + "_" + UUID.randomUUID().toString());
- }
-
- /**
* {@inheritDoc}
*/
@Override
@@ -324,7 +323,7 @@ public class SdcReceptionHandlerConfigurationParameterGroup extends ReceptionHan
*/
private void validateStringElement(final GroupValidationResult validationResult, final String element,
final String elementName) {
- if (!ParameterValidationUtils.validateStringParameter(asdcAddress)) {
+ if (!ParameterValidationUtils.validateStringParameter(element)) {
validationResult.setResult(elementName, ValidationStatus.INVALID,
elementName + " must be a non-blank string");
}
diff --git a/reception/src/main/java/org/onap/policy/distribution/reception/handling/AbstractReceptionHandler.java b/reception/src/main/java/org/onap/policy/distribution/reception/handling/AbstractReceptionHandler.java
index 300dae8f..8782f795 100644
--- a/reception/src/main/java/org/onap/policy/distribution/reception/handling/AbstractReceptionHandler.java
+++ b/reception/src/main/java/org/onap/policy/distribution/reception/handling/AbstractReceptionHandler.java
@@ -22,6 +22,7 @@ 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;
@@ -35,10 +36,9 @@ import org.onap.policy.distribution.reception.decoding.PolicyDecodingException;
import org.onap.policy.distribution.reception.parameters.ReceptionHandlerParameters;
/**
- * 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.
+ * 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 {
@@ -51,15 +51,14 @@ public abstract class AbstractReceptionHandler implements ReceptionHandler {
*/
@Override
public void initialize(final String parameterGroupName) throws PluginInitializationException {
- final ReceptionHandlerParameters receptionHandlerParameters =
- (ReceptionHandlerParameters) ParameterService.get(parameterGroupName);
+ 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.
+ * 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
@@ -67,13 +66,12 @@ public abstract class AbstractReceptionHandler implements ReceptionHandler {
protected abstract void initializeReception(String parameterGroupName) throws PluginInitializationException;
/**
- * Handle input that has been received. The given input shall be decoded using the
- * {@link PolicyDecoder}s configured for this reception handler and forwarded using the
- * {@link PolicyForwarder}s configured for this reception handler.
+ * Handle input that has been received. The given input shall be decoded using the {@link PolicyDecoder}s configured
+ * for this reception handler and forwarded using the {@link PolicyForwarder}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
+ * @throws PolicyDecodingException if an error occurs in decoding a policy from the received input
*/
protected void inputReceived(final PolicyInput policyInput) throws PolicyDecodingException {
diff --git a/reception/src/main/java/org/onap/policy/distribution/reception/handling/PluginHandler.java b/reception/src/main/java/org/onap/policy/distribution/reception/handling/PluginHandler.java
index 4f3f41e3..e6bfefea 100644
--- a/reception/src/main/java/org/onap/policy/distribution/reception/handling/PluginHandler.java
+++ b/reception/src/main/java/org/onap/policy/distribution/reception/handling/PluginHandler.java
@@ -23,6 +23,7 @@ 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;
@@ -52,7 +53,7 @@ public class PluginHandler {
* @throws PluginInitializationException exception if it occurs
*/
public PluginHandler(final String parameterGroupName) throws PluginInitializationException {
- final PluginHandlerParameters params = (PluginHandlerParameters) ParameterService.get(parameterGroupName);
+ final PluginHandlerParameters params = ParameterService.get(parameterGroupName);
initializePolicyDecoders(params.getPolicyDecoders());
initializePolicyForwarders(params.getPolicyForwarders());
}
@@ -113,7 +114,7 @@ public class PluginHandler {
try {
final Class<PolicyForwarder> policyForwarderClass =
(Class<PolicyForwarder>) Class.forName(forwarderParameters.getForwarderClassName());
- PolicyForwarder policyForwarder = policyForwarderClass.newInstance();
+ final PolicyForwarder policyForwarder = policyForwarderClass.newInstance();
policyForwarder.configure(forwarderParameters.getForwarderConfigurationName());
policyForwarders.add(policyForwarder);
} catch (final ClassNotFoundException | InstantiationException | IllegalAccessException exp) {