Add BARE and REFERENCED mode to policy fetches 84/104684/3
authorliamfallon <liam.fallon@est.tech>
Mon, 30 Mar 2020 12:28:20 +0000 (13:28 +0100)
committerliamfallon <liam.fallon@est.tech>
Mon, 30 Mar 2020 18:27:05 +0000 (19:27 +0100)
In BARE mode (default), just the policy definitions are returned, in
REFERENCED mode, the policy and all referenced policy and data types are
returned.

Issue-ID: POLICY-2377
Change-Id: Idc227d512d56945cc14dec0eae9264dbb3ca52a0
Signed-off-by: liamfallon <liam.fallon@est.tech>
main/src/main/java/org/onap/policy/api/main/rest/ApiRestController.java
main/src/main/java/org/onap/policy/api/main/rest/PolicyFetchMode.java [new file with mode: 0644]
main/src/main/java/org/onap/policy/api/main/rest/provider/PolicyProvider.java
main/src/test/java/org/onap/policy/api/main/rest/TestApiRestServer.java
main/src/test/java/org/onap/policy/api/main/rest/provider/TestPolicyProvider.java

index 60ccba0..7661c27 100644 (file)
@@ -4,6 +4,7 @@
  * ================================================================================\r
  * Copyright (C) 2018 Samsung Electronics Co., Ltd. All rights reserved.\r
  * Copyright (C) 2019-2020 AT&T Intellectual Property. All rights reserved.\r
+ * Modifications Copyright (C) 2020 Nordix Foundation.\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
@@ -36,16 +37,21 @@ import io.swagger.annotations.Info;
 import io.swagger.annotations.ResponseHeader;\r
 import io.swagger.annotations.SecurityDefinition;\r
 import io.swagger.annotations.SwaggerDefinition;\r
+\r
 import java.util.UUID;\r
+\r
 import javax.ws.rs.Consumes;\r
 import javax.ws.rs.DELETE;\r
+import javax.ws.rs.DefaultValue;\r
 import javax.ws.rs.GET;\r
 import javax.ws.rs.HeaderParam;\r
 import javax.ws.rs.POST;\r
 import javax.ws.rs.Path;\r
 import javax.ws.rs.PathParam;\r
 import javax.ws.rs.Produces;\r
+import javax.ws.rs.QueryParam;\r
 import javax.ws.rs.core.Response;\r
+\r
 import org.onap.policy.api.main.rest.provider.HealthCheckProvider;\r
 import org.onap.policy.api.main.rest.provider.PolicyProvider;\r
 import org.onap.policy.api.main.rest.provider.PolicyTypeProvider;\r
@@ -69,19 +75,20 @@ import org.slf4j.LoggerFactory;
 @Api(value = "Policy Design API")\r
 @Produces({"application/json", "application/yaml"})\r
 @Consumes({"application/json", "application/yaml"})\r
-@SwaggerDefinition(info = @Info(\r
+@SwaggerDefinition(\r
+    info = @Info(\r
         description = "Policy Design API is publicly exposed for clients to Create/Read/Update/Delete"\r
-                + " policy types, policy type implementation and policies which can be recognized"\r
-                + " and executable by incorporated policy engines. It is an"\r
-                + " independent component running rest service that takes all policy design API calls"\r
-                + " from clients and then assign them to different API working functions. Besides"\r
-                + " that, API is also exposed for clients to retrieve healthcheck status of this API"\r
-                + " rest service and the statistics report including the counters of API invocation.",\r
+            + " policy types, policy type implementation and policies which can be recognized"\r
+            + " and executable by incorporated policy engines. It is an"\r
+            + " independent component running rest service that takes all policy design API calls"\r
+            + " from clients and then assign them to different API working functions. Besides"\r
+            + " that, API is also exposed for clients to retrieve healthcheck status of this API"\r
+            + " rest service and the statistics report including the counters of API invocation.",\r
         version = "1.0.0", title = "Policy Design",\r
         extensions = {@Extension(properties = {@ExtensionProperty(name = "planned-retirement-date", value = "tbd"),\r
             @ExtensionProperty(name = "component", value = "Policy Framework")})}),\r
-        schemes = {SwaggerDefinition.Scheme.HTTP, SwaggerDefinition.Scheme.HTTPS},\r
-        securityDefinition = @SecurityDefinition(basicAuthDefinitions = {@BasicAuthDefinition(key = "basicAuth")}))\r
+    schemes = {SwaggerDefinition.Scheme.HTTP, SwaggerDefinition.Scheme.HTTPS},\r
+    securityDefinition = @SecurityDefinition(basicAuthDefinitions = {@BasicAuthDefinition(key = "basicAuth")}))\r
 public class ApiRestController extends CommonRestController {\r
 \r
     private static final Logger LOGGER = LoggerFactory.getLogger(ApiRestController.class);\r
@@ -94,30 +101,29 @@ public class ApiRestController extends CommonRestController {
     @GET\r
     @Path("/healthcheck")\r
     @ApiOperation(value = "Perform a system healthcheck", notes = "Returns healthy status of the Policy API component",\r
-            response = HealthCheckReport.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
-            authorizations = @Authorization(value = "basicAuth"), tags = {"HealthCheck",},\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
+        response = HealthCheckReport.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" + " the client on request",\r
+                response = String.class),\r
+            @ResponseHeader(name = "X-LatestVersion", 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", response = UUID.class)},\r
+        authorizations = @Authorization(value = "basicAuth"), tags = {"HealthCheck",},\r
+        extensions = {\r
+            @Extension(name = "interface info", properties = {@ExtensionProperty(name = "api-version", value = "1.0.0"),\r
+                @ExtensionProperty(name = "last-mod-release", value = "Dublin")})})\r
     @ApiResponses(value = {@ApiResponse(code = 401, message = "Authentication Error"),\r
         @ApiResponse(code = 403, message = "Authorization Error"),\r
         @ApiResponse(code = 500, message = "Internal Server Error")})\r
-    public Response getHealthCheck(\r
-            @HeaderParam("X-ONAP-RequestID") @ApiParam("RequestID for http transaction") UUID requestId) {\r
+    public Response\r
+        getHealthCheck(@HeaderParam("X-ONAP-RequestID") @ApiParam("RequestID for http transaction") UUID requestId) {\r
 \r
         updateApiStatisticsCounter(Target.OTHER, Result.SUCCESS, HttpMethod.GET);\r
         return makeOkResponse(requestId, new HealthCheckProvider().performHealthCheck());\r
@@ -131,31 +137,30 @@ public class ApiRestController extends CommonRestController {
     @GET\r
     @Path("/statistics")\r
     @ApiOperation(value = "Retrieve current statistics",\r
-            notes = "Returns current statistics including the counters of API invocation",\r
-            response = StatisticsReport.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
-            authorizations = @Authorization(value = "basicAuth"), tags = {"Statistics",},\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
+        notes = "Returns current statistics including the counters of API invocation",\r
+        response = StatisticsReport.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" + " the client on request",\r
+                response = String.class),\r
+            @ResponseHeader(name = "X-LatestVersion", 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", response = UUID.class)},\r
+        authorizations = @Authorization(value = "basicAuth"), tags = {"Statistics",},\r
+        extensions = {\r
+            @Extension(name = "interface info", properties = {@ExtensionProperty(name = "api-version", value = "1.0.0"),\r
+                @ExtensionProperty(name = "last-mod-release", value = "Dublin")})})\r
     @ApiResponses(value = {@ApiResponse(code = 401, message = "Authentication Error"),\r
         @ApiResponse(code = 403, message = "Authorization Error"),\r
         @ApiResponse(code = 500, message = "Internal Server Error")})\r
     public Response\r
-            getStatistics(@HeaderParam("X-ONAP-RequestID") @ApiParam("RequestID for http transaction") UUID requestId) {\r
+        getStatistics(@HeaderParam("X-ONAP-RequestID") @ApiParam("RequestID for http transaction") UUID requestId) {\r
 \r
         updateApiStatisticsCounter(Target.OTHER, Result.SUCCESS, HttpMethod.GET);\r
 \r
@@ -170,31 +175,30 @@ public class ApiRestController extends CommonRestController {
     @GET\r
     @Path("/policytypes")\r
     @ApiOperation(value = "Retrieve existing policy types",\r
-            notes = "Returns a list of existing policy types stored in Policy Framework",\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
-            authorizations = @Authorization(value = "basicAuth"), tags = {"PolicyType",},\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
+        notes = "Returns a list of existing policy types stored in Policy Framework",\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" + " the client on request",\r
+                response = String.class),\r
+            @ResponseHeader(name = "X-LatestVersion", 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", response = UUID.class)},\r
+        authorizations = @Authorization(value = "basicAuth"), tags = {"PolicyType",},\r
+        extensions = {\r
+            @Extension(name = "interface info", properties = {@ExtensionProperty(name = "api-version", value = "1.0.0"),\r
+                @ExtensionProperty(name = "last-mod-release", value = "Dublin")})})\r
     @ApiResponses(value = {@ApiResponse(code = 401, message = "Authentication Error"),\r
         @ApiResponse(code = 403, message = "Authorization Error"),\r
         @ApiResponse(code = 500, message = "Internal Server Error")})\r
-    public Response getAllPolicyTypes(\r
-            @HeaderParam("X-ONAP-RequestID") @ApiParam("RequestID for http transaction") UUID requestId) {\r
+    public Response\r
+        getAllPolicyTypes(@HeaderParam("X-ONAP-RequestID") @ApiParam("RequestID for http transaction") UUID requestId) {\r
 \r
         try (PolicyTypeProvider policyTypeProvider = new PolicyTypeProvider()) {\r
             ToscaServiceTemplate serviceTemplate = policyTypeProvider.fetchPolicyTypes(null, null);\r
@@ -217,33 +221,32 @@ public class ApiRestController extends CommonRestController {
     @GET\r
     @Path("/policytypes/{policyTypeId}")\r
     @ApiOperation(value = "Retrieve all available versions of a policy type",\r
-            notes = "Returns a list of all available versions for the specified policy type",\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
-            authorizations = @Authorization(value = "basicAuth"), tags = {"PolicyType",},\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
+        notes = "Returns a list of all available versions for the specified policy type",\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" + " the client on request",\r
+                response = String.class),\r
+            @ResponseHeader(name = "X-LatestVersion", 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", response = UUID.class)},\r
+        authorizations = @Authorization(value = "basicAuth"), tags = {"PolicyType",},\r
+        extensions = {\r
+            @Extension(name = "interface info", properties = {@ExtensionProperty(name = "api-version", value = "1.0.0"),\r
+                @ExtensionProperty(name = "last-mod-release", value = "Dublin")})})\r
     @ApiResponses(value = {@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
     public Response getAllVersionsOfPolicyType(\r
-            @PathParam("policyTypeId") @ApiParam(value = "ID of policy type", required = true) String policyTypeId,\r
-            @HeaderParam("X-ONAP-RequestID") @ApiParam("RequestID for http transaction") UUID requestId) {\r
+        @PathParam("policyTypeId") @ApiParam(value = "ID of policy type", required = true) String policyTypeId,\r
+        @HeaderParam("X-ONAP-RequestID") @ApiParam("RequestID for http transaction") UUID requestId) {\r
 \r
         try (PolicyTypeProvider policyTypeProvider = new PolicyTypeProvider()) {\r
             ToscaServiceTemplate serviceTemplate = policyTypeProvider.fetchPolicyTypes(policyTypeId, null);\r
@@ -267,33 +270,32 @@ public class ApiRestController extends CommonRestController {
     @GET\r
     @Path("/policytypes/{policyTypeId}/versions/{versionId}")\r
     @ApiOperation(value = "Retrieve one particular version of a policy type",\r
-            notes = "Returns a particular version for the specified policy type", 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
-            authorizations = @Authorization(value = "basicAuth"), tags = {"PolicyType",},\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
+        notes = "Returns a particular version for the specified policy type", 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" + " the client on request",\r
+                response = String.class),\r
+            @ResponseHeader(name = "X-LatestVersion", 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", response = UUID.class)},\r
+        authorizations = @Authorization(value = "basicAuth"), tags = {"PolicyType",},\r
+        extensions = {\r
+            @Extension(name = "interface info", properties = {@ExtensionProperty(name = "api-version", value = "1.0.0"),\r
+                @ExtensionProperty(name = "last-mod-release", value = "Dublin")})})\r
     @ApiResponses(value = {@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
     public Response getSpecificVersionOfPolicyType(\r
-            @PathParam("policyTypeId") @ApiParam(value = "ID of policy type", required = true) String policyTypeId,\r
-            @PathParam("versionId") @ApiParam(value = "Version of policy type", required = true) String versionId,\r
-            @HeaderParam("X-ONAP-RequestID") @ApiParam("RequestID for http transaction") UUID requestId) {\r
+        @PathParam("policyTypeId") @ApiParam(value = "ID of policy type", required = true) String policyTypeId,\r
+        @PathParam("versionId") @ApiParam(value = "Version of policy type", required = true) String versionId,\r
+        @HeaderParam("X-ONAP-RequestID") @ApiParam("RequestID for http transaction") UUID requestId) {\r
 \r
         try (PolicyTypeProvider policyTypeProvider = new PolicyTypeProvider()) {\r
             ToscaServiceTemplate serviceTemplate = policyTypeProvider.fetchPolicyTypes(policyTypeId, versionId);\r
@@ -316,32 +318,31 @@ public class ApiRestController extends CommonRestController {
     @GET\r
     @Path("/policytypes/{policyTypeId}/versions/latest")\r
     @ApiOperation(value = "Retrieve latest version of a policy type",\r
-            notes = "Returns latest version for the specified policy type", 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
-            authorizations = @Authorization(value = "basicAuth"), tags = {"PolicyType",},\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
+        notes = "Returns latest version for the specified policy type", 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" + " the client on request",\r
+                response = String.class),\r
+            @ResponseHeader(name = "X-LatestVersion", 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", response = UUID.class)},\r
+        authorizations = @Authorization(value = "basicAuth"), tags = {"PolicyType",},\r
+        extensions = {\r
+            @Extension(name = "interface info", properties = {@ExtensionProperty(name = "api-version", value = "1.0.0"),\r
+                @ExtensionProperty(name = "last-mod-release", value = "Dublin")})})\r
     @ApiResponses(value = {@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
     public Response getLatestVersionOfPolicyType(\r
-            @PathParam("policyTypeId") @ApiParam(value = "ID of policy type", required = true) String policyTypeId,\r
-            @HeaderParam("X-ONAP-RequestID") @ApiParam("RequestID for http transaction") UUID requestId) {\r
+        @PathParam("policyTypeId") @ApiParam(value = "ID of policy type", required = true) String policyTypeId,\r
+        @HeaderParam("X-ONAP-RequestID") @ApiParam("RequestID for http transaction") UUID requestId) {\r
 \r
         try (PolicyTypeProvider policyTypeProvider = new PolicyTypeProvider()) {\r
             ToscaServiceTemplate serviceTemplate = policyTypeProvider.fetchLatestPolicyTypes(policyTypeId);\r
@@ -364,41 +365,32 @@ public class ApiRestController extends CommonRestController {
     @POST\r
     @Path("/policytypes")\r
     @ApiOperation(value = "Create a new policy type", notes = "Client should provide TOSCA body of the new policy type",\r
-            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",\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
+        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" + " the client on request",\r
+                response = String.class),\r
+            @ResponseHeader(name = "X-LatestVersion", 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", response = UUID.class)},\r
+        extensions = {\r
+            @Extension(name = "interface info", 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 = 406, message = "Not Acceptable Payload"),\r
+        @ApiResponse(code = 500, message = "Internal Server Error")})\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
+        @ApiParam(value = "Entity body of policy type", required = true) ToscaServiceTemplate body,\r
+        @HeaderParam("X-ONAP-RequestID") @ApiParam("RequestID for http transaction") UUID requestId) {\r
 \r
         if (NetLoggerUtil.getNetworkLogger().isInfoEnabled()) {\r
             NetLoggerUtil.log(EventType.IN, CommInfrastructure.REST, "/policytypes", toJson(body));\r
@@ -426,37 +418,36 @@ public class ApiRestController extends CommonRestController {
     @DELETE\r
     @Path("/policytypes/{policyTypeId}/versions/{versionId}")\r
     @ApiOperation(value = "Delete one version of a policy type",\r
-            notes = "Rule 1: pre-defined policy types cannot be deleted;"\r
-                    + "Rule 2: policy types that are in use (parameterized by a TOSCA policy) cannot be deleted."\r
-                    + "The parameterizing TOSCA policies must be deleted first;",\r
-            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
+        notes = "Rule 1: pre-defined policy types cannot be deleted;"\r
+            + "Rule 2: policy types that are in use (parameterized by a TOSCA policy) cannot be deleted."\r
+            + "The parameterizing TOSCA policies must be deleted first;",\r
+        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" + " the client on request",\r
+                response = String.class),\r
+            @ResponseHeader(name = "X-LatestVersion", 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", response = UUID.class)},\r
+        extensions = {\r
+            @Extension(name = "interface info", properties = {@ExtensionProperty(name = "api-version", value = "1.0.0"),\r
+                @ExtensionProperty(name = "last-mod-release", value = "Dublin")})})\r
     @ApiResponses(value = {@ApiResponse(code = 401, message = "Authentication Error"),\r
         @ApiResponse(code = 403, message = "Authorization Error"),\r
         @ApiResponse(code = 404, message = "Resource Not Found"),\r
         @ApiResponse(code = 409, message = "Delete Conflict, Rule Violation"),\r
         @ApiResponse(code = 500, message = "Internal Server Error")})\r
     public Response deleteSpecificVersionOfPolicyType(\r
-            @PathParam("policyTypeId") @ApiParam(value = "ID of policy type", required = true) String policyTypeId,\r
-            @PathParam("versionId") @ApiParam(value = "Version of policy type", required = true) String versionId,\r
-            @HeaderParam("X-ONAP-RequestID") @ApiParam("RequestID for http transaction") UUID requestId) {\r
+        @PathParam("policyTypeId") @ApiParam(value = "ID of policy type", required = true) String policyTypeId,\r
+        @PathParam("versionId") @ApiParam(value = "Version of policy type", required = true) String versionId,\r
+        @HeaderParam("X-ONAP-RequestID") @ApiParam("RequestID for http transaction") UUID requestId) {\r
 \r
         try (PolicyTypeProvider policyTypeProvider = new PolicyTypeProvider()) {\r
             ToscaServiceTemplate serviceTemplate = policyTypeProvider.deletePolicyType(policyTypeId, versionId);\r
@@ -475,42 +466,52 @@ public class ApiRestController extends CommonRestController {
      *\r
      * @return the Response object containing the results of the API operation\r
      */\r
+    // @formatter:off\r
     @GET\r
     @Path("/policytypes/{policyTypeId}/versions/{policyTypeVersion}/policies")\r
-    @ApiOperation(value = "Retrieve all versions of a policy created for a particular policy type version",\r
-            notes = "Returns a list of all versions of specified policy created for the specified policy type version",\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
-            authorizations = @Authorization(value = "basicAuth"), tags = {"Policy",},\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 = 401, message = "Authentication Error"),\r
+    @ApiOperation(\r
+        value = "Retrieve all versions of a policy created for a particular policy type version",\r
+        notes = "Returns a list of all versions of specified policy created for the specified policy type version",\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" + " the client on request",\r
+                response = String.class),\r
+            @ResponseHeader(name = "X-LatestVersion", 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", response = UUID.class)},\r
+        authorizations = @Authorization(value = "basicAuth"), tags = {"Policy,"},\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
+    )\r
+    @ApiResponses(value = {\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
+        @ApiResponse(code = 500, message = "Internal Server Error")\r
+    })\r
     public Response getAllPolicies(\r
-            @PathParam("policyTypeId") @ApiParam(value = "ID of policy type", required = true) String policyTypeId,\r
-            @PathParam("policyTypeVersion") @ApiParam(value = "Version of policy type",\r
-                    required = true) String policyTypeVersion,\r
-            @HeaderParam("X-ONAP-RequestID") @ApiParam("RequestID for http transaction") UUID requestId) {\r
+        @PathParam("policyTypeId") @ApiParam(value = "ID of policy type", required = true) String policyTypeId,\r
+        @PathParam("policyTypeVersion") @ApiParam(value = "Version of policy type",\r
+            required = true) String policyTypeVersion,\r
+        @HeaderParam("X-ONAP-RequestID") @ApiParam("RequestID for http transaction") UUID requestId,\r
+        @QueryParam("mode") @DefaultValue("bare") @ApiParam("Fetch mode for policies, BARE for bare policies (default),"\r
+            + " REFERENCED for fully referenced policies") PolicyFetchMode mode\r
+    ) {\r
 \r
         try (PolicyProvider policyProvider = new PolicyProvider()) {\r
             ToscaServiceTemplate serviceTemplate =\r
-                    policyProvider.fetchPolicies(policyTypeId, policyTypeVersion, null, null);\r
+                policyProvider.fetchPolicies(policyTypeId, policyTypeVersion, null, null, mode);\r
             updateApiStatisticsCounter(Target.POLICY, Result.SUCCESS, HttpMethod.GET);\r
             return makeOkResponse(requestId, serviceTemplate);\r
         } catch (PfModelException | PfModelRuntimeException pfme) {\r
@@ -519,6 +520,7 @@ public class ApiRestController extends CommonRestController {
             return makeErrorResponse(requestId, pfme);\r
         }\r
     }\r
+    // @formatter:on\r
 \r
     /**\r
      * Retrieves all versions of a particular policy.\r
@@ -529,43 +531,50 @@ public class ApiRestController extends CommonRestController {
      *\r
      * @return the Response object containing the results of the API operation\r
      */\r
+    // @formatter:off\r
     @GET\r
     @Path("/policytypes/{policyTypeId}/versions/{policyTypeVersion}/policies/{policyId}")\r
     @ApiOperation(value = "Retrieve all version details of a policy created for a particular policy type version",\r
-            notes = "Returns a list of all version details of the specified 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
-            authorizations = @Authorization(value = "basicAuth"), tags = {"Policy",},\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 = 401, message = "Authentication Error"),\r
+        notes = "Returns a list of all version details of the specified policy", 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" + " the client on request",\r
+                response = String.class),\r
+            @ResponseHeader(name = "X-LatestVersion", 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", response = UUID.class)},\r
+        authorizations = @Authorization(value = "basicAuth"), tags = {"Policy",},\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
+    )\r
+    @ApiResponses(value = {\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
+        @ApiResponse(code = 500, message = "Internal Server Error")\r
+    })\r
     public Response getAllVersionsOfPolicy(\r
-            @PathParam("policyTypeId") @ApiParam(value = "ID of policy type", required = true) String policyTypeId,\r
-            @PathParam("policyTypeVersion") @ApiParam(value = "Version of policy type",\r
-                    required = true) String policyTypeVersion,\r
-            @PathParam("policyId") @ApiParam(value = "ID of policy", required = true) String policyId,\r
-            @HeaderParam("X-ONAP-RequestID") @ApiParam("RequestID for http transaction") UUID requestId) {\r
-\r
+        @PathParam("policyTypeId") @ApiParam(value = "ID of policy type", required = true) String policyTypeId,\r
+        @PathParam("policyTypeVersion") @ApiParam(value = "Version of policy type",\r
+            required = true) String policyTypeVersion,\r
+        @PathParam("policyId") @ApiParam(value = "ID of policy", required = true) String policyId,\r
+        @HeaderParam("X-ONAP-RequestID") @ApiParam("RequestID for http transaction") UUID requestId,\r
+        @QueryParam("mode") @DefaultValue("bare") @ApiParam("Fetch mode for policies, BARE for bare policies (default),"\r
+            + " REFERENCED for fully referenced policies") PolicyFetchMode mode\r
+    ) {\r
         try (PolicyProvider policyProvider = new PolicyProvider()) {\r
             ToscaServiceTemplate serviceTemplate =\r
-                    policyProvider.fetchPolicies(policyTypeId, policyTypeVersion, policyId, null);\r
+                policyProvider.fetchPolicies(policyTypeId, policyTypeVersion, policyId, null, mode);\r
             updateApiStatisticsCounter(Target.POLICY, Result.SUCCESS, HttpMethod.GET);\r
             return makeOkResponse(requestId, serviceTemplate);\r
         } catch (PfModelException | PfModelRuntimeException pfme) {\r
@@ -574,6 +583,7 @@ public class ApiRestController extends CommonRestController {
             return makeErrorResponse(requestId, pfme);\r
         }\r
     }\r
+    // @formatter:on\r
 \r
     /**\r
      * Retrieves the specified version of a particular policy.\r
@@ -585,53 +595,62 @@ public class ApiRestController extends CommonRestController {
      *\r
      * @return the Response object containing the results of the API operation\r
      */\r
+    // @formatter:off\r
     @GET\r
     @Path("/policytypes/{policyTypeId}/versions/{policyTypeVersion}/policies/{policyId}/versions/{policyVersion}")\r
     @ApiOperation(value = "Retrieve one version of a policy created for a particular policy type version",\r
-            notes = "Returns a particular version of specified policy created for the specified policy type version",\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
-            authorizations = @Authorization(value = "basicAuth"), tags = {"Policy",},\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 = 401, message = "Authentication Error"),\r
+        notes = "Returns a particular version of specified policy created for the specified policy type version",\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" + " the client on request",\r
+                response = String.class),\r
+            @ResponseHeader(name = "X-LatestVersion", 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", response = UUID.class)},\r
+        authorizations = @Authorization(value = "basicAuth"), tags = {"Policy",},\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
+    )\r
+    @ApiResponses(value = {\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
+        @ApiResponse(code = 500, message = "Internal Server Error")\r
+    })\r
     public Response getSpecificVersionOfPolicy(\r
-            @PathParam("policyTypeId") @ApiParam(value = "ID of policy type", required = true) String policyTypeId,\r
-            @PathParam("policyTypeVersion") @ApiParam(value = "Version of policy type",\r
-                    required = true) String policyTypeVersion,\r
-            @PathParam("policyId") @ApiParam(value = "ID of policy", required = true) String policyId,\r
-            @PathParam("policyVersion") @ApiParam(value = "Version of policy", required = true) String policyVersion,\r
-            @HeaderParam("X-ONAP-RequestID") @ApiParam("RequestID for http transaction") UUID requestId) {\r
-\r
+        @PathParam("policyTypeId") @ApiParam(value = "ID of policy type", required = true) String policyTypeId,\r
+        @PathParam("policyTypeVersion") @ApiParam(value = "Version of policy type",\r
+            required = true) String policyTypeVersion,\r
+        @PathParam("policyId") @ApiParam(value = "ID of policy", required = true) String policyId,\r
+        @PathParam("policyVersion") @ApiParam(value = "Version of policy", required = true) String policyVersion,\r
+        @HeaderParam("X-ONAP-RequestID") @ApiParam("RequestID for http transaction") UUID requestId,\r
+        @QueryParam("mode") @DefaultValue("bare") @ApiParam("Fetch mode for policies, BARE for bare policies (default),"\r
+            + " REFERENCED for fully referenced policies") PolicyFetchMode mode\r
+    ) {\r
         try (PolicyProvider policyProvider = new PolicyProvider()) {\r
             ToscaServiceTemplate serviceTemplate =\r
-                    policyProvider.fetchPolicies(policyTypeId, policyTypeVersion, policyId, policyVersion);\r
+                policyProvider.fetchPolicies(policyTypeId, policyTypeVersion, policyId, policyVersion, mode);\r
             updateApiStatisticsCounter(Target.POLICY, Result.SUCCESS, HttpMethod.GET);\r
             return makeOkResponse(requestId, serviceTemplate);\r
         } catch (PfModelException | PfModelRuntimeException pfme) {\r
             LOGGER.debug("GET /policytypes/{}/versions/{}/policies/{}/versions/{}", policyTypeId, policyTypeVersion,\r
-                    policyId, policyVersion, pfme);\r
+                policyId, policyVersion, pfme);\r
             updateApiStatisticsCounter(Target.POLICY, Result.FAILURE, HttpMethod.GET);\r
             return makeErrorResponse(requestId, pfme);\r
         }\r
     }\r
+    // @formatter:on\r
 \r
     /**\r
      * Retrieves the latest version of a particular policy.\r
@@ -645,44 +664,45 @@ public class ApiRestController extends CommonRestController {
     @GET\r
     @Path("/policytypes/{policyTypeId}/versions/{policyTypeVersion}/policies/{policyId}/versions/latest")\r
     @ApiOperation(value = "Retrieve the latest version of a particular policy",\r
-            notes = "Returns the latest version of specified policy", 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
-            authorizations = @Authorization(value = "basicAuth"), tags = {"Policy",},\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
+        notes = "Returns the latest version of specified policy", 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" + " the client on request",\r
+                response = String.class),\r
+            @ResponseHeader(name = "X-LatestVersion", 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", response = UUID.class)},\r
+        authorizations = @Authorization(value = "basicAuth"), tags = {"Policy",},\r
+        extensions = {\r
+            @Extension(name = "interface info", properties = {@ExtensionProperty(name = "api-version", value = "1.0.0"),\r
+                @ExtensionProperty(name = "last-mod-release", value = "Dublin")})})\r
     @ApiResponses(value = {@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
     public Response getLatestVersionOfPolicy(\r
-            @PathParam("policyTypeId") @ApiParam(value = "ID of policy type", required = true) String policyTypeId,\r
-            @PathParam("policyTypeVersion") @ApiParam(value = "Version of policy type",\r
-                    required = true) String policyTypeVersion,\r
-            @PathParam("policyId") @ApiParam(value = "ID of policy", required = true) String policyId,\r
-            @HeaderParam("X-ONAP-RequestID") @ApiParam("RequestID for http transaction") UUID requestId) {\r
+        @PathParam("policyTypeId") @ApiParam(value = "ID of policy type", required = true) String policyTypeId,\r
+        @PathParam("policyTypeVersion") @ApiParam(value = "Version of policy type",\r
+            required = true) String policyTypeVersion,\r
+        @PathParam("policyId") @ApiParam(value = "ID of policy", required = true) String policyId,\r
+        @HeaderParam("X-ONAP-RequestID") @ApiParam("RequestID for http transaction") UUID requestId,\r
+        @QueryParam("mode") @ApiParam("Fetch mode for policies, TERSE for bare policies (default), "\r
+            + "REFERENCED for fully referenced policies") PolicyFetchMode mode) {\r
 \r
         try (PolicyProvider policyProvider = new PolicyProvider()) {\r
             ToscaServiceTemplate serviceTemplate =\r
-                    policyProvider.fetchLatestPolicies(policyTypeId, policyTypeVersion, policyId);\r
+                policyProvider.fetchLatestPolicies(policyTypeId, policyTypeVersion, policyId, mode);\r
             updateApiStatisticsCounter(Target.POLICY, Result.SUCCESS, HttpMethod.GET);\r
             return makeOkResponse(requestId, serviceTemplate);\r
         } catch (PfModelException | PfModelRuntimeException pfme) {\r
             LOGGER.debug("GET /policytypes/{}/versions/{}/policies/{}/versions/latest", policyTypeId, policyTypeVersion,\r
-                    policyId, pfme);\r
+                policyId, pfme);\r
             updateApiStatisticsCounter(Target.POLICY, Result.FAILURE, HttpMethod.GET);\r
             return makeErrorResponse(requestId, pfme);\r
         }\r
@@ -700,50 +720,40 @@ public class ApiRestController extends CommonRestController {
     @POST\r
     @Path("/policytypes/{policyTypeId}/versions/{policyTypeVersion}/policies")\r
     @ApiOperation(value = "Create a new policy for a policy type version",\r
-            notes = "Client should provide TOSCA body of the new policy",\r
-            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",\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
+        notes = "Client should provide TOSCA body of the new policy",\r
+        authorizations = @Authorization(value = "basicAuth"), tags = {"Policy",}, 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" + " the client on request",\r
+                response = String.class),\r
+            @ResponseHeader(name = "X-LatestVersion", 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", response = UUID.class)},\r
+        extensions = {\r
+            @Extension(name = "interface info", 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 = 406, message = "Not Acceptable Payload"),\r
+        @ApiResponse(code = 500, message = "Internal Server Error")})\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
-                    required = true) String policyTypeVersion,\r
-            @HeaderParam("X-ONAP-RequestID") @ApiParam("RequestID for http transaction") UUID requestId,\r
-            @ApiParam(value = "Entity body of policy", required = true) ToscaServiceTemplate body) {\r
+        @PathParam("policyTypeId") @ApiParam(value = "ID of policy type", required = true) String policyTypeId,\r
+        @PathParam("policyTypeVersion") @ApiParam(value = "Version of policy type",\r
+            required = true) String policyTypeVersion,\r
+        @HeaderParam("X-ONAP-RequestID") @ApiParam("RequestID for http transaction") UUID requestId,\r
+        @ApiParam(value = "Entity body of policy", required = true) ToscaServiceTemplate body) {\r
 \r
         if (NetLoggerUtil.getNetworkLogger().isInfoEnabled()) {\r
             NetLoggerUtil.log(EventType.IN, CommInfrastructure.REST,\r
-                    "/policytypes/" + policyTypeId + "/versions/" + policyTypeVersion + "/policies", toJson(body));\r
+                "/policytypes/" + policyTypeId + "/versions/" + policyTypeVersion + "/policies", toJson(body));\r
         }\r
 \r
         try (PolicyProvider policyProvider = new PolicyProvider()) {\r
@@ -767,43 +777,33 @@ public class ApiRestController extends CommonRestController {
     @POST\r
     @Path("/policies")\r
     @ApiOperation(value = "Create one or more new policies",\r
-            notes = "Client should provide TOSCA body of the new polic(ies)",\r
-            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",\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
+        notes = "Client should provide TOSCA body of the new polic(ies)",\r
+        authorizations = @Authorization(value = "basicAuth"), tags = {"Policy",}, 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" + " the client on request",\r
+                response = String.class),\r
+            @ResponseHeader(name = "X-LatestVersion", 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", response = UUID.class)},\r
+        extensions = {\r
+            @Extension(name = "interface info", 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 = 406, message = "Not Acceptable Payload"),\r
+        @ApiResponse(code = 500, message = "Internal Server Error")})\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
+        @HeaderParam("X-ONAP-RequestID") @ApiParam("RequestID for http transaction") UUID requestId,\r
+        @ApiParam(value = "Entity body of policy", required = true) ToscaServiceTemplate body) {\r
 \r
         if (NetLoggerUtil.getNetworkLogger().isInfoEnabled()) {\r
             NetLoggerUtil.log(EventType.IN, CommInfrastructure.REST, "/policies", toJson(body));\r
@@ -833,46 +833,44 @@ public class ApiRestController extends CommonRestController {
     @DELETE\r
     @Path("/policytypes/{policyTypeId}/versions/{policyTypeVersion}/policies/{policyId}/versions/{policyVersion}")\r
     @ApiOperation(value = "Delete a particular version of a policy",\r
-            notes = "Rule: the version that has been deployed in PDP group(s) cannot be deleted",\r
-            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
+        notes = "Rule: the version that has been deployed in PDP group(s) cannot be deleted",\r
+        authorizations = @Authorization(value = "basicAuth"), tags = {"Policy",}, 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" + " the client on request",\r
+                response = String.class),\r
+            @ResponseHeader(name = "X-LatestVersion", 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", response = UUID.class)},\r
+        extensions = {\r
+            @Extension(name = "interface info", properties = {@ExtensionProperty(name = "api-version", value = "1.0.0"),\r
+                @ExtensionProperty(name = "last-mod-release", value = "Dublin")})})\r
     @ApiResponses(value = {@ApiResponse(code = 401, message = "Authentication Error"),\r
         @ApiResponse(code = 403, message = "Authorization Error"),\r
         @ApiResponse(code = 404, message = "Resource Not Found"),\r
         @ApiResponse(code = 409, message = "Delete Conflict, Rule Violation"),\r
         @ApiResponse(code = 500, message = "Internal Server Error")})\r
     public Response deleteSpecificVersionOfPolicy(\r
-            @PathParam("policyTypeId") @ApiParam(value = "PolicyType ID", required = true) String policyTypeId,\r
-            @PathParam("policyTypeVersion") @ApiParam(value = "Version of policy type",\r
-                    required = true) String policyTypeVersion,\r
-            @PathParam("policyId") @ApiParam(value = "ID of policy", required = true) String policyId,\r
-            @PathParam("policyVersion") @ApiParam(value = "Version of policy", required = true) String policyVersion,\r
-            @HeaderParam("X-ONAP-RequestID") @ApiParam("RequestID for http transaction") UUID requestId) {\r
+        @PathParam("policyTypeId") @ApiParam(value = "PolicyType ID", required = true) String policyTypeId,\r
+        @PathParam("policyTypeVersion") @ApiParam(value = "Version of policy type",\r
+            required = true) String policyTypeVersion,\r
+        @PathParam("policyId") @ApiParam(value = "ID of policy", required = true) String policyId,\r
+        @PathParam("policyVersion") @ApiParam(value = "Version of policy", required = true) String policyVersion,\r
+        @HeaderParam("X-ONAP-RequestID") @ApiParam("RequestID for http transaction") UUID requestId) {\r
 \r
         try (PolicyProvider policyProvider = new PolicyProvider()) {\r
             ToscaServiceTemplate serviceTemplate =\r
-                    policyProvider.deletePolicy(policyTypeId, policyTypeVersion, policyId, policyVersion);\r
+                policyProvider.deletePolicy(policyTypeId, policyTypeVersion, policyId, policyVersion);\r
             return makeOkResponse(requestId, serviceTemplate);\r
         } catch (PfModelException | PfModelRuntimeException pfme) {\r
             LOGGER.debug("DELETE /policytypes/{}/versions/{}/policies/{}/versions/{}", policyTypeId, policyTypeVersion,\r
-                    policyId, policyVersion, pfme);\r
+                policyId, policyVersion, pfme);\r
             return makeErrorResponse(requestId, pfme);\r
         }\r
     }\r
diff --git a/main/src/main/java/org/onap/policy/api/main/rest/PolicyFetchMode.java b/main/src/main/java/org/onap/policy/api/main/rest/PolicyFetchMode.java
new file mode 100644 (file)
index 0000000..99678b8
--- /dev/null
@@ -0,0 +1,37 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * Copyright (C) 2020 Nordix Foundation.
+ * ================================================================================
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ * SPDX-License-Identifier: Apache-2.0
+ * ============LICENSE_END=========================================================
+ */
+
+package org.onap.policy.api.main.rest;
+
+public enum PolicyFetchMode {
+    BARE,
+    REFERENCED;
+
+    /**
+     * Convert a string to this ENUM.
+     *
+     * @param modeString the incoming string value
+     * @return the enum value of the string
+     */
+    public static PolicyFetchMode fromString(final String modeString) {
+        String modeStringUpper = modeString.toUpperCase();
+        return valueOf(modeStringUpper);
+    }
+}
index 35d0e80..4ba3322 100644 (file)
@@ -23,6 +23,7 @@
 \r
 package org.onap.policy.api.main.rest.provider;\r
 \r
+import org.onap.policy.api.main.rest.PolicyFetchMode;\r
 import org.onap.policy.models.base.PfModelException;\r
 import org.onap.policy.models.tosca.authorative.concepts.ToscaPolicyFilter;\r
 import org.onap.policy.models.tosca.authorative.concepts.ToscaServiceTemplate;\r
@@ -48,15 +49,16 @@ public class PolicyProvider extends CommonModelProvider {
      * @param policyTypeVersion the version of policy type\r
      * @param policyId the ID of policy\r
      * @param policyVersion the version of policy\r
+     * @param mode the fetch mode for policies\r
      *\r
      * @return the ToscaServiceTemplate object\r
      *\r
      * @throws PfModelException the PfModel parsing exception\r
      */\r
-    public ToscaServiceTemplate fetchPolicies(String policyTypeId, String policyTypeVersion, String policyId,\r
-            String policyVersion) throws PfModelException {\r
+    public ToscaServiceTemplate fetchPolicies(final String policyTypeId, final String policyTypeVersion,\r
+        final String policyId, final String policyVersion, final PolicyFetchMode mode) throws PfModelException {\r
 \r
-        return getFilteredPolicies(policyTypeId, policyTypeVersion, policyId, policyVersion);\r
+        return getFilteredPolicies(policyTypeId, policyTypeVersion, policyId, policyVersion, mode);\r
     }\r
 \r
     /**\r
@@ -65,15 +67,15 @@ public class PolicyProvider extends CommonModelProvider {
      * @param policyTypeId the ID of policy type\r
      * @param policyTypeVersion the version of policy type\r
      * @param policyId the ID of the policy\r
-     *\r
+     * @param mode the fetch mode for policies\r
      * @return the ToscaServiceTemplate object\r
      *\r
      * @throws PfModelException the PfModel parsing exception\r
      */\r
-    public ToscaServiceTemplate fetchLatestPolicies(String policyTypeId, String policyTypeVersion, String policyId)\r
-            throws PfModelException {\r
+    public ToscaServiceTemplate fetchLatestPolicies(final String policyTypeId, final String policyTypeVersion,\r
+        final String policyId, final PolicyFetchMode mode) throws PfModelException {\r
 \r
-        return getFilteredPolicies(policyTypeId, policyTypeVersion, policyId, ToscaPolicyFilter.LATEST_VERSION);\r
+        return getFilteredPolicies(policyTypeId, policyTypeVersion, policyId, ToscaPolicyFilter.LATEST_VERSION, mode);\r
     }\r
 \r
     /**\r
@@ -88,7 +90,7 @@ public class PolicyProvider extends CommonModelProvider {
      * @throws PfModelException the PfModel parsing exception\r
      */\r
     public ToscaServiceTemplate createPolicy(String policyTypeId, String policyTypeVersion, ToscaServiceTemplate body)\r
-            throws PfModelException {\r
+        throws PfModelException {\r
 \r
         return modelsProvider.createPolicies(body);\r
     }\r
@@ -119,7 +121,7 @@ public class PolicyProvider extends CommonModelProvider {
      * @throws PfModelException the PfModel parsing exception\r
      */\r
     public ToscaServiceTemplate deletePolicy(String policyTypeId, String policyTypeVersion, String policyId,\r
-            String policyVersion) throws PfModelException {\r
+        String policyVersion) throws PfModelException {\r
 \r
         return modelsProvider.deletePolicy(policyId, policyVersion);\r
     }\r
@@ -131,16 +133,25 @@ public class PolicyProvider extends CommonModelProvider {
      * @param policyTypeVersion the version of the policy type\r
      * @param policyName the name of the policy\r
      * @param policyVersion the version of the policy\r
+     * @param mode the fetch mode for policies\r
      *\r
      * @return the TOSCA service template containing the specified version of the policy\r
      *\r
      * @throws PfModelException the PfModel parsing exception\r
      */\r
-    private ToscaServiceTemplate getFilteredPolicies(String policyTypeName, String policyTypeVersion, String policyName,\r
-            String policyVersion) throws PfModelException {\r
+    private ToscaServiceTemplate getFilteredPolicies(final String policyTypeName, final String policyTypeVersion,\r
+        final String policyName, final String policyVersion, final PolicyFetchMode mode) throws PfModelException {\r
 \r
         ToscaPolicyFilter policyFilter = ToscaPolicyFilter.builder().name(policyName).version(policyVersion)\r
-                .type(policyTypeName).typeVersion(policyTypeVersion).build();\r
-        return modelsProvider.getFilteredPolicies(policyFilter);\r
+            .type(policyTypeName).typeVersion(policyTypeVersion).build();\r
+\r
+        ToscaServiceTemplate serviceTemplate = modelsProvider.getFilteredPolicies(policyFilter);\r
+\r
+        if (mode == null || PolicyFetchMode.BARE.equals(mode)) {\r
+            serviceTemplate.setPolicyTypes(null);\r
+            serviceTemplate.setDataTypes(null);\r
+        }\r
+\r
+        return serviceTemplate;\r
     }\r
 }\r
index 21bd5cd..1b1ed3c 100644 (file)
@@ -26,6 +26,7 @@ import static org.assertj.core.api.Assertions.assertThat;
 import static org.junit.Assert.assertEquals;
 import static org.junit.Assert.assertFalse;
 import static org.junit.Assert.assertNotNull;
+import static org.junit.Assert.assertNull;
 import static org.junit.Assert.assertTrue;
 
 import java.io.File;
@@ -586,13 +587,17 @@ public class TestApiRestServer {
             + "policies/SDNC_Policy.ONAP_VNF_NAMING_TIMESTAMP/versions/1.0.0", APP_JSON);
         assertEquals(Response.Status.OK.getStatusCode(), rawResponse.getStatus());
 
+        rawResponse = readResource("policytypes/onap.policies.Naming/versions/1.0.0/"
+            + "policies/SDNC_Policy.ONAP_VNF_NAMING_TIMESTAMP/versions/1.0.0?mode=referenced", APP_JSON);
+        assertEquals(Response.Status.OK.getStatusCode(), rawResponse.getStatus());
+
         ToscaServiceTemplate namingServiceTemplate = rawResponse.readEntity(ToscaServiceTemplate.class);
         assertEquals(1, namingServiceTemplate.getToscaTopologyTemplate().getPoliciesAsMap().size());
         assertEquals(1, namingServiceTemplate.getPolicyTypesAsMap().size());
         assertEquals(3, namingServiceTemplate.getDataTypesAsMap().size());
 
         rawResponse = readResource("policytypes/onap.policies.Naming/versions/1.0.0/"
-            + "policies/SDNC_Policy.ONAP_VNF_NAMING_TIMESTAMP/versions/latest", APP_JSON);
+            + "policies/SDNC_Policy.ONAP_VNF_NAMING_TIMESTAMP/versions/latest?mode=referenced", APP_JSON);
         assertEquals(Response.Status.OK.getStatusCode(), rawResponse.getStatus());
 
         namingServiceTemplate = rawResponse.readEntity(ToscaServiceTemplate.class);
@@ -600,13 +605,41 @@ public class TestApiRestServer {
         assertEquals(1, namingServiceTemplate.getPolicyTypesAsMap().size());
         assertEquals(3, namingServiceTemplate.getDataTypesAsMap().size());
 
-        rawResponse = readResource("policytypes/onap.policies.Naming/versions/1.0.0/policies", APP_JSON);
+        rawResponse =
+            readResource("policytypes/onap.policies.Naming/versions/1.0.0/policies?mode=referenced", APP_JSON);
         assertEquals(Response.Status.OK.getStatusCode(), rawResponse.getStatus());
 
         namingServiceTemplate = rawResponse.readEntity(ToscaServiceTemplate.class);
         assertEquals(1, namingServiceTemplate.getToscaTopologyTemplate().getPoliciesAsMap().size());
         assertEquals(1, namingServiceTemplate.getPolicyTypesAsMap().size());
         assertEquals(3, namingServiceTemplate.getDataTypesAsMap().size());
+
+        rawResponse = readResource("policytypes/onap.policies.Naming/versions/1.0.0/"
+            + "policies/SDNC_Policy.ONAP_VNF_NAMING_TIMESTAMP/versions/1.0.0", APP_JSON);
+        assertEquals(Response.Status.OK.getStatusCode(), rawResponse.getStatus());
+
+        namingServiceTemplate = rawResponse.readEntity(ToscaServiceTemplate.class);
+
+        assertEquals(1, namingServiceTemplate.getToscaTopologyTemplate().getPoliciesAsMap().size());
+        assertNull(namingServiceTemplate.getPolicyTypes());
+        assertNull(namingServiceTemplate.getDataTypes());
+
+        rawResponse = readResource("policytypes/onap.policies.Naming/versions/1.0.0/"
+            + "policies/SDNC_Policy.ONAP_VNF_NAMING_TIMESTAMP/versions/latest", APP_JSON);
+        assertEquals(Response.Status.OK.getStatusCode(), rawResponse.getStatus());
+
+        namingServiceTemplate = rawResponse.readEntity(ToscaServiceTemplate.class);
+        assertEquals(1, namingServiceTemplate.getToscaTopologyTemplate().getPoliciesAsMap().size());
+        assertNull(namingServiceTemplate.getPolicyTypes());
+        assertNull(namingServiceTemplate.getDataTypes());
+
+        rawResponse = readResource("policytypes/onap.policies.Naming/versions/1.0.0/policies", APP_JSON);
+        assertEquals(Response.Status.OK.getStatusCode(), rawResponse.getStatus());
+
+        namingServiceTemplate = rawResponse.readEntity(ToscaServiceTemplate.class);
+        assertEquals(1, namingServiceTemplate.getToscaTopologyTemplate().getPoliciesAsMap().size());
+        assertNull(namingServiceTemplate.getPolicyTypes());
+        assertNull(namingServiceTemplate.getDataTypes());
     }
 
     @Test
index f458013..6354242 100644 (file)
@@ -34,6 +34,7 @@ import java.util.ArrayList;
 import java.util.Base64;
 import java.util.Collections;
 import java.util.List;
+
 import org.junit.After;
 import org.junit.Before;
 import org.junit.Test;
@@ -75,18 +76,18 @@ public class TestPolicyProvider {
     private static final String POLICY_TYPE_RESOURCE = "policytypes/onap.policies.monitoring.cdap.tca.hi.lo.app.yaml";
     private static final String POLICY_RESOURCE_WITH_BAD_POLICYTYPE_ID = "policies/vCPE.policy.bad.policytypeid.json";
     private static final String POLICY_RESOURCE_WITH_BAD_POLICYTYPE_VERSION =
-            "policies/vCPE.policy.bad.policytypeversion.json";
+        "policies/vCPE.policy.bad.policytypeversion.json";
     private static final String POLICY_RESOURCE_WITH_NO_POLICY_VERSION = "policies/vCPE.policy.no.policyversion.json";
     private static final String POLICY_RESOURCE_WITH_DIFFERENT_FIELDS =
-            "policies/vCPE.policy.different.policy.fields.json";
+        "policies/vCPE.policy.different.policy.fields.json";
     private static final String MULTIPLE_POLICIES_RESOURCE = "policies/vCPE.policies.optimization.input.tosca.json";
 
     public static final String POLICY_TYPE_RESOURCE_OPERATIONAL =
-            "policytypes/onap.policies.controlloop.Operational.yaml";
+        "policytypes/onap.policies.controlloop.Operational.yaml";
     public static final String POLICY_TYPE_RESOURCE_OPERATIONAL_COMMON =
-            "policytypes/onap.policies.controlloop.operational.Common.yaml";
+        "policytypes/onap.policies.controlloop.operational.Common.yaml";
     public static final String POLICY_TYPE_RESOURCE_OPERATIONAL_DROOLS =
-            "policytypes/onap.policies.controlloop.operational.common.Drools.yaml";
+        "policytypes/onap.policies.controlloop.operational.common.Drools.yaml";
     private static final String POLICY_RESOURCE_OPERATIONAL = "policies/vCPE.policy.operational.input.tosca.json";
     public static final String POLICY_TYPE_OPERATIONAL_DROOLS = "onap.policies.controlloop.operational.common.Drools";
 
@@ -106,8 +107,8 @@ public class TestPolicyProvider {
         providerParams.setDatabaseUser("policy");
         providerParams.setDatabasePassword(Base64.getEncoder().encodeToString("P01icY".getBytes()));
         providerParams.setPersistenceUnit("ToscaConceptTest");
-        apiParamGroup = new ApiParameterGroup("ApiGroup", null, providerParams,
-                Collections.emptyList(), Collections.emptyList());
+        apiParamGroup =
+            new ApiParameterGroup("ApiGroup", null, providerParams, Collections.emptyList(), Collections.emptyList());
         ParameterService.register(apiParamGroup, true);
         policyTypeProvider = new PolicyTypeProvider();
         policyProvider = new PolicyProvider();
@@ -130,15 +131,15 @@ public class TestPolicyProvider {
     public void testFetchPolicies() {
 
         assertThatThrownBy(() -> {
-            policyProvider.fetchPolicies("dummy", "1.0.0", null, null);
+            policyProvider.fetchPolicies("dummy", "1.0.0", null, null, null);
         }).hasMessage("service template not found in database");
 
         assertThatThrownBy(() -> {
-            policyProvider.fetchPolicies("dummy", "1.0.0", "dummy", null);
+            policyProvider.fetchPolicies("dummy", "1.0.0", "dummy", null, null);
         }).hasMessage("service template not found in database");
 
         assertThatThrownBy(() -> {
-            policyProvider.fetchPolicies("dummy", "1.0.0", "dummy", "1.0.0");
+            policyProvider.fetchPolicies("dummy", "1.0.0", "dummy", "1.0.0", null);
         }).hasMessage("service template not found in database");
     }
 
@@ -146,7 +147,7 @@ public class TestPolicyProvider {
     public void testFetchLatestPolicies() {
 
         assertThatThrownBy(() -> {
-            policyProvider.fetchLatestPolicies("dummy", "dummy", "dummy");
+            policyProvider.fetchLatestPolicies("dummy", "dummy", "dummy", null);
         }).hasMessage("service template not found in database");
     }
 
@@ -158,7 +159,7 @@ public class TestPolicyProvider {
         String policyTypeId = "onap.policies.monitoring.cdap.tca.hi.lo.app";
 
         try (PolicyModelsProvider databaseProvider =
-                new PolicyModelsProviderFactory().createPolicyModelsProvider(providerParams)) {
+            new PolicyModelsProviderFactory().createPolicyModelsProvider(providerParams)) {
             assertEquals(0, databaseProvider.getPdpGroups("name").size());
             assertEquals(0, databaseProvider.getFilteredPdpGroups(PdpGroupFilter.builder().build()).size());
 
@@ -189,14 +190,14 @@ public class TestPolicyProvider {
             pdpSubGroup.getPdpInstances().add(pdp);
 
             // Create Pdp Groups
-            assertEquals(123, databaseProvider.createPdpGroups(groupList).get(0).getPdpSubgroups().get(0)
-                    .getDesiredInstanceCount());
+            assertEquals(123,
+                databaseProvider.createPdpGroups(groupList).get(0).getPdpSubgroups().get(0).getDesiredInstanceCount());
             assertEquals(1, databaseProvider.getPdpGroups("group").size());
 
             // Create Policy Type
             assertThatCode(() -> {
                 ToscaServiceTemplate policyTypeServiceTemplate = standardYamlCoder
-                        .decode(ResourceUtils.getResourceAsString(POLICY_TYPE_RESOURCE), ToscaServiceTemplate.class);
+                    .decode(ResourceUtils.getResourceAsString(POLICY_TYPE_RESOURCE), ToscaServiceTemplate.class);
                 policyTypeProvider.createPolicyType(policyTypeServiceTemplate);
             }).doesNotThrowAnyException();
 
@@ -204,9 +205,9 @@ public class TestPolicyProvider {
             assertThatCode(() -> {
                 String policyString = ResourceUtils.getResourceAsString(POLICY_RESOURCE);
                 ToscaServiceTemplate policyServiceTemplate =
-                        standardCoder.decode(policyString, ToscaServiceTemplate.class);
+                    standardCoder.decode(policyString, ToscaServiceTemplate.class);
                 ToscaServiceTemplate serviceTemplate =
-                        policyProvider.createPolicy(policyTypeId, policyTypeVersion, policyServiceTemplate);
+                    policyProvider.createPolicy(policyTypeId, policyTypeVersion, policyServiceTemplate);
                 assertFalse(serviceTemplate.getToscaTopologyTemplate().getPolicies().get(0).isEmpty());
             }).doesNotThrowAnyException();
 
@@ -214,12 +215,12 @@ public class TestPolicyProvider {
             pdpSubGroup.setPolicies(new ArrayList<>());
             pdpSubGroup.getPolicies().add(new ToscaPolicyIdentifier(policyId, policyVersion));
             assertEquals(1,
-                    databaseProvider.createPdpGroups(groupList).get(0).getPdpSubgroups().get(0).getPolicies().size());
+                databaseProvider.createPdpGroups(groupList).get(0).getPdpSubgroups().get(0).getPolicies().size());
 
             // Test validateDeleteEligibility exception path(!pdpGroups.isEmpty())
             assertThatThrownBy(() -> {
                 policyProvider.deletePolicy("onap.policies.monitoring.cdap.tca.hi.lo.app", "1.0.0", "onap.restart.tca",
-                        "1.0.0");
+                    "1.0.0");
             }).hasMessageContaining("policy is in use, it is deployed in PDP group group subgroup type");
         } catch (Exception exc) {
             fail("Test should not throw an exception");
@@ -234,7 +235,7 @@ public class TestPolicyProvider {
         }).hasMessage("topology template not specified on service template");
 
         ToscaServiceTemplate policyTypeServiceTemplate = standardYamlCoder
-                .decode(ResourceUtils.getResourceAsString(POLICY_TYPE_RESOURCE), ToscaServiceTemplate.class);
+            .decode(ResourceUtils.getResourceAsString(POLICY_TYPE_RESOURCE), ToscaServiceTemplate.class);
         policyTypeProvider.createPolicyType(policyTypeServiceTemplate);
 
         assertThatCode(() -> policyTypeProvider.createPolicyType(policyTypeServiceTemplate)).doesNotThrowAnyException();
@@ -242,63 +243,63 @@ public class TestPolicyProvider {
         assertThatThrownBy(() -> {
             String badPolicyString = ResourceUtils.getResourceAsString(POLICY_RESOURCE_WITH_BAD_POLICYTYPE_ID);
             ToscaServiceTemplate badPolicyServiceTemplate =
-                    standardCoder.decode(badPolicyString, ToscaServiceTemplate.class);
+                standardCoder.decode(badPolicyString, ToscaServiceTemplate.class);
             policyProvider.createPolicy("onap.policies.monitoring.cdap.tca.hi.lo.app", "1.0.0",
-                    badPolicyServiceTemplate);
+                badPolicyServiceTemplate);
         }).hasMessageContaining(
-                "policy type onap.policies.monitoring.cdap.tca.hi.lo.appxxx:0.0.0 referenced in policy not found");
+            "policy type onap.policies.monitoring.cdap.tca.hi.lo.appxxx:0.0.0 referenced in policy not found");
 
         assertThatThrownBy(() -> {
             String badPolicyString = ResourceUtils.getResourceAsString(POLICY_RESOURCE_WITH_BAD_POLICYTYPE_VERSION);
             ToscaServiceTemplate badPolicyServiceTemplate =
-                    standardCoder.decode(badPolicyString, ToscaServiceTemplate.class);
+                standardCoder.decode(badPolicyString, ToscaServiceTemplate.class);
             policyProvider.createPolicy("onap.policies.monitoring.cdap.tca.hi.lo.app", "1.0.0",
-                    badPolicyServiceTemplate);
+                badPolicyServiceTemplate);
         }).hasMessageContaining(
-                "policy type onap.policies.monitoring.cdap.tca.hi.lo.app:2.0.0 referenced in policy not found");
+            "policy type onap.policies.monitoring.cdap.tca.hi.lo.app:2.0.0 referenced in policy not found");
 
         assertThatThrownBy(() -> {
             String badPolicyString = ResourceUtils.getResourceAsString(POLICY_RESOURCE_WITH_NO_POLICY_VERSION);
             ToscaServiceTemplate badPolicyServiceTemplate =
-                    standardCoder.decode(badPolicyString, ToscaServiceTemplate.class);
+                standardCoder.decode(badPolicyString, ToscaServiceTemplate.class);
             policyProvider.createPolicy("onap.policies.monitoring.cdap.tca.hi.lo.app", "1.0.0",
-                    badPolicyServiceTemplate);
+                badPolicyServiceTemplate);
         }).hasMessageContaining("key version is a null version");
 
         String policyString = ResourceUtils.getResourceAsString(POLICY_RESOURCE);
         ToscaServiceTemplate policyServiceTemplate = standardCoder.decode(policyString, ToscaServiceTemplate.class);
-        ToscaServiceTemplate serviceTemplate = policyProvider
-                .createPolicy("onap.policies.monitoring.cdap.tca.hi.lo.app", "1.0.0", policyServiceTemplate);
+        ToscaServiceTemplate serviceTemplate =
+            policyProvider.createPolicy("onap.policies.monitoring.cdap.tca.hi.lo.app", "1.0.0", policyServiceTemplate);
         assertFalse(serviceTemplate.getToscaTopologyTemplate().getPolicies().get(0).isEmpty());
 
         assertThatThrownBy(() -> {
             String badPolicyString = ResourceUtils.getResourceAsString(POLICY_RESOURCE_WITH_DIFFERENT_FIELDS);
             ToscaServiceTemplate badPolicyServiceTemplate =
-                    standardCoder.decode(badPolicyString, ToscaServiceTemplate.class);
+                standardCoder.decode(badPolicyString, ToscaServiceTemplate.class);
             policyProvider.createPolicy("onap.policies.monitoring.cdap.tca.hi.lo.app", "1.0.0",
-                    badPolicyServiceTemplate);
+                badPolicyServiceTemplate);
         }).hasMessageContaining("entity in incoming fragment does not equal existing entity");
     }
 
     @Test
     public void testCreateOperationalDroolsPolicy() throws CoderException, PfModelException {
-        ToscaServiceTemplate policyTypeServiceTemplate = standardYamlCoder.decode(
-                ResourceUtils.getResourceAsString(POLICY_TYPE_RESOURCE_OPERATIONAL), ToscaServiceTemplate.class);
+        ToscaServiceTemplate policyTypeServiceTemplate = standardYamlCoder
+            .decode(ResourceUtils.getResourceAsString(POLICY_TYPE_RESOURCE_OPERATIONAL), ToscaServiceTemplate.class);
 
         policyTypeProvider.createPolicyType(policyTypeServiceTemplate);
         policyTypeServiceTemplate = standardYamlCoder.decode(
-                ResourceUtils.getResourceAsString(POLICY_TYPE_RESOURCE_OPERATIONAL_COMMON), ToscaServiceTemplate.class);
+            ResourceUtils.getResourceAsString(POLICY_TYPE_RESOURCE_OPERATIONAL_COMMON), ToscaServiceTemplate.class);
 
         policyTypeProvider.createPolicyType(policyTypeServiceTemplate);
 
         policyTypeServiceTemplate = standardYamlCoder.decode(
-                ResourceUtils.getResourceAsString(POLICY_TYPE_RESOURCE_OPERATIONAL_DROOLS), ToscaServiceTemplate.class);
+            ResourceUtils.getResourceAsString(POLICY_TYPE_RESOURCE_OPERATIONAL_DROOLS), ToscaServiceTemplate.class);
         policyTypeProvider.createPolicyType(policyTypeServiceTemplate);
 
         String policyString = ResourceUtils.getResourceAsString(POLICY_RESOURCE_OPERATIONAL);
         ToscaServiceTemplate policyServiceTemplate = standardCoder.decode(policyString, ToscaServiceTemplate.class);
         ToscaServiceTemplate serviceTemplate =
-                policyProvider.createPolicy(POLICY_TYPE_OPERATIONAL_DROOLS, "1.0.0", policyServiceTemplate);
+            policyProvider.createPolicy(POLICY_TYPE_OPERATIONAL_DROOLS, "1.0.0", policyServiceTemplate);
         assertFalse(serviceTemplate.getToscaTopologyTemplate().getPolicies().get(0).isEmpty());
     }
 
@@ -308,74 +309,71 @@ public class TestPolicyProvider {
         assertThatThrownBy(() -> {
             String multiPoliciesString = ResourceUtils.getResourceAsString(MULTIPLE_POLICIES_RESOURCE);
             ToscaServiceTemplate multiPoliciesServiceTemplate =
-                    standardCoder.decode(multiPoliciesString, ToscaServiceTemplate.class);
+                standardCoder.decode(multiPoliciesString, ToscaServiceTemplate.class);
             policyProvider.createPolicies(multiPoliciesServiceTemplate);
         }).hasMessageContaining(
-                "no policy types are defined on the service template for the policies in the topology template");
+            "no policy types are defined on the service template for the policies in the topology template");
 
         // Create required policy types
-        ToscaServiceTemplate policyTypeServiceTemplate = standardYamlCoder.decode(
-                ResourceUtils.getResourceAsString("policytypes/onap.policies.Optimization.yaml"),
+        ToscaServiceTemplate policyTypeServiceTemplate =
+            standardYamlCoder.decode(ResourceUtils.getResourceAsString("policytypes/onap.policies.Optimization.yaml"),
                 ToscaServiceTemplate.class);
         policyTypeProvider.createPolicyType(policyTypeServiceTemplate);
 
         policyTypeServiceTemplate = standardYamlCoder.decode(
-                ResourceUtils.getResourceAsString("policytypes/onap.policies.optimization.Resource.yaml"),
-                ToscaServiceTemplate.class);
+            ResourceUtils.getResourceAsString("policytypes/onap.policies.optimization.Resource.yaml"),
+            ToscaServiceTemplate.class);
         policyTypeProvider.createPolicyType(policyTypeServiceTemplate);
 
         policyTypeServiceTemplate = standardYamlCoder.decode(
-                ResourceUtils
-                        .getResourceAsString("policytypes/onap.policies.optimization.resource.AffinityPolicy.yaml"),
-                ToscaServiceTemplate.class);
+            ResourceUtils.getResourceAsString("policytypes/onap.policies.optimization.resource.AffinityPolicy.yaml"),
+            ToscaServiceTemplate.class);
         policyTypeProvider.createPolicyType(policyTypeServiceTemplate);
 
         policyTypeServiceTemplate = standardYamlCoder.decode(
-                ResourceUtils
-                        .getResourceAsString("policytypes/onap.policies.optimization.resource.DistancePolicy.yaml"),
-                ToscaServiceTemplate.class);
+            ResourceUtils.getResourceAsString("policytypes/onap.policies.optimization.resource.DistancePolicy.yaml"),
+            ToscaServiceTemplate.class);
         policyTypeProvider.createPolicyType(policyTypeServiceTemplate);
 
         policyTypeServiceTemplate = standardYamlCoder.decode(
-                ResourceUtils.getResourceAsString("policytypes/onap.policies.optimization.resource.Vim_fit.yaml"),
-                ToscaServiceTemplate.class);
+            ResourceUtils.getResourceAsString("policytypes/onap.policies.optimization.resource.Vim_fit.yaml"),
+            ToscaServiceTemplate.class);
         policyTypeProvider.createPolicyType(policyTypeServiceTemplate);
 
         policyTypeServiceTemplate = standardYamlCoder.decode(
-                ResourceUtils.getResourceAsString("policytypes/onap.policies.optimization.resource.HpaPolicy.yaml"),
-                ToscaServiceTemplate.class);
+            ResourceUtils.getResourceAsString("policytypes/onap.policies.optimization.resource.HpaPolicy.yaml"),
+            ToscaServiceTemplate.class);
         policyTypeProvider.createPolicyType(policyTypeServiceTemplate);
 
         policyTypeServiceTemplate = standardYamlCoder.decode(
-                ResourceUtils.getResourceAsString("policytypes/onap.policies.optimization.resource.VnfPolicy.yaml"),
-                ToscaServiceTemplate.class);
+            ResourceUtils.getResourceAsString("policytypes/onap.policies.optimization.resource.VnfPolicy.yaml"),
+            ToscaServiceTemplate.class);
         policyTypeProvider.createPolicyType(policyTypeServiceTemplate);
 
         policyTypeServiceTemplate = standardYamlCoder.decode(
-                ResourceUtils.getResourceAsString("policytypes/onap.policies.optimization.Service.yaml"),
-                ToscaServiceTemplate.class);
+            ResourceUtils.getResourceAsString("policytypes/onap.policies.optimization.Service.yaml"),
+            ToscaServiceTemplate.class);
         policyTypeProvider.createPolicyType(policyTypeServiceTemplate);
 
         policyTypeServiceTemplate = standardYamlCoder.decode(
-                ResourceUtils
-                        .getResourceAsString("policytypes/onap.policies.optimization.service.SubscriberPolicy.yaml"),
-                ToscaServiceTemplate.class);
+            ResourceUtils.getResourceAsString("policytypes/onap.policies.optimization.service.SubscriberPolicy.yaml"),
+            ToscaServiceTemplate.class);
         policyTypeProvider.createPolicyType(policyTypeServiceTemplate);
 
         policyTypeServiceTemplate = standardYamlCoder.decode(
-                ResourceUtils.getResourceAsString("policytypes/onap.policies.optimization.service.QueryPolicy.yaml"),
-                ToscaServiceTemplate.class);
+            ResourceUtils.getResourceAsString("policytypes/onap.policies.optimization.service.QueryPolicy.yaml"),
+            ToscaServiceTemplate.class);
         policyTypeProvider.createPolicyType(policyTypeServiceTemplate);
 
         policyTypeServiceTemplate = standardYamlCoder.decode(
-                ResourceUtils.getResourceAsString("policytypes/onap.policies.monitoring.cdap.tca.hi.lo.app.yaml"),
-                ToscaServiceTemplate.class);
+            ResourceUtils.getResourceAsString("policytypes/onap.policies.monitoring.cdap.tca.hi.lo.app.yaml"),
+            ToscaServiceTemplate.class);
         policyTypeProvider.createPolicyType(policyTypeServiceTemplate);
 
         // Create multiple policies in one call
         String multiPoliciesString = ResourceUtils.getResourceAsString(MULTIPLE_POLICIES_RESOURCE);
         ToscaServiceTemplate multiPoliciesServiceTemplate =
-                standardCoder.decode(multiPoliciesString, ToscaServiceTemplate.class);
+            standardCoder.decode(multiPoliciesString, ToscaServiceTemplate.class);
 
         assertThatCode(() -> {
             policyProvider.createPolicies(multiPoliciesServiceTemplate);
@@ -392,7 +390,7 @@ public class TestPolicyProvider {
 
         assertThatCode(() -> {
             ToscaServiceTemplate policyTypeServiceTemplate = standardYamlCoder
-                    .decode(ResourceUtils.getResourceAsString(POLICY_TYPE_RESOURCE), ToscaServiceTemplate.class);
+                .decode(ResourceUtils.getResourceAsString(POLICY_TYPE_RESOURCE), ToscaServiceTemplate.class);
             policyTypeProvider.createPolicyType(policyTypeServiceTemplate);
         }).doesNotThrowAnyException();
 
@@ -400,19 +398,19 @@ public class TestPolicyProvider {
             String policyString = ResourceUtils.getResourceAsString(POLICY_RESOURCE);
             ToscaServiceTemplate policyServiceTemplate = standardCoder.decode(policyString, ToscaServiceTemplate.class);
             ToscaServiceTemplate serviceTemplate = policyProvider
-                    .createPolicy("onap.policies.monitoring.cdap.tca.hi.lo.app", "1.0.0", policyServiceTemplate);
+                .createPolicy("onap.policies.monitoring.cdap.tca.hi.lo.app", "1.0.0", policyServiceTemplate);
             assertFalse(serviceTemplate.getToscaTopologyTemplate().getPolicies().get(0).isEmpty());
         }).doesNotThrowAnyException();
 
         assertThatCode(() -> {
             ToscaServiceTemplate serviceTemplate = policyProvider
-                    .deletePolicy("onap.policies.monitoring.cdap.tca.hi.lo.app", "1.0.0", "onap.restart.tca", "1.0.0");
+                .deletePolicy("onap.policies.monitoring.cdap.tca.hi.lo.app", "1.0.0", "onap.restart.tca", "1.0.0");
             assertFalse(serviceTemplate.getToscaTopologyTemplate().getPolicies().get(0).isEmpty());
         }).doesNotThrowAnyException();
 
         assertThatThrownBy(() -> {
             policyProvider.deletePolicy("onap.policies.monitoring.cdap.tca.hi.lo.app", "1.0.0", "onap.restart.tca",
-                    "1.0.0");
+                "1.0.0");
         }).hasMessageContaining("no policies found");
     }
 }