summaryrefslogtreecommitdiffstats
path: root/POLICY-SDK-APP/src/main/java/org/openecomp
diff options
context:
space:
mode:
Diffstat (limited to 'POLICY-SDK-APP/src/main/java/org/openecomp')
-rw-r--r--POLICY-SDK-APP/src/main/java/org/openecomp/policy/admin/PolicyManagerServlet.java35
-rw-r--r--POLICY-SDK-APP/src/main/java/org/openecomp/policy/admin/PolicyNotificationMail.java69
-rw-r--r--POLICY-SDK-APP/src/main/java/org/openecomp/policy/admin/PolicyRestController.java156
-rw-r--r--POLICY-SDK-APP/src/main/java/org/openecomp/policy/controller/ActionPolicyController.java4
-rw-r--r--POLICY-SDK-APP/src/main/java/org/openecomp/policy/controller/CreateBRMSParamController.java74
-rw-r--r--POLICY-SDK-APP/src/main/java/org/openecomp/policy/controller/CreateBRMSRawController.java1
-rw-r--r--POLICY-SDK-APP/src/main/java/org/openecomp/policy/controller/CreateClosedLoopFaultController.java164
-rw-r--r--POLICY-SDK-APP/src/main/java/org/openecomp/policy/controller/CreateClosedLoopPMController.java1
-rw-r--r--POLICY-SDK-APP/src/main/java/org/openecomp/policy/controller/CreateDcaeMicroServiceController.java41
-rw-r--r--POLICY-SDK-APP/src/main/java/org/openecomp/policy/controller/CreateFirewallController.java49
-rw-r--r--POLICY-SDK-APP/src/main/java/org/openecomp/policy/controller/DashboardController.java67
-rw-r--r--POLICY-SDK-APP/src/main/java/org/openecomp/policy/controller/DecisionPolicyController.java40
-rw-r--r--POLICY-SDK-APP/src/main/java/org/openecomp/policy/controller/PDPController.java88
-rw-r--r--POLICY-SDK-APP/src/main/java/org/openecomp/policy/controller/PolicyExportAndImportController.java10
-rw-r--r--POLICY-SDK-APP/src/main/java/org/openecomp/policy/controller/PolicyValidationController.java22
15 files changed, 423 insertions, 398 deletions
diff --git a/POLICY-SDK-APP/src/main/java/org/openecomp/policy/admin/PolicyManagerServlet.java b/POLICY-SDK-APP/src/main/java/org/openecomp/policy/admin/PolicyManagerServlet.java
index 639e29e3d..1821e1031 100644
--- a/POLICY-SDK-APP/src/main/java/org/openecomp/policy/admin/PolicyManagerServlet.java
+++ b/POLICY-SDK-APP/src/main/java/org/openecomp/policy/admin/PolicyManagerServlet.java
@@ -95,13 +95,13 @@ public class PolicyManagerServlet extends HttpServlet {
LIST, RENAME, COPY, DELETE, EDITFILE, ADDFOLDER, DESCRIBEPOLICYFILE, VIEWPOLICY, ADDSUBSCOPE, SWITCHVERSION, EXPORT, SEARCHLIST
}
- private PolicyController policyController;
- public PolicyController getPolicyController() {
+ private static PolicyController policyController;
+ public synchronized PolicyController getPolicyController() {
return policyController;
}
- public void setPolicyController(PolicyController policyController) {
- this.policyController = policyController;
+ public synchronized static void setPolicyController(PolicyController policyController) {
+ PolicyManagerServlet.policyController = policyController;
}
private static String CONTENTTYPE = "application/json";
@@ -115,7 +115,7 @@ public class PolicyManagerServlet extends HttpServlet {
private static Path closedLoopJsonLocation;
private static JsonArray policyNames;
- private String testUserId = null;
+ private static String testUserId = null;
public static JsonArray getPolicyNames() {
return policyNames;
@@ -126,7 +126,6 @@ public class PolicyManagerServlet extends HttpServlet {
}
private static List<String> serviceTypeNamesList = new ArrayList<>();
- private List<Object> policyData;
public static List<String> getServiceTypeNamesList() {
return serviceTypeNamesList;
@@ -192,7 +191,11 @@ public class PolicyManagerServlet extends HttpServlet {
fileOperation(request, response);
}
} catch (Exception e) {
- setError(e, response);
+ try {
+ setError(e, response);
+ }catch(Exception e1){
+ LOGGER.error("Exception Occured"+e1);
+ }
}
}
@@ -270,6 +273,7 @@ public class PolicyManagerServlet extends HttpServlet {
Mode mode = Mode.valueOf(params.getString("mode"));
switch (mode) {
case ADDFOLDER:
+ case ADDSUBSCOPE:
responseJsonObject = addFolder(params, request);
break;
case COPY:
@@ -278,12 +282,10 @@ public class PolicyManagerServlet extends HttpServlet {
case DELETE:
responseJsonObject = delete(params, request);
break;
- case EDITFILE:
+ case EDITFILE:
+ case VIEWPOLICY:
responseJsonObject = editFile(params);
break;
- case VIEWPOLICY:
- responseJsonObject = editFile(params);
- break;
case LIST:
responseJsonObject = list(params, request);
break;
@@ -293,9 +295,6 @@ public class PolicyManagerServlet extends HttpServlet {
case DESCRIBEPOLICYFILE:
responseJsonObject = describePolicy(params);
break;
- case ADDSUBSCOPE:
- responseJsonObject = addFolder(params, request);
- break;
case SWITCHVERSION:
responseJsonObject = switchVersion(params, request);
break;
@@ -321,7 +320,7 @@ public class PolicyManagerServlet extends HttpServlet {
private JSONObject searchPolicyList(JSONObject params, HttpServletRequest request) {
Set<String> scopes = null;
List<String> roles = null;
- policyData = new ArrayList<>();
+ List<Object> policyData = new ArrayList<>();
JSONArray policyList = null;
if(params.has("policyList")){
policyList = (JSONArray) params.get("policyList");
@@ -1230,7 +1229,7 @@ public class PolicyManagerServlet extends HttpServlet {
policyEntity = (PolicyEntity) object;
String policyEntityName = policyEntity.getPolicyName().replace(".xml", "");
int policyEntityVersion = Integer.parseInt(policyEntityName.substring(policyEntityName.lastIndexOf(".")+1));
- if(policyEntityVersion > highestVersion){
+ if(policyEntityVersion > highestVersion && policyEntityVersion != version){
highestVersion = policyEntityVersion;
}
}
@@ -1472,7 +1471,7 @@ public class PolicyManagerServlet extends HttpServlet {
return testUserId;
}
- public void setTestUserId(String testUserId) {
- this.testUserId = testUserId;
+ public static void setTestUserId(String testUserId) {
+ PolicyManagerServlet.testUserId = testUserId;
}
} \ No newline at end of file
diff --git a/POLICY-SDK-APP/src/main/java/org/openecomp/policy/admin/PolicyNotificationMail.java b/POLICY-SDK-APP/src/main/java/org/openecomp/policy/admin/PolicyNotificationMail.java
index 9bd6e4f43..1a535dc76 100644
--- a/POLICY-SDK-APP/src/main/java/org/openecomp/policy/admin/PolicyNotificationMail.java
+++ b/POLICY-SDK-APP/src/main/java/org/openecomp/policy/admin/PolicyNotificationMail.java
@@ -106,7 +106,7 @@ public class PolicyNotificationMail{
+ '\n' + '\n' + "Moved By : " +entityItem.getModifiedBy() + '\n' + "Moved Time : " +dateFormat.format(date) + '\n' + '\n' + '\n' + '\n' + "Policy Notification System (please don't respond to this email)";
}
String policyFileName = entityItem.getPolicyName();
- String checkPolicyName = policyFileName;
+ String checkPolicyName = policyName;
if(policyFileName.contains("/")){
policyFileName = policyFileName.substring(0, policyFileName.indexOf("/"));
policyFileName = policyFileName.replace("/", File.separator);
@@ -119,40 +119,41 @@ public class PolicyNotificationMail{
String query = "from WatchPolicyNotificationTable where policyName like'" +policyFileName+"%'";
boolean sendFlag = false;
List<Object> watchList = policyNotificationDao.getDataByQuery(query);
- if(watchList != null){
- if(watchList.isEmpty()){
- for(Object watch : watchList){
- WatchPolicyNotificationTable list = (WatchPolicyNotificationTable) watch;
- String watchPolicyName = list.getPolicyName();
- if(watchPolicyName.contains("Config_") || watchPolicyName.contains("Action_") || watchPolicyName.contains("Decision_")){
- if(watchPolicyName.equals(checkPolicyName)){
- sendFlag = true;
- }else{
- sendFlag = false;
- }
+ if(watchList != null && !watchList.isEmpty()){
+ for(Object watch : watchList){
+ WatchPolicyNotificationTable list = (WatchPolicyNotificationTable) watch;
+ String watchPolicyName = list.getPolicyName();
+ if(watchPolicyName.contains("Config_") || watchPolicyName.contains("Action_") || watchPolicyName.contains("Decision_")){
+ if(watchPolicyName.equals(checkPolicyName)){
+ sendFlag = true;
+ }else{
+ sendFlag = false;
}
- if(sendFlag){
- AnnotationConfigApplicationContext ctx = null;
- try {
- to = list.getLoginIds()+"@"+PolicyController.getSmtpApplicationName();
- to = to.trim();
- ctx = new AnnotationConfigApplicationContext();
- ctx.register(PolicyNotificationMail.class);
- ctx.refresh();
- JavaMailSenderImpl mailSender = ctx.getBean(JavaMailSenderImpl.class);
- MimeMessage mimeMessage = mailSender.createMimeMessage();
- MimeMessageHelper mailMsg = new MimeMessageHelper(mimeMessage);
- mailMsg.setFrom(new InternetAddress(from, "Policy Notification System"));
- mailMsg.setTo(to);
- mailMsg.setSubject(subject);
- mailMsg.setText(message);
- mailSender.send(mimeMessage);
- } catch (Exception e) {
- policyLogger.error(XACMLErrorConstants.ERROR_PROCESS_FLOW+"Exception Occured in Policy Notification" +e);
- }finally{
- if(ctx != null){
- ctx.close();
- }
+ }
+ if(sendFlag){
+ AnnotationConfigApplicationContext ctx = null;
+ try {
+ to = list.getLoginIds()+"@"+PolicyController.getSmtpEmailExtension();
+ to = to.trim();
+ ctx = new AnnotationConfigApplicationContext();
+ ctx.register(PolicyNotificationMail.class);
+ ctx.refresh();
+ JavaMailSenderImpl mailSender = ctx.getBean(JavaMailSenderImpl.class);
+ MimeMessage mimeMessage = mailSender.createMimeMessage();
+ MimeMessageHelper mailMsg = new MimeMessageHelper(mimeMessage);
+ mailMsg.setFrom(new InternetAddress(from, "Policy Notification System"));
+ mailMsg.setTo(to);
+ mailMsg.setSubject(subject);
+ mailMsg.setText(message);
+ mailSender.send(mimeMessage);
+ if(mode.equalsIgnoreCase("Rename") || mode.contains("Delete") || mode.contains("Move")){
+ policyNotificationDao.delete(watch);
+ }
+ } catch (Exception e) {
+ policyLogger.error(XACMLErrorConstants.ERROR_PROCESS_FLOW+"Exception Occured in Policy Notification" +e);
+ }finally{
+ if(ctx != null){
+ ctx.close();
}
}
}
diff --git a/POLICY-SDK-APP/src/main/java/org/openecomp/policy/admin/PolicyRestController.java b/POLICY-SDK-APP/src/main/java/org/openecomp/policy/admin/PolicyRestController.java
index 2c04bc66d..08ef99f94 100644
--- a/POLICY-SDK-APP/src/main/java/org/openecomp/policy/admin/PolicyRestController.java
+++ b/POLICY-SDK-APP/src/main/java/org/openecomp/policy/admin/PolicyRestController.java
@@ -86,90 +86,90 @@ public class PolicyRestController extends RestrictedBaseController{
CommonClassDao commonClassDao;
@RequestMapping(value={"/policycreation/save_policy"}, method={RequestMethod.POST})
- public ModelAndView policyCreationController(HttpServletRequest request, HttpServletResponse response) throws Exception{
-
+ public void policyCreationController(HttpServletRequest request, HttpServletResponse response) {
String userId = UserUtils.getUserSession(request).getOrgUserId();
ObjectMapper mapper = new ObjectMapper();
mapper.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false);
- JsonNode root = mapper.readTree(request.getReader());
-
- PolicyRestAdapter policyData = mapper.readValue(root.get(PolicyController.getPolicydata()).get("policy").toString(), PolicyRestAdapter.class);
-
- if("file".equals(root.get(PolicyController.getPolicydata()).get(modal).get("type").toString().replace("\"", ""))){
- policyData.setEditPolicy(true);
- }
- if(root.get(PolicyController.getPolicydata()).get(modal).get("path").size() != 0){
- String dirName = "";
- for(int i = 0; i < root.get(PolicyController.getPolicydata()).get(modal).get("path").size(); i++){
- dirName = dirName.replace("\"", "") + root.get(PolicyController.getPolicydata()).get(modal).get("path").get(i).toString().replace("\"", "") + File.separator;
+ try{
+ JsonNode root = mapper.readTree(request.getReader());
+
+ PolicyRestAdapter policyData = mapper.readValue(root.get(PolicyController.getPolicydata()).get("policy").toString(), PolicyRestAdapter.class);
+
+ if("file".equals(root.get(PolicyController.getPolicydata()).get(modal).get("type").toString().replace("\"", ""))){
+ policyData.setEditPolicy(true);
}
- if(policyData.isEditPolicy()){
- policyData.setDomainDir(dirName.substring(0, dirName.lastIndexOf(File.separator)));
+ if(root.get(PolicyController.getPolicydata()).get(modal).get("path").size() != 0){
+ String dirName = "";
+ for(int i = 0; i < root.get(PolicyController.getPolicydata()).get(modal).get("path").size(); i++){
+ dirName = dirName.replace("\"", "") + root.get(PolicyController.getPolicydata()).get(modal).get("path").get(i).toString().replace("\"", "") + File.separator;
+ }
+ if(policyData.isEditPolicy()){
+ policyData.setDomainDir(dirName.substring(0, dirName.lastIndexOf(File.separator)));
+ }else{
+ policyData.setDomainDir(dirName + root.get(PolicyController.getPolicydata()).get(modal).get("name").toString().replace("\"", ""));
+ }
}else{
- policyData.setDomainDir(dirName + root.get(PolicyController.getPolicydata()).get(modal).get("name").toString().replace("\"", ""));
- }
- }else{
- String domain = root.get(PolicyController.getPolicydata()).get("model").get("name").toString();
- if(domain.contains("/")){
- domain = domain.substring(0, domain.lastIndexOf('/')).replace("/", File.separator);
+ String domain = root.get(PolicyController.getPolicydata()).get("model").get("name").toString();
+ if(domain.contains("/")){
+ domain = domain.substring(0, domain.lastIndexOf('/')).replace("/", File.separator);
+ }
+ domain = domain.replace("\"", "");
+ policyData.setDomainDir(domain);
}
- domain = domain.replace("\"", "");
- policyData.setDomainDir(domain);
- }
-
- if(policyData.getConfigPolicyType() != null){
- if("ClosedLoop_Fault".equalsIgnoreCase(policyData.getConfigPolicyType())){
- CreateClosedLoopFaultController faultController = new CreateClosedLoopFaultController();
- policyData = faultController.setDataToPolicyRestAdapter(policyData, root);
- }else if("Firewall Config".equalsIgnoreCase(policyData.getConfigPolicyType())){
- CreateFirewallController fwController = new CreateFirewallController();
- policyData = fwController.setDataToPolicyRestAdapter(policyData);
- }else if("Micro Service".equalsIgnoreCase(policyData.getConfigPolicyType())){
- CreateDcaeMicroServiceController msController = new CreateDcaeMicroServiceController();
- policyData = msController.setDataToPolicyRestAdapter(policyData, root);
+
+ if(policyData.getConfigPolicyType() != null){
+ if("ClosedLoop_Fault".equalsIgnoreCase(policyData.getConfigPolicyType())){
+ CreateClosedLoopFaultController faultController = new CreateClosedLoopFaultController();
+ policyData = faultController.setDataToPolicyRestAdapter(policyData, root);
+ }else if("Firewall Config".equalsIgnoreCase(policyData.getConfigPolicyType())){
+ CreateFirewallController fwController = new CreateFirewallController();
+ policyData = fwController.setDataToPolicyRestAdapter(policyData);
+ }else if("Micro Service".equalsIgnoreCase(policyData.getConfigPolicyType())){
+ CreateDcaeMicroServiceController msController = new CreateDcaeMicroServiceController();
+ policyData = msController.setDataToPolicyRestAdapter(policyData, root);
+ }
}
- }
-
- policyData.setUserId(userId);
-
- String result;
- String body = PolicyUtils.objectToJsonString(policyData);
- String uri = request.getRequestURI();
- ResponseEntity<?> responseEntity = sendToPAP(body, uri, HttpMethod.POST);
- if(responseEntity != null && responseEntity.getBody().equals(HttpServletResponse.SC_CONFLICT)){
- result = "PolicyExists";
- }else if(responseEntity != null){
- result = responseEntity.getBody().toString();
- String policyName = responseEntity.getHeaders().get("policyName").get(0);
- if(policyData.isEditPolicy() && "success".equalsIgnoreCase(result)){
- PolicyNotificationMail email = new PolicyNotificationMail();
- String mode = "EditPolicy";
- String watchPolicyName = policyName.replace(".xml", "");
- String version = watchPolicyName.substring(watchPolicyName.lastIndexOf('.')+1);
- watchPolicyName = watchPolicyName.substring(0, watchPolicyName.lastIndexOf('.')).replace(".", File.separator);
- String policyVersionName = watchPolicyName.replace(".", File.separator);
- watchPolicyName = watchPolicyName + "." + version + ".xml";
- PolicyVersion entityItem = new PolicyVersion();
- entityItem.setPolicyName(policyVersionName);
- entityItem.setActiveVersion(Integer.parseInt(version));
- entityItem.setModifiedBy(userId);
- email.sendMail(entityItem, watchPolicyName, mode, commonClassDao);
+
+ policyData.setUserId(userId);
+
+ String result;
+ String body = PolicyUtils.objectToJsonString(policyData);
+ String uri = request.getRequestURI();
+ ResponseEntity<?> responseEntity = sendToPAP(body, uri, HttpMethod.POST);
+ if(responseEntity != null && responseEntity.getBody().equals(HttpServletResponse.SC_CONFLICT)){
+ result = "PolicyExists";
+ }else if(responseEntity != null){
+ result = responseEntity.getBody().toString();
+ String policyName = responseEntity.getHeaders().get("policyName").get(0);
+ if(policyData.isEditPolicy() && "success".equalsIgnoreCase(result)){
+ PolicyNotificationMail email = new PolicyNotificationMail();
+ String mode = "EditPolicy";
+ String watchPolicyName = policyName.replace(".xml", "");
+ String version = watchPolicyName.substring(watchPolicyName.lastIndexOf('.')+1);
+ watchPolicyName = watchPolicyName.substring(0, watchPolicyName.lastIndexOf('.')).replace(".", File.separator);
+ String policyVersionName = watchPolicyName.replace(".", File.separator);
+ watchPolicyName = watchPolicyName + "." + version + ".xml";
+ PolicyVersion entityItem = new PolicyVersion();
+ entityItem.setPolicyName(policyVersionName);
+ entityItem.setActiveVersion(Integer.parseInt(version));
+ entityItem.setModifiedBy(userId);
+ email.sendMail(entityItem, watchPolicyName, mode, commonClassDao);
+ }
+ }else{
+ result = "Response is null from PAP";
}
- }else{
- result = "Response is null from PAP";
- }
-
-
- response.setCharacterEncoding(PolicyController.getCharacterencoding());
- response.setContentType(PolicyController.getContenttype());
- request.setCharacterEncoding(PolicyController.getCharacterencoding());
- PrintWriter out = response.getWriter();
- String responseString = mapper.writeValueAsString(result);
- JSONObject j = new JSONObject("{policyData: " + responseString + "}");
- out.write(j.toString());
- return null;
+ response.setCharacterEncoding(PolicyController.getCharacterencoding());
+ response.setContentType(PolicyController.getContenttype());
+ request.setCharacterEncoding(PolicyController.getCharacterencoding());
+ PrintWriter out = response.getWriter();
+ String responseString = mapper.writeValueAsString(result);
+ JSONObject j = new JSONObject("{policyData: " + responseString + "}");
+ out.write(j.toString());
+ }catch(Exception e){
+ policyLogger.error("Exception Occured while saving policy" , e);
+ }
}
@@ -344,7 +344,7 @@ public class PolicyRestController extends RestrictedBaseController{
}
@RequestMapping(value={"/getDictionary/*"}, method={RequestMethod.GET})
- public void getDictionaryController(HttpServletRequest request, HttpServletResponse response) throws Exception{
+ public void getDictionaryController(HttpServletRequest request, HttpServletResponse response){
String uri = request.getRequestURI().replace("/getDictionary", "");
String body = null;
ResponseEntity<?> responseEntity = sendToPAP(null, uri, HttpMethod.GET);
@@ -353,7 +353,11 @@ public class PolicyRestController extends RestrictedBaseController{
}else{
body = "";
}
- response.getWriter().write(body);
+ try {
+ response.getWriter().write(body);
+ } catch (IOException e) {
+ policyLogger.error("Exception occured while getting Dictionary entries", e);
+ }
}
@RequestMapping(value={"/saveDictionary/*/*"}, method={RequestMethod.POST})
diff --git a/POLICY-SDK-APP/src/main/java/org/openecomp/policy/controller/ActionPolicyController.java b/POLICY-SDK-APP/src/main/java/org/openecomp/policy/controller/ActionPolicyController.java
index 2c68df65f..c88412b8b 100644
--- a/POLICY-SDK-APP/src/main/java/org/openecomp/policy/controller/ActionPolicyController.java
+++ b/POLICY-SDK-APP/src/main/java/org/openecomp/policy/controller/ActionPolicyController.java
@@ -58,7 +58,9 @@ import org.openecomp.policy.common.logging.flexlogger.Logger;
public class ActionPolicyController extends RestrictedBaseController{
private static final Logger LOGGER = FlexLogger.getLogger(ActionPolicyController.class);
- public ActionPolicyController(){}
+ public ActionPolicyController(){
+ //Default Constructor
+ }
private ArrayList<Object> attributeList;
protected LinkedList<Integer> ruleAlgoirthmTracker;
diff --git a/POLICY-SDK-APP/src/main/java/org/openecomp/policy/controller/CreateBRMSParamController.java b/POLICY-SDK-APP/src/main/java/org/openecomp/policy/controller/CreateBRMSParamController.java
index 8258b8bed..4f4838dc7 100644
--- a/POLICY-SDK-APP/src/main/java/org/openecomp/policy/controller/CreateBRMSParamController.java
+++ b/POLICY-SDK-APP/src/main/java/org/openecomp/policy/controller/CreateBRMSParamController.java
@@ -42,17 +42,19 @@ import javax.servlet.http.HttpServletResponse;
import javax.xml.bind.JAXBElement;
import org.json.JSONObject;
+import org.openecomp.policy.common.logging.flexlogger.FlexLogger;
+import org.openecomp.policy.common.logging.flexlogger.Logger;
import org.openecomp.policy.rest.adapter.PolicyRestAdapter;
import org.openecomp.policy.rest.dao.CommonClassDao;
import org.openecomp.policy.rest.jpa.BRMSParamTemplate;
import org.openecomp.policy.rest.jpa.PolicyEntity;
+import org.openecomp.policy.xacml.api.XACMLErrorConstants;
import org.openecomp.portalsdk.core.controller.RestrictedBaseController;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.servlet.ModelAndView;
-import org.openecomp.policy.xacml.api.XACMLErrorConstants;
import com.fasterxml.jackson.databind.DeserializationFeature;
import com.fasterxml.jackson.databind.JsonNode;
import com.fasterxml.jackson.databind.ObjectMapper;
@@ -69,9 +71,6 @@ import oasis.names.tc.xacml._3_0.core.schema.wd_17.PolicyType;
import oasis.names.tc.xacml._3_0.core.schema.wd_17.RuleType;
import oasis.names.tc.xacml._3_0.core.schema.wd_17.TargetType;
-import org.openecomp.policy.common.logging.flexlogger.FlexLogger;
-import org.openecomp.policy.common.logging.flexlogger.Logger;
-
@Controller
@RequestMapping("/")
public class CreateBRMSParamController extends RestrictedBaseController {
@@ -79,6 +78,14 @@ public class CreateBRMSParamController extends RestrictedBaseController {
private static CommonClassDao commonClassDao;
+ public static CommonClassDao getCommonClassDao() {
+ return commonClassDao;
+ }
+
+ public static void setCommonClassDao(CommonClassDao commonClassDao) {
+ CreateBRMSParamController.commonClassDao = commonClassDao;
+ }
+
@Autowired
private CreateBRMSParamController(CommonClassDao commonClassDao){
CreateBRMSParamController.commonClassDao = commonClassDao;
@@ -90,35 +97,36 @@ public class CreateBRMSParamController extends RestrictedBaseController {
private HashMap<String, String> dynamicLayoutMap;
private static String brmsTemplateVlaue = "<$%BRMSParamTemplate=";
- private static String String = "String";
+ private static String string = "String";
@RequestMapping(value={"/policyController/getBRMSTemplateData.htm"}, method={org.springframework.web.bind.annotation.RequestMethod.POST})
- public ModelAndView getBRMSParamPolicyRuleData(HttpServletRequest request, HttpServletResponse response) throws Exception{
- dynamicLayoutMap = new HashMap<>();
- ObjectMapper mapper = new ObjectMapper();
- mapper.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false);
- JsonNode root = mapper.readTree(request.getReader());
- String rule = findRule(root.get(PolicyController.getPolicydata()).toString().replaceAll("^\"|\"$", ""));
- generateUI(rule);
- response.setCharacterEncoding(PolicyController.getCharacterencoding());
- response.setContentType(PolicyController.getContenttype());
- request.setCharacterEncoding(PolicyController.getCharacterencoding());
+ public void getBRMSParamPolicyRuleData(HttpServletRequest request, HttpServletResponse response){
+ try{
+ dynamicLayoutMap = new HashMap<>();
+ ObjectMapper mapper = new ObjectMapper();
+ mapper.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false);
+ JsonNode root = mapper.readTree(request.getReader());
+ String rule = findRule(root.get(PolicyController.getPolicydata()).toString().replaceAll("^\"|\"$", ""));
+ generateUI(rule);
+ response.setCharacterEncoding(PolicyController.getCharacterencoding());
+ response.setContentType(PolicyController.getContenttype());
+ request.setCharacterEncoding(PolicyController.getCharacterencoding());
- PrintWriter out = response.getWriter();
- String responseString = mapper.writeValueAsString(dynamicLayoutMap);
- JSONObject j = new JSONObject("{policyData: " + responseString + "}");
- out.write(j.toString());
- return null;
+ PrintWriter out = response.getWriter();
+ String responseString = mapper.writeValueAsString(dynamicLayoutMap);
+ JSONObject j = new JSONObject("{policyData: " + responseString + "}");
+ out.write(j.toString());
+ }catch(Exception e){
+ policyLogger.error("Exception Occured while getting BRMS Rule data" , e);
+ }
}
protected String findRule(String ruleTemplate) {
- List<Object> datas = commonClassDao.getData(BRMSParamTemplate.class);
- for (Object data: datas){
- BRMSParamTemplate bRMSParamTemplate = (BRMSParamTemplate) data;
- if(bRMSParamTemplate.getRuleName().equals(ruleTemplate)){
- return bRMSParamTemplate.getRule();
- }
+ List<Object> datas = commonClassDao.getDataById(BRMSParamTemplate.class, "ruleName", ruleTemplate);
+ if(datas != null && !datas.isEmpty()){
+ BRMSParamTemplate bRMSParamTemplate = (BRMSParamTemplate) datas.get(0);
+ return bRMSParamTemplate.getRule();
}
return null;
}
@@ -197,10 +205,10 @@ public class CreateBRMSParamController extends RestrictedBaseController {
policyLogger.info("Just for Logging"+e);
nextComponent = components[i];
}
- if (nextComponent.startsWith(String)) {
+ if (nextComponent.startsWith(string)) {
type = "String";
createField(caption, type);
- caption = nextComponent.replace(String, "");
+ caption = nextComponent.replace(string, "");
} else if (nextComponent.startsWith("int")) {
type = "int";
createField(caption, type);
@@ -357,7 +365,7 @@ public class CreateBRMSParamController extends RestrictedBaseController {
return formateDate;
}
// This method generates the UI from rule configuration
- private void paramUIGenerate(PolicyRestAdapter policyAdapter, PolicyEntity entity) {
+ public void paramUIGenerate(PolicyRestAdapter policyAdapter, PolicyEntity entity) {
String data = entity.getConfigurationData().getConfigBody();
if(data != null){
File file = new File(PolicyController.getConfigHome() +File.separator+ entity.getConfigurationData().getConfigurationName());
@@ -471,7 +479,7 @@ public class CreateBRMSParamController extends RestrictedBaseController {
// set View Rule
@SuppressWarnings("unchecked")
@RequestMapping(value={"/policyController/ViewBRMSParamPolicyRule.htm"}, method={org.springframework.web.bind.annotation.RequestMethod.POST})
- public ModelAndView setViewRule(HttpServletRequest request, HttpServletResponse response) throws Exception{
+ public void setViewRule(HttpServletRequest request, HttpServletResponse response){
try {
ObjectMapper mapper = new ObjectMapper();
mapper.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false);
@@ -493,7 +501,7 @@ public class CreateBRMSParamController extends RestrictedBaseController {
if(policyData.getRuleData().size() > 0){
for(Object keyValue: policyData.getRuleData().keySet()){
String key = keyValue.toString().substring(0, 1).toUpperCase() + keyValue.toString().substring(1);
- if (String.equals(keyValue)) {
+ if (string.equals(keyValue)) {
generatedRule.append("\n\t\tparams.set"
+ key + "(\""
+ policyData.getRuleData().get(keyValue).toString() + "\");");
@@ -537,10 +545,8 @@ public class CreateBRMSParamController extends RestrictedBaseController {
String responseString = mapper.writeValueAsString(body);
JSONObject j = new JSONObject("{policyData: " + responseString + "}");
out.write(j.toString());
- return null;
} catch (Exception e) {
policyLogger.error(XACMLErrorConstants.ERROR_PROCESS_FLOW + e);
- }
- return null;
+ }
}
}
diff --git a/POLICY-SDK-APP/src/main/java/org/openecomp/policy/controller/CreateBRMSRawController.java b/POLICY-SDK-APP/src/main/java/org/openecomp/policy/controller/CreateBRMSRawController.java
index 67945e1b9..c5b97ad45 100644
--- a/POLICY-SDK-APP/src/main/java/org/openecomp/policy/controller/CreateBRMSRawController.java
+++ b/POLICY-SDK-APP/src/main/java/org/openecomp/policy/controller/CreateBRMSRawController.java
@@ -72,6 +72,7 @@ public class CreateBRMSRawController{
try{
description = policy.getDescription().substring(0, policy.getDescription().indexOf("@CreatedBy:"));
}catch(Exception e){
+ logger.info("Not able to see the createdby in description. So, add generic description", e);
description = policy.getDescription();
}
policyAdapter.setPolicyDescription(description);
diff --git a/POLICY-SDK-APP/src/main/java/org/openecomp/policy/controller/CreateClosedLoopFaultController.java b/POLICY-SDK-APP/src/main/java/org/openecomp/policy/controller/CreateClosedLoopFaultController.java
index ccecf5d7f..08c0c38e7 100644
--- a/POLICY-SDK-APP/src/main/java/org/openecomp/policy/controller/CreateClosedLoopFaultController.java
+++ b/POLICY-SDK-APP/src/main/java/org/openecomp/policy/controller/CreateClosedLoopFaultController.java
@@ -61,7 +61,7 @@ import oasis.names.tc.xacml._3_0.core.schema.wd_17.TargetType;
@RequestMapping("/")
public class CreateClosedLoopFaultController extends RestrictedBaseController{
- private static final Logger LOGGER = FlexLogger.getLogger(CreateClosedLoopFaultController.class);
+ private static final Logger policyLogger = FlexLogger.getLogger(CreateClosedLoopFaultController.class);
protected PolicyRestAdapter policyAdapter = null;
@@ -75,86 +75,91 @@ public class CreateClosedLoopFaultController extends RestrictedBaseController{
public CreateClosedLoopFaultController(){}
- public PolicyRestAdapter setDataToPolicyRestAdapter(PolicyRestAdapter policyData, JsonNode root) throws Exception{
- ObjectMapper mapper = new ObjectMapper();
- mapper.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false);
- TrapDatas trapDatas = mapper.readValue(root.get("trapData").toString(), TrapDatas.class);
- TrapDatas faultDatas = mapper.readValue(root.get("faultData").toString(), TrapDatas.class);
- ClosedLoopGridJSONData policyJsonData = mapper.readValue(root.get("policyData").get("policy").toString(), ClosedLoopGridJSONData.class);
- ClosedLoopFaultBody jsonBody = mapper.readValue(root.get("policyData").get("policy").get("jsonBodyData").toString(), ClosedLoopFaultBody.class);
-
- ArrayList<Object> trapSignatureDatas = new ArrayList<>();
- if(trapDatas.getTrap1() != null){
- trapSignatureDatas.add(trapDatas);
- }
- ArrayList<Object> faultSignatureDatas = new ArrayList<>();
- if(faultDatas.getTrap1() != null){
- faultSignatureDatas.add(faultDatas);
- }
-
- String resultBody = "";
- if(!policyJsonData.getConnecttriggerSignatures().isEmpty()){
- resultBody = resultBody + "(";
- for(int i = policyJsonData.getConnecttriggerSignatures().size()-1; i>=0 ; i--){
- String connectBody = connectTriggerSignature(i, policyJsonData.getConnecttriggerSignatures(), trapSignatureDatas.get(0));
- resultBody = resultBody + connectBody;
+ public PolicyRestAdapter setDataToPolicyRestAdapter(PolicyRestAdapter policyData, JsonNode root){
+ try{
+ ObjectMapper mapper = new ObjectMapper();
+ mapper.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false);
+ TrapDatas trapDatas = mapper.readValue(root.get("trapData").toString(), TrapDatas.class);
+ TrapDatas faultDatas = mapper.readValue(root.get("faultData").toString(), TrapDatas.class);
+ ClosedLoopGridJSONData policyJsonData = mapper.readValue(root.get("policyData").get("policy").toString(), ClosedLoopGridJSONData.class);
+ ClosedLoopFaultBody jsonBody = mapper.readValue(root.get("policyData").get("policy").get("jsonBodyData").toString(), ClosedLoopFaultBody.class);
+
+ ArrayList<Object> trapSignatureDatas = new ArrayList<>();
+ if(trapDatas.getTrap1() != null){
+ trapSignatureDatas.add(trapDatas);
}
- resultBody = resultBody + ")";
- }else{
- if(!trapSignatureDatas.isEmpty()){
- resultBody = callTrap("nill", trapSignatureDatas.get(0));
+ ArrayList<Object> faultSignatureDatas = new ArrayList<>();
+ if(faultDatas.getTrap1() != null){
+ faultSignatureDatas.add(faultDatas);
}
- }
- ClosedLoopSignatures triggerSignatures = new ClosedLoopSignatures();
- triggerSignatures.setSignatures(resultBody);
- if(policyData.getClearTimeOut() != null){
- triggerSignatures.setTimeWindow(Integer.parseInt(policyData.getClearTimeOut()));
- triggerSignatures.setTrapMaxAge(Integer.parseInt(policyData.getTrapMaxAge()));
- ClosedLoopFaultTriggerUISignatures uiTriggerSignatures = new ClosedLoopFaultTriggerUISignatures();
- if(!trapSignatureDatas.isEmpty()){
- uiTriggerSignatures.setSignatures(getUITriggerSignature("Trap", trapSignatureDatas.get(0)));
- if(!policyJsonData.getConnecttriggerSignatures().isEmpty()){
- uiTriggerSignatures.setConnectSignatures(getUIConnectTraps(policyJsonData.getConnecttriggerSignatures()));
- }
- }
- jsonBody.setTriggerSignaturesUsedForUI(uiTriggerSignatures);
- jsonBody.setTriggerTimeWindowUsedForUI(Integer.parseInt(policyData.getClearTimeOut()));
- jsonBody.setTrapMaxAgeUsedForUI(Integer.parseInt(policyData.getTrapMaxAge()));
- }
-
- jsonBody.setTriggerSignatures(triggerSignatures);
- String faultBody = "";
- if(!policyJsonData.getConnectVerificationSignatures().isEmpty()){
- faultBody = faultBody + "(";
- for(int i = policyJsonData.getConnectVerificationSignatures().size()-1; i>=0 ; i--){
- String connectBody = connectTriggerSignature(i, policyJsonData.getConnectVerificationSignatures(), faultSignatureDatas.get(0));
- faultBody = faultBody + connectBody;
+
+ String resultBody = "";
+ if(!policyJsonData.getConnecttriggerSignatures().isEmpty()){
+ resultBody = resultBody + "(";
+ for(int i = policyJsonData.getConnecttriggerSignatures().size()-1; i>=0 ; i--){
+ String connectBody = connectTriggerSignature(i, policyJsonData.getConnecttriggerSignatures(), trapSignatureDatas.get(0));
+ resultBody = resultBody + connectBody;
+ }
+ resultBody = resultBody + ")";
+ }else{
+ if(!trapSignatureDatas.isEmpty()){
+ resultBody = callTrap("nill", trapSignatureDatas.get(0));
+ }
}
- faultBody = faultBody + ")";
- }else{
- if(!faultSignatureDatas.isEmpty()){
- faultBody = callTrap("nill", faultSignatureDatas.get(0));
+ ClosedLoopSignatures triggerSignatures = new ClosedLoopSignatures();
+ triggerSignatures.setSignatures(resultBody);
+ if(policyData.getClearTimeOut() != null){
+ triggerSignatures.setTimeWindow(Integer.parseInt(policyData.getClearTimeOut()));
+ triggerSignatures.setTrapMaxAge(Integer.parseInt(policyData.getTrapMaxAge()));
+ ClosedLoopFaultTriggerUISignatures uiTriggerSignatures = new ClosedLoopFaultTriggerUISignatures();
+ if(!trapSignatureDatas.isEmpty()){
+ uiTriggerSignatures.setSignatures(getUITriggerSignature("Trap", trapSignatureDatas.get(0)));
+ if(!policyJsonData.getConnecttriggerSignatures().isEmpty()){
+ uiTriggerSignatures.setConnectSignatures(getUIConnectTraps(policyJsonData.getConnecttriggerSignatures()));
+ }
+ }
+ jsonBody.setTriggerSignaturesUsedForUI(uiTriggerSignatures);
+ jsonBody.setTriggerTimeWindowUsedForUI(Integer.parseInt(policyData.getClearTimeOut()));
+ jsonBody.setTrapMaxAgeUsedForUI(Integer.parseInt(policyData.getTrapMaxAge()));
}
- }
- ClosedLoopSignatures faultSignatures = new ClosedLoopSignatures();
- faultSignatures.setSignatures(faultBody);
- if(policyData.getVerificationclearTimeOut() != null){
- faultSignatures.setTimeWindow(Integer.parseInt(policyData.getVerificationclearTimeOut()));
- ClosedLoopFaultTriggerUISignatures uifaultSignatures = new ClosedLoopFaultTriggerUISignatures();
- if(!faultSignatureDatas.isEmpty()){
- uifaultSignatures.setSignatures(getUITriggerSignature("Fault", faultSignatureDatas.get(0)));
- if(!policyJsonData.getConnectVerificationSignatures().isEmpty()){
- uifaultSignatures.setConnectSignatures(getUIConnectTraps(policyJsonData.getConnectVerificationSignatures()));
- }
+
+ jsonBody.setTriggerSignatures(triggerSignatures);
+ String faultBody = "";
+ if(!policyJsonData.getConnectVerificationSignatures().isEmpty()){
+ faultBody = faultBody + "(";
+ for(int i = policyJsonData.getConnectVerificationSignatures().size()-1; i>=0 ; i--){
+ String connectBody = connectTriggerSignature(i, policyJsonData.getConnectVerificationSignatures(), faultSignatureDatas.get(0));
+ faultBody = faultBody + connectBody;
+ }
+ faultBody = faultBody + ")";
+ }else{
+ if(!faultSignatureDatas.isEmpty()){
+ faultBody = callTrap("nill", faultSignatureDatas.get(0));
+ }
}
-
- jsonBody.setVerificationSignaturesUsedForUI(uifaultSignatures);
- jsonBody.setVerfificationTimeWindowUsedForUI(Integer.parseInt(policyData.getVerificationclearTimeOut()));
- }
- jsonBody.setVerificationSignatures(faultSignatures);
- ObjectWriter om = new ObjectMapper().writer();
- String json = om.writeValueAsString(jsonBody);
- policyData.setJsonBody(json);
+ ClosedLoopSignatures faultSignatures = new ClosedLoopSignatures();
+ faultSignatures.setSignatures(faultBody);
+ if(policyData.getVerificationclearTimeOut() != null){
+ faultSignatures.setTimeWindow(Integer.parseInt(policyData.getVerificationclearTimeOut()));
+ ClosedLoopFaultTriggerUISignatures uifaultSignatures = new ClosedLoopFaultTriggerUISignatures();
+ if(!faultSignatureDatas.isEmpty()){
+ uifaultSignatures.setSignatures(getUITriggerSignature("Fault", faultSignatureDatas.get(0)));
+ if(!policyJsonData.getConnectVerificationSignatures().isEmpty()){
+ uifaultSignatures.setConnectSignatures(getUIConnectTraps(policyJsonData.getConnectVerificationSignatures()));
+ }
+ }
+
+ jsonBody.setVerificationSignaturesUsedForUI(uifaultSignatures);
+ jsonBody.setVerfificationTimeWindowUsedForUI(Integer.parseInt(policyData.getVerificationclearTimeOut()));
+ }
+ jsonBody.setVerificationSignatures(faultSignatures);
+ ObjectWriter om = new ObjectMapper().writer();
+ String json = om.writeValueAsString(jsonBody);
+ policyData.setJsonBody(json);
+
+ }catch(Exception e){
+ policyLogger.error("Exception Occured while setting data to Adapter" , e);
+ }
return policyData;
}
@@ -170,6 +175,7 @@ public class CreateClosedLoopFaultController extends RestrictedBaseController{
}
resultBody = resultBody + "(" + notBox;
}catch(NullPointerException e){
+ policyLogger.info("General error" , e);
resultBody = resultBody + "(";
}
String connectTrap1 = connectTraps.get("connectTrap1");
@@ -194,11 +200,13 @@ public class CreateClosedLoopFaultController extends RestrictedBaseController{
String trapCount1 = connectTraps.get("trapCount1");
resultBody = resultBody + ", Time = " + trapCount1 + ")";
}catch(NullPointerException e){
+ policyLogger.info("General error" , e);
}
try{
String operatorBox = connectTraps.get("operatorBox");
resultBody = resultBody + operatorBox +"(";
}catch (NullPointerException e){
+ policyLogger.info("General error" , e);
}
try{
String connectTrap2 = connectTraps.get("connectTrap2");
@@ -220,11 +228,13 @@ public class CreateClosedLoopFaultController extends RestrictedBaseController{
}
}
}catch(NullPointerException e){
+ policyLogger.info("General error" , e);
}
try{
String trapCount2 = connectTraps.get("trapCount2");
resultBody = resultBody + ", Time = " + trapCount2 + ")";
}catch(NullPointerException e){
+ policyLogger.info("General error" , e);
}
return resultBody;
}
@@ -603,7 +613,7 @@ public class CreateClosedLoopFaultController extends RestrictedBaseController{
}
} catch (Exception e) {
- LOGGER.error("Exception Occured"+e);
+ policyLogger.error("Exception Occured"+e);
}
return null;
diff --git a/POLICY-SDK-APP/src/main/java/org/openecomp/policy/controller/CreateClosedLoopPMController.java b/POLICY-SDK-APP/src/main/java/org/openecomp/policy/controller/CreateClosedLoopPMController.java
index 385ca159c..39850d990 100644
--- a/POLICY-SDK-APP/src/main/java/org/openecomp/policy/controller/CreateClosedLoopPMController.java
+++ b/POLICY-SDK-APP/src/main/java/org/openecomp/policy/controller/CreateClosedLoopPMController.java
@@ -63,6 +63,7 @@ public class CreateClosedLoopPMController{
try{
description = policy.getDescription().substring(0, policy.getDescription().indexOf("@CreatedBy:"));
}catch(Exception e){
+ LOGGER.info("General error" , e);
description = policy.getDescription();
}
policyAdapter.setPolicyDescription(description);
diff --git a/POLICY-SDK-APP/src/main/java/org/openecomp/policy/controller/CreateDcaeMicroServiceController.java b/POLICY-SDK-APP/src/main/java/org/openecomp/policy/controller/CreateDcaeMicroServiceController.java
index e156002bf..777fb89e3 100644
--- a/POLICY-SDK-APP/src/main/java/org/openecomp/policy/controller/CreateDcaeMicroServiceController.java
+++ b/POLICY-SDK-APP/src/main/java/org/openecomp/policy/controller/CreateDcaeMicroServiceController.java
@@ -35,6 +35,7 @@ import java.nio.file.Files;
import java.nio.file.Path;
import java.nio.file.Paths;
import java.util.ArrayList;
+import java.util.Arrays;
import java.util.Enumeration;
import java.util.HashMap;
import java.util.HashSet;
@@ -160,7 +161,7 @@ public class CreateDcaeMicroServiceController extends RestrictedBaseController {
jsonContent = decodeContent(root.get("policyJSON")).toString();
constructJson(policyData, jsonContent);
}catch(Exception e){
- LOGGER.error("Error while decoding microservice content");
+ LOGGER.error("Error while decoding microservice content", e);
}
return policyData;
@@ -224,7 +225,7 @@ public class CreateDcaeMicroServiceController extends RestrictedBaseController {
try {
json = om.writeValueAsString(microServiceObject);
} catch (JsonProcessingException e) {
- LOGGER.error("Error writing out the object");
+ LOGGER.error("Error writing out the object", e);
}
LOGGER.info(json);
String cleanJson = cleanUPJson(json);
@@ -254,7 +255,7 @@ public class CreateDcaeMicroServiceController extends RestrictedBaseController {
cleanJson = returnNode.toString();
}
} catch (IOException e) {
- LOGGER.error("Error writing out the JsonNode");
+ LOGGER.error("Error writing out the JsonNode",e);
}
return cleanJson;
}
@@ -311,7 +312,7 @@ public class CreateDcaeMicroServiceController extends RestrictedBaseController {
public Map<String, String> load(byte[] source) throws IOException {
Yaml yaml = new Yaml();
@SuppressWarnings("unchecked")
- Map<Object, Object> yamlMap = (Map<Object, Object>) yaml.load(source.toString());
+ Map<Object, Object> yamlMap = (Map<Object, Object>) yaml.load(Arrays.toString(source));
StringBuilder sb = new StringBuilder();
Map<String, String> settings = new HashMap <>();
if (yamlMap == null) {
@@ -397,10 +398,7 @@ public class CreateDcaeMicroServiceController extends RestrictedBaseController {
HashMap<String,String> dataMapForJson=new HashMap <>();
for(String uniqueDataKey: uniqueDataKeys){
if(uniqueDataKey.contains("%")){
- String[] uniqueDataKeySplit= uniqueDataKey.split("%",2);
- if (uniqueDataKeySplit.length < 2) {
- continue;
- }
+ String[] uniqueDataKeySplit= uniqueDataKey.split("%");
String findType=DATATYPE+uniqueDataKeySplit[0]+PROPERTIES+uniqueDataKeySplit[1]+TYPE;
String typeValue=map.get(findType);
LOGGER.info(typeValue);
@@ -476,10 +474,7 @@ public class CreateDcaeMicroServiceController extends RestrictedBaseController {
HashMap<String,String> hmSub;
for(Map.Entry<String, String> entry: dataMapForJson.entrySet()){
String uniqueDataKey= entry.getKey();
- String[] uniqueDataKeySplit=uniqueDataKey.split("%",2);
- if (uniqueDataKeySplit.length < 2) {
- continue;
- }
+ String[] uniqueDataKeySplit=uniqueDataKey.split("%");
String value= dataMapForJson.get(uniqueDataKey);
if(dataMapKey.containsKey(uniqueDataKeySplit[0])){
hmSub = dataMapKey.get(uniqueDataKeySplit[0]);
@@ -743,10 +738,7 @@ public class CreateDcaeMicroServiceController extends RestrictedBaseController {
if(jsonArray != null && arryKey.equals(nodeKey.substring(0,nodeKey.indexOf("@")))){
jsonArray.put(decodeContent(node));
}
- if(key.contains("@") && !arryKey.equals(key.substring(0,nodeKey.indexOf("@")))){
- jsonResult.put(arryKey, jsonArray);
- jsonArray = new JSONArray();
- }else if(!key.contains("@")){
+ if((key.contains("@") && !arryKey.equals(key.substring(0,nodeKey.indexOf("@")))) || !key.contains("@")){
jsonResult.put(arryKey, jsonArray);
jsonArray = new JSONArray();
}
@@ -1231,18 +1223,13 @@ public class CreateDcaeMicroServiceController extends RestrictedBaseController {
}
}
- private String getPolicyScope(String value) {
- GroupPolicyScopeList pScope = new GroupPolicyScopeList();
- List<Object> groupList= commonClassDao.getData(GroupPolicyScopeList.class);
- if(groupList.size() > 0){
- for(int i = 0 ; i < groupList.size() ; i ++){
- pScope = (GroupPolicyScopeList) groupList.get(i);
- if (pScope.getGroupList().equals(value)){
- break;
- }
- }
+ private String getPolicyScope(String value) {
+ List<Object> groupList= commonClassDao.getDataById(GroupPolicyScopeList.class, "groupList", value);
+ if(groupList != null && !groupList.isEmpty()){
+ GroupPolicyScopeList pScope = (GroupPolicyScopeList) groupList.get(0);
+ return pScope.getGroupName();
}
- return pScope.getGroupName();
+ return null;
}
//Convert the map values and set into JSON body
diff --git a/POLICY-SDK-APP/src/main/java/org/openecomp/policy/controller/CreateFirewallController.java b/POLICY-SDK-APP/src/main/java/org/openecomp/policy/controller/CreateFirewallController.java
index 4aea6370b..2232da608 100644
--- a/POLICY-SDK-APP/src/main/java/org/openecomp/policy/controller/CreateFirewallController.java
+++ b/POLICY-SDK-APP/src/main/java/org/openecomp/policy/controller/CreateFirewallController.java
@@ -19,7 +19,6 @@
*/
package org.openecomp.policy.controller;
-import java.io.IOException;
import java.io.PrintWriter;
import java.util.ArrayList;
import java.util.HashMap;
@@ -67,11 +66,8 @@ import org.openecomp.portalsdk.core.controller.RestrictedBaseController;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
-import org.springframework.web.servlet.ModelAndView;
-import com.fasterxml.jackson.core.JsonGenerationException;
import com.fasterxml.jackson.databind.DeserializationFeature;
-import com.fasterxml.jackson.databind.JsonMappingException;
import com.fasterxml.jackson.databind.JsonNode;
import com.fasterxml.jackson.databind.ObjectMapper;
import com.fasterxml.jackson.databind.ObjectWriter;
@@ -87,7 +83,7 @@ import oasis.names.tc.xacml._3_0.core.schema.wd_17.TargetType;
@Controller
@RequestMapping("/")
public class CreateFirewallController extends RestrictedBaseController {
- private static Logger logger = FlexLogger.getLogger(CreateFirewallController.class);
+ private static Logger policyLogger = FlexLogger.getLogger(CreateFirewallController.class);
@Autowired
SessionFactory sessionFactory;
@@ -110,9 +106,9 @@ public class CreateFirewallController extends RestrictedBaseController {
public PolicyRestAdapter setDataToPolicyRestAdapter(PolicyRestAdapter policyData){
- termCollectorList = new ArrayList<String>();
- tagCollectorList = new ArrayList<String>();
- if(policyData.getAttributes().size() > 0){
+ termCollectorList = new ArrayList<>();
+ tagCollectorList = new ArrayList<>();
+ if(!policyData.getAttributes().isEmpty()){
for(Object attribute : policyData.getAttributes()){
if(attribute instanceof LinkedHashMap<?, ?>){
String key = ((LinkedHashMap<?, ?>) attribute).get("key").toString();
@@ -135,16 +131,14 @@ public class CreateFirewallController extends RestrictedBaseController {
}
private List<String> mapping(String expandableList) {
- String value = new String();
- String desc = new String();
List <String> valueDesc= new ArrayList<>();
List<Object> prefixListData = commonClassDao.getData(PrefixList.class);
for (int i = 0; i< prefixListData.size(); i++) {
PrefixList prefixList = (PrefixList) prefixListData.get(i);
if (prefixList.getPrefixListName().equals(expandableList)) {
- value = prefixList.getPrefixListValue();
+ String value = prefixList.getPrefixListValue();
valueDesc.add(value);
- desc= prefixList.getDescription();
+ String desc= prefixList.getDescription();
valueDesc.add(desc);
break;
}
@@ -198,14 +192,15 @@ public class CreateFirewallController extends RestrictedBaseController {
// policy name value is the policy name without any prefix and Extensions.
policyAdapter.setOldPolicyFileName(policyAdapter.getPolicyName());
String policyNameValue = policyAdapter.getPolicyName().substring(policyAdapter.getPolicyName().indexOf("FW_") +3);
- if (logger.isDebugEnabled()) {
- logger.debug("Prepopulating form data for Config Policy selected:"+ policyAdapter.getPolicyName());
+ if (policyLogger.isDebugEnabled()) {
+ policyLogger.debug("Prepopulating form data for Config Policy selected:"+ policyAdapter.getPolicyName());
}
policyAdapter.setPolicyName(policyNameValue);
String description = "";
try{
description = policy.getDescription().substring(0, policy.getDescription().indexOf("@CreatedBy:"));
}catch(Exception e){
+ policyLogger.info("General error", e);
description = policy.getDescription();
}
policyAdapter.setPolicyDescription(description);
@@ -229,7 +224,7 @@ public class CreateFirewallController extends RestrictedBaseController {
}
}
catch(Exception e) {
- logger.error("Exception Caused while Retriving the JSON body data" +e);
+ policyLogger.error("Exception Caused while Retriving the JSON body data" +e);
}
Map<String, String> termTagMap=null;
@@ -317,14 +312,14 @@ public class CreateFirewallController extends RestrictedBaseController {
}
@RequestMapping(value={"/policyController/ViewFWPolicyRule.htm"}, method={org.springframework.web.bind.annotation.RequestMethod.POST})
- public ModelAndView setFWViewRule(HttpServletRequest request, HttpServletResponse response) throws Exception{
+ public void setFWViewRule(HttpServletRequest request, HttpServletResponse response){
try {
termCollectorList = new ArrayList<>();
ObjectMapper mapper = new ObjectMapper();
mapper.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false);
JsonNode root = mapper.readTree(request.getReader());
PolicyRestAdapter policyData = (PolicyRestAdapter)mapper.readValue(root.get("policyData").toString(), PolicyRestAdapter.class);
- if(policyData.getAttributes().size() > 0){
+ if(!policyData.getAttributes().isEmpty()){
for(Object attribute : policyData.getAttributes()){
if(attribute instanceof LinkedHashMap<?, ?>){
String key = ((LinkedHashMap<?, ?>) attribute).get("key").toString();
@@ -450,7 +445,7 @@ public class CreateFirewallController extends RestrictedBaseController {
}
}
}
- displayString.append("\n");
+ displayString.append("\n");
}
ruleAction=(jpaTermList).getAction();
@@ -469,11 +464,9 @@ public class CreateFirewallController extends RestrictedBaseController {
String responseString = mapper.writeValueAsString(displayString);
JSONObject j = new JSONObject("{policyData: " + responseString + "}");
out.write(j.toString());
- return null;
} catch (Exception e) {
- logger.error(XACMLErrorConstants.ERROR_PROCESS_FLOW + e);
+ policyLogger.error(XACMLErrorConstants.ERROR_PROCESS_FLOW + e);
}
- return null;
}
private String constructJson(PolicyRestAdapter policyData) {
@@ -847,10 +840,10 @@ public class CreateFirewallController extends RestrictedBaseController {
PrefixIPList targetAddressList = new PrefixIPList();
AddressMembers addressMembers= new AddressMembers();
targetAddressList.setName(prefixIP);
- logger.error(XACMLErrorConstants.ERROR_PROCESS_FLOW + "PrefixList value:"+prefixIP);
+ policyLogger.error(XACMLErrorConstants.ERROR_PROCESS_FLOW + "PrefixList value:"+prefixIP);
valueDesc = mapping(prefixIP);
if(!valueDesc.isEmpty()){
- logger.error(XACMLErrorConstants.ERROR_PROCESS_FLOW + "PrefixList description:"+valueDesc.get(1));
+ policyLogger.error(XACMLErrorConstants.ERROR_PROCESS_FLOW + "PrefixList description:"+valueDesc.get(1));
targetAddressList.setDescription(valueDesc.get(1));
}
@@ -922,16 +915,12 @@ public class CreateFirewallController extends RestrictedBaseController {
ObjectWriter om = new ObjectMapper().writer();
try {
json = om.writeValueAsString(tc);
- } catch (JsonGenerationException e) {
- logger.error("Exception Occured"+e);
- } catch (JsonMappingException e) {
- logger.error("Exception Occured"+e);
- } catch (IOException e) {
- logger.error("Exception Occured"+e);
+ } catch (Exception e) {
+ policyLogger.error("Exception Occured"+e);
}
}catch (Exception e) {
- logger.error("Exception Occured"+e);
+ policyLogger.error("Exception Occured"+e);
}
return json;
diff --git a/POLICY-SDK-APP/src/main/java/org/openecomp/policy/controller/DashboardController.java b/POLICY-SDK-APP/src/main/java/org/openecomp/policy/controller/DashboardController.java
index 56ff637e9..089470671 100644
--- a/POLICY-SDK-APP/src/main/java/org/openecomp/policy/controller/DashboardController.java
+++ b/POLICY-SDK-APP/src/main/java/org/openecomp/policy/controller/DashboardController.java
@@ -73,7 +73,7 @@ import com.fasterxml.jackson.databind.ObjectMapper;
@Controller
@RequestMapping({"/"})
public class DashboardController extends RestrictedBaseController{
- private static final Logger logger = FlexLogger.getLogger(DashboardController.class);
+ private static final Logger policyLogger = FlexLogger.getLogger(DashboardController.class);
@Autowired
SystemLogDbDao systemDAO;
@@ -110,7 +110,7 @@ public class DashboardController extends RestrictedBaseController{
response.getWriter().write(j.toString());
}
catch (Exception e){
- logger.error("Exception Occured"+e);
+ policyLogger.error("Exception Occured"+e);
}
}
@@ -125,7 +125,7 @@ public class DashboardController extends RestrictedBaseController{
response.getWriter().write(j.toString());
}
catch (Exception e){
- logger.error("Exception Occured"+e);
+ policyLogger.error("Exception Occured"+e);
}
}
@@ -142,7 +142,7 @@ public class DashboardController extends RestrictedBaseController{
response.getWriter().write(j.toString());
}
catch (Exception e){
- logger.error("Exception Occured"+e);
+ policyLogger.error("Exception Occured"+e);
}
}
@@ -161,7 +161,7 @@ public class DashboardController extends RestrictedBaseController{
response.getWriter().write(j.toString());
}
catch (Exception e){
- logger.error("Exception Occured"+e);
+ policyLogger.error("Exception Occured"+e);
}
}
@@ -180,7 +180,7 @@ public class DashboardController extends RestrictedBaseController{
response.getWriter().write(j.toString());
}
catch (Exception e){
- logger.error("Exception Occured"+e);
+ policyLogger.error("Exception Occured"+e);
}
}
@@ -201,7 +201,7 @@ public class DashboardController extends RestrictedBaseController{
}
} catch (PAPException | NullPointerException e1) {
papStatus = "CANNOT_CONNECT";
- logger.error("Error getting PAP status, PAP not responding to requests");
+ policyLogger.error("Error getting PAP status, PAP not responding to requests", e1);
}
String papURL = XACMLProperties.getProperty(XACMLRestProperties.PROP_PAP_URL);
JSONObject object = new JSONObject();
@@ -229,11 +229,12 @@ public class DashboardController extends RestrictedBaseController{
if (pdp.getStatus().getStatus().toString() == "UP_TO_DATE" && ((EcompPDP) pdp).getJmxPort() != 0){
String pdpIpAddress = parseIPSystem(pdp.getId());
int port = ((EcompPDP) pdp).getJmxPort();
- if (port != 0)
- logger.debug("Getting JMX Response Counts from " + pdpIpAddress + " at JMX port " + port);
- naCount = getRequestCounts(pdpIpAddress, port, "pdpEvaluationNA");
- permitCount = getRequestCounts(pdpIpAddress, port, "PdpEvaluationPermit");
- denyCount = getRequestCounts(pdpIpAddress, port, "PdpEvaluationDeny");
+ if (port != 0){
+ policyLogger.debug("Getting JMX Response Counts from " + pdpIpAddress + " at JMX port " + port);
+ naCount = getRequestCounts(pdpIpAddress, port, "pdpEvaluationNA");
+ permitCount = getRequestCounts(pdpIpAddress, port, "PdpEvaluationPermit");
+ denyCount = getRequestCounts(pdpIpAddress, port, "PdpEvaluationDeny");
+ }
}
if (naCount == -1){
JSONObject object = new JSONObject();
@@ -279,7 +280,7 @@ public class DashboardController extends RestrictedBaseController{
@SuppressWarnings({ "rawtypes", "unchecked" })
private long getRequestCounts(String host, int port, String jmxAttribute) {
- logger.debug("Create an RMI connector client and connect it to the JMX connector server");
+ policyLogger.debug("Create an RMI connector client and connect it to the JMX connector server");
HashMap map = new HashMap();
map = null;
JMXConnector jmxConnection;
@@ -288,23 +289,23 @@ public class DashboardController extends RestrictedBaseController{
jmxConnection.connect();
Object o = jmxConnection.getMBeanServerConnection().getAttribute(new ObjectName("PdpRest:type=PdpRestMonitor"), jmxAttribute);
jmxConnection.close();
- logger.debug("pdpEvaluationNA value retreived: " + o);
+ policyLogger.debug("pdpEvaluationNA value retreived: " + o);
return (long) o;
} catch (MalformedURLException e) {
- logger.error("MalformedURLException for JMX connection");
+ policyLogger.error("MalformedURLException for JMX connection" , e);
} catch (IOException e) {
- logger.error("Error in reteriving" + jmxAttribute + " from JMX connection");
+ policyLogger.error("Error in reteriving" + jmxAttribute + " from JMX connection", e);
} catch (AttributeNotFoundException e) {
- logger.error("AttributeNotFoundException " + jmxAttribute + " for JMX connection");
+ policyLogger.error("AttributeNotFoundException " + jmxAttribute + " for JMX connection", e);
} catch (InstanceNotFoundException e) {
- logger.error("InstanceNotFoundException " + host + " for JMX connection");
+ policyLogger.error("InstanceNotFoundException " + host + " for JMX connection", e);
} catch (MalformedObjectNameException e) {
- logger.error("MalformedObjectNameException for JMX connection");
+ policyLogger.error("MalformedObjectNameException for JMX connection", e);
} catch (MBeanException e) {
- logger.error("MBeanException for JMX connection");
- logger.error("Exception Occured"+e);
+ policyLogger.error("MBeanException for JMX connection");
+ policyLogger.error("Exception Occured"+e);
} catch (ReflectionException e) {
- logger.error("ReflectionException for JMX connection");
+ policyLogger.error("ReflectionException for JMX connection", e);
}
return -1;
@@ -332,7 +333,7 @@ public class DashboardController extends RestrictedBaseController{
try{
policyMap.put(policy.getPolicyId().replace(" ", ""), policy.getId());
}catch(Exception e){
- logger.error(XACMLErrorConstants.ERROR_SCHEMA_INVALID+policy.getName() +e);
+ policyLogger.error(XACMLErrorConstants.ERROR_SCHEMA_INVALID+policy.getName() +e);
}
}
@@ -386,7 +387,7 @@ public class DashboardController extends RestrictedBaseController{
*/
@SuppressWarnings({ "rawtypes", "unchecked" })
private Object getPolicy(String host, int port, String jmxAttribute){
- logger.debug("Create an RMI connector client and connect it to the JMX connector server for Policy: " + host);
+ policyLogger.debug("Create an RMI connector client and connect it to the JMX connector server for Policy: " + host);
HashMap map = new HashMap();
map = null;
JMXConnector jmxConnection;
@@ -395,23 +396,23 @@ public class DashboardController extends RestrictedBaseController{
jmxConnection.connect();
Object o = jmxConnection.getMBeanServerConnection().getAttribute(new ObjectName("PdpRest:type=PdpRestMonitor"), "policyMap");
jmxConnection.close();
- logger.debug("policyMap value retreived: " + o);
+ policyLogger.debug("policyMap value retreived: " + o);
return o;
} catch (MalformedURLException e) {
- logger.error("MalformedURLException for JMX connection");
+ policyLogger.error("MalformedURLException for JMX connection");
} catch (IOException e) {
- logger.error("AttributeNotFoundException for policyMap" );
+ policyLogger.error("AttributeNotFoundException for policyMap" );
} catch (AttributeNotFoundException e) {
- logger.error("AttributeNotFoundException for JMX connection");
+ policyLogger.error("AttributeNotFoundException for JMX connection");
} catch (InstanceNotFoundException e) {
- logger.error("InstanceNotFoundException " + host + " for JMX connection");
+ policyLogger.error("InstanceNotFoundException " + host + " for JMX connection");
} catch (MalformedObjectNameException e) {
- logger.error("MalformedObjectNameException for JMX connection");
+ policyLogger.error("MalformedObjectNameException for JMX connection");
} catch (MBeanException e) {
- logger.error("MBeanException for JMX connection");
- logger.error("Exception Occured"+e);
+ policyLogger.error("MBeanException for JMX connection");
+ policyLogger.error("Exception Occured"+e);
} catch (ReflectionException e) {
- logger.error("ReflectionException for JMX connection");
+ policyLogger.error("ReflectionException for JMX connection");
}
return null;
diff --git a/POLICY-SDK-APP/src/main/java/org/openecomp/policy/controller/DecisionPolicyController.java b/POLICY-SDK-APP/src/main/java/org/openecomp/policy/controller/DecisionPolicyController.java
index ef43135c2..f959495c6 100644
--- a/POLICY-SDK-APP/src/main/java/org/openecomp/policy/controller/DecisionPolicyController.java
+++ b/POLICY-SDK-APP/src/main/java/org/openecomp/policy/controller/DecisionPolicyController.java
@@ -21,6 +21,7 @@
package org.openecomp.policy.controller;
import java.util.ArrayList;
+import java.util.Arrays;
import java.util.HashMap;
import java.util.Iterator;
import java.util.LinkedList;
@@ -39,7 +40,6 @@ import org.openecomp.portalsdk.core.controller.RestrictedBaseController;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
-import oasis.names.tc.xacml._3_0.core.schema.wd_17.AdviceExpressionType;
import oasis.names.tc.xacml._3_0.core.schema.wd_17.AdviceExpressionsType;
import oasis.names.tc.xacml._3_0.core.schema.wd_17.AllOfType;
import oasis.names.tc.xacml._3_0.core.schema.wd_17.AnyOfType;
@@ -58,7 +58,7 @@ import oasis.names.tc.xacml._3_0.core.schema.wd_17.VariableReferenceType;
@Controller
@RequestMapping("/")
public class DecisionPolicyController extends RestrictedBaseController {
- private static final Logger logger = FlexLogger.getLogger(DecisionPolicyController.class);
+ private static final Logger policyLogger = FlexLogger.getLogger(DecisionPolicyController.class);
public DecisionPolicyController(){}
@@ -88,6 +88,7 @@ public class DecisionPolicyController extends RestrictedBaseController {
try{
description = policy.getDescription().substring(0, policy.getDescription().indexOf("@CreatedBy:"));
}catch(Exception e){
+ policyLogger.info("General error", e);
description = policy.getDescription();
}
policyAdapter.setPolicyDescription(description);
@@ -141,23 +142,28 @@ public class DecisionPolicyController extends RestrictedBaseController {
}
}
// Setting rainy day attributes to the parameters object if they exist
+ boolean rainy = false;
if(!attributeList.isEmpty()) {
for(int i=0; i<attributeList.size() ; i++){
Map<String, String> map = (Map<String,String>)attributeList.get(i);
if(map.get("key").equals("WorkStep")){
rainydayParams.setWorkstep(map.get("value"));
+ rainy=true;
}else if(map.get("key").equals("BB_ID")){
rainydayParams.setBbid(map.get("value"));
+ rainy=true;
}else if(map.get("key").equals("ServiceType")){
rainydayParams.setServiceType(map.get("value"));
+ rainy=true;
}else if(map.get("key").equals("VNFType")){
rainydayParams.setVnfType(map.get("value"));
+ rainy=true;
}
}
}
-
- policyAdapter.setRuleProvider("Rainy_Day");
-
+ if(rainy){
+ policyAdapter.setRuleProvider("Rainy_Day");
+ }
}
List<Object> ruleList = policy.getCombinerParametersOrRuleCombinerParametersOrVariableDefinition();
@@ -165,7 +171,7 @@ public class DecisionPolicyController extends RestrictedBaseController {
for (Object object : ruleList) {
if (object instanceof VariableDefinitionType) {
VariableDefinitionType variableDefinitionType = (VariableDefinitionType) object;
- Map<String, String> settings = new HashMap<String, String>();
+ Map<String, String> settings = new HashMap<>();
settings.put("key", variableDefinitionType.getVariableId());
JAXBElement<AttributeValueType> attributeValueTypeElement = (JAXBElement<AttributeValueType>) variableDefinitionType.getExpression();
if (attributeValueTypeElement != null) {
@@ -201,6 +207,10 @@ public class DecisionPolicyController extends RestrictedBaseController {
yamlParams.setActor(map.get("value"));
}else if(map.get("key").equals("recipe")){
yamlParams.setRecipe(map.get("value"));
+ }else if(map.get("key").equals("targets")){
+ yamlParams.setTargets(Arrays.asList(map.get("value").split("\\|")));
+ }else if(map.get("key").equals("clname")){
+ yamlParams.setClname(map.get("value"));
}
}
ApplyType apply = ((ApplyType)((ApplyType)decisionApply.getExpression().get(0).getValue()).getExpression().get(0).getValue());
@@ -215,9 +225,11 @@ public class DecisionPolicyController extends RestrictedBaseController {
}
yamlParams.setBlackList(blackList);
}else{
- yamlParams.setLimit(((AttributeValueType)((ApplyType)decisionApply.getExpression().get(1).getValue()).getExpression().get(1).getValue()).getContent().get(0).toString());
- String timeWindow = ((AttributeDesignatorType)((ApplyType)((ApplyType)decisionApply.getExpression().get(1).getValue()).getExpression().get(0).getValue()).getExpression().get(0).getValue()).getIssuer();
- yamlParams.setTimeWindow(timeWindow.substring(timeWindow.lastIndexOf(":")+1));
+ ApplyType timeWindowSection = (ApplyType)((ApplyType)decisionApply.getExpression().get(0).getValue()).getExpression().get(1).getValue();
+ yamlParams.setLimit(((AttributeValueType)timeWindowSection.getExpression().get(1).getValue()).getContent().get(0).toString());
+ String timeWindow = ((AttributeDesignatorType)((ApplyType)timeWindowSection.getExpression().get(0).getValue()).getExpression().get(0).getValue()).getIssuer();
+ yamlParams.setTimeUnits(timeWindow.substring(timeWindow.lastIndexOf(':')+1));
+ yamlParams.setTimeWindow(timeWindow.substring(timeWindow.indexOf(":tw:")+4,timeWindow.lastIndexOf(':')));
}
policyAdapter.setYamlparams(yamlParams);
policyAdapter.setAttributes(new ArrayList<Object>());
@@ -228,7 +240,7 @@ public class DecisionPolicyController extends RestrictedBaseController {
prePopulateDecisionCompoundRuleAlgorithm(index, decisionApply);
policyAdapter.setRuleAlgorithmschoices(ruleAlgorithmList);
}
- } else if (((RuleType) object).getEffect().equals(EffectType.PERMIT)) {
+ } else if(policyAdapter.getRuleProvider()!=null && policyAdapter.getRuleProvider().equals("Rainy_Day")&& ((RuleType) object).getEffect().equals(EffectType.PERMIT)) {
TargetType ruleTarget = ((RuleType) object).getTarget();
AdviceExpressionsType adviceExpression = ((RuleType) object).getAdviceExpressions();
@@ -303,8 +315,8 @@ public class DecisionPolicyController extends RestrictedBaseController {
List<JAXBElement<?>> jaxbDecisionTypes = decisionApply.getExpression();
for (JAXBElement<?> jaxbElement : jaxbDecisionTypes) {
// If There is Attribute Value under Decision Type that means we came to the final child
- if (logger.isDebugEnabled()) {
- logger.debug("Prepopulating rule algoirthm: " + index);
+ if (policyLogger.isDebugEnabled()) {
+ policyLogger.debug("Prepopulating rule algoirthm: " + index);
}
// Check to see if Attribute Value exists, if yes then it is not a compound rule
if(jaxbElement.getValue() instanceof AttributeValueType) {
@@ -321,8 +333,8 @@ public class DecisionPolicyController extends RestrictedBaseController {
index = prePopulateDecisionCompoundRuleAlgorithm(index, innerDecisionApply);
}
// Populate combo box
- if (logger.isDebugEnabled()) {
- logger.debug("Prepopulating Compound rule algorithm: " + index);
+ if (policyLogger.isDebugEnabled()) {
+ policyLogger.debug("Prepopulating Compound rule algorithm: " + index);
}
Map<String, String> rule = new HashMap<>();
for (String key : PolicyController.getDropDownMap().keySet()) {
diff --git a/POLICY-SDK-APP/src/main/java/org/openecomp/policy/controller/PDPController.java b/POLICY-SDK-APP/src/main/java/org/openecomp/policy/controller/PDPController.java
index 2e9771ec8..6ef7165b3 100644
--- a/POLICY-SDK-APP/src/main/java/org/openecomp/policy/controller/PDPController.java
+++ b/POLICY-SDK-APP/src/main/java/org/openecomp/policy/controller/PDPController.java
@@ -59,7 +59,7 @@ import com.fasterxml.jackson.databind.ObjectMapper;
@Controller
@RequestMapping({"/"})
public class PDPController extends RestrictedBaseController {
- private static final Logger logger = FlexLogger.getLogger(PDPController.class);
+ private static final Logger policyLogger = FlexLogger.getLogger(PDPController.class);
protected List<EcompPDPGroup> groups = Collections.synchronizedList(new ArrayList<EcompPDPGroup>());
private PDPGroupContainer container;
@@ -152,7 +152,7 @@ public class PDPController extends RestrictedBaseController {
}
} catch (PAPException e) {
String message = "Unable to retrieve Groups from server: " + e;
- logger.error(XACMLErrorConstants.ERROR_SYSTEM_ERROR+"Pap Engine is Null" + message);
+ policyLogger.error(XACMLErrorConstants.ERROR_SYSTEM_ERROR+"Pap Engine is Null" + message);
}
}
}
@@ -167,12 +167,12 @@ public class PDPController extends RestrictedBaseController {
response.getWriter().write(j.toString());
}
catch (Exception e){
- logger.error(XACMLErrorConstants.ERROR_DATA_ISSUE+"Error Occured while retrieving the PDP Group data" + e);
+ policyLogger.error(XACMLErrorConstants.ERROR_DATA_ISSUE+"Error Occured while retrieving the PDP Group data" + e);
}
}
@RequestMapping(value={"/pdp_Group/save_pdp_group"}, method={org.springframework.web.bind.annotation.RequestMethod.POST})
- public ModelAndView savePDPGroup(HttpServletRequest request, HttpServletResponse response) throws Exception{
+ public void savePDPGroup(HttpServletRequest request, HttpServletResponse response){
try {
ObjectMapper mapper = new ObjectMapper();
PolicyController controller = getPolicyControllerInstance();
@@ -189,7 +189,7 @@ public class PDPController extends RestrictedBaseController {
} catch (Exception e) {
String message = "Unable to create Group. Reason:\n" + e.getMessage();
- logger.error(XACMLErrorConstants.ERROR_DATA_ISSUE+"Error Occured while creating the PDP Group" + message);
+ policyLogger.error(XACMLErrorConstants.ERROR_DATA_ISSUE+"Error Occured while creating the PDP Group" + message + e);
}
@@ -202,21 +202,23 @@ public class PDPController extends RestrictedBaseController {
JsonMessage msg = new JsonMessage(mapper.writeValueAsString(groups));
JSONObject j = new JSONObject(msg);
out.write(j.toString());
-
- return null;
}
catch (Exception e){
- logger.error(XACMLErrorConstants.ERROR_DATA_ISSUE+"Error Occured while Saving the PDP Group" + e);
+ policyLogger.error(XACMLErrorConstants.ERROR_DATA_ISSUE+"Error Occured while Saving the PDP Group" + e);
response.setCharacterEncoding("UTF-8");
- request.setCharacterEncoding("UTF-8");
- PrintWriter out = response.getWriter();
- out.write(e.getMessage());
+ PrintWriter out = null;
+ try {
+ request.setCharacterEncoding("UTF-8");
+ out = response.getWriter();
+ out.write(e.getMessage());
+ } catch (Exception e1) {
+ policyLogger.error(XACMLErrorConstants.ERROR_DATA_ISSUE+"Error Occured while Saving the PDP Group" + e1);
+ }
}
- return null;
}
@RequestMapping(value={"/pdp_Group/remove_pdp_group"}, method={org.springframework.web.bind.annotation.RequestMethod.POST})
- public ModelAndView removePDPGroup(HttpServletRequest request, HttpServletResponse response) throws Exception {
+ public void removePDPGroup(HttpServletRequest request, HttpServletResponse response){
try{
ObjectMapper mapper = new ObjectMapper();
mapper.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false);
@@ -240,21 +242,23 @@ public class PDPController extends RestrictedBaseController {
JsonMessage msg = new JsonMessage(mapper.writeValueAsString(groups));
JSONObject j = new JSONObject(msg);
out.write(j.toString());
-
- return null;
}
catch (Exception e){
- logger.error(XACMLErrorConstants.ERROR_DATA_ISSUE+"Error Occured while Removing the PDP Group" + e);
- response.setCharacterEncoding("UTF-8");
- request.setCharacterEncoding("UTF-8");
- PrintWriter out = response.getWriter();
- out.write(e.getMessage());
+ policyLogger.error(XACMLErrorConstants.ERROR_DATA_ISSUE+"Error Occured while Removing the PDP Group" + e);
+ PrintWriter out;
+ try {
+ response.setCharacterEncoding("UTF-8");
+ request.setCharacterEncoding("UTF-8");
+ out = response.getWriter();
+ out.write(e.getMessage());
+ } catch (Exception e1) {
+ policyLogger.error("Exception Occured"+ e1);
+ }
}
- return null;
}
@RequestMapping(value={"/pdp_Group/save_pdpTogroup"}, method={org.springframework.web.bind.annotation.RequestMethod.POST})
- public ModelAndView savePDPToGroup(HttpServletRequest request, HttpServletResponse response) throws Exception{
+ public void savePDPToGroup(HttpServletRequest request, HttpServletResponse response){
try {
ObjectMapper mapper = new ObjectMapper();
mapper.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false);
@@ -273,7 +277,7 @@ public class PDPController extends RestrictedBaseController {
}
} catch (Exception e) {
String message = "Unable to create Group. Reason:\n" + e.getMessage();
- logger.error(XACMLErrorConstants.ERROR_DATA_ISSUE+"Error Occured while Creating Pdp in PDP Group" + message);
+ policyLogger.error(XACMLErrorConstants.ERROR_DATA_ISSUE+"Error Occured while Creating Pdp in PDP Group" + message + e);
}
@@ -286,21 +290,23 @@ public class PDPController extends RestrictedBaseController {
JsonMessage msg = new JsonMessage(mapper.writeValueAsString(groups));
JSONObject j = new JSONObject(msg);
out.write(j.toString());
-
- return null;
}
catch (Exception e){
- logger.error(XACMLErrorConstants.ERROR_DATA_ISSUE+"Error Occured while Creating Pdp in PDP Group" + e);
- response.setCharacterEncoding("UTF-8");
- request.setCharacterEncoding("UTF-8");
- PrintWriter out = response.getWriter();
- out.write(e.getMessage());
+ policyLogger.error(XACMLErrorConstants.ERROR_DATA_ISSUE+"Error Occured while Creating Pdp in PDP Group" + e);
+ PrintWriter out;
+ try {
+ response.setCharacterEncoding("UTF-8");
+ request.setCharacterEncoding("UTF-8");
+ out = response.getWriter();
+ out.write(e.getMessage());
+ } catch (Exception e1) {
+ policyLogger.error("Exception Occured"+ e1);
+ }
}
- return null;
}
@RequestMapping(value={"/pdp_Group/remove_pdpFromGroup"}, method={org.springframework.web.bind.annotation.RequestMethod.POST})
- public ModelAndView removePDPFromGroup(HttpServletRequest request, HttpServletResponse response) throws Exception {
+ public void removePDPFromGroup(HttpServletRequest request, HttpServletResponse response){
try{
ObjectMapper mapper = new ObjectMapper();
mapper.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false);
@@ -320,17 +326,19 @@ public class PDPController extends RestrictedBaseController {
String responseString = mapper.writeValueAsString(groups);
JSONObject j = new JSONObject("{pdpEntityDatas: " + responseString + "}");
out.write(j.toString());
-
- return null;
}
catch (Exception e){
- logger.error(XACMLErrorConstants.ERROR_DATA_ISSUE+"Error Occured while Removing Pdp from PDP Group" + e);
- response.setCharacterEncoding("UTF-8");
- request.setCharacterEncoding("UTF-8");
- PrintWriter out = response.getWriter();
- out.write(e.getMessage());
+ policyLogger.error(XACMLErrorConstants.ERROR_DATA_ISSUE+"Error Occured while Removing Pdp from PDP Group" + e);
+ PrintWriter out;
+ try {
+ response.setCharacterEncoding("UTF-8");
+ request.setCharacterEncoding("UTF-8");
+ out = response.getWriter();
+ out.write(e.getMessage());
+ } catch (Exception e1) {
+ policyLogger.error("Exception Occured"+ e1);
+ }
}
- return null;
}
private PolicyController getPolicyControllerInstance(){
diff --git a/POLICY-SDK-APP/src/main/java/org/openecomp/policy/controller/PolicyExportAndImportController.java b/POLICY-SDK-APP/src/main/java/org/openecomp/policy/controller/PolicyExportAndImportController.java
index bf2a148e6..8fe2d492f 100644
--- a/POLICY-SDK-APP/src/main/java/org/openecomp/policy/controller/PolicyExportAndImportController.java
+++ b/POLICY-SDK-APP/src/main/java/org/openecomp/policy/controller/PolicyExportAndImportController.java
@@ -99,6 +99,14 @@ public class PolicyExportAndImportController extends RestrictedBaseController {
this.policyController = policyController;
}
+ public static CommonClassDao getCommonClassDao() {
+ return commonClassDao;
+ }
+
+ public static void setCommonClassDao(CommonClassDao commonClassDao) {
+ PolicyExportAndImportController.commonClassDao = commonClassDao;
+ }
+
@Autowired
private PolicyExportAndImportController(CommonClassDao commonClassDao){
PolicyExportAndImportController.commonClassDao = commonClassDao;
@@ -107,7 +115,7 @@ public class PolicyExportAndImportController extends RestrictedBaseController {
public PolicyExportAndImportController(){}
@RequestMapping(value={"/policy_download/exportPolicy.htm"}, method={org.springframework.web.bind.annotation.RequestMethod.POST})
- public void ExportPolicy(HttpServletRequest request, HttpServletResponse response) throws Exception{
+ public void exportPolicy(HttpServletRequest request, HttpServletResponse response) throws Exception{
try{
String file = null;
selectedPolicy = new ArrayList<>();
diff --git a/POLICY-SDK-APP/src/main/java/org/openecomp/policy/controller/PolicyValidationController.java b/POLICY-SDK-APP/src/main/java/org/openecomp/policy/controller/PolicyValidationController.java
index cc6903b91..0f8b3795f 100644
--- a/POLICY-SDK-APP/src/main/java/org/openecomp/policy/controller/PolicyValidationController.java
+++ b/POLICY-SDK-APP/src/main/java/org/openecomp/policy/controller/PolicyValidationController.java
@@ -401,10 +401,8 @@ public class PolicyValidationController extends RestrictedBaseController {
int endNum = Integer.parseInt(tempString[1]);
String returnString = "Invalid Range:" + rMap.getKey() + " must be between "
+ startNum + " - " + endNum + ",";
- if (isInteger(value.replace("\"", ""))){
+ if (PolicyUtils.isInteger(value.replace("\"", ""))){
int result = Integer.parseInt(value.replace("\"", ""));
-
-
if (result < startNum || result > endNum){
responseString.append(returnString);
valid = false;
@@ -492,13 +490,20 @@ public class PolicyValidationController extends RestrictedBaseController {
if(policyData.getYamlparams().getLimit()==null){
responseString.append(" Guard Params <b>Limit</b> is Required " + "<br>");
valid = false;
- }else if(!isInteger(policyData.getYamlparams().getLimit())){
+ }else if(!PolicyUtils.isInteger(policyData.getYamlparams().getLimit())){
responseString.append(" Guard Params <b>Limit</b> Should be Integer " + "<br>");
valid = false;
}
if(policyData.getYamlparams().getTimeWindow()==null){
responseString.append("Guard Params <b>Time Window</b> is Required" + "<br>");
valid = false;
+ }else if(!PolicyUtils.isInteger(policyData.getYamlparams().getTimeWindow())){
+ responseString.append(" Guard Params <b>Time Window</b> Should be Integer " + "<br>");
+ valid = false;
+ }
+ if(policyData.getYamlparams().getTimeUnits()==null){
+ responseString.append("Guard Params <b>Time Units</b> is Required" + "<br>");
+ valid = false;
}
}else if("GUARD_BL_YAML".equals(policyData.getRuleProvider())){
if(policyData.getYamlparams().getBlackList()==null || policyData.getYamlparams().getBlackList().isEmpty()){
@@ -623,15 +628,6 @@ public class PolicyValidationController extends RestrictedBaseController {
return null;
}
- protected boolean isInteger(String number) {
- try{
- Integer.parseInt(number);
- }catch(NumberFormatException e){
- return false;
- }
- return true;
- }
-
protected String emptyValidator(String field){
String error;
if ("".equals(field) || field.contains(" ") || !field.matches("^[a-zA-Z0-9_]*$")) {