From 2924fa7d806435a3bf9f2cb5abcdb01aa7295b00 Mon Sep 17 00:00:00 2001 From: Pamela Dragosh Date: Wed, 11 Mar 2020 14:06:42 -0400 Subject: Better error handling for decisions Throw exceptions when requests cannot be created and return error information back. Consolidated some code to avoid sonar duplication issues. Companion review to https://gerrit.onap.org/r/c/policy/models/+/103548 Issue-ID: POLICY-2242 Change-Id: Ic873af933dab82e3aeef6335f55939666be20385 Signed-off-by: Pamela Dragosh --- .../optimization/OptimizationPdpApplication.java | 18 ++++-------------- 1 file changed, 4 insertions(+), 14 deletions(-) (limited to 'applications/optimization/src') diff --git a/applications/optimization/src/main/java/org/onap/policy/xacml/pdp/application/optimization/OptimizationPdpApplication.java b/applications/optimization/src/main/java/org/onap/policy/xacml/pdp/application/optimization/OptimizationPdpApplication.java index ee1ccdce..5a8978f7 100644 --- a/applications/optimization/src/main/java/org/onap/policy/xacml/pdp/application/optimization/OptimizationPdpApplication.java +++ b/applications/optimization/src/main/java/org/onap/policy/xacml/pdp/application/optimization/OptimizationPdpApplication.java @@ -25,7 +25,6 @@ package org.onap.policy.xacml.pdp.application.optimization; import com.att.research.xacml.api.Advice; import com.att.research.xacml.api.AttributeAssignment; import com.att.research.xacml.api.Decision; -import com.att.research.xacml.api.Request; import com.att.research.xacml.api.Response; import com.att.research.xacml.api.Result; import java.nio.file.Path; @@ -180,25 +179,16 @@ public class OptimizationPdpApplication extends StdXacmlApplicationServiceProvid } } // - // Convert to a XacmlRequest + // Make the decision // - Request xacmlRequest = this.getTranslator().convertRequest(request); - // - // Now get a decision - // - Response xacmlResponse = this.xacmlDecision(xacmlRequest); - // - // Convert to a DecisionResponse - // - Pair returnPair = Pair.of(this.getTranslator().convertResponse(xacmlResponse), - xacmlResponse); + Pair decisionPair = super.makeDecision(request, requestQueryParams); // // Add back in advice from subscriber // if (xacmlSubscriberResponse != null) { - addSubscriberAdvice(xacmlSubscriberResponse, returnPair.getLeft()); + addSubscriberAdvice(xacmlSubscriberResponse, decisionPair.getLeft()); } - return returnPair; + return decisionPair; } @Override -- cgit 1.2.3-korg