/*-
* ============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.common.endpoints.http.client.HttpClientConfigException;
import org.onap.policy.common.endpoints.http.client.HttpClientFactoryInstance;
import org.onap.policy.common.endpoints.parameters.RestServerParameters;
-import org.onap.policy.models.tosca.authorative.concepts.ToscaPolicyTypeIdentifier;
+import org.onap.policy.models.tosca.authorative.concepts.ToscaConceptIdentifier;
import org.onap.policy.models.tosca.authorative.concepts.ToscaServiceTemplate;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
* @return the desired policy type
* @throws PolicyApiException if an error occurs
*/
- public ToscaServiceTemplate getPolicyType(ToscaPolicyTypeIdentifier type) throws PolicyApiException {
+ public ToscaServiceTemplate getPolicyType(ToscaConceptIdentifier type) throws PolicyApiException {
try {
Response resp = httpClient
* ONAP
* ================================================================================
* Copyright (C) 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.parameters.RestServerParameters;
import org.onap.policy.models.decisions.concepts.DecisionRequest;
import org.onap.policy.models.decisions.concepts.DecisionResponse;
+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;
/**
* This interface is how the XACML REST controller can communicate
*
* @return List of Strings (eg. "onap.policy.foo.bar")
*/
- List<ToscaPolicyTypeIdentifier> supportedPolicyTypes();
+ List<ToscaConceptIdentifier> supportedPolicyTypes();
/**
* Asks whether the application can support the incoming
* @param toscaPolicyId Identifier for policy type
* @return true if supported
*/
- boolean canSupportPolicyType(ToscaPolicyTypeIdentifier toscaPolicyId);
+ boolean canSupportPolicyType(ToscaConceptIdentifier toscaPolicyId);
/**
* Load a Tosca Policy.
* ONAP
* ================================================================================
* Copyright (C) 2020 AT&T Intellectual Property. All rights reserved.
- * Modifications Copyright (C) 2020 Nordix Foundation.
+ * Modifications Copyright (C) 2020-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 java.util.function.Function;
import lombok.Getter;
import lombok.NonNull;
+import org.onap.policy.models.tosca.authorative.concepts.ToscaConceptIdentifier;
import org.onap.policy.models.tosca.authorative.concepts.ToscaDataType;
-import org.onap.policy.models.tosca.authorative.concepts.ToscaPolicyIdentifier;
import org.onap.policy.models.tosca.authorative.concepts.ToscaPolicyType;
import org.onap.policy.models.tosca.authorative.concepts.ToscaProperty;
import org.onap.policy.models.tosca.authorative.concepts.ToscaSchemaDefinition;
);
//@formatter:on
- ToscaPolicyIdentifier policyId;
+ ToscaConceptIdentifier policyId;
Map<String, MatchableProperty> matchables = new HashMap<>();
public MatchablePolicyType(@NonNull ToscaPolicyType policyType, @NonNull MatchableCallback callback) {
- this.policyId = new ToscaPolicyIdentifier(policyType.getName(), policyType.getVersion());
+ this.policyId = new ToscaConceptIdentifier(policyType.getName(), policyType.getVersion());
scanPolicyType(policyType, callback);
}
* 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.common.utils.coder.StandardYamlCoder;
import org.onap.policy.models.decisions.concepts.DecisionRequest;
import org.onap.policy.models.decisions.concepts.DecisionResponse;
+import org.onap.policy.models.tosca.authorative.concepts.ToscaConceptIdentifier;
import org.onap.policy.models.tosca.authorative.concepts.ToscaDataType;
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.onap.policy.models.tosca.authorative.concepts.ToscaServiceTemplate;
import org.onap.policy.models.tosca.simple.concepts.JpaToscaServiceTemplate;
import org.onap.policy.pdp.xacml.application.common.OnapObligation;
private static final Logger LOGGER = LoggerFactory.getLogger(StdMatchableTranslator.class);
private static final StandardYamlCoder standardYamlCoder = new StandardYamlCoder();
- private final Map<ToscaPolicyTypeIdentifier, ToscaServiceTemplate> matchablePolicyTypes = new HashMap<>();
- private final Map<ToscaPolicyTypeIdentifier, MatchablePolicyType> matchableCache = new HashMap<>();
+ private final Map<ToscaConceptIdentifier, ToscaServiceTemplate> matchablePolicyTypes = new HashMap<>();
+ private final Map<ToscaConceptIdentifier, MatchablePolicyType> matchableCache = new HashMap<>();
@Setter
private RestServerParameters apiRestParameters;
@Override
public ToscaPolicyType retrievePolicyType(String derivedFrom) {
- ToscaServiceTemplate template = this.findPolicyType(new ToscaPolicyTypeIdentifier(derivedFrom, "1.0.0"));
+ ToscaServiceTemplate template = this.findPolicyType(new ToscaConceptIdentifier(derivedFrom, "1.0.0"));
if (template == null) {
LOGGER.error("Could not retrieve Policy Type {}", derivedFrom);
return null;
}
/**
- * findPolicyType - given the ToscaPolicyTypeIdentifier, finds it in memory, or
+ * findPolicyType - given the ToscaConceptIdentifier, finds it in memory, or
* then tries to find it either locally on disk or pull it from the Policy
* Lifecycle API the given TOSCA Policy Type.
*
- * @param policyTypeId ToscaPolicyTypeIdentifier to find
+ * @param policyTypeId ToscaConceptIdentifier to find
* @return ToscaPolicyType object. Can be null if failure.
*/
- private ToscaServiceTemplate findPolicyType(ToscaPolicyTypeIdentifier policyTypeId) {
+ private ToscaServiceTemplate findPolicyType(ToscaConceptIdentifier policyTypeId) {
//
// Is it loaded in memory?
//
}
/**
- * loadPolicyType - Tries to load the given ToscaPolicyTypeIdentifier from local
+ * loadPolicyType - Tries to load the given ToscaConceptIdentifier from local
* storage. If it does not exist, will then attempt to pull from Policy Lifecycle
* API.
*
- * @param policyTypeId ToscaPolicyTypeIdentifier input
+ * @param policyTypeId ToscaConceptIdentifier input
* @return ToscaPolicyType object. Null if failure.
*/
- private ToscaServiceTemplate loadPolicyType(ToscaPolicyTypeIdentifier policyTypeId) {
+ private ToscaServiceTemplate loadPolicyType(ToscaConceptIdentifier policyTypeId) {
//
// Construct what the file name should be
//
}
/**
- * pullPolicyType - pulls the given ToscaPolicyTypeIdentifier from the Policy Lifecycle API.
+ * pullPolicyType - pulls the given ToscaConceptIdentifier from the Policy Lifecycle API.
* If successful, will store it locally given the policyTypePath.
*
- * @param policyTypeId ToscaPolicyTypeIdentifier
+ * @param policyTypeId ToscaConceptIdentifier
* @param policyTypePath Path object to store locally
* @return ToscaPolicyType object. Null if failure.
*/
- private synchronized ToscaServiceTemplate pullPolicyType(ToscaPolicyTypeIdentifier policyTypeId,
+ private synchronized ToscaServiceTemplate pullPolicyType(ToscaConceptIdentifier policyTypeId,
Path policyTypePath) {
//
// This is what we return
* constructLocalFilePath - common method to ensure the name of the local file for the
* policy type is the same.
*
- * @param policyTypeId ToscaPolicyTypeIdentifier
+ * @param policyTypeId ToscaConceptIdentifier
* @return Path object
*/
- private Path constructLocalFilePath(ToscaPolicyTypeIdentifier policyTypeId) {
+ private Path constructLocalFilePath(ToscaConceptIdentifier policyTypeId) {
return Paths.get(this.pathForData.toAbsolutePath().toString(), policyTypeId.getName() + "-"
+ policyTypeId.getVersion() + ".yaml");
}
* 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.common.endpoints.parameters.RestServerParameters;
import org.onap.policy.models.decisions.concepts.DecisionRequest;
import org.onap.policy.models.decisions.concepts.DecisionResponse;
+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.pdp.xacml.application.common.ToscaPolicyConversionException;
import org.onap.policy.pdp.xacml.application.common.ToscaPolicyTranslator;
import org.onap.policy.pdp.xacml.application.common.XacmlApplicationException;
protected String applicationName = "Please Override";
protected List<String> actions = Collections.emptyList();
- protected List<ToscaPolicyTypeIdentifier> supportedPolicyTypes = new ArrayList<>();
+ protected List<ToscaConceptIdentifier> supportedPolicyTypes = new ArrayList<>();
private Path pathForData = null;
@Getter
}
@Override
- public List<ToscaPolicyTypeIdentifier> supportedPolicyTypes() {
+ public List<ToscaConceptIdentifier> supportedPolicyTypes() {
return supportedPolicyTypes;
}
@Override
- public boolean canSupportPolicyType(ToscaPolicyTypeIdentifier policyTypeId) {
+ public boolean canSupportPolicyType(ToscaConceptIdentifier policyTypeId) {
throw new UnsupportedOperationException("Please override and implement canSupportPolicyType");
}
/*-
* ============LICENSE_START=======================================================
* Copyright (C) 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.properties.PolicyEndPointProperties;
import org.onap.policy.common.gson.GsonMessageBodyHandler;
import org.onap.policy.common.utils.network.NetworkUtil;
+import org.onap.policy.models.tosca.authorative.concepts.ToscaConceptIdentifier;
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;
@Test
public void testGetPolicyType() throws Exception {
- assertNotNull(api.getPolicyType(new ToscaPolicyTypeIdentifier(MY_TYPE, MY_VERSION)));
+ assertNotNull(api.getPolicyType(new ToscaConceptIdentifier(MY_TYPE, MY_VERSION)));
- assertThatThrownBy(() -> api.getPolicyType(new ToscaPolicyTypeIdentifier(INVALID_TYPE, MY_VERSION)))
+ assertThatThrownBy(() -> api.getPolicyType(new ToscaConceptIdentifier(INVALID_TYPE, MY_VERSION)))
.isInstanceOf(PolicyApiException.class);
- assertThatThrownBy(() -> api.getPolicyType(new ToscaPolicyTypeIdentifier(UNKNOWN_TYPE, MY_VERSION)))
+ assertThatThrownBy(() -> api.getPolicyType(new ToscaConceptIdentifier(UNKNOWN_TYPE, MY_VERSION)))
.isInstanceOf(NotFoundException.class);
- assertThatThrownBy(() -> api.getPolicyType(new ToscaPolicyTypeIdentifier(NOT_A_TYPE, MY_VERSION)))
+ assertThatThrownBy(() -> api.getPolicyType(new ToscaConceptIdentifier(NOT_A_TYPE, MY_VERSION)))
.isInstanceOf(PolicyApiException.class);
// connect to a port that has no server
when(clientParams.getPort()).thenReturn(NetworkUtil.allocPort());
api = new PolicyApiCaller(clientParams);
- assertThatThrownBy(() -> api.getPolicyType(new ToscaPolicyTypeIdentifier(MY_TYPE, MY_VERSION)))
+ assertThatThrownBy(() -> api.getPolicyType(new ToscaConceptIdentifier(MY_TYPE, MY_VERSION)))
.isInstanceOf(PolicyApiException.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.
package org.onap.policy.xacml.pdp.application.guard;
import java.util.Arrays;
-import org.onap.policy.models.tosca.authorative.concepts.ToscaPolicyTypeIdentifier;
+import org.onap.policy.models.tosca.authorative.concepts.ToscaConceptIdentifier;
import org.onap.policy.pdp.xacml.application.common.ToscaPolicyTranslator;
import org.onap.policy.pdp.xacml.application.common.std.StdXacmlApplicationServiceProvider;
import org.slf4j.Logger;
applicationName = "guard";
actions = Arrays.asList("guard");
- this.supportedPolicyTypes.add(new ToscaPolicyTypeIdentifier(
+ this.supportedPolicyTypes.add(new ToscaConceptIdentifier(
GuardTranslator.POLICYTYPE_FREQUENCY,
STRING_VERSION100));
- this.supportedPolicyTypes.add(new ToscaPolicyTypeIdentifier(
+ this.supportedPolicyTypes.add(new ToscaConceptIdentifier(
GuardTranslator.POLICYTYPE_MINMAX,
STRING_VERSION100));
- this.supportedPolicyTypes.add(new ToscaPolicyTypeIdentifier(
+ this.supportedPolicyTypes.add(new ToscaConceptIdentifier(
GuardTranslator.POLICYTYPE_BLACKLIST,
STRING_VERSION100));
- this.supportedPolicyTypes.add(new ToscaPolicyTypeIdentifier(
+ this.supportedPolicyTypes.add(new ToscaConceptIdentifier(
GuardTranslator.POLICYTYPE_FILTER,
STRING_VERSION100));
- this.supportedPolicyTypes.add(new ToscaPolicyTypeIdentifier(
+ this.supportedPolicyTypes.add(new ToscaConceptIdentifier(
"onap.policies.controlloop.guard.coordination.FirstBlocksSecond",
STRING_VERSION100));
}
@Override
- public boolean canSupportPolicyType(ToscaPolicyTypeIdentifier policyTypeId) {
+ public boolean canSupportPolicyType(ToscaConceptIdentifier policyTypeId) {
//
// For the time being, restrict this if the version isn't known.
// Could be too difficult to support changing of versions dynamically.
//
- for (ToscaPolicyTypeIdentifier supported : this.supportedPolicyTypes) {
+ for (ToscaConceptIdentifier supported : this.supportedPolicyTypes) {
if (policyTypeId.equals(supported)) {
return true;
}
* 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.guard.OperationsHistory;
import org.onap.policy.models.decisions.concepts.DecisionRequest;
import org.onap.policy.models.decisions.concepts.DecisionResponse;
+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.pdp.xacml.application.common.XacmlApplicationException;
import org.onap.policy.pdp.xacml.application.common.XacmlApplicationServiceProvider;
import org.onap.policy.pdp.xacml.application.common.XacmlPolicyUtils;
assertThat(service.supportedPolicyTypes()).isNotEmpty();
assertThat(service.supportedPolicyTypes().size()).isEqualTo(5);
assertThat(service.canSupportPolicyType(
- new ToscaPolicyTypeIdentifier("onap.policies.controlloop.guard.common.FrequencyLimiter", "1.0.0")))
+ new ToscaConceptIdentifier("onap.policies.controlloop.guard.common.FrequencyLimiter", "1.0.0")))
.isTrue();
assertThat(service.canSupportPolicyType(
- new ToscaPolicyTypeIdentifier("onap.policies.controlloop.guard.common.FrequencyLimiter", "1.0.1")))
+ new ToscaConceptIdentifier("onap.policies.controlloop.guard.common.FrequencyLimiter", "1.0.1")))
.isFalse();
assertThat(service.canSupportPolicyType(
- new ToscaPolicyTypeIdentifier("onap.policies.controlloop.guard.common.MinMax", "1.0.0"))).isTrue();
+ new ToscaConceptIdentifier("onap.policies.controlloop.guard.common.MinMax", "1.0.0"))).isTrue();
assertThat(service.canSupportPolicyType(
- new ToscaPolicyTypeIdentifier("onap.policies.controlloop.guard.common.MinMax", "1.0.1"))).isFalse();
+ new ToscaConceptIdentifier("onap.policies.controlloop.guard.common.MinMax", "1.0.1"))).isFalse();
assertThat(service.canSupportPolicyType(
- new ToscaPolicyTypeIdentifier("onap.policies.controlloop.guard.common.Blacklist", "1.0.0"))).isTrue();
+ new ToscaConceptIdentifier("onap.policies.controlloop.guard.common.Blacklist", "1.0.0"))).isTrue();
assertThat(service.canSupportPolicyType(
- new ToscaPolicyTypeIdentifier("onap.policies.controlloop.guard.common.Blacklist", "1.0.1"))).isFalse();
- assertThat(service.canSupportPolicyType(new ToscaPolicyTypeIdentifier(
+ new ToscaConceptIdentifier("onap.policies.controlloop.guard.common.Blacklist", "1.0.1"))).isFalse();
+ assertThat(service.canSupportPolicyType(new ToscaConceptIdentifier(
"onap.policies.controlloop.guard.coordination.FirstBlocksSecond", "1.0.0"))).isTrue();
- assertThat(service.canSupportPolicyType(new ToscaPolicyTypeIdentifier(
+ assertThat(service.canSupportPolicyType(new ToscaConceptIdentifier(
"onap.policies.controlloop.guard.coordination.FirstBlocksSecond", "1.0.1"))).isFalse();
- assertThat(service.canSupportPolicyType(new ToscaPolicyTypeIdentifier("onap.foo", "1.0.1"))).isFalse();
+ assertThat(service.canSupportPolicyType(new ToscaConceptIdentifier("onap.foo", "1.0.1"))).isFalse();
assertThat(service.canSupportPolicyType(
- new ToscaPolicyTypeIdentifier("onap.policies.controlloop.guard.common.Filter", "1.0.0"))).isTrue();
+ new ToscaConceptIdentifier("onap.policies.controlloop.guard.common.Filter", "1.0.0"))).isTrue();
}
@Test
* 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 java.nio.file.Path;
import java.util.Arrays;
import org.onap.policy.common.endpoints.parameters.RestServerParameters;
-import org.onap.policy.models.tosca.authorative.concepts.ToscaPolicyTypeIdentifier;
+import org.onap.policy.models.tosca.authorative.concepts.ToscaConceptIdentifier;
import org.onap.policy.pdp.xacml.application.common.ToscaPolicyTranslator;
import org.onap.policy.pdp.xacml.application.common.XacmlApplicationException;
import org.onap.policy.pdp.xacml.application.common.std.StdMatchableTranslator;
public static final String ONAP_MATCH_BASE_POLICY_TYPE = "onap.policies.Match";
public static final String ONAP_MATCH_DERIVED_POLICY_TYPE = "onap.policies.match.";
- private static final ToscaPolicyTypeIdentifier supportedPolicy = new ToscaPolicyTypeIdentifier(
+ private static final ToscaConceptIdentifier supportedPolicy = new ToscaConceptIdentifier(
ONAP_MATCH_BASE_POLICY_TYPE, "1.0.0");
private StdMatchableTranslator translator = new StdMatchableTranslator();
}
@Override
- public boolean canSupportPolicyType(ToscaPolicyTypeIdentifier policyTypeId) {
+ public boolean canSupportPolicyType(ToscaConceptIdentifier policyTypeId) {
return policyTypeId.getName().startsWith(ONAP_MATCH_DERIVED_POLICY_TYPE);
}
* 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.TextFileUtils;
import org.onap.policy.models.decisions.concepts.DecisionRequest;
import org.onap.policy.models.decisions.concepts.DecisionResponse;
-import org.onap.policy.models.tosca.authorative.concepts.ToscaPolicyTypeIdentifier;
+import org.onap.policy.models.tosca.authorative.concepts.ToscaConceptIdentifier;
import org.onap.policy.pdp.xacml.application.common.XacmlApplicationException;
import org.onap.policy.pdp.xacml.application.common.XacmlApplicationServiceProvider;
import org.onap.policy.pdp.xacml.application.common.XacmlPolicyUtils;
// Ensure it has the supported policy types and
// can support the correct policy types.
//
- assertThat(service.canSupportPolicyType(new ToscaPolicyTypeIdentifier(
+ assertThat(service.canSupportPolicyType(new ToscaConceptIdentifier(
"onap.policies.match.Test", "1.0.0"))).isTrue();
- assertThat(service.canSupportPolicyType(new ToscaPolicyTypeIdentifier(
+ assertThat(service.canSupportPolicyType(new ToscaConceptIdentifier(
"onap.foobar", "1.0.0"))).isFalse();
}
* 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.apache.commons.lang3.tuple.Pair;
import org.onap.policy.models.decisions.concepts.DecisionRequest;
import org.onap.policy.models.decisions.concepts.DecisionResponse;
-import org.onap.policy.models.tosca.authorative.concepts.ToscaPolicyTypeIdentifier;
+import org.onap.policy.models.tosca.authorative.concepts.ToscaConceptIdentifier;
import org.onap.policy.pdp.xacml.application.common.ToscaPolicyTranslator;
import org.onap.policy.pdp.xacml.application.common.std.StdCombinedPolicyResultsTranslator;
import org.onap.policy.pdp.xacml.application.common.std.StdXacmlApplicationServiceProvider;
//
// By default this supports just Monitoring policy types
//
- supportedPolicyTypes.add(new ToscaPolicyTypeIdentifier(ONAP_MONITORING_BASE_POLICY_TYPE, VERSION_100));
+ supportedPolicyTypes.add(new ToscaConceptIdentifier(ONAP_MONITORING_BASE_POLICY_TYPE, VERSION_100));
}
@Override
- public boolean canSupportPolicyType(ToscaPolicyTypeIdentifier policyTypeId) {
+ public boolean canSupportPolicyType(ToscaConceptIdentifier policyTypeId) {
//
// For Monitoring, we will attempt to support all versions
// of the policy type. Since we are only packaging a decision
* 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.common.utils.resources.TextFileUtils;
import org.onap.policy.models.decisions.concepts.DecisionRequest;
import org.onap.policy.models.decisions.concepts.DecisionResponse;
+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.pdp.xacml.application.common.XacmlApplicationException;
import org.onap.policy.pdp.xacml.application.common.XacmlApplicationServiceProvider;
import org.onap.policy.pdp.xacml.application.common.XacmlPolicyUtils;
// can support the correct policy types.
//
assertThat(service.canSupportPolicyType(
- new ToscaPolicyTypeIdentifier("onap.policies.monitoring.tcagen2", "1.0.0"))).isTrue();
+ new ToscaConceptIdentifier("onap.policies.monitoring.tcagen2", "1.0.0"))).isTrue();
assertThat(service.canSupportPolicyType(
- new ToscaPolicyTypeIdentifier(
+ new ToscaConceptIdentifier(
"onap.policies.monitoring.foobar", "1.0.1"))).isTrue();
assertThat(service.canSupportPolicyType(
- new ToscaPolicyTypeIdentifier("onap.foobar", "1.0.0"))).isFalse();
+ new ToscaConceptIdentifier("onap.foobar", "1.0.0"))).isFalse();
//
// Ensure it supports decisions
//
* 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.
package org.onap.policy.xacml.pdp.application.naming;
import java.util.Arrays;
-import org.onap.policy.models.tosca.authorative.concepts.ToscaPolicyTypeIdentifier;
+import org.onap.policy.models.tosca.authorative.concepts.ToscaConceptIdentifier;
import org.onap.policy.pdp.xacml.application.common.ToscaPolicyTranslator;
import org.onap.policy.pdp.xacml.application.common.std.StdCombinedPolicyResultsTranslator;
import org.onap.policy.pdp.xacml.application.common.std.StdXacmlApplicationServiceProvider;
public class NamingPdpApplication extends StdXacmlApplicationServiceProvider {
- private static final ToscaPolicyTypeIdentifier namingPolicyType = new ToscaPolicyTypeIdentifier(
+ private static final ToscaConceptIdentifier namingPolicyType = new ToscaConceptIdentifier(
"onap.policies.Naming", "1.0.0");
private StdCombinedPolicyResultsTranslator translator = new StdCombinedPolicyResultsTranslator();
}
@Override
- public boolean canSupportPolicyType(ToscaPolicyTypeIdentifier policyTypeId) {
+ public boolean canSupportPolicyType(ToscaConceptIdentifier policyTypeId) {
return namingPolicyType.equals(policyTypeId);
}
* 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.common.utils.resources.TextFileUtils;
import org.onap.policy.models.decisions.concepts.DecisionRequest;
import org.onap.policy.models.decisions.concepts.DecisionResponse;
-import org.onap.policy.models.tosca.authorative.concepts.ToscaPolicyTypeIdentifier;
+import org.onap.policy.models.tosca.authorative.concepts.ToscaConceptIdentifier;
import org.onap.policy.pdp.xacml.application.common.XacmlApplicationException;
import org.onap.policy.pdp.xacml.application.common.XacmlApplicationServiceProvider;
import org.onap.policy.pdp.xacml.application.common.XacmlPolicyUtils;
// Ensure it has the supported policy types and
// can support the correct policy types.
//
- assertThat(service.canSupportPolicyType(new ToscaPolicyTypeIdentifier(
+ assertThat(service.canSupportPolicyType(new ToscaConceptIdentifier(
"onap.policies.Naming", "1.0.0"))).isTrue();
- assertThat(service.canSupportPolicyType(new ToscaPolicyTypeIdentifier(
+ assertThat(service.canSupportPolicyType(new ToscaConceptIdentifier(
"onap.foobar", "1.0.0"))).isFalse();
}
* 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 com.att.research.xacml.api.Request;
import com.att.research.xacml.api.Response;
import java.util.Arrays;
-import org.onap.policy.models.tosca.authorative.concepts.ToscaPolicyTypeIdentifier;
+import org.onap.policy.models.tosca.authorative.concepts.ToscaConceptIdentifier;
import org.onap.policy.pdp.xacml.application.common.ToscaPolicyTranslator;
import org.onap.policy.pdp.xacml.application.common.std.StdXacmlApplicationServiceProvider;
*/
public class NativePdpApplication extends StdXacmlApplicationServiceProvider {
- private static final ToscaPolicyTypeIdentifier nativePolicyType = new ToscaPolicyTypeIdentifier(
+ private static final ToscaConceptIdentifier nativePolicyType = new ToscaConceptIdentifier(
"onap.policies.native.Xacml", "1.0.0");
private NativePdpApplicationTranslator translator = new NativePdpApplicationTranslator();
}
@Override
- public boolean canSupportPolicyType(ToscaPolicyTypeIdentifier policyTypeId) {
+ public boolean canSupportPolicyType(ToscaConceptIdentifier policyTypeId) {
return nativePolicyType.equals(policyTypeId);
}
* 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.StandardYamlCoder;
import org.onap.policy.common.utils.resources.ResourceUtils;
import org.onap.policy.common.utils.resources.TextFileUtils;
+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;
import org.onap.policy.models.tosca.simple.concepts.JpaToscaServiceTemplate;
import org.onap.policy.pdp.xacml.application.common.ToscaPolicyConversionException;
assertThat(translator.convertResponse(null)).isNull();
NativePdpApplication application = new NativePdpApplication();
- assertThat(application.canSupportPolicyType(new ToscaPolicyTypeIdentifier(
+ assertThat(application.canSupportPolicyType(new ToscaConceptIdentifier(
"onap.policies.native.Xacml", "1.0.0"))).isTrue();
- assertThat(application.canSupportPolicyType(new ToscaPolicyTypeIdentifier(
+ assertThat(application.canSupportPolicyType(new ToscaConceptIdentifier(
"onap.policies.native.SomethingElse", "1.0.0"))).isFalse();
assertThat(application.actionDecisionsSupported()).contains("native");
}
assertThat(decision).hasToString(expected);
LOGGER.info("Xacml response we received {}", DOMResponse.toString(response));
}
-}
\ No newline at end of file
+}
* 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.common.endpoints.parameters.RestServerParameters;
import org.onap.policy.models.decisions.concepts.DecisionRequest;
import org.onap.policy.models.decisions.concepts.DecisionResponse;
-import org.onap.policy.models.tosca.authorative.concepts.ToscaPolicyTypeIdentifier;
+import org.onap.policy.models.tosca.authorative.concepts.ToscaConceptIdentifier;
import org.onap.policy.pdp.xacml.application.common.ToscaDictionary;
import org.onap.policy.pdp.xacml.application.common.ToscaPolicyTranslator;
import org.onap.policy.pdp.xacml.application.common.XacmlApplicationException;
applicationName = "optimization";
actions = Arrays.asList("optimize");
- this.supportedPolicyTypes.add(new ToscaPolicyTypeIdentifier(POLICYTYPE_AFFINITY, STRING_VERSION100));
- this.supportedPolicyTypes.add(new ToscaPolicyTypeIdentifier(POLICYTYPE_DISTANCE, STRING_VERSION100));
- this.supportedPolicyTypes.add(new ToscaPolicyTypeIdentifier(POLICYTYPE_HPA, STRING_VERSION100));
- this.supportedPolicyTypes.add(new ToscaPolicyTypeIdentifier(POLICYTYPE_OPTIMIZATION, STRING_VERSION100));
- this.supportedPolicyTypes.add(new ToscaPolicyTypeIdentifier(POLICYTYPE_PCI, STRING_VERSION100));
- this.supportedPolicyTypes.add(new ToscaPolicyTypeIdentifier(POLICYTYPE_QUERY, STRING_VERSION100));
- this.supportedPolicyTypes.add(new ToscaPolicyTypeIdentifier(POLICYTYPE_SUBSCRIBER, STRING_VERSION100));
- this.supportedPolicyTypes.add(new ToscaPolicyTypeIdentifier(POLICYTYPE_VIMFIT, STRING_VERSION100));
- this.supportedPolicyTypes.add(new ToscaPolicyTypeIdentifier(POLICYTYPE_VNF, STRING_VERSION100));
+ this.supportedPolicyTypes.add(new ToscaConceptIdentifier(POLICYTYPE_AFFINITY, STRING_VERSION100));
+ this.supportedPolicyTypes.add(new ToscaConceptIdentifier(POLICYTYPE_DISTANCE, STRING_VERSION100));
+ this.supportedPolicyTypes.add(new ToscaConceptIdentifier(POLICYTYPE_HPA, STRING_VERSION100));
+ this.supportedPolicyTypes.add(new ToscaConceptIdentifier(POLICYTYPE_OPTIMIZATION, STRING_VERSION100));
+ this.supportedPolicyTypes.add(new ToscaConceptIdentifier(POLICYTYPE_PCI, STRING_VERSION100));
+ this.supportedPolicyTypes.add(new ToscaConceptIdentifier(POLICYTYPE_QUERY, STRING_VERSION100));
+ this.supportedPolicyTypes.add(new ToscaConceptIdentifier(POLICYTYPE_SUBSCRIBER, STRING_VERSION100));
+ this.supportedPolicyTypes.add(new ToscaConceptIdentifier(POLICYTYPE_VIMFIT, STRING_VERSION100));
+ this.supportedPolicyTypes.add(new ToscaConceptIdentifier(POLICYTYPE_VNF, STRING_VERSION100));
}
@Override
}
@Override
- public boolean canSupportPolicyType(ToscaPolicyTypeIdentifier policyTypeId) {
+ public boolean canSupportPolicyType(ToscaConceptIdentifier policyTypeId) {
//
// For the time being, restrict this if the version isn't known.
// Could be too difficult to support changing of versions dynamically.
//
- for (ToscaPolicyTypeIdentifier supported : this.supportedPolicyTypes) {
+ for (ToscaConceptIdentifier supported : this.supportedPolicyTypes) {
if (policyTypeId.equals(supported)) {
LOGGER.info("optimization can support {}", supported);
return true;
* ONAP
* ================================================================================
* Copyright (C) 2019-2020 AT&T Intellectual Property. All rights reserved.
- Modifications Copyright (C) 2019-2020 Nordix Foundation.
+ * Modifications Copyright (C) 2019-2021 Nordix Foundation.
* ================================================================================
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
import org.onap.policy.common.utils.resources.TextFileUtils;
import org.onap.policy.models.decisions.concepts.DecisionRequest;
import org.onap.policy.models.decisions.concepts.DecisionResponse;
+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;
import org.onap.policy.models.tosca.simple.concepts.JpaToscaServiceTemplate;
import org.onap.policy.pdp.xacml.application.common.XacmlApplicationException;
// Ensure it has the supported policy types and
// can support the correct policy types.
//
- assertThat(service.canSupportPolicyType(new ToscaPolicyTypeIdentifier(
+ assertThat(service.canSupportPolicyType(new ToscaConceptIdentifier(
"onap.policies.optimization.resource.AffinityPolicy", "1.0.0"))).isTrue();
- assertThat(service.canSupportPolicyType(new ToscaPolicyTypeIdentifier(
+ assertThat(service.canSupportPolicyType(new ToscaConceptIdentifier(
"onap.policies.optimization.service.SubscriberPolicy", "1.0.0"))).isTrue();
- assertThat(service.canSupportPolicyType(new ToscaPolicyTypeIdentifier(
+ assertThat(service.canSupportPolicyType(new ToscaConceptIdentifier(
"onap.policies.optimization.service.CustomUseCase", "1.0.0"))).isTrue();
- assertThat(service.canSupportPolicyType(new ToscaPolicyTypeIdentifier(
+ assertThat(service.canSupportPolicyType(new ToscaConceptIdentifier(
"onap.foobar", "1.0.0"))).isFalse();
}
/*-
* ============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 lombok.Setter;
import org.onap.policy.common.endpoints.parameters.RestServerParameters;
import org.onap.policy.models.decisions.concepts.DecisionRequest;
+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.onap.policy.pdp.xacml.application.common.XacmlApplicationException;
import org.onap.policy.pdp.xacml.application.common.XacmlApplicationServiceProvider;
import org.slf4j.Logger;
private ServiceLoader<XacmlApplicationServiceProvider> applicationLoader;
private Map<String, XacmlApplicationServiceProvider> providerActionMap = new HashMap<>();
- private List<ToscaPolicyTypeIdentifier> toscaPolicyTypeIdents = new ArrayList<>();
+ private List<ToscaConceptIdentifier> toscaPolicyTypeIdents = new ArrayList<>();
private Map<ToscaPolicy, XacmlApplicationServiceProvider> mapLoadedPolicies = new HashMap<>();
*
* @return list of ToscaPolicyIdentifier
*/
- public List<ToscaPolicyIdentifier> getToscaPolicyIdentifiers() {
+ public List<ToscaConceptIdentifier> getToscaPolicyIdentifiers() {
//
// converting map to return List of ToscaPolicyIdentiers
//
return mapLoadedPolicies.keySet().stream().map(ToscaPolicy::getIdentifier).collect(Collectors.toList());
}
- public List<ToscaPolicyTypeIdentifier> getToscaPolicyTypeIdents() {
+ public List<ToscaConceptIdentifier> getToscaPolicyTypeIdents() {
return toscaPolicyTypeIdents;
}
/*-
* ============LICENSE_START=======================================================
* Copyright (C) 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.models.pdp.enums.PdpHealthStatus;
import org.onap.policy.models.pdp.enums.PdpResponseStatus;
import org.onap.policy.models.pdp.enums.PdpState;
-import org.onap.policy.models.tosca.authorative.concepts.ToscaPolicyTypeIdentifier;
+import org.onap.policy.models.tosca.authorative.concepts.ToscaConceptIdentifier;
import org.onap.policy.pdpx.main.rest.XacmlPdpApplicationManager;
import org.onap.policy.pdpx.main.startstop.XacmlPdpActivator;
@Mock
private XacmlPdpActivator act;
- private ToscaPolicyTypeIdentifier ident1;
- private ToscaPolicyTypeIdentifier ident2;
+ private ToscaConceptIdentifier ident1;
+ private ToscaConceptIdentifier ident2;
private String hostName;
hostName = NetworkUtil.getHostname();
- ident1 = new ToscaPolicyTypeIdentifier("nameA", "typeA");
- ident2 = new ToscaPolicyTypeIdentifier("nameB", "typeB");
+ ident1 = new ToscaConceptIdentifier("nameA", "typeA");
+ ident2 = new ToscaConceptIdentifier("nameB", "typeB");
when(appmgr.getToscaPolicyTypeIdents()).thenReturn(Arrays.asList(ident1, ident2));
/*-
* ============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 java.util.Arrays;
import java.util.List;
-import org.onap.policy.models.tosca.authorative.concepts.ToscaPolicyTypeIdentifier;
+import org.onap.policy.models.tosca.authorative.concepts.ToscaConceptIdentifier;
import org.onap.policy.pdp.xacml.application.common.ToscaPolicyTranslator;
import org.onap.policy.pdp.xacml.application.common.std.StdXacmlApplicationServiceProvider;
public class TutorialApplication extends StdXacmlApplicationServiceProvider {
- private final ToscaPolicyTypeIdentifier supportedPolicyType =
- new ToscaPolicyTypeIdentifier("onap.policies.Authorization", "1.0.0");
+ private final ToscaConceptIdentifier supportedPolicyType =
+ new ToscaConceptIdentifier("onap.policies.Authorization", "1.0.0");
private final TutorialTranslator translator = new TutorialTranslator();
@Override
}
@Override
- public synchronized List<ToscaPolicyTypeIdentifier> supportedPolicyTypes() {
+ public synchronized List<ToscaConceptIdentifier> supportedPolicyTypes() {
return Arrays.asList(supportedPolicyType);
}
@Override
- public boolean canSupportPolicyType(ToscaPolicyTypeIdentifier policyTypeId) {
+ public boolean canSupportPolicyType(ToscaConceptIdentifier policyTypeId) {
return supportedPolicyType.equals(policyTypeId);
}