Added the new versioning validation for policy and policy type
[policy/api.git] / main / src / main / java / org / onap / policy / api / main / rest / ApiRestController.java
index 6d6b4d1..f9eff4c 100644 (file)
@@ -3,7 +3,7 @@
  * ONAP Policy API\r
  * ================================================================================\r
  * Copyright (C) 2018 Samsung Electronics Co., Ltd. All rights reserved.\r
- * Copyright (C) 2019 AT&T Intellectual Property. All rights reserved.\r
+ * Copyright (C) 2019-2020 AT&T Intellectual Property. All rights reserved.\r
  * ================================================================================\r
  * Licensed under the Apache License, Version 2.0 (the "License");\r
  * you may not use this file except in compliance with the License.\r
@@ -374,26 +374,35 @@ public class ApiRestController extends CommonRestController {
             authorizations = @Authorization(value = "basicAuth"), tags = {"PolicyType",},\r
             response = ToscaServiceTemplate.class,\r
             responseHeaders = {\r
-                @ResponseHeader(name = "X-MinorVersion",\r
-                        description = "Used to request or communicate a MINOR version back from the client"\r
-                                + " to the server, and from the server back to the client",\r
-                        response = String.class),\r
-                @ResponseHeader(name = "X-PatchVersion",\r
-                        description = "Used only to communicate a PATCH version in a response for"\r
-                                + " troubleshooting purposes only, and will not be provided by"\r
-                                + " the client on request",\r
-                        response = String.class),\r
-                @ResponseHeader(name = "X-LatestVersion",\r
-                        description = "Used only to communicate an API's latest version", response = String.class),\r
-                @ResponseHeader(name = "X-ONAP-RequestID",\r
-                        description = "Used to track REST transactions for logging purpose", response = UUID.class)},\r
-            extensions = {@Extension(name = "interface info",\r
-                    properties = {@ExtensionProperty(name = "api-version", value = "1.0.0"),\r
-                        @ExtensionProperty(name = "last-mod-release", value = "Dublin")})})\r
-    @ApiResponses(value = {@ApiResponse(code = 400, message = "Invalid Body"),\r
-        @ApiResponse(code = 401, message = "Authentication Error"),\r
-        @ApiResponse(code = 403, message = "Authorization Error"),\r
-        @ApiResponse(code = 500, message = "Internal Server Error")})\r
+                    @ResponseHeader(name = "X-MinorVersion",\r
+                                    description = "Used to request or communicate a MINOR version back from the client"\r
+                                                + " to the server, and from the server back to the client",\r
+                                    response = String.class),\r
+                    @ResponseHeader(name = "X-PatchVersion",\r
+                                    description = "Used only to communicate a PATCH version in a response for"\r
+                                                + " troubleshooting purposes only, and will not be provided by"\r
+                                                + " the client on request",\r
+                                    response = String.class),\r
+                    @ResponseHeader(name = "X-LatestVersion",\r
+                                    description = "Used only to communicate an API's latest version",\r
+                                    response = String.class),\r
+                    @ResponseHeader(name = "X-ONAP-RequestID",\r
+                                    description = "Used to track REST transactions for logging purpose",\r
+                                    response = UUID.class)\r
+            },\r
+            extensions = {\r
+                    @Extension(name = "interface info", properties = {\r
+                            @ExtensionProperty(name = "api-version", value = "1.0.0"),\r
+                            @ExtensionProperty(name = "last-mod-release", value = "Dublin")\r
+                    })\r
+            })\r
+    @ApiResponses(value = {\r
+            @ApiResponse(code = 400, message = "Invalid Body"),\r
+            @ApiResponse(code = 401, message = "Authentication Error"),\r
+            @ApiResponse(code = 403, message = "Authorization Error"),\r
+            @ApiResponse(code = 406, message = "Not Acceptable Payload"),\r
+            @ApiResponse(code = 500, message = "Internal Server Error")\r
+        })\r
     public Response createPolicyType(\r
             @ApiParam(value = "Entity body of policy type", required = true) ToscaServiceTemplate body,\r
             @HeaderParam("X-ONAP-RequestID") @ApiParam("RequestID for http transaction") UUID requestId) {\r
@@ -758,27 +767,36 @@ public class ApiRestController extends CommonRestController {
             authorizations = @Authorization(value = "basicAuth"), tags = {"Policy",},\r
             response = ToscaServiceTemplate.class,\r
             responseHeaders = {\r
-                @ResponseHeader(name = "X-MinorVersion",\r
-                        description = "Used to request or communicate a MINOR version back from the client"\r
-                                + " to the server, and from the server back to the client",\r
-                        response = String.class),\r
-                @ResponseHeader(name = "X-PatchVersion",\r
-                        description = "Used only to communicate a PATCH version in a response for"\r
-                                + " troubleshooting purposes only, and will not be provided by"\r
-                                + " the client on request",\r
-                        response = String.class),\r
-                @ResponseHeader(name = "X-LatestVersion",\r
-                        description = "Used only to communicate an API's latest version", response = String.class),\r
-                @ResponseHeader(name = "X-ONAP-RequestID",\r
-                        description = "Used to track REST transactions for logging purpose", response = UUID.class)},\r
-            extensions = {@Extension(name = "interface info",\r
-                    properties = {@ExtensionProperty(name = "api-version", value = "1.0.0"),\r
-                        @ExtensionProperty(name = "last-mod-release", value = "Dublin")})})\r
-    @ApiResponses(value = {@ApiResponse(code = 400, message = "Invalid Body"),\r
-        @ApiResponse(code = 401, message = "Authentication Error"),\r
-        @ApiResponse(code = 403, message = "Authorization Error"),\r
-        @ApiResponse(code = 404, message = "Resource Not Found"),\r
-        @ApiResponse(code = 500, message = "Internal Server Error")})\r
+                    @ResponseHeader(name = "X-MinorVersion",\r
+                                    description = "Used to request or communicate a MINOR version back from the client"\r
+                                                + " to the server, and from the server back to the client",\r
+                                    response = String.class),\r
+                    @ResponseHeader(name = "X-PatchVersion",\r
+                                    description = "Used only to communicate a PATCH version in a response for"\r
+                                                + " troubleshooting purposes only, and will not be provided by"\r
+                                                + " the client on request",\r
+                                    response = String.class),\r
+                    @ResponseHeader(name = "X-LatestVersion",\r
+                                    description = "Used only to communicate an API's latest version",\r
+                                    response = String.class),\r
+                    @ResponseHeader(name = "X-ONAP-RequestID",\r
+                                    description = "Used to track REST transactions for logging purpose",\r
+                                    response = UUID.class)\r
+            },\r
+            extensions = {\r
+                    @Extension(name = "interface info", properties = {\r
+                            @ExtensionProperty(name = "api-version", value = "1.0.0"),\r
+                            @ExtensionProperty(name = "last-mod-release", value = "Dublin")\r
+                    })\r
+            })\r
+    @ApiResponses(value = {\r
+            @ApiResponse(code = 400, message = "Invalid Body"),\r
+            @ApiResponse(code = 401, message = "Authentication Error"),\r
+            @ApiResponse(code = 403, message = "Authorization Error"),\r
+            @ApiResponse(code = 404, message = "Resource Not Found"),\r
+            @ApiResponse(code = 406, message = "Not Acceptable Payload"),\r
+            @ApiResponse(code = 500, message = "Internal Server Error")\r
+        })\r
     public Response createPolicy(\r
             @PathParam("policyTypeId") @ApiParam(value = "ID of policy type", required = true) String policyTypeId,\r
             @PathParam("policyTypeVersion") @ApiParam(value = "Version of policy type",\r
@@ -816,27 +834,36 @@ public class ApiRestController extends CommonRestController {
             authorizations = @Authorization(value = "basicAuth"), tags = {"Policy",},\r
             response = ToscaServiceTemplate.class,\r
             responseHeaders = {\r
-                @ResponseHeader(name = "X-MinorVersion",\r
-                        description = "Used to request or communicate a MINOR version back from the client"\r
-                                + " to the server, and from the server back to the client",\r
-                        response = String.class),\r
-                @ResponseHeader(name = "X-PatchVersion",\r
-                        description = "Used only to communicate a PATCH version in a response for"\r
-                                + " troubleshooting purposes only, and will not be provided by"\r
-                                + " the client on request",\r
-                        response = String.class),\r
-                @ResponseHeader(name = "X-LatestVersion",\r
-                        description = "Used only to communicate an API's latest version", response = String.class),\r
-                @ResponseHeader(name = "X-ONAP-RequestID",\r
-                        description = "Used to track REST transactions for logging purpose", response = UUID.class)},\r
-            extensions = {@Extension(name = "interface info",\r
-                    properties = {@ExtensionProperty(name = "api-version", value = "1.0.0"),\r
-                        @ExtensionProperty(name = "last-mod-release", value = "El Alto")})})\r
-    @ApiResponses(value = {@ApiResponse(code = 400, message = "Invalid Body"),\r
-        @ApiResponse(code = 401, message = "Authentication Error"),\r
-        @ApiResponse(code = 403, message = "Authorization Error"),\r
-        @ApiResponse(code = 404, message = "Resource Not Found"),\r
-        @ApiResponse(code = 500, message = "Internal Server Error")})\r
+                    @ResponseHeader(name = "X-MinorVersion",\r
+                                    description = "Used to request or communicate a MINOR version back from the client"\r
+                                                + " to the server, and from the server back to the client",\r
+                                    response = String.class),\r
+                    @ResponseHeader(name = "X-PatchVersion",\r
+                                    description = "Used only to communicate a PATCH version in a response for"\r
+                                                + " troubleshooting purposes only, and will not be provided by"\r
+                                                + " the client on request",\r
+                                    response = String.class),\r
+                    @ResponseHeader(name = "X-LatestVersion",\r
+                                    description = "Used only to communicate an API's latest version",\r
+                                    response = String.class),\r
+                    @ResponseHeader(name = "X-ONAP-RequestID",\r
+                                    description = "Used to track REST transactions for logging purpose",\r
+                                    response = UUID.class)\r
+            },\r
+            extensions = {\r
+                    @Extension(name = "interface info", properties = {\r
+                            @ExtensionProperty(name = "api-version", value = "1.0.0"),\r
+                            @ExtensionProperty(name = "last-mod-release", value = "El Alto")\r
+                    })\r
+            })\r
+    @ApiResponses(value = {\r
+            @ApiResponse(code = 400, message = "Invalid Body"),\r
+            @ApiResponse(code = 401, message = "Authentication Error"),\r
+            @ApiResponse(code = 403, message = "Authorization Error"),\r
+            @ApiResponse(code = 404, message = "Resource Not Found"),\r
+            @ApiResponse(code = 406, message = "Not Acceptable Payload"),\r
+            @ApiResponse(code = 500, message = "Internal Server Error")\r
+        })\r
     public Response createPolicies(\r
             @HeaderParam("X-ONAP-RequestID") @ApiParam("RequestID for http transaction") UUID requestId,\r
             @ApiParam(value = "Entity body of policy", required = true) ToscaServiceTemplate body) {\r