From f9455834e7e014fed6e941184ab80eb9fe91d89f Mon Sep 17 00:00:00 2001 From: liamfallon Date: Mon, 4 Jan 2021 13:55:46 +0000 Subject: Changed identifiers to concept identifiers The policy models tosca classes ToscaPolicyIdentifier and ToscaPolicyIdentifierOptVersion can be used to identify any TOSCA concept, not just TOSCA policies so they are renamed to ToscaConceptIdentifier and ToscaCinceptIdentifierOptVersion respectively. The class ToscaPolicyTypeIdentifier is redundant and is replaced by ToscaConceptIdentifier. Issue-ID: POLICY-2900 Change-Id: I5df89d023949cdf0f649951dbbd81a0b30f44ef6 Signed-off-by: liamfallon --- .../apex/services/onappf/ApexStarterActivator.java | 6 +++--- .../apex/services/onappf/handler/ApexEngineHandler.java | 14 +++++++------- .../apex/services/onappf/handler/PdpMessageHandler.java | 17 ++++++++--------- .../onappf/handler/PdpStateChangeMessageHandler.java | 8 ++++---- .../onappf/handler/PdpUpdateMessageHandler.java | 8 ++++---- 5 files changed, 26 insertions(+), 27 deletions(-) (limited to 'services/services-onappf/src') diff --git a/services/services-onappf/src/main/java/org/onap/policy/apex/services/onappf/ApexStarterActivator.java b/services/services-onappf/src/main/java/org/onap/policy/apex/services/onappf/ApexStarterActivator.java index 364221fc1..6a309632e 100644 --- a/services/services-onappf/src/main/java/org/onap/policy/apex/services/onappf/ApexStarterActivator.java +++ b/services/services-onappf/src/main/java/org/onap/policy/apex/services/onappf/ApexStarterActivator.java @@ -1,6 +1,6 @@ /*- * ============LICENSE_START======================================================= - * Copyright (C) 2019 Nordix Foundation. + * Copyright (C) 2019-2021 Nordix Foundation. * Modifications Copyright (C) 2019 AT&T Intellectual Property. All rights reserved. * ================================================================================ * Licensed under the Apache License, Version 2.0 (the "License"); @@ -41,7 +41,7 @@ import org.onap.policy.common.utils.services.Registry; import org.onap.policy.common.utils.services.ServiceManager; import org.onap.policy.common.utils.services.ServiceManagerException; import org.onap.policy.models.pdp.enums.PdpMessageType; -import org.onap.policy.models.tosca.authorative.concepts.ToscaPolicyTypeIdentifier; +import org.onap.policy.models.tosca.authorative.concepts.ToscaConceptIdentifier; import org.slf4j.Logger; import org.slf4j.LoggerFactory; @@ -78,7 +78,7 @@ public class ApexStarterActivator { private volatile boolean alive = false; @Getter - private List supportedPolicyTypes; + private List supportedPolicyTypes; /** * Instantiate the activator for onappf PDP-A. diff --git a/services/services-onappf/src/main/java/org/onap/policy/apex/services/onappf/handler/ApexEngineHandler.java b/services/services-onappf/src/main/java/org/onap/policy/apex/services/onappf/handler/ApexEngineHandler.java index f90938013..4d560a3bb 100644 --- a/services/services-onappf/src/main/java/org/onap/policy/apex/services/onappf/handler/ApexEngineHandler.java +++ b/services/services-onappf/src/main/java/org/onap/policy/apex/services/onappf/handler/ApexEngineHandler.java @@ -1,6 +1,6 @@ /*- * ============LICENSE_START======================================================= - * Copyright (C) 2019-2020 Nordix Foundation. + * Copyright (C) 2019-2021 Nordix Foundation. * Modifications Copyright (C) 2020 Bell Canada. All rights reserved. * ================================================================================ * Licensed under the Apache License, Version 2.0 (the "License"); @@ -33,8 +33,8 @@ import org.onap.policy.apex.service.engine.main.ApexMain; import org.onap.policy.apex.services.onappf.exception.ApexStarterException; import org.onap.policy.common.utils.coder.CoderException; import org.onap.policy.common.utils.coder.StandardCoder; +import org.onap.policy.models.tosca.authorative.concepts.ToscaConceptIdentifier; import org.onap.policy.models.tosca.authorative.concepts.ToscaPolicy; -import org.onap.policy.models.tosca.authorative.concepts.ToscaPolicyIdentifier; import org.onap.policy.models.tosca.authorative.concepts.ToscaServiceTemplate; import org.onap.policy.models.tosca.authorative.concepts.ToscaTopologyTemplate; import org.slf4j.Logger; @@ -58,7 +58,7 @@ public class ApexEngineHandler { * @throws ApexStarterException if the apex engine instantiation failed using the policies passed */ public ApexEngineHandler(List policies) throws ApexStarterException { - Map policyArgsMap = createPolicyArgsMap(policies); + Map policyArgsMap = createPolicyArgsMap(policies); LOGGER.debug("Starting apex engine."); try { apexMain = new ApexMain(policyArgsMap); @@ -77,7 +77,7 @@ public class ApexEngineHandler { if (null == apexMain || !apexMain.isAlive()) { throw new ApexStarterException("Apex Engine not initialized."); } - Map policyArgsMap = createPolicyArgsMap(policies); + Map policyArgsMap = createPolicyArgsMap(policies); try { apexMain.updateModel(policyArgsMap); } catch (ApexException e) { @@ -85,9 +85,9 @@ public class ApexEngineHandler { } } - private Map createPolicyArgsMap(List policies) + private Map createPolicyArgsMap(List policies) throws ApexStarterException { - Map policyArgsMap = new LinkedHashMap<>(); + Map policyArgsMap = new LinkedHashMap<>(); for (ToscaPolicy policy : policies) { String policyName = policy.getIdentifier().getName(); final StandardCoder standardCoder = new StandardCoder(); @@ -129,7 +129,7 @@ public class ApexEngineHandler { /** * Method that return the list of running policies in the apex engine. */ - public List getRunningPolicies() { + public List getRunningPolicies() { return new ArrayList<>(apexMain.getApexParametersMap().keySet()); } diff --git a/services/services-onappf/src/main/java/org/onap/policy/apex/services/onappf/handler/PdpMessageHandler.java b/services/services-onappf/src/main/java/org/onap/policy/apex/services/onappf/handler/PdpMessageHandler.java index e82e34755..c16f11c9c 100644 --- a/services/services-onappf/src/main/java/org/onap/policy/apex/services/onappf/handler/PdpMessageHandler.java +++ b/services/services-onappf/src/main/java/org/onap/policy/apex/services/onappf/handler/PdpMessageHandler.java @@ -1,6 +1,6 @@ /*- * ============LICENSE_START======================================================= - * Copyright (C) 2019-2020 Nordix Foundation. + * Copyright (C) 2019-2021 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,9 +39,8 @@ import org.onap.policy.models.pdp.enums.PdpEngineWorkerState; import org.onap.policy.models.pdp.enums.PdpHealthStatus; import org.onap.policy.models.pdp.enums.PdpResponseStatus; import org.onap.policy.models.pdp.enums.PdpState; +import org.onap.policy.models.tosca.authorative.concepts.ToscaConceptIdentifier; import org.onap.policy.models.tosca.authorative.concepts.ToscaPolicy; -import org.onap.policy.models.tosca.authorative.concepts.ToscaPolicyIdentifier; -import org.onap.policy.models.tosca.authorative.concepts.ToscaPolicyTypeIdentifier; import org.slf4j.Logger; import org.slf4j.LoggerFactory; @@ -80,13 +79,13 @@ public class PdpMessageHandler { * @param pdpStatusParameters pdp status parameters * @return supportedPolicyTypes list of PolicyTypeIdent */ - public List getSupportedPolicyTypesFromParameters( + public List getSupportedPolicyTypesFromParameters( final PdpStatusParameters pdpStatusParameters) { - final List supportedPolicyTypes = + final List supportedPolicyTypes = new ArrayList<>(pdpStatusParameters.getSupportedPolicyTypes().size()); for (final ToscaPolicyTypeIdentifierParameters policyTypeIdentParameters : pdpStatusParameters .getSupportedPolicyTypes()) { - supportedPolicyTypes.add(new ToscaPolicyTypeIdentifier(policyTypeIdentParameters.getName(), + supportedPolicyTypes.add(new ToscaConceptIdentifier(policyTypeIdentParameters.getName(), policyTypeIdentParameters.getVersion())); } return supportedPolicyTypes; @@ -222,11 +221,11 @@ public class PdpMessageHandler { * * @return policyTypeIdentifiers */ - public List getToscaPolicyIdentifiers(final List policies) { - final List policyIdentifiers = new ArrayList<>(policies.size()); + public List getToscaPolicyIdentifiers(final List policies) { + final List policyIdentifiers = new ArrayList<>(policies.size()); for (final ToscaPolicy policy : policies) { if (null != policy.getName() && null != policy.getVersion()) { - policyIdentifiers.add(new ToscaPolicyIdentifier(policy.getName(), policy.getVersion())); + policyIdentifiers.add(new ToscaConceptIdentifier(policy.getName(), policy.getVersion())); } } return policyIdentifiers; diff --git a/services/services-onappf/src/main/java/org/onap/policy/apex/services/onappf/handler/PdpStateChangeMessageHandler.java b/services/services-onappf/src/main/java/org/onap/policy/apex/services/onappf/handler/PdpStateChangeMessageHandler.java index 46d04f63f..bbdbb22db 100644 --- a/services/services-onappf/src/main/java/org/onap/policy/apex/services/onappf/handler/PdpStateChangeMessageHandler.java +++ b/services/services-onappf/src/main/java/org/onap/policy/apex/services/onappf/handler/PdpStateChangeMessageHandler.java @@ -1,6 +1,6 @@ /*- * ============LICENSE_START======================================================= - * Copyright (C) 2019-2020 Nordix Foundation. + * Copyright (C) 2019-2021 Nordix Foundation. * ================================================================================ * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -32,8 +32,8 @@ import org.onap.policy.models.pdp.concepts.PdpStateChange; import org.onap.policy.models.pdp.concepts.PdpStatus; import org.onap.policy.models.pdp.enums.PdpResponseStatus; import org.onap.policy.models.pdp.enums.PdpState; +import org.onap.policy.models.tosca.authorative.concepts.ToscaConceptIdentifier; import org.onap.policy.models.tosca.authorative.concepts.ToscaPolicy; -import org.onap.policy.models.tosca.authorative.concepts.ToscaPolicyIdentifier; import org.slf4j.Logger; import org.slf4j.LoggerFactory; @@ -118,7 +118,7 @@ public class PdpStateChangeMessageHandler { final ApexEngineHandler apexEngineHandler = new ApexEngineHandler(policies); Registry.registerOrReplace(ApexStarterConstants.REG_APEX_ENGINE_HANDLER, apexEngineHandler); if (apexEngineHandler.isApexEngineRunning()) { - List runningPolicies = apexEngineHandler.getRunningPolicies(); + List runningPolicies = apexEngineHandler.getRunningPolicies(); // only the policies which are succesfully executed should be there in the heartbeat pdpStatusContext.setPolicies(runningPolicies); if (new HashSet<>(runningPolicies) @@ -129,7 +129,7 @@ public class PdpStateChangeMessageHandler { } else { StringBuilder message = new StringBuilder( "Apex engine started. But, only the following polices are running - "); - for (ToscaPolicyIdentifier policy : runningPolicies) { + for (ToscaConceptIdentifier policy : runningPolicies) { message.append(policy.getName()).append(":").append(policy.getVersion()).append(" "); } message.append(". Other policies failed execution. Please see the logs for more details."); diff --git a/services/services-onappf/src/main/java/org/onap/policy/apex/services/onappf/handler/PdpUpdateMessageHandler.java b/services/services-onappf/src/main/java/org/onap/policy/apex/services/onappf/handler/PdpUpdateMessageHandler.java index aa5a6457e..bf72b0999 100644 --- a/services/services-onappf/src/main/java/org/onap/policy/apex/services/onappf/handler/PdpUpdateMessageHandler.java +++ b/services/services-onappf/src/main/java/org/onap/policy/apex/services/onappf/handler/PdpUpdateMessageHandler.java @@ -1,6 +1,6 @@ /*- * ============LICENSE_START======================================================= - * Copyright (C) 2019-2020 Nordix Foundation. + * Copyright (C) 2019-2021 Nordix Foundation. * ================================================================================ * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -34,7 +34,7 @@ import org.onap.policy.models.pdp.concepts.PdpStatus; import org.onap.policy.models.pdp.concepts.PdpUpdate; import org.onap.policy.models.pdp.enums.PdpResponseStatus; import org.onap.policy.models.pdp.enums.PdpState; -import org.onap.policy.models.tosca.authorative.concepts.ToscaPolicyIdentifier; +import org.onap.policy.models.tosca.authorative.concepts.ToscaConceptIdentifier; import org.slf4j.Logger; import org.slf4j.LoggerFactory; @@ -170,7 +170,7 @@ public class PdpUpdateMessageHandler { Registry.registerOrReplace(ApexStarterConstants.REG_APEX_ENGINE_HANDLER, apexEngineHandler); } if (apexEngineHandler.isApexEngineRunning()) { - List runningPolicies = apexEngineHandler.getRunningPolicies(); + List runningPolicies = apexEngineHandler.getRunningPolicies(); if (new HashSet<>(runningPolicies) .equals(new HashSet<>(pdpMessageHandler.getToscaPolicyIdentifiers(pdpUpdateMsg.getPolicies())))) { pdpResponseDetails = pdpMessageHandler.createPdpResonseDetails(pdpUpdateMsg.getRequestId(), @@ -178,7 +178,7 @@ public class PdpUpdateMessageHandler { } else { StringBuilder message = new StringBuilder("Apex engine started. But, only the following polices are running - "); - for (ToscaPolicyIdentifier policy : runningPolicies) { + for (ToscaConceptIdentifier policy : runningPolicies) { message.append(policy.getName()).append(":").append(policy.getVersion()).append(" "); } message.append(". Other policies failed execution. Please see the logs for more details."); -- cgit 1.2.3-korg