Remove AAF references from distribution. 57/136157/2
authoradheli.tavares <adheli.tavares@est.tech>
Thu, 12 Oct 2023 12:07:28 +0000 (13:07 +0100)
committeradheli.tavares <adheli.tavares@est.tech>
Thu, 12 Oct 2023 12:33:51 +0000 (13:33 +0100)
Issue-ID: POLICY-4592
Change-Id: Ifa924a99a9429494052a1d36d4b7480b9ddce37d
Signed-off-by: adheli.tavares <adheli.tavares@est.tech>
main/src/main/java/org/onap/policy/distribution/main/rest/aaf/AafDistributionFilter.java [deleted file]
main/src/main/java/org/onap/policy/distribution/main/startstop/DistributionActivator.java
plugins/forwarding-plugins/src/test/java/org/onap/policy/distribution/forwarding/lifecycle/api/LifecycleApiAutomationCompositionForwarderTest.java
plugins/forwarding-plugins/src/test/java/org/onap/policy/distribution/forwarding/lifecycle/api/LifecycleApiPolicyForwarderTest.java
plugins/forwarding-plugins/src/test/java/org/onap/policy/distribution/forwarding/testclasses/LifecycleApiAutomationCompositionSimulatorMain.java
plugins/forwarding-plugins/src/test/java/org/onap/policy/distribution/forwarding/testclasses/LifecycleApiSimulatorMain.java
plugins/reception-plugins/src/main/java/org/onap/policy/distribution/reception/handling/sdc/SdcReceptionHandler.java
reception/src/test/java/org/onap/policy/distribution/reception/parameters/TestPolicyDecoderConfigurationParametersJsonAdapter.java

diff --git a/main/src/main/java/org/onap/policy/distribution/main/rest/aaf/AafDistributionFilter.java b/main/src/main/java/org/onap/policy/distribution/main/rest/aaf/AafDistributionFilter.java
deleted file mode 100644 (file)
index d32c29d..0000000
+++ /dev/null
@@ -1,39 +0,0 @@
-/*-
- * ============LICENSE_START=======================================================
- * ONAP Policy API
- * ================================================================================
- * Copyright (C) 2019 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.
- * You may obtain a copy of the License at
- *
- *      http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- *
- * SPDX-License-Identifier: Apache-2.0
- * ============LICENSE_END=========================================================
- */
-
-package org.onap.policy.distribution.main.rest.aaf;
-
-import org.onap.policy.common.endpoints.http.server.aaf.AafGranularAuthFilter;
-
-/**
- * Distribution AAF authorization filter.
- */
-public class AafDistributionFilter extends AafGranularAuthFilter {
-
-    public static final String AAF_NODETYPE = "policy-distribution";
-    public static final String AAF_ROOT_PERMISSION = DEFAULT_NAMESPACE + "." + AAF_NODETYPE;
-
-    @Override
-    public String getPermissionTypeRoot() {
-        return AAF_ROOT_PERMISSION;
-    }
-}
index 6121034..6ff225e 100644 (file)
@@ -1,7 +1,7 @@
 /*-
  * ============LICENSE_START=======================================================
  *  Copyright (C) 2018 Ericsson. All rights reserved.
- *  Copyright (C) 2019 Nordix Foundation.
+ *  Copyright (C) 2019, 2023 Nordix Foundation.
  *  Modifications Copyright (C) 2019-2020 AT&T Intellectual Property. All rights reserved.
  *  Modifications Copyright (C) 2021 Bell Canada. All rights reserved.
  * ================================================================================
@@ -25,6 +25,7 @@ package org.onap.policy.distribution.main.startstop;
 
 import java.lang.reflect.InvocationTargetException;
 import java.util.HashMap;
+import java.util.List;
 import java.util.Map;
 import java.util.Map.Entry;
 import lombok.Getter;
@@ -35,7 +36,6 @@ import org.onap.policy.distribution.main.PolicyDistributionException;
 import org.onap.policy.distribution.main.parameters.DistributionParameterGroup;
 import org.onap.policy.distribution.main.parameters.PolicyForwarderConfigurationParameterGroup;
 import org.onap.policy.distribution.main.rest.DistributionRestController;
-import org.onap.policy.distribution.main.rest.aaf.AafDistributionFilter;
 import org.onap.policy.distribution.reception.decoding.PluginInitializationException;
 import org.onap.policy.distribution.reception.handling.AbstractReceptionHandler;
 import org.onap.policy.distribution.reception.parameters.PolicyDecoderConfigurationParameterGroup;
@@ -110,8 +110,8 @@ public class DistributionActivator {
      */
     private void startDistributionRestServer() throws PolicyDistributionException {
         distributionParameterGroup.getRestServerParameters().setName(distributionParameterGroup.getName());
-        restServer = new RestServer(distributionParameterGroup.getRestServerParameters(), AafDistributionFilter.class,
-                        DistributionRestController.class);
+        restServer = new RestServer(distributionParameterGroup.getRestServerParameters(), List.of(),
+            List.of(DistributionRestController.class));
         if (!restServer.start()) {
             throw new PolicyDistributionException(
                     "Failed to start distribution rest server. Check log for more details...");
index f28b52e..6069b66 100644 (file)
@@ -65,7 +65,7 @@ class LifecycleApiAutomationCompositionForwarderTest {
                 "src/test/resources/parameters/LifecycleApiAutomationCompositionForwarderParameters.json",
                 LifecycleApiAutomationCompositionForwarderParameters.class);
         ParameterService.register(parameterGroup);
-        simulator.startLifecycycleApiSimulator();
+        simulator.startLifecycleApiSimulator();
         if (!NetworkUtil.isTcpPortOpen("localhost", 6969, 50, 200L)) {
             throw new IllegalStateException("cannot connect to port 6969");
         }
index ba85505..a78debe 100644 (file)
@@ -66,7 +66,7 @@ class LifecycleApiPolicyForwarderTest {
                 "src/test/resources/parameters/LifecycleApiPolicyForwarderParameters.json",
                 LifecycleApiForwarderParameters.class);
         ParameterService.register(parameterGroup);
-        simulator.startLifecycycleApiSimulator();
+        simulator.startLifecycleApiSimulator();
         if (!NetworkUtil.isTcpPortOpen("localhost", 6969, 50, 200L)) {
             throw new IllegalStateException("cannot connect to port 6969");
         }
@@ -78,7 +78,7 @@ class LifecycleApiPolicyForwarderTest {
     @AfterAll
     static void tearDown() {
         ParameterService.deregister(LifecycleApiForwarderParameters.class.getSimpleName());
-        simulator.stopLifecycycleApiSimulator();
+        simulator.stopLifecycleApiSimulator();
     }
 
     @Test
index 98615af..be8cc82 100644 (file)
@@ -1,7 +1,6 @@
 /*-
  * ============LICENSE_START=======================================================
- *  Copyright (C) 2022 Nordix Foundation.
- *  Modifications Copyright (C) 2022 Nordix Foundation.
+ *  Copyright (C) 2022-2023 Nordix Foundation.
  * ================================================================================
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
@@ -21,6 +20,7 @@
 
 package org.onap.policy.distribution.forwarding.testclasses;
 
+import java.util.List;
 import org.onap.policy.common.endpoints.http.server.RestServer;
 import org.onap.policy.common.endpoints.parameters.RestServerParameters;
 import org.onap.policy.common.utils.coder.CoderException;
@@ -28,7 +28,6 @@ import org.onap.policy.common.utils.coder.StandardCoder;
 import org.onap.policy.common.utils.resources.ResourceUtils;
 import org.onap.policy.distribution.forwarding.PolicyForwardingException;
 import org.onap.policy.distribution.forwarding.lifecycle.api.LifecycleApiAutomationCompositionForwarder;
-import org.onap.policy.distribution.main.rest.aaf.AafDistributionFilter;
 
 /**
  * The class for starting/stopping simulator for testing {@link LifecycleApiAutomationCompositionForwarder} .
@@ -44,13 +43,13 @@ public class LifecycleApiAutomationCompositionSimulatorMain {
      * @throws PolicyForwardingException if error occurs
      * @throws CoderException if error occurs
      */
-    public void startLifecycycleApiSimulator() throws PolicyForwardingException, CoderException {
+    public void startLifecycleApiSimulator() throws PolicyForwardingException, CoderException {
         final StandardCoder standardCoder = new StandardCoder();
         final RestServerParameters restServerParameters = standardCoder.decode(
                 ResourceUtils.getResourceAsString("src/test/resources/parameters/RestServerParameters.json"),
                 RestServerParameters.class);
-        restServer = new RestServer(restServerParameters, AafDistributionFilter.class,
-                LifecycleApiAutomationCompositionSimulatorEndpoint.class);
+        restServer = new RestServer(restServerParameters, List.of(),
+                List.of(LifecycleApiAutomationCompositionSimulatorEndpoint.class));
         if (!restServer.start()) {
             throw new PolicyForwardingException("Failed to start rest simulator. Check log for more details...");
         }
index 07c4b6c..ef89149 100644 (file)
@@ -1,6 +1,6 @@
 /*-
  * ============LICENSE_START=======================================================
- *  Copyright (C) 2019 Nordix Foundation.
+ *  Copyright (C) 2019, 2023 Nordix Foundation.
  * ================================================================================
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
@@ -20,6 +20,7 @@
 
 package org.onap.policy.distribution.forwarding.testclasses;
 
+import java.util.List;
 import org.onap.policy.common.endpoints.http.server.RestServer;
 import org.onap.policy.common.endpoints.parameters.RestServerParameters;
 import org.onap.policy.common.utils.coder.CoderException;
@@ -27,7 +28,6 @@ import org.onap.policy.common.utils.coder.StandardCoder;
 import org.onap.policy.common.utils.resources.ResourceUtils;
 import org.onap.policy.distribution.forwarding.PolicyForwardingException;
 import org.onap.policy.distribution.forwarding.lifecycle.api.LifecycleApiPolicyForwarder;
-import org.onap.policy.distribution.main.rest.aaf.AafDistributionFilter;
 
 /**
  * The class for starting/stopping simulator for testing {@link LifecycleApiPolicyForwarder} .
@@ -43,13 +43,13 @@ public class LifecycleApiSimulatorMain {
      * @throws PolicyForwardingException if error occurs
      * @throws CoderException if error occurs
      */
-    public void startLifecycycleApiSimulator() throws PolicyForwardingException, CoderException {
+    public void startLifecycleApiSimulator() throws PolicyForwardingException, CoderException {
         final StandardCoder standardCoder = new StandardCoder();
         final RestServerParameters restServerParameters = standardCoder.decode(
                 ResourceUtils.getResourceAsString("src/test/resources/parameters/RestServerParameters.json"),
                 RestServerParameters.class);
-        restServer = new RestServer(restServerParameters, AafDistributionFilter.class,
-                LifecycycleApiSimulatorEndpoint.class);
+        restServer = new RestServer(restServerParameters, List.of(),
+                List.of(LifecycycleApiSimulatorEndpoint.class));
         if (!restServer.start()) {
             throw new PolicyForwardingException("Failed to start rest simulator. Check log for more details...");
         }
@@ -58,7 +58,7 @@ public class LifecycleApiSimulatorMain {
     /**
      * Shut down Execution.
      */
-    public void stopLifecycycleApiSimulator() {
+    public void stopLifecycleApiSimulator() {
         if (restServer != null) {
             restServer.stop();
         }
index ff91561..de44dc8 100644 (file)
@@ -1,7 +1,7 @@
 /*-
  * ============LICENSE_START=======================================================
  *  Copyright (C) 2018 Ericsson. All rights reserved.
- *  Copyright (C) 2019, 2022 Nordix Foundation.
+ *  Copyright (C) 2019, 2022-2023 Nordix Foundation.
  *  Modifications Copyright (C) 2020-2021 AT&T Intellectual Property. All rights reserved.
  *  Modifications Copyright (C) 2021 Bell Canada. All rights reserved.
  * ================================================================================
@@ -104,8 +104,7 @@ public class SdcReceptionHandler extends AbstractReceptionHandler implements INo
      */
     private synchronized void changeSdcReceptionHandlerStatus(final SdcReceptionHandlerStatus newStatus) {
         switch (newStatus) {
-            case INIT:
-            case STOPPED:
+            case INIT, STOPPED:
                 sdcReceptionHandlerStatus = newStatus;
                 break;
             case IDLE:
@@ -212,7 +211,10 @@ public class SdcReceptionHandler extends AbstractReceptionHandler implements INo
                     "Failed to deploy the artifact due to: " + exp.getMessage());
             }
         }
-        if (artifactsProcessedSuccessfully) {
+
+        // NoSonar here for complaining about var not changing, when, in fact,
+        // can change to false when Exceptions are triggered.
+        if (artifactsProcessedSuccessfully) { // NOSONAR
             DistributionStatisticsManager.updateDistributionSuccessCount();
             sendComponentDoneStatus(notificationData.getDistributionID(), DistributionStatusEnum.COMPONENT_DONE_OK,
                 null);
@@ -379,7 +381,7 @@ public class SdcReceptionHandler extends AbstractReceptionHandler implements INo
     }
 
     private File safelyCreateFile(String prefix) throws IOException {
-        File file = Files.createTempFile(prefix, ".csar").toFile();
+        File file = Files.createTempFile(prefix, ".csar").toFile(); // NOSONAR
         if (file.setReadable(true, false)
             && file.setWritable(true, true)) {
             return file;
index d3a0e3d..ebab535 100644 (file)
@@ -1,6 +1,6 @@
 /*-
  * ============LICENSE_START=======================================================
- *  Copyright (C) 2021 Nordix Foundation.
+ *  Copyright (C) 2021, 2023 Nordix Foundation.
  * ================================================================================
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
@@ -39,7 +39,7 @@ import org.onap.policy.distribution.reception.testclasses.DummyPolicyDecoderPara
  * @author Adheli Tavares (adheli.tavares@est.tech)
  *
  */
-public class TestPolicyDecoderConfigurationParametersJsonAdapter {
+class TestPolicyDecoderConfigurationParametersJsonAdapter {
 
     @Test
     void testDeserialize() throws JsonSyntaxException, IOException {