Improved validation of parameters for putPolicy in the NBI
Change-Id: I6aab3b8415986c48a111304df153b4c44586fcbf
Issue-ID: CCSDK-2502
Signed-off-by: PatrikBuhr <patrik.buhr@est.tech>
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 c18ec81..13568db 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 Mono<ResponseEntity<Object>> 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 @@
@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<Object> getPolicies( //
+ public ResponseEntity<Object> 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 0ec2165..594cf78 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 @@
@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() {}