summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--feature-lifecycle/src/main/feature/config/feature-lifecycle.properties16
-rw-r--r--feature-lifecycle/src/main/java/org/onap/policy/drools/lifecycle/LifecycleFsm.java4
-rw-r--r--feature-lifecycle/src/main/java/org/onap/policy/drools/lifecycle/PolicyTypeDroolsController.java93
-rw-r--r--feature-lifecycle/src/main/java/org/onap/policy/drools/lifecycle/PolicyTypeNativeArtifactController.java (renamed from feature-lifecycle/src/main/java/org/onap/policy/drools/lifecycle/PolicyTypeRulesController.java)16
-rw-r--r--feature-lifecycle/src/main/java/org/onap/policy/drools/lifecycle/PolicyTypeNativeController.java66
-rw-r--r--feature-lifecycle/src/main/java/org/onap/policy/drools/lifecycle/PolicyTypeNativeDroolsController.java250
-rw-r--r--feature-lifecycle/src/test/java/org/onap/policy/drools/domain/models/DroolsPolicyModelsTest.java90
-rw-r--r--feature-lifecycle/src/test/java/org/onap/policy/drools/lifecycle/LifecycleStatePassiveTest.java2
-rw-r--r--feature-lifecycle/src/test/java/org/onap/policy/drools/lifecycle/PolicyTypeDroolsControllerTest.java100
-rw-r--r--feature-lifecycle/src/test/java/org/onap/policy/drools/lifecycle/PolicyTypeNativeArtifactControllerTest.java (renamed from feature-lifecycle/src/test/java/org/onap/policy/drools/lifecycle/PolicyTypeRulesControllerTest.java)16
-rw-r--r--feature-lifecycle/src/test/java/org/onap/policy/drools/lifecycle/PolicyTypeNativeDroolsControllerTest.java (renamed from feature-lifecycle/src/test/java/org/onap/policy/drools/lifecycle/PolicyTypeNativeControllerTest.java)29
-rw-r--r--feature-lifecycle/src/test/resources/tosca-policy-native-artifact-example.json (renamed from feature-lifecycle/src/test/resources/example.policy.native.drools.tosca.json)2
-rw-r--r--feature-lifecycle/src/test/resources/tosca-policy-native-controller-example.json (renamed from feature-lifecycle/src/test/resources/example.policy.drools.controller.tosca.json)14
-rw-r--r--packages/base/src/files/bin/configure-maven4
-rw-r--r--packages/base/src/files/bin/monitor12
-rw-r--r--packages/base/src/files/bin/policy12
-rw-r--r--policy-domains/lombok.config3
-rw-r--r--policy-domains/pom.xml89
-rw-r--r--policy-domains/src/main/java/org/onap/policy/drools/domain/models/DroolsPolicy.java (renamed from policy-management/src/main/java/org/onap/policy/drools/domain/models/DroolsPolicy.java)0
-rw-r--r--policy-domains/src/main/java/org/onap/policy/drools/domain/models/Metadata.java (renamed from policy-management/src/main/java/org/onap/policy/drools/domain/models/Metadata.java)0
-rw-r--r--policy-domains/src/main/java/org/onap/policy/drools/domain/models/artifact/NativeArtifactController.java (renamed from feature-lifecycle/src/main/java/org/onap/policy/drools/domain/models/nativ/rules/NativeDroolsController.java)11
-rw-r--r--policy-domains/src/main/java/org/onap/policy/drools/domain/models/artifact/NativeArtifactPolicy.java (renamed from feature-lifecycle/src/main/java/org/onap/policy/drools/domain/models/nativ/rules/NativeDroolsPolicy.java)8
-rw-r--r--policy-domains/src/main/java/org/onap/policy/drools/domain/models/artifact/NativeArtifactProperties.java (renamed from feature-lifecycle/src/main/java/org/onap/policy/drools/domain/models/nativ/rules/NativeDroolsProperties.java)12
-rw-r--r--policy-domains/src/main/java/org/onap/policy/drools/domain/models/artifact/NativeArtifactRulesArtifact.java (renamed from feature-lifecycle/src/main/java/org/onap/policy/drools/domain/models/nativ/rules/NativeDroolsRulesArtifact.java)16
-rw-r--r--policy-domains/src/main/java/org/onap/policy/drools/domain/models/controller/ControllerCustomSerialization.java (renamed from feature-lifecycle/src/main/java/org/onap/policy/drools/domain/models/controller/ControllerCustomSerializer.java)10
-rw-r--r--policy-domains/src/main/java/org/onap/policy/drools/domain/models/controller/ControllerEvent.java (renamed from feature-lifecycle/src/main/java/org/onap/policy/drools/domain/models/controller/ControllerSerialization.java)16
-rw-r--r--policy-domains/src/main/java/org/onap/policy/drools/domain/models/controller/ControllerPolicy.java (renamed from feature-lifecycle/src/main/java/org/onap/policy/drools/domain/models/controller/ControllerPolicy.java)4
-rw-r--r--policy-domains/src/main/java/org/onap/policy/drools/domain/models/controller/ControllerProperties.java (renamed from feature-lifecycle/src/main/java/org/onap/policy/drools/domain/models/controller/ControllerProperties.java)17
-rw-r--r--policy-domains/src/main/java/org/onap/policy/drools/domain/models/controller/ControllerSinkTopic.java (renamed from feature-lifecycle/src/main/java/org/onap/policy/drools/domain/models/controller/ControllerSinkTopic.java)15
-rw-r--r--policy-domains/src/main/java/org/onap/policy/drools/domain/models/controller/ControllerSourceTopic.java (renamed from feature-lifecycle/src/main/java/org/onap/policy/drools/domain/models/controller/ControllerSourceTopic.java)10
-rw-r--r--policy-domains/src/main/java/org/onap/policy/drools/domain/models/controller/ControllerTopic.java37
-rw-r--r--policy-domains/src/main/java/org/onap/policy/drools/domain/models/legacy/LegacyPolicy.java39
-rw-r--r--policy-domains/src/main/java/org/onap/policy/drools/domain/models/legacy/LegacyProperties.java47
-rw-r--r--policy-domains/src/main/java/org/onap/policy/drools/domain/models/operational/ActorOperation.java59
-rw-r--r--policy-domains/src/main/java/org/onap/policy/drools/domain/models/operational/Operation.java104
-rw-r--r--policy-domains/src/main/java/org/onap/policy/drools/domain/models/operational/OperationalPolicy.java40
-rw-r--r--policy-domains/src/main/java/org/onap/policy/drools/domain/models/operational/OperationalProperties.java69
-rw-r--r--policy-domains/src/main/java/org/onap/policy/drools/domain/models/operational/OperationalTarget.java49
-rw-r--r--policy-domains/src/main/resources/schemas/onap.policies.controlloop.Operational-1.0.0.schema.json (renamed from feature-lifecycle/src/test/resources/schemas/onap.policies.controlloop.Operational-1.0.0.schema.json)9
-rw-r--r--policy-domains/src/main/resources/schemas/onap.policies.controlloop.operational.common.Drools-1.0.0.schema.json (renamed from feature-lifecycle/src/test/resources/schemas/onap.policies.controlloop.operational.common.Drools-1.0.0.schema.json)3
-rw-r--r--policy-domains/src/main/resources/schemas/onap.policies.native.drools.Artifact-1.0.0.schema.json (renamed from feature-lifecycle/src/main/resources/schemas/onap.policies.native.Drools-1.0.0.schema.json)8
-rw-r--r--policy-domains/src/main/resources/schemas/onap.policies.native.drools.Controller-1.0.0.schema.json (renamed from feature-lifecycle/src/main/resources/schemas/onap.policies.drools.Controller-1.0.0.schema.json)85
-rw-r--r--policy-domains/src/test/java/org/onap/policy/drools/domain/models/DomainPolicyTypesTest.java (renamed from feature-lifecycle/src/test/java/org/onap/policy/drools/domain/models/DomainPolicyTypesTest.java)62
-rw-r--r--policy-domains/src/test/java/org/onap/policy/drools/domain/models/DroolsPolicyTest.java (renamed from policy-management/src/test/java/org/onap/policy/drools/domain/models/DroolsPolicyTest.java)20
-rw-r--r--policy-domains/src/test/java/org/onap/policy/drools/domain/models/artifact/ArtifactPolicyTest.java51
-rw-r--r--policy-domains/src/test/java/org/onap/policy/drools/domain/models/controller/ControllerPolicyTest.java48
-rw-r--r--policy-domains/src/test/java/org/onap/policy/drools/domain/models/legacy/LegacyPolicyTest.java64
-rw-r--r--policy-domains/src/test/java/org/onap/policy/drools/domain/models/operational/OperationalPolicyTest.java122
-rw-r--r--policy-domains/src/test/resources/tosca-legacy-vcpe.json10
-rw-r--r--policy-domains/src/test/resources/tosca-policy-native-artifact-example.json29
-rw-r--r--policy-domains/src/test/resources/tosca-policy-native-controller-example.json58
-rw-r--r--policy-domains/src/test/resources/tosca-policy-operational-restart.json9
-rw-r--r--policy-management/pom.xml6
-rw-r--r--policy-management/src/main/java/org/onap/policy/drools/server/restful/RestManager.java4
-rw-r--r--policy-management/src/main/java/org/onap/policy/drools/system/internal/AggregatedPolicyController.java3
-rw-r--r--policy-management/src/main/server-gen/bin/db-migrator6
-rw-r--r--policy-management/src/main/server-gen/bin/deploy-artifact6
-rw-r--r--policy-management/src/main/server-gen/bin/pdpd-configuration8
-rw-r--r--policy-management/src/main/server-gen/bin/policy-management-controller6
-rw-r--r--policy-management/src/main/server-gen/bin/rest-add-controller6
-rw-r--r--policy-management/src/main/server-gen/bin/rest-delete-controller30
-rw-r--r--policy-management/src/main/server-gen/bin/telemetry35
-rw-r--r--pom.xml9
63 files changed, 1634 insertions, 444 deletions
diff --git a/feature-lifecycle/src/main/feature/config/feature-lifecycle.properties b/feature-lifecycle/src/main/feature/config/feature-lifecycle.properties
index 1bb32169..076da1f9 100644
--- a/feature-lifecycle/src/main/feature/config/feature-lifecycle.properties
+++ b/feature-lifecycle/src/main/feature/config/feature-lifecycle.properties
@@ -21,14 +21,14 @@ lifecycle.pdp.group=${envd:POLICY_PDP_PAP_GROUP:defaultGroup}
dmaap.source.topics=POLICY-PDP-PAP
dmaap.sink.topics=POLICY-PDP-PAP
-dmaap.source.topics.POLICY-PDP-PAP.servers=${env:DMAAP_SERVERS}
-dmaap.source.topics.POLICY-PDP-PAP.effectiveTopic=${env:POLICY_PDP_PAP_TOPIC}
-dmaap.source.topics.POLICY-PDP-PAP.apiKey=${env:POLICY_PDP_PAP_API_KEY}
-dmaap.source.topics.POLICY-PDP-PAP.apiSecret=${env:POLICY_PDP_PAP_API_SECRET}
+dmaap.source.topics.POLICY-PDP-PAP.servers=${envd:DMAAP_SERVERS}
+dmaap.source.topics.POLICY-PDP-PAP.effectiveTopic=${envd:POLICY_PDP_PAP_TOPIC}
+dmaap.source.topics.POLICY-PDP-PAP.apiKey=${envd:POLICY_PDP_PAP_API_KEY}
+dmaap.source.topics.POLICY-PDP-PAP.apiSecret=${envd:POLICY_PDP_PAP_API_SECRET}
dmaap.source.topics.POLICY-PDP-PAP.https=true
-dmaap.sink.topics.POLICY-PDP-PAP.servers=${env:DMAAP_SERVERS}
-dmaap.sink.topics.POLICY-PDP-PAP.effectiveTopic=${env:POLICY_PDP_PAP_TOPIC}
-dmaap.sink.topics.POLICY-PDP-PAP.apiKey=${env:POLICY_PDP_PAP_API_KEY}
-dmaap.sink.topics.POLICY-PDP-PAP.apiSecret=${env:POLICY_PDP_PAP_API_SECRET}
+dmaap.sink.topics.POLICY-PDP-PAP.servers=${envd:DMAAP_SERVERS}
+dmaap.sink.topics.POLICY-PDP-PAP.effectiveTopic=${envd:POLICY_PDP_PAP_TOPIC}
+dmaap.sink.topics.POLICY-PDP-PAP.apiKey=${envd:POLICY_PDP_PAP_API_KEY}
+dmaap.sink.topics.POLICY-PDP-PAP.apiSecret=${envd:POLICY_PDP_PAP_API_SECRET}
dmaap.sink.topics.POLICY-PDP-PAP.https=true
diff --git a/feature-lifecycle/src/main/java/org/onap/policy/drools/lifecycle/LifecycleFsm.java b/feature-lifecycle/src/main/java/org/onap/policy/drools/lifecycle/LifecycleFsm.java
index 119ae7aa..a435f02e 100644
--- a/feature-lifecycle/src/main/java/org/onap/policy/drools/lifecycle/LifecycleFsm.java
+++ b/feature-lifecycle/src/main/java/org/onap/policy/drools/lifecycle/LifecycleFsm.java
@@ -132,10 +132,10 @@ public class LifecycleFsm implements Startable {
this.policyTypesMap.put(
POLICY_TYPE_DROOLS_CONTROLLER,
- new PolicyTypeNativeController(this, POLICY_TYPE_DROOLS_CONTROLLER));
+ new PolicyTypeNativeDroolsController(this, POLICY_TYPE_DROOLS_CONTROLLER));
this.policyTypesMap.put(
POLICY_TYPE_DROOLS_NATIVE_RULES,
- new PolicyTypeRulesController(this, POLICY_TYPE_DROOLS_NATIVE_RULES));
+ new PolicyTypeNativeArtifactController(this, POLICY_TYPE_DROOLS_NATIVE_RULES));
}
@JsonIgnore
diff --git a/feature-lifecycle/src/main/java/org/onap/policy/drools/lifecycle/PolicyTypeDroolsController.java b/feature-lifecycle/src/main/java/org/onap/policy/drools/lifecycle/PolicyTypeDroolsController.java
index f5ceafbe..36c52e2b 100644
--- a/feature-lifecycle/src/main/java/org/onap/policy/drools/lifecycle/PolicyTypeDroolsController.java
+++ b/feature-lifecycle/src/main/java/org/onap/policy/drools/lifecycle/PolicyTypeDroolsController.java
@@ -20,23 +20,45 @@
package org.onap.policy.drools.lifecycle;
+import com.fasterxml.jackson.annotation.JsonIgnore;
+import java.util.List;
+import java.util.Map;
+import java.util.concurrent.ConcurrentHashMap;
+import java.util.function.Function;
import lombok.Getter;
-
+import org.apache.commons.lang3.StringUtils;
+import org.onap.policy.common.gson.annotation.GsonJsonIgnore;
+import org.onap.policy.common.utils.coder.CoderException;
+import org.onap.policy.drools.domain.models.legacy.LegacyPolicy;
+import org.onap.policy.drools.domain.models.operational.OperationalPolicy;
import org.onap.policy.drools.system.PolicyController;
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;
/**
* Policy Type Drools Controller that delegates to a corresponding
* PolicyController that supports this policy type.
*/
-@Getter
public class PolicyTypeDroolsController implements PolicyTypeController {
+ protected static final ToscaPolicyTypeIdentifier legacyType =
+ new ToscaPolicyTypeIdentifier("onap.policies.controlloop.Operational", "1.0.0");
+
+ protected static final ToscaPolicyTypeIdentifier compliantType =
+ new ToscaPolicyTypeIdentifier("onap.policies.controlloop.operational.common.Drools", "1.0.0");
+
+ private static final Logger logger = LoggerFactory.getLogger(PolicyTypeController.class);
- protected final PolicyController controller;
+ protected final Map<String, PolicyController> controllers = new ConcurrentHashMap<>();
+
+ @Getter
protected final ToscaPolicyTypeIdentifier policyType;
- protected final LifecycleFsm fsm;
+
+ @GsonJsonIgnore
+ @JsonIgnore
+ protected final transient LifecycleFsm fsm;
/**
* Creates a Policy Type Drools Controller.
@@ -44,17 +66,74 @@ public class PolicyTypeDroolsController implements PolicyTypeController {
public PolicyTypeDroolsController(
LifecycleFsm fsm, ToscaPolicyTypeIdentifier policyType, PolicyController controller) {
this.policyType = policyType;
- this.controller = controller;
+ this.controllers.put(controller.getName(), controller);
this.fsm = fsm;
}
@Override
public boolean deploy(ToscaPolicy policy) {
- return fsm.getDomainMaker().isConformant(policy) && this.controller.offer(policy);
+ return perform(policy, (PolicyController controller) -> controller.offer(policy));
}
@Override
public boolean undeploy(ToscaPolicy policy) {
- return controller.getDrools().delete(policy);
+ return perform(policy, (PolicyController controller) -> controller.getDrools().delete(policy));
+ }
+
+ private boolean perform(ToscaPolicy policy, Function<PolicyController, Boolean> operation) {
+ try {
+ List<PolicyController> selected = selectControllers(policy);
+ boolean success = true;
+ for (PolicyController controller : selected) {
+ try {
+ success = operation.apply(controller) && success;
+ } catch (RuntimeException r) {
+ logger.warn("invalid offer to controller: {}", controller);
+ success = false;
+ }
+ }
+ return success && !selected.isEmpty();
+ } catch (CoderException e) {
+ logger.warn("perform: invalid formatted policy: {}", policy, e);
+ return false;
+ }
+ }
+
+ private List<PolicyController> selectControllers(ToscaPolicy policy) throws CoderException {
+ List<PolicyController> selected;
+ if (legacyType.equals(policyType)) {
+ selected = controllers(
+ fsm.getDomainMaker().convertTo(policy, LegacyPolicy.class)
+ .getProperties()
+ .getControllerName());
+ } else if (compliantType.equals(policyType)) {
+ selected = controllers(
+ fsm.getDomainMaker().convertTo(policy, OperationalPolicy.class)
+ .getProperties()
+ .getControllerName());
+ } else {
+ selected = List.copyOf(controllers.values());
+ }
+ return selected;
+ }
+
+ private List<PolicyController> controllers(String controllerName) {
+ if (StringUtils.isBlank(controllerName)) {
+ /* this policy applies to all controllers */
+ return controllers();
+ }
+
+ if (!this.controllers.containsKey(controllerName)) {
+ return List.of();
+ }
+
+ return List.of(this.controllers.get(controllerName));
+ }
+
+ /**
+ * Get all controllers that support the policy type.
+ */
+ public List<PolicyController> controllers() {
+ return List.copyOf(controllers.values());
}
}
diff --git a/feature-lifecycle/src/main/java/org/onap/policy/drools/lifecycle/PolicyTypeRulesController.java b/feature-lifecycle/src/main/java/org/onap/policy/drools/lifecycle/PolicyTypeNativeArtifactController.java
index 79e2ddb8..31e9059d 100644
--- a/feature-lifecycle/src/main/java/org/onap/policy/drools/lifecycle/PolicyTypeRulesController.java
+++ b/feature-lifecycle/src/main/java/org/onap/policy/drools/lifecycle/PolicyTypeNativeArtifactController.java
@@ -25,7 +25,7 @@ import lombok.Getter;
import org.onap.policy.common.gson.annotation.GsonJsonIgnore;
import org.onap.policy.common.utils.coder.CoderException;
import org.onap.policy.drools.controller.DroolsControllerConstants;
-import org.onap.policy.drools.domain.models.nativ.rules.NativeDroolsPolicy;
+import org.onap.policy.drools.domain.models.artifact.NativeArtifactPolicy;
import org.onap.policy.drools.protocol.configuration.DroolsConfiguration;
import org.onap.policy.drools.system.PolicyController;
import org.onap.policy.drools.system.PolicyControllerConstants;
@@ -34,27 +34,27 @@ import org.onap.policy.models.tosca.authorative.concepts.ToscaPolicyTypeIdentifi
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
-public class PolicyTypeRulesController implements PolicyTypeController {
- private static final Logger logger = LoggerFactory.getLogger(PolicyTypeRulesController.class);
+public class PolicyTypeNativeArtifactController implements PolicyTypeController {
+ private static final Logger logger = LoggerFactory.getLogger(PolicyTypeNativeArtifactController.class);
@Getter
protected final ToscaPolicyTypeIdentifier policyType;
@GsonJsonIgnore
@JsonIgnore
- protected final LifecycleFsm fsm;
+ protected final transient LifecycleFsm fsm;
- public PolicyTypeRulesController(LifecycleFsm fsm, ToscaPolicyTypeIdentifier policyType) {
+ public PolicyTypeNativeArtifactController(LifecycleFsm fsm, ToscaPolicyTypeIdentifier policyType) {
this.policyType = policyType;
this.fsm = fsm;
}
@Override
public boolean deploy(ToscaPolicy policy) {
- NativeDroolsPolicy nativePolicy;
+ NativeArtifactPolicy nativePolicy;
PolicyController controller;
try {
- nativePolicy = fsm.getDomainMaker().convertTo(policy, NativeDroolsPolicy.class);
+ nativePolicy = fsm.getDomainMaker().convertTo(policy, NativeArtifactPolicy.class);
controller =
PolicyControllerConstants.getFactory().get(nativePolicy.getProperties().getController().getName());
} catch (CoderException e) {
@@ -76,7 +76,7 @@ public class PolicyTypeRulesController implements PolicyTypeController {
public boolean undeploy(ToscaPolicy policy) {
PolicyController controller;
try {
- NativeDroolsPolicy nativePolicy = fsm.getDomainMaker().convertTo(policy, NativeDroolsPolicy.class);
+ NativeArtifactPolicy nativePolicy = fsm.getDomainMaker().convertTo(policy, NativeArtifactPolicy.class);
controller =
PolicyControllerConstants.getFactory().get(nativePolicy.getProperties().getController().getName());
} catch (RuntimeException | CoderException e) {
diff --git a/feature-lifecycle/src/main/java/org/onap/policy/drools/lifecycle/PolicyTypeNativeController.java b/feature-lifecycle/src/main/java/org/onap/policy/drools/lifecycle/PolicyTypeNativeController.java
deleted file mode 100644
index 1b5e7c47..00000000
--- a/feature-lifecycle/src/main/java/org/onap/policy/drools/lifecycle/PolicyTypeNativeController.java
+++ /dev/null
@@ -1,66 +0,0 @@
-/*
- * ============LICENSE_START=======================================================
- * ONAP
- * ================================================================================
- * Copyright (C) 2020 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.
- * ============LICENSE_END=========================================================
- */
-
-package org.onap.policy.drools.lifecycle;
-
-import com.fasterxml.jackson.annotation.JsonIgnore;
-import lombok.Getter;
-import org.onap.policy.common.gson.annotation.GsonJsonIgnore;
-import org.onap.policy.common.utils.coder.CoderException;
-import org.onap.policy.drools.domain.models.controller.ControllerPolicy;
-import org.onap.policy.drools.system.PolicyControllerConstants;
-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;
-
-public class PolicyTypeNativeController implements PolicyTypeController {
- private static final Logger logger = LoggerFactory.getLogger(PolicyTypeNativeController.class);
-
- @Getter
- protected final ToscaPolicyTypeIdentifier policyType;
-
- @GsonJsonIgnore
- @JsonIgnore
- protected final LifecycleFsm fsm;
-
- public PolicyTypeNativeController(LifecycleFsm fsm, ToscaPolicyTypeIdentifier policyType) {
- this.policyType = policyType;
- this.fsm = fsm;
- }
-
- @Override
- public boolean deploy(ToscaPolicy policy) {
- // TODO
- return fsm.getDomainMaker().isConformant(policy);
- }
-
- @Override
- public boolean undeploy(ToscaPolicy policy) {
- try {
- ControllerPolicy nativePolicy = fsm.getDomainMaker().convertTo(policy, ControllerPolicy.class);
- PolicyControllerConstants.getFactory().destroy(nativePolicy.getProperties().getControllerName());
- return true;
- } catch (RuntimeException | CoderException e) {
- logger.warn("failed undeploy of policy: {}", policy);
- return false;
- }
- }
-}
diff --git a/feature-lifecycle/src/main/java/org/onap/policy/drools/lifecycle/PolicyTypeNativeDroolsController.java b/feature-lifecycle/src/main/java/org/onap/policy/drools/lifecycle/PolicyTypeNativeDroolsController.java
new file mode 100644
index 00000000..b0118fbe
--- /dev/null
+++ b/feature-lifecycle/src/main/java/org/onap/policy/drools/lifecycle/PolicyTypeNativeDroolsController.java
@@ -0,0 +1,250 @@
+/*
+ * ============LICENSE_START=======================================================
+ * ONAP
+ * ================================================================================
+ * Copyright (C) 2020 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.
+ * ============LICENSE_END=========================================================
+ */
+
+package org.onap.policy.drools.lifecycle;
+
+import com.fasterxml.jackson.annotation.JsonIgnore;
+import java.util.List;
+import java.util.Map;
+import java.util.Properties;
+import java.util.stream.Collectors;
+import lombok.Getter;
+import org.onap.policy.common.endpoints.event.comm.TopicEndpointManager;
+import org.onap.policy.common.endpoints.event.comm.TopicSink;
+import org.onap.policy.common.endpoints.event.comm.TopicSource;
+import org.onap.policy.common.gson.annotation.GsonJsonIgnore;
+import org.onap.policy.common.utils.coder.CoderException;
+import org.onap.policy.drools.domain.models.controller.ControllerCustomSerialization;
+import org.onap.policy.drools.domain.models.controller.ControllerEvent;
+import org.onap.policy.drools.domain.models.controller.ControllerPolicy;
+import org.onap.policy.drools.domain.models.controller.ControllerProperties;
+import org.onap.policy.drools.domain.models.controller.ControllerSinkTopic;
+import org.onap.policy.drools.domain.models.controller.ControllerSourceTopic;
+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.models.tosca.authorative.concepts.ToscaPolicy;
+import org.onap.policy.models.tosca.authorative.concepts.ToscaPolicyTypeIdentifier;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+public class PolicyTypeNativeDroolsController implements PolicyTypeController {
+ private static final Logger logger = LoggerFactory.getLogger(PolicyTypeNativeDroolsController.class);
+
+ @Getter
+ protected final ToscaPolicyTypeIdentifier policyType;
+
+ @GsonJsonIgnore
+ @JsonIgnore
+ protected final transient LifecycleFsm fsm;
+
+ public PolicyTypeNativeDroolsController(LifecycleFsm fsm, ToscaPolicyTypeIdentifier policyType) {
+ this.policyType = policyType;
+ this.fsm = fsm;
+ }
+
+ @Override
+ public boolean deploy(ToscaPolicy policy) {
+ Properties controllerProps = new Properties();
+ ControllerPolicy controllerPolicy = toDomainPolicy(policy);
+ if (controllerPolicy == null) {
+ return false;
+ }
+
+ ControllerProperties controllerConfig = controllerPolicy.getProperties();
+
+ boolean success =
+ configControllerName(controllerConfig, controllerProps)
+ && configControllerSources(controllerConfig, controllerProps)
+ && configControllerSinks(controllerConfig, controllerProps)
+ && configControllerCustom(controllerConfig, controllerProps);
+
+ if (!success) {
+ return false;
+ }
+
+ PolicyController controller;
+ try {
+ controller =
+ PolicyControllerConstants.getFactory().build(
+ controllerConfig.getControllerName(), controllerProps);
+ } catch (RuntimeException e) {
+ logger.warn("failed deploy (cannot create controller) for policy: {}", policy);
+ return false;
+ }
+
+ return controller != null;
+ }
+
+ @Override
+ public boolean undeploy(ToscaPolicy policy) {
+ try {
+ ControllerPolicy nativePolicy = fsm.getDomainMaker().convertTo(policy, ControllerPolicy.class);
+ PolicyControllerConstants.getFactory()
+ .destroy(nativePolicy.getProperties().getControllerName());
+ return true;
+ } catch (RuntimeException | CoderException e) {
+ logger.warn("failed undeploy of policy: {}", policy);
+ return false;
+ }
+ }
+
+ private ControllerPolicy toDomainPolicy(ToscaPolicy policy) {
+ ControllerPolicy nativePolicy = null;
+ try {
+ nativePolicy = fsm.getDomainMaker().convertTo(policy, ControllerPolicy.class);
+ ControllerProperties config = nativePolicy.getProperties();
+
+ /* check for duplicates */
+
+ if (isDups(sourceTopics(config.getSourceTopics()))
+ || isDups(sinkTopics(config.getSinkTopics()))) {
+ logger.warn("there are duplicated topics in policy {}", policy);
+ return null;
+ }
+
+ /* check for non-existance of the controller - throws IAE if there's not */
+
+ PolicyControllerConstants.getFactory().get(nativePolicy.getProperties().getControllerName());
+
+ } catch (CoderException e) {
+ logger.warn("failed deploy of policy (invalid): {}", policy);
+ return null;
+ } catch (IllegalArgumentException e) {
+ // this is OK
+ logger.trace("proceeding with the deploy of native controller policy: {}", policy);
+ }
+
+ return nativePolicy;
+ }
+
+ private boolean configControllerName(ControllerProperties controllerConfig, Properties controllerProps) {
+ controllerProps
+ .setProperty(DroolsPropertyConstants.PROPERTY_CONTROLLER_NAME, controllerConfig.getControllerName());
+ return true;
+ }
+
+ private boolean configControllerSources(ControllerProperties controllerConfig, Properties controllerProps) {
+ for (ControllerSourceTopic configSourceTopic : controllerConfig.getSourceTopics()) {
+ List<TopicSource> sources =
+ TopicEndpointManager.getManager().getTopicSources(List.of(configSourceTopic.getTopicName()));
+ if (sources.size() != 1) {
+ logger.warn("Topic {} is not present or ambigous {}", configSourceTopic.getTopicName(), sources);
+ return false;
+ }
+
+ configSourceTopic(sources.get(0), configSourceTopic, controllerProps);
+ }
+ return true;
+ }
+
+ private void configSourceTopic(TopicSource topic, ControllerSourceTopic configTopic, Properties controllerProps) {
+ String configCommPrefix = topic.getTopicCommInfrastructure().name().toLowerCase() + ".source";
+ configTopic(configCommPrefix, topic.getTopic(), configTopic.getEvents(), controllerProps);
+ }
+
+ private boolean configControllerSinks(ControllerProperties controllerConfig, Properties controllerProps) {
+ for (ControllerSinkTopic configSinkTopic : controllerConfig.getSinkTopics()) {
+ List<TopicSink> sinks =
+ TopicEndpointManager.getManager().getTopicSinks(List.of(configSinkTopic.getTopicName()));
+ if (sinks.size() != 1) {
+ logger.warn("Topic {} is not present or ambigous {}", configSinkTopic.getTopicName(), sinks);
+ return false;
+ }
+
+ configSinkTopic(sinks.get(0), configSinkTopic, controllerProps);
+ }
+ return true;
+ }
+
+ private void configSinkTopic(TopicSink topic, ControllerSinkTopic configTopic, Properties controllerProps) {
+ String configCommPrefix = topic.getTopicCommInfrastructure().name().toLowerCase() + ".sink";
+ configTopic(configCommPrefix, topic.getTopic(), configTopic.getEvents(), controllerProps);
+ }
+
+ private void configTopic(
+ String configCommPrefix, String topicName, List<ControllerEvent> events, Properties controllerProps) {
+ String configTopicPrefix = configCommPrefix + "." + topicName;
+ configTopics(configCommPrefix, topicName, controllerProps);
+ for (ControllerEvent configEvent : events) {
+ configEvent(configTopicPrefix, configEvent, controllerProps);
+ }
+ }
+
+ private void configTopics(String propPrefix, String topicName, Properties controllerProps) {
+ String topicsPropKey = propPrefix + ".topics";
+ configTopicItemList(topicsPropKey, topicName, controllerProps);
+ }
+
+ private void configEvent(String propPrefix, ControllerEvent configEvent, Properties controllerProps) {
+ String eventPropPrefix = propPrefix + ".events";
+ controllerProps.setProperty(eventPropPrefix, configEvent.getEventClass());
+ if (configEvent.getEventFilter() != null) {
+ controllerProps.setProperty(
+ eventPropPrefix + "." + configEvent.getEventClass() + ".filter", configEvent.getEventFilter());
+ }
+ if (configEvent.getCustomSerialization() != null) {
+ configSerialization(eventPropPrefix, configEvent.getCustomSerialization(), controllerProps);
+ }
+ configTopicItemList(eventPropPrefix, configEvent.getEventClass(), controllerProps);
+ }
+
+ private void configTopicItemList(String itemPrefix, String item, Properties controllerProps) {
+ if (controllerProps.getProperty(itemPrefix) == null) {
+ controllerProps.setProperty(itemPrefix, item);
+ } else {
+ controllerProps.setProperty(itemPrefix, "," + item);
+ }
+ }
+
+ private void configSerialization(
+ String propPrefix, ControllerCustomSerialization configCustom, Properties controllerProps) {
+ String customPropPrefix = propPrefix + ".custom.gson";
+ controllerProps.setProperty(
+ customPropPrefix, configCustom.getCustomSerializerClass() + "," + configCustom.getJsonParser());
+ }
+
+ private boolean configControllerCustom(ControllerProperties controllerConfig, Properties controllerProps) {
+ Map<String, String> configCustom = controllerConfig.getCustomConfig();
+ if (configCustom == null || configCustom.isEmpty()) {
+ return true;
+ }
+
+ controllerProps.putAll(configCustom);
+ return true;
+ }
+
+ private <T> boolean isDups(List<T> items) {
+ return items.size() != items.stream().distinct().count();
+ }
+
+ private List<String> sourceTopics(List<ControllerSourceTopic> sourceTopics) {
+ return sourceTopics.stream()
+ .map(ControllerSourceTopic::getTopicName)
+ .collect(Collectors.toList());
+ }
+
+ private List<String> sinkTopics(List<ControllerSinkTopic> sourceTopics) {
+ return sourceTopics.stream()
+ .map(ControllerSinkTopic::getTopicName)
+ .collect(Collectors.toList());
+ }
+
+}
diff --git a/feature-lifecycle/src/test/java/org/onap/policy/drools/domain/models/DroolsPolicyModelsTest.java b/feature-lifecycle/src/test/java/org/onap/policy/drools/domain/models/DroolsPolicyModelsTest.java
deleted file mode 100644
index d99dd089..00000000
--- a/feature-lifecycle/src/test/java/org/onap/policy/drools/domain/models/DroolsPolicyModelsTest.java
+++ /dev/null
@@ -1,90 +0,0 @@
-/*
- * ============LICENSE_START=======================================================
- * Copyright (C) 2020 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.drools.domain.models;
-
-import static org.junit.Assert.assertNotNull;
-
-import com.openpojo.reflection.PojoClass;
-import com.openpojo.reflection.filters.FilterChain;
-import com.openpojo.reflection.filters.FilterClassName;
-import com.openpojo.reflection.filters.FilterNonConcrete;
-import com.openpojo.reflection.impl.PojoClassFactory;
-import com.openpojo.validation.Validator;
-import com.openpojo.validation.ValidatorBuilder;
-import com.openpojo.validation.test.impl.GetterTester;
-import com.openpojo.validation.test.impl.SetterTester;
-import java.util.ArrayList;
-import java.util.List;
-import org.junit.Test;
-import org.onap.policy.drools.domain.models.controller.ControllerPolicy;
-import org.onap.policy.drools.domain.models.controller.ControllerProperties;
-import org.onap.policy.drools.domain.models.nativ.rules.NativeDroolsController;
-import org.onap.policy.drools.domain.models.nativ.rules.NativeDroolsPolicy;
-import org.onap.policy.drools.domain.models.nativ.rules.NativeDroolsProperties;
-import org.onap.policy.drools.domain.models.nativ.rules.NativeDroolsRulesArtifact;
-
-public class DroolsPolicyModelsTest {
-
- @Test
- public void testPackage() {
- /* validate model pojos */
- List<PojoClass> pojoClasses =
- PojoClassFactory
- .getPojoClassesRecursively("org.onap.policy.drools.domain.models",
- new FilterChain(new FilterNonConcrete(),
- new FilterClassName(DroolsPolicy.class.getName())));
-
- Validator validator = ValidatorBuilder.create()
- .with(new SetterTester(), new GetterTester()).build();
- validator.validate(pojoClasses);
- }
-
- @Test
- public void testBuildDomainPolicyNativeDrools() {
- /* manually create a native drools policy */
- assertNotNull(NativeDroolsPolicy.builder().metadata(Metadata.builder().policyId("policy-id").build())
- .name("example")
- .type("onap.policies.native.Drools")
- .typeVersion("1.0.0")
- .version("1.0.0")
- .properties(
- NativeDroolsProperties.builder().controller(
- NativeDroolsController.builder().name("example").version("1.0.0").build())
- .rulesArtifact(
- NativeDroolsRulesArtifact.builder().groupId("org.onap.policy.controlloop")
- .artifactId("example").version("example").build()).build())
- .build());
- }
-
- @Test
- public void testBuildDomainPolicyController() {
- /* manually create a controller policy */
- assertNotNull(ControllerPolicy.builder().metadata(Metadata.builder().policyId("policy-id").build())
- .name("example")
- .version("1.0.0")
- .type("onap.policies.drools.Controller")
- .typeVersion("1.0.0")
- .properties(ControllerProperties.builder().controllerName("example").sourceTopics(
- new ArrayList<>()).sinkTopics(new ArrayList<>()).build())
- .build());
- }
-
-} \ No newline at end of file
diff --git a/feature-lifecycle/src/test/java/org/onap/policy/drools/lifecycle/LifecycleStatePassiveTest.java b/feature-lifecycle/src/test/java/org/onap/policy/drools/lifecycle/LifecycleStatePassiveTest.java
index b42e0fb6..219aa0fb 100644
--- a/feature-lifecycle/src/test/java/org/onap/policy/drools/lifecycle/LifecycleStatePassiveTest.java
+++ b/feature-lifecycle/src/test/java/org/onap/policy/drools/lifecycle/LifecycleStatePassiveTest.java
@@ -77,7 +77,7 @@ public class LifecycleStatePassiveTest extends LifecycleStateRunningTest {
((PolicyTypeDroolsController) fsm.getController(
new ToscaPolicyTypeIdentifier(
ControllerSupport.POLICY_TYPE, ControllerSupport.POLICY_TYPE_VERSION)))
- .getController());
+ .controllers().get(0));
fsm.stop(controllerSupport.getController());
assertNull(fsm.getController(new ToscaPolicyTypeIdentifier(ControllerSupport.POLICY_TYPE,
diff --git a/feature-lifecycle/src/test/java/org/onap/policy/drools/lifecycle/PolicyTypeDroolsControllerTest.java b/feature-lifecycle/src/test/java/org/onap/policy/drools/lifecycle/PolicyTypeDroolsControllerTest.java
new file mode 100644
index 00000000..a56e250b
--- /dev/null
+++ b/feature-lifecycle/src/test/java/org/onap/policy/drools/lifecycle/PolicyTypeDroolsControllerTest.java
@@ -0,0 +1,100 @@
+/*
+ * ============LICENSE_START=======================================================
+ * Copyright (C) 2020 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.drools.lifecycle;
+
+import static org.junit.Assert.assertFalse;
+import static org.junit.Assert.assertSame;
+import static org.junit.Assert.assertTrue;
+
+import org.junit.Before;
+import org.junit.Test;
+import org.onap.policy.common.utils.coder.CoderException;
+import org.onap.policy.common.utils.coder.StandardCoder;
+import org.onap.policy.common.utils.resources.ResourceUtils;
+import org.onap.policy.drools.domain.models.operational.OperationalPolicy;
+import org.onap.policy.drools.system.PolicyControllerConstants;
+import org.onap.policy.models.tosca.authorative.concepts.ToscaPolicy;
+import org.onap.policy.models.tosca.authorative.concepts.ToscaServiceTemplate;
+
+/**
+ * Drools Controller Policy Test.
+ */
+public class PolicyTypeDroolsControllerTest extends LifecycleStateRunningTest {
+
+ // Operational vCPE Policies
+ private static final String OP_POLICY_NAME_VCPE = "operational.restart";
+ private static final String VCPE_OPERATIONAL_DROOLS_POLICY_JSON =
+ "policies/vCPE.policy.operational.input.tosca.json";
+
+ private ToscaPolicy policy;
+ private OperationalPolicy operationalPolicy;
+ private PolicyTypeDroolsController controller;
+
+ /**
+ * Test initialization.
+ */
+ @Before
+ public void init() throws CoderException {
+ fsm = makeFsmWithPseudoTime();
+ policy = getExamplesPolicy(VCPE_OPERATIONAL_DROOLS_POLICY_JSON, OP_POLICY_NAME_VCPE);
+ operationalPolicy = fsm.getDomainMaker().convertTo(policy, OperationalPolicy.class);
+ controller = new PolicyTypeDroolsController(
+ fsm, PolicyTypeDroolsController.compliantType, controllerSupport.getController());
+
+ assertTrue(controllerSupport.getController().getDrools().isBrained());
+ assertFalse(controllerSupport.getController().isAlive());
+ assertFalse(controllerSupport.getController().getDrools().isAlive());
+ assertSame(controllerSupport.getController(), PolicyControllerConstants.getFactory().get("lifecycle"));
+
+ /* start controller */
+ assertTrue(controllerSupport.getController().start());
+
+ assertTrue(controllerSupport.getController().isAlive());
+ assertTrue(controllerSupport.getController().getDrools().isAlive());
+ assertTrue(controllerSupport.getController().getDrools().isBrained());
+ assertSame(controllerSupport.getController(), PolicyControllerConstants.getFactory().get("lifecycle"));
+ }
+
+ @Test
+ public void testDeployUndeploy() {
+ /* non-existing controller */
+ assertFalse(controller.undeploy(policy));
+ assertFalse(controller.deploy(policy));
+
+ policy.getProperties().remove("controllerName");
+ assertTrue(controller.deploy(policy));
+ assertTrue(controller.undeploy(policy));
+ assertFalse(controller.undeploy(policy));
+
+ /* existing controller */
+ policy.getProperties().put("controllerName", "lifecycle");
+ assertTrue(controller.deploy(policy));
+ assertTrue(controller.undeploy(policy));
+ assertFalse(controller.undeploy(policy));
+ }
+
+ private ToscaPolicy getExamplesPolicy(String resourcePath, String policyName) throws CoderException {
+ String policyJson = ResourceUtils.getResourceAsString(resourcePath);
+ ToscaServiceTemplate serviceTemplate = new StandardCoder().decode(policyJson, ToscaServiceTemplate.class);
+ return serviceTemplate.getToscaTopologyTemplate().getPolicies().get(0).get(policyName);
+ }
+
+} \ No newline at end of file
diff --git a/feature-lifecycle/src/test/java/org/onap/policy/drools/lifecycle/PolicyTypeRulesControllerTest.java b/feature-lifecycle/src/test/java/org/onap/policy/drools/lifecycle/PolicyTypeNativeArtifactControllerTest.java
index 369284dc..cb55e637 100644
--- a/feature-lifecycle/src/test/java/org/onap/policy/drools/lifecycle/PolicyTypeRulesControllerTest.java
+++ b/feature-lifecycle/src/test/java/org/onap/policy/drools/lifecycle/PolicyTypeNativeArtifactControllerTest.java
@@ -33,7 +33,7 @@ import org.onap.policy.common.utils.coder.CoderException;
import org.onap.policy.drools.controller.DroolsControllerConstants;
import org.onap.policy.drools.controller.internal.MavenDroolsController;
import org.onap.policy.drools.controller.internal.NullDroolsController;
-import org.onap.policy.drools.domain.models.nativ.rules.NativeDroolsPolicy;
+import org.onap.policy.drools.domain.models.artifact.NativeArtifactPolicy;
import org.onap.policy.drools.system.PolicyControllerConstants;
import org.onap.policy.models.tosca.authorative.concepts.ToscaPolicy;
import org.onap.policy.models.tosca.authorative.concepts.ToscaPolicyTypeIdentifier;
@@ -41,15 +41,15 @@ import org.onap.policy.models.tosca.authorative.concepts.ToscaPolicyTypeIdentifi
/**
* Rules Controller Test.
*/
-public class PolicyTypeRulesControllerTest extends LifecycleStateRunningTest {
+public class PolicyTypeNativeArtifactControllerTest extends LifecycleStateRunningTest {
// Native Drools Policy
private static final String EXAMPLE_NATIVE_DROOLS_POLICY_NAME = "example";
private static final String EXAMPLE_NATIVE_DROOLS_POLICY_JSON =
- "src/test/resources/example.policy.native.drools.tosca.json";
+ "src/test/resources/tosca-policy-native-artifact-example.json";
private ToscaPolicy policy;
- private NativeDroolsPolicy nativePolicy;
- private PolicyTypeRulesController controller;
+ private NativeArtifactPolicy nativePolicy;
+ private PolicyTypeNativeArtifactController controller;
/**
* Test Set initialization.
@@ -58,10 +58,10 @@ public class PolicyTypeRulesControllerTest extends LifecycleStateRunningTest {
public void init() throws IOException, CoderException {
fsm = makeFsmWithPseudoTime();
policy = getPolicyFromFile(EXAMPLE_NATIVE_DROOLS_POLICY_JSON, EXAMPLE_NATIVE_DROOLS_POLICY_NAME);
- nativePolicy = fsm.getDomainMaker().convertTo(policy, NativeDroolsPolicy.class);
+ nativePolicy = fsm.getDomainMaker().convertTo(policy, NativeArtifactPolicy.class);
controller =
- new PolicyTypeRulesController(fsm,
- new ToscaPolicyTypeIdentifier("onap.policies.native.Drools", "1.0.0"));
+ new PolicyTypeNativeArtifactController(fsm,
+ new ToscaPolicyTypeIdentifier("onap.policies.native.drools.Artifact", "1.0.0"));
assertTrue(controllerSupport.getController().getDrools().isBrained());
assertFalse(controllerSupport.getController().isAlive());
diff --git a/feature-lifecycle/src/test/java/org/onap/policy/drools/lifecycle/PolicyTypeNativeControllerTest.java b/feature-lifecycle/src/test/java/org/onap/policy/drools/lifecycle/PolicyTypeNativeDroolsControllerTest.java
index 528fa7ef..1aa3a684 100644
--- a/feature-lifecycle/src/test/java/org/onap/policy/drools/lifecycle/PolicyTypeNativeControllerTest.java
+++ b/feature-lifecycle/src/test/java/org/onap/policy/drools/lifecycle/PolicyTypeNativeDroolsControllerTest.java
@@ -1,6 +1,6 @@
/*
* ============LICENSE_START=======================================================
- * Copyright (C) 2019-2020 AT&T Intellectual Property. All rights reserved.
+ * Copyright (C) 2020 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.
@@ -26,26 +26,28 @@ import static org.junit.Assert.assertSame;
import static org.junit.Assert.assertTrue;
import java.io.IOException;
+import java.util.Properties;
import org.junit.Before;
import org.junit.Test;
+import org.onap.policy.common.endpoints.event.comm.TopicEndpointManager;
+import org.onap.policy.common.endpoints.properties.PolicyEndPointProperties;
import org.onap.policy.common.utils.coder.CoderException;
import org.onap.policy.drools.domain.models.controller.ControllerPolicy;
import org.onap.policy.drools.system.PolicyControllerConstants;
import org.onap.policy.models.tosca.authorative.concepts.ToscaPolicy;
-import org.onap.policy.models.tosca.authorative.concepts.ToscaPolicyTypeIdentifier;
/**
* Native Controller Policy Test.
*/
-public class PolicyTypeNativeControllerTest extends LifecycleStateRunningTest {
+public class PolicyTypeNativeDroolsControllerTest extends LifecycleStateRunningTest {
// Native Drools Policy
private static final String EXAMPLE_NATIVE_DROOLS_POLICY_NAME = "example";
private static final String EXAMPLE_NATIVE_DROOLS_POLICY_JSON =
- "src/test/resources/example.policy.drools.controller.tosca.json";
+ "src/test/resources/tosca-policy-native-controller-example.json";
private ToscaPolicy policy;
private ControllerPolicy controllerPolicy;
- private PolicyTypeNativeController controller;
+ private PolicyTypeNativeDroolsController controller;
/**
* Test initialization.
@@ -55,9 +57,7 @@ public class PolicyTypeNativeControllerTest extends LifecycleStateRunningTest {
fsm = makeFsmWithPseudoTime();
policy = getPolicyFromFile(EXAMPLE_NATIVE_DROOLS_POLICY_JSON, EXAMPLE_NATIVE_DROOLS_POLICY_NAME);
controllerPolicy = fsm.getDomainMaker().convertTo(policy, ControllerPolicy.class);
- controller =
- new PolicyTypeNativeController(fsm,
- new ToscaPolicyTypeIdentifier("onap.policies.drools.Controller", "1.0.0"));
+ controller = new PolicyTypeNativeDroolsController(fsm, policy.getTypeIdentifier());
assertTrue(controllerSupport.getController().getDrools().isBrained());
assertFalse(controllerSupport.getController().isAlive());
@@ -74,9 +74,20 @@ public class PolicyTypeNativeControllerTest extends LifecycleStateRunningTest {
}
@Test
- public void testUndeploy() {
+ public void testUndeployDeploy() {
assertTrue(controller.undeploy(policy));
assertThatIllegalArgumentException().isThrownBy(
() -> PolicyControllerConstants.getFactory().get(controllerPolicy.getName()));
+
+ assertFalse(controller.deploy(policy));
+
+ Properties noopTopicProperties = new Properties();
+ noopTopicProperties.put(PolicyEndPointProperties.PROPERTY_NOOP_SOURCE_TOPICS, "DCAE_TOPIC");
+ noopTopicProperties.put(PolicyEndPointProperties.PROPERTY_NOOP_SINK_TOPICS, "APPC-CL");
+ TopicEndpointManager.getManager().addTopics(noopTopicProperties);
+
+ controller.deploy(policy);
+
+ return;
}
} \ No newline at end of file
diff --git a/feature-lifecycle/src/test/resources/example.policy.native.drools.tosca.json b/feature-lifecycle/src/test/resources/tosca-policy-native-artifact-example.json
index f3f34b6f..f521953d 100644
--- a/feature-lifecycle/src/test/resources/example.policy.native.drools.tosca.json
+++ b/feature-lifecycle/src/test/resources/tosca-policy-native-artifact-example.json
@@ -4,7 +4,7 @@
"policies": [
{
"example": {
- "type": "onap.policies.native.Drools",
+ "type": "onap.policies.native.drools.Artifact",
"type_version": "1.0.0",
"version": "1.0.0",
"name": "example",
diff --git a/feature-lifecycle/src/test/resources/example.policy.drools.controller.tosca.json b/feature-lifecycle/src/test/resources/tosca-policy-native-controller-example.json
index f5a9151f..3d716845 100644
--- a/feature-lifecycle/src/test/resources/example.policy.drools.controller.tosca.json
+++ b/feature-lifecycle/src/test/resources/tosca-policy-native-controller-example.json
@@ -4,7 +4,7 @@
"policies": [
{
"example": {
- "type": "onap.policies.drools.Controller",
+ "type": "onap.policies.native.drools.Controller",
"type_version": "1.0.0",
"version": "1.0.0",
"name": "example",
@@ -16,14 +16,18 @@
"sourceTopics": [
{
"topicName": "DCAE_TOPIC",
- "serialization": [
+ "events": [
{
"eventClass": "org.onap.policy.controlloop.CanonicalOnset",
"eventFilter": "[?($.closedLoopEventStatus == 'ONSET')]",
- "customSerializer": {
+ "customSerialization": {
"customSerializerClass": "org.onap.policy.controlloop.util.Serialization",
"jsonParser": "gson"
}
+ },
+ {
+ "eventClass": "org.onap.policy.controlloop.CanonicalAbated",
+ "eventFilter": "[?($.closedLoopEventStatus == 'ABATED')]"
}
]
}
@@ -31,11 +35,11 @@
"sinkTopics": [
{
"topicName": "APPC-CL",
- "serialization": [
+ "events": [
{
"eventClass": "org.onap.policy.appc.Response",
"eventFilter": "[?($.CommonHeader && $.Status)]",
- "customSerializer": {
+ "customSerialization": {
"customSerializerClass": "org.onap.policy.appc.util.Serialization",
"jsonParser": "gsonPretty"
}
diff --git a/packages/base/src/files/bin/configure-maven b/packages/base/src/files/bin/configure-maven
index fc6a7f9c..7da5f6a4 100644
--- a/packages/base/src/files/bin/configure-maven
+++ b/packages/base/src/files/bin/configure-maven
@@ -3,7 +3,7 @@
# ============LICENSE_START=======================================================
# ONAP
# ================================================================================
-# Copyright (C) 2019 AT&T Intellectual Property. All rights reserved.
+# Copyright (C) 2019-2020 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.
@@ -18,6 +18,8 @@
# limitations under the License.
# ============LICENSE_END=========================================================
+source ${POLICY_HOME}/etc/profile.d/env.sh
+
if [[ ${DEBUG} == y ]]; then
set -x
fi
diff --git a/packages/base/src/files/bin/monitor b/packages/base/src/files/bin/monitor
index 1137628a..6d40f7e2 100644
--- a/packages/base/src/files/bin/monitor
+++ b/packages/base/src/files/bin/monitor
@@ -1,24 +1,24 @@
#!/bin/bash
-###
# ============LICENSE_START=======================================================
-# Base Package
+# ONAP
# ================================================================================
-# Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.
+# Copyright (C) 2017-2020 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.
# ============LICENSE_END=========================================================
-###
+
+source ${POLICY_HOME}/etc/profile.d/env.sh
function usage() {
echo -n "syntax: $(basename $0) "
diff --git a/packages/base/src/files/bin/policy b/packages/base/src/files/bin/policy
index d5fabdec..b02ac3d9 100644
--- a/packages/base/src/files/bin/policy
+++ b/packages/base/src/files/bin/policy
@@ -1,24 +1,24 @@
#!/bin/bash
-###
# ============LICENSE_START=======================================================
-# Base Package
+# ONAP
# ================================================================================
-# Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.
+# Copyright (C) 2017-2020 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.
# ============LICENSE_END=========================================================
-###
+
+source ${POLICY_HOME}/etc/profile.d/env.sh
function usage() {
echo -n "syntax: $(basename $0) "
diff --git a/policy-domains/lombok.config b/policy-domains/lombok.config
new file mode 100644
index 00000000..2384843f
--- /dev/null
+++ b/policy-domains/lombok.config
@@ -0,0 +1,3 @@
+config.stopBubbling = true
+lombok.addLombokGeneratedAnnotation = true
+lombok.nonNull.exceptionType = IllegalArgumentException
diff --git a/policy-domains/pom.xml b/policy-domains/pom.xml
new file mode 100644
index 00000000..c28d5b29
--- /dev/null
+++ b/policy-domains/pom.xml
@@ -0,0 +1,89 @@
+<!--
+ ============LICENSE_START=======================================================
+ ONAP
+ ================================================================================
+ Copyright (C) 2020 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.
+ ============LICENSE_END=========================================================
+ -->
+
+<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
+ <modelVersion>4.0.0</modelVersion>
+
+ <parent>
+ <groupId>org.onap.policy.drools-pdp</groupId>
+ <artifactId>drools-pdp</artifactId>
+ <version>1.6.0-SNAPSHOT</version>
+ </parent>
+
+ <artifactId>policy-domains</artifactId>
+
+ <name>policy-domains</name>
+ <description>domain policies</description>
+
+ <dependencies>
+
+ <dependency>
+ <groupId>org.projectlombok</groupId>
+ <artifactId>lombok</artifactId>
+ <scope>provided</scope>
+ </dependency>
+
+ <dependency>
+ <groupId>junit</groupId>
+ <artifactId>junit</artifactId>
+ <scope>test</scope>
+ </dependency>
+
+ <dependency>
+ <groupId>org.assertj</groupId>
+ <artifactId>assertj-core</artifactId>
+ <scope>test</scope>
+ </dependency>
+
+ <dependency>
+ <groupId>org.powermock</groupId>
+ <artifactId>powermock-api-mockito2</artifactId>
+ <scope>test</scope>
+ </dependency>
+
+ <dependency>
+ <groupId>com.google.code.gson</groupId>
+ <artifactId>gson</artifactId>
+ </dependency>
+
+ <dependency>
+ <groupId>com.openpojo</groupId>
+ <artifactId>openpojo</artifactId>
+ <scope>test</scope>
+ </dependency>
+
+ <dependency>
+ <groupId>org.onap.policy.common</groupId>
+ <artifactId>utils</artifactId>
+ <version>1.6.2-SNAPSHOT</version>
+ <scope>test</scope>
+ </dependency>
+
+ <dependency>
+ <groupId>org.onap.policy.drools-pdp</groupId>
+ <artifactId>policy-utils</artifactId>
+ <version>1.6.0-SNAPSHOT</version>
+ <scope>test</scope>
+ </dependency>
+
+ </dependencies>
+
+</project>
diff --git a/policy-management/src/main/java/org/onap/policy/drools/domain/models/DroolsPolicy.java b/policy-domains/src/main/java/org/onap/policy/drools/domain/models/DroolsPolicy.java
index 4b1a1cbd..4b1a1cbd 100644
--- a/policy-management/src/main/java/org/onap/policy/drools/domain/models/DroolsPolicy.java
+++ b/policy-domains/src/main/java/org/onap/policy/drools/domain/models/DroolsPolicy.java
diff --git a/policy-management/src/main/java/org/onap/policy/drools/domain/models/Metadata.java b/policy-domains/src/main/java/org/onap/policy/drools/domain/models/Metadata.java
index fd68e5b5..fd68e5b5 100644
--- a/policy-management/src/main/java/org/onap/policy/drools/domain/models/Metadata.java
+++ b/policy-domains/src/main/java/org/onap/policy/drools/domain/models/Metadata.java
diff --git a/feature-lifecycle/src/main/java/org/onap/policy/drools/domain/models/nativ/rules/NativeDroolsController.java b/policy-domains/src/main/java/org/onap/policy/drools/domain/models/artifact/NativeArtifactController.java
index 0af96331..c5d29b02 100644
--- a/feature-lifecycle/src/main/java/org/onap/policy/drools/domain/models/nativ/rules/NativeDroolsController.java
+++ b/policy-domains/src/main/java/org/onap/policy/drools/domain/models/artifact/NativeArtifactController.java
@@ -18,9 +18,8 @@
* ============LICENSE_END=========================================================
*/
-package org.onap.policy.drools.domain.models.nativ.rules;
+package org.onap.policy.drools.domain.models.artifact;
-import com.google.gson.annotations.SerializedName;
import java.io.Serializable;
import lombok.Builder;
import lombok.Data;
@@ -31,13 +30,9 @@ import lombok.Data;
@Data
@Builder
-public class NativeDroolsController implements Serializable {
+public class NativeArtifactController implements Serializable {
private static final long serialVersionUID = -2070515139072136869L;
- @SerializedName("name")
- protected String name;
-
- @SerializedName("version")
- protected String version;
+ private String name;
}
diff --git a/feature-lifecycle/src/main/java/org/onap/policy/drools/domain/models/nativ/rules/NativeDroolsPolicy.java b/policy-domains/src/main/java/org/onap/policy/drools/domain/models/artifact/NativeArtifactPolicy.java
index fce6ca1a..0f53b532 100644
--- a/feature-lifecycle/src/main/java/org/onap/policy/drools/domain/models/nativ/rules/NativeDroolsPolicy.java
+++ b/policy-domains/src/main/java/org/onap/policy/drools/domain/models/artifact/NativeArtifactPolicy.java
@@ -18,9 +18,8 @@
* ============LICENSE_END=========================================================
*/
-package org.onap.policy.drools.domain.models.nativ.rules;
+package org.onap.policy.drools.domain.models.artifact;
-import com.google.gson.annotations.SerializedName;
import java.io.Serializable;
import lombok.Data;
import lombok.experimental.SuperBuilder;
@@ -32,10 +31,9 @@ import org.onap.policy.drools.domain.models.DroolsPolicy;
@Data
@SuperBuilder
-public class NativeDroolsPolicy extends DroolsPolicy implements Serializable {
+public class NativeArtifactPolicy extends DroolsPolicy implements Serializable {
private static final long serialVersionUID = -8171337852833516581L;
- @SerializedName("properties")
- protected NativeDroolsProperties properties;
+ private NativeArtifactProperties properties;
}
diff --git a/feature-lifecycle/src/main/java/org/onap/policy/drools/domain/models/nativ/rules/NativeDroolsProperties.java b/policy-domains/src/main/java/org/onap/policy/drools/domain/models/artifact/NativeArtifactProperties.java
index dfd25ca7..e5ab1561 100644
--- a/feature-lifecycle/src/main/java/org/onap/policy/drools/domain/models/nativ/rules/NativeDroolsProperties.java
+++ b/policy-domains/src/main/java/org/onap/policy/drools/domain/models/artifact/NativeArtifactProperties.java
@@ -18,9 +18,8 @@
* ============LICENSE_END=========================================================
*/
-package org.onap.policy.drools.domain.models.nativ.rules;
+package org.onap.policy.drools.domain.models.artifact;
-import com.google.gson.annotations.SerializedName;
import java.io.Serializable;
import lombok.Builder;
import lombok.Data;
@@ -31,12 +30,9 @@ import lombok.Data;
@Data
@Builder
-public class NativeDroolsProperties implements Serializable {
+public class NativeArtifactProperties implements Serializable {
private static final long serialVersionUID = 2360030332628276427L;
- @SerializedName("rulesArtifact")
- protected NativeDroolsRulesArtifact rulesArtifact;
-
- @SerializedName("controller")
- protected NativeDroolsController controller;
+ private NativeArtifactRulesArtifact rulesArtifact;
+ private NativeArtifactController controller;
}
diff --git a/feature-lifecycle/src/main/java/org/onap/policy/drools/domain/models/nativ/rules/NativeDroolsRulesArtifact.java b/policy-domains/src/main/java/org/onap/policy/drools/domain/models/artifact/NativeArtifactRulesArtifact.java
index 8ca33865..c93c2609 100644
--- a/feature-lifecycle/src/main/java/org/onap/policy/drools/domain/models/nativ/rules/NativeDroolsRulesArtifact.java
+++ b/policy-domains/src/main/java/org/onap/policy/drools/domain/models/artifact/NativeArtifactRulesArtifact.java
@@ -18,9 +18,8 @@
* ============LICENSE_END=========================================================
*/
-package org.onap.policy.drools.domain.models.nativ.rules;
+package org.onap.policy.drools.domain.models.artifact;
-import com.google.gson.annotations.SerializedName;
import java.io.Serializable;
import lombok.Builder;
import lombok.Data;
@@ -31,16 +30,11 @@ import lombok.Data;
@Data
@Builder
-public class NativeDroolsRulesArtifact implements Serializable {
+public class NativeArtifactRulesArtifact implements Serializable {
private static final long serialVersionUID = -3519759514319217518L;
- @SerializedName("groupId")
- protected String groupId;
-
- @SerializedName("artifactId")
- protected String artifactId;
-
- @SerializedName("version")
- protected String version;
+ private String groupId;
+ private String artifactId;
+ private String version;
}
diff --git a/feature-lifecycle/src/main/java/org/onap/policy/drools/domain/models/controller/ControllerCustomSerializer.java b/policy-domains/src/main/java/org/onap/policy/drools/domain/models/controller/ControllerCustomSerialization.java
index d7956b41..4977f9a1 100644
--- a/feature-lifecycle/src/main/java/org/onap/policy/drools/domain/models/controller/ControllerCustomSerializer.java
+++ b/policy-domains/src/main/java/org/onap/policy/drools/domain/models/controller/ControllerCustomSerialization.java
@@ -20,7 +20,6 @@
package org.onap.policy.drools.domain.models.controller;
-import com.google.gson.annotations.SerializedName;
import java.io.Serializable;
import lombok.Builder;
import lombok.Data;
@@ -28,12 +27,9 @@ import lombok.Data;
@Data
@Builder
-public class ControllerCustomSerializer implements Serializable {
+public class ControllerCustomSerialization implements Serializable {
private static final long serialVersionUID = 1505345574249332514L;
- @SerializedName("customSerializerClass")
- protected String customSerializerClass;
-
- @SerializedName("jsonParser")
- protected String jsonParser;
+ private String customSerializerClass;
+ private String jsonParser;
}
diff --git a/feature-lifecycle/src/main/java/org/onap/policy/drools/domain/models/controller/ControllerSerialization.java b/policy-domains/src/main/java/org/onap/policy/drools/domain/models/controller/ControllerEvent.java
index 8daaa31f..d6817a4a 100644
--- a/feature-lifecycle/src/main/java/org/onap/policy/drools/domain/models/controller/ControllerSerialization.java
+++ b/policy-domains/src/main/java/org/onap/policy/drools/domain/models/controller/ControllerEvent.java
@@ -20,7 +20,6 @@
package org.onap.policy.drools.domain.models.controller;
-import com.google.gson.annotations.SerializedName;
import java.io.Serializable;
import lombok.Builder;
import lombok.Data;
@@ -28,15 +27,10 @@ import lombok.Data;
@Data
@Builder
-public class ControllerSerialization implements Serializable {
-
- @SerializedName("eventClass")
- public String eventClass;
-
- @SerializedName("eventFilter")
- public String eventFilter;
-
- @SerializedName("customSerializer")
- public ControllerCustomSerializer customSerializer;
+public class ControllerEvent implements Serializable {
+ private static final long serialVersionUID = 8770353732981476267L;
+ private String eventClass;
+ private String eventFilter;
+ private ControllerCustomSerialization customSerialization;
}
diff --git a/feature-lifecycle/src/main/java/org/onap/policy/drools/domain/models/controller/ControllerPolicy.java b/policy-domains/src/main/java/org/onap/policy/drools/domain/models/controller/ControllerPolicy.java
index 0d5a363e..09236c84 100644
--- a/feature-lifecycle/src/main/java/org/onap/policy/drools/domain/models/controller/ControllerPolicy.java
+++ b/policy-domains/src/main/java/org/onap/policy/drools/domain/models/controller/ControllerPolicy.java
@@ -20,7 +20,6 @@
package org.onap.policy.drools.domain.models.controller;
-import com.google.gson.annotations.SerializedName;
import java.io.Serializable;
import lombok.Data;
import lombok.experimental.SuperBuilder;
@@ -36,6 +35,5 @@ public class ControllerPolicy extends DroolsPolicy implements Serializable {
private static final long serialVersionUID = -8171337852833516581L;
- @SerializedName("properties")
- protected ControllerProperties properties;
+ private ControllerProperties properties;
}
diff --git a/feature-lifecycle/src/main/java/org/onap/policy/drools/domain/models/controller/ControllerProperties.java b/policy-domains/src/main/java/org/onap/policy/drools/domain/models/controller/ControllerProperties.java
index 692b1790..780c20dc 100644
--- a/feature-lifecycle/src/main/java/org/onap/policy/drools/domain/models/controller/ControllerProperties.java
+++ b/policy-domains/src/main/java/org/onap/policy/drools/domain/models/controller/ControllerProperties.java
@@ -20,7 +20,6 @@
package org.onap.policy.drools.domain.models.controller;
-import com.google.gson.annotations.SerializedName;
import java.io.Serializable;
import java.util.List;
import java.util.Map;
@@ -37,16 +36,8 @@ import lombok.Data;
public class ControllerProperties implements Serializable {
private static final long serialVersionUID = 1259434187110418986L;
- @SerializedName("controllerName")
- protected String controllerName;
-
- @SerializedName("sourceTopics")
- protected List<ControllerSourceTopic> sourceTopics;
-
- @SerializedName("sinkTopics")
- protected List<ControllerSinkTopic> sinkTopics;
-
- @SerializedName("customConfig")
- protected Map<String, String> customConfig;
-
+ private String controllerName;
+ private List<ControllerSourceTopic> sourceTopics;
+ private List<ControllerSinkTopic> sinkTopics;
+ private Map<String, String> customConfig;
}
diff --git a/feature-lifecycle/src/main/java/org/onap/policy/drools/domain/models/controller/ControllerSinkTopic.java b/policy-domains/src/main/java/org/onap/policy/drools/domain/models/controller/ControllerSinkTopic.java
index ecd66a3f..87af6c36 100644
--- a/feature-lifecycle/src/main/java/org/onap/policy/drools/domain/models/controller/ControllerSinkTopic.java
+++ b/policy-domains/src/main/java/org/onap/policy/drools/domain/models/controller/ControllerSinkTopic.java
@@ -20,11 +20,9 @@
package org.onap.policy.drools.domain.models.controller;
-import com.google.gson.annotations.SerializedName;
import java.io.Serializable;
-import java.util.List;
-import lombok.Builder;
import lombok.Data;
+import lombok.experimental.SuperBuilder;
/**
@@ -32,14 +30,7 @@ import lombok.Data;
*/
@Data
-@Builder
-public class ControllerSinkTopic implements Serializable {
+@SuperBuilder
+public class ControllerSinkTopic extends ControllerTopic implements Serializable {
private static final long serialVersionUID = 8770353732981476267L;
-
- @SerializedName("topicName")
- protected String topicName;
-
- @SerializedName("serialization")
- protected List<ControllerSerialization> serialization;
-
}
diff --git a/feature-lifecycle/src/main/java/org/onap/policy/drools/domain/models/controller/ControllerSourceTopic.java b/policy-domains/src/main/java/org/onap/policy/drools/domain/models/controller/ControllerSourceTopic.java
index 09344016..e41f4dc3 100644
--- a/feature-lifecycle/src/main/java/org/onap/policy/drools/domain/models/controller/ControllerSourceTopic.java
+++ b/policy-domains/src/main/java/org/onap/policy/drools/domain/models/controller/ControllerSourceTopic.java
@@ -21,9 +21,8 @@
package org.onap.policy.drools.domain.models.controller;
import java.io.Serializable;
-import java.util.List;
-import lombok.Builder;
import lombok.Data;
+import lombok.experimental.SuperBuilder;
/**
@@ -31,10 +30,7 @@ import lombok.Data;
*/
@Data
-@Builder
-public class ControllerSourceTopic implements Serializable {
+@SuperBuilder
+public class ControllerSourceTopic extends ControllerTopic implements Serializable {
private static final long serialVersionUID = -1732598566914643612L;
-
- protected String topicName;
- protected List<ControllerSerialization> serialization;
}
diff --git a/policy-domains/src/main/java/org/onap/policy/drools/domain/models/controller/ControllerTopic.java b/policy-domains/src/main/java/org/onap/policy/drools/domain/models/controller/ControllerTopic.java
new file mode 100644
index 00000000..2954350d
--- /dev/null
+++ b/policy-domains/src/main/java/org/onap/policy/drools/domain/models/controller/ControllerTopic.java
@@ -0,0 +1,37 @@
+/*
+ * ============LICENSE_START=======================================================
+ * Copyright (C) 2020 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.drools.domain.models.controller;
+
+import java.util.List;
+import lombok.Data;
+import lombok.experimental.SuperBuilder;
+
+
+/**
+ * Source Topics.
+ */
+
+@Data
+@SuperBuilder
+public abstract class ControllerTopic {
+ protected String topicName;
+ protected List<ControllerEvent> events;
+}
diff --git a/policy-domains/src/main/java/org/onap/policy/drools/domain/models/legacy/LegacyPolicy.java b/policy-domains/src/main/java/org/onap/policy/drools/domain/models/legacy/LegacyPolicy.java
new file mode 100644
index 00000000..f4fcb702
--- /dev/null
+++ b/policy-domains/src/main/java/org/onap/policy/drools/domain/models/legacy/LegacyPolicy.java
@@ -0,0 +1,39 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * ONAP
+ * ================================================================================
+ * Copyright (C) 2020 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.
+ * ============LICENSE_END=========================================================
+ */
+
+package org.onap.policy.drools.domain.models.legacy;
+
+import java.io.Serializable;
+import lombok.Data;
+import lombok.experimental.SuperBuilder;
+import org.onap.policy.drools.domain.models.DroolsPolicy;
+
+
+/**
+ * Operational Domain Policy.
+ */
+
+@Data
+@SuperBuilder
+public class LegacyPolicy extends DroolsPolicy implements Serializable {
+ private static final long serialVersionUID = 4100092564657497713L;
+
+ private LegacyProperties properties;
+}
diff --git a/policy-domains/src/main/java/org/onap/policy/drools/domain/models/legacy/LegacyProperties.java b/policy-domains/src/main/java/org/onap/policy/drools/domain/models/legacy/LegacyProperties.java
new file mode 100644
index 00000000..b74d9a6c
--- /dev/null
+++ b/policy-domains/src/main/java/org/onap/policy/drools/domain/models/legacy/LegacyProperties.java
@@ -0,0 +1,47 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * ONAP
+ * ================================================================================
+ * Copyright (C) 2020 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.
+ * ============LICENSE_END=========================================================
+ */
+
+package org.onap.policy.drools.domain.models.legacy;
+
+import java.io.Serializable;
+import lombok.Builder;
+import lombok.Data;
+
+
+/**
+ * Legacy Operational Policy Properties.
+ */
+
+@Data
+@Builder
+public class LegacyProperties implements Serializable {
+ private static final long serialVersionUID = 2455300363502597721L;
+
+ /**
+ * Content (Operational Policy URL encoded yaml).
+ */
+ private String content;
+
+ /**
+ * Controller Name (optional) to select an specific controller among many that
+ * support a policy type.
+ */
+ private String controllerName;
+}
diff --git a/policy-domains/src/main/java/org/onap/policy/drools/domain/models/operational/ActorOperation.java b/policy-domains/src/main/java/org/onap/policy/drools/domain/models/operational/ActorOperation.java
new file mode 100644
index 00000000..af39f792
--- /dev/null
+++ b/policy-domains/src/main/java/org/onap/policy/drools/domain/models/operational/ActorOperation.java
@@ -0,0 +1,59 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * ONAP
+ * ================================================================================
+ * Copyright (C) 2020 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.
+ * ============LICENSE_END=========================================================
+ */
+
+package org.onap.policy.drools.domain.models.operational;
+
+import java.io.Serializable;
+import java.util.HashMap;
+import java.util.Map;
+import lombok.Builder;
+import lombok.Data;
+
+
+/**
+ * Actor Operation.
+ */
+
+@Data
+@Builder
+public class ActorOperation implements Serializable {
+ private static final long serialVersionUID = -534488831693359530L;
+
+ /**
+ * Actor.
+ */
+ private String actor;
+
+ /**
+ * Operation Name.
+ */
+ private String operation;
+
+ /**
+ * Target.
+ */
+ private OperationalTarget target;
+
+ /**
+ * Payload.
+ */
+ @Builder.Default
+ private Map<String, String> payload = new HashMap<>();
+}
diff --git a/policy-domains/src/main/java/org/onap/policy/drools/domain/models/operational/Operation.java b/policy-domains/src/main/java/org/onap/policy/drools/domain/models/operational/Operation.java
new file mode 100644
index 00000000..b996c825
--- /dev/null
+++ b/policy-domains/src/main/java/org/onap/policy/drools/domain/models/operational/Operation.java
@@ -0,0 +1,104 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * ONAP
+ * ================================================================================
+ * Copyright (C) 2020 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.
+ * ============LICENSE_END=========================================================
+ */
+
+package org.onap.policy.drools.domain.models.operational;
+
+import com.google.gson.annotations.SerializedName;
+import java.io.Serializable;
+import lombok.Builder;
+import lombok.Data;
+
+/**
+ * Policy Operation.
+ */
+
+@Data
+@Builder
+public class Operation implements Serializable {
+ private static final long serialVersionUID = 6175229119078195110L;
+
+ /**
+ * Operation Identifier.
+ */
+ private String id;
+
+ /**
+ * Description.
+ */
+ private String description;
+
+ /**
+ * Actor Operation.
+ */
+ @SerializedName("operation")
+ private ActorOperation actorOperation;
+
+ /**
+ * Operation Timeout in seconds.
+ */
+ @Builder.Default
+ private int timeout = 10;
+
+ /**
+ * Number of Retries.
+ */
+ @Builder.Default
+ private int retries = 0;
+
+ /**
+ * Success Treatment.
+ */
+ @Builder.Default
+ private String success = "final_success";
+
+ /**
+ * Failure Treatment.
+ */
+ @Builder.Default
+ private String failure = "final_failure";
+
+ /**
+ * Failure Timeout Treatment.
+ */
+ @SerializedName("failure_timeout")
+ @Builder.Default
+ private String failureTimeout = "final_failure_timeout";
+
+ /**
+ * Failure Retry Treatment.
+ */
+ @SerializedName("failure_retries")
+ @Builder.Default
+ private String failureRetries = "final_failure_retries";
+
+ /**
+ * Failure Exception Treatment.
+ */
+ @SerializedName("failure_exception")
+ @Builder.Default
+ private String failureException = "final_failure_exception";
+
+ /**
+ * Failure Guard Treatment.
+ */
+ @SerializedName("failure_guard")
+ @Builder.Default
+ private String failureGuard = "final_failure_guard";
+}
diff --git a/policy-domains/src/main/java/org/onap/policy/drools/domain/models/operational/OperationalPolicy.java b/policy-domains/src/main/java/org/onap/policy/drools/domain/models/operational/OperationalPolicy.java
new file mode 100644
index 00000000..d158608b
--- /dev/null
+++ b/policy-domains/src/main/java/org/onap/policy/drools/domain/models/operational/OperationalPolicy.java
@@ -0,0 +1,40 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * ONAP
+ * ================================================================================
+ * Copyright (C) 2020 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.
+ * ============LICENSE_END=========================================================
+ */
+
+package org.onap.policy.drools.domain.models.operational;
+
+import java.io.Serializable;
+import lombok.Data;
+import lombok.experimental.SuperBuilder;
+import org.onap.policy.drools.domain.models.DroolsPolicy;
+
+
+/**
+ * Operational Domain Policy.
+ */
+
+@Data
+@SuperBuilder
+public class OperationalPolicy extends DroolsPolicy implements Serializable {
+ private static final long serialVersionUID = 4100092564657497713L;
+
+ private OperationalProperties properties;
+
+}
diff --git a/policy-domains/src/main/java/org/onap/policy/drools/domain/models/operational/OperationalProperties.java b/policy-domains/src/main/java/org/onap/policy/drools/domain/models/operational/OperationalProperties.java
new file mode 100644
index 00000000..993ba024
--- /dev/null
+++ b/policy-domains/src/main/java/org/onap/policy/drools/domain/models/operational/OperationalProperties.java
@@ -0,0 +1,69 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * ONAP
+ * ================================================================================
+ * Copyright (C) 2020 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.
+ * ============LICENSE_END=========================================================
+ */
+
+package org.onap.policy.drools.domain.models.operational;
+
+import java.io.Serializable;
+import java.util.ArrayList;
+import java.util.List;
+import lombok.Builder;
+import lombok.Data;
+
+
+/**
+ * Operational Policy Properties.
+ */
+
+@Data
+@Builder
+public class OperationalProperties implements Serializable {
+ private static final long serialVersionUID = 2455300363502597721L;
+
+ /**
+ * Control Loop Name.
+ */
+ private String id;
+
+ /**
+ * Timeout in seconds.
+ */
+ private int timeout = 30;
+
+ /**
+ * Abatement.
+ */
+ private boolean abatement = false;
+
+ /**
+ * Trigger Operation.
+ */
+ private String trigger;
+
+ /**
+ * Operations.
+ */
+ @Builder.Default
+ private List<Operation> operations = new ArrayList<>();
+
+ /**
+ * Controller Name.
+ */
+ private String controllerName;
+}
diff --git a/policy-domains/src/main/java/org/onap/policy/drools/domain/models/operational/OperationalTarget.java b/policy-domains/src/main/java/org/onap/policy/drools/domain/models/operational/OperationalTarget.java
new file mode 100644
index 00000000..34f405ee
--- /dev/null
+++ b/policy-domains/src/main/java/org/onap/policy/drools/domain/models/operational/OperationalTarget.java
@@ -0,0 +1,49 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * ONAP
+ * ================================================================================
+ * Copyright (C) 2020 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.
+ * ============LICENSE_END=========================================================
+ */
+
+package org.onap.policy.drools.domain.models.operational;
+
+import java.io.Serializable;
+import java.util.HashMap;
+import java.util.Map;
+import lombok.Builder;
+import lombok.Data;
+
+
+/**
+ * Operational Target.
+ */
+
+@Data
+@Builder
+public class OperationalTarget implements Serializable {
+ private static final long serialVersionUID = -3557887855401250181L;
+
+ /**
+ * Target Type.
+ */
+ private String targetType;
+
+ /**
+ * Payload.
+ */
+ @Builder.Default
+ private Map<String, String> entityIds = new HashMap<>();
+}
diff --git a/feature-lifecycle/src/test/resources/schemas/onap.policies.controlloop.Operational-1.0.0.schema.json b/policy-domains/src/main/resources/schemas/onap.policies.controlloop.Operational-1.0.0.schema.json
index 801859be..820bdd70 100644
--- a/feature-lifecycle/src/test/resources/schemas/onap.policies.controlloop.Operational-1.0.0.schema.json
+++ b/policy-domains/src/main/resources/schemas/onap.policies.controlloop.Operational-1.0.0.schema.json
@@ -84,6 +84,15 @@
"controlLoop%3A%0A%20%20version%3A%202.0.0%0A%20%20controlLoopName%3A%20ControlLoop-vCPEv2-48f0c2c3-a172-4192-9ae3-052274181b6e%0A%20%20trigger_policy%3A%20unique-policy-id-1-restart%0A%20%20timeout%3A%203600%0A%20%20abatement%3A%20true%0A%20%0Apolicies%3A%0A%20%20-%20id%3A%20unique-policy-id-1-restart%0A%20%20%20%20name%3A%20Restart%20the%20VM%0A%20%20%20%20description%3A%0A%20%20%20%20actor%3A%20APPC%0A%20%20%20%20recipe%3A%20Restart%0A%20%20%20%20target%3A%0A%20%20%20%20%20%20type%3A%20VM%0A%20%20%20%20retry%3A%203%0A%20%20%20%20timeout%3A%201200%0A%20%20%20%20success%3A%20final_success%0A%20%20%20%20failure%3A%20final_failure%0A%20%20%20%20failure_timeout%3A%20final_failure_timeout%0A%20%20%20%20failure_retries%3A%20final_failure_retries%0A%20%20%20%20failure_exception%3A%20final_failure_exception%0A%20%20%20%20failure_guard%3A%20final_failure_guard"
],
"pattern": "^(.+)$"
+ },
+ "controllerName": {
+ "$id": "#/properties/properties/properties/controllerName",
+ "type": "string",
+ "title": "Controller Name",
+ "examples": [
+ "usecases"
+ ],
+ "pattern": "^(.+)$"
}
}
}
diff --git a/feature-lifecycle/src/test/resources/schemas/onap.policies.controlloop.operational.common.Drools-1.0.0.schema.json b/policy-domains/src/main/resources/schemas/onap.policies.controlloop.operational.common.Drools-1.0.0.schema.json
index 5d032f06..a7dbf8b0 100644
--- a/feature-lifecycle/src/test/resources/schemas/onap.policies.controlloop.operational.common.Drools-1.0.0.schema.json
+++ b/policy-domains/src/main/resources/schemas/onap.policies.controlloop.operational.common.Drools-1.0.0.schema.json
@@ -80,8 +80,7 @@
"timeout",
"abatement",
"trigger",
- "operations",
- "controllerName"
+ "operations"
],
"properties": {
"id": {
diff --git a/feature-lifecycle/src/main/resources/schemas/onap.policies.native.Drools-1.0.0.schema.json b/policy-domains/src/main/resources/schemas/onap.policies.native.drools.Artifact-1.0.0.schema.json
index 8742768b..add06c07 100644
--- a/feature-lifecycle/src/main/resources/schemas/onap.policies.native.Drools-1.0.0.schema.json
+++ b/policy-domains/src/main/resources/schemas/onap.policies.native.drools.Artifact-1.0.0.schema.json
@@ -1,9 +1,9 @@
{
"definitions": {},
"$schema": "http://json-schema.org/draft-07/schema#",
- "$id": "http://www.onap.org/policy/models/schemas/onap.policies.controlloop.native.Drools.schema.json",
+ "$id": "http://www.onap.org/policy/models/schemas/onap.policies.native.drools.Artifact.schema.json",
"type": "object",
- "title": "Domain onap.policies.controlloop.native.Drools Policy root schema",
+ "title": "Domain onap.policies.native.drools.Artifact Policy root schema",
"required": [
"type",
"type_version",
@@ -16,9 +16,9 @@
"$id": "#/properties/type",
"type": "string",
"title": "Policy Type",
- "default": "onap.policies.native.Drools",
+ "default": "onap.policies.native.drools.Artifact",
"examples": [
- "onap.policies.native.Drools"
+ "onap.policies.native.drools.Artifact"
],
"pattern": "^(.+)$"
},
diff --git a/feature-lifecycle/src/main/resources/schemas/onap.policies.drools.Controller-1.0.0.schema.json b/policy-domains/src/main/resources/schemas/onap.policies.native.drools.Controller-1.0.0.schema.json
index d638e3b9..41fbf4e9 100644
--- a/feature-lifecycle/src/main/resources/schemas/onap.policies.drools.Controller-1.0.0.schema.json
+++ b/policy-domains/src/main/resources/schemas/onap.policies.native.drools.Controller-1.0.0.schema.json
@@ -1,9 +1,9 @@
{
"definitions": {},
"$schema": "http://json-schema.org/draft-07/schema#",
- "$id": "http://www.onap.org/policy/models/schemas/onap.policies.drools.Controller.schema.json",
+ "$id": "http://www.onap.org/policy/models/schemas/onap.policies.native.drools.Controller.schema.json",
"type": "object",
- "title": "Domain onap.policies.drools.Controller Policy root schema",
+ "title": "Domain onap.policies.native.drools.Controller Policy root schema",
"required": [
"type",
"type_version",
@@ -16,9 +16,9 @@
"$id": "#/properties/type",
"type": "string",
"title": "Policy Type",
- "default": "onap.policies.native.Drools",
+ "default": "onap.policies.native.drools.Controller",
"examples": [
- "onap.policies.native.Drools"
+ "onap.policies.native.drools.Controller"
],
"pattern": "^(.+)$"
},
@@ -92,10 +92,10 @@
"items": {
"$id": "#/properties/properties/properties/sourceTopics/items",
"type": "object",
- "title": "Topic Data",
+ "title": "Topic Sources",
"required": [
"topicName",
- "serialization"
+ "events"
],
"properties": {
"topicName": {
@@ -107,22 +107,20 @@
],
"pattern": "^(.+)$"
},
- "serialization": {
- "$id": "#/properties/properties/properties/sourceTopics/items/properties/serialization",
+ "events": {
+ "$id": "#/properties/properties/properties/sourceTopics/items/properties/events",
"type": "array",
- "title": "Serialization",
+ "title": "Source Events",
"items": {
- "$id": "#/properties/properties/properties/sourceTopics/items/properties/serialization/items",
+ "$id": "#/properties/properties/properties/sourceTopics/items/properties/events/items",
"type": "object",
- "title": "Serialization Data",
+ "title": "Event Information",
"required": [
- "eventClass",
- "eventFilter",
- "customSerializer"
+ "eventClass"
],
"properties": {
"eventClass": {
- "$id": "#/properties/properties/properties/sourceTopics/items/properties/serialization/items/properties/eventClass",
+ "$id": "#/properties/properties/properties/sourceTopics/items/properties/events/items/properties/eventClass",
"type": "string",
"title": "Event Class",
"examples": [
@@ -131,7 +129,7 @@
"pattern": "^(.+)$"
},
"eventFilter": {
- "$id": "#/properties/properties/properties/sourceTopics/items/properties/serialization/items/properties/eventFilter",
+ "$id": "#/properties/properties/properties/sourceTopics/items/properties/events/items/properties/eventFilter",
"type": "string",
"title": "Event Filter",
"examples": [
@@ -139,28 +137,28 @@
],
"pattern": "^(.+)$"
},
- "customSerializer": {
- "$id": "#/properties/properties/properties/sourceTopics/items/properties/serialization/items/properties/customSerializer",
+ "customSerialization": {
+ "$id": "#/properties/properties/properties/sourceTopics/items/properties/events/items/properties/customSerialization",
"type": "object",
- "title": "Custom Serializer",
+ "title": "Custom Serialization",
"required": [
"customSerializerClass",
"jsonParser"
],
"properties": {
"customSerializerClass": {
- "$id": "#/properties/properties/properties/sourceTopics/items/properties/serialization/items/properties/customSerializer/properties/customSerializerClass",
+ "$id": "#/properties/properties/properties/sourceTopics/items/properties/events/items/properties/customSerialization/properties/customSerializerClass",
"type": "string",
- "title": "Custom Serializer Class",
+ "title": "Custom Serializer Class for customized JSON parsing",
"examples": [
"org.onap.policy.controlloop.util.Serialization"
],
- "pattern": "^(.*)$"
+ "pattern": "^(.+)$"
},
"jsonParser": {
- "$id": "#/properties/properties/properties/sourceTopics/items/properties/serialization/items/properties/customSerializer/properties/jsonParser",
+ "$id": "#/properties/properties/properties/sourceTopics/items/properties/events/items/properties/customSerialization/properties/jsonParser",
"type": "string",
- "title": "JSON Parser reference",
+ "title": "JSON Parser Static Field (currently only GSON is supported)",
"examples": [
"gson"
],
@@ -184,7 +182,7 @@
"title": "Sink Topic Data",
"required": [
"topicName",
- "serialization"
+ "events"
],
"properties": {
"topicName": {
@@ -197,21 +195,20 @@
],
"pattern": "^(.+)$"
},
- "serialization": {
- "$id": "#/properties/properties/properties/sinkTopics/items/properties/serialization",
+ "events": {
+ "$id": "#/properties/properties/properties/sinkTopics/items/properties/events",
"type": "array",
- "title": "The Serialization Schema",
+ "title": "Source Events",
"items": {
- "$id": "#/properties/properties/properties/sinkTopics/items/properties/serialization/items",
+ "$id": "#/properties/properties/properties/sinkTopics/items/properties/events/items",
"type": "object",
- "title": "Serialization Data",
+ "title": "Event Information",
"required": [
- "eventClass",
- "eventFilter"
+ "eventClass"
],
"properties": {
"eventClass": {
- "$id": "#/properties/properties/properties/sinkTopics/items/properties/serialization/items/properties/eventClass",
+ "$id": "#/properties/properties/properties/sinkTopics/items/properties/events/items/properties/eventClass",
"type": "string",
"title": "Event Class",
"examples": [
@@ -220,38 +217,38 @@
"pattern": "^(.+)$"
},
"eventFilter": {
- "$id": "#/properties/properties/properties/sinkTopics/items/properties/serialization/items/properties/eventFilter",
+ "$id": "#/properties/properties/properties/sinkTopics/items/properties/events/items/properties/eventFilter",
"type": "string",
- "title": "The Eventfilter Schema",
+ "title": "Event Filter",
"examples": [
"[?($.CommonHeader && $.Status)]"
],
"pattern": "^(.+)$"
},
- "customSerializer": {
- "$id": "#/properties/properties/properties/sinkTopics/items/properties/serialization/items/properties/customSerializer",
+ "customSerialization": {
+ "$id": "#/properties/properties/properties/sinkTopics/items/properties/events/items/properties/customSerialization",
"type": "object",
- "title": "The Customserializer Schema",
+ "title": "Custom Serialization",
"required": [
"customSerializerClass",
"jsonParser"
],
"properties": {
"customSerializerClass": {
- "$id": "#/properties/properties/properties/sinkTopics/items/properties/serialization/items/properties/customSerializer/properties/customSerializerClass",
+ "$id": "#/properties/properties/properties/sinkTopics/items/properties/events/items/properties/customSerialization/properties/customSerializerClass",
"type": "string",
- "title": "The Customserializerclass Schema",
+ "title": "Custom Serializer Class for customized JSON parsing",
"examples": [
- "org.onap.policy.appc.util.Serialization"
+ "org.onap.policy.controlloop.util.Serialization"
],
"pattern": "^(.+)$"
},
"jsonParser": {
- "$id": "#/properties/properties/properties/sinkTopics/items/properties/serialization/items/properties/customSerializer/properties/jsonParser",
+ "$id": "#/properties/properties/properties/sinkTopics/items/properties/events/items/properties/customSerialization/properties/jsonParser",
"type": "string",
- "title": "The Jsonparser Schema",
+ "title": "JSON Parser Static Field (currently only GSON is supported)",
"examples": [
- "gsonPretty"
+ "gson"
],
"pattern": "^(.+)$"
}
diff --git a/feature-lifecycle/src/test/java/org/onap/policy/drools/domain/models/DomainPolicyTypesTest.java b/policy-domains/src/test/java/org/onap/policy/drools/domain/models/DomainPolicyTypesTest.java
index dd70553d..6fdcc0a5 100644
--- a/feature-lifecycle/src/test/java/org/onap/policy/drools/domain/models/DomainPolicyTypesTest.java
+++ b/policy-domains/src/test/java/org/onap/policy/drools/domain/models/DomainPolicyTypesTest.java
@@ -34,11 +34,11 @@ import org.junit.Test;
import org.onap.policy.common.utils.coder.CoderException;
import org.onap.policy.common.utils.coder.StandardCoder;
import org.onap.policy.common.utils.resources.ResourceUtils;
+import org.onap.policy.drools.domain.models.artifact.NativeArtifactController;
+import org.onap.policy.drools.domain.models.artifact.NativeArtifactPolicy;
+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.domain.models.nativ.rules.NativeDroolsController;
-import org.onap.policy.drools.domain.models.nativ.rules.NativeDroolsPolicy;
-import org.onap.policy.drools.domain.models.nativ.rules.NativeDroolsProperties;
-import org.onap.policy.drools.domain.models.nativ.rules.NativeDroolsRulesArtifact;
import org.onap.policy.drools.policies.DomainMaker;
import org.onap.policy.models.tosca.authorative.concepts.ToscaPolicy;
import org.onap.policy.models.tosca.authorative.concepts.ToscaPolicyTypeIdentifier;
@@ -48,7 +48,7 @@ public class DomainPolicyTypesTest {
// Policy Types
private static final String OPERATIONAL_DROOLS_POLICY_TYPE = "onap.policies.controlloop.operational.common.Drools";
- private static final String NATIVE_DROOLS_POLICY_TYPE = "onap.policies.native.Drools";
+ private static final String NATIVE_DROOLS_POLICY_TYPE = "onap.policies.native.drools.Artifact";
// Operational vCPE Policy
private static final String OP_POLICY_NAME_VCPE = "operational.restart";
@@ -60,12 +60,12 @@ public class DomainPolicyTypesTest {
// Native Drools Policy
private static final String EXAMPLE_NATIVE_DROOLS_POLICY_NAME = "example";
private static final String EXAMPLE_NATIVE_DROOLS_POLICY_JSON =
- "src/test/resources/example.policy.native.drools.tosca.json";
+ "src/test/resources/tosca-policy-native-artifact-example.json";
// Controller Drools Policy
private static final String EXAMPLE_CONTROLLER_DROOLS_POLICY_NAME = "example";
private static final String EXAMPLE_CONTROLLER_DROOLS_POLICY_JSON =
- "src/test/resources/example.policy.drools.controller.tosca.json";
+ "src/test/resources/tosca-policy-native-controller-example.json";
private DomainMaker domainMaker;
private StandardCoder nonValCoder;
@@ -139,13 +139,13 @@ public class DomainPolicyTypesTest {
domainMaker.isConformant(policyTypeId, rawNativeDroolsPolicy);
assertTrue(domainMaker.isConformant(toscaPolicy));
- NativeDroolsPolicy domainDroolsPolicy = domainMaker.convertTo(toscaPolicy, NativeDroolsPolicy.class);
+ NativeArtifactPolicy domainDroolsPolicy = domainMaker.convertTo(toscaPolicy, NativeArtifactPolicy.class);
assertEquals("org.onap.policy.drools.test", domainDroolsPolicy.getProperties().getRulesArtifact().getGroupId());
assertEquals("lifecycle", domainDroolsPolicy.getProperties().getRulesArtifact().getArtifactId());
assertEquals("1.0.0", domainDroolsPolicy.getProperties().getRulesArtifact().getVersion());
String policyId = toscaPolicy.getMetadata().remove("policy-id");
- assertThatThrownBy(() -> domainMaker.convertTo(toscaPolicy, NativeDroolsPolicy.class))
+ assertThatThrownBy(() -> domainMaker.convertTo(toscaPolicy, NativeArtifactPolicy.class))
.isInstanceOf(CoderException.class).hasCauseInstanceOf(ValidationFailedException.class);
toscaPolicy.getMetadata().put("policy-id", policyId);
@@ -159,16 +159,20 @@ public class DomainPolicyTypesTest {
.isInstanceOf(ValidationFailedException.class)
.hasMessageContaining("Pattern ^(.+)$ is not contained in text");
- NativeDroolsPolicy domainDroolsPolicy2 =
- NativeDroolsPolicy.builder().metadata(Metadata.builder().policyId("policy-id").build()).name("example")
+ // @formatter:off
+ NativeArtifactPolicy domainDroolsPolicy2 =
+ NativeArtifactPolicy.builder().metadata(Metadata.builder().policyId("policy-id").build())
+ .name("example")
.version("1.0.0").properties(
- NativeDroolsProperties.builder().controller(
- NativeDroolsController.builder().name("example").version("1.0.0").build())
+ NativeArtifactProperties.builder().controller(
+ NativeArtifactController.builder().name("example").build())
.rulesArtifact(
- NativeDroolsRulesArtifact.builder().groupId("org.onap.policy.controlloop")
+ NativeArtifactRulesArtifact.builder().groupId("org.onap.policy.controlloop")
.artifactId("example").version("example").build()).build())
- .type("onap.policies.native.Drools")
+ .type("onap.policies.native.drools.Artifact")
.typeVersion("1.0.0").build();
+ // @formatter:on
+
assertTrue(domainMaker
.isDomainConformant(
new ToscaPolicyTypeIdentifier(domainDroolsPolicy2.getType(), domainDroolsPolicy2.getTypeVersion()),
@@ -185,37 +189,37 @@ public class DomainPolicyTypesTest {
assertEquals("example", controllerPolicy.getName());
assertEquals("1.0.0", controllerPolicy.getVersion());
- assertEquals("onap.policies.drools.Controller", controllerPolicy.getType());
+ assertEquals("onap.policies.native.drools.Controller", controllerPolicy.getType());
assertEquals("1.0.0", controllerPolicy.getTypeVersion());
assertEquals("example", controllerPolicy.getMetadata().getPolicyId());
assertEquals("lifecycle", controllerPolicy.getProperties().getControllerName());
assertEquals("DCAE_TOPIC", controllerPolicy.getProperties().getSourceTopics().get(0).getTopicName());
assertEquals("org.onap.policy.controlloop.CanonicalOnset",
- controllerPolicy.getProperties().getSourceTopics().get(0).getSerialization().get(0).getEventClass());
+ controllerPolicy.getProperties().getSourceTopics().get(0).getEvents().get(0).getEventClass());
assertEquals("[?($.closedLoopEventStatus == 'ONSET')]",
- controllerPolicy.getProperties().getSourceTopics().get(0).getSerialization().get(0).getEventFilter());
+ controllerPolicy.getProperties().getSourceTopics().get(0).getEvents().get(0).getEventFilter());
assertEquals("org.onap.policy.controlloop.util.Serialization",
- controllerPolicy.getProperties().getSourceTopics().get(0).getSerialization().get(0)
- .getCustomSerializer().getCustomSerializerClass());
+ controllerPolicy.getProperties().getSourceTopics().get(0).getEvents().get(0)
+ .getCustomSerialization().getCustomSerializerClass());
assertEquals("gson",
- controllerPolicy.getProperties().getSourceTopics().get(0).getSerialization().get(0)
- .getCustomSerializer().getJsonParser());
+ controllerPolicy.getProperties().getSourceTopics().get(0).getEvents().get(0)
+ .getCustomSerialization().getJsonParser());
assertEquals("APPC-CL", controllerPolicy.getProperties().getSinkTopics().get(0).getTopicName());
assertEquals("org.onap.policy.appc.Response",
- controllerPolicy.getProperties().getSinkTopics().get(0).getSerialization().get(0).getEventClass());
+ controllerPolicy.getProperties().getSinkTopics().get(0).getEvents().get(0).getEventClass());
assertEquals("[?($.CommonHeader && $.Status)]",
- controllerPolicy.getProperties().getSinkTopics().get(0).getSerialization().get(0).getEventFilter());
+ controllerPolicy.getProperties().getSinkTopics().get(0).getEvents().get(0).getEventFilter());
assertEquals("org.onap.policy.appc.util.Serialization",
- controllerPolicy.getProperties().getSinkTopics().get(0).getSerialization().get(0)
- .getCustomSerializer().getCustomSerializerClass());
+ controllerPolicy.getProperties().getSinkTopics().get(0).getEvents().get(0)
+ .getCustomSerialization().getCustomSerializerClass());
assertEquals("gsonPretty",
- controllerPolicy.getProperties().getSinkTopics().get(0).getSerialization().get(0)
- .getCustomSerializer().getJsonParser());
+ controllerPolicy.getProperties().getSinkTopics().get(0).getEvents().get(0)
+ .getCustomSerialization().getJsonParser());
assertEquals("value1", controllerPolicy.getProperties().getCustomConfig().get("field1"));
}
private String getJsonFromFile(String filePath) throws IOException {
- return new String(Files.readAllBytes(Paths.get(filePath)));
+ return Files.readString(Paths.get(filePath));
}
private String getJsonFromResource(String resourcePath) {
diff --git a/policy-management/src/test/java/org/onap/policy/drools/domain/models/DroolsPolicyTest.java b/policy-domains/src/test/java/org/onap/policy/drools/domain/models/DroolsPolicyTest.java
index 22edbb44..c6e8990e 100644
--- a/policy-management/src/test/java/org/onap/policy/drools/domain/models/DroolsPolicyTest.java
+++ b/policy-domains/src/test/java/org/onap/policy/drools/domain/models/DroolsPolicyTest.java
@@ -20,12 +20,17 @@
package org.onap.policy.drools.domain.models;
+import com.openpojo.reflection.PojoClass;
+import com.openpojo.reflection.filters.FilterChain;
+import com.openpojo.reflection.filters.FilterClassName;
+import com.openpojo.reflection.filters.FilterNonConcrete;
import com.openpojo.reflection.impl.PojoClassFactory;
import com.openpojo.validation.Validator;
import com.openpojo.validation.ValidatorBuilder;
import com.openpojo.validation.test.impl.GetterTester;
import com.openpojo.validation.test.impl.SetterTester;
import java.io.Serializable;
+import java.util.List;
import lombok.Data;
import lombok.NoArgsConstructor;
import lombok.experimental.SuperBuilder;
@@ -41,7 +46,7 @@ public class DroolsPolicyTest {
}
@Test
- public void testPackage() {
+ public void testDerivedClass() {
/* validate model pojos */
Validator validator = ValidatorBuilder.create()
.with(new SetterTester(), new GetterTester()).build();
@@ -49,4 +54,17 @@ public class DroolsPolicyTest {
validator.validate(PojoClassFactory.getPojoClass(DerivedDomainPolicy.class));
}
+ @Test
+ public void testPackage() {
+ /* validate model pojos */
+ List<PojoClass> pojoClasses =
+ PojoClassFactory
+ .getPojoClassesRecursively("org.onap.policy.drools.domain.models",
+ new FilterChain(new FilterNonConcrete(),
+ new FilterClassName(DroolsPolicy.class.getName())));
+
+ Validator validator = ValidatorBuilder.create()
+ .with(new SetterTester(), new GetterTester()).build();
+ validator.validate(pojoClasses);
+ }
} \ No newline at end of file
diff --git a/policy-domains/src/test/java/org/onap/policy/drools/domain/models/artifact/ArtifactPolicyTest.java b/policy-domains/src/test/java/org/onap/policy/drools/domain/models/artifact/ArtifactPolicyTest.java
new file mode 100644
index 00000000..b4c71f0d
--- /dev/null
+++ b/policy-domains/src/test/java/org/onap/policy/drools/domain/models/artifact/ArtifactPolicyTest.java
@@ -0,0 +1,51 @@
+/*
+ * ============LICENSE_START=======================================================
+ * Copyright (C) 2020 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.drools.domain.models.artifact;
+
+import static org.junit.Assert.assertNotNull;
+
+import org.junit.Test;
+import org.onap.policy.drools.domain.models.Metadata;
+
+public class ArtifactPolicyTest {
+
+ @Test
+ public void testBuildDomainPolicyNativeArtifact() {
+ /* manually create a native drools policy */
+
+ // @formatter:off
+ assertNotNull(NativeArtifactPolicy.builder()
+ .metadata(Metadata.builder().policyId("policy-id").build())
+ .name("example")
+ .type("onap.policies.native.drools.Artifact")
+ .typeVersion("1.0.0")
+ .version("1.0.0")
+ .properties(
+ NativeArtifactProperties.builder().controller(
+ NativeArtifactController.builder().name("example").build())
+ .rulesArtifact(
+ NativeArtifactRulesArtifact.builder().groupId("org.onap.policy.controlloop")
+ .artifactId("example").version("example").build()).build())
+ .build());
+ // @formatter:on
+ }
+
+} \ No newline at end of file
diff --git a/policy-domains/src/test/java/org/onap/policy/drools/domain/models/controller/ControllerPolicyTest.java b/policy-domains/src/test/java/org/onap/policy/drools/domain/models/controller/ControllerPolicyTest.java
new file mode 100644
index 00000000..d24a8f70
--- /dev/null
+++ b/policy-domains/src/test/java/org/onap/policy/drools/domain/models/controller/ControllerPolicyTest.java
@@ -0,0 +1,48 @@
+/*
+ * ============LICENSE_START=======================================================
+ * Copyright (C) 2020 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.drools.domain.models.controller;
+
+import static org.junit.Assert.assertNotNull;
+
+import java.util.ArrayList;
+import org.junit.Test;
+import org.onap.policy.drools.domain.models.Metadata;
+
+public class ControllerPolicyTest {
+
+ @Test
+ public void testBuildDomainPolicyController() {
+ /* manually create a controller policy */
+
+ // @formatter:off
+ assertNotNull(ControllerPolicy.builder()
+ .metadata(Metadata.builder().policyId("policy-id").build())
+ .name("example")
+ .version("1.0.0")
+ .type("onap.policies.drools.Controller")
+ .typeVersion("1.0.0")
+ .properties(ControllerProperties.builder().controllerName("example").sourceTopics(
+ new ArrayList<>()).sinkTopics(new ArrayList<>()).build())
+ .build());
+ // @formatter:on
+ }
+
+} \ No newline at end of file
diff --git a/policy-domains/src/test/java/org/onap/policy/drools/domain/models/legacy/LegacyPolicyTest.java b/policy-domains/src/test/java/org/onap/policy/drools/domain/models/legacy/LegacyPolicyTest.java
new file mode 100644
index 00000000..7eb2532f
--- /dev/null
+++ b/policy-domains/src/test/java/org/onap/policy/drools/domain/models/legacy/LegacyPolicyTest.java
@@ -0,0 +1,64 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * ONAP
+ * ================================================================================
+ * Copyright (C) 2020 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.
+ * ============LICENSE_END=========================================================
+ */
+
+package org.onap.policy.drools.domain.models.legacy;
+
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertTrue;
+
+import java.io.IOException;
+import java.nio.file.Files;
+import java.nio.file.Paths;
+import org.junit.Test;
+import org.onap.policy.common.utils.coder.CoderException;
+import org.onap.policy.common.utils.coder.StandardCoder;
+import org.onap.policy.drools.policies.DomainMaker;
+import org.onap.policy.models.tosca.authorative.concepts.ToscaPolicy;
+import org.onap.policy.models.tosca.authorative.concepts.ToscaPolicyTypeIdentifier;
+
+public class LegacyPolicyTest {
+ // Policy Types
+ private static final String OPERATIONAL_LEGACY_POLICY_TYPE = "onap.policies.controlloop.Operational";
+
+ // Operational vCPE Legacy Policy
+ private static final String OP_POLICY_NAME_VCPE = "operational.restart";
+ public static final String VCPE_OPERATIONAL_LEGACY_POLICY_JSON = "src/test/resources/tosca-legacy-vcpe.json";
+
+ @Test
+ public void testToscaLegacyOperationalPolicyType() throws IOException, CoderException {
+ String rawVcpeToscaPolicy = getJsonFromFile(VCPE_OPERATIONAL_LEGACY_POLICY_JSON);
+
+ ToscaPolicyTypeIdentifier legacyType =
+ new ToscaPolicyTypeIdentifier(OPERATIONAL_LEGACY_POLICY_TYPE, "1.0.0");
+
+ DomainMaker domainMaker = new DomainMaker();
+ assertTrue(domainMaker .isConformant(legacyType, rawVcpeToscaPolicy));
+ LegacyPolicy legacyPolicy = domainMaker.convertTo(legacyType, rawVcpeToscaPolicy, LegacyPolicy.class);
+
+ ToscaPolicy policy = new StandardCoder().decode(rawVcpeToscaPolicy, ToscaPolicy.class);
+ assertEquals(policy.getProperties().get("content").toString(), legacyPolicy.getProperties().getContent());
+ assertEquals(policy.getProperties().get("controllerName").toString(),
+ legacyPolicy.getProperties().getControllerName());
+ }
+
+ private String getJsonFromFile(String filePath) throws IOException {
+ return Files.readString(Paths.get(filePath));
+ }
+} \ No newline at end of file
diff --git a/policy-domains/src/test/java/org/onap/policy/drools/domain/models/operational/OperationalPolicyTest.java b/policy-domains/src/test/java/org/onap/policy/drools/domain/models/operational/OperationalPolicyTest.java
new file mode 100644
index 00000000..bf50a3df
--- /dev/null
+++ b/policy-domains/src/test/java/org/onap/policy/drools/domain/models/operational/OperationalPolicyTest.java
@@ -0,0 +1,122 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * ONAP
+ * ================================================================================
+ * Copyright (C) 2020 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.
+ * ============LICENSE_END=========================================================
+ */
+
+package org.onap.policy.drools.domain.models.operational;
+
+import static org.junit.Assert.assertNotNull;
+import static org.junit.Assert.assertTrue;
+
+import java.io.IOException;
+import java.nio.file.Files;
+import java.nio.file.Paths;
+import java.util.List;
+import org.junit.Before;
+import org.junit.Test;
+import org.onap.policy.common.utils.coder.CoderException;
+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.ToscaPolicy;
+import org.onap.policy.models.tosca.authorative.concepts.ToscaPolicyTypeIdentifier;
+import org.onap.policy.models.tosca.authorative.concepts.ToscaServiceTemplate;
+
+public class OperationalPolicyTest {
+ // Policy Types
+ private static final String OPERATIONAL_DROOLS_POLICY_TYPE = "onap.policies.controlloop.operational.common.Drools";
+
+ // Operational vCPE Policies
+ private static final String OP_POLICY_NAME_VCPE = "operational.restart";
+ private static final String VCPE_OPERATIONAL_DROOLS_POLICY_JSON =
+ "policies/vCPE.policy.operational.input.tosca.json";
+
+ private DomainMaker domainMaker;
+ private StandardCoder nonValCoder;
+
+ @Before
+ public void setUp() {
+ domainMaker = new DomainMaker();
+ nonValCoder = new StandardCoder();
+ }
+
+ @Test
+ public void testToscaCompliantOperationalPolicyType() throws CoderException {
+ 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");
+ assertTrue(domainMaker.isConformant(operationalCompliantType, rawVcpeToscaPolicy));
+ assertNotNull(domainMaker.convertTo(operationalCompliantType, rawVcpeToscaPolicy, OperationalPolicy.class));
+ }
+
+ @Test
+ public void testOperationalCompliantModel() {
+ // @formatter:off
+ OperationalPolicy policy =
+ OperationalPolicy.builder()
+ .metadata(Metadata.builder().policyId(OP_POLICY_NAME_VCPE).build())
+ .name(OP_POLICY_NAME_VCPE)
+ .type(OPERATIONAL_DROOLS_POLICY_TYPE)
+ .typeVersion("1.0.0")
+ .version("1.0.0")
+ .properties(
+ OperationalProperties.builder()
+ .id("ControlLoop-vCPE-48f0c2c3-a172-4192-9ae3-052274181b6e")
+ .abatement(true)
+ .trigger("unique-policy-id-1-restart")
+ .operations(
+ List.of(Operation.builder()
+ .id("unique-policy-id-1-restart")
+ .description("Restart the VM")
+ .timeout(60)
+ .retries(3)
+ .actorOperation(ActorOperation.builder()
+ .operation("Restart")
+ .actor("APPC")
+ .target(OperationalTarget.builder().targetType("VNF").build())
+ .build())
+ .build()))
+ .controllerName("usecases")
+ .build())
+ .build();
+ // @formatter:on
+
+ assertNotNull(policy);
+ }
+
+ private String getJsonFromFile(String filePath) throws IOException {
+ return Files.readString(Paths.get(filePath));
+ }
+
+ private String getJsonFromResource(String resourcePath) {
+ return ResourceUtils.getResourceAsString(resourcePath);
+ }
+
+ private ToscaPolicy getExamplesPolicy(String resourcePath, String policyName) throws CoderException {
+ String policyJson = getJsonFromResource(resourcePath);
+ ToscaServiceTemplate serviceTemplate = new StandardCoder().decode(policyJson, ToscaServiceTemplate.class);
+ return serviceTemplate.getToscaTopologyTemplate().getPolicies().get(0).get(policyName);
+ }
+
+ private String getExamplesPolicyString(String resourcePath, String policyName) throws CoderException {
+ return nonValCoder.encode(getExamplesPolicy(resourcePath, policyName));
+ }
+} \ No newline at end of file
diff --git a/policy-domains/src/test/resources/tosca-legacy-vcpe.json b/policy-domains/src/test/resources/tosca-legacy-vcpe.json
new file mode 100644
index 00000000..ab0e59d7
--- /dev/null
+++ b/policy-domains/src/test/resources/tosca-legacy-vcpe.json
@@ -0,0 +1,10 @@
+{
+ "type": "onap.policies.controlloop.Operational",
+ "type_version": "1.0.0",
+ "properties": {
+ "content": "controlLoop%3A%0A%20%20version%3A%202.0.0%0A%20%20controlLoopName%3A%20ControlLoop-vCPE-48f0c2c3-a172-4192-9ae3-052274181b6e%0A%20%20trigger_policy%3A%20unique-policy-id-1-restart%0A%20%20timeout%3A%203600%0A%20%20abatement%3A%20true%0A%20%0Apolicies%3A%0A%20%20-%20id%3A%20unique-policy-id-1-restart%0A%20%20%20%20name%3A%20Restart%20the%20VM%0A%20%20%20%20description%3A%0A%20%20%20%20actor%3A%20APPC%0A%20%20%20%20recipe%3A%20Restart%0A%20%20%20%20target%3A%0A%20%20%20%20%20%20type%3A%20VM%0A%20%20%20%20retry%3A%203%0A%20%20%20%20timeout%3A%201200%0A%20%20%20%20success%3A%20final_success%0A%20%20%20%20failure%3A%20final_failure%0A%20%20%20%20failure_timeout%3A%20final_failure_timeout%0A%20%20%20%20failure_retries%3A%20final_failure_retries%0A%20%20%20%20failure_exception%3A%20final_failure_exception%0A%20%20%20%20failure_guard%3A%20final_failure_guard",
+ "controllerName": "usecases"
+ },
+ "name": "operational.restart",
+ "version": "1.0.0"
+}
diff --git a/policy-domains/src/test/resources/tosca-policy-native-artifact-example.json b/policy-domains/src/test/resources/tosca-policy-native-artifact-example.json
new file mode 100644
index 00000000..f521953d
--- /dev/null
+++ b/policy-domains/src/test/resources/tosca-policy-native-artifact-example.json
@@ -0,0 +1,29 @@
+{
+ "tosca_definitions_version": "tosca_simple_yaml_1_0_0",
+ "topology_template": {
+ "policies": [
+ {
+ "example": {
+ "type": "onap.policies.native.drools.Artifact",
+ "type_version": "1.0.0",
+ "version": "1.0.0",
+ "name": "example",
+ "metadata": {
+ "policy-id": "example"
+ },
+ "properties": {
+ "rulesArtifact": {
+ "groupId": "org.onap.policy.drools.test",
+ "artifactId": "lifecycle",
+ "version": "1.0.0"
+ },
+ "controller": {
+ "name": "lifecycle",
+ "version": "1.0.0"
+ }
+ }
+ }
+ }
+ ]
+ }
+} \ No newline at end of file
diff --git a/policy-domains/src/test/resources/tosca-policy-native-controller-example.json b/policy-domains/src/test/resources/tosca-policy-native-controller-example.json
new file mode 100644
index 00000000..3d716845
--- /dev/null
+++ b/policy-domains/src/test/resources/tosca-policy-native-controller-example.json
@@ -0,0 +1,58 @@
+{
+ "tosca_definitions_version": "tosca_simple_yaml_1_0_0",
+ "topology_template": {
+ "policies": [
+ {
+ "example": {
+ "type": "onap.policies.native.drools.Controller",
+ "type_version": "1.0.0",
+ "version": "1.0.0",
+ "name": "example",
+ "metadata": {
+ "policy-id": "example"
+ },
+ "properties": {
+ "controllerName": "lifecycle",
+ "sourceTopics": [
+ {
+ "topicName": "DCAE_TOPIC",
+ "events": [
+ {
+ "eventClass": "org.onap.policy.controlloop.CanonicalOnset",
+ "eventFilter": "[?($.closedLoopEventStatus == 'ONSET')]",
+ "customSerialization": {
+ "customSerializerClass": "org.onap.policy.controlloop.util.Serialization",
+ "jsonParser": "gson"
+ }
+ },
+ {
+ "eventClass": "org.onap.policy.controlloop.CanonicalAbated",
+ "eventFilter": "[?($.closedLoopEventStatus == 'ABATED')]"
+ }
+ ]
+ }
+ ],
+ "sinkTopics": [
+ {
+ "topicName": "APPC-CL",
+ "events": [
+ {
+ "eventClass": "org.onap.policy.appc.Response",
+ "eventFilter": "[?($.CommonHeader && $.Status)]",
+ "customSerialization": {
+ "customSerializerClass": "org.onap.policy.appc.util.Serialization",
+ "jsonParser": "gsonPretty"
+ }
+ }
+ ]
+ }
+ ],
+ "customConfig": {
+ "field1" : "value1"
+ }
+ }
+ }
+ }
+ ]
+ }
+} \ No newline at end of file
diff --git a/policy-domains/src/test/resources/tosca-policy-operational-restart.json b/policy-domains/src/test/resources/tosca-policy-operational-restart.json
new file mode 100644
index 00000000..98e8bb8f
--- /dev/null
+++ b/policy-domains/src/test/resources/tosca-policy-operational-restart.json
@@ -0,0 +1,9 @@
+{
+ "type": "onap.policies.controlloop.Operational",
+ "type_version": "1.0.0",
+ "properties": {
+ "content": "controlLoop%3A%0A%20%20version%3A%202.0.0%0A%20%20controlLoopName%3A%20ControlLoop-vCPE-48f0c2c3-a172-4192-9ae3-052274181b6e%0A%20%20trigger_policy%3A%20unique-policy-id-1-restart%0A%20%20timeout%3A%203600%0A%20%20abatement%3A%20true%0A%20%0Apolicies%3A%0A%20%20-%20id%3A%20unique-policy-id-1-restart%0A%20%20%20%20name%3A%20Restart%20the%20VM%0A%20%20%20%20description%3A%0A%20%20%20%20actor%3A%20APPC%0A%20%20%20%20recipe%3A%20Restart%0A%20%20%20%20target%3A%0A%20%20%20%20%20%20type%3A%20VM%0A%20%20%20%20retry%3A%203%0A%20%20%20%20timeout%3A%201200%0A%20%20%20%20success%3A%20final_success%0A%20%20%20%20failure%3A%20final_failure%0A%20%20%20%20failure_timeout%3A%20final_failure_timeout%0A%20%20%20%20failure_retries%3A%20final_failure_retries%0A%20%20%20%20failure_exception%3A%20final_failure_exception%0A%20%20%20%20failure_guard%3A%20final_failure_guard"
+ },
+ "name": "operational.restart",
+ "version": "1.0.0"
+}
diff --git a/policy-management/pom.xml b/policy-management/pom.xml
index 7d3ac12f..1498dddc 100644
--- a/policy-management/pom.xml
+++ b/policy-management/pom.xml
@@ -174,6 +174,12 @@
</dependency>
<dependency>
+ <groupId>org.onap.policy.drools-pdp</groupId>
+ <artifactId>policy-domains</artifactId>
+ <version>${project.version}</version>
+ </dependency>
+
+ <dependency>
<groupId>org.onap.policy.common</groupId>
<artifactId>policy-endpoints</artifactId>
<version>${policy.common.version}</version>
diff --git a/policy-management/src/main/java/org/onap/policy/drools/server/restful/RestManager.java b/policy-management/src/main/java/org/onap/policy/drools/server/restful/RestManager.java
index cd3951d7..c6d5e02d 100644
--- a/policy-management/src/main/java/org/onap/policy/drools/server/restful/RestManager.java
+++ b/policy-management/src/main/java/org/onap/policy/drools/server/restful/RestManager.java
@@ -1,8 +1,8 @@
/*
* ============LICENSE_START=======================================================
- * policy-management
+ * ONAP
* ================================================================================
- * Copyright (C) 2017-2019 AT&T Intellectual Property. All rights reserved.
+ * Copyright (C) 2017-2020 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.
diff --git a/policy-management/src/main/java/org/onap/policy/drools/system/internal/AggregatedPolicyController.java b/policy-management/src/main/java/org/onap/policy/drools/system/internal/AggregatedPolicyController.java
index 1fd42546..5685ff6e 100644
--- a/policy-management/src/main/java/org/onap/policy/drools/system/internal/AggregatedPolicyController.java
+++ b/policy-management/src/main/java/org/onap/policy/drools/system/internal/AggregatedPolicyController.java
@@ -45,6 +45,7 @@ import org.onap.policy.drools.persistence.SystemPersistenceConstants;
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.slf4j.Logger;
import org.slf4j.LoggerFactory;
@@ -141,7 +142,7 @@ public class AggregatedPolicyController implements PolicyController, TopicListen
/* persist new properties */
getPersistenceManager().storeController(name, properties);
- this.properties = properties;
+ this.properties = PropertyUtil.getInterpolatedProperties(properties);
this.policyTypes = getPolicyTypesFromProperties();
}
diff --git a/policy-management/src/main/server-gen/bin/db-migrator b/policy-management/src/main/server-gen/bin/db-migrator
index 29a50d42..f5029460 100644
--- a/policy-management/src/main/server-gen/bin/db-migrator
+++ b/policy-management/src/main/server-gen/bin/db-migrator
@@ -1,9 +1,9 @@
#!/bin/bash
-#
+
# ============LICENSE_START=======================================================
# ONAP
# ================================================================================
-# Copyright (C) 2017, 2019 AT&T Intellectual Property. All rights reserved.
+# Copyright (C) 2017-2020 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.
@@ -52,6 +52,8 @@
#
# #####################################################################
+source ${POLICY_HOME}/etc/profile.d/env.sh
+
METADATA_DB=migration
METADATA_TABLE="${METADATA_DB}".metadata_versions
MIGRATION_DIR="${POLICY_HOME}"/etc/db/migration
diff --git a/policy-management/src/main/server-gen/bin/deploy-artifact b/policy-management/src/main/server-gen/bin/deploy-artifact
index b02c4e0c..b142bcde 100644
--- a/policy-management/src/main/server-gen/bin/deploy-artifact
+++ b/policy-management/src/main/server-gen/bin/deploy-artifact
@@ -1,10 +1,9 @@
#!/usr/bin/env bash
-#
# ============LICENSE_START=======================================================
# ONAP
# ================================================================================
-# Copyright (C) 2018-2019 AT&T Intellectual Property. All rights reserved.
+# Copyright (C) 2018-2020 AT&T Intellectual Property. All rights reserved.
# Modifications Copyright (C) 2020 Bell Canada.
# ================================================================================
# Licensed under the Apache License, Version 2.0 (the "License");
@@ -19,7 +18,8 @@
# See the License for the specific language governing permissions and
# limitations under the License.
# ============LICENSE_END=========================================================
-###
+
+source ${POLICY_HOME}/etc/profile.d/env.sh
##############################################################################
# Usage: usage
diff --git a/policy-management/src/main/server-gen/bin/pdpd-configuration b/policy-management/src/main/server-gen/bin/pdpd-configuration
index bfff60ba..fc822e18 100644
--- a/policy-management/src/main/server-gen/bin/pdpd-configuration
+++ b/policy-management/src/main/server-gen/bin/pdpd-configuration
@@ -1,10 +1,9 @@
#! /bin/bash
-###
# ============LICENSE_START=======================================================
-# policy-management
+# ONAP
# ================================================================================
-# Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.
+# Copyright (C) 2017-2020 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.
@@ -18,7 +17,8 @@
# See the License for the specific language governing permissions and
# limitations under the License.
# ============LICENSE_END=========================================================
-###
+
+source ${POLICY_HOME}/etc/profile.d/env.sh
function usage() {
echo -n "Usage: $(basename $0) "
diff --git a/policy-management/src/main/server-gen/bin/policy-management-controller b/policy-management/src/main/server-gen/bin/policy-management-controller
index 389f7d2e..56db98df 100644
--- a/policy-management/src/main/server-gen/bin/policy-management-controller
+++ b/policy-management/src/main/server-gen/bin/policy-management-controller
@@ -1,10 +1,9 @@
#!/bin/bash
-###
# ============LICENSE_START=======================================================
# ONAP POLICY
# ================================================================================
-# Copyright (C) 2017-2019 AT&T Intellectual Property. All rights reserved.
+# Copyright (C) 2017-2020 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.
@@ -18,7 +17,8 @@
# See the License for the specific language governing permissions and
# limitations under the License.
# ============LICENSE_END=========================================================
-##
+
+source ${POLICY_HOME}/etc/profile.d/env.sh
SNAME="Policy Management"
PNAME=policy-management
diff --git a/policy-management/src/main/server-gen/bin/rest-add-controller b/policy-management/src/main/server-gen/bin/rest-add-controller
index 98b5702b..1c7dfbc1 100644
--- a/policy-management/src/main/server-gen/bin/rest-add-controller
+++ b/policy-management/src/main/server-gen/bin/rest-add-controller
@@ -1,10 +1,9 @@
#! /bin/bash
-###
# ============LICENSE_START=======================================================
-# policy-management
+# ONAP
# ================================================================================
-# Copyright (C) 2017-2018 AT&T Intellectual Property. All rights reserved.
+# Copyright (C) 2017-2020 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.
@@ -18,7 +17,6 @@
# See the License for the specific language governing permissions and
# limitations under the License.
# ============LICENSE_END=========================================================
-###
source $POLICY_HOME/etc/profile.d/env.sh
diff --git a/policy-management/src/main/server-gen/bin/rest-delete-controller b/policy-management/src/main/server-gen/bin/rest-delete-controller
index 7a47c928..c2741191 100644
--- a/policy-management/src/main/server-gen/bin/rest-delete-controller
+++ b/policy-management/src/main/server-gen/bin/rest-delete-controller
@@ -1,41 +1,37 @@
#! /bin/bash
-###
# ============LICENSE_START=======================================================
-# policy-management
+# ONAP
# ================================================================================
-# Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.
+# Copyright (C) 2017-2020 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.
# ============LICENSE_END=========================================================
-###
source $POLICY_HOME/etc/profile.d/env.sh
if [[ -n $1 ]]; then
- if [[ -n ${TELEMETRY_PASSWORD} ]]; then
- curl -k --silent --user ${TELEMETRY_USER}:${TELEMETRY_PASSWORD} -X DELETE --header "Content-Type: application/json" \
- https://localhost:${TELEMETRY_PORT}/policy/pdp/engine/controllers/${1}
- else
- curl -k --silent -X DELETE --header "Content-Type: application/json" \
- https://localhost:${TELEMETRY_PORT}/policy/pdp/engine/controllers/${1}
- fi
- echo
- exit
+ if [[ -n ${TELEMETRY_PASSWORD} ]]; then
+ curl -k --silent --user ${TELEMETRY_USER}:${TELEMETRY_PASSWORD} -X DELETE --header "Content-Type: application/json" \
+ https://localhost:${TELEMETRY_PORT}/policy/pdp/engine/controllers/${1}
+ else
+ curl -k --silent -X DELETE --header "Content-Type: application/json" \
+ https://localhost:${TELEMETRY_PORT}/policy/pdp/engine/controllers/${1}
+ fi
+ echo
+ exit
fi
-
-
cat <<-'EOF'
Usage: rest-delete-controller.sh closed-loop-sample|reporter|sepc|vsegw|.. (or any other controller idenfied by name)
diff --git a/policy-management/src/main/server-gen/bin/telemetry b/policy-management/src/main/server-gen/bin/telemetry
index 37614b08..9d4b857a 100644
--- a/policy-management/src/main/server-gen/bin/telemetry
+++ b/policy-management/src/main/server-gen/bin/telemetry
@@ -1,44 +1,45 @@
#! /bin/bash
-###
# ============LICENSE_START=======================================================
-# ONAP POLICY
+# ONAP
# ================================================================================
-# Copyright (C) 2017-2018 AT&T Intellectual Property. All rights reserved.
+# Copyright (C) 2017-2020 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.
# ============LICENSE_END=========================================================
-##
+
+source ${POLICY_HOME}/etc/profile.d/env.sh
REST_TOOL="http-prompt"
TELEMETRY_SPEC="${POLICY_HOME}/config/telemetry-spec.json"
-if ! type -p "${REST_TOOL}" > /dev/null 2>&1; then
- echo "error: prerequisite software not found: http-prompt"
- exit 1
+if ! type -p "${REST_TOOL}" >/dev/null 2>&1; then
+ echo "error: prerequisite software not found: http-prompt"
+ exit 1
fi
-if ! "${POLICY_HOME}"/bin/policy-management-controller status > /dev/null 2>&1; then
- echo "error: pdp-d is not running"
- exit 2
+if ! "${POLICY_HOME}"/bin/policy-management-controller status >/dev/null 2>&1; then
+ echo "error: pdp-d is not running"
+ exit 2
fi
if [[ ! -r ${TELEMETRY_SPEC} ]]; then
- echo "generating new spec .."
- if ! http --verify=no -a "${TELEMETRY_USER}:${TELEMETRY_PASSWORD}" https://localhost:9696/swagger.json > ${TELEMETRY_SPEC} 2> /dev/null; then
- echo "error: cannot generate telemetry spec"
- exit 3
- fi
+ echo "generating new spec .."
+ if ! http --verify=no -a "${TELEMETRY_USER}:${TELEMETRY_PASSWORD}" https://localhost:9696/swagger.json >${TELEMETRY_SPEC} 2>/dev/null; then
+ echo "error: cannot generate telemetry spec"
+ rm -f ${TELEMETRY_SPEC} 2>/dev/null
+ exit 3
+ fi
fi
exec http-prompt https://localhost:9696/policy/pdp/engine --verify=no --auth "${TELEMETRY_USER}:${TELEMETRY_PASSWORD}" --spec ${TELEMETRY_SPEC}
diff --git a/pom.xml b/pom.xml
index 26de27a9..a8f15df1 100644
--- a/pom.xml
+++ b/pom.xml
@@ -59,6 +59,7 @@
<modules>
<module>policy-utils</module>
<module>policy-core</module>
+ <module>policy-domains</module>
<module>policy-management</module>
<module>feature-healthcheck</module>
<module>feature-eelf</module>
@@ -168,18 +169,10 @@
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
- <configuration>
- <encoding>${project.encoding}</encoding>
- <source>${project.source.version}</source>
- <target>${project.target.version}</target>
- </configuration>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-resources-plugin</artifactId>
- <configuration>
- <encoding>${project.encoding}</encoding>
- </configuration>
</plugin>
<plugin>