summaryrefslogtreecommitdiffstats
path: root/applications/guard/src/main
diff options
context:
space:
mode:
authorPamela Dragosh <pdragosh@research.att.com>2019-10-22 13:06:56 -0400
committerPamela Dragosh <pdragosh@research.att.com>2019-10-23 09:19:24 -0400
commit5bc83b197ad010bbdf5916493d078818c2c10bcb (patch)
treec4cc4bcf283047ebb71e2f338048a1f1760be11c /applications/guard/src/main
parentfc07c32a4c01a2541c8061a37c3c6589c720e2b3 (diff)
Consolidate common translatable code some sonar
There is duplicate code for some common translation of policy decision responses and for scanning obligations. Removed some TODO items (left others because I want to look at them more closely). Stored System.lineSeparator into a static var so that I can remove some unnecessary ifs. There's still one left that I am not worried about. Gson as a static variable. Issue-ID: POLICY-2066 Change-Id: I9c8162d5ad1c5f884be347dd94631fa74ca76f85 Signed-off-by: Pamela Dragosh <pdragosh@research.att.com>
Diffstat (limited to 'applications/guard/src/main')
-rw-r--r--applications/guard/src/main/java/org/onap/policy/xacml/pdp/application/guard/CoordinationGuardTranslator.java3
-rw-r--r--applications/guard/src/main/java/org/onap/policy/xacml/pdp/application/guard/LegacyGuardTranslator.java8
2 files changed, 2 insertions, 9 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 92e0301d..eb793f69 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
@@ -50,6 +50,7 @@ import org.onap.policy.models.decisions.concepts.DecisionResponse;
import org.onap.policy.models.tosca.authorative.concepts.ToscaPolicy;
import org.onap.policy.pdp.xacml.application.common.ToscaPolicyConversionException;
import org.onap.policy.pdp.xacml.application.common.ToscaPolicyTranslator;
+import org.onap.policy.pdp.xacml.application.common.XacmlPolicyUtils;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
@@ -153,7 +154,7 @@ public class CoordinationGuardTranslator implements ToscaPolicyTranslator {
return stream.map(s -> s.replaceAll("UNIQUE_ID", uniqueId))
.map(s -> s.replaceAll("CONTROL_LOOP_ONE", cLOne))
.map(s -> s.replaceAll("CONTROL_LOOP_TWO", cLTwo))
- .collect(Collectors.joining(System.lineSeparator()));
+ .collect(Collectors.joining(XacmlPolicyUtils.LINE_SEPARATOR));
} catch (IOException e) {
throw new
ToscaPolicyConversionException("Error while generating XACML policy for coordination directive", e);
diff --git a/applications/guard/src/main/java/org/onap/policy/xacml/pdp/application/guard/LegacyGuardTranslator.java b/applications/guard/src/main/java/org/onap/policy/xacml/pdp/application/guard/LegacyGuardTranslator.java
index 3ccbd9cd..0cb06ea0 100644
--- a/applications/guard/src/main/java/org/onap/policy/xacml/pdp/application/guard/LegacyGuardTranslator.java
+++ b/applications/guard/src/main/java/org/onap/policy/xacml/pdp/application/guard/LegacyGuardTranslator.java
@@ -342,10 +342,6 @@ public class LegacyGuardTranslator implements ToscaPolicyTranslator {
//
permit.setCondition(condition);
//
- // TODO Add the advice - Is the request id needed to be returned?
- //
- // permit . setAdviceExpressions (adviceExpressions)
- //
// Done
//
return permit;
@@ -400,10 +396,6 @@ public class LegacyGuardTranslator implements ToscaPolicyTranslator {
//
permit.setCondition(createCondition(timeRange, minApply, maxApply));
//
- // TODO Add the advice - Is the request id needed to be returned?
- //
- // permit . setAdviceExpressions (adviceExpressions)
- //
// Done
//
return permit;