summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorTej, Tarun <tt3868@att.com>2017-08-24 12:13:12 -0400
committerTarun Tej Velaga <tt3868@att.com>2017-08-24 17:18:56 +0000
commited2bcd773ec3dbe07311bad597ec664c4e38c009 (patch)
treee8a96b23e150e75cbb1d1729e1dcd825175c90f5
parentcbc5914ca2c1770797f6ad2a05ea9d7c30a55b63 (diff)
Fixes for missed sonar critical issues
Few fixes to the missed sonar critical issues and import warning fixes which are part of sonar critical fixes. Issue-Id: POLICY-113 Change-Id: If5010e984020b673e058cc1d01a8964a2354796d Signed-off-by: Tarun Tej Velaga <tt3868@att.com>
-rw-r--r--ONAP-PAP-REST/src/main/java/org/onap/policy/pap/xacml/rest/handler/DeleteHandler.java26
-rw-r--r--ONAP-PAP-REST/src/main/java/org/onap/policy/pap/xacml/rest/handler/DictionaryHandler.java3
-rw-r--r--ONAP-PAP-REST/src/main/java/org/onap/policy/pap/xacml/rest/handler/SavePolicyHandler.java4
-rw-r--r--ONAP-PAP-REST/src/main/java/org/onap/policy/pap/xacml/rest/service/DictionaryService.java143
-rw-r--r--ONAP-PAP-REST/src/main/java/org/onap/policy/pap/xacml/rest/service/ImportService.java1
-rw-r--r--ONAP-PAP-REST/src/main/java/org/onap/policy/pap/xacml/rest/util/JPAUtils.java6
-rw-r--r--ONAP-PDP-REST/src/main/java/org/onap/policy/pdp/rest/api/services/NotificationService.java7
-rw-r--r--ONAP-PDP-REST/src/main/java/org/onap/policy/pdp/rest/notifications/NotificationController.java2
-rw-r--r--ONAP-PDP-REST/src/test/java/org/onap/policy/pdp/rest/api/test/PolicyEngineServicesTest.java3
-rw-r--r--PolicyEngineAPI/src/main/java/org/onap/policy/api/PolicyEngine.java2
-rw-r--r--PolicyEngineAPI/src/main/java/org/onap/policy/std/AutoClientDMAAP.java2
-rw-r--r--PolicyEngineAPI/src/main/java/org/onap/policy/std/StdPolicyEngine.java112
12 files changed, 153 insertions, 158 deletions
diff --git a/ONAP-PAP-REST/src/main/java/org/onap/policy/pap/xacml/rest/handler/DeleteHandler.java b/ONAP-PAP-REST/src/main/java/org/onap/policy/pap/xacml/rest/handler/DeleteHandler.java
index a18505478..ab0492312 100644
--- a/ONAP-PAP-REST/src/main/java/org/onap/policy/pap/xacml/rest/handler/DeleteHandler.java
+++ b/ONAP-PAP-REST/src/main/java/org/onap/policy/pap/xacml/rest/handler/DeleteHandler.java
@@ -37,6 +37,7 @@ import org.onap.policy.common.logging.ONAPLoggingContext;
import org.onap.policy.common.logging.eelf.MessageCodes;
import org.onap.policy.common.logging.eelf.PolicyLogger;
import org.onap.policy.common.logging.flexlogger.FlexLogger;
+import org.onap.policy.common.logging.flexlogger.Logger;
import org.onap.policy.pap.xacml.rest.XACMLPapServlet;
import org.onap.policy.pap.xacml.rest.components.PolicyDBDaoTransaction;
import org.onap.policy.pap.xacml.rest.elk.client.PolicyElasticSearchController;
@@ -51,8 +52,7 @@ import org.onap.policy.xacml.api.XACMLErrorConstants;
import org.onap.policy.xacml.api.pap.OnapPDPGroup;
import org.onap.policy.xacml.std.pap.StdPAPPolicy;
import org.onap.policy.xacml.std.pap.StdPDPGroup;
-import org.onap.policy.common.logging.flexlogger.FlexLogger;
-import org.onap.policy.common.logging.flexlogger.Logger;
+
import com.att.research.xacml.api.pap.PAPException;
import com.att.research.xacml.api.pap.PDPPolicy;
import com.att.research.xacml.util.XACMLProperties;
@@ -62,12 +62,7 @@ public class DeleteHandler {
private OnapPDPGroup newgroup;
private static Logger logger = FlexLogger.getLogger(DeleteHandler.class);
- private static String papDbDriver = null;
- private static String papDbUrl = null;
- private static String papDbUser = null;
- private static String papDbPassword = null;
-
- public static void doAPIDeleteFromPAP(HttpServletRequest request, HttpServletResponse response, ONAPLoggingContext loggingContext) throws IOException, SQLException {
+ public void doAPIDeleteFromPAP(HttpServletRequest request, HttpServletResponse response, ONAPLoggingContext loggingContext) throws IOException, SQLException {
// get the request content into a String
String json = null;
java.util.Scanner scanner = new java.util.Scanner(request.getInputStream());
@@ -88,10 +83,10 @@ public class DeleteHandler {
PolicyEntity policyEntity = null;
JPAUtils jpaUtils = null;
- papDbDriver = XACMLProperties.getProperty(XACMLRestProperties.PROP_PAP_DB_DRIVER);
- papDbUrl = XACMLProperties.getProperty(XACMLRestProperties.PROP_PAP_DB_URL);
- papDbUser = XACMLProperties.getProperty(XACMLRestProperties.PROP_PAP_DB_USER);
- papDbPassword = XACMLProperties.getProperty(XACMLRestProperties.PROP_PAP_DB_PASSWORD);
+ String papDbDriver = XACMLProperties.getProperty(XACMLRestProperties.PROP_PAP_DB_DRIVER);
+ String papDbUrl = XACMLProperties.getProperty(XACMLRestProperties.PROP_PAP_DB_URL);
+ String papDbUser = XACMLProperties.getProperty(XACMLRestProperties.PROP_PAP_DB_USER);
+ String papDbPassword = XACMLProperties.getProperty(XACMLRestProperties.PROP_PAP_DB_PASSWORD);
Connection con = null;
try {
@@ -110,7 +105,7 @@ public class DeleteHandler {
response.setStatus(HttpServletResponse.SC_ACCEPTED);
return;
}
- EntityManager em = (EntityManager) XACMLPapServlet.getEmf().createEntityManager();
+ EntityManager em = XACMLPapServlet.getEmf().createEntityManager();
Query policyEntityQuery = null;
try{
if(policyName.endsWith(".xml")){
@@ -280,7 +275,7 @@ public class DeleteHandler {
}
}
- public static String deletePolicyEntityData(EntityManager em, PolicyEntity policyEntity) throws SQLException{
+ public static String deletePolicyEntityData(EntityManager em, PolicyEntity policyEntity){
PolicyElasticSearchController controller = new PolicyElasticSearchController();
PolicyRestAdapter policyData = new PolicyRestAdapter();
String policyName = policyEntity.getPolicyName();
@@ -473,8 +468,7 @@ public class DeleteHandler {
public static DeleteHandler getInstance() {
try {
Class<?> deleteHandler = Class.forName(XACMLProperties.getProperty("deletePolicy.impl.className", DeleteHandler.class.getName()));
- DeleteHandler instance = (DeleteHandler) deleteHandler.newInstance();
- return instance;
+ return (DeleteHandler) deleteHandler.newInstance();
} catch (Exception e) {
logger.error(e.getMessage(),e);
}
diff --git a/ONAP-PAP-REST/src/main/java/org/onap/policy/pap/xacml/rest/handler/DictionaryHandler.java b/ONAP-PAP-REST/src/main/java/org/onap/policy/pap/xacml/rest/handler/DictionaryHandler.java
index d30c70204..6aec7a9bc 100644
--- a/ONAP-PAP-REST/src/main/java/org/onap/policy/pap/xacml/rest/handler/DictionaryHandler.java
+++ b/ONAP-PAP-REST/src/main/java/org/onap/policy/pap/xacml/rest/handler/DictionaryHandler.java
@@ -22,10 +22,9 @@ package org.onap.policy.pap.xacml.rest.handler;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
-import org.onap.policy.common.logging.eelf.PolicyLogger;
-import org.onap.policy.common.logging.flexlogger.FlexLogger;
import org.onap.policy.common.logging.flexlogger.FlexLogger;
import org.onap.policy.common.logging.flexlogger.Logger;
+
import com.att.research.xacml.util.XACMLProperties;
public interface DictionaryHandler {
diff --git a/ONAP-PAP-REST/src/main/java/org/onap/policy/pap/xacml/rest/handler/SavePolicyHandler.java b/ONAP-PAP-REST/src/main/java/org/onap/policy/pap/xacml/rest/handler/SavePolicyHandler.java
index 3864ba1fd..c86ded43f 100644
--- a/ONAP-PAP-REST/src/main/java/org/onap/policy/pap/xacml/rest/handler/SavePolicyHandler.java
+++ b/ONAP-PAP-REST/src/main/java/org/onap/policy/pap/xacml/rest/handler/SavePolicyHandler.java
@@ -26,14 +26,14 @@ import javax.servlet.ServletException;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import javax.xml.parsers.ParserConfigurationException;
+
+import org.onap.policy.common.logging.eelf.PolicyLogger;
import org.onap.policy.common.logging.flexlogger.FlexLogger;
import org.onap.policy.common.logging.flexlogger.Logger;
-import org.onap.policy.common.logging.eelf.PolicyLogger;
import org.onap.policy.pap.xacml.rest.XACMLPapServlet;
import org.onap.policy.pap.xacml.rest.policycontroller.PolicyCreation;
import org.onap.policy.rest.adapter.PolicyRestAdapter;
import org.onap.policy.utils.PolicyUtils;
-import org.onap.policy.xacml.api.XACMLErrorConstants;
import org.onap.policy.xacml.std.pap.StdPAPPolicy;
import org.xml.sax.SAXException;
diff --git a/ONAP-PAP-REST/src/main/java/org/onap/policy/pap/xacml/rest/service/DictionaryService.java b/ONAP-PAP-REST/src/main/java/org/onap/policy/pap/xacml/rest/service/DictionaryService.java
index 1c873561f..c96f85dcf 100644
--- a/ONAP-PAP-REST/src/main/java/org/onap/policy/pap/xacml/rest/service/DictionaryService.java
+++ b/ONAP-PAP-REST/src/main/java/org/onap/policy/pap/xacml/rest/service/DictionaryService.java
@@ -20,12 +20,10 @@
package org.onap.policy.pap.xacml.rest.service;
import java.io.IOException;
-import java.io.UnsupportedEncodingException;
+
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
-import org.onap.policy.common.logging.flexlogger.FlexLogger;
-import org.onap.policy.common.logging.flexlogger.Logger;
import org.onap.policy.pap.xacml.rest.controller.ActionPolicyDictionaryController;
import org.onap.policy.pap.xacml.rest.controller.BRMSDictionaryController;
import org.onap.policy.pap.xacml.rest.controller.ClosedLoopDictionaryController;
@@ -37,20 +35,17 @@ import org.onap.policy.pap.xacml.rest.controller.FirewallDictionaryController;
import org.onap.policy.pap.xacml.rest.controller.MicroServiceDictionaryController;
import org.onap.policy.pap.xacml.rest.controller.PolicyScopeDictionaryController;
import org.onap.policy.pap.xacml.rest.controller.SafePolicyController;
-import org.onap.policy.xacml.api.XACMLErrorConstants;
import org.springframework.stereotype.Service;
import org.springframework.web.servlet.ModelAndView;
@Service("DictionaryService")
public class DictionaryService {
-
- private static final Logger LOGGER = FlexLogger.getLogger(DictionaryService.class);
/*
* Methods that call the controller method directly to Save and Update dictionary data
*/
- public String saveOnapDictionary(HttpServletRequest request, HttpServletResponse response) throws UnsupportedEncodingException, IOException {
+ public String saveOnapDictionary(HttpServletRequest request, HttpServletResponse response) throws IOException {
DictionaryController dictionary = new DictionaryController();
String responseString = null;
@@ -60,7 +55,7 @@ public class DictionaryService {
}
- public String saveAttributeDictionary(HttpServletRequest request, HttpServletResponse response) throws UnsupportedEncodingException, IOException{
+ public String saveAttributeDictionary(HttpServletRequest request, HttpServletResponse response) throws IOException{
DictionaryController dictionary = new DictionaryController();
String responseString = null;
@@ -69,7 +64,7 @@ public class DictionaryService {
return responseString;
}
- public String saveActionPolicyDictionary(HttpServletRequest request, HttpServletResponse response) throws UnsupportedEncodingException, IOException {
+ public String saveActionPolicyDictionary(HttpServletRequest request, HttpServletResponse response) throws IOException {
ActionPolicyDictionaryController action = new ActionPolicyDictionaryController();
String responseString = null;
@@ -78,7 +73,7 @@ public class DictionaryService {
return responseString;
}
- public String saveBRMSParamDictionary(HttpServletRequest request, HttpServletResponse response) throws UnsupportedEncodingException, IOException {
+ public String saveBRMSParamDictionary(HttpServletRequest request, HttpServletResponse response) throws IOException {
BRMSDictionaryController dictionary = new BRMSDictionaryController();
String responseString = null;
@@ -87,7 +82,7 @@ public class DictionaryService {
return responseString;
}
- public String saveVSCLAction(HttpServletRequest request, HttpServletResponse response) throws UnsupportedEncodingException, IOException{
+ public String saveVSCLAction(HttpServletRequest request, HttpServletResponse response) throws IOException{
ClosedLoopDictionaryController dictionary = new ClosedLoopDictionaryController();
String responseString = null;
@@ -96,7 +91,7 @@ public class DictionaryService {
return responseString;
}
- public String saveVnfType(HttpServletRequest request, HttpServletResponse response) throws UnsupportedEncodingException, IOException{
+ public String saveVnfType(HttpServletRequest request, HttpServletResponse response) throws IOException{
ClosedLoopDictionaryController dictionary = new ClosedLoopDictionaryController();
String responseString = null;
@@ -105,7 +100,7 @@ public class DictionaryService {
return responseString;
}
- public String savePEPOptions(HttpServletRequest request, HttpServletResponse response) throws UnsupportedEncodingException, IOException{
+ public String savePEPOptions(HttpServletRequest request, HttpServletResponse response) throws IOException{
ClosedLoopDictionaryController dictionary = new ClosedLoopDictionaryController();
String responseString = null;
@@ -114,7 +109,7 @@ public class DictionaryService {
return responseString;
}
- public String saveVarbind(HttpServletRequest request, HttpServletResponse response) throws UnsupportedEncodingException, IOException{
+ public String saveVarbind(HttpServletRequest request, HttpServletResponse response) throws IOException{
ClosedLoopDictionaryController dictionary = new ClosedLoopDictionaryController();
String responseString = null;
@@ -123,7 +118,7 @@ public class DictionaryService {
return responseString;
}
- public String saveServiceType(HttpServletRequest request, HttpServletResponse response) throws UnsupportedEncodingException, IOException{
+ public String saveServiceType(HttpServletRequest request, HttpServletResponse response) throws IOException{
ClosedLoopDictionaryController dictionary = new ClosedLoopDictionaryController();
String responseString = null;
@@ -132,7 +127,7 @@ public class DictionaryService {
return responseString;
}
- public String saveSiteType(HttpServletRequest request, HttpServletResponse response) throws UnsupportedEncodingException, IOException{
+ public String saveSiteType(HttpServletRequest request, HttpServletResponse response) throws IOException{
ClosedLoopDictionaryController dictionary = new ClosedLoopDictionaryController();
String responseString = null;
@@ -141,7 +136,7 @@ public class DictionaryService {
return responseString;
}
- public String saveSettingsDictionary(HttpServletRequest request, HttpServletResponse response) throws UnsupportedEncodingException, IOException{
+ public String saveSettingsDictionary(HttpServletRequest request, HttpServletResponse response) throws IOException{
DecisionPolicyDictionaryController dictionary = new DecisionPolicyDictionaryController();
String responseString = null;
@@ -150,7 +145,7 @@ public class DictionaryService {
return responseString;
}
- public String saveDescriptiveDictionary(HttpServletRequest request, HttpServletResponse response) throws UnsupportedEncodingException, IOException{
+ public String saveDescriptiveDictionary(HttpServletRequest request, HttpServletResponse response) throws IOException{
DescriptiveDictionaryController dictionary = new DescriptiveDictionaryController();
String responseString = null;
@@ -159,7 +154,7 @@ public class DictionaryService {
return responseString;
}
- public String saveEnforcerDictionary(HttpServletRequest request, HttpServletResponse response) throws UnsupportedEncodingException, IOException{
+ public String saveEnforcerDictionary(HttpServletRequest request, HttpServletResponse response) throws IOException{
EnforcerDictionaryController dictionary = new EnforcerDictionaryController();
String responseString = null;
@@ -168,7 +163,7 @@ public class DictionaryService {
return responseString;
}
- public String saveActionListDictionary(HttpServletRequest request, HttpServletResponse response) throws UnsupportedEncodingException, IOException{
+ public String saveActionListDictionary(HttpServletRequest request, HttpServletResponse response) throws IOException{
FirewallDictionaryController dictionary = new FirewallDictionaryController();
String responseString = null;
@@ -177,7 +172,7 @@ public class DictionaryService {
return responseString;
}
- public String saveProtocolListDictionary(HttpServletRequest request, HttpServletResponse response) throws UnsupportedEncodingException, IOException{
+ public String saveProtocolListDictionary(HttpServletRequest request, HttpServletResponse response) throws IOException{
FirewallDictionaryController dictionary = new FirewallDictionaryController();
String responseString = null;
@@ -186,7 +181,7 @@ public class DictionaryService {
return responseString;
}
- public String saveZoneDictionary(HttpServletRequest request, HttpServletResponse response) throws UnsupportedEncodingException, IOException{
+ public String saveZoneDictionary(HttpServletRequest request, HttpServletResponse response) throws IOException{
FirewallDictionaryController dictionary = new FirewallDictionaryController();
String responseString = null;
@@ -195,7 +190,7 @@ public class DictionaryService {
return responseString;
}
- public String saveSecurityZoneDictionary(HttpServletRequest request, HttpServletResponse response) throws UnsupportedEncodingException, IOException{
+ public String saveSecurityZoneDictionary(HttpServletRequest request, HttpServletResponse response) throws IOException{
FirewallDictionaryController dictionary = new FirewallDictionaryController();
String responseString = null;
@@ -204,7 +199,7 @@ public class DictionaryService {
return responseString;
}
- public String savePrefixListDictionary(HttpServletRequest request, HttpServletResponse response) throws UnsupportedEncodingException, IOException{
+ public String savePrefixListDictionary(HttpServletRequest request, HttpServletResponse response) throws IOException{
FirewallDictionaryController dictionary = new FirewallDictionaryController();
String responseString = null;
@@ -213,7 +208,7 @@ public class DictionaryService {
return responseString;
}
- public String saveAddressGroupDictionary(HttpServletRequest request, HttpServletResponse response) throws UnsupportedEncodingException, IOException{
+ public String saveAddressGroupDictionary(HttpServletRequest request, HttpServletResponse response) throws IOException{
FirewallDictionaryController dictionary = new FirewallDictionaryController();
String responseString = null;
@@ -222,7 +217,7 @@ public class DictionaryService {
return responseString;
}
- public String saveServiceGroupDictionary(HttpServletRequest request, HttpServletResponse response) throws UnsupportedEncodingException, IOException{
+ public String saveServiceGroupDictionary(HttpServletRequest request, HttpServletResponse response) throws IOException{
FirewallDictionaryController dictionary = new FirewallDictionaryController();
String responseString = null;
@@ -231,7 +226,7 @@ public class DictionaryService {
return responseString;
}
- public String saveServiceListDictionary(HttpServletRequest request, HttpServletResponse response) throws UnsupportedEncodingException, IOException{
+ public String saveServiceListDictionary(HttpServletRequest request, HttpServletResponse response) throws IOException{
FirewallDictionaryController dictionary = new FirewallDictionaryController();
String responseString = null;
@@ -240,7 +235,7 @@ public class DictionaryService {
return responseString;
}
- public String saveTermListDictionary(HttpServletRequest request, HttpServletResponse response) throws UnsupportedEncodingException, IOException{
+ public String saveTermListDictionary(HttpServletRequest request, HttpServletResponse response) throws IOException{
FirewallDictionaryController dictionary = new FirewallDictionaryController();
String responseString = null;
@@ -252,7 +247,7 @@ public class DictionaryService {
- public String saveMicroServiceLocationDictionary(HttpServletRequest request, HttpServletResponse response) throws UnsupportedEncodingException, IOException{
+ public String saveMicroServiceLocationDictionary(HttpServletRequest request, HttpServletResponse response) throws IOException{
MicroServiceDictionaryController dictionary = new MicroServiceDictionaryController();
String responseString = null;
@@ -261,7 +256,7 @@ public class DictionaryService {
return responseString;
}
- public String saveMicroServiceConfigNameDictionary(HttpServletRequest request, HttpServletResponse response) throws UnsupportedEncodingException, IOException{
+ public String saveMicroServiceConfigNameDictionary(HttpServletRequest request, HttpServletResponse response) throws IOException{
MicroServiceDictionaryController dictionary = new MicroServiceDictionaryController();
String responseString = null;
@@ -270,7 +265,7 @@ public class DictionaryService {
return responseString;
}
- public String saveDCAEUUIDDictionary(HttpServletRequest request, HttpServletResponse response) throws UnsupportedEncodingException, IOException{
+ public String saveDCAEUUIDDictionary(HttpServletRequest request, HttpServletResponse response) throws IOException{
MicroServiceDictionaryController dictionary = new MicroServiceDictionaryController();
String responseString = null;
@@ -279,7 +274,7 @@ public class DictionaryService {
return responseString;
}
- public String saveMicroServiceModelsDictionary(HttpServletRequest request, HttpServletResponse response) throws UnsupportedEncodingException, IOException{
+ public String saveMicroServiceModelsDictionary(HttpServletRequest request, HttpServletResponse response) throws IOException{
MicroServiceDictionaryController dictionary = new MicroServiceDictionaryController();
String responseString = null;
@@ -288,7 +283,7 @@ public class DictionaryService {
return responseString;
}
- public String saveMicroServiceDictionary(HttpServletRequest request, HttpServletResponse response) throws UnsupportedEncodingException, IOException{
+ public String saveMicroServiceDictionary(HttpServletRequest request, HttpServletResponse response) throws IOException{
MicroServiceDictionaryController dictionary = new MicroServiceDictionaryController();
String responseString = null;
@@ -297,7 +292,7 @@ public class DictionaryService {
return responseString;
}
- public String savePSServiceDictionary(HttpServletRequest request, HttpServletResponse response) throws UnsupportedEncodingException, IOException{
+ public String savePSServiceDictionary(HttpServletRequest request, HttpServletResponse response) throws IOException{
PolicyScopeDictionaryController dictionary = new PolicyScopeDictionaryController();
String responseString = null;
@@ -306,7 +301,7 @@ public class DictionaryService {
return responseString;
}
- public String savePSResourceDictionary(HttpServletRequest request, HttpServletResponse response) throws UnsupportedEncodingException, IOException{
+ public String savePSResourceDictionary(HttpServletRequest request, HttpServletResponse response) throws IOException{
PolicyScopeDictionaryController dictionary = new PolicyScopeDictionaryController();
String responseString = null;
@@ -315,7 +310,7 @@ public class DictionaryService {
return responseString;
}
- public String savePSTypeDictionary(HttpServletRequest request, HttpServletResponse response) throws UnsupportedEncodingException, IOException{
+ public String savePSTypeDictionary(HttpServletRequest request, HttpServletResponse response) throws IOException{
PolicyScopeDictionaryController dictionary = new PolicyScopeDictionaryController();
String responseString = null;
@@ -324,7 +319,7 @@ public class DictionaryService {
return responseString;
}
- public String savePSClosedLoopDictionary(HttpServletRequest request, HttpServletResponse response) throws UnsupportedEncodingException, IOException{
+ public String savePSClosedLoopDictionary(HttpServletRequest request, HttpServletResponse response) throws IOException{
PolicyScopeDictionaryController dictionary = new PolicyScopeDictionaryController();
String responseString = null;
@@ -333,7 +328,7 @@ public class DictionaryService {
return responseString;
}
- public String savePSGroupScopeDictionary(HttpServletRequest request, HttpServletResponse response) throws UnsupportedEncodingException, IOException{
+ public String savePSGroupScopeDictionary(HttpServletRequest request, HttpServletResponse response) throws IOException{
PolicyScopeDictionaryController dictionary = new PolicyScopeDictionaryController();
String responseString = null;
@@ -342,7 +337,7 @@ public class DictionaryService {
return responseString;
}
- public String saveRiskTypeDictionary(HttpServletRequest request, HttpServletResponse response) throws UnsupportedEncodingException, IOException{
+ public String saveRiskTypeDictionary(HttpServletRequest request, HttpServletResponse response) throws IOException{
SafePolicyController dictionary = new SafePolicyController();
String responseString = null;
@@ -351,7 +346,7 @@ public class DictionaryService {
return responseString;
}
- public String saveSafePolicyWarningDictionary(HttpServletRequest request, HttpServletResponse response) throws UnsupportedEncodingException, IOException{
+ public String saveSafePolicyWarningDictionary(HttpServletRequest request, HttpServletResponse response) throws IOException{
SafePolicyController dictionary = new SafePolicyController();
String responseString = null;
ModelAndView result = dictionary.saveSafePolicyWarningDictionary(request, response);
@@ -363,173 +358,173 @@ public class DictionaryService {
/*
* Methods that call the controller get methods directly to get dictionary data
*/
- public void getOnapDictionary(HttpServletRequest request, HttpServletResponse response) throws UnsupportedEncodingException, IOException{
+ public void getOnapDictionary(HttpServletRequest request, HttpServletResponse response){
DictionaryController dictionary = new DictionaryController();
dictionary.getOnapNameDictionaryEntityData(request, response);
}
- public void getAttributeDictionary(HttpServletRequest request, HttpServletResponse response) throws UnsupportedEncodingException, IOException{
+ public void getAttributeDictionary(HttpServletRequest request, HttpServletResponse response){
DictionaryController dictionary = new DictionaryController();
dictionary.getAttributeDictionaryEntityData(request, response);
}
- public void getActionPolicyDictionary(HttpServletRequest request, HttpServletResponse response) throws UnsupportedEncodingException, IOException{
+ public void getActionPolicyDictionary(HttpServletRequest request, HttpServletResponse response){
ActionPolicyDictionaryController action = new ActionPolicyDictionaryController();
action.getActionPolicyDictionaryEntityData(request, response);
}
- public void getBRMSParamDictionary(HttpServletRequest request, HttpServletResponse response) throws UnsupportedEncodingException, IOException{
+ public void getBRMSParamDictionary(HttpServletRequest request, HttpServletResponse response){
BRMSDictionaryController dictionary = new BRMSDictionaryController();
dictionary.getBRMSParamDictionaryEntityData(request, response);
}
- public void getVSCLAction(HttpServletRequest request, HttpServletResponse response) throws UnsupportedEncodingException, IOException{
+ public void getVSCLAction(HttpServletRequest request, HttpServletResponse response){
ClosedLoopDictionaryController dictionary = new ClosedLoopDictionaryController();
dictionary.getVSCLActionDictionaryEntityData(request, response);
}
- public void getVnfType(HttpServletRequest request, HttpServletResponse response) throws UnsupportedEncodingException, IOException{
+ public void getVnfType(HttpServletRequest request, HttpServletResponse response){
ClosedLoopDictionaryController dictionary = new ClosedLoopDictionaryController();
dictionary.getVNFTypeDictionaryEntityData(request, response);
}
- public void getPEPOptions(HttpServletRequest request, HttpServletResponse response) throws UnsupportedEncodingException, IOException{
+ public void getPEPOptions(HttpServletRequest request, HttpServletResponse response){
ClosedLoopDictionaryController dictionary = new ClosedLoopDictionaryController();
dictionary.getPEPOptionsDictionaryEntityData(request, response);
}
- public void getVarbind(HttpServletRequest request, HttpServletResponse response) throws UnsupportedEncodingException, IOException{
+ public void getVarbind(HttpServletRequest request, HttpServletResponse response){
ClosedLoopDictionaryController dictionary = new ClosedLoopDictionaryController();
dictionary.getVarbindDictionaryEntityData(request, response);
}
- public void getServiceType(HttpServletRequest request, HttpServletResponse response) throws UnsupportedEncodingException, IOException{
+ public void getServiceType(HttpServletRequest request, HttpServletResponse response){
ClosedLoopDictionaryController dictionary = new ClosedLoopDictionaryController();
dictionary.getClosedLoopServiceDictionaryEntityData(request, response);
}
- public void getSiteType(HttpServletRequest request, HttpServletResponse response) throws UnsupportedEncodingException, IOException{
+ public void getSiteType(HttpServletRequest request, HttpServletResponse response){
ClosedLoopDictionaryController dictionary = new ClosedLoopDictionaryController();
dictionary.getClosedLoopSiteDictionaryEntityData(request, response);
}
- public void getSettingsDictionary(HttpServletRequest request, HttpServletResponse response) throws UnsupportedEncodingException, IOException{
+ public void getSettingsDictionary(HttpServletRequest request, HttpServletResponse response){
DecisionPolicyDictionaryController dictionary = new DecisionPolicyDictionaryController();
dictionary.getSettingsDictionaryEntityData(request, response);
}
- public void getDescriptiveDictionary(HttpServletRequest request, HttpServletResponse response) throws UnsupportedEncodingException, IOException{
+ public void getDescriptiveDictionary(HttpServletRequest request, HttpServletResponse response){
DescriptiveDictionaryController dictionary = new DescriptiveDictionaryController();
dictionary.getDescriptiveDictionaryEntityData(request, response);
}
- public void getEnforcerDictionary(HttpServletRequest request, HttpServletResponse response) throws UnsupportedEncodingException, IOException{
+ public void getEnforcerDictionary(HttpServletRequest request, HttpServletResponse response){
EnforcerDictionaryController dictionary = new EnforcerDictionaryController();
dictionary.getEnforcerDictionaryEntityData(request, response);
}
- public void getActionListDictionary(HttpServletRequest request, HttpServletResponse response) throws UnsupportedEncodingException, IOException{
+ public void getActionListDictionary(HttpServletRequest request, HttpServletResponse response){
FirewallDictionaryController dictionary = new FirewallDictionaryController();
dictionary.getActionListDictionaryEntityData(request, response);
}
- public void getProtocolListDictionary(HttpServletRequest request, HttpServletResponse response) throws UnsupportedEncodingException, IOException{
+ public void getProtocolListDictionary(HttpServletRequest request, HttpServletResponse response){
FirewallDictionaryController dictionary = new FirewallDictionaryController();
dictionary.getProtocolListDictionaryEntityData(request, response);
}
- public void getZoneDictionary(HttpServletRequest request, HttpServletResponse response) throws UnsupportedEncodingException, IOException{
+ public void getZoneDictionary(HttpServletRequest request, HttpServletResponse response){
FirewallDictionaryController dictionary = new FirewallDictionaryController();
dictionary.getZoneDictionaryEntityData(request, response);
}
- public void getSecurityZoneDictionary(HttpServletRequest request, HttpServletResponse response) throws UnsupportedEncodingException, IOException{
+ public void getSecurityZoneDictionary(HttpServletRequest request, HttpServletResponse response){
FirewallDictionaryController dictionary = new FirewallDictionaryController();
dictionary.getSecurityZoneDictionaryEntityData(request, response);
}
- public void getPrefixListDictionary(HttpServletRequest request, HttpServletResponse response) throws UnsupportedEncodingException, IOException{
+ public void getPrefixListDictionary(HttpServletRequest request, HttpServletResponse response){
FirewallDictionaryController dictionary = new FirewallDictionaryController();
dictionary.getPrefixListDictionaryEntityData(request, response);
}
- public void getAddressGroupDictionary(HttpServletRequest request, HttpServletResponse response) throws UnsupportedEncodingException, IOException{
+ public void getAddressGroupDictionary(HttpServletRequest request, HttpServletResponse response){
FirewallDictionaryController dictionary = new FirewallDictionaryController();
dictionary.getAddressGroupDictionaryEntityData(request, response);
}
- public void getServiceGroupDictionary(HttpServletRequest request, HttpServletResponse response) throws UnsupportedEncodingException, IOException{
+ public void getServiceGroupDictionary(HttpServletRequest request, HttpServletResponse response){
FirewallDictionaryController dictionary = new FirewallDictionaryController();
dictionary.getServiceGroupDictionaryEntityData(request, response);
}
- public void getServiceListDictionary(HttpServletRequest request, HttpServletResponse response) throws UnsupportedEncodingException, IOException{
+ public void getServiceListDictionary(HttpServletRequest request, HttpServletResponse response){
FirewallDictionaryController dictionary = new FirewallDictionaryController();
dictionary.getServiceListDictionaryEntityData(request, response);
}
- public void getTermListDictionary(HttpServletRequest request, HttpServletResponse response) throws UnsupportedEncodingException, IOException{
+ public void getTermListDictionary(HttpServletRequest request, HttpServletResponse response){
FirewallDictionaryController dictionary = new FirewallDictionaryController();
dictionary.getTermListDictionaryEntityData(request, response);
}
- public void getMicroServiceLocationDictionary(HttpServletRequest request, HttpServletResponse response) throws UnsupportedEncodingException, IOException{
+ public void getMicroServiceLocationDictionary(HttpServletRequest request, HttpServletResponse response){
MicroServiceDictionaryController dictionary = new MicroServiceDictionaryController();
dictionary.getMicroServiceLocationDictionaryEntityData(request, response);
}
- public void getMicroServiceConfigNameDictionary(HttpServletRequest request, HttpServletResponse response) throws UnsupportedEncodingException, IOException{
+ public void getMicroServiceConfigNameDictionary(HttpServletRequest request, HttpServletResponse response){
MicroServiceDictionaryController dictionary = new MicroServiceDictionaryController();
dictionary.getMicroServiceConfigNameDictionaryEntityData(request, response);
}
- public void getDCAEUUIDDictionary(HttpServletRequest request, HttpServletResponse response) throws UnsupportedEncodingException, IOException{
+ public void getDCAEUUIDDictionary(HttpServletRequest request, HttpServletResponse response){
MicroServiceDictionaryController dictionary = new MicroServiceDictionaryController();
dictionary.getDCAEUUIDDictionaryEntityData(request, response);
}
- public void getMicroServiceModelsDictionary(HttpServletRequest request, HttpServletResponse response) throws UnsupportedEncodingException, IOException{
+ public void getMicroServiceModelsDictionary(HttpServletRequest request, HttpServletResponse response){
MicroServiceDictionaryController dictionary = new MicroServiceDictionaryController();
dictionary.getMicroServiceModelsDictionaryEntityData(request, response);
}
- public void getMicroServiceDictionary(HttpServletRequest request, HttpServletResponse response) throws UnsupportedEncodingException, IOException{
+ public void getMicroServiceDictionary(HttpServletRequest request, HttpServletResponse response){
MicroServiceDictionaryController dictionary = new MicroServiceDictionaryController();
dictionary.getMicroServiceModelsDictionaryEntityData(request, response);
}
- public void getPSServiceDictionary(HttpServletRequest request, HttpServletResponse response) throws UnsupportedEncodingException, IOException{
+ public void getPSServiceDictionary(HttpServletRequest request, HttpServletResponse response){
PolicyScopeDictionaryController dictionary = new PolicyScopeDictionaryController();
dictionary.getPSServiceEntityData(request, response);
}
- public void getPSResourceDictionary(HttpServletRequest request, HttpServletResponse response) throws UnsupportedEncodingException, IOException{
+ public void getPSResourceDictionary(HttpServletRequest request, HttpServletResponse response){
PolicyScopeDictionaryController dictionary = new PolicyScopeDictionaryController();
dictionary.getPSResourceEntityData(request, response);
}
- public void getPSTypeDictionary(HttpServletRequest request, HttpServletResponse response) throws UnsupportedEncodingException, IOException{
+ public void getPSTypeDictionary(HttpServletRequest request, HttpServletResponse response){
PolicyScopeDictionaryController dictionary = new PolicyScopeDictionaryController();
dictionary.getPSTypeEntityData(request, response);
}
- public void getPSClosedLoopDictionary(HttpServletRequest request, HttpServletResponse response) throws UnsupportedEncodingException, IOException{
+ public void getPSClosedLoopDictionary(HttpServletRequest request, HttpServletResponse response){
PolicyScopeDictionaryController dictionary = new PolicyScopeDictionaryController();
dictionary.getPSClosedLoopEntityData(request, response);
}
- public void getPSGroupScopeDictionary(HttpServletRequest request, HttpServletResponse response) throws UnsupportedEncodingException, IOException{
+ public void getPSGroupScopeDictionary(HttpServletRequest request, HttpServletResponse response){
PolicyScopeDictionaryController dictionary = new PolicyScopeDictionaryController();
dictionary.getGroupPolicyScopeEntityData(request, response);
}
- public void getRiskTypeDictionary(HttpServletRequest request, HttpServletResponse response) throws UnsupportedEncodingException, IOException{
+ public void getRiskTypeDictionary(HttpServletRequest request, HttpServletResponse response){
SafePolicyController dictionary = new SafePolicyController();
dictionary.getOnapNameDictionaryEntityData(request, response);
}
- public void getSafePolicyWarningDictionary(HttpServletRequest request, HttpServletResponse response) throws UnsupportedEncodingException, IOException{
+ public void getSafePolicyWarningDictionary(HttpServletRequest request, HttpServletResponse response) {
SafePolicyController dictionary = new SafePolicyController();
dictionary.getSafePolicyWarningeEntityData(request, response);
}
diff --git a/ONAP-PAP-REST/src/main/java/org/onap/policy/pap/xacml/rest/service/ImportService.java b/ONAP-PAP-REST/src/main/java/org/onap/policy/pap/xacml/rest/service/ImportService.java
index 166720714..8a9e8ffac 100644
--- a/ONAP-PAP-REST/src/main/java/org/onap/policy/pap/xacml/rest/service/ImportService.java
+++ b/ONAP-PAP-REST/src/main/java/org/onap/policy/pap/xacml/rest/service/ImportService.java
@@ -38,7 +38,6 @@ import org.onap.policy.common.logging.flexlogger.FlexLogger;
import org.onap.policy.common.logging.flexlogger.Logger;
import org.onap.policy.pap.xacml.rest.components.CreateBRMSRuleTemplate;
import org.onap.policy.pap.xacml.rest.components.CreateNewMicroServiceModel;
-import org.onap.policy.pap.xacml.rest.model.PDPPolicyContainer;
public class ImportService {
private static final Logger logger = FlexLogger.getLogger(ImportService.class);
diff --git a/ONAP-PAP-REST/src/main/java/org/onap/policy/pap/xacml/rest/util/JPAUtils.java b/ONAP-PAP-REST/src/main/java/org/onap/policy/pap/xacml/rest/util/JPAUtils.java
index 05885ee16..e18ca9ebd 100644
--- a/ONAP-PAP-REST/src/main/java/org/onap/policy/pap/xacml/rest/util/JPAUtils.java
+++ b/ONAP-PAP-REST/src/main/java/org/onap/policy/pap/xacml/rest/util/JPAUtils.java
@@ -43,7 +43,7 @@ import org.onap.policy.common.logging.flexlogger.FlexLogger;
import org.onap.policy.common.logging.flexlogger.Logger;
public class JPAUtils {
- private static Logger LOGGER = FlexLogger.getLogger(JPAUtils.class);
+ private static final Logger LOGGER = FlexLogger.getLogger(JPAUtils.class);
private static EntityManagerFactory emf;
private static final Object mapAccess = new Object();
@@ -73,7 +73,7 @@ public class JPAUtils {
private JPAUtils(EntityManagerFactory emf){
LOGGER.debug("JPAUtils(EntityManagerFactory emf) as JPAUtils("+emf+") called");
- this.emf = emf;
+ JPAUtils.emf = emf;
}
/**
@@ -169,7 +169,7 @@ public class JPAUtils {
for (Object id : functionList) {
FunctionDefinition value = (FunctionDefinition)id;
mapID2Function.put(value.getXacmlid(), value);
- if (mapDatatype2Function.containsKey(value.getDatatypeBean()) == false) {
+ if (!mapDatatype2Function.containsKey(value.getDatatypeBean())) {
mapDatatype2Function.put(value.getDatatypeBean(), new ArrayList<FunctionDefinition>());
}
mapDatatype2Function.get(value.getDatatypeBean()).add(value);
diff --git a/ONAP-PDP-REST/src/main/java/org/onap/policy/pdp/rest/api/services/NotificationService.java b/ONAP-PDP-REST/src/main/java/org/onap/policy/pdp/rest/api/services/NotificationService.java
index c1b9f63e1..6ca52ca40 100644
--- a/ONAP-PDP-REST/src/main/java/org/onap/policy/pdp/rest/api/services/NotificationService.java
+++ b/ONAP-PDP-REST/src/main/java/org/onap/policy/pdp/rest/api/services/NotificationService.java
@@ -118,6 +118,13 @@ public class NotificationService {
callThread();
}
}
+
+ public static void reloadProps(){
+ dmaapServers = null;
+ aafLogin = null;
+ aafPassword = null;
+ backUpthread = null;
+ }
private void run(String notificationTopic, NotificationServiceType serviceType) throws PolicyException{
// Check Validation
diff --git a/ONAP-PDP-REST/src/main/java/org/onap/policy/pdp/rest/notifications/NotificationController.java b/ONAP-PDP-REST/src/main/java/org/onap/policy/pdp/rest/notifications/NotificationController.java
index 577d5b347..8121bdc8f 100644
--- a/ONAP-PDP-REST/src/main/java/org/onap/policy/pdp/rest/notifications/NotificationController.java
+++ b/ONAP-PDP-REST/src/main/java/org/onap/policy/pdp/rest/notifications/NotificationController.java
@@ -175,7 +175,7 @@ public class NotificationController {
}
}
- private void setNotificationFlag(boolean value) {
+ private static void setNotificationFlag(boolean value) {
notificationFlag = value;
}
diff --git a/ONAP-PDP-REST/src/test/java/org/onap/policy/pdp/rest/api/test/PolicyEngineServicesTest.java b/ONAP-PDP-REST/src/test/java/org/onap/policy/pdp/rest/api/test/PolicyEngineServicesTest.java
index fe4ce0599..ac8b269eb 100644
--- a/ONAP-PDP-REST/src/test/java/org/onap/policy/pdp/rest/api/test/PolicyEngineServicesTest.java
+++ b/ONAP-PDP-REST/src/test/java/org/onap/policy/pdp/rest/api/test/PolicyEngineServicesTest.java
@@ -55,6 +55,7 @@ import org.onap.policy.pdp.rest.api.models.ConfigFirewallPolicyAPIRequest;
import org.onap.policy.pdp.rest.api.models.ConfigNameRequest;
import org.onap.policy.pdp.rest.api.models.ConfigPolicyAPIRequest;
import org.onap.policy.pdp.rest.api.services.CreateUpdatePolicyServiceImpl;
+import org.onap.policy.pdp.rest.api.services.NotificationService;
import org.onap.policy.pdp.rest.config.PDPRestConfig;
import org.onap.policy.utils.PolicyUtils;
import org.springframework.beans.factory.annotation.Autowired;
@@ -195,9 +196,11 @@ public class PolicyEngineServicesTest {
@Test
public void getNotificationTopicValidPassTest() throws Exception{
+ // Values can be polluted due to failure tests and need to be reloaded.
XACMLProperties.reloadProperties();
System.setProperty(XACMLProperties.XACML_PROPERTIES_NAME, "src/test/resources/notification.xacml.pdp.properties");
XACMLProperties.getProperties();
+ NotificationService.reloadProps();
// Add a Topic.
mockMvc.perform(post("/getNotification").headers(headers).header(UUIDHEADER, "123").content("test")).andExpect(status().isOk());
// Try to add same topic should fail.
diff --git a/PolicyEngineAPI/src/main/java/org/onap/policy/api/PolicyEngine.java b/PolicyEngineAPI/src/main/java/org/onap/policy/api/PolicyEngine.java
index 7bd45983b..2b5252c26 100644
--- a/PolicyEngineAPI/src/main/java/org/onap/policy/api/PolicyEngine.java
+++ b/PolicyEngineAPI/src/main/java/org/onap/policy/api/PolicyEngine.java
@@ -586,7 +586,7 @@ public class PolicyEngine{
* @param clientKey depicts String format of Password/ Client_Key.
*/
public void setClientKey(String clientKey){
- stdPolicyEngine.setClientKey(clientKey);
+ StdPolicyEngine.setClientKey(clientKey);
}
// Internal Setter Method to help build configRequestParameters.
diff --git a/PolicyEngineAPI/src/main/java/org/onap/policy/std/AutoClientDMAAP.java b/PolicyEngineAPI/src/main/java/org/onap/policy/std/AutoClientDMAAP.java
index d031868f0..5bfe360fb 100644
--- a/PolicyEngineAPI/src/main/java/org/onap/policy/std/AutoClientDMAAP.java
+++ b/PolicyEngineAPI/src/main/java/org/onap/policy/std/AutoClientDMAAP.java
@@ -102,7 +102,7 @@ public class AutoClientDMAAP implements Runnable {
}
}
- private void setNotification(StdPDPNotification notificationJSON) {
+ private static void setNotification(StdPDPNotification notificationJSON) {
notification = notificationJSON;
}
diff --git a/PolicyEngineAPI/src/main/java/org/onap/policy/std/StdPolicyEngine.java b/PolicyEngineAPI/src/main/java/org/onap/policy/std/StdPolicyEngine.java
index 4e904b6e1..bef964174 100644
--- a/PolicyEngineAPI/src/main/java/org/onap/policy/std/StdPolicyEngine.java
+++ b/PolicyEngineAPI/src/main/java/org/onap/policy/std/StdPolicyEngine.java
@@ -28,7 +28,6 @@ import java.io.UnsupportedEncodingException;
import java.net.URL;
import java.net.URLConnection;
import java.nio.charset.StandardCharsets;
-import java.nio.file.Files;
import java.nio.file.Path;
import java.nio.file.Paths;
import java.text.ParseException;
@@ -108,8 +107,12 @@ import com.google.gson.GsonBuilder;
public class StdPolicyEngine {
private static final String ERROR_AUTH_GET_PERM = "You are not allowed to Make this Request. Please contact PolicyAdmin to give access to: ";
private static final String DEFAULT_NOTIFICATION = "websocket";
-
- private String clientEncoding = null;
+ private static final String ERROR_DATA_ISSUE = "Invalid Data is given.";
+ private static final String DMAAP = "dmaap";
+ private static final String ERROR_INVALID_PDPS = "Unable to get valid Response from PDP(s) ";
+ private static final String ERROR_WHILE_CONNECTING = "Error while connecting to ";
+
+ private static String clientEncoding = null;
private String contentType = null;
private static List<String> pdps = null;
private static String environment = null;
@@ -117,8 +120,6 @@ public class StdPolicyEngine {
private static String pass = null;
private static List<String> encoding = null;
private static boolean junit = false;
- private List<String> pdpDefault = null;
- private List<String> typeDefault = null;
private List<String> notificationType = new ArrayList<>();
private List<String> notificationURLList = new ArrayList<>();
private NotificationScheme scheme = null;
@@ -151,7 +152,7 @@ public class StdPolicyEngine {
setProperty(propertyFilePath, null);
this.scheme = scheme;
this.handler = handler;
- if ((!"ueb".equals(notificationType.get(0))) || (!"dmaap".equals(notificationType.get(0)))) {
+ if ((!"ueb".equals(notificationType.get(0))) || (!DMAAP.equals(notificationType.get(0)))) {
AutoClientEnd.setAuto(scheme, handler);
}
notification(scheme, handler);
@@ -365,12 +366,12 @@ public class StdPolicyEngine {
return response;
}
if (exception.getCause().getMessage().contains("400")) {
- String message = XACMLErrorConstants.ERROR_DATA_ISSUE + "Invalid Data is given.";
+ String message = XACMLErrorConstants.ERROR_DATA_ISSUE + ERROR_DATA_ISSUE;
response.setResponseMessage(message);
response.setResponseCode(400);
return response;
}
- String message = XACMLErrorConstants.ERROR_PERMISSIONS + "Unable to get valid Response from PDP(s) "
+ String message = XACMLErrorConstants.ERROR_PERMISSIONS + ERROR_INVALID_PDPS
+ pdps;
LOGGER.error(message, exception);
response.setResponseMessage(message);
@@ -449,7 +450,7 @@ public class StdPolicyEngine {
public PolicyChangeResponse policyEngineImportImpl(ImportParameters importParameters) throws PolicyException {
StdPolicyChangeResponse response = new StdPolicyChangeResponse();
String resource = "policyEngineImport";
- LinkedMultiValueMap<String, Object> parameters = new LinkedMultiValueMap<String, Object>();
+ LinkedMultiValueMap<String, Object> parameters = new LinkedMultiValueMap<>();
// Create Request.
try {
String body = PolicyUtils.objectToJsonString(importParameters);
@@ -563,11 +564,11 @@ public class StdPolicyEngine {
throw new PolicyDecisionException(message, exception);
}
if (exception.getCause().getMessage().contains("400")) {
- String message = XACMLErrorConstants.ERROR_DATA_ISSUE + "Invalid Data is given.";
+ String message = XACMLErrorConstants.ERROR_DATA_ISSUE + ERROR_DATA_ISSUE;
LOGGER.error(message);
throw new PolicyDecisionException(message, exception);
}
- String message = XACMLErrorConstants.ERROR_PERMISSIONS + "Unable to get valid Response from PDP(s) "
+ String message = XACMLErrorConstants.ERROR_PERMISSIONS + ERROR_INVALID_PDPS
+ pdps;
LOGGER.error(message, exception);
throw new PolicyDecisionException(message, exception);
@@ -578,7 +579,7 @@ public class StdPolicyEngine {
public Collection<PolicyConfig> getConfigImpl(ConfigRequestParameters configRequestParameters)
throws PolicyConfigException {
String resource = "getConfig";
- ArrayList<PolicyConfig> response = new ArrayList<>();
+ ArrayList<PolicyConfig> response = null;
String body = null;
// Create Request.
try {
@@ -601,11 +602,11 @@ public class StdPolicyEngine {
throw new PolicyConfigException(message, exception);
}
if (exception.getCause().getMessage().contains("400")) {
- String message = XACMLErrorConstants.ERROR_DATA_ISSUE + "Invalid Data is given.";
+ String message = XACMLErrorConstants.ERROR_DATA_ISSUE + ERROR_DATA_ISSUE;
LOGGER.error(message);
throw new PolicyConfigException(message, exception);
}
- String message = XACMLErrorConstants.ERROR_PROCESS_FLOW + "Unable to get valid Response from PDP(s) "
+ String message = XACMLErrorConstants.ERROR_PROCESS_FLOW + ERROR_INVALID_PDPS
+ pdps;
LOGGER.error(message, exception);
throw new PolicyConfigException(message, exception);
@@ -668,13 +669,13 @@ public class StdPolicyEngine {
Matches match = new Matches();
HashMap<String, String> configAttributes = new HashMap<>();
try {
- for (String key : matchingConditions.keySet()) {
- if (key.equalsIgnoreCase("ONAPName")) {
- match.setOnapName(matchingConditions.get(key));
- } else if (key.equalsIgnoreCase("ConfigName")) {
- match.setConfigName(matchingConditions.get(key));
+ for (Map.Entry<String,String> entry : matchingConditions.entrySet()) {
+ if (entry.getKey().equalsIgnoreCase("ONAPName")) {
+ match.setOnapName(entry.getValue());
+ } else if (entry.getKey().equalsIgnoreCase("ConfigName")) {
+ match.setConfigName(entry.getValue());
} else {
- configAttributes.put(key, matchingConditions.get(key));
+ configAttributes.put(entry.getKey(), entry.getValue());
}
}
if (!configAttributes.isEmpty()) {
@@ -700,10 +701,10 @@ public class StdPolicyEngine {
try {
result = restTemplate.exchange(pdps.get(0) + "/api/" + resource, method, requestEntity, responseType);
} catch (HttpClientErrorException e) {
- LOGGER.error(XACMLErrorConstants.ERROR_PROCESS_FLOW + "Error while connecting to " + pdps.get(0), e);
+ LOGGER.error(XACMLErrorConstants.ERROR_PROCESS_FLOW + ERROR_WHILE_CONNECTING + pdps.get(0), e);
exception = e;
} catch (Exception e) {
- LOGGER.error(XACMLErrorConstants.ERROR_PROCESS_FLOW + "Error while connecting to " + pdps.get(0), e);
+ LOGGER.error(XACMLErrorConstants.ERROR_PROCESS_FLOW + ERROR_WHILE_CONNECTING + pdps.get(0), e);
exception = new HttpClientErrorException(HttpStatus.INTERNAL_SERVER_ERROR, e.getMessage());
}
if (result == null) {
@@ -728,7 +729,7 @@ public class StdPolicyEngine {
throw new PolicyException(message, exception);
}
if (exception.getStatusCode().equals(HttpStatus.NOT_FOUND)) {
- String message = XACMLErrorConstants.ERROR_PROCESS_FLOW + "Error while connecting to " + pdps
+ String message = XACMLErrorConstants.ERROR_PROCESS_FLOW + ERROR_WHILE_CONNECTING + pdps
+ exception;
LOGGER.error(message);
throw new PolicyException(message, exception);
@@ -746,7 +747,7 @@ public class StdPolicyEngine {
headers.set("ClientAuth", "Basic " + clientEncoding);
headers.set("Authorization", "Basic " + encoding.get(0));
if (contentType != null) {
- headers.set("Content-Type", contentType.toString());
+ headers.set("Content-Type", contentType);
} else {
headers.set("Content-Type", MediaType.APPLICATION_JSON_VALUE);
}
@@ -754,7 +755,7 @@ public class StdPolicyEngine {
return headers;
}
- private void setClientEncoding() {
+ private static void setClientEncoding() {
Base64.Encoder encoder = Base64.getEncoder();
clientEncoding = encoder.encodeToString((userName + ":" + pass).getBytes(StandardCharsets.UTF_8));
}
@@ -780,8 +781,8 @@ public class StdPolicyEngine {
public Collection<PolicyResponse> sendEventImpl(Map<String, String> eventAttributes, UUID requestID)
throws PolicyEventException {
String resource = "sendEvent";
- ArrayList<PolicyResponse> response = new ArrayList<PolicyResponse>();
- String body = new String();
+ ArrayList<PolicyResponse> response = null;
+ String body = null;
// Create Request.
try {
// Long way here, can be shortened and will be done.
@@ -807,11 +808,11 @@ public class StdPolicyEngine {
throw new PolicyEventException(message, exception);
}
if (exception.getCause().getMessage().contains("400")) {
- String message = XACMLErrorConstants.ERROR_DATA_ISSUE + "Invalid Data is given.";
+ String message = XACMLErrorConstants.ERROR_DATA_ISSUE + ERROR_DATA_ISSUE;
LOGGER.error(message);
throw new PolicyEventException(message, exception);
}
- String message = XACMLErrorConstants.ERROR_PERMISSIONS + "Unable to get valid Response from PDP(s) "
+ String message = XACMLErrorConstants.ERROR_PERMISSIONS + ERROR_INVALID_PDPS
+ pdps;
LOGGER.error(message, exception);
throw new PolicyEventException(message, exception);
@@ -819,7 +820,7 @@ public class StdPolicyEngine {
return response;
}
- private ArrayList<PolicyResponse> eventResult(StdPolicyResponse[] response) throws PolicyEventException {
+ private ArrayList<PolicyResponse> eventResult(StdPolicyResponse[] response){
ArrayList<PolicyResponse> eventResult = new ArrayList<>();
if (response != null && response.length > 0) {
for (StdPolicyResponse policyConfigResponse : response) {
@@ -850,7 +851,7 @@ public class StdPolicyEngine {
}
} else {
Path file = Paths.get(propertyFilePath);
- if (Files.notExists(file)) {
+ if (!file.toFile().exists()) {
throw new PolicyEngineException(XACMLErrorConstants.ERROR_DATA_ISSUE
+ "File doesn't exist in the specified Path " + file.toString());
}
@@ -884,8 +885,7 @@ public class StdPolicyEngine {
} else {
checkType = checkType.trim();
if (checkType.contains(",")) {
- typeDefault = new ArrayList<>(Arrays.asList(prop.getProperty("NOTIFICATION_TYPE").split(",")));
- notificationType = typeDefault;
+ notificationType = new ArrayList<>(Arrays.asList(prop.getProperty("NOTIFICATION_TYPE").split(",")));
} else {
notificationType = new ArrayList<>();
notificationType.add(checkType);
@@ -899,7 +899,7 @@ public class StdPolicyEngine {
} else {
serverList = serverList.trim();
if (serverList.contains(",")) {
- notificationURLList = new ArrayList<String>(Arrays.asList(serverList.split(",")));
+ notificationURLList = new ArrayList<>(Arrays.asList(serverList.split(",")));
} else {
notificationURLList = new ArrayList<>();
notificationURLList.add(serverList);
@@ -948,7 +948,7 @@ public class StdPolicyEngine {
+ "Properties file doesn't have the PDP_URL parameter");
}
if (checkVal.contains(";")) {
- pdpDefault = new ArrayList<>(Arrays.asList(checkVal.split("\\s*;\\s*")));
+ List<String> pdpDefault = new ArrayList<>(Arrays.asList(checkVal.split("\\s*;\\s*")));
int pdpCount = 0;
while (pdpCount < pdpDefault.size()) {
String pdpVal = pdpDefault.get(pdpCount);
@@ -1008,15 +1008,15 @@ public class StdPolicyEngine {
*/
private void readPDPParam(String pdpVal) throws PolicyEngineException {
if (pdpVal.contains(",")) {
- List<String> pdpValues = new ArrayList<String>(Arrays.asList(pdpVal.split("\\s*,\\s*")));
+ List<String> pdpValues = new ArrayList<>(Arrays.asList(pdpVal.split("\\s*,\\s*")));
if (pdpValues.size() == 3) {
// 0 - PDPURL
pdps.add(pdpValues.get(0));
// 1:2 will be UserID:Password
String userID = pdpValues.get(1);
- String pass = pdpValues.get(2);
+ String userPas = pdpValues.get(2);
Base64.Encoder encoder = Base64.getEncoder();
- encoding.add(encoder.encodeToString((userID + ":" + pass).getBytes(StandardCharsets.UTF_8)));
+ encoding.add(encoder.encodeToString((userID + ":" + userPas).getBytes(StandardCharsets.UTF_8)));
} else {
LOGGER.error(XACMLErrorConstants.ERROR_DATA_ISSUE + "No Credentials to send Request: " + pdpValues);
throw new PolicyEngineException(
@@ -1044,7 +1044,7 @@ public class StdPolicyEngine {
AutoClientUEB.setAuto(scheme, handler);
this.uebThread = registerUEBThread.isAlive();
}
- } else if (notificationType.get(0).equals("dmaap")) {
+ } else if (notificationType.get(0).equals(DMAAP)) {
if (this.dmaapThread) {
AutoClientDMAAP.setAuto(scheme, handler);
this.dmaapThread = registerDMAAPThread.isAlive();
@@ -1064,7 +1064,7 @@ public class StdPolicyEngine {
this.registerUEBThread = new Thread(this.uebClientThread);
this.registerUEBThread.start();
this.uebThread = true;
- } else if (notificationType.get(0).equals("dmaap") && !this.dmaapThread) {
+ } else if (notificationType.get(0).equals(DMAAP) && !this.dmaapThread) {
this.dmaapClientThread = new AutoClientDMAAP(notificationURLList, topic, userName, pass);
AutoClientDMAAP.setAuto(scheme, handler);
this.registerDMAAPThread = new Thread(this.dmaapClientThread);
@@ -1094,7 +1094,7 @@ public class StdPolicyEngine {
if (notificationType.get(0).equals("ueb")) {
ManualClientEndUEB.start(pdps.get(0), notificationURLList, UNIQUEID);
notification = ManualClientEndUEB.result(scheme);
- } else if (notificationType.get(0).equals("dmaap")) {
+ } else if (notificationType.get(0).equals(DMAAP)) {
ManualClientEndDMAAP.start(notificationURLList, topic, UNIQUEID, userName, pass);
notification = ManualClientEndDMAAP.result(scheme);
} else {
@@ -1123,7 +1123,7 @@ public class StdPolicyEngine {
if (this.scheme.equals(NotificationScheme.MANUAL_ALL_NOTIFICATIONS)) {
ManualClientEndUEB.createTopic(pdps.get(0), UNIQUEID, notificationURLList);
}
- } else if (notificationType.get(0).equals("dmaap")) {
+ } else if (notificationType.get(0).equals(DMAAP)) {
AutoClientDMAAP.setScheme(this.scheme);
if (this.scheme.equals(NotificationScheme.MANUAL_ALL_NOTIFICATIONS)) {
ManualClientEndDMAAP.createTopic(topic, UNIQUEID, notificationURLList, userName, pass);
@@ -1151,19 +1151,17 @@ public class StdPolicyEngine {
* Stop the Notification Service if its running.
*/
public void stopNotification() {
- if (this.scheme != null && this.handler != null) {
- if (this.scheme.equals(NotificationScheme.AUTO_ALL_NOTIFICATIONS)
- || this.scheme.equals(NotificationScheme.AUTO_NOTIFICATIONS)) {
- LOGGER.info("Clear Notification called.. ");
- if (notificationType.get(0).equals("ueb")) {
- this.uebClientThread.terminate();
- this.uebThread = false;
- } else if (notificationType.get(0).equals("dmaap")) {
- this.dmaapClientThread.terminate();
- this.dmaapThread = false;
- } else {
- AutoClientEnd.stop();
- }
+ if (this.scheme != null && this.handler != null && (this.scheme.equals(NotificationScheme.AUTO_ALL_NOTIFICATIONS)
+ || this.scheme.equals(NotificationScheme.AUTO_NOTIFICATIONS))) {
+ LOGGER.info("Clear Notification called.. ");
+ if (notificationType.get(0).equals("ueb")) {
+ this.uebClientThread.terminate();
+ this.uebThread = false;
+ } else if (notificationType.get(0).equals(DMAAP)) {
+ this.dmaapClientThread.terminate();
+ this.dmaapThread = false;
+ } else {
+ AutoClientEnd.stop();
}
}
}
@@ -1276,13 +1274,13 @@ public class StdPolicyEngine {
try {
policyParameters.setTtlDate(new SimpleDateFormat("dd-MM-yyyy").parse(ttlDate));
} catch (NullPointerException | ParseException e) {
- LOGGER.warn("Error Parsing date given " + ttlDate);
+ LOGGER.warn("Error Parsing date given " + ttlDate, e);
policyParameters.setTtlDate(null);
}
return createUpdatePolicyImpl(policyParameters, updateFlag).getResponseMessage();
}
- public void setClientKey(String clientKey) {
+ public static void setClientKey(String clientKey) {
if (clientKey != null && !clientKey.isEmpty()) {
StdPolicyEngine.pass = clientKey;
setClientEncoding();