Changed identifiers to concept identifiers 70/116570/1
authorliamfallon <liam.fallon@est.tech>
Mon, 4 Jan 2021 15:58:25 +0000 (15:58 +0000)
committerliamfallon <liam.fallon@est.tech>
Mon, 4 Jan 2021 16:22:19 +0000 (16:22 +0000)
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: I677cc1f8730001b300ab2041f2d57c2485cbc4ed
Signed-off-by: liamfallon <liam.fallon@est.tech>
17 files changed:
feature-lifecycle/src/main/java/org/onap/policy/drools/lifecycle/LifecycleFsm.java
feature-lifecycle/src/main/java/org/onap/policy/drools/lifecycle/LifecycleStateRunning.java
feature-lifecycle/src/main/java/org/onap/policy/drools/lifecycle/PolicyTypeController.java
feature-lifecycle/src/main/java/org/onap/policy/drools/lifecycle/PolicyTypeDroolsController.java
feature-lifecycle/src/main/java/org/onap/policy/drools/lifecycle/PolicyTypeNativeArtifactController.java
feature-lifecycle/src/main/java/org/onap/policy/drools/lifecycle/PolicyTypeNativeDroolsController.java
feature-lifecycle/src/main/java/org/onap/policy/drools/server/restful/RestLifecycleManager.java
feature-lifecycle/src/test/java/org/onap/policy/drools/lifecycle/LifecycleStateActivePoliciesTest.java
feature-lifecycle/src/test/java/org/onap/policy/drools/lifecycle/LifecycleStateActiveTest.java
feature-lifecycle/src/test/java/org/onap/policy/drools/lifecycle/LifecycleStatePassiveTest.java
feature-lifecycle/src/test/java/org/onap/policy/drools/lifecycle/PolicyTypeNativeArtifactControllerTest.java
policy-domains/src/test/java/org/onap/policy/drools/domain/models/DomainPolicyTypesTest.java
policy-domains/src/test/java/org/onap/policy/drools/domain/models/operational/OperationalPolicyTest.java
policy-management/src/main/java/org/onap/policy/drools/system/PolicyController.java
policy-management/src/main/java/org/onap/policy/drools/system/internal/AggregatedPolicyController.java
policy-utils/src/main/java/org/onap/policy/drools/policies/DomainMaker.java
policy-utils/src/test/java/org/onap/policy/drools/policies/DomainMakerTest.java

index a45f2b4..ef47e1d 100644 (file)
@@ -3,6 +3,7 @@
  * ONAP
  * ================================================================================
  * Copyright (C) 2019-2020 AT&T Intellectual Property. All rights reserved.
+ * Modifications Copyright (C) 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.
@@ -59,9 +60,8 @@ import org.onap.policy.models.pdp.concepts.PdpUpdate;
 import org.onap.policy.models.pdp.enums.PdpHealthStatus;
 import org.onap.policy.models.pdp.enums.PdpMessageType;
 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;
 
@@ -84,11 +84,11 @@ public class LifecycleFsm implements Startable {
     protected static final long MIN_STATUS_INTERVAL_SECONDS = 5L;
     protected static final String PDP_MESSAGE_NAME = "messageName";
 
-    protected static final ToscaPolicyTypeIdentifier POLICY_TYPE_DROOLS_NATIVE_RULES =
-            new ToscaPolicyTypeIdentifier("onap.policies.native.drools.Artifact", "1.0.0");
+    protected static final ToscaConceptIdentifier POLICY_TYPE_DROOLS_NATIVE_RULES =
+            new ToscaConceptIdentifier("onap.policies.native.drools.Artifact", "1.0.0");
 
-    protected static final ToscaPolicyTypeIdentifier POLICY_TYPE_DROOLS_NATIVE_CONTROLLER =
-            new ToscaPolicyTypeIdentifier("onap.policies.native.drools.Controller", "1.0.0");
+    protected static final ToscaConceptIdentifier POLICY_TYPE_DROOLS_NATIVE_CONTROLLER =
+            new ToscaConceptIdentifier("onap.policies.native.drools.Controller", "1.0.0");
 
     @Getter
     protected final Properties properties;
@@ -135,10 +135,10 @@ public class LifecycleFsm implements Startable {
     protected Set<String> mandatoryPolicyTypes = new HashSet<>();
 
     @Getter
-    protected final Map<ToscaPolicyTypeIdentifier, PolicyTypeController> policyTypesMap = new HashMap<>();
+    protected final Map<ToscaConceptIdentifier, PolicyTypeController> policyTypesMap = new HashMap<>();
 
     @Getter
-    protected final Map<ToscaPolicyIdentifier, ToscaPolicy> policiesMap = new HashMap<>();
+    protected final Map<ToscaConceptIdentifier, ToscaPolicy> policiesMap = new HashMap<>();
 
     /**
      * Constructor.
@@ -200,7 +200,7 @@ public class LifecycleFsm implements Startable {
             return;
         }
 
-        for (ToscaPolicyTypeIdentifier id : controller.getPolicyTypes()) {
+        for (ToscaConceptIdentifier id : controller.getPolicyTypes()) {
             PolicyTypeDroolsController ptDc = (PolicyTypeDroolsController) policyTypesMap.get(id); //NOSONAR
             if (ptDc == null) {
                 policyTypesMap.put(id, new PolicyTypeDroolsController(this, id, controller));
@@ -374,7 +374,7 @@ public class LifecycleFsm implements Startable {
         return (this.scheduler.submit(() -> state.updatePolicies(toscaPolicies)) != null);
     }
 
-    protected PolicyTypeController getController(ToscaPolicyTypeIdentifier policyType) {
+    protected PolicyTypeController getController(ToscaConceptIdentifier policyType) {
         return policyTypesMap.get(policyType);
     }
 
@@ -387,7 +387,7 @@ public class LifecycleFsm implements Startable {
 
     protected Set<String> getCurrentPolicyTypes() {
         return getPolicyTypesMap().keySet().stream()
-                       .map(ToscaPolicyTypeIdentifier::getName).collect(Collectors.toSet());
+                       .map(ToscaConceptIdentifier::getName).collect(Collectors.toSet());
     }
 
     /* ** Action Helpers ** */
index 860986d..8654009 100644 (file)
@@ -4,6 +4,7 @@
  * ================================================================================
  * Copyright (C) 2019-2020 AT&T Intellectual Property. All rights reserved.
  * Modifications Copyright (C) 2019 Bell Canada.
+ * Modifications Copyright (C) 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.
@@ -30,8 +31,8 @@ import org.onap.policy.models.pdp.concepts.PdpStateChange;
 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.ToscaConceptIdentifier;
 import org.onap.policy.models.tosca.authorative.concepts.ToscaPolicy;
-import org.onap.policy.models.tosca.authorative.concepts.ToscaPolicyTypeIdentifier;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
@@ -164,7 +165,7 @@ public abstract class LifecycleStateRunning extends LifecycleStateDefault {
         boolean success = true;
         DomainMaker domain = fsm.getDomainMaker();
         for (ToscaPolicy policy : policies) {
-            ToscaPolicyTypeIdentifier policyType = policy.getTypeIdentifier();
+            ToscaConceptIdentifier policyType = policy.getTypeIdentifier();
             PolicyTypeController controller = fsm.getController(policyType);
             if (controller == null) {
                 logger.warn("no controller found for {}", policyType);
index a61088d..a376506 100644 (file)
@@ -3,6 +3,7 @@
  * ONAP
  * ================================================================================
  * Copyright (C) 2017-2019 AT&T Intellectual Property. All rights reserved.
+ * Modifications Copyright (C) 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.
@@ -20,8 +21,8 @@
 
 package org.onap.policy.drools.lifecycle;
 
+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.ToscaPolicyTypeIdentifier;
 
 /**
  * Policy Type Controller.
@@ -32,7 +33,7 @@ public interface PolicyTypeController {
     /**
      * Get Policy Type.
      */
-    ToscaPolicyTypeIdentifier getPolicyType();
+    ToscaConceptIdentifier getPolicyType();
 
     /**
      * Deploy a Tosca Policy.
index 39930c4..cdf9f14 100644 (file)
@@ -3,6 +3,7 @@
  * ONAP
  * ================================================================================
  * Copyright (C) 2020 AT&T Intellectual Property. All rights reserved.
+ * Modifications Copyright (C) 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.
@@ -31,8 +32,8 @@ import org.onap.policy.common.gson.annotation.GsonJsonIgnore;
 import org.onap.policy.common.utils.coder.CoderException;
 import org.onap.policy.drools.domain.models.operational.OperationalPolicy;
 import org.onap.policy.drools.system.PolicyController;
+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.ToscaPolicyTypeIdentifier;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
@@ -43,8 +44,8 @@ import org.slf4j.LoggerFactory;
 
 public class PolicyTypeDroolsController implements PolicyTypeController {
 
-    protected static final ToscaPolicyTypeIdentifier compliantType =
-        new ToscaPolicyTypeIdentifier("onap.policies.controlloop.operational.common.Drools", "1.0.0");
+    protected static final ToscaConceptIdentifier compliantType =
+        new ToscaConceptIdentifier("onap.policies.controlloop.operational.common.Drools", "1.0.0");
 
     private static final Logger logger = LoggerFactory.getLogger(PolicyTypeDroolsController.class);
 
@@ -52,7 +53,7 @@ public class PolicyTypeDroolsController implements PolicyTypeController {
     protected final Map<String, PolicyController> controllers = new ConcurrentHashMap<>();
 
     @Getter
-    protected final ToscaPolicyTypeIdentifier policyType;
+    protected final ToscaConceptIdentifier policyType;
 
     @GsonJsonIgnore
     protected final LifecycleFsm fsm;
@@ -61,7 +62,7 @@ public class PolicyTypeDroolsController implements PolicyTypeController {
      * Creates a Policy Type Drools Controller.
      */
     public PolicyTypeDroolsController(
-            LifecycleFsm fsm, ToscaPolicyTypeIdentifier policyType, PolicyController controller) {
+            LifecycleFsm fsm, ToscaConceptIdentifier policyType, PolicyController controller) {
         this.policyType = policyType;
         this.controllers.put(controller.getName(), controller);
         this.fsm = fsm;
index 53945f5..b97d902 100644 (file)
@@ -3,6 +3,7 @@
  * ONAP
  * ================================================================================
  * Copyright (C) 2020 AT&T Intellectual Property. All rights reserved.
+ * Modifications Copyright (C) 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.
@@ -30,8 +31,8 @@ import org.onap.policy.drools.protocol.configuration.DroolsConfiguration;
 import org.onap.policy.drools.system.PolicyController;
 import org.onap.policy.drools.system.PolicyControllerConstants;
 import org.onap.policy.drools.system.PolicyEngineConstants;
+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.ToscaPolicyTypeIdentifier;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
@@ -39,12 +40,12 @@ public class PolicyTypeNativeArtifactController implements PolicyTypeController
     private static final Logger logger = LoggerFactory.getLogger(PolicyTypeNativeArtifactController.class);
 
     @Getter
-    protected final ToscaPolicyTypeIdentifier policyType;
+    protected final ToscaConceptIdentifier policyType;
 
     @GsonJsonIgnore
     protected final LifecycleFsm fsm;
 
-    public PolicyTypeNativeArtifactController(LifecycleFsm fsm, ToscaPolicyTypeIdentifier policyType) {
+    public PolicyTypeNativeArtifactController(LifecycleFsm fsm, ToscaConceptIdentifier policyType) {
         this.policyType = policyType;
         this.fsm = fsm;
     }
index 48e0a49..cb7da95 100644 (file)
@@ -3,6 +3,7 @@
  * ONAP
  * ================================================================================
  * Copyright (C) 2020 AT&T Intellectual Property. All rights reserved.
+ * Modifications Copyright (C) 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.
@@ -41,8 +42,8 @@ import org.onap.policy.drools.properties.DroolsPropertyConstants;
 import org.onap.policy.drools.system.PolicyController;
 import org.onap.policy.drools.system.PolicyControllerConstants;
 import org.onap.policy.drools.system.PolicyEngineConstants;
+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.ToscaPolicyTypeIdentifier;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
@@ -50,12 +51,12 @@ public class PolicyTypeNativeDroolsController implements PolicyTypeController {
     private static final Logger logger = LoggerFactory.getLogger(PolicyTypeNativeDroolsController.class);
 
     @Getter
-    protected final ToscaPolicyTypeIdentifier policyType;
+    protected final ToscaConceptIdentifier policyType;
 
     @GsonJsonIgnore
     protected final LifecycleFsm fsm;
 
-    public PolicyTypeNativeDroolsController(LifecycleFsm fsm, ToscaPolicyTypeIdentifier policyType) {
+    public PolicyTypeNativeDroolsController(LifecycleFsm fsm, ToscaConceptIdentifier policyType) {
         this.policyType = policyType;
         this.fsm = fsm;
     }
index b430533..b28f06e 100644 (file)
@@ -1,6 +1,7 @@
 /*-
  * ============LICENSE_START=======================================================
  * Copyright (C) 2019-2020 AT&T Intellectual Property. All rights reserved.
+ * Modifications Copyright (C) 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.
@@ -46,9 +47,8 @@ import org.onap.policy.drools.lifecycle.PolicyTypeController;
 import org.onap.policy.models.pdp.concepts.PdpStateChange;
 import org.onap.policy.models.pdp.concepts.PdpUpdate;
 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;
 
@@ -239,7 +239,7 @@ public class RestLifecycleManager {
             @PathParam("policyTypeVersion") String policyTypeVersion) {
         PolicyTypeController typeController =
             LifecycleFeature.fsm.getPolicyTypesMap()
-                    .get(new ToscaPolicyTypeIdentifier(policyType, policyTypeVersion));
+                    .get(new ToscaConceptIdentifier(policyType, policyTypeVersion));
         if (typeController == null) {
             return Response.status(Response.Status.NOT_FOUND).build();
         }
@@ -307,7 +307,7 @@ public class RestLifecycleManager {
         ToscaPolicy policy;
         try {
             policy =
-                LifecycleFeature.fsm.getPoliciesMap().get(new ToscaPolicyIdentifier(policyName, policyVersion));
+                LifecycleFeature.fsm.getPoliciesMap().get(new ToscaConceptIdentifier(policyName, policyVersion));
         } catch (RuntimeException r) {
             logger.debug("policy {}:{} has not been found", policyName, policyVersion, r);
             return Response.status(Response.Status.NOT_FOUND).build();
@@ -334,7 +334,7 @@ public class RestLifecycleManager {
         ToscaPolicy policy;
         try {
             policy =
-                LifecycleFeature.fsm.getPoliciesMap().get(new ToscaPolicyIdentifier(policyName, policyVersion));
+                LifecycleFeature.fsm.getPoliciesMap().get(new ToscaConceptIdentifier(policyName, policyVersion));
         } catch (RuntimeException r) {
             logger.debug("policy {}:{} has not been found", policyName, policyVersion, r);
             return Response.status(Response.Status.NOT_FOUND).build();
index 2b0e65b..d961dce 100644 (file)
@@ -1,6 +1,7 @@
 /*
  * ============LICENSE_START=======================================================
  * Copyright (C) 2020 AT&T Intellectual Property. All rights reserved.
+ * Modifications Copyright (C) 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.
@@ -44,8 +45,8 @@ import org.onap.policy.common.utils.network.NetworkUtil;
 import org.onap.policy.models.pdp.concepts.PdpStateChange;
 import org.onap.policy.models.pdp.concepts.PdpUpdate;
 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.ToscaPolicyTypeIdentifier;
 
 /**
  * Lifecycle State Active Test.
@@ -104,9 +105,9 @@ public class LifecycleStateActivePoliciesTest extends LifecycleStateRunningTest
     public void testUpdatePolicies() throws IOException, CoderException {
         assertEquals(2, fsm.policyTypesMap.size());
         assertNotNull(fsm.getPolicyTypesMap().get(
-                new ToscaPolicyTypeIdentifier("onap.policies.native.drools.Controller", "1.0.0")));
+                new ToscaConceptIdentifier("onap.policies.native.drools.Controller", "1.0.0")));
         assertNotNull(fsm.getPolicyTypesMap().get(
-                new ToscaPolicyTypeIdentifier("onap.policies.native.drools.Artifact", "1.0.0")));
+                new ToscaConceptIdentifier("onap.policies.native.drools.Artifact", "1.0.0")));
 
         //
         // create controller using native policy
@@ -177,11 +178,11 @@ public class LifecycleStateActivePoliciesTest extends LifecycleStateRunningTest
 
         assertEquals(3, fsm.policyTypesMap.size());
         assertNotNull(fsm.getPolicyTypesMap().get(
-                new ToscaPolicyTypeIdentifier("onap.policies.native.drools.Controller", "1.0.0")));
+                new ToscaConceptIdentifier("onap.policies.native.drools.Controller", "1.0.0")));
         assertNotNull(fsm.getPolicyTypesMap().get(
-                new ToscaPolicyTypeIdentifier("onap.policies.native.drools.Artifact", "1.0.0")));
+                new ToscaConceptIdentifier("onap.policies.native.drools.Artifact", "1.0.0")));
         assertNotNull(fsm.getPolicyTypesMap().get(
-                new ToscaPolicyTypeIdentifier("onap.policies.controlloop.operational.common.Drools",
+                new ToscaConceptIdentifier("onap.policies.controlloop.operational.common.Drools",
                         "1.0.0")));
 
         // invalid controller name
index 39a3a93..8a5ea6e 100644 (file)
@@ -1,6 +1,7 @@
 /*
  * ============LICENSE_START=======================================================
  * Copyright (C) 2019-2020 AT&T Intellectual Property. All rights reserved.
+ * Modifications Copyright (C) 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.
@@ -46,8 +47,8 @@ import org.onap.policy.models.pdp.concepts.PdpStateChange;
 import org.onap.policy.models.pdp.concepts.PdpStatus;
 import org.onap.policy.models.pdp.concepts.PdpUpdate;
 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.ToscaPolicyTypeIdentifier;
 
 /**
  * Lifecycle State Active Test.
@@ -215,11 +216,11 @@ public class LifecycleStateActiveTest extends LifecycleStateRunningTest {
         assertEquals(qlength + 1, fsm.client.getSink().getRecentEvents().length);
         assertEquals(3, fsm.policyTypesMap.size());
         assertNotNull(fsm.getPolicyTypesMap().get(
-                new ToscaPolicyTypeIdentifier("onap.policies.native.drools.Controller", "1.0.0")));
+                new ToscaConceptIdentifier("onap.policies.native.drools.Controller", "1.0.0")));
         assertNotNull(fsm.getPolicyTypesMap().get(
-                new ToscaPolicyTypeIdentifier("onap.policies.native.drools.Artifact", "1.0.0")));
+                new ToscaConceptIdentifier("onap.policies.native.drools.Artifact", "1.0.0")));
         assertNotNull(fsm.getPolicyTypesMap().get(
-                new ToscaPolicyTypeIdentifier("onap.policies.controlloop.operational.common.Drools",
+                new ToscaConceptIdentifier("onap.policies.controlloop.operational.common.Drools",
                 "1.0.0")));
         PdpStatus cachedStatus = new StandardCoder()
                                     .decode(fsm.client.getSink().getRecentEvents()[qlength], PdpStatus.class);
index 23c6e20..9547aa4 100644 (file)
@@ -3,6 +3,7 @@
  * ONAP
  * ================================================================================
  * Copyright (C) 2019-2020 AT&T Intellectual Property. All rights reserved.
+ * Modifications Copyright (C) 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.
@@ -43,8 +44,8 @@ import org.onap.policy.models.pdp.concepts.PdpUpdate;
 import org.onap.policy.models.pdp.enums.PdpHealthStatus;
 import org.onap.policy.models.pdp.enums.PdpMessageType;
 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.ToscaPolicyTypeIdentifier;
 
 /**
  * Lifecycle State Passive Tests.
@@ -73,12 +74,12 @@ public class LifecycleStatePassiveTest extends LifecycleStateRunningTest {
         fsm.start(controllerSupport.getController());
         assertSame(controllerSupport.getController(),
             ((PolicyTypeDroolsController) fsm.getController(
-                    new ToscaPolicyTypeIdentifier(
+                    new ToscaConceptIdentifier(
                             ControllerSupport.POLICY_TYPE_COMPLIANT_OP, ControllerSupport.POLICY_TYPE_VERSION)))
                 .controllers().get(0));
 
         fsm.stop(controllerSupport.getController());
-        assertNull(fsm.getController(new ToscaPolicyTypeIdentifier(ControllerSupport.POLICY_TYPE_COMPLIANT_OP,
+        assertNull(fsm.getController(new ToscaConceptIdentifier(ControllerSupport.POLICY_TYPE_COMPLIANT_OP,
                         ControllerSupport.POLICY_TYPE_VERSION)));
 
         fsm.shutdown();
index cd17385..3c8be31 100644 (file)
@@ -3,6 +3,7 @@
  * ONAP
  * ================================================================================
  * Copyright (C) 2020 AT&T Intellectual Property. All rights reserved.
+ * Modifications Copyright (C) 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.
@@ -35,8 +36,8 @@ import org.onap.policy.drools.controller.internal.MavenDroolsController;
 import org.onap.policy.drools.controller.internal.NullDroolsController;
 import org.onap.policy.drools.domain.models.artifact.NativeArtifactPolicy;
 import org.onap.policy.drools.system.PolicyControllerConstants;
+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.ToscaPolicyTypeIdentifier;
 
 /**
  * Rules Controller Test.
@@ -61,7 +62,7 @@ public class PolicyTypeNativeArtifactControllerTest extends LifecycleStateRunnin
         nativePolicy = fsm.getDomainMaker().convertTo(policy, NativeArtifactPolicy.class);
         controller =
                 new PolicyTypeNativeArtifactController(fsm,
-                        new ToscaPolicyTypeIdentifier("onap.policies.native.drools.Artifact", "1.0.0"));
+                        new ToscaConceptIdentifier("onap.policies.native.drools.Artifact", "1.0.0"));
 
         assertTrue(controllerSupport.getController().getDrools().isBrained());
         assertFalse(controllerSupport.getController().isAlive());
@@ -147,4 +148,4 @@ public class PolicyTypeNativeArtifactControllerTest extends LifecycleStateRunnin
         assertTrue(controllerSupport.getController().getDrools() instanceof MavenDroolsController);
     }
 
-}
\ No newline at end of file
+}
index f737766..e9071a2 100644 (file)
@@ -1,6 +1,7 @@
 /*
  * ============LICENSE_START=======================================================
  *  Copyright (C) 2020 AT&T Intellectual Property. All rights reserved.
+ *  Modifications Copyright (C) 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.
@@ -40,8 +41,8 @@ import org.onap.policy.drools.domain.models.artifact.NativeArtifactProperties;
 import org.onap.policy.drools.domain.models.artifact.NativeArtifactRulesArtifact;
 import org.onap.policy.drools.domain.models.controller.ControllerPolicy;
 import org.onap.policy.drools.policies.DomainMaker;
+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.ToscaPolicyTypeIdentifier;
 import org.onap.policy.models.tosca.authorative.concepts.ToscaServiceTemplate;
 
 public class DomainPolicyTypesTest {
@@ -75,8 +76,8 @@ public class DomainPolicyTypesTest {
         ToscaPolicy toscaPolicy =
             getExamplesPolicy(EXAMPLE_NATIVE_DROOLS_POLICY_JSON, EXAMPLE_NATIVE_DROOLS_POLICY_NAME);
 
-        ToscaPolicyTypeIdentifier policyTypeId =
-            new ToscaPolicyTypeIdentifier(NATIVE_DROOLS_POLICY_TYPE, "1.0.0");
+        ToscaConceptIdentifier policyTypeId =
+            new ToscaConceptIdentifier(NATIVE_DROOLS_POLICY_TYPE, "1.0.0");
         domainMaker.isConformant(policyTypeId, rawNativeDroolsPolicy);
 
         assertTrue(domainMaker.isConformant(toscaPolicy));
@@ -116,7 +117,7 @@ public class DomainPolicyTypesTest {
 
         assertTrue(domainMaker
             .isDomainConformant(
-                    new ToscaPolicyTypeIdentifier(domainDroolsPolicy2.getType(), domainDroolsPolicy2.getTypeVersion()),
+                    new ToscaConceptIdentifier(domainDroolsPolicy2.getType(), domainDroolsPolicy2.getTypeVersion()),
                     domainDroolsPolicy2));
     }
 
index 8f37b47..91e8acc 100644 (file)
@@ -3,6 +3,7 @@
  * ONAP
  * ================================================================================
  * Copyright (C) 2020 AT&T Intellectual Property. All rights reserved.
+ * Modifications Copyright (C) 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.
@@ -31,8 +32,8 @@ import org.onap.policy.common.utils.coder.StandardCoder;
 import org.onap.policy.common.utils.resources.ResourceUtils;
 import org.onap.policy.drools.domain.models.Metadata;
 import org.onap.policy.drools.policies.DomainMaker;
+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.ToscaPolicyTypeIdentifier;
 import org.onap.policy.models.tosca.authorative.concepts.ToscaServiceTemplate;
 
 public class OperationalPolicyTest {
@@ -58,8 +59,8 @@ public class OperationalPolicyTest {
         String rawVcpeToscaPolicy = getExamplesPolicyString(VCPE_OPERATIONAL_DROOLS_POLICY_JSON, OP_POLICY_NAME_VCPE);
 
         // valid "known" policy type with implicit schema
-        ToscaPolicyTypeIdentifier operationalCompliantType =
-                new ToscaPolicyTypeIdentifier(OPERATIONAL_DROOLS_POLICY_TYPE, "1.0.0");
+        ToscaConceptIdentifier operationalCompliantType =
+                new ToscaConceptIdentifier(OPERATIONAL_DROOLS_POLICY_TYPE, "1.0.0");
         assertTrue(domainMaker.isConformant(operationalCompliantType, rawVcpeToscaPolicy));
         assertNotNull(domainMaker.convertTo(operationalCompliantType, rawVcpeToscaPolicy, OperationalPolicy.class));
     }
@@ -112,4 +113,4 @@ public class OperationalPolicyTest {
     private String getExamplesPolicyString(String resourcePath, String policyName) throws CoderException {
         return nonValCoder.encode(getExamplesPolicy(resourcePath, policyName));
     }
-}
\ No newline at end of file
+}
index 82cd015..7501aed 100644 (file)
@@ -3,6 +3,7 @@
  * policy-management
  * ================================================================================
  * Copyright (C) 2017-2019 AT&T Intellectual Property. All rights reserved.
+ * Modifications Copyright (C) 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.
@@ -29,7 +30,7 @@ import org.onap.policy.common.endpoints.event.comm.TopicSink;
 import org.onap.policy.common.endpoints.event.comm.TopicSource;
 import org.onap.policy.drools.controller.DroolsController;
 import org.onap.policy.drools.protocol.configuration.DroolsConfiguration;
-import org.onap.policy.models.tosca.authorative.concepts.ToscaPolicyTypeIdentifier;
+import org.onap.policy.models.tosca.authorative.concepts.ToscaConceptIdentifier;
 
 /**
  * A Policy Controller is the higher level unit of control. It corresponds to the ncomp equivalent
@@ -63,7 +64,7 @@ public interface PolicyController extends Startable, Lockable {
     /**
      * Get Policy Types supported by this controller.
      */
-    List<ToscaPolicyTypeIdentifier> getPolicyTypes();
+    List<ToscaConceptIdentifier> getPolicyTypes();
 
     /**
      * Update maven configuration.
index 3f74402..e14b162 100644 (file)
@@ -3,6 +3,7 @@
  * ONAP
  * ================================================================================
  * Copyright (C) 2017-2020 AT&T Intellectual Property. All rights reserved.
+ * Modifications Copyright (C) 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.
@@ -46,7 +47,7 @@ import org.onap.policy.drools.properties.DroolsPropertyConstants;
 import org.onap.policy.drools.protocol.configuration.DroolsConfiguration;
 import org.onap.policy.drools.system.PolicyController;
 import org.onap.policy.drools.utils.PropertyUtil;
-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;
 
@@ -110,7 +111,7 @@ public class AggregatedPolicyController implements PolicyController, TopicListen
     /**
      * Policy Types.
      */
-    private List<ToscaPolicyTypeIdentifier> policyTypes;
+    private List<ToscaConceptIdentifier> policyTypes;
 
     /**
      * Constructor version mainly used for bootstrapping at initialization time a policy engine
@@ -147,7 +148,7 @@ public class AggregatedPolicyController implements PolicyController, TopicListen
     }
 
     @Override
-    public List<ToscaPolicyTypeIdentifier> getPolicyTypes() {
+    public List<ToscaConceptIdentifier> getPolicyTypes() {
         if (!policyTypes.isEmpty()) {
             return policyTypes;
         }
@@ -156,13 +157,13 @@ public class AggregatedPolicyController implements PolicyController, TopicListen
                 .get()
                 .getBaseDomainNames()
                 .stream()
-                .map(d -> new ToscaPolicyTypeIdentifier(d,
+                .map(d -> new ToscaConceptIdentifier(d,
                                 DroolsPropertyConstants.DEFAULT_CONTROLLER_POLICY_TYPE_VERSION))
                 .collect(Collectors.toList());
     }
 
-    protected List<ToscaPolicyTypeIdentifier> getPolicyTypesFromProperties() {
-        List<ToscaPolicyTypeIdentifier> policyTypeIds = new ArrayList<>();
+    protected List<ToscaConceptIdentifier> getPolicyTypesFromProperties() {
+        List<ToscaConceptIdentifier> policyTypeIds = new ArrayList<>();
 
         String ptiPropValue = properties.getProperty(DroolsPropertyConstants.PROPERTY_CONTROLLER_POLICY_TYPES);
         if (ptiPropValue == null) {
@@ -173,10 +174,10 @@ public class AggregatedPolicyController implements PolicyController, TopicListen
         for (String pti : ptiPropList) {
             String[] ptv = pti.split(":");
             if (ptv.length == 1) {
-                policyTypeIds.add(new ToscaPolicyTypeIdentifier(ptv[0],
+                policyTypeIds.add(new ToscaConceptIdentifier(ptv[0],
                     DroolsPropertyConstants.DEFAULT_CONTROLLER_POLICY_TYPE_VERSION));
             } else if (ptv.length == 2) {
-                policyTypeIds.add(new ToscaPolicyTypeIdentifier(ptv[0], ptv[1]));
+                policyTypeIds.add(new ToscaConceptIdentifier(ptv[0], ptv[1]));
             }
         }
 
index 58d5052..ae85d57 100644 (file)
@@ -1,6 +1,7 @@
 /*
  * ============LICENSE_START=======================================================
  *  Copyright (C) 2020 AT&T Intellectual Property. All rights reserved.
+ *  Modifications Copyright (C) 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.
@@ -30,9 +31,9 @@ import org.onap.policy.common.utils.coder.CoderException;
 import org.onap.policy.common.utils.coder.StandardCoder;
 import org.onap.policy.common.utils.coder.StandardValCoder;
 import org.onap.policy.common.utils.resources.ResourceUtils;
+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.ToscaPolicyType;
-import org.onap.policy.models.tosca.authorative.concepts.ToscaPolicyTypeIdentifier;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
@@ -56,7 +57,7 @@ public class DomainMaker {
     /**
      * policy-type -> schema validator map.
      */
-    private final Map<ToscaPolicyTypeIdentifier, StandardValCoder> validators = new ConcurrentHashMap<>();
+    private final Map<ToscaConceptIdentifier, StandardValCoder> validators = new ConcurrentHashMap<>();
 
     /**
      * non-validation serialization coder.
@@ -66,7 +67,7 @@ public class DomainMaker {
     /**
      * Does this json conform to a registered policy type schema?.
      */
-    public boolean isConformant(@NonNull ToscaPolicyTypeIdentifier policyType, @NonNull String json) {
+    public boolean isConformant(@NonNull ToscaConceptIdentifier policyType, @NonNull String json) {
         if (!isRegistered(policyType)) {
             return false;
         }
@@ -89,7 +90,7 @@ public class DomainMaker {
     /**
      * Does this domain policy conforms to its schema definition?.
      */
-    public <T> boolean isDomainConformant(@NonNull ToscaPolicyTypeIdentifier policyType, @NonNull T domainPolicy) {
+    public <T> boolean isDomainConformant(@NonNull ToscaConceptIdentifier policyType, @NonNull T domainPolicy) {
         if (!isRegistered(policyType)) {
             return false;
         }
@@ -134,7 +135,7 @@ public class DomainMaker {
      * Checks a domain policy conformance to its specification providing a list of errors
      * in a ValidationFailedException.
      */
-    public <T> boolean conformance(@NonNull ToscaPolicyTypeIdentifier policyType, T domainPolicy) {
+    public <T> boolean conformance(@NonNull ToscaConceptIdentifier policyType, T domainPolicy) {
 
         if (!isRegistered(policyType)) {
             return false;
@@ -156,7 +157,7 @@ public class DomainMaker {
     /**
      * Registers a known schema resource for validation.
      */
-    public boolean registerValidator(@NonNull ToscaPolicyTypeIdentifier policyType) {
+    public boolean registerValidator(@NonNull ToscaConceptIdentifier policyType) {
         //
         // A known schema is one that embedded in a .jar in the classpath as a resource
         // matching the following syntax: <policy-type-name>-<policy-type-version>.schema.json.
@@ -175,7 +176,7 @@ public class DomainMaker {
     /**
      * Registers/Overrides a new/known schema for a policy type.
      */
-    public boolean registerValidator(@NonNull ToscaPolicyTypeIdentifier policyType, @NonNull String schema) {
+    public boolean registerValidator(@NonNull ToscaConceptIdentifier policyType, @NonNull String schema) {
         try {
             validators.put(policyType, new StandardValCoder(schema, policyType.toString()));
         } catch (RuntimeException r) {
@@ -195,7 +196,7 @@ public class DomainMaker {
     /**
      * Converts a JSON policy into a Domain Policy.
      */
-    public <T> T convertTo(@NonNull ToscaPolicyTypeIdentifier policyType, @NonNull String json, @NonNull Class<T> clazz)
+    public <T> T convertTo(@NonNull ToscaConceptIdentifier policyType, @NonNull String json, @NonNull Class<T> clazz)
             throws CoderException {
         if (isRegistered(policyType)) {
             return validators.get(policyType).decode(json, clazz);
@@ -215,7 +216,7 @@ public class DomainMaker {
         throw new UnsupportedOperationException("schema generation from policy type is not supported");
     }
 
-    public boolean isRegistered(@NonNull ToscaPolicyTypeIdentifier policyType) {
+    public boolean isRegistered(@NonNull ToscaConceptIdentifier policyType) {
         return validators.containsKey(policyType) || registerValidator(policyType);
     }
 
index 5bc767c..2c88330 100644 (file)
@@ -1,6 +1,7 @@
 /*
  * ============LICENSE_START=======================================================
  *  Copyright (C) 2020 AT&T Intellectual Property. All rights reserved.
+ *  Modifications Copyright (C) 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.
@@ -38,9 +39,9 @@ import org.onap.policy.drools.models.domains.a.DomainAPolicy;
 import org.onap.policy.drools.models.domains.a.Metadata;
 import org.onap.policy.drools.models.domains.a.Nested;
 import org.onap.policy.drools.models.domains.a.Properties;
+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.ToscaPolicyType;
-import org.onap.policy.models.tosca.authorative.concepts.ToscaPolicyTypeIdentifier;
 
 public class DomainMakerTest {
 
@@ -53,8 +54,8 @@ public class DomainMakerTest {
 
     @Test
     public void testIsConformantString() throws IOException {
-        ToscaPolicyTypeIdentifier policyTypeId =
-            new ToscaPolicyTypeIdentifier("policy.type.A", "1.0.0");
+        ToscaConceptIdentifier policyTypeId =
+            new ToscaConceptIdentifier("policy.type.A", "1.0.0");
         String rawJsonPolicyType =
             getJsonFromFile("src/test/resources/policyA.json");
 
@@ -75,8 +76,8 @@ public class DomainMakerTest {
 
     @Test
     public void testIsDomainConformant() {
-        ToscaPolicyTypeIdentifier policyTypeId =
-                new ToscaPolicyTypeIdentifier("policy.type.A", "1.0.0");
+        ToscaConceptIdentifier policyTypeId =
+                new ToscaConceptIdentifier("policy.type.A", "1.0.0");
 
         DomainAPolicy domainAPolicy = createDomainPolicy();
 
@@ -108,7 +109,7 @@ public class DomainMakerTest {
         assertDomainPolicy(domainAPolicy);
 
         domainAPolicy.getProperties().getNested().setNested1("");
-        ToscaPolicyTypeIdentifier ident1 = policy1.getTypeIdentifier();
+        ToscaConceptIdentifier ident1 = policy1.getTypeIdentifier();
         assertThatThrownBy(() -> domainMaker.conformance(ident1, domainAPolicy))
                 .isInstanceOf(ValidationFailedException.class)
                 .hasMessageContaining("Pattern ^(.+)$ is not contained in text");
@@ -116,8 +117,8 @@ public class DomainMakerTest {
 
     @Test
     public void testRegisterValidator() throws IOException, CoderException {
-        ToscaPolicyTypeIdentifier policyTypeId =
-                new ToscaPolicyTypeIdentifier("policy.type.external", "9.9.9");
+        ToscaConceptIdentifier policyTypeId =
+                new ToscaConceptIdentifier("policy.type.external", "9.9.9");
 
         assertTrue(domainMaker.registerValidator(policyTypeId,
             getJsonFromFile("src/test/resources/policy.type.external-9.9.9.schema.json")));
@@ -151,12 +152,12 @@ public class DomainMakerTest {
 
     @Test
     public void testIsRegistered() {
-        ToscaPolicyTypeIdentifier policyTypeId1 =
-                new ToscaPolicyTypeIdentifier("policy.type.A", "1.0.0");
+        ToscaConceptIdentifier policyTypeId1 =
+                new ToscaConceptIdentifier("policy.type.A", "1.0.0");
         assertTrue(domainMaker.isRegistered(policyTypeId1));
 
-        ToscaPolicyTypeIdentifier policyTypeId2 =
-                new ToscaPolicyTypeIdentifier("policy.type.external", "7.7.9");
+        ToscaConceptIdentifier policyTypeId2 =
+                new ToscaConceptIdentifier("policy.type.external", "7.7.9");
         assertFalse(domainMaker.isRegistered(policyTypeId2));
 
     }
@@ -191,4 +192,4 @@ public class DomainMakerTest {
         assertEquals(true, domainAPolicy.getProperties().getNested().isNested2());
         assertEquals(50, domainAPolicy.getProperties().getNested().getNested3());
     }
-}
\ No newline at end of file
+}