Java 17 / Spring 6 / Spring Boot 3 Upgrade
[policy/api.git] / main / src / main / java / org / onap / policy / api / main / rest / ApiRestController.java
index a1e6db2..b44e60f 100644 (file)
@@ -4,7 +4,7 @@
  * ================================================================================\r
  * Copyright (C) 2018 Samsung Electronics Co., Ltd. All rights reserved.\r
  * Modifications Copyright (C) 2019-2021 AT&T Intellectual Property. All rights reserved.\r
- * Modifications Copyright (C) 2020-2022 Nordix Foundation.\r
+ * Modifications Copyright (C) 2020-2023 Nordix Foundation.\r
  * Modifications Copyright (C) 2020-2023 Bell Canada. All rights reserved.\r
  * ================================================================================\r
  * Licensed under the Apache License, Version 2.0 (the "License");\r
@@ -25,9 +25,9 @@
 \r
 package org.onap.policy.api.main.rest;\r
 \r
+import jakarta.ws.rs.core.Response.Status;\r
 import java.util.List;\r
 import java.util.UUID;\r
-import javax.ws.rs.core.Response.Status;\r
 import lombok.RequiredArgsConstructor;\r
 import org.onap.policy.api.main.exception.PolicyApiRuntimeException;\r
 import org.onap.policy.api.main.rest.genapi.PolicyDesignApi;\r
@@ -41,8 +41,6 @@ import org.onap.policy.models.base.PfModelException;
 import org.onap.policy.models.base.PfModelRuntimeException;\r
 import org.onap.policy.models.tosca.authorative.concepts.ToscaServiceTemplate;\r
 import org.springframework.context.annotation.Profile;\r
-import org.springframework.http.HttpMethod;\r
-import org.springframework.http.HttpStatus;\r
 import org.springframework.http.ResponseEntity;\r
 import org.springframework.web.bind.annotation.RestController;\r
 \r
@@ -56,12 +54,6 @@ import org.springframework.web.bind.annotation.RestController;
 @Profile("default")\r
 public class ApiRestController extends CommonRestController implements PolicyDesignApi {\r
 \r
-    private enum Target {\r
-        POLICY,\r
-        POLICY_TYPE,\r
-        OTHER\r
-    }\r
-\r
     private final ToscaServiceTemplateService toscaServiceTemplateService;\r
     private final HealthCheckProvider healthCheckProvider;\r
 \r
@@ -96,13 +88,12 @@ public class ApiRestController extends CommonRestController implements PolicyDes
      * Retrieves all versions of a particular policy type.\r
      *\r
      * @param policyTypeId the ID of specified policy type\r
-     *\r
      * @return the Response object containing the results of the API operation\r
      */\r
     @Override\r
     public ResponseEntity<ToscaServiceTemplate> getAllVersionsOfPolicyType(\r
-            String policyTypeId,\r
-            UUID requestId) {\r
+        String policyTypeId,\r
+        UUID requestId) {\r
         try {\r
             ToscaServiceTemplate serviceTemplate = toscaServiceTemplateService.fetchPolicyTypes(policyTypeId, null);\r
             return makeOkResponse(requestId, serviceTemplate);\r
@@ -116,15 +107,14 @@ public class ApiRestController extends CommonRestController implements PolicyDes
      * Retrieves specified version of a particular policy type.\r
      *\r
      * @param policyTypeId the ID of specified policy type\r
-     * @param versionId the version of specified policy type\r
-     *\r
+     * @param versionId    the version of specified policy type\r
      * @return the Response object containing the results of the API operation\r
      */\r
     @Override\r
     public ResponseEntity<ToscaServiceTemplate> getSpecificVersionOfPolicyType(\r
-            String policyTypeId,\r
-            String versionId,\r
-            UUID requestId) {\r
+        String policyTypeId,\r
+        String versionId,\r
+        UUID requestId) {\r
         try {\r
             ToscaServiceTemplate serviceTemplate =\r
                 toscaServiceTemplateService.fetchPolicyTypes(policyTypeId, versionId);\r
@@ -139,13 +129,12 @@ public class ApiRestController extends CommonRestController implements PolicyDes
      * Retrieves latest version of a particular policy type.\r
      *\r
      * @param policyTypeId the ID of specified policy type\r
-     *\r
      * @return the Response object containing the results of the API operation\r
      */\r
     @Override\r
     public ResponseEntity<ToscaServiceTemplate> getLatestVersionOfPolicyType(\r
-            String policyTypeId,\r
-            UUID requestId) {\r
+        String policyTypeId,\r
+        UUID requestId) {\r
         try {\r
             ToscaServiceTemplate serviceTemplate = toscaServiceTemplateService.fetchLatestPolicyTypes(policyTypeId);\r
             return makeOkResponse(requestId, serviceTemplate);\r
@@ -159,13 +148,12 @@ public class ApiRestController extends CommonRestController implements PolicyDes
      * Creates a new policy type.\r
      *\r
      * @param body the body of policy type following TOSCA definition\r
-     *\r
      * @return the Response object containing the results of the API operation\r
      */\r
     @Override\r
     public ResponseEntity<ToscaServiceTemplate> createPolicyType(\r
-            ToscaServiceTemplate body,\r
-            UUID requestId) {\r
+        ToscaServiceTemplate body,\r
+        UUID requestId) {\r
         if (NetLoggerUtil.getNetworkLogger().isInfoEnabled()) {\r
             NetLoggerUtil.log(EventType.IN, CommInfrastructure.REST, "/policytypes", toJson(body));\r
         }\r
@@ -182,15 +170,14 @@ public class ApiRestController extends CommonRestController implements PolicyDes
      * Deletes specified version of a particular policy type.\r
      *\r
      * @param policyTypeId the ID of specified policy type\r
-     * @param versionId the version of specified policy type\r
-     *\r
+     * @param versionId    the version of specified policy type\r
      * @return the Response object containing the results of the API operation\r
      */\r
     @Override\r
     public ResponseEntity<ToscaServiceTemplate> deleteSpecificVersionOfPolicyType(\r
-            String policyTypeId,\r
-            String versionId,\r
-            UUID requestId) {\r
+        String policyTypeId,\r
+        String versionId,\r
+        UUID requestId) {\r
         try {\r
             ToscaServiceTemplate serviceTemplate =\r
                 toscaServiceTemplateService.deletePolicyType(policyTypeId, versionId);\r
@@ -204,17 +191,16 @@ public class ApiRestController extends CommonRestController implements PolicyDes
     /**\r
      * Retrieves all versions of a particular policy.\r
      *\r
-     * @param policyTypeId the ID of specified policy type\r
+     * @param policyTypeId      the ID of specified policy type\r
      * @param policyTypeVersion the version of specified policy type\r
-     *\r
      * @return the Response object containing the results of the API operation\r
      */\r
     @Override\r
     public ResponseEntity<ToscaServiceTemplate> getAllPolicies(\r
-            String policyTypeId,\r
-            String policyTypeVersion,\r
-            PolicyFetchMode mode,\r
-            UUID requestId) {\r
+        String policyTypeId,\r
+        String policyTypeVersion,\r
+        PolicyFetchMode mode,\r
+        UUID requestId) {\r
         try {\r
             ToscaServiceTemplate serviceTemplate =\r
                 toscaServiceTemplateService.fetchPolicies(policyTypeId, policyTypeVersion, null, null, mode);\r
@@ -228,19 +214,18 @@ public class ApiRestController extends CommonRestController implements PolicyDes
     /**\r
      * Retrieves all versions of a particular policy.\r
      *\r
-     * @param policyTypeId the ID of specified policy type\r
+     * @param policyTypeId      the ID of specified policy type\r
      * @param policyTypeVersion the version of specified policy type\r
-     * @param policyId the ID of specified policy\r
-     *\r
+     * @param policyId          the ID of specified policy\r
      * @return the Response object containing the results of the API operation\r
      */\r
     @Override\r
     public ResponseEntity<ToscaServiceTemplate> getAllVersionsOfPolicy(\r
-            String policyId,\r
-            String policyTypeId,\r
-            String policyTypeVersion,\r
-            PolicyFetchMode mode,\r
-            UUID requestId) {\r
+        String policyId,\r
+        String policyTypeId,\r
+        String policyTypeVersion,\r
+        PolicyFetchMode mode,\r
+        UUID requestId) {\r
         try {\r
             ToscaServiceTemplate serviceTemplate =\r
                 toscaServiceTemplateService.fetchPolicies(policyTypeId, policyTypeVersion, policyId, null, mode);\r
@@ -255,21 +240,20 @@ public class ApiRestController extends CommonRestController implements PolicyDes
     /**\r
      * Retrieves the specified version of a particular policy.\r
      *\r
-     * @param policyTypeId the ID of specified policy type\r
+     * @param policyTypeId      the ID of specified policy type\r
      * @param policyTypeVersion the version of specified policy type\r
-     * @param policyId the ID of specified policy\r
-     * @param policyVersion the version of specified policy\r
-     *\r
+     * @param policyId          the ID of specified policy\r
+     * @param policyVersion     the version of specified policy\r
      * @return the Response object containing the results of the API operation\r
      */\r
     @Override\r
     public ResponseEntity<ToscaServiceTemplate> getSpecificVersionOfPolicy(\r
-            String policyId,\r
-            String policyTypeId,\r
-            String policyTypeVersion,\r
-            String policyVersion,\r
-            PolicyFetchMode mode,\r
-            UUID requestId) {\r
+        String policyId,\r
+        String policyTypeId,\r
+        String policyTypeVersion,\r
+        String policyVersion,\r
+        PolicyFetchMode mode,\r
+        UUID requestId) {\r
         try {\r
             ToscaServiceTemplate serviceTemplate = toscaServiceTemplateService\r
                 .fetchPolicies(policyTypeId, policyTypeVersion, policyId, policyVersion, mode);\r
@@ -284,19 +268,18 @@ public class ApiRestController extends CommonRestController implements PolicyDes
     /**\r
      * Retrieves the latest version of a particular policy.\r
      *\r
-     * @param policyTypeId the ID of specified policy type\r
+     * @param policyTypeId      the ID of specified policy type\r
      * @param policyTypeVersion the version of specified policy type\r
-     * @param policyId the ID of specified policy\r
-     *\r
+     * @param policyId          the ID of specified policy\r
      * @return the Response object containing the results of the API operation\r
      */\r
     @Override\r
     public ResponseEntity<ToscaServiceTemplate> getLatestVersionOfPolicy(\r
-            String policyId,\r
-            String policyTypeId,\r
-            String policyTypeVersion,\r
-            PolicyFetchMode mode,\r
-            UUID requestId) {\r
+        String policyId,\r
+        String policyTypeId,\r
+        String policyTypeVersion,\r
+        PolicyFetchMode mode,\r
+        UUID requestId) {\r
         try {\r
             ToscaServiceTemplate serviceTemplate =\r
                 toscaServiceTemplateService.fetchLatestPolicies(policyTypeId, policyTypeVersion, policyId, mode);\r
@@ -311,18 +294,17 @@ public class ApiRestController extends CommonRestController implements PolicyDes
     /**\r
      * Creates a new policy for a particular policy type and version.\r
      *\r
-     * @param policyTypeId the ID of specified policy type\r
+     * @param policyTypeId      the ID of specified policy type\r
      * @param policyTypeVersion the version of specified policy type\r
-     * @param body the body of policy following TOSCA definition\r
-     *\r
+     * @param body              the body of policy following TOSCA definition\r
      * @return the Response object containing the results of the API operation\r
      */\r
     @Override\r
     public ResponseEntity<ToscaServiceTemplate> createPolicy(\r
-            String policyTypeId,\r
-            String policyTypeVersion,\r
-            ToscaServiceTemplate body,\r
-            UUID requestId) {\r
+        String policyTypeId,\r
+        String policyTypeVersion,\r
+        ToscaServiceTemplate body,\r
+        UUID requestId) {\r
         if (NetLoggerUtil.getNetworkLogger().isInfoEnabled()) {\r
             NetLoggerUtil.log(EventType.IN, CommInfrastructure.REST,\r
                 "/policytypes/" + policyTypeId + "/versions/" + policyTypeVersion + "/policies", toJson(body));\r
@@ -340,11 +322,10 @@ public class ApiRestController extends CommonRestController implements PolicyDes
     /**\r
      * Deletes the specified version of a particular policy.\r
      *\r
-     * @param policyTypeId the ID of specified policy type\r
+     * @param policyTypeId      the ID of specified policy type\r
      * @param policyTypeVersion the version of specified policy type\r
-     * @param policyId the ID of specified policy\r
-     * @param policyVersion the version of specified policy\r
-     *\r
+     * @param policyId          the ID of specified policy\r
+     * @param policyVersion     the version of specified policy\r
      * @return the Response object containing the results of the API operation\r
      */\r
     @Override\r
@@ -372,8 +353,8 @@ public class ApiRestController extends CommonRestController implements PolicyDes
      */\r
     @Override\r
     public ResponseEntity<ToscaServiceTemplate> getPolicies(\r
-            PolicyFetchMode mode,\r
-            UUID requestId) {\r
+        PolicyFetchMode mode,\r
+        UUID requestId) {\r
         try {\r
             ToscaServiceTemplate serviceTemplate =\r
                 toscaServiceTemplateService.fetchPolicies(null, null, null, null, mode);\r
@@ -391,17 +372,16 @@ public class ApiRestController extends CommonRestController implements PolicyDes
     /**\r
      * Retrieves the specified version of a particular policy.\r
      *\r
-     * @param policyId the Name of specified policy\r
+     * @param policyId      the Name of specified policy\r
      * @param policyVersion the version of specified policy\r
-     *\r
      * @return the Response object containing the results of the API operation\r
      */\r
     @Override\r
     public ResponseEntity<ToscaServiceTemplate> getSpecificPolicy(\r
-            String policyId,\r
-            String policyVersion,\r
-            PolicyFetchMode mode,\r
-            UUID requestId) {\r
+        String policyId,\r
+        String policyVersion,\r
+        PolicyFetchMode mode,\r
+        UUID requestId) {\r
         try {\r
             ToscaServiceTemplate serviceTemplate =\r
                 toscaServiceTemplateService.fetchPolicies(null, null, policyId, policyVersion, mode);\r
@@ -416,7 +396,6 @@ public class ApiRestController extends CommonRestController implements PolicyDes
      * Creates one or more new policies in one call.\r
      *\r
      * @param body the body of policy following TOSCA definition\r
-     *\r
      * @return the Response object containing the results of the API operation\r
      */\r
     @Override\r
@@ -438,9 +417,8 @@ public class ApiRestController extends CommonRestController implements PolicyDes
     /**\r
      * Deletes the specified version of a particular policy.\r
      *\r
-     * @param policyId the ID of specified policy\r
+     * @param policyId      the ID of specified policy\r
      * @param policyVersion the version of specified policy\r
-     *\r
      * @return the Response object containing the results of the API operation\r
      */\r
     @Override\r