summaryrefslogtreecommitdiffstats
path: root/POLICY-SDK-APP
diff options
context:
space:
mode:
Diffstat (limited to 'POLICY-SDK-APP')
-rw-r--r--POLICY-SDK-APP/config/policyLogger.properties24
-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
-rw-r--r--POLICY-SDK-APP/src/main/webapp/app/policyApp/CSS/bootstrap/docs/assets/js/vendor/autoprefixer.js6
-rw-r--r--POLICY-SDK-APP/src/main/webapp/app/policyApp/Windows/PushtabWindow/removeGroupPoliciesWindow.html2
-rw-r--r--POLICY-SDK-APP/src/main/webapp/app/policyApp/policy-models/Editor/PolicyTemplateController/DCAEMicroServicePolicyController.js74
-rw-r--r--POLICY-SDK-APP/src/main/webapp/app/policyApp/policy-models/Editor/PolicyTemplateController/DecisionPolicyController.js60
-rw-r--r--POLICY-SDK-APP/src/main/webapp/app/policyApp/policy-models/Editor/PolicyTemplates/DCAEMicroServicePolicyTemplate.html2
-rw-r--r--POLICY-SDK-APP/src/main/webapp/app/policyApp/policy-models/Editor/PolicyTemplates/DecisionPolicyTemplate.html109
-rw-r--r--POLICY-SDK-APP/src/main/webapp/app/policyApp/policy-models/Editor/css/main.css36
-rw-r--r--POLICY-SDK-APP/src/main/webapp/app/policyApp/policy-models/Editor/templates/modals.html22
-rw-r--r--POLICY-SDK-APP/src/main/webapp/app/policyApp/policy-models/Editor/templates/searchNavbar.html4
-rw-r--r--POLICY-SDK-APP/src/test/java/org/openecomp/policy/admin/PolicyManagerServletTest.java423
-rw-r--r--POLICY-SDK-APP/src/test/java/org/openecomp/policy/controller/AdminTabControllerTest.java35
-rw-r--r--POLICY-SDK-APP/src/test/java/org/openecomp/policy/controller/CreateDcaeMicroServiceControllerTest.java1
-rw-r--r--POLICY-SDK-APP/src/test/resources/Action_TestActionPolicy.1.xml52
-rw-r--r--POLICY-SDK-APP/src/test/resources/Config_BRMS_Param_BRMSParamvFWDemoPolicy.1.xml93
-rw-r--r--POLICY-SDK-APP/src/test/resources/Config_BRMS_Raw_TestBRMSRawPolicy.1.xml110
-rw-r--r--POLICY-SDK-APP/src/test/resources/Config_FW_TestFireWallPolicy.1.xml86
-rw-r--r--POLICY-SDK-APP/src/test/resources/Config_Fault_TestClosedLoopPolicy.1.xml83
-rw-r--r--POLICY-SDK-APP/src/test/resources/Config_MS_vFirewall.1.xml114
-rw-r--r--POLICY-SDK-APP/src/test/resources/Config_PM_TestClosedLoopPMPolicy.1.xml90
-rw-r--r--POLICY-SDK-APP/src/test/resources/Config_SampleTest1206.1.xml4
-rw-r--r--POLICY-SDK-APP/src/test/resources/Decision_TestDecisionPolicyWithRuleAlgorithms.1.xml85
-rw-r--r--POLICY-SDK-APP/src/test/resources/JSONConfig.json132
-rw-r--r--POLICY-SDK-APP/src/test/resources/com.Action_TestActionPolicy.1.json1
-rw-r--r--POLICY-SDK-APP/src/test/resources/com.Config_BRMS_Param_BRMSParamvFWDemoPolicy.1.txt1145
-rw-r--r--POLICY-SDK-APP/src/test/resources/com.Config_BRMS_Raw_TestBRMSRawPolicy.1.txt35
-rw-r--r--POLICY-SDK-APP/src/test/resources/com.Config_FW_TestFireWallPolicy.1.json1
-rw-r--r--POLICY-SDK-APP/src/test/resources/com.Config_Fault_TestClosedLoopPolicy.1.json1
-rw-r--r--POLICY-SDK-APP/src/test/resources/com.Config_MS_vFirewall.1.json1
-rw-r--r--POLICY-SDK-APP/src/test/resources/com.Config_PM_TestClosedLoopPMPolicy.1.json1
45 files changed, 3177 insertions, 476 deletions
diff --git a/POLICY-SDK-APP/config/policyLogger.properties b/POLICY-SDK-APP/config/policyLogger.properties
new file mode 100644
index 000000000..030c5ee13
--- /dev/null
+++ b/POLICY-SDK-APP/config/policyLogger.properties
@@ -0,0 +1,24 @@
+################################### Set concurrentHashMap and timer info #######################
+#Timer initial delay and the delay between in milliseconds before task is to be execute.
+timer.delay.time=1000
+#Timer scheduleAtFixedRate period - time in milliseconds between successive task executions.
+check.interval= 30000
+#Longest time an event info can be stored in the concurrentHashMap for logging - in seconds.
+event.expired.time=86400
+#Size of the concurrentHashMap which stores the event starting time, etc - when its size reaches this limit, the Timer gets executed
+#to remove all expired records from this concurrentHashMap.
+concurrentHashMap.limit=5000
+#Size of the concurrentHashMap - when its size drops to this point, stop the Timer
+stop.check.point=2500
+################################### Set logging format #############################################
+# set EELF for EELF logging format, set LOG4J for using log4j, set SYSTEMOUT for using system.out.println
+logger.type=SYSTEMOUT
+#################################### Set level for EELF or SYSTEMOUT logging ##################################
+# Set level for debug file. Set DEBUG to enable .info, .warn and .debug; set INFO for enable .info and .warn; set OFF to disable all
+debugLogger.level=INFO
+# Set level for metrics file. Set OFF to disable; set ON to enable
+metricsLogger.level=ON
+# Set level for error file. Set OFF to disable; set ON to enable
+error.level=ON
+# Set level for audit file. Set OFF to disable; set ON to enable
+audit.level=ON
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_]*$")) {
diff --git a/POLICY-SDK-APP/src/main/webapp/app/policyApp/CSS/bootstrap/docs/assets/js/vendor/autoprefixer.js b/POLICY-SDK-APP/src/main/webapp/app/policyApp/CSS/bootstrap/docs/assets/js/vendor/autoprefixer.js
index 2919f5f62..2cf57d3ed 100644
--- a/POLICY-SDK-APP/src/main/webapp/app/policyApp/CSS/bootstrap/docs/assets/js/vendor/autoprefixer.js
+++ b/POLICY-SDK-APP/src/main/webapp/app/policyApp/CSS/bootstrap/docs/assets/js/vendor/autoprefixer.js
@@ -14778,7 +14778,7 @@ var _inherits = function (subClass, superClass) { if (typeof superClass !== "fun
var Container = require("./container");
-// CSS at-rule like “this.keyframes name { }”.
+// CSS at-rule like �this.keyframes name { }�.
//
// Can contain declarations (like this.font-face or this.page) ot another rules.
var AtRule = (function (Container) {
@@ -15486,7 +15486,7 @@ var _inherits = function (subClass, superClass) { if (typeof superClass !== "fun
var Node = require("./node");
var vendor = require("./vendor");
-// CSS declaration like “color: black” in rules
+// CSS declaration like �color: black� in rules
var Declaration = (function (Node) {
function Declaration(defaults) {
this.type = "decl";
@@ -17281,7 +17281,7 @@ var Container = require("./container");
var Declaration = require("./declaration");
var list = require("./list");
-// CSS rule like “a { }”
+// CSS rule like �a { }�
var Rule = (function (Container) {
function Rule(defaults) {
this.type = "rule";
diff --git a/POLICY-SDK-APP/src/main/webapp/app/policyApp/Windows/PushtabWindow/removeGroupPoliciesWindow.html b/POLICY-SDK-APP/src/main/webapp/app/policyApp/Windows/PushtabWindow/removeGroupPoliciesWindow.html
index 6ebda43a7..0cd3c52bd 100644
--- a/POLICY-SDK-APP/src/main/webapp/app/policyApp/Windows/PushtabWindow/removeGroupPoliciesWindow.html
+++ b/POLICY-SDK-APP/src/main/webapp/app/policyApp/Windows/PushtabWindow/removeGroupPoliciesWindow.html
@@ -18,7 +18,7 @@
* ============LICENSE_END=========================================================
*/-->
<script type="text/ng-template" id="remove_PDPGroupPolicies_popup.html">
-<div class="modal" style="margin-bottom: 20px; width: 100%; height:80%" data-backdrop="static"
+<div class="modal" style="margin-bottom: 20px; width: 100%" height:80%" data-backdrop="static"
data-keyboard="false">
<div class="modal-dialog-lg">
<div class="modal-content">
diff --git a/POLICY-SDK-APP/src/main/webapp/app/policyApp/policy-models/Editor/PolicyTemplateController/DCAEMicroServicePolicyController.js b/POLICY-SDK-APP/src/main/webapp/app/policyApp/policy-models/Editor/PolicyTemplateController/DCAEMicroServicePolicyController.js
index fb966430c..94c1bc998 100644
--- a/POLICY-SDK-APP/src/main/webapp/app/policyApp/policy-models/Editor/PolicyTemplateController/DCAEMicroServicePolicyController.js
+++ b/POLICY-SDK-APP/src/main/webapp/app/policyApp/policy-models/Editor/PolicyTemplateController/DCAEMicroServicePolicyController.js
@@ -163,10 +163,14 @@ angular.module('abs').controller('dcaeMicroServiceController', ['$scope', '$wind
var addElement = parentElement.childElementCount + 1;
clone.id = ''+value+'@'+addElement;
clone.value = '';
+ clone.className += ' child_single'; //here cloned is single element
document.getElementById("div."+value).appendChild(clone);
plainAttributeKeys.push(''+value+'@'+addElement);
}else{
div = document.getElementById("div."+value+"@0");
+
+ div.className += ' children_group'; //here is div with a group of children.
+
var childElement = parentElement.firstElementChild;
var countParent = parentElement.childElementCount;
var childElementString = childElement.innerHTML;
@@ -295,9 +299,12 @@ angular.module('abs').controller('dcaeMicroServiceController', ['$scope', '$wind
var plainAttributeKeys = [];
$scope.dcaeModelData = data[0].dcaeModelData;
$scope.dcaeJsonDate = data[0].jsonValue;
+ console.log("$scope.dcaeJsonDate: " + $scope.dcaeJsonDate);
var attributes = $scope.dcaeModelData.attributes;
var refAttributes = $scope.dcaeModelData.ref_attributes;
- var subAttributes = $scope.dcaeModelData.sub_attributes;
+ var subAttributes = $scope.dcaeModelData.sub_attributes;
+ console.log("subAttributes: " + subAttributes);
+
var enumAttributes = $scope.dcaeModelData.enumValues;
var annotation = $scope.dcaeModelData.annotation;
var dictionary = $scope.microServiceAttributeDictionaryDatas;
@@ -442,11 +449,11 @@ angular.module('abs').controller('dcaeMicroServiceController', ['$scope', '$wind
return Object.prototype.toString.call(arrayTest) === '[object Array]';
}
var lableList = [];
-
function deconstructJSON(dataTest, level , name) {
var array = false;
var label = level;
var stringValue = "java.lang.String";
+ var string = "string";
var intValue = "int";
var double = "double";
var boolean = "boolean";
@@ -459,6 +466,7 @@ angular.module('abs').controller('dcaeMicroServiceController', ['$scope', '$wind
for (key in dataTest) {
array = isArray(dataTest[key]);
console.log(key , dataTest[key]);
+
if (!!dataTest[key] && typeof(dataTest[key])=="object") {
if (array==false && key!=="0"){
$scope.labelLayout(label, key, array );
@@ -500,11 +508,35 @@ angular.module('abs').controller('dcaeMicroServiceController', ['$scope', '$wind
if (dataTest[key].includes('required-true')){
isRequired = true;
}
- console.log("attirbuteLabel = " + attirbuteLabel);
+
+ var subAttributes = $scope.dcaeModelData.sub_attributes;
+
+ if(subAttributes){
+ var jsonObject = JSON.parse(subAttributes);
+ var allkeys = Object.keys(jsonObject);
+ if(allkeys){
+ for (var k = 0; k < allkeys.length; k++) {
+ var keyValue = allkeys[k];
+ console.log(" keyValue:jsonObject["+keyValue+ "]: " + jsonObject[keyValue]);
+ if(jsonObject[keyValue]){
+ var tempObject = jsonObject[keyValue];
+ if(tempObject && tempObject[key]){
+ if (tempObject[key].includes('required-true')){
+ isRequired = true;
+ }
+ }
+ }
+ }
+ }
+ }
+
switch (dataTest[key].split(splitcolon)[0]){
case stringValue:
$scope.attributeBox(attributekey, array, attirbuteLabel, defaultValue, isRequired);
break;
+ case string:
+ $scope.attributeBox(attributekey, array, attirbuteLabel, defaultValue, isRequired);
+ break;
case intValue:
$scope.attributeBox(attributekey, array, attirbuteLabel, defaultValue, isRequired);
break;
@@ -582,13 +614,13 @@ angular.module('abs').controller('dcaeMicroServiceController', ['$scope', '$wind
var buttonaddLabel = document.createTextNode("+");
addButton.appendChild(buttonaddLabel);
addButton.setAttribute("id", labelValue + attibuteKey);
- addButton.setAttribute("class", "btn btn-default");
+ addButton.setAttribute("class", "btn btn-add-remove");
addButton.setAttribute("ng-click" , 'addNewChoice("'+labelValue + attibuteKey+'");');
addButton.setAttribute("ng-disabled" , "temp.policy.readOnly");
var removeButton = document.createElement("BUTTON");
var buttonremoveLabel = document.createTextNode("-");
removeButton.appendChild(buttonremoveLabel);
- removeButton.setAttribute("class", "btn btn-default");
+ removeButton.setAttribute("class", "btn btn-add-remove");
removeButton.setAttribute("ng-click" , 'removeChoice("'+labelValue + attibuteKey+'");');
removeButton.setAttribute("ng-disabled" , "temp.policy.readOnly");
document.getElementById(divID).appendChild(addButton);
@@ -597,6 +629,7 @@ angular.module('abs').controller('dcaeMicroServiceController', ['$scope', '$wind
document.getElementById(divID).appendChild(textField);
document.getElementById(divID).appendChild(br);
document.getElementById(divID).appendChild(divTag);
+
}else{
checkKey = labelValue + attibuteKey;
textField.setAttribute("id" , ''+labelValue +attibuteKey+'');
@@ -609,6 +642,16 @@ angular.module('abs').controller('dcaeMicroServiceController', ['$scope', '$wind
}
+ if(divID.includes("@0") && divID.includes("div.")){
+ var firstChild_Id = divID.split("@0")[0];
+ var firstChild_element = document.getElementById(firstChild_Id);
+ if(firstChild_element){
+ firstChild_element.className += ' children_group'; //here is a div with a group of children.
+ }
+ }
+ console.log('firstChild_Id: ' + firstChild_Id);
+ console.log('divID: ' + divID);
+
if (defaultValue.length > 0){
if(defaultValue.includes(":")){
defaultValue = defaultValue.split(":")[0];
@@ -661,18 +704,20 @@ angular.module('abs').controller('dcaeMicroServiceController', ['$scope', '$wind
var labeltext = document.createTextNode(lableName);
label.appendChild(labeltext);
+
+ var subAttributes = $scope.dcaeModelData.sub_attributes;
if(labelManyKey){
var addButton = document.createElement("BUTTON");
var buttonLabel = document.createTextNode("+");
addButton.appendChild(buttonLabel);
- addButton.setAttribute("class", "btn btn-default");
+ addButton.setAttribute("class", "btn btn-add-remove");
addButton.setAttribute("ng-click" , 'addNewChoice("'+labelValue + lableName+'");');
addButton.setAttribute("ng-disabled" , "temp.policy.readOnly");
var removeButton = document.createElement("BUTTON");
var buttonremoveLabel = document.createTextNode("-");
removeButton.appendChild(buttonremoveLabel);
- removeButton.setAttribute("class", "btn btn-default");
+ removeButton.setAttribute("class", "btn btn-add-remove");
removeButton.setAttribute("ng-click" , 'removeChoice("'+labelValue +lableName+'");');
removeButton.setAttribute("ng-disabled" , "temp.policy.readOnly");
document.getElementById(divID).appendChild(addButton);
@@ -685,12 +730,16 @@ angular.module('abs').controller('dcaeMicroServiceController', ['$scope', '$wind
var divTag = document.createElement("div");
divTag.setAttribute("id", id +'@0');
+
+ divTag.className += ' children_group'; //here is div with a group of children.
+
document.getElementById(id).appendChild(divTag);
}else{
var divTag = document.createElement("div");
divTag.setAttribute("id", "div."+labelValue+lableName);
+ divTag.className += ' children_group'; //here is div with a group of children.
document.getElementById(divID).appendChild(label);
- document.getElementById(divID).appendChild(divTag);
+ document.getElementById(divID).appendChild(divTag);
}
};
@@ -801,7 +850,6 @@ angular.module('abs').controller('dcaeMicroServiceController', ['$scope', '$wind
if (elumentLocation > 1){
enumKey = keySplit[keySplit.length - 1];
}
- var aWhiteSpace = " ";
if (enumKeyList.indexOf(enumKey) != -1){
if (splitPlainAttributeKey[1].indexOf("true") !== -1){
var multiSlect = [];
@@ -810,19 +858,11 @@ angular.module('abs').controller('dcaeMicroServiceController', ['$scope', '$wind
}
jsonPolicy[key]= multiSlect;
}else{
- //set a space due to empty value caused JSON format error in PolicyRestAdapter and remove it in back-end.
- if(searchElement.value == ""){
- searchElement.value = aWhiteSpace;
- }
console.log(" searchElement.value = > " + searchElement.value);
jsonPolicy[key]= searchElement.value;
}
} else {
if(searchElement.value != null){
- //set a default value due to empty value caused JSON format error in PolicyRestAdapter
- if(searchElement.value == ""){
- searchElement.value = aWhiteSpace;
- }
console.log(" searchElement.value = > " + searchElement.value);
jsonPolicy[key]= searchElement.value;
}
diff --git a/POLICY-SDK-APP/src/main/webapp/app/policyApp/policy-models/Editor/PolicyTemplateController/DecisionPolicyController.js b/POLICY-SDK-APP/src/main/webapp/app/policyApp/policy-models/Editor/PolicyTemplateController/DecisionPolicyController.js
index 4b5a990ef..72b6f06ca 100644
--- a/POLICY-SDK-APP/src/main/webapp/app/policyApp/policy-models/Editor/PolicyTemplateController/DecisionPolicyController.js
+++ b/POLICY-SDK-APP/src/main/webapp/app/policyApp/policy-models/Editor/PolicyTemplateController/DecisionPolicyController.js
@@ -80,6 +80,26 @@ angular.module('abs').controller('decisionPolicyController', ['$scope', 'PolicyA
console.log("failed");
});
+ PolicyAppService.getData('getDictionary/get_RainyDayDictionaryDataByName').then(function (data) {
+ var j = data;
+ $scope.data = JSON.parse(j.data);
+ console.log($scope.data);
+ $scope.rainyDayDictionaryDatas = JSON.parse($scope.data.rainyDayDictionaryDatas);
+ console.log($scope.rainyDayDictionaryDatas);
+ }, function (error) {
+ console.log("failed");
+ });
+
+ PolicyAppService.getData('getDictionary/get_RainyDayDictionaryData').then(function (data) {
+ var j = data;
+ $scope.data = JSON.parse(j.data);
+ console.log($scope.data);
+ $scope.rainyDayDictionaryDataEntity = JSON.parse($scope.data.rainyDayDictionaryDatas);
+ console.log($scope.rainyDayDictionaryDatasEntity);
+ }, function (error) {
+ console.log("failed");
+ });
+
function extend(obj, src) {
for (var key in src) {
if (src.hasOwnProperty(key)) obj[key] = src[key];
@@ -166,6 +186,9 @@ angular.module('abs').controller('decisionPolicyController', ['$scope', 'PolicyA
if(!$scope.temp.policy.yamlparams){
$scope.temp.policy.yamlparams = {};
}
+ if(!$scope.temp.policy.yamlparams.targets){
+ $scope.temp.policy.yamlparams.targets = [];
+ }
if(!$scope.temp.policy.yamlparams.blackList){
$scope.temp.policy.yamlparams.blackList = [];
}
@@ -178,7 +201,7 @@ angular.module('abs').controller('decisionPolicyController', ['$scope', 'PolicyA
}else if($scope.temp.policy.ruleProvider=="Custom"){
if($scope.temp.policy.attributes.length == 0){
- $scope.temp.policy.attributes = [];
+ $scope.temp.policy.attributes = [];
}
if($scope.temp.policy.settings.length == 0){
$scope.temp.policy.settings = [];
@@ -190,6 +213,10 @@ angular.module('abs').controller('decisionPolicyController', ['$scope', 'PolicyA
if($scope.temp.policy.yamlparams.blackList.length==0){
$scope.temp.policy.yamlparams.blackList = [];
}
+ }else if($scope.temp.policy.ruleProvider=="GUARD_YAML"){
+ if($scope.temp.policy.yamlparams.targets.length==0){
+ $scope.temp.policy.yamlparams.targets = [];
+ }
}else if($scope.temp.policy.ruleProvider=="Rainy_Day"){
if($scope.temp.policy.rainyday.treatmentTableChoices == null || $scope.temp.policy.rainyday.treatmentTableChoices.length == 0){
$scope.temp.policy.rainyday.treatmentTableChoices = [];
@@ -215,6 +242,14 @@ angular.module('abs').controller('decisionPolicyController', ['$scope', 'PolicyA
$scope.temp.policy.settings.splice(lastItem);
};
+ $scope.addNewTarget = function(){
+ $scope.temp.policy.yamlparams.targets.push('');
+ };
+ $scope.removeTarget = function(){
+ var lastItem = $scope.temp.policy.yamlparams.targets.length-1;
+ $scope.temp.policy.yamlparams.targets.splice(lastItem);
+ };
+
$scope.addNewBL = function() {
$scope.temp.policy.yamlparams.blackList.push('');
};
@@ -232,6 +267,29 @@ angular.module('abs').controller('decisionPolicyController', ['$scope', 'PolicyA
$scope.temp.policy.rainyday.treatmentTableChoices.splice(lastItem);
};
+ $scope.workstepDictionaryDatas = [];
+ $scope.getWorkstepValues = function(bbidValue){
+ for (var i = 0; i < $scope.rainyDayDictionaryDataEntity.length; ++i) {
+ var obj = $scope.rainyDayDictionaryDataEntity[i];
+ if (obj.bbid == bbidValue){
+ $scope.workstepDictionaryDatas.push(obj.workstep);
+ }
+ }
+ };
+
+ $scope.allowedTreatmentsDatas = [];
+ $scope.getTreatmentValues = function(bbidValue, workstepValue){
+ for (var i = 0; i < $scope.rainyDayDictionaryDataEntity.length; ++i) {
+ var obj = $scope.rainyDayDictionaryDataEntity[i];
+ if (obj.bbid == bbidValue && obj.workstep == workstepValue){
+ var splitAlarm = obj.treatments.split(',');
+ for (var j = 0; j < splitAlarm.length; ++j) {
+ $scope.allowedTreatmentsDatas.push(splitAlarm[j]);
+ }
+ }
+ }
+ };
+
$scope.ItemNo = 0;
$scope.ruleAlgorithmDatas = [{"ruleAlgorithms" : $scope.temp.policy.ruleAlgorithmschoices }];
diff --git a/POLICY-SDK-APP/src/main/webapp/app/policyApp/policy-models/Editor/PolicyTemplates/DCAEMicroServicePolicyTemplate.html b/POLICY-SDK-APP/src/main/webapp/app/policyApp/policy-models/Editor/PolicyTemplates/DCAEMicroServicePolicyTemplate.html
index a12300b97..f621f2cba 100644
--- a/POLICY-SDK-APP/src/main/webapp/app/policyApp/policy-models/Editor/PolicyTemplates/DCAEMicroServicePolicyTemplate.html
+++ b/POLICY-SDK-APP/src/main/webapp/app/policyApp/policy-models/Editor/PolicyTemplates/DCAEMicroServicePolicyTemplate.html
@@ -83,7 +83,7 @@
</div>
</div>
<div class="well">
- <div class="form-group col-sm-3" id="DynamicTemplate">
+ <div class="form-group col-sm-12" id="DynamicTemplate">
<label>Micro Service Attributes:<sup><b>*</b></sup></label><br>
</div>
</br>
diff --git a/POLICY-SDK-APP/src/main/webapp/app/policyApp/policy-models/Editor/PolicyTemplates/DecisionPolicyTemplate.html b/POLICY-SDK-APP/src/main/webapp/app/policyApp/policy-models/Editor/PolicyTemplates/DecisionPolicyTemplate.html
index 49fc70df4..973a7afc2 100644
--- a/POLICY-SDK-APP/src/main/webapp/app/policyApp/policy-models/Editor/PolicyTemplates/DecisionPolicyTemplate.html
+++ b/POLICY-SDK-APP/src/main/webapp/app/policyApp/policy-models/Editor/PolicyTemplates/DecisionPolicyTemplate.html
@@ -62,17 +62,25 @@
<label>Building Block ID:<sup><b>*</b></sup></label>
</div>
<div class="form-group col-sm-2">
- <input type="text" class="form-control"
- ng-disabled="temp.policy.readOnly" ng-model="temp.policy.rainyday.bbid"
- placeholder="Building Block ID" />
+ <select
+ class="form-control" ng-disabled="temp.policy.readOnly"
+ ng-model="temp.policy.rainyday.bbid"
+ ng-options="option for option in rainyDayDictionaryDatas track by option"
+ ng-change="getWorkstepValues(temp.policy.rainyday.bbid)">
+ <option value="">{{temp.policy.rainyday.bbid}}</option>
+ </select>
</div>
<div class="form-group col-sm-1">
<label>Work Step:<sup><b>*</b></sup></label>
</div>
<div class="form-group col-sm-2">
- <input type="text" class="form-control"
- ng-disabled="temp.policy.readOnly" ng-model="temp.policy.rainyday.workstep"
- placeholder="Work Step" />
+ <select
+ class="form-control" ng-disabled="temp.policy.readOnly"
+ ng-model="temp.policy.rainyday.workstep"
+ ng-options="option for option in workstepDictionaryDatas track by option"
+ ng-change="getTreatmentValues(temp.policy.rainyday.bbid, temp.policy.rainyday.workstep)">
+ <option value="">{{temp.policy.rainyday.workstep}}</option>
+ </select>
</div>
</div>
<div class="form-group row">
@@ -100,19 +108,14 @@
<div class="form-group col-sm-1">
<label>Desired Treatment:<sup><b>*</b></sup></label>
</div>
- <div class="form-group col-sm-3">
- <select class="form-control" id="mySelect"
+ <div class="form-group col-sm-3">
+ <select
+ class="form-control"
ng-disabled="temp.policy.readOnly"
ng-model="treatmentTableChoice.treatment"
- placeholder="Desired Treatment">
-<!-- <option value="">{{tableChoice.desiredtreatment}}</option> -->
- <option>Rollback</option>
- <option>Manual Handling</option>
- <option>Abort</option>
- <option>Auto Rollback</option>
- <option>Retry</option>
- <option>Skip</option>
- </select>
+ ng-options="option for option in allowedTreatmentsDatas track by option">
+ <option value="">{{treatmentTableChoice.treatment}}</option>
+ </select>
</div>
<div class="form-group col-sm-1">
<button type="button" class="btn btn-default"
@@ -131,7 +134,7 @@
<div class="well">
<div class="form-group row">
<div class="form-group col-sm-1">
- <label>Guard YAML Attributes:</label><br>
+ <label>Guard BlackList YAML Attributes:</label><br>
</div>
</div>
<div class="form-group row">
@@ -157,6 +160,16 @@
</div>
<div class="form-group row" style="margin-left: 2%">
<div class="form-group col-sm-3">
+ <label> CLName: </label>
+ </div>
+ <div class="form-group col-sm-3">
+ <input type="text" class="form-control"
+ ng-disabled="temp.policy.readOnly" ng-model="temp.policy.yamlparams.clname"
+ placeholder="CLName" />
+ </div>
+ </div>
+ <div class="form-group row" style="margin-left: 2%">
+ <div class="form-group col-sm-3">
<label> guardActiveStart: </label>
</div>
<div class="form-group col-sm-3">
@@ -235,6 +248,42 @@
</div>
<div class="form-group row" style="margin-left: 2%">
<div class="form-group col-sm-3">
+ <label> CLName: </label>
+ </div>
+ <div class="form-group col-sm-3">
+ <input type="text" class="form-control"
+ ng-disabled="temp.policy.readOnly" ng-model="temp.policy.yamlparams.clname"
+ placeholder="CLName" />
+ </div>
+ </div>
+ <div class="form-group row" style="margin-left: 2%">
+ <div class="form-group col-sm-3">
+ <label> Targets: </label>
+ <button type="button" class="btn btn-default"
+ ng-disabled="temp.policy.readOnly" ng-click="addNewTarget()">
+ <i class="fa fa-plus"></i>
+ </button>
+ </div>
+ <div class="form-group col-sm-4">
+ <div data-ng-repeat="choice in temp.policy.yamlparams.targets track by $index">
+ <div class="form-group row">
+ <div class="form-group col-sm-9">
+ <input type="text" class="form-control"
+ ng-disabled="temp.policy.readOnly"
+ ng-model="temp.policy.yamlparams.targets[$index]" placeholder="Target" />
+ </div>
+ <div class="form-group col-sm-1">
+ <button type="button" class="btn btn-default" ng-show="$last"
+ ng-disabled="temp.policy.readOnly" ng-click="removeTarget()">
+ <i class="fa fa-minus"></i>
+ </button>
+ </div>
+ </div>
+ </div>
+ </div>
+ </div>
+ <div class="form-group row" style="margin-left: 2%">
+ <div class="form-group col-sm-3">
<label> limit: </label>
</div>
<div class="form-group col-sm-3">
@@ -247,18 +296,20 @@
<div class="form-group col-sm-3">
<label> timeWindow: </label>
</div>
- <div class="form-group col-sm-3">
+ <div class="form-group col-sm-2">
+ <input type="text" class="form-control"
+ ng-disabled="temp.policy.readOnly" ng-model="temp.policy.yamlparams.timeWindow"
+ placeholder="Time Window" />
+ </div>
+ <div class="form-group col-sm-1">
<select class="form-control" ng-disabled="temp.policy.readOnly"
- ng-model="temp.policy.yamlparams.timeWindow">
- <option>tw5min</option>
- <option>tw10min</option>
- <option>tw30min</option>
- <option>tw1h</option>
- <option>tw12h</option>
- <option>tw1d</option>
- <option>tw5d</option>
- <option>tw1w</option>
- <option>tw1mon</option>
+ ng-model="temp.policy.yamlparams.timeUnits">
+ <option>minute</option>
+ <option>hour</option>
+ <option>day</option>
+ <option>week</option>
+ <option>month</option>
+ <option>year</option>
</select>
</div>
</div>
diff --git a/POLICY-SDK-APP/src/main/webapp/app/policyApp/policy-models/Editor/css/main.css b/POLICY-SDK-APP/src/main/webapp/app/policyApp/policy-models/Editor/css/main.css
index 78001f400..1122b6f1b 100644
--- a/POLICY-SDK-APP/src/main/webapp/app/policyApp/policy-models/Editor/css/main.css
+++ b/POLICY-SDK-APP/src/main/webapp/app/policyApp/policy-models/Editor/css/main.css
@@ -58,11 +58,47 @@ body {
margin-top: -5px;
}
+.btn.btn-pedefault {
+ color: #444;
+ background-color: #FAFAFA;
+}
+
.btn.btn-default {
color: #444;
background-color: #FAFAFA;
}
+.btn-add-remove {
+ color: #444;
+ background-color: #FAFAFA;
+ margin-right: 12px;
+ margin-bottom: 10px;
+}
+
+.child_single {
+ color: #444;
+ background-color: #FAFAFA;
+ margin-left: 0px;
+ margin-bottom: 10px;
+ border: 1px solid #ccc;
+ border-radius: 4px;
+}
+
+.children_group {
+ color: #444;
+ background-color: white;
+ margin-left: 20px;
+ margin-bottom: 20px;
+ margin-top: 20px;
+ margin-right: 20px;
+ padding-top: 10px;
+ padding-left: 10px;
+ padding-right: 20px;
+ padding-bottom: 10px;
+ border: 1px solid #ccc;
+ border-radius: 4px;
+}
+
.btn {
box-shadow: 0 2px 5px 0 rgba(0, 0, 0, .26);
font-weight: 500;
diff --git a/POLICY-SDK-APP/src/main/webapp/app/policyApp/policy-models/Editor/templates/modals.html b/POLICY-SDK-APP/src/main/webapp/app/policyApp/policy-models/Editor/templates/modals.html
index 754f95bb5..f7a6d2442 100644
--- a/POLICY-SDK-APP/src/main/webapp/app/policyApp/policy-models/Editor/templates/modals.html
+++ b/POLICY-SDK-APP/src/main/webapp/app/policyApp/policy-models/Editor/templates/modals.html
@@ -13,7 +13,7 @@
<div ng-include data-src="'error-bar'" class="clearfix"></div>
</div>
<div class="modal-footer">
- <button type="button" class="btn btn-default" data-dismiss="modal" ng-click="refresh();" ng-disabled="temp.inprocess">Cancel</button>
+ <button type="button" class="btn btn-pedefault" data-dismiss="modal" ng-click="refresh();" ng-disabled="temp.inprocess">Cancel</button>
<button type="submit" class="btn btn-primary" ng-disabled="temp.inprocess" autofocus="autofocus">Delete</button>
</div>
</form>
@@ -42,7 +42,7 @@
<div ng-include data-src="'error-bar'" class="clearfix"></div>
</div>
<div class="modal-footer">
- <button type="button" class="btn btn-default" data-dismiss="modal" ng-click="refresh();" ng-disabled="temp.inprocess">Cancel</button>
+ <button type="button" class="btn btn-pedefault" data-dismiss="modal" ng-click="refresh();" ng-disabled="temp.inprocess">Cancel</button>
<button type="submit" class="btn btn-primary" ng-disabled="temp.inprocess" autofocus="autofocus">Delete</button>
</div>
</form>
@@ -67,7 +67,7 @@
<div ng-include data-src="'error-bar'" class="clearfix"></div>
</div>
<div class="modal-footer">
- <button type="button" class="btn btn-default" data-dismiss="modal" ng-click="refresh();" ng-disabled="temp.inprocess">Cancel</button>
+ <button type="button" class="btn btn-pedefault" data-dismiss="modal" ng-click="refresh();" ng-disabled="temp.inprocess">Cancel</button>
<button type="submit" class="btn btn-primary" ng-disabled="temp.inprocess">Rename</button>
</div>
</form>
@@ -89,7 +89,7 @@
<div ng-include data-src="'error-bar'" class="clearfix"></div>
</div>
<div class="modal-footer">
- <button type="button" class="btn btn-default" data-dismiss="modal" ng-disabled="temp.inprocess">Cancel</button>
+ <button type="button" class="btn btn-pedefault" data-dismiss="modal" ng-disabled="temp.inprocess">Cancel</button>
</div>
</form>
</div>
@@ -111,7 +111,7 @@
<div ng-include data-src="'error-bar'" class="clearfix"></div>
</div>
<div class="modal-footer">
- <button type="button" class="btn btn-default" data-dismiss="modal" ng-click="refresh();" ng-disabled="temp.inprocess">Cancel</button>
+ <button type="button" class="btn btn-pedefault" data-dismiss="modal" ng-click="refresh();" ng-disabled="temp.inprocess">Cancel</button>
<button type="submit" class="btn btn-primary" ng-disabled="temp.inprocess">Move</button>
</div>
</form>
@@ -139,7 +139,7 @@
<div ng-include data-src="'error-bar'" class="clearfix"></div>
</div>
<div class="modal-footer">
- <button type="button" class="btn btn-default" data-dismiss="modal" ng-disabled="temp.inprocess">Cancel</button>
+ <button type="button" class="btn btn-pedefault" data-dismiss="modal" ng-disabled="temp.inprocess">Cancel</button>
<button type="submit" class="btn btn-primary" ng-disabled="temp.inprocess">Save</button>
</div>
</form>
@@ -165,7 +165,7 @@
<div ng-include data-src="'error-bar'" class="clearfix"></div>
</div>
<div class="modal-footer">
- <button type="button" class="btn btn-default" data-dismiss="modal" ng-disabled="temp.inprocess">Cancel</button>
+ <button type="button" class="btn btn-pedefault" data-dismiss="modal" ng-disabled="temp.inprocess">Cancel</button>
<button type="submit" class="btn btn-primary" ng-disabled="temp.inprocess">Clone</button>
</div>
</form>
@@ -189,7 +189,7 @@
<div ng-include data-src="'error-bar'" class="clearfix"></div>
</div>
<div class="modal-footer">
- <button id = "cancel" type="button" class="btn btn-default" data-dismiss="modal" ng-disabled="temp.inprocess">Cancel</button>
+ <button id = "cancel" type="button" class="btn btn-pedefault" data-dismiss="modal" ng-disabled="temp.inprocess">Cancel</button>
<button type="submit" class="btn btn-primary" ng-disabled="temp.inprocess">Create</button>
</div>
</form>
@@ -213,7 +213,7 @@
<div ng-include data-src="'error-bar'" class="clearfix"></div>
</div>
<div class="modal-footer">
- <button type="button" class="btn btn-default" data-dismiss="modal" ng-disabled="temp.inprocess">Cancel</button>
+ <button type="button" class="btn btn-pedefault" data-dismiss="modal" ng-disabled="temp.inprocess">Cancel</button>
<button type="submit" class="btn btn-primary" ng-disabled="temp.inprocess">Create</button>
</div>
</form>
@@ -238,7 +238,7 @@
</div>
<div class="modal-footer">
<div ng-show="!fileUploader.requesting">
- <button type="button" class="btn btn-default" data-dismiss="modal">Cancel</button>
+ <button type="button" class="btn btn-pedefault" data-dismiss="modal">Cancel</button>
<button type="submit" class="btn btn-primary" ng-disabled="!uploadFileList.length || fileUploader.requesting">{{'upload' | translate}}</button>
</div>
<div ng-show="fileUploader.requesting">
@@ -266,7 +266,7 @@
</div>
</div>
<div class="modal-footer">
- <button type="button" class="btn btn-default" data-dismiss="modal" ng-disabled="temp.inprocess">Close</button>
+ <button type="button" class="btn btn-pedefault" data-dismiss="modal" ng-disabled="temp.inprocess">Close</button>
</div>
</div>
</div>
diff --git a/POLICY-SDK-APP/src/main/webapp/app/policyApp/policy-models/Editor/templates/searchNavbar.html b/POLICY-SDK-APP/src/main/webapp/app/policyApp/policy-models/Editor/templates/searchNavbar.html
index 72985a190..768fe5e19 100644
--- a/POLICY-SDK-APP/src/main/webapp/app/policyApp/policy-models/Editor/templates/searchNavbar.html
+++ b/POLICY-SDK-APP/src/main/webapp/app/policyApp/policy-models/Editor/templates/searchNavbar.html
@@ -62,7 +62,7 @@ body {
<div class="input-group-btn">
<div class="btn-group" role="group">
<div class="dropdown dropdown-lg">
- <button type="button" class="btn btn-default dropdown-toggle"
+ <button type="button" class="btn btn-pedefault dropdown-toggle"
data-toggle="dropdown" aria-expanded="false">
<span class="caret"></span>
</button>
@@ -166,7 +166,7 @@ body {
</form>
</div>
</div>
- <button type="button" class="btn btn-default"
+ <button type="button" class="btn btn-pedefault"
ng-click="refresh(search = null);">
<span aria-hidden="true">Clear</span>
</button>
diff --git a/POLICY-SDK-APP/src/test/java/org/openecomp/policy/admin/PolicyManagerServletTest.java b/POLICY-SDK-APP/src/test/java/org/openecomp/policy/admin/PolicyManagerServletTest.java
index 773955d85..a25027679 100644
--- a/POLICY-SDK-APP/src/test/java/org/openecomp/policy/admin/PolicyManagerServletTest.java
+++ b/POLICY-SDK-APP/src/test/java/org/openecomp/policy/admin/PolicyManagerServletTest.java
@@ -19,11 +19,16 @@
*/
package org.openecomp.policy.admin;
+import static org.junit.Assert.fail;
+
import java.io.BufferedReader;
+import java.io.File;
import java.io.StringReader;
import java.util.ArrayList;
+import java.util.Collections;
import java.util.List;
+import javax.servlet.ServletConfig;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
@@ -33,8 +38,13 @@ import org.junit.Test;
import org.mockito.Mockito;
import org.openecomp.policy.common.logging.flexlogger.FlexLogger;
import org.openecomp.policy.common.logging.flexlogger.Logger;
+import org.openecomp.policy.controller.CreateDcaeMicroServiceController;
import org.openecomp.policy.controller.PolicyController;
import org.openecomp.policy.model.Roles;
+import org.openecomp.policy.rest.dao.CommonClassDao;
+import org.openecomp.policy.rest.jpa.ActionBodyEntity;
+import org.openecomp.policy.rest.jpa.ConfigurationDataEntity;
+import org.openecomp.policy.rest.jpa.GroupPolicyScopeList;
import org.openecomp.policy.rest.jpa.PolicyEditorScopes;
import org.openecomp.policy.rest.jpa.PolicyEntity;
import org.openecomp.policy.rest.jpa.PolicyVersion;
@@ -43,11 +53,13 @@ import org.openecomp.policy.rest.jpa.UserInfo;
public class PolicyManagerServletTest extends Mockito{
private static Logger logger = FlexLogger.getLogger(PolicyManagerServletTest.class);
+ private List<String> headers = new ArrayList<String>();
private static List<Object> rolesdata;
- private static List<Object> policyData;
+ private static List<Object> basePolicyData;
private static List<Object> policyEditorScopes;
private static List<Object> policyVersion;
+ private static CommonClassDao commonClassDao;
@Before
public void setUp() throws Exception{
@@ -68,7 +80,7 @@ public class PolicyManagerServletTest extends Mockito{
rolesdata.add(roles1);
//PolicyEntity Data
- policyData = new ArrayList<>();
+ basePolicyData = new ArrayList<>();
String policyContent = "";
try {
ClassLoader classLoader = getClass().getClassLoader();
@@ -80,7 +92,13 @@ public class PolicyManagerServletTest extends Mockito{
entity.setPolicyName("Config_SampleTest.1.xml");
entity.setPolicyData(policyContent);
entity.setScope("com");
- policyData.add(entity);
+ ConfigurationDataEntity configurationEntity = new ConfigurationDataEntity();
+ configurationEntity.setConfigBody("Sample Test");
+ configurationEntity.setConfigType("OTHER");
+ configurationEntity.setConfigurationName("com.Config_SampleTest1206.1.txt");
+ configurationEntity.setDescription("test");
+ entity.setConfigurationData(configurationEntity);
+ basePolicyData.add(entity);
//PolicyEditorScopes data
policyEditorScopes = new ArrayList<>();
@@ -107,6 +125,21 @@ public class PolicyManagerServletTest extends Mockito{
}
@Test
+ public void testInit(){
+ PolicyManagerServlet servlet = new PolicyManagerServlet();
+ ServletConfig servletConfig = mock(ServletConfig.class);
+ try {
+ when(servletConfig.getInitParameterNames()).thenReturn(Collections.enumeration(headers));
+ when(servletConfig.getInitParameter("XACML_PROPERTIES_NAME")).thenReturn("xacml.admin.properties");
+ System.setProperty("xacml.rest.admin.closedLoopJSON", new File(".").getCanonicalPath() + File.separator + "src"+ File.separator + "test" + File.separator + "resources" + File.separator + "JSONConfig.json");
+ servlet.init(servletConfig);
+ } catch (Exception e1) {
+ logger.error("Exception Occured"+e1);
+ fail();
+ }
+ }
+
+ @Test
public void testDescribePolicy(){
PolicyManagerServlet servlet = new PolicyManagerServlet();
HttpServletRequest request = mock(HttpServletRequest.class);
@@ -116,11 +149,12 @@ public class PolicyManagerServletTest extends Mockito{
BufferedReader reader = new BufferedReader(new StringReader("{params: { mode: 'DESCRIBEPOLICYFILE', path: 'com.Config_SampleTest1206.1.xml'}}"));
try {
when(request.getReader()).thenReturn(reader);
- when(controller.getDataByQuery("FROM PolicyEntity where policyName = 'Config_SampleTest1206.1.xml' and scope ='com'")).thenReturn(policyData);
+ when(controller.getDataByQuery("FROM PolicyEntity where policyName = 'Config_SampleTest1206.1.xml' and scope ='com'")).thenReturn(basePolicyData);
servlet.setPolicyController(controller);
servlet.doPost(request, response);
} catch (Exception e1) {
logger.error("Exception Occured"+e1);
+ fail();
}
}
@@ -147,9 +181,390 @@ public class PolicyManagerServletTest extends Mockito{
servlet.doPost(request, response);
} catch (Exception e1) {
logger.error("Exception Occured"+e1);
+ fail();
+ }
+ }
+ }
+
+ @Test
+ public void editBasePolicyTest(){
+ PolicyManagerServlet servlet = new PolicyManagerServlet();
+ HttpServletRequest request = mock(HttpServletRequest.class);
+ HttpServletResponse response = mock(HttpServletResponse.class);
+ PolicyController controller = mock(PolicyController.class);
+ List<String> list = new ArrayList<>();
+ list.add("{params: { mode: 'EDITFILE', path: '/com/Config_SampleTest1206.1.xml', onlyFolders: false}}");
+ for(int i =0; i < list.size(); i++){
+ BufferedReader reader = new BufferedReader(new StringReader(list.get(i)));
+ try {
+ when(request.getReader()).thenReturn(reader);
+ when(controller.getRoles("Test")).thenReturn(rolesdata);
+ when(controller.getDataByQuery("FROM PolicyEntity where policyName = 'Config_SampleTest1206.1.xml' and scope ='com'")).thenReturn(basePolicyData);
+ servlet.setPolicyController(controller);
+ servlet.setTestUserId("Test");
+ servlet.doPost(request, response);
+ } catch (Exception e1) {
+ logger.error("Exception Occured"+e1);
+ fail();
}
}
}
+ @Test
+ public void editBRMSParamPolicyTest(){
+ List<Object> policyData = new ArrayList<>();
+ String policyContent = "";
+ String configData = "";
+ try {
+ ClassLoader classLoader = getClass().getClassLoader();
+ policyContent = IOUtils.toString(classLoader.getResourceAsStream("Config_BRMS_Param_BRMSParamvFWDemoPolicy.1.xml"));
+ configData = IOUtils.toString(classLoader.getResourceAsStream("com.Config_BRMS_Param_BRMSParamvFWDemoPolicy.1.txt"));
+ } catch (Exception e1) {
+ logger.error("Exception Occured"+e1);
+ }
+ PolicyEntity entity = new PolicyEntity();
+ entity.setPolicyName("Config_BRMS_Param_BRMSParamvFWDemoPolicy.1.xml");
+ entity.setPolicyData(policyContent);
+ entity.setScope("com");
+ ConfigurationDataEntity configurationEntity = new ConfigurationDataEntity();
+ configurationEntity.setConfigBody(configData);
+ configurationEntity.setConfigType("OTHER");
+ configurationEntity.setConfigurationName("com.Config_BRMS_Param_BRMSParamvFWDemoPolicy.1.txt");
+ configurationEntity.setDescription("test");
+ entity.setConfigurationData(configurationEntity);
+ policyData.add(entity);
+ PolicyManagerServlet servlet = new PolicyManagerServlet();
+ HttpServletRequest request = mock(HttpServletRequest.class);
+ HttpServletResponse response = mock(HttpServletResponse.class);
+ PolicyController controller = mock(PolicyController.class);
+ List<String> list = new ArrayList<>();
+ list.add("{params: { mode: 'EDITFILE', path: '/com/Config_BRMS_Param_BRMSParamvFWDemoPolicy.1.xml', onlyFolders: false}}");
+ for(int i =0; i < list.size(); i++){
+ BufferedReader reader = new BufferedReader(new StringReader(list.get(i)));
+ try {
+ when(request.getReader()).thenReturn(reader);
+ when(controller.getRoles("Test")).thenReturn(rolesdata);
+ when(controller.getDataByQuery("FROM PolicyEntity where policyName = 'Config_BRMS_Param_BRMSParamvFWDemoPolicy.1.xml' and scope ='com'")).thenReturn(policyData);
+ servlet.setPolicyController(controller);
+ servlet.setTestUserId("Test");
+ servlet.doPost(request, response);
+ } catch (Exception e1) {
+ logger.error("Exception Occured"+e1);
+ fail();
+ }
+ }
+ }
+ @Test
+ public void editBRMSRawPolicyTest(){
+ List<Object> policyData = new ArrayList<>();
+ String policyContent = "";
+ String configData = "";
+ try {
+ ClassLoader classLoader = getClass().getClassLoader();
+ policyContent = IOUtils.toString(classLoader.getResourceAsStream("Config_BRMS_Raw_TestBRMSRawPolicy.1.xml"));
+ configData = IOUtils.toString(classLoader.getResourceAsStream("com.Config_BRMS_Raw_TestBRMSRawPolicy.1.txt"));
+ } catch (Exception e1) {
+ logger.error("Exception Occured"+e1);
+ }
+ PolicyEntity entity = new PolicyEntity();
+ entity.setPolicyName("Config_BRMS_Raw_TestBRMSRawPolicy.1.xml");
+ entity.setPolicyData(policyContent);
+ entity.setScope("com");
+ ConfigurationDataEntity configurationEntity = new ConfigurationDataEntity();
+ configurationEntity.setConfigBody(configData);
+ configurationEntity.setConfigType("OTHER");
+ configurationEntity.setConfigurationName("com.Config_BRMS_Raw_TestBRMSRawPolicy.1.txt");
+ configurationEntity.setDescription("test");
+ entity.setConfigurationData(configurationEntity);
+ policyData.add(entity);
+ PolicyManagerServlet servlet = new PolicyManagerServlet();
+ HttpServletRequest request = mock(HttpServletRequest.class);
+ HttpServletResponse response = mock(HttpServletResponse.class);
+ PolicyController controller = mock(PolicyController.class);
+ List<String> list = new ArrayList<>();
+ list.add("{params: { mode: 'EDITFILE', path: '/com/Config_BRMS_Raw_TestBRMSRawPolicy.1.xml', onlyFolders: false}}");
+ for(int i =0; i < list.size(); i++){
+ BufferedReader reader = new BufferedReader(new StringReader(list.get(i)));
+ try {
+ when(request.getReader()).thenReturn(reader);
+ when(controller.getRoles("Test")).thenReturn(rolesdata);
+ when(controller.getDataByQuery("FROM PolicyEntity where policyName = 'Config_BRMS_Raw_TestBRMSRawPolicy.1.xml' and scope ='com'")).thenReturn(policyData);
+ servlet.setPolicyController(controller);
+ servlet.setTestUserId("Test");
+ servlet.doPost(request, response);
+ } catch (Exception e1) {
+ logger.error("Exception Occured"+e1);
+ fail();
+ }
+ }
+ }
+
+ @Test
+ public void editClosedLoopFaultPolicyTest(){
+ List<Object> policyData = new ArrayList<>();
+ String policyContent = "";
+ String configData = "";
+ try {
+ ClassLoader classLoader = getClass().getClassLoader();
+ policyContent = IOUtils.toString(classLoader.getResourceAsStream("Config_Fault_TestClosedLoopPolicy.1.xml"));
+ configData = IOUtils.toString(classLoader.getResourceAsStream("com.Config_Fault_TestClosedLoopPolicy.1.json"));
+ } catch (Exception e1) {
+ logger.error("Exception Occured"+e1);
+ }
+ PolicyEntity entity = new PolicyEntity();
+ entity.setPolicyName("Config_Fault_TestClosedLoopPolicy.1.xml");
+ entity.setPolicyData(policyContent);
+ entity.setScope("com");
+ ConfigurationDataEntity configurationEntity = new ConfigurationDataEntity();
+ configurationEntity.setConfigBody(configData);
+ configurationEntity.setConfigType("JSON");
+ configurationEntity.setConfigurationName("com.Config_Fault_TestClosedLoopPolicy.1.json");
+ configurationEntity.setDescription("test");
+ entity.setConfigurationData(configurationEntity);
+ policyData.add(entity);
+ PolicyManagerServlet servlet = new PolicyManagerServlet();
+ HttpServletRequest request = mock(HttpServletRequest.class);
+ HttpServletResponse response = mock(HttpServletResponse.class);
+ PolicyController controller = mock(PolicyController.class);
+ List<String> list = new ArrayList<>();
+ list.add("{params: { mode: 'EDITFILE', path: '/com/Config_Fault_TestClosedLoopPolicy.1.xml', onlyFolders: false}}");
+ for(int i =0; i < list.size(); i++){
+ BufferedReader reader = new BufferedReader(new StringReader(list.get(i)));
+ try {
+ when(request.getReader()).thenReturn(reader);
+ when(controller.getRoles("Test")).thenReturn(rolesdata);
+ when(controller.getDataByQuery("FROM PolicyEntity where policyName = 'Config_Fault_TestClosedLoopPolicy.1.xml' and scope ='com'")).thenReturn(policyData);
+ servlet.setPolicyController(controller);
+ servlet.setTestUserId("Test");
+ servlet.doPost(request, response);
+ } catch (Exception e1) {
+ logger.error("Exception Occured"+e1);
+ fail();
+ }
+ }
+ }
+
+ @Test
+ public void editClosedLoopPMPolicyTest(){
+ List<Object> policyData = new ArrayList<>();
+ String policyContent = "";
+ String configData = "";
+ try {
+ ClassLoader classLoader = getClass().getClassLoader();
+ policyContent = IOUtils.toString(classLoader.getResourceAsStream("Config_PM_TestClosedLoopPMPolicy.1.xml"));
+ configData = IOUtils.toString(classLoader.getResourceAsStream("com.Config_PM_TestClosedLoopPMPolicy.1.json"));
+ } catch (Exception e1) {
+ logger.error("Exception Occured"+e1);
+ }
+ PolicyEntity entity = new PolicyEntity();
+ entity.setPolicyName("Config_PM_TestClosedLoopPMPolicy.1.xml");
+ entity.setPolicyData(policyContent);
+ entity.setScope("com");
+ ConfigurationDataEntity configurationEntity = new ConfigurationDataEntity();
+ configurationEntity.setConfigBody(configData);
+ configurationEntity.setConfigType("JSON");
+ configurationEntity.setConfigurationName("com.Config_PM_TestClosedLoopPMPolicy.1.json");
+ configurationEntity.setDescription("test");
+ entity.setConfigurationData(configurationEntity);
+ policyData.add(entity);
+ PolicyManagerServlet servlet = new PolicyManagerServlet();
+ HttpServletRequest request = mock(HttpServletRequest.class);
+ HttpServletResponse response = mock(HttpServletResponse.class);
+ PolicyController controller = mock(PolicyController.class);
+ List<String> list = new ArrayList<>();
+ list.add("{params: { mode: 'EDITFILE', path: '/com/Config_PM_TestClosedLoopPMPolicy.1.xml', onlyFolders: false}}");
+ for(int i =0; i < list.size(); i++){
+ BufferedReader reader = new BufferedReader(new StringReader(list.get(i)));
+ try {
+ when(request.getReader()).thenReturn(reader);
+ when(controller.getRoles("Test")).thenReturn(rolesdata);
+ when(controller.getDataByQuery("FROM PolicyEntity where policyName = 'Config_PM_TestClosedLoopPMPolicy.1.xml' and scope ='com'")).thenReturn(policyData);
+ servlet.setPolicyController(controller);
+ servlet.setTestUserId("Test");
+ servlet.doPost(request, response);
+ } catch (Exception e1) {
+ logger.error("Exception Occured"+e1);
+ fail();
+ }
+ }
+ }
+
+ @Test
+ public void editMicroServicePolicyTest(){
+ GroupPolicyScopeList groupData = new GroupPolicyScopeList();
+ groupData.setGroupName("Test");
+ groupData.setGroupList("resource=SampleResource,service=SampleService,type=SampleType,closedLoopControlName=SampleClosedLoop");
+ List<Object> groupListData = new ArrayList<>();
+ groupListData.add(groupData);
+ commonClassDao = mock(CommonClassDao.class);
+ CreateDcaeMicroServiceController.setCommonClassDao(commonClassDao);
+ List<Object> policyData = new ArrayList<>();
+ String policyContent = "";
+ String configData = "";
+ try {
+ ClassLoader classLoader = getClass().getClassLoader();
+ policyContent = IOUtils.toString(classLoader.getResourceAsStream("Config_MS_vFirewall.1.xml"));
+ configData = IOUtils.toString(classLoader.getResourceAsStream("com.Config_MS_vFirewall.1.json"));
+ } catch (Exception e1) {
+ logger.error("Exception Occured"+e1);
+ }
+ PolicyEntity entity = new PolicyEntity();
+ entity.setPolicyName("Config_MS_vFirewall.1.xml");
+ entity.setPolicyData(policyContent);
+ entity.setScope("com");
+ ConfigurationDataEntity configurationEntity = new ConfigurationDataEntity();
+ configurationEntity.setConfigBody(configData);
+ configurationEntity.setConfigType("JSON");
+ configurationEntity.setConfigurationName("com.Config_MS_vFirewall.1.json");
+ configurationEntity.setDescription("test");
+ entity.setConfigurationData(configurationEntity);
+ policyData.add(entity);
+ PolicyManagerServlet servlet = new PolicyManagerServlet();
+ HttpServletRequest request = mock(HttpServletRequest.class);
+ HttpServletResponse response = mock(HttpServletResponse.class);
+ PolicyController controller = mock(PolicyController.class);
+ List<String> list = new ArrayList<>();
+ list.add("{params: { mode: 'EDITFILE', path: '/com/Config_MS_vFirewall.1.xml', onlyFolders: false}}");
+ for(int i =0; i < list.size(); i++){
+ BufferedReader reader = new BufferedReader(new StringReader(list.get(i)));
+ try {
+ when(request.getReader()).thenReturn(reader);
+ when(commonClassDao.getDataById(GroupPolicyScopeList.class, "groupList", "resource=SampleResource,service=SampleService,type=SampleType,closedLoopControlName=SampleClosedLoop")).thenReturn(groupListData);
+ when(controller.getRoles("Test")).thenReturn(rolesdata);
+ when(controller.getDataByQuery("FROM PolicyEntity where policyName = 'Config_MS_vFirewall.1.xml' and scope ='com'")).thenReturn(policyData);
+ servlet.setPolicyController(controller);
+ servlet.setTestUserId("Test");
+ servlet.doPost(request, response);
+ } catch (Exception e1) {
+ logger.error("Exception Occured"+e1);
+ fail();
+ }
+ }
+ }
+
+ @Test
+ public void editFirewallPolicyTest(){
+ List<Object> policyData = new ArrayList<>();
+ String policyContent = "";
+ String configData = "";
+ try {
+ ClassLoader classLoader = getClass().getClassLoader();
+ policyContent = IOUtils.toString(classLoader.getResourceAsStream("Config_FW_TestFireWallPolicy.1.xml"));
+ configData = IOUtils.toString(classLoader.getResourceAsStream("com.Config_FW_TestFireWallPolicy.1.json"));
+ } catch (Exception e1) {
+ logger.error("Exception Occured"+e1);
+ }
+ PolicyEntity entity = new PolicyEntity();
+ entity.setPolicyName("Config_FW_TestFireWallPolicy.1.xml");
+ entity.setPolicyData(policyContent);
+ entity.setScope("com");
+ ConfigurationDataEntity configurationEntity = new ConfigurationDataEntity();
+ configurationEntity.setConfigBody(configData);
+ configurationEntity.setConfigType("JSON");
+ configurationEntity.setConfigurationName("com.Config_FW_TestFireWallPolicy.1.json");
+ configurationEntity.setDescription("test");
+ entity.setConfigurationData(configurationEntity);
+ policyData.add(entity);
+ PolicyManagerServlet servlet = new PolicyManagerServlet();
+ HttpServletRequest request = mock(HttpServletRequest.class);
+ HttpServletResponse response = mock(HttpServletResponse.class);
+ PolicyController controller = mock(PolicyController.class);
+ List<String> list = new ArrayList<>();
+ list.add("{params: { mode: 'EDITFILE', path: '/com/Config_FW_TestFireWallPolicy.1.xml', onlyFolders: false}}");
+ for(int i =0; i < list.size(); i++){
+ BufferedReader reader = new BufferedReader(new StringReader(list.get(i)));
+ try {
+ when(request.getReader()).thenReturn(reader);
+ when(controller.getRoles("Test")).thenReturn(rolesdata);
+ when(controller.getDataByQuery("FROM PolicyEntity where policyName = 'Config_FW_TestFireWallPolicy.1.xml' and scope ='com'")).thenReturn(policyData);
+ servlet.setPolicyController(controller);
+ servlet.setTestUserId("Test");
+ servlet.doPost(request, response);
+ } catch (Exception e1) {
+ logger.error("Exception Occured"+e1);
+ fail();
+ }
+ }
+ }
+
+ @Test
+ public void editActionPolicyTest(){
+ List<Object> policyData = new ArrayList<>();
+ String policyContent = "";
+ String configData = "";
+ try {
+ ClassLoader classLoader = getClass().getClassLoader();
+ policyContent = IOUtils.toString(classLoader.getResourceAsStream("Action_TestActionPolicy.1.xml"));
+ configData = IOUtils.toString(classLoader.getResourceAsStream("com.Action_TestActionPolicy.1.json"));
+ } catch (Exception e1) {
+ logger.error("Exception Occured"+e1);
+ }
+ PolicyEntity entity = new PolicyEntity();
+ entity.setPolicyName("Action_TestActionPolicy.1.xml");
+ entity.setPolicyData(policyContent);
+ entity.setScope("com");
+ ActionBodyEntity configurationEntity = new ActionBodyEntity();
+ configurationEntity.setActionBody(configData);
+ configurationEntity.setActionBodyName("com.Action_TestActionPolicy.1.json");
+ entity.setActionBodyEntity(configurationEntity);
+ policyData.add(entity);
+ PolicyManagerServlet servlet = new PolicyManagerServlet();
+ HttpServletRequest request = mock(HttpServletRequest.class);
+ HttpServletResponse response = mock(HttpServletResponse.class);
+ PolicyController controller = mock(PolicyController.class);
+ List<String> list = new ArrayList<>();
+ list.add("{params: { mode: 'EDITFILE', path: '/com/Action_TestActionPolicy.1.xml', onlyFolders: false}}");
+ for(int i =0; i < list.size(); i++){
+ BufferedReader reader = new BufferedReader(new StringReader(list.get(i)));
+ try {
+ when(request.getReader()).thenReturn(reader);
+ when(controller.getRoles("Test")).thenReturn(rolesdata);
+ when(controller.getDataByQuery("FROM PolicyEntity where policyName = 'Action_TestActionPolicy.1.xml' and scope ='com'")).thenReturn(policyData);
+ servlet.setPolicyController(controller);
+ servlet.setTestUserId("Test");
+ servlet.doPost(request, response);
+ } catch (Exception e1) {
+ logger.error("Exception Occured"+e1);
+ fail();
+ }
+ }
+ }
+
+ @Test
+ public void editDecisionPolicyTest(){
+ List<Object> policyData = new ArrayList<>();
+ String policyContent = "";
+ try {
+ ClassLoader classLoader = getClass().getClassLoader();
+ policyContent = IOUtils.toString(classLoader.getResourceAsStream("Decision_TestDecisionPolicyWithRuleAlgorithms.1.xml"));
+ } catch (Exception e1) {
+ logger.error("Exception Occured"+e1);
+ }
+ PolicyEntity entity = new PolicyEntity();
+ entity.setPolicyName("Decision_TestDecisionPolicyWithRuleAlgorithms.1.xml");
+ entity.setPolicyData(policyContent);
+ entity.setScope("com");
+ policyData.add(entity);
+ PolicyManagerServlet servlet = new PolicyManagerServlet();
+ HttpServletRequest request = mock(HttpServletRequest.class);
+ HttpServletResponse response = mock(HttpServletResponse.class);
+ PolicyController controller = mock(PolicyController.class);
+ List<String> list = new ArrayList<>();
+ list.add("{params: { mode: 'EDITFILE', path: '/com/Decision_TestDecisionPolicyWithRuleAlgorithms.1.xml', onlyFolders: false}}");
+ for(int i =0; i < list.size(); i++){
+ BufferedReader reader = new BufferedReader(new StringReader(list.get(i)));
+ try {
+ when(request.getReader()).thenReturn(reader);
+ when(controller.getRoles("Test")).thenReturn(rolesdata);
+ when(controller.getDataByQuery("FROM PolicyEntity where policyName = 'Decision_TestDecisionPolicyWithRuleAlgorithms.1.xml' and scope ='com'")).thenReturn(policyData);
+ servlet.setPolicyController(controller);
+ servlet.setTestUserId("Test");
+ servlet.doPost(request, response);
+ } catch (Exception e1) {
+ logger.error("Exception Occured"+e1);
+ fail();
+ }
+ }
+ }
}
diff --git a/POLICY-SDK-APP/src/test/java/org/openecomp/policy/controller/AdminTabControllerTest.java b/POLICY-SDK-APP/src/test/java/org/openecomp/policy/controller/AdminTabControllerTest.java
index 43b8a6f25..07bd54939 100644
--- a/POLICY-SDK-APP/src/test/java/org/openecomp/policy/controller/AdminTabControllerTest.java
+++ b/POLICY-SDK-APP/src/test/java/org/openecomp/policy/controller/AdminTabControllerTest.java
@@ -19,10 +19,12 @@
*/
package org.openecomp.policy.controller;
-import static org.junit.Assert.assertTrue;
+import static org.junit.Assert.*;
import static org.mockito.Mockito.mock;
import static org.mockito.Mockito.when;
+import java.io.BufferedReader;
+import java.io.StringReader;
import java.io.UnsupportedEncodingException;
import java.util.ArrayList;
import java.util.List;
@@ -41,12 +43,20 @@ public class AdminTabControllerTest {
private static Logger logger = FlexLogger.getLogger(AdminTabControllerTest.class);
private static CommonClassDao commonClassDao;
+ private HttpServletRequest request;
+ private MockHttpServletResponse response;
@Before
public void setUp() throws Exception {
logger.info("setUp: Entering");
commonClassDao = mock(CommonClassDao.class);
+
+ request = mock(HttpServletRequest.class);
+ response = new MockHttpServletResponse();
+
+ AdminTabController.setCommonClassDao(commonClassDao);
+
GlobalRoleSettings globalRole = new GlobalRoleSettings();
globalRole.setLockdown(true);
globalRole.setRole("super-admin");
@@ -57,17 +67,28 @@ public class AdminTabControllerTest {
@Test
public void testGetAdminRole(){
- HttpServletRequest request = mock(HttpServletRequest.class);
- MockHttpServletResponse response = new MockHttpServletResponse();
-
AdminTabController admin = new AdminTabController();
- AdminTabController.setCommonClassDao(commonClassDao);
- admin.getAdminTabEntityData(request, response);
-
try {
+ admin.getAdminTabEntityData(request, response);
assertTrue(response.getContentAsString() != null && response.getContentAsString().contains("lockdowndata"));
} catch (UnsupportedEncodingException e) {
logger.error("Exception Occured"+e);
+ fail();
+ }
+ }
+
+ @Test
+ public void testSaveAdminRole() throws Exception{
+ AdminTabController admin = new AdminTabController();
+ String data = "{\"lockdowndata\":{\"lockdown\":true}}";
+ BufferedReader reader = new BufferedReader(new StringReader(data));
+ try {
+ when(request.getReader()).thenReturn(reader);
+ admin.saveAdminTabLockdownValue(request, response);
+ assertTrue(response.getContentAsString() != null && response.getContentAsString().contains("descriptiveScopeDictionaryDatas"));
+ } catch (UnsupportedEncodingException e) {
+ logger.error("Exception Occured"+e);
+ fail();
}
}
diff --git a/POLICY-SDK-APP/src/test/java/org/openecomp/policy/controller/CreateDcaeMicroServiceControllerTest.java b/POLICY-SDK-APP/src/test/java/org/openecomp/policy/controller/CreateDcaeMicroServiceControllerTest.java
index b4619b852..ca915440e 100644
--- a/POLICY-SDK-APP/src/test/java/org/openecomp/policy/controller/CreateDcaeMicroServiceControllerTest.java
+++ b/POLICY-SDK-APP/src/test/java/org/openecomp/policy/controller/CreateDcaeMicroServiceControllerTest.java
@@ -169,6 +169,7 @@ public class CreateDcaeMicroServiceControllerTest {
//expect: uniqueKeys should contain a string value
CreateDcaeMicroServiceController controllerA = new CreateDcaeMicroServiceController();
String str = "testing\\.byCorrectWay\\.OfDATA";
+ String value = null;
assertEquals(1, controllerA.stringBetweenDots(str));
//expect: uniqueKeys should not contain a string value
diff --git a/POLICY-SDK-APP/src/test/resources/Action_TestActionPolicy.1.xml b/POLICY-SDK-APP/src/test/resources/Action_TestActionPolicy.1.xml
new file mode 100644
index 000000000..77c9367aa
--- /dev/null
+++ b/POLICY-SDK-APP/src/test/resources/Action_TestActionPolicy.1.xml
@@ -0,0 +1,52 @@
+<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
+ <Policy xmlns="urn:oasis:names:tc:xacml:3.0:core:schema:wd-17" PolicyId="urn:xacml:policy:id:b8e180de-3dcc-4b5b-814d-925e674e573c" Version="1" RuleCombiningAlgId="urn:oasis:names:tc:xacml:3.0:rule-combining-algorithm:permit-overrides">
+ <Description>TestActionPolicy@CreatedBy:@CreatedBy:@ModifiedBy:@ModifiedBy:</Description>
+ <Target>
+ <AnyOf>
+ <AllOf>
+ <Match MatchId="org.openecomp.function.regex-match">
+ <AttributeValue DataType="http://www.w3.org/2001/XMLSchema#string">12</AttributeValue>
+ <AttributeDesignator Category="urn:oasis:names:tc:xacml:3.0:attribute-category:resource" AttributeId="SamplTest" DataType="http://www.w3.org/2001/XMLSchema#string" MustBePresent="false"/>
+ </Match>
+ </AllOf>
+ </AnyOf>
+ </Target>
+ <Rule RuleId="" Effect="Permit">
+ <Target/>
+ <Condition>
+ <Apply FunctionId="urn:oasis:names:tc:xacml:1.0:function:and">
+ <Apply FunctionId="urn:oasis:names:tc:xacml:3.0:function:string-equal-ignore-case">
+ <Apply FunctionId="urn:oasis:names:tc:xacml:1.0:function:string-one-and-only">
+ <AttributeDesignator Category="urn:oasis:names:tc:xacml:3.0:attribute-category:resource" AttributeId="SamplTest" DataType="http://www.w3.org/2001/XMLSchema#string" MustBePresent="false"/>
+ </Apply>
+ <AttributeValue DataType="http://www.w3.org/2001/XMLSchema#string">test</AttributeValue>
+ </Apply>
+ <Apply FunctionId="urn:oasis:names:tc:xacml:3.0:function:string-equal-ignore-case">
+ <Apply FunctionId="urn:oasis:names:tc:xacml:1.0:function:string-one-and-only">
+ <AttributeDesignator Category="urn:oasis:names:tc:xacml:3.0:attribute-category:resource" AttributeId="SamplTest" DataType="http://www.w3.org/2001/XMLSchema#string" MustBePresent="false"/>
+ </Apply>
+ <AttributeValue DataType="http://www.w3.org/2001/XMLSchema#string">Sample</AttributeValue>
+ </Apply>
+ </Apply>
+ </Condition>
+ <ObligationExpressions>
+ <ObligationExpression ObligationId="Test" FulfillOn="Permit">
+ <AttributeAssignmentExpression AttributeId="performer" Category="urn:oasis:names:tc:xacml:1.0:subject-category:recipient-subject">
+ <AttributeValue DataType="http://www.w3.org/2001/XMLSchema#string">PEPAction</AttributeValue>
+ </AttributeAssignmentExpression>
+ <AttributeAssignmentExpression AttributeId="type" Category="urn:oasis:names:tc:xacml:3.0:attribute-category:resource">
+ <AttributeValue DataType="http://www.w3.org/2001/XMLSchema#string">REST</AttributeValue>
+ </AttributeAssignmentExpression>
+ <AttributeAssignmentExpression AttributeId="url" Category="urn:oasis:names:tc:xacml:3.0:attribute-category:resource">
+ <AttributeValue DataType="http://www.w3.org/2001/XMLSchema#anyURI">http://localhost.com</AttributeValue>
+ </AttributeAssignmentExpression>
+ <AttributeAssignmentExpression AttributeId="method" Category="urn:oasis:names:tc:xacml:3.0:attribute-category:resource">
+ <AttributeValue DataType="http://www.w3.org/2001/XMLSchema#string">GET</AttributeValue>
+ </AttributeAssignmentExpression>
+ <AttributeAssignmentExpression AttributeId="body" Category="urn:oasis:names:tc:xacml:3.0:attribute-category:resource">
+ <AttributeValue DataType="http://www.w3.org/2001/XMLSchema#anyURI">$URL/Action/com.Action_TestActionPolicy.1.xml.json</AttributeValue>
+ </AttributeAssignmentExpression>
+ </ObligationExpression>
+ </ObligationExpressions>
+ </Rule>
+ </Policy> \ No newline at end of file
diff --git a/POLICY-SDK-APP/src/test/resources/Config_BRMS_Param_BRMSParamvFWDemoPolicy.1.xml b/POLICY-SDK-APP/src/test/resources/Config_BRMS_Param_BRMSParamvFWDemoPolicy.1.xml
new file mode 100644
index 000000000..ddf1864e4
--- /dev/null
+++ b/POLICY-SDK-APP/src/test/resources/Config_BRMS_Param_BRMSParamvFWDemoPolicy.1.xml
@@ -0,0 +1,93 @@
+<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
+<Policy xmlns="urn:oasis:names:tc:xacml:3.0:core:schema:wd-17" PolicyId="urn:com:xacml:policy:id:256f4712-a965-4817-a851-a71bdeb9fb49" Version="1" RuleCombiningAlgId="urn:oasis:names:tc:xacml:3.0:rule-combining-algorithm:permit-overrides">
+ <Description>BRMSParam vFW Demo Policy@CreatedBy:@CreatedBy:@ModifiedBy:@ModifiedBy:</Description>
+ <Target>
+ <AnyOf>
+ <AllOf>
+ <Match MatchId="org.openecomp.function.regex-match">
+ <AttributeValue DataType="http://www.w3.org/2001/XMLSchema#string">com.Config_BRMS_Param_BRMSParamvFWDemoPolicy.1.xml</AttributeValue>
+ <AttributeDesignator Category="urn:oasis:names:tc:xacml:1.0:subject-category:access-subject" AttributeId="PolicyName" DataType="http://www.w3.org/2001/XMLSchema#string" MustBePresent="false"/>
+ </Match>
+ </AllOf>
+ <AllOf>
+ <Match MatchId="org.openecomp.function.regex-match">
+ <AttributeValue DataType="http://www.w3.org/2001/XMLSchema#string">DROOLS</AttributeValue>
+ <AttributeDesignator Category="urn:oasis:names:tc:xacml:1.0:subject-category:access-subject" AttributeId="ECOMPName" DataType="http://www.w3.org/2001/XMLSchema#string" MustBePresent="false"/>
+ </Match>
+ <Match MatchId="org.openecomp.function.regex-match">
+ <AttributeValue DataType="http://www.w3.org/2001/XMLSchema#string">BRMS_PARAM_RULE</AttributeValue>
+ <AttributeDesignator Category="urn:oasis:names:tc:xacml:1.0:subject-category:access-subject" AttributeId="ConfigName" DataType="http://www.w3.org/2001/XMLSchema#string" MustBePresent="false"/>
+ </Match>
+ <Match MatchId="org.openecomp.function.regex-match">
+ <AttributeValue DataType="http://www.w3.org/2001/XMLSchema#string">SampleRiskType</AttributeValue>
+ <AttributeDesignator Category="urn:oasis:names:tc:xacml:3.0:attribute-category:resource" AttributeId="RiskType" DataType="http://www.w3.org/2001/XMLSchema#string" MustBePresent="false"/>
+ </Match>
+ <Match MatchId="org.openecomp.function.regex-match">
+ <AttributeValue DataType="http://www.w3.org/2001/XMLSchema#string">1</AttributeValue>
+ <AttributeDesignator Category="urn:oasis:names:tc:xacml:3.0:attribute-category:resource" AttributeId="RiskLevel" DataType="http://www.w3.org/2001/XMLSchema#string" MustBePresent="false"/>
+ </Match>
+ <Match MatchId="org.openecomp.function.regex-match">
+ <AttributeValue DataType="http://www.w3.org/2001/XMLSchema#string">False</AttributeValue>
+ <AttributeDesignator Category="urn:oasis:names:tc:xacml:3.0:attribute-category:resource" AttributeId="guard" DataType="http://www.w3.org/2001/XMLSchema#string" MustBePresent="false"/>
+ </Match>
+ <Match MatchId="org.openecomp.function.regex-match">
+ <AttributeValue DataType="http://www.w3.org/2001/XMLSchema#string">08-06-2017</AttributeValue>
+ <AttributeDesignator Category="urn:oasis:names:tc:xacml:3.0:attribute-category:resource" AttributeId="TTLDate" DataType="http://www.w3.org/2001/XMLSchema#string" MustBePresent="false"/>
+ </Match>
+ </AllOf>
+ </AnyOf>
+ </Target>
+ <Rule RuleId="urn:com:xacml:rule:id:8cdb88aa-448b-4ed1-bce5-6a037651e73c" Effect="Permit">
+ <Target>
+ <AnyOf>
+ <AllOf>
+ <Match MatchId="urn:oasis:names:tc:xacml:3.0:function:string-equal-ignore-case">
+ <AttributeValue DataType="http://www.w3.org/2001/XMLSchema#string">ACCESS</AttributeValue>
+ <AttributeDesignator Category="urn:oasis:names:tc:xacml:3.0:attribute-category:action" AttributeId="urn:oasis:names:tc:xacml:1.0:action:action-id" DataType="http://www.w3.org/2001/XMLSchema#string" MustBePresent="false"/>
+ </Match>
+ <Match MatchId="urn:oasis:names:tc:xacml:3.0:function:string-equal-ignore-case">
+ <AttributeValue DataType="http://www.w3.org/2001/XMLSchema#string">Config</AttributeValue>
+ <AttributeDesignator Category="urn:oasis:names:tc:xacml:3.0:attribute-category:resource" AttributeId="urn:oasis:names:tc:xacml:1.0:resource:resource-id" DataType="http://www.w3.org/2001/XMLSchema#string" MustBePresent="false"/>
+ </Match>
+ </AllOf>
+ </AnyOf>
+ </Target>
+ <AdviceExpressions>
+ <AdviceExpression AdviceId="BRMSPARAMID" AppliesTo="Permit">
+ <AttributeAssignmentExpression AttributeId="type" Category="urn:oasis:names:tc:xacml:3.0:attribute-category:resource" Issuer="">
+ <AttributeValue DataType="http://www.w3.org/2001/XMLSchema#string">Configuration</AttributeValue>
+ </AttributeAssignmentExpression>
+ <AttributeAssignmentExpression AttributeId="URLID" Category="urn:oasis:names:tc:xacml:3.0:attribute-category:resource" Issuer="">
+ <AttributeValue DataType="http://www.w3.org/2001/XMLSchema#anyURI">$URL/Config/com.Config_BRMS_Param_BRMSParamvFWDemoPolicy.1.txt</AttributeValue>
+ </AttributeAssignmentExpression>
+ <AttributeAssignmentExpression AttributeId="PolicyName" Category="urn:oasis:names:tc:xacml:3.0:attribute-category:resource" Issuer="">
+ <AttributeValue DataType="http://www.w3.org/2001/XMLSchema#string">com.Config_BRMS_Param_BRMSParamvFWDemoPolicy.1.xml</AttributeValue>
+ </AttributeAssignmentExpression>
+ <AttributeAssignmentExpression AttributeId="VersionNumber" Category="urn:oasis:names:tc:xacml:3.0:attribute-category:resource" Issuer="">
+ <AttributeValue DataType="http://www.w3.org/2001/XMLSchema#string">1</AttributeValue>
+ </AttributeAssignmentExpression>
+ <AttributeAssignmentExpression AttributeId="matching:ECOMPName" Category="urn:oasis:names:tc:xacml:3.0:attribute-category:resource" Issuer="">
+ <AttributeValue DataType="http://www.w3.org/2001/XMLSchema#string">DROOLS</AttributeValue>
+ </AttributeAssignmentExpression>
+ <AttributeAssignmentExpression AttributeId="matching:ConfigName" Category="urn:oasis:names:tc:xacml:3.0:attribute-category:resource" Issuer="">
+ <AttributeValue DataType="http://www.w3.org/2001/XMLSchema#string">BRMS_PARAM_RULE</AttributeValue>
+ </AttributeAssignmentExpression>
+ <AttributeAssignmentExpression AttributeId="key:controller" Category="urn:oasis:names:tc:xacml:3.0:attribute-category:resource" Issuer="">
+ <AttributeValue DataType="http://www.w3.org/2001/XMLSchema#string">vFW</AttributeValue>
+ </AttributeAssignmentExpression>
+ <AttributeAssignmentExpression AttributeId="RiskType" Category="urn:oasis:names:tc:xacml:3.0:attribute-category:resource" Issuer="">
+ <AttributeValue DataType="http://www.w3.org/2001/XMLSchema#string">SampleRiskType</AttributeValue>
+ </AttributeAssignmentExpression>
+ <AttributeAssignmentExpression AttributeId="RiskLevel" Category="urn:oasis:names:tc:xacml:3.0:attribute-category:resource" Issuer="">
+ <AttributeValue DataType="http://www.w3.org/2001/XMLSchema#string">1</AttributeValue>
+ </AttributeAssignmentExpression>
+ <AttributeAssignmentExpression AttributeId="guard" Category="urn:oasis:names:tc:xacml:3.0:attribute-category:resource" Issuer="">
+ <AttributeValue DataType="http://www.w3.org/2001/XMLSchema#string">False</AttributeValue>
+ </AttributeAssignmentExpression>
+ <AttributeAssignmentExpression AttributeId="TTLDate" Category="urn:oasis:names:tc:xacml:3.0:attribute-category:resource" Issuer="">
+ <AttributeValue DataType="http://www.w3.org/2001/XMLSchema#string">08-06-2017</AttributeValue>
+ </AttributeAssignmentExpression>
+ </AdviceExpression>
+ </AdviceExpressions>
+ </Rule>
+</Policy> \ No newline at end of file
diff --git a/POLICY-SDK-APP/src/test/resources/Config_BRMS_Raw_TestBRMSRawPolicy.1.xml b/POLICY-SDK-APP/src/test/resources/Config_BRMS_Raw_TestBRMSRawPolicy.1.xml
new file mode 100644
index 000000000..aa8abc4c9
--- /dev/null
+++ b/POLICY-SDK-APP/src/test/resources/Config_BRMS_Raw_TestBRMSRawPolicy.1.xml
@@ -0,0 +1,110 @@
+<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
+ <Policy xmlns="urn:oasis:names:tc:xacml:3.0:core:schema:wd-17" PolicyId="urn:xacml:policy:id:05c1c4eb-a94c-4f1c-8ff7-548f7d0b03c2" Version="1" RuleCombiningAlgId="urn:oasis:names:tc:xacml:3.0:rule-combining-algorithm:permit-overrides">
+ <Description>TestBRMSRawPolicy@CreatedBy:@CreatedBy:@ModifiedBy:@ModifiedBy:</Description>
+ <Target>
+ <AnyOf>
+ <AllOf>
+ <Match MatchId="org.openecomp.function.regex-match">
+ <AttributeValue DataType="http://www.w3.org/2001/XMLSchema#string">com.Config_BRMS_Raw_TestBRMSRawPolicy.1.xml</AttributeValue>
+ <AttributeDesignator Category="urn:oasis:names:tc:xacml:1.0:subject-category:access-subject" AttributeId="PolicyName" DataType="http://www.w3.org/2001/XMLSchema#string" MustBePresent="false"/>
+ </Match>
+ </AllOf>
+ <AllOf>
+ <Match MatchId="org.openecomp.function.regex-match">
+ <AttributeValue DataType="http://www.w3.org/2001/XMLSchema#string">DROOLS</AttributeValue>
+ <AttributeDesignator Category="urn:oasis:names:tc:xacml:1.0:subject-category:access-subject" AttributeId="ECOMPName" DataType="http://www.w3.org/2001/XMLSchema#string" MustBePresent="false"/>
+ </Match>
+ <Match MatchId="org.openecomp.function.regex-match">
+ <AttributeValue DataType="http://www.w3.org/2001/XMLSchema#string">BRMS_RAW_RULE</AttributeValue>
+ <AttributeDesignator Category="urn:oasis:names:tc:xacml:1.0:subject-category:access-subject" AttributeId="ConfigName" DataType="http://www.w3.org/2001/XMLSchema#string" MustBePresent="false"/>
+ </Match>
+ <Match MatchId="org.openecomp.function.regex-match">
+ <AttributeValue DataType="http://www.w3.org/2001/XMLSchema#string">High</AttributeValue>
+ <AttributeDesignator Category="urn:oasis:names:tc:xacml:3.0:attribute-category:resource" AttributeId="RiskType" DataType="http://www.w3.org/2001/XMLSchema#string" MustBePresent="false"/>
+ </Match>
+ <Match MatchId="org.openecomp.function.regex-match">
+ <AttributeValue DataType="http://www.w3.org/2001/XMLSchema#string">2</AttributeValue>
+ <AttributeDesignator Category="urn:oasis:names:tc:xacml:3.0:attribute-category:resource" AttributeId="RiskLevel" DataType="http://www.w3.org/2001/XMLSchema#string" MustBePresent="false"/>
+ </Match>
+ <Match MatchId="org.openecomp.function.regex-match">
+ <AttributeValue DataType="http://www.w3.org/2001/XMLSchema#string">True</AttributeValue>
+ <AttributeDesignator Category="urn:oasis:names:tc:xacml:3.0:attribute-category:resource" AttributeId="guard" DataType="http://www.w3.org/2001/XMLSchema#string" MustBePresent="false"/>
+ </Match>
+ <Match MatchId="org.openecomp.function.regex-match">
+ <AttributeValue DataType="http://www.w3.org/2001/XMLSchema#string">08-06-2017</AttributeValue>
+ <AttributeDesignator Category="urn:oasis:names:tc:xacml:3.0:attribute-category:resource" AttributeId="TTLDate" DataType="http://www.w3.org/2001/XMLSchema#string" MustBePresent="false"/>
+ </Match>
+ </AllOf>
+ </AnyOf>
+ </Target>
+ <Rule RuleId="" Effect="Permit">
+ <Target>
+ <AnyOf>
+ <AllOf>
+ <Match MatchId="urn:oasis:names:tc:xacml:3.0:function:string-equal-ignore-case">
+ <AttributeValue DataType="http://www.w3.org/2001/XMLSchema#string">ACCESS</AttributeValue>
+ <AttributeDesignator Category="urn:oasis:names:tc:xacml:3.0:attribute-category:action" AttributeId="urn:oasis:names:tc:xacml:1.0:action:action-id" DataType="http://www.w3.org/2001/XMLSchema#string" MustBePresent="false"/>
+ </Match>
+ <Match MatchId="urn:oasis:names:tc:xacml:3.0:function:string-equal-ignore-case">
+ <AttributeValue DataType="http://www.w3.org/2001/XMLSchema#string">Config</AttributeValue>
+ <AttributeDesignator Category="urn:oasis:names:tc:xacml:3.0:attribute-category:resource" AttributeId="urn:oasis:names:tc:xacml:1.0:resource:resource-id" DataType="http://www.w3.org/2001/XMLSchema#string" MustBePresent="false"/>
+ </Match>
+ </AllOf>
+ </AnyOf>
+ </Target>
+ <AdviceExpressions>
+ <AdviceExpression AdviceId="BRMSRAWID" AppliesTo="Permit">
+ <AttributeAssignmentExpression AttributeId="type" Category="urn:oasis:names:tc:xacml:3.0:attribute-category:resource" Issuer="">
+ <AttributeValue DataType="http://www.w3.org/2001/XMLSchema#string">Configuration</AttributeValue>
+ </AttributeAssignmentExpression>
+ <AttributeAssignmentExpression AttributeId="URLID" Category="urn:oasis:names:tc:xacml:3.0:attribute-category:resource" Issuer="">
+ <AttributeValue DataType="http://www.w3.org/2001/XMLSchema#anyURI">$URL/Config/com.Config_BRMS_Raw_TestBRMSRawPolicy.1.txt</AttributeValue>
+ </AttributeAssignmentExpression>
+ <AttributeAssignmentExpression AttributeId="PolicyName" Category="urn:oasis:names:tc:xacml:3.0:attribute-category:resource" Issuer="">
+ <AttributeValue DataType="http://www.w3.org/2001/XMLSchema#string">com.Config_BRMS_Raw_TestBRMSRawPolicy.1.xml</AttributeValue>
+ </AttributeAssignmentExpression>
+ <AttributeAssignmentExpression AttributeId="VersionNumber" Category="urn:oasis:names:tc:xacml:3.0:attribute-category:resource" Issuer="">
+ <AttributeValue DataType="http://www.w3.org/2001/XMLSchema#string">1</AttributeValue>
+ </AttributeAssignmentExpression>
+ <AttributeAssignmentExpression AttributeId="matching:ECOMPName" Category="urn:oasis:names:tc:xacml:3.0:attribute-category:resource" Issuer="">
+ <AttributeValue DataType="http://www.w3.org/2001/XMLSchema#string">DROOLS</AttributeValue>
+ </AttributeAssignmentExpression>
+ <AttributeAssignmentExpression AttributeId="matching:ConfigName" Category="urn:oasis:names:tc:xacml:3.0:attribute-category:resource" Issuer="">
+ <AttributeValue DataType="http://www.w3.org/2001/XMLSchema#string">BRMS_RAW_RULE</AttributeValue>
+ </AttributeAssignmentExpression>
+ <AttributeAssignmentExpression AttributeId="controller:TestController" Category="urn:oasis:names:tc:xacml:3.0:attribute-category:resource" Issuer="">
+ <AttributeValue DataType="http://www.w3.org/2001/XMLSchema#string">{
+ "artifactId": "testing",
+ "groupId" : "org.openecomp"
+ }</AttributeValue>
+ </AttributeAssignmentExpression>
+ <AttributeAssignmentExpression AttributeId="dependencies:TestBRMSDependency," Category="urn:oasis:names:tc:xacml:3.0:attribute-category:resource" Issuer="">
+ <AttributeValue DataType="http://www.w3.org/2001/XMLSchema#string">[{
+ "groupId" :"org.test" ,
+ "artifactId" : "test_2.10",
+ "version" : "3.0.2",
+ "exclusions" : [ {
+ "groupId" :"org.test.tests" ,
+ "artifactId" : "test-config_2.10"
+ }]
+ }]</AttributeValue>
+ </AttributeAssignmentExpression>
+ <AttributeAssignmentExpression AttributeId="key:controller" Category="urn:oasis:names:tc:xacml:3.0:attribute-category:resource" Issuer="">
+ <AttributeValue DataType="http://www.w3.org/2001/XMLSchema#string">vFW</AttributeValue>
+ </AttributeAssignmentExpression>
+ <AttributeAssignmentExpression AttributeId="RiskType" Category="urn:oasis:names:tc:xacml:3.0:attribute-category:resource" Issuer="">
+ <AttributeValue DataType="http://www.w3.org/2001/XMLSchema#string">High</AttributeValue>
+ </AttributeAssignmentExpression>
+ <AttributeAssignmentExpression AttributeId="RiskLevel" Category="urn:oasis:names:tc:xacml:3.0:attribute-category:resource" Issuer="">
+ <AttributeValue DataType="http://www.w3.org/2001/XMLSchema#string">2</AttributeValue>
+ </AttributeAssignmentExpression>
+ <AttributeAssignmentExpression AttributeId="guard" Category="urn:oasis:names:tc:xacml:3.0:attribute-category:resource" Issuer="">
+ <AttributeValue DataType="http://www.w3.org/2001/XMLSchema#string">True</AttributeValue>
+ </AttributeAssignmentExpression>
+ <AttributeAssignmentExpression AttributeId="TTLDate" Category="urn:oasis:names:tc:xacml:3.0:attribute-category:resource" Issuer="">
+ <AttributeValue DataType="http://www.w3.org/2001/XMLSchema#string">08-06-2017</AttributeValue>
+ </AttributeAssignmentExpression>
+ </AdviceExpression>
+ </AdviceExpressions>
+ </Rule>
+ </Policy> \ No newline at end of file
diff --git a/POLICY-SDK-APP/src/test/resources/Config_FW_TestFireWallPolicy.1.xml b/POLICY-SDK-APP/src/test/resources/Config_FW_TestFireWallPolicy.1.xml
new file mode 100644
index 000000000..f334cae46
--- /dev/null
+++ b/POLICY-SDK-APP/src/test/resources/Config_FW_TestFireWallPolicy.1.xml
@@ -0,0 +1,86 @@
+<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
+ <Policy xmlns="urn:oasis:names:tc:xacml:3.0:core:schema:wd-17" PolicyId="urn:xacml:policy:id:2f5c1b1e-7cd4-4e71-9a0d-2fcef2a6cb7b" Version="1" RuleCombiningAlgId="urn:oasis:names:tc:xacml:3.0:rule-combining-algorithm:permit-overrides">
+ <Description>TestFireWallPolicy@CreatedBy:@CreatedBy:@ModifiedBy:@ModifiedBy:</Description>
+ <Target>
+ <AnyOf>
+ <AllOf>
+ <Match MatchId="org.openecomp.function.regex-match">
+ <AttributeValue DataType="http://www.w3.org/2001/XMLSchema#string">com.Config_FW_TestFireWallPolicy.1.xml</AttributeValue>
+ <AttributeDesignator Category="urn:oasis:names:tc:xacml:1.0:subject-category:access-subject" AttributeId="PolicyName" DataType="http://www.w3.org/2001/XMLSchema#string" MustBePresent="false"/>
+ </Match>
+ </AllOf>
+ <AllOf>
+ <Match MatchId="org.openecomp.function.regex-match">
+ <AttributeValue DataType="http://www.w3.org/2001/XMLSchema#string">TestFireWallPolicy</AttributeValue>
+ <AttributeDesignator Category="urn:oasis:names:tc:xacml:1.0:subject-category:access-subject" AttributeId="ConfigName" DataType="http://www.w3.org/2001/XMLSchema#string" MustBePresent="false"/>
+ </Match>
+ <Match MatchId="org.openecomp.function.regex-match">
+ <AttributeValue DataType="http://www.w3.org/2001/XMLSchema#string">SampleRiskType</AttributeValue>
+ <AttributeDesignator Category="urn:oasis:names:tc:xacml:3.0:attribute-category:resource" AttributeId="RiskType" DataType="http://www.w3.org/2001/XMLSchema#string" MustBePresent="false"/>
+ </Match>
+ <Match MatchId="org.openecomp.function.regex-match">
+ <AttributeValue DataType="http://www.w3.org/2001/XMLSchema#string">1</AttributeValue>
+ <AttributeDesignator Category="urn:oasis:names:tc:xacml:3.0:attribute-category:resource" AttributeId="RiskLevel" DataType="http://www.w3.org/2001/XMLSchema#string" MustBePresent="false"/>
+ </Match>
+ <Match MatchId="org.openecomp.function.regex-match">
+ <AttributeValue DataType="http://www.w3.org/2001/XMLSchema#string">True</AttributeValue>
+ <AttributeDesignator Category="urn:oasis:names:tc:xacml:3.0:attribute-category:resource" AttributeId="guard" DataType="http://www.w3.org/2001/XMLSchema#string" MustBePresent="false"/>
+ </Match>
+ <Match MatchId="org.openecomp.function.regex-match">
+ <AttributeValue DataType="http://www.w3.org/2001/XMLSchema#string">08-06-2017</AttributeValue>
+ <AttributeDesignator Category="urn:oasis:names:tc:xacml:3.0:attribute-category:resource" AttributeId="TTLDate" DataType="http://www.w3.org/2001/XMLSchema#string" MustBePresent="false"/>
+ </Match>
+ </AllOf>
+ </AnyOf>
+ </Target>
+ <Rule RuleId="" Effect="Permit">
+ <Target>
+ <AnyOf>
+ <AllOf>
+ <Match MatchId="urn:oasis:names:tc:xacml:3.0:function:string-equal-ignore-case">
+ <AttributeValue DataType="http://www.w3.org/2001/XMLSchema#string">ACCESS</AttributeValue>
+ <AttributeDesignator Category="urn:oasis:names:tc:xacml:3.0:attribute-category:action" AttributeId="urn:oasis:names:tc:xacml:1.0:action:action-id" DataType="http://www.w3.org/2001/XMLSchema#string" MustBePresent="false"/>
+ </Match>
+ <Match MatchId="urn:oasis:names:tc:xacml:3.0:function:string-equal-ignore-case">
+ <AttributeValue DataType="http://www.w3.org/2001/XMLSchema#string">Config</AttributeValue>
+ <AttributeDesignator Category="urn:oasis:names:tc:xacml:3.0:attribute-category:resource" AttributeId="urn:oasis:names:tc:xacml:1.0:resource:resource-id" DataType="http://www.w3.org/2001/XMLSchema#string" MustBePresent="false"/>
+ </Match>
+ </AllOf>
+ </AnyOf>
+ </Target>
+ <AdviceExpressions>
+ <AdviceExpression AdviceId="firewallConfigID" AppliesTo="Permit">
+ <AttributeAssignmentExpression AttributeId="type" Category="urn:oasis:names:tc:xacml:3.0:attribute-category:resource" Issuer="">
+ <AttributeValue DataType="http://www.w3.org/2001/XMLSchema#string">Configuration</AttributeValue>
+ </AttributeAssignmentExpression>
+ <AttributeAssignmentExpression AttributeId="URLID" Category="urn:oasis:names:tc:xacml:3.0:attribute-category:resource" Issuer="">
+ <AttributeValue DataType="http://www.w3.org/2001/XMLSchema#anyURI">$URL/Config/com.Config_FW_TestFireWallPolicy.1.json</AttributeValue>
+ </AttributeAssignmentExpression>
+ <AttributeAssignmentExpression AttributeId="PolicyName" Category="urn:oasis:names:tc:xacml:3.0:attribute-category:resource" Issuer="">
+ <AttributeValue DataType="http://www.w3.org/2001/XMLSchema#string">com.Config_FW_TestFireWallPolicy.1.xml</AttributeValue>
+ </AttributeAssignmentExpression>
+ <AttributeAssignmentExpression AttributeId="VersionNumber" Category="urn:oasis:names:tc:xacml:3.0:attribute-category:resource" Issuer="">
+ <AttributeValue DataType="http://www.w3.org/2001/XMLSchema#string">1</AttributeValue>
+ </AttributeAssignmentExpression>
+ <AttributeAssignmentExpression AttributeId="matching:ECOMPName" Category="urn:oasis:names:tc:xacml:3.0:attribute-category:resource" Issuer="">
+ <AttributeValue DataType="http://www.w3.org/2001/XMLSchema#string"/>
+ </AttributeAssignmentExpression>
+ <AttributeAssignmentExpression AttributeId="matching:ConfigName" Category="urn:oasis:names:tc:xacml:3.0:attribute-category:resource" Issuer="">
+ <AttributeValue DataType="http://www.w3.org/2001/XMLSchema#string">TestFireWallPolicy</AttributeValue>
+ </AttributeAssignmentExpression>
+ <AttributeAssignmentExpression AttributeId="RiskType" Category="urn:oasis:names:tc:xacml:3.0:attribute-category:resource" Issuer="">
+ <AttributeValue DataType="http://www.w3.org/2001/XMLSchema#string">SampleRiskType</AttributeValue>
+ </AttributeAssignmentExpression>
+ <AttributeAssignmentExpression AttributeId="RiskLevel" Category="urn:oasis:names:tc:xacml:3.0:attribute-category:resource" Issuer="">
+ <AttributeValue DataType="http://www.w3.org/2001/XMLSchema#string">1</AttributeValue>
+ </AttributeAssignmentExpression>
+ <AttributeAssignmentExpression AttributeId="guard" Category="urn:oasis:names:tc:xacml:3.0:attribute-category:resource" Issuer="">
+ <AttributeValue DataType="http://www.w3.org/2001/XMLSchema#string">True</AttributeValue>
+ </AttributeAssignmentExpression>
+ <AttributeAssignmentExpression AttributeId="TTLDate" Category="urn:oasis:names:tc:xacml:3.0:attribute-category:resource" Issuer="">
+ <AttributeValue DataType="http://www.w3.org/2001/XMLSchema#string">08-06-2017</AttributeValue>
+ </AttributeAssignmentExpression>
+ </AdviceExpression>
+ </AdviceExpressions>
+ </Rule>
+ </Policy> \ No newline at end of file
diff --git a/POLICY-SDK-APP/src/test/resources/Config_Fault_TestClosedLoopPolicy.1.xml b/POLICY-SDK-APP/src/test/resources/Config_Fault_TestClosedLoopPolicy.1.xml
new file mode 100644
index 000000000..82be3420e
--- /dev/null
+++ b/POLICY-SDK-APP/src/test/resources/Config_Fault_TestClosedLoopPolicy.1.xml
@@ -0,0 +1,83 @@
+<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
+ <Policy xmlns="urn:oasis:names:tc:xacml:3.0:core:schema:wd-17" PolicyId="urn:xacml:policy:id:947cfa37-71da-4c10-9e64-bb3635aa9f52" Version="1" RuleCombiningAlgId="urn:oasis:names:tc:xacml:3.0:rule-combining-algorithm:permit-overrides">
+ <Description>TestClosedLoopPolicy@CreatedBy:rb7147@CreatedBy:@ModifiedBy:rb7147@ModifiedBy:</Description>
+ <Target>
+ <AnyOf>
+ <AllOf>
+ <Match MatchId="org.openecomp.function.regex-match">
+ <AttributeValue DataType="http://www.w3.org/2001/XMLSchema#string">com.Config_Fault_TestClosedLoopPolicy.1.xml</AttributeValue>
+ <AttributeDesignator Category="urn:oasis:names:tc:xacml:1.0:subject-category:access-subject" AttributeId="PolicyName" DataType="http://www.w3.org/2001/XMLSchema#string" MustBePresent="false"/>
+ </Match>
+ </AllOf>
+ <AllOf>
+ <Match MatchId="org.openecomp.function.regex-match">
+ <AttributeValue DataType="http://www.w3.org/2001/XMLSchema#string">DCAE</AttributeValue>
+ <AttributeDesignator Category="urn:oasis:names:tc:xacml:1.0:subject-category:access-subject" AttributeId="ECOMPName" DataType="http://www.w3.org/2001/XMLSchema#string" MustBePresent="false"/>
+ </Match>
+ <Match MatchId="org.openecomp.function.regex-match">
+ <AttributeValue DataType="http://www.w3.org/2001/XMLSchema#string">SampleRiskType</AttributeValue>
+ <AttributeDesignator Category="urn:oasis:names:tc:xacml:3.0:attribute-category:resource" AttributeId="RiskType" DataType="http://www.w3.org/2001/XMLSchema#string" MustBePresent="false"/>
+ </Match>
+ <Match MatchId="org.openecomp.function.regex-match">
+ <AttributeValue DataType="http://www.w3.org/2001/XMLSchema#string">1</AttributeValue>
+ <AttributeDesignator Category="urn:oasis:names:tc:xacml:3.0:attribute-category:resource" AttributeId="RiskLevel" DataType="http://www.w3.org/2001/XMLSchema#string" MustBePresent="false"/>
+ </Match>
+ <Match MatchId="org.openecomp.function.regex-match">
+ <AttributeValue DataType="http://www.w3.org/2001/XMLSchema#string">True</AttributeValue>
+ <AttributeDesignator Category="urn:oasis:names:tc:xacml:3.0:attribute-category:resource" AttributeId="guard" DataType="http://www.w3.org/2001/XMLSchema#string" MustBePresent="false"/>
+ </Match>
+ <Match MatchId="org.openecomp.function.regex-match">
+ <AttributeValue DataType="http://www.w3.org/2001/XMLSchema#string">07-06-2017</AttributeValue>
+ <AttributeDesignator Category="urn:oasis:names:tc:xacml:3.0:attribute-category:resource" AttributeId="TTLDate" DataType="http://www.w3.org/2001/XMLSchema#string" MustBePresent="false"/>
+ </Match>
+ </AllOf>
+ </AnyOf>
+ </Target>
+ <Rule RuleId="" Effect="Permit">
+ <Target>
+ <AnyOf>
+ <AllOf>
+ <Match MatchId="urn:oasis:names:tc:xacml:3.0:function:string-equal-ignore-case">
+ <AttributeValue DataType="http://www.w3.org/2001/XMLSchema#string">ACCESS</AttributeValue>
+ <AttributeDesignator Category="urn:oasis:names:tc:xacml:3.0:attribute-category:action" AttributeId="urn:oasis:names:tc:xacml:1.0:action:action-id" DataType="http://www.w3.org/2001/XMLSchema#string" MustBePresent="false"/>
+ </Match>
+ <Match MatchId="urn:oasis:names:tc:xacml:3.0:function:string-equal-ignore-case">
+ <AttributeValue DataType="http://www.w3.org/2001/XMLSchema#string">Config</AttributeValue>
+ <AttributeDesignator Category="urn:oasis:names:tc:xacml:3.0:attribute-category:resource" AttributeId="urn:oasis:names:tc:xacml:1.0:resource:resource-id" DataType="http://www.w3.org/2001/XMLSchema#string" MustBePresent="false"/>
+ </Match>
+ </AllOf>
+ </AnyOf>
+ </Target>
+ <AdviceExpressions>
+ <AdviceExpression AdviceId="faultID" AppliesTo="Permit">
+ <AttributeAssignmentExpression AttributeId="type" Category="urn:oasis:names:tc:xacml:3.0:attribute-category:resource" Issuer="">
+ <AttributeValue DataType="http://www.w3.org/2001/XMLSchema#string">Configuration</AttributeValue>
+ </AttributeAssignmentExpression>
+ <AttributeAssignmentExpression AttributeId="URLID" Category="urn:oasis:names:tc:xacml:3.0:attribute-category:resource" Issuer="">
+ <AttributeValue DataType="http://www.w3.org/2001/XMLSchema#anyURI">$URL/Config/com.Config_Fault_TestClosedLoopPolicy.1.json</AttributeValue>
+ </AttributeAssignmentExpression>
+ <AttributeAssignmentExpression AttributeId="PolicyName" Category="urn:oasis:names:tc:xacml:3.0:attribute-category:resource" Issuer="">
+ <AttributeValue DataType="http://www.w3.org/2001/XMLSchema#string">com.Config_Fault_TestClosedLoopPolicy.1.xml</AttributeValue>
+ </AttributeAssignmentExpression>
+ <AttributeAssignmentExpression AttributeId="VersionNumber" Category="urn:oasis:names:tc:xacml:3.0:attribute-category:resource" Issuer="">
+ <AttributeValue DataType="http://www.w3.org/2001/XMLSchema#string">1</AttributeValue>
+ </AttributeAssignmentExpression>
+ <AttributeAssignmentExpression AttributeId="matching:ECOMPName" Category="urn:oasis:names:tc:xacml:3.0:attribute-category:resource" Issuer="">
+ <AttributeValue DataType="http://www.w3.org/2001/XMLSchema#string">DCAE</AttributeValue>
+ </AttributeAssignmentExpression>
+ <AttributeAssignmentExpression AttributeId="RiskType" Category="urn:oasis:names:tc:xacml:3.0:attribute-category:resource" Issuer="">
+ <AttributeValue DataType="http://www.w3.org/2001/XMLSchema#string">SampleRiskType</AttributeValue>
+ </AttributeAssignmentExpression>
+ <AttributeAssignmentExpression AttributeId="RiskLevel" Category="urn:oasis:names:tc:xacml:3.0:attribute-category:resource" Issuer="">
+ <AttributeValue DataType="http://www.w3.org/2001/XMLSchema#string">1</AttributeValue>
+ </AttributeAssignmentExpression>
+ <AttributeAssignmentExpression AttributeId="guard" Category="urn:oasis:names:tc:xacml:3.0:attribute-category:resource" Issuer="">
+ <AttributeValue DataType="http://www.w3.org/2001/XMLSchema#string">True</AttributeValue>
+ </AttributeAssignmentExpression>
+ <AttributeAssignmentExpression AttributeId="TTLDate" Category="urn:oasis:names:tc:xacml:3.0:attribute-category:resource" Issuer="">
+ <AttributeValue DataType="http://www.w3.org/2001/XMLSchema#string">07-06-2017</AttributeValue>
+ </AttributeAssignmentExpression>
+ </AdviceExpression>
+ </AdviceExpressions>
+ </Rule>
+ </Policy> \ No newline at end of file
diff --git a/POLICY-SDK-APP/src/test/resources/Config_MS_vFirewall.1.xml b/POLICY-SDK-APP/src/test/resources/Config_MS_vFirewall.1.xml
new file mode 100644
index 000000000..4fd0b7b5c
--- /dev/null
+++ b/POLICY-SDK-APP/src/test/resources/Config_MS_vFirewall.1.xml
@@ -0,0 +1,114 @@
+<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
+<Policy xmlns="urn:oasis:names:tc:xacml:3.0:core:schema:wd-17" PolicyId="urn:com:xacml:policy:id:34928b05-b0f6-4974-8458-f4d34a2a1764" Version="1" RuleCombiningAlgId="urn:oasis:names:tc:xacml:3.0:rule-combining-algorithm:permit-overrides">
+ <Description>Micro Service vFirewall Demo Policy@CreatedBy:demo@CreatedBy:@ModifiedBy:demo@ModifiedBy:</Description>
+ <Target>
+ <AnyOf>
+ <AllOf>
+ <Match MatchId="org.openecomp.function.regex-match">
+ <AttributeValue DataType="http://www.w3.org/2001/XMLSchema#string">com.Config_MS_vFirewall.1.xml</AttributeValue>
+ <AttributeDesignator Category="urn:oasis:names:tc:xacml:1.0:subject-category:access-subject" AttributeId="PolicyName" DataType="http://www.w3.org/2001/XMLSchema#string" MustBePresent="false"/>
+ </Match>
+ </AllOf>
+ <AllOf>
+ <Match MatchId="org.openecomp.function.regex-match">
+ <AttributeValue DataType="http://www.w3.org/2001/XMLSchema#string">DCAE</AttributeValue>
+ <AttributeDesignator Category="urn:oasis:names:tc:xacml:1.0:subject-category:access-subject" AttributeId="ECOMPName" DataType="http://www.w3.org/2001/XMLSchema#string" MustBePresent="false"/>
+ </Match>
+ <Match MatchId="org.openecomp.function.regex-match">
+ <AttributeValue DataType="http://www.w3.org/2001/XMLSchema#string">SampleConfigName</AttributeValue>
+ <AttributeDesignator Category="urn:oasis:names:tc:xacml:1.0:subject-category:access-subject" AttributeId="ConfigName" DataType="http://www.w3.org/2001/XMLSchema#string" MustBePresent="false"/>
+ </Match>
+ <Match MatchId="org.openecomp.function.regex-match">
+ <AttributeValue DataType="http://www.w3.org/2001/XMLSchema#string">TcaMetrics-v1.0.0.5</AttributeValue>
+ <AttributeDesignator Category="urn:oasis:names:tc:xacml:3.0:attribute-category:resource" AttributeId="service" DataType="http://www.w3.org/2001/XMLSchema#string" MustBePresent="false"/>
+ </Match>
+ <Match MatchId="org.openecomp.function.regex-match">
+ <AttributeValue DataType="http://www.w3.org/2001/XMLSchema#string">/services/cdap-tca-hi-lo/instances/demo/configuration/metricsPerFunctionalRole/vFirewall</AttributeValue>
+ <AttributeDesignator Category="urn:oasis:names:tc:xacml:3.0:attribute-category:resource" AttributeId="uuid" DataType="http://www.w3.org/2001/XMLSchema#string" MustBePresent="false"/>
+ </Match>
+ <Match MatchId="org.openecomp.function.regex-match">
+ <AttributeValue DataType="http://www.w3.org/2001/XMLSchema#string">SampleServiceLocation</AttributeValue>
+ <AttributeDesignator Category="urn:oasis:names:tc:xacml:3.0:attribute-category:resource" AttributeId="location" DataType="http://www.w3.org/2001/XMLSchema#string" MustBePresent="false"/>
+ </Match>
+ <Match MatchId="org.openecomp.function.regex-match">
+ <AttributeValue DataType="http://www.w3.org/2001/XMLSchema#string">SampleRiskType</AttributeValue>
+ <AttributeDesignator Category="urn:oasis:names:tc:xacml:3.0:attribute-category:resource" AttributeId="RiskType" DataType="http://www.w3.org/2001/XMLSchema#string" MustBePresent="false"/>
+ </Match>
+ <Match MatchId="org.openecomp.function.regex-match">
+ <AttributeValue DataType="http://www.w3.org/2001/XMLSchema#string">1</AttributeValue>
+ <AttributeDesignator Category="urn:oasis:names:tc:xacml:3.0:attribute-category:resource" AttributeId="RiskLevel" DataType="http://www.w3.org/2001/XMLSchema#string" MustBePresent="false"/>
+ </Match>
+ <Match MatchId="org.openecomp.function.regex-match">
+ <AttributeValue DataType="http://www.w3.org/2001/XMLSchema#string">False</AttributeValue>
+ <AttributeDesignator Category="urn:oasis:names:tc:xacml:3.0:attribute-category:resource" AttributeId="guard" DataType="http://www.w3.org/2001/XMLSchema#string" MustBePresent="false"/>
+ </Match>
+ <Match MatchId="org.openecomp.function.regex-match">
+ <AttributeValue DataType="http://www.w3.org/2001/XMLSchema#string">07-06-2017</AttributeValue>
+ <AttributeDesignator Category="urn:oasis:names:tc:xacml:3.0:attribute-category:resource" AttributeId="TTLDate" DataType="http://www.w3.org/2001/XMLSchema#string" MustBePresent="false"/>
+ </Match>
+ </AllOf>
+ </AnyOf>
+ </Target>
+ <Rule RuleId="urn:com:xacml:rule:id:063161de-0534-4989-bd01-42f784daf21e" Effect="Permit">
+ <Target>
+ <AnyOf>
+ <AllOf>
+ <Match MatchId="urn:oasis:names:tc:xacml:3.0:function:string-equal-ignore-case">
+ <AttributeValue DataType="http://www.w3.org/2001/XMLSchema#string">ACCESS</AttributeValue>
+ <AttributeDesignator Category="urn:oasis:names:tc:xacml:3.0:attribute-category:action" AttributeId="urn:oasis:names:tc:xacml:1.0:action:action-id" DataType="http://www.w3.org/2001/XMLSchema#string" MustBePresent="false"/>
+ </Match>
+ <Match MatchId="urn:oasis:names:tc:xacml:3.0:function:string-equal-ignore-case">
+ <AttributeValue DataType="http://www.w3.org/2001/XMLSchema#string">Config</AttributeValue>
+ <AttributeDesignator Category="urn:oasis:names:tc:xacml:3.0:attribute-category:resource" AttributeId="urn:oasis:names:tc:xacml:1.0:resource:resource-id" DataType="http://www.w3.org/2001/XMLSchema#string" MustBePresent="false"/>
+ </Match>
+ </AllOf>
+ </AnyOf>
+ </Target>
+ <AdviceExpressions>
+ <AdviceExpression AdviceId="MSID" AppliesTo="Permit">
+ <AttributeAssignmentExpression AttributeId="type" Category="urn:oasis:names:tc:xacml:3.0:attribute-category:resource" Issuer="">
+ <AttributeValue DataType="http://www.w3.org/2001/XMLSchema#string">Configuration</AttributeValue>
+ </AttributeAssignmentExpression>
+ <AttributeAssignmentExpression AttributeId="URLID" Category="urn:oasis:names:tc:xacml:3.0:attribute-category:resource" Issuer="">
+ <AttributeValue DataType="http://www.w3.org/2001/XMLSchema#anyURI">$URL/Config/com.Config_MS_vFirewall.1.json</AttributeValue>
+ </AttributeAssignmentExpression>
+ <AttributeAssignmentExpression AttributeId="PolicyName" Category="urn:oasis:names:tc:xacml:3.0:attribute-category:resource" Issuer="">
+ <AttributeValue DataType="http://www.w3.org/2001/XMLSchema#string">com.Config_MS_vFirewall.1.xml</AttributeValue>
+ </AttributeAssignmentExpression>
+ <AttributeAssignmentExpression AttributeId="VersionNumber" Category="urn:oasis:names:tc:xacml:3.0:attribute-category:resource" Issuer="">
+ <AttributeValue DataType="http://www.w3.org/2001/XMLSchema#string">1</AttributeValue>
+ </AttributeAssignmentExpression>
+ <AttributeAssignmentExpression AttributeId="matching:ECOMPName" Category="urn:oasis:names:tc:xacml:3.0:attribute-category:resource" Issuer="">
+ <AttributeValue DataType="http://www.w3.org/2001/XMLSchema#string">DCAE</AttributeValue>
+ </AttributeAssignmentExpression>
+ <AttributeAssignmentExpression AttributeId="matching:ConfigName" Category="urn:oasis:names:tc:xacml:3.0:attribute-category:resource" Issuer="">
+ <AttributeValue DataType="http://www.w3.org/2001/XMLSchema#string">SampleConfigName</AttributeValue>
+ </AttributeAssignmentExpression>
+ <AttributeAssignmentExpression AttributeId="matching:service" Category="urn:oasis:names:tc:xacml:3.0:attribute-category:resource" Issuer="">
+ <AttributeValue DataType="http://www.w3.org/2001/XMLSchema#string">TcaMetrics-v1.0.0.5</AttributeValue>
+ </AttributeAssignmentExpression>
+ <AttributeAssignmentExpression AttributeId="matching:uuid" Category="urn:oasis:names:tc:xacml:3.0:attribute-category:resource" Issuer="">
+ <AttributeValue DataType="http://www.w3.org/2001/XMLSchema#string">/services/cdap-tca-hi-lo/instances/demo/configuration/metricsPerFunctionalRole/vFirewall</AttributeValue>
+ </AttributeAssignmentExpression>
+ <AttributeAssignmentExpression AttributeId="matching:Location" Category="urn:oasis:names:tc:xacml:3.0:attribute-category:resource" Issuer="">
+ <AttributeValue DataType="http://www.w3.org/2001/XMLSchema#string">SampleServiceLocation</AttributeValue>
+ </AttributeAssignmentExpression>
+ <AttributeAssignmentExpression AttributeId="Priority" Category="urn:oasis:names:tc:xacml:3.0:attribute-category:resource" Issuer="">
+ <AttributeValue DataType="http://www.w3.org/2001/XMLSchema#string">1</AttributeValue>
+ </AttributeAssignmentExpression>
+ <AttributeAssignmentExpression AttributeId="RiskType" Category="urn:oasis:names:tc:xacml:3.0:attribute-category:resource" Issuer="">
+ <AttributeValue DataType="http://www.w3.org/2001/XMLSchema#string">SampleRiskType</AttributeValue>
+ </AttributeAssignmentExpression>
+ <AttributeAssignmentExpression AttributeId="RiskLevel" Category="urn:oasis:names:tc:xacml:3.0:attribute-category:resource" Issuer="">
+ <AttributeValue DataType="http://www.w3.org/2001/XMLSchema#string">1</AttributeValue>
+ </AttributeAssignmentExpression>
+ <AttributeAssignmentExpression AttributeId="guard" Category="urn:oasis:names:tc:xacml:3.0:attribute-category:resource" Issuer="">
+ <AttributeValue DataType="http://www.w3.org/2001/XMLSchema#string">1</AttributeValue>
+ </AttributeAssignmentExpression>
+ <AttributeAssignmentExpression AttributeId="TTLDate" Category="urn:oasis:names:tc:xacml:3.0:attribute-category:resource" Issuer="">
+ <AttributeValue DataType="http://www.w3.org/2001/XMLSchema#string">07-06-2017</AttributeValue>
+ </AttributeAssignmentExpression>
+ </AdviceExpression>
+ </AdviceExpressions>
+ </Rule>
+</Policy> \ No newline at end of file
diff --git a/POLICY-SDK-APP/src/test/resources/Config_PM_TestClosedLoopPMPolicy.1.xml b/POLICY-SDK-APP/src/test/resources/Config_PM_TestClosedLoopPMPolicy.1.xml
new file mode 100644
index 000000000..ca56cf4f7
--- /dev/null
+++ b/POLICY-SDK-APP/src/test/resources/Config_PM_TestClosedLoopPMPolicy.1.xml
@@ -0,0 +1,90 @@
+<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
+ <Policy xmlns="urn:oasis:names:tc:xacml:3.0:core:schema:wd-17" PolicyId="urn:xacml:policy:id:a3ff3c48-b16f-436a-9aaa-ac7a3515b0e8" Version="1" RuleCombiningAlgId="urn:oasis:names:tc:xacml:3.0:rule-combining-algorithm:permit-overrides">
+ <Description>TestClosedLoopPMPolicy@CreatedBy:rb7147@CreatedBy:@ModifiedBy:rb7147@ModifiedBy:</Description>
+ <Target>
+ <AnyOf>
+ <AllOf>
+ <Match MatchId="org.openecomp.function.regex-match">
+ <AttributeValue DataType="http://www.w3.org/2001/XMLSchema#string">com.Config_PM_TestClosedLoopPMPolicy.1.xml</AttributeValue>
+ <AttributeDesignator Category="urn:oasis:names:tc:xacml:1.0:subject-category:access-subject" AttributeId="PolicyName" DataType="http://www.w3.org/2001/XMLSchema#string" MustBePresent="false"/>
+ </Match>
+ </AllOf>
+ <AllOf>
+ <Match MatchId="org.openecomp.function.regex-match">
+ <AttributeValue DataType="http://www.w3.org/2001/XMLSchema#string">Test</AttributeValue>
+ <AttributeDesignator Category="urn:oasis:names:tc:xacml:1.0:subject-category:access-subject" AttributeId="ECOMPName" DataType="http://www.w3.org/2001/XMLSchema#string" MustBePresent="false"/>
+ </Match>
+ <Match MatchId="org.openecomp.function.regex-match">
+ <AttributeValue DataType="http://www.w3.org/2001/XMLSchema#string">SampleRiskType</AttributeValue>
+ <AttributeDesignator Category="urn:oasis:names:tc:xacml:3.0:attribute-category:resource" AttributeId="RiskType" DataType="http://www.w3.org/2001/XMLSchema#string" MustBePresent="false"/>
+ </Match>
+ <Match MatchId="org.openecomp.function.regex-match">
+ <AttributeValue DataType="http://www.w3.org/2001/XMLSchema#string">1</AttributeValue>
+ <AttributeDesignator Category="urn:oasis:names:tc:xacml:3.0:attribute-category:resource" AttributeId="RiskLevel" DataType="http://www.w3.org/2001/XMLSchema#string" MustBePresent="false"/>
+ </Match>
+ <Match MatchId="org.openecomp.function.regex-match">
+ <AttributeValue DataType="http://www.w3.org/2001/XMLSchema#string">True</AttributeValue>
+ <AttributeDesignator Category="urn:oasis:names:tc:xacml:3.0:attribute-category:resource" AttributeId="guard" DataType="http://www.w3.org/2001/XMLSchema#string" MustBePresent="false"/>
+ </Match>
+ <Match MatchId="org.openecomp.function.regex-match">
+ <AttributeValue DataType="http://www.w3.org/2001/XMLSchema#string">08-06-2017</AttributeValue>
+ <AttributeDesignator Category="urn:oasis:names:tc:xacml:3.0:attribute-category:resource" AttributeId="TTLDate" DataType="http://www.w3.org/2001/XMLSchema#string" MustBePresent="false"/>
+ </Match>
+ <Match MatchId="org.openecomp.function.regex-match">
+ <AttributeValue DataType="http://www.w3.org/2001/XMLSchema#string">Registration Failure(Trinity)</AttributeValue>
+ <AttributeDesignator Category="urn:oasis:names:tc:xacml:1.0:subject-category:access-subject" AttributeId="ServiceType" DataType="http://www.w3.org/2001/XMLSchema#string" MustBePresent="false"/>
+ </Match>
+ </AllOf>
+ </AnyOf>
+ </Target>
+ <Rule RuleId="" Effect="Permit">
+ <Target>
+ <AnyOf>
+ <AllOf>
+ <Match MatchId="urn:oasis:names:tc:xacml:3.0:function:string-equal-ignore-case">
+ <AttributeValue DataType="http://www.w3.org/2001/XMLSchema#string">ACCESS</AttributeValue>
+ <AttributeDesignator Category="urn:oasis:names:tc:xacml:3.0:attribute-category:action" AttributeId="urn:oasis:names:tc:xacml:1.0:action:action-id" DataType="http://www.w3.org/2001/XMLSchema#string" MustBePresent="false"/>
+ </Match>
+ <Match MatchId="urn:oasis:names:tc:xacml:3.0:function:string-equal-ignore-case">
+ <AttributeValue DataType="http://www.w3.org/2001/XMLSchema#string">Config</AttributeValue>
+ <AttributeDesignator Category="urn:oasis:names:tc:xacml:3.0:attribute-category:resource" AttributeId="urn:oasis:names:tc:xacml:1.0:resource:resource-id" DataType="http://www.w3.org/2001/XMLSchema#string" MustBePresent="false"/>
+ </Match>
+ </AllOf>
+ </AnyOf>
+ </Target>
+ <AdviceExpressions>
+ <AdviceExpression AdviceId="PMID" AppliesTo="Permit">
+ <AttributeAssignmentExpression AttributeId="type" Category="urn:oasis:names:tc:xacml:3.0:attribute-category:resource" Issuer="">
+ <AttributeValue DataType="http://www.w3.org/2001/XMLSchema#string">Configuration</AttributeValue>
+ </AttributeAssignmentExpression>
+ <AttributeAssignmentExpression AttributeId="URLID" Category="urn:oasis:names:tc:xacml:3.0:attribute-category:resource" Issuer="">
+ <AttributeValue DataType="http://www.w3.org/2001/XMLSchema#anyURI">$URL/Config/com.Config_PM_TestClosedLoopPMPolicy.1.json</AttributeValue>
+ </AttributeAssignmentExpression>
+ <AttributeAssignmentExpression AttributeId="PolicyName" Category="urn:oasis:names:tc:xacml:3.0:attribute-category:resource" Issuer="">
+ <AttributeValue DataType="http://www.w3.org/2001/XMLSchema#string">com.Config_PM_TestClosedLoopPMPolicy.1.xml</AttributeValue>
+ </AttributeAssignmentExpression>
+ <AttributeAssignmentExpression AttributeId="VersionNumber" Category="urn:oasis:names:tc:xacml:3.0:attribute-category:resource" Issuer="">
+ <AttributeValue DataType="http://www.w3.org/2001/XMLSchema#string">1</AttributeValue>
+ </AttributeAssignmentExpression>
+ <AttributeAssignmentExpression AttributeId="matching:ECOMPName" Category="urn:oasis:names:tc:xacml:3.0:attribute-category:resource" Issuer="">
+ <AttributeValue DataType="http://www.w3.org/2001/XMLSchema#string">Test</AttributeValue>
+ </AttributeAssignmentExpression>
+ <AttributeAssignmentExpression AttributeId="matching:ServiceType" Category="urn:oasis:names:tc:xacml:3.0:attribute-category:resource" Issuer="">
+ <AttributeValue DataType="http://www.w3.org/2001/XMLSchema#string">Registration Failure(Trinity)</AttributeValue>
+ </AttributeAssignmentExpression>
+ <AttributeAssignmentExpression AttributeId="RiskType" Category="urn:oasis:names:tc:xacml:3.0:attribute-category:resource" Issuer="">
+ <AttributeValue DataType="http://www.w3.org/2001/XMLSchema#string">SampleRiskType</AttributeValue>
+ </AttributeAssignmentExpression>
+ <AttributeAssignmentExpression AttributeId="RiskLevel" Category="urn:oasis:names:tc:xacml:3.0:attribute-category:resource" Issuer="">
+ <AttributeValue DataType="http://www.w3.org/2001/XMLSchema#string">1</AttributeValue>
+ </AttributeAssignmentExpression>
+ <AttributeAssignmentExpression AttributeId="guard" Category="urn:oasis:names:tc:xacml:3.0:attribute-category:resource" Issuer="">
+ <AttributeValue DataType="http://www.w3.org/2001/XMLSchema#string">True</AttributeValue>
+ </AttributeAssignmentExpression>
+ <AttributeAssignmentExpression AttributeId="TTLDate" Category="urn:oasis:names:tc:xacml:3.0:attribute-category:resource" Issuer="">
+ <AttributeValue DataType="http://www.w3.org/2001/XMLSchema#string">08-06-2017</AttributeValue>
+ </AttributeAssignmentExpression>
+ </AdviceExpression>
+ </AdviceExpressions>
+ </Rule>
+ </Policy> \ No newline at end of file
diff --git a/POLICY-SDK-APP/src/test/resources/Config_SampleTest1206.1.xml b/POLICY-SDK-APP/src/test/resources/Config_SampleTest1206.1.xml
index 5c32cd4f1..5390548d9 100644
--- a/POLICY-SDK-APP/src/test/resources/Config_SampleTest1206.1.xml
+++ b/POLICY-SDK-APP/src/test/resources/Config_SampleTest1206.1.xml
@@ -27,7 +27,7 @@
<AttributeDesignator Category="urn:oasis:names:tc:xacml:3.0:attribute-category:resource" AttributeId="guard" DataType="http://www.w3.org/2001/XMLSchema#string" MustBePresent="false"/>
</Match>
<Match MatchId="org.openecomp.function.regex-match">
- <AttributeValue DataType="http://www.w3.org/2001/XMLSchema#string">NA</AttributeValue>
+ <AttributeValue DataType="http://www.w3.org/2001/XMLSchema#string">08-06-2017</AttributeValue>
<AttributeDesignator Category="urn:oasis:names:tc:xacml:3.0:attribute-category:resource" AttributeId="TTLDate" DataType="http://www.w3.org/2001/XMLSchema#string" MustBePresent="false"/>
</Match>
<Match MatchId="org.openecomp.function.regex-match">
@@ -82,7 +82,7 @@
<AttributeValue DataType="http://www.w3.org/2001/XMLSchema#string">True</AttributeValue>
</AttributeAssignmentExpression>
<AttributeAssignmentExpression AttributeId="TTLDate" Category="urn:oasis:names:tc:xacml:3.0:attribute-category:resource" Issuer="">
- <AttributeValue DataType="http://www.w3.org/2001/XMLSchema#string">NA</AttributeValue>
+ <AttributeValue DataType="http://www.w3.org/2001/XMLSchema#string">08-06-2017</AttributeValue>
</AttributeAssignmentExpression>
</AdviceExpression>
</AdviceExpressions>
diff --git a/POLICY-SDK-APP/src/test/resources/Decision_TestDecisionPolicyWithRuleAlgorithms.1.xml b/POLICY-SDK-APP/src/test/resources/Decision_TestDecisionPolicyWithRuleAlgorithms.1.xml
new file mode 100644
index 000000000..74a0e6842
--- /dev/null
+++ b/POLICY-SDK-APP/src/test/resources/Decision_TestDecisionPolicyWithRuleAlgorithms.1.xml
@@ -0,0 +1,85 @@
+<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
+ <Policy xmlns="urn:oasis:names:tc:xacml:3.0:core:schema:wd-17" PolicyId="urn:xacml:policy:id:b622d808-ba62-4392-93c8-eaff0cbfb63f" Version="1" RuleCombiningAlgId="urn:oasis:names:tc:xacml:3.0:rule-combining-algorithm:permit-overrides">
+ <Description>TestDecisionPolicyWithRuleAlgorithms@CreatedBy:rb7147@CreatedBy:@ModifiedBy:rb7147@ModifiedBy:</Description>
+ <Target>
+ <AnyOf>
+ <AllOf>
+ <Match MatchId="org.openecomp.function.regex-match">
+ <AttributeValue DataType="http://www.w3.org/2001/XMLSchema#string">com.Decision_TestDecisionPolicyWithRuleAlgorithms.1.xml</AttributeValue>
+ <AttributeDesignator Category="urn:oasis:names:tc:xacml:1.0:subject-category:access-subject" AttributeId="PolicyName" DataType="http://www.w3.org/2001/XMLSchema#string" MustBePresent="false"/>
+ </Match>
+ </AllOf>
+ <AllOf>
+ <Match MatchId="org.openecomp.function.regex-match">
+ <AttributeValue DataType="http://www.w3.org/2001/XMLSchema#string">Test</AttributeValue>
+ <AttributeDesignator Category="urn:oasis:names:tc:xacml:1.0:subject-category:access-subject" AttributeId="ECOMPName" DataType="http://www.w3.org/2001/XMLSchema#string" MustBePresent="false"/>
+ </Match>
+ <Match MatchId="org.openecomp.function.regex-match">
+ <AttributeValue DataType="http://www.w3.org/2001/XMLSchema#string">test</AttributeValue>
+ <AttributeDesignator Category="urn:oasis:names:tc:xacml:3.0:attribute-category:resource" AttributeId="SamplTest" DataType="http://www.w3.org/2001/XMLSchema#string" MustBePresent="false"/>
+ </Match>
+ </AllOf>
+ </AnyOf>
+ </Target>
+ <VariableDefinition VariableId="TestSettings">
+ <AttributeValue DataType="http://www.w3.org/2001/XMLSchema#string">test</AttributeValue>
+ </VariableDefinition>
+ <Rule RuleId="" Effect="Permit">
+ <Target>
+ <AnyOf>
+ <AllOf>
+ <Match MatchId="urn:oasis:names:tc:xacml:3.0:function:string-equal-ignore-case">
+ <AttributeValue DataType="http://www.w3.org/2001/XMLSchema#string">DECIDE</AttributeValue>
+ <AttributeDesignator Category="urn:oasis:names:tc:xacml:3.0:attribute-category:action" AttributeId="urn:oasis:names:tc:xacml:1.0:action:action-id" DataType="http://www.w3.org/2001/XMLSchema#string" MustBePresent="false"/>
+ </Match>
+ </AllOf>
+ </AnyOf>
+ </Target>
+ <Condition>
+ <Apply FunctionId="urn:oasis:names:tc:xacml:1.0:function:and">
+ <Apply FunctionId="urn:oasis:names:tc:xacml:1.0:function:string-equal">
+ <AttributeValue DataType="http://www.w3.org/2001/XMLSchema#string">Sample</AttributeValue>
+ <Apply FunctionId="urn:oasis:names:tc:xacml:1.0:function:string-one-and-only">
+ <AttributeDesignator Category="urn:oasis:names:tc:xacml:3.0:attribute-category:resource" AttributeId="SamplTest" DataType="http://www.w3.org/2001/XMLSchema#string" MustBePresent="false"/>
+ </Apply>
+ </Apply>
+ <Apply FunctionId="urn:oasis:names:tc:xacml:3.0:function:string-equal-ignore-case">
+ <AttributeValue DataType="http://www.w3.org/2001/XMLSchema#string">test</AttributeValue>
+ <Apply FunctionId="urn:oasis:names:tc:xacml:1.0:function:string-one-and-only">
+ <AttributeDesignator Category="urn:oasis:names:tc:xacml:3.0:attribute-category:resource" AttributeId="SamplTest" DataType="http://www.w3.org/2001/XMLSchema#string" MustBePresent="false"/>
+ </Apply>
+ </Apply>
+ </Apply>
+ </Condition>
+ </Rule>
+ <Rule RuleId="" Effect="Deny">
+ <Target>
+ <AnyOf>
+ <AllOf>
+ <Match MatchId="urn:oasis:names:tc:xacml:3.0:function:string-equal-ignore-case">
+ <AttributeValue DataType="http://www.w3.org/2001/XMLSchema#string">DECIDE</AttributeValue>
+ <AttributeDesignator Category="urn:oasis:names:tc:xacml:3.0:attribute-category:action" AttributeId="urn:oasis:names:tc:xacml:1.0:action:action-id" DataType="http://www.w3.org/2001/XMLSchema#string" MustBePresent="false"/>
+ </Match>
+ </AllOf>
+ </AnyOf>
+ </Target>
+ <Condition>
+ <Apply FunctionId="urn:oasis:names:tc:xacml:1.0:function:not">
+ <Apply FunctionId="urn:oasis:names:tc:xacml:1.0:function:and">
+ <Apply FunctionId="urn:oasis:names:tc:xacml:1.0:function:string-equal">
+ <AttributeValue DataType="http://www.w3.org/2001/XMLSchema#string">Sample</AttributeValue>
+ <Apply FunctionId="urn:oasis:names:tc:xacml:1.0:function:string-one-and-only">
+ <AttributeDesignator Category="urn:oasis:names:tc:xacml:3.0:attribute-category:resource" AttributeId="SamplTest" DataType="http://www.w3.org/2001/XMLSchema#string" MustBePresent="false"/>
+ </Apply>
+ </Apply>
+ <Apply FunctionId="urn:oasis:names:tc:xacml:3.0:function:string-equal-ignore-case">
+ <AttributeValue DataType="http://www.w3.org/2001/XMLSchema#string">test</AttributeValue>
+ <Apply FunctionId="urn:oasis:names:tc:xacml:1.0:function:string-one-and-only">
+ <AttributeDesignator Category="urn:oasis:names:tc:xacml:3.0:attribute-category:resource" AttributeId="SamplTest" DataType="http://www.w3.org/2001/XMLSchema#string" MustBePresent="false"/>
+ </Apply>
+ </Apply>
+ </Apply>
+ </Apply>
+ </Condition>
+ </Rule>
+ </Policy> \ No newline at end of file
diff --git a/POLICY-SDK-APP/src/test/resources/JSONConfig.json b/POLICY-SDK-APP/src/test/resources/JSONConfig.json
new file mode 100644
index 000000000..23f985962
--- /dev/null
+++ b/POLICY-SDK-APP/src/test/resources/JSONConfig.json
@@ -0,0 +1,132 @@
+[
+ {
+ "serviceTypePolicyName": "Registration Failure(Trinity)",
+ "verticaMetrics": "DATETIMEUTC\n VNFC_NAME\n BW_SIP_STATS_REGISTER_RESPONSE_CODE_VALUE \nBW_SIP_STATS_REGISTER_RESPONSE_INS \n BW_SIP_STATS_REGISTER_RESPONSE_OUTS",
+ "attributes": {
+ "Onset&abatement anomaly detection": {
+ "PtileLimit": "Percentile value used by anomaly detection model",
+ "Threshold": "initial value for the quantile at percentile(PtileLimit) used by the anomaly detection model",
+ "Window": "Number of weeks anomaly detection model keeps in memory to estimate Threshold",
+ "Training": "Number of historical weeks anomaly detection model needs for training ",
+ "FractionSamplePerDay": "This corresponds to the minimum number of samples per day to be used in the daily percentile computation when updating the distribution tail crossing model. When there are less samples than that threshold, the model is not updated with these samples. "
+ },
+ "Onset signature trigger": {
+ "ConsecutiveIntervalOnset": "Number of consecutive intervals normalized metric must trigger the anomaly detection model before resulting in an action",
+ "RetryTimer": "Minimum interval between policy triggers"
+ },
+ "Abatement signature trigger": {
+ "ConsecutiveIntervalAbatement": "Number of consecutive intervals normalized metric does not trigger the anomaly detection model after onset signature was triggered"
+ },
+ "Onset & abatement UEB notification": {
+ "OnsetMessage": "Value of field OnSetMessage sent by Analytics Engine published on UEB",
+ "AbatementMessage": "Value of field AbatementMessage sent by Analytics Engine published on UEB",
+ "PolicyName": "Value of field PolicyName sent by Analytics Engine published on UEB"
+ }
+ },
+ "policyDescription": "Policy to detect instances where SIP registration rate exceeds a normal level over a number of consecutive sampling periods. \n Notes \n (1) Vertica metrics normalized and combined in a SIP registration failure probability per Site and per VM. \n (2) Anomaly detection model operates on SIP registration failure probability. \n (3) Anomaly detection consists of an estimated distribution percentile threshold crossing. \n (4) Actions: Send email and/or UEB notification"
+ },
+ {
+ "serviceTypePolicyName": "International Fraud(Trinity)",
+ "verticaMetrics": "INTERVAL_START_TS\n CUSTOMER\n A_SITE\n A_SBG\n BW\n Z_COUNTRY\n CALL_COUNT\n MINUTES_OF_USE",
+ "attributes": {
+ "Onset&abatement anomaly detection": {
+ "PtileLimit": "Percentile value used by anomaly detection model",
+ "Threshold": "initial value for the quantile at percentile(PtileLimit) used by the anomaly detection model",
+ "Window": "Number of weeks anomaly detection model keeps in memory to estimate Threshold",
+ "Training": "Number of historical weeks anomaly detection model needs for training ",
+ "FractionSamplePerDay": "This corresponds to the minimum number of samples per day to be used in the daily percentile computation when updating the distribution tail crossing model. When there are less samples than that threshold, the model is not updated with these samples. "
+ },
+ "Onset signature trigger": {
+ "ConsecutiveIntervalOnset": "Number of consecutive intervals normalized metric must trigger the anomaly detection model before resulting in an action",
+ "RetryTimer": "Minimum interval between policy triggers"
+ },
+ "Abatement signature trigger": {
+ "ConsecutiveIntervalAbatement": "Number of consecutive intervals normalized metric does not trigger the anomaly detection model after onset signature was triggered"
+ },
+ "Onset & abatement UEB notification ": {
+ "OnsetMessage": "Value of field OnSetMessage sent by Analytics Engine published on UEB",
+ "AbatementMessage": "Value of field AbatementMessage sent by Analytics Engine published on UEB",
+ "PolicyName": "Value of field PolicyName sent by Analytics Engine published on UEB"
+ }
+ },
+ "policyDescription": "Policy to detect instances where count of calls towards an international destination exceeds a normal level over a number of consecutive sampling periods. \n Notes \n (1) Vertica metrics normalized and combined in a SIP registration failure probability per Customer, per Site and per VM. \n (2) Anomaly detection model operates on counts towards an international destination. \n (3) Anomaly detection consists of an estimated distribution percentile threshold crossing. \n (4) Actions: Send email and/or UEB notification"
+ },
+ {
+ "serviceTypePolicyName": "No dial tone(Trinity)",
+ "verticaMetrics": "INTERVAL_START_TS\n SUM(CALLS_ATTEMPTED)\n SUM(NO_ANSWER_OR_VOICE_MAIL)\n A_SITE or A_SBG or BW or CUSTOMER",
+ "attributes": {
+ "Onset&abatement anomaly detection": {
+ "PtileLimit": "Percentile value used by anomaly detection model",
+ "Threshold": "initial value for the quantile at percentile(PtileLimit) used by the anomaly detection model",
+ "Window": "Number of weeks anomaly detection model keeps in memory to estimate Threshold",
+ "Training": "Number of historical weeks anomaly detection model needs for training ",
+ "FractionSamplePerDay": "This corresponds to the minimum number of samples per day to be used in the daily percentile computation when updating the distribution tail crossing model. When there are less samples than that threshold, the model is not updated with these samples. "
+ },
+ "Onset signature trigger": {
+ "ConsecutiveIntervalOnset": "Number of consecutive intervals normalized metric must trigger the anomaly detection model before resulting in an action",
+ "RetryTimer": "Minimum interval between policy triggers"
+ },
+ "Abatement signature trigger": {
+ "ConsecutiveIntervalAbatement": "Number of consecutive intervals normalized metric does not trigger the anomaly detection model after onset signature was triggered"
+ },
+ "Onset & abatement UEB notification ": {
+ "OnsetMessage": "Value of field OnSetMessage sent by Analytics Engine published on UEB",
+ "AbatementMessage": "Value of field AbatementMessage sent by Analytics Engine published on UEB",
+ "PolicyName": "Value of field PolicyName sent by Analytics Engine published on UEB"
+ }
+ },
+ "policyDescription": "Policy to detect ? \n Notes:\n (1) Actions: Send email and/or UEB notification"
+ },
+ {
+ "serviceTypePolicyName": "Call storm(Trinity)",
+ "verticaMetrics": "",
+ "attributes": {
+ "Onset&abatement anomaly detection": {
+ "SeasonLength": "Metric seasonality (5min sampling period with 7 days seasonality: 7*288) used by Holt-Winters model",
+ "TrainLength": "Training length (5min sampling period with 7 days seasonality and 5 cycles training: 7*288*5) used by Holt-Winters",
+ "Alpha": "Smoothing parameter (range 0-1, default 0.2)",
+ "Beta": "Trend parameter (range 0-1, default 0) ",
+ "Gamma": "Seasonality (range 0-1, default 0.05)",
+ "Deviation Threshold": "Approximately a limit on the factor by how much current value has deviated compared to expected variance"
+ },
+ "Onset signature trigger": {
+ "RetryTimer": "Minimum interval between policy triggers"
+ },
+ "Abatement signature trigger": {
+ "Hw-Timeout": "Maximum time for an HealthCheck response (measured from the time a positive App-C response was received)",
+ "OnSetMessage": "Value of field Message sent by Analytics Engine published on UEB "
+ },
+ "Onset & abatement UEB notification ": {
+ "AbatementMessage": "Value of field AbatementMessage sent by Analytics Engine published on UEB",
+ "PolicyName": "Value of field PolicyName sent by Analytics Engine published on UEB"
+ }
+ },
+ "policyDescription": "Policy to detect instances where count of Formatted table ? exceeds a predicted level. \n Notes \n (1) Vertica metrics normalized and combined in ? per Customer, per Site and per VM. \n (2) Anomaly detection model operates on ? \n (3) Anomaly detection consists of detecting deviations from Holt-Winters predictions. \n (4) Actions: Send email and/or UEB notification"
+ },
+ {
+ "serviceTypePolicyName": "Registration storm(Trinity)",
+ "verticaMetrics": "",
+ "attributes": {
+ "Onset&abatement anomaly detection": {
+ "SeasonLength": "Metric seasonality (5min sampling period with 7 days seasonality: 7*288) used by Holt-Winters model",
+ "TrainLength": "Training length (5min sampling period with 7 days seasonality and 5 cycles training: 7*288*5) used by Holt-Winters",
+ "Alpha": "Smoothing parameter (range 0-1, default 0.2)",
+ "Beta": "Trend parameter (range 0-1, default 0) ",
+ "Gamma": "Seasonality (range 0-1, default 0.05)",
+ "Deviation Threshold": "Approximately a limit on the factor by how much current value has deviated compared to expected variance"
+ },
+ "Onset signature trigger": {
+ "RetryTimer": "Minimum interval between policy triggers"
+ },
+ "Abatement signature trigger": {
+ "Hw-Timeout": "Maximum time for an HealthCheck response (measured from the time a positive App-C response was received)",
+ "OnSetMessage": "Value of field Message sent by Analytics Engine published on UEB "
+ },
+ "Onset & abatement UEB notification ": {
+ "AbatementMessage": "Value of field AbatementMessage sent by Analytics Engine published on UEB",
+ "PolicyName": "Value of field PolicyName sent by Analytics Engine published on UEB"
+ }
+ },
+ "policyDescription": "Policy to detect instances where count of Formatted table ? exceeds a predicted level. \n Notes \n (1) Vertica metrics normalized and combined in ? per Customer, per Site and per VM. \n (2) Anomaly detection model operates on ? \n (3) Anomaly detection consists of detecting deviations from Holt-Winters predictions. \n (4) Actions: Send email and/or UEB notification"
+ }
+] \ No newline at end of file
diff --git a/POLICY-SDK-APP/src/test/resources/com.Action_TestActionPolicy.1.json b/POLICY-SDK-APP/src/test/resources/com.Action_TestActionPolicy.1.json
new file mode 100644
index 000000000..7f228f99e
--- /dev/null
+++ b/POLICY-SDK-APP/src/test/resources/com.Action_TestActionPolicy.1.json
@@ -0,0 +1 @@
+{"a":"b"} \ No newline at end of file
diff --git a/POLICY-SDK-APP/src/test/resources/com.Config_BRMS_Param_BRMSParamvFWDemoPolicy.1.txt b/POLICY-SDK-APP/src/test/resources/com.Config_BRMS_Param_BRMSParamvFWDemoPolicy.1.txt
new file mode 100644
index 000000000..955afbd0f
--- /dev/null
+++ b/POLICY-SDK-APP/src/test/resources/com.Config_BRMS_Param_BRMSParamvFWDemoPolicy.1.txt
@@ -0,0 +1,1145 @@
+/* Autogenerated Code Please Don't change/remove this comment section. This is for the UI purpose.
+ <$%BRMSParamTemplate=ControlLoopDemo__closedLoopControlName%$>
+ */
+
+
+/*-
+ * ============LICENSE_START=======================================================
+ * archetype-closed-loop-demo-rules
+ * ================================================================================
+ * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.
+ * ================================================================================
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * ============LICENSE_END=========================================================
+ */
+
+package org.openecomp.policy.controlloop;
+
+import java.util.List;
+import java.util.LinkedList;
+import java.util.Map;
+import java.util.HashMap;
+import java.util.UUID;
+
+import org.openecomp.policy.controlloop.VirtualControlLoopEvent;
+import org.openecomp.policy.controlloop.ControlLoopEventStatus;
+import org.openecomp.policy.controlloop.VirtualControlLoopNotification;
+import org.openecomp.policy.controlloop.ControlLoopNotificationType;
+import org.openecomp.policy.controlloop.ControlLoopOperation;
+import org.openecomp.policy.controlloop.ControlLoopOperationWrapper;
+import org.openecomp.policy.template.demo.ControlLoopException;
+
+import org.openecomp.policy.aai.AAINQF199.AAINQF199CloudRegion;
+import org.openecomp.policy.aai.AAINQF199.AAINQF199ExtraProperties;
+import org.openecomp.policy.aai.AAINQF199.AAINQF199ExtraProperty;
+import org.openecomp.policy.aai.AAINQF199.AAINQF199GenericVNF;
+import org.openecomp.policy.aai.AAINQF199.AAINQF199InstanceFilters;
+import org.openecomp.policy.aai.AAINQF199.AAINQF199InventoryResponseItem;
+import org.openecomp.policy.aai.AAINQF199.AAINQF199InventoryResponseItems;
+import org.openecomp.policy.aai.AAINQF199.AAINQF199Manager;
+import org.openecomp.policy.aai.AAINQF199.AAINQF199NamedQuery;
+import org.openecomp.policy.aai.AAINQF199.AAINQF199QueryParameters;
+import org.openecomp.policy.aai.AAINQF199.AAINQF199Request;
+import org.openecomp.policy.aai.AAINQF199.AAINQF199RequestWrapper;
+import org.openecomp.policy.aai.AAINQF199.AAINQF199Response;
+import org.openecomp.policy.aai.AAINQF199.AAINQF199ResponseWrapper;
+import org.openecomp.policy.aai.AAINQF199.AAINQF199ServiceInstance;
+import org.openecomp.policy.aai.AAINQF199.AAINQF199Tenant;
+import org.openecomp.policy.aai.AAINQF199.AAINQF199VfModule;
+import org.openecomp.policy.aai.AAINQF199.AAINQF199VServer;
+import org.openecomp.policy.aai.util.Serialization;
+
+import org.openecomp.policy.appc.CommonHeader;
+import org.openecomp.policy.appc.Request;
+import org.openecomp.policy.appc.Response;
+import org.openecomp.policy.appc.ResponseCode;
+import org.openecomp.policy.appc.ResponseStatus;
+import org.openecomp.policy.appc.ResponseValue;
+
+import org.openecomp.policy.template.demo.EventManager;
+import org.openecomp.policy.vnf.trafficgenerator.PGRequest;
+import org.openecomp.policy.vnf.trafficgenerator.PGStream;
+import org.openecomp.policy.vnf.trafficgenerator.PGStreams;
+
+import org.openecomp.policy.mso.MSOManager;
+import org.openecomp.policy.mso.MSORequest;
+import org.openecomp.policy.mso.MSORequestStatus;
+import org.openecomp.policy.mso.MSORequestDetails;
+import org.openecomp.policy.mso.MSOModelInfo;
+import org.openecomp.policy.mso.MSOCloudConfiguration;
+import org.openecomp.policy.mso.MSORequestInfo;
+import org.openecomp.policy.mso.MSORequestParameters;
+import org.openecomp.policy.mso.MSORelatedInstanceListElement;
+import org.openecomp.policy.mso.MSORelatedInstance;
+import org.openecomp.policy.mso.MSOResponse;
+
+import org.openecomp.policy.drools.system.PolicyEngine;
+
+//
+// These parameters are required to build the runtime policy
+//
+declare Params
+ closedLoopControlName : String
+ actor : String
+ aaiURL : String
+ aaiUsername : String
+ aaiPassword : String
+ msoURL : String
+ msoUsername : String
+ msoPassword : String
+ aaiNamedQueryUUID : String
+ aaiPatternMatch : int
+ notificationTopic : String
+ appcTopic : String
+end
+
+/*
+*
+* Called once and only once to insert the parameters into working memory for this Closed Loop policy.
+* (Comment SETUP rule out for the first ECOMP opensource release since policy BRMS_GW already puts a Params fact in there)
+*
+*
+*rule "BRMSParamvFWDemoPolicy.SETUP"
+* when
+* then
+* System.out.println("rule SETUP is triggered.");
+* Params params = new Params();
+* params.setClosedLoopControlName("CL-FRWL-LOW-TRAFFIC-SIG-d925ed73-8231-4d02-9545-db4e101f88f8");
+* params.setActor("APPC");
+* params.setAaiURL("null");
+* params.setAaiUsername("null");
+* params.setAaiPassword("null");
+* params.setMsoURL("null");
+* params.setMsoUsername("null");
+* params.setMsoPassword("null");
+* params.setAaiNamedQueryUUID("null");
+* params.setAaiPatternMatch(1);
+* params.setNotificationTopic("POLICY-CL-MGT");
+* params.setAppcTopic("APPC-CL");
+* //
+* // This stays in memory as long as the rule is alive and running
+* //
+* insert(params);
+*end
+*/
+/*
+*
+* This rule responds to DCAE Events
+*
+*/
+rule "BRMSParamvFWDemoPolicy.EVENT"
+ when
+ $params : Params( getClosedLoopControlName() == "CL-FRWL-LOW-TRAFFIC-SIG-d925ed73-8231-4d02-9545-db4e101f88f8" )
+ $event : VirtualControlLoopEvent( closedLoopControlName == $params.getClosedLoopControlName(), closedLoopEventStatus == ControlLoopEventStatus.ONSET )
+ not ( EventManager( closedLoopControlName == $event.closedLoopControlName ))
+ then
+ System.out.println("rule EVENT is triggered.");
+ try {
+ //
+ // Check the requestID in the event to make sure it is not null before we create the EventManager.
+ // The EventManager will do extra syntax checking as well check if the closed loop is disabled/
+ //
+ if ($event.requestID == null) {
+ VirtualControlLoopNotification notification = new VirtualControlLoopNotification($event);
+ notification.notification = ControlLoopNotificationType.REJECTED;
+ notification.from = "policy";
+ notification.message = "Missing requestID from DCAE event";
+ notification.policyName = drools.getRule().getName();
+ notification.policyScope = "com";
+ notification.policyVersion = "1";
+ //
+ // Let interested parties know
+ //
+ try {
+ System.out.println(Serialization.gsonPretty.toJson(notification));
+ PolicyEngine.manager.deliver($params.getNotificationTopic(), notification);
+ } catch (Exception e) {
+ e.printStackTrace();
+ System.out.println("Can't deliver notification: " + notification);
+ }
+ //
+ // Retract it from memory
+ //
+ retract($event);
+ System.out.println("Event with requestID=null has been retracted.");
+ } else {
+ //
+ // Create an EventManager
+ //
+ EventManager manager = new EventManager($params.getClosedLoopControlName(), $event.requestID, $event.target);
+ //
+ // Determine if EventManager can actively process the event (i.e. syntax)
+ //
+ VirtualControlLoopNotification notification = manager.activate($event);
+ notification.from = "policy";
+ notification.policyName = drools.getRule().getName();
+ notification.policyScope = "com";
+ notification.policyVersion = "1";
+ //
+ // Are we actively pursuing this event?
+ //
+ if (notification.notification == ControlLoopNotificationType.ACTIVE) {
+ //
+ // Insert Event Manager into memory, this will now kick off processing.
+ //
+ insert(manager);
+ //
+ // Let interested parties know
+ //
+ try {
+ System.out.println(Serialization.gsonPretty.toJson(notification));
+ PolicyEngine.manager.deliver($params.getNotificationTopic(), notification);
+ } catch (Exception e) {
+ e.printStackTrace();
+ System.out.println("Can't deliver notification: " + notification);
+ }
+ } else {
+ //
+ // Let interested parties know
+ //
+ try {
+ System.out.println(Serialization.gsonPretty.toJson(notification));
+ PolicyEngine.manager.deliver($params.getNotificationTopic(), notification);
+ } catch (Exception e) {
+ e.printStackTrace();
+ System.out.println("Can't deliver notification: " + notification);
+ }
+ //
+ // Retract it from memory
+ //
+ retract($event);
+ }
+ //
+ // Now that the manager is inserted into Drools working memory, we'll wait for
+ // another rule to fire in order to continue processing. This way we can also
+ // then screen for additional ONSET and ABATED events for this same RequestIDs
+ // and for different RequestIDs but with the same closedLoopControlName and target.
+ //
+ }
+ //
+ } catch (Exception e) {
+ e.printStackTrace();
+ VirtualControlLoopNotification notification = new VirtualControlLoopNotification($event);
+ notification.notification = ControlLoopNotificationType.REJECTED;
+ notification.message = "Exception occurred " + e.getMessage();
+ notification.policyName = drools.getRule().getName();
+ notification.policyScope = "com";
+ notification.policyVersion = "1";
+ //
+ //
+ //
+ try {
+ System.out.println(Serialization.gsonPretty.toJson(notification));
+ PolicyEngine.manager.deliver($params.getNotificationTopic(), notification);
+ } catch (Exception e1) {
+ System.out.println("Can't deliver notification: " + notification);
+ e1.printStackTrace();
+ }
+ //
+ // Retract the event
+ //
+ retract($event);
+ }
+end
+
+/*
+*
+* This rule happens when we got a valid ONSET, closed loop is enabled and an Event Manager
+* is created. We can start the operations for this closed loop.
+*
+*/
+rule "BRMSParamvFWDemoPolicy.EVENT.MANAGER"
+ when
+ $params : Params( getClosedLoopControlName() == "CL-FRWL-LOW-TRAFFIC-SIG-d925ed73-8231-4d02-9545-db4e101f88f8" )
+ $event : VirtualControlLoopEvent( closedLoopControlName == $params.getClosedLoopControlName(), closedLoopEventStatus == ControlLoopEventStatus.ONSET )
+ $manager : EventManager( closedLoopControlName == $event.closedLoopControlName, controlLoopResult == null)
+ then
+ System.out.println("rule EVENT.MANAGER is triggered.");
+ //
+ // Check which event this is.
+ //
+ EventManager.NEW_EVENT_STATUS eventStatus = $manager.onNewEvent($event);
+ //
+ // We only want the initial ONSET event in memory,
+ // all the other events need to be retracted to support
+ // cleanup and avoid the other rules being fired for this event.
+ //
+ if (eventStatus != EventManager.NEW_EVENT_STATUS.FIRST_ONSET) {
+ System.out.println("Retracting "+eventStatus+" Event.");
+ retract($event);
+ return;
+ }
+ //
+ // Now the event in memory is first onset event
+ //
+ try {
+ //
+ // Pull the known AAI field from the Event
+ //
+ // generic-vnf is needed for vFirewall case
+ // vserver-name is needed for vLoadBalancer case
+ //
+ String genericVNF = $event.AAI.get("generic-vnf.vnf-id");
+ String vserver = $event.AAI.get("vserver.vserver-name");
+ //
+ // Check if we are implementing a simple pattern match.
+ //
+ if ($params.getAaiPatternMatch() == 1) {
+ //
+ // Yes
+ //
+ //Basic naming characteristics:
+ //VF Name (9 char)+VM name (13 char total)+VFC (19 char total)
+ //Example:
+ //VF Name (9 characters): cscf0001v
+ //VM Name(13 characters): cscf0001vm001
+ //VFC name(19 characters): cscf0001vm001cfg001
+ //
+ // zdfw1fwl01fwl02 or zdfw1fwl01fwl01
+ // replaced with
+ // zdfw1fwl01pgn02 or zdfw1fwl01pgn01
+ //
+ int index = genericVNF.lastIndexOf("fwl");
+ if (index == -1) {
+ System.err.println("The generic-vnf.vnf-id from DCAE Event is not valid.");
+ } else {
+ genericVNF = genericVNF.substring(0, index) + "pgn" + genericVNF.substring(index+"fwl".length());
+ }
+ //
+ // Construct an APPC request
+ //
+ ControlLoopOperation operation = new ControlLoopOperation();
+ operation.actor = $params.getActor();
+ operation.operation = "ModifyConfig";
+ operation.target = $event.target;
+ //
+ // Create operationWrapper
+ //
+ ControlLoopOperationWrapper operationWrapper = new ControlLoopOperationWrapper($event.requestID, operation);
+ //
+ // insert operationWrapper into memory
+ //
+ insert(operationWrapper);
+ //
+ Request request = new Request();
+ request.CommonHeader = new CommonHeader();
+ request.CommonHeader.RequestID = $event.requestID;
+ request.Action = operation.operation;
+ request.Payload = new HashMap<String, Object>();
+ //
+ // Fill in the payload
+ //
+ request.Payload.put("generic-vnf.vnf-id", genericVNF);
+ //
+ PGRequest pgRequest = new PGRequest();
+ pgRequest.pgStreams = new PGStreams();
+
+ PGStream pgStream;
+ for(int i = 0; i < 5; i++){
+ pgStream = new PGStream();
+ pgStream.streamId = "fw_udp"+(i+1);
+ pgStream.isEnabled = "true";
+ pgRequest.pgStreams.pgStream.add(pgStream);
+ }
+ request.Payload.put("pg-streams", pgRequest.pgStreams);
+
+ if (request != null) {
+ //
+ // Insert request into memory
+ //
+ insert(request);
+ //
+ // Tell interested parties we are performing this Operation
+ //
+ VirtualControlLoopNotification notification = new VirtualControlLoopNotification($event);
+ notification.notification = ControlLoopNotificationType.OPERATION;
+ // message and history ??
+ notification.from = "policy";
+ notification.policyName = drools.getRule().getName();
+ notification.policyScope = "com";
+ notification.policyVersion = "1";
+ try {
+ System.out.println(Serialization.gsonPretty.toJson(notification));
+ PolicyEngine.manager.deliver($params.getNotificationTopic(), notification);
+ } catch (Exception e) {
+ System.out.println("Can't deliver notification: " + notification);
+ e.printStackTrace();
+ }
+ //
+ // Now send the operation request
+ //
+ if (request instanceof Request) {
+ try {
+ System.out.println("APPC request sent:");
+ System.out.println(Serialization.gsonPretty.toJson(request));
+ PolicyEngine.manager.deliver($params.getAppcTopic(), request);
+ } catch (Exception e) {
+ e.printStackTrace();
+ System.out.println("Can't deliver request: " + request);
+ }
+ }
+ } else {
+ //
+ // what happens if it is null
+ //
+ }
+ //
+ } else {
+ //
+ // create AAI named-query request with UUID started with "F199"
+ //
+ AAINQF199Request aainqf199request = new AAINQF199Request();
+ AAINQF199QueryParameters aainqf199queryparam = new AAINQF199QueryParameters();
+ AAINQF199NamedQuery aainqf199namedquery = new AAINQF199NamedQuery();
+ AAINQF199InstanceFilters aainqf199instancefilter = new AAINQF199InstanceFilters();
+ //
+ // queryParameters
+ //
+ aainqf199namedquery.namedQueryUUID = UUID.fromString($params.getAaiNamedQueryUUID());
+ aainqf199queryparam.namedQuery = aainqf199namedquery;
+ aainqf199request.queryParameters = aainqf199queryparam;
+ //
+ // instanceFilters
+ //
+ Map aainqf199instancefiltermap = new HashMap();
+ Map aainqf199instancefiltermapitem = new HashMap();
+ aainqf199instancefiltermapitem.put("vserver-name", vserver);
+ aainqf199instancefiltermap.put("vserver", aainqf199instancefiltermapitem);
+ aainqf199instancefilter.instanceFilter.add(aainqf199instancefiltermap);
+ aainqf199request.instanceFilters = aainqf199instancefilter;
+ //
+ // print aainqf199request for debug
+ //
+ System.out.println("AAI Request sent:");
+ System.out.println(Serialization.gsonPretty.toJson(aainqf199request));
+ //
+ // Create AAINQF199RequestWrapper
+ //
+ AAINQF199RequestWrapper aainqf199RequestWrapper = new AAINQF199RequestWrapper($event.requestID, aainqf199request);
+ //
+ // insert aainqf199request into memory
+ //
+ insert(aainqf199RequestWrapper);
+ }
+ //
+ } catch (Exception e) {
+ e.printStackTrace();
+ }
+end
+
+/*
+*
+* This rule happens when we got a valid ONSET, closed loop is enabled, an Event Manager
+* is created, AAI Manager and AAI Request are ready in memory. We can start sending query to AAI and then wait for response.
+*
+*/
+rule "BRMSParamvFWDemoPolicy.EVENT.MANAGER.AAINQF199REQUEST"
+ when
+ $params : Params( getClosedLoopControlName() == "CL-FRWL-LOW-TRAFFIC-SIG-d925ed73-8231-4d02-9545-db4e101f88f8" )
+ $event : VirtualControlLoopEvent( closedLoopControlName == $params.getClosedLoopControlName(), closedLoopEventStatus == ControlLoopEventStatus.ONSET )
+ $manager : EventManager( closedLoopControlName == $event.closedLoopControlName )
+ $aainqf199RequestWrapper : AAINQF199RequestWrapper(requestID == $event.requestID)
+ then
+ System.out.println("rule EVENT.MANAGER.AAINQF199REQUEST is triggered.");
+ //
+ // send the request
+ //
+ AAINQF199Response aainqf199response = AAINQF199Manager.postQuery($params.getAaiURL(), $params.getAaiUsername(), $params.getAaiPassword(),
+ $aainqf199RequestWrapper.aainqf199request, $event.requestID);
+ //
+ // Check AAI response
+ //
+ if (aainqf199response == null) {
+ System.err.println("Failed to get AAI response");
+ //
+ // Fail and retract everything
+ //
+ retract($event);
+ retract($manager);
+ retract($aainqf199RequestWrapper);
+ } else {
+ //
+ // Create AAINQF199ResponseWrapper
+ //
+ AAINQF199ResponseWrapper aainqf199ResponseWrapper = new AAINQF199ResponseWrapper($event.requestID, aainqf199response);
+ //
+ // insert aainqf199ResponseWrapper to memeory
+ //
+ insert(aainqf199ResponseWrapper);
+ }
+end
+
+/*
+*
+* This rule happens when we got a valid AAI response. We can start sending request to APPC or MSO now.
+*
+*/
+rule "BRMSParamvFWDemoPolicy.EVENT.MANAGER.AAINQF199RESPONSE"
+ when
+ $params : Params( getClosedLoopControlName() == "CL-FRWL-LOW-TRAFFIC-SIG-d925ed73-8231-4d02-9545-db4e101f88f8" )
+ $event : VirtualControlLoopEvent( closedLoopControlName == $params.getClosedLoopControlName(), closedLoopEventStatus == ControlLoopEventStatus.ONSET )
+ $manager : EventManager( closedLoopControlName == $event.closedLoopControlName )
+ $aainqf199RequestWrapper : AAINQF199RequestWrapper(requestID == $event.requestID)
+ $aainqf199ResponseWrapper : AAINQF199ResponseWrapper(requestID == $event.requestID)
+ then
+ System.out.println("rule EVENT.MANAGER.AAINQF199RESPONSE is triggered.");
+ //
+ // Extract related fields out of AAINQF199RESPONSE
+ //
+ String vnfItemVnfId, vnfItemVnfType, vnfItemPersonaModelId, vnfItemPersonaModelVersion, vnfItemModelName,
+ vnfItemModelVersion, vnfItemModelNameVersionId, serviceItemServiceInstanceId, serviceItemPersonaModelId,
+ serviceItemModelName, serviceItemModelType, serviceItemModelVersion, serviceItemModelNameVersionId,
+ vfModuleItemVfModuleName, vfModuleItemPersonaModelId, vfModuleItemPersonaModelVersion, vfModuleItemModelName,
+ vfModuleItemModelNameVersionId, tenantItemTenantId, cloudRegionItemCloudRegionId;
+ try {
+ //
+ // vnfItem
+ //
+ vnfItemVnfId = $aainqf199ResponseWrapper.aainqf199response.inventoryResponseItems.get(0).items.inventoryResponseItems.get(0).genericVNF.vnfID;
+ vnfItemVnfType = $aainqf199ResponseWrapper.aainqf199response.inventoryResponseItems.get(0).items.inventoryResponseItems.get(0).genericVNF.vnfType;
+ vnfItemVnfType = vnfItemVnfType.substring(vnfItemVnfType.lastIndexOf("/")+1);
+ vnfItemPersonaModelId = $aainqf199ResponseWrapper.aainqf199response.inventoryResponseItems.get(0).items.inventoryResponseItems.get(0).genericVNF.personaModelId;
+ vnfItemPersonaModelVersion = $aainqf199ResponseWrapper.aainqf199response.inventoryResponseItems.get(0).items.inventoryResponseItems.get(0).genericVNF.personaModelVersion;
+ vnfItemModelName = $aainqf199ResponseWrapper.aainqf199response.inventoryResponseItems.get(0).items.inventoryResponseItems.get(0).extraProperties.extraProperty.get(0).propertyValue;
+ vnfItemModelVersion = $aainqf199ResponseWrapper.aainqf199response.inventoryResponseItems.get(0).items.inventoryResponseItems.get(0).extraProperties.extraProperty.get(2).propertyValue;
+ vnfItemModelNameVersionId = $aainqf199ResponseWrapper.aainqf199response.inventoryResponseItems.get(0).items.inventoryResponseItems.get(0).extraProperties.extraProperty.get(4).propertyValue;
+ //
+ // serviceItem
+ //
+ serviceItemServiceInstanceId = $aainqf199ResponseWrapper.aainqf199response.inventoryResponseItems.get(0).items.inventoryResponseItems.get(0).items.inventoryResponseItems.get(0).serviceInstance.serviceInstanceID;
+ serviceItemPersonaModelId = $aainqf199ResponseWrapper.aainqf199response.inventoryResponseItems.get(0).items.inventoryResponseItems.get(0).items.inventoryResponseItems.get(0).serviceInstance.personaModelId;
+ serviceItemModelName = $aainqf199ResponseWrapper.aainqf199response.inventoryResponseItems.get(0).items.inventoryResponseItems.get(0).items.inventoryResponseItems.get(0).extraProperties.extraProperty.get(0).propertyValue;
+ serviceItemModelType = $aainqf199ResponseWrapper.aainqf199response.inventoryResponseItems.get(0).items.inventoryResponseItems.get(0).items.inventoryResponseItems.get(0).extraProperties.extraProperty.get(1).propertyValue;
+ serviceItemModelVersion = $aainqf199ResponseWrapper.aainqf199response.inventoryResponseItems.get(0).items.inventoryResponseItems.get(0).items.inventoryResponseItems.get(0).serviceInstance.personaModelVersion;
+ serviceItemModelNameVersionId = $aainqf199ResponseWrapper.aainqf199response.inventoryResponseItems.get(0).items.inventoryResponseItems.get(0).items.inventoryResponseItems.get(0).extraProperties.extraProperty.get(4).propertyValue;
+ //
+ // Find the index for base vf module and non-base vf module
+ //
+ int baseIndex = -1;
+ int nonBaseIndex = -1;
+ List<AAINQF199InventoryResponseItem> inventoryItems = $aainqf199ResponseWrapper.aainqf199response.inventoryResponseItems.get(0).items.inventoryResponseItems.get(0).items.inventoryResponseItems;
+ for (AAINQF199InventoryResponseItem m : inventoryItems) {
+ if (m.vfModule != null && m.vfModule.isBaseVfModule == true) {
+ baseIndex = inventoryItems.indexOf(m);
+ } else if (m.vfModule != null && m.vfModule.isBaseVfModule == false && m.vfModule.orchestrationStatus == null) {
+ nonBaseIndex = inventoryItems.indexOf(m);
+ }
+ //
+ if (baseIndex != -1 && nonBaseIndex != -1) {
+ break;
+ }
+ }
+ //
+ // Report the error if either base vf module or non-base vf module is not found
+ //
+ if (baseIndex == -1 || nonBaseIndex == -1) {
+ System.err.println("Either base or non-base vf module is not found from AAI response.");
+ retract($aainqf199RequestWrapper);
+ retract($aainqf199ResponseWrapper);
+ retract($manager);
+ retract($event);
+ return;
+ }
+ //
+ // This comes from the base module
+ //
+ vfModuleItemVfModuleName = $aainqf199ResponseWrapper.aainqf199response.inventoryResponseItems.get(0).items.inventoryResponseItems.get(0).items.inventoryResponseItems.get(baseIndex).vfModule.vfModuleName;
+ vfModuleItemVfModuleName = vfModuleItemVfModuleName.replace("Vfmodule", "vDNS");
+ //
+ // vfModuleItem - NOT the base module
+ //
+ vfModuleItemPersonaModelId = $aainqf199ResponseWrapper.aainqf199response.inventoryResponseItems.get(0).items.inventoryResponseItems.get(0).items.inventoryResponseItems.get(nonBaseIndex).vfModule.personaModelId;
+ vfModuleItemPersonaModelVersion = $aainqf199ResponseWrapper.aainqf199response.inventoryResponseItems.get(0).items.inventoryResponseItems.get(0).items.inventoryResponseItems.get(nonBaseIndex).vfModule.personaModelVersion;
+ vfModuleItemModelName = $aainqf199ResponseWrapper.aainqf199response.inventoryResponseItems.get(0).items.inventoryResponseItems.get(0).items.inventoryResponseItems.get(nonBaseIndex).extraProperties.extraProperty.get(0).propertyValue;
+ vfModuleItemModelNameVersionId = $aainqf199ResponseWrapper.aainqf199response.inventoryResponseItems.get(0).items.inventoryResponseItems.get(0).items.inventoryResponseItems.get(nonBaseIndex).extraProperties.extraProperty.get(4).propertyValue;
+ //
+ // tenantItem
+ //
+ tenantItemTenantId = $aainqf199ResponseWrapper.aainqf199response.inventoryResponseItems.get(0).items.inventoryResponseItems.get(1).tenant.tenantId;
+ //
+ // cloudRegionItem
+ //
+ cloudRegionItemCloudRegionId = $aainqf199ResponseWrapper.aainqf199response.inventoryResponseItems.get(0).items.inventoryResponseItems.get(1).items.inventoryResponseItems.get(0).cloudRegion.cloudRegionId;
+ //
+ } catch (Exception e) {
+ e.printStackTrace();
+ VirtualControlLoopNotification notification = new VirtualControlLoopNotification($event);
+ notification.notification = ControlLoopNotificationType.REJECTED;
+ notification.message = "Exception occurred " + e.getMessage();
+ notification.policyName = drools.getRule().getName();
+ notification.policyScope = "com";
+ notification.policyVersion = "1";
+ //
+ try {
+ System.out.println(Serialization.gsonPretty.toJson(notification));
+ PolicyEngine.manager.deliver($params.getNotificationTopic(), notification);
+ } catch (Exception e1) {
+ System.out.println("Can't deliver notification: " + notification);
+ e1.printStackTrace();
+ }
+ //
+ notification.notification = ControlLoopNotificationType.FINAL_FAILURE;
+ notification.message = "Invalid named-query response from AAI";
+ //
+ try {
+ System.out.println(Serialization.gsonPretty.toJson(notification));
+ PolicyEngine.manager.deliver($params.getNotificationTopic(), notification);
+ } catch (Exception e1) {
+ System.out.println("Can't deliver notification: " + notification);
+ e1.printStackTrace();
+ }
+ //
+ // Retract everything
+ //
+ retract($aainqf199RequestWrapper);
+ retract($aainqf199ResponseWrapper);
+ retract($manager);
+ retract($event);
+ return;
+ }
+ //
+ // Extracted fields should not be null
+ //
+ if ((vnfItemVnfId == null) || (vnfItemVnfType == null) ||
+ (vnfItemPersonaModelId == null) || (vnfItemModelName == null) ||
+ (vnfItemModelVersion == null) || (vnfItemModelNameVersionId == null) ||
+ (serviceItemServiceInstanceId == null) || (serviceItemModelName == null) ||
+ (serviceItemModelType == null) || (serviceItemModelVersion == null) ||
+ (serviceItemModelNameVersionId == null) || (vfModuleItemVfModuleName == null) ||
+ (vfModuleItemPersonaModelId == null) || (vfModuleItemPersonaModelVersion == null) ||
+ (vfModuleItemModelName == null) || (vfModuleItemModelNameVersionId == null) ||
+ (tenantItemTenantId == null) || (cloudRegionItemCloudRegionId == null)) {
+ //
+ System.err.println("some fields are missing from AAI response.");
+ //
+ // Fail and retract everything
+ //
+ retract($aainqf199RequestWrapper);
+ retract($aainqf199ResponseWrapper);
+ retract($manager);
+ retract($event);
+ return;
+ }
+ //
+ // We don't need them any more
+ //
+ retract($aainqf199ResponseWrapper);
+ retract($aainqf199RequestWrapper);
+ //
+ // check the actor of this closed loop
+ //
+ switch ($params.getActor()) {
+ case "APPC":
+ {
+ //
+ // Construct an APPC request
+ //
+ ControlLoopOperation operation = new ControlLoopOperation();
+ operation.actor = $params.getActor();
+ operation.operation = "ModifyConfig";
+ operation.target = $event.target;
+ //
+ // Create operationWrapper
+ //
+ ControlLoopOperationWrapper operationWrapper = new ControlLoopOperationWrapper($event.requestID, operation);
+ //
+ // insert operationWrapper into memory
+ //
+ insert(operationWrapper);
+ //
+ Request request = new Request();
+ request.CommonHeader = new CommonHeader();
+ request.CommonHeader.RequestID = $event.requestID;
+ request.Action = operation.operation;
+ request.Payload = new HashMap<String, Object>();
+ //
+ // Fill in the payload
+ // Hardcode genericVNF for now since AAI has not been ready for vFirewall demo case
+ //
+ String genericVNF = "zdfw1fwl01pgn02";
+ request.Payload.put("generic-vnf.vnf-id", genericVNF);
+ //
+ PGRequest pgRequest = new PGRequest();
+ pgRequest.pgStreams = new PGStreams();
+
+ PGStream pgStream;
+ for(int i = 0; i < 5; i++){
+ pgStream = new PGStream();
+ pgStream.streamId = "fw_udp"+(i+1);
+ pgStream.isEnabled = "true";
+ pgRequest.pgStreams.pgStream.add(pgStream);
+ }
+ request.Payload.put("pg-streams", pgRequest.pgStreams);
+
+ if (request != null) {
+ //
+ // Insert request into memory
+ //
+ insert(request);
+ //
+ // Tell interested parties we are performing this Operation
+ //
+ VirtualControlLoopNotification notification = new VirtualControlLoopNotification($event);
+ notification.notification = ControlLoopNotificationType.OPERATION;
+ // message and history ??
+ notification.from = "policy";
+ notification.policyName = drools.getRule().getName();
+ notification.policyScope = "com";
+ notification.policyVersion = "1";
+ try {
+ System.out.println(Serialization.gsonPretty.toJson(notification));
+ PolicyEngine.manager.deliver($params.getNotificationTopic(), notification);
+ } catch (Exception e) {
+ System.out.println("Can't deliver notification: " + notification);
+ e.printStackTrace();
+ }
+ //
+ // Now send the operation request
+ //
+ if (request instanceof Request) {
+ try {
+ System.out.println("APPC request sent:");
+ System.out.println(Serialization.gsonPretty.toJson(request));
+ PolicyEngine.manager.deliver($params.getAppcTopic(), request);
+ } catch (Exception e) {
+ e.printStackTrace();
+ System.out.println("Can't deliver request: " + request);
+ }
+ }
+ } else {
+ //
+ // what happens if it is null
+ //
+ }
+ }
+ break;
+ case "MSO":
+ {
+ //
+ // Construct an operation
+ //
+ ControlLoopOperation operation = new ControlLoopOperation();
+ operation.actor = $params.getActor();
+ operation.operation = "createModuleInstance";
+ operation.target = $event.target;
+ //
+ // Create operationWrapper
+ //
+ ControlLoopOperationWrapper operationWrapper = new ControlLoopOperationWrapper($event.requestID, operation);
+ //
+ // Construct an MSO request
+ //
+ MSORequest request = new MSORequest();
+ request.requestDetails = new MSORequestDetails();
+ request.requestDetails.modelInfo = new MSOModelInfo();
+ request.requestDetails.cloudConfiguration = new MSOCloudConfiguration();
+ request.requestDetails.requestInfo = new MSORequestInfo();
+ request.requestDetails.requestParameters = new MSORequestParameters();
+ request.requestDetails.requestParameters.userParams = null;
+ //
+ // cloudConfiguration
+ //
+ request.requestDetails.cloudConfiguration.lcpCloudRegionId = cloudRegionItemCloudRegionId;
+ request.requestDetails.cloudConfiguration.tenantId = tenantItemTenantId;
+ //
+ // modelInfo
+ //
+ request.requestDetails.modelInfo.modelType = "vfModule";
+ request.requestDetails.modelInfo.modelInvariantId = vfModuleItemPersonaModelId;
+ request.requestDetails.modelInfo.modelNameVersionId = vfModuleItemModelNameVersionId;
+ request.requestDetails.modelInfo.modelName = vfModuleItemModelName;
+ request.requestDetails.modelInfo.modelVersion = vfModuleItemPersonaModelVersion;
+ //
+ // requestInfo
+ //
+ request.requestDetails.requestInfo.instanceName = vfModuleItemVfModuleName;
+ request.requestDetails.requestInfo.source = "POLICY";
+ request.requestDetails.requestInfo.suppressRollback = false;
+ //
+ // relatedInstanceList
+ //
+ MSORelatedInstanceListElement relatedInstanceListElement1 = new MSORelatedInstanceListElement();
+ MSORelatedInstanceListElement relatedInstanceListElement2 = new MSORelatedInstanceListElement();
+ relatedInstanceListElement1.relatedInstance = new MSORelatedInstance();
+ relatedInstanceListElement2.relatedInstance = new MSORelatedInstance();
+ //
+ relatedInstanceListElement1.relatedInstance.instanceId = serviceItemServiceInstanceId;
+ relatedInstanceListElement1.relatedInstance.modelInfo = new MSOModelInfo();
+ relatedInstanceListElement1.relatedInstance.modelInfo.modelType = "service";
+ relatedInstanceListElement1.relatedInstance.modelInfo.modelInvariantId = serviceItemPersonaModelId;
+ relatedInstanceListElement1.relatedInstance.modelInfo.modelNameVersionId = serviceItemModelNameVersionId;
+ relatedInstanceListElement1.relatedInstance.modelInfo.modelName = serviceItemModelName;
+ relatedInstanceListElement1.relatedInstance.modelInfo.modelVersion = serviceItemModelVersion;
+ //
+ relatedInstanceListElement2.relatedInstance.instanceId = vnfItemVnfId;
+ relatedInstanceListElement2.relatedInstance.modelInfo = new MSOModelInfo();
+ relatedInstanceListElement2.relatedInstance.modelInfo.modelType = "vnf";
+ relatedInstanceListElement2.relatedInstance.modelInfo.modelInvariantId = vnfItemPersonaModelId;
+ relatedInstanceListElement2.relatedInstance.modelInfo.modelNameVersionId = vnfItemModelNameVersionId;
+ relatedInstanceListElement2.relatedInstance.modelInfo.modelName = vnfItemModelName;
+ relatedInstanceListElement2.relatedInstance.modelInfo.modelVersion = vnfItemModelVersion;
+ relatedInstanceListElement2.relatedInstance.modelInfo.modelCustomizationName = vnfItemVnfType;
+ //
+ request.requestDetails.relatedInstanceList.add(relatedInstanceListElement1);
+ request.requestDetails.relatedInstanceList.add(relatedInstanceListElement2);
+ //
+ // print MSO request for debug
+ //
+ System.out.println("MSO request sent:");
+ System.out.println(Serialization.gsonPretty.toJson(request));
+ //
+ //
+ //
+ if (request != null) {
+ //
+ // Tell interested parties we are performing this Operation
+ //
+ VirtualControlLoopNotification notification = new VirtualControlLoopNotification($event);
+ notification.notification = ControlLoopNotificationType.OPERATION;
+ notification.from = "policy";
+ notification.policyName = drools.getRule().getName();
+ notification.policyScope = "com";
+ notification.policyVersion = "1";
+ try {
+ System.out.println(Serialization.gsonPretty.toJson(notification));
+ PolicyEngine.manager.deliver($params.getNotificationTopic(), notification);
+ } catch (Exception e) {
+ System.out.println("Can't deliver notification: " + notification);
+ e.printStackTrace();
+ }
+ //
+ // Concatenate serviceItemServiceInstanceId and vnfItemVnfId to msoURL
+ //
+ String MSOUrl = $params.getMsoURL() + "/serviceInstances/v2/" + serviceItemServiceInstanceId + "/vnfs/" + vnfItemVnfId + "/vfModules";
+ //
+ // Call MSO
+ //
+ MSOResponse response = MSOManager.createModuleInstance(MSOUrl, $params.getMsoURL(), $params.getMsoUsername(), $params.getMsoPassword(), request);
+ //
+ if (response != null) {
+ //
+ // Assign requestId
+ //
+ request.requestId = $event.requestID.toString();
+ response.request.requestId = $event.requestID.toString();
+ //
+ // Insert facts
+ //
+ insert(operationWrapper);
+ insert(request);
+ insert(response);
+ } else {
+ //
+ // MSO request not even accepted
+ //
+ notification.message = operationWrapper.operation.toMessage();
+ operationWrapper.operation.message = operationWrapper.operation.toMessage();
+ operationWrapper.operation.outcome = "FAILURE_EXCEPTION";
+ $manager.setControlLoopResult("FAILURE_EXCEPTION");
+ notification.history.add(operationWrapper.operation);
+ notification.notification = ControlLoopNotificationType.OPERATION_FAILURE;
+ //
+ // Let interested parties know
+ //
+ try {
+ System.out.println(Serialization.gsonPretty.toJson(notification));
+ PolicyEngine.manager.deliver($params.getNotificationTopic(), notification);
+ } catch (Exception e) {
+ System.out.println("Can't deliver notification: " + notification);
+ e.printStackTrace();
+ }
+ notification.notification = ControlLoopNotificationType.FINAL_FAILURE;
+ try {
+ System.out.println(Serialization.gsonPretty.toJson(notification));
+ PolicyEngine.manager.deliver($params.getNotificationTopic(), notification);
+ } catch (Exception e) {
+ System.out.println("Can't deliver notification: " + notification);
+ e.printStackTrace();
+ }
+ //
+ // Retract everything
+ //
+ retract($event);
+ retract($manager);
+ }
+ } else {
+ System.err.println("constructed MSO request is invalid.");
+ }
+ }
+ break;
+ }
+end
+
+/*
+*
+* This rule responds to APPC Response Events
+*
+*/
+rule "BRMSParamvFWDemoPolicy.APPC.RESPONSE"
+ when
+ $params : Params( getClosedLoopControlName() == "CL-FRWL-LOW-TRAFFIC-SIG-d925ed73-8231-4d02-9545-db4e101f88f8" )
+ $event : VirtualControlLoopEvent( closedLoopControlName == $params.getClosedLoopControlName(), closedLoopEventStatus == ControlLoopEventStatus.ONSET )
+ $manager : EventManager( closedLoopControlName == $event.closedLoopControlName )
+ $operationWrapper : ControlLoopOperationWrapper( requestID == $event.requestID )
+ $request : Request( getCommonHeader().RequestID == $event.requestID )
+ $response : Response( getCommonHeader().RequestID == $event.requestID )
+ then
+ System.out.println("rule APPC.RESPONSE is triggered.");
+ if ($response.Status == null) {
+ $operationWrapper.operation.outcome = "FAILURE_EXCEPTION";
+ $manager.setControlLoopResult("FAILURE_EXCEPTION");
+ }
+ //
+ // Get the Response Code
+ //
+ ResponseCode code = ResponseCode.toResponseCode($response.Status.Code);
+ if (code == null) {
+ $operationWrapper.operation.outcome = "FAILURE_EXCEPTION";
+ $manager.setControlLoopResult("FAILURE_EXCEPTION");
+ }
+ //
+ // Construct notification
+ //
+ VirtualControlLoopNotification notification = new VirtualControlLoopNotification($event);
+ notification.from = "policy";
+ notification.policyName = drools.getRule().getName();
+ notification.policyScope = "com";
+ notification.policyVersion = "1";
+ notification.message = $operationWrapper.operation.toMessage();
+ $operationWrapper.operation.message = $operationWrapper.operation.toMessage();
+ //
+ // Ok, let's figure out what APP-C's response is
+ //
+ switch (code) {
+ case ACCEPT:
+ $operationWrapper.operation.outcome = "PROCESSING";
+ break;
+ case ERROR:
+ case REJECT:
+ $operationWrapper.operation.outcome = "FAILURE_EXCEPTION";
+ $manager.setControlLoopResult("FAILURE_EXCEPTION");
+ break;
+ case SUCCESS:
+ $operationWrapper.operation.outcome = "SUCCESS";
+ $manager.setControlLoopResult("SUCCESS");
+ break;
+ case FAILURE:
+ $operationWrapper.operation.outcome = "FAILURE";
+ $manager.setControlLoopResult("FAILURE");
+ break;
+ }
+ if ($operationWrapper.operation.outcome.equals("SUCCESS")) {
+ notification.history.add($operationWrapper.operation);
+ notification.notification = ControlLoopNotificationType.OPERATION_SUCCESS;
+ //
+ // Let interested parties know
+ //
+ try {
+ System.out.println(Serialization.gsonPretty.toJson(notification));
+ PolicyEngine.manager.deliver($params.getNotificationTopic(), notification);
+ } catch (Exception e) {
+ System.out.println("Can't deliver notification: " + notification);
+ e.printStackTrace();
+ }
+ notification.notification = ControlLoopNotificationType.FINAL_SUCCESS;
+ try {
+ System.out.println(Serialization.gsonPretty.toJson(notification));
+ PolicyEngine.manager.deliver($params.getNotificationTopic(), notification);
+ } catch (Exception e) {
+ System.out.println("Can't deliver notification: " + notification);
+ e.printStackTrace();
+ }
+
+ //
+ // We are going to retract these objects from memory
+ //
+ System.out.println("Retracting everything");
+ retract($operationWrapper);
+ retract($request);
+ retract($response);
+ retract($event);
+ retract($manager);
+ } else if ($operationWrapper.operation.outcome.equals("PROCESSING")) {
+ retract($response);
+ } else {
+ notification.history.add($operationWrapper.operation);
+ notification.notification = ControlLoopNotificationType.OPERATION_FAILURE;
+ //
+ // Let interested parties know
+ //
+ try {
+ System.out.println(Serialization.gsonPretty.toJson(notification));
+ PolicyEngine.manager.deliver($params.getNotificationTopic(), notification);
+ } catch (Exception e) {
+ System.out.println("Can't deliver notification: " + notification);
+ e.printStackTrace();
+ }
+ notification.notification = ControlLoopNotificationType.FINAL_FAILURE;
+ //
+ // Let interested parties know
+ //
+ try {
+ System.out.println(Serialization.gsonPretty.toJson(notification));
+ PolicyEngine.manager.deliver($params.getNotificationTopic(), notification);
+ } catch (Exception e) {
+ System.out.println("Can't deliver notification: " + notification);
+ e.printStackTrace();
+ }
+ //
+ // We are going to retract these objects from memory
+ //
+ System.out.println("Retracting everything");
+ retract($operationWrapper);
+ retract($request);
+ retract($response);
+ retract($event);
+ retract($manager);
+ }
+
+end
+
+/*
+*
+* This rule is used to clean up APPC response
+*
+*/
+rule "BRMSParamvFWDemoPolicy.APPC.RESPONSE.CLEANUP"
+ when
+ $params : Params( getClosedLoopControlName() == "CL-FRWL-LOW-TRAFFIC-SIG-d925ed73-8231-4d02-9545-db4e101f88f8" )
+ $response : Response($id : getCommonHeader().RequestID )
+ not ( VirtualControlLoopEvent( closedLoopControlName == $params.getClosedLoopControlName(), requestID == $id, closedLoopEventStatus == ControlLoopEventStatus.ONSET ) )
+ then
+ System.out.println("rule APPC.RESPONSE.CLEANUP is triggered.");
+ retract($response);
+end
+
+/*
+*
+* This rule responds to MSO Response Events
+*
+*/
+rule "BRMSParamvFWDemoPolicy.MSO.RESPONSE"
+ when
+ $params : Params( getClosedLoopControlName() == "CL-FRWL-LOW-TRAFFIC-SIG-d925ed73-8231-4d02-9545-db4e101f88f8" )
+ $event : VirtualControlLoopEvent( closedLoopControlName == $params.getClosedLoopControlName(), closedLoopEventStatus == ControlLoopEventStatus.ONSET )
+ $manager : EventManager( closedLoopControlName == $event.closedLoopControlName )
+ $operationWrapper : ControlLoopOperationWrapper( requestID == $event.requestID )
+ $request : MSORequest( requestId == $event.requestID.toString() )
+ $response : MSOResponse( request.requestId == $event.requestID.toString() )
+ then
+ System.out.println("rule MSO.RESPONSE is triggered.");
+ //
+ // Construct notification
+ //
+ VirtualControlLoopNotification notification = new VirtualControlLoopNotification($event);
+ notification.from = "policy";
+ notification.policyName = drools.getRule().getName();
+ notification.policyScope = "com";
+ notification.policyVersion = "1";
+ notification.message = $operationWrapper.operation.toMessage();
+ $operationWrapper.operation.message = $operationWrapper.operation.toMessage();
+ //
+ // The operation can either be succeeded or failed
+ //
+ if($response.request.requestStatus.requestState.equals("COMPLETE")) {
+ $operationWrapper.operation.outcome = "SUCCESS";
+ $manager.setControlLoopResult("SUCCESS");
+ notification.history.add($operationWrapper.operation);
+ notification.notification = ControlLoopNotificationType.OPERATION_SUCCESS;
+ //
+ // Let interested parties know
+ //
+ try {
+ System.out.println(Serialization.gsonPretty.toJson(notification));
+ PolicyEngine.manager.deliver($params.getNotificationTopic(), notification);
+ } catch (Exception e) {
+ System.out.println("Can't deliver notification: " + notification);
+ e.printStackTrace();
+ }
+ notification.notification = ControlLoopNotificationType.FINAL_SUCCESS;
+ //
+ // Let interested parties know
+ //
+ try {
+ System.out.println(Serialization.gsonPretty.toJson(notification));
+ PolicyEngine.manager.deliver($params.getNotificationTopic(), notification);
+ } catch (Exception e) {
+ System.out.println("Can't deliver notification: " + notification);
+ e.printStackTrace();
+ }
+ //
+ // We are going to retract these objects from memory
+ //
+ System.out.println("Retracting everything");
+ retract($operationWrapper);
+ retract($request);
+ retract($response);
+ retract($event);
+ retract($manager);
+ } else {
+ $operationWrapper.operation.outcome = "FAILURE";
+ $manager.setControlLoopResult("FAILURE");
+ notification.history.add($operationWrapper.operation);
+ notification.notification = ControlLoopNotificationType.OPERATION_FAILURE;
+ //
+ // Let interested parties know
+ //
+ try {
+ System.out.println(Serialization.gsonPretty.toJson(notification));
+ PolicyEngine.manager.deliver($params.getNotificationTopic(), notification);
+ } catch (Exception e) {
+ System.out.println("Can't deliver notification: " + notification);
+ e.printStackTrace();
+ }
+ notification.notification = ControlLoopNotificationType.FINAL_FAILURE;
+ //
+ // Let interested parties know
+ //
+ try {
+ System.out.println(Serialization.gsonPretty.toJson(notification));
+ PolicyEngine.manager.deliver($params.getNotificationTopic(), notification);
+ } catch (Exception e) {
+ System.out.println("Can't deliver notification: " + notification);
+ e.printStackTrace();
+ }
+ //
+ // We are going to retract these objects from memory
+ //
+ System.out.println("Retracting everything");
+ retract($operationWrapper);
+ retract($request);
+ retract($response);
+ retract($event);
+ retract($manager);
+ }
+
+end
+rule "com.Config_BRMS_Param_BRMSParamvFWDemoPolicy.Params"
+ salience 1000
+ when
+ then
+ Params params = new Params();
+ params.setAaiPatternMatch(1);
+ params.setAppcTopic("APPC-CL");
+ params.setAaiURL("null");
+ params.setMsoPassword("null");
+ params.setClosedLoopControlName("CL-FRWL-LOW-TRAFFIC-SIG-d925ed73-8231-4d02-9545-db4e101f88f8");
+ params.setMsoURL("null");
+ params.setAaiUsername("null");
+ params.setActor("APPC");
+ params.setMsoUsername("null");
+ params.setAaiNamedQueryUUID("null");
+ params.setAaiPassword("null");
+ params.setNotificationTopic("POLICY-CL-MGT");
+ insert(params);
+end
diff --git a/POLICY-SDK-APP/src/test/resources/com.Config_BRMS_Raw_TestBRMSRawPolicy.1.txt b/POLICY-SDK-APP/src/test/resources/com.Config_BRMS_Raw_TestBRMSRawPolicy.1.txt
new file mode 100644
index 000000000..6924fc3a9
--- /dev/null
+++ b/POLICY-SDK-APP/src/test/resources/com.Config_BRMS_Raw_TestBRMSRawPolicy.1.txt
@@ -0,0 +1,35 @@
+package com.sample
+import com.sample.DroolsTest.Message;
+// Declare the Parameters here.
+declare Params
+ samPoll : int
+ value : String
+end
+// This Rule will be generated by the UI.
+rule "Create parameters structure"
+ salience 1000
+ when
+ then
+ Params params = new Params();
+ params.setSamPoll(76);
+ params.setValue("Bobby");
+ insertLogical(params);
+end
+// Start using the parameters as below in Rules.
+rule "Rule 1: Check parameter structure access from when/then"
+ when
+ $param: Params()
+ Params($param.samPoll > 50)
+ then
+ System.out.println("Firing rule 1");
+ System.out.println($param);
+end
+rule "Rule 2: Check parameter value access from when/then"
+ when
+ $param: Params()
+ Params($param.samPoll > 50)
+ then
+ System.out.println("Firing rule 2");
+ System.out.println($param.getValue());
+ System.out.println($param.getSamPoll());
+end
diff --git a/POLICY-SDK-APP/src/test/resources/com.Config_FW_TestFireWallPolicy.1.json b/POLICY-SDK-APP/src/test/resources/com.Config_FW_TestFireWallPolicy.1.json
new file mode 100644
index 000000000..eae1ed575
--- /dev/null
+++ b/POLICY-SDK-APP/src/test/resources/com.Config_FW_TestFireWallPolicy.1.json
@@ -0,0 +1 @@
+{"serviceTypeId":"/v0/firewall/pan","configName":"TestFireWallPolicy","deploymentOption":{"deployNow":false},"securityZoneId":"1.5.3","vendorServiceId":"vipr","vendorSpecificData":{"idMap":[{"astraId":"1.5.3","vendorId":"deviceGroup:dev"}]},"serviceGroups":[],"addressGroups":[],"firewallRuleList":[{"position":"1","ruleName":"test","fromZones":[],"toZones":[],"negateSource":false,"negateDestination":false,"sourceList":[],"destinationList":[],"sourceServices":[],"destServices":[],"action":null,"description":null,"enabled":true,"log":true}],"ruleToTag":[{"ruleName":"test","tags":[{"key":"test","value":"test"}],"tagPickerName":"test","networkRole":"test"}]} \ No newline at end of file
diff --git a/POLICY-SDK-APP/src/test/resources/com.Config_Fault_TestClosedLoopPolicy.1.json b/POLICY-SDK-APP/src/test/resources/com.Config_Fault_TestClosedLoopPolicy.1.json
new file mode 100644
index 000000000..f7e25ca47
--- /dev/null
+++ b/POLICY-SDK-APP/src/test/resources/com.Config_Fault_TestClosedLoopPolicy.1.json
@@ -0,0 +1 @@
+{"trinity":false,"vUSP":true,"mcr":false,"gama":false,"vDNS":false,"vnfType":"SampleVNF","vServices":null,"closedLoopPolicyStatus":"Active","triggerSignatures":{"signatures":"((NOT(NOT(1.0.2.3)AND(1.0.2.3)), Time = 11)AND((NOT(1.0.2.3)AND(1.0.2.3)), Time = 12))","timeWindow":11,"trapMaxAge":12},"actions":"SampleVSCL","timeInterval":11,"timeOutvPRO":11,"timeOutRuby":11,"retrys":1,"agingWindow":1,"geoLink":"TEST","emailAddress":"aa@test.con","verificationSignatures":{"signatures":"(NOT(1.0.2.3)AND(1.0.2.3))","timeWindow":12},"conditions":"SEND","triggerSignaturesUsedForUI":{"signatures":"NOT@!SampleVarbind@!AND@!SampleVarbind#!?!NOT@!SampleVarbind@!OR@!SampleVarbind#!NOT@!A1@!AND@!SampleVarbind#!NOT@!A1@!AND@!A2#!?!","connectSignatures":"NOT@!Trap1@!11@!AND@!Trap1@!12#!?!"},"verificationSignaturesUsedForUI":{"signatures":"NOT@!SampleVarbind@!AND@!SampleVarbind#!?!","connectSignatures":null},"triggerTimeWindowUsedForUI":11,"verfificationTimeWindowUsedForUI":12,"pepName":null,"pepAction":null,"templateVersion":null,"trapMaxAgeUsedForUI":12,"ecompname":null}
diff --git a/POLICY-SDK-APP/src/test/resources/com.Config_MS_vFirewall.1.json b/POLICY-SDK-APP/src/test/resources/com.Config_MS_vFirewall.1.json
new file mode 100644
index 000000000..6b128f1a1
--- /dev/null
+++ b/POLICY-SDK-APP/src/test/resources/com.Config_MS_vFirewall.1.json
@@ -0,0 +1 @@
+{"service":"TcaMetrics","location":"SampleServiceLocation","uuid":"/services/cdap-tca-hi-lo/instances/demo/configuration/metricsPerFunctionalRole/vFirewall","policyName":"vFirewall","description":"Micro Service vFirewall Demo Policy@CreatedBy:@CreatedBy:@ModifiedBy:@ModifiedBy:","configName":"SampleConfigName","templateVersion":"OpenSource.version.1","version":"1.0.0.5","priority":"1","policyScope":"resource=SampleResource,service=SampleService,type=SampleType,closedLoopControlName=SampleClosedLoop","content":{"thresholds":[{"severity":"MAJOR","fieldPath":"$.event.measurementsForVfScalingFields.vNicUsageArray[*].packetsIn","thresholdValue":"300","closedLoopControlName":"CL-FRWL-LOW-TRAFFIC-SIG-d925ed73-8231-4d02-9545-db4e101f88f8","version":"1.0.2","direction":"LESS_OR_EQUAL"},{"severity":"CRITICAL","fieldPath":"$.event.measurementsForVfScalingFields.vNicUsageArray[*].packetsIn","thresholdValue":"700","closedLoopControlName":"CL-FRWL-LOW-TRAFFIC-SIG-d925ed73-8231-4d02-9545-db4e101f88f8","version":"1.0.2","direction":"GREATER_OR_EQUAL"}],"functionalRole":"vFirewall","name":"0"}} \ No newline at end of file
diff --git a/POLICY-SDK-APP/src/test/resources/com.Config_PM_TestClosedLoopPMPolicy.1.json b/POLICY-SDK-APP/src/test/resources/com.Config_PM_TestClosedLoopPMPolicy.1.json
new file mode 100644
index 000000000..e0057ed1e
--- /dev/null
+++ b/POLICY-SDK-APP/src/test/resources/com.Config_PM_TestClosedLoopPMPolicy.1.json
@@ -0,0 +1 @@
+{"serviceTypePolicyName": "Registration Failure(Trinity)","vUSP":true,"attributes":{"PtileLimit":"11","Threshold":"12","Window":"13","Training":"14","FractionSamplePerDay":"15","ConsecutiveIntervalOnset":"11","RetryTimer":"12","ConsecutiveIntervalAbatement":"11","OnsetMessage":"11","AbatementMessage":"12","PolicyName":"13"},"geoLink":"TEST","emailAddress":"test@test.com"}