summaryrefslogtreecommitdiffstats
path: root/controlloop/common/guard
diff options
context:
space:
mode:
Diffstat (limited to 'controlloop/common/guard')
-rw-r--r--controlloop/common/guard/src/main/java/org/onap/policy/guard/CallGuardTask.java2
-rw-r--r--controlloop/common/guard/src/main/java/org/onap/policy/guard/PipEngineGetHistory.java10
-rw-r--r--controlloop/common/guard/src/main/java/org/onap/policy/guard/PipEngineGetStatus.java31
-rw-r--r--controlloop/common/guard/src/main/java/org/onap/policy/guard/Util.java10
4 files changed, 27 insertions, 26 deletions
diff --git a/controlloop/common/guard/src/main/java/org/onap/policy/guard/CallGuardTask.java b/controlloop/common/guard/src/main/java/org/onap/policy/guard/CallGuardTask.java
index 59a1816b7..fefea39ab 100644
--- a/controlloop/common/guard/src/main/java/org/onap/policy/guard/CallGuardTask.java
+++ b/controlloop/common/guard/src/main/java/org/onap/policy/guard/CallGuardTask.java
@@ -151,7 +151,7 @@ public class CallGuardTask 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/common/guard/src/main/java/org/onap/policy/guard/PipEngineGetHistory.java b/controlloop/common/guard/src/main/java/org/onap/policy/guard/PipEngineGetHistory.java
index 2a1ef2fc6..37c4e4c68 100644
--- a/controlloop/common/guard/src/main/java/org/onap/policy/guard/PipEngineGetHistory.java
+++ b/controlloop/common/guard/src/main/java/org/onap/policy/guard/PipEngineGetHistory.java
@@ -122,7 +122,7 @@ public class PipEngineGetHistory extends StdConfigurableEngine {
// Notice, we are checking here for the base issuer prefix.
if (!string.contains(this.getIssuer())) {
logger.debug("Requested issuer '{}' does not match {}", string, getIssuer());
- logger.debug("FeqLimiter PIP - Issuer {} does not match with: ", string, this.getIssuer());
+ logger.debug("FeqLimiter PIP - Issuer {} does not match with: {}", string, this.getIssuer());
return StdPIPResponse.PIP_RESPONSE_EMPTY;
}
}
@@ -184,14 +184,14 @@ public class PipEngineGetHistory extends StdConfigurableEngine {
if (pipResponse.getStatus() != null && !pipResponse.getStatus().isOk()) {
if (logger.isWarnEnabled()) {
logger.warn("PIP response error {}: {}", pipRequest.getAttributeId().stringValue(),
- pipResponse.getStatus().toString());
+ pipResponse.getStatus());
}
return null;
}
if (pipResponse.getAttributes() != null && pipResponse.getAttributes().isEmpty()) {
if (logger.isWarnEnabled()) {
logger.warn("No attributes in POP response {}: {}", pipRequest.getAttributeId().stringValue(),
- pipResponse.getStatus().toString());
+ pipResponse.getStatus());
}
return null;
}
@@ -309,7 +309,7 @@ public class PipEngineGetHistory extends StdConfigurableEngine {
EntityManager em = null;
String opsHistPu = System.getProperty("OperationsHistoryPU");
- if (opsHistPu == null || !opsHistPu.equals("TestOperationsHistoryPU")) {
+ if (!"TestOperationsHistoryPU".equals(opsHistPu)) {
opsHistPu = "OperationsHistoryPU";
} else {
props.clear();
@@ -328,7 +328,7 @@ public class PipEngineGetHistory extends StdConfigurableEngine {
try {
diff = now - getMsFromTimeWindow(timeWindow);
} catch (Exception ex) {
- logger.error("PIP thread got Exception " + ex);
+ logger.error("PIP thread got Exception ", ex);
return -1;
}
diff --git a/controlloop/common/guard/src/main/java/org/onap/policy/guard/PipEngineGetStatus.java b/controlloop/common/guard/src/main/java/org/onap/policy/guard/PipEngineGetStatus.java
index 36bb36f5c..b61ab5d73 100644
--- a/controlloop/common/guard/src/main/java/org/onap/policy/guard/PipEngineGetStatus.java
+++ b/controlloop/common/guard/src/main/java/org/onap/policy/guard/PipEngineGetStatus.java
@@ -148,7 +148,7 @@ public class PipEngineGetStatus extends StdConfigurableEngine {
try {
pipResponse = pipFinder.getMatchingAttributes(pipRequest, this);
} catch (PIPException ex) {
- logger.error("getAttribute threw:", ex);
+ logger.error("getAttribute threw", ex);
return null;
}
if (pipResponse == null) {
@@ -197,16 +197,17 @@ public class PipEngineGetStatus extends StdConfigurableEngine {
Set<String> setUids = new HashSet<>();
for (Attribute attributeUid : listUids) {
Iterator<AttributeValue<String>> iterAttributeValues = attributeUid.findValues(DataTypes.DT_STRING);
- if (iterAttributeValues != null) {
- while (iterAttributeValues.hasNext()) {
- String uid = iterAttributeValues.next().getValue();
- if (uid != null) {
- setUids.add(uid);
- }
+ if (iterAttributeValues == null) {
+ continue;
+ }
+ while (iterAttributeValues.hasNext()) {
+ String uid = iterAttributeValues.next().getValue();
+ if (uid == null) {
+ continue;
}
+ setUids.add(uid);
}
}
-
return setUids;
}
@@ -220,13 +221,13 @@ public class PipEngineGetStatus extends StdConfigurableEngine {
props.put(Util.ECLIPSE_LINK_KEY_USER, PolicyEngine.manager.getEnvironmentProperty(Util.ONAP_KEY_USER));
props.put(Util.ECLIPSE_LINK_KEY_PASS, PolicyEngine.manager.getEnvironmentProperty(Util.ONAP_KEY_PASS));
} catch (NullPointerException e) {
- logger.error("getStatusFromDB: {} when setting properties", e.getMessage());
+ logger.error("getStatusFromDb: when setting properties", e);
}
//
// Set opsHistPu to the correct value and clear properties if necessary.
//
String opsHistPu = System.getProperty("OperationsHistoryPU");
- if (opsHistPu == null || !opsHistPu.equals("TestOperationsHistoryPU")) {
+ if (!"TestOperationsHistoryPU".equals(opsHistPu)) {
opsHistPu = "OperationsHistoryPU";
} else {
props.clear();
@@ -240,14 +241,14 @@ public class PipEngineGetStatus extends StdConfigurableEngine {
emf = Persistence.createEntityManagerFactory(opsHistPu, props);
} catch (Exception ex) {
logger.error("PIP thread got Exception. Can't connect to Operations History DB -- {}", opsHistPu);
- logger.error("getStatusFromDb threw: ", ex);
+ logger.error("getStatusFromDb threw", ex);
return null;
}
try {
em = emf.createEntityManager();
} catch (Exception ex) {
logger.error("PIP thread got Exception. Problem creating EntityManager");
- logger.error("getStatusFromDb threw: ", ex);
+ logger.error("getStatusFromDb threw", ex);
emf.close();
return null;
}
@@ -269,7 +270,7 @@ public class PipEngineGetStatus extends StdConfigurableEngine {
try {
ret = ((String)nq.getSingleResult());
} catch (NoResultException ex) {
- logger.debug("NoResultException for getSingleResult()");
+ logger.debug("NoResultException for getSingleResult()", ex);
ret = "NO_MATCHING_ENTRY";
} catch (Exception ex) {
logger.error("getStatusFromDB threw an exception", ex);
@@ -283,12 +284,12 @@ public class PipEngineGetStatus extends StdConfigurableEngine {
try {
em.close();
} catch (Exception ex) {
- logger.error("getStatusFromDB threw an exception ", ex);
+ logger.error("getStatusFromDB threw an exception", ex);
}
try {
emf.close();
} catch (Exception ex) {
- logger.error("getStatusFromDB threw an exception ", ex);
+ logger.error("getStatusFromDB threw an exception", ex);
}
return ret;
}
diff --git a/controlloop/common/guard/src/main/java/org/onap/policy/guard/Util.java b/controlloop/common/guard/src/main/java/org/onap/policy/guard/Util.java
index 46a815cdd..d159bd425 100644
--- a/controlloop/common/guard/src/main/java/org/onap/policy/guard/Util.java
+++ b/controlloop/common/guard/src/main/java/org/onap/policy/guard/Util.java
@@ -2,7 +2,7 @@
* ============LICENSE_START=======================================================
* guard
* ================================================================================
- * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.
+ * Copyright (C) 2017-2018 AT&T Intellectual Property. All rights reserved.
* ================================================================================
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -36,10 +36,6 @@ import org.yaml.snakeyaml.Yaml;
import org.yaml.snakeyaml.constructor.Constructor;
public final class Util {
- private Util() {
- // This static class cannot be instantiated
- }
-
/*
* Keys for guard properties
*/
@@ -87,6 +83,10 @@ public final class Util {
}
}
+ private Util() {
+ // This static class cannot be instantiated
+ }
+
/**
* Load a Yaml file.
*