aboutsummaryrefslogtreecommitdiffstats
path: root/applications/guard/src/main/java
diff options
context:
space:
mode:
Diffstat (limited to 'applications/guard/src/main/java')
-rw-r--r--applications/guard/src/main/java/org/onap/policy/xacml/pdp/application/guard/CoordinationGuardTranslator.java11
-rw-r--r--applications/guard/src/main/java/org/onap/policy/xacml/pdp/application/guard/GuardPolicyRequest.java14
2 files changed, 19 insertions, 6 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 d20a25f0..126955e7 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
@@ -113,6 +113,9 @@ public class CoordinationGuardTranslator implements ToscaPolicyTranslator {
*/
public static CoordinationDirective loadCoordinationDirectiveFromFile(
String directiveFilename) {
+ if (directiveFilename == null) {
+ return null;
+ }
try (InputStream is = new FileInputStream(new File(directiveFilename))) {
String contents = IOUtils.toString(is, StandardCharsets.UTF_8);
//
@@ -142,19 +145,19 @@ public class CoordinationGuardTranslator implements ToscaPolicyTranslator {
*/
String xacmlProtoFilename =
protoDir + File.separator + cd.getCoordinationFunction() + ".xml";
- LOGGER.debug("xacmlProtoFilename={}", xacmlProtoFilename);
+ LOGGER.info("xacmlProtoFilename={}", xacmlProtoFilename);
/*
- * Values to be used for placeholders
+ * Values to be substituted for placeholder's
*/
final String uniqueId = UUID.randomUUID().toString();
final String cLOne = cd.getControlLoop(0);
final String cLTwo = cd.getControlLoop(1);
/*
- * Replace function placeholders with appropriate values
+ * Replace function placeholder's with appropriate values
*/
String policyXml = ResourceUtils.getResourceAsString(xacmlProtoFilename);
if (policyXml == null) {
- throw new ToscaPolicyConversionException("Error while generating XACML policy for coordination directive");
+ throw new ToscaPolicyConversionException("Unable to find prototype " + xacmlProtoFilename);
}
policyXml = policyXml.replace("UNIQUE_ID", uniqueId);
policyXml = policyXml.replace("CONTROL_LOOP_ONE", cLOne);
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 72c8ddd2..87635963 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
@@ -139,6 +139,13 @@ public class GuardPolicyRequest {
//
// Find our fields
//
+ findFields(request, guard);
+ findFilterFields(request, guard);
+ return request;
+ }
+
+ private static GuardPolicyRequest findFields(GuardPolicyRequest request, Map<String, Object> guard)
+ throws ToscaPolicyConversionException {
if (guard.containsKey("actor")) {
request.actorId = guard.get("actor").toString();
}
@@ -158,6 +165,11 @@ public class GuardPolicyRequest {
throw new ToscaPolicyConversionException("Failed to decode vfCount", e);
}
}
+
+ return request;
+ }
+
+ private static GuardPolicyRequest findFilterFields(GuardPolicyRequest request, Map<String, Object> guard) {
if (guard.containsKey("generic-vnf.vnf-name")) {
request.vnfName = guard.get("generic-vnf.vnf-name").toString();
}
@@ -176,8 +188,6 @@ public class GuardPolicyRequest {
if (guard.containsKey("cloud-region.cloud-region-id")) {
request.cloudRegionId = guard.get("cloud-region.cloud-region-id").toString();
}
-
return request;
}
-
}