aboutsummaryrefslogtreecommitdiffstats
path: root/applications/common/src
diff options
context:
space:
mode:
Diffstat (limited to 'applications/common/src')
-rw-r--r--applications/common/src/main/java/org/onap/policy/pdp/xacml/application/common/PolicyApiCaller.java5
-rw-r--r--applications/common/src/main/java/org/onap/policy/pdp/xacml/application/common/XacmlApplicationServiceProvider.java7
-rw-r--r--applications/common/src/main/java/org/onap/policy/pdp/xacml/application/common/matchable/MatchablePolicyType.java8
-rw-r--r--applications/common/src/main/java/org/onap/policy/pdp/xacml/application/common/std/StdMatchableTranslator.java31
-rw-r--r--applications/common/src/main/java/org/onap/policy/pdp/xacml/application/common/std/StdXacmlApplicationServiceProvider.java9
-rw-r--r--applications/common/src/test/java/org/onap/policy/pdp/xacml/application/common/PolicyApiCallerTest.java13
6 files changed, 39 insertions, 34 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);
}