From 77efb4458cefbc496ffe25874e8bb42d77abb97c Mon Sep 17 00:00:00 2001 From: FrancescoFioraEst Date: Fri, 28 Nov 2025 10:57:51 +0000 Subject: [PATCH] Refactor policy participant dependencies Issue-ID: POLICY-5516 Change-Id: I9c992b73fe21bda140e04e45ed3888c6d81d8a65 Signed-off-by: FrancescoFioraEst --- .../participant-impl-policy/pom.xml | 5 --- .../policy/client/PolicyPapHttpClient.java | 8 ++-- .../policy/concepts/DeploymentGroup.java | 39 ++++++++++++++++++ .../policy/concepts/DeploymentGroups.java | 37 +++++++++++++++++ .../policy/concepts/DeploymentSubGroup.java | 46 ++++++++++++++++++++++ .../AutomationCompositionElementHandler.java | 4 +- .../participant/policy/client/HttpClientTest.java | 4 +- .../policy/main/utils/MockRestEndpoint.java | 5 +-- 8 files changed, 132 insertions(+), 16 deletions(-) create mode 100644 participant/participant-impl/participant-impl-policy/src/main/java/org/onap/policy/clamp/acm/participant/policy/concepts/DeploymentGroup.java create mode 100644 participant/participant-impl/participant-impl-policy/src/main/java/org/onap/policy/clamp/acm/participant/policy/concepts/DeploymentGroups.java create mode 100644 participant/participant-impl/participant-impl-policy/src/main/java/org/onap/policy/clamp/acm/participant/policy/concepts/DeploymentSubGroup.java diff --git a/participant/participant-impl/participant-impl-policy/pom.xml b/participant/participant-impl/participant-impl-policy/pom.xml index f1916e0a8..9beb0eb6c 100644 --- a/participant/participant-impl/participant-impl-policy/pom.xml +++ b/participant/participant-impl/participant-impl-policy/pom.xml @@ -32,11 +32,6 @@ ${project.artifactId} Policy participant, that allows Policy to partake in automation compositions - - org.onap.policy.models - policy-models-pdp - ${policy.models.version} - org.apache.httpcomponents.core5 httpcore5 diff --git a/participant/participant-impl/participant-impl-policy/src/main/java/org/onap/policy/clamp/acm/participant/policy/client/PolicyPapHttpClient.java b/participant/participant-impl/participant-impl-policy/src/main/java/org/onap/policy/clamp/acm/participant/policy/client/PolicyPapHttpClient.java index 8e4b59c35..3f6c4cbbb 100644 --- a/participant/participant-impl/participant-impl-policy/src/main/java/org/onap/policy/clamp/acm/participant/policy/client/PolicyPapHttpClient.java +++ b/participant/participant-impl/participant-impl-policy/src/main/java/org/onap/policy/clamp/acm/participant/policy/client/PolicyPapHttpClient.java @@ -1,6 +1,6 @@ /*- * ============LICENSE_START======================================================= - * Copyright (C) 2021 Nordix Foundation. + * Copyright (C) 2021-2025 OpenInfra Foundation Europe. 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. @@ -24,10 +24,10 @@ import jakarta.ws.rs.client.Entity; import jakarta.ws.rs.core.MediaType; import jakarta.ws.rs.core.Response; import java.util.List; +import org.onap.policy.clamp.acm.participant.policy.concepts.DeploymentGroup; +import org.onap.policy.clamp.acm.participant.policy.concepts.DeploymentGroups; +import org.onap.policy.clamp.acm.participant.policy.concepts.DeploymentSubGroup; import org.onap.policy.clamp.acm.participant.policy.main.parameters.ParticipantPolicyParameters; -import org.onap.policy.models.pdp.concepts.DeploymentGroup; -import org.onap.policy.models.pdp.concepts.DeploymentGroups; -import org.onap.policy.models.pdp.concepts.DeploymentSubGroup; import org.onap.policy.models.tosca.authorative.concepts.ToscaConceptIdentifier; import org.springframework.stereotype.Component; diff --git a/participant/participant-impl/participant-impl-policy/src/main/java/org/onap/policy/clamp/acm/participant/policy/concepts/DeploymentGroup.java b/participant/participant-impl/participant-impl-policy/src/main/java/org/onap/policy/clamp/acm/participant/policy/concepts/DeploymentGroup.java new file mode 100644 index 000000000..e2c5e9c20 --- /dev/null +++ b/participant/participant-impl/participant-impl-policy/src/main/java/org/onap/policy/clamp/acm/participant/policy/concepts/DeploymentGroup.java @@ -0,0 +1,39 @@ +/*- + * ============LICENSE_START======================================================= + * Copyright (C) 2019, 2021 AT&T Intellectual Property. + * Modifications Copyright (C) 2025 OpenInfra Foundation Europe. 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.clamp.acm.participant.policy.concepts; + +import java.util.List; +import lombok.Data; +import lombok.NoArgsConstructor; + +/** + * Batch modification of a deployment group, which groups multiple DeploymentSubGroup + * entities together for a particular domain. + */ +@Data +@NoArgsConstructor +public class DeploymentGroup { + private static final String SUBGROUP_FIELD = "deploymentSubgroups"; + + private String name; + private List deploymentSubgroups; +} diff --git a/participant/participant-impl/participant-impl-policy/src/main/java/org/onap/policy/clamp/acm/participant/policy/concepts/DeploymentGroups.java b/participant/participant-impl/participant-impl-policy/src/main/java/org/onap/policy/clamp/acm/participant/policy/concepts/DeploymentGroups.java new file mode 100644 index 000000000..f8fb8bb11 --- /dev/null +++ b/participant/participant-impl/participant-impl-policy/src/main/java/org/onap/policy/clamp/acm/participant/policy/concepts/DeploymentGroups.java @@ -0,0 +1,37 @@ +/* + * ============LICENSE_START======================================================= + * Copyright (C) 2019, 2021 AT&T Intellectual Property. All rights reserved. + * Modifications Copyright (C) 2021-2025 OpenInfra Foundation Europe. 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.clamp.acm.participant.policy.concepts; + +import java.util.List; +import lombok.Getter; +import lombok.Setter; +import lombok.ToString; + +/** + * Batch modification of a deployment groups via the PDP Group deployment REST API. + */ +@Getter +@Setter +@ToString +public class DeploymentGroups { + private List groups; +} diff --git a/participant/participant-impl/participant-impl-policy/src/main/java/org/onap/policy/clamp/acm/participant/policy/concepts/DeploymentSubGroup.java b/participant/participant-impl/participant-impl-policy/src/main/java/org/onap/policy/clamp/acm/participant/policy/concepts/DeploymentSubGroup.java new file mode 100644 index 000000000..e20bd9620 --- /dev/null +++ b/participant/participant-impl/participant-impl-policy/src/main/java/org/onap/policy/clamp/acm/participant/policy/concepts/DeploymentSubGroup.java @@ -0,0 +1,46 @@ +/*- + * ============LICENSE_START======================================================= + * Copyright (C) 2019, 2021 AT&T Intellectual Property. All rights reserved. + * Modifications Copyright (C) 2021-2025 OpenInfra Foundation Europe. 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.clamp.acm.participant.policy.concepts; + +import java.util.List; +import lombok.Data; +import lombok.NoArgsConstructor; +import org.onap.policy.models.tosca.authorative.concepts.ToscaConceptIdentifier; + +/** + * A deployment (i.e., set of policies) for all PDPs of the same pdp type running within a + * particular domain. + */ +@Data +@NoArgsConstructor +public class DeploymentSubGroup { + + public enum Action { + POST, // all listed policies are to be added + DELETE, // all listed policies are to be deleted + PATCH // update the deployment so that the policies match exactly + } + + private String pdpType; + private Action action; + private List policies; +} diff --git a/participant/participant-impl/participant-impl-policy/src/main/java/org/onap/policy/clamp/acm/participant/policy/main/handler/AutomationCompositionElementHandler.java b/participant/participant-impl/participant-impl-policy/src/main/java/org/onap/policy/clamp/acm/participant/policy/main/handler/AutomationCompositionElementHandler.java index 4230fbe98..c410ddbbd 100644 --- a/participant/participant-impl/participant-impl-policy/src/main/java/org/onap/policy/clamp/acm/participant/policy/main/handler/AutomationCompositionElementHandler.java +++ b/participant/participant-impl/participant-impl-policy/src/main/java/org/onap/policy/clamp/acm/participant/policy/main/handler/AutomationCompositionElementHandler.java @@ -1,6 +1,6 @@ /*- * ============LICENSE_START======================================================= - * Copyright (C) 2021-2024 Nordix Foundation. + * Copyright (C) 2021-2025 OpenInfra Foundation Europe. All rights reserved. * ================================================================================ * Modifications Copyright (C) 2021 AT&T Intellectual Property. All rights reserved. * ================================================================================ @@ -34,13 +34,13 @@ import org.onap.policy.clamp.acm.participant.intermediary.api.ParticipantInterme import org.onap.policy.clamp.acm.participant.intermediary.api.impl.AcElementListenerV3; import org.onap.policy.clamp.acm.participant.policy.client.PolicyApiHttpClient; import org.onap.policy.clamp.acm.participant.policy.client.PolicyPapHttpClient; +import org.onap.policy.clamp.acm.participant.policy.concepts.DeploymentSubGroup; import org.onap.policy.clamp.models.acm.concepts.DeployState; import org.onap.policy.clamp.models.acm.concepts.StateChangeResult; import org.onap.policy.common.utils.coder.Coder; import org.onap.policy.common.utils.coder.CoderException; import org.onap.policy.common.utils.coder.StandardCoder; import org.onap.policy.models.base.PfModelException; -import org.onap.policy.models.pdp.concepts.DeploymentSubGroup; import org.onap.policy.models.tosca.authorative.concepts.ToscaConceptIdentifier; import org.onap.policy.models.tosca.authorative.concepts.ToscaServiceTemplate; import org.slf4j.Logger; diff --git a/participant/participant-impl/participant-impl-policy/src/test/java/org/onap/policy/clamp/acm/participant/policy/client/HttpClientTest.java b/participant/participant-impl/participant-impl-policy/src/test/java/org/onap/policy/clamp/acm/participant/policy/client/HttpClientTest.java index 5cf72e7b5..642670734 100644 --- a/participant/participant-impl/participant-impl-policy/src/test/java/org/onap/policy/clamp/acm/participant/policy/client/HttpClientTest.java +++ b/participant/participant-impl/participant-impl-policy/src/test/java/org/onap/policy/clamp/acm/participant/policy/client/HttpClientTest.java @@ -1,6 +1,6 @@ /*- * ============LICENSE_START======================================================= - * Copyright (C) 2022, 2024 Nordix Foundation. + * Copyright (C) 2022, 2024-2025 OpenInfra Foundation Europe. 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. @@ -30,12 +30,12 @@ import jakarta.ws.rs.core.Response; import java.io.IOException; import org.junit.jupiter.api.BeforeAll; import org.junit.jupiter.api.Test; +import org.onap.policy.clamp.acm.participant.policy.concepts.DeploymentSubGroup; import org.onap.policy.clamp.acm.participant.policy.main.parameters.ParticipantPolicyParameters; import org.onap.policy.clamp.acm.participant.policy.main.utils.MockServer; import org.onap.policy.clamp.common.acm.exception.AutomationCompositionRuntimeException; import org.onap.policy.common.parameters.rest.RestClientParameters; import org.onap.policy.common.utils.network.NetworkUtil; -import org.onap.policy.models.pdp.concepts.DeploymentSubGroup; import org.onap.policy.models.tosca.authorative.concepts.ToscaServiceTemplate; /** diff --git a/participant/participant-impl/participant-impl-policy/src/test/java/org/onap/policy/clamp/acm/participant/policy/main/utils/MockRestEndpoint.java b/participant/participant-impl/participant-impl-policy/src/test/java/org/onap/policy/clamp/acm/participant/policy/main/utils/MockRestEndpoint.java index f032d37f9..64879aaa6 100644 --- a/participant/participant-impl/participant-impl-policy/src/test/java/org/onap/policy/clamp/acm/participant/policy/main/utils/MockRestEndpoint.java +++ b/participant/participant-impl/participant-impl-policy/src/test/java/org/onap/policy/clamp/acm/participant/policy/main/utils/MockRestEndpoint.java @@ -1,6 +1,6 @@ /*- * ============LICENSE_START======================================================= - * Copyright (C) 2022 Nordix Foundation. + * Copyright (C) 2022-2025 OpenInfra Foundation Europe. 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. @@ -25,11 +25,10 @@ import jakarta.ws.rs.POST; import jakarta.ws.rs.Path; import jakarta.ws.rs.Produces; import jakarta.ws.rs.core.Response; -import org.onap.policy.models.pdp.concepts.DeploymentGroups; +import org.onap.policy.clamp.acm.participant.policy.concepts.DeploymentGroups; import org.onap.policy.models.tosca.authorative.concepts.ToscaServiceTemplate; import org.springframework.web.bind.annotation.RequestBody; - /** * Mock rest endpoints for api and pap servers. */ -- 2.16.6