diff options
author | Krishnajinka <kris.jinka@samsung.com> | 2018-08-20 14:18:14 +0900 |
---|---|---|
committer | Krishnajinka <kris.jinka@samsung.com> | 2018-08-20 14:18:50 +0900 |
commit | c47063d7cf7b6294547c7628630a5b9fca1daedc (patch) | |
tree | a025965d319f5138238d153c32245f86ccf7dbed /ONAP-PDP-REST/src/main/java/org/onap/policy/pdp/rest/api/services/MicroServicesPolicyService.java | |
parent | 84df4a428ded309f750f52ac1c104ac84e426fc0 (diff) |
Use builder for std pap policy
Modify constructor in stdpappolicy to use builder
this will fix the sonar issue related with more than
7 parameters method parameters
Issue-ID: POLICY-1016
Change-Id: Id736a66e5ea48f0f233cffb640cdce8aaa8f2c0d
Signed-off-by: Krishnajinka <kris.jinka@samsung.com>
Diffstat (limited to 'ONAP-PDP-REST/src/main/java/org/onap/policy/pdp/rest/api/services/MicroServicesPolicyService.java')
-rw-r--r-- | ONAP-PDP-REST/src/main/java/org/onap/policy/pdp/rest/api/services/MicroServicesPolicyService.java | 29 |
1 files changed, 24 insertions, 5 deletions
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"); |