X-Git-Url: https://gerrit.onap.org/r/gitweb?a=blobdiff_plain;f=main%2Fsrc%2Fmain%2Fjava%2Forg%2Fonap%2Fpolicy%2Fapi%2Fmain%2Frest%2FApiRestController.java;h=6d6b4d14f0a57a9b4f5b63703b8fc0cfe589a739;hb=177ee181ab92f51171b3a9886f6ae152e1468d4c;hp=67baa8a4c681705c8227d111723969046872e6f1;hpb=aff0352cc138a494ec105947d446a54d5fa035cf;p=policy%2Fapi.git diff --git a/main/src/main/java/org/onap/policy/api/main/rest/ApiRestController.java b/main/src/main/java/org/onap/policy/api/main/rest/ApiRestController.java index 67baa8a4..6d6b4d14 100644 --- a/main/src/main/java/org/onap/policy/api/main/rest/ApiRestController.java +++ b/main/src/main/java/org/onap/policy/api/main/rest/ApiRestController.java @@ -36,9 +36,11 @@ import io.swagger.annotations.Info; import io.swagger.annotations.ResponseHeader; import io.swagger.annotations.SecurityDefinition; import io.swagger.annotations.SwaggerDefinition; + import java.util.List; import java.util.Map; import java.util.UUID; + import javax.ws.rs.Consumes; import javax.ws.rs.DELETE; import javax.ws.rs.GET; @@ -48,6 +50,7 @@ import javax.ws.rs.Path; import javax.ws.rs.PathParam; import javax.ws.rs.Produces; import javax.ws.rs.core.Response; + import org.apache.commons.lang3.tuple.Pair; import org.onap.policy.api.main.rest.provider.HealthCheckProvider; import org.onap.policy.api.main.rest.provider.PolicyProvider; @@ -75,22 +78,17 @@ import org.slf4j.LoggerFactory; @Consumes({"application/json", "application/yaml"}) @SwaggerDefinition(info = @Info( description = "Policy Design API is publicly exposed for clients to Create/Read/Update/Delete" - + " policy types, policy type implementation and policies which can be recognized" - + " and executable by incorporated policy engines. It is an" - + " independent component running rest service that takes all policy design API calls" - + " from clients and then assign them to different API working functions. Besides" - + " that, API is also exposed for clients to retrieve healthcheck status of this API" - + " rest service and the statistics report including the counters of API invocation.", - version = "1.0.0", - title = "Policy Design", - extensions = { - @Extension(properties = { - @ExtensionProperty(name = "planned-retirement-date", value = "tbd"), - @ExtensionProperty(name = "component", value = "Policy Framework") - }) - }), - schemes = { SwaggerDefinition.Scheme.HTTP, SwaggerDefinition.Scheme.HTTPS }, - securityDefinition = @SecurityDefinition(basicAuthDefinitions = { @BasicAuthDefinition(key = "basicAuth") })) + + " policy types, policy type implementation and policies which can be recognized" + + " and executable by incorporated policy engines. It is an" + + " independent component running rest service that takes all policy design API calls" + + " from clients and then assign them to different API working functions. Besides" + + " that, API is also exposed for clients to retrieve healthcheck status of this API" + + " rest service and the statistics report including the counters of API invocation.", + version = "1.0.0", title = "Policy Design", + extensions = {@Extension(properties = {@ExtensionProperty(name = "planned-retirement-date", value = "tbd"), + @ExtensionProperty(name = "component", value = "Policy Framework")})}), + schemes = {SwaggerDefinition.Scheme.HTTP, SwaggerDefinition.Scheme.HTTPS}, + securityDefinition = @SecurityDefinition(basicAuthDefinitions = {@BasicAuthDefinition(key = "basicAuth")})) public class ApiRestController extends CommonRestController { private static final Logger LOGGER = LoggerFactory.getLogger(ApiRestController.class); @@ -102,39 +100,29 @@ public class ApiRestController extends CommonRestController { */ @GET @Path("/healthcheck") - @ApiOperation(value = "Perform a system healthcheck", - notes = "Returns healthy status of the Policy API component", + @ApiOperation(value = "Perform a system healthcheck", notes = "Returns healthy status of the Policy API component", response = HealthCheckReport.class, responseHeaders = { - @ResponseHeader(name = "X-MinorVersion", - description = "Used to request or communicate a MINOR version back from the client" - + " to the server, and from the server back to the client", - response = String.class), - @ResponseHeader(name = "X-PatchVersion", - description = "Used only to communicate a PATCH version in a response for" - + " troubleshooting purposes only, and will not be provided by" - + " the client on request", - response = String.class), - @ResponseHeader(name = "X-LatestVersion", - description = "Used only to communicate an API's latest version", - response = String.class), - @ResponseHeader(name = "X-ONAP-RequestID", - description = "Used to track REST transactions for logging purpose", - response = UUID.class) - }, - authorizations = @Authorization(value = "basicAuth"), - tags = { "HealthCheck", }, - extensions = { - @Extension(name = "interface info", properties = { - @ExtensionProperty(name = "api-version", value = "1.0.0"), - @ExtensionProperty(name = "last-mod-release", value = "Dublin") - }) - }) - @ApiResponses(value = { - @ApiResponse(code = 401, message = "Authentication Error"), - @ApiResponse(code = 403, message = "Authorization Error"), - @ApiResponse(code = 500, message = "Internal Server Error") - }) + @ResponseHeader(name = "X-MinorVersion", + description = "Used to request or communicate a MINOR version back from the client" + + " to the server, and from the server back to the client", + response = String.class), + @ResponseHeader(name = "X-PatchVersion", + description = "Used only to communicate a PATCH version in a response for" + + " troubleshooting purposes only, and will not be provided by" + + " the client on request", + response = String.class), + @ResponseHeader(name = "X-LatestVersion", + description = "Used only to communicate an API's latest version", response = String.class), + @ResponseHeader(name = "X-ONAP-RequestID", + description = "Used to track REST transactions for logging purpose", response = UUID.class)}, + authorizations = @Authorization(value = "basicAuth"), tags = {"HealthCheck",}, + extensions = {@Extension(name = "interface info", + properties = {@ExtensionProperty(name = "api-version", value = "1.0.0"), + @ExtensionProperty(name = "last-mod-release", value = "Dublin")})}) + @ApiResponses(value = {@ApiResponse(code = 401, message = "Authentication Error"), + @ApiResponse(code = 403, message = "Authorization Error"), + @ApiResponse(code = 500, message = "Internal Server Error")}) public Response getHealthCheck( @HeaderParam("X-ONAP-RequestID") @ApiParam("RequestID for http transaction") UUID requestId) { @@ -153,37 +141,28 @@ public class ApiRestController extends CommonRestController { notes = "Returns current statistics including the counters of API invocation", response = StatisticsReport.class, responseHeaders = { - @ResponseHeader(name = "X-MinorVersion", - description = "Used to request or communicate a MINOR version back from the client" - + " to the server, and from the server back to the client", - response = String.class), - @ResponseHeader(name = "X-PatchVersion", - description = "Used only to communicate a PATCH version in a response for" - + " troubleshooting purposes only, and will not be provided by" - + " the client on request", - response = String.class), - @ResponseHeader(name = "X-LatestVersion", - description = "Used only to communicate an API's latest version", - response = String.class), - @ResponseHeader(name = "X-ONAP-RequestID", - description = "Used to track REST transactions for logging purpose", - response = UUID.class) - }, - authorizations = @Authorization(value = "basicAuth"), - tags = { "Statistics", }, - extensions = { - @Extension(name = "interface info", properties = { - @ExtensionProperty(name = "api-version", value = "1.0.0"), - @ExtensionProperty(name = "last-mod-release", value = "Dublin") - }) - }) - @ApiResponses(value = { - @ApiResponse(code = 401, message = "Authentication Error"), - @ApiResponse(code = 403, message = "Authorization Error"), - @ApiResponse(code = 500, message = "Internal Server Error") - }) - public Response getStatistics( - @HeaderParam("X-ONAP-RequestID") @ApiParam("RequestID for http transaction") UUID requestId) { + @ResponseHeader(name = "X-MinorVersion", + description = "Used to request or communicate a MINOR version back from the client" + + " to the server, and from the server back to the client", + response = String.class), + @ResponseHeader(name = "X-PatchVersion", + description = "Used only to communicate a PATCH version in a response for" + + " troubleshooting purposes only, and will not be provided by" + + " the client on request", + response = String.class), + @ResponseHeader(name = "X-LatestVersion", + description = "Used only to communicate an API's latest version", response = String.class), + @ResponseHeader(name = "X-ONAP-RequestID", + description = "Used to track REST transactions for logging purpose", response = UUID.class)}, + authorizations = @Authorization(value = "basicAuth"), tags = {"Statistics",}, + extensions = {@Extension(name = "interface info", + properties = {@ExtensionProperty(name = "api-version", value = "1.0.0"), + @ExtensionProperty(name = "last-mod-release", value = "Dublin")})}) + @ApiResponses(value = {@ApiResponse(code = 401, message = "Authentication Error"), + @ApiResponse(code = 403, message = "Authorization Error"), + @ApiResponse(code = 500, message = "Internal Server Error")}) + public Response + getStatistics(@HeaderParam("X-ONAP-RequestID") @ApiParam("RequestID for http transaction") UUID requestId) { updateApiStatisticsCounter(Target.OTHER, Result.SUCCESS, HttpMethod.GET); @@ -201,35 +180,26 @@ public class ApiRestController extends CommonRestController { notes = "Returns a list of existing policy types stored in Policy Framework", response = ToscaServiceTemplate.class, responseHeaders = { - @ResponseHeader(name = "X-MinorVersion", - description = "Used to request or communicate a MINOR version back from the client" - + " to the server, and from the server back to the client", - response = String.class), - @ResponseHeader(name = "X-PatchVersion", - description = "Used only to communicate a PATCH version in a response for" - + " troubleshooting purposes only, and will not be provided by" - + " the client on request", - response = String.class), - @ResponseHeader(name = "X-LatestVersion", - description = "Used only to communicate an API's latest version", - response = String.class), - @ResponseHeader(name = "X-ONAP-RequestID", - description = "Used to track REST transactions for logging purpose", - response = UUID.class) - }, - authorizations = @Authorization(value = "basicAuth"), - tags = { "PolicyType", }, - extensions = { - @Extension(name = "interface info", properties = { - @ExtensionProperty(name = "api-version", value = "1.0.0"), - @ExtensionProperty(name = "last-mod-release", value = "Dublin") - }) - }) - @ApiResponses(value = { - @ApiResponse(code = 401, message = "Authentication Error"), - @ApiResponse(code = 403, message = "Authorization Error"), - @ApiResponse(code = 500, message = "Internal Server Error") - }) + @ResponseHeader(name = "X-MinorVersion", + description = "Used to request or communicate a MINOR version back from the client" + + " to the server, and from the server back to the client", + response = String.class), + @ResponseHeader(name = "X-PatchVersion", + description = "Used only to communicate a PATCH version in a response for" + + " troubleshooting purposes only, and will not be provided by" + + " the client on request", + response = String.class), + @ResponseHeader(name = "X-LatestVersion", + description = "Used only to communicate an API's latest version", response = String.class), + @ResponseHeader(name = "X-ONAP-RequestID", + description = "Used to track REST transactions for logging purpose", response = UUID.class)}, + authorizations = @Authorization(value = "basicAuth"), tags = {"PolicyType",}, + extensions = {@Extension(name = "interface info", + properties = {@ExtensionProperty(name = "api-version", value = "1.0.0"), + @ExtensionProperty(name = "last-mod-release", value = "Dublin")})}) + @ApiResponses(value = {@ApiResponse(code = 401, message = "Authentication Error"), + @ApiResponse(code = 403, message = "Authorization Error"), + @ApiResponse(code = 500, message = "Internal Server Error")}) public Response getAllPolicyTypes( @HeaderParam("X-ONAP-RequestID") @ApiParam("RequestID for http transaction") UUID requestId) { @@ -238,7 +208,7 @@ public class ApiRestController extends CommonRestController { updateApiStatisticsCounter(Target.POLICY_TYPE, Result.SUCCESS, HttpMethod.GET); return makeOkResponse(requestId, serviceTemplate); } catch (PfModelException | PfModelRuntimeException pfme) { - LOGGER.error("GET /policytypes", pfme); + LOGGER.debug("GET /policytypes", pfme); updateApiStatisticsCounter(Target.POLICY_TYPE, Result.FAILURE, HttpMethod.GET); return makeErrorResponse(requestId, pfme); } @@ -257,36 +227,27 @@ public class ApiRestController extends CommonRestController { notes = "Returns a list of all available versions for the specified policy type", response = ToscaServiceTemplate.class, responseHeaders = { - @ResponseHeader(name = "X-MinorVersion", - description = "Used to request or communicate a MINOR version back from the client" - + " to the server, and from the server back to the client", - response = String.class), - @ResponseHeader(name = "X-PatchVersion", - description = "Used only to communicate a PATCH version in a response for" - + " troubleshooting purposes only, and will not be provided by" - + " the client on request", - response = String.class), - @ResponseHeader(name = "X-LatestVersion", - description = "Used only to communicate an API's latest version", - response = String.class), - @ResponseHeader(name = "X-ONAP-RequestID", - description = "Used to track REST transactions for logging purpose", - response = UUID.class) - }, - authorizations = @Authorization(value = "basicAuth"), - tags = { "PolicyType", }, - extensions = { - @Extension(name = "interface info", properties = { - @ExtensionProperty(name = "api-version", value = "1.0.0"), - @ExtensionProperty(name = "last-mod-release", value = "Dublin") - }) - }) - @ApiResponses(value = { - @ApiResponse(code = 401, message = "Authentication Error"), - @ApiResponse(code = 403, message = "Authorization Error"), - @ApiResponse(code = 404, message = "Resource Not Found"), - @ApiResponse(code = 500, message = "Internal Server Error") - }) + @ResponseHeader(name = "X-MinorVersion", + description = "Used to request or communicate a MINOR version back from the client" + + " to the server, and from the server back to the client", + response = String.class), + @ResponseHeader(name = "X-PatchVersion", + description = "Used only to communicate a PATCH version in a response for" + + " troubleshooting purposes only, and will not be provided by" + + " the client on request", + response = String.class), + @ResponseHeader(name = "X-LatestVersion", + description = "Used only to communicate an API's latest version", response = String.class), + @ResponseHeader(name = "X-ONAP-RequestID", + description = "Used to track REST transactions for logging purpose", response = UUID.class)}, + authorizations = @Authorization(value = "basicAuth"), tags = {"PolicyType",}, + extensions = {@Extension(name = "interface info", + properties = {@ExtensionProperty(name = "api-version", value = "1.0.0"), + @ExtensionProperty(name = "last-mod-release", value = "Dublin")})}) + @ApiResponses(value = {@ApiResponse(code = 401, message = "Authentication Error"), + @ApiResponse(code = 403, message = "Authorization Error"), + @ApiResponse(code = 404, message = "Resource Not Found"), + @ApiResponse(code = 500, message = "Internal Server Error")}) public Response getAllVersionsOfPolicyType( @PathParam("policyTypeId") @ApiParam(value = "ID of policy type", required = true) String policyTypeId, @HeaderParam("X-ONAP-RequestID") @ApiParam("RequestID for http transaction") UUID requestId) { @@ -296,7 +257,7 @@ public class ApiRestController extends CommonRestController { updateApiStatisticsCounter(Target.POLICY_TYPE, Result.SUCCESS, HttpMethod.GET); return makeOkResponse(requestId, serviceTemplate); } catch (PfModelException | PfModelRuntimeException pfme) { - LOGGER.error("GET /policytypes/{}", policyTypeId, pfme); + LOGGER.debug("GET /policytypes/{}", policyTypeId, pfme); updateApiStatisticsCounter(Target.POLICY_TYPE, Result.FAILURE, HttpMethod.GET); return makeErrorResponse(requestId, pfme); } @@ -313,39 +274,29 @@ public class ApiRestController extends CommonRestController { @GET @Path("/policytypes/{policyTypeId}/versions/{versionId}") @ApiOperation(value = "Retrieve one particular version of a policy type", - notes = "Returns a particular version for the specified policy type", - response = ToscaServiceTemplate.class, + notes = "Returns a particular version for the specified policy type", response = ToscaServiceTemplate.class, responseHeaders = { - @ResponseHeader(name = "X-MinorVersion", - description = "Used to request or communicate a MINOR version back from the client" - + " to the server, and from the server back to the client", - response = String.class), - @ResponseHeader(name = "X-PatchVersion", - description = "Used only to communicate a PATCH version in a response for" - + " troubleshooting purposes only, and will not be provided by" - + " the client on request", - response = String.class), - @ResponseHeader(name = "X-LatestVersion", - description = "Used only to communicate an API's latest version", - response = String.class), - @ResponseHeader(name = "X-ONAP-RequestID", - description = "Used to track REST transactions for logging purpose", - response = UUID.class) - }, - authorizations = @Authorization(value = "basicAuth"), - tags = { "PolicyType", }, - extensions = { - @Extension(name = "interface info", properties = { - @ExtensionProperty(name = "api-version", value = "1.0.0"), - @ExtensionProperty(name = "last-mod-release", value = "Dublin") - }) - }) - @ApiResponses(value = { - @ApiResponse(code = 401, message = "Authentication Error"), - @ApiResponse(code = 403, message = "Authorization Error"), - @ApiResponse(code = 404, message = "Resource Not Found"), - @ApiResponse(code = 500, message = "Internal Server Error") - }) + @ResponseHeader(name = "X-MinorVersion", + description = "Used to request or communicate a MINOR version back from the client" + + " to the server, and from the server back to the client", + response = String.class), + @ResponseHeader(name = "X-PatchVersion", + description = "Used only to communicate a PATCH version in a response for" + + " troubleshooting purposes only, and will not be provided by" + + " the client on request", + response = String.class), + @ResponseHeader(name = "X-LatestVersion", + description = "Used only to communicate an API's latest version", response = String.class), + @ResponseHeader(name = "X-ONAP-RequestID", + description = "Used to track REST transactions for logging purpose", response = UUID.class)}, + authorizations = @Authorization(value = "basicAuth"), tags = {"PolicyType",}, + extensions = {@Extension(name = "interface info", + properties = {@ExtensionProperty(name = "api-version", value = "1.0.0"), + @ExtensionProperty(name = "last-mod-release", value = "Dublin")})}) + @ApiResponses(value = {@ApiResponse(code = 401, message = "Authentication Error"), + @ApiResponse(code = 403, message = "Authorization Error"), + @ApiResponse(code = 404, message = "Resource Not Found"), + @ApiResponse(code = 500, message = "Internal Server Error")}) public Response getSpecificVersionOfPolicyType( @PathParam("policyTypeId") @ApiParam(value = "ID of policy type", required = true) String policyTypeId, @PathParam("versionId") @ApiParam(value = "Version of policy type", required = true) String versionId, @@ -356,7 +307,7 @@ public class ApiRestController extends CommonRestController { updateApiStatisticsCounter(Target.POLICY_TYPE, Result.SUCCESS, HttpMethod.GET); return makeOkResponse(requestId, serviceTemplate); } catch (PfModelException | PfModelRuntimeException pfme) { - LOGGER.error("GET /policytypes/{}/versions/{}", policyTypeId, versionId, pfme); + LOGGER.debug("GET /policytypes/{}/versions/{}", policyTypeId, versionId, pfme); updateApiStatisticsCounter(Target.POLICY_TYPE, Result.FAILURE, HttpMethod.GET); return makeErrorResponse(requestId, pfme); } @@ -372,39 +323,29 @@ public class ApiRestController extends CommonRestController { @GET @Path("/policytypes/{policyTypeId}/versions/latest") @ApiOperation(value = "Retrieve latest version of a policy type", - notes = "Returns latest version for the specified policy type", - response = ToscaServiceTemplate.class, + notes = "Returns latest version for the specified policy type", response = ToscaServiceTemplate.class, responseHeaders = { - @ResponseHeader(name = "X-MinorVersion", - description = "Used to request or communicate a MINOR version back from the client" - + " to the server, and from the server back to the client", - response = String.class), - @ResponseHeader(name = "X-PatchVersion", - description = "Used only to communicate a PATCH version in a response for" - + " troubleshooting purposes only, and will not be provided by" - + " the client on request", - response = String.class), - @ResponseHeader(name = "X-LatestVersion", - description = "Used only to communicate an API's latest version", - response = String.class), - @ResponseHeader(name = "X-ONAP-RequestID", - description = "Used to track REST transactions for logging purpose", - response = UUID.class) - }, - authorizations = @Authorization(value = "basicAuth"), - tags = { "PolicyType", }, - extensions = { - @Extension(name = "interface info", properties = { - @ExtensionProperty(name = "api-version", value = "1.0.0"), - @ExtensionProperty(name = "last-mod-release", value = "Dublin") - }) - }) - @ApiResponses(value = { - @ApiResponse(code = 401, message = "Authentication Error"), - @ApiResponse(code = 403, message = "Authorization Error"), - @ApiResponse(code = 404, message = "Resource Not Found"), - @ApiResponse(code = 500, message = "Internal Server Error") - }) + @ResponseHeader(name = "X-MinorVersion", + description = "Used to request or communicate a MINOR version back from the client" + + " to the server, and from the server back to the client", + response = String.class), + @ResponseHeader(name = "X-PatchVersion", + description = "Used only to communicate a PATCH version in a response for" + + " troubleshooting purposes only, and will not be provided by" + + " the client on request", + response = String.class), + @ResponseHeader(name = "X-LatestVersion", + description = "Used only to communicate an API's latest version", response = String.class), + @ResponseHeader(name = "X-ONAP-RequestID", + description = "Used to track REST transactions for logging purpose", response = UUID.class)}, + authorizations = @Authorization(value = "basicAuth"), tags = {"PolicyType",}, + extensions = {@Extension(name = "interface info", + properties = {@ExtensionProperty(name = "api-version", value = "1.0.0"), + @ExtensionProperty(name = "last-mod-release", value = "Dublin")})}) + @ApiResponses(value = {@ApiResponse(code = 401, message = "Authentication Error"), + @ApiResponse(code = 403, message = "Authorization Error"), + @ApiResponse(code = 404, message = "Resource Not Found"), + @ApiResponse(code = 500, message = "Internal Server Error")}) public Response getLatestVersionOfPolicyType( @PathParam("policyTypeId") @ApiParam(value = "ID of policy type", required = true) String policyTypeId, @HeaderParam("X-ONAP-RequestID") @ApiParam("RequestID for http transaction") UUID requestId) { @@ -414,7 +355,7 @@ public class ApiRestController extends CommonRestController { updateApiStatisticsCounter(Target.POLICY_TYPE, Result.SUCCESS, HttpMethod.GET); return makeOkResponse(requestId, serviceTemplate); } catch (PfModelException | PfModelRuntimeException pfme) { - LOGGER.error("GET /policytypes/{}/versions/latest", policyTypeId, pfme); + LOGGER.debug("GET /policytypes/{}/versions/latest", policyTypeId, pfme); updateApiStatisticsCounter(Target.POLICY_TYPE, Result.FAILURE, HttpMethod.GET); return makeErrorResponse(requestId, pfme); } @@ -429,40 +370,30 @@ public class ApiRestController extends CommonRestController { */ @POST @Path("/policytypes") - @ApiOperation(value = "Create a new policy type", - notes = "Client should provide TOSCA body of the new policy type", - authorizations = @Authorization(value = "basicAuth"), - tags = { "PolicyType", }, + @ApiOperation(value = "Create a new policy type", notes = "Client should provide TOSCA body of the new policy type", + authorizations = @Authorization(value = "basicAuth"), tags = {"PolicyType",}, response = ToscaServiceTemplate.class, responseHeaders = { - @ResponseHeader(name = "X-MinorVersion", - description = "Used to request or communicate a MINOR version back from the client" - + " to the server, and from the server back to the client", - response = String.class), - @ResponseHeader(name = "X-PatchVersion", - description = "Used only to communicate a PATCH version in a response for" - + " troubleshooting purposes only, and will not be provided by" - + " the client on request", - response = String.class), - @ResponseHeader(name = "X-LatestVersion", - description = "Used only to communicate an API's latest version", - response = String.class), - @ResponseHeader(name = "X-ONAP-RequestID", - description = "Used to track REST transactions for logging purpose", - response = UUID.class) - }, - extensions = { - @Extension(name = "interface info", properties = { - @ExtensionProperty(name = "api-version", value = "1.0.0"), - @ExtensionProperty(name = "last-mod-release", value = "Dublin") - }) - }) - @ApiResponses(value = { - @ApiResponse(code = 400, message = "Invalid Body"), - @ApiResponse(code = 401, message = "Authentication Error"), - @ApiResponse(code = 403, message = "Authorization Error"), - @ApiResponse(code = 500, message = "Internal Server Error") - }) + @ResponseHeader(name = "X-MinorVersion", + description = "Used to request or communicate a MINOR version back from the client" + + " to the server, and from the server back to the client", + response = String.class), + @ResponseHeader(name = "X-PatchVersion", + description = "Used only to communicate a PATCH version in a response for" + + " troubleshooting purposes only, and will not be provided by" + + " the client on request", + response = String.class), + @ResponseHeader(name = "X-LatestVersion", + description = "Used only to communicate an API's latest version", response = String.class), + @ResponseHeader(name = "X-ONAP-RequestID", + description = "Used to track REST transactions for logging purpose", response = UUID.class)}, + extensions = {@Extension(name = "interface info", + properties = {@ExtensionProperty(name = "api-version", value = "1.0.0"), + @ExtensionProperty(name = "last-mod-release", value = "Dublin")})}) + @ApiResponses(value = {@ApiResponse(code = 400, message = "Invalid Body"), + @ApiResponse(code = 401, message = "Authentication Error"), + @ApiResponse(code = 403, message = "Authorization Error"), + @ApiResponse(code = 500, message = "Internal Server Error")}) public Response createPolicyType( @ApiParam(value = "Entity body of policy type", required = true) ToscaServiceTemplate body, @HeaderParam("X-ONAP-RequestID") @ApiParam("RequestID for http transaction") UUID requestId) { @@ -476,7 +407,7 @@ public class ApiRestController extends CommonRestController { updateApiStatisticsCounter(Target.POLICY_TYPE, Result.SUCCESS, HttpMethod.POST); return makeOkResponse(requestId, serviceTemplate); } catch (PfModelException | PfModelRuntimeException pfme) { - LOGGER.error("POST /policytypes", pfme); + LOGGER.debug("POST /policytypes", pfme); updateApiStatisticsCounter(Target.POLICY_TYPE, Result.FAILURE, HttpMethod.POST); return makeErrorResponse(requestId, pfme); } @@ -494,41 +425,32 @@ public class ApiRestController extends CommonRestController { @Path("/policytypes/{policyTypeId}/versions/{versionId}") @ApiOperation(value = "Delete one version of a policy type", notes = "Rule 1: pre-defined policy types cannot be deleted;" - + "Rule 2: policy types that are in use (parameterized by a TOSCA policy) cannot be deleted." - + "The parameterizing TOSCA policies must be deleted first;", - authorizations = @Authorization(value = "basicAuth"), - tags = { "PolicyType", }, + + "Rule 2: policy types that are in use (parameterized by a TOSCA policy) cannot be deleted." + + "The parameterizing TOSCA policies must be deleted first;", + authorizations = @Authorization(value = "basicAuth"), tags = {"PolicyType",}, response = ToscaServiceTemplate.class, responseHeaders = { - @ResponseHeader(name = "X-MinorVersion", - description = "Used to request or communicate a MINOR version back from the client" - + " to the server, and from the server back to the client", - response = String.class), - @ResponseHeader(name = "X-PatchVersion", - description = "Used only to communicate a PATCH version in a response for" - + " troubleshooting purposes only, and will not be provided by" - + " the client on request", - response = String.class), - @ResponseHeader(name = "X-LatestVersion", - description = "Used only to communicate an API's latest version", - response = String.class), - @ResponseHeader(name = "X-ONAP-RequestID", - description = "Used to track REST transactions for logging purpose", - response = UUID.class) - }, - extensions = { - @Extension(name = "interface info", properties = { - @ExtensionProperty(name = "api-version", value = "1.0.0"), - @ExtensionProperty(name = "last-mod-release", value = "Dublin") - }) - }) - @ApiResponses(value = { - @ApiResponse(code = 401, message = "Authentication Error"), - @ApiResponse(code = 403, message = "Authorization Error"), - @ApiResponse(code = 404, message = "Resource Not Found"), - @ApiResponse(code = 409, message = "Delete Conflict, Rule Violation"), - @ApiResponse(code = 500, message = "Internal Server Error") - }) + @ResponseHeader(name = "X-MinorVersion", + description = "Used to request or communicate a MINOR version back from the client" + + " to the server, and from the server back to the client", + response = String.class), + @ResponseHeader(name = "X-PatchVersion", + description = "Used only to communicate a PATCH version in a response for" + + " troubleshooting purposes only, and will not be provided by" + + " the client on request", + response = String.class), + @ResponseHeader(name = "X-LatestVersion", + description = "Used only to communicate an API's latest version", response = String.class), + @ResponseHeader(name = "X-ONAP-RequestID", + description = "Used to track REST transactions for logging purpose", response = UUID.class)}, + extensions = {@Extension(name = "interface info", + properties = {@ExtensionProperty(name = "api-version", value = "1.0.0"), + @ExtensionProperty(name = "last-mod-release", value = "Dublin")})}) + @ApiResponses(value = {@ApiResponse(code = 401, message = "Authentication Error"), + @ApiResponse(code = 403, message = "Authorization Error"), + @ApiResponse(code = 404, message = "Resource Not Found"), + @ApiResponse(code = 409, message = "Delete Conflict, Rule Violation"), + @ApiResponse(code = 500, message = "Internal Server Error")}) public Response deleteSpecificVersionOfPolicyType( @PathParam("policyTypeId") @ApiParam(value = "ID of policy type", required = true) String policyTypeId, @PathParam("versionId") @ApiParam(value = "Version of policy type", required = true) String versionId, @@ -538,7 +460,7 @@ public class ApiRestController extends CommonRestController { ToscaServiceTemplate serviceTemplate = policyTypeProvider.deletePolicyType(policyTypeId, versionId); return makeOkResponse(requestId, serviceTemplate); } catch (PfModelException | PfModelRuntimeException pfme) { - LOGGER.error("DELETE /policytypes/{}/versions/{}", policyTypeId, versionId, pfme); + LOGGER.debug("DELETE /policytypes/{}/versions/{}", policyTypeId, versionId, pfme); return makeErrorResponse(requestId, pfme); } } @@ -557,40 +479,31 @@ public class ApiRestController extends CommonRestController { notes = "Returns a list of all versions of specified policy created for the specified policy type version", response = ToscaServiceTemplate.class, responseHeaders = { - @ResponseHeader(name = "X-MinorVersion", - description = "Used to request or communicate a MINOR version back from the client" - + " to the server, and from the server back to the client", - response = String.class), - @ResponseHeader(name = "X-PatchVersion", - description = "Used only to communicate a PATCH version in a response for" - + " troubleshooting purposes only, and will not be provided by" - + " the client on request", - response = String.class), - @ResponseHeader(name = "X-LatestVersion", - description = "Used only to communicate an API's latest version", - response = String.class), - @ResponseHeader(name = "X-ONAP-RequestID", - description = "Used to track REST transactions for logging purpose", - response = UUID.class) - }, - authorizations = @Authorization(value = "basicAuth"), - tags = { "Policy", }, - extensions = { - @Extension(name = "interface info", properties = { - @ExtensionProperty(name = "api-version", value = "1.0.0"), - @ExtensionProperty(name = "last-mod-release", value = "Dublin") - }) - }) - @ApiResponses(value = { - @ApiResponse(code = 401, message = "Authentication Error"), - @ApiResponse(code = 403, message = "Authorization Error"), - @ApiResponse(code = 404, message = "Resource Not Found"), - @ApiResponse(code = 500, message = "Internal Server Error") - }) + @ResponseHeader(name = "X-MinorVersion", + description = "Used to request or communicate a MINOR version back from the client" + + " to the server, and from the server back to the client", + response = String.class), + @ResponseHeader(name = "X-PatchVersion", + description = "Used only to communicate a PATCH version in a response for" + + " troubleshooting purposes only, and will not be provided by" + + " the client on request", + response = String.class), + @ResponseHeader(name = "X-LatestVersion", + description = "Used only to communicate an API's latest version", response = String.class), + @ResponseHeader(name = "X-ONAP-RequestID", + description = "Used to track REST transactions for logging purpose", response = UUID.class)}, + authorizations = @Authorization(value = "basicAuth"), tags = {"Policy",}, + extensions = {@Extension(name = "interface info", + properties = {@ExtensionProperty(name = "api-version", value = "1.0.0"), + @ExtensionProperty(name = "last-mod-release", value = "Dublin")})}) + @ApiResponses(value = {@ApiResponse(code = 401, message = "Authentication Error"), + @ApiResponse(code = 403, message = "Authorization Error"), + @ApiResponse(code = 404, message = "Resource Not Found"), + @ApiResponse(code = 500, message = "Internal Server Error")}) public Response getAllPolicies( @PathParam("policyTypeId") @ApiParam(value = "ID of policy type", required = true) String policyTypeId, - @PathParam("policyTypeVersion") - @ApiParam(value = "Version of policy type", required = true) String policyTypeVersion, + @PathParam("policyTypeVersion") @ApiParam(value = "Version of policy type", + required = true) String policyTypeVersion, @HeaderParam("X-ONAP-RequestID") @ApiParam("RequestID for http transaction") UUID requestId) { try (PolicyProvider policyProvider = new PolicyProvider()) { @@ -599,7 +512,7 @@ public class ApiRestController extends CommonRestController { updateApiStatisticsCounter(Target.POLICY, Result.SUCCESS, HttpMethod.GET); return makeOkResponse(requestId, serviceTemplate); } catch (PfModelException | PfModelRuntimeException pfme) { - LOGGER.error("GET /policytypes/{}/versions/{}/policies", policyTypeId, policyTypeVersion, pfme); + LOGGER.debug("GET /policytypes/{}/versions/{}/policies", policyTypeId, policyTypeVersion, pfme); updateApiStatisticsCounter(Target.POLICY, Result.FAILURE, HttpMethod.GET); return makeErrorResponse(requestId, pfme); } @@ -620,51 +533,41 @@ public class ApiRestController extends CommonRestController { notes = "Returns a list of all version details of the specified policy", response = ToscaServiceTemplate.class, responseHeaders = { - @ResponseHeader(name = "X-MinorVersion", - description = "Used to request or communicate a MINOR version back from the client" - + " to the server, and from the server back to the client", - response = String.class), - @ResponseHeader(name = "X-PatchVersion", - description = "Used only to communicate a PATCH version in a response for" - + " troubleshooting purposes only, and will not be provided by" - + " the client on request", - response = String.class), - @ResponseHeader(name = "X-LatestVersion", - description = "Used only to communicate an API's latest version", - response = String.class), - @ResponseHeader(name = "X-ONAP-RequestID", - description = "Used to track REST transactions for logging purpose", - response = UUID.class) - }, - authorizations = @Authorization(value = "basicAuth"), - tags = { "Policy", }, - extensions = { - @Extension(name = "interface info", properties = { - @ExtensionProperty(name = "api-version", value = "1.0.0"), - @ExtensionProperty(name = "last-mod-release", value = "Dublin") - }) - }) - @ApiResponses(value = { - @ApiResponse(code = 401, message = "Authentication Error"), - @ApiResponse(code = 403, message = "Authorization Error"), - @ApiResponse(code = 404, message = "Resource Not Found"), - @ApiResponse(code = 500, message = "Internal Server Error") - }) + @ResponseHeader(name = "X-MinorVersion", + description = "Used to request or communicate a MINOR version back from the client" + + " to the server, and from the server back to the client", + response = String.class), + @ResponseHeader(name = "X-PatchVersion", + description = "Used only to communicate a PATCH version in a response for" + + " troubleshooting purposes only, and will not be provided by" + + " the client on request", + response = String.class), + @ResponseHeader(name = "X-LatestVersion", + description = "Used only to communicate an API's latest version", response = String.class), + @ResponseHeader(name = "X-ONAP-RequestID", + description = "Used to track REST transactions for logging purpose", response = UUID.class)}, + authorizations = @Authorization(value = "basicAuth"), tags = {"Policy",}, + extensions = {@Extension(name = "interface info", + properties = {@ExtensionProperty(name = "api-version", value = "1.0.0"), + @ExtensionProperty(name = "last-mod-release", value = "Dublin")})}) + @ApiResponses(value = {@ApiResponse(code = 401, message = "Authentication Error"), + @ApiResponse(code = 403, message = "Authorization Error"), + @ApiResponse(code = 404, message = "Resource Not Found"), + @ApiResponse(code = 500, message = "Internal Server Error")}) public Response getAllVersionsOfPolicy( @PathParam("policyTypeId") @ApiParam(value = "ID of policy type", required = true) String policyTypeId, - @PathParam("policyTypeVersion") - @ApiParam(value = "Version of policy type", required = true) String policyTypeVersion, + @PathParam("policyTypeVersion") @ApiParam(value = "Version of policy type", + required = true) String policyTypeVersion, @PathParam("policyId") @ApiParam(value = "ID of policy", required = true) String policyId, @HeaderParam("X-ONAP-RequestID") @ApiParam("RequestID for http transaction") UUID requestId) { try (PolicyProvider policyProvider = new PolicyProvider()) { - ToscaServiceTemplate serviceTemplate = policyProvider - .fetchPolicies(policyTypeId, policyTypeVersion, policyId, null); + ToscaServiceTemplate serviceTemplate = + policyProvider.fetchPolicies(policyTypeId, policyTypeVersion, policyId, null); updateApiStatisticsCounter(Target.POLICY, Result.SUCCESS, HttpMethod.GET); return makeOkResponse(requestId, serviceTemplate); } catch (PfModelException | PfModelRuntimeException pfme) { - LOGGER.error("/policytypes/{}/versions/{}/policies/{}", policyTypeId, policyTypeVersion, policyId, - pfme); + LOGGER.debug("/policytypes/{}/versions/{}/policies/{}", policyTypeId, policyTypeVersion, policyId, pfme); updateApiStatisticsCounter(Target.POLICY, Result.FAILURE, HttpMethod.GET); return makeErrorResponse(requestId, pfme); } @@ -686,52 +589,43 @@ public class ApiRestController extends CommonRestController { notes = "Returns a particular version of specified policy created for the specified policy type version", response = ToscaServiceTemplate.class, responseHeaders = { - @ResponseHeader(name = "X-MinorVersion", - description = "Used to request or communicate a MINOR version back from the client" - + " to the server, and from the server back to the client", - response = String.class), - @ResponseHeader(name = "X-PatchVersion", - description = "Used only to communicate a PATCH version in a response for" - + " troubleshooting purposes only, and will not be provided by" - + " the client on request", - response = String.class), - @ResponseHeader(name = "X-LatestVersion", - description = "Used only to communicate an API's latest version", - response = String.class), - @ResponseHeader(name = "X-ONAP-RequestID", - description = "Used to track REST transactions for logging purpose", - response = UUID.class) - }, - authorizations = @Authorization(value = "basicAuth"), - tags = { "Policy", }, - extensions = { - @Extension(name = "interface info", properties = { - @ExtensionProperty(name = "api-version", value = "1.0.0"), - @ExtensionProperty(name = "last-mod-release", value = "Dublin") - }) - }) - @ApiResponses(value = { - @ApiResponse(code = 401, message = "Authentication Error"), - @ApiResponse(code = 403, message = "Authorization Error"), - @ApiResponse(code = 404, message = "Resource Not Found"), - @ApiResponse(code = 500, message = "Internal Server Error") - }) + @ResponseHeader(name = "X-MinorVersion", + description = "Used to request or communicate a MINOR version back from the client" + + " to the server, and from the server back to the client", + response = String.class), + @ResponseHeader(name = "X-PatchVersion", + description = "Used only to communicate a PATCH version in a response for" + + " troubleshooting purposes only, and will not be provided by" + + " the client on request", + response = String.class), + @ResponseHeader(name = "X-LatestVersion", + description = "Used only to communicate an API's latest version", response = String.class), + @ResponseHeader(name = "X-ONAP-RequestID", + description = "Used to track REST transactions for logging purpose", response = UUID.class)}, + authorizations = @Authorization(value = "basicAuth"), tags = {"Policy",}, + extensions = {@Extension(name = "interface info", + properties = {@ExtensionProperty(name = "api-version", value = "1.0.0"), + @ExtensionProperty(name = "last-mod-release", value = "Dublin")})}) + @ApiResponses(value = {@ApiResponse(code = 401, message = "Authentication Error"), + @ApiResponse(code = 403, message = "Authorization Error"), + @ApiResponse(code = 404, message = "Resource Not Found"), + @ApiResponse(code = 500, message = "Internal Server Error")}) public Response getSpecificVersionOfPolicy( @PathParam("policyTypeId") @ApiParam(value = "ID of policy type", required = true) String policyTypeId, - @PathParam("policyTypeVersion") - @ApiParam(value = "Version of policy type", required = true) String policyTypeVersion, + @PathParam("policyTypeVersion") @ApiParam(value = "Version of policy type", + required = true) String policyTypeVersion, @PathParam("policyId") @ApiParam(value = "ID of policy", required = true) String policyId, @PathParam("policyVersion") @ApiParam(value = "Version of policy", required = true) String policyVersion, @HeaderParam("X-ONAP-RequestID") @ApiParam("RequestID for http transaction") UUID requestId) { try (PolicyProvider policyProvider = new PolicyProvider()) { - ToscaServiceTemplate serviceTemplate = policyProvider - .fetchPolicies(policyTypeId, policyTypeVersion, policyId, policyVersion); + ToscaServiceTemplate serviceTemplate = + policyProvider.fetchPolicies(policyTypeId, policyTypeVersion, policyId, policyVersion); updateApiStatisticsCounter(Target.POLICY, Result.SUCCESS, HttpMethod.GET); return makeOkResponse(requestId, serviceTemplate); } catch (PfModelException | PfModelRuntimeException pfme) { - LOGGER.error("GET /policytypes/{}/versions/{}/policies/{}/versions/{}", policyTypeId, - policyTypeVersion, policyId, policyVersion, pfme); + LOGGER.debug("GET /policytypes/{}/versions/{}/policies/{}/versions/{}", policyTypeId, policyTypeVersion, + policyId, policyVersion, pfme); updateApiStatisticsCounter(Target.POLICY, Result.FAILURE, HttpMethod.GET); return makeErrorResponse(requestId, pfme); } @@ -749,43 +643,33 @@ public class ApiRestController extends CommonRestController { @GET @Path("/policytypes/{policyTypeId}/versions/{policyTypeVersion}/policies/{policyId}/versions/latest") @ApiOperation(value = "Retrieve the latest version of a particular policy", - notes = "Returns the latest version of specified policy", - response = ToscaServiceTemplate.class, + notes = "Returns the latest version of specified policy", response = ToscaServiceTemplate.class, responseHeaders = { - @ResponseHeader(name = "X-MinorVersion", - description = "Used to request or communicate a MINOR version back from the client" - + " to the server, and from the server back to the client", - response = String.class), - @ResponseHeader(name = "X-PatchVersion", - description = "Used only to communicate a PATCH version in a response for" - + " troubleshooting purposes only, and will not be provided by" - + " the client on request", - response = String.class), - @ResponseHeader(name = "X-LatestVersion", - description = "Used only to communicate an API's latest version", - response = String.class), - @ResponseHeader(name = "X-ONAP-RequestID", - description = "Used to track REST transactions for logging purpose", - response = UUID.class) - }, - authorizations = @Authorization(value = "basicAuth"), - tags = { "Policy", }, - extensions = { - @Extension(name = "interface info", properties = { - @ExtensionProperty(name = "api-version", value = "1.0.0"), - @ExtensionProperty(name = "last-mod-release", value = "Dublin") - }) - }) - @ApiResponses(value = { - @ApiResponse(code = 401, message = "Authentication Error"), - @ApiResponse(code = 403, message = "Authorization Error"), - @ApiResponse(code = 404, message = "Resource Not Found"), - @ApiResponse(code = 500, message = "Internal Server Error") - }) + @ResponseHeader(name = "X-MinorVersion", + description = "Used to request or communicate a MINOR version back from the client" + + " to the server, and from the server back to the client", + response = String.class), + @ResponseHeader(name = "X-PatchVersion", + description = "Used only to communicate a PATCH version in a response for" + + " troubleshooting purposes only, and will not be provided by" + + " the client on request", + response = String.class), + @ResponseHeader(name = "X-LatestVersion", + description = "Used only to communicate an API's latest version", response = String.class), + @ResponseHeader(name = "X-ONAP-RequestID", + description = "Used to track REST transactions for logging purpose", response = UUID.class)}, + authorizations = @Authorization(value = "basicAuth"), tags = {"Policy",}, + extensions = {@Extension(name = "interface info", + properties = {@ExtensionProperty(name = "api-version", value = "1.0.0"), + @ExtensionProperty(name = "last-mod-release", value = "Dublin")})}) + @ApiResponses(value = {@ApiResponse(code = 401, message = "Authentication Error"), + @ApiResponse(code = 403, message = "Authorization Error"), + @ApiResponse(code = 404, message = "Resource Not Found"), + @ApiResponse(code = 500, message = "Internal Server Error")}) public Response getLatestVersionOfPolicy( @PathParam("policyTypeId") @ApiParam(value = "ID of policy type", required = true) String policyTypeId, - @PathParam("policyTypeVersion") - @ApiParam(value = "Version of policy type", required = true) String policyTypeVersion, + @PathParam("policyTypeVersion") @ApiParam(value = "Version of policy type", + required = true) String policyTypeVersion, @PathParam("policyId") @ApiParam(value = "ID of policy", required = true) String policyId, @HeaderParam("X-ONAP-RequestID") @ApiParam("RequestID for http transaction") UUID requestId) { @@ -795,8 +679,8 @@ public class ApiRestController extends CommonRestController { updateApiStatisticsCounter(Target.POLICY, Result.SUCCESS, HttpMethod.GET); return makeOkResponse(requestId, serviceTemplate); } catch (PfModelException | PfModelRuntimeException pfme) { - LOGGER.error("GET /policytypes/{}/versions/{}/policies/{}/versions/latest", policyTypeId, - policyTypeVersion, policyId, pfme); + LOGGER.debug("GET /policytypes/{}/versions/{}/policies/{}/versions/latest", policyTypeId, policyTypeVersion, + policyId, pfme); updateApiStatisticsCounter(Target.POLICY, Result.FAILURE, HttpMethod.GET); return makeErrorResponse(requestId, pfme); } @@ -814,53 +698,44 @@ public class ApiRestController extends CommonRestController { @GET @Path("/policytypes/{policyTypeId}/versions/{policyTypeVersion}/policies/{policyId}/versions/deployed") @ApiOperation(value = "Retrieve deployed versions of a particular policy in pdp groups", - notes = "Returns deployed versions of specified policy in pdp groups", - response = ToscaPolicy.class, responseContainer = "List", + notes = "Returns deployed versions of specified policy in pdp groups", response = ToscaPolicy.class, + responseContainer = "List", responseHeaders = { - @ResponseHeader(name = "X-MinorVersion", - description = "Used to request or communicate a MINOR version back from the client" - + " to the server, and from the server back to the client", - response = String.class), - @ResponseHeader(name = "X-PatchVersion", - description = "Used only to communicate a PATCH version in a response for" - + " troubleshooting purposes only, and will not be provided by" - + " the client on request", - response = String.class), - @ResponseHeader(name = "X-LatestVersion", - description = "Used only to communicate an API's latest version", - response = String.class), - @ResponseHeader(name = "X-ONAP-RequestID", - description = "Used to track REST transactions for logging purpose", - response = UUID.class) - }, - authorizations = @Authorization(value = "basicAuth"), - tags = { "Policy", }, - extensions = { - @Extension(name = "interface info", properties = { - @ExtensionProperty(name = "api-version", value = "1.0.0"), - @ExtensionProperty(name = "last-mod-release", value = "Dublin") - }) - }) - @ApiResponses(value = { - @ApiResponse(code = 401, message = "Authentication Error"), - @ApiResponse(code = 403, message = "Authorization Error"), - @ApiResponse(code = 404, message = "Resource Not Found"), - @ApiResponse(code = 500, message = "Internal Server Error") - }) + @ResponseHeader(name = "X-MinorVersion", + description = "Used to request or communicate a MINOR version back from the client" + + " to the server, and from the server back to the client", + response = String.class), + @ResponseHeader(name = "X-PatchVersion", + description = "Used only to communicate a PATCH version in a response for" + + " troubleshooting purposes only, and will not be provided by" + + " the client on request", + response = String.class), + @ResponseHeader(name = "X-LatestVersion", + description = "Used only to communicate an API's latest version", response = String.class), + @ResponseHeader(name = "X-ONAP-RequestID", + description = "Used to track REST transactions for logging purpose", response = UUID.class)}, + authorizations = @Authorization(value = "basicAuth"), tags = {"Policy",}, + extensions = {@Extension(name = "interface info", + properties = {@ExtensionProperty(name = "api-version", value = "1.0.0"), + @ExtensionProperty(name = "last-mod-release", value = "Dublin")})}) + @ApiResponses(value = {@ApiResponse(code = 401, message = "Authentication Error"), + @ApiResponse(code = 403, message = "Authorization Error"), + @ApiResponse(code = 404, message = "Resource Not Found"), + @ApiResponse(code = 500, message = "Internal Server Error")}) public Response getDeployedVersionsOfPolicy( @PathParam("policyTypeId") @ApiParam(value = "ID of policy type", required = true) String policyTypeId, - @PathParam("policyTypeVersion") - @ApiParam(value = "Version of policy type", required = true) String policyTypeVersion, + @PathParam("policyTypeVersion") @ApiParam(value = "Version of policy type", + required = true) String policyTypeVersion, @PathParam("policyId") @ApiParam(value = "ID of policy", required = true) String policyId, @HeaderParam("X-ONAP-RequestID") @ApiParam("RequestID for http transaction") UUID requestId) { try (PolicyProvider policyProvider = new PolicyProvider()) { - Map, List> deployedPolicies = policyProvider - .fetchDeployedPolicies(policyTypeId, policyTypeVersion, policyId); + Map, List> deployedPolicies = + policyProvider.fetchDeployedPolicies(policyTypeId, policyTypeVersion, policyId); updateApiStatisticsCounter(Target.POLICY, Result.SUCCESS, HttpMethod.GET); return makeOkResponse(requestId, deployedPolicies); } catch (PfModelException | PfModelRuntimeException pfme) { - LOGGER.error("GET /policytypes/{}/versions/{}/policies/{}/versions/deployed", policyTypeId, + LOGGER.debug("GET /policytypes/{}/versions/{}/policies/{}/versions/deployed", policyTypeId, policyTypeVersion, policyId, pfme); updateApiStatisticsCounter(Target.POLICY, Result.FAILURE, HttpMethod.GET); return makeErrorResponse(requestId, pfme); @@ -880,59 +755,48 @@ public class ApiRestController extends CommonRestController { @Path("/policytypes/{policyTypeId}/versions/{policyTypeVersion}/policies") @ApiOperation(value = "Create a new policy for a policy type version", notes = "Client should provide TOSCA body of the new policy", - authorizations = @Authorization(value = "basicAuth"), - tags = { "Policy", }, + authorizations = @Authorization(value = "basicAuth"), tags = {"Policy",}, response = ToscaServiceTemplate.class, responseHeaders = { - @ResponseHeader(name = "X-MinorVersion", - description = "Used to request or communicate a MINOR version back from the client" - + " to the server, and from the server back to the client", - response = String.class), - @ResponseHeader(name = "X-PatchVersion", - description = "Used only to communicate a PATCH version in a response for" - + " troubleshooting purposes only, and will not be provided by" - + " the client on request", - response = String.class), - @ResponseHeader(name = "X-LatestVersion", - description = "Used only to communicate an API's latest version", - response = String.class), - @ResponseHeader(name = "X-ONAP-RequestID", - description = "Used to track REST transactions for logging purpose", - response = UUID.class) - }, - extensions = { - @Extension(name = "interface info", properties = { - @ExtensionProperty(name = "api-version", value = "1.0.0"), - @ExtensionProperty(name = "last-mod-release", value = "Dublin") - }) - }) - @ApiResponses(value = { - @ApiResponse(code = 400, message = "Invalid Body"), - @ApiResponse(code = 401, message = "Authentication Error"), - @ApiResponse(code = 403, message = "Authorization Error"), - @ApiResponse(code = 404, message = "Resource Not Found"), - @ApiResponse(code = 500, message = "Internal Server Error") - }) + @ResponseHeader(name = "X-MinorVersion", + description = "Used to request or communicate a MINOR version back from the client" + + " to the server, and from the server back to the client", + response = String.class), + @ResponseHeader(name = "X-PatchVersion", + description = "Used only to communicate a PATCH version in a response for" + + " troubleshooting purposes only, and will not be provided by" + + " the client on request", + response = String.class), + @ResponseHeader(name = "X-LatestVersion", + description = "Used only to communicate an API's latest version", response = String.class), + @ResponseHeader(name = "X-ONAP-RequestID", + description = "Used to track REST transactions for logging purpose", response = UUID.class)}, + extensions = {@Extension(name = "interface info", + properties = {@ExtensionProperty(name = "api-version", value = "1.0.0"), + @ExtensionProperty(name = "last-mod-release", value = "Dublin")})}) + @ApiResponses(value = {@ApiResponse(code = 400, message = "Invalid Body"), + @ApiResponse(code = 401, message = "Authentication Error"), + @ApiResponse(code = 403, message = "Authorization Error"), + @ApiResponse(code = 404, message = "Resource Not Found"), + @ApiResponse(code = 500, message = "Internal Server Error")}) public Response createPolicy( @PathParam("policyTypeId") @ApiParam(value = "ID of policy type", required = true) String policyTypeId, - @PathParam("policyTypeVersion") - @ApiParam(value = "Version of policy type", required = true) String policyTypeVersion, + @PathParam("policyTypeVersion") @ApiParam(value = "Version of policy type", + required = true) String policyTypeVersion, @HeaderParam("X-ONAP-RequestID") @ApiParam("RequestID for http transaction") UUID requestId, @ApiParam(value = "Entity body of policy", required = true) ToscaServiceTemplate body) { if (NetLoggerUtil.getNetworkLogger().isInfoEnabled()) { NetLoggerUtil.log(EventType.IN, CommInfrastructure.REST, - "/policytypes/" + policyTypeId + "/versions/" + policyTypeVersion + "/policies", - toJson(body)); + "/policytypes/" + policyTypeId + "/versions/" + policyTypeVersion + "/policies", toJson(body)); } try (PolicyProvider policyProvider = new PolicyProvider()) { - ToscaServiceTemplate serviceTemplate = policyProvider - .createPolicy(policyTypeId, policyTypeVersion, body); + ToscaServiceTemplate serviceTemplate = policyProvider.createPolicy(policyTypeId, policyTypeVersion, body); updateApiStatisticsCounter(Target.POLICY, Result.SUCCESS, HttpMethod.POST); return makeOkResponse(requestId, serviceTemplate); } catch (PfModelException | PfModelRuntimeException pfme) { - LOGGER.error("POST /policytypes/{}/versions/{}/policies", policyTypeId, policyTypeVersion, pfme); + LOGGER.debug("POST /policytypes/{}/versions/{}/policies", policyTypeId, policyTypeVersion, pfme); updateApiStatisticsCounter(Target.POLICY, Result.FAILURE, HttpMethod.POST); return makeErrorResponse(requestId, pfme); } @@ -949,39 +813,30 @@ public class ApiRestController extends CommonRestController { @Path("/policies") @ApiOperation(value = "Create one or more new policies", notes = "Client should provide TOSCA body of the new polic(ies)", - authorizations = @Authorization(value = "basicAuth"), - tags = { "Policy", }, + authorizations = @Authorization(value = "basicAuth"), tags = {"Policy",}, response = ToscaServiceTemplate.class, responseHeaders = { - @ResponseHeader(name = "X-MinorVersion", - description = "Used to request or communicate a MINOR version back from the client" - + " to the server, and from the server back to the client", - response = String.class), - @ResponseHeader(name = "X-PatchVersion", - description = "Used only to communicate a PATCH version in a response for" - + " troubleshooting purposes only, and will not be provided by" - + " the client on request", - response = String.class), - @ResponseHeader(name = "X-LatestVersion", - description = "Used only to communicate an API's latest version", - response = String.class), - @ResponseHeader(name = "X-ONAP-RequestID", - description = "Used to track REST transactions for logging purpose", - response = UUID.class) - }, - extensions = { - @Extension(name = "interface info", properties = { - @ExtensionProperty(name = "api-version", value = "1.0.0"), - @ExtensionProperty(name = "last-mod-release", value = "El Alto") - }) - }) - @ApiResponses(value = { - @ApiResponse(code = 400, message = "Invalid Body"), - @ApiResponse(code = 401, message = "Authentication Error"), - @ApiResponse(code = 403, message = "Authorization Error"), - @ApiResponse(code = 404, message = "Resource Not Found"), - @ApiResponse(code = 500, message = "Internal Server Error") - }) + @ResponseHeader(name = "X-MinorVersion", + description = "Used to request or communicate a MINOR version back from the client" + + " to the server, and from the server back to the client", + response = String.class), + @ResponseHeader(name = "X-PatchVersion", + description = "Used only to communicate a PATCH version in a response for" + + " troubleshooting purposes only, and will not be provided by" + + " the client on request", + response = String.class), + @ResponseHeader(name = "X-LatestVersion", + description = "Used only to communicate an API's latest version", response = String.class), + @ResponseHeader(name = "X-ONAP-RequestID", + description = "Used to track REST transactions for logging purpose", response = UUID.class)}, + extensions = {@Extension(name = "interface info", + properties = {@ExtensionProperty(name = "api-version", value = "1.0.0"), + @ExtensionProperty(name = "last-mod-release", value = "El Alto")})}) + @ApiResponses(value = {@ApiResponse(code = 400, message = "Invalid Body"), + @ApiResponse(code = 401, message = "Authentication Error"), + @ApiResponse(code = 403, message = "Authorization Error"), + @ApiResponse(code = 404, message = "Resource Not Found"), + @ApiResponse(code = 500, message = "Internal Server Error")}) public Response createPolicies( @HeaderParam("X-ONAP-RequestID") @ApiParam("RequestID for http transaction") UUID requestId, @ApiParam(value = "Entity body of policy", required = true) ToscaServiceTemplate body) { @@ -995,7 +850,7 @@ public class ApiRestController extends CommonRestController { updateApiStatisticsCounter(Target.POLICY, Result.SUCCESS, HttpMethod.POST); return makeOkResponse(requestId, serviceTemplate); } catch (PfModelException | PfModelRuntimeException pfme) { - LOGGER.error("POST /policies", pfme); + LOGGER.debug("POST /policies", pfme); updateApiStatisticsCounter(Target.POLICY, Result.FAILURE, HttpMethod.POST); return makeErrorResponse(requestId, pfme); } @@ -1015,68 +870,63 @@ public class ApiRestController extends CommonRestController { @Path("/policytypes/{policyTypeId}/versions/{policyTypeVersion}/policies/{policyId}/versions/{policyVersion}") @ApiOperation(value = "Delete a particular version of a policy", notes = "Rule: the version that has been deployed in PDP group(s) cannot be deleted", - authorizations = @Authorization(value = "basicAuth"), - tags = { "Policy", }, + authorizations = @Authorization(value = "basicAuth"), tags = {"Policy",}, response = ToscaServiceTemplate.class, responseHeaders = { - @ResponseHeader(name = "X-MinorVersion", - description = "Used to request or communicate a MINOR version back from the client" - + " to the server, and from the server back to the client", - response = String.class), - @ResponseHeader(name = "X-PatchVersion", - description = "Used only to communicate a PATCH version in a response for" - + " troubleshooting purposes only, and will not be provided by" - + " the client on request", - response = String.class), - @ResponseHeader(name = "X-LatestVersion", - description = "Used only to communicate an API's latest version", - response = String.class), - @ResponseHeader(name = "X-ONAP-RequestID", - description = "Used to track REST transactions for logging purpose", - response = UUID.class) - }, - extensions = { - @Extension(name = "interface info", properties = { - @ExtensionProperty(name = "api-version", value = "1.0.0"), - @ExtensionProperty(name = "last-mod-release", value = "Dublin") - }) - }) - @ApiResponses(value = { - @ApiResponse(code = 401, message = "Authentication Error"), - @ApiResponse(code = 403, message = "Authorization Error"), - @ApiResponse(code = 404, message = "Resource Not Found"), - @ApiResponse(code = 409, message = "Delete Conflict, Rule Violation"), - @ApiResponse(code = 500, message = "Internal Server Error") - }) + @ResponseHeader(name = "X-MinorVersion", + description = "Used to request or communicate a MINOR version back from the client" + + " to the server, and from the server back to the client", + response = String.class), + @ResponseHeader(name = "X-PatchVersion", + description = "Used only to communicate a PATCH version in a response for" + + " troubleshooting purposes only, and will not be provided by" + + " the client on request", + response = String.class), + @ResponseHeader(name = "X-LatestVersion", + description = "Used only to communicate an API's latest version", response = String.class), + @ResponseHeader(name = "X-ONAP-RequestID", + description = "Used to track REST transactions for logging purpose", response = UUID.class)}, + extensions = {@Extension(name = "interface info", + properties = {@ExtensionProperty(name = "api-version", value = "1.0.0"), + @ExtensionProperty(name = "last-mod-release", value = "Dublin")})}) + @ApiResponses(value = {@ApiResponse(code = 401, message = "Authentication Error"), + @ApiResponse(code = 403, message = "Authorization Error"), + @ApiResponse(code = 404, message = "Resource Not Found"), + @ApiResponse(code = 409, message = "Delete Conflict, Rule Violation"), + @ApiResponse(code = 500, message = "Internal Server Error")}) public Response deleteSpecificVersionOfPolicy( @PathParam("policyTypeId") @ApiParam(value = "PolicyType ID", required = true) String policyTypeId, - @PathParam("policyTypeVersion") - @ApiParam(value = "Version of policy type", required = true) String policyTypeVersion, + @PathParam("policyTypeVersion") @ApiParam(value = "Version of policy type", + required = true) String policyTypeVersion, @PathParam("policyId") @ApiParam(value = "ID of policy", required = true) String policyId, @PathParam("policyVersion") @ApiParam(value = "Version of policy", required = true) String policyVersion, @HeaderParam("X-ONAP-RequestID") @ApiParam("RequestID for http transaction") UUID requestId) { try (PolicyProvider policyProvider = new PolicyProvider()) { - ToscaServiceTemplate serviceTemplate = policyProvider - .deletePolicy(policyTypeId, policyTypeVersion, policyId, policyVersion); + ToscaServiceTemplate serviceTemplate = + policyProvider.deletePolicy(policyTypeId, policyTypeVersion, policyId, policyVersion); return makeOkResponse(requestId, serviceTemplate); } catch (PfModelException | PfModelRuntimeException pfme) { - LOGGER.error("DELETE /policytypes/{}/versions/{}/policies/{}/versions/{}", policyTypeId, - policyTypeVersion, policyId, policyVersion, pfme); + LOGGER.debug("DELETE /policytypes/{}/versions/{}/policies/{}/versions/{}", policyTypeId, policyTypeVersion, + policyId, policyVersion, pfme); return makeErrorResponse(requestId, pfme); } } private enum Target { - POLICY, POLICY_TYPE, OTHER + POLICY, + POLICY_TYPE, + OTHER } private enum Result { - SUCCESS, FAILURE + SUCCESS, + FAILURE } private enum HttpMethod { - POST, GET + POST, + GET } private void updateApiStatisticsCounter(Target target, Result result, HttpMethod http) {