* ONAP
* ================================================================================
* Copyright (C) 2019-2020 AT&T Intellectual Property. All rights reserved.
+ * Modifications Copyright (C) 2021 Nordix Foundation.
* ================================================================================
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
import org.onap.policy.models.pdp.enums.PdpHealthStatus;
import org.onap.policy.models.pdp.enums.PdpMessageType;
import org.onap.policy.models.pdp.enums.PdpState;
+import org.onap.policy.models.tosca.authorative.concepts.ToscaConceptIdentifier;
import org.onap.policy.models.tosca.authorative.concepts.ToscaPolicy;
-import org.onap.policy.models.tosca.authorative.concepts.ToscaPolicyIdentifier;
-import org.onap.policy.models.tosca.authorative.concepts.ToscaPolicyTypeIdentifier;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
protected static final long MIN_STATUS_INTERVAL_SECONDS = 5L;
protected static final String PDP_MESSAGE_NAME = "messageName";
- protected static final ToscaPolicyTypeIdentifier POLICY_TYPE_DROOLS_NATIVE_RULES =
- new ToscaPolicyTypeIdentifier("onap.policies.native.drools.Artifact", "1.0.0");
+ protected static final ToscaConceptIdentifier POLICY_TYPE_DROOLS_NATIVE_RULES =
+ new ToscaConceptIdentifier("onap.policies.native.drools.Artifact", "1.0.0");
- protected static final ToscaPolicyTypeIdentifier POLICY_TYPE_DROOLS_NATIVE_CONTROLLER =
- new ToscaPolicyTypeIdentifier("onap.policies.native.drools.Controller", "1.0.0");
+ protected static final ToscaConceptIdentifier POLICY_TYPE_DROOLS_NATIVE_CONTROLLER =
+ new ToscaConceptIdentifier("onap.policies.native.drools.Controller", "1.0.0");
@Getter
protected final Properties properties;
protected Set<String> mandatoryPolicyTypes = new HashSet<>();
@Getter
- protected final Map<ToscaPolicyTypeIdentifier, PolicyTypeController> policyTypesMap = new HashMap<>();
+ protected final Map<ToscaConceptIdentifier, PolicyTypeController> policyTypesMap = new HashMap<>();
@Getter
- protected final Map<ToscaPolicyIdentifier, ToscaPolicy> policiesMap = new HashMap<>();
+ protected final Map<ToscaConceptIdentifier, ToscaPolicy> policiesMap = new HashMap<>();
/**
* Constructor.
return;
}
- for (ToscaPolicyTypeIdentifier id : controller.getPolicyTypes()) {
+ for (ToscaConceptIdentifier id : controller.getPolicyTypes()) {
PolicyTypeDroolsController ptDc = (PolicyTypeDroolsController) policyTypesMap.get(id); //NOSONAR
if (ptDc == null) {
policyTypesMap.put(id, new PolicyTypeDroolsController(this, id, controller));
return (this.scheduler.submit(() -> state.updatePolicies(toscaPolicies)) != null);
}
- protected PolicyTypeController getController(ToscaPolicyTypeIdentifier policyType) {
+ protected PolicyTypeController getController(ToscaConceptIdentifier policyType) {
return policyTypesMap.get(policyType);
}
protected Set<String> getCurrentPolicyTypes() {
return getPolicyTypesMap().keySet().stream()
- .map(ToscaPolicyTypeIdentifier::getName).collect(Collectors.toSet());
+ .map(ToscaConceptIdentifier::getName).collect(Collectors.toSet());
}
/* ** Action Helpers ** */
* ================================================================================
* Copyright (C) 2019-2020 AT&T Intellectual Property. All rights reserved.
* Modifications Copyright (C) 2019 Bell Canada.
+ * Modifications Copyright (C) 2021 Nordix Foundation.
* ================================================================================
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
import org.onap.policy.models.pdp.concepts.PdpUpdate;
import org.onap.policy.models.pdp.enums.PdpResponseStatus;
import org.onap.policy.models.pdp.enums.PdpState;
+import org.onap.policy.models.tosca.authorative.concepts.ToscaConceptIdentifier;
import org.onap.policy.models.tosca.authorative.concepts.ToscaPolicy;
-import org.onap.policy.models.tosca.authorative.concepts.ToscaPolicyTypeIdentifier;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
boolean success = true;
DomainMaker domain = fsm.getDomainMaker();
for (ToscaPolicy policy : policies) {
- ToscaPolicyTypeIdentifier policyType = policy.getTypeIdentifier();
+ ToscaConceptIdentifier policyType = policy.getTypeIdentifier();
PolicyTypeController controller = fsm.getController(policyType);
if (controller == null) {
logger.warn("no controller found for {}", policyType);
* ONAP
* ================================================================================
* Copyright (C) 2017-2019 AT&T Intellectual Property. All rights reserved.
+ * Modifications Copyright (C) 2021 Nordix Foundation.
* ================================================================================
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
package org.onap.policy.drools.lifecycle;
+import org.onap.policy.models.tosca.authorative.concepts.ToscaConceptIdentifier;
import org.onap.policy.models.tosca.authorative.concepts.ToscaPolicy;
-import org.onap.policy.models.tosca.authorative.concepts.ToscaPolicyTypeIdentifier;
/**
* Policy Type Controller.
/**
* Get Policy Type.
*/
- ToscaPolicyTypeIdentifier getPolicyType();
+ ToscaConceptIdentifier getPolicyType();
/**
* Deploy a Tosca Policy.
* ONAP
* ================================================================================
* Copyright (C) 2020 AT&T Intellectual Property. All rights reserved.
+ * Modifications Copyright (C) 2021 Nordix Foundation.
* ================================================================================
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
import org.onap.policy.common.utils.coder.CoderException;
import org.onap.policy.drools.domain.models.operational.OperationalPolicy;
import org.onap.policy.drools.system.PolicyController;
+import org.onap.policy.models.tosca.authorative.concepts.ToscaConceptIdentifier;
import org.onap.policy.models.tosca.authorative.concepts.ToscaPolicy;
-import org.onap.policy.models.tosca.authorative.concepts.ToscaPolicyTypeIdentifier;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
public class PolicyTypeDroolsController implements PolicyTypeController {
- protected static final ToscaPolicyTypeIdentifier compliantType =
- new ToscaPolicyTypeIdentifier("onap.policies.controlloop.operational.common.Drools", "1.0.0");
+ protected static final ToscaConceptIdentifier compliantType =
+ new ToscaConceptIdentifier("onap.policies.controlloop.operational.common.Drools", "1.0.0");
private static final Logger logger = LoggerFactory.getLogger(PolicyTypeDroolsController.class);
protected final Map<String, PolicyController> controllers = new ConcurrentHashMap<>();
@Getter
- protected final ToscaPolicyTypeIdentifier policyType;
+ protected final ToscaConceptIdentifier policyType;
@GsonJsonIgnore
protected final LifecycleFsm fsm;
* Creates a Policy Type Drools Controller.
*/
public PolicyTypeDroolsController(
- LifecycleFsm fsm, ToscaPolicyTypeIdentifier policyType, PolicyController controller) {
+ LifecycleFsm fsm, ToscaConceptIdentifier policyType, PolicyController controller) {
this.policyType = policyType;
this.controllers.put(controller.getName(), controller);
this.fsm = fsm;
* ONAP
* ================================================================================
* Copyright (C) 2020 AT&T Intellectual Property. All rights reserved.
+ * Modifications Copyright (C) 2021 Nordix Foundation.
* ================================================================================
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
import org.onap.policy.drools.system.PolicyController;
import org.onap.policy.drools.system.PolicyControllerConstants;
import org.onap.policy.drools.system.PolicyEngineConstants;
+import org.onap.policy.models.tosca.authorative.concepts.ToscaConceptIdentifier;
import org.onap.policy.models.tosca.authorative.concepts.ToscaPolicy;
-import org.onap.policy.models.tosca.authorative.concepts.ToscaPolicyTypeIdentifier;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
private static final Logger logger = LoggerFactory.getLogger(PolicyTypeNativeArtifactController.class);
@Getter
- protected final ToscaPolicyTypeIdentifier policyType;
+ protected final ToscaConceptIdentifier policyType;
@GsonJsonIgnore
protected final LifecycleFsm fsm;
- public PolicyTypeNativeArtifactController(LifecycleFsm fsm, ToscaPolicyTypeIdentifier policyType) {
+ public PolicyTypeNativeArtifactController(LifecycleFsm fsm, ToscaConceptIdentifier policyType) {
this.policyType = policyType;
this.fsm = fsm;
}
* ONAP
* ================================================================================
* Copyright (C) 2020 AT&T Intellectual Property. All rights reserved.
+ * Modifications Copyright (C) 2021 Nordix Foundation.
* ================================================================================
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
import org.onap.policy.drools.system.PolicyController;
import org.onap.policy.drools.system.PolicyControllerConstants;
import org.onap.policy.drools.system.PolicyEngineConstants;
+import org.onap.policy.models.tosca.authorative.concepts.ToscaConceptIdentifier;
import org.onap.policy.models.tosca.authorative.concepts.ToscaPolicy;
-import org.onap.policy.models.tosca.authorative.concepts.ToscaPolicyTypeIdentifier;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
private static final Logger logger = LoggerFactory.getLogger(PolicyTypeNativeDroolsController.class);
@Getter
- protected final ToscaPolicyTypeIdentifier policyType;
+ protected final ToscaConceptIdentifier policyType;
@GsonJsonIgnore
protected final LifecycleFsm fsm;
- public PolicyTypeNativeDroolsController(LifecycleFsm fsm, ToscaPolicyTypeIdentifier policyType) {
+ public PolicyTypeNativeDroolsController(LifecycleFsm fsm, ToscaConceptIdentifier policyType) {
this.policyType = policyType;
this.fsm = fsm;
}
/*-
* ============LICENSE_START=======================================================
* Copyright (C) 2019-2020 AT&T Intellectual Property. All rights reserved.
+ * Modifications Copyright (C) 2021 Nordix Foundation.
* ================================================================================
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
import org.onap.policy.models.pdp.concepts.PdpStateChange;
import org.onap.policy.models.pdp.concepts.PdpUpdate;
import org.onap.policy.models.pdp.enums.PdpState;
+import org.onap.policy.models.tosca.authorative.concepts.ToscaConceptIdentifier;
import org.onap.policy.models.tosca.authorative.concepts.ToscaPolicy;
-import org.onap.policy.models.tosca.authorative.concepts.ToscaPolicyIdentifier;
-import org.onap.policy.models.tosca.authorative.concepts.ToscaPolicyTypeIdentifier;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
@PathParam("policyTypeVersion") String policyTypeVersion) {
PolicyTypeController typeController =
LifecycleFeature.fsm.getPolicyTypesMap()
- .get(new ToscaPolicyTypeIdentifier(policyType, policyTypeVersion));
+ .get(new ToscaConceptIdentifier(policyType, policyTypeVersion));
if (typeController == null) {
return Response.status(Response.Status.NOT_FOUND).build();
}
ToscaPolicy policy;
try {
policy =
- LifecycleFeature.fsm.getPoliciesMap().get(new ToscaPolicyIdentifier(policyName, policyVersion));
+ LifecycleFeature.fsm.getPoliciesMap().get(new ToscaConceptIdentifier(policyName, policyVersion));
} catch (RuntimeException r) {
logger.debug("policy {}:{} has not been found", policyName, policyVersion, r);
return Response.status(Response.Status.NOT_FOUND).build();
ToscaPolicy policy;
try {
policy =
- LifecycleFeature.fsm.getPoliciesMap().get(new ToscaPolicyIdentifier(policyName, policyVersion));
+ LifecycleFeature.fsm.getPoliciesMap().get(new ToscaConceptIdentifier(policyName, policyVersion));
} catch (RuntimeException r) {
logger.debug("policy {}:{} has not been found", policyName, policyVersion, r);
return Response.status(Response.Status.NOT_FOUND).build();
/*
* ============LICENSE_START=======================================================
* Copyright (C) 2020 AT&T Intellectual Property. All rights reserved.
+ * Modifications Copyright (C) 2021 Nordix Foundation.
* ================================================================================
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
import org.onap.policy.models.pdp.concepts.PdpStateChange;
import org.onap.policy.models.pdp.concepts.PdpUpdate;
import org.onap.policy.models.pdp.enums.PdpState;
+import org.onap.policy.models.tosca.authorative.concepts.ToscaConceptIdentifier;
import org.onap.policy.models.tosca.authorative.concepts.ToscaPolicy;
-import org.onap.policy.models.tosca.authorative.concepts.ToscaPolicyTypeIdentifier;
/**
* Lifecycle State Active Test.
public void testUpdatePolicies() throws IOException, CoderException {
assertEquals(2, fsm.policyTypesMap.size());
assertNotNull(fsm.getPolicyTypesMap().get(
- new ToscaPolicyTypeIdentifier("onap.policies.native.drools.Controller", "1.0.0")));
+ new ToscaConceptIdentifier("onap.policies.native.drools.Controller", "1.0.0")));
assertNotNull(fsm.getPolicyTypesMap().get(
- new ToscaPolicyTypeIdentifier("onap.policies.native.drools.Artifact", "1.0.0")));
+ new ToscaConceptIdentifier("onap.policies.native.drools.Artifact", "1.0.0")));
//
// create controller using native policy
assertEquals(3, fsm.policyTypesMap.size());
assertNotNull(fsm.getPolicyTypesMap().get(
- new ToscaPolicyTypeIdentifier("onap.policies.native.drools.Controller", "1.0.0")));
+ new ToscaConceptIdentifier("onap.policies.native.drools.Controller", "1.0.0")));
assertNotNull(fsm.getPolicyTypesMap().get(
- new ToscaPolicyTypeIdentifier("onap.policies.native.drools.Artifact", "1.0.0")));
+ new ToscaConceptIdentifier("onap.policies.native.drools.Artifact", "1.0.0")));
assertNotNull(fsm.getPolicyTypesMap().get(
- new ToscaPolicyTypeIdentifier("onap.policies.controlloop.operational.common.Drools",
+ new ToscaConceptIdentifier("onap.policies.controlloop.operational.common.Drools",
"1.0.0")));
// invalid controller name
/*
* ============LICENSE_START=======================================================
* Copyright (C) 2019-2020 AT&T Intellectual Property. All rights reserved.
+ * Modifications Copyright (C) 2021 Nordix Foundation.
* ================================================================================
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
import org.onap.policy.models.pdp.concepts.PdpStatus;
import org.onap.policy.models.pdp.concepts.PdpUpdate;
import org.onap.policy.models.pdp.enums.PdpState;
+import org.onap.policy.models.tosca.authorative.concepts.ToscaConceptIdentifier;
import org.onap.policy.models.tosca.authorative.concepts.ToscaPolicy;
-import org.onap.policy.models.tosca.authorative.concepts.ToscaPolicyTypeIdentifier;
/**
* Lifecycle State Active Test.
assertEquals(qlength + 1, fsm.client.getSink().getRecentEvents().length);
assertEquals(3, fsm.policyTypesMap.size());
assertNotNull(fsm.getPolicyTypesMap().get(
- new ToscaPolicyTypeIdentifier("onap.policies.native.drools.Controller", "1.0.0")));
+ new ToscaConceptIdentifier("onap.policies.native.drools.Controller", "1.0.0")));
assertNotNull(fsm.getPolicyTypesMap().get(
- new ToscaPolicyTypeIdentifier("onap.policies.native.drools.Artifact", "1.0.0")));
+ new ToscaConceptIdentifier("onap.policies.native.drools.Artifact", "1.0.0")));
assertNotNull(fsm.getPolicyTypesMap().get(
- new ToscaPolicyTypeIdentifier("onap.policies.controlloop.operational.common.Drools",
+ new ToscaConceptIdentifier("onap.policies.controlloop.operational.common.Drools",
"1.0.0")));
PdpStatus cachedStatus = new StandardCoder()
.decode(fsm.client.getSink().getRecentEvents()[qlength], PdpStatus.class);
* ONAP
* ================================================================================
* Copyright (C) 2019-2020 AT&T Intellectual Property. All rights reserved.
+ * Modifications Copyright (C) 2021 Nordix Foundation.
* ================================================================================
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
import org.onap.policy.models.pdp.enums.PdpHealthStatus;
import org.onap.policy.models.pdp.enums.PdpMessageType;
import org.onap.policy.models.pdp.enums.PdpState;
+import org.onap.policy.models.tosca.authorative.concepts.ToscaConceptIdentifier;
import org.onap.policy.models.tosca.authorative.concepts.ToscaPolicy;
-import org.onap.policy.models.tosca.authorative.concepts.ToscaPolicyTypeIdentifier;
/**
* Lifecycle State Passive Tests.
fsm.start(controllerSupport.getController());
assertSame(controllerSupport.getController(),
((PolicyTypeDroolsController) fsm.getController(
- new ToscaPolicyTypeIdentifier(
+ new ToscaConceptIdentifier(
ControllerSupport.POLICY_TYPE_COMPLIANT_OP, ControllerSupport.POLICY_TYPE_VERSION)))
.controllers().get(0));
fsm.stop(controllerSupport.getController());
- assertNull(fsm.getController(new ToscaPolicyTypeIdentifier(ControllerSupport.POLICY_TYPE_COMPLIANT_OP,
+ assertNull(fsm.getController(new ToscaConceptIdentifier(ControllerSupport.POLICY_TYPE_COMPLIANT_OP,
ControllerSupport.POLICY_TYPE_VERSION)));
fsm.shutdown();
* ONAP
* ================================================================================
* Copyright (C) 2020 AT&T Intellectual Property. All rights reserved.
+ * Modifications Copyright (C) 2021 Nordix Foundation.
* ================================================================================
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
import org.onap.policy.drools.controller.internal.NullDroolsController;
import org.onap.policy.drools.domain.models.artifact.NativeArtifactPolicy;
import org.onap.policy.drools.system.PolicyControllerConstants;
+import org.onap.policy.models.tosca.authorative.concepts.ToscaConceptIdentifier;
import org.onap.policy.models.tosca.authorative.concepts.ToscaPolicy;
-import org.onap.policy.models.tosca.authorative.concepts.ToscaPolicyTypeIdentifier;
/**
* Rules Controller Test.
nativePolicy = fsm.getDomainMaker().convertTo(policy, NativeArtifactPolicy.class);
controller =
new PolicyTypeNativeArtifactController(fsm,
- new ToscaPolicyTypeIdentifier("onap.policies.native.drools.Artifact", "1.0.0"));
+ new ToscaConceptIdentifier("onap.policies.native.drools.Artifact", "1.0.0"));
assertTrue(controllerSupport.getController().getDrools().isBrained());
assertFalse(controllerSupport.getController().isAlive());
assertTrue(controllerSupport.getController().getDrools() instanceof MavenDroolsController);
}
-}
\ No newline at end of file
+}
/*
* ============LICENSE_START=======================================================
* Copyright (C) 2020 AT&T Intellectual Property. All rights reserved.
+ * Modifications Copyright (C) 2021 Nordix Foundation.
* ================================================================================
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
import org.onap.policy.drools.domain.models.artifact.NativeArtifactRulesArtifact;
import org.onap.policy.drools.domain.models.controller.ControllerPolicy;
import org.onap.policy.drools.policies.DomainMaker;
+import org.onap.policy.models.tosca.authorative.concepts.ToscaConceptIdentifier;
import org.onap.policy.models.tosca.authorative.concepts.ToscaPolicy;
-import org.onap.policy.models.tosca.authorative.concepts.ToscaPolicyTypeIdentifier;
import org.onap.policy.models.tosca.authorative.concepts.ToscaServiceTemplate;
public class DomainPolicyTypesTest {
ToscaPolicy toscaPolicy =
getExamplesPolicy(EXAMPLE_NATIVE_DROOLS_POLICY_JSON, EXAMPLE_NATIVE_DROOLS_POLICY_NAME);
- ToscaPolicyTypeIdentifier policyTypeId =
- new ToscaPolicyTypeIdentifier(NATIVE_DROOLS_POLICY_TYPE, "1.0.0");
+ ToscaConceptIdentifier policyTypeId =
+ new ToscaConceptIdentifier(NATIVE_DROOLS_POLICY_TYPE, "1.0.0");
domainMaker.isConformant(policyTypeId, rawNativeDroolsPolicy);
assertTrue(domainMaker.isConformant(toscaPolicy));
assertTrue(domainMaker
.isDomainConformant(
- new ToscaPolicyTypeIdentifier(domainDroolsPolicy2.getType(), domainDroolsPolicy2.getTypeVersion()),
+ new ToscaConceptIdentifier(domainDroolsPolicy2.getType(), domainDroolsPolicy2.getTypeVersion()),
domainDroolsPolicy2));
}
* ONAP
* ================================================================================
* Copyright (C) 2020 AT&T Intellectual Property. All rights reserved.
+ * Modifications Copyright (C) 2021 Nordix Foundation.
* ================================================================================
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
import org.onap.policy.common.utils.resources.ResourceUtils;
import org.onap.policy.drools.domain.models.Metadata;
import org.onap.policy.drools.policies.DomainMaker;
+import org.onap.policy.models.tosca.authorative.concepts.ToscaConceptIdentifier;
import org.onap.policy.models.tosca.authorative.concepts.ToscaPolicy;
-import org.onap.policy.models.tosca.authorative.concepts.ToscaPolicyTypeIdentifier;
import org.onap.policy.models.tosca.authorative.concepts.ToscaServiceTemplate;
public class OperationalPolicyTest {
String rawVcpeToscaPolicy = getExamplesPolicyString(VCPE_OPERATIONAL_DROOLS_POLICY_JSON, OP_POLICY_NAME_VCPE);
// valid "known" policy type with implicit schema
- ToscaPolicyTypeIdentifier operationalCompliantType =
- new ToscaPolicyTypeIdentifier(OPERATIONAL_DROOLS_POLICY_TYPE, "1.0.0");
+ ToscaConceptIdentifier operationalCompliantType =
+ new ToscaConceptIdentifier(OPERATIONAL_DROOLS_POLICY_TYPE, "1.0.0");
assertTrue(domainMaker.isConformant(operationalCompliantType, rawVcpeToscaPolicy));
assertNotNull(domainMaker.convertTo(operationalCompliantType, rawVcpeToscaPolicy, OperationalPolicy.class));
}
private String getExamplesPolicyString(String resourcePath, String policyName) throws CoderException {
return nonValCoder.encode(getExamplesPolicy(resourcePath, policyName));
}
-}
\ No newline at end of file
+}
* policy-management
* ================================================================================
* Copyright (C) 2017-2019 AT&T Intellectual Property. All rights reserved.
+ * Modifications Copyright (C) 2021 Nordix Foundation.
* ================================================================================
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
import org.onap.policy.common.endpoints.event.comm.TopicSource;
import org.onap.policy.drools.controller.DroolsController;
import org.onap.policy.drools.protocol.configuration.DroolsConfiguration;
-import org.onap.policy.models.tosca.authorative.concepts.ToscaPolicyTypeIdentifier;
+import org.onap.policy.models.tosca.authorative.concepts.ToscaConceptIdentifier;
/**
* A Policy Controller is the higher level unit of control. It corresponds to the ncomp equivalent
/**
* Get Policy Types supported by this controller.
*/
- List<ToscaPolicyTypeIdentifier> getPolicyTypes();
+ List<ToscaConceptIdentifier> getPolicyTypes();
/**
* Update maven configuration.
* ONAP
* ================================================================================
* Copyright (C) 2017-2020 AT&T Intellectual Property. All rights reserved.
+ * Modifications Copyright (C) 2021 Nordix Foundation.
* ================================================================================
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
import org.onap.policy.drools.protocol.configuration.DroolsConfiguration;
import org.onap.policy.drools.system.PolicyController;
import org.onap.policy.drools.utils.PropertyUtil;
-import org.onap.policy.models.tosca.authorative.concepts.ToscaPolicyTypeIdentifier;
+import org.onap.policy.models.tosca.authorative.concepts.ToscaConceptIdentifier;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
/**
* Policy Types.
*/
- private List<ToscaPolicyTypeIdentifier> policyTypes;
+ private List<ToscaConceptIdentifier> policyTypes;
/**
* Constructor version mainly used for bootstrapping at initialization time a policy engine
}
@Override
- public List<ToscaPolicyTypeIdentifier> getPolicyTypes() {
+ public List<ToscaConceptIdentifier> getPolicyTypes() {
if (!policyTypes.isEmpty()) {
return policyTypes;
}
.get()
.getBaseDomainNames()
.stream()
- .map(d -> new ToscaPolicyTypeIdentifier(d,
+ .map(d -> new ToscaConceptIdentifier(d,
DroolsPropertyConstants.DEFAULT_CONTROLLER_POLICY_TYPE_VERSION))
.collect(Collectors.toList());
}
- protected List<ToscaPolicyTypeIdentifier> getPolicyTypesFromProperties() {
- List<ToscaPolicyTypeIdentifier> policyTypeIds = new ArrayList<>();
+ protected List<ToscaConceptIdentifier> getPolicyTypesFromProperties() {
+ List<ToscaConceptIdentifier> policyTypeIds = new ArrayList<>();
String ptiPropValue = properties.getProperty(DroolsPropertyConstants.PROPERTY_CONTROLLER_POLICY_TYPES);
if (ptiPropValue == null) {
for (String pti : ptiPropList) {
String[] ptv = pti.split(":");
if (ptv.length == 1) {
- policyTypeIds.add(new ToscaPolicyTypeIdentifier(ptv[0],
+ policyTypeIds.add(new ToscaConceptIdentifier(ptv[0],
DroolsPropertyConstants.DEFAULT_CONTROLLER_POLICY_TYPE_VERSION));
} else if (ptv.length == 2) {
- policyTypeIds.add(new ToscaPolicyTypeIdentifier(ptv[0], ptv[1]));
+ policyTypeIds.add(new ToscaConceptIdentifier(ptv[0], ptv[1]));
}
}
/*
* ============LICENSE_START=======================================================
* Copyright (C) 2020 AT&T Intellectual Property. All rights reserved.
+ * Modifications Copyright (C) 2021 Nordix Foundation.
* ================================================================================
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
import org.onap.policy.common.utils.coder.StandardCoder;
import org.onap.policy.common.utils.coder.StandardValCoder;
import org.onap.policy.common.utils.resources.ResourceUtils;
+import org.onap.policy.models.tosca.authorative.concepts.ToscaConceptIdentifier;
import org.onap.policy.models.tosca.authorative.concepts.ToscaPolicy;
import org.onap.policy.models.tosca.authorative.concepts.ToscaPolicyType;
-import org.onap.policy.models.tosca.authorative.concepts.ToscaPolicyTypeIdentifier;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
/**
* policy-type -> schema validator map.
*/
- private final Map<ToscaPolicyTypeIdentifier, StandardValCoder> validators = new ConcurrentHashMap<>();
+ private final Map<ToscaConceptIdentifier, StandardValCoder> validators = new ConcurrentHashMap<>();
/**
* non-validation serialization coder.
/**
* Does this json conform to a registered policy type schema?.
*/
- public boolean isConformant(@NonNull ToscaPolicyTypeIdentifier policyType, @NonNull String json) {
+ public boolean isConformant(@NonNull ToscaConceptIdentifier policyType, @NonNull String json) {
if (!isRegistered(policyType)) {
return false;
}
/**
* Does this domain policy conforms to its schema definition?.
*/
- public <T> boolean isDomainConformant(@NonNull ToscaPolicyTypeIdentifier policyType, @NonNull T domainPolicy) {
+ public <T> boolean isDomainConformant(@NonNull ToscaConceptIdentifier policyType, @NonNull T domainPolicy) {
if (!isRegistered(policyType)) {
return false;
}
* Checks a domain policy conformance to its specification providing a list of errors
* in a ValidationFailedException.
*/
- public <T> boolean conformance(@NonNull ToscaPolicyTypeIdentifier policyType, T domainPolicy) {
+ public <T> boolean conformance(@NonNull ToscaConceptIdentifier policyType, T domainPolicy) {
if (!isRegistered(policyType)) {
return false;
/**
* Registers a known schema resource for validation.
*/
- public boolean registerValidator(@NonNull ToscaPolicyTypeIdentifier policyType) {
+ public boolean registerValidator(@NonNull ToscaConceptIdentifier policyType) {
//
// A known schema is one that embedded in a .jar in the classpath as a resource
// matching the following syntax: <policy-type-name>-<policy-type-version>.schema.json.
/**
* Registers/Overrides a new/known schema for a policy type.
*/
- public boolean registerValidator(@NonNull ToscaPolicyTypeIdentifier policyType, @NonNull String schema) {
+ public boolean registerValidator(@NonNull ToscaConceptIdentifier policyType, @NonNull String schema) {
try {
validators.put(policyType, new StandardValCoder(schema, policyType.toString()));
} catch (RuntimeException r) {
/**
* Converts a JSON policy into a Domain Policy.
*/
- public <T> T convertTo(@NonNull ToscaPolicyTypeIdentifier policyType, @NonNull String json, @NonNull Class<T> clazz)
+ public <T> T convertTo(@NonNull ToscaConceptIdentifier policyType, @NonNull String json, @NonNull Class<T> clazz)
throws CoderException {
if (isRegistered(policyType)) {
return validators.get(policyType).decode(json, clazz);
throw new UnsupportedOperationException("schema generation from policy type is not supported");
}
- public boolean isRegistered(@NonNull ToscaPolicyTypeIdentifier policyType) {
+ public boolean isRegistered(@NonNull ToscaConceptIdentifier policyType) {
return validators.containsKey(policyType) || registerValidator(policyType);
}
/*
* ============LICENSE_START=======================================================
* Copyright (C) 2020 AT&T Intellectual Property. All rights reserved.
+ * Modifications Copyright (C) 2021 Nordix Foundation.
* ================================================================================
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
import org.onap.policy.drools.models.domains.a.Metadata;
import org.onap.policy.drools.models.domains.a.Nested;
import org.onap.policy.drools.models.domains.a.Properties;
+import org.onap.policy.models.tosca.authorative.concepts.ToscaConceptIdentifier;
import org.onap.policy.models.tosca.authorative.concepts.ToscaPolicy;
import org.onap.policy.models.tosca.authorative.concepts.ToscaPolicyType;
-import org.onap.policy.models.tosca.authorative.concepts.ToscaPolicyTypeIdentifier;
public class DomainMakerTest {
@Test
public void testIsConformantString() throws IOException {
- ToscaPolicyTypeIdentifier policyTypeId =
- new ToscaPolicyTypeIdentifier("policy.type.A", "1.0.0");
+ ToscaConceptIdentifier policyTypeId =
+ new ToscaConceptIdentifier("policy.type.A", "1.0.0");
String rawJsonPolicyType =
getJsonFromFile("src/test/resources/policyA.json");
@Test
public void testIsDomainConformant() {
- ToscaPolicyTypeIdentifier policyTypeId =
- new ToscaPolicyTypeIdentifier("policy.type.A", "1.0.0");
+ ToscaConceptIdentifier policyTypeId =
+ new ToscaConceptIdentifier("policy.type.A", "1.0.0");
DomainAPolicy domainAPolicy = createDomainPolicy();
assertDomainPolicy(domainAPolicy);
domainAPolicy.getProperties().getNested().setNested1("");
- ToscaPolicyTypeIdentifier ident1 = policy1.getTypeIdentifier();
+ ToscaConceptIdentifier ident1 = policy1.getTypeIdentifier();
assertThatThrownBy(() -> domainMaker.conformance(ident1, domainAPolicy))
.isInstanceOf(ValidationFailedException.class)
.hasMessageContaining("Pattern ^(.+)$ is not contained in text");
@Test
public void testRegisterValidator() throws IOException, CoderException {
- ToscaPolicyTypeIdentifier policyTypeId =
- new ToscaPolicyTypeIdentifier("policy.type.external", "9.9.9");
+ ToscaConceptIdentifier policyTypeId =
+ new ToscaConceptIdentifier("policy.type.external", "9.9.9");
assertTrue(domainMaker.registerValidator(policyTypeId,
getJsonFromFile("src/test/resources/policy.type.external-9.9.9.schema.json")));
@Test
public void testIsRegistered() {
- ToscaPolicyTypeIdentifier policyTypeId1 =
- new ToscaPolicyTypeIdentifier("policy.type.A", "1.0.0");
+ ToscaConceptIdentifier policyTypeId1 =
+ new ToscaConceptIdentifier("policy.type.A", "1.0.0");
assertTrue(domainMaker.isRegistered(policyTypeId1));
- ToscaPolicyTypeIdentifier policyTypeId2 =
- new ToscaPolicyTypeIdentifier("policy.type.external", "7.7.9");
+ ToscaConceptIdentifier policyTypeId2 =
+ new ToscaConceptIdentifier("policy.type.external", "7.7.9");
assertFalse(domainMaker.isRegistered(policyTypeId2));
}
assertEquals(true, domainAPolicy.getProperties().getNested().isNested2());
assertEquals(50, domainAPolicy.getProperties().getNested().getNested3());
}
-}
\ No newline at end of file
+}