aboutsummaryrefslogtreecommitdiffstats
path: root/controlloop/templates
diff options
context:
space:
mode:
authorJoshua Reich <jreich@research.att.com>2018-09-21 16:44:25 -0700
committerJoshua Reich <jreich@research.att.com>2018-09-27 12:53:38 -0700
commitdaa096b8149e18e69e1344e01cf4627d7e0dede5 (patch)
treec8dd5ea368d5ef615bb5e3780fcf751de4371c99 /controlloop/templates
parent72d5a239ff15617b2d218d3b8f3f8a2099007142 (diff)
Yet more sonar issues in drools-applications
removed unused imports and variable definitions moved variable declarations above methods refactored deeply nested if/while removed code smell due to unecessary use of static keyword moved string literals to left side of comparator fixed logging of exceptions immediately return expression instead of assigning it to the temporary variable Change-Id: Idfd2a2bdf3c2f3bbfcb54a06b713d57bc867b3ab Issue-ID: POLICY-1129 Signed-off-by: Joshua Reich <jreich@research.att.com>
Diffstat (limited to 'controlloop/templates')
-rw-r--r--controlloop/templates/template.demo.clc/src/main/java/org/onap/policy/guard/CallGuardTaskEmbedded.java2
-rw-r--r--controlloop/templates/template.demo.clc/src/main/java/org/onap/policy/guard/PolicyGuardXacmlHelperEmbedded.java25
2 files changed, 13 insertions, 14 deletions
diff --git a/controlloop/templates/template.demo.clc/src/main/java/org/onap/policy/guard/CallGuardTaskEmbedded.java b/controlloop/templates/template.demo.clc/src/main/java/org/onap/policy/guard/CallGuardTaskEmbedded.java
index 7abf38620..c75c8a0b7 100644
--- a/controlloop/templates/template.demo.clc/src/main/java/org/onap/policy/guard/CallGuardTaskEmbedded.java
+++ b/controlloop/templates/template.demo.clc/src/main/java/org/onap/policy/guard/CallGuardTaskEmbedded.java
@@ -151,7 +151,7 @@ public class CallGuardTaskEmbedded implements Runnable {
//
// Create an artificial Guard response in case we didn't get a clear Permit or Deny
//
- if (guardResponse.getResult().equals("Indeterminate")) {
+ if ("Indeterminate".equals(guardResponse.getResult())) {
guardResponse.setOperation(recipe);
guardResponse.setRequestID(UUID.fromString(requestId));
}
diff --git a/controlloop/templates/template.demo.clc/src/main/java/org/onap/policy/guard/PolicyGuardXacmlHelperEmbedded.java b/controlloop/templates/template.demo.clc/src/main/java/org/onap/policy/guard/PolicyGuardXacmlHelperEmbedded.java
index e14946274..64fb70bbd 100644
--- a/controlloop/templates/template.demo.clc/src/main/java/org/onap/policy/guard/PolicyGuardXacmlHelperEmbedded.java
+++ b/controlloop/templates/template.demo.clc/src/main/java/org/onap/policy/guard/PolicyGuardXacmlHelperEmbedded.java
@@ -60,9 +60,14 @@ public class PolicyGuardXacmlHelperEmbedded {
private static final Logger netLogger =
LoggerFactory.getLogger(org.onap.policy.common.endpoints.event.comm.Topic.NETWORK_LOGGER);
- // Constant for the systme line separator
+ // Constant for the system line separator
private static final String SYSTEM_LS = System.lineSeparator();
- private static String propfile;
+ private String propfile;
+ private UrlEntry[] restUrls = null;
+ private int restUrlIndex = 0;
+
+ // REST timeout, initialized from 'pdpx.timeout' property
+ private int timeout = 20000;
public PolicyGuardXacmlHelperEmbedded() {
init(PolicyEngine.manager.getEnvironment());
@@ -82,12 +87,6 @@ public class PolicyGuardXacmlHelperEmbedded {
String environment = null;
}
- private UrlEntry[] restUrls = null;
- private int restUrlIndex = 0;
-
- // REST timeout, initialized from 'pdpx.timeout' property
- private int timeout = 20000;
-
/**
* Call PDP.
*
@@ -133,7 +132,7 @@ public class PolicyGuardXacmlHelperEmbedded {
urlEntry.authorization, urlEntry.clientAuth, urlEntry.environment);
netLogger.info("[IN|{}|{}|]{}{}", "GUARD", urlEntry.restUrl, SYSTEM_LS, response);
} catch (Exception e) {
- logger.error("Error in sending RESTful request: ", e);
+ logger.error("Error in sending RESTful request", e);
}
return response;
@@ -235,7 +234,7 @@ public class PolicyGuardXacmlHelperEmbedded {
* @param xacmlReq the XACML request
* @return the response
*/
- public static String callEmbeddedPdp(PolicyGuardXacmlRequestAttributes xacmlReq) {
+ public String callEmbeddedPdp(PolicyGuardXacmlRequestAttributes xacmlReq) {
com.att.research.xacml.api.Response response = null;
Properties props = new Properties();
//
@@ -246,7 +245,7 @@ public class PolicyGuardXacmlHelperEmbedded {
BufferedReader br = new BufferedReader(isr) ) {
props.load(br);
} catch (Exception e) {
- logger.error("Unable to load properties file {} {}", propfile, e.getMessage());
+ logger.error("Unable to load properties file {}", propfile, e);
}
//
// Create embedded PDPEngine
@@ -255,7 +254,7 @@ public class PolicyGuardXacmlHelperEmbedded {
try {
xacmlPdpEngine = ATTPDPEngineFactory.newInstance().newEngine(props);
} catch (Exception e) {
- logger.error("Failed to create new PDPEngine {}", e.getMessage());
+ logger.error("callEmbeddedPdpEngine failed to create new PDPEngine", e);
return null;
}
logger.debug("embedded Engine created");
@@ -269,7 +268,7 @@ public class PolicyGuardXacmlHelperEmbedded {
try {
response = xacmlPdpEngine.decide(RequestParser.parseRequest(xacmlReq));
} catch (Exception e) {
- logger.error(e.getMessage(), e);
+ logger.error("callEmbeddedPdpEngine failed on decide", e);
}
long timeEnd = System.currentTimeMillis();
logger.debug("Elapsed Time: {} ms", (timeEnd - timeStart));