summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--ONAP-PAP-REST/src/test/java/org/onap/policy/pap/test/XACMLPAPTest.java41
-rw-r--r--ONAP-PDP-REST/src/main/java/org/onap/policy/pdp/rest/api/services/ActionPolicyService.java3
-rw-r--r--ONAP-PDP-REST/src/main/java/org/onap/policy/pdp/rest/api/services/BRMSRawPolicyService.java25
-rw-r--r--ONAP-PDP-REST/src/main/java/org/onap/policy/pdp/rest/api/services/ConfigPolicyService.java2
-rw-r--r--ONAP-PDP-REST/src/main/java/org/onap/policy/pdp/rest/api/services/DecisionPolicyService.java3
-rw-r--r--ONAP-PDP-REST/src/main/java/org/onap/policy/pdp/rest/api/services/FirewallPolicyService.java20
-rw-r--r--ONAP-XACML/src/main/java/org/onap/policy/xacml/std/pap/StdPAPPolicy.java229
-rw-r--r--ONAP-XACML/src/main/java/org/onap/policy/xacml/std/pap/StdPAPPolicyParams.java80
-rw-r--r--ONAP-XACML/src/test/java/org/onap/policy/xacml/test/std/pap/StdPAPPolicyTest.java179
-rw-r--r--PolicyEngineClient/src/test/java/org/onap/policyengine/BrmsRawPolicyClient.java157
10 files changed, 386 insertions, 353 deletions
diff --git a/ONAP-PAP-REST/src/test/java/org/onap/policy/pap/test/XACMLPAPTest.java b/ONAP-PAP-REST/src/test/java/org/onap/policy/pap/test/XACMLPAPTest.java
index ab4f2a00f..bb14ff866 100644
--- a/ONAP-PAP-REST/src/test/java/org/onap/policy/pap/test/XACMLPAPTest.java
+++ b/ONAP-PAP-REST/src/test/java/org/onap/policy/pap/test/XACMLPAPTest.java
@@ -182,8 +182,20 @@ public class XACMLPAPTest {
Mockito.when(httpServletRequest.getParameter("operation")).thenReturn("create");
Mockito.when(httpServletRequest.getParameter("policyType")).thenReturn("Config");
StdPAPPolicy newPAPPolicy =
- new StdPAPPolicy("Firewall Config", "test", "testDescription", "Test", false, "test", json, 0,
- "5", "default", "false", "");
+ new StdPAPPolicy(StdPAPPolicyParams.builder()
+ .configPolicyType("Firewall Config")
+ .policyName("test")
+ .description("testDescription")
+ .configName("Test")
+ .editPolicy(false)
+ .domain("test")
+ .jsonBody(json)
+ .highestVersion(0)
+ .riskLevel("5")
+ .riskType("default")
+ .guard("false")
+ .ttlDate("")
+ .build());
MockServletInputStream mockInput =
new MockServletInputStream(PolicyUtils.objectToJsonString(newPAPPolicy).getBytes());
Mockito.when(httpServletRequest.getInputStream()).thenReturn(mockInput);
@@ -239,10 +251,21 @@ public class XACMLPAPTest {
Mockito.when(httpServletRequest.getParameter("policyType")).thenReturn("Config");
Map<String, String> ruleAttributes = new HashMap<>();
ruleAttributes.put("value", "test");
- StdPAPPolicy newPAPPolicy = new StdPAPPolicy("BRMS_Raw", "test", "testig description",
- "BRMS_RAW_RULE", false, "test", ruleAttributes, 0, "DROOLS",
- "test", "4",
- "default", "false", null, null, null);
+ StdPAPPolicy newPAPPolicy = new StdPAPPolicy(StdPAPPolicyParams.builder()
+ .configPolicyType("BRMS_Raw")
+ .policyName("test")
+ .description("testig description")
+ .configName("BRMS_RAW_RULE")
+ .editPolicy(false)
+ .domain("test")
+ .dynamicFieldConfigAttributes(ruleAttributes)
+ .highestVersion(0)
+ .onapName("DROOLS")
+ .configBodyData("test")
+ .riskLevel("4")
+ .riskType("default")
+ .guard("false")
+ .build());
MockServletInputStream mockInput =
new MockServletInputStream(PolicyUtils.objectToJsonString(newPAPPolicy).getBytes());
Mockito.when(httpServletRequest.getInputStream()).thenReturn(mockInput);
@@ -338,7 +361,7 @@ public class XACMLPAPTest {
.description("test rule")
.onapName("PDPD")
.providerComboBox("GUARD_YAML")
- .dyanamicFieldConfigAttributes(matchingAttributes)
+ .dynamicFieldConfigAttributes(matchingAttributes)
.editPolicy(false)
.domain("test")
.highestVersion(0)
@@ -377,7 +400,7 @@ public class XACMLPAPTest {
.description("test rule")
.onapName("PDPD")
.providerComboBox("GUARD_BL_YAML")
- .dyanamicFieldConfigAttributes(matchingAttributes)
+ .dynamicFieldConfigAttributes(matchingAttributes)
.editPolicy(false)
.domain("test")
.highestVersion(0)
@@ -411,7 +434,7 @@ public class XACMLPAPTest {
.description("test rule")
.onapName("TEST")
.configName("config")
- .dyanamicFieldConfigAttributes(configAttributes)
+ .dynamicFieldConfigAttributes(configAttributes)
.configType("OTHER")
.configBodyData("test body")
.editPolicy(false)
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 ab5b60cea..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.
@@ -97,7 +98,7 @@ public class ActionPolicyService {
// Create Policy
StdPAPPolicy newPAPPolicy = new StdPAPPolicy(StdPAPPolicyParams.builder().policyName(policyName)
.description(policyParameters.getPolicyDescription())
- .dyanamicFieldConfigAttributes(componentAttributes)
+ .dynamicFieldConfigAttributes(componentAttributes)
.dynamicRuleAlgorithmLabels(policyParameters.getDynamicRuleAlgorithmLabels())
.dynamicRuleAlgorithmCombo(policyParameters.getDynamicRuleAlgorithmFunctions())
.dynamicRuleAlgorithmField1(policyParameters.getDynamicRuleAlgorithmField1())
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 e25e94cd0..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
@@ -133,7 +133,7 @@ public class ConfigPolicyService {
.description(policyParameters.getPolicyDescription())
.onapName(onapName)
.configName(configName)
- .dyanamicFieldConfigAttributes(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 00a3cc890..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.
@@ -103,7 +104,7 @@ public class DecisionPolicyService {
.description(policyParameters.getPolicyDescription())
.onapName(onapName)
.providerComboBox(ruleProvider.toString())
- .dyanamicFieldConfigAttributes(matchingAttributes)
+ .dynamicFieldConfigAttributes(matchingAttributes)
.dynamicSettingsMap(settingsAttributes)
.treatments(policyParameters.getTreatments())
.dynamicRuleAlgorithmLabels(policyParameters.getDynamicRuleAlgorithmLabels())
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");
diff --git a/ONAP-XACML/src/main/java/org/onap/policy/xacml/std/pap/StdPAPPolicy.java b/ONAP-XACML/src/main/java/org/onap/policy/xacml/std/pap/StdPAPPolicy.java
index 435e3c347..74ded6d43 100644
--- a/ONAP-XACML/src/main/java/org/onap/policy/xacml/std/pap/StdPAPPolicy.java
+++ b/ONAP-XACML/src/main/java/org/onap/policy/xacml/std/pap/StdPAPPolicy.java
@@ -36,7 +36,7 @@ public class StdPAPPolicy implements OnapPAPPolicy, Serializable {
private String policyDescription = null;
private String onapName = null;
private String configName = null;
- private Map<String, String> dyanamicFieldConfigAttributes = new HashMap<>();
+ private Map<String, String> dynamicFieldConfigAttributes = new HashMap<>();
private Map<String, String> treatments = new HashMap<>();
private Map<String, String> dropDownMap = new HashMap<>();
private Map<String, String> dynamicSettingsMap = new HashMap<>();
@@ -117,7 +117,7 @@ public class StdPAPPolicy implements OnapPAPPolicy, Serializable {
this.onapName = stdPAPPolicyParams.getOnapName();
this.providerComboBox = stdPAPPolicyParams.getProviderComboBox();
this.configName = stdPAPPolicyParams.getConfigName();
- this.dyanamicFieldConfigAttributes = stdPAPPolicyParams.getDyanamicFieldConfigAttributes();
+ this.dynamicFieldConfigAttributes = stdPAPPolicyParams.getDynamicFieldConfigAttributes();
this.dynamicSettingsMap = stdPAPPolicyParams.getDynamicSettingsMap();
this.configType = stdPAPPolicyParams.getConfigType();
this.configBodyData = stdPAPPolicyParams.getConfigBodyData();
@@ -138,113 +138,19 @@ public class StdPAPPolicy implements OnapPAPPolicy, Serializable {
this.actionPerformer = stdPAPPolicyParams.getActionPerformer();
this.actionAttribute = stdPAPPolicyParams.getActionAttribute();
this.treatments = stdPAPPolicyParams.getTreatments();
- }
-
- //convenience constructor
- public StdPAPPolicy(String configPolicyType, String policyName, String description, String onapName,
- String configName, Map<String, String> attributes, String body, String policyID,
- String ruleID, String configType, Boolean editPolicy, String version, String domain,
- String riskLevel, String riskType, String guard, String ttlDate) {
- this(configPolicyType, policyName, description, onapName, configName, attributes, body, policyID,
- ruleID, configType, editPolicy, version, domain, 1, riskLevel, riskType, guard, ttlDate);
- }
-
- //Constructor for Updating Config Policies from Admin Console
- public StdPAPPolicy(String configPolicyType, String policyName, String description, String onapName,
- String configName, Map<String, String> attributes, String body, String policyID,
- String ruleID, String configType, Boolean editPolicy, String version, String domain,
- int highestVersion, String riskLevel, String riskType, String guard, String ttlDate) {
-
- this.configPolicyType = configPolicyType;
- this.policyName = policyName;
- this.policyDescription = description;
- this.onapName = onapName;
- this.configName = configName;
- this.dyanamicFieldConfigAttributes = attributes;
- this.configBodyData = body;
- this.policyID = policyID;
- this.ruleID = ruleID;
- this.configType = configType;
- this.editPolicy = editPolicy;
- this.version = version;
- this.domain = domain;
- this.highestVersion = highestVersion;
- this.riskLevel = riskLevel;
- this.riskType = riskType;
- this.guard = guard;
- this.ttlDate = ttlDate;
- }
-
-
- //Constructor for Creating Config Firewall Policies
- public StdPAPPolicy(String configPolicyType, String policyName, String description, String configName,
- Boolean editPolicy, String domain, String jsonBody, Integer highestVersion, String riskLevel,
- String riskType, String guard, String ttlDate) {
-
- this.configPolicyType = configPolicyType;
- this.policyName = policyName;
- this.policyDescription = description;
- this.configName = configName;
- this.editPolicy = editPolicy;
- this.domain = domain;
- this.jsonBody = jsonBody;
- this.highestVersion = highestVersion;
- this.riskLevel = riskLevel;
- this.riskType = riskType;
- this.guard = guard;
- this.ttlDate = ttlDate;
-
- }
-
- //Constructor for Creating Goc Policies
- public StdPAPPolicy(String configPolicyType, String policyName, String description, String configName,
- Boolean editPolicy, String domain, String jsonBody, Integer highestVersion, String eCompName,
- String riskLevel, String riskType, String guard, String ttlDate) {
-
- this.configPolicyType = configPolicyType;
- this.policyName = policyName;
- this.policyDescription = description;
- this.configName = configName;
- this.editPolicy = editPolicy;
- this.domain = domain;
- this.jsonBody = jsonBody;
- this.highestVersion = highestVersion;
- this.onapName = eCompName;
- this.riskLevel = riskLevel;
- this.riskType = riskType;
- this.guard = guard;
- this.ttlDate = ttlDate;
- }
-
- //Constructor for Creating BRMS Policies from the Admin Console
- public StdPAPPolicy(String configPolicyType, String policyName, String description,
- String configName, Boolean editPolicy, String domain,
- Map<String, String> dyanamicFieldConfigAttributes, Integer highestVersion, String eCompName,
- String configBodyData, String riskLevel, String riskType, String guard, String ttlDate,
- String brmsController, List<String> brmsDependency) {
-
- this.configPolicyType = configPolicyType;
- this.policyName = policyName;
- this.policyDescription = description;
- this.configName = configName;
- this.editPolicy = editPolicy;
- this.domain = domain;
- this.dyanamicFieldConfigAttributes = dyanamicFieldConfigAttributes;
- this.highestVersion = highestVersion;
- this.onapName = eCompName;
- this.configBodyData = configBodyData;
- this.riskLevel = riskLevel;
- this.riskType = riskType;
- this.guard = guard;
- this.ttlDate = ttlDate;
- this.brmsController = brmsController;
- this.brmsDependency = brmsDependency;
+ this.policyID = stdPAPPolicyParams.getPolicyID();
+ this.ruleID = stdPAPPolicyParams.getRuleID();
+ this.version = stdPAPPolicyParams.getVersion();
+ this.jsonBody = stdPAPPolicyParams.getJsonBody();
+ this.brmsController = stdPAPPolicyParams.getBrmsController();
+ this.brmsDependency = stdPAPPolicyParams.getBrmsDependency();
+ this.drlRuleAndUIParams = stdPAPPolicyParams.getDrlRuleAndUIParams();
}
//Constructor for Creating BRMS Param Policies from the Admin Console
public StdPAPPolicy(String configPolicyType, String policyName, String description,
String configName, Boolean editPolicy, String domain,
- Map<String, String> dyanamicFieldConfigAttributes, Integer highestVersion, String eCompName,
+ Map<String, String> dynamicFieldConfigAttributes, Integer highestVersion, String eCompName,
String configBodyData, Map<String, String> drlRuleAndUIParams, String riskLevel,
String riskType, String guard, String ttlDate, String brmsController,
List<String> brmsDependency) {
@@ -255,7 +161,7 @@ public class StdPAPPolicy implements OnapPAPPolicy, Serializable {
this.configName = configName;
this.editPolicy = editPolicy;
this.domain = domain;
- this.dyanamicFieldConfigAttributes = dyanamicFieldConfigAttributes;
+ this.dynamicFieldConfigAttributes = dynamicFieldConfigAttributes;
this.highestVersion = highestVersion;
this.onapName = eCompName;
this.configBodyData = configBodyData;
@@ -292,29 +198,6 @@ public class StdPAPPolicy implements OnapPAPPolicy, Serializable {
this.ttlDate = ttlDate;
}
- //Constructor for Updating Config Firewall Policies from the Admin Console
- public StdPAPPolicy(String configPolicyType, String policyName, String description, String configName,
- Boolean editPolicy, String domain, String policyID,
- String ruleID, String version, String jsonBody, Integer highestVersion, String riskLevel,
- String riskType, String guard, String ttlDate) {
-
- this.configPolicyType = configPolicyType;
- this.policyName = policyName;
- this.policyDescription = description;
- this.configName = configName;
- this.editPolicy = editPolicy;
- this.domain = domain;
- this.policyID = policyID;
- this.ruleID = ruleID;
- this.version = version;
- this.jsonBody = jsonBody;
- this.highestVersion = highestVersion;
- this.riskLevel = riskLevel;
- this.riskType = riskType;
- this.guard = guard;
- this.ttlDate = ttlDate;
- }
-
//Constructor for Micro Service Creating/Updating Policies from the Admin Console
public StdPAPPolicy(String configPolicyType, String policyName, String description, String onapName,
String configName, String serviceType, String uuid,
@@ -342,84 +225,6 @@ public class StdPAPPolicy implements OnapPAPPolicy, Serializable {
this.ttlDate = ttlDate;
}
- //Constructor for Updating Goc Policies from the Admin Console
- public StdPAPPolicy(String configPolicyType, String policyName, String description,
- String configName, Boolean editPolicy, String domain,
- String policyID, String ruleID, String version,
- String jsonBody, Integer highestVersion, String eCompName, String riskLevel, String riskType,
- String guard, String ttlDate) {
-
- this.configPolicyType = configPolicyType;
- this.policyName = policyName;
- this.policyDescription = description;
- this.configName = configName;
- this.editPolicy = editPolicy;
- this.domain = domain;
- this.policyID = policyID;
- this.ruleID = ruleID;
- this.version = version;
- this.jsonBody = jsonBody;
- this.highestVersion = highestVersion;
- this.onapName = eCompName;
- this.riskLevel = riskLevel;
- this.riskType = riskType;
- this.guard = guard;
- this.ttlDate = ttlDate;
- }
-
- //Constructor for Updating Brms Policies from the Admin Console
- public StdPAPPolicy(String configPolicyType, String policyName, String description,
- String configName, Boolean editPolicy, String domain,
- String policyID, String ruleID, String version,
- Map<String, String> dyanamicFieldConfigAttributes, Integer highestVersion, String eCompName,
- String configBodyData, String riskLevel, String riskType, String guard, String ttlDate
- ) {
- this.configPolicyType = configPolicyType;
- this.policyName = policyName;
- this.policyDescription = description;
- this.configName = configName;
- this.editPolicy = editPolicy;
- this.domain = domain;
- this.policyID = policyID;
- this.ruleID = ruleID;
- this.version = version;
- this.dyanamicFieldConfigAttributes = dyanamicFieldConfigAttributes;
- this.highestVersion = highestVersion;
- this.onapName = eCompName;
- this.configBodyData = configBodyData;
- this.riskLevel = riskLevel;
- this.riskType = riskType;
- this.guard = guard;
- this.ttlDate = ttlDate;
- }
-
- //Constructor for Updating Brms Param Policies from the Admin Console
- public StdPAPPolicy(String configPolicyType, String policyName, String description,
- String configName, Boolean editPolicy, String domain,
- String policyID, String ruleID, String version,
- Map<String, String> dyanamicFieldConfigAttributes, Integer highestVersion, String eCompName,
- Map<String, String> drlRuleAndUIParams, String riskLevel, String riskType, String guard,
- String ttlDate
- ) {
- this.configPolicyType = configPolicyType;
- this.policyName = policyName;
- this.policyDescription = description;
- this.configName = configName;
- this.editPolicy = editPolicy;
- this.domain = domain;
- this.policyID = policyID;
- this.ruleID = ruleID;
- this.version = version;
- this.dyanamicFieldConfigAttributes = dyanamicFieldConfigAttributes;
- this.highestVersion = highestVersion;
- this.onapName = eCompName;
- this.drlRuleAndUIParams = drlRuleAndUIParams;
- this.riskLevel = riskLevel;
- this.riskType = riskType;
- this.guard = guard;
- this.ttlDate = ttlDate;
- }
-
// Constructor for deleting policies from the API
public StdPAPPolicy(String policyName, String deleteCondition) {
this.policyName = policyName;
@@ -455,7 +260,7 @@ public class StdPAPPolicy implements OnapPAPPolicy, Serializable {
@Override
public Map<String, String> getDynamicFieldConfigAttributes() {
- return dyanamicFieldConfigAttributes;
+ return dynamicFieldConfigAttributes;
}
@Override
@@ -666,8 +471,8 @@ public class StdPAPPolicy implements OnapPAPPolicy, Serializable {
@Override
public String toString() {
return "StdPAPPolicy [policyName=" + policyName + ", policyDescription=" + policyDescription + ", onapName="
- + onapName + ", configName=" + configName + ", dyanamicFieldConfigAttributes=" +
- dyanamicFieldConfigAttributes + ", configBodyData=" + configBodyData
+ + onapName + ", configName=" + configName + ", dynamicFieldConfigAttributes=" +
+ dynamicFieldConfigAttributes + ", configBodyData=" + configBodyData
+ ", policyID=" + policyID + ", ruleID=" + ruleID + ", configType=" + configType + ", editPolicy=" +
", version=" + ", domain=" + domain
+ ", configPolicyType=" + configPolicyType + ", jsonBody=" + jsonBody + ", highestVersion=" +
@@ -710,9 +515,9 @@ public class StdPAPPolicy implements OnapPAPPolicy, Serializable {
this.configName = configName;
}
- public void setDyanamicFieldConfigAttributes(
- Map<String, String> dyanamicFieldConfigAttributes) {
- this.dyanamicFieldConfigAttributes = dyanamicFieldConfigAttributes;
+ public void setDynamicFieldConfigAttributes(
+ Map<String, String> dynamicFieldConfigAttributes) {
+ this.dynamicFieldConfigAttributes = dynamicFieldConfigAttributes;
}
public void setConfigBodyData(String configBodyData) {
diff --git a/ONAP-XACML/src/main/java/org/onap/policy/xacml/std/pap/StdPAPPolicyParams.java b/ONAP-XACML/src/main/java/org/onap/policy/xacml/std/pap/StdPAPPolicyParams.java
index 0e183e08a..7eb422b99 100644
--- a/ONAP-XACML/src/main/java/org/onap/policy/xacml/std/pap/StdPAPPolicyParams.java
+++ b/ONAP-XACML/src/main/java/org/onap/policy/xacml/std/pap/StdPAPPolicyParams.java
@@ -32,7 +32,7 @@ public class StdPAPPolicyParams {
private String description;
private String onapName;
private String configName;
- private Map<String, String> dyanamicFieldConfigAttributes;
+ private Map<String, String> dynamicFieldConfigAttributes;
private String configType;
private String configBodyData;
private Boolean editPolicy;
@@ -54,6 +54,13 @@ public class StdPAPPolicyParams {
private List<String> dataTypeList;
private Map<String, String> dropDownMap;
private Map<String,String> treatments;
+ private String policyID;
+ private String ruleID;
+ private String version;
+ private String jsonBody;
+ private String brmsController;
+ private List<String> brmsDependency;
+ private Map<String,String> drlRuleAndUIParams;
/**
* Default constructor
@@ -90,8 +97,8 @@ public class StdPAPPolicyParams {
return configName;
}
- public Map<String, String> getDyanamicFieldConfigAttributes() {
- return dyanamicFieldConfigAttributes;
+ public Map<String, String> getDynamicFieldConfigAttributes() {
+ return dynamicFieldConfigAttributes;
}
public String getConfigType() {
@@ -174,6 +181,34 @@ public class StdPAPPolicyParams {
return treatments;
}
+ public String getPolicyID() {
+ return policyID;
+ }
+
+ public String getRuleID() {
+ return ruleID;
+ }
+
+ public String getVersion() {
+ return version;
+ }
+
+ public String getJsonBody() {
+ return jsonBody;
+ }
+
+ public String getBrmsController() {
+ return brmsController;
+ }
+
+ public List<String> getBrmsDependency() {
+ return brmsDependency;
+ }
+
+ public Map<String,String> getDrlRuleAndUIParams() {
+ return drlRuleAndUIParams;
+ }
+
/**
* Builder class for the Policy parameters
*/
@@ -210,8 +245,8 @@ public class StdPAPPolicyParams {
return this;
}
- public StdPAPPolicyParamsBuilder dyanamicFieldConfigAttributes(Map<String, String> attributes) {
- m.dyanamicFieldConfigAttributes = attributes;
+ public StdPAPPolicyParamsBuilder dynamicFieldConfigAttributes(Map<String, String> attributes) {
+ m.dynamicFieldConfigAttributes = attributes;
return this;
}
@@ -319,5 +354,40 @@ public class StdPAPPolicyParams {
m.treatments = treatments;
return this;
}
+
+ public StdPAPPolicyParamsBuilder policyID(String policyID) {
+ m.policyID = policyID;
+ return this;
+ }
+
+ public StdPAPPolicyParamsBuilder ruleID(String ruleID) {
+ m.ruleID = ruleID;
+ return this;
+ }
+
+ public StdPAPPolicyParamsBuilder version(String version) {
+ m.version = version;
+ return this;
+ }
+
+ public StdPAPPolicyParamsBuilder jsonBody(String jsonBody) {
+ m.jsonBody = jsonBody;
+ return this;
+ }
+
+ public StdPAPPolicyParamsBuilder brmsController(String controllerName) {
+ m.brmsController = controllerName;
+ return this;
+ }
+
+ public StdPAPPolicyParamsBuilder brmsDependency(List<String> dependencyNames) {
+ m.brmsDependency = dependencyNames;
+ return this;
+ }
+
+ public StdPAPPolicyParamsBuilder drlRuleAndUIParams(Map<String,String> drlRuleAndUIParams) {
+ m.drlRuleAndUIParams = drlRuleAndUIParams;
+ return this;
+ }
}
}
diff --git a/ONAP-XACML/src/test/java/org/onap/policy/xacml/test/std/pap/StdPAPPolicyTest.java b/ONAP-XACML/src/test/java/org/onap/policy/xacml/test/std/pap/StdPAPPolicyTest.java
index 4a9370c41..2de4a0456 100644
--- a/ONAP-XACML/src/test/java/org/onap/policy/xacml/test/std/pap/StdPAPPolicyTest.java
+++ b/ONAP-XACML/src/test/java/org/onap/policy/xacml/test/std/pap/StdPAPPolicyTest.java
@@ -3,6 +3,7 @@
* ONAP-XACML
* ================================================================================
* 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.
@@ -586,7 +587,7 @@ public class StdPAPPolicyTest {
.description("description")
.onapName("onapName")
.configName("configName")
- .dyanamicFieldConfigAttributes(attributes)
+ .dynamicFieldConfigAttributes(attributes)
.configType("configType")
.configBodyData("body")
.editPolicy(true)
@@ -625,7 +626,7 @@ public class StdPAPPolicyTest {
List<String> dynamicRuleAlgorithmField2 = new ArrayList<>();
dynamicRuleAlgorithmField2.add("dynamicRuleAlgorithmField2");
StdPAPPolicy stdPAPPolicy = new StdPAPPolicy(StdPAPPolicyParams.builder().policyName("policyName").description("description")
- .dyanamicFieldConfigAttributes(attributes)
+ .dynamicFieldConfigAttributes(attributes)
.dynamicRuleAlgorithmLabels(dynamicRuleAlgorithmLabels)
.dynamicRuleAlgorithmCombo(dynamicRuleAlgorithmCombo)
.dynamicRuleAlgorithmField1(dynamicRuleAlgorithmField1)
@@ -677,7 +678,7 @@ public class StdPAPPolicyTest {
.description("description")
.onapName("onapName")
.providerComboBox("providerComboBox")
- .dyanamicFieldConfigAttributes(attributes)
+ .dynamicFieldConfigAttributes(attributes)
.dynamicSettingsMap(settings)
.treatments(treatments)
.dynamicRuleAlgorithmLabels(dynamicRuleAlgorithmLabels)
@@ -715,10 +716,26 @@ public class StdPAPPolicyTest {
throws URISyntaxException {
Map<String, String> attributes = new HashMap<>();
attributes.put("aKey", "aValue");
- StdPAPPolicy stdPAPPolicy = new StdPAPPolicy("configTypePolicy", "policyName", "description", "onapName",
- "configName", attributes,
- "body", "policyId", "ruleId", "configType", true, "version", "domain", 1, "riskLevel", "riskType",
- "guard", "ttlDate");
+ StdPAPPolicy stdPAPPolicy = new StdPAPPolicy(StdPAPPolicyParams.builder()
+ .configPolicyType("configTypePolicy")
+ .policyName("policyName")
+ .description("description")
+ .onapName("onapName")
+ .configName("configName")
+ .dynamicFieldConfigAttributes(attributes)
+ .configBodyData("body")
+ .policyID("policyId")
+ .ruleID("ruleId")
+ .configType("configType")
+ .editPolicy(true)
+ .version("version")
+ .domain("domain")
+ .highestVersion(1)
+ .riskLevel("riskLevel")
+ .riskType("riskType")
+ .guard("guard")
+ .ttlDate("ttlDate")
+ .build());
assertEquals("configTypePolicy", stdPAPPolicy.getConfigPolicyType());
assertEquals("policyName", stdPAPPolicy.getPolicyName());
assertEquals("description", stdPAPPolicy.getPolicyDescription());
@@ -742,9 +759,20 @@ public class StdPAPPolicyTest {
@Test
public void testConstructorStringStringStringStringBooleanStringStringIntegerStringStringStringString()
throws URISyntaxException {
- StdPAPPolicy stdPAPPolicy = new StdPAPPolicy("configTypePolicy", "policyName", "description", "configName",
- true,
- "domain", "jasonBody", 1, "riskLevel", "riskType", "guard", "ttlDate");
+ StdPAPPolicy stdPAPPolicy = new StdPAPPolicy(StdPAPPolicyParams.builder()
+ .configPolicyType("configTypePolicy")
+ .policyName("policyName")
+ .description("description")
+ .configName("configName")
+ .editPolicy(true)
+ .domain("domain")
+ .jsonBody("jasonBody")
+ .highestVersion(1)
+ .riskLevel("riskLevel")
+ .riskType("riskType")
+ .guard("guard")
+ .ttlDate("ttlDate")
+ .build());
assertEquals("configTypePolicy", stdPAPPolicy.getConfigPolicyType());
assertEquals("policyName", stdPAPPolicy.getPolicyName());
assertEquals("description", stdPAPPolicy.getPolicyDescription());
@@ -762,9 +790,21 @@ public class StdPAPPolicyTest {
@Test
public void testConstructorStringStringStringStringBooleanStringStringIntegerStringStringStringStringString()
throws URISyntaxException {
- StdPAPPolicy stdPAPPolicy = new StdPAPPolicy("configTypePolicy", "policyName", "description", "configName",
- true,
- "domain", "jasonBody", 1, "eCompName", "riskLevel", "riskType", "guard", "ttlDate");
+ StdPAPPolicy stdPAPPolicy = new StdPAPPolicy(StdPAPPolicyParams.builder()
+ .configPolicyType("configTypePolicy")
+ .policyName("policyName")
+ .description("description")
+ .configName("configName")
+ .editPolicy(true)
+ .domain("domain")
+ .jsonBody("jasonBody")
+ .highestVersion(1)
+ .onapName("eCompName")
+ .riskLevel("riskLevel")
+ .riskType("riskType")
+ .guard("guard")
+ .ttlDate("ttlDate")
+ .build());
assertEquals("configTypePolicy", stdPAPPolicy.getConfigPolicyType());
assertEquals("policyName", stdPAPPolicy.getPolicyName());
assertEquals("description", stdPAPPolicy.getPolicyDescription());
@@ -787,10 +827,24 @@ public class StdPAPPolicyTest {
dyanamicFieldConfigAttributes.put("aKey", "aValue");
ArrayList<String> brmsDependency = new ArrayList<>();
brmsDependency.add("brmsDependency");
- StdPAPPolicy stdPAPPolicy = new StdPAPPolicy("configTypePolicy", "policyName", "description", "configName",
- true,
- "domain", dyanamicFieldConfigAttributes, 1, "eCompName", "configBodyData", "riskLevel", "riskType",
- "guard", "ttlDate", "brmsController", brmsDependency);
+ StdPAPPolicy stdPAPPolicy = new StdPAPPolicy(StdPAPPolicyParams.builder()
+ .configPolicyType("configTypePolicy")
+ .policyName("policyName")
+ .description("description")
+ .configName("configName")
+ .editPolicy(true)
+ .domain("domain")
+ .dynamicFieldConfigAttributes(dyanamicFieldConfigAttributes)
+ .highestVersion(1)
+ .onapName("eCompName")
+ .configBodyData("configBodyData")
+ .riskLevel("riskLevel")
+ .riskType("riskType")
+ .guard("guard")
+ .ttlDate("ttlDate")
+ .brmsController("brmsController")
+ .brmsDependency(brmsDependency)
+ .build());
assertEquals("configTypePolicy", stdPAPPolicy.getConfigPolicyType());
assertEquals("policyName", stdPAPPolicy.getPolicyName());
assertEquals("description", stdPAPPolicy.getPolicyDescription());
@@ -867,9 +921,24 @@ public class StdPAPPolicyTest {
@Test
public void testConstructorStringStringStringStringBooleanStringStringStringStringStringIntegerStringStringStringString()
throws URISyntaxException {
- StdPAPPolicy stdPAPPolicy = new StdPAPPolicy("configTypePolicy", "policyName", "description", "configName",
- true, "domain", "policyId", "ruleId",
- "version", "jasonBody", 1, "riskLevel", "riskType", "guard", "ttlDate");
+ //test for Updating Config Firewall Policies from the Admin Console
+ StdPAPPolicy stdPAPPolicy = new StdPAPPolicy(StdPAPPolicyParams.builder()
+ .configPolicyType("configTypePolicy")
+ .policyName("policyName")
+ .description("description")
+ .configName("configName")
+ .editPolicy(true)
+ .domain("domain")
+ .policyID("policyId")
+ .ruleID("ruleId")
+ .version("version")
+ .jsonBody("jasonBody")
+ .highestVersion(1)
+ .riskLevel("riskLevel")
+ .riskType("riskType")
+ .guard("guard")
+ .ttlDate("ttlDate")
+ .build());
assertEquals("configTypePolicy", stdPAPPolicy.getConfigPolicyType());
assertEquals("policyName", stdPAPPolicy.getPolicyName());
assertEquals("description", stdPAPPolicy.getPolicyDescription());
@@ -917,9 +986,25 @@ public class StdPAPPolicyTest {
@Test
public void testConstructorStringStringStringStringBooleanStringStringStringStringStringIntegerStringStringStringStringString()
throws URISyntaxException {
- StdPAPPolicy stdPAPPolicy = new StdPAPPolicy("configTypePolicy", "policyName", "description", "configName",
- true, "domain", "policyId", "ruleId", "version",
- "jasonBody", 1, "ecompName", "riskLevel", "riskType", "guard", "ttlDate");
+ //test for Updating Goc Policies from the Admin Console
+ StdPAPPolicy stdPAPPolicy = new StdPAPPolicy(StdPAPPolicyParams.builder()
+ .configPolicyType("configTypePolicy")
+ .policyName("policyName")
+ .description("description")
+ .configName("configName")
+ .editPolicy(true)
+ .domain("domain")
+ .policyID("policyId")
+ .ruleID("ruleId")
+ .version("version")
+ .jsonBody("jasonBody")
+ .highestVersion(1)
+ .onapName("ecompName")
+ .riskLevel("riskLevel")
+ .riskType("riskType")
+ .guard("guard")
+ .ttlDate("ttlDate")
+ .build());
assertEquals("configTypePolicy", stdPAPPolicy.getConfigPolicyType());
assertEquals("policyName", stdPAPPolicy.getPolicyName());
assertEquals("description", stdPAPPolicy.getPolicyDescription());
@@ -941,12 +1026,28 @@ public class StdPAPPolicyTest {
@Test
public void testConstructorStringStringStringStringBooleanStringStringStringStringMapStringStringIntegerStringStringStringStringString()
throws URISyntaxException {
+ //for Updating Brms Policies from the Admin Console
Map<String, String> dyanamicFieldConfigAttributes = new HashMap<>();
dyanamicFieldConfigAttributes.put("aKey", "aValue");
- StdPAPPolicy stdPAPPolicy = new StdPAPPolicy("configTypePolicy", "policyName", "description", "configName",
- true,
- "domain", "policyId", "ruleId", "version", dyanamicFieldConfigAttributes, 1, "eCompName",
- "configBodyData", "riskLevel", "riskType", "guard", "ttlDate");
+ StdPAPPolicy stdPAPPolicy = new StdPAPPolicy(StdPAPPolicyParams.builder()
+ .configPolicyType("configTypePolicy")
+ .policyName("policyName")
+ .description("description")
+ .configName("configName")
+ .editPolicy(true)
+ .domain("domain")
+ .policyID("policyId")
+ .ruleID("ruleId")
+ .version("version")
+ .dynamicFieldConfigAttributes(dyanamicFieldConfigAttributes)
+ .highestVersion(1)
+ .onapName("eCompName")
+ .configBodyData("configBodyData")
+ .riskLevel("riskLevel")
+ .riskType("riskType")
+ .guard("guard")
+ .ttlDate("ttlDate")
+ .build());
assertEquals("configTypePolicy", stdPAPPolicy.getConfigPolicyType());
assertEquals("policyName", stdPAPPolicy.getPolicyName());
assertEquals("description", stdPAPPolicy.getPolicyDescription());
@@ -969,14 +1070,30 @@ public class StdPAPPolicyTest {
@Test
public void testConstructorStringStringStringStringBooleanStringStringStringStringMapStringStringIntegerStringMapStringStringStringStringStringString()
throws URISyntaxException {
+ //for Updating Brms Param Policies from the Admin Console
Map<String, String> dyanamicFieldConfigAttributes = new HashMap<>();
dyanamicFieldConfigAttributes.put("aKey", "aValue");
Map<String, String> drlRuleAndUIParams = new HashMap<>();
drlRuleAndUIParams.put("aDrlRuleKey", "aDrlRuleValue");
- StdPAPPolicy stdPAPPolicy = new StdPAPPolicy("configTypePolicy", "policyName", "description", "configName",
- true,
- "domain", "policyId", "ruleId", "version", dyanamicFieldConfigAttributes, 1, "eCompName",
- drlRuleAndUIParams, "riskLevel", "riskType", "guard", "ttlDate");
+ StdPAPPolicy stdPAPPolicy = new StdPAPPolicy(StdPAPPolicyParams.builder()
+ .configPolicyType("configTypePolicy")
+ .policyName("policyName")
+ .description("description")
+ .configName("configName")
+ .editPolicy(true)
+ .domain("domain")
+ .policyID("policyId")
+ .ruleID("ruleId")
+ .version("version")
+ .dynamicFieldConfigAttributes(dyanamicFieldConfigAttributes)
+ .highestVersion(1)
+ .onapName("eCompName")
+ .drlRuleAndUIParams(drlRuleAndUIParams)
+ .riskLevel("riskLevel")
+ .riskType("riskType")
+ .guard("guard")
+ .ttlDate("ttlDate")
+ .build());
assertEquals("configTypePolicy", stdPAPPolicy.getConfigPolicyType());
assertEquals("policyName", stdPAPPolicy.getPolicyName());
assertEquals("description", stdPAPPolicy.getPolicyDescription());
diff --git a/PolicyEngineClient/src/test/java/org/onap/policyengine/BrmsRawPolicyClient.java b/PolicyEngineClient/src/test/java/org/onap/policyengine/BrmsRawPolicyClient.java
index 18d404dc2..60e2c5df7 100644
--- a/PolicyEngineClient/src/test/java/org/onap/policyengine/BrmsRawPolicyClient.java
+++ b/PolicyEngineClient/src/test/java/org/onap/policyengine/BrmsRawPolicyClient.java
@@ -40,92 +40,81 @@ import org.onap.policy.api.PolicyParameters;
import org.onap.policy.api.PolicyType;
public class BrmsRawPolicyClient {
- static Boolean isEdit = true;
-
- //Reads a File and converts into a String.
- private static String readFile( String file ) throws IOException {
- BufferedReader reader = new BufferedReader( new FileReader (file));
- String line = null;
- StringBuilder stringBuilder = new StringBuilder();
- String ls = System.getProperty("line.separator");
-
- try {
- while( ( line = reader.readLine() ) != null ) {
- stringBuilder.append( line );
- stringBuilder.append( ls );
- }
-
- return stringBuilder.toString();
- } finally {
- reader.close();
- }
- }
-
-
- public static void main(String[] args) {
- try {
- PolicyEngine policyEngine = new PolicyEngine("config.properties");
- PolicyParameters policyParameters = new PolicyParameters();
- Map<String, String> attrib= new HashMap<>();
- attrib.put("cpu","80");
- attrib.put("memory", "50");
- Map<AttributeType, Map<String, String>> attributes = new HashMap<>();
+ static Boolean isEdit = true;
+
+ //Reads a File and converts into a String.
+ private static String readFile( String file ) throws IOException {
+
+ String line = null;
+ StringBuilder stringBuilder = new StringBuilder();
+ String ls = System.getProperty("line.separator");
+
+ try (BufferedReader reader = new BufferedReader( new FileReader (file))) {
+ while( ( line = reader.readLine() ) != null ) {
+ stringBuilder.append( line );
+ stringBuilder.append( ls );
+ }
+ return stringBuilder.toString();
+ }
+ }
+
+
+ public static void main(String[] args) {
+ try {
+ PolicyEngine policyEngine = new PolicyEngine("config.properties");
+ PolicyParameters policyParameters = new PolicyParameters();
+ Map<String, String> attrib= new HashMap<>();
+ attrib.put("cpu","80");
+ attrib.put("memory", "50");
+ Map<AttributeType, Map<String, String>> attributes = new HashMap<>();
attributes.put(AttributeType.RULE, attrib);
-
- // Set Policy Type
- policyParameters.setPolicyConfigType(PolicyConfigType.BRMS_RAW); //required
- policyParameters.setPolicyName("Lakshman.testBRMSRawAPITwo"); //required
- policyParameters.setPolicyDescription("This is a sample BRMS Raw policy body"); //optional
- policyParameters.setAttributes(attributes);
- //policyParameters.setPolicyScope("Lakshman"); //Directory will be created where the Policies are saved... this displays a a subscope on the GUI
- policyParameters.setRequestID(UUID.randomUUID());
-
+
+ // Set Policy Type
+ policyParameters.setPolicyConfigType(PolicyConfigType.BRMS_RAW); //required
+ policyParameters.setPolicyName("Lakshman.testBRMSRawAPITwo"); //required
+ policyParameters.setPolicyDescription("This is a sample BRMS Raw policy body"); //optional
+ policyParameters.setAttributes(attributes);
+ //policyParameters.setPolicyScope("Lakshman"); //Directory will be created where the Policies are saved... this displays a a subscope on the GUI
+ policyParameters.setRequestID(UUID.randomUUID());
+
// Set Safe Policy value for Risk Type
- SimpleDateFormat dateformat3 = new SimpleDateFormat("dd/MM/yyyy");
- Date date = dateformat3.parse("15/10/2016");
- policyParameters.setTtlDate(date);
- // Set Safe Policy value for Guard
- policyParameters.setGuard(true);
- // Set Safe Policy value for Risk Level
- policyParameters.setRiskLevel("5");
- // Set Safe Policy value for Risk Type
- policyParameters.setRiskType("PROD");
-
- File rawBodyFile = null;
-
- Path file = Paths.get("C:\\Users\\testuser\\Documents\\API\\com.Config_BRMS_Raw_TestBrmsPolicy.1.txt");
- rawBodyFile = file.toFile();
-
- policyParameters.setConfigBody(readFile(rawBodyFile.toString()));
- policyParameters.setConfigBodyType(PolicyType.OTHER);
-
- /*public String createUpdateBRMSRawPolicy(String policyName,
- String policyDescription,
- Map<String,String> dyanamicFieldConfigAttributes,
- String brmsRawBody,
- String policyScope,
- Boolean isEdit,
- UUID requestID) */
-
- // API method to create Policy or update policy
- PolicyChangeResponse response = null;
- if (!isEdit) {
- response = policyEngine.createPolicy(policyParameters);
- } else {
- response = policyEngine.updatePolicy(policyParameters);
- }
-
- if(response.getResponseCode()==200){
- System.out.println(response.getResponseMessage());
- System.out.println("Policy Created Successfully!");
- }else{
- System.out.println("Error! " + response.getResponseMessage());
- }
- } catch (Exception e) {
- System.err.println(e.getMessage());
- }
- }
-
+ SimpleDateFormat dateformat3 = new SimpleDateFormat("dd/MM/yyyy");
+ Date date = dateformat3.parse("15/10/2016");
+ policyParameters.setTtlDate(date);
+ // Set Safe Policy value for Guard
+ policyParameters.setGuard(true);
+ // Set Safe Policy value for Risk Level
+ policyParameters.setRiskLevel("5");
+ // Set Safe Policy value for Risk Type
+ policyParameters.setRiskType("PROD");
+
+ File rawBodyFile = null;
+
+ Path file = Paths.get("C:\\Users\\testuser\\Documents\\API\\com.Config_BRMS_Raw_TestBrmsPolicy.1.txt");
+ rawBodyFile = file.toFile();
+
+ policyParameters.setConfigBody(readFile(rawBodyFile.toString()));
+ policyParameters.setConfigBodyType(PolicyType.OTHER);
+
+ // API method to create Policy or update policy
+ PolicyChangeResponse response = null;
+ if (!isEdit) {
+ response = policyEngine.createPolicy(policyParameters);
+ } else {
+ response = policyEngine.updatePolicy(policyParameters);
+ }
+
+ if(response.getResponseCode()==200){
+ System.out.println(response.getResponseMessage());
+ System.out.println("Policy Created Successfully!");
+ }else{
+ System.out.println("Error! " + response.getResponseMessage());
+ }
+ } catch (Exception e) {
+ System.err.println(e.getMessage());
+ }
+ }
+
}