Use singleton for api statistics
[policy/api.git] / main / src / main / java / org / onap / policy / api / main / rest / ApiRestController.java
index e7deb11..eb60c5e 100644 (file)
@@ -3,7 +3,9 @@
  * ONAP Policy API\r
  * ================================================================================\r
  * Copyright (C) 2018 Samsung Electronics Co., Ltd. All rights reserved.\r
- * Copyright (C) 2019 AT&T Intellectual Property. All rights reserved.\r
+ * Modifications Copyright (C) 2019-2021 AT&T Intellectual Property. All rights reserved.\r
+ * Modifications Copyright (C) 2020 Nordix Foundation.\r
+ * Modifications Copyright (C) 2020 Bell Canada.\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,9 +38,12 @@ import io.swagger.annotations.Info;
 import io.swagger.annotations.ResponseHeader;\r
 import io.swagger.annotations.SecurityDefinition;\r
 import io.swagger.annotations.SwaggerDefinition;\r
+import java.net.HttpURLConnection;\r
+import java.util.List;\r
 import java.util.UUID;\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
@@ -46,42 +51,84 @@ import javax.ws.rs.Path;
 import javax.ws.rs.PathParam;\r
 import javax.ws.rs.Produces;\r
 import javax.ws.rs.QueryParam;\r
-import javax.ws.rs.core.MediaType;\r
 import javax.ws.rs.core.Response;\r
-import javax.ws.rs.core.Response.ResponseBuilder;\r
+import javax.ws.rs.core.Response.Status;\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
 import org.onap.policy.api.main.rest.provider.StatisticsProvider;\r
+import org.onap.policy.common.endpoints.event.comm.Topic.CommInfrastructure;\r
 import org.onap.policy.common.endpoints.report.HealthCheckReport;\r
-import org.onap.policy.models.tosca.concepts.ToscaServiceTemplate;\r
+import org.onap.policy.common.endpoints.utils.NetLoggerUtil;\r
+import org.onap.policy.common.endpoints.utils.NetLoggerUtil.EventType;\r
+import org.onap.policy.models.base.PfModelException;\r
+import org.onap.policy.models.base.PfModelRuntimeException;\r
+import org.onap.policy.models.tosca.authorative.concepts.ToscaServiceTemplate;\r
+import org.slf4j.Logger;\r
+import org.slf4j.LoggerFactory;\r
 \r
 /**\r
  * Class to provide REST API services.\r
+ *\r
+ * @author Chenfei Gao (cgao@research.att.com)\r
  */\r
 @Path("/policy/api/v1")\r
 @Api(value = "Policy Design API")\r
-@Produces(MediaType.APPLICATION_JSON)\r
-@Consumes(MediaType.APPLICATION_JSON)\r
-@SwaggerDefinition(info = @Info(\r
+@Produces({"application/json", "application/yaml"})\r
+@Consumes({"application/json", "application/yaml"})\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
-        version = "1.0.0",\r
-        title = "Policy Design",\r
-        extensions = {\r
-                @Extension(properties = {\r
-                        @ExtensionProperty(name = "planned-retirement-date", value = "tbd"),\r
-                        @ExtensionProperty(name = "component", value = "Policy Framework")\r
-                })\r
-        }),\r
-        schemes = { SwaggerDefinition.Scheme.HTTP, SwaggerDefinition.Scheme.HTTPS },\r
-        securityDefinition = @SecurityDefinition(basicAuthDefinitions = { @BasicAuthDefinition(key = "basicAuth") }))\r
-public class ApiRestController {\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
+public class ApiRestController extends CommonRestController {\r
+\r
+    private static final Logger LOGGER = LoggerFactory.getLogger(ApiRestController.class);\r
+\r
+    private static final String ERROR_MESSAGE_NO_POLICIES_FOUND = "No policies found";\r
+\r
+    private static final String EXTENSION_NAME = "interface info";\r
+\r
+    private static final String API_VERSION_NAME = "api-version";\r
+    private static final String API_VERSION = "1.0.0";\r
+\r
+    private static final String LAST_MOD_NAME = "last-mod-release";\r
+\r
+    private static final String AUTHORIZATION_TYPE = "basicAuth";\r
+\r
+    private static final String VERSION_MINOR_NAME = "X-MinorVersion";\r
+    private static final String VERSION_MINOR_DESCRIPTION =\r
+        "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
+\r
+    private static final String VERSION_PATCH_NAME = "X-PatchVersion";\r
+    private static final String VERSION_PATCH_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
+\r
+    private static final String VERSION_LATEST_NAME = "X-LatestVersion";\r
+    private static final String VERSION_LATEST_DESCRIPTION = "Used only to communicate an API's latest version";\r
+\r
+    private static final String REQUEST_ID_NAME = "X-ONAP-RequestID";\r
+    private static final String REQUEST_ID_HDR_DESCRIPTION = "Used to track REST transactions for logging purpose";\r
+    private static final String REQUEST_ID_PARAM_DESCRIPTION = "RequestID for http transaction";\r
+\r
+    private static final String AUTHENTICATION_ERROR_MESSAGE = "Authentication Error";\r
+    private static final String AUTHORIZATION_ERROR_MESSAGE = "Authorization Error";\r
+    private static final String SERVER_ERROR_MESSAGE = "Internal Server Error";\r
+    private static final String NOT_FOUND_MESSAGE = "Resource Not Found";\r
+    private static final String INVALID_BODY_MESSAGE = "Invalid Body";\r
+    private static final String INVALID_PAYLOAD_MESSAGE = "Not Acceptable Payload";\r
+    private static final String HTTP_CONFLICT_MESSAGE = "Delete Conflict, Rule Violation";\r
+\r
 \r
     /**\r
      * Retrieves the healthcheck status of the API component.\r
@@ -90,43 +137,33 @@ public class ApiRestController {
      */\r
     @GET\r
     @Path("/healthcheck")\r
-    @ApiOperation(value = "Perform a system healthcheck",\r
-            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",\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
-            authorizations = @Authorization(value = "basicAuth"),\r
-            tags = { "HealthCheck", },\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
+    @ApiOperation(value = "Perform a system healthcheck", notes = "Returns healthy status of the Policy API component",\r
+        response = HealthCheckReport.class,\r
+        responseHeaders = {\r
+            @ResponseHeader(name = VERSION_MINOR_NAME,\r
+                description = VERSION_MINOR_DESCRIPTION,\r
+                response = String.class),\r
+            @ResponseHeader(name = VERSION_PATCH_NAME,\r
+                description = VERSION_PATCH_DESCRIPTION,\r
+                response = String.class),\r
+            @ResponseHeader(name = VERSION_LATEST_NAME, description = VERSION_LATEST_DESCRIPTION,\r
+                response = String.class),\r
+            @ResponseHeader(name = REQUEST_ID_NAME,\r
+                description = REQUEST_ID_HDR_DESCRIPTION, response = UUID.class)},\r
+        authorizations = @Authorization(value = AUTHORIZATION_TYPE), tags = {"HealthCheck", },\r
+        extensions = {\r
+            @Extension(name = EXTENSION_NAME, properties = {\r
+                @ExtensionProperty(name = API_VERSION_NAME, value = API_VERSION),\r
+                @ExtensionProperty(name = LAST_MOD_NAME, value = "Dublin")})})\r
     @ApiResponses(value = {\r
-            @ApiResponse(code = 401, message = "Authentication Error"),\r
-            @ApiResponse(code = 403, message = "Authorization Error"),\r
-            @ApiResponse(code = 500, message = "Internal Server Error")\r
-        })\r
-    public Response getHealthCheck(\r
-            @HeaderParam("X-ONAP-RequestID") @ApiParam("RequestID for http transaction") UUID requestId) {\r
-        return addLoggingHeaders(addVersionControlHeaders(Response.status(Response.Status.OK)), requestId)\r
-            .entity(new HealthCheckProvider().performHealthCheck()).build();\r
+        @ApiResponse(code = HttpURLConnection.HTTP_UNAUTHORIZED, message = AUTHENTICATION_ERROR_MESSAGE),\r
+        @ApiResponse(code = HttpURLConnection.HTTP_FORBIDDEN, message = AUTHORIZATION_ERROR_MESSAGE),\r
+        @ApiResponse(code = HttpURLConnection.HTTP_INTERNAL_ERROR, message = SERVER_ERROR_MESSAGE)})\r
+    public Response\r
+        getHealthCheck(@HeaderParam(REQUEST_ID_NAME) @ApiParam(REQUEST_ID_PARAM_DESCRIPTION) UUID requestId) {\r
+\r
+        updateApiStatisticsCounter(Target.OTHER, Result.SUCCESS, HttpMethod.GET);\r
+        return makeOkResponse(requestId, new HealthCheckProvider().performHealthCheck());\r
     }\r
 \r
     /**\r
@@ -137,42 +174,34 @@ public class ApiRestController {
     @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",\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
-            authorizations = @Authorization(value = "basicAuth"),\r
-            tags = { "Statistics", },\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
+        notes = "Returns current statistics including the counters of API invocation",\r
+        response = StatisticsReport.class,\r
+        responseHeaders = {\r
+            @ResponseHeader(name = VERSION_MINOR_NAME,\r
+                description = VERSION_MINOR_DESCRIPTION,\r
+                response = String.class),\r
+            @ResponseHeader(name = VERSION_PATCH_NAME,\r
+                description = VERSION_PATCH_DESCRIPTION,\r
+                response = String.class),\r
+            @ResponseHeader(name = VERSION_LATEST_NAME, description = VERSION_LATEST_DESCRIPTION,\r
+                response = String.class),\r
+            @ResponseHeader(name = REQUEST_ID_NAME,\r
+                description = REQUEST_ID_HDR_DESCRIPTION, response = UUID.class)},\r
+        authorizations = @Authorization(value = AUTHORIZATION_TYPE), tags = {"Statistics", },\r
+        extensions = {\r
+            @Extension(name = EXTENSION_NAME, properties = {\r
+                @ExtensionProperty(name = API_VERSION_NAME, value = API_VERSION),\r
+                @ExtensionProperty(name = LAST_MOD_NAME, value = "Dublin")})})\r
     @ApiResponses(value = {\r
-            @ApiResponse(code = 401, message = "Authentication Error"),\r
-            @ApiResponse(code = 403, message = "Authorization Error"),\r
-            @ApiResponse(code = 500, message = "Internal Server Error")\r
-        })\r
-    public Response getStatistics(\r
-            @HeaderParam("X-ONAP-RequestID") @ApiParam("RequestID for http transaction") UUID requestId) {\r
-        return addLoggingHeaders(addVersionControlHeaders(Response.status(Response.Status.OK)), requestId)\r
-            .entity(new StatisticsProvider().fetchCurrentStatistics()).build();\r
+        @ApiResponse(code = HttpURLConnection.HTTP_UNAUTHORIZED, message = AUTHENTICATION_ERROR_MESSAGE),\r
+        @ApiResponse(code = HttpURLConnection.HTTP_FORBIDDEN, message = AUTHORIZATION_ERROR_MESSAGE),\r
+        @ApiResponse(code = HttpURLConnection.HTTP_INTERNAL_ERROR, message = SERVER_ERROR_MESSAGE)})\r
+    public Response\r
+        getStatistics(@HeaderParam(REQUEST_ID_NAME) @ApiParam(REQUEST_ID_PARAM_DESCRIPTION) UUID requestId) {\r
+\r
+        updateApiStatisticsCounter(Target.OTHER, Result.SUCCESS, HttpMethod.GET);\r
+\r
+        return makeOkResponse(requestId, new StatisticsProvider().fetchCurrentStatistics());\r
     }\r
 \r
     /**\r
@@ -183,42 +212,40 @@ public class ApiRestController {
     @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",\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
-            authorizations = @Authorization(value = "basicAuth"),\r
-            tags = { "PolicyType", },\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
+        notes = "Returns a list of existing policy types stored in Policy Framework",\r
+        response = ToscaServiceTemplate.class,\r
+        responseHeaders = {\r
+            @ResponseHeader(name = VERSION_MINOR_NAME,\r
+                description = VERSION_MINOR_DESCRIPTION,\r
+                response = String.class),\r
+            @ResponseHeader(name = VERSION_PATCH_NAME,\r
+                description = VERSION_PATCH_DESCRIPTION,\r
+                response = String.class),\r
+            @ResponseHeader(name = VERSION_LATEST_NAME, description = VERSION_LATEST_DESCRIPTION,\r
+                response = String.class),\r
+            @ResponseHeader(name = REQUEST_ID_NAME,\r
+                description = REQUEST_ID_HDR_DESCRIPTION, response = UUID.class)},\r
+        authorizations = @Authorization(value = AUTHORIZATION_TYPE), tags = {"PolicyType", },\r
+        extensions = {\r
+            @Extension(name = EXTENSION_NAME, properties = {\r
+                @ExtensionProperty(name = API_VERSION_NAME, value = API_VERSION),\r
+                @ExtensionProperty(name = LAST_MOD_NAME, value = "Dublin")})})\r
     @ApiResponses(value = {\r
-            @ApiResponse(code = 401, message = "Authentication Error"),\r
-            @ApiResponse(code = 403, message = "Authorization Error"),\r
-            @ApiResponse(code = 500, message = "Internal Server Error")\r
-        })\r
-    public Response getAllPolicyTypes(\r
-            @HeaderParam("X-ONAP-RequestID") @ApiParam("RequestID for http transaction") UUID requestId) {\r
-        return addLoggingHeaders(addVersionControlHeaders(Response.status(Response.Status.OK)), requestId)\r
-            .entity(new PolicyTypeProvider().fetchPolicyTypes(null, null)).build();\r
+        @ApiResponse(code = HttpURLConnection.HTTP_UNAUTHORIZED, message = AUTHENTICATION_ERROR_MESSAGE),\r
+        @ApiResponse(code = HttpURLConnection.HTTP_FORBIDDEN, message = AUTHORIZATION_ERROR_MESSAGE),\r
+        @ApiResponse(code = HttpURLConnection.HTTP_INTERNAL_ERROR, message = SERVER_ERROR_MESSAGE)})\r
+    public Response\r
+        getAllPolicyTypes(@HeaderParam(REQUEST_ID_NAME) @ApiParam(REQUEST_ID_PARAM_DESCRIPTION) UUID requestId) {\r
+\r
+        try (var policyTypeProvider = new PolicyTypeProvider()) {\r
+            ToscaServiceTemplate serviceTemplate = policyTypeProvider.fetchPolicyTypes(null, null);\r
+            updateApiStatisticsCounter(Target.POLICY_TYPE, Result.SUCCESS, HttpMethod.GET);\r
+            return makeOkResponse(requestId, serviceTemplate);\r
+        } catch (PfModelException | PfModelRuntimeException pfme) {\r
+            LOGGER.warn("GET /policytypes", pfme);\r
+            updateApiStatisticsCounter(Target.POLICY_TYPE, Result.FAILURE, HttpMethod.GET);\r
+            return makeErrorResponse(requestId, pfme);\r
+        }\r
     }\r
 \r
     /**\r
@@ -231,44 +258,42 @@ public class ApiRestController {
     @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",\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
-            authorizations = @Authorization(value = "basicAuth"),\r
-            tags = { "PolicyType", },\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
+        notes = "Returns a list of all available versions for the specified policy type",\r
+        response = ToscaServiceTemplate.class,\r
+        responseHeaders = {\r
+            @ResponseHeader(name = VERSION_MINOR_NAME,\r
+                description = VERSION_MINOR_DESCRIPTION,\r
+                response = String.class),\r
+            @ResponseHeader(name = VERSION_PATCH_NAME,\r
+                description = VERSION_PATCH_DESCRIPTION,\r
+                response = String.class),\r
+            @ResponseHeader(name = VERSION_LATEST_NAME, description = VERSION_LATEST_DESCRIPTION,\r
+                response = String.class),\r
+            @ResponseHeader(name = REQUEST_ID_NAME,\r
+                description = REQUEST_ID_HDR_DESCRIPTION, response = UUID.class)},\r
+        authorizations = @Authorization(value = AUTHORIZATION_TYPE), tags = {"PolicyType", },\r
+        extensions = {\r
+            @Extension(name = EXTENSION_NAME, properties = {\r
+                @ExtensionProperty(name = API_VERSION_NAME, value = API_VERSION),\r
+                @ExtensionProperty(name = LAST_MOD_NAME, value = "Dublin")})})\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
-        })\r
+        @ApiResponse(code = HttpURLConnection.HTTP_UNAUTHORIZED, message = AUTHENTICATION_ERROR_MESSAGE),\r
+        @ApiResponse(code = HttpURLConnection.HTTP_FORBIDDEN, message = AUTHORIZATION_ERROR_MESSAGE),\r
+        @ApiResponse(code = HttpURLConnection.HTTP_NOT_FOUND, message = NOT_FOUND_MESSAGE),\r
+        @ApiResponse(code = HttpURLConnection.HTTP_INTERNAL_ERROR, message = SERVER_ERROR_MESSAGE)})\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
-        return addLoggingHeaders(addVersionControlHeaders(Response.status(Response.Status.OK)), requestId)\r
-            .entity(new PolicyTypeProvider().fetchPolicyTypes(policyTypeId, null)).build();\r
+        @PathParam("policyTypeId") @ApiParam(value = "ID of policy type", required = true) String policyTypeId,\r
+        @HeaderParam(REQUEST_ID_NAME) @ApiParam(REQUEST_ID_PARAM_DESCRIPTION) UUID requestId) {\r
+\r
+        try (var policyTypeProvider = new PolicyTypeProvider()) {\r
+            ToscaServiceTemplate serviceTemplate = policyTypeProvider.fetchPolicyTypes(policyTypeId, null);\r
+            updateApiStatisticsCounter(Target.POLICY_TYPE, Result.SUCCESS, HttpMethod.GET);\r
+            return makeOkResponse(requestId, serviceTemplate);\r
+        } catch (PfModelException | PfModelRuntimeException pfme) {\r
+            LOGGER.warn("GET /policytypes/{}", policyTypeId, pfme);\r
+            updateApiStatisticsCounter(Target.POLICY_TYPE, Result.FAILURE, HttpMethod.GET);\r
+            return makeErrorResponse(requestId, pfme);\r
+        }\r
     }\r
 \r
     /**\r
@@ -282,148 +307,141 @@ public class ApiRestController {
     @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",\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
-            authorizations = @Authorization(value = "basicAuth"),\r
-            tags = { "PolicyType", },\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
+        notes = "Returns a particular version for the specified policy type", response = ToscaServiceTemplate.class,\r
+        responseHeaders = {\r
+            @ResponseHeader(name = VERSION_MINOR_NAME,\r
+                description = VERSION_MINOR_DESCRIPTION,\r
+                response = String.class),\r
+            @ResponseHeader(name = VERSION_PATCH_NAME,\r
+                description = VERSION_PATCH_DESCRIPTION,\r
+                response = String.class),\r
+            @ResponseHeader(name = VERSION_LATEST_NAME, description = VERSION_LATEST_DESCRIPTION,\r
+                response = String.class),\r
+            @ResponseHeader(name = REQUEST_ID_NAME,\r
+                description = REQUEST_ID_HDR_DESCRIPTION, response = UUID.class)},\r
+        authorizations = @Authorization(value = AUTHORIZATION_TYPE), tags = {"PolicyType", },\r
+        extensions = {\r
+            @Extension(name = EXTENSION_NAME, properties = {\r
+                @ExtensionProperty(name = API_VERSION_NAME, value = API_VERSION),\r
+                @ExtensionProperty(name = LAST_MOD_NAME, value = "Dublin")})})\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
-        })\r
+        @ApiResponse(code = HttpURLConnection.HTTP_UNAUTHORIZED, message = AUTHENTICATION_ERROR_MESSAGE),\r
+        @ApiResponse(code = HttpURLConnection.HTTP_FORBIDDEN, message = AUTHORIZATION_ERROR_MESSAGE),\r
+        @ApiResponse(code = HttpURLConnection.HTTP_NOT_FOUND, message = NOT_FOUND_MESSAGE),\r
+        @ApiResponse(code = HttpURLConnection.HTTP_INTERNAL_ERROR, message = SERVER_ERROR_MESSAGE)})\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
-        return addLoggingHeaders(addVersionControlHeaders(Response.status(Response.Status.OK)), requestId)\r
-            .entity(new PolicyTypeProvider().fetchPolicyTypes(policyTypeId, versionId)).build();\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(REQUEST_ID_NAME) @ApiParam(REQUEST_ID_PARAM_DESCRIPTION) UUID requestId) {\r
+\r
+        try (var policyTypeProvider = new PolicyTypeProvider()) {\r
+            ToscaServiceTemplate serviceTemplate = policyTypeProvider.fetchPolicyTypes(policyTypeId, versionId);\r
+            updateApiStatisticsCounter(Target.POLICY_TYPE, Result.SUCCESS, HttpMethod.GET);\r
+            return makeOkResponse(requestId, serviceTemplate);\r
+        } catch (PfModelException | PfModelRuntimeException pfme) {\r
+            LOGGER.warn("GET /policytypes/{}/versions/{}", policyTypeId, versionId, pfme);\r
+            updateApiStatisticsCounter(Target.POLICY_TYPE, Result.FAILURE, HttpMethod.GET);\r
+            return makeErrorResponse(requestId, pfme);\r
+        }\r
     }\r
 \r
     /**\r
-     * Creates a new policy type.\r
+     * Retrieves latest version of a particular policy type.\r
      *\r
-     * @param body the body of policy type following TOSCA definition\r
+     * @param policyTypeId the ID of specified policy type\r
      *\r
      * @return the Response object containing the results of the API operation\r
      */\r
-    @POST\r
-    @Path("/policytypes")\r
-    @ApiOperation(value = "Create a new policy type",\r
-            notes = "Client should provide TOSCA body of the new policy type",\r
-            authorizations = @Authorization(value = "basicAuth"),\r
-            tags = { "PolicyType", },\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
+    @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 = VERSION_MINOR_NAME,\r
+                description = VERSION_MINOR_DESCRIPTION,\r
+                response = String.class),\r
+            @ResponseHeader(name = VERSION_PATCH_NAME,\r
+                description = VERSION_PATCH_DESCRIPTION,\r
+                response = String.class),\r
+            @ResponseHeader(name = VERSION_LATEST_NAME, description = VERSION_LATEST_DESCRIPTION,\r
+                response = String.class),\r
+            @ResponseHeader(name = REQUEST_ID_NAME,\r
+                description = REQUEST_ID_HDR_DESCRIPTION, response = UUID.class)},\r
+        authorizations = @Authorization(value = AUTHORIZATION_TYPE), tags = {"PolicyType", },\r
+        extensions = {\r
+            @Extension(name = EXTENSION_NAME, properties = {\r
+                @ExtensionProperty(name = API_VERSION_NAME, value = API_VERSION),\r
+                @ExtensionProperty(name = LAST_MOD_NAME, value = "Dublin")})})\r
     @ApiResponses(value = {\r
-            @ApiResponse(code = 201, message = "Resource successfully created",\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
-            @ApiResponse(code = 400, message = "Invalid Body"),\r
-            @ApiResponse(code = 401, message = "Authentication Error"),\r
-            @ApiResponse(code = 403, message = "Authorization Error"),\r
-            @ApiResponse(code = 500, message = "Internal Server Error")\r
-        })\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
-        return addLoggingHeaders(addVersionControlHeaders(Response.status(Response.Status.OK)), requestId)\r
-            .entity(new PolicyTypeProvider().createPolicyType(body)).build();\r
+        @ApiResponse(code = HttpURLConnection.HTTP_UNAUTHORIZED, message = AUTHENTICATION_ERROR_MESSAGE),\r
+        @ApiResponse(code = HttpURLConnection.HTTP_FORBIDDEN, message = AUTHORIZATION_ERROR_MESSAGE),\r
+        @ApiResponse(code = HttpURLConnection.HTTP_NOT_FOUND, message = NOT_FOUND_MESSAGE),\r
+        @ApiResponse(code = HttpURLConnection.HTTP_INTERNAL_ERROR, message = SERVER_ERROR_MESSAGE)})\r
+    public Response getLatestVersionOfPolicyType(\r
+        @PathParam("policyTypeId") @ApiParam(value = "ID of policy type", required = true) String policyTypeId,\r
+        @HeaderParam(REQUEST_ID_NAME) @ApiParam(REQUEST_ID_PARAM_DESCRIPTION) UUID requestId) {\r
+\r
+        try (var policyTypeProvider = new PolicyTypeProvider()) {\r
+            ToscaServiceTemplate serviceTemplate = policyTypeProvider.fetchLatestPolicyTypes(policyTypeId);\r
+            updateApiStatisticsCounter(Target.POLICY_TYPE, Result.SUCCESS, HttpMethod.GET);\r
+            return makeOkResponse(requestId, serviceTemplate);\r
+        } catch (PfModelException | PfModelRuntimeException pfme) {\r
+            LOGGER.warn("GET /policytypes/{}/versions/latest", policyTypeId, pfme);\r
+            updateApiStatisticsCounter(Target.POLICY_TYPE, Result.FAILURE, HttpMethod.GET);\r
+            return makeErrorResponse(requestId, pfme);\r
+        }\r
     }\r
 \r
     /**\r
-     * Deletes all versions of a particular policy type.\r
+     * Creates a new policy type.\r
      *\r
-     * @param policyTypeId the ID of specified policy type\r
+     * @param body the body of policy type following TOSCA definition\r
      *\r
      * @return the Response object containing the results of the API operation\r
      */\r
-    @DELETE\r
-    @Path("/policytypes/{policyTypeId}")\r
-    @ApiOperation(value = "Delete all versions 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"),\r
-            tags = { "PolicyType", },\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
+    @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 = AUTHORIZATION_TYPE), tags = {"PolicyType", },\r
+        response = ToscaServiceTemplate.class,\r
+        responseHeaders = {\r
+            @ResponseHeader(name = VERSION_MINOR_NAME,\r
+                description = VERSION_MINOR_DESCRIPTION,\r
+                response = String.class),\r
+            @ResponseHeader(name = VERSION_PATCH_NAME,\r
+                description = VERSION_PATCH_DESCRIPTION,\r
+                response = String.class),\r
+            @ResponseHeader(name = VERSION_LATEST_NAME, description = VERSION_LATEST_DESCRIPTION,\r
+                response = String.class),\r
+            @ResponseHeader(name = REQUEST_ID_NAME,\r
+                description = REQUEST_ID_HDR_DESCRIPTION, response = UUID.class)},\r
+        extensions = {\r
+            @Extension(name = EXTENSION_NAME, properties = {\r
+                @ExtensionProperty(name = API_VERSION_NAME, value = API_VERSION),\r
+                @ExtensionProperty(name = LAST_MOD_NAME, value = "Dublin")})})\r
     @ApiResponses(value = {\r
-            @ApiResponse(code = 204, message = "Resources successfully deleted, no content returned",\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
-            @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
-        })\r
-    public Response deleteAllVersionsOfPolicyType(\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
-        return addLoggingHeaders(addVersionControlHeaders(Response.status(Response.Status.OK)), requestId)\r
-            .entity(new PolicyTypeProvider().deletePolicyTypes(policyTypeId, null)).build();\r
+        @ApiResponse(code = HttpURLConnection.HTTP_BAD_REQUEST, message = INVALID_BODY_MESSAGE),\r
+        @ApiResponse(code = HttpURLConnection.HTTP_UNAUTHORIZED, message = AUTHENTICATION_ERROR_MESSAGE),\r
+        @ApiResponse(code = HttpURLConnection.HTTP_FORBIDDEN, message = AUTHORIZATION_ERROR_MESSAGE),\r
+        @ApiResponse(code = HttpURLConnection.HTTP_NOT_ACCEPTABLE, message = INVALID_PAYLOAD_MESSAGE),\r
+        @ApiResponse(code = HttpURLConnection.HTTP_INTERNAL_ERROR, message = SERVER_ERROR_MESSAGE)})\r
+    public Response createPolicyType(\r
+        @ApiParam(value = "Entity body of policy type", required = true) ToscaServiceTemplate body,\r
+        @HeaderParam(REQUEST_ID_NAME) @ApiParam(REQUEST_ID_PARAM_DESCRIPTION) UUID requestId) {\r
+\r
+        if (NetLoggerUtil.getNetworkLogger().isInfoEnabled()) {\r
+            NetLoggerUtil.log(EventType.IN, CommInfrastructure.REST, "/policytypes", toJson(body));\r
+        }\r
+\r
+        try (var policyTypeProvider = new PolicyTypeProvider()) {\r
+            ToscaServiceTemplate serviceTemplate = policyTypeProvider.createPolicyType(body);\r
+            updateApiStatisticsCounter(Target.POLICY_TYPE, Result.SUCCESS, HttpMethod.POST);\r
+            return makeOkResponse(requestId, serviceTemplate);\r
+        } catch (PfModelException | PfModelRuntimeException pfme) {\r
+            LOGGER.warn("POST /policytypes", pfme);\r
+            updateApiStatisticsCounter(Target.POLICY_TYPE, Result.FAILURE, HttpMethod.POST);\r
+            return makeErrorResponse(requestId, pfme);\r
+        }\r
     }\r
 \r
     /**\r
@@ -437,48 +455,46 @@ public class ApiRestController {
     @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"),\r
-            tags = { "PolicyType", },\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
+        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 = AUTHORIZATION_TYPE), tags = {"PolicyType", },\r
+        response = ToscaServiceTemplate.class,\r
+        responseHeaders = {\r
+            @ResponseHeader(name = VERSION_MINOR_NAME,\r
+                description = VERSION_MINOR_DESCRIPTION,\r
+                response = String.class),\r
+            @ResponseHeader(name = VERSION_PATCH_NAME,\r
+                description = VERSION_PATCH_DESCRIPTION,\r
+                response = String.class),\r
+            @ResponseHeader(name = VERSION_LATEST_NAME, description = VERSION_LATEST_DESCRIPTION,\r
+                response = String.class),\r
+            @ResponseHeader(name = REQUEST_ID_NAME,\r
+                description = REQUEST_ID_HDR_DESCRIPTION, response = UUID.class)},\r
+        extensions = {\r
+            @Extension(name = EXTENSION_NAME, properties = {\r
+                @ExtensionProperty(name = API_VERSION_NAME, value = API_VERSION),\r
+                @ExtensionProperty(name = LAST_MOD_NAME, value = "Dublin")})})\r
     @ApiResponses(value = {\r
-            @ApiResponse(code = 204, message = "Resource successfully deleted, no content returned",\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
-            @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
-        })\r
+        @ApiResponse(code = HttpURLConnection.HTTP_UNAUTHORIZED, message = AUTHENTICATION_ERROR_MESSAGE),\r
+        @ApiResponse(code = HttpURLConnection.HTTP_FORBIDDEN, message = AUTHORIZATION_ERROR_MESSAGE),\r
+        @ApiResponse(code = HttpURLConnection.HTTP_NOT_FOUND, message = NOT_FOUND_MESSAGE),\r
+        @ApiResponse(code = HttpURLConnection.HTTP_CONFLICT, message = HTTP_CONFLICT_MESSAGE),\r
+        @ApiResponse(code = HttpURLConnection.HTTP_INTERNAL_ERROR, message = SERVER_ERROR_MESSAGE)})\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
-        return addLoggingHeaders(addVersionControlHeaders(Response.status(Response.Status.OK)), requestId)\r
-            .entity(new PolicyTypeProvider().deletePolicyTypes(policyTypeId, versionId)).build();\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(REQUEST_ID_NAME) @ApiParam(REQUEST_ID_PARAM_DESCRIPTION) UUID requestId) {\r
+\r
+        try (var policyTypeProvider = new PolicyTypeProvider()) {\r
+            ToscaServiceTemplate serviceTemplate = policyTypeProvider.deletePolicyType(policyTypeId, versionId);\r
+            updateApiStatisticsCounter(Target.POLICY_TYPE, Result.SUCCESS, HttpMethod.DELETE);\r
+            return makeOkResponse(requestId, serviceTemplate);\r
+        } catch (PfModelException | PfModelRuntimeException pfme) {\r
+            LOGGER.warn("DELETE /policytypes/{}/versions/{}", policyTypeId, versionId, pfme);\r
+            updateApiStatisticsCounter(Target.POLICY_TYPE, Result.FAILURE, HttpMethod.DELETE);\r
+            return makeErrorResponse(requestId, pfme);\r
+        }\r
     }\r
 \r
     /**\r
@@ -491,47 +507,54 @@ public class ApiRestController {
      */\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",\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
-            authorizations = @Authorization(value = "basicAuth"),\r
-            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
+    @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 = VERSION_MINOR_NAME,\r
+                description = VERSION_MINOR_DESCRIPTION,\r
+                response = String.class),\r
+            @ResponseHeader(name = VERSION_PATCH_NAME,\r
+                description = VERSION_PATCH_DESCRIPTION,\r
+                response = String.class),\r
+            @ResponseHeader(name = VERSION_LATEST_NAME, description = VERSION_LATEST_DESCRIPTION,\r
+                response = String.class),\r
+            @ResponseHeader(name = REQUEST_ID_NAME,\r
+                description = REQUEST_ID_HDR_DESCRIPTION, response = UUID.class)},\r
+        authorizations = @Authorization(value = AUTHORIZATION_TYPE), tags = {"Policy,"},\r
+        extensions = {\r
+            @Extension(name = EXTENSION_NAME, properties = {\r
+                @ExtensionProperty(name = API_VERSION_NAME, value = API_VERSION),\r
+                @ExtensionProperty(name = LAST_MOD_NAME, 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
-        })\r
+        @ApiResponse(code = HttpURLConnection.HTTP_UNAUTHORIZED, message = AUTHENTICATION_ERROR_MESSAGE),\r
+        @ApiResponse(code = HttpURLConnection.HTTP_FORBIDDEN, message = AUTHORIZATION_ERROR_MESSAGE),\r
+        @ApiResponse(code = HttpURLConnection.HTTP_NOT_FOUND, message = NOT_FOUND_MESSAGE),\r
+        @ApiResponse(code = HttpURLConnection.HTTP_INTERNAL_ERROR, message = SERVER_ERROR_MESSAGE)\r
+    })\r
     public Response getAllPolicies(\r
-            @PathParam("policyTypeId") @ApiParam(value = "ID of policy type", required = true) String policyTypeId,\r
-            @PathParam("policyTypeVersion")\r
-                @ApiParam(value = "Version of policy type", required = true) String policyTypeVersion,\r
-            @HeaderParam("X-ONAP-RequestID") @ApiParam("RequestID for http transaction") UUID requestId) {\r
-        return addLoggingHeaders(addVersionControlHeaders(Response.status(Response.Status.OK)), requestId)\r
-            .entity(new PolicyProvider().fetchPolicies(policyTypeId, policyTypeVersion, null, null)).build();\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(REQUEST_ID_NAME) @ApiParam(REQUEST_ID_PARAM_DESCRIPTION) 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 (var policyProvider = new PolicyProvider()) {\r
+            ToscaServiceTemplate serviceTemplate =\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
+            LOGGER.warn("GET /policytypes/{}/versions/{}/policies", policyTypeId, policyTypeVersion, pfme);\r
+            updateApiStatisticsCounter(Target.POLICY, Result.FAILURE, HttpMethod.GET);\r
+            return makeErrorResponse(requestId, pfme);\r
+        }\r
     }\r
 \r
     /**\r
@@ -546,47 +569,51 @@ public class ApiRestController {
     @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",\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
-            authorizations = @Authorization(value = "basicAuth"),\r
-            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
+        notes = "Returns a list of all version details of the specified policy", response = ToscaServiceTemplate.class,\r
+        responseHeaders = {\r
+            @ResponseHeader(name = VERSION_MINOR_NAME,\r
+                description = VERSION_MINOR_DESCRIPTION,\r
+                response = String.class),\r
+            @ResponseHeader(name = VERSION_PATCH_NAME,\r
+                description = VERSION_PATCH_DESCRIPTION,\r
+                response = String.class),\r
+            @ResponseHeader(name = VERSION_LATEST_NAME, description = VERSION_LATEST_DESCRIPTION,\r
+                response = String.class),\r
+            @ResponseHeader(name = REQUEST_ID_NAME,\r
+                description = REQUEST_ID_HDR_DESCRIPTION, response = UUID.class)},\r
+        authorizations = @Authorization(value = AUTHORIZATION_TYPE), tags = {"Policy", },\r
+        extensions = {\r
+            @Extension(name = EXTENSION_NAME, properties = {\r
+                @ExtensionProperty(name = API_VERSION_NAME, value = API_VERSION),\r
+                @ExtensionProperty(name = LAST_MOD_NAME, 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
-        })\r
+        @ApiResponse(code = HttpURLConnection.HTTP_UNAUTHORIZED, message = AUTHENTICATION_ERROR_MESSAGE),\r
+        @ApiResponse(code = HttpURLConnection.HTTP_FORBIDDEN, message = AUTHORIZATION_ERROR_MESSAGE),\r
+        @ApiResponse(code = HttpURLConnection.HTTP_NOT_FOUND, message = NOT_FOUND_MESSAGE),\r
+        @ApiResponse(code = HttpURLConnection.HTTP_INTERNAL_ERROR, message = SERVER_ERROR_MESSAGE)\r
+    })\r
     public Response getAllVersionsOfPolicy(\r
-            @PathParam("policyTypeId") @ApiParam(value = "ID of policy type", required = true) String policyTypeId,\r
-            @PathParam("policyTypeVersion")\r
-                @ApiParam(value = "Version of policy type", 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
-        return addLoggingHeaders(addVersionControlHeaders(Response.status(Response.Status.OK)), requestId)\r
-            .entity(new PolicyProvider().fetchPolicies(policyTypeId, policyTypeVersion, policyId, null)).build();\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(REQUEST_ID_NAME) @ApiParam(REQUEST_ID_PARAM_DESCRIPTION) 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 (var policyProvider = new PolicyProvider()) {\r
+            ToscaServiceTemplate serviceTemplate =\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
+            LOGGER.warn("/policytypes/{}/versions/{}/policies/{}", policyTypeId, policyTypeVersion, policyId, pfme);\r
+            updateApiStatisticsCounter(Target.POLICY, Result.FAILURE, HttpMethod.GET);\r
+            return makeErrorResponse(requestId, pfme);\r
+        }\r
     }\r
 \r
     /**\r
@@ -602,53 +629,58 @@ public class ApiRestController {
     @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",\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
-            authorizations = @Authorization(value = "basicAuth"),\r
-            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
+        notes = "Returns a particular version of specified policy created for the specified policy type version",\r
+        response = ToscaServiceTemplate.class,\r
+        responseHeaders = {\r
+            @ResponseHeader(name = VERSION_MINOR_NAME,\r
+                description = VERSION_MINOR_DESCRIPTION,\r
+                response = String.class),\r
+            @ResponseHeader(name = VERSION_PATCH_NAME,\r
+                description = VERSION_PATCH_DESCRIPTION,\r
+                response = String.class),\r
+            @ResponseHeader(name = VERSION_LATEST_NAME, description = VERSION_LATEST_DESCRIPTION,\r
+                response = String.class),\r
+            @ResponseHeader(name = REQUEST_ID_NAME,\r
+                description = REQUEST_ID_HDR_DESCRIPTION, response = UUID.class)},\r
+        authorizations = @Authorization(value = AUTHORIZATION_TYPE), tags = {"Policy", },\r
+        extensions = {\r
+            @Extension(name = EXTENSION_NAME, properties = {\r
+                @ExtensionProperty(name = API_VERSION_NAME, value = API_VERSION),\r
+                @ExtensionProperty(name = LAST_MOD_NAME, 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
-        })\r
+        @ApiResponse(code = HttpURLConnection.HTTP_UNAUTHORIZED, message = AUTHENTICATION_ERROR_MESSAGE),\r
+        @ApiResponse(code = HttpURLConnection.HTTP_FORBIDDEN, message = AUTHORIZATION_ERROR_MESSAGE),\r
+        @ApiResponse(code = HttpURLConnection.HTTP_NOT_FOUND, message = NOT_FOUND_MESSAGE),\r
+        @ApiResponse(code = HttpURLConnection.HTTP_INTERNAL_ERROR, message = SERVER_ERROR_MESSAGE)\r
+    })\r
     public Response getSpecificVersionOfPolicy(\r
-            @PathParam("policyTypeId") @ApiParam(value = "ID of policy type", required = true) String policyTypeId,\r
-            @PathParam("policyTypeVersion")\r
-                @ApiParam(value = "Version of policy type", 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
-        return addLoggingHeaders(addVersionControlHeaders(Response.status(Response.Status.OK)), requestId)\r
-            .entity(new PolicyProvider().fetchPolicies(policyTypeId, policyTypeVersion,\r
-                                                       policyId, policyVersion)).build();\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(REQUEST_ID_NAME) @ApiParam(REQUEST_ID_PARAM_DESCRIPTION) 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 (var policyProvider = new PolicyProvider()) {\r
+            ToscaServiceTemplate serviceTemplate =\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.warn("GET /policytypes/{}/versions/{}/policies/{}/versions/{}", policyTypeId, policyTypeVersion,\r
+                policyId, policyVersion, pfme);\r
+            updateApiStatisticsCounter(Target.POLICY, Result.FAILURE, HttpMethod.GET);\r
+            return makeErrorResponse(requestId, pfme);\r
+        }\r
     }\r
 \r
     /**\r
-     * Retrieves either latest or deployed version of a particular policy depending on query parameter.\r
+     * Retrieves the latest version of a particular policy.\r
      *\r
      * @param policyTypeId the ID of specified policy type\r
      * @param policyTypeVersion the version of specified policy type\r
@@ -657,51 +689,50 @@ public class ApiRestController {
      * @return the Response object containing the results of the API operation\r
      */\r
     @GET\r
-    @Path("/policytypes/{policyTypeId}/versions/{policyTypeVersion}/policies/{policyId}/versions")\r
-    @ApiOperation(value = "Retrieve either latest or deployed version of a particular policy depending on query param",\r
-            notes = "Returns either latest or deployed version of specified policy depending on query param",\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
-            authorizations = @Authorization(value = "basicAuth"),\r
-            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
+    @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 = VERSION_MINOR_NAME,\r
+                description = VERSION_MINOR_DESCRIPTION,\r
+                response = String.class),\r
+            @ResponseHeader(name = VERSION_PATCH_NAME,\r
+                description = VERSION_PATCH_DESCRIPTION,\r
+                response = String.class),\r
+            @ResponseHeader(name = VERSION_LATEST_NAME, description = VERSION_LATEST_DESCRIPTION,\r
+                response = String.class),\r
+            @ResponseHeader(name = REQUEST_ID_NAME,\r
+                description = REQUEST_ID_HDR_DESCRIPTION, response = UUID.class)},\r
+        authorizations = @Authorization(value = AUTHORIZATION_TYPE), tags = {"Policy", },\r
+        extensions = {\r
+            @Extension(name = EXTENSION_NAME, properties = {\r
+                @ExtensionProperty(name = API_VERSION_NAME, value = API_VERSION),\r
+                @ExtensionProperty(name = LAST_MOD_NAME, value = "Dublin")})})\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
-        })\r
-    public Response getEitherLatestOrDeployedVersionOfPolicy(\r
-            @PathParam("policyTypeId") @ApiParam(value = "ID of policy type", required = true) String policyTypeId,\r
-            @PathParam("policyTypeVersion")\r
-                @ApiParam(value = "Version of policy type", required = true) String policyTypeVersion,\r
-            @PathParam("policyId") @ApiParam(value = "ID of policy", required = true) String policyId,\r
-            @QueryParam("type")\r
-                @ApiParam(value = "Version that can only be 'latest' or 'deployed'", required = true) String type,\r
-            @HeaderParam("X-ONAP-RequestID") @ApiParam("RequestID for http transaction") UUID requestId) {\r
-        return addLoggingHeaders(addVersionControlHeaders(Response.status(Response.Status.OK)), requestId)\r
-            .entity(new PolicyProvider().fetchPolicies(policyTypeId, policyTypeVersion, policyId, type)).build();\r
+        @ApiResponse(code = HttpURLConnection.HTTP_UNAUTHORIZED, message = AUTHENTICATION_ERROR_MESSAGE),\r
+        @ApiResponse(code = HttpURLConnection.HTTP_FORBIDDEN, message = AUTHORIZATION_ERROR_MESSAGE),\r
+        @ApiResponse(code = HttpURLConnection.HTTP_NOT_FOUND, message = NOT_FOUND_MESSAGE),\r
+        @ApiResponse(code = HttpURLConnection.HTTP_INTERNAL_ERROR, message = SERVER_ERROR_MESSAGE)})\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(REQUEST_ID_NAME) @ApiParam(REQUEST_ID_PARAM_DESCRIPTION) 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 (var policyProvider = new PolicyProvider()) {\r
+            ToscaServiceTemplate serviceTemplate =\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.warn("GET /policytypes/{}/versions/{}/policies/{}/versions/latest", policyTypeId, policyTypeVersion,\r
+                policyId, pfme);\r
+            updateApiStatisticsCounter(Target.POLICY, Result.FAILURE, HttpMethod.GET);\r
+            return makeErrorResponse(requestId, pfme);\r
+        }\r
     }\r
 \r
     /**\r
@@ -715,177 +746,462 @@ public class ApiRestController {
      */\r
     @POST\r
     @Path("/policytypes/{policyTypeId}/versions/{policyTypeVersion}/policies")\r
-    @Consumes("application/json")\r
-    @Produces("application/json")\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"),\r
-            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
+        notes = "Client should provide TOSCA body of the new policy",\r
+        authorizations = @Authorization(value = AUTHORIZATION_TYPE), tags = {"Policy", },\r
+            response = ToscaServiceTemplate.class,\r
+        responseHeaders = {\r
+            @ResponseHeader(name = VERSION_MINOR_NAME,\r
+                description = VERSION_MINOR_DESCRIPTION,\r
+                response = String.class),\r
+            @ResponseHeader(name = VERSION_PATCH_NAME,\r
+                description = VERSION_PATCH_DESCRIPTION,\r
+                response = String.class),\r
+            @ResponseHeader(name = VERSION_LATEST_NAME, description = VERSION_LATEST_DESCRIPTION,\r
+                response = String.class),\r
+            @ResponseHeader(name = REQUEST_ID_NAME,\r
+                description = REQUEST_ID_HDR_DESCRIPTION, response = UUID.class)},\r
+        extensions = {\r
+            @Extension(name = EXTENSION_NAME, properties = {\r
+                @ExtensionProperty(name = API_VERSION_NAME, value = API_VERSION),\r
+                @ExtensionProperty(name = LAST_MOD_NAME, value = "Dublin")})})\r
     @ApiResponses(value = {\r
-            @ApiResponse(code = 201, message = "Resource successfully created",\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
-            @ApiResponse(code = 400, message = "Invalid Body"),\r
-            @ApiResponse(code = 401, message = "Authentication Error"),\r
-            @ApiResponse(code = 403, message = "Authorization Error"),\r
-            @ApiResponse(code = 404, message = "Resource Not Found"),\r
-            @ApiResponse(code = 500, message = "Internal Server Error")\r
-        })\r
+        @ApiResponse(code = HttpURLConnection.HTTP_BAD_REQUEST, message = INVALID_BODY_MESSAGE),\r
+        @ApiResponse(code = HttpURLConnection.HTTP_UNAUTHORIZED, message = AUTHENTICATION_ERROR_MESSAGE),\r
+        @ApiResponse(code = HttpURLConnection.HTTP_FORBIDDEN, message = AUTHORIZATION_ERROR_MESSAGE),\r
+        @ApiResponse(code = HttpURLConnection.HTTP_NOT_FOUND, message = NOT_FOUND_MESSAGE),\r
+        @ApiResponse(code = HttpURLConnection.HTTP_NOT_ACCEPTABLE, message = INVALID_PAYLOAD_MESSAGE),\r
+        @ApiResponse(code = HttpURLConnection.HTTP_INTERNAL_ERROR, message = SERVER_ERROR_MESSAGE)})\r
     public Response createPolicy(\r
-            @PathParam("policyTypeId") @ApiParam(value = "ID of policy type", required = true) String policyTypeId,\r
-            @PathParam("policyTypeVersion")\r
-                @ApiParam(value = "Version of policy type", 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
-        return addLoggingHeaders(addVersionControlHeaders(Response.status(Response.Status.OK)), requestId)\r
-            .entity(new PolicyProvider().createPolicy(policyTypeId, policyTypeVersion, body)).build();\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(REQUEST_ID_NAME) @ApiParam(REQUEST_ID_PARAM_DESCRIPTION) 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
+        }\r
+\r
+        try (var policyProvider = new PolicyProvider()) {\r
+            ToscaServiceTemplate serviceTemplate = policyProvider.createPolicy(policyTypeId, policyTypeVersion, body);\r
+            updateApiStatisticsCounter(Target.POLICY, Result.SUCCESS, HttpMethod.POST);\r
+            return makeOkResponse(requestId, serviceTemplate);\r
+        } catch (PfModelException | PfModelRuntimeException pfme) {\r
+            LOGGER.warn("POST /policytypes/{}/versions/{}/policies", policyTypeId, policyTypeVersion, pfme);\r
+            updateApiStatisticsCounter(Target.POLICY, Result.FAILURE, HttpMethod.POST);\r
+            return makeErrorResponse(requestId, pfme);\r
+        }\r
     }\r
 \r
     /**\r
-     * Deletes all versions of a particular policy.\r
+     * Deletes the specified version of a particular policy.\r
      *\r
      * @param policyTypeId the ID of specified policy type\r
      * @param policyTypeVersion the version of specified policy type\r
      * @param policyId the ID of specified policy\r
+     * @param policyVersion the version of specified policy\r
      *\r
      * @return the Response object containing the results of the API operation\r
      */\r
     @DELETE\r
-    @Path("/policytypes/{policyTypeId}/versions/{policyTypeVersion}/policies/{policyId}")\r
-    @ApiOperation(value = "Delete all versions of a policy",\r
-            notes = "Rule: the version that has been deployed in PDP group(s) cannot be deleted",\r
-            authorizations = @Authorization(value = "basicAuth"),\r
-            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
+    @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 = AUTHORIZATION_TYPE), tags = {"Policy", },\r
+        response = ToscaServiceTemplate.class,\r
+        responseHeaders = {\r
+            @ResponseHeader(name = VERSION_MINOR_NAME,\r
+                description = VERSION_MINOR_DESCRIPTION,\r
+                response = String.class),\r
+            @ResponseHeader(name = VERSION_PATCH_NAME,\r
+                description = VERSION_PATCH_DESCRIPTION,\r
+                response = String.class),\r
+            @ResponseHeader(name = VERSION_LATEST_NAME, description = VERSION_LATEST_DESCRIPTION,\r
+                response = String.class),\r
+            @ResponseHeader(name = REQUEST_ID_NAME,\r
+                description = REQUEST_ID_HDR_DESCRIPTION, response = UUID.class)},\r
+        extensions = {\r
+            @Extension(name = EXTENSION_NAME, properties = {\r
+                @ExtensionProperty(name = API_VERSION_NAME, value = API_VERSION),\r
+                @ExtensionProperty(name = LAST_MOD_NAME, value = "Dublin")})})\r
+    @ApiResponses(value = {\r
+        @ApiResponse(code = HttpURLConnection.HTTP_UNAUTHORIZED, message = AUTHENTICATION_ERROR_MESSAGE),\r
+        @ApiResponse(code = HttpURLConnection.HTTP_FORBIDDEN, message = AUTHORIZATION_ERROR_MESSAGE),\r
+        @ApiResponse(code = HttpURLConnection.HTTP_NOT_FOUND, message = NOT_FOUND_MESSAGE),\r
+        @ApiResponse(code = HttpURLConnection.HTTP_CONFLICT, message = HTTP_CONFLICT_MESSAGE),\r
+        @ApiResponse(code = HttpURLConnection.HTTP_INTERNAL_ERROR, message = SERVER_ERROR_MESSAGE)})\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(REQUEST_ID_NAME) @ApiParam(REQUEST_ID_PARAM_DESCRIPTION) UUID requestId) {\r
+\r
+        try (var policyProvider = new PolicyProvider()) {\r
+            ToscaServiceTemplate serviceTemplate =\r
+                policyProvider.deletePolicy(policyTypeId, policyTypeVersion, policyId, policyVersion);\r
+            updateApiStatisticsCounter(Target.POLICY, Result.SUCCESS, HttpMethod.DELETE);\r
+            return makeOkResponse(requestId, serviceTemplate);\r
+        } catch (PfModelException | PfModelRuntimeException pfme) {\r
+            LOGGER.warn("DELETE /policytypes/{}/versions/{}/policies/{}/versions/{}", policyTypeId, policyTypeVersion,\r
+                policyId, policyVersion, pfme);\r
+            updateApiStatisticsCounter(Target.POLICY, Result.FAILURE, HttpMethod.DELETE);\r
+            return makeErrorResponse(requestId, pfme);\r
+        }\r
+    }\r
+\r
+    /**\r
+     * Retrieves all the available policies.\r
+     *\r
+     * @return the Response object containing the results of the API operation\r
+     */\r
+    @GET\r
+    @Path("/policies")\r
+    @ApiOperation(value = "Retrieve all versions of available policies",\r
+        notes = "Returns all version of available policies",\r
+        response = ToscaServiceTemplate.class,\r
+        responseHeaders = {\r
+            @ResponseHeader(name = VERSION_MINOR_NAME,\r
+                description = VERSION_MINOR_DESCRIPTION,\r
+                response = String.class),\r
+            @ResponseHeader(name = VERSION_PATCH_NAME,\r
+                description = VERSION_PATCH_DESCRIPTION,\r
+                response = String.class),\r
+            @ResponseHeader(name = VERSION_LATEST_NAME, description = VERSION_LATEST_DESCRIPTION,\r
+                response = String.class),\r
+            @ResponseHeader(name = REQUEST_ID_NAME,\r
+                description = REQUEST_ID_HDR_DESCRIPTION, response = UUID.class)},\r
+        authorizations = @Authorization(value = AUTHORIZATION_TYPE), tags = {"Policy", },\r
+        extensions = {\r
+            @Extension(name = EXTENSION_NAME, properties = {\r
+                @ExtensionProperty(name = API_VERSION_NAME, value = API_VERSION),\r
+                @ExtensionProperty(name = LAST_MOD_NAME, value = "Guilin")\r
+            })\r
+        }\r
+    )\r
+    @ApiResponses(value = {\r
+        @ApiResponse(code = HttpURLConnection.HTTP_UNAUTHORIZED, message = AUTHENTICATION_ERROR_MESSAGE),\r
+        @ApiResponse(code = HttpURLConnection.HTTP_FORBIDDEN, message = AUTHORIZATION_ERROR_MESSAGE),\r
+        @ApiResponse(code = HttpURLConnection.HTTP_NOT_FOUND, message = NOT_FOUND_MESSAGE),\r
+        @ApiResponse(code = HttpURLConnection.HTTP_INTERNAL_ERROR, message = SERVER_ERROR_MESSAGE)\r
+    })\r
+    public Response getPolicies(\r
+        @HeaderParam(REQUEST_ID_NAME) @ApiParam(REQUEST_ID_PARAM_DESCRIPTION) 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 (var policyProvider = new PolicyProvider()) {\r
+            ToscaServiceTemplate serviceTemplate =\r
+                policyProvider.fetchPolicies(null, null, null, null, mode);\r
+            updateApiStatisticsCounter(Target.POLICY, Result.SUCCESS, HttpMethod.GET);\r
+            return makeOkResponse(requestId, serviceTemplate);\r
+        } catch (PfModelException | PfModelRuntimeException pfme) {\r
+            LOGGER.warn("GET /policies/ --", pfme);\r
+            updateApiStatisticsCounter(Target.POLICY, Result.FAILURE, HttpMethod.GET);\r
+            if (pfme.getErrorResponse().getResponseCode().equals(Status.NOT_FOUND)) {\r
+                pfme.getErrorResponse().setErrorMessage(ERROR_MESSAGE_NO_POLICIES_FOUND);\r
+                pfme.getErrorResponse().setErrorDetails(List.of(ERROR_MESSAGE_NO_POLICIES_FOUND));\r
+            }\r
+            return makeErrorResponse(requestId, pfme);\r
+        }\r
+    }\r
+\r
+    /**\r
+     * Retrieves the specified version of a particular policy.\r
+     *\r
+     * @param policyId the Name of specified policy\r
+     * @param policyVersion the version of specified policy\r
+     *\r
+     * @return the Response object containing the results of the API operation\r
+     */\r
+    @GET\r
+    @Path("/policies/{policyId}/versions/{policyVersion}")\r
+    @ApiOperation(value = "Retrieve specific version of a specified policy",\r
+        notes = "Returns a particular version of specified policy",\r
+        response = ToscaServiceTemplate.class,\r
+        responseHeaders = {\r
+            @ResponseHeader(name = VERSION_MINOR_NAME,\r
+                description = VERSION_MINOR_DESCRIPTION,\r
+                response = String.class),\r
+            @ResponseHeader(name = VERSION_PATCH_NAME,\r
+                description = VERSION_PATCH_DESCRIPTION,\r
+                response = String.class),\r
+            @ResponseHeader(name = VERSION_LATEST_NAME, description = VERSION_LATEST_DESCRIPTION,\r
+                response = String.class),\r
+            @ResponseHeader(name = REQUEST_ID_NAME,\r
+                description = REQUEST_ID_HDR_DESCRIPTION, response = UUID.class)},\r
+        authorizations = @Authorization(value = AUTHORIZATION_TYPE), tags = {"Policy", },\r
+        extensions = {\r
+            @Extension(name = EXTENSION_NAME, properties = {\r
+                @ExtensionProperty(name = API_VERSION_NAME, value = API_VERSION),\r
+                @ExtensionProperty(name = LAST_MOD_NAME, value = "Guilin")\r
             })\r
+        }\r
+    )\r
     @ApiResponses(value = {\r
-            @ApiResponse(code = 204, message = "Resources successfully deleted, no content returned",\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
-            @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
-        })\r
-    public Response deleteAllVersionsOfPolicy(\r
-            @PathParam("policyTypeId") @ApiParam(value = "ID of policy type", required = true) String policyTypeId,\r
-            @PathParam("policyTypeVersion")\r
-                @ApiParam(value = "Version of policy type", 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
-        return addLoggingHeaders(addVersionControlHeaders(Response.status(Response.Status.OK)), requestId)\r
-            .entity(new PolicyProvider().deletePolicies(policyTypeId, policyTypeVersion, policyId, null)).build();\r
+        @ApiResponse(code = HttpURLConnection.HTTP_UNAUTHORIZED, message = AUTHENTICATION_ERROR_MESSAGE),\r
+        @ApiResponse(code = HttpURLConnection.HTTP_FORBIDDEN, message = AUTHORIZATION_ERROR_MESSAGE),\r
+        @ApiResponse(code = HttpURLConnection.HTTP_NOT_FOUND, message = NOT_FOUND_MESSAGE),\r
+        @ApiResponse(code = HttpURLConnection.HTTP_INTERNAL_ERROR, message = SERVER_ERROR_MESSAGE)\r
+    })\r
+    public Response getSpecificPolicy(\r
+        @PathParam("policyId") @ApiParam(value = "Name of policy", required = true) String policyId,\r
+        @PathParam("policyVersion") @ApiParam(value = "Version of policy", required = true) String policyVersion,\r
+        @HeaderParam(REQUEST_ID_NAME) @ApiParam(REQUEST_ID_PARAM_DESCRIPTION) 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 (var policyProvider = new PolicyProvider()) {\r
+            ToscaServiceTemplate serviceTemplate =\r
+                policyProvider.fetchPolicies(null, null, policyId, policyVersion, mode);\r
+            updateApiStatisticsCounter(Target.POLICY, Result.SUCCESS, HttpMethod.GET);\r
+            return makeOkResponse(requestId, serviceTemplate);\r
+        } catch (PfModelException | PfModelRuntimeException pfme) {\r
+            LOGGER.warn("GET /policies/{}/versions/{}", policyId, policyVersion, pfme);\r
+            updateApiStatisticsCounter(Target.POLICY, Result.FAILURE, HttpMethod.GET);\r
+            return makeErrorResponse(requestId, pfme);\r
+        }\r
+    }\r
+\r
+    /**\r
+     * Creates one or more new policies in one call.\r
+     *\r
+     * @param body the body of policy following TOSCA definition\r
+     *\r
+     * @return the Response object containing the results of the API operation\r
+     */\r
+    @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 = AUTHORIZATION_TYPE), tags = {"Policy", },\r
+            response = ToscaServiceTemplate.class,\r
+        responseHeaders = {\r
+            @ResponseHeader(name = VERSION_MINOR_NAME,\r
+                description = VERSION_MINOR_DESCRIPTION,\r
+                response = String.class),\r
+            @ResponseHeader(name = VERSION_PATCH_NAME,\r
+                description = VERSION_PATCH_DESCRIPTION,\r
+                response = String.class),\r
+            @ResponseHeader(name = VERSION_LATEST_NAME, description = VERSION_LATEST_DESCRIPTION,\r
+                response = String.class),\r
+            @ResponseHeader(name = REQUEST_ID_NAME,\r
+                description = REQUEST_ID_HDR_DESCRIPTION, response = UUID.class)},\r
+        extensions = {\r
+            @Extension(name = EXTENSION_NAME, properties = {\r
+                @ExtensionProperty(name = API_VERSION_NAME, value = API_VERSION),\r
+                @ExtensionProperty(name = LAST_MOD_NAME, value = "El Alto")})})\r
+    @ApiResponses(value = {\r
+        @ApiResponse(code = HttpURLConnection.HTTP_BAD_REQUEST, message = INVALID_BODY_MESSAGE),\r
+        @ApiResponse(code = HttpURLConnection.HTTP_UNAUTHORIZED, message = AUTHENTICATION_ERROR_MESSAGE),\r
+        @ApiResponse(code = HttpURLConnection.HTTP_FORBIDDEN, message = AUTHORIZATION_ERROR_MESSAGE),\r
+        @ApiResponse(code = HttpURLConnection.HTTP_NOT_FOUND, message = NOT_FOUND_MESSAGE),\r
+        @ApiResponse(code = HttpURLConnection.HTTP_NOT_ACCEPTABLE, message = INVALID_PAYLOAD_MESSAGE),\r
+        @ApiResponse(code = HttpURLConnection.HTTP_INTERNAL_ERROR, message = SERVER_ERROR_MESSAGE)})\r
+    public Response createPolicies(\r
+        @HeaderParam(REQUEST_ID_NAME) @ApiParam(REQUEST_ID_PARAM_DESCRIPTION) 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
+        }\r
+\r
+        try (var policyProvider = new PolicyProvider()) {\r
+            ToscaServiceTemplate serviceTemplate = policyProvider.createPolicies(body);\r
+            updateApiStatisticsCounter(Target.POLICY, Result.SUCCESS, HttpMethod.POST);\r
+            return makeOkResponse(requestId, serviceTemplate);\r
+        } catch (PfModelException | PfModelRuntimeException pfme) {\r
+            LOGGER.warn("POST /policies", pfme);\r
+            updateApiStatisticsCounter(Target.POLICY, Result.FAILURE, HttpMethod.POST);\r
+            return makeErrorResponse(requestId, pfme);\r
+        }\r
     }\r
 \r
     /**\r
      * Deletes the specified version of a particular policy.\r
      *\r
-     * @param policyTypeId the ID of specified policy type\r
-     * @param policyTypeVersion the version of specified policy type\r
      * @param policyId the ID of specified policy\r
      * @param policyVersion the version of specified policy\r
      *\r
      * @return the Response object containing the results of the API operation\r
      */\r
     @DELETE\r
-    @Path("/policytypes/{policyTypeId}/versions/{policyTypeVersion}/policies/{policyId}/versions/{policyVersion}")\r
+    @Path("/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"),\r
-            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
+        notes = "Rule: the version that has been deployed in PDP group(s) cannot be deleted",\r
+        authorizations = @Authorization(value = AUTHORIZATION_TYPE), tags = {"Policy", },\r
+        response = ToscaServiceTemplate.class,\r
+        responseHeaders = {\r
+            @ResponseHeader(name = VERSION_MINOR_NAME,\r
+                description = VERSION_MINOR_DESCRIPTION,\r
+                response = String.class),\r
+            @ResponseHeader(name = VERSION_PATCH_NAME,\r
+                description = VERSION_PATCH_DESCRIPTION,\r
+                response = String.class),\r
+            @ResponseHeader(name = VERSION_LATEST_NAME, description = VERSION_LATEST_DESCRIPTION,\r
+                response = String.class),\r
+            @ResponseHeader(name = REQUEST_ID_NAME,\r
+                description = REQUEST_ID_HDR_DESCRIPTION, response = UUID.class)},\r
+        extensions = {\r
+            @Extension(name = EXTENSION_NAME, properties = {\r
+                @ExtensionProperty(name = API_VERSION_NAME, value = API_VERSION),\r
+                @ExtensionProperty(name = LAST_MOD_NAME, value = "Guilin")})})\r
     @ApiResponses(value = {\r
-            @ApiResponse(code = 204, message = "Resource successfully deleted, no content returned",\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
-            @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
-        })\r
-    public Response deleteSpecificVersionOfPolicy(\r
-            @PathParam("policyTypeId") @ApiParam(value = "PolicyType ID", required = true) String policyTypeId,\r
-            @PathParam("policyTypeVersion")\r
-                @ApiParam(value = "Version of policy type", 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
-        return addLoggingHeaders(addVersionControlHeaders(Response.status(Response.Status.OK)), requestId)\r
-            .entity(new PolicyProvider().deletePolicies(policyTypeId, policyTypeVersion,\r
-                                                        policyId, policyVersion)).build();\r
+        @ApiResponse(code = HttpURLConnection.HTTP_UNAUTHORIZED, message = AUTHENTICATION_ERROR_MESSAGE),\r
+        @ApiResponse(code = HttpURLConnection.HTTP_FORBIDDEN, message = AUTHORIZATION_ERROR_MESSAGE),\r
+        @ApiResponse(code = HttpURLConnection.HTTP_NOT_FOUND, message = NOT_FOUND_MESSAGE),\r
+        @ApiResponse(code = HttpURLConnection.HTTP_CONFLICT, message = HTTP_CONFLICT_MESSAGE),\r
+        @ApiResponse(code = HttpURLConnection.HTTP_INTERNAL_ERROR, message = SERVER_ERROR_MESSAGE)})\r
+    public Response deleteSpecificPolicy(\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(REQUEST_ID_NAME) @ApiParam(REQUEST_ID_PARAM_DESCRIPTION) UUID requestId) {\r
+\r
+        try (var policyProvider = new PolicyProvider()) {\r
+            ToscaServiceTemplate serviceTemplate =\r
+                policyProvider.deletePolicy(null, null, policyId, policyVersion);\r
+            updateApiStatisticsCounter(Target.POLICY, Result.SUCCESS, HttpMethod.DELETE);\r
+            return makeOkResponse(requestId, serviceTemplate);\r
+        } catch (PfModelException | PfModelRuntimeException pfme) {\r
+            LOGGER.warn("DELETE /policies/{}/versions/{}", policyId, policyVersion, pfme);\r
+            updateApiStatisticsCounter(Target.POLICY, Result.FAILURE, HttpMethod.DELETE);\r
+            return makeErrorResponse(requestId, pfme);\r
+        }\r
+    }\r
+\r
+\r
+\r
+    private enum Target {\r
+        POLICY,\r
+        POLICY_TYPE,\r
+        OTHER\r
+    }\r
+\r
+    private enum Result {\r
+        SUCCESS,\r
+        FAILURE\r
     }\r
 \r
-    private ResponseBuilder addVersionControlHeaders(ResponseBuilder rb) {\r
-        return rb.header("X-MinorVersion", "0").header("X-PatchVersion", "0").header("X-LatestVersion", "1.0.0");\r
+    private enum HttpMethod {\r
+        POST,\r
+        GET,\r
+        DELETE\r
     }\r
 \r
-    private ResponseBuilder addLoggingHeaders(ResponseBuilder rb, UUID requestId) {\r
-        if (requestId == null) {\r
-            // Generate a random uuid if client does not embed requestId in rest request\r
-            return rb.header("X-ONAP-RequestID", UUID.randomUUID());\r
+    private void updateApiStatisticsCounter(Target target, Result result, HttpMethod http) {\r
+\r
+        var mgr = ApiStatisticsManager.getInstance();\r
+        mgr.updateTotalApiCallCount();\r
+\r
+        switch (target) {\r
+            case POLICY:\r
+                updatePolicyStats(result, http);\r
+                break;\r
+            case POLICY_TYPE:\r
+                updatePolicyTypeStats(result, http);\r
+                break;\r
+            default:\r
+                mgr.updateApiCallSuccessCount();\r
+                break;\r
+        }\r
+    }\r
+\r
+    private void updatePolicyStats(Result result, HttpMethod http) {\r
+        var mgr = ApiStatisticsManager.getInstance();\r
+\r
+        if (result == Result.SUCCESS) {\r
+            switch (http) {\r
+                case GET:\r
+                    mgr.updateApiCallSuccessCount();\r
+                    mgr.updateTotalPolicyGetCount();\r
+                    mgr.updatePolicyGetSuccessCount();\r
+                    break;\r
+                case POST:\r
+                    mgr.updateApiCallSuccessCount();\r
+                    mgr.updateTotalPolicyPostCount();\r
+                    mgr.updatePolicyPostSuccessCount();\r
+                    break;\r
+                case DELETE:\r
+                    mgr.updateApiCallSuccessCount();\r
+                    mgr.updateTotalPolicyDeleteCount();\r
+                    mgr.updatePolicyDeleteSuccessCount();\r
+                    break;\r
+                default:\r
+                    mgr.updateApiCallSuccessCount();\r
+                    break;\r
+            }\r
+        } else {\r
+            switch (http) {\r
+                case GET:\r
+                    mgr.updateApiCallFailureCount();\r
+                    mgr.updateTotalPolicyGetCount();\r
+                    mgr.updatePolicyGetFailureCount();\r
+                    break;\r
+                case POST:\r
+                    mgr.updateApiCallFailureCount();\r
+                    mgr.updateTotalPolicyPostCount();\r
+                    mgr.updatePolicyPostFailureCount();\r
+                    break;\r
+                case DELETE:\r
+                    mgr.updateApiCallFailureCount();\r
+                    mgr.updateTotalPolicyDeleteCount();\r
+                    mgr.updatePolicyDeleteFailureCount();\r
+                    break;\r
+                default:\r
+                    mgr.updateApiCallFailureCount();\r
+                    break;\r
+            }\r
+        }\r
+    }\r
+\r
+    private void updatePolicyTypeStats(Result result, HttpMethod http) {\r
+        var mgr = ApiStatisticsManager.getInstance();\r
+\r
+        if (result == Result.SUCCESS) {\r
+            switch (http) {\r
+                case GET:\r
+                    mgr.updateApiCallSuccessCount();\r
+                    mgr.updateTotalPolicyTypeGetCount();\r
+                    mgr.updatePolicyTypeGetSuccessCount();\r
+                    break;\r
+                case POST:\r
+                    mgr.updateApiCallSuccessCount();\r
+                    mgr.updateTotalPolicyTypePostCount();\r
+                    mgr.updatePolicyTypePostSuccessCount();\r
+                    break;\r
+                case DELETE:\r
+                    mgr.updateApiCallSuccessCount();\r
+                    mgr.updateTotalPolicyTypeDeleteCount();\r
+                    mgr.updatePolicyTypeDeleteSuccessCount();\r
+                    break;\r
+                default:\r
+                    mgr.updateApiCallSuccessCount();\r
+                    break;\r
+            }\r
+        } else {\r
+            switch (http) {\r
+                case GET:\r
+                    mgr.updateApiCallFailureCount();\r
+                    mgr.updateTotalPolicyTypeGetCount();\r
+                    mgr.updatePolicyTypeGetFailureCount();\r
+                    break;\r
+                case POST:\r
+                    mgr.updateApiCallFailureCount();\r
+                    mgr.updateTotalPolicyTypePostCount();\r
+                    mgr.updatePolicyTypePostFailureCount();\r
+                    break;\r
+                case DELETE:\r
+                    mgr.updateApiCallFailureCount();\r
+                    mgr.updateTotalPolicyTypeDeleteCount();\r
+                    mgr.updatePolicyTypeDeleteFailureCount();\r
+                    break;\r
+                default:\r
+                    mgr.updateApiCallFailureCount();\r
+                    break;\r
+            }\r
         }\r
-        return rb.header("X-ONAP-RequestID", requestId);\r
     }\r
-}
\ No newline at end of file
+}\r