summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJim Hahn <jrh3@att.com>2021-05-06 17:32:21 -0400
committerJim Hahn <jrh3@att.com>2021-05-06 17:53:00 -0400
commitccca53bbd25af1230e135587163bcb53e381058c (patch)
tree921e378cdce276092a11261d9d094e8c96f3f5cf
parenta7bf744a50dcb660818a6bc6f265191b3389c13b (diff)
Fix sonars in policy-pap
Fixed: - use "var" instead of actual type - remove unused parameter - remove un-thrown exception from method declaration - call isPresent() before Optional.get() - check empty list before invoking doesNotContain() Issue-ID: POLICY-3285 Change-Id: Ic90dccfd591c102ce29f14084f025b3ca69587dc Signed-off-by: Jim Hahn <jrh3@att.com>
-rw-r--r--main/src/main/java/org/onap/policy/pap/main/comm/PdpHeartbeatListener.java4
-rw-r--r--main/src/main/java/org/onap/policy/pap/main/comm/PdpMessageGenerator.java16
-rw-r--r--main/src/main/java/org/onap/policy/pap/main/comm/PdpModifyRequestMap.java8
-rw-r--r--main/src/main/java/org/onap/policy/pap/main/comm/PdpRequests.java6
-rw-r--r--main/src/main/java/org/onap/policy/pap/main/comm/PdpStatusMessageHandler.java34
-rw-r--r--main/src/main/java/org/onap/policy/pap/main/comm/PdpTracker.java5
-rw-r--r--main/src/main/java/org/onap/policy/pap/main/comm/Publisher.java4
-rw-r--r--main/src/main/java/org/onap/policy/pap/main/comm/TimerManager.java4
-rw-r--r--main/src/main/java/org/onap/policy/pap/main/notification/DeploymentStatus.java4
-rw-r--r--main/src/main/java/org/onap/policy/pap/main/notification/DeploymentTracker.java4
-rw-r--r--main/src/main/java/org/onap/policy/pap/main/notification/PolicyNotifier.java2
-rw-r--r--main/src/main/java/org/onap/policy/pap/main/parameters/PapParameterHandler.java2
-rw-r--r--main/src/main/java/org/onap/policy/pap/main/rest/HealthCheckProvider.java4
-rw-r--r--main/src/main/java/org/onap/policy/pap/main/rest/PdpGroupCreateOrUpdateControllerV1.java3
-rw-r--r--main/src/main/java/org/onap/policy/pap/main/rest/PdpGroupCreateOrUpdateProvider.java24
-rw-r--r--main/src/main/java/org/onap/policy/pap/main/rest/PdpGroupDeleteControllerV1.java6
-rw-r--r--main/src/main/java/org/onap/policy/pap/main/rest/PdpGroupDeleteProvider.java2
-rw-r--r--main/src/main/java/org/onap/policy/pap/main/rest/PdpGroupDeployControllerV1.java4
-rw-r--r--main/src/main/java/org/onap/policy/pap/main/rest/PdpGroupDeployProvider.java18
-rw-r--r--main/src/main/java/org/onap/policy/pap/main/rest/PdpGroupHealthCheckProvider.java3
-rw-r--r--main/src/main/java/org/onap/policy/pap/main/rest/PdpGroupQueryProvider.java3
-rw-r--r--main/src/main/java/org/onap/policy/pap/main/rest/PdpGroupStateChangeProvider.java10
-rw-r--r--main/src/main/java/org/onap/policy/pap/main/rest/PolicyComponentsHealthCheckProvider.java15
-rw-r--r--main/src/main/java/org/onap/policy/pap/main/rest/PolicyStatusProvider.java10
-rw-r--r--main/src/main/java/org/onap/policy/pap/main/rest/PolicyUndeployerImpl.java2
-rw-r--r--main/src/main/java/org/onap/policy/pap/main/rest/ProviderBase.java8
-rw-r--r--main/src/main/java/org/onap/policy/pap/main/rest/SessionData.java4
-rw-r--r--main/src/main/java/org/onap/policy/pap/main/rest/StatisticsRestProvider.java4
-rw-r--r--main/src/main/java/org/onap/policy/pap/main/startstop/Main.java6
-rw-r--r--main/src/main/java/org/onap/policy/pap/main/startstop/PapActivator.java11
-rw-r--r--main/src/main/java/org/onap/policy/pap/main/startstop/PapDatabaseInitializer.java9
-rw-r--r--main/src/test/java/org/onap/policy/pap/main/comm/PdpHeartbeatListenerTest.java4
-rw-r--r--main/src/test/java/org/onap/policy/pap/main/comm/msgdata/UpdateReqTest.java5
33 files changed, 118 insertions, 130 deletions
diff --git a/main/src/main/java/org/onap/policy/pap/main/comm/PdpHeartbeatListener.java b/main/src/main/java/org/onap/policy/pap/main/comm/PdpHeartbeatListener.java
index 512609a4..1a58ad96 100644
--- a/main/src/main/java/org/onap/policy/pap/main/comm/PdpHeartbeatListener.java
+++ b/main/src/main/java/org/onap/policy/pap/main/comm/PdpHeartbeatListener.java
@@ -1,7 +1,7 @@
/*-
* ============LICENSE_START=======================================================
* Copyright (C) 2019 Nordix Foundation.
- * Modifications Copyright (C) 2020 AT&T Intellectual Property. All rights reserved.
+ * Modifications Copyright (C) 2020-2021 AT&T Intellectual Property. 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.
@@ -47,7 +47,7 @@ public class PdpHeartbeatListener implements TypedMessageListener<PdpStatus> {
@Override
public void onTopicEvent(final CommInfrastructure infra, final String topic, final PdpStatus message) {
- final PdpStatusMessageHandler handler = new PdpStatusMessageHandler(params);
+ final var handler = new PdpStatusMessageHandler(params);
handler.handlePdpStatus(message);
}
}
diff --git a/main/src/main/java/org/onap/policy/pap/main/comm/PdpMessageGenerator.java b/main/src/main/java/org/onap/policy/pap/main/comm/PdpMessageGenerator.java
index 99408eb2..76c47544 100644
--- a/main/src/main/java/org/onap/policy/pap/main/comm/PdpMessageGenerator.java
+++ b/main/src/main/java/org/onap/policy/pap/main/comm/PdpMessageGenerator.java
@@ -2,7 +2,7 @@
* ============LICENSE_START=======================================================
* ONAP PAP
* ================================================================================
- * Copyright (C) 2019 AT&T Intellectual Property. All rights reserved.
+ * Copyright (C) 2019, 2021 AT&T Intellectual Property. All rights reserved.
* Modifications Copyright (C) 2021 Nordix Foundation.
* Modifications Copyright (C) 2021 Bell Canada. All rights reserved.
* ================================================================================
@@ -93,11 +93,11 @@ public class PdpMessageGenerator {
}
protected PdpUpdate createPdpUpdateMessage(final String pdpGroupName, final PdpSubGroup subGroup,
- final String pdpInstanceId, final PolicyModelsProvider databaseProvider,
- final List<ToscaPolicy> policies, final List<ToscaPolicy> policiesToBeDeployed,
- final List<ToscaConceptIdentifier> policiesToBeUndeployed) throws PfModelException {
+ final String pdpInstanceId, final List<ToscaPolicy> policies,
+ final List<ToscaPolicy> policiesToBeDeployed,
+ final List<ToscaConceptIdentifier> policiesToBeUndeployed) {
- final PdpUpdate update = new PdpUpdate();
+ final var update = new PdpUpdate();
update.setName(pdpInstanceId);
update.setPdpGroup(pdpGroupName);
@@ -134,7 +134,7 @@ public class PdpMessageGenerator {
protected PdpStateChange createPdpStateChangeMessage(final String pdpGroupName, final PdpSubGroup subGroup,
final String pdpInstanceId, final PdpState pdpState) {
- final PdpStateChange stateChange = new PdpStateChange();
+ final var stateChange = new PdpStateChange();
stateChange.setName(pdpInstanceId);
stateChange.setPdpGroup(pdpGroupName);
stateChange.setPdpSubgroup(subGroup.getPdpType());
@@ -159,7 +159,7 @@ public class PdpMessageGenerator {
protected void updateDeploymentStatus(final String pdpGroupName, final String pdpType, final String pdpInstanceId,
PdpState pdpState, final PolicyModelsProvider databaseProvider, List<ToscaPolicy> policies)
throws PfModelException {
- DeploymentStatus deploymentStatus = new DeploymentStatus(databaseProvider);
+ var deploymentStatus = new DeploymentStatus(databaseProvider);
deploymentStatus.loadByGroup(pdpGroupName);
if (pdpState.equals(PdpState.PASSIVE)) {
deploymentStatus.deleteDeployment(pdpInstanceId);
@@ -169,7 +169,7 @@ public class PdpMessageGenerator {
pdpGroupName, pdpType, true);
}
}
- PolicyNotification notification = new PolicyNotification();
+ var notification = new PolicyNotification();
deploymentStatus.flush(notification);
PolicyNotifier notifier = Registry.get(PapConstants.REG_POLICY_NOTIFIER);
notifier.publish(notification);
diff --git a/main/src/main/java/org/onap/policy/pap/main/comm/PdpModifyRequestMap.java b/main/src/main/java/org/onap/policy/pap/main/comm/PdpModifyRequestMap.java
index fb19b01a..e00eadaa 100644
--- a/main/src/main/java/org/onap/policy/pap/main/comm/PdpModifyRequestMap.java
+++ b/main/src/main/java/org/onap/policy/pap/main/comm/PdpModifyRequestMap.java
@@ -190,7 +190,7 @@ public class PdpModifyRequestMap {
// @formatter:on
String name = update.getName() + " " + PdpUpdate.class.getSimpleName();
- UpdateReq request = new UpdateReq(reqparams, name, update);
+ var request = new UpdateReq(reqparams, name, update);
addSingleton(request);
}
@@ -219,7 +219,7 @@ public class PdpModifyRequestMap {
// @formatter:on
String name = stateChange.getName() + " " + PdpStateChange.class.getSimpleName();
- StateChangeReq request = new StateChangeReq(reqparams, name, stateChange);
+ var request = new StateChangeReq(reqparams, name, stateChange);
addSingleton(request);
}
@@ -266,7 +266,7 @@ public class PdpModifyRequestMap {
List<PdpGroup> groups = dao.getFilteredPdpGroups(filter);
List<PdpGroup> updates = new ArrayList<>(1);
- DeploymentStatus status = new DeploymentStatus(dao);
+ var status = new DeploymentStatus(dao);
for (PdpGroup group : groups) {
if (removeFromGroup(pdpName, group)) {
@@ -282,7 +282,7 @@ public class PdpModifyRequestMap {
} else {
dao.updatePdpGroups(updates);
- PolicyNotification notification = new PolicyNotification();
+ var notification = new PolicyNotification();
status.flush(notification);
policyNotifier.publish(notification);
diff --git a/main/src/main/java/org/onap/policy/pap/main/comm/PdpRequests.java b/main/src/main/java/org/onap/policy/pap/main/comm/PdpRequests.java
index eaacee9e..7815c837 100644
--- a/main/src/main/java/org/onap/policy/pap/main/comm/PdpRequests.java
+++ b/main/src/main/java/org/onap/policy/pap/main/comm/PdpRequests.java
@@ -2,7 +2,7 @@
* ============LICENSE_START=======================================================
* ONAP PAP
* ================================================================================
- * Copyright (C) 2019-2020 AT&T Intellectual Property. All rights reserved.
+ * Copyright (C) 2019-2021 AT&T Intellectual Property. 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.
@@ -101,7 +101,7 @@ public class PdpRequests {
* Stops all publishing and removes this PDP from any broadcast messages.
*/
public void stopPublishing() {
- Request request = requests.peek();
+ var request = requests.peek();
if (request != null) {
request.stopPublishing();
}
@@ -135,7 +135,7 @@ public class PdpRequests {
requests.remove();
// start publishing next request, but don't remove it from the queue
- Request nextRequest = requests.peek();
+ var nextRequest = requests.peek();
if (nextRequest == null) {
logger.info("{} has no more requests", pdpName);
return false;
diff --git a/main/src/main/java/org/onap/policy/pap/main/comm/PdpStatusMessageHandler.java b/main/src/main/java/org/onap/policy/pap/main/comm/PdpStatusMessageHandler.java
index 5ec9aba0..79889a79 100644
--- a/main/src/main/java/org/onap/policy/pap/main/comm/PdpStatusMessageHandler.java
+++ b/main/src/main/java/org/onap/policy/pap/main/comm/PdpStatusMessageHandler.java
@@ -1,7 +1,7 @@
/*-
* ============LICENSE_START=======================================================
* Copyright (C) 2019-2020 Nordix Foundation.
- * Modifications Copyright (C) 2019-2020 AT&T Intellectual Property.
+ * Modifications Copyright (C) 2019-2021 AT&T Intellectual Property.
* Modifications Copyright (C) 2021 Bell Canada. All rights reserved.
* ================================================================================
* Licensed under the Apache License, Version 2.0 (the "License");
@@ -36,11 +36,9 @@ import org.onap.policy.models.base.PfModelException;
import org.onap.policy.models.pdp.concepts.Pdp;
import org.onap.policy.models.pdp.concepts.PdpGroup;
import org.onap.policy.models.pdp.concepts.PdpGroupFilter;
-import org.onap.policy.models.pdp.concepts.PdpStateChange;
import org.onap.policy.models.pdp.concepts.PdpStatistics;
import org.onap.policy.models.pdp.concepts.PdpStatus;
import org.onap.policy.models.pdp.concepts.PdpSubGroup;
-import org.onap.policy.models.pdp.concepts.PdpUpdate;
import org.onap.policy.models.pdp.enums.PdpState;
import org.onap.policy.models.provider.PolicyModelsProvider;
import org.onap.policy.models.tosca.authorative.concepts.ToscaConceptIdentifier;
@@ -112,7 +110,7 @@ public class PdpStatusMessageHandler extends PdpMessageGenerator {
* throw an exception.
*/
if (message.getName() != null) {
- final PdpTracker pdpTracker = Registry.get(PapConstants.REG_PDP_TRACKER);
+ final var pdpTracker = (PdpTracker) Registry.get(PapConstants.REG_PDP_TRACKER);
pdpTracker.add(message.getName());
}
} catch (final PolicyPapException exp) {
@@ -126,7 +124,7 @@ public class PdpStatusMessageHandler extends PdpMessageGenerator {
private void handlePdpRegistration(final PdpStatus message, final PolicyModelsProvider databaseProvider)
throws PfModelException, PolicyPapException {
if (!findAndUpdatePdpGroup(message, databaseProvider)) {
- final String errorMessage = "Failed to register PDP. No matching PdpGroup/SubGroup Found - ";
+ final var errorMessage = "Failed to register PDP. No matching PdpGroup/SubGroup Found - ";
LOGGER.debug("{}{}", errorMessage, message);
throw new PolicyPapException(errorMessage + message);
}
@@ -134,7 +132,7 @@ public class PdpStatusMessageHandler extends PdpMessageGenerator {
private boolean findAndUpdatePdpGroup(final PdpStatus message, final PolicyModelsProvider databaseProvider)
throws PfModelException {
- boolean pdpGroupFound = false;
+ var pdpGroupFound = false;
final PdpGroupFilter filter =
PdpGroupFilter.builder().name(message.getPdpGroup()).groupState(PdpState.ACTIVE).build();
@@ -148,15 +146,15 @@ public class PdpStatusMessageHandler extends PdpMessageGenerator {
private boolean registerPdp(final PdpStatus message, final PolicyModelsProvider databaseProvider,
final PdpGroup finalizedPdpGroup) throws PfModelException {
Optional<PdpSubGroup> subGroup;
- boolean pdpGroupFound = false;
+ var pdpGroupFound = false;
subGroup = findPdpSubGroup(message, finalizedPdpGroup);
- policies = getToscaPolicies(subGroup.get(), databaseProvider);
- policiesToBeDeployed = policies.stream().collect(Collectors
- .toMap(ToscaPolicy::getIdentifier, policy -> policy));
- policiesToBeUndeployed = null;
-
if (subGroup.isPresent()) {
+ policies = getToscaPolicies(subGroup.get(), databaseProvider);
+ policiesToBeDeployed = policies.stream().collect(Collectors
+ .toMap(ToscaPolicy::getIdentifier, policy -> policy));
+ policiesToBeUndeployed = null;
+
LOGGER.debug("Found pdpGroup - {}, going for registration of PDP - {}", finalizedPdpGroup, message);
if (!findPdpInstance(message, subGroup.get()).isPresent()) {
updatePdpSubGroup(finalizedPdpGroup, subGroup.get(), message, databaseProvider);
@@ -170,7 +168,7 @@ public class PdpStatusMessageHandler extends PdpMessageGenerator {
private void updatePdpSubGroup(final PdpGroup pdpGroup, final PdpSubGroup pdpSubGroup, final PdpStatus message,
final PolicyModelsProvider databaseProvider) throws PfModelException {
- final Pdp pdpInstance = new Pdp();
+ final var pdpInstance = new Pdp();
pdpInstance.setInstanceId(message.getName());
pdpInstance.setPdpState(PdpState.ACTIVE);
pdpInstance.setHealthy(message.getHealthy());
@@ -191,7 +189,7 @@ public class PdpStatusMessageHandler extends PdpMessageGenerator {
PdpGroupFilter.builder().name(message.getPdpGroup()).groupState(PdpState.ACTIVE).build();
final List<PdpGroup> pdpGroups = databaseProvider.getFilteredPdpGroups(filter);
if (!pdpGroups.isEmpty()) {
- PdpGroup pdpGroup = pdpGroups.get(0);
+ var pdpGroup = pdpGroups.get(0);
Optional<PdpSubGroup> pdpSubgroup = findPdpSubGroup(message, pdpGroup);
if (pdpSubgroup.isPresent()) {
Optional<Pdp> pdpInstance = findPdpInstance(message, pdpSubgroup.get());
@@ -326,10 +324,10 @@ public class PdpStatusMessageHandler extends PdpMessageGenerator {
final PdpState pdpState, final PolicyModelsProvider databaseProvider)
throws PfModelException {
final List<ToscaPolicy> polsToBeDeployed = new LinkedList<>(policiesToBeDeployed.values());
- final PdpUpdate pdpUpdatemessage =
- createPdpUpdateMessage(pdpGroupName, subGroup, pdpInstanceId, databaseProvider, policies,
+ final var pdpUpdatemessage =
+ createPdpUpdateMessage(pdpGroupName, subGroup, pdpInstanceId, policies,
polsToBeDeployed, policiesToBeUndeployed);
- final PdpStateChange pdpStateChangeMessage =
+ final var pdpStateChangeMessage =
createPdpStateChangeMessage(pdpGroupName, subGroup, pdpInstanceId, pdpState);
updateDeploymentStatus(pdpGroupName, subGroup.getPdpType(), pdpInstanceId, pdpStateChangeMessage.getState(),
databaseProvider, pdpUpdatemessage.getPolicies());
@@ -338,4 +336,4 @@ public class PdpStatusMessageHandler extends PdpMessageGenerator {
LOGGER.debug("Sent PdpUpdate message - {}", pdpUpdatemessage);
LOGGER.debug("Sent PdpStateChange message - {}", pdpStateChangeMessage);
}
-} \ No newline at end of file
+}
diff --git a/main/src/main/java/org/onap/policy/pap/main/comm/PdpTracker.java b/main/src/main/java/org/onap/policy/pap/main/comm/PdpTracker.java
index f79326dc..53dcf65b 100644
--- a/main/src/main/java/org/onap/policy/pap/main/comm/PdpTracker.java
+++ b/main/src/main/java/org/onap/policy/pap/main/comm/PdpTracker.java
@@ -2,7 +2,7 @@
* ============LICENSE_START=======================================================
* ONAP PAP
* ================================================================================
- * Copyright (C) 2019-2020 AT&T Intellectual Property. All rights reserved.
+ * Copyright (C) 2019-2021 AT&T Intellectual Property. 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.
@@ -31,7 +31,6 @@ import org.onap.policy.models.pdp.concepts.PdpSubGroup;
import org.onap.policy.models.provider.PolicyModelsProvider;
import org.onap.policy.pap.main.PolicyModelsProviderFactoryWrapper;
import org.onap.policy.pap.main.PolicyPapRuntimeException;
-import org.onap.policy.pap.main.comm.TimerManager.Timer;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
@@ -122,7 +121,7 @@ public class PdpTracker {
*/
public void add(String pdpName) {
synchronized (modifyLock) {
- Timer timer = pdp2timer.remove(pdpName);
+ var timer = pdp2timer.remove(pdpName);
if (timer != null) {
timer.cancel();
}
diff --git a/main/src/main/java/org/onap/policy/pap/main/comm/Publisher.java b/main/src/main/java/org/onap/policy/pap/main/comm/Publisher.java
index 3fbaa99b..27c3b053 100644
--- a/main/src/main/java/org/onap/policy/pap/main/comm/Publisher.java
+++ b/main/src/main/java/org/onap/policy/pap/main/comm/Publisher.java
@@ -2,7 +2,7 @@
* ============LICENSE_START=======================================================
* ONAP PAP
* ================================================================================
- * Copyright (C) 2019-2020 AT&T Intellectual Property. All rights reserved.
+ * Copyright (C) 2019-2021 AT&T Intellectual Property. 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.
@@ -107,7 +107,7 @@ public class Publisher<T> implements Runnable {
break;
}
- T data = token.replaceItem(null);
+ var data = token.replaceItem(null);
if (data != null) {
client.send(data);
}
diff --git a/main/src/main/java/org/onap/policy/pap/main/comm/TimerManager.java b/main/src/main/java/org/onap/policy/pap/main/comm/TimerManager.java
index f64c2694..38d86989 100644
--- a/main/src/main/java/org/onap/policy/pap/main/comm/TimerManager.java
+++ b/main/src/main/java/org/onap/policy/pap/main/comm/TimerManager.java
@@ -2,7 +2,7 @@
* ============LICENSE_START=======================================================
* ONAP PAP
* ================================================================================
- * Copyright (C) 2019-2020 AT&T Intellectual Property. All rights reserved.
+ * Copyright (C) 2019-2021 AT&T Intellectual Property. 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.
@@ -110,7 +110,7 @@ public class TimerManager implements Runnable {
synchronized (lockit) {
// always remove existing entry so that new entry goes at the end of the map
- Timer timer = name2timer.remove(timerName);
+ var timer = name2timer.remove(timerName);
if (timer != null) {
logger.info("{} timer replaced {}", name, timer);
}
diff --git a/main/src/main/java/org/onap/policy/pap/main/notification/DeploymentStatus.java b/main/src/main/java/org/onap/policy/pap/main/notification/DeploymentStatus.java
index 7b627803..087383f4 100644
--- a/main/src/main/java/org/onap/policy/pap/main/notification/DeploymentStatus.java
+++ b/main/src/main/java/org/onap/policy/pap/main/notification/DeploymentStatus.java
@@ -88,7 +88,7 @@ public class DeploymentStatus {
* @param notif notification to which to add policy status
*/
protected void addNotifications(PolicyNotification notif) {
- DeploymentTracker newTracker = new DeploymentTracker();
+ var newTracker = new DeploymentTracker();
recordMap.values().forEach(newTracker::add);
tracker.addNotifications(notif, newTracker);
@@ -110,7 +110,7 @@ public class DeploymentStatus {
pdpGroupLoaded.add(pdpGroup);
for (PdpPolicyStatus status : provider.getGroupPolicyStatus(pdpGroup)) {
- StatusAction status2 = new StatusAction(Action.UNCHANGED, status);
+ var status2 = new StatusAction(Action.UNCHANGED, status);
recordMap.put(new StatusKey(status), status2);
tracker.add(status2);
}
diff --git a/main/src/main/java/org/onap/policy/pap/main/notification/DeploymentTracker.java b/main/src/main/java/org/onap/policy/pap/main/notification/DeploymentTracker.java
index 4522debb..cbc4f495 100644
--- a/main/src/main/java/org/onap/policy/pap/main/notification/DeploymentTracker.java
+++ b/main/src/main/java/org/onap/policy/pap/main/notification/DeploymentTracker.java
@@ -140,7 +140,7 @@ public class DeploymentTracker {
PolicyStatus status = entry.getValue();
// create a status with counts that are all zero
- PolicyStatus newStatus = new PolicyStatus();
+ var newStatus = new PolicyStatus();
newStatus.setPolicyId(status.getPolicyId());
newStatus.setPolicyVersion(status.getPolicyVersion());
newStatus.setPolicyTypeId(status.getPolicyTypeId());
@@ -186,7 +186,7 @@ public class DeploymentTracker {
Map<ToscaConceptIdentifier, PolicyStatus> map = (status.isDeploy() ? deployMap : undeployMap);
PolicyStatus newStat = map.computeIfAbsent(policy, key -> {
- PolicyStatus value = new PolicyStatus();
+ var value = new PolicyStatus();
value.setPolicyId(policy.getName());
value.setPolicyVersion(policy.getVersion());
value.setPolicyTypeId(status.getPolicyType().getName());
diff --git a/main/src/main/java/org/onap/policy/pap/main/notification/PolicyNotifier.java b/main/src/main/java/org/onap/policy/pap/main/notification/PolicyNotifier.java
index 66b83ccc..24e3ced6 100644
--- a/main/src/main/java/org/onap/policy/pap/main/notification/PolicyNotifier.java
+++ b/main/src/main/java/org/onap/policy/pap/main/notification/PolicyNotifier.java
@@ -75,7 +75,7 @@ public class PolicyNotifier {
status.loadByGroup(pdpGroup);
status.completeDeploy(pdp, expectedPolicies, actualPolicies);
- PolicyNotification notification = new PolicyNotification();
+ var notification = new PolicyNotification();
status.flush(notification);
publish(notification);
diff --git a/main/src/main/java/org/onap/policy/pap/main/parameters/PapParameterHandler.java b/main/src/main/java/org/onap/policy/pap/main/parameters/PapParameterHandler.java
index 848ce2cb..2f53b9bc 100644
--- a/main/src/main/java/org/onap/policy/pap/main/parameters/PapParameterHandler.java
+++ b/main/src/main/java/org/onap/policy/pap/main/parameters/PapParameterHandler.java
@@ -55,7 +55,7 @@ public class PapParameterHandler {
// Read the parameters
try {
// Read the parameters from JSON
- File file = new File(arguments.getFullConfigurationFilePath());
+ var file = new File(arguments.getFullConfigurationFilePath());
papParameterGroup = CODER.decode(file, PapParameterGroup.class);
} catch (final CoderException e) {
final String errorMessage = "error reading parameters from \"" + arguments.getConfigurationFilePath()
diff --git a/main/src/main/java/org/onap/policy/pap/main/rest/HealthCheckProvider.java b/main/src/main/java/org/onap/policy/pap/main/rest/HealthCheckProvider.java
index 9d3ad816..4b9c6f70 100644
--- a/main/src/main/java/org/onap/policy/pap/main/rest/HealthCheckProvider.java
+++ b/main/src/main/java/org/onap/policy/pap/main/rest/HealthCheckProvider.java
@@ -1,7 +1,7 @@
/*-
* ============LICENSE_START=======================================================
* Copyright (C) 2019 Nordix Foundation.
- * Modifications Copyright (C) 2019 AT&T Intellectual Property.
+ * Modifications Copyright (C) 2019, 2021 AT&T Intellectual Property.
* ================================================================================
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -45,7 +45,7 @@ public class HealthCheckProvider {
* @return Report containing health check status
*/
public HealthCheckReport performHealthCheck() {
- final HealthCheckReport report = new HealthCheckReport();
+ final var report = new HealthCheckReport();
report.setName(NAME);
report.setUrl(URL);
diff --git a/main/src/main/java/org/onap/policy/pap/main/rest/PdpGroupCreateOrUpdateControllerV1.java b/main/src/main/java/org/onap/policy/pap/main/rest/PdpGroupCreateOrUpdateControllerV1.java
index 9f72816d..fc118012 100644
--- a/main/src/main/java/org/onap/policy/pap/main/rest/PdpGroupCreateOrUpdateControllerV1.java
+++ b/main/src/main/java/org/onap/policy/pap/main/rest/PdpGroupCreateOrUpdateControllerV1.java
@@ -3,6 +3,7 @@
* ONAP PAP
* ================================================================================
* Copyright (C) 2019 Nordix Foundation.
+ * Modifications Copyright (C) 2021 AT&T Intellectual Property. 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.
@@ -104,7 +105,7 @@ public class PdpGroupCreateOrUpdateControllerV1 extends PapRestControllerV1 {
} catch (PfModelException | PfModelRuntimeException e) {
logger.warn(errmsg, e);
- PdpGroupUpdateResponse resp = new PdpGroupUpdateResponse();
+ var resp = new PdpGroupUpdateResponse();
resp.setErrorDetails(e.getErrorResponse().getErrorMessage());
return addLoggingHeaders(addVersionControlHeaders(Response.status(e.getErrorResponse().getResponseCode())),
requestId).entity(resp).build();
diff --git a/main/src/main/java/org/onap/policy/pap/main/rest/PdpGroupCreateOrUpdateProvider.java b/main/src/main/java/org/onap/policy/pap/main/rest/PdpGroupCreateOrUpdateProvider.java
index 2ad84dc5..7fa50484 100644
--- a/main/src/main/java/org/onap/policy/pap/main/rest/PdpGroupCreateOrUpdateProvider.java
+++ b/main/src/main/java/org/onap/policy/pap/main/rest/PdpGroupCreateOrUpdateProvider.java
@@ -75,7 +75,7 @@ public class PdpGroupCreateOrUpdateProvider extends ProviderBase {
* @throws PfModelException if an error occurred
*/
public void createOrUpdateGroups(PdpGroups groups) throws PfModelException {
- BeanValidationResult result = new BeanValidationResult("groups", groups);
+ var result = new BeanValidationResult("groups", groups);
groups.checkForDuplicateGroups(result);
if (!result.isValid()) {
String msg = result.getResult().trim();
@@ -104,7 +104,7 @@ public class PdpGroupCreateOrUpdateProvider extends ProviderBase {
* @throws PfModelException if an error occurred
*/
private void createOrUpdate(SessionData data, PdpGroups groups) throws PfModelException {
- BeanValidationResult result = new BeanValidationResult("groups", groups);
+ var result = new BeanValidationResult("groups", groups);
for (PdpGroup group : groups.getGroups()) {
PdpGroup dbgroup = data.getGroup(group.getName());
@@ -143,7 +143,7 @@ public class PdpGroupCreateOrUpdateProvider extends ProviderBase {
* @throws PfModelException if an error occurred
*/
private ValidationResult addGroup(SessionData data, PdpGroup group) throws PfModelException {
- BeanValidationResult result = new BeanValidationResult(group.getName(), group);
+ var result = new BeanValidationResult(group.getName(), group);
validateGroupOnly(group, result);
if (!result.isValid()) {
@@ -199,7 +199,7 @@ public class PdpGroupCreateOrUpdateProvider extends ProviderBase {
* @throws PfModelException if an error occurred
*/
private ValidationResult updateGroup(SessionData data, PdpGroup dbgroup, PdpGroup group) throws PfModelException {
- BeanValidationResult result = new BeanValidationResult(group.getName(), group);
+ var result = new BeanValidationResult(group.getName(), group);
if (!Objects.equals(dbgroup.getProperties(), group.getProperties())) {
result.addResult("properties", "", ValidationStatus.INVALID, "cannot change properties");
@@ -257,11 +257,11 @@ public class PdpGroupCreateOrUpdateProvider extends ProviderBase {
Map<String, PdpSubGroup> type2sub = new HashMap<>();
dbgroup.getPdpSubgroups().forEach(subgrp -> type2sub.put(subgrp.getPdpType(), subgrp));
- boolean updated = false;
+ var updated = false;
for (PdpSubGroup subgrp : group.getPdpSubgroups()) {
PdpSubGroup dbsub = type2sub.get(subgrp.getPdpType());
- BeanValidationResult subResult = new BeanValidationResult(subgrp.getPdpType(), subgrp);
+ var subResult = new BeanValidationResult(subgrp.getPdpType(), subgrp);
if (dbsub == null) {
updated = true;
@@ -288,7 +288,7 @@ public class PdpGroupCreateOrUpdateProvider extends ProviderBase {
* @throws PfModelException if an error occurred
*/
private boolean notifyPdpsDelSubGroups(SessionData data, PdpGroup dbgroup, PdpGroup group) throws PfModelException {
- boolean updated = false;
+ var updated = false;
// subgroups, as they appear within the updated group
Set<String> subgroups = new HashSet<>();
@@ -319,12 +319,12 @@ public class PdpGroupCreateOrUpdateProvider extends ProviderBase {
String name = pdp.getInstanceId();
// make it passive
- PdpStateChange change = new PdpStateChange();
+ var change = new PdpStateChange();
change.setName(name);
change.setState(PdpState.PASSIVE);
// remove it from subgroup and undeploy all policies
- PdpUpdate update = new PdpUpdate();
+ var update = new PdpUpdate();
update.setName(name);
data.addRequests(update, change);
@@ -360,7 +360,7 @@ public class PdpGroupCreateOrUpdateProvider extends ProviderBase {
subgrp.setCurrentInstanceCount(0);
subgrp.setPdpInstances(Collections.emptyList());
- BeanValidationResult result = new BeanValidationResult(subgrp.getPdpType(), subgrp);
+ var result = new BeanValidationResult(subgrp.getPdpType(), subgrp);
result.addResult(validateSupportedTypes(data, subgrp));
return result;
@@ -408,7 +408,7 @@ public class PdpGroupCreateOrUpdateProvider extends ProviderBase {
*/
private boolean validateSubGroup(PdpSubGroup dbsub, PdpSubGroup subgrp, BeanValidationResult container) {
- BeanValidationResult result = new BeanValidationResult(subgrp.getPdpType(), subgrp);
+ var result = new BeanValidationResult(subgrp.getPdpType(), subgrp);
if (!Objects.equals(dbsub.getProperties(), subgrp.getProperties())) {
result.addResult("properties", "", ValidationStatus.INVALID, "cannot change properties");
@@ -428,7 +428,7 @@ public class PdpGroupCreateOrUpdateProvider extends ProviderBase {
* @throws PfModelException if an error occurred
*/
private ValidationResult validateSupportedTypes(SessionData data, PdpSubGroup subgrp) throws PfModelException {
- BeanValidationResult result = new BeanValidationResult(subgrp.getPdpType(), subgrp);
+ var result = new BeanValidationResult(subgrp.getPdpType(), subgrp);
for (ToscaConceptIdentifier type : subgrp.getSupportedPolicyTypes()) {
if (!type.getName().endsWith(".*") && data.getPolicyType(type) == null) {
result.addResult("policy type", type, ValidationStatus.INVALID, "unknown policy type");
diff --git a/main/src/main/java/org/onap/policy/pap/main/rest/PdpGroupDeleteControllerV1.java b/main/src/main/java/org/onap/policy/pap/main/rest/PdpGroupDeleteControllerV1.java
index 0db12301..a76914a0 100644
--- a/main/src/main/java/org/onap/policy/pap/main/rest/PdpGroupDeleteControllerV1.java
+++ b/main/src/main/java/org/onap/policy/pap/main/rest/PdpGroupDeleteControllerV1.java
@@ -2,7 +2,7 @@
* ============LICENSE_START=======================================================
* ONAP PAP
* ================================================================================
- * Copyright (C) 2019 AT&T Intellectual Property. All rights reserved.
+ * Copyright (C) 2019, 2021 AT&T Intellectual Property. All rights reserved.
* Modifications Copyright (C) 2021 Nordix Foundation.
* Modifications Copyright (C) 2021 Bell Canada. All rights reserved.
* ================================================================================
@@ -188,7 +188,7 @@ public class PdpGroupDeleteControllerV1 extends PapRestControllerV1 {
} catch (PfModelException | PfModelRuntimeException e) {
logger.warn(errmsg, e);
- PdpGroupDeleteResponse resp = new PdpGroupDeleteResponse();
+ var resp = new PdpGroupDeleteResponse();
resp.setErrorDetails(e.getErrorResponse().getErrorMessage());
return addLoggingHeaders(addVersionControlHeaders(Response.status(e.getErrorResponse().getResponseCode())),
requestId).entity(resp).build();
@@ -213,7 +213,7 @@ public class PdpGroupDeleteControllerV1 extends PapRestControllerV1 {
} catch (PfModelException | PfModelRuntimeException e) {
logger.warn(errmsg, e);
- PdpGroupDeployResponse resp = new PdpGroupDeployResponse();
+ var resp = new PdpGroupDeployResponse();
resp.setErrorDetails(e.getErrorResponse().getErrorMessage());
return addLoggingHeaders(addVersionControlHeaders(Response.status(e.getErrorResponse().getResponseCode())),
requestId).entity(resp).build();
diff --git a/main/src/main/java/org/onap/policy/pap/main/rest/PdpGroupDeleteProvider.java b/main/src/main/java/org/onap/policy/pap/main/rest/PdpGroupDeleteProvider.java
index 0170197c..f80b1bd1 100644
--- a/main/src/main/java/org/onap/policy/pap/main/rest/PdpGroupDeleteProvider.java
+++ b/main/src/main/java/org/onap/policy/pap/main/rest/PdpGroupDeleteProvider.java
@@ -146,7 +146,7 @@ public class PdpGroupDeleteProvider extends ProviderBase {
Set<String> pdps = subgroup.getPdpInstances().stream().map(Pdp::getInstanceId).collect(Collectors.toSet());
- boolean result = false;
+ var result = false;
Iterator<ToscaConceptIdentifier> iter = subgroup.getPolicies().iterator();
while (iter.hasNext()) {
diff --git a/main/src/main/java/org/onap/policy/pap/main/rest/PdpGroupDeployControllerV1.java b/main/src/main/java/org/onap/policy/pap/main/rest/PdpGroupDeployControllerV1.java
index d8650f51..890d40bc 100644
--- a/main/src/main/java/org/onap/policy/pap/main/rest/PdpGroupDeployControllerV1.java
+++ b/main/src/main/java/org/onap/policy/pap/main/rest/PdpGroupDeployControllerV1.java
@@ -2,7 +2,7 @@
* ============LICENSE_START=======================================================
* ONAP PAP
* ================================================================================
- * Copyright (C) 2019 AT&T Intellectual Property. All rights reserved.
+ * Copyright (C) 2019, 2021 AT&T Intellectual Property. All rights reserved.
* Modifications Copyright (C) 2021 Bell Canada. All rights reserved.
* ================================================================================
* Licensed under the Apache License, Version 2.0 (the "License");
@@ -152,7 +152,7 @@ public class PdpGroupDeployControllerV1 extends PapRestControllerV1 {
} catch (PfModelException | PfModelRuntimeException e) {
logger.warn(errmsg, e);
- PdpGroupDeployResponse resp = new PdpGroupDeployResponse();
+ var resp = new PdpGroupDeployResponse();
resp.setErrorDetails(e.getErrorResponse().getErrorMessage());
return addLoggingHeaders(addVersionControlHeaders(Response.status(e.getErrorResponse().getResponseCode())),
requestId).entity(resp).build();
diff --git a/main/src/main/java/org/onap/policy/pap/main/rest/PdpGroupDeployProvider.java b/main/src/main/java/org/onap/policy/pap/main/rest/PdpGroupDeployProvider.java
index d400fa11..1f97551b 100644
--- a/main/src/main/java/org/onap/policy/pap/main/rest/PdpGroupDeployProvider.java
+++ b/main/src/main/java/org/onap/policy/pap/main/rest/PdpGroupDeployProvider.java
@@ -105,7 +105,7 @@ public class PdpGroupDeployProvider extends ProviderBase {
* @throws PfModelException if an error occurred
*/
private void updateGroups(SessionData data, DeploymentGroups groups) throws PfModelException {
- BeanValidationResult result = new BeanValidationResult("groups", groups);
+ var result = new BeanValidationResult("groups", groups);
for (DeploymentGroup group : groups.getGroups()) {
PdpGroup dbgroup = data.getGroup(group.getName());
@@ -135,7 +135,7 @@ public class PdpGroupDeployProvider extends ProviderBase {
private ValidationResult updateGroup(SessionData data, PdpGroup dbgroup, DeploymentGroup group)
throws PfModelException {
- BeanValidationResult result = new BeanValidationResult(group.getName(), group);
+ var result = new BeanValidationResult(group.getName(), group);
boolean updated = updateSubGroups(data, dbgroup, group, result);
@@ -163,11 +163,11 @@ public class PdpGroupDeployProvider extends ProviderBase {
Map<String, PdpSubGroup> type2sub = new HashMap<>();
dbgroup.getPdpSubgroups().forEach(subgrp -> type2sub.put(subgrp.getPdpType(), subgrp));
- boolean updated = false;
+ var updated = false;
for (DeploymentSubGroup subgrp : group.getDeploymentSubgroups()) {
PdpSubGroup dbsub = type2sub.get(subgrp.getPdpType());
- BeanValidationResult subResult = new BeanValidationResult(subgrp.getPdpType(), subgrp);
+ var subResult = new BeanValidationResult(subgrp.getPdpType(), subgrp);
if (dbsub == null) {
subResult.addResult(subgrp.getPdpType(), subgrp, ValidationStatus.INVALID, "unknown subgroup");
@@ -203,7 +203,7 @@ public class PdpGroupDeployProvider extends ProviderBase {
return false;
}
- boolean updated = false;
+ var updated = false;
switch (subgrp.getAction()) {
case POST:
@@ -233,7 +233,7 @@ public class PdpGroupDeployProvider extends ProviderBase {
Set<ToscaConceptIdentifier> policies = new LinkedHashSet<>(dbsub.getPolicies());
policies.addAll(subgrp.getPolicies());
- DeploymentSubGroup subgrp2 = new DeploymentSubGroup(subgrp);
+ var subgrp2 = new DeploymentSubGroup(subgrp);
subgrp2.getPolicies().clear();
subgrp2.getPolicies().addAll(policies);
@@ -246,7 +246,7 @@ public class PdpGroupDeployProvider extends ProviderBase {
Set<ToscaConceptIdentifier> policies = new LinkedHashSet<>(dbsub.getPolicies());
policies.removeAll(subgrp.getPolicies());
- DeploymentSubGroup subgrp2 = new DeploymentSubGroup(subgrp);
+ var subgrp2 = new DeploymentSubGroup(subgrp);
subgrp2.getPolicies().clear();
subgrp2.getPolicies().addAll(policies);
@@ -296,7 +296,7 @@ public class PdpGroupDeployProvider extends ProviderBase {
private boolean validateSubGroup(SessionData data, PdpSubGroup dbsub, DeploymentSubGroup subgrp,
BeanValidationResult container) throws PfModelException {
- BeanValidationResult result = new BeanValidationResult(subgrp.getPdpType(), subgrp);
+ var result = new BeanValidationResult(subgrp.getPdpType(), subgrp);
result.addResult(validatePolicies(data, dbsub, subgrp));
container.addResult(result);
@@ -322,7 +322,7 @@ public class PdpGroupDeployProvider extends ProviderBase {
Map<String, String> dbname2vers = new HashMap<>();
dbsub.getPolicies().forEach(ident -> dbname2vers.put(ident.getName(), ident.getVersion()));
- BeanValidationResult result = new BeanValidationResult(subgrp.getPdpType(), subgrp);
+ var result = new BeanValidationResult(subgrp.getPdpType(), subgrp);
for (ToscaConceptIdentifier ident : subgrp.getPolicies()) {
// note: "ident" may not have a fully qualified version
diff --git a/main/src/main/java/org/onap/policy/pap/main/rest/PdpGroupHealthCheckProvider.java b/main/src/main/java/org/onap/policy/pap/main/rest/PdpGroupHealthCheckProvider.java
index 9db38499..ce820f08 100644
--- a/main/src/main/java/org/onap/policy/pap/main/rest/PdpGroupHealthCheckProvider.java
+++ b/main/src/main/java/org/onap/policy/pap/main/rest/PdpGroupHealthCheckProvider.java
@@ -1,6 +1,7 @@
/*-
* ============LICENSE_START=======================================================
* Copyright (C) 2019 Nordix Foundation.
+ * Modifications Copyright (C) 2021 AT&T Intellectual Property. 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.
@@ -53,7 +54,7 @@ public class PdpGroupHealthCheckProvider {
*/
public Pair<Response.Status, Pdps> fetchPdpGroupHealthStatus() throws PfModelException {
- final Pdps pdps = new Pdps();
+ final var pdps = new Pdps();
final PolicyModelsProviderFactoryWrapper modelProviderWrapper =
Registry.get(PapConstants.REG_PAP_DAO_FACTORY, PolicyModelsProviderFactoryWrapper.class);
try (PolicyModelsProvider databaseProvider = modelProviderWrapper.create()) {
diff --git a/main/src/main/java/org/onap/policy/pap/main/rest/PdpGroupQueryProvider.java b/main/src/main/java/org/onap/policy/pap/main/rest/PdpGroupQueryProvider.java
index 32b00c87..3edc38af 100644
--- a/main/src/main/java/org/onap/policy/pap/main/rest/PdpGroupQueryProvider.java
+++ b/main/src/main/java/org/onap/policy/pap/main/rest/PdpGroupQueryProvider.java
@@ -1,6 +1,7 @@
/*-
* ============LICENSE_START=======================================================
* Copyright (C) 2019 Nordix Foundation.
+ * Modifications Copyright (C) 2021 AT&T Intellectual Property. 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.
@@ -48,7 +49,7 @@ public class PdpGroupQueryProvider {
*/
public Pair<Response.Status, PdpGroups> fetchPdpGroupDetails() throws PfModelException {
- final PdpGroups pdpGroups = new PdpGroups();
+ final var pdpGroups = new PdpGroups();
final PolicyModelsProviderFactoryWrapper modelProviderWrapper =
Registry.get(PapConstants.REG_PAP_DAO_FACTORY, PolicyModelsProviderFactoryWrapper.class);
try (PolicyModelsProvider databaseProvider = modelProviderWrapper.create()) {
diff --git a/main/src/main/java/org/onap/policy/pap/main/rest/PdpGroupStateChangeProvider.java b/main/src/main/java/org/onap/policy/pap/main/rest/PdpGroupStateChangeProvider.java
index abea6966..f0de7f9a 100644
--- a/main/src/main/java/org/onap/policy/pap/main/rest/PdpGroupStateChangeProvider.java
+++ b/main/src/main/java/org/onap/policy/pap/main/rest/PdpGroupStateChangeProvider.java
@@ -1,7 +1,7 @@
/*-
* ============LICENSE_START=======================================================
* Copyright (C) 2019 Nordix Foundation.
- * Modifications Copyright (C) 2019-2020 AT&T Intellectual Property.
+ * Modifications Copyright (C) 2019-2021 AT&T Intellectual Property.
* Modifications Copyright (C) 2021 Bell Canada. All rights reserved.
* ================================================================================
* Licensed under the Apache License, Version 2.0 (the "License");
@@ -29,9 +29,7 @@ import org.onap.policy.models.base.PfModelException;
import org.onap.policy.models.pap.concepts.PdpGroupStateChangeResponse;
import org.onap.policy.models.pdp.concepts.Pdp;
import org.onap.policy.models.pdp.concepts.PdpGroup;
-import org.onap.policy.models.pdp.concepts.PdpStateChange;
import org.onap.policy.models.pdp.concepts.PdpSubGroup;
-import org.onap.policy.models.pdp.concepts.PdpUpdate;
import org.onap.policy.models.pdp.enums.PdpState;
import org.onap.policy.models.provider.PolicyModelsProvider;
import org.onap.policy.models.tosca.authorative.concepts.ToscaPolicy;
@@ -121,10 +119,10 @@ public class PdpGroupStateChangeProvider extends PdpMessageGenerator {
List<ToscaPolicy> policies = getToscaPolicies(subGroup, databaseProvider);
for (final Pdp pdp : subGroup.getPdpInstances()) {
String pdpInstanceId = pdp.getInstanceId();
- final PdpUpdate pdpUpdatemessage =
- createPdpUpdateMessage(pdpGroup.getName(), subGroup, pdp.getInstanceId(), databaseProvider,
+ final var pdpUpdatemessage =
+ createPdpUpdateMessage(pdpGroup.getName(), subGroup, pdp.getInstanceId(),
policies, policies, null);
- final PdpStateChange pdpStateChangeMessage =
+ final var pdpStateChangeMessage =
createPdpStateChangeMessage(pdpGroupName, subGroup, pdpInstanceId, pdpState);
updateDeploymentStatus(pdpGroupName, subGroup.getPdpType(), pdpInstanceId,
pdpStateChangeMessage.getState(), databaseProvider, pdpUpdatemessage.getPolicies());
diff --git a/main/src/main/java/org/onap/policy/pap/main/rest/PolicyComponentsHealthCheckProvider.java b/main/src/main/java/org/onap/policy/pap/main/rest/PolicyComponentsHealthCheckProvider.java
index 461fbd01..2b28b1c5 100644
--- a/main/src/main/java/org/onap/policy/pap/main/rest/PolicyComponentsHealthCheckProvider.java
+++ b/main/src/main/java/org/onap/policy/pap/main/rest/PolicyComponentsHealthCheckProvider.java
@@ -1,7 +1,7 @@
/*-
* ============LICENSE_START=======================================================
* Copyright (C) 2019-2020 Nordix Foundation.
- * Modifications Copyright (C) 2020 AT&T Intellectual Property. All rights reserved.
+ * Modifications Copyright (C) 2021 AT&T Intellectual Property. All rights reserved.
* Modifications Copyright (C) 2020 Bell Canada. All rights reserved.
* ================================================================================
* Licensed under the Apache License, Version 2.0 (the "License");
@@ -34,7 +34,6 @@ import java.util.concurrent.ExecutionException;
import java.util.concurrent.ExecutorService;
import java.util.concurrent.Executors;
import java.util.concurrent.Future;
-import java.util.regex.Matcher;
import java.util.regex.Pattern;
import java.util.stream.Collectors;
import javax.ws.rs.core.Response;
@@ -44,7 +43,6 @@ import org.onap.policy.common.endpoints.event.comm.bus.internal.BusTopicParams;
import org.onap.policy.common.endpoints.http.client.HttpClient;
import org.onap.policy.common.endpoints.http.client.HttpClientConfigException;
import org.onap.policy.common.endpoints.http.client.HttpClientFactory;
-import org.onap.policy.common.endpoints.parameters.RestServerParameters;
import org.onap.policy.common.endpoints.report.HealthCheckReport;
import org.onap.policy.common.parameters.ParameterService;
import org.onap.policy.common.utils.services.Registry;
@@ -131,7 +129,7 @@ public class PolicyComponentsHealthCheckProvider {
// Check PAP itself
HealthCheckReport papReport = new HealthCheckProvider().performHealthCheck();
- RestServerParameters restServerParameters = papParameterGroup.getRestServerParameters();
+ var restServerParameters = papParameterGroup.getRestServerParameters();
papReport.setUrl(
(restServerParameters.isHttps() ? "https://" : "http://") + papReport.getUrl() + ":" + restServerParameters
.getPort() + POLICY_PAP_HEALTHCHECK_URI);
@@ -171,7 +169,7 @@ public class PolicyComponentsHealthCheckProvider {
}
private boolean verifyNumberOfPdps(List<PdpGroup> groups) {
- boolean flag = true;
+ var flag = true;
for (final PdpGroup group : groups) {
for (final PdpSubGroup subGroup : group.getPdpSubgroups()) {
if (subGroup.getCurrentInstanceCount() < subGroup.getDesiredInstanceCount()) {
@@ -213,7 +211,7 @@ public class PolicyComponentsHealthCheckProvider {
}
private HealthCheckReport createUnHealthCheckReport(String name, String url, int code, String message) {
- HealthCheckReport report = new HealthCheckReport();
+ var report = new HealthCheckReport();
report.setName(name);
report.setUrl(url);
report.setHealthy(false);
@@ -223,10 +221,9 @@ public class PolicyComponentsHealthCheckProvider {
}
private HealthCheckReport replaceIpWithHostname(HealthCheckReport report, String baseUrl) {
- Matcher matcher = IP_REPLACEMENT_PATTERN.matcher(baseUrl);
- String ip = "";
+ var matcher = IP_REPLACEMENT_PATTERN.matcher(baseUrl);
if (matcher.find()) {
- ip = matcher.group(1);
+ var ip = matcher.group(1);
report.setUrl(baseUrl.replace(ip, report.getUrl()));
}
return report;
diff --git a/main/src/main/java/org/onap/policy/pap/main/rest/PolicyStatusProvider.java b/main/src/main/java/org/onap/policy/pap/main/rest/PolicyStatusProvider.java
index 17651875..d8e7e549 100644
--- a/main/src/main/java/org/onap/policy/pap/main/rest/PolicyStatusProvider.java
+++ b/main/src/main/java/org/onap/policy/pap/main/rest/PolicyStatusProvider.java
@@ -22,7 +22,6 @@
package org.onap.policy.pap.main.rest;
-import com.google.re2j.Matcher;
import com.google.re2j.Pattern;
import java.util.Collection;
import java.util.List;
@@ -89,7 +88,7 @@ public class PolicyStatusProvider {
*/
public Collection<PolicyStatus> getByRegex(String patternString) throws PfModelException {
// try to make pattern out of regex
- final Pattern pattern = Pattern.compile(patternString);
+ final var pattern = Pattern.compile(patternString);
// get all the statuses
final List<PdpPolicyStatus> policyStatuses;
try (PolicyModelsProvider dao = daoFactory.create()) {
@@ -110,7 +109,7 @@ public class PolicyStatusProvider {
* @return the deployment status of the policies
*/
private Collection<PolicyStatus> accumulate(Collection<PdpPolicyStatus> source) {
- DeploymentTracker tracker = new DeploymentTracker();
+ var tracker = new DeploymentTracker();
for (PdpPolicyStatus status : source) {
if (status.isDeploy()) {
@@ -173,7 +172,7 @@ public class PolicyStatusProvider {
*/
public Collection<PdpPolicyStatus> getPolicyStatusByRegex(String pdpGroupName, String patternString)
throws PfModelException {
- final Pattern pattern = Pattern.compile(patternString);
+ final var pattern = Pattern.compile(patternString);
// get all the statuses
final Collection<PdpPolicyStatus> policyStatuses = getPolicyStatus(pdpGroupName);
// filter out statuses with the wrong name
@@ -188,8 +187,7 @@ public class PolicyStatusProvider {
final String policyName = policyStatus
.getPolicy()
.getName();
- final Matcher matcher = pattern.matcher(policyName);
- return matcher.matches();
+ return pattern.matcher(policyName).matches();
})
.collect(Collectors.toList());
}
diff --git a/main/src/main/java/org/onap/policy/pap/main/rest/PolicyUndeployerImpl.java b/main/src/main/java/org/onap/policy/pap/main/rest/PolicyUndeployerImpl.java
index c3dd505c..fe584265 100644
--- a/main/src/main/java/org/onap/policy/pap/main/rest/PolicyUndeployerImpl.java
+++ b/main/src/main/java/org/onap/policy/pap/main/rest/PolicyUndeployerImpl.java
@@ -81,7 +81,7 @@ public class PolicyUndeployerImpl extends ProviderBase implements PolicyUndeploy
PdpSubGroup subgroup = optsub.get();
// remove the policies
- boolean updated = false;
+ var updated = false;
Set<String> pdps = subgroup.getPdpInstances().stream().map(Pdp::getInstanceId).collect(Collectors.toSet());
for (ToscaConceptIdentifier ident : policyInfo.policies) {
diff --git a/main/src/main/java/org/onap/policy/pap/main/rest/ProviderBase.java b/main/src/main/java/org/onap/policy/pap/main/rest/ProviderBase.java
index d64d4e36..6aefce01 100644
--- a/main/src/main/java/org/onap/policy/pap/main/rest/ProviderBase.java
+++ b/main/src/main/java/org/onap/policy/pap/main/rest/ProviderBase.java
@@ -95,7 +95,7 @@ public abstract class ProviderBase {
synchronized (updateLock) {
SessionData data;
- PolicyNotification notif = new PolicyNotification();
+ var notif = new PolicyNotification();
try (PolicyModelsProvider dao = daoFactory.create()) {
@@ -138,7 +138,7 @@ public abstract class ProviderBase {
+ desiredPolicy.getName() + " " + desiredPolicy.getVersion());
}
- Updater updater = makeUpdater(data, policy, desiredPolicy);
+ var updater = makeUpdater(data, policy, desiredPolicy);
for (PdpGroup group : groups) {
upgradeGroup(data, group, updater);
@@ -184,7 +184,7 @@ public abstract class ProviderBase {
private void upgradeGroup(SessionData data, PdpGroup group, Updater updater)
throws PfModelException {
- boolean updated = false;
+ var updated = false;
for (PdpSubGroup subgroup : group.getPdpSubgroups()) {
@@ -227,7 +227,7 @@ public abstract class ProviderBase {
*/
private PdpUpdate makeUpdate(SessionData data, PdpGroup group, PdpSubGroup subgroup, Pdp pdp) {
- PdpUpdate update = new PdpUpdate();
+ var update = new PdpUpdate();
update.setName(pdp.getInstanceId());
update.setDescription(group.getDescription());
diff --git a/main/src/main/java/org/onap/policy/pap/main/rest/SessionData.java b/main/src/main/java/org/onap/policy/pap/main/rest/SessionData.java
index c8cddbb7..923871eb 100644
--- a/main/src/main/java/org/onap/policy/pap/main/rest/SessionData.java
+++ b/main/src/main/java/org/onap/policy/pap/main/rest/SessionData.java
@@ -463,7 +463,7 @@ public class SessionData {
String pdpType) throws PfModelException {
ToscaConceptIdentifier policyId = policy.getIdentifier();
policiesToBeDeployed.put(policyId, policy);
-
+
addData(policyId, pdps, pdpGroup, pdpType, true);
}
@@ -498,7 +498,7 @@ public class SessionData {
// delete all records whose "deploy" flag is the opposite of what we want
deployStatus.deleteDeployment(policyId, !deploy);
- ToscaConceptIdentifierOptVersion optid = new ToscaConceptIdentifierOptVersion(policyId);
+ var optid = new ToscaConceptIdentifierOptVersion(policyId);
ToscaConceptIdentifier policyType = getPolicy(optid).getTypeIdentifier();
for (String pdp : pdps) {
diff --git a/main/src/main/java/org/onap/policy/pap/main/rest/StatisticsRestProvider.java b/main/src/main/java/org/onap/policy/pap/main/rest/StatisticsRestProvider.java
index 512dbe76..27e3d7ac 100644
--- a/main/src/main/java/org/onap/policy/pap/main/rest/StatisticsRestProvider.java
+++ b/main/src/main/java/org/onap/policy/pap/main/rest/StatisticsRestProvider.java
@@ -1,7 +1,7 @@
/*-
* ============LICENSE_START=======================================================
* Copyright (C) 2020-2021 Nordix Foundation.
- * Modifications Copyright (C) 2019 AT&T Intellectual Property.
+ * Modifications Copyright (C) 2019, 2021 AT&T Intellectual Property.
* ================================================================================
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -54,7 +54,7 @@ public class StatisticsRestProvider {
* @return Report containing statistics of pap component
*/
public StatisticsReport fetchCurrentStatistics() {
- final StatisticsReport report = new StatisticsReport();
+ final var report = new StatisticsReport();
report.setCode(Registry.get(PapConstants.REG_PAP_ACTIVATOR, PapActivator.class).isAlive() ? 200 : 500);
PapStatisticsManager mgr = Registry.get(PapConstants.REG_STATISTICS_MANAGER, PapStatisticsManager.class);
diff --git a/main/src/main/java/org/onap/policy/pap/main/startstop/Main.java b/main/src/main/java/org/onap/policy/pap/main/startstop/Main.java
index a351e6f7..fe9b736a 100644
--- a/main/src/main/java/org/onap/policy/pap/main/startstop/Main.java
+++ b/main/src/main/java/org/onap/policy/pap/main/startstop/Main.java
@@ -51,11 +51,11 @@ public class Main {
* @param args the command line arguments
*/
public Main(final String[] args) {
- final String argumentString = Arrays.toString(args);
+ final var argumentString = Arrays.toString(args);
LOGGER.info("Starting policy pap service with arguments - {}", argumentString);
// Check the arguments
- final PapCommandLineArguments arguments = new PapCommandLineArguments();
+ final var arguments = new PapCommandLineArguments();
try {
// The arguments return a string if there is a message to print and we should exit
final String argumentMessage = arguments.parse(args);
@@ -94,7 +94,7 @@ public class Main {
// Add a shutdown hook to shut everything down in an orderly manner
Runtime.getRuntime().addShutdownHook(new PolicyPapShutdownHookClass());
- String successMsg = String.format(MessageConstants.START_SUCCESS_MSG, MessageConstants.POLICY_PAP);
+ var successMsg = String.format(MessageConstants.START_SUCCESS_MSG, MessageConstants.POLICY_PAP);
LOGGER.info(successMsg);
}
diff --git a/main/src/main/java/org/onap/policy/pap/main/startstop/PapActivator.java b/main/src/main/java/org/onap/policy/pap/main/startstop/PapActivator.java
index 4272e491..5c942341 100644
--- a/main/src/main/java/org/onap/policy/pap/main/startstop/PapActivator.java
+++ b/main/src/main/java/org/onap/policy/pap/main/startstop/PapActivator.java
@@ -1,7 +1,7 @@
/*-
* ============LICENSE_START=======================================================
* Copyright (C) 2019 Nordix Foundation.
- * Modifications Copyright (C) 2019-2020 AT&T Intellectual Property.
+ * Modifications Copyright (C) 2019-2021 AT&T Intellectual Property.
* ================================================================================
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -47,7 +47,6 @@ import org.onap.policy.pap.main.comm.TimerManager;
import org.onap.policy.pap.main.notification.PolicyNotifier;
import org.onap.policy.pap.main.parameters.PapParameterGroup;
import org.onap.policy.pap.main.parameters.PdpModifyRequestMapParams;
-import org.onap.policy.pap.main.parameters.PdpParameters;
import org.onap.policy.pap.main.rest.HealthCheckRestControllerV1;
import org.onap.policy.pap.main.rest.PapAafFilter;
import org.onap.policy.pap.main.rest.PapStatisticsManager;
@@ -119,8 +118,8 @@ public class PapActivator extends ServiceManagerContainer {
papParameterGroup.getRestServerParameters().setName(papParameterGroup.getName());
- final Object pdpUpdateLock = new Object();
- final PdpParameters pdpParams = papParameterGroup.getPdpParameters();
+ final var pdpUpdateLock = new Object();
+ final var pdpParams = papParameterGroup.getPdpParameters();
final AtomicReference<Publisher<PdpMessage>> pdpPub = new AtomicReference<>();
final AtomicReference<Publisher<PolicyNotification>> notifyPub = new AtomicReference<>();
final AtomicReference<TimerManager> pdpUpdTimers = new AtomicReference<>();
@@ -246,7 +245,7 @@ public class PapActivator extends ServiceManagerContainer {
addAction("REST server",
() -> {
- RestServer server = new RestServer(papParameterGroup.getRestServerParameters(), PapAafFilter.class,
+ var server = new RestServer(papParameterGroup.getRestServerParameters(), PapAafFilter.class,
HealthCheckRestControllerV1.class,
StatisticsRestControllerV1.class,
PdpGroupCreateOrUpdateControllerV1.class,
@@ -270,7 +269,7 @@ public class PapActivator extends ServiceManagerContainer {
* @param runner function to run in the background
*/
private void startThread(final Runnable runner) {
- final Thread thread = new Thread(runner);
+ final var thread = new Thread(runner);
thread.setDaemon(true);
thread.start();
diff --git a/main/src/main/java/org/onap/policy/pap/main/startstop/PapDatabaseInitializer.java b/main/src/main/java/org/onap/policy/pap/main/startstop/PapDatabaseInitializer.java
index affe1e9f..a266d695 100644
--- a/main/src/main/java/org/onap/policy/pap/main/startstop/PapDatabaseInitializer.java
+++ b/main/src/main/java/org/onap/policy/pap/main/startstop/PapDatabaseInitializer.java
@@ -1,7 +1,7 @@
/*-
* ============LICENSE_START=======================================================
* Copyright (C) 2019 Nordix Foundation.
- * Modifications Copyright (C) 2019 AT&T Intellectual Property.
+ * Modifications Copyright (C) 2019, 2021 AT&T Intellectual Property.
* ================================================================================
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -29,7 +29,6 @@ import org.onap.policy.common.utils.resources.ResourceUtils;
import org.onap.policy.models.base.PfModelException;
import org.onap.policy.models.pdp.concepts.PdpGroup;
import org.onap.policy.models.pdp.concepts.PdpGroups;
-import org.onap.policy.models.provider.PolicyModelsProvider;
import org.onap.policy.models.provider.PolicyModelsProviderFactory;
import org.onap.policy.models.provider.PolicyModelsProviderParameters;
import org.onap.policy.pap.main.PolicyPapException;
@@ -65,10 +64,10 @@ public class PapDatabaseInitializer {
public void initializePapDatabase(final PolicyModelsProviderParameters policyModelsProviderParameters)
throws PolicyPapException {
- try (PolicyModelsProvider databaseProvider =
+ try (var databaseProvider =
factory.createPolicyModelsProvider(policyModelsProviderParameters)) {
- final String originalJson = ResourceUtils.getResourceAsString("PapDb.json");
- final PdpGroups pdpGroupsToCreate = standardCoder.decode(originalJson, PdpGroups.class);
+ final var originalJson = ResourceUtils.getResourceAsString("PapDb.json");
+ final var pdpGroupsToCreate = standardCoder.decode(originalJson, PdpGroups.class);
final List<PdpGroup> pdpGroupsFromDb = databaseProvider.getPdpGroups(
pdpGroupsToCreate.getGroups().get(0).getName());
if (pdpGroupsFromDb.isEmpty()) {
diff --git a/main/src/test/java/org/onap/policy/pap/main/comm/PdpHeartbeatListenerTest.java b/main/src/test/java/org/onap/policy/pap/main/comm/PdpHeartbeatListenerTest.java
index 4a386c9c..0ceef772 100644
--- a/main/src/test/java/org/onap/policy/pap/main/comm/PdpHeartbeatListenerTest.java
+++ b/main/src/test/java/org/onap/policy/pap/main/comm/PdpHeartbeatListenerTest.java
@@ -1,7 +1,7 @@
/*-
* ============LICENSE_START=======================================================
* Copyright (C) 2019-2021 Nordix Foundation.
- * Modifications Copyright (C) 2020 AT&T Intellectual Property.
+ * Modifications Copyright (C) 2020-2021 AT&T Intellectual Property.
* ================================================================================
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -225,7 +225,7 @@ public class PdpHeartbeatListenerTest extends End2EndBase {
PdpStatusMessageHandler handler = new PdpStatusMessageHandler(params);
PdpUpdate update10 = handler.createPdpUpdateMessage(
status3.getPdpGroup(), new PdpSubGroup(), "pdp_2",
- null, policies, policies, polsUndep);
+ policies, policies, polsUndep);
assertSame(update10.getPolicies(), policies);
assertSame(update10.getPoliciesToBeDeployed(), policies);
assertSame(update10.getPoliciesToBeUndeployed(), polsUndep);
diff --git a/main/src/test/java/org/onap/policy/pap/main/comm/msgdata/UpdateReqTest.java b/main/src/test/java/org/onap/policy/pap/main/comm/msgdata/UpdateReqTest.java
index d85bf737..02f47287 100644
--- a/main/src/test/java/org/onap/policy/pap/main/comm/msgdata/UpdateReqTest.java
+++ b/main/src/test/java/org/onap/policy/pap/main/comm/msgdata/UpdateReqTest.java
@@ -236,10 +236,7 @@ public class UpdateReqTest extends CommonRequestBase {
assertTrue(data.reconfigure(msg2));
- List<ToscaConceptIdentifier> dataPols = data.getMessage().getPoliciesToBeDeployed().stream()
- .map(ToscaPolicy::getIdentifier)
- .collect(Collectors.toList());
- assertThat(dataPols).doesNotContainAnyElementsOf(data.getMessage().getPoliciesToBeUndeployed());
+ assertThat(data.getMessage().getPoliciesToBeDeployed()).isEmpty();
// some items only in deploy
policies = new ArrayList<>(update.getPolicies());