diff options
Diffstat (limited to 'ONAP-PDP-REST')
5 files changed, 71 insertions, 21 deletions
diff --git a/ONAP-PDP-REST/src/main/java/org/onap/policy/pdp/rest/api/services/ActionPolicyService.java b/ONAP-PDP-REST/src/main/java/org/onap/policy/pdp/rest/api/services/ActionPolicyService.java index 5016e0690..b60878f8b 100644 --- a/ONAP-PDP-REST/src/main/java/org/onap/policy/pdp/rest/api/services/ActionPolicyService.java +++ b/ONAP-PDP-REST/src/main/java/org/onap/policy/pdp/rest/api/services/ActionPolicyService.java @@ -3,6 +3,7 @@ * ONAP-PDP-REST * ================================================================================ * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. + * Modified Copyright (C) 2018 Samsung Electronics Co., Ltd. * ================================================================================ * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -28,6 +29,7 @@ import org.onap.policy.common.logging.flexlogger.FlexLogger; import org.onap.policy.common.logging.flexlogger.Logger; import org.onap.policy.xacml.api.XACMLErrorConstants; import org.onap.policy.xacml.std.pap.StdPAPPolicy; +import org.onap.policy.xacml.std.pap.StdPAPPolicyParams; /** * Action Policy Implementation. @@ -94,11 +96,19 @@ public class ActionPolicyService { operation = "create"; } // Create Policy - StdPAPPolicy newPAPPolicy = new StdPAPPolicy(policyName, policyParameters.getPolicyDescription(), - componentAttributes, policyParameters.getDynamicRuleAlgorithmLabels(), - policyParameters.getDynamicRuleAlgorithmFunctions(), - policyParameters.getDynamicRuleAlgorithmField1(), policyParameters.getDynamicRuleAlgorithmField2(), - actionPerformer, actionAttribute, updateFlag, policyScope, 0); + StdPAPPolicy newPAPPolicy = new StdPAPPolicy(StdPAPPolicyParams.builder().policyName(policyName) + .description(policyParameters.getPolicyDescription()) + .dynamicFieldConfigAttributes(componentAttributes) + .dynamicRuleAlgorithmLabels(policyParameters.getDynamicRuleAlgorithmLabels()) + .dynamicRuleAlgorithmCombo(policyParameters.getDynamicRuleAlgorithmFunctions()) + .dynamicRuleAlgorithmField1(policyParameters.getDynamicRuleAlgorithmField1()) + .dynamicRuleAlgorithmField2(policyParameters.getDynamicRuleAlgorithmField2()) + .actionPerformer(actionPerformer) + .actionAttribute(actionAttribute) + .editPolicy(updateFlag) + .domain(policyScope) + .highestVersion(0) + .build()); // send Json to PAP response = (String) papServices.callPAP(newPAPPolicy, new String[]{"operation=" + operation, "apiflag=api", "policyType=Action"}, policyParameters.getRequestID(), "Action"); diff --git a/ONAP-PDP-REST/src/main/java/org/onap/policy/pdp/rest/api/services/BRMSRawPolicyService.java b/ONAP-PDP-REST/src/main/java/org/onap/policy/pdp/rest/api/services/BRMSRawPolicyService.java index df3f0356f..71d49addc 100644 --- a/ONAP-PDP-REST/src/main/java/org/onap/policy/pdp/rest/api/services/BRMSRawPolicyService.java +++ b/ONAP-PDP-REST/src/main/java/org/onap/policy/pdp/rest/api/services/BRMSRawPolicyService.java @@ -3,6 +3,7 @@ * ONAP-PDP-REST * ================================================================================ * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. + * Modified Copyright (C) 2018 Samsung Electronics Co., Ltd. * ================================================================================ * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -30,6 +31,7 @@ import org.onap.policy.pdp.rest.api.utils.PolicyApiUtils; import org.onap.policy.utils.PolicyUtils; import org.onap.policy.xacml.api.XACMLErrorConstants; import org.onap.policy.xacml.std.pap.StdPAPPolicy; +import org.onap.policy.xacml.std.pap.StdPAPPolicyParams; /** * BRMS RAW Policy Implementation. @@ -93,11 +95,24 @@ public class BRMSRawPolicyService { ruleAttributes = policyParameters.getAttributes().get(AttributeType.RULE); } // Create Policy - StdPAPPolicy newPAPPolicy = new StdPAPPolicy("BRMS_Raw", policyName, policyParameters.getPolicyDescription(), - "BRMS_RAW_RULE", updateFlag, policyScope, ruleAttributes, 0, "DROOLS", - brmsRawBody, policyParameters.getRiskLevel(), - policyParameters.getRiskType(), String.valueOf(policyParameters.getGuard()), date, - policyParameters.getControllerName(), policyParameters.getDependencyNames()); + StdPAPPolicy newPAPPolicy = new StdPAPPolicy(StdPAPPolicyParams.builder() + .configPolicyType("BRMS_Raw") + .policyName(policyName) + .description(policyParameters.getPolicyDescription()) + .configName("BRMS_RAW_RULE") + .editPolicy(updateFlag) + .domain(policyScope) + .dynamicFieldConfigAttributes(ruleAttributes) + .highestVersion(0) + .onapName("DROOLS") + .configBodyData(brmsRawBody) + .riskLevel(policyParameters.getRiskLevel()) + .riskType(policyParameters.getRiskType()) + .guard(String.valueOf(policyParameters.getGuard())) + .ttlDate(date) + .brmsController(policyParameters.getControllerName()) + .brmsDependency(policyParameters.getDependencyNames()) + .build()); // Send JSON to PAP response = (String) papServices.callPAP(newPAPPolicy, new String[]{"operation=" + operation, "apiflag=api", "policyType=Config"}, policyParameters.getRequestID(), "ConfigBrmsRaw"); diff --git a/ONAP-PDP-REST/src/main/java/org/onap/policy/pdp/rest/api/services/ConfigPolicyService.java b/ONAP-PDP-REST/src/main/java/org/onap/policy/pdp/rest/api/services/ConfigPolicyService.java index 46f968aac..779e3e35c 100644 --- a/ONAP-PDP-REST/src/main/java/org/onap/policy/pdp/rest/api/services/ConfigPolicyService.java +++ b/ONAP-PDP-REST/src/main/java/org/onap/policy/pdp/rest/api/services/ConfigPolicyService.java @@ -3,6 +3,7 @@ * ONAP-PDP-REST * ================================================================================ * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. + * Modified Copyright (C) 2018 Samsung Electronics Co., Ltd. * ================================================================================ * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -132,7 +133,7 @@ public class ConfigPolicyService { .description(policyParameters.getPolicyDescription()) .onapName(onapName) .configName(configName) - .attributes(configAttributes) + .dynamicFieldConfigAttributes(configAttributes) .configType(configType) .configBodyData(configBody) .editPolicy(updateFlag) diff --git a/ONAP-PDP-REST/src/main/java/org/onap/policy/pdp/rest/api/services/DecisionPolicyService.java b/ONAP-PDP-REST/src/main/java/org/onap/policy/pdp/rest/api/services/DecisionPolicyService.java index 7bdf1dc71..85e9c6ae5 100644 --- a/ONAP-PDP-REST/src/main/java/org/onap/policy/pdp/rest/api/services/DecisionPolicyService.java +++ b/ONAP-PDP-REST/src/main/java/org/onap/policy/pdp/rest/api/services/DecisionPolicyService.java @@ -3,6 +3,7 @@ * ONAP-PDP-REST * ================================================================================ * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. + * Modified Copyright (C) 2018 Samsung Electronics Co., Ltd. * ================================================================================ * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -29,6 +30,7 @@ import org.onap.policy.common.logging.flexlogger.FlexLogger; import org.onap.policy.common.logging.flexlogger.Logger; import org.onap.policy.xacml.api.XACMLErrorConstants; import org.onap.policy.xacml.std.pap.StdPAPPolicy; +import org.onap.policy.xacml.std.pap.StdPAPPolicyParams; /** * Decision Policy Implementation @@ -97,12 +99,22 @@ public class DecisionPolicyService { matchingAttributes = policyParameters.getAttributes().get(AttributeType.MATCHING); } // Create StdPAPPolicy object used to send policy data to PAP-REST. - StdPAPPolicy newPAPPolicy = new StdPAPPolicy(policyName, policyParameters.getPolicyDescription(), onapName, - ruleProvider.toString(), matchingAttributes, settingsAttributes, - policyParameters.getTreatments(), policyParameters.getDynamicRuleAlgorithmLabels(), - policyParameters.getDynamicRuleAlgorithmFunctions(), - policyParameters.getDynamicRuleAlgorithmField1(), policyParameters.getDynamicRuleAlgorithmField2(), - null, null, null, updateFlag, policyScope, 0); + StdPAPPolicy newPAPPolicy = new StdPAPPolicy(StdPAPPolicyParams.builder() + .policyName(policyName) + .description(policyParameters.getPolicyDescription()) + .onapName(onapName) + .providerComboBox(ruleProvider.toString()) + .dynamicFieldConfigAttributes(matchingAttributes) + .dynamicSettingsMap(settingsAttributes) + .treatments(policyParameters.getTreatments()) + .dynamicRuleAlgorithmLabels(policyParameters.getDynamicRuleAlgorithmLabels()) + .dynamicRuleAlgorithmCombo(policyParameters.getDynamicRuleAlgorithmFunctions()) + .dynamicRuleAlgorithmField1(policyParameters.getDynamicRuleAlgorithmField1()) + .dynamicRuleAlgorithmField2(policyParameters.getDynamicRuleAlgorithmField2()) + .editPolicy(updateFlag) + .domain(policyScope) + .highestVersion(0) + .build()); // Send JSON to PAP. response = (String) papServices.callPAP(newPAPPolicy, new String[]{"operation=" + operation, "apiflag=api", "policyType=Decision"}, policyParameters.getRequestID(), "Decision"); diff --git a/ONAP-PDP-REST/src/main/java/org/onap/policy/pdp/rest/api/services/FirewallPolicyService.java b/ONAP-PDP-REST/src/main/java/org/onap/policy/pdp/rest/api/services/FirewallPolicyService.java index 45deeb49f..c3a2ce64b 100644 --- a/ONAP-PDP-REST/src/main/java/org/onap/policy/pdp/rest/api/services/FirewallPolicyService.java +++ b/ONAP-PDP-REST/src/main/java/org/onap/policy/pdp/rest/api/services/FirewallPolicyService.java @@ -3,6 +3,7 @@ * ONAP-PDP-REST * ================================================================================ * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. + * Modified Copyright (C) 2018 Samsung Electronics Co., Ltd. * ================================================================================ * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -29,6 +30,7 @@ import org.onap.policy.common.logging.flexlogger.Logger; import org.onap.policy.pdp.rest.api.utils.PolicyApiUtils; import org.onap.policy.xacml.api.XACMLErrorConstants; import org.onap.policy.xacml.std.pap.StdPAPPolicy; +import org.onap.policy.xacml.std.pap.StdPAPPolicyParams; /** * Firewall Policy Implementation. @@ -104,10 +106,20 @@ public class FirewallPolicyService { String configDescription = ""; String json = firewallJson.toString(); // Create Policy. - StdPAPPolicy newPAPPolicy = new StdPAPPolicy("Firewall Config", policyName, configDescription, configName, - updateFlag, policyScope, json, 0, - policyParameters.getRiskLevel(), policyParameters.getRiskType(), - String.valueOf(policyParameters.getGuard()), date); + StdPAPPolicy newPAPPolicy = new StdPAPPolicy(StdPAPPolicyParams.builder() + .configPolicyType("Firewall Config") + .policyName(policyName) + .description(configDescription) + .configName(configName) + .editPolicy(updateFlag) + .domain(policyScope) + .jsonBody(json) + .highestVersion(0) + .riskLevel(policyParameters.getRiskLevel()) + .riskType(policyParameters.getRiskType()) + .guard(String.valueOf(policyParameters.getGuard())) + .ttlDate(date) + .build()); // Send Json to PAP. response = (String) papServices.callPAP(newPAPPolicy, new String[]{"operation=" + operation, "apiflag=api", "policyType=Config"}, policyParameters.getRequestID(), "ConfigFirewall"); |