From c19f81387f4efc666cfa45b000275f3ee7c1d9d1 Mon Sep 17 00:00:00 2001 From: Pamela Dragosh Date: Mon, 16 Sep 2019 13:09:46 -0400 Subject: Sonar xacml-pdp issues Either log or re-throw exception Refactor to not nest more than 3 statements Refactor to throw at most one exception Move variable to comply with Java Code conventions String literal on LHS Issue-ID: POLICY-2079 Change-Id: Iac33623ef4694cf38c4a69c8f0b9040d8439998e Signed-off-by: Pamela Dragosh --- .../java/org/onap/policy/pdpx/main/rest/XacmlPdpRestController.java | 5 +++++ 1 file changed, 5 insertions(+) (limited to 'main/src') diff --git a/main/src/main/java/org/onap/policy/pdpx/main/rest/XacmlPdpRestController.java b/main/src/main/java/org/onap/policy/pdpx/main/rest/XacmlPdpRestController.java index 3de830e3..5b17c34e 100644 --- a/main/src/main/java/org/onap/policy/pdpx/main/rest/XacmlPdpRestController.java +++ b/main/src/main/java/org/onap/policy/pdpx/main/rest/XacmlPdpRestController.java @@ -55,6 +55,8 @@ import org.onap.policy.pdpx.main.rest.model.StatisticsReport; import org.onap.policy.pdpx.main.rest.provider.DecisionProvider; import org.onap.policy.pdpx.main.rest.provider.HealthCheckProvider; import org.onap.policy.pdpx.main.rest.provider.StatisticsProvider; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; /** * Class to provide xacml pdp REST services. @@ -70,8 +72,10 @@ import org.onap.policy.pdpx.main.rest.provider.StatisticsProvider; schemes = {SwaggerDefinition.Scheme.HTTP, SwaggerDefinition.Scheme.HTTPS}, securityDefinition = @SecurityDefinition(basicAuthDefinitions = {@BasicAuthDefinition(key = "basicAuth")})) public class XacmlPdpRestController { + private static final Logger LOGGER = LoggerFactory.getLogger(XacmlPdpRestController.class); public static final String APPLICATION_YAML = "application/yaml"; + @GET @Path("/healthcheck") @ApiOperation(value = "Perform a system healthcheck", @@ -176,6 +180,7 @@ public class XacmlPdpRestController { return addLoggingHeaders(addVersionControlHeaders(Response.status(Response.Status.OK)), requestId) .entity(new DecisionProvider().fetchDecision(body)).build(); } catch (DecisionException e) { + LOGGER.error("Decision exception", e); XacmlPdpStatisticsManager.getCurrent().updateErrorCount(); return addLoggingHeaders( addVersionControlHeaders(Response.status((e.getErrorResponse().getResponseCode()))), requestId) -- cgit 1.2.3-korg