summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorPamela Dragosh <pdragosh@research.att.com>2018-08-22 12:02:52 +0000
committerGerrit Code Review <gerrit@onap.org>2018-08-22 12:02:52 +0000
commitc25e4d412eb573de020ba4e5da48f48451217f52 (patch)
treed0744a92887a390f51d9b3c68a878600a97e70c6
parentb0557d5e3e2218d794fac3b28c2254593a6c3a80 (diff)
parentc47063d7cf7b6294547c7628630a5b9fca1daedc (diff)
Merge "Use builder for std pap policy"
-rw-r--r--ONAP-PAP-REST/src/test/java/org/onap/policy/pap/test/XACMLPAPTest.java48
-rw-r--r--ONAP-PDP-REST/src/main/java/org/onap/policy/pdp/rest/api/services/BRMSParamPolicyService.java28
-rw-r--r--ONAP-PDP-REST/src/main/java/org/onap/policy/pdp/rest/api/services/ClosedLoopFaultPolicyService.java24
-rw-r--r--ONAP-PDP-REST/src/main/java/org/onap/policy/pdp/rest/api/services/ClosedLoopPMPolicyService.java24
-rw-r--r--ONAP-PDP-REST/src/main/java/org/onap/policy/pdp/rest/api/services/DeletePolicyService.java9
-rw-r--r--ONAP-PDP-REST/src/main/java/org/onap/policy/pdp/rest/api/services/MicroServicesPolicyService.java29
-rw-r--r--ONAP-PDP-REST/src/main/java/org/onap/policy/pdp/rest/api/services/OptimizationPolicyService.java26
-rw-r--r--ONAP-XACML/src/main/java/org/onap/policy/xacml/std/pap/StdPAPPolicy.java102
-rw-r--r--ONAP-XACML/src/main/java/org/onap/policy/xacml/std/pap/StdPAPPolicyParams.java129
-rw-r--r--ONAP-XACML/src/test/java/org/onap/policy/xacml/test/std/pap/StdPAPPolicyTest.java86
10 files changed, 366 insertions, 139 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 bb14ff866..4ba72afcb 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
@@ -3,7 +3,7 @@
* ONAP-PAP-REST
* ================================================================================
* Copyright (C) 2017-2018 AT&T Intellectual Property. All rights reserved.
- * Modified Copyright (C) 2018 Samsung Electronics Co., Ltd.
+ * Modifications 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.
@@ -222,11 +222,26 @@ public class XACMLPAPTest {
ruleAttributes.put("templateName", "testPolicy");
ruleAttributes.put("samPoll", "5");
ruleAttributes.put("value", "test");
- StdPAPPolicy newPAPPolicy = new StdPAPPolicy("BRMS_Param", "test", "testing",
- "BRMS_PARAM_RULE", false, "test",
- matchingAttributes, 0, "DROOLS",
- null, ruleAttributes, "5",
- "default", "false", "", null, null);
+ //Creating BRMS Param Policies from the Admin Console
+ StdPAPPolicy newPAPPolicy = new StdPAPPolicy(StdPAPPolicyParams.builder()
+ .configPolicyType("BRMS_Param")
+ .policyName("test")
+ .description("testing")
+ .configName("BRMS_PARAM_RULE")
+ .editPolicy(false)
+ .domain("test")
+ .dynamicFieldConfigAttributes(matchingAttributes)
+ .highestVersion(0)
+ .onapName("DROOLS")
+ .configBodyData(null)
+ .drlRuleAndUIParams(ruleAttributes)
+ .riskLevel("5")
+ .riskType("default")
+ .guard("false")
+ .ttlDate("")
+ .brmsController(null)
+ .brmsDependency(null)
+ .build());
MockServletInputStream mockInput =
new MockServletInputStream(PolicyUtils.objectToJsonString(newPAPPolicy).getBytes());
Mockito.when(httpServletRequest.getInputStream()).thenReturn(mockInput);
@@ -289,9 +304,24 @@ public class XACMLPAPTest {
Mockito.when(httpServletRequest.getParameter("operation")).thenReturn("create");
Mockito.when(httpServletRequest.getParameter("policyType")).thenReturn("Config");
String json = "{\"test\":\"java\"}";
- StdPAPPolicy newPAPPolicy = new StdPAPPolicy("ClosedLoop_PM", "test", "testing", "onap",
- json, false, null, "Registration Failure(Trinity)", false, "test", 0, null,
- "default", "true", "");
+ //Creating CloseLoop_Fault and Performance Metric Policies
+ StdPAPPolicy newPAPPolicy = new StdPAPPolicy(StdPAPPolicyParams.builder()
+ .configPolicyType("ClosedLoop_PM")
+ .policyName("test")
+ .description("testing")
+ .onapName("onap")
+ .jsonBody(json)
+ .draft(false)
+ .oldPolicyFileName(null)
+ .serviceType("Registration Failure(Trinity)")
+ .editPolicy(false)
+ .domain("test")
+ .highestVersion(0)
+ .riskLevel(null)
+ .riskType("default")
+ .guard("true")
+ .ttlDate("")
+ .build());
MockServletInputStream mockInput =
new MockServletInputStream(PolicyUtils.objectToJsonString(newPAPPolicy).getBytes());
Mockito.when(httpServletRequest.getInputStream()).thenReturn(mockInput);
diff --git a/ONAP-PDP-REST/src/main/java/org/onap/policy/pdp/rest/api/services/BRMSParamPolicyService.java b/ONAP-PDP-REST/src/main/java/org/onap/policy/pdp/rest/api/services/BRMSParamPolicyService.java
index 29b181238..6b29f27b1 100644
--- a/ONAP-PDP-REST/src/main/java/org/onap/policy/pdp/rest/api/services/BRMSParamPolicyService.java
+++ b/ONAP-PDP-REST/src/main/java/org/onap/policy/pdp/rest/api/services/BRMSParamPolicyService.java
@@ -3,6 +3,7 @@
* ONAP-PDP-REST
* ================================================================================
* Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.
+ * Modifications 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;
/**
* BRMS Param Policy Implementation.
@@ -82,12 +84,26 @@ public class BRMSParamPolicyService {
operation = "create";
}
// Create Policy
- StdPAPPolicy newPAPPolicy = new StdPAPPolicy("BRMS_Param", policyName, policyParameters.getPolicyDescription(),
- "BRMS_PARAM_RULE", updateFlag, policyScope,
- drlRuleAndUIParams.get(AttributeType.MATCHING), 0, "DROOLS",
- null, drlRuleAndUIParams.get(AttributeType.RULE), policyParameters.getRiskLevel(),
- policyParameters.getRiskType(), String.valueOf(policyParameters.getGuard()), date,
- policyParameters.getControllerName(), policyParameters.getDependencyNames());
+ // Creating BRMS Param Policies from the Admin Console
+ StdPAPPolicy newPAPPolicy = new StdPAPPolicy(StdPAPPolicyParams.builder()
+ .configPolicyType("BRMS_Param")
+ .policyName(policyName)
+ .description(policyParameters.getPolicyDescription())
+ .configName("BRMS_PARAM_RULE")
+ .editPolicy(updateFlag)
+ .domain(policyScope)
+ .dynamicFieldConfigAttributes(drlRuleAndUIParams.get(AttributeType.MATCHING))
+ .highestVersion(0)
+ .onapName("DROOLS")
+ .configBodyData(null)
+ .drlRuleAndUIParams(drlRuleAndUIParams.get(AttributeType.RULE))
+ .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(), "ConfigBrmsParam");
diff --git a/ONAP-PDP-REST/src/main/java/org/onap/policy/pdp/rest/api/services/ClosedLoopFaultPolicyService.java b/ONAP-PDP-REST/src/main/java/org/onap/policy/pdp/rest/api/services/ClosedLoopFaultPolicyService.java
index 6879b6e2f..c4210bb66 100644
--- a/ONAP-PDP-REST/src/main/java/org/onap/policy/pdp/rest/api/services/ClosedLoopFaultPolicyService.java
+++ b/ONAP-PDP-REST/src/main/java/org/onap/policy/pdp/rest/api/services/ClosedLoopFaultPolicyService.java
@@ -3,6 +3,7 @@
* ONAP-PDP-REST
* ================================================================================
* Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.
+ * Modifications 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;
/**
* Closed Loop Fault Policy Implementation.
@@ -114,10 +116,24 @@ public class ClosedLoopFaultPolicyService {
}
String jsonBody = configBody.toString();
// Create Policy.
- StdPAPPolicy newPAPPolicy = new StdPAPPolicy("ClosedLoop_Fault", policyName,
- policyParameters.getPolicyDescription(), onapName,
- jsonBody, false, oldPolicyName, null, updateFlag, policyScope, 0, policyParameters.getRiskLevel(),
- policyParameters.getRiskType(), String.valueOf(policyParameters.getGuard()), date);
+ // Creating CloseLoop_Fault and Performance Metric Policies
+ StdPAPPolicy newPAPPolicy = new StdPAPPolicy(StdPAPPolicyParams.builder()
+ .configPolicyType("ClosedLoop_Fault")
+ .policyName(policyName)
+ .description(policyParameters.getPolicyDescription())
+ .onapName(onapName)
+ .jsonBody(jsonBody)
+ .draft(false)
+ .oldPolicyFileName(oldPolicyName)
+ .serviceType(null)
+ .editPolicy(updateFlag)
+ .domain(policyScope)
+ .highestVersion(0)
+ .riskLevel(policyParameters.getRiskLevel())
+ .riskType(policyParameters.getRiskType())
+ .guard(String.valueOf(policyParameters.getGuard()))
+ .ttlDate(date)
+ .build());
//send JSON object to PAP
response = (String) papServices.callPAP(newPAPPolicy, new String[]{"operation=" + operation, "apiflag=api",
"policyType=Config"}, policyParameters.getRequestID(), "ConfigClosedLoop");
diff --git a/ONAP-PDP-REST/src/main/java/org/onap/policy/pdp/rest/api/services/ClosedLoopPMPolicyService.java b/ONAP-PDP-REST/src/main/java/org/onap/policy/pdp/rest/api/services/ClosedLoopPMPolicyService.java
index 3f0416492..64178fc00 100644
--- a/ONAP-PDP-REST/src/main/java/org/onap/policy/pdp/rest/api/services/ClosedLoopPMPolicyService.java
+++ b/ONAP-PDP-REST/src/main/java/org/onap/policy/pdp/rest/api/services/ClosedLoopPMPolicyService.java
@@ -3,6 +3,7 @@
* ONAP-PDP-REST
* ================================================================================
* Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.
+ * Modifications 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;
/**
* Closed Loop PM policy Implementation.
@@ -116,10 +118,24 @@ public class ClosedLoopPMPolicyService {
String jsonBody = configBody.toString();
String serviceType = configBody.get("serviceTypePolicyName").toString().replace("\"", "");
// Create Policy.
- StdPAPPolicy newPAPPolicy = new StdPAPPolicy("ClosedLoop_PM", policyName,
- policyParameters.getPolicyDescription(), onapName,
- jsonBody, false, null, serviceType, updateFlag, policyScope, 0, policyParameters.getRiskLevel(),
- policyParameters.getRiskType(), String.valueOf(policyParameters.getGuard()), date);
+ // Creating CloseLoop_Fault and Performance Metric Policies
+ StdPAPPolicy newPAPPolicy = new StdPAPPolicy(StdPAPPolicyParams.builder()
+ .configPolicyType("ClosedLoop_PM")
+ .policyName(policyName)
+ .description(policyParameters.getPolicyDescription())
+ .onapName(onapName)
+ .jsonBody(jsonBody)
+ .draft(false)
+ .oldPolicyFileName(null)
+ .serviceType(serviceType)
+ .editPolicy(updateFlag)
+ .domain(policyScope)
+ .highestVersion(0)
+ .riskLevel(policyParameters.getRiskLevel())
+ .riskType(policyParameters.getRiskType())
+ .guard(String.valueOf(policyParameters.getGuard()))
+ .ttlDate(date)
+ .build());
//send JSON object to PAP
response = (String) papServices.callPAP(newPAPPolicy, new String[]{"operation=" + operation, "apiflag=api",
"policyType=Config"}, policyParameters.getRequestID(), "ConfigClosedLoop");
diff --git a/ONAP-PDP-REST/src/main/java/org/onap/policy/pdp/rest/api/services/DeletePolicyService.java b/ONAP-PDP-REST/src/main/java/org/onap/policy/pdp/rest/api/services/DeletePolicyService.java
index a7dc42642..52e3bcc1b 100644
--- a/ONAP-PDP-REST/src/main/java/org/onap/policy/pdp/rest/api/services/DeletePolicyService.java
+++ b/ONAP-PDP-REST/src/main/java/org/onap/policy/pdp/rest/api/services/DeletePolicyService.java
@@ -3,6 +3,7 @@
* ONAP-PDP-REST
* ================================================================================
* Copyright (C) 2017-2018 AT&T Intellectual Property. All rights reserved.
+ * Modifications 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;
import org.springframework.http.HttpStatus;
public class DeletePolicyService {
@@ -162,9 +164,12 @@ public class DeletePolicyService {
LOGGER.error(message);
return message;
}
-
+ // for deleting policies from the API
final StdPAPPolicy deletePapPolicy =
- new StdPAPPolicy(fullPolicyName, deletePolicyParameters.getDeleteCondition().toString());
+ new StdPAPPolicy(StdPAPPolicyParams.builder()
+ .policyName(fullPolicyName)
+ .deleteCondition(deletePolicyParameters.getDeleteCondition().toString())
+ .build());
// send JSON object to PAP
response = (String) papServices.callPAP(deletePapPolicy,
new String[] {"groupId=" + pdpGroup, "apiflag=deletePapApi", "operation=delete"},
diff --git a/ONAP-PDP-REST/src/main/java/org/onap/policy/pdp/rest/api/services/MicroServicesPolicyService.java b/ONAP-PDP-REST/src/main/java/org/onap/policy/pdp/rest/api/services/MicroServicesPolicyService.java
index 9ca149240..bc3888820 100644
--- a/ONAP-PDP-REST/src/main/java/org/onap/policy/pdp/rest/api/services/MicroServicesPolicyService.java
+++ b/ONAP-PDP-REST/src/main/java/org/onap/policy/pdp/rest/api/services/MicroServicesPolicyService.java
@@ -3,6 +3,7 @@
* ONAP-PDP-REST
* ================================================================================
* Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.
+ * Modifications 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;
/**
* MicroServices Policy implementation.
@@ -126,11 +128,28 @@ public class MicroServicesPolicyService {
if (microServiceAttributes.containsKey("version")) {
version = microServiceAttributes.get("version").toString().replace("\"", "");
}
- // Create Policy.
- StdPAPPolicy newPAPPolicy = new StdPAPPolicy("Micro Service", policyName, policyDescription, onapName,
- configName, microService, uuid, msLocation, microServiceAttributes.toString(), priority,
- version, updateFlag, policyScope, 0, policyParameters.getRiskLevel(),
- policyParameters.getRiskType(), String.valueOf(policyParameters.getGuard()), date);
+ // Create Policy.
+ // for Micro Service Creating/Updating Policies from the Admin Console
+ StdPAPPolicy newPAPPolicy = new StdPAPPolicy(
+ StdPAPPolicyParams.builder().configPolicyType("Micro Service")
+ .policyName(policyName)
+ .description(policyDescription)
+ .onapName(onapName)
+ .configName(configName)
+ .serviceType(microService)
+ .uuid(uuid)
+ .msLocation(msLocation)
+ .jsonBody(microServiceAttributes.toString())
+ .priority(priority)
+ .version(version)
+ .editPolicy(updateFlag)
+ .domain(policyScope)
+ .highestVersion(0)
+ .riskLevel(policyParameters.getRiskLevel())
+ .riskType(policyParameters.getRiskType())
+ .guard(String.valueOf(policyParameters.getGuard()))
+ .ttlDate(date)
+ .build());
// Send JSON Object to PAP.
response = (String) papServices.callPAP(newPAPPolicy, new String[]{"operation=" + operation, "apiflag=api",
"policyType=Config"}, policyParameters.getRequestID(), "ConfigMS");
diff --git a/ONAP-PDP-REST/src/main/java/org/onap/policy/pdp/rest/api/services/OptimizationPolicyService.java b/ONAP-PDP-REST/src/main/java/org/onap/policy/pdp/rest/api/services/OptimizationPolicyService.java
index 7df90ed8b..7f9aec6fa 100644
--- a/ONAP-PDP-REST/src/main/java/org/onap/policy/pdp/rest/api/services/OptimizationPolicyService.java
+++ b/ONAP-PDP-REST/src/main/java/org/onap/policy/pdp/rest/api/services/OptimizationPolicyService.java
@@ -3,6 +3,7 @@
* ONAP-PDP-REST
* ================================================================================
* Copyright (C) 2018 AT&T Intellectual Property. All rights reserved.
+ * Modifications 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;
/**
* Optimization Policy implementation.
@@ -100,10 +102,26 @@ public class OptimizationPolicyService {
}
// Create Policy Object
- StdPAPPolicy newPAPPolicy = new StdPAPPolicy("Optimization", policyName, policyDescription, onapName,
- null, servicModel, null, null, optimizationAttributes.toString(), priority,
- version, updateFlag, policyScope, 0, policyParameters.getRiskLevel(),
- policyParameters.getRiskType(), String.valueOf(policyParameters.getGuard()), date);
+ StdPAPPolicy newPAPPolicy = new StdPAPPolicy(StdPAPPolicyParams.builder()
+ .configPolicyType("Optimization")
+ .policyName(policyName)
+ .description(policyDescription)
+ .onapName(onapName)
+ .configName(null)
+ .serviceType(servicModel)
+ .uuid(null)
+ .msLocation(null)
+ .jsonBody(optimizationAttributes.toString())
+ .priority(priority)
+ .version(version)
+ .editPolicy(updateFlag)
+ .domain(policyScope)
+ .highestVersion(0)
+ .riskLevel(policyParameters.getRiskLevel())
+ .riskType(policyParameters.getRiskType())
+ .guard(String.valueOf(policyParameters.getGuard()))
+ .ttlDate(date)
+ .build());
// Send JSON Object to PAP
response = (String) papServices.callPAP(newPAPPolicy, new String[]{"operation=" + operation, "apiflag=api",
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 74ded6d43..185175907 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
@@ -3,7 +3,7 @@
* ONAP-XACML
* ================================================================================
* Copyright (C) 2017-2018 AT&T Intellectual Property. All rights reserved.
- * Modified Copyright (C) 2018 Samsung Electronics Co., Ltd.
+ * Modifications 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.
@@ -145,97 +145,17 @@ public class StdPAPPolicy implements OnapPAPPolicy, Serializable {
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> dynamicFieldConfigAttributes, Integer highestVersion, String eCompName,
- String configBodyData, Map<String, String> drlRuleAndUIParams, 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.dynamicFieldConfigAttributes = dynamicFieldConfigAttributes;
- this.highestVersion = highestVersion;
- this.onapName = eCompName;
- this.configBodyData = configBodyData;
- this.drlRuleAndUIParams = drlRuleAndUIParams;
- this.riskLevel = riskLevel;
- this.riskType = riskType;
- this.guard = guard;
- this.ttlDate = ttlDate;
- this.brmsController = brmsController;
- this.brmsDependency = brmsDependency;
- }
-
- //Constructor for Creating CloseLoop_Fault and Performance Metric Policies
- public StdPAPPolicy(String configPolicyType, String policyName, String description, String onapName,
- String jsonBody, Boolean draft, String oldPolicyFileName, String serviceType,
- Boolean editPolicy,
- String domain, Integer highestVersion, String riskLevel, String riskType, String guard,
- String ttlDate) {
+ this.serviceType = stdPAPPolicyParams.getServiceType();
+ this.oldPolicyFileName = stdPAPPolicyParams.getOldPolicyFileName();
+ this.draft = stdPAPPolicyParams.isDraft();
+ this.uuid = stdPAPPolicyParams.getUuid();
+ this.msLocation = stdPAPPolicyParams.getMsLocation();
+ this.priority = stdPAPPolicyParams.getPriority();
+ this.deleteCondition = stdPAPPolicyParams.getDeleteCondition();
+ this.dictionaryType = stdPAPPolicyParams.getDictionaryType();
+ this.dictionary = stdPAPPolicyParams.getDictionary();
+ this.dictionaryFields = stdPAPPolicyParams.getDictionaryFields();
- this.configPolicyType = configPolicyType;
- this.policyName = policyName;
- this.policyDescription = description;
- this.onapName = onapName;
- this.jsonBody = jsonBody;
- this.draft = draft;
- this.oldPolicyFileName = oldPolicyFileName;
- this.serviceType = serviceType;
- this.editPolicy = editPolicy;
- this.domain = domain;
- 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,
- String msLocation, String jsonBody, String priority, String version, Boolean editPolicy,
- 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.serviceType = serviceType;
- this.uuid = uuid;
- this.msLocation = msLocation;
- this.priority = priority;
- this.version = version;
- this.jsonBody = jsonBody;
- this.editPolicy = editPolicy;
- this.domain = domain;
- this.highestVersion = highestVersion;
- 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;
- this.deleteCondition = deleteCondition;
- }
-
- // Constructor for creating dictionary items from the API>
- public StdPAPPolicy(String dictionaryType, String dictionary, String dictionaryFields) {
- this.dictionaryType = dictionaryType;
- this.dictionary = dictionary;
- this.dictionaryFields = dictionaryFields;
}
@Override
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 7eb422b99..780decd88 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
@@ -61,14 +61,37 @@ public class StdPAPPolicyParams {
private String brmsController;
private List<String> brmsDependency;
private Map<String,String> drlRuleAndUIParams;
+ private boolean draft;
+ private String oldPolicyFileName;
+ private String serviceType;
+ private String uuid;
+ private String msLocation;
+ private String priority;
+ private String deleteCondition;
+ private String dictionaryType;
+ private String dictionary;
+ private String dictionaryFields;
/**
+
* Default constructor
*/
private StdPAPPolicyParams() {
super();
}
+ public String getServiceType() {
+ return serviceType;
+ }
+
+ public String getOldPolicyFileName() {
+ return oldPolicyFileName;
+ }
+
+ public boolean isDraft() {
+ return draft;
+ }
+
public int getHighestVersion() {
return highestVersion;
}
@@ -209,6 +232,62 @@ public class StdPAPPolicyParams {
return drlRuleAndUIParams;
}
+ public String getUuid() {
+ return uuid;
+ }
+
+ public void setUuid(String uuid) {
+ this.uuid = uuid;
+ }
+
+ public String getMsLocation() {
+ return msLocation;
+ }
+
+ public void setMsLocation(String msLocation) {
+ this.msLocation = msLocation;
+ }
+
+ public String getPriority() {
+ return priority;
+ }
+
+ public void setPriority(String priority) {
+ this.priority = priority;
+ }
+
+ public String getDeleteCondition() {
+ return deleteCondition;
+ }
+
+ public void setDeleteCondition(String deleteCondition) {
+ this.deleteCondition = deleteCondition;
+ }
+
+ public String getDictionaryType() {
+ return dictionaryType;
+ }
+
+ public void setDictionaryType(String dictionaryType) {
+ this.dictionaryType = dictionaryType;
+ }
+
+ public String getDictionary() {
+ return dictionary;
+ }
+
+ public void setDictionary(String dictionary) {
+ this.dictionary = dictionary;
+ }
+
+ public String getDictionaryFields() {
+ return dictionaryFields;
+ }
+
+ public void setDictionaryFields(String dictionaryFields) {
+ this.dictionaryFields = dictionaryFields;
+ }
+
/**
* Builder class for the Policy parameters
*/
@@ -389,5 +468,55 @@ public class StdPAPPolicyParams {
m.drlRuleAndUIParams = drlRuleAndUIParams;
return this;
}
+
+ public StdPAPPolicyParamsBuilder draft(boolean b) {
+ m.draft = b;
+ return this;
+ }
+
+ public StdPAPPolicyParamsBuilder oldPolicyFileName(String name) {
+ m.oldPolicyFileName = name;
+ return this;
+ }
+
+ public StdPAPPolicyParamsBuilder serviceType(String s) {
+ m.serviceType = s;
+ return this;
+ }
+
+ public StdPAPPolicyParamsBuilder uuid(String uuid) {
+ m.uuid = uuid;
+ return this;
+ }
+
+ public StdPAPPolicyParamsBuilder msLocation(String msLocation) {
+ m.msLocation = msLocation;
+ return this;
+ }
+
+ public StdPAPPolicyParamsBuilder priority(String priority) {
+ m.priority = priority;
+ return this;
+ }
+
+ public StdPAPPolicyParamsBuilder deleteCondition(String deleteCondition) {
+ m.deleteCondition = deleteCondition;
+ return this;
+ }
+
+ public StdPAPPolicyParamsBuilder dictionaryType(String dictionaryType) {
+ m.dictionaryType = dictionaryType;
+ return this;
+ }
+
+ public StdPAPPolicyParamsBuilder dictionary(String dictionary) {
+ m.dictionary = dictionary;
+ return this;
+ }
+
+ public StdPAPPolicyParamsBuilder dictionaryFields(String dictionaryFields) {
+ m.dictionaryFields = dictionaryFields;
+ 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 2de4a0456..d5146d05a 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,7 +3,7 @@
* ONAP-XACML
* ================================================================================
* Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.
- * Modified Copyright (C) 2018 Samsung Electronics Co., Ltd.
+ * Modifications 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.
@@ -872,10 +872,26 @@ public class StdPAPPolicyTest {
drlRuleAndUIParams.put("aDrlRuleKey", "aDrlRuleValue");
ArrayList<String> brmsDependency = new ArrayList<>();
brmsDependency.add("brmsDependency");
- StdPAPPolicy stdPAPPolicy = new StdPAPPolicy("configTypePolicy", "policyName", "description", "configName",
- true,
- "domain", dyanamicFieldConfigAttributes, 1, "eCompName", "configBodyData", drlRuleAndUIParams,
- "riskLevel", "riskType", "guard", "ttlDate", "brmsController", brmsDependency);
+ //Creating BRMS Param Policies from the Admin Console
+ 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")
+ .drlRuleAndUIParams(drlRuleAndUIParams)
+ .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());
@@ -898,9 +914,24 @@ public class StdPAPPolicyTest {
@Test
public void testConstructorStringStringStringStringStringBooleanStringStringBooleanStringIntegerStringStringStringString()
throws URISyntaxException {
- StdPAPPolicy stdPAPPolicy = new StdPAPPolicy("configTypePolicy", "policyName", "description", "onapName",
- "jasonBody", true,
- "oldPolicyFileName", "serviceType", true, "domain", 1, "riskLevel", "riskType", "guard", "ttlDate");
+ //Creating CloseLoop_Fault and Performance Metric Policies
+ StdPAPPolicy stdPAPPolicy = new StdPAPPolicy(StdPAPPolicyParams.builder()
+ .configPolicyType("configTypePolicy")
+ .policyName("policyName")
+ .description("description")
+ .onapName("onapName")
+ .jsonBody("jasonBody")
+ .draft(true)
+ .oldPolicyFileName("oldPolicyFileName")
+ .serviceType("serviceType")
+ .editPolicy(true)
+ .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());
@@ -959,10 +990,27 @@ public class StdPAPPolicyTest {
@Test
public void testConstructorStringStringStringStringStringStringStringStringStringStringStringBooleanStringintStringStringStringString()
throws URISyntaxException {
- StdPAPPolicy stdPAPPolicy = new StdPAPPolicy("configTypePolicy", "policyName", "description", "onapName",
- "configName", "serviceType",
- "uuid", "msLocation", "jasonBody", "priority", "version", true, "domain",
- 1, "riskLevel", "riskType", "guard", "ttlDate");
+ //for Micro Service Creating/Updating Policies from the Admin Console
+ StdPAPPolicy stdPAPPolicy = new StdPAPPolicy(StdPAPPolicyParams.builder()
+ .configPolicyType("configTypePolicy")
+ .policyName("policyName")
+ .description("description")
+ .onapName("onapName")
+ .configName("configName")
+ .serviceType("serviceType")
+ .uuid("uuid")
+ .msLocation("msLocation")
+ .jsonBody("jasonBody")
+ .priority("priority")
+ .version("version")
+ .editPolicy(true)
+ .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());
@@ -1115,14 +1163,24 @@ public class StdPAPPolicyTest {
@Test
public void testConstructorStringString() {
- StdPAPPolicy stdPAPPolicy = new StdPAPPolicy("policyName", "deleteCondition");
+ // for deleting policies from the API
+ StdPAPPolicy stdPAPPolicy = new StdPAPPolicy(StdPAPPolicyParams.builder()
+ .policyName("policyName")
+ .deleteCondition("deleteCondition")
+ .build());
assertEquals("policyName", stdPAPPolicy.getPolicyName());
assertEquals("deleteCondition", stdPAPPolicy.getDeleteCondition());
}
@Test
public void testConstructorStringStringString() {
- StdPAPPolicy stdPAPPolicy = new StdPAPPolicy("dictionaryType", "dictionary", "dictionaryFields");
+ // for creating dictionary items from the API>
+ StdPAPPolicy stdPAPPolicy = new StdPAPPolicy(
+ StdPAPPolicyParams.builder()
+ .dictionaryType("dictionaryType")
+ .dictionary("dictionary")
+ .dictionaryFields("dictionaryFields")
+ .build());
assertEquals("dictionaryType", stdPAPPolicy.getDictionaryType());
assertEquals("dictionary", stdPAPPolicy.getDictionary());
assertEquals("dictionaryFields", stdPAPPolicy.getDictionaryFields());