aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--POLICY-SDK-APP/src/main/java/org/onap/policy/admin/CheckPDP.java17
-rw-r--r--POLICY-SDK-APP/src/main/java/org/onap/policy/admin/PolicyAdapter.java2
-rw-r--r--POLICY-SDK-APP/src/main/java/org/onap/policy/admin/RESTfulPAPEngine.java32
-rw-r--r--PolicyEngineAPI/src/main/java/org/onap/policy/api/AttributeType.java1
-rw-r--r--PolicyEngineAPI/src/main/java/org/onap/policy/api/DeletePolicyCondition.java1
-rw-r--r--PolicyEngineAPI/src/main/java/org/onap/policy/api/DictionaryType.java1
-rw-r--r--PolicyEngineAPI/src/main/java/org/onap/policy/api/PolicyClass.java1
-rw-r--r--PolicyEngineAPI/src/main/java/org/onap/policy/api/PolicyConfigStatus.java3
-rw-r--r--PolicyEngineAPI/src/main/java/org/onap/policy/api/PolicyConfigType.java1
-rw-r--r--PolicyEngineAPI/src/main/java/org/onap/policy/api/PolicyDecision.java1
-rw-r--r--PolicyEngineAPI/src/main/java/org/onap/policy/api/PolicyParameters.java1
-rw-r--r--PolicyEngineAPI/src/main/java/org/onap/policy/api/PolicyResponseStatus.java5
-rw-r--r--PolicyEngineAPI/src/main/java/org/onap/policy/api/PolicyType.java1
-rw-r--r--PolicyEngineAPI/src/main/java/org/onap/policy/api/RuleProvider.java1
-rw-r--r--PolicyEngineUtils/src/main/java/org/onap/policy/api/NotificationHandler.java1
15 files changed, 40 insertions, 29 deletions
diff --git a/POLICY-SDK-APP/src/main/java/org/onap/policy/admin/CheckPDP.java b/POLICY-SDK-APP/src/main/java/org/onap/policy/admin/CheckPDP.java
index 87ed1fec9..3febbed44 100644
--- a/POLICY-SDK-APP/src/main/java/org/onap/policy/admin/CheckPDP.java
+++ b/POLICY-SDK-APP/src/main/java/org/onap/policy/admin/CheckPDP.java
@@ -66,7 +66,6 @@ public class CheckPDP {
private static void readFile(){
String pdpFile = null;
- Long newModified = null;
try{
pdpFile = XACMLProperties.getProperty(XACMLRestProperties.PROP_PDP_IDFILE);
}catch (Exception e){
@@ -90,7 +89,7 @@ public class CheckPDP {
}
// Check if File is updated recently
else {
- newModified = pdpPath.toFile().lastModified();
+ Long newModified = pdpPath.toFile().lastModified();
if (!newModified.equals(oldModified)) {
// File has been updated.
readProps();
@@ -100,7 +99,7 @@ public class CheckPDP {
@SuppressWarnings({ "unchecked", "rawtypes" })
private static void readProps() {
- Properties pdpProp = null;
+ Properties pdpProp;
pdpProp = new Properties();
try {
InputStream in = new FileInputStream(pdpPath.toFile());
@@ -126,15 +125,15 @@ public class CheckPDP {
private static void loadPDPProperties(String propKey, Properties pdpProp){
if (propKey.startsWith("PDP_URL")) {
- String check_val = pdpProp.getProperty(propKey);
- if (check_val == null) {
+ String checkVal = pdpProp.getProperty(propKey);
+ if (checkVal == null) {
LOGGER.error("Properties file doesn't have the PDP_URL parameter");
}
- if (check_val != null && check_val.contains(";")) {
- List<String> pdp_default = new ArrayList<>(Arrays.asList(check_val.split("\\s*;\\s*")));
+ if (checkVal != null && checkVal.contains(";")) {
+ List<String> pdpDefault = new ArrayList<>(Arrays.asList(checkVal.split("\\s*;\\s*")));
int pdpCount = 0;
- while (pdpCount < pdp_default.size()) {
- String pdpVal = pdp_default.get(pdpCount);
+ while (pdpCount < pdpDefault.size()) {
+ String pdpVal = pdpDefault.get(pdpCount);
readPDPParam(pdpVal);
pdpCount++;
}
diff --git a/POLICY-SDK-APP/src/main/java/org/onap/policy/admin/PolicyAdapter.java b/POLICY-SDK-APP/src/main/java/org/onap/policy/admin/PolicyAdapter.java
index fdfb99d3e..a15eb5882 100644
--- a/POLICY-SDK-APP/src/main/java/org/onap/policy/admin/PolicyAdapter.java
+++ b/POLICY-SDK-APP/src/main/java/org/onap/policy/admin/PolicyAdapter.java
@@ -41,7 +41,7 @@ public class PolicyAdapter {
private static final Logger LOGGER = FlexLogger.getLogger(PolicyAdapter.class);
public void configure(PolicyRestAdapter policyAdapter, PolicyEntity entity) {
- String policyNameValue = null ;
+ String policyNameValue;
String configPolicyName = null ;
if(extendedOptions(policyAdapter, entity)){
return;
diff --git a/POLICY-SDK-APP/src/main/java/org/onap/policy/admin/RESTfulPAPEngine.java b/POLICY-SDK-APP/src/main/java/org/onap/policy/admin/RESTfulPAPEngine.java
index 1f9372a7d..e48b0cb19 100644
--- a/POLICY-SDK-APP/src/main/java/org/onap/policy/admin/RESTfulPAPEngine.java
+++ b/POLICY-SDK-APP/src/main/java/org/onap/policy/admin/RESTfulPAPEngine.java
@@ -160,6 +160,7 @@ public class RESTfulPAPEngine extends StdPDPItemSetChangeNotifier implements PAP
* @return
* @throws PAPException
*/
+ @Override
public void updateGroup(OnapPDPGroup group) throws PAPException {
try {
@@ -242,12 +243,10 @@ public class RESTfulPAPEngine extends StdPDPItemSetChangeNotifier implements PAP
//Validate the Policy Data
public boolean validatePolicyRequest(PolicyRestAdapter policyAdapter, String policyType) throws PAPException {
- Boolean isValidData = false;
StdPAPPolicy newPAPPolicy = new StdPAPPolicy(policyAdapter.getPolicyName(), policyAdapter.getConfigBodyData(), policyAdapter.getConfigType(), "Base");
//send JSON object to PAP
- isValidData = (Boolean) sendToPAP("PUT", newPAPPolicy, null, null, "operation=validate", "apiflag=admin", "policyType=" + policyType);
- return isValidData;
+ return (Boolean) sendToPAP("PUT", newPAPPolicy, null, null, "operation=validate", "apiflag=admin", "policyType=" + policyType);
}
@@ -321,7 +320,7 @@ public class RESTfulPAPEngine extends StdPDPItemSetChangeNotifier implements PAP
* @return
* @throws PAPException
*/
-
+ @Override
public PDPStatus getStatus(OnapPDP pdp) throws PAPException {
return (StdPDPStatus)sendToPAP("GET", pdp, null, StdPDPStatus.class);
}
@@ -355,6 +354,7 @@ public class RESTfulPAPEngine extends StdPDPItemSetChangeNotifier implements PAP
String papPass = XACMLProperties.getProperty(XACMLRestProperties.PROP_PAP_PASS);
Base64.Encoder encoder = Base64.getEncoder();
String encoding = encoder.encodeToString((papID+":"+papPass).getBytes(StandardCharsets.UTF_8));
+ Object contentObj = content;
LOGGER.info("Encoding for the PAP is: " + encoding);
try {
String fullURL = papServletURLString;
@@ -367,11 +367,11 @@ public class RESTfulPAPEngine extends StdPDPItemSetChangeNotifier implements PAP
}
// special case - Status (actually the detailed status) comes from the PDP directly, not the PAP
- if (method.equals("GET") && (content instanceof OnapPDP) && responseContentClass == StdPDPStatus.class) {
+ if ("GET".equals(method) && (contentObj instanceof OnapPDP) && responseContentClass == StdPDPStatus.class) {
// Adjust the url and properties appropriately
- String pdpID =((OnapPDP)content).getId();
+ String pdpID =((OnapPDP)contentObj).getId();
fullURL = pdpID + "?type=Status";
- content = null;
+ contentObj = null;
if(CheckPDP.validateID(pdpID)){
encoding = CheckPDP.getEncoding(pdpID);
}
@@ -401,14 +401,14 @@ public class RESTfulPAPEngine extends StdPDPItemSetChangeNotifier implements PAP
connection.setDoOutput(true);
connection.setDoInput(true);
- if (content != null) {
- if (content instanceof InputStream) {
+ if (contentObj != null) {
+ if (contentObj instanceof InputStream) {
try {
//
// Send our current policy configuration
//
try (OutputStream os = connection.getOutputStream()) {
- int count = IOUtils.copy((InputStream)content, os);
+ int count = IOUtils.copy((InputStream)contentObj, os);
if (LOGGER.isDebugEnabled()) {
LOGGER.debug("copied to output, bytes="+count);
}
@@ -417,9 +417,9 @@ public class RESTfulPAPEngine extends StdPDPItemSetChangeNotifier implements PAP
LOGGER.error(XACMLErrorConstants.ERROR_PROCESS_FLOW + "Failed to write content in '" + method + "'", e);
}
} else {
- // The content is an object to be encoded in JSON
+ // The contentObj is an object to be encoded in JSON
ObjectMapper mapper = new ObjectMapper();
- mapper.writeValue(connection.getOutputStream(), content);
+ mapper.writeValue(connection.getOutputStream(), contentObj);
}
}
//
@@ -434,18 +434,18 @@ public class RESTfulPAPEngine extends StdPDPItemSetChangeNotifier implements PAP
String isValidData = connection.getHeaderField("isValidData");
String isSuccess = connection.getHeaderField("successMapKey");
Map<String, String> successMap = new HashMap<>();
- if (isValidData != null && isValidData.equalsIgnoreCase("true")){
+ if (isValidData != null && "true".equalsIgnoreCase(isValidData)){
LOGGER.info("Policy Data is valid.");
return true;
- } else if (isValidData != null && isValidData.equalsIgnoreCase("false")) {
+ } else if (isValidData != null && "false".equalsIgnoreCase(isValidData)) {
LOGGER.info("Policy Data is invalid.");
return false;
- } else if (isSuccess != null && isSuccess.equalsIgnoreCase("success")) {
+ } else if (isSuccess != null && "success".equalsIgnoreCase(isSuccess)) {
LOGGER.info("Policy Created Successfully!" );
String finalPolicyPath = connection.getHeaderField("finalPolicyPath");
successMap.put("success", finalPolicyPath);
return successMap;
- } else if (isSuccess != null && isSuccess.equalsIgnoreCase("error")) {
+ } else if (isSuccess != null && "error".equalsIgnoreCase(isSuccess)) {
LOGGER.info("There was an error while creating the policy!");
successMap.put("error", "error");
return successMap;
diff --git a/PolicyEngineAPI/src/main/java/org/onap/policy/api/AttributeType.java b/PolicyEngineAPI/src/main/java/org/onap/policy/api/AttributeType.java
index 8cfa51212..0a4621902 100644
--- a/PolicyEngineAPI/src/main/java/org/onap/policy/api/AttributeType.java
+++ b/PolicyEngineAPI/src/main/java/org/onap/policy/api/AttributeType.java
@@ -62,6 +62,7 @@ public enum AttributeType {
* Returns the <code>String</code> format of Type for this <code>AttributeType</code>
* @return the <code>String</code> of the Type for this <code>AttributeType</code>
*/
+ @Override
public String toString() {
return this.name;
}
diff --git a/PolicyEngineAPI/src/main/java/org/onap/policy/api/DeletePolicyCondition.java b/PolicyEngineAPI/src/main/java/org/onap/policy/api/DeletePolicyCondition.java
index 4001d3fa6..117ac716e 100644
--- a/PolicyEngineAPI/src/main/java/org/onap/policy/api/DeletePolicyCondition.java
+++ b/PolicyEngineAPI/src/main/java/org/onap/policy/api/DeletePolicyCondition.java
@@ -49,6 +49,7 @@ public enum DeletePolicyCondition {
* Returns the <code>String</code> format of delete condition for this Policy
* @return the <code>String</code> of the delete condition for this Policy
*/
+ @Override
public String toString(){
return this.name;
}
diff --git a/PolicyEngineAPI/src/main/java/org/onap/policy/api/DictionaryType.java b/PolicyEngineAPI/src/main/java/org/onap/policy/api/DictionaryType.java
index 5ac6d5ed8..499295d65 100644
--- a/PolicyEngineAPI/src/main/java/org/onap/policy/api/DictionaryType.java
+++ b/PolicyEngineAPI/src/main/java/org/onap/policy/api/DictionaryType.java
@@ -83,6 +83,7 @@ public enum DictionaryType{
* Returns the <code>String</code> format of Type for this <code>PolicyClass</code>
* @return the <code>String</code> of the Type for this <code>PolicyClass</code>
*/
+ @Override
public String toString() {
return this.name;
}
diff --git a/PolicyEngineAPI/src/main/java/org/onap/policy/api/PolicyClass.java b/PolicyEngineAPI/src/main/java/org/onap/policy/api/PolicyClass.java
index 5132a44be..6a648e8e6 100644
--- a/PolicyEngineAPI/src/main/java/org/onap/policy/api/PolicyClass.java
+++ b/PolicyEngineAPI/src/main/java/org/onap/policy/api/PolicyClass.java
@@ -52,6 +52,7 @@ public enum PolicyClass {
* Returns the <code>String</code> format of Type for this <code>PolicyClass</code>
* @return the <code>String</code> of the Type for this <code>PolicyClass</code>
*/
+ @Override
public String toString() {
return this.name;
}
diff --git a/PolicyEngineAPI/src/main/java/org/onap/policy/api/PolicyConfigStatus.java b/PolicyEngineAPI/src/main/java/org/onap/policy/api/PolicyConfigStatus.java
index 23291c9b9..cee156786 100644
--- a/PolicyEngineAPI/src/main/java/org/onap/policy/api/PolicyConfigStatus.java
+++ b/PolicyEngineAPI/src/main/java/org/onap/policy/api/PolicyConfigStatus.java
@@ -52,7 +52,7 @@ public enum PolicyConfigStatus {
* if no match is found
*/
public static PolicyConfigStatus getStatus(String configStatus) {
- if(configStatus.equalsIgnoreCase("retrieved")) {
+ if("retrieved".equalsIgnoreCase(configStatus)) {
return CONFIG_RETRIEVED;
}else {
return CONFIG_NOT_FOUND;
@@ -64,6 +64,7 @@ public enum PolicyConfigStatus {
*
* @return the <code>String</code> name for this <code>PolicyConfigStatus</code>
*/
+ @Override
public String toString(){
return this.name;
}
diff --git a/PolicyEngineAPI/src/main/java/org/onap/policy/api/PolicyConfigType.java b/PolicyEngineAPI/src/main/java/org/onap/policy/api/PolicyConfigType.java
index 59fd42733..2fb5d96db 100644
--- a/PolicyEngineAPI/src/main/java/org/onap/policy/api/PolicyConfigType.java
+++ b/PolicyEngineAPI/src/main/java/org/onap/policy/api/PolicyConfigType.java
@@ -73,6 +73,7 @@ public enum PolicyConfigType{
* Returns the <code>String</code> format of Type for this <code>PolicyClass</code>
* @return the <code>String</code> of the Type for this <code>PolicyClass</code>
*/
+ @Override
public String toString() {
return name;
}
diff --git a/PolicyEngineAPI/src/main/java/org/onap/policy/api/PolicyDecision.java b/PolicyEngineAPI/src/main/java/org/onap/policy/api/PolicyDecision.java
index b5fdc1e01..6bae84cc7 100644
--- a/PolicyEngineAPI/src/main/java/org/onap/policy/api/PolicyDecision.java
+++ b/PolicyEngineAPI/src/main/java/org/onap/policy/api/PolicyDecision.java
@@ -53,6 +53,7 @@ public enum PolicyDecision {
*
* @return the <code>String</code> name for this <code>PolicyDecision</code>
*/
+ @Override
public String toString(){
return this.name;
}
diff --git a/PolicyEngineAPI/src/main/java/org/onap/policy/api/PolicyParameters.java b/PolicyEngineAPI/src/main/java/org/onap/policy/api/PolicyParameters.java
index 1078916eb..2062638cf 100644
--- a/PolicyEngineAPI/src/main/java/org/onap/policy/api/PolicyParameters.java
+++ b/PolicyEngineAPI/src/main/java/org/onap/policy/api/PolicyParameters.java
@@ -568,6 +568,7 @@ public class PolicyParameters {
this.extendedOption = extendedOption;
}
+ @Override
public String toString() {
return "PolicyParameters [ policyName=" + policyName + ", policyDescription=" + policyDescription + ", onapName="+ onapName
+ ", configName=" + configName + ", attributes=" + attributes + ", configBody=" + configBody
diff --git a/PolicyEngineAPI/src/main/java/org/onap/policy/api/PolicyResponseStatus.java b/PolicyEngineAPI/src/main/java/org/onap/policy/api/PolicyResponseStatus.java
index 4368b646d..63cb9185c 100644
--- a/PolicyEngineAPI/src/main/java/org/onap/policy/api/PolicyResponseStatus.java
+++ b/PolicyEngineAPI/src/main/java/org/onap/policy/api/PolicyResponseStatus.java
@@ -55,9 +55,9 @@ public enum PolicyResponseStatus {
* @return the <code>PolicyResponseStatus</code> with the name matching <code>ACTION_ADVISED</code> or <code>ACTION_TAKEN</code> or <code>NO_ACTION_REQUIRED</code>
*/
public static PolicyResponseStatus getStatus(String responseStatus) {
- if(responseStatus.equalsIgnoreCase("action_advised")) {
+ if("action_advised".equalsIgnoreCase(responseStatus)) {
return ACTION_ADVISED;
- }else if(responseStatus.equalsIgnoreCase("action_taken")) {
+ }else if("action_taken".equalsIgnoreCase(responseStatus)) {
return ACTION_TAKEN;
}else {
return NO_ACTION_REQUIRED;
@@ -69,6 +69,7 @@ public enum PolicyResponseStatus {
*
* @return the <code>String</code> name for this <code>PolicyResponseStatus</code>
*/
+ @Override
public String toString(){
return this.name;
}
diff --git a/PolicyEngineAPI/src/main/java/org/onap/policy/api/PolicyType.java b/PolicyEngineAPI/src/main/java/org/onap/policy/api/PolicyType.java
index f026596e9..a29a6c440 100644
--- a/PolicyEngineAPI/src/main/java/org/onap/policy/api/PolicyType.java
+++ b/PolicyEngineAPI/src/main/java/org/onap/policy/api/PolicyType.java
@@ -57,6 +57,7 @@ public enum PolicyType {
* Returns the <code>String</code> format of Type for this <code>PolicyType</code>
* @return the <code>String</code> of the Type for this <code>PolicyType</code>
*/
+ @Override
public String toString() {
return this.name;
}
diff --git a/PolicyEngineAPI/src/main/java/org/onap/policy/api/RuleProvider.java b/PolicyEngineAPI/src/main/java/org/onap/policy/api/RuleProvider.java
index c34e05e89..94ad67861 100644
--- a/PolicyEngineAPI/src/main/java/org/onap/policy/api/RuleProvider.java
+++ b/PolicyEngineAPI/src/main/java/org/onap/policy/api/RuleProvider.java
@@ -57,6 +57,7 @@ public enum RuleProvider {
* Returns the <code>String</code> format of Type for this <code>AttributeType</code>
* @return the <code>String</code> of the Type for this <code>AttributeType</code>
*/
+ @Override
public String toString() {
return this.name;
}
diff --git a/PolicyEngineUtils/src/main/java/org/onap/policy/api/NotificationHandler.java b/PolicyEngineUtils/src/main/java/org/onap/policy/api/NotificationHandler.java
index 6484a9d7e..837eba967 100644
--- a/PolicyEngineUtils/src/main/java/org/onap/policy/api/NotificationHandler.java
+++ b/PolicyEngineUtils/src/main/java/org/onap/policy/api/NotificationHandler.java
@@ -24,6 +24,7 @@ package org.onap.policy.api;
*
* @version 0.1
*/
+@FunctionalInterface
public interface NotificationHandler {
/**
* <code>notificationReceived</code> method will be triggered automatically whenever a Notification is received by the PEP.