aboutsummaryrefslogtreecommitdiffstats
path: root/plugins/forwarding-plugins/src/main
diff options
context:
space:
mode:
authorramverma <ram.krishna.verma@est.tech>2019-07-17 11:03:26 +0000
committerramverma <ram.krishna.verma@est.tech>2019-07-17 11:03:26 +0000
commitcf748512392e5d3257de629dc57fb353dc073c92 (patch)
tree8e81a773d1f9556669b344d5f31dd139999ef2f6 /plugins/forwarding-plugins/src/main
parent5f032e0363703239f30dff29914dc41dd3abca48 (diff)
Changing policy/distribution to use policy/models
1) Changed policy distribution framework to use entities from policy/models 2) Changed all the test cases. 3) Commented few test cases which will be fixed along with code fixes. 4) Will be removing the old policy entities once all the pieces are ready. Change-Id: I1fd7b975b2e072c0b24e429903c9ca4796173929 Issue-ID: POLICY-1888 Signed-off-by: ramverma <ram.krishna.verma@est.tech>
Diffstat (limited to 'plugins/forwarding-plugins/src/main')
-rw-r--r--plugins/forwarding-plugins/src/main/java/org/onap/policy/distribution/forwarding/apex/pdp/ApexPdpPolicyForwarder.java32
-rw-r--r--plugins/forwarding-plugins/src/main/java/org/onap/policy/distribution/forwarding/file/FilePolicyForwarder.java51
-rw-r--r--plugins/forwarding-plugins/src/main/java/org/onap/policy/distribution/forwarding/xacml/pdp/XacmlPdpPolicyAdapter.java18
-rw-r--r--plugins/forwarding-plugins/src/main/java/org/onap/policy/distribution/forwarding/xacml/pdp/XacmlPdpPolicyForwarder.java65
-rw-r--r--plugins/forwarding-plugins/src/main/java/org/onap/policy/distribution/forwarding/xacml/pdp/adapters/AbstractXacmlPdpPolicyAdapter.java22
-rw-r--r--plugins/forwarding-plugins/src/main/java/org/onap/policy/distribution/forwarding/xacml/pdp/adapters/XacmlPdpOptimizationPolicyAdapter.java31
6 files changed, 101 insertions, 118 deletions
diff --git a/plugins/forwarding-plugins/src/main/java/org/onap/policy/distribution/forwarding/apex/pdp/ApexPdpPolicyForwarder.java b/plugins/forwarding-plugins/src/main/java/org/onap/policy/distribution/forwarding/apex/pdp/ApexPdpPolicyForwarder.java
index 8b8528fb..996b887d 100644
--- a/plugins/forwarding-plugins/src/main/java/org/onap/policy/distribution/forwarding/apex/pdp/ApexPdpPolicyForwarder.java
+++ b/plugins/forwarding-plugins/src/main/java/org/onap/policy/distribution/forwarding/apex/pdp/ApexPdpPolicyForwarder.java
@@ -31,10 +31,8 @@ import org.onap.policy.apex.model.basicmodel.concepts.ApexException;
import org.onap.policy.common.parameters.ParameterService;
import org.onap.policy.distribution.forwarding.PolicyForwarder;
import org.onap.policy.distribution.forwarding.PolicyForwardingException;
-import org.onap.policy.distribution.forwarding.xacml.pdp.XacmlPdpPolicyForwarder;
-import org.onap.policy.distribution.model.Policy;
-import org.onap.policy.distribution.model.PolicyAsString;
-
+import org.onap.policy.models.tosca.authorative.concepts.ToscaEntity;
+import org.onap.policy.models.tosca.authorative.concepts.ToscaPolicy;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
@@ -46,7 +44,7 @@ import org.slf4j.LoggerFactory;
*/
public class ApexPdpPolicyForwarder implements PolicyForwarder {
- private static final Logger LOGGER = LoggerFactory.getLogger(XacmlPdpPolicyForwarder.class);
+ private static final Logger LOGGER = LoggerFactory.getLogger(ApexPdpPolicyForwarder.class);
private static final String POLICY_TYPE = "APEX";
private ApexPdpPolicyForwarderParameterGroup apexForwarderParameters;
@@ -67,7 +65,7 @@ public class ApexPdpPolicyForwarder implements PolicyForwarder {
* {@inheritDoc}.
*/
@Override
- public void forward(final Collection<Policy> policies) throws PolicyForwardingException {
+ public void forward(final Collection<ToscaEntity> policies) throws PolicyForwardingException {
if (policies.isEmpty()) {
final String message = "No apex policy to be forwarded to an apex engine";
LOGGER.debug(message);
@@ -77,12 +75,18 @@ public class ApexPdpPolicyForwarder implements PolicyForwarder {
LOGGER.debug(message);
throw new PolicyForwardingException(message);
} else {
- final Policy policy = (Policy) policies.toArray()[0];
- if (policy.getClass().isAssignableFrom(PolicyAsString.class)
- && policy.getPolicyType().equalsIgnoreCase(POLICY_TYPE)) {
- forwardPolicy((PolicyAsString) policy);
+ final ToscaEntity policy = (ToscaEntity) policies.toArray()[0];
+ if (policy instanceof ToscaPolicy) {
+ final ToscaPolicy toscaPolicy = (ToscaPolicy) policy;
+ if (POLICY_TYPE.equalsIgnoreCase(toscaPolicy.getType())) {
+ forwardPolicy(toscaPolicy);
+ } else {
+ final String message = "Ignoring the policy as it is not an apex-pdp policy";
+ LOGGER.debug(message);
+ throw new PolicyForwardingException(message);
+ }
} else {
- final String message = "Ignoring the policy as it is not an apex-pdp policy";
+ final String message = "Ignoring the policy as it is not of type ToscaPolicy";
LOGGER.debug(message);
throw new PolicyForwardingException(message);
}
@@ -95,11 +99,11 @@ public class ApexPdpPolicyForwarder implements PolicyForwarder {
* @param apexPolicy the apex policy
* @throws PolicyForwardingException if any exception occurs while forwarding policy
*/
- private void forwardPolicy(final PolicyAsString apexPolicy) throws PolicyForwardingException {
+ private void forwardPolicy(final ToscaPolicy apexPolicy) throws PolicyForwardingException {
try {
engineServiceFacade.init();
- final InputStream policyInputStream = IOUtils.toInputStream(apexPolicy.getPolicy(), "UTF-8");
- engineServiceFacade.deployModel(apexPolicy.getPolicyName(), policyInputStream,
+ final InputStream policyInputStream = IOUtils.toInputStream(apexPolicy.toString(), "UTF-8");
+ engineServiceFacade.deployModel(apexPolicy.getName(), policyInputStream,
apexForwarderParameters.isIgnoreConflicts(), apexForwarderParameters.isForceUpdate());
LOGGER.debug("Sucessfully forwarded the policy to apex-pdp egine at {}:{}",
diff --git a/plugins/forwarding-plugins/src/main/java/org/onap/policy/distribution/forwarding/file/FilePolicyForwarder.java b/plugins/forwarding-plugins/src/main/java/org/onap/policy/distribution/forwarding/file/FilePolicyForwarder.java
index 51700005..55735662 100644
--- a/plugins/forwarding-plugins/src/main/java/org/onap/policy/distribution/forwarding/file/FilePolicyForwarder.java
+++ b/plugins/forwarding-plugins/src/main/java/org/onap/policy/distribution/forwarding/file/FilePolicyForwarder.java
@@ -21,8 +21,8 @@
package org.onap.policy.distribution.forwarding.file;
import java.io.BufferedWriter;
-import java.io.FileWriter;
import java.io.IOException;
+import java.nio.charset.StandardCharsets;
import java.nio.file.Files;
import java.nio.file.InvalidPathException;
import java.nio.file.Path;
@@ -32,15 +32,14 @@ import java.util.Collection;
import org.onap.policy.common.parameters.ParameterService;
import org.onap.policy.distribution.forwarding.PolicyForwarder;
import org.onap.policy.distribution.forwarding.PolicyForwardingException;
-import org.onap.policy.distribution.model.OptimizationPolicy;
-import org.onap.policy.distribution.model.Policy;
-
+import org.onap.policy.models.tosca.authorative.concepts.ToscaEntity;
+import org.onap.policy.models.tosca.authorative.concepts.ToscaPolicy;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
/**
- * This class provides an implementation of {@link PolicyForwarder} interface for forwarding the given policies to
- * a file directory.
+ * This class provides an implementation of {@link PolicyForwarder} interface for forwarding the given policies to a
+ * file directory.
*/
public class FilePolicyForwarder implements PolicyForwarder {
@@ -54,7 +53,7 @@ public class FilePolicyForwarder implements PolicyForwarder {
public void configure(final String parameterGroupName) {
fileForwarderParameters = ParameterService.get(parameterGroupName);
try {
- Path path = Paths.get(fileForwarderParameters.getPath());
+ final Path path = Paths.get(fileForwarderParameters.getPath());
if (!path.toFile().exists()) {
Files.createDirectories(path);
}
@@ -67,13 +66,13 @@ public class FilePolicyForwarder implements PolicyForwarder {
* {@inheritDoc}.
*/
@Override
- public void forward(final Collection<Policy> policies) throws PolicyForwardingException {
- for (Policy policy : policies) {
- if (policy instanceof OptimizationPolicy) {
- forwardPolicy((OptimizationPolicy) policy);
+ public void forward(final Collection<ToscaEntity> policies) throws PolicyForwardingException {
+ for (final ToscaEntity policy : policies) {
+ if (policy instanceof ToscaPolicy) {
+ forwardPolicy((ToscaPolicy) policy);
} else {
- final String message = "Cannot forward policy " + policy
- + ". Unsupported policy type " + policy.getClass().getSimpleName();
+ final String message = "Cannot forward policy " + policy + ". Unsupported policy type "
+ + policy.getClass().getSimpleName();
LOGGER.error(message);
throw new PolicyForwardingException(message);
}
@@ -86,30 +85,14 @@ public class FilePolicyForwarder implements PolicyForwarder {
* @param pol the policy
* @throws PolicyForwardingException if any exception occurs while forwarding policy
*/
- private void forwardPolicy(final OptimizationPolicy pol) throws PolicyForwardingException {
- final String name = pol.getPolicyName();
- Path path = Paths.get(fileForwarderParameters.getPath(), name);
- try (BufferedWriter writer = new BufferedWriter(new FileWriter(path.toString()))) {
+ private void forwardPolicy(final ToscaPolicy pol) throws PolicyForwardingException {
+ final String name = pol.getName();
+ final Path path = Paths.get(fileForwarderParameters.getPath(), name);
+ try (BufferedWriter writer = Files.newBufferedWriter(path, StandardCharsets.UTF_8)) {
writer.write("policyName: " + name);
if (fileForwarderParameters.isVerbose()) {
writer.newLine();
- writer.write("policyType: " + pol.getPolicyType());
- writer.newLine();
- writer.write("policyDescription: " + pol.getPolicyDescription());
- writer.newLine();
- writer.write("onapName: " + pol.getOnapName());
- writer.newLine();
- writer.write("configBodyType: " + pol.getConfigBodyType());
- writer.newLine();
- writer.write("configBody: " + pol.getConfigBody());
- writer.newLine();
- writer.write("timetolive: " + pol.getTimetolive().toString());
- writer.newLine();
- writer.write("guard: " + pol.getGuard());
- writer.newLine();
- writer.write("riskLevel: " + pol.getRiskLevel());
- writer.newLine();
- writer.write("riskType: " + pol.getRiskType());
+ writer.write("policy: " + pol.toString());
}
LOGGER.debug("Sucessfully forwarded the policy to store into file {}.", path);
} catch (final InvalidPathException | IOException exp) {
diff --git a/plugins/forwarding-plugins/src/main/java/org/onap/policy/distribution/forwarding/xacml/pdp/XacmlPdpPolicyAdapter.java b/plugins/forwarding-plugins/src/main/java/org/onap/policy/distribution/forwarding/xacml/pdp/XacmlPdpPolicyAdapter.java
index c50eac12..613a406f 100644
--- a/plugins/forwarding-plugins/src/main/java/org/onap/policy/distribution/forwarding/xacml/pdp/XacmlPdpPolicyAdapter.java
+++ b/plugins/forwarding-plugins/src/main/java/org/onap/policy/distribution/forwarding/xacml/pdp/XacmlPdpPolicyAdapter.java
@@ -5,15 +5,15 @@
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
- *
+ *
* http://www.apache.org/licenses/LICENSE-2.0
- *
+ *
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
- *
+ *
* SPDX-License-Identifier: Apache-2.0
* ============LICENSE_END=========================================================
*/
@@ -22,30 +22,30 @@ package org.onap.policy.distribution.forwarding.xacml.pdp;
import org.onap.policy.api.PolicyParameters;
import org.onap.policy.api.PushPolicyParameters;
-import org.onap.policy.distribution.model.Policy;
+import org.onap.policy.models.tosca.authorative.concepts.ToscaPolicy;
/**
- * Adapts {@link Policy} objects to objects compatible with the XACML PDP API.
+ * Adapts {@link ToscaPolicy} objects to objects compatible with the XACML PDP API.
*/
-public interface XacmlPdpPolicyAdapter<T extends Policy> {
+public interface XacmlPdpPolicyAdapter<T extends ToscaPolicy> {
/**
* Get the policy.
- *
+ *
* @return the policy
*/
T getPolicy();
/**
* Get as a {@link PolicyParameters} object.
- *
+ *
* @returna {@link PolicyParameters} object
*/
PolicyParameters getAsPolicyParameters();
/**
* Get as a {@link PushPolicyParameters} object.
- *
+ *
* @returna {@link PushPolicyParameters} object
*/
PushPolicyParameters getAsPushPolicyParameters(final String pdpGroups);
diff --git a/plugins/forwarding-plugins/src/main/java/org/onap/policy/distribution/forwarding/xacml/pdp/XacmlPdpPolicyForwarder.java b/plugins/forwarding-plugins/src/main/java/org/onap/policy/distribution/forwarding/xacml/pdp/XacmlPdpPolicyForwarder.java
index 196818b5..8eeeda7e 100644
--- a/plugins/forwarding-plugins/src/main/java/org/onap/policy/distribution/forwarding/xacml/pdp/XacmlPdpPolicyForwarder.java
+++ b/plugins/forwarding-plugins/src/main/java/org/onap/policy/distribution/forwarding/xacml/pdp/XacmlPdpPolicyForwarder.java
@@ -24,9 +24,11 @@ package org.onap.policy.distribution.forwarding.xacml.pdp;
import java.util.Collection;
import java.util.Collections;
+
import javax.ws.rs.client.Entity;
import javax.ws.rs.core.MediaType;
import javax.ws.rs.core.Response;
+
import org.onap.policy.api.PolicyParameters;
import org.onap.policy.api.PushPolicyParameters;
import org.onap.policy.common.endpoints.event.comm.bus.internal.BusTopicParams;
@@ -37,8 +39,8 @@ import org.onap.policy.common.endpoints.http.client.HttpClientFactoryInstance;
import org.onap.policy.common.parameters.ParameterService;
import org.onap.policy.distribution.forwarding.PolicyForwarder;
import org.onap.policy.distribution.forwarding.xacml.pdp.adapters.XacmlPdpOptimizationPolicyAdapter;
-import org.onap.policy.distribution.model.OptimizationPolicy;
-import org.onap.policy.distribution.model.Policy;
+import org.onap.policy.models.tosca.authorative.concepts.ToscaEntity;
+import org.onap.policy.models.tosca.authorative.concepts.ToscaPolicy;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.http.HttpStatus;
@@ -55,53 +57,53 @@ public class XacmlPdpPolicyForwarder implements PolicyForwarder {
@Override
- public void forward(final Collection<Policy> policies) {
- for (Policy policy : policies) {
+ public void forward(final Collection<ToscaEntity> policies) {
+ for (final ToscaEntity policy : policies) {
forward(policy);
}
}
- private void forward(Policy policy) {
- XacmlPdpPolicyAdapter<?> policyAdapter = getXacmlPdpPolicyAdapter(policy);
+ private void forward(final ToscaEntity policy) {
+ final XacmlPdpPolicyAdapter<?> policyAdapter = getXacmlPdpPolicyAdapter(policy);
if (policyAdapter == null) {
- LOGGER.error("Cannot forward policy {}. Unsupported policy type {}",
- policy, policy.getClass().getSimpleName());
+ LOGGER.error("Cannot forward policy {}. Unsupported policy type {}", policy,
+ policy.getClass().getSimpleName());
return;
}
- boolean policyCreated = createPolicy(policyAdapter);
+ final boolean policyCreated = createPolicy(policyAdapter);
if (policyCreated) {
pushPolicy(policyAdapter);
}
}
- private XacmlPdpPolicyAdapter<?> getXacmlPdpPolicyAdapter(Policy policy) {
- if (policy instanceof OptimizationPolicy) {
- return new XacmlPdpOptimizationPolicyAdapter((OptimizationPolicy) policy);
+ private XacmlPdpPolicyAdapter<?> getXacmlPdpPolicyAdapter(final ToscaEntity policy) {
+ if (policy instanceof ToscaPolicy) {
+ return new XacmlPdpOptimizationPolicyAdapter((ToscaPolicy) policy);
}
return null;
}
- private boolean createPolicy(XacmlPdpPolicyAdapter<?> policyAdapter) {
- PolicyParameters policyParameters = policyAdapter.getAsPolicyParameters();
- Entity<PolicyParameters> entity = Entity.entity(policyParameters, MediaType.APPLICATION_JSON);
+ private boolean createPolicy(final XacmlPdpPolicyAdapter<?> policyAdapter) {
+ final PolicyParameters policyParameters = policyAdapter.getAsPolicyParameters();
+ final Entity<PolicyParameters> entity = Entity.entity(policyParameters, MediaType.APPLICATION_JSON);
- return invokeHttpClient(entity, "createPolicy", policyAdapter.getPolicy().getPolicyName());
+ return invokeHttpClient(entity, "createPolicy", policyAdapter.getPolicy().getName());
}
- private boolean pushPolicy(XacmlPdpPolicyAdapter<?> policyAdapter) {
- PushPolicyParameters pushPolicyParameters =
+ private boolean pushPolicy(final XacmlPdpPolicyAdapter<?> policyAdapter) {
+ final PushPolicyParameters pushPolicyParameters =
policyAdapter.getAsPushPolicyParameters(configurationParameters.getPdpGroup());
- Entity<PushPolicyParameters> entity = Entity.entity(pushPolicyParameters, MediaType.APPLICATION_JSON);
+ final Entity<PushPolicyParameters> entity = Entity.entity(pushPolicyParameters, MediaType.APPLICATION_JSON);
- return invokeHttpClient(entity, "pushPolicy", policyAdapter.getPolicy().getPolicyName());
+ return invokeHttpClient(entity, "pushPolicy", policyAdapter.getPolicy().getName());
}
private boolean invokeHttpClient(final Entity<?> entity, final String method, final String policyName) {
try {
- Response response = getHttpClient().put(method, entity,
+ final Response response = getHttpClient().put(method, entity,
Collections.singletonMap("ClientAuth", configurationParameters.getClientAuth()));
if (response.getStatus() != HttpStatus.OK.value()) {
@@ -110,7 +112,7 @@ public class XacmlPdpPolicyForwarder implements PolicyForwarder {
method, policyName, response.getStatus(), response.getStatusInfo());
return false;
}
- } catch (HttpClientConfigException exception) {
+ } catch (final HttpClientConfigException exception) {
LOGGER.error("Invocation of method " + method + " failed for policy " + policyName
+ " due to error opening Http client", exception);
return false;
@@ -119,19 +121,20 @@ public class XacmlPdpPolicyForwarder implements PolicyForwarder {
}
private HttpClient getHttpClient() throws HttpClientConfigException {
- boolean useHttps = configurationParameters.isUseHttps();
- String hostname = configurationParameters.getHostname();
- int port = configurationParameters.getPort();
- String userName = configurationParameters.getUserName();
- String password = configurationParameters.getPassword();
- boolean managed = configurationParameters.isManaged();
- BusTopicParams params = BusTopicParams.builder().clientName("SDC Dist").useHttps(useHttps).hostname(hostname)
- .port(port).userName(userName).password(password).basePath(BASE_PATH).managed(managed).build();
+ final boolean useHttps = configurationParameters.isUseHttps();
+ final String hostname = configurationParameters.getHostname();
+ final int port = configurationParameters.getPort();
+ final String userName = configurationParameters.getUserName();
+ final String password = configurationParameters.getPassword();
+ final boolean managed = configurationParameters.isManaged();
+ final BusTopicParams params =
+ BusTopicParams.builder().clientName("SDC Dist").useHttps(useHttps).hostname(hostname).port(port)
+ .userName(userName).password(password).basePath(BASE_PATH).managed(managed).build();
return getHttpClientFactory().build(params);
}
@Override
- public void configure(String parameterGroupName) {
+ public void configure(final String parameterGroupName) {
configurationParameters = ParameterService.get(parameterGroupName);
}
diff --git a/plugins/forwarding-plugins/src/main/java/org/onap/policy/distribution/forwarding/xacml/pdp/adapters/AbstractXacmlPdpPolicyAdapter.java b/plugins/forwarding-plugins/src/main/java/org/onap/policy/distribution/forwarding/xacml/pdp/adapters/AbstractXacmlPdpPolicyAdapter.java
index c1365166..f978d3a9 100644
--- a/plugins/forwarding-plugins/src/main/java/org/onap/policy/distribution/forwarding/xacml/pdp/adapters/AbstractXacmlPdpPolicyAdapter.java
+++ b/plugins/forwarding-plugins/src/main/java/org/onap/policy/distribution/forwarding/xacml/pdp/adapters/AbstractXacmlPdpPolicyAdapter.java
@@ -5,15 +5,15 @@
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
- *
+ *
* http://www.apache.org/licenses/LICENSE-2.0
- *
+ *
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
- *
+ *
* SPDX-License-Identifier: Apache-2.0
* ============LICENSE_END=========================================================
*/
@@ -22,18 +22,18 @@ package org.onap.policy.distribution.forwarding.xacml.pdp.adapters;
import org.onap.policy.api.PushPolicyParameters;
import org.onap.policy.distribution.forwarding.xacml.pdp.XacmlPdpPolicyAdapter;
-import org.onap.policy.distribution.model.Policy;
+import org.onap.policy.models.tosca.authorative.concepts.ToscaPolicy;
/**
* Base class for {@link XacmlPdpPolicyAdapter} implementations.
- *
+ *
* @param <T> the type of policy the adapter handles
*/
-public abstract class AbstractXacmlPdpPolicyAdapter<T extends Policy> implements XacmlPdpPolicyAdapter<T> {
+public abstract class AbstractXacmlPdpPolicyAdapter<T extends ToscaPolicy> implements XacmlPdpPolicyAdapter<T> {
private T policy;
- protected AbstractXacmlPdpPolicyAdapter(T policy) {
+ protected AbstractXacmlPdpPolicyAdapter(final T policy) {
this.policy = policy;
}
@@ -43,10 +43,10 @@ public abstract class AbstractXacmlPdpPolicyAdapter<T extends Policy> implements
}
@Override
- public PushPolicyParameters getAsPushPolicyParameters(String pdpGroups) {
- PushPolicyParameters pushPolicyParameters = new PushPolicyParameters();
- pushPolicyParameters.setPolicyName(policy.getPolicyName());
- pushPolicyParameters.setPolicyType(policy.getPolicyType());
+ public PushPolicyParameters getAsPushPolicyParameters(final String pdpGroups) {
+ final PushPolicyParameters pushPolicyParameters = new PushPolicyParameters();
+ pushPolicyParameters.setPolicyName(policy.getName());
+ pushPolicyParameters.setPolicyType(policy.getType());
pushPolicyParameters.setPdpGroup(pdpGroups);
return pushPolicyParameters;
}
diff --git a/plugins/forwarding-plugins/src/main/java/org/onap/policy/distribution/forwarding/xacml/pdp/adapters/XacmlPdpOptimizationPolicyAdapter.java b/plugins/forwarding-plugins/src/main/java/org/onap/policy/distribution/forwarding/xacml/pdp/adapters/XacmlPdpOptimizationPolicyAdapter.java
index 1ec654fa..c9633b15 100644
--- a/plugins/forwarding-plugins/src/main/java/org/onap/policy/distribution/forwarding/xacml/pdp/adapters/XacmlPdpOptimizationPolicyAdapter.java
+++ b/plugins/forwarding-plugins/src/main/java/org/onap/policy/distribution/forwarding/xacml/pdp/adapters/XacmlPdpOptimizationPolicyAdapter.java
@@ -5,49 +5,42 @@
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
- *
+ *
* http://www.apache.org/licenses/LICENSE-2.0
- *
+ *
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
- *
+ *
* SPDX-License-Identifier: Apache-2.0
* ============LICENSE_END=========================================================
*/
package org.onap.policy.distribution.forwarding.xacml.pdp.adapters;
-import org.onap.policy.api.PolicyConfigType;
import org.onap.policy.api.PolicyParameters;
-import org.onap.policy.distribution.model.OptimizationPolicy;
+import org.onap.policy.models.tosca.authorative.concepts.ToscaPolicy;
/**
- * Adapts {@link OptimizationPolicy} objects to objects compatible with the XACML PDP API.
+ * Adapts {@link ToscaPolicy} objects to objects compatible with the XACML PDP API.
*/
-public class XacmlPdpOptimizationPolicyAdapter extends AbstractXacmlPdpPolicyAdapter<OptimizationPolicy> {
+public class XacmlPdpOptimizationPolicyAdapter extends AbstractXacmlPdpPolicyAdapter<ToscaPolicy> {
/**
- * Create an instance to adapt the given {@link OptimizationPolicy}.
- *
- * @param optimizationPolicy the {@link OptimizationPolicy} to be adapted
+ * Create an instance to adapt the given {@link ToscaPolicy}.
+ *
+ * @param optimizationPolicy the {@link ToscaPolicy} to be adapted
*/
- public XacmlPdpOptimizationPolicyAdapter(final OptimizationPolicy optimizationPolicy) {
+ public XacmlPdpOptimizationPolicyAdapter(final ToscaPolicy optimizationPolicy) {
super(optimizationPolicy);
}
@Override
public PolicyParameters getAsPolicyParameters() {
- PolicyParameters policyParameters = new PolicyParameters();
- policyParameters.setPolicyName(getPolicy().getPolicyName());
- policyParameters.setPolicyDescription(getPolicy().getPolicyDescription());
- policyParameters.setPolicyConfigType(PolicyConfigType.valueOf(getPolicy().getPolicyConfigType()));
- policyParameters.setOnapName(getPolicy().getOnapName());
- policyParameters.setRiskLevel(getPolicy().getRiskLevel());
- policyParameters.setConfigBody(getPolicy().getConfigBody());
- policyParameters.setRiskType(getPolicy().getRiskType());
+ final PolicyParameters policyParameters = new PolicyParameters();
+ policyParameters.setPolicyName(getPolicy().getName());
return policyParameters;
}