summaryrefslogtreecommitdiffstats
path: root/services/services-onappf
diff options
context:
space:
mode:
authorliamfallon <liam.fallon@est.tech>2021-01-04 13:55:46 +0000
committerliamfallon <liam.fallon@est.tech>2021-01-04 16:26:58 +0000
commitf9455834e7e014fed6e941184ab80eb9fe91d89f (patch)
tree1770a8a258a2516530581d60e50f3841bfd74eaa /services/services-onappf
parente267120c204303088f3c15e580a5e1a364e014f5 (diff)
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 <liam.fallon@est.tech>
Diffstat (limited to 'services/services-onappf')
-rw-r--r--services/services-onappf/src/main/java/org/onap/policy/apex/services/onappf/ApexStarterActivator.java6
-rw-r--r--services/services-onappf/src/main/java/org/onap/policy/apex/services/onappf/handler/ApexEngineHandler.java14
-rw-r--r--services/services-onappf/src/main/java/org/onap/policy/apex/services/onappf/handler/PdpMessageHandler.java17
-rw-r--r--services/services-onappf/src/main/java/org/onap/policy/apex/services/onappf/handler/PdpStateChangeMessageHandler.java8
-rw-r--r--services/services-onappf/src/main/java/org/onap/policy/apex/services/onappf/handler/PdpUpdateMessageHandler.java8
5 files changed, 26 insertions, 27 deletions
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<ToscaPolicyTypeIdentifier> supportedPolicyTypes;
+ private List<ToscaConceptIdentifier> 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<ToscaPolicy> policies) throws ApexStarterException {
- Map<ToscaPolicyIdentifier, String[]> policyArgsMap = createPolicyArgsMap(policies);
+ Map<ToscaConceptIdentifier, String[]> 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<ToscaPolicyIdentifier, String[]> policyArgsMap = createPolicyArgsMap(policies);
+ Map<ToscaConceptIdentifier, String[]> policyArgsMap = createPolicyArgsMap(policies);
try {
apexMain.updateModel(policyArgsMap);
} catch (ApexException e) {
@@ -85,9 +85,9 @@ public class ApexEngineHandler {
}
}
- private Map<ToscaPolicyIdentifier, String[]> createPolicyArgsMap(List<ToscaPolicy> policies)
+ private Map<ToscaConceptIdentifier, String[]> createPolicyArgsMap(List<ToscaPolicy> policies)
throws ApexStarterException {
- Map<ToscaPolicyIdentifier, String[]> policyArgsMap = new LinkedHashMap<>();
+ Map<ToscaConceptIdentifier, String[]> 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<ToscaPolicyIdentifier> getRunningPolicies() {
+ public List<ToscaConceptIdentifier> 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<ToscaPolicyTypeIdentifier> getSupportedPolicyTypesFromParameters(
+ public List<ToscaConceptIdentifier> getSupportedPolicyTypesFromParameters(
final PdpStatusParameters pdpStatusParameters) {
- final List<ToscaPolicyTypeIdentifier> supportedPolicyTypes =
+ final List<ToscaConceptIdentifier> 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<ToscaPolicyIdentifier> getToscaPolicyIdentifiers(final List<ToscaPolicy> policies) {
- final List<ToscaPolicyIdentifier> policyIdentifiers = new ArrayList<>(policies.size());
+ public List<ToscaConceptIdentifier> getToscaPolicyIdentifiers(final List<ToscaPolicy> policies) {
+ final List<ToscaConceptIdentifier> 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<ToscaPolicyIdentifier> runningPolicies = apexEngineHandler.getRunningPolicies();
+ List<ToscaConceptIdentifier> 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<ToscaPolicyIdentifier> runningPolicies = apexEngineHandler.getRunningPolicies();
+ List<ToscaConceptIdentifier> 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.");