diff options
21 files changed, 130 insertions, 112 deletions
diff --git a/applications/common/src/main/java/org/onap/policy/pdp/xacml/application/common/PolicyApiCaller.java b/applications/common/src/main/java/org/onap/policy/pdp/xacml/application/common/PolicyApiCaller.java index 44593e1b..7d360da2 100644 --- a/applications/common/src/main/java/org/onap/policy/pdp/xacml/application/common/PolicyApiCaller.java +++ b/applications/common/src/main/java/org/onap/policy/pdp/xacml/application/common/PolicyApiCaller.java @@ -1,6 +1,7 @@ /*- * ============LICENSE_START======================================================= * Copyright (C) 2019-2020 AT&T Intellectual Property. All rights reserved. + * Modifications Copyright (C) 2021 Nordix Foundation. * ================================================================================ * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -27,7 +28,7 @@ import org.onap.policy.common.endpoints.http.client.HttpClient; 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; @@ -73,7 +74,7 @@ public class PolicyApiCaller { * @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 diff --git a/applications/common/src/main/java/org/onap/policy/pdp/xacml/application/common/XacmlApplicationServiceProvider.java b/applications/common/src/main/java/org/onap/policy/pdp/xacml/application/common/XacmlApplicationServiceProvider.java index edd33c0e..d80572a2 100644 --- a/applications/common/src/main/java/org/onap/policy/pdp/xacml/application/common/XacmlApplicationServiceProvider.java +++ b/applications/common/src/main/java/org/onap/policy/pdp/xacml/application/common/XacmlApplicationServiceProvider.java @@ -2,6 +2,7 @@ * 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. @@ -29,8 +30,8 @@ import org.apache.commons.lang3.tuple.Pair; 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 @@ -73,7 +74,7 @@ public interface XacmlApplicationServiceProvider { * * @return List of Strings (eg. "onap.policy.foo.bar") */ - List<ToscaPolicyTypeIdentifier> supportedPolicyTypes(); + List<ToscaConceptIdentifier> supportedPolicyTypes(); /** * Asks whether the application can support the incoming @@ -82,7 +83,7 @@ public interface XacmlApplicationServiceProvider { * @param toscaPolicyId Identifier for policy type * @return true if supported */ - boolean canSupportPolicyType(ToscaPolicyTypeIdentifier toscaPolicyId); + boolean canSupportPolicyType(ToscaConceptIdentifier toscaPolicyId); /** * Load a Tosca Policy. diff --git a/applications/common/src/main/java/org/onap/policy/pdp/xacml/application/common/matchable/MatchablePolicyType.java b/applications/common/src/main/java/org/onap/policy/pdp/xacml/application/common/matchable/MatchablePolicyType.java index e3174dda..c0cbb77f 100644 --- a/applications/common/src/main/java/org/onap/policy/pdp/xacml/application/common/matchable/MatchablePolicyType.java +++ b/applications/common/src/main/java/org/onap/policy/pdp/xacml/application/common/matchable/MatchablePolicyType.java @@ -3,7 +3,7 @@ * 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. @@ -29,8 +29,8 @@ import java.util.Map.Entry; 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; @@ -69,11 +69,11 @@ public class MatchablePolicyType { ); //@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); } diff --git a/applications/common/src/main/java/org/onap/policy/pdp/xacml/application/common/std/StdMatchableTranslator.java b/applications/common/src/main/java/org/onap/policy/pdp/xacml/application/common/std/StdMatchableTranslator.java index 1a5e9dd8..329a21ca 100644 --- a/applications/common/src/main/java/org/onap/policy/pdp/xacml/application/common/std/StdMatchableTranslator.java +++ b/applications/common/src/main/java/org/onap/policy/pdp/xacml/application/common/std/StdMatchableTranslator.java @@ -3,6 +3,7 @@ * ONAP * ================================================================================ * Copyright (C) 2019-2020 AT&T Intellectual Property. All rights reserved. + * Modifications Copyright (C) 2021 Nordix Foundation. * ================================================================================ * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -56,10 +57,10 @@ import org.onap.policy.common.utils.coder.StandardCoder; 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; @@ -87,8 +88,8 @@ public class StdMatchableTranslator extends StdBaseTranslator implements Matcha 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; @@ -324,7 +325,7 @@ public class StdMatchableTranslator extends StdBaseTranslator implements Matcha @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; @@ -469,14 +470,14 @@ public class StdMatchableTranslator extends StdBaseTranslator implements Matcha } /** - * 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? // @@ -500,14 +501,14 @@ public class StdMatchableTranslator extends StdBaseTranslator implements Matcha } /** - * 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 // @@ -559,14 +560,14 @@ public class StdMatchableTranslator extends StdBaseTranslator implements Matcha } /** - * 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 @@ -600,10 +601,10 @@ public class StdMatchableTranslator extends StdBaseTranslator implements Matcha * 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"); } diff --git a/applications/common/src/main/java/org/onap/policy/pdp/xacml/application/common/std/StdXacmlApplicationServiceProvider.java b/applications/common/src/main/java/org/onap/policy/pdp/xacml/application/common/std/StdXacmlApplicationServiceProvider.java index 28b861d2..fcfbf535 100644 --- a/applications/common/src/main/java/org/onap/policy/pdp/xacml/application/common/std/StdXacmlApplicationServiceProvider.java +++ b/applications/common/src/main/java/org/onap/policy/pdp/xacml/application/common/std/StdXacmlApplicationServiceProvider.java @@ -3,6 +3,7 @@ * ONAP * ================================================================================ * Copyright (C) 2019-2020 AT&T Intellectual Property. All rights reserved. + * Modifications Copyright (C) 2021 Nordix Foundation. * ================================================================================ * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -43,8 +44,8 @@ import org.apache.commons.lang3.tuple.Pair; 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; @@ -59,7 +60,7 @@ public abstract class StdXacmlApplicationServiceProvider implements XacmlApplica 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 @@ -110,12 +111,12 @@ public abstract class StdXacmlApplicationServiceProvider implements XacmlApplica } @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"); } diff --git a/applications/common/src/test/java/org/onap/policy/pdp/xacml/application/common/PolicyApiCallerTest.java b/applications/common/src/test/java/org/onap/policy/pdp/xacml/application/common/PolicyApiCallerTest.java index 6e7ec7c8..31cb481f 100644 --- a/applications/common/src/test/java/org/onap/policy/pdp/xacml/application/common/PolicyApiCallerTest.java +++ b/applications/common/src/test/java/org/onap/policy/pdp/xacml/application/common/PolicyApiCallerTest.java @@ -1,6 +1,7 @@ /*- * ============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. @@ -50,8 +51,8 @@ import org.onap.policy.common.endpoints.parameters.RestServerParameters; 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; @@ -138,22 +139,22 @@ public class PolicyApiCallerTest { @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); } diff --git a/applications/guard/src/main/java/org/onap/policy/xacml/pdp/application/guard/GuardPdpApplication.java b/applications/guard/src/main/java/org/onap/policy/xacml/pdp/application/guard/GuardPdpApplication.java index bb1b7588..1832945c 100644 --- a/applications/guard/src/main/java/org/onap/policy/xacml/pdp/application/guard/GuardPdpApplication.java +++ b/applications/guard/src/main/java/org/onap/policy/xacml/pdp/application/guard/GuardPdpApplication.java @@ -3,6 +3,7 @@ * ONAP * ================================================================================ * Copyright (C) 2019-2020 AT&T Intellectual Property. All rights reserved. + * Modifications Copyright (C) 2021 Nordix Foundation. * ================================================================================ * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -23,7 +24,7 @@ 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; @@ -52,30 +53,30 @@ public class GuardPdpApplication extends StdXacmlApplicationServiceProvider { 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; } diff --git a/applications/guard/src/test/java/org/onap/policy/xacml/pdp/application/guard/GuardPdpApplicationTest.java b/applications/guard/src/test/java/org/onap/policy/xacml/pdp/application/guard/GuardPdpApplicationTest.java index 08495a7e..3b1b1c60 100644 --- a/applications/guard/src/test/java/org/onap/policy/xacml/pdp/application/guard/GuardPdpApplicationTest.java +++ b/applications/guard/src/test/java/org/onap/policy/xacml/pdp/application/guard/GuardPdpApplicationTest.java @@ -3,6 +3,7 @@ * ONAP * ================================================================================ * Copyright (C) 2019-2020 AT&T Intellectual Property. All rights reserved. + * Modifications Copyright (C) 2021 Nordix Foundation. * ================================================================================ * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -55,8 +56,8 @@ import org.onap.policy.common.utils.resources.TextFileUtils; 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; @@ -219,26 +220,26 @@ public class GuardPdpApplicationTest { 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 diff --git a/applications/match/src/main/java/org/onap/policy/xacml/pdp/application/match/MatchPdpApplication.java b/applications/match/src/main/java/org/onap/policy/xacml/pdp/application/match/MatchPdpApplication.java index 62466b95..444c481c 100644 --- a/applications/match/src/main/java/org/onap/policy/xacml/pdp/application/match/MatchPdpApplication.java +++ b/applications/match/src/main/java/org/onap/policy/xacml/pdp/application/match/MatchPdpApplication.java @@ -3,6 +3,7 @@ * ONAP * ================================================================================ * Copyright (C) 2020 AT&T Intellectual Property. All rights reserved. + * Modifications Copyright (C) 2021 Nordix Foundation. * ================================================================================ * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -25,7 +26,7 @@ package org.onap.policy.xacml.pdp.application.match; 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; @@ -36,7 +37,7 @@ public class MatchPdpApplication extends StdXacmlApplicationServiceProvider { 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(); @@ -68,7 +69,7 @@ public class MatchPdpApplication extends StdXacmlApplicationServiceProvider { } @Override - public boolean canSupportPolicyType(ToscaPolicyTypeIdentifier policyTypeId) { + public boolean canSupportPolicyType(ToscaConceptIdentifier policyTypeId) { return policyTypeId.getName().startsWith(ONAP_MATCH_DERIVED_POLICY_TYPE); } diff --git a/applications/match/src/test/java/org/onap/policy/xacml/pdp/application/match/MatchPdpApplicationTest.java b/applications/match/src/test/java/org/onap/policy/xacml/pdp/application/match/MatchPdpApplicationTest.java index 23b3d6ea..a8b1399a 100644 --- a/applications/match/src/test/java/org/onap/policy/xacml/pdp/application/match/MatchPdpApplicationTest.java +++ b/applications/match/src/test/java/org/onap/policy/xacml/pdp/application/match/MatchPdpApplicationTest.java @@ -3,6 +3,7 @@ * ONAP * ================================================================================ * Copyright (C) 2020 AT&T Intellectual Property. All rights reserved. + * Modifications Copyright (C) 2021 Nordix Foundation. * ================================================================================ * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -50,7 +51,7 @@ import org.onap.policy.common.utils.resources.ResourceUtils; 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; @@ -154,9 +155,9 @@ public class MatchPdpApplicationTest { // 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(); } diff --git a/applications/monitoring/src/main/java/org/onap/policy/xacml/pdp/application/monitoring/MonitoringPdpApplication.java b/applications/monitoring/src/main/java/org/onap/policy/xacml/pdp/application/monitoring/MonitoringPdpApplication.java index a3456aea..17a9e743 100644 --- a/applications/monitoring/src/main/java/org/onap/policy/xacml/pdp/application/monitoring/MonitoringPdpApplication.java +++ b/applications/monitoring/src/main/java/org/onap/policy/xacml/pdp/application/monitoring/MonitoringPdpApplication.java @@ -3,6 +3,7 @@ * ONAP * ================================================================================ * Copyright (C) 2019-2020 AT&T Intellectual Property. All rights reserved. + * Modifications Copyright (C) 2021 Nordix Foundation. * ================================================================================ * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -29,7 +30,7 @@ import java.util.Map.Entry; 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; @@ -66,11 +67,11 @@ public class MonitoringPdpApplication extends 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 diff --git a/applications/monitoring/src/test/java/org/onap/policy/xacml/pdp/application/monitoring/MonitoringPdpApplicationTest.java b/applications/monitoring/src/test/java/org/onap/policy/xacml/pdp/application/monitoring/MonitoringPdpApplicationTest.java index 04895b8b..1c2967de 100644 --- a/applications/monitoring/src/test/java/org/onap/policy/xacml/pdp/application/monitoring/MonitoringPdpApplicationTest.java +++ b/applications/monitoring/src/test/java/org/onap/policy/xacml/pdp/application/monitoring/MonitoringPdpApplicationTest.java @@ -3,6 +3,7 @@ * ONAP * ================================================================================ * Copyright (C) 2019-2020 AT&T Intellectual Property. All rights reserved. + * Modifications Copyright (C) 2021 Nordix Foundation. * ================================================================================ * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -46,8 +47,8 @@ import org.onap.policy.common.utils.coder.StandardCoder; 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; @@ -143,12 +144,12 @@ public class MonitoringPdpApplicationTest { // 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 // diff --git a/applications/naming/src/main/java/org/onap/policy/xacml/pdp/application/naming/NamingPdpApplication.java b/applications/naming/src/main/java/org/onap/policy/xacml/pdp/application/naming/NamingPdpApplication.java index fe781a96..92dab81d 100644 --- a/applications/naming/src/main/java/org/onap/policy/xacml/pdp/application/naming/NamingPdpApplication.java +++ b/applications/naming/src/main/java/org/onap/policy/xacml/pdp/application/naming/NamingPdpApplication.java @@ -3,6 +3,7 @@ * ONAP * ================================================================================ * Copyright (C) 2019-2020 AT&T Intellectual Property. All rights reserved. + * Modifications Copyright (C) 2021 Nordix Foundation. * ================================================================================ * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -23,14 +24,14 @@ 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(); @@ -47,7 +48,7 @@ public class NamingPdpApplication extends StdXacmlApplicationServiceProvider { } @Override - public boolean canSupportPolicyType(ToscaPolicyTypeIdentifier policyTypeId) { + public boolean canSupportPolicyType(ToscaConceptIdentifier policyTypeId) { return namingPolicyType.equals(policyTypeId); } diff --git a/applications/naming/src/test/java/org/onap/policy/xacml/pdp/application/naming/NamingPdpApplicationTest.java b/applications/naming/src/test/java/org/onap/policy/xacml/pdp/application/naming/NamingPdpApplicationTest.java index 85b182cd..98385cae 100644 --- a/applications/naming/src/test/java/org/onap/policy/xacml/pdp/application/naming/NamingPdpApplicationTest.java +++ b/applications/naming/src/test/java/org/onap/policy/xacml/pdp/application/naming/NamingPdpApplicationTest.java @@ -3,6 +3,7 @@ * ONAP * ================================================================================ * Copyright (C) 2019-2020 AT&T Intellectual Property. All rights reserved. + * Modifications Copyright (C) 2021 Nordix Foundation. * ================================================================================ * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -54,7 +55,7 @@ import org.onap.policy.common.utils.resources.ResourceUtils; 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; @@ -160,9 +161,9 @@ public class NamingPdpApplicationTest { // 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(); } diff --git a/applications/native/src/main/java/org/onap/policy/xacml/pdp/application/nativ/NativePdpApplication.java b/applications/native/src/main/java/org/onap/policy/xacml/pdp/application/nativ/NativePdpApplication.java index f8248f1c..cfe1a710 100644 --- a/applications/native/src/main/java/org/onap/policy/xacml/pdp/application/nativ/NativePdpApplication.java +++ b/applications/native/src/main/java/org/onap/policy/xacml/pdp/application/nativ/NativePdpApplication.java @@ -3,6 +3,7 @@ * ONAP * ================================================================================ * Copyright (C) 2020 AT&T Intellectual Property. All rights reserved. + * Modifications Copyright (C) 2021 Nordix Foundation. * ================================================================================ * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -25,7 +26,7 @@ package org.onap.policy.xacml.pdp.application.nativ; 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; @@ -37,7 +38,7 @@ import org.onap.policy.pdp.xacml.application.common.std.StdXacmlApplicationServi */ 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(); @@ -53,7 +54,7 @@ public class NativePdpApplication extends StdXacmlApplicationServiceProvider { } @Override - public boolean canSupportPolicyType(ToscaPolicyTypeIdentifier policyTypeId) { + public boolean canSupportPolicyType(ToscaConceptIdentifier policyTypeId) { return nativePolicyType.equals(policyTypeId); } diff --git a/applications/native/src/test/java/org/onap/policy/xacml/pdp/application/nativ/NativePdpApplicationTest.java b/applications/native/src/test/java/org/onap/policy/xacml/pdp/application/nativ/NativePdpApplicationTest.java index f434e80f..9a0ebc01 100644 --- a/applications/native/src/test/java/org/onap/policy/xacml/pdp/application/nativ/NativePdpApplicationTest.java +++ b/applications/native/src/test/java/org/onap/policy/xacml/pdp/application/nativ/NativePdpApplicationTest.java @@ -3,6 +3,7 @@ * ONAP * ================================================================================ * Copyright (C) 2020 AT&T Intellectual Property. All rights reserved. + * Modifications Copyright (C) 2021 Nordix Foundation. * ================================================================================ * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -42,8 +43,8 @@ import org.onap.policy.common.endpoints.parameters.RestServerParameters; 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; @@ -130,9 +131,9 @@ public class NativePdpApplicationTest { 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"); } @@ -223,4 +224,4 @@ public class NativePdpApplicationTest { assertThat(decision).hasToString(expected); LOGGER.info("Xacml response we received {}", DOMResponse.toString(response)); } -}
\ No newline at end of file +} diff --git a/applications/optimization/src/main/java/org/onap/policy/xacml/pdp/application/optimization/OptimizationPdpApplication.java b/applications/optimization/src/main/java/org/onap/policy/xacml/pdp/application/optimization/OptimizationPdpApplication.java index 1cc94ed6..8b0442bb 100644 --- a/applications/optimization/src/main/java/org/onap/policy/xacml/pdp/application/optimization/OptimizationPdpApplication.java +++ b/applications/optimization/src/main/java/org/onap/policy/xacml/pdp/application/optimization/OptimizationPdpApplication.java @@ -3,6 +3,7 @@ * ONAP * ================================================================================ * Copyright (C) 2019-2020 AT&T Intellectual Property. All rights reserved. + * Modifications Copyright (C) 2021 Nordix Foundation. * ================================================================================ * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -36,7 +37,7 @@ import org.apache.commons.lang3.tuple.Pair; 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; @@ -74,15 +75,15 @@ public class OptimizationPdpApplication extends StdXacmlApplicationServiceProvid 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 @@ -101,12 +102,12 @@ public class OptimizationPdpApplication extends StdXacmlApplicationServiceProvid } @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; diff --git a/applications/optimization/src/test/java/org/onap/policy/xacml/pdp/application/optimization/OptimizationPdpApplicationTest.java b/applications/optimization/src/test/java/org/onap/policy/xacml/pdp/application/optimization/OptimizationPdpApplicationTest.java index 1a1e7566..44de7f02 100644 --- a/applications/optimization/src/test/java/org/onap/policy/xacml/pdp/application/optimization/OptimizationPdpApplicationTest.java +++ b/applications/optimization/src/test/java/org/onap/policy/xacml/pdp/application/optimization/OptimizationPdpApplicationTest.java @@ -3,7 +3,7 @@ * 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. @@ -56,8 +56,8 @@ import org.onap.policy.common.utils.resources.ResourceUtils; 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; @@ -183,13 +183,13 @@ public class OptimizationPdpApplicationTest { // 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(); } diff --git a/main/src/main/java/org/onap/policy/pdpx/main/rest/XacmlPdpApplicationManager.java b/main/src/main/java/org/onap/policy/pdpx/main/rest/XacmlPdpApplicationManager.java index 66f965ff..7c46ef38 100644 --- a/main/src/main/java/org/onap/policy/pdpx/main/rest/XacmlPdpApplicationManager.java +++ b/main/src/main/java/org/onap/policy/pdpx/main/rest/XacmlPdpApplicationManager.java @@ -1,6 +1,7 @@ /*- * ============LICENSE_START======================================================= * Copyright (C) 2019-2020 AT&T Intellectual Property. All rights reserved. + * Modifications Copyright (C) 2021 Nordix Foundation. * ================================================================================ * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -34,9 +35,8 @@ import lombok.Getter; 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; @@ -51,7 +51,7 @@ public class XacmlPdpApplicationManager { 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<>(); @@ -136,14 +136,14 @@ public class XacmlPdpApplicationManager { * * @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; } diff --git a/main/src/test/java/org/onap/policy/pdpx/main/XacmlStateTest.java b/main/src/test/java/org/onap/policy/pdpx/main/XacmlStateTest.java index 185f538e..8fb7664e 100644 --- a/main/src/test/java/org/onap/policy/pdpx/main/XacmlStateTest.java +++ b/main/src/test/java/org/onap/policy/pdpx/main/XacmlStateTest.java @@ -1,6 +1,7 @@ /*- * ============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. @@ -42,7 +43,7 @@ import org.onap.policy.models.pdp.concepts.PdpUpdate; 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; @@ -58,8 +59,8 @@ public class XacmlStateTest { @Mock private XacmlPdpActivator act; - private ToscaPolicyTypeIdentifier ident1; - private ToscaPolicyTypeIdentifier ident2; + private ToscaConceptIdentifier ident1; + private ToscaConceptIdentifier ident2; private String hostName; @@ -74,8 +75,8 @@ public class XacmlStateTest { 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)); diff --git a/tutorials/tutorial-xacml-application/src/main/java/org/onap/policy/tutorial/tutorial/TutorialApplication.java b/tutorials/tutorial-xacml-application/src/main/java/org/onap/policy/tutorial/tutorial/TutorialApplication.java index 3c76494b..5d486c42 100644 --- a/tutorials/tutorial-xacml-application/src/main/java/org/onap/policy/tutorial/tutorial/TutorialApplication.java +++ b/tutorials/tutorial-xacml-application/src/main/java/org/onap/policy/tutorial/tutorial/TutorialApplication.java @@ -1,6 +1,7 @@ /*- * ============LICENSE_START======================================================= * Copyright (C) 2020 AT&T Intellectual Property. All rights reserved. + * Modifications Copyright (C) 2021 Nordix Foundation. * ================================================================================ * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -20,14 +21,14 @@ package org.onap.policy.tutorial.tutorial; 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 @@ -41,12 +42,12 @@ public class TutorialApplication extends StdXacmlApplicationServiceProvider { } @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); } |