Fix sonars in policy-pap 48/121148/2
authorJim Hahn <jrh3@att.com>
Thu, 6 May 2021 21:32:21 +0000 (17:32 -0400)
committerJim Hahn <jrh3@att.com>
Thu, 6 May 2021 21:53:00 +0000 (17:53 -0400)
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>
33 files changed:
main/src/main/java/org/onap/policy/pap/main/comm/PdpHeartbeatListener.java
main/src/main/java/org/onap/policy/pap/main/comm/PdpMessageGenerator.java
main/src/main/java/org/onap/policy/pap/main/comm/PdpModifyRequestMap.java
main/src/main/java/org/onap/policy/pap/main/comm/PdpRequests.java
main/src/main/java/org/onap/policy/pap/main/comm/PdpStatusMessageHandler.java
main/src/main/java/org/onap/policy/pap/main/comm/PdpTracker.java
main/src/main/java/org/onap/policy/pap/main/comm/Publisher.java
main/src/main/java/org/onap/policy/pap/main/comm/TimerManager.java
main/src/main/java/org/onap/policy/pap/main/notification/DeploymentStatus.java
main/src/main/java/org/onap/policy/pap/main/notification/DeploymentTracker.java
main/src/main/java/org/onap/policy/pap/main/notification/PolicyNotifier.java
main/src/main/java/org/onap/policy/pap/main/parameters/PapParameterHandler.java
main/src/main/java/org/onap/policy/pap/main/rest/HealthCheckProvider.java
main/src/main/java/org/onap/policy/pap/main/rest/PdpGroupCreateOrUpdateControllerV1.java
main/src/main/java/org/onap/policy/pap/main/rest/PdpGroupCreateOrUpdateProvider.java
main/src/main/java/org/onap/policy/pap/main/rest/PdpGroupDeleteControllerV1.java
main/src/main/java/org/onap/policy/pap/main/rest/PdpGroupDeleteProvider.java
main/src/main/java/org/onap/policy/pap/main/rest/PdpGroupDeployControllerV1.java
main/src/main/java/org/onap/policy/pap/main/rest/PdpGroupDeployProvider.java
main/src/main/java/org/onap/policy/pap/main/rest/PdpGroupHealthCheckProvider.java
main/src/main/java/org/onap/policy/pap/main/rest/PdpGroupQueryProvider.java
main/src/main/java/org/onap/policy/pap/main/rest/PdpGroupStateChangeProvider.java
main/src/main/java/org/onap/policy/pap/main/rest/PolicyComponentsHealthCheckProvider.java
main/src/main/java/org/onap/policy/pap/main/rest/PolicyStatusProvider.java
main/src/main/java/org/onap/policy/pap/main/rest/PolicyUndeployerImpl.java
main/src/main/java/org/onap/policy/pap/main/rest/ProviderBase.java
main/src/main/java/org/onap/policy/pap/main/rest/SessionData.java
main/src/main/java/org/onap/policy/pap/main/rest/StatisticsRestProvider.java
main/src/main/java/org/onap/policy/pap/main/startstop/Main.java
main/src/main/java/org/onap/policy/pap/main/startstop/PapActivator.java
main/src/main/java/org/onap/policy/pap/main/startstop/PapDatabaseInitializer.java
main/src/test/java/org/onap/policy/pap/main/comm/PdpHeartbeatListenerTest.java
main/src/test/java/org/onap/policy/pap/main/comm/msgdata/UpdateReqTest.java

index 512609a..1a58ad9 100644 (file)
@@ -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);
     }
 }
index 99408eb..76c4754 100644 (file)
@@ -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);
index fb19b01..e00eada 100644 (file)
@@ -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);
index eaacee9..7815c83 100644 (file)
@@ -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;
index 5ec9aba..79889a7 100644 (file)
@@ -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
+}
index f79326d..53dcf65 100644 (file)
@@ -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();
             }
index 3fbaa99..27c3b05 100644 (file)
@@ -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);
             }
index f64c269..38d8698 100644 (file)
@@ -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);
             }
index 7b62780..087383f 100644 (file)
@@ -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);
         }
index 4522deb..cbc4f49 100644 (file)
@@ -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());
index 66b83cc..24e3ced 100644 (file)
@@ -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);
index 848ce2c..2f53b9b 100644 (file)
@@ -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()
index 9d3ad81..4b9c6f7 100644 (file)
@@ -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);
 
index 9f72816..fc11801 100644 (file)
@@ -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();
index 2ad84dc..7fa5048 100644 (file)
@@ -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");
index 0db1230..a76914a 100644 (file)
@@ -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();
index 0170197..f80b1bd 100644 (file)
@@ -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()) {
index d8650f5..890d40b 100644 (file)
@@ -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();
index d400fa1..1f97551 100644 (file)
@@ -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
index 9db3849..ce820f0 100644 (file)
@@ -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()) {
index 32b00c8..3edc38a 100644 (file)
@@ -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()) {
index abea696..f0de7f9 100644 (file)
@@ -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());
index 461fbd0..2b28b1c 100644 (file)
@@ -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;
index 1765187..d8e7e54 100644 (file)
@@ -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());
     }
index c3dd505..fe58426 100644 (file)
@@ -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) {
index d64d4e3..6aefce0 100644 (file)
@@ -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());
index c8cddbb..923871e 100644 (file)
@@ -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) {
index 512dbe7..27e3d7a 100644 (file)
@@ -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);
index a351e6f..fe9b736 100644 (file)
@@ -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);
     }
 
index 4272e49..5c94234 100644 (file)
@@ -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();
index affe1e9..a266d69 100644 (file)
@@ -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()) {
index 4a386c9..0ceef77 100644 (file)
@@ -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);
index d85bf73..02f4728 100644 (file)
@@ -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());