summaryrefslogtreecommitdiffstats
path: root/ONAP-PDP-REST
diff options
context:
space:
mode:
Diffstat (limited to 'ONAP-PDP-REST')
-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
6 files changed, 115 insertions, 25 deletions
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",