aboutsummaryrefslogtreecommitdiffstats
path: root/applications/guard/src/main
diff options
context:
space:
mode:
Diffstat (limited to 'applications/guard/src/main')
-rw-r--r--applications/guard/src/main/java/org/onap/policy/xacml/pdp/application/guard/CoordinationGuardTranslator.java5
-rw-r--r--applications/guard/src/main/java/org/onap/policy/xacml/pdp/application/guard/GuardPolicyRequest.java18
-rw-r--r--applications/guard/src/main/java/org/onap/policy/xacml/pdp/application/guard/GuardTranslator.java8
3 files changed, 14 insertions, 17 deletions
diff --git a/applications/guard/src/main/java/org/onap/policy/xacml/pdp/application/guard/CoordinationGuardTranslator.java b/applications/guard/src/main/java/org/onap/policy/xacml/pdp/application/guard/CoordinationGuardTranslator.java
index 60fac498..f1006c6d 100644
--- a/applications/guard/src/main/java/org/onap/policy/xacml/pdp/application/guard/CoordinationGuardTranslator.java
+++ b/applications/guard/src/main/java/org/onap/policy/xacml/pdp/application/guard/CoordinationGuardTranslator.java
@@ -99,9 +99,8 @@ public class CoordinationGuardTranslator implements ToscaPolicyTranslator {
* the one in LegacyGuardTranslator is used.
*/
@Override
- public Request convertRequest(DecisionRequest request) {
- LOGGER.info("this convertRequest shouldn't be used");
- return null;
+ public Request convertRequest(DecisionRequest request) throws ToscaPolicyConversionException {
+ throw new ToscaPolicyConversionException("this convertRequest shouldn't be used");
}
/**
diff --git a/applications/guard/src/main/java/org/onap/policy/xacml/pdp/application/guard/GuardPolicyRequest.java b/applications/guard/src/main/java/org/onap/policy/xacml/pdp/application/guard/GuardPolicyRequest.java
index 51d8f0ed..1e3e9150 100644
--- a/applications/guard/src/main/java/org/onap/policy/xacml/pdp/application/guard/GuardPolicyRequest.java
+++ b/applications/guard/src/main/java/org/onap/policy/xacml/pdp/application/guard/GuardPolicyRequest.java
@@ -34,13 +34,13 @@ import lombok.Setter;
import lombok.ToString;
import org.onap.policy.models.decisions.concepts.DecisionRequest;
+import org.onap.policy.pdp.xacml.application.common.ToscaPolicyConversionException;
@Getter
@Setter
@ToString
@XACMLRequest(ReturnPolicyIdList = true)
public class GuardPolicyRequest {
-
private static final String STR_GUARD = "guard";
@XACMLSubject(includeInResults = true)
@@ -82,9 +82,11 @@ public class GuardPolicyRequest {
*
* @param decisionRequest Input DecisionRequest
* @return StdMetadataPolicyRequest
+ * @throws ToscaPolicyConversionException If we cannot parse the request
*/
@SuppressWarnings("unchecked")
- public static GuardPolicyRequest createInstance(DecisionRequest decisionRequest) {
+ public static GuardPolicyRequest createInstance(DecisionRequest decisionRequest)
+ throws ToscaPolicyConversionException {
//
// Create our return object
//
@@ -133,14 +135,14 @@ public class GuardPolicyRequest {
request.targetId = guard.get("target").toString();
}
if (guard.containsKey("vfCount")) {
- //
- // TODO this can potentially throw a NumberFormatException. Fix this to
- // throw the exception when you fix the ConvertRequest to throw exceptions also.
- //
- request.vfCount = Integer.decode(guard.get("vfCount").toString());
+ try {
+ request.vfCount = Integer.decode(guard.get("vfCount").toString());
+ } catch (NumberFormatException e) {
+ throw new ToscaPolicyConversionException("Failed to decode vfCount", e);
+ }
}
return request;
}
-}
+} \ No newline at end of file
diff --git a/applications/guard/src/main/java/org/onap/policy/xacml/pdp/application/guard/GuardTranslator.java b/applications/guard/src/main/java/org/onap/policy/xacml/pdp/application/guard/GuardTranslator.java
index 4365cad6..fd46a988 100644
--- a/applications/guard/src/main/java/org/onap/policy/xacml/pdp/application/guard/GuardTranslator.java
+++ b/applications/guard/src/main/java/org/onap/policy/xacml/pdp/application/guard/GuardTranslator.java
@@ -140,17 +140,13 @@ public class GuardTranslator implements ToscaPolicyTranslator {
/**
* Convert Request.
*/
- public Request convertRequest(DecisionRequest request) {
+ public Request convertRequest(DecisionRequest request) throws ToscaPolicyConversionException {
LOGGER.info("Converting Request {}", request);
try {
return RequestParser.parseRequest(GuardPolicyRequest.createInstance(request));
} catch (IllegalArgumentException | IllegalAccessException | DataTypeException e) {
- LOGGER.error("Failed to convert DecisionRequest", e);
+ throw new ToscaPolicyConversionException("Failed to convert DecisionRequest", e);
}
- //
- // TODO throw exception
- //
- return null;
}
/**