From d8e7dc1541d7467faf1b49df6a3539ab3d6c142f Mon Sep 17 00:00:00 2001 From: PatrikBuhr Date: Wed, 28 Oct 2020 09:55:53 +0100 Subject: Improved validation of parameters for putPolicy in the NBI Change-Id: I6aab3b8415986c48a111304df153b4c44586fcbf Issue-ID: CCSDK-2502 Signed-off-by: PatrikBuhr --- .../a1policymanagementservice/controllers/v2/PolicyController.java | 5 ++++- .../oran/a1policymanagementservice/controllers/v2/PolicyInfo.java | 2 +- 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/a1-policy-management/src/main/java/org/onap/ccsdk/oran/a1policymanagementservice/controllers/v2/PolicyController.java b/a1-policy-management/src/main/java/org/onap/ccsdk/oran/a1policymanagementservice/controllers/v2/PolicyController.java index c18ec81b..13568dbc 100644 --- a/a1-policy-management/src/main/java/org/onap/ccsdk/oran/a1policymanagementservice/controllers/v2/PolicyController.java +++ b/a1-policy-management/src/main/java/org/onap/ccsdk/oran/a1policymanagementservice/controllers/v2/PolicyController.java @@ -190,6 +190,9 @@ public class PolicyController { }) public Mono> putPolicy(@RequestBody PolicyInfo policyInfo) { + if (!policyInfo.validate()) { + return ErrorResponse.createMono("Missing required parameter in body", HttpStatus.BAD_REQUEST); + } String jsonString = gson.toJson(policyInfo.policyData); Ric ric = rics.get(policyInfo.ricId); PolicyType type = policyTypes.get(policyInfo.policyTypeId); @@ -286,7 +289,7 @@ public class PolicyController { @ApiResponse(code = 200, message = "Policies", response = PolicyInfoList.class), @ApiResponse(code = 404, message = "Near-RT RIC, policy type or service not found", response = ErrorResponse.ErrorInfo.class)}) - public ResponseEntity getPolicies( // + public ResponseEntity getPolicyInstances( // @ApiParam(name = Consts.POLICY_TYPE_ID_PARAM, required = false, value = "The identity of the policy type to get policies for.") // @RequestParam(name = Consts.POLICY_TYPE_ID_PARAM, required = false) String type, // diff --git a/a1-policy-management/src/main/java/org/onap/ccsdk/oran/a1policymanagementservice/controllers/v2/PolicyInfo.java b/a1-policy-management/src/main/java/org/onap/ccsdk/oran/a1policymanagementservice/controllers/v2/PolicyInfo.java index 0ec2165c..594cf786 100644 --- a/a1-policy-management/src/main/java/org/onap/ccsdk/oran/a1policymanagementservice/controllers/v2/PolicyInfo.java +++ b/a1-policy-management/src/main/java/org/onap/ccsdk/oran/a1policymanagementservice/controllers/v2/PolicyInfo.java @@ -65,7 +65,7 @@ public class PolicyInfo { @ApiModelProperty(value = "Callback URI for policy status updates", required = false) @JsonProperty(value = "status_notification_uri", required = false) @SerializedName("status_notification_uri") - public String statusNotificationUri; + public String statusNotificationUri = ""; PolicyInfo() {} -- cgit 1.2.3-korg