aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorPatrikBuhr <patrik.buhr@est.tech>2020-10-28 09:55:53 +0100
committerPatrikBuhr <patrik.buhr@est.tech>2020-10-28 09:56:32 +0100
commitd8e7dc1541d7467faf1b49df6a3539ab3d6c142f (patch)
treed8b20689ae0ef7e6a2e974b52d132e08c34a790f
parentc655306c67fd9ed6b95d6b111f7bedab79c02f44 (diff)
Improved validation of parameters for putPolicy in the NBI
Change-Id: I6aab3b8415986c48a111304df153b4c44586fcbf Issue-ID: CCSDK-2502 Signed-off-by: PatrikBuhr <patrik.buhr@est.tech>
-rw-r--r--a1-policy-management/src/main/java/org/onap/ccsdk/oran/a1policymanagementservice/controllers/v2/PolicyController.java5
-rw-r--r--a1-policy-management/src/main/java/org/onap/ccsdk/oran/a1policymanagementservice/controllers/v2/PolicyInfo.java2
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<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 @@ 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<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 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() {}