summaryrefslogtreecommitdiffstats
path: root/feature-lifecycle/src/main
diff options
context:
space:
mode:
authorJim Hahn <jrh3@att.com>2021-08-26 14:36:35 -0400
committerJim Hahn <jrh3@att.com>2021-08-26 15:12:19 -0400
commitd04af420514c9c852af77780f0bd5ee23ebb401a (patch)
tree4212f3e411714770bd4bae3ecb25634190868b13 /feature-lifecycle/src/main
parent9869e3a9665c0215dc9f9724fe3b5576c0479157 (diff)
Fix sonars in drools-pdp
Fixed sonars: - use "var" - override "equals" - unused imports Also changed some of the JPA queries to make them typed queries. Issue-ID: POLICY-3289 Change-Id: Ib3a00be322d8d00ba492673708439cacfe2c7fc4 Signed-off-by: Jim Hahn <jrh3@att.com>
Diffstat (limited to 'feature-lifecycle/src/main')
-rw-r--r--feature-lifecycle/src/main/java/org/onap/policy/drools/lifecycle/LifecycleFsm.java9
-rw-r--r--feature-lifecycle/src/main/java/org/onap/policy/drools/lifecycle/LifecycleStateRunning.java5
-rw-r--r--feature-lifecycle/src/main/java/org/onap/policy/drools/lifecycle/PolicyTypeDroolsController.java2
-rw-r--r--feature-lifecycle/src/main/java/org/onap/policy/drools/lifecycle/PolicyTypeNativeArtifactController.java6
4 files changed, 11 insertions, 11 deletions
diff --git a/feature-lifecycle/src/main/java/org/onap/policy/drools/lifecycle/LifecycleFsm.java b/feature-lifecycle/src/main/java/org/onap/policy/drools/lifecycle/LifecycleFsm.java
index 8e97d3ef..e0ac880e 100644
--- a/feature-lifecycle/src/main/java/org/onap/policy/drools/lifecycle/LifecycleFsm.java
+++ b/feature-lifecycle/src/main/java/org/onap/policy/drools/lifecycle/LifecycleFsm.java
@@ -109,9 +109,6 @@ public class LifecycleFsm implements Startable {
@Getter
protected TopicSinkClient client;
- @Getter
- protected final String name = PolicyEngineConstants.PDP_NAME;
-
protected LifecycleState state = new LifecycleStateTerminated(this);
@GsonJsonIgnore
@@ -180,6 +177,10 @@ public class LifecycleFsm implements Startable {
stats.setPdpInstanceId(PolicyEngineConstants.PDP_NAME);
}
+ public String getName() {
+ return PolicyEngineConstants.PDP_NAME;
+ }
+
@GsonJsonIgnore
public DomainMaker getDomainMaker() {
return PolicyEngineConstants.getManager().getDomainMaker();
@@ -625,7 +626,7 @@ public class LifecycleFsm implements Startable {
protected PdpStatus statusPayload(@NonNull PdpState state) {
var status = new PdpStatus();
- status.setName(name);
+ status.setName(getName());
status.setPdpGroup(group);
status.setPdpSubgroup(subGroup);
status.setState(state);
diff --git a/feature-lifecycle/src/main/java/org/onap/policy/drools/lifecycle/LifecycleStateRunning.java b/feature-lifecycle/src/main/java/org/onap/policy/drools/lifecycle/LifecycleStateRunning.java
index 4c92b67b..db4f23d8 100644
--- a/feature-lifecycle/src/main/java/org/onap/policy/drools/lifecycle/LifecycleStateRunning.java
+++ b/feature-lifecycle/src/main/java/org/onap/policy/drools/lifecycle/LifecycleStateRunning.java
@@ -31,7 +31,6 @@ import lombok.NonNull;
import org.apache.commons.lang3.tuple.Pair;
import org.onap.policy.common.utils.coder.CoderException;
import org.onap.policy.drools.domain.models.artifact.NativeArtifactPolicy;
-import org.onap.policy.drools.policies.DomainMaker;
import org.onap.policy.models.pdp.concepts.PdpResponseDetails;
import org.onap.policy.models.pdp.concepts.PdpStateChange;
import org.onap.policy.models.pdp.concepts.PdpUpdate;
@@ -326,7 +325,7 @@ public abstract class LifecycleStateRunning extends LifecycleStateDefault {
protected List<ToscaPolicy> syncPolicies(List<ToscaPolicy> policies,
BiPredicate<PolicyTypeController, ToscaPolicy> sync) {
List<ToscaPolicy> failedPolicies = new ArrayList<>();
- DomainMaker domain = fsm.getDomainMaker();
+ var domain = fsm.getDomainMaker();
for (ToscaPolicy policy : policies) {
ToscaConceptIdentifier policyType = policy.getTypeIdentifier();
PolicyTypeController controller = fsm.getController(policyType);
@@ -357,7 +356,7 @@ public abstract class LifecycleStateRunning extends LifecycleStateDefault {
}
protected PdpResponseDetails response(String requestId, PdpResponseStatus responseStatus, String message) {
- PdpResponseDetails response = new PdpResponseDetails();
+ var response = new PdpResponseDetails();
response.setResponseTo(requestId);
response.setResponseStatus(responseStatus);
if (message != null) {
diff --git a/feature-lifecycle/src/main/java/org/onap/policy/drools/lifecycle/PolicyTypeDroolsController.java b/feature-lifecycle/src/main/java/org/onap/policy/drools/lifecycle/PolicyTypeDroolsController.java
index fa87617d..5f12a2a5 100644
--- a/feature-lifecycle/src/main/java/org/onap/policy/drools/lifecycle/PolicyTypeDroolsController.java
+++ b/feature-lifecycle/src/main/java/org/onap/policy/drools/lifecycle/PolicyTypeDroolsController.java
@@ -140,7 +140,7 @@ public class PolicyTypeDroolsController implements PolicyTypeController {
private boolean perform(ToscaPolicy policy, Predicate<PolicyController> operation) {
try {
List<PolicyController> selected = selectControllers(policy);
- boolean success = true;
+ var success = true;
for (PolicyController controller : selected) {
success = modifyController(operation, controller) && success;
}
diff --git a/feature-lifecycle/src/main/java/org/onap/policy/drools/lifecycle/PolicyTypeNativeArtifactController.java b/feature-lifecycle/src/main/java/org/onap/policy/drools/lifecycle/PolicyTypeNativeArtifactController.java
index fd98eed3..7532dd52 100644
--- a/feature-lifecycle/src/main/java/org/onap/policy/drools/lifecycle/PolicyTypeNativeArtifactController.java
+++ b/feature-lifecycle/src/main/java/org/onap/policy/drools/lifecycle/PolicyTypeNativeArtifactController.java
@@ -53,7 +53,7 @@ public class PolicyTypeNativeArtifactController implements PolicyTypeController
PolicyController controller;
try {
nativePolicy = fsm.getDomainMaker().convertTo(policy, NativeArtifactPolicy.class);
- DroolsConfiguration droolsConfig =
+ var droolsConfig =
new DroolsConfiguration(
nativePolicy.getProperties().getRulesArtifact().getArtifactId(),
nativePolicy.getProperties().getRulesArtifact().getGroupId(),
@@ -77,7 +77,7 @@ public class PolicyTypeNativeArtifactController implements PolicyTypeController
public boolean undeploy(ToscaPolicy policy) {
try {
NativeArtifactPolicy nativePolicy = fsm.getDomainMaker().convertTo(policy, NativeArtifactPolicy.class);
- DroolsConfiguration noConfig =
+ var noConfig =
new DroolsConfiguration(
DroolsControllerConstants.NO_ARTIFACT_ID,
DroolsControllerConstants.NO_GROUP_ID,
@@ -91,7 +91,7 @@ public class PolicyTypeNativeArtifactController implements PolicyTypeController
}
private boolean update(NativeArtifactPolicy nativePolicy, DroolsConfiguration droolsConfig) {
- ControllerConfiguration controllerConfig =
+ var controllerConfig =
new ControllerConfiguration(nativePolicy.getProperties().getController().getName(),
ControllerConfiguration.CONFIG_CONTROLLER_OPERATION_UPDATE, droolsConfig);
return PolicyEngineConstants.getManager().updatePolicyController(controllerConfig) != null;