diff options
author | ITSERVICES\rb7147 <rb7147@att.com> | 2017-05-08 22:20:44 -0400 |
---|---|---|
committer | ITSERVICES\rb7147 <rb7147@att.com> | 2017-05-09 13:58:03 -0400 |
commit | dda032f8bb161d54eb1f59de2b4a3efb774fc4d1 (patch) | |
tree | 9a11825d59434d97bb0c7dcbf00a0b84e7e5f526 /POLICY-SDK-APP/src/main | |
parent | a330af579866dacbe595e2e4ad1dd29cd3c96945 (diff) |
Policy 1707 Second commit
Change-Id: I18f5b142238733d17280cf17c3d1dd28204d34e9
Signed-off-by: ITSERVICES\rb7147 <rb7147@att.com>
Diffstat (limited to 'POLICY-SDK-APP/src/main')
46 files changed, 1381 insertions, 349 deletions
diff --git a/POLICY-SDK-APP/src/main/java/org/openecomp/policy/admin/PolicyManagerServlet.java b/POLICY-SDK-APP/src/main/java/org/openecomp/policy/admin/PolicyManagerServlet.java index 86210cdef..6c60c58c2 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 @@ -18,11 +18,6 @@ * ============LICENSE_END========================================================= */ -/* - * - * - * - * */ package org.openecomp.policy.admin; import java.io.BufferedReader; @@ -63,6 +58,7 @@ import org.apache.commons.fileupload.FileItem; import org.apache.commons.fileupload.disk.DiskFileItemFactory; import org.apache.commons.fileupload.servlet.ServletFileUpload; import org.apache.http.HttpStatus; +import org.json.JSONArray; import org.json.JSONException; import org.json.JSONObject; import org.openecomp.policy.common.logging.flexlogger.FlexLogger; @@ -96,7 +92,7 @@ public class PolicyManagerServlet extends HttpServlet { private static final long serialVersionUID = -8453502699403909016L; private enum Mode { - LIST, RENAME, COPY, DELETE, EDITFILE, ADDFOLDER, DESCRIBEPOLICYFILE, VIEWPOLICY, ADDSUBSCOPE, SWITCHVERSION, EXPORT + LIST, RENAME, COPY, DELETE, EDITFILE, ADDFOLDER, DESCRIBEPOLICYFILE, VIEWPOLICY, ADDSUBSCOPE, SWITCHVERSION, EXPORT, SEARCHLIST } private static String CONTENTTYPE = "application/json"; @@ -120,6 +116,7 @@ public class PolicyManagerServlet extends HttpServlet { } private static List<String> serviceTypeNamesList = new ArrayList<String>(); + private List<Object> policyData; public static List<String> getServiceTypeNamesList() { return serviceTypeNamesList; @@ -276,6 +273,9 @@ public class PolicyManagerServlet extends HttpServlet { case SWITCHVERSION: responseJsonObject = switchVersion(params, request); break; + case SEARCHLIST: + responseJsonObject = searchPolicyList(params, request); + break; default: throw new ServletException("not implemented"); } @@ -292,6 +292,101 @@ public class PolicyManagerServlet extends HttpServlet { out.flush(); } + private JSONObject searchPolicyList(JSONObject params, HttpServletRequest request) { + Set<String> scopes = null; + List<String> roles = null; + policyData = null; + JSONArray policyList = null; + if(params.has("policyList")){ + policyList = (JSONArray) params.get("policyList"); + } + PolicyController controller = new PolicyController(); + List<JSONObject> resultList = new ArrayList<JSONObject>(); + try { + //Get the Login Id of the User from Request + String userId = UserUtils.getUserSession(request).getOrgUserId(); + //Check if the Role and Scope Size are Null get the values from db. + List<Object> userRoles = PolicyController.getRoles(userId); + roles = new ArrayList<String>(); + scopes = new HashSet<String>(); + for(Object role: userRoles){ + Roles userRole = (Roles) role; + roles.add(userRole.getRole()); + if(userRole.getScope() != null){ + if(userRole.getScope().contains(",")){ + String[] multipleScopes = userRole.getScope().split(","); + for(int i =0; i < multipleScopes.length; i++){ + scopes.add(multipleScopes[i]); + } + }else{ + scopes.add(userRole.getScope()); + } + } + } + if (roles.contains(ADMIN) || roles.contains(EDITOR) || roles.contains(GUEST) ) { + if(scopes.isEmpty()){ + return error("No Scopes has been Assigned to the User. Please, Contact Super-Admin"); + } + } + if(policyList!= null){ + for(int i = 0; i < policyList.length(); i++){ + String policyName = policyList.get(i).toString().replace(".xml", ""); + String version = policyName.substring(policyName.lastIndexOf(".")+1); + policyName = policyName.substring(0, policyName.lastIndexOf(".")).replace(".", File.separator); + if(policyName.contains("\\")){ + policyName = policyName.replace("\\", "\\\\"); + } + String policyVersionQuery = "From PolicyVersion where policy_name ='"+policyName+"' and active_version = '"+version+"'and id >0"; + List<Object> activeData = controller.getDataByQuery(policyVersionQuery); + if(!activeData.isEmpty()){ + PolicyVersion policy = (PolicyVersion) activeData.get(0); + JSONObject el = new JSONObject(); + el.put("name", policy.getPolicyName().replace(File.separator, "/")); + el.put("date", policy.getModifiedDate()); + el.put("version", policy.getActiveVersion()); + el.put("size", ""); + el.put("type", "file"); + el.put("createdBy", getUserName(policy.getCreatedBy())); + el.put("modifiedBy", getUserName(policy.getModifiedBy())); + resultList.add(el); + } + } + }else{ + if (roles.contains("super-admin") || roles.contains("super-editor") || roles.contains("super-guest") ){ + policyData = controller.getData(PolicyVersion.class); + }else{ + List<Object> filterdatas = controller.getData(PolicyVersion.class); + for(Object filter : filterdatas){ + PolicyVersion filterdata = (PolicyVersion) filter; + String scopeName = filterdata.getPolicyName().substring(0, filterdata.getPolicyName().lastIndexOf(File.separator)); + if(scopes.contains(scopeName)){ + policyData.add(filterdata); + } + } + } + + if(!policyData.isEmpty()){ + for(int i =0; i < policyData.size(); i++){ + PolicyVersion policy = (PolicyVersion) policyData.get(i); + JSONObject el = new JSONObject(); + el.put("name", policy.getPolicyName().replace(File.separator, "/")); + el.put("date", policy.getModifiedDate()); + el.put("version", policy.getActiveVersion()); + el.put("size", ""); + el.put("type", "file"); + el.put("createdBy", getUserName(policy.getCreatedBy())); + el.put("modifiedBy", getUserName(policy.getModifiedBy())); + resultList.add(el); + } + } + } + }catch(Exception e){ + LOGGER.error("Exception occured while reading policy Data from Policy Version table for Policy Search Data"+e); + } + + return new JSONObject().put(RESULT, resultList); + } + //Switch Version Functionality private JSONObject switchVersion(JSONObject params, HttpServletRequest request) throws ServletException{ String path = params.getString("path"); @@ -387,7 +482,7 @@ public class PolicyManagerServlet extends HttpServlet { String[] split = path.split(":"); String query = "FROM PolicyEntity where policyName = '"+split[1]+"' and scope ='"+split[0]+"'"; List<Object> queryData = controller.getDataByQuery(query); - if(queryData != null){ + if(!queryData.isEmpty()){ PolicyEntity entity = (PolicyEntity) queryData.get(0); File temp = null; try { @@ -731,7 +826,7 @@ public class PolicyManagerServlet extends HttpServlet { //Check Policy Group Entity table if policy has been pushed or not String query = "from PolicyGroupEntity where policyid = '"+entity.getPolicyId()+"'"; List<Object> object = controller.getDataByQuery(query); - if(object == null){ + if(object.isEmpty()){ String oldPolicyNameWithoutExtension = removeoldPolicyExtension; String newPolicyNameWithoutExtension = removenewPolicyExtension; if(removeoldPolicyExtension.endsWith(".xml")){ @@ -926,7 +1021,7 @@ public class PolicyManagerServlet extends HttpServlet { controller.saveData(entityItem); } - LOGGER.debug("copy from: {} to: {}" + oldPath +newPath); + LOGGER.debug("copy from: {} to:Â {}" + oldPath +newPath); return success(); } catch (Exception e) { @@ -972,7 +1067,8 @@ public class PolicyManagerServlet extends HttpServlet { } List<Object> policyEntityobjects = controller.getDataByQuery(query); - boolean pdpCheck = true; + String activePolicyName = null; + boolean pdpCheck = false; if(path.endsWith(".xml")){ policyNamewithoutExtension = policyNamewithoutExtension.replace(".", File.separator); int version = Integer.parseInt(policyVersionName.substring(policyVersionName.indexOf(".")+1)); @@ -982,38 +1078,43 @@ public class PolicyManagerServlet extends HttpServlet { policyEntity = (PolicyEntity) object; String groupEntityquery = "from PolicyGroupEntity where policyid = '"+policyEntity.getPolicyId()+"'"; List<Object> groupobject = controller.getDataByQuery(groupEntityquery); - if(groupobject != null){ - pdpCheck = false; - break; + if(!groupobject.isEmpty()){ + pdpCheck = true; + activePolicyName = policyEntity.getScope() +"."+ policyEntity.getPolicyName(); + }else{ + //Delete the entity from Elastic Search Database + String searchFileName = policyEntity.getScope() + "." + policyEntity.getPolicyName(); + restController.deleteElasticData(searchFileName); + //Delete the entity from Policy Entity table + controller.deleteData(policyEntity); + if(policyNamewithoutExtension.contains("Config_")){ + controller.deleteData(policyEntity.getConfigurationData()); + }else if(policyNamewithoutExtension.contains("Action_")){ + controller.deleteData(policyEntity.getActionBodyEntity()); + } } } } + //Policy Notification + PolicyVersion versionEntity = new PolicyVersion(); + versionEntity.setPolicyName(policyNamewithoutExtension); + versionEntity.setModifiedBy(userId); + controller.watchPolicyFunction(versionEntity, policyNamewithExtension, "DeleteAll"); if(pdpCheck){ - for(Object object : policyEntityobjects){ - policyEntity = (PolicyEntity) object; - //Delete the entity from Elastic Search Database - String searchFileName = policyEntity.getScope() + "." + policyEntity.getPolicyName(); - restController.deleteElasticData(searchFileName); - //Delete the entity from Policy Entity table - controller.deleteData(policyEntity); - if(policyNamewithoutExtension.contains("Config_")){ - controller.deleteData(policyEntity.getConfigurationData()); - }else if(policyNamewithoutExtension.contains("Action_")){ - controller.deleteData(policyEntity.getActionBodyEntity()); - } - } - //Policy Notification - PolicyVersion versionEntity = new PolicyVersion(); - versionEntity.setPolicyName(policyNamewithoutExtension); - versionEntity.setModifiedBy(userId); - controller.watchPolicyFunction(versionEntity, policyNamewithExtension, "DeleteAll"); //Delete from policyVersion table - String policyVersionQuery = "delete from PolicyVersion where policy_name ='" +policyNamewithoutExtension.replace("\\", "\\\\")+"' and id >0"; + String getActivePDPPolicyVersion = activePolicyName.replace(".xml", ""); + getActivePDPPolicyVersion = getActivePDPPolicyVersion.substring(getActivePDPPolicyVersion.lastIndexOf(".")+1); + String policyVersionQuery = "update PolicyVersion set active_version='"+getActivePDPPolicyVersion+"' , highest_version='"+getActivePDPPolicyVersion+"' where policy_name ='" +policyNamewithoutExtension.replace("\\", "\\\\")+"' and id >0"; if(policyVersionQuery != null){ controller.executeQuery(policyVersionQuery); } + return error("Policies with Same name has been deleted. Except the Active Policy in PDP. PolicyName: "+activePolicyName); }else{ - return error("Policy can't be deleted, it is active in PDP Groups. PolicyName: '"+policyEntity.getScope() + "." +policyEntity.getPolicyName()+"'"); + //No Active Policy in PDP. So, deleting all entries from policyVersion table + String policyVersionQuery = "delete from PolicyVersion where policy_name ='" +policyNamewithoutExtension.replace("\\", "\\\\")+"' and id >0"; + if(policyVersionQuery != null){ + controller.executeQuery(policyVersionQuery); + } } }else if("CURRENT".equals(deleteVersion)){ String currentVersionPolicyName = policyNamewithExtension.substring(policyNamewithExtension.lastIndexOf(File.separator)+1); @@ -1024,9 +1125,9 @@ public class PolicyManagerServlet extends HttpServlet { policyEntity = (PolicyEntity) policyEntitys.get(0); } if(policyEntity != null){ - String groupEntityquery = "from PolicyGroupEntity where policyid = '"+policyEntity.getPolicyId()+"'"; + String groupEntityquery = "from PolicyGroupEntity where policyid = '"+policyEntity.getPolicyId()+"' and policyid > 0"; List<Object> groupobject = controller.getDataByQuery(groupEntityquery); - if(groupobject == null){ + if(groupobject.isEmpty()){ //Delete the entity from Elastic Search Database String searchFileName = policyEntity.getScope() + "." + policyEntity.getPolicyName(); restController.deleteElasticData(searchFileName); @@ -1040,7 +1141,7 @@ public class PolicyManagerServlet extends HttpServlet { if(version > 1){ int highestVersion = 0; - if(policyEntityobjects.isEmpty()){ + if(!policyEntityobjects.isEmpty()){ for(Object object : policyEntityobjects){ policyEntity = (PolicyEntity) object; String policyEntityName = policyEntity.getPolicyName().replace(".xml", ""); @@ -1072,18 +1173,16 @@ public class PolicyManagerServlet extends HttpServlet { } } }else{ + List<String> activePoliciesInPDP = new ArrayList<String>(); if(!policyEntityobjects.isEmpty()){ for(Object object : policyEntityobjects){ policyEntity = (PolicyEntity) object; String groupEntityquery = "from PolicyGroupEntity where policyid = '"+policyEntity.getPolicyId()+"'"; List<Object> groupobject = controller.getDataByQuery(groupEntityquery); - if(groupobject != null){ - pdpCheck = false; - } - } - if(pdpCheck){ - for(Object object : policyEntityobjects){ - policyEntity = (PolicyEntity) object; + if(!groupobject.isEmpty()){ + pdpCheck = true; + activePoliciesInPDP.add(policyEntity.getScope()+"."+policyEntity.getPolicyName()); + }else{ //Delete the entity from Elastic Search Database String searchFileName = policyEntity.getScope() + "." + policyEntity.getPolicyName(); restController.deleteElasticData(searchFileName); @@ -1096,17 +1195,35 @@ public class PolicyManagerServlet extends HttpServlet { controller.deleteData(policyEntity.getActionBodyEntity()); } } + } + //Delete from policyVersion and policyEditor Scope table + String policyVersionQuery = "delete PolicyVersion where POLICY_NAME like '"+path.replace("\\", "\\\\")+"%' and id >0"; + controller.executeQuery(policyVersionQuery); + + //Policy Notification + PolicyVersion entity = new PolicyVersion(); + entity.setPolicyName(path); + entity.setModifiedBy(userId); + controller.watchPolicyFunction(entity, path, "DeleteScope"); + if(pdpCheck){ + //Add Active Policies List to PolicyVersionTable + for(int i =0; i < activePoliciesInPDP.size(); i++){ + String activePDPPolicyName = activePoliciesInPDP.get(i).replace(".xml", ""); + int activePDPPolicyVersion = Integer.parseInt(activePDPPolicyName.substring(activePDPPolicyName.lastIndexOf(".")+1)); + activePDPPolicyName = activePDPPolicyName.substring(0, activePDPPolicyName.lastIndexOf(".")).replace(".", File.separator); + PolicyVersion insertactivePDPVersion = new PolicyVersion(); + insertactivePDPVersion.setPolicyName(activePDPPolicyName); + insertactivePDPVersion.setHigherVersion(activePDPPolicyVersion); + insertactivePDPVersion.setActiveVersion(activePDPPolicyVersion); + insertactivePDPVersion.setCreatedBy(userId); + insertactivePDPVersion.setModifiedBy(userId); + controller.saveData(insertactivePDPVersion); + } - //Delete from policyVersion and policyEditor Scope table - String policyVersionQuery = "delete PolicyVersion where POLICY_NAME like '"+path.replace("\\", "\\\\")+"%' and id >0"; + return error("All the Policies has been deleted in Scope. Except the following list of Policies:"+activePoliciesInPDP); + }else{ String policyScopeQuery = "delete PolicyEditorScopes where SCOPENAME like '"+path.replace("\\", "\\\\")+"%' and id >0"; - controller.executeQuery(policyVersionQuery); - controller.executeQuery(policyScopeQuery); - //Policy Notification - PolicyVersion entity = new PolicyVersion(); - entity.setPolicyName(path); - entity.setModifiedBy(userId); - controller.watchPolicyFunction(entity, path, "DeleteScope"); + controller.executeQuery(policyScopeQuery); } } } 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 2a1129cf6..c40f0da0c 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 @@ -92,10 +92,29 @@ public class PolicyRestController extends RestrictedBaseController{ JsonNode root = mapper.readTree(request.getReader()); PolicyRestAdapter policyData = (PolicyRestAdapter)mapper.readValue(root.get("policyData").get("policy").toString(), PolicyRestAdapter.class); - policyData.setDomainDir(root.get("policyData").get("model").get("name").toString().replace("\"", "")); + if(root.get("policyData").get("model").get("type").toString().replace("\"", "").equals("file")){ policyData.isEditPolicy = true; } + if(root.get("policyData").get("model").get("path").size() != 0){ + String dirName = ""; + for(int i = 0; i < root.get("policyData").get("model").get("path").size(); i++){ + dirName = dirName.replace("\"", "") + root.get("policyData").get("model").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("policyData").get("model").get("name").toString().replace("\"", "")); + } + }else{ + String domain = root.get("policyData").get("model").get("name").toString(); + if(domain.contains("/")){ + domain = domain.substring(0, domain.lastIndexOf("/")).replace("/", File.separator); + } + domain = domain.replace("\"", ""); + policyData.setDomainDir(domain); + } + if(policyData.getConfigPolicyType() != null){ if(policyData.getConfigPolicyType().equalsIgnoreCase("ClosedLoop_Fault")){ CreateClosedLoopFaultController faultController = new CreateClosedLoopFaultController(); @@ -111,19 +130,6 @@ public class PolicyRestController extends RestrictedBaseController{ policyData.setUserId(userId); - if(root.get("policyData").get("model").get("path").size() != 0){ - String dirName = ""; - for(int i = 0; i < root.get("policyData").get("model").get("path").size(); i++){ - dirName = dirName.replace("\"", "") + root.get("policyData").get("model").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("policyData").get("model").get("name").toString().replace("\"", "")); - } - }else{ - policyData.setDomainDir(root.get("policyData").get("model").get("name").toString().replace("\"", "")); - } String result; String body = PolicyUtils.objectToJsonString(policyData); String uri = request.getRequestURI(); @@ -253,7 +259,8 @@ public class PolicyRestController extends RestrictedBaseController{ connection.setDoOutput(true); connection.setDoInput(true); - if(!uri.contains("searchPolicy")){ + if(!uri.contains("searchPolicy?action=delete&")){ + if(!(uri.endsWith("set_BRMSParamData") || uri.contains("import_dictionary"))){ connection.setRequestProperty("Content-Type","application/json"); ObjectMapper mapper = new ObjectMapper(); @@ -371,6 +378,23 @@ public class PolicyRestController extends RestrictedBaseController{ return null; } + @RequestMapping(value={"/searchPolicy"}, method={RequestMethod.POST}) + public ModelAndView searchPolicy(HttpServletRequest request, HttpServletResponse response) throws Exception{ + String uri = request.getRequestURI()+"?action=search"; + String body = callPAP(request, response, "POST", uri.replaceFirst("/", "").trim()); + JSONObject json = new JSONObject(body); + Object resultList = json.get("policyresult"); + + response.setCharacterEncoding("UTF-8"); + response.setContentType("application / json"); + request.setCharacterEncoding("UTF-8"); + + PrintWriter out = response.getWriter(); + JSONObject j = new JSONObject("{result: " + resultList + "}"); + out.write(j.toString()); + return null; + } + public void deleteElasticData(String fileName){ String uri = "searchPolicy?action=delete&policyName='"+fileName+"'"; callPAP(null, null, "POST", uri.trim()); diff --git a/POLICY-SDK-APP/src/main/java/org/openecomp/policy/controller/AutoPushController.java b/POLICY-SDK-APP/src/main/java/org/openecomp/policy/controller/AutoPushController.java index 77bcea6ef..86d9920d9 100644 --- a/POLICY-SDK-APP/src/main/java/org/openecomp/policy/controller/AutoPushController.java +++ b/POLICY-SDK-APP/src/main/java/org/openecomp/policy/controller/AutoPushController.java @@ -106,7 +106,7 @@ public class AutoPushController extends RestrictedBaseController{ try{ Set<String> scopes = null; List<String> roles = null; - data = null; + data = new ArrayList<Object>(); String userId = UserUtils.getUserSession(request).getOrgUserId(); Map<String, Object> model = new HashMap<String, Object>(); ObjectMapper mapper = new ObjectMapper(); @@ -123,20 +123,29 @@ public class AutoPushController extends RestrictedBaseController{ scopes.add(multipleScopes[i]); } }else{ - scopes.add(userRole.getScope()); + if(!userRole.getScope().equals("")){ + scopes.add(userRole.getScope()); + } } } } - if (roles.contains("super-admin") || roles.contains("super-editor") || roles.contains("super-guest") ) { + if (roles.contains("super-admin") || roles.contains("super-editor") || roles.contains("super-guest")) { data = commonClassDao.getData(PolicyVersion.class); }else{ - List<Object> filterdatas = commonClassDao.getData(PolicyVersion.class); - for(Object filter : filterdatas){ - PolicyVersion filterdata = (PolicyVersion) filter; - String scopeName = filterdata.getPolicyName().substring(0, filterdata.getPolicyName().lastIndexOf(File.separator)); - if(scopes.contains(scopeName)){ - data.add(filterdata); + if(!scopes.isEmpty()){ + for(String scope : scopes){ + String query = "From PolicyVersion where policy_name like '"+scope+"%' and id > 0"; + List<Object> filterdatas = commonClassDao.getDataByQuery(query); + if(filterdatas != null){ + for(int i =0; i < filterdatas.size(); i++){ + data.add(filterdatas.get(i)); + } + } } + }else{ + PolicyVersion emptyPolicyName = new PolicyVersion(); + emptyPolicyName.setPolicyName("Please Contact Policy Super Admin, There are no scopes assigned to you"); + data.add(emptyPolicyName); } } model.put("policydatas", mapper.writeValueAsString(data)); 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 570ceac31..aeb5266c5 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 @@ -24,8 +24,11 @@ package org.openecomp.policy.controller; import java.io.BufferedInputStream; import java.io.BufferedOutputStream; import java.io.File; +import java.io.FileInputStream; +import java.io.FileNotFoundException; import java.io.FileOutputStream; import java.io.IOException; +import java.io.InputStream; import java.io.OutputStream; import java.io.PrintWriter; import java.nio.file.Files; @@ -75,6 +78,7 @@ import org.springframework.http.MediaType; import org.springframework.stereotype.Controller; import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.servlet.ModelAndView; +import org.yaml.snakeyaml.Yaml; import com.att.research.xacml.util.XACMLProperties; import com.fasterxml.jackson.core.JsonProcessingException; @@ -105,6 +109,14 @@ public class CreateDcaeMicroServiceController extends RestrictedBaseController { private List<String> modelList = new ArrayList<String>(); private List<String> dirDependencyList = new ArrayList<String>(); private HashMap<String,MSAttributeObject > classMap = new HashMap<String,MSAttributeObject>(); + //Tosca Model related Datastructure. + String referenceAttributes; + String attributeString; + String listConstraints; + String subAttributeString; + HashMap<String, Object> retmap = new HashMap<String, Object>(); + Set<String> uniqueKeys= new HashSet<String>(); + Set<String> uniqueDataKeys= new HashSet<String>(); @Autowired private CreateDcaeMicroServiceController(CommonClassDao commonClassDao){ @@ -191,7 +203,7 @@ public class CreateDcaeMicroServiceController extends RestrictedBaseController { } catch (JsonProcessingException e) { logger.error("Error writing out the object"); } - System.out.println(json); + logger.info(json); String cleanJson = cleanUPJson(json); cleanJson = removeNullAttributes(cleanJson); policyAdapter.setJsonBody(cleanJson); @@ -223,8 +235,360 @@ public class CreateDcaeMicroServiceController extends RestrictedBaseController { } return cleanJson; } + + // Second index of dot should be returned. + public void stringBetweenDots(String str,String value){ + String stringToSearch=str; + String[]ss=stringToSearch.split("\\."); + if(ss!=null){ + int len= ss.length; + if(len>2){ + uniqueKeys.add(ss[2]); + } + } + } + + public void stringBetweenDotsForDataFields(String str,String value){ + String stringToSearch=str; + String[]ss=stringToSearch.split("\\."); + if(ss!=null){ + int len= ss.length; + if(len>2){ + uniqueDataKeys.add(ss[0]+"%"+ss[2]); + } + } + } + + public Map<String, String> load(String fileName) throws IOException { + File newConfiguration = new File(fileName); + InputStream is = null; + try { + is = new FileInputStream(newConfiguration); + } catch (FileNotFoundException e) { + logger.error(e); + } + + Yaml yaml = new Yaml(); + @SuppressWarnings("unchecked") + Map<Object, Object> yamlMap = (Map<Object, Object>) yaml.load(is); + StringBuilder sb = new StringBuilder(); + Map<String, String> settings = new HashMap<String, String>(); + if (yamlMap == null) { + return settings; + } + List<String> path = new ArrayList<String>(); + serializeMap(settings, sb, path, yamlMap); + return settings; + } + + 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()); + StringBuilder sb = new StringBuilder(); + Map<String, String> settings = new HashMap<String, String>(); + if (yamlMap == null) { + return settings; + } + List<String> path = new ArrayList<String>(); + serializeMap(settings, sb, path, yamlMap); + return settings; + } + + @SuppressWarnings({ "unchecked", "rawtypes" }) + private void serializeMap(Map<String, String> settings, StringBuilder sb, List<String> path, Map<Object, Object> yamlMap) { + for (Map.Entry<Object, Object> entry : yamlMap.entrySet()) { + if (entry.getValue() instanceof Map) { + path.add((String) entry.getKey()); + serializeMap(settings, sb, path, (Map<Object, Object>) entry.getValue()); + path.remove(path.size() - 1); + } else if (entry.getValue() instanceof List) { + path.add((String) entry.getKey()); + serializeList(settings, sb, path, (List) entry.getValue()); + path.remove(path.size() - 1); + } else { + serializeValue(settings, sb, path, (String) entry.getKey(), entry.getValue()); + } + } + } + + @SuppressWarnings("unchecked") + private void serializeList(Map<String, String> settings, StringBuilder sb, List<String> path, List<String> yamlList) { + int counter = 0; + for (Object listEle : yamlList) { + if (listEle instanceof Map) { + path.add(Integer.toString(counter)); + serializeMap(settings, sb, path, (Map<Object, Object>) listEle); + path.remove(path.size() - 1); + } else if (listEle instanceof List) { + path.add(Integer.toString(counter)); + serializeList(settings, sb, path, (List<String>) listEle); + path.remove(path.size() - 1); + } else { + serializeValue(settings, sb, path, Integer.toString(counter), listEle); + } + counter++; + } + } + + private void serializeValue(Map<String, String> settings, StringBuilder sb, List<String> path, String name, Object value) { + if (value == null) { + return; + } + sb.setLength(0); + for (String pathEle : path) { + sb.append(pathEle).append('.'); + } + sb.append(name); + settings.put(sb.toString(), value.toString()); + } + + + public void parseTosca (String fileName){ + Map<String,String> map= new HashMap<String, String>(); + try { + map=load(fileName); + for(String key:map.keySet()){ + if(key.contains("policy.nodes.Root")) + { + continue; + } + else if(key.contains("policy.nodes")){ + String wordToFind = "policy.nodes."; + int indexForPolicyNode=key.indexOf(wordToFind); + String subNodeString= key.substring(indexForPolicyNode+13, key.length()); + + stringBetweenDots(subNodeString,map.get(key)); + } + else if(key.contains("policy.data")){ + String wordToFind="policy.data."; + int indexForPolicyNode=key.indexOf(wordToFind); + String subNodeString= key.substring(indexForPolicyNode+12, key.length()); + + stringBetweenDotsForDataFields(subNodeString,map.get(key)); + Iterator<String> itr= uniqueDataKeys.iterator(); + while(itr.hasNext()){ + logger.info(itr.next()); + } + } + } + + String attributeIndividualString=""; + String userDefinedIndividualString=""; + String referenceIndividualAttributes=""; + + String attributeString=""; + String userDefinedString=""; + String referenceAttributes=""; + String listConstraints=""; + + for(String uniqueDataKey: uniqueDataKeys){ + String[] uniqueDataKeySplit= uniqueDataKey.split("%"); + userDefinedIndividualString=userDefinedIndividualString+uniqueDataKey+"="; + userDefinedIndividualString=userDefinedIndividualString+"#A:defaultValue-#B:required-#C:MANY-false"; + for(String key:map.keySet()){ + if(key.contains("policy.data")){ + String containsKey= uniqueDataKeySplit[1]+".type"; + if(key.contains(uniqueDataKeySplit[0])){ + if(key.contains("default")){ + userDefinedIndividualString=userDefinedIndividualString.replace("#B", map.get(key)); + } + else if(key.contains("required")){ + userDefinedIndividualString=userDefinedIndividualString.replace("#C", map.get(key)); + } + else if(key.contains(containsKey)){ + String typeValue= map.get(key); + userDefinedIndividualString=userDefinedIndividualString.replace("#A", typeValue); + } + } + } + + } + if(userDefinedString!=""){ + userDefinedString=userDefinedString+","+userDefinedIndividualString; + }else{ + userDefinedString=userDefinedString+userDefinedIndividualString; + } + userDefinedIndividualString=""; + } + logger.info("userDefinedString :"+userDefinedString); + + HashMap<String,ArrayList<String>> mapKey= new HashMap<String,ArrayList<String>>(); + String secondPartString=""; + String firstPartString=""; + for(String value: userDefinedString.split(",")){ + String[] splitWithEquals= value.split("="); + secondPartString=splitWithEquals[0].substring(splitWithEquals[0].indexOf("%")+1); + firstPartString=splitWithEquals[0].substring(0, splitWithEquals[0].indexOf("%")); + ArrayList<String> list; + if(mapKey.containsKey(firstPartString)){ + list = mapKey.get(firstPartString); + list.add(secondPartString+"<"+splitWithEquals[1]); + } else { + list = new ArrayList<String>(); + list.add(secondPartString+"<"+splitWithEquals[1]); + mapKey.put(firstPartString, list); + } + } + + JSONObject mainObject= new JSONObject();; + JSONObject json; + for(String s: mapKey.keySet()){ + json= new JSONObject(); + List<String> value=mapKey.get(s); + for(String listValue:value){ + String[] splitValue=listValue.split("<"); + json.put(splitValue[0], splitValue[1]); + } + mainObject.put(s,json); + } + + logger.info(mainObject); + + Iterator<String> keysItr = mainObject.keys(); + while(keysItr.hasNext()) { + String key = keysItr.next(); + String value = mainObject.get(key).toString(); + retmap.put(key, value); + } + + for(String str:retmap.keySet()){ + logger.info(str+":"+retmap.get(str)); + } + + String typeValueFromKey=""; + boolean userDefinedDataType=false; + boolean isList=false; + for(String uniqueKey: uniqueKeys){ + List<String> constraints= new ArrayList<String>(); + logger.info("===================="); + attributeIndividualString=attributeIndividualString+uniqueKey+"="; + attributeIndividualString=attributeIndividualString+"#A:defaultValue-#B:required-#C:MANY-false"; + + logger.info("UniqueStrings: "+uniqueKey); + for(String key:map.keySet()){ + if(key.contains("policy.nodes.Root")|| + key.contains("policy.data")) + { + continue; + } + else if(key.contains("policy.nodes")){ + if(key.contains(uniqueKey)){ + int p=key.lastIndexOf("."); + String firstLastOccurance=key.substring(0,p); + int p1=firstLastOccurance.lastIndexOf("."); + String secondLastOccurance= firstLastOccurance.substring(p1+1,firstLastOccurance.length()); + if(secondLastOccurance.equals(uniqueKey)){ + String checkTypeString= firstLastOccurance+".type"; + typeValueFromKey= map.get(checkTypeString); + }//Its a list. + else if (key.contains("entry_schema")){ + if(key.contains("constraints")){ + constraints.add(map.get(key)); + } + if(key.contains("type")){ + isList=true; + String value= map.get(key); + if(! (value.contains("string")) || + (value.contains("integer")) || + (value.contains("boolean")) ) + { + if(!key.contains("valid_values")){ + String trimValue=value.substring(value.lastIndexOf(".")+1); + referenceIndividualAttributes=referenceIndividualAttributes+uniqueKey+"="+trimValue+":MANY-true"; + attributeIndividualString=""; + } + + } + } + } + + if(!(typeValueFromKey.equals("string")|| + typeValueFromKey.equals("integer") || + typeValueFromKey.equals("boolean"))) + { + if(typeValueFromKey.equals("list")){ + isList=true; + userDefinedDataType=false; + } + else{ + userDefinedDataType=true; + } + } + if(userDefinedDataType==false && isList==false){ + if(key.contains("default")){ + attributeIndividualString=attributeIndividualString.replace("#B", map.get(key)); + } + else if(key.contains("required")){ + attributeIndividualString=attributeIndividualString.replace("#C", map.get(key)); + } + else if(key.contains("type")){ + String typeValue= map.get(key); + attributeIndividualString=attributeIndividualString.replace("#A", typeValue); + } + } + else if(userDefinedDataType==true){ + String checkTypeAndUpdate=key.substring(p+1); + if(checkTypeAndUpdate.equals("type")){ + String value=map.get(key); + String trimValue=value.substring(value.lastIndexOf(".")+1); + referenceIndividualAttributes=referenceIndividualAttributes+uniqueKey+"="+trimValue+":MANY-false"; + } + attributeIndividualString=""; + } + } + } + } + + if(constraints!=null &&constraints.isEmpty()==false){ + //List handling. + listConstraints=uniqueKey.toUpperCase()+"=["; + isList=true; + for(String str:constraints){ + listConstraints=listConstraints+str+","; + } + listConstraints+="],"; + logger.info(listConstraints); + attributeIndividualString=""; + referenceIndividualAttributes=referenceIndividualAttributes+uniqueKey+"="+uniqueKey.toUpperCase()+":MANY-false"; + constraints=null; + + } + if(userDefinedDataType==false && isList==false){ + if(attributeString!=""){ + attributeString=attributeString+","+attributeIndividualString; + }else{ + attributeString=attributeString+attributeIndividualString; + } + } + if(isList==true || userDefinedDataType==true){ + if(referenceAttributes!=""){ + referenceAttributes=referenceAttributes+","+referenceIndividualAttributes; + }else{ + referenceAttributes=referenceAttributes+referenceIndividualAttributes; + } + logger.info("ReferenceAttributes: "+referenceAttributes); + } + + logger.info("AttributeString: "+ attributeString); + logger.info("ListConstraints is: "+listConstraints); + + attributeIndividualString=""; + referenceIndividualAttributes=""; + userDefinedDataType=false; + isList=false; + + } + this.listConstraints=listConstraints; + this.referenceAttributes=referenceAttributes; + this.attributeString=attributeString; + } catch (IOException e) { + logger.error(e); + } + } + private String cleanUPJson(String json) { String cleanJson = StringUtils.replaceEach(json, new String[]{"\\\\", "\\\\\\", "\\\\\\\\"}, new String[]{"\\", "\\", "\\"}); cleanJson = StringUtils.replaceEach(cleanJson, new String[]{"\\\\\\"}, new String[]{"\\"}); @@ -269,7 +633,7 @@ public class CreateDcaeMicroServiceController extends RestrictedBaseController { presKey = key; } // first check if we are different from old. - System.out.println(key+"\n"); + logger.info(key+"\n"); if(jsonArray!=null && jsonArray.length()>0 && key.contains("@") && !key.contains(".") && oldValue!=null){ if(!oldValue.equals(key.substring(0,key.indexOf("@")))){ jsonResult.put(oldValue, jsonArray); @@ -444,7 +808,7 @@ public class CreateDcaeMicroServiceController extends RestrictedBaseController { return null; } - @SuppressWarnings("unchecked") + @SuppressWarnings({ "unchecked", "rawtypes" }) private String createMicroSeriveJson(MicroServiceModels returnModel) { Map<String, String> attributeMap = new HashMap<String, String>(); Map<String, String> refAttributeMap = new HashMap<String, String>(); @@ -620,7 +984,7 @@ public class CreateDcaeMicroServiceController extends RestrictedBaseController { response.getWriter().write(j.toString()); } catch (Exception e){ - e.printStackTrace(); + logger.error(e); } } @@ -755,7 +1119,7 @@ public class CreateDcaeMicroServiceController extends RestrictedBaseController { } } catch (Exception e) { - e.printStackTrace(); + logger.error(e); } } @@ -852,8 +1216,9 @@ public class CreateDcaeMicroServiceController extends RestrictedBaseController { public void SetMSModelData(HttpServletRequest request, HttpServletResponse response) throws Exception{ List<FileItem> items = new ServletFileUpload(new DiskFileItemFactory()).parseRequest(request); boolean zip = false; + boolean yml= false; for (FileItem item : items) { - if(item.getName().endsWith(".zip") || item.getName().endsWith(".xmi")){ + if(item.getName().endsWith(".zip") || item.getName().endsWith(".xmi")||item.getName().endsWith(".yml")){ this.newModel = new MicroServiceModels(); try{ File file = new File(item.getName()); @@ -862,41 +1227,81 @@ public class CreateDcaeMicroServiceController extends RestrictedBaseController { outputStream.close(); this.newFile = file.toString(); this.newModel.setModelName(this.newFile.toString().split("-v")[0]); + if (this.newFile.toString().contains("-v")){ if (item.getName().endsWith(".zip")){ this.newModel.setVersion(this.newFile.toString().split("-v")[1].replace(".zip", "")); zip = true; - }else { + }else if(item.getName().endsWith(".yml")){ + this.newModel.setVersion(this.newFile.toString().split("-v")[1].replace(".yml", "")); + yml = true; + } + else { this.newModel.setVersion(this.newFile.toString().split("-v")[1].replace(".xmi", "")); } } + }catch(Exception e){ logger.error("Upload error : " + e); } } + } List<File> fileList = new ArrayList<File>();; this.directory = "model"; if (zip){ extractFolder(this.newFile); fileList = listModelFiles(this.directory); + }else if (yml==true){ + parseTosca(this.newFile); }else { File file = new File(this.newFile); fileList.add(file); } - - //Process Main Model file first - classMap = new HashMap<String,MSAttributeObject>(); - for (File file : fileList) { - if(!file.isDirectory() && file.getName().endsWith(".xmi")){ - retreiveDependency(file.toString(), true); - } + String modelType= ""; + if(yml==false){ + modelType="xmi"; + //Process Main Model file first + classMap = new HashMap<String,MSAttributeObject>(); + for (File file : fileList) { + if(!file.isDirectory() && file.getName().endsWith(".xmi")){ + retreiveDependency(file.toString(), true); + } + } + + modelList = createList(); + + cleanUp(this.newFile); + cleanUp(directory); + }else{ + modelType="yml"; + modelList.add(this.newModel.getModelName()); + String className=this.newModel.getModelName(); + MSAttributeObject msAttributes= new MSAttributeObject(); + msAttributes.setClassName(className); + + HashMap<String, String> returnAttributeList =new HashMap<String, String>(); + returnAttributeList.put(className, this.attributeString); + msAttributes.setAttribute(returnAttributeList); + + msAttributes.setSubClass(this.retmap); + + HashMap<String, String> returnReferenceList =new HashMap<String, String>(); + //String[] referenceArray=this.referenceAttributes.split("="); + returnReferenceList.put(className, this.referenceAttributes); + msAttributes.setRefAttribute(returnReferenceList); + + if(this.listConstraints!=""){ + HashMap<String, String> enumList =new HashMap<String, String>(); + String[] listArray=this.listConstraints.split("="); + enumList.put(listArray[0], listArray[1]); + msAttributes.setEnumType(enumList); + } + + classMap=new HashMap<String,MSAttributeObject>(); + classMap.put(className, msAttributes); + } - - modelList = createList(); - - cleanUp(this.newFile); - cleanUp(directory); PrintWriter out = response.getWriter(); @@ -908,6 +1313,7 @@ public class CreateDcaeMicroServiceController extends RestrictedBaseController { JSONObject j = new JSONObject(); j.put("classListDatas", modelList); j.put("modelDatas", mapper.writeValueAsString(classMap)); + j.put("modelType", modelType); out.write(j.toString()); } @@ -969,7 +1375,7 @@ public class CreateDcaeMicroServiceController extends RestrictedBaseController { tempMap = utils.processEpackage(workingFile, MODEL_TYPE.XMI); classMap.putAll(tempMap); - System.out.println(tempMap); + logger.info(tempMap); return; 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 ecc39cdb6..41c960680 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,8 +19,6 @@ */ package org.openecomp.policy.controller; - - import java.io.IOException; import java.io.PrintWriter; import java.util.ArrayList; @@ -514,7 +512,7 @@ public class CreateFirewallController extends RestrictedBaseController { ServiceListJson targetSl=null; int i=0; try{ - + String networkRole=""; for(String tag:tagCollectorList){ tags= new Tags(); List<Object> tagListData = commonClassDao.getData(FWTagPicker.class); @@ -535,12 +533,14 @@ public class CreateFirewallController extends RestrictedBaseController { tagList.add(tagDefine); } - + networkRole=jpaTagPickerList.getNetworkRole(); + break; } } tags.setTags(tagList); tags.setTagPickerName(tag); tags.setRuleName(termCollectorList.get(i)); + tags.setNetworkRole(networkRole); tagsList.add(tags); i++; } 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 d21788e90..57e8821f4 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 @@ -29,14 +29,14 @@ import java.util.Map; import javax.xml.bind.JAXBElement; -import org.openecomp.portalsdk.core.controller.RestrictedBaseController; -import org.springframework.stereotype.Controller; -import org.springframework.web.bind.annotation.RequestMapping; - 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.adapter.YAMLParams; import org.openecomp.policy.rest.jpa.PolicyEntity; +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.AllOfType; import oasis.names.tc.xacml._3_0.core.schema.wd_17.AnyOfType; @@ -150,24 +150,47 @@ public class DecisionPolicyController extends RestrictedBaseController { decisionList.add(settings); } else if (object instanceof RuleType) { // get the condition data under the rule for rule Algorithms. - if (((RuleType) object).getEffect().equals(EffectType.PERMIT)) { - ConditionType condition = ((RuleType) object).getCondition(); - if (condition != null) { - ApplyType decisionApply = (ApplyType) condition.getExpression().getValue(); - ruleAlgoirthmTracker = new LinkedList<Integer>(); - // Populating Rule Algorithms starting from compound. - prePopulateDecisionCompoundRuleAlgorithm(index, decisionApply); - policyAdapter.setRuleAlgorithmschoices(ruleAlgorithmList); - } - }else if(((RuleType) object).getEffect().equals(EffectType.DENY)) { + if(((RuleType) object).getEffect().equals(EffectType.DENY)) { if(((RuleType) object).getAdviceExpressions()!=null){ if(((RuleType) object).getAdviceExpressions().getAdviceExpression().get(0).getAdviceId().toString().equalsIgnoreCase("AAF")){ policyAdapter.setRuleProvider("AAF"); break; + }else if(((RuleType) object).getAdviceExpressions().getAdviceExpression().get(0).getAdviceId().toString().equalsIgnoreCase("GUARD_YAML")){ + policyAdapter.setRuleProvider("GUARD_YAML"); } }else{ policyAdapter.setRuleProvider("Custom"); } + ConditionType condition = ((RuleType) object).getCondition(); + if (condition != null) { + ApplyType decisionApply = (ApplyType) condition.getExpression().getValue(); + decisionApply = (ApplyType) decisionApply.getExpression().get(0).getValue(); + ruleAlgoirthmTracker = new LinkedList<Integer>(); + if(policyAdapter.getRuleProvider()!=null && policyAdapter.getRuleProvider().equals("GUARD_YAML")){ + YAMLParams yamlParams = new YAMLParams(); + for(int i=0; i<attributeList.size() ; i++){ + Map<String, String> map = (Map<String,String>)attributeList.get(i); + if(map.get("key").equals("actor")){ + yamlParams.setActor(map.get("value")); + }else if(map.get("key").equals("recipe")){ + yamlParams.setRecipe(map.get("value")); + } + } + ApplyType apply = ((ApplyType)((ApplyType)decisionApply.getExpression().get(0).getValue()).getExpression().get(0).getValue()); + yamlParams.setGuardActiveStart(((AttributeValueType)apply.getExpression().get(1).getValue()).getContent().get(0).toString()); + yamlParams.setGuardActiveEnd(((AttributeValueType)apply.getExpression().get(2).getValue()).getContent().get(0).toString()); + 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)); + policyAdapter.setYamlparams(yamlParams); + policyAdapter.setAttributes(new ArrayList<Object>()); + policyAdapter.setRuleAlgorithmschoices(new ArrayList<Object>()); + break; + } + // Populating Rule Algorithms starting from compound. + prePopulateDecisionCompoundRuleAlgorithm(index, decisionApply); + policyAdapter.setRuleAlgorithmschoices(ruleAlgorithmList); + } } } } @@ -244,6 +267,7 @@ public class DecisionPolicyController extends RestrictedBaseController { String keyValue = PolicyController.getDropDownMap().get(key); if (keyValue.equals(decisionApply.getFunctionId())) { rule.put("dynamicRuleAlgorithmCombo", key); + break; } } diff --git a/POLICY-SDK-APP/src/main/java/org/openecomp/policy/controller/PolicyController.java b/POLICY-SDK-APP/src/main/java/org/openecomp/policy/controller/PolicyController.java index 72dfb164b..7d8701ef4 100644 --- a/POLICY-SDK-APP/src/main/java/org/openecomp/policy/controller/PolicyController.java +++ b/POLICY-SDK-APP/src/main/java/org/openecomp/policy/controller/PolicyController.java @@ -361,6 +361,10 @@ public class PolicyController extends RestrictedBaseController { public void deleteData(Object entity) { commonClassDao.delete(entity); } + + public List<Object> getData(@SuppressWarnings("rawtypes") Class className){ + return commonClassDao.getData(className); + } public PolicyVersion getPolicyEntityFromPolicyVersion(String query){ PolicyVersion policyVersionEntity = (PolicyVersion) commonClassDao.getEntityItem(PolicyVersion.class, "policyName", query); 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 55bff24a0..eb144cc18 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 @@ -448,7 +448,44 @@ public class PolicyValidationController extends RestrictedBaseController { responseString = responseString + "Ecomp Name: Ecomp Name Should not be empty" + "<br>"; valid = false; } - + if(policyData.getRuleProvider().equals("GUARD_YAML")){ + if(policyData.getYamlparams()==null){ + responseString = responseString + "<b> Guard Params are Required </b>" + "<br>"; + valid = false; + }else{ + if(policyData.getYamlparams().getActor()==null){ + responseString = responseString + "Guard Params <b>Actor</b> is Required " + "<br>"; + valid = false; + } + if(policyData.getYamlparams().getRecipe()==null){ + responseString = responseString + "Guard Params <b>Recipe</b> is Required " + "<br>"; + valid = false; + } + if(policyData.getYamlparams().getLimit()==null){ + responseString = responseString + " Guard Params <b>Limit</b> is Required " + "<br>"; + valid = false; + }else{ + try{ + Integer.parseInt(policyData.getYamlparams().getLimit()); + }catch(NumberFormatException e){ + responseString = responseString + " Guard Params <b>Limit</b> Should be Integer " + "<br>"; + valid = false; + } + } + if(policyData.getYamlparams().getTimeWindow()==null){ + responseString = responseString + "Guard Params <b>Time Window</b> is Required" + "<br>"; + valid = false; + } + if(policyData.getYamlparams().getGuardActiveStart()==null){ + responseString = responseString + "Guard Params <b>Guard Active Start/b>is Required " + "<br>"; + valid = false; + } + if(policyData.getYamlparams().getGuardActiveEnd()==null){ + responseString = responseString + "Guard Params <b>Guard Active End</b>is Required " + "<br>"; + valid = false; + } + } + } } if(policyData.getPolicyType().equals(ACTION_POLICY)){ diff --git a/POLICY-SDK-APP/src/main/java/org/openecomp/policy/daoImp/CommonClassDaoImpl.java b/POLICY-SDK-APP/src/main/java/org/openecomp/policy/daoImp/CommonClassDaoImpl.java index 6ac4afbcf..9cb41eeab 100644 --- a/POLICY-SDK-APP/src/main/java/org/openecomp/policy/daoImp/CommonClassDaoImpl.java +++ b/POLICY-SDK-APP/src/main/java/org/openecomp/policy/daoImp/CommonClassDaoImpl.java @@ -264,8 +264,6 @@ public class CommonClassDaoImpl implements CommonClassDao{ @SuppressWarnings("rawtypes") @Override public Object getEntityItem(Class className, String columnName, String key) { - System.out.println(columnName); - System.out.println(key); Session session = sessionfactory.openSession(); Transaction tx = session.beginTransaction(); Object data = null; @@ -281,7 +279,6 @@ public class CommonClassDaoImpl implements CommonClassDao{ cr.add(Restrictions.eq(columnName, key)); } data = cr.list().get(0); - System.out.println(data); tx.commit(); } catch (Exception e) { LOGGER.error(XACMLErrorConstants.ERROR_PROCESS_FLOW + "Error While Querying Database Table"+e); diff --git a/POLICY-SDK-APP/src/main/webapp/app/policyApp/Windows/Dictionary/FWAddressGroupDictionary.html b/POLICY-SDK-APP/src/main/webapp/app/policyApp/Windows/Dictionary/FWAddressGroupDictionary.html index 231ac0a33..5f403b104 100644 --- a/POLICY-SDK-APP/src/main/webapp/app/policyApp/Windows/Dictionary/FWAddressGroupDictionary.html +++ b/POLICY-SDK-APP/src/main/webapp/app/policyApp/Windows/Dictionary/FWAddressGroupDictionary.html @@ -48,7 +48,7 @@ <div class="form-group row"> <div class="form-group"> <div data-ng-repeat="choice in apchoices"> - <div class="form-group row"> + <div class="form-group row" style="margin-left: 2%"> <div class="form-group col-sm-5" ng-class="{ 'has-error' : formdata.option.$invalid && !formdata.option.$pristine }"> <select class="form-control" ng-model="choice.option" ng-options="option for option in prefixListDictionaryDatas track by option"></select> <p ng-show="formdata.option.$invalid && !formdata.option.$pristine" class="help-block">Key is required.</p> diff --git a/POLICY-SDK-APP/src/main/webapp/app/policyApp/Windows/Dictionary/FWServiceGroupDictionary.html b/POLICY-SDK-APP/src/main/webapp/app/policyApp/Windows/Dictionary/FWServiceGroupDictionary.html index 3f676938e..4fb043136 100644 --- a/POLICY-SDK-APP/src/main/webapp/app/policyApp/Windows/Dictionary/FWServiceGroupDictionary.html +++ b/POLICY-SDK-APP/src/main/webapp/app/policyApp/Windows/Dictionary/FWServiceGroupDictionary.html @@ -23,7 +23,7 @@ <div class="form-group row"> <div class="form-group"> <div data-ng-repeat="choice in slchoices"> - <div class="form-group row"> + <div class="form-group row" style="margin-left: 2%"> <div class="form-group col-sm-5" ng-class="{ 'has-error' : formdata.option.$invalid && !formdata.option.$pristine }"> <select class="form-control" ng-model="choice.option" name= "option" required ng-options="option for option in serviceListDictionaryDatas track by option"><option value = "">{{choice.option}}</option></select> <p ng-show="formdata.option.$invalid && !formdata.option.$pristine" class="help-block">ServiceList is required.</p> diff --git a/POLICY-SDK-APP/src/main/webapp/app/policyApp/Windows/Dictionary/FWServiceListDictionary.html b/POLICY-SDK-APP/src/main/webapp/app/policyApp/Windows/Dictionary/FWServiceListDictionary.html index 130542326..8696f24f6 100644 --- a/POLICY-SDK-APP/src/main/webapp/app/policyApp/Windows/Dictionary/FWServiceListDictionary.html +++ b/POLICY-SDK-APP/src/main/webapp/app/policyApp/Windows/Dictionary/FWServiceListDictionary.html @@ -46,7 +46,7 @@ <div class="form-group row"> <div class="form-group"> <div data-ng-repeat="choice in tpchoices"> - <div class="form-group row"> + <div class="form-group row" style="margin-left: 2%"> <div class="form-group col-sm-5" ng-class="{ 'has-error' : formdata.option.$invalid && !formdata.option.$pristine }"> <select class="form-control" name= "option" required ng-model="choice.option" ng-options="option for option in protocolListDictionaryDatas track by option" > <option value="">{{choice.option}}</option></select> @@ -68,7 +68,7 @@ <div class="form-group row"> <div class="form-group"> <div data-ng-repeat="choice in apchoices"> - <div class="form-group row"> + <div class="form-group row" style="margin-left: 2%"> <div class="form-group col-sm-5" ng-class="{ 'has-error' : formdata.option.$invalid && !formdata.option.$pristine }"> <select class="form-control" name= "option" required ng-model="choice.option" ng-options="option for option in protocolListDictionaryDatas track by option" > <option value="">{{choice.option}}</option></select> diff --git a/POLICY-SDK-APP/src/main/webapp/app/policyApp/Windows/Dictionary/FWTagPicker.html b/POLICY-SDK-APP/src/main/webapp/app/policyApp/Windows/Dictionary/FWTagPicker.html index 30c4e6372..96ba42f1b 100644 --- a/POLICY-SDK-APP/src/main/webapp/app/policyApp/Windows/Dictionary/FWTagPicker.html +++ b/POLICY-SDK-APP/src/main/webapp/app/policyApp/Windows/Dictionary/FWTagPicker.html @@ -38,6 +38,12 @@ </div> </div> <div class="form-group row"> + <div class="form-group col-sm-6"> + <label>Network role:</label><br> + <input type="text" ng-model="editFWTagPicker.networkRole" class="form-control"/> + </div> + </div> + <div class="form-group row"> <div class="form-group col-sm-4"> <label>Select Tags:</label><br> <button type="button" class="btn btn-secondary btn-small" ng-click="addNewChoice()"><i class="fa fa-plus"></i></button> diff --git a/POLICY-SDK-APP/src/main/webapp/app/policyApp/Windows/Dictionary/FWTermListDictionary.html b/POLICY-SDK-APP/src/main/webapp/app/policyApp/Windows/Dictionary/FWTermListDictionary.html index 412cce34e..2e7a064f3 100644 --- a/POLICY-SDK-APP/src/main/webapp/app/policyApp/Windows/Dictionary/FWTermListDictionary.html +++ b/POLICY-SDK-APP/src/main/webapp/app/policyApp/Windows/Dictionary/FWTermListDictionary.html @@ -91,7 +91,7 @@ <div data-ng-repeat="choice in sourceListchoices"> <div class="form-group row"> <div class="form-group col-sm-5" ng-class="{ 'has-error' : formdata.option.$invalid && !formdata.option.$pristine }"> - <select class="form-control" ng-model="choice.option" ng-options="option for option in addressGroupDictionaryDatas track by option"><option value = "" name= "option" required>{{choice.option}}</option></select> + <select class="form-control" ng-model="choice.option" ng-options="option for option in groupAddresses track by option"><option value = "" name= "option" required>{{choice.option}}</option></select> <p ng-show="formdata.option.$invalid && !formdata.option.$pristine" class="help-block">Source-List is required.</p> </div> <div class="form-group col-sm-1"> @@ -112,7 +112,7 @@ <div data-ng-repeat="choice in destinationListchoices"> <div class="form-group row"> <div class="form-group col-sm-5" ng-class="{ 'has-error' : formdata.option.$invalid && !formdata.option.$pristine }"> - <select class="form-control" ng-model="choice.option" ng-options="option for option in prefixListDictionaryDatas track by option"><option value = "" name= "option" required>{{choice.option}}</option></select> + <select class="form-control" ng-model="choice.option" ng-options="option for option in groupAddresses track by option"><option value = "" name= "option" required>{{choice.option}}</option></select> <p ng-show="formdata.option.$invalid && !formdata.option.$pristine" class="help-block">Destination-List is required.</p> </div> <div class="form-group col-sm-1"> @@ -133,7 +133,7 @@ <div data-ng-repeat="choice in sourceServicechoices"> <div class="form-group row"> <div class="form-group col-sm-5" ng-class="{ 'has-error' : formdata.option.$invalid && !formdata.option.$pristine }"> - <select class="form-control" ng-model="choice.option" ng-options="option for option in serviceListDictionaryDatas track by option" ng-options="option for option in serviceGroupDictionaryDatas track by option"><option value = "" name= "option" required>{{choice.option}}</option></select> + <select class="form-control" ng-model="choice.option" ng-options="option for option in groupServices track by option" ng-options="option for option in groupServices track by option"><option value = "" name= "option" required>{{choice.option}}</option></select> <p ng-show="formdata.option.$invalid && !formdata.option.$pristine" class="help-block">Source-Services is required.</p> </div> <div class="form-group col-sm-1"> @@ -154,7 +154,7 @@ <div data-ng-repeat="choice in destinationServicechoices"> <div class="form-group row"> <div class="form-group col-sm-5" ng-class="{ 'has-error' : formdata.option.$invalid && !formdata.option.$pristine }"> - <select class="form-control" ng-model="choice.option" ng-options="option for option in serviceListDictionaryDatas track by option" ng-options="option for option in serviceGroupDictionaryDatas track by option" name= "option" required><option value = "">{{choice.option}}</option></select> + <select class="form-control" ng-model="choice.option" ng-options="option for option in groupServices track by option" ng-options="option for option in groupServices track by option" name= "option" required><option value = "">{{choice.option}}</option></select> <p ng-show="formdata.option.$invalid && !formdata.option.$pristine" class="help-block">Destination-Services is required.</p> </div> <div class="form-group col-sm-1"> diff --git a/POLICY-SDK-APP/src/main/webapp/app/policyApp/Windows/Dictionary/MSModelsDictionary.html b/POLICY-SDK-APP/src/main/webapp/app/policyApp/Windows/Dictionary/MSModelsDictionary.html index 0bc58fc1c..303f122cd 100644 --- a/POLICY-SDK-APP/src/main/webapp/app/policyApp/Windows/Dictionary/MSModelsDictionary.html +++ b/POLICY-SDK-APP/src/main/webapp/app/policyApp/Windows/Dictionary/MSModelsDictionary.html @@ -49,8 +49,8 @@ <p ng-show="formdata.classList.$invalid && !formdata.classList.$pristine" class="help-block">Micro Service is required.</p> </div> <div class="form-group col-sm-6"> - <label>Verison:</label><br> - <input type="text" ng-model="editMSmodelName.version" class="form-control"/> + <label>Version:<sup><b>*</b></sup></label><br> + <input type="text" required ng-model="editMSmodelName.version" class="form-control"/> </div> </div> </div> diff --git a/POLICY-SDK-APP/src/main/webapp/app/policyApp/controller/dictionaryController/FWTermListDictController.js b/POLICY-SDK-APP/src/main/webapp/app/policyApp/controller/dictionaryController/FWTermListDictController.js index 4c3ddb4ab..be2f7449b 100644 --- a/POLICY-SDK-APP/src/main/webapp/app/policyApp/controller/dictionaryController/FWTermListDictController.js +++ b/POLICY-SDK-APP/src/main/webapp/app/policyApp/controller/dictionaryController/FWTermListDictController.js @@ -25,6 +25,8 @@ app.controller('editFWTermListController' , function ($scope, $modalInstance, me $scope.sourceServicechoices = []; $scope.destinationServicechoices = []; $scope.actionListchoices = []; + $scope.groupAddresses=[]; + $scope.groupServices=[]; if(message.termListDictionaryData==null){ $scope.label='Add Term List Name' }else{ @@ -143,6 +145,10 @@ app.controller('editFWTermListController' , function ($scope, $modalInstance, me console.log($scope.data); $scope.prefixListDictionaryDatas = JSON.parse($scope.data.prefixListDictionaryDatas); console.log($scope.prefixListDictionaryDatas); + for(i = 0; i < $scope.prefixListDictionaryDatas.length; i++){ + var key = $scope.prefixListDictionaryDatas[i]; + $scope.groupAddresses.push(key); + } }, function (error) { console.log("failed"); }); @@ -163,6 +169,10 @@ app.controller('editFWTermListController' , function ($scope, $modalInstance, me console.log($scope.data); $scope.addressGroupDictionaryDatas = JSON.parse($scope.data.addressGroupDictionaryDatas); console.log($scope.addressGroupDictionaryDatas); + for(i = 0; i < $scope.addressGroupDictionaryDatas.length; i++){ + var key = $scope.addressGroupDictionaryDatas[i]; + $scope.groupAddresses.push(key); + } }, function (error) { console.log("failed"); }); @@ -173,6 +183,10 @@ app.controller('editFWTermListController' , function ($scope, $modalInstance, me console.log($scope.data); $scope.serviceListDictionaryDatas = JSON.parse($scope.data.serviceListDictionaryDatas); console.log($scope.serviceListDictionaryDatas); + for(i = 0; i < $scope.serviceListDictionaryDatas.length; i++){ + var key = $scope.serviceListDictionaryDatas[i]; + $scope.groupServices.push(key); + } }, function (error) { console.log("failed"); }); @@ -183,6 +197,10 @@ app.controller('editFWTermListController' , function ($scope, $modalInstance, me console.log($scope.data); $scope.serviceGroupDictionaryDatas = JSON.parse($scope.data.serviceGroupDictionaryDatas); console.log($scope.serviceGroupDictionaryDatas); + for(i = 0; i < $scope.serviceGroupDictionaryDatas.length; i++){ + var key = $scope.serviceGroupDictionaryDatas[i]; + $scope.groupServices.push(key); + } }, function (error) { console.log("failed"); }); diff --git a/POLICY-SDK-APP/src/main/webapp/app/policyApp/controller/dictionaryController/MSModelsDictController.js b/POLICY-SDK-APP/src/main/webapp/app/policyApp/controller/dictionaryController/MSModelsDictController.js index 2e30523ad..67b68eca8 100644 --- a/POLICY-SDK-APP/src/main/webapp/app/policyApp/controller/dictionaryController/MSModelsDictController.js +++ b/POLICY-SDK-APP/src/main/webapp/app/policyApp/controller/dictionaryController/MSModelsDictController.js @@ -37,7 +37,7 @@ app.controller('editMSModelController' , function ($scope, $modalInstance, mess $scope.uploadFile = function(files) { var extn = files[0].name.substr(files[0].name.lastIndexOf('.')+1); - if(extn == 'zip' || extn == 'xmi'){ + if(extn == 'zip' || extn == 'xmi'|| extn == 'yml'){ valid = true; var fd = new FormData(); fd.append("file", files[0]); @@ -51,6 +51,7 @@ app.controller('editMSModelController' , function ($scope, $modalInstance, mess }else{ $scope.classListDatas=data.classListDatas; $scope.modalDatas = data.modelDatas; + $scope.modelType= data.modelType; console.log($scope.classListDatas); } }).error( ); @@ -64,7 +65,7 @@ app.controller('editMSModelController' , function ($scope, $modalInstance, mess $scope.saveMSModel = function(microServiceModelsDictionaryData) { if(valid){ var uuu = "saveDictionary/ms_dictionary/save_model"; - var postData={microServiceModelsDictionaryData: microServiceModelsDictionaryData, userid: userid, classMap: $scope.modalDatas}; + var postData={microServiceModelsDictionaryData: microServiceModelsDictionaryData, userid: userid, classMap: $scope.modalDatas,modelType:$scope.modelType}; $.ajax({ type : 'POST', url : uuu, diff --git a/POLICY-SDK-APP/src/main/webapp/app/policyApp/controller/policyController.js b/POLICY-SDK-APP/src/main/webapp/app/policyApp/controller/policyController.js index ec6a56c05..4699512be 100644 --- a/POLICY-SDK-APP/src/main/webapp/app/policyApp/controller/policyController.js +++ b/POLICY-SDK-APP/src/main/webapp/app/policyApp/controller/policyController.js @@ -55,7 +55,7 @@ app.config(function($routeProvider) { }) .when('/policy_SearchFilter', { templateUrl: 'app/policyApp/policy-models/policy_SearchFilter.html', - controller : "PolicyManagerController" + controller : "PolicySearchController" }) .otherwise({ templateUrl:'app/policyApp/policy-models/Editor/templates/policyEditor.html', diff --git a/POLICY-SDK-APP/src/main/webapp/app/policyApp/main/policyEditor.html b/POLICY-SDK-APP/src/main/webapp/app/policyApp/main/policyEditor.html index 55b3214d2..dedf4b414 100644 --- a/POLICY-SDK-APP/src/main/webapp/app/policyApp/main/policyEditor.html +++ b/POLICY-SDK-APP/src/main/webapp/app/policyApp/main/policyEditor.html @@ -90,6 +90,7 @@ <script src= "app/policyApp/policy-models/Editor/js/services/policynavigator.js"></script> <script src= "app/policyApp/policy-models/Editor/js/services/policyuploader.js"></script> <script src= "app/policyApp/policy-models/Editor/js/controllers/policyManager.js"></script> + <script src= "app/policyApp/policy-models/Editor/js/controllers/policySearchManager.js"></script> <script src= "app/policyApp/policy-models/Editor/js/controllers/selector-controller.js"></script> <script src= "app/policyApp/controller/policyController.js"></script> diff --git a/POLICY-SDK-APP/src/main/webapp/app/policyApp/policy-models/Editor/PolicyTemplateController/ActionPolicyController.js b/POLICY-SDK-APP/src/main/webapp/app/policyApp/policy-models/Editor/PolicyTemplateController/ActionPolicyController.js index fde8d4e9e..6ca9dfd93 100644 --- a/POLICY-SDK-APP/src/main/webapp/app/policyApp/policy-models/Editor/PolicyTemplateController/ActionPolicyController.js +++ b/POLICY-SDK-APP/src/main/webapp/app/policyApp/policy-models/Editor/PolicyTemplateController/ActionPolicyController.js @@ -17,12 +17,24 @@ * limitations under the License. * ============LICENSE_END========================================================= */ -angular.module('abs').controller('actionPolicyController', function ($scope, PolicyAppService, modalService, $modal, Notification) { +app.controller('actionPolicyController', ['$scope', 'PolicyAppService', 'policyNavigator', 'modalService', '$modal', 'Notification', function ($scope, PolicyAppService, PolicyNavigator, modalService, $modal, Notification) { $("#dialog").hide(); + $scope.policyNavigator; $scope.savebutton = true; - $scope.finalPath = null; - + $scope.refreshCheck = false; + + $scope.refresh = function(){ + if($scope.refreshCheck){ + $scope.policyNavigator.refresh(); + } + $scope.modal('createNewPolicy', true); + }; + + $scope.modal = function(id, hide) { + return $('#' + id).modal(hide ? 'hide' : 'show'); + }; + PolicyAppService.getData('getDictionary/get_ActionPolicyDictDataByName').then(function (data) { var j = data; $scope.data = JSON.parse(j.data); @@ -61,7 +73,11 @@ angular.module('abs').controller('actionPolicyController', function ($scope, Pol } $scope.saveActionPolicy = function(policy){ - console.log(policy); + if(policy.itemContent != undefined){ + $scope.refreshCheck = true; + $scope.policyNavigator = policy.itemContent; + policy.itemContent = ""; + } $scope.savebutton = false; var uuu = "policycreation/save_policy"; var postData={policyData: policy}; @@ -82,7 +98,6 @@ angular.module('abs').controller('actionPolicyController', function ($scope, Pol Notification.error("Policy Already Exists with Same Name in Scope."); } }); - console.log($scope.data); }, error : function(data){ Notification.error("Error Occured while saving Policy."); @@ -92,9 +107,8 @@ angular.module('abs').controller('actionPolicyController', function ($scope, Pol }; $scope.validatePolicy = function(policy){ - console.log(policy); document.getElementById("validate").innerHTML = ""; - var uuu = "policyController/validate_policy.htm"; + var uuu = "policyController/validate_policy.htm"; var postData={policyData: policy}; $.ajax({ type : 'POST', @@ -118,7 +132,6 @@ angular.module('abs').controller('actionPolicyController', function ($scope, Pol } }); - console.log($scope.data); }, error : function(data){ Notification.error("Validation Failed."); @@ -170,4 +183,4 @@ angular.module('abs').controller('actionPolicyController', function ($scope, Pol $scope.temp.policy.ruleAlgorithmschoices.splice(lastItem); }; -});
\ No newline at end of file +}]);
\ No newline at end of file diff --git a/POLICY-SDK-APP/src/main/webapp/app/policyApp/policy-models/Editor/PolicyTemplateController/BRMSParamPolicyController.js b/POLICY-SDK-APP/src/main/webapp/app/policyApp/policy-models/Editor/PolicyTemplateController/BRMSParamPolicyController.js index c5160e741..ebec3a526 100644 --- a/POLICY-SDK-APP/src/main/webapp/app/policyApp/policy-models/Editor/PolicyTemplateController/BRMSParamPolicyController.js +++ b/POLICY-SDK-APP/src/main/webapp/app/policyApp/policy-models/Editor/PolicyTemplateController/BRMSParamPolicyController.js @@ -17,11 +17,23 @@ * limitations under the License. * ============LICENSE_END========================================================= */ -angular.module('abs').controller('brmsParamPolicyController', function ($scope, $window, PolicyAppService, modalService, $modal, Notification) { +angular.module('abs').controller('brmsParamPolicyController', ['$scope', '$window', 'PolicyAppService', 'policyNavigator', 'modalService', '$modal', 'Notification', function ($scope, $window, PolicyAppService, PolicyNavigator, modalService, $modal, Notification) { $("#dialog").hide(); + $scope.policyNavigator; $scope.savebutton = true; - $scope.finalPath = null; + $scope.refreshCheck = false; + + $scope.refresh = function(){ + if($scope.refreshCheck){ + $scope.policyNavigator.refresh(); + } + $scope.modal('createNewPolicy', true); + }; + + $scope.modal = function(id, hide) { + return $('#' + id).modal(hide ? 'hide' : 'show'); + }; $scope.validateSuccess = true; var readValue = $scope.temp.policy.readOnly; @@ -129,7 +141,11 @@ angular.module('abs').controller('brmsParamPolicyController', function ($scope, }; $scope.saveBrmsParamPolicy = function(policy){ - console.log(policy); + if(policy.itemContent != undefined){ + $scope.refreshCheck = true; + $scope.policyNavigator = policy.itemContent; + policy.itemContent = ""; + } $scope.savebutton = false; var uuu = "policycreation/save_policy"; var postData={policyData: policy}; @@ -231,7 +247,7 @@ angular.module('abs').controller('brmsParamPolicyController', function ($scope, var lastItem = $scope.temp.policy.attributes.length-1; $scope.temp.policy.attributes.splice(lastItem); }; -}); +}]); app.controller('showrulecontroller' , function ($scope, $modalInstance, message){ if(message.datas!=null){ diff --git a/POLICY-SDK-APP/src/main/webapp/app/policyApp/policy-models/Editor/PolicyTemplateController/BRMSRawPolicyController.js b/POLICY-SDK-APP/src/main/webapp/app/policyApp/policy-models/Editor/PolicyTemplateController/BRMSRawPolicyController.js index 5b78193ee..97f6d2997 100644 --- a/POLICY-SDK-APP/src/main/webapp/app/policyApp/policy-models/Editor/PolicyTemplateController/BRMSRawPolicyController.js +++ b/POLICY-SDK-APP/src/main/webapp/app/policyApp/policy-models/Editor/PolicyTemplateController/BRMSRawPolicyController.js @@ -17,11 +17,23 @@ * limitations under the License. * ============LICENSE_END========================================================= */ -angular.module('abs').controller('brmsRawPolicyController', function ($scope, $window, PolicyAppService, modalService, $modal, Notification) { +angular.module('abs').controller('brmsRawPolicyController', ['$scope', '$window', 'PolicyAppService', 'policyNavigator', 'modalService', '$modal', 'Notification', function ($scope, $window, PolicyAppService, PolicyNavigator, modalService, $modal, Notification) { $("#dialog").hide(); + $scope.policyNavigator; $scope.savebutton = true; - $scope.finalPath = null; + $scope.refreshCheck = false; + + $scope.refresh = function(){ + if($scope.refreshCheck){ + $scope.policyNavigator.refresh(); + } + $scope.modal('createNewPolicy', true); + }; + + $scope.modal = function(id, hide) { + return $('#' + id).modal(hide ? 'hide' : 'show'); + }; PolicyAppService.getData('getDictionary/get_BRMSControllerDataByName').then(function (data) { var j = data; @@ -54,7 +66,11 @@ angular.module('abs').controller('brmsRawPolicyController', function ($scope, $w }); $scope.saveBrmsRawPolicy = function(policy){ - console.log(policy); + if(policy.itemContent != undefined){ + $scope.refreshCheck = true; + $scope.policyNavigator = policy.itemContent; + policy.itemContent = ""; + } $scope.savebutton = false; var uuu = "policycreation/save_policy"; var postData={policyData: policy}; @@ -149,4 +165,4 @@ angular.module('abs').controller('brmsRawPolicyController', function ($scope, $w var lastItem = $scope.temp.policy.attributes.length-1; $scope.temp.policy.attributes.splice(lastItem); }; -});
\ No newline at end of file +}]);
\ No newline at end of file diff --git a/POLICY-SDK-APP/src/main/webapp/app/policyApp/policy-models/Editor/PolicyTemplateController/BaseConfigPolicyController.js b/POLICY-SDK-APP/src/main/webapp/app/policyApp/policy-models/Editor/PolicyTemplateController/BaseConfigPolicyController.js index 9f2863579..20287baf1 100644 --- a/POLICY-SDK-APP/src/main/webapp/app/policyApp/policy-models/Editor/PolicyTemplateController/BaseConfigPolicyController.js +++ b/POLICY-SDK-APP/src/main/webapp/app/policyApp/policy-models/Editor/PolicyTemplateController/BaseConfigPolicyController.js @@ -17,11 +17,25 @@ * limitations under the License. * ============LICENSE_END========================================================= */ -app.controller('baseConfigController', function ($scope, PolicyAppService, modalService, $modal, Notification) { +app.controller('baseConfigController', ['$scope', 'PolicyAppService', 'policyNavigator', 'modalService', '$modal', 'Notification', function ($scope, PolicyAppService, PolicyNavigator, modalService, $modal, Notification) { $("#dialog").hide(); + + $scope.policyNavigator; $scope.savebutton = true; - + $scope.refreshCheck = false; + + $scope.refresh = function(){ + if($scope.refreshCheck){ + $scope.policyNavigator.refresh(); + } + $scope.modal('createNewPolicy', true); + }; + + $scope.modal = function(id, hide) { + return $('#' + id).modal(hide ? 'hide' : 'show'); + }; + PolicyAppService.getData('getDictionary/get_EcompNameDataByName').then(function (data) { var j = data; $scope.data = JSON.parse(j.data); @@ -61,8 +75,12 @@ app.controller('baseConfigController', function ($scope, PolicyAppService, modal } $scope.savePolicy = function(policy){ + if(policy.itemContent != undefined){ + $scope.refreshCheck = true; + $scope.policyNavigator = policy.itemContent; + policy.itemContent = ""; + } $scope.savebutton = false; - console.log(policy); var uuu = "policycreation/save_policy"; var postData={policyData: policy}; $.ajax({ @@ -92,7 +110,7 @@ app.controller('baseConfigController', function ($scope, PolicyAppService, modal $scope.validatePolicy = function(policy){ - console.log(policy); + $scope.scope = policy.domain; document.getElementById("validate").innerHTML = ""; var uuu = "policyController/validate_policy.htm"; var postData={policyData: policy}; @@ -150,5 +168,4 @@ app.controller('baseConfigController', function ($scope, PolicyAppService, modal var lastItem = $scope.temp.policy.attributes.length-1; $scope.temp.policy.attributes.splice(lastItem); }; - -});
\ No newline at end of file +}]);
\ No newline at end of file diff --git a/POLICY-SDK-APP/src/main/webapp/app/policyApp/policy-models/Editor/PolicyTemplateController/ClosedLoopFaultController.js b/POLICY-SDK-APP/src/main/webapp/app/policyApp/policy-models/Editor/PolicyTemplateController/ClosedLoopFaultController.js index a8dcd7b0a..11254742a 100644 --- a/POLICY-SDK-APP/src/main/webapp/app/policyApp/policy-models/Editor/PolicyTemplateController/ClosedLoopFaultController.js +++ b/POLICY-SDK-APP/src/main/webapp/app/policyApp/policy-models/Editor/PolicyTemplateController/ClosedLoopFaultController.js @@ -17,11 +17,23 @@ * limitations under the License. * ============LICENSE_END========================================================= */ -angular.module("abs").controller('clFaultController', function($scope, $window, PolicyAppService, modalService, $modal, Notification){ +angular.module("abs").controller('clFaultController', ['$scope', '$window', 'PolicyAppService', 'policyNavigator', 'modalService', '$modal', 'Notification', function($scope, $window, PolicyAppService, PolicyNavigator, modalService, $modal, Notification){ $("#dialog").hide(); + $scope.policyNavigator; $scope.savebutton = true; - $scope.finalPath = null; + $scope.refreshCheck = false; + + $scope.refresh = function(){ + if($scope.refreshCheck){ + $scope.policyNavigator.refresh(); + } + $scope.modal('createNewPolicy', true); + }; + + $scope.modal = function(id, hide) { + return $('#' + id).modal(hide ? 'hide' : 'show'); + }; if($scope.temp.policy.triggerTrapSignatures == undefined){ $scope.temp.policy.triggerTrapSignatures = []; @@ -501,7 +513,11 @@ angular.module("abs").controller('clFaultController', function($scope, $window, }; $scope.saveFaultPolicy = function(policy){ - console.log(policy); + if(policy.itemContent != undefined){ + $scope.refreshCheck = true; + $scope.policyNavigator = policy.itemContent; + policy.itemContent = ""; + } $scope.savebutton = false; var data = {}; var faultData = {}; @@ -780,4 +796,4 @@ angular.module("abs").controller('clFaultController', function($scope, $window, }; -});
\ No newline at end of file +}]);
\ No newline at end of file diff --git a/POLICY-SDK-APP/src/main/webapp/app/policyApp/policy-models/Editor/PolicyTemplateController/ClosedLoopPMController.js b/POLICY-SDK-APP/src/main/webapp/app/policyApp/policy-models/Editor/PolicyTemplateController/ClosedLoopPMController.js index 2f709a716..393780705 100644 --- a/POLICY-SDK-APP/src/main/webapp/app/policyApp/policy-models/Editor/PolicyTemplateController/ClosedLoopPMController.js +++ b/POLICY-SDK-APP/src/main/webapp/app/policyApp/policy-models/Editor/PolicyTemplateController/ClosedLoopPMController.js @@ -17,11 +17,23 @@ * limitations under the License. * ============LICENSE_END========================================================= */ -angular.module("abs").controller('clPMController', function($scope, $window, $timeout, PolicyAppService, modalService, $modal, Notification){ +angular.module("abs").controller('clPMController', ['$scope', '$window', '$timeout', 'PolicyAppService', 'policyNavigator', 'modalService', '$modal', 'Notification', function($scope, $window, $timeout, PolicyAppService, PolicyNavigator, modalService, $modal, Notification){ $("#dialog").hide(); + $scope.policyNavigator; $scope.savebutton = true; - $scope.finalPath = null; + $scope.refreshCheck = false; + + $scope.refresh = function(){ + if($scope.refreshCheck){ + $scope.policyNavigator.refresh(); + } + $scope.modal('createNewPolicy', true); + }; + + $scope.modal = function(id, hide) { + return $('#' + id).modal(hide ? 'hide' : 'show'); + }; PolicyAppService.getData('getDictionary/get_EcompNameDataByName').then(function (data) { var j = data; @@ -88,7 +100,11 @@ angular.module("abs").controller('clPMController', function($scope, $window, $ti }; $scope.saveCLPMPolicy = function(policy){ - console.log(policy); + if(policy.itemContent != undefined){ + $scope.refreshCheck = true; + $scope.policyNavigator = policy.itemContent; + policy.itemContent = ""; + } $scope.savebutton = false; var uuu = "policycreation/save_policy"; var postData={policyData: policy}; @@ -160,4 +176,4 @@ angular.module("abs").controller('clPMController', function($scope, $window, $ti }); }; -})
\ No newline at end of file +}]);
\ No newline at end of file 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 d0f44d46e..b87299cbd 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 @@ -17,13 +17,25 @@ * limitations under the License. * ============LICENSE_END========================================================= */ -angular.module('abs').controller('dcaeMicroServiceController', function ($scope, $window, $compile, PolicyAppService, modalService, $modal, Notification) { +angular.module('abs').controller('dcaeMicroServiceController', ['$scope', '$window', '$compile', 'PolicyAppService', 'policyNavigator', 'modalService', '$modal', 'Notification', function ($scope, $window, $compile, PolicyAppService, PolicyNavigator, modalService, $modal, Notification) { $("#dialog").hide(); + + $scope.policyNavigator; $scope.isCheck = false; $scope.savebutton = true; - $scope.finalPath = null; + $scope.refreshCheck = false; + + $scope.refresh = function(){ + if($scope.refreshCheck){ + $scope.policyNavigator.refresh(); + } + $scope.modal('createNewPolicy', true); + }; + + $scope.modal = function(id, hide) { + return $('#' + id).modal(hide ? 'hide' : 'show'); + }; -// $scope.temp.policy.ttlDate = "2016-12-31"; if ($scope.temp.policy.editPolicy != undefined|| $scope.temp.policy.readOnly != undefined){ if ($scope.temp.policy.configName == undefined){ $scope.isCheck = false; @@ -384,11 +396,17 @@ angular.module('abs').controller('dcaeMicroServiceController', function ($scope, } function getList(attribute) { - + var enumName = attribute; + console.log("In getList: attribute => " + attribute); + if(attribute){ + if(attribute.includes(":")){ + enumName = attribute.split(":")[0]; + } + } var baseEnum = $scope.dcaeModelData.enumValues; var enumList = baseEnum.split(splitEnum); var enumAttributes; - var patternTest = new RegExp(attribute); + var patternTest = new RegExp(enumName); for (k=0; k < enumList.length; k += 1){ if(patternTest.test(enumList[k]) == true){ enumAttributes = enumList[k].trim(); @@ -399,12 +417,9 @@ angular.module('abs').controller('dcaeMicroServiceController', function ($scope, enumAttributes = enumAttributes.replace("[", ""); enumAttributes = enumAttributes.replace("]", ""); enumAttributes = enumAttributes.replace(/ /g, ''); - var dropListAfterCommaSplit = enumAttributes.split(splitEqual); listemunerateValues = dropListAfterCommaSplit[1].split(splitComma); - - enumKeyList.push(attribute); - + //enumKeyList.push(attribute); return listemunerateValues; } @@ -704,7 +719,10 @@ angular.module('abs').controller('dcaeMicroServiceController', function ($scope, option.appendChild(document.createTextNode(listemunerateValues[i])); listField.appendChild(option); } - listField.setAttribute("id" , ''+ labelLevel + attributeName + '');; + listField.setAttribute("id" , ''+ labelLevel + attributeName + ''); + + enumKeyList.push(attributeName); + document.getElementById(divID).appendChild(label); document.getElementById(divID).appendChild(br); @@ -750,6 +768,11 @@ angular.module('abs').controller('dcaeMicroServiceController', function ($scope, } $scope.savePolicy = function(policy){ + if(policy.itemContent != undefined){ + $scope.refreshCheck = true; + $scope.policyNavigator = policy.itemContent; + policy.itemContent = ""; + } $scope.savebutton = false; var splitAt = '*'; var dot ='.'; @@ -926,4 +949,4 @@ angular.module('abs').controller('dcaeMicroServiceController', function ($scope, } return obj; } -});
\ No newline at end of file +}]);
\ No newline at end of file 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 f5932e2f4..d0c72682b 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 @@ -17,10 +17,23 @@ * limitations under the License. * ============LICENSE_END========================================================= */ -angular.module('abs').controller('decisionPolicyController', function ($scope, PolicyAppService, modalService, $modal, Notification) { +angular.module('abs').controller('decisionPolicyController', ['$scope', 'PolicyAppService', 'policyNavigator', 'modalService', '$modal', 'Notification', function ($scope, PolicyAppService, PolicyNavigator, modalService, $modal, Notification) { $("#dialog").hide(); + + $scope.policyNavigator; $scope.savebutton = true; - $scope.finalPath = null; + $scope.refreshCheck = false; + + $scope.refresh = function(){ + if($scope.refreshCheck){ + $scope.policyNavigator.refresh(); + } + $scope.modal('createNewPolicy', true); + }; + + $scope.modal = function(id, hide) { + return $('#' + id).modal(hide ? 'hide' : 'show'); + }; if($scope.temp.policy.ruleProvider==undefined){ $scope.temp.policy.ruleProvider="Custom"; @@ -76,6 +89,11 @@ angular.module('abs').controller('decisionPolicyController', function ($scope, P } $scope.saveDecisionPolicy = function(policy){ + if(policy.itemContent != undefined){ + $scope.refreshCheck = true; + $scope.policyNavigator = policy.itemContent; + policy.itemContent = ""; + } $scope.savebutton = false; console.log(policy); var uuu = "policycreation/save_policy"; @@ -146,7 +164,7 @@ angular.module('abs').controller('decisionPolicyController', function ($scope, P $scope.temp.policy.attributes = []; $scope.temp.policy.settings = []; $scope.temp.policy.ruleAlgorithmschoices = []; - }else{ + }else if($scope.temp.policy.ruleProvider=="Custom"){ if($scope.temp.policy.attributes.length == 0){ $scope.temp.policy.attributes = []; } @@ -206,4 +224,4 @@ angular.module('abs').controller('decisionPolicyController', function ($scope, P $scope.temp.policy.attributes = []; } }; -});
\ No newline at end of file +}]);
\ No newline at end of file diff --git a/POLICY-SDK-APP/src/main/webapp/app/policyApp/policy-models/Editor/PolicyTemplateController/FirewallPolicyController.js b/POLICY-SDK-APP/src/main/webapp/app/policyApp/policy-models/Editor/PolicyTemplateController/FirewallPolicyController.js index cc051769c..46b6711cd 100644 --- a/POLICY-SDK-APP/src/main/webapp/app/policyApp/policy-models/Editor/PolicyTemplateController/FirewallPolicyController.js +++ b/POLICY-SDK-APP/src/main/webapp/app/policyApp/policy-models/Editor/PolicyTemplateController/FirewallPolicyController.js @@ -17,11 +17,23 @@ * limitations under the License. * ============LICENSE_END========================================================= */ -angular.module('abs').controller('fwPolicyController', function ($scope, $window, PolicyAppService, modalService, $modal, Notification) { +angular.module('abs').controller('fwPolicyController', ['$scope', '$window', 'PolicyAppService', 'policyNavigator', 'modalService', '$modal', 'Notification', function ($scope, $window, PolicyAppService, PolicyNavigator, modalService, $modal, Notification) { $("#dialog").hide(); + $scope.policyNavigator; $scope.savebutton = true; - $scope.finalPath = null; + $scope.refreshCheck = false; + + $scope.refresh = function(){ + if($scope.refreshCheck){ + $scope.policyNavigator.refresh(); + } + $scope.modal('createNewPolicy', true); + }; + + $scope.modal = function(id, hide) { + return $('#' + id).modal(hide ? 'hide' : 'show'); + }; PolicyAppService.getData('getDictionary/get_SecurityZoneDataByName').then(function (data) { var j = data; @@ -113,6 +125,11 @@ angular.module('abs').controller('fwPolicyController', function ($scope, $window $scope.saveFWPolicy = function(policy){ + if(policy.itemContent != undefined){ + $scope.refreshCheck = true; + $scope.policyNavigator = policy.itemContent; + policy.itemContent = ""; + } $scope.savebutton = false; console.log(policy); var uuu = "policycreation/save_policy"; @@ -224,4 +241,4 @@ angular.module('abs').controller('fwPolicyController', function ($scope, $window $scope.temp.policy.fwattributes.splice(lastItem); }; -});
\ No newline at end of file +}]);
\ No newline at end of file diff --git a/POLICY-SDK-APP/src/main/webapp/app/policyApp/policy-models/Editor/PolicyTemplates/ActionPolicyTemplate.html b/POLICY-SDK-APP/src/main/webapp/app/policyApp/policy-models/Editor/PolicyTemplates/ActionPolicyTemplate.html index 3b60c9b19..ffb0e972f 100644 --- a/POLICY-SDK-APP/src/main/webapp/app/policyApp/policy-models/Editor/PolicyTemplates/ActionPolicyTemplate.html +++ b/POLICY-SDK-APP/src/main/webapp/app/policyApp/policy-models/Editor/PolicyTemplates/ActionPolicyTemplate.html @@ -133,10 +133,7 @@ <button class="btn btn-success" ng-disabled="savebutton" herf="javascript:void(0)" ng-disabled="temp.policy.readOnly" ng-click="saveActionPolicy(temp);">Save</button> - <button class="btn btn-default" data-dismiss="modal" - ng-disabled="temp.inprocess" ng-model="finalPath" - ng-controller="FileManagerCtrl" - ng-click="closefunction(finalPath);">Close</button> + <button type="button" class="btn btn-default" ng-click="refresh();">Close</button> </div> </form> </div> diff --git a/POLICY-SDK-APP/src/main/webapp/app/policyApp/policy-models/Editor/PolicyTemplates/BRMSParamPolicyTemplate.html b/POLICY-SDK-APP/src/main/webapp/app/policyApp/policy-models/Editor/PolicyTemplates/BRMSParamPolicyTemplate.html index 6989a8509..2aa3b23d9 100644 --- a/POLICY-SDK-APP/src/main/webapp/app/policyApp/policy-models/Editor/PolicyTemplates/BRMSParamPolicyTemplate.html +++ b/POLICY-SDK-APP/src/main/webapp/app/policyApp/policy-models/Editor/PolicyTemplates/BRMSParamPolicyTemplate.html @@ -47,7 +47,7 @@ <div class="form-group row"> <div class="form-group col-sm-3"> <label>Time to Live Date:</label> <input type="date" - class="form-control" name="ttlDate" class="date" + class="form-control" name="ttlDate" ng-disabled="temp.policy.readOnly" class="date" ng-model="temp.policy.ttlDate" /> </div> <div class="form-group col-sm-3"> @@ -136,10 +136,7 @@ <button class="btn btn-success" herf="javascript:void(0)" ng-disabled="savebutton" ng-disabled="temp.policy.readOnly" ng-click="saveBrmsParamPolicy(temp);">Save</button> - <button type="button" class="btn btn-default" data-dismiss="modal" - ng-model="finalPath" - ng-controller="FileManagerCtrl" - ng-click="closefunction(finalPath);">Close</button> + <button type="button" class="btn btn-default" ng-click="refresh();">Close</button> </div> </div> </form> diff --git a/POLICY-SDK-APP/src/main/webapp/app/policyApp/policy-models/Editor/PolicyTemplates/BRMSRawPolicyTemplate.html b/POLICY-SDK-APP/src/main/webapp/app/policyApp/policy-models/Editor/PolicyTemplates/BRMSRawPolicyTemplate.html index 75b8c3ba2..a778b13fe 100644 --- a/POLICY-SDK-APP/src/main/webapp/app/policyApp/policy-models/Editor/PolicyTemplates/BRMSRawPolicyTemplate.html +++ b/POLICY-SDK-APP/src/main/webapp/app/policyApp/policy-models/Editor/PolicyTemplates/BRMSRawPolicyTemplate.html @@ -46,7 +46,7 @@ <div class="form-group row"> <div class="form-group col-sm-3"> <label>Time to Live Date:</label> <input type="date" - class="form-control" name="ttlDate" class="date" + class="form-control" name="ttlDate" ng-disabled="temp.policy.readOnly" class="date" ng-model="temp.policy.ttlDate" /> </div> <div class="form-group col-sm-3"> @@ -116,10 +116,7 @@ <button class="btn btn-success" herf="javascript:void(0)" ng-disabled="savebutton" ng-disabled="temp.policy.readOnly" ng-click="saveBrmsRawPolicy(temp);">Save</button> - <button type="button" class="btn btn-default" data-dismiss="modal" - ng-disabled="temp.inprocess" ng-model="finalPath" - ng-controller="FileManagerCtrl" - ng-click="closefunction(finalPath);">Close</button> + <button type="button" class="btn btn-default" ng-click="refresh();">Close</button> </div> </div> </form> diff --git a/POLICY-SDK-APP/src/main/webapp/app/policyApp/policy-models/Editor/PolicyTemplates/BasePolicyTemplate.html b/POLICY-SDK-APP/src/main/webapp/app/policyApp/policy-models/Editor/PolicyTemplates/BasePolicyTemplate.html index 16b8cad9a..1ecfd2fbd 100644 --- a/POLICY-SDK-APP/src/main/webapp/app/policyApp/policy-models/Editor/PolicyTemplates/BasePolicyTemplate.html +++ b/POLICY-SDK-APP/src/main/webapp/app/policyApp/policy-models/Editor/PolicyTemplates/BasePolicyTemplate.html @@ -31,7 +31,7 @@ </div> <div class="form-group col-sm-3"> <label>Time to Live Date:</label> <input type="date" - class="form-control" name="ttlDate" class="date" + class="form-control" ng-disabled="temp.policy.readOnly" name="ttlDate" class="date" ng-model="temp.policy.ttlDate" /> </div> </div> @@ -132,7 +132,7 @@ herf="javascript:void(0)" ng-click="validatePolicy(temp.policy);">Validate</button> <button class="btn btn-success" ng-disabled="savebutton" herf="javascript:void(0)" ng-click="savePolicy(temp);">Save</button> - <button type="button" class="btn btn-default" data-dismiss="modal">Close</button> + <button type="button" class="btn btn-default" ng-click="refresh();">Close</button> </div> </div> </form> diff --git a/POLICY-SDK-APP/src/main/webapp/app/policyApp/policy-models/Editor/PolicyTemplates/ClosedLoopFaultPolicyTemplate.html b/POLICY-SDK-APP/src/main/webapp/app/policyApp/policy-models/Editor/PolicyTemplates/ClosedLoopFaultPolicyTemplate.html index 6590d2690..e831bb40e 100644 --- a/POLICY-SDK-APP/src/main/webapp/app/policyApp/policy-models/Editor/PolicyTemplates/ClosedLoopFaultPolicyTemplate.html +++ b/POLICY-SDK-APP/src/main/webapp/app/policyApp/policy-models/Editor/PolicyTemplates/ClosedLoopFaultPolicyTemplate.html @@ -68,7 +68,7 @@ <option>InActive</option> </select> </div> - <div class="form-group col-sm-6"> + <div class="form-group col-sm-3"> <label>D2/Virtualized Services(s):<sup><b>*</b></sup></label><br> <input type="checkbox" ng-disabled="temp.policy.readOnly" ng-model="temp.policy.jsonBodyData.trinity"> Hosted Voice @@ -81,6 +81,11 @@ type="checkbox" ng-disabled="temp.policy.readOnly" ng-model="temp.policy.jsonBodyData.vDNS"> vDNS</input> </div> + <div class="form-group col-sm-3"> + <label>Time to Live Date:</label> <input type="date" + class="form-control" name="ttlDate" ng-disabled="temp.policy.readOnly" class="date" + ng-model="temp.policy.ttlDate" /> + </div> </div> </div> <div class="well"> @@ -492,9 +497,7 @@ <button class="btn btn-success" herf="javascript:void(0)" ng-disabled="savebutton" ng-disabled="temp.policy.readOnly" ng-click="saveFaultPolicy(temp);">Save</button> - <button type="button" class="btn btn-default" data-dismiss="modal" - ng-disabled="temp.inprocess" ng-model="finalPath" - ng-controller="FileManagerCtrl" ng-click="closefunction(finalPath);">Close</button> + <button type="button" class="btn btn-default" ng-click="refresh();">Close</button> </div> </form> </div>
\ No newline at end of file diff --git a/POLICY-SDK-APP/src/main/webapp/app/policyApp/policy-models/Editor/PolicyTemplates/ClosedLoopPMPolicyTemplate.html b/POLICY-SDK-APP/src/main/webapp/app/policyApp/policy-models/Editor/PolicyTemplates/ClosedLoopPMPolicyTemplate.html index e22070308..20781a369 100644 --- a/POLICY-SDK-APP/src/main/webapp/app/policyApp/policy-models/Editor/PolicyTemplates/ClosedLoopPMPolicyTemplate.html +++ b/POLICY-SDK-APP/src/main/webapp/app/policyApp/policy-models/Editor/PolicyTemplates/ClosedLoopPMPolicyTemplate.html @@ -25,7 +25,7 @@ </div> <div class="form-group col-sm-3"> <label>Time to Live Date:</label> <input type="date" - class="form-control" name="ttlDate" class="date" + class="form-control" name="ttlDate" ng-disabled="temp.policy.readOnly" class="date" ng-model="temp.policy.ttlDate" /> </div> <div class="form-group col-sm-3"> @@ -148,10 +148,7 @@ <button class="btn btn-success" herf="javascript:void(0)" ng-disabled="savebutton" ng-disabled="temp.policy.readOnly" ng-click="saveCLPMPolicy(temp);">Save</button> - <button type="button" class="btn btn-default" data-dismiss="modal" - ng-disabled="temp.inprocess" ng-model="finalPath" - ng-controller="FileManagerCtrl" - ng-click="closefunction(finalPath);">Close</button> + <button type="button" class="btn btn-default" ng-click="refresh();">Close</button> </div> </div> </form> 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 945e8655a..a12300b97 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 @@ -25,7 +25,7 @@ </div> <div class="form-group col-sm-3"> <label>Time to Live Date:</label> <input type="date" - class="form-control" name="ttlDate" class="date" + class="form-control" name="ttlDate" ng-disabled="temp.policy.readOnly" class="date" ng-model="temp.policy.ttlDate" /> </div> <div class="form-group col-sm-3"> @@ -126,9 +126,7 @@ <button class="btn btn-success" herf="javascript:void(0)" ng-disabled="savebutton" ng-disabled="temp.policy.readOnly" ng-click="savePolicy(temp);">Save</button> - <button type="button" class="btn btn-default" data-dismiss="modal" - ng-disabled="temp.inprocess" ng-model="finalPath" - ng-controller="FileManagerCtrl" ng-click="closefunction(finalPath);">Close</button> + <button type="button" class="btn btn-default" ng-click="refresh();">Close</button> </div> </form> </div> 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 d386770b9..a98dbff1d 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 @@ -31,10 +31,93 @@ ng-click="providerListener(temp.policy.ruleProvider);"> <option>Custom</option> <option>AAF</option> + <option>GUARD_YAML</option> </select> </div> </div> </div> + + <div ng-if="temp.policy.ruleProvider == 'GUARD_YAML'"> + <div class="well"> + <div class="form-group row"> + <div class="form-group col-sm-1"> + <label>Guard YAML Attributes:</label><br> + </div> + </div> + <div class="form-group row"> + <div class="form-group row" style="margin-left: 2%"> + <div class="form-group col-sm-3"> + <label> actor: </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.actor" + placeholder="Actor" /> + </div> + </div> + <div class="form-group row" style="margin-left: 2%"> + <div class="form-group col-sm-3"> + <label> recipe: </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.recipe" + placeholder="Recipe" /> + </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"> + <input type="text" class="form-control" + ng-disabled="temp.policy.readOnly" ng-model="temp.policy.yamlparams.limit" + placeholder="Limit" /> + </div> + </div> + <div class="form-group row" style="margin-left: 2%"> + <div class="form-group col-sm-3"> + <label> timeWindow: </label> + </div> + <div class="form-group col-sm-3"> + <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> + </select> + </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"> + <input type="text" class="form-control" + ng-disabled="temp.policy.readOnly" ng-model="temp.policy.yamlparams.guardActiveStart" + placeholder="00:00:00-05:00" /> + </div> + </div> + <div class="form-group row" style="margin-left: 2%"> + <div class="form-group col-sm-3"> + <label> guardActiveEnd: </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.guardActiveEnd" + placeholder="00:00:00-05:00" /> + </div> + </div> + </div> + </div> + </div> + <div ng-if="temp.policy.ruleProvider == 'Custom'"> <div class="well"> @@ -179,9 +262,7 @@ <button class="btn btn-success" herf="javascript:void(0)" ng-disabled="savebutton" ng-disabled="temp.policy.readOnly" ng-click="saveDecisionPolicy(temp);">Save</button> - <button class="btn btn-default" data-dismiss="modal" - ng-disabled="temp.inprocess" ng-model="finalPath" - ng-controller="FileManagerCtrl" ng-click="closefunction(finalPath);">Close</button> + <button type="button" class="btn btn-default" ng-click="refresh();">Close</button> </div> </form> </div> diff --git a/POLICY-SDK-APP/src/main/webapp/app/policyApp/policy-models/Editor/PolicyTemplates/FirewallPolicyTemplate.html b/POLICY-SDK-APP/src/main/webapp/app/policyApp/policy-models/Editor/PolicyTemplates/FirewallPolicyTemplate.html index 85ffbf7ab..2a4a6534f 100644 --- a/POLICY-SDK-APP/src/main/webapp/app/policyApp/policy-models/Editor/PolicyTemplates/FirewallPolicyTemplate.html +++ b/POLICY-SDK-APP/src/main/webapp/app/policyApp/policy-models/Editor/PolicyTemplates/FirewallPolicyTemplate.html @@ -51,7 +51,7 @@ </div> <div class="form-group col-sm-3"> <label>Time to Live Date:</label> <input type="date" - class="form-control" name="ttlDate" class="date" + class="form-control" name="ttlDate" ng-disabled="temp.policy.readOnly" class="date" ng-model="temp.policy.ttlDate" /> </div> <div class="form-group col-sm-3"> @@ -111,9 +111,7 @@ <button class="btn btn-success" herf="javascript:void(0)" ng-disabled="temp.policy.readOnly" ng-disabled="savebutton" ng-click="saveFWPolicy(temp);">Save</button> - <button type="button" class="btn btn-default" data-dismiss="modal" - ng-disabled="temp.inprocess" ng-model="finalPath" - ng-controller="FileManagerCtrl" ng-click="closefunction(finalPath);">Close</button> + <button type="button" class="btn btn-default" ng-click="refresh();">Close</button> </div> </form> </div>
\ No newline at end of file diff --git a/POLICY-SDK-APP/src/main/webapp/app/policyApp/policy-models/Editor/PolicyTemplates/PolicyTypeTemplate.html b/POLICY-SDK-APP/src/main/webapp/app/policyApp/policy-models/Editor/PolicyTemplates/PolicyTypeTemplate.html index 568387827..ada2428ed 100644 --- a/POLICY-SDK-APP/src/main/webapp/app/policyApp/policy-models/Editor/PolicyTemplates/PolicyTypeTemplate.html +++ b/POLICY-SDK-APP/src/main/webapp/app/policyApp/policy-models/Editor/PolicyTemplates/PolicyTypeTemplate.html @@ -26,7 +26,7 @@ <div class="modal-content"> <div class="modal-header"> <button type="button" class="close" data-dismiss="modal"> - <span aria-hidden="true">×</span> <span class="sr-only">{{"close" + <span class="sr-only">{{"close" | translate}}</span> </button> <form> diff --git a/POLICY-SDK-APP/src/main/webapp/app/policyApp/policy-models/Editor/js/controllers/policyManager.js b/POLICY-SDK-APP/src/main/webapp/app/policyApp/policy-models/Editor/js/controllers/policyManager.js index 869d26ba3..d471f2763 100644 --- a/POLICY-SDK-APP/src/main/webapp/app/policyApp/policy-models/Editor/js/controllers/policyManager.js +++ b/POLICY-SDK-APP/src/main/webapp/app/policyApp/policy-models/Editor/js/controllers/policyManager.js @@ -208,55 +208,12 @@ app.controller('PolicyManagerController', [ } }); }; - - $scope.search = function(search){ - var deferred = $q.defer(); - var uuu = "searchPolicy"; - var postData = {searchdata : search}; - $.ajax({ - type : 'POST', - url : uuu, - dataType: 'json', - contentType: 'application/json', - data: JSON.stringify(postData), - success : function(data){ - $scope.$apply(function(){ - $scope.searchdata=data.result;}); - if($scope.searchdata[0].error != undefined){ - Notification.info($scope.searchdata[0].error); - }else{ - var j = data; - $scope.data = JSON.stringify(data.result); - $scope.searchDatas = JSON.parse($scope.data); - var searchString = "Policies List" + "<br>"; - var i; - for(i = 0 ; i < $scope.searchDatas.length; i++){ - searchString += $scope.searchDatas[i].name + ".xml" + "<br>"; - } - var myWindow = window.open("", "MsgWindow", "width=500,height=500"); - myWindow.document.write("<p>Search List</p>"); - myWindow.document.write("<p>"+searchString+"</p>"); - } - }, - error : function(data){ - alert("Error while Searching."); - } - }); - }; - - - /* $scope.describePolicy = function(item){ - item.describePolicy().then(function(){ - $scope.modal('describePolicy', true); - }); - }; - - $scope.exportPolicy = function(item){ - item.exportPolicy().then(function(){ - $scope.modal('exportPolicy', true); - }); - };*/ + + $scope.refresh = function(){ + $scope.policyNavigator.refresh(); + }; + $scope.switchVersion = function(item){ if ($scope.policyNavigator.fileNameExists(item.tempModel.content.activeVersion)) { item.error = 'Invalid filename or already exists, specify another name'; @@ -268,13 +225,6 @@ app.controller('PolicyManagerController', [ }); }; - - /* $scope.viewPolicy = function(item){ - item.viewPolicy().then(function(){ - $scope.modal('createNewPolicy', true); - }); - };*/ - $scope.copy = function(item) { var samePath = item.tempModel.path.join() === item.model.path.join(); if (samePath && $scope.policyNavigator.fileNameExists(item.tempModel.name)) { diff --git a/POLICY-SDK-APP/src/main/webapp/app/policyApp/policy-models/Editor/js/controllers/policySearchManager.js b/POLICY-SDK-APP/src/main/webapp/app/policyApp/policy-models/Editor/js/controllers/policySearchManager.js new file mode 100644 index 000000000..83c3820a6 --- /dev/null +++ b/POLICY-SDK-APP/src/main/webapp/app/policyApp/policy-models/Editor/js/controllers/policySearchManager.js @@ -0,0 +1,204 @@ +/*- + * ============LICENSE_START======================================================= + * ECOMP Policy Engine + * ================================================================================ + * 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========================================================= + */ +app.controller('PolicySearchController', [ + '$scope', '$q', '$window', '$cookies', 'policyManagerConfig', 'item', 'policyNavigator', 'policyUploader', 'Notification','PolicyAppService', + function($scope, $q, $Window, $cookies, policyManagerConfig, Item, PolicyNavigator, PolicyUploader, Notification, PolicyAppService ) { + + $scope.isDisabled = true; + $scope.superAdminId = false; + $scope.exportPolicyId = false; + $scope.importPolicyId = false; + $scope.createScopeId = false; + $scope.deleteScopeId = false; + $scope.renameId = false; + $scope.createPolicyId = false; + $scope.cloneId = false; + $scope.editPolicyId = false; + $scope.switchVersionId = false; + $scope.describePolicyId = false; + $scope.viewPolicyId = false; + $scope.deletePolicyId = false; + PolicyAppService.getData('get_LockDownData').then(function(data){ + var j = data; + $scope.data = JSON.parse(j.data); + $scope.lockdowndata = JSON.parse($scope.data.lockdowndata); + if($scope.lockdowndata[0].lockdown == true){ + $scope.isDisabled = true; + }else{ + $scope.isDisabled = false; + } + console.log($scope.data); + },function(error){ + console.log("failed"); + }); + + PolicyAppService.getData('getDictionary/get_DescriptiveScopeByName').then(function(data){ + var j = data; + $scope.data = JSON.parse(j.data); + console.log($scope.data); + $scope.descriptiveScopeDictionaryDatas = JSON.parse($scope.data.descriptiveScopeDictionaryDatas); + }, function (error) { + console.log("failed"); + }); + + PolicyAppService.getData('getDictionary/get_EcompNameDataByName').then(function(data){ + var j = data; + $scope.data = JSON.parse(j.data); + console.log($scope.data); + $scope.ecompNameDictionaryDatas = JSON.parse($scope.data.ecompNameDictionaryDatas); + }, function (error) { + console.log("failed"); + }); + + PolicyAppService.getData('getDictionary/get_VSCLActionDataByName').then(function(data){ + var j = data; + $scope.data = JSON.parse(j.data); + console.log($scope.data); + $scope.vsclActionDictionaryDatas = JSON.parse($scope.data.vsclActionDictionaryDatas); + }, function (error) { + console.log("failed"); + }); + + PolicyAppService.getData('getDictionary/get_VNFTypeDataByName').then(function(data){ + var j = data; + $scope.data = JSON.parse(j.data); + console.log($scope.data); + $scope.vnfTypeDictionaryDatas = JSON.parse($scope.data.vnfTypeDictionaryDatas); + }, function (error) { + console.log("failed"); + }); + + + PolicyAppService.getData('get_UserRolesData').then(function (data) { + var j = data; + $scope.data = JSON.parse(j.data); + console.log($scope.data); + $scope.userRolesDatas = JSON.parse($scope.data.userRolesDatas); + console.log($scope.userRolesDatas); + if($scope.userRolesDatas[0] == 'super-admin'){ + $scope.superAdminId = true; + $scope.createPolicyId = true; + $scope.editPolicyId = true; + $scope.describePolicyId = true; + $scope.viewPolicyId = true; + }else if($scope.userRolesDatas[0] == 'super-editor' || $scope.userRolesDatas[0] == 'editor' || $scope.userRolesDatas[0] == 'admin'){ + $scope.editPolicyId = true; + $scope.createPolicyId = true; + $scope.describePolicyId = true; + $scope.viewPolicyId = true; + }else if($scope.userRolesDatas[0] == 'super-guest' || $scope.userRolesDatas[0] == 'guest'){ + $scope.describePolicyId = true; + $scope.viewPolicyId = true; + } + }, function (error) { + console.log("failed"); + }); + + $scope.config = policyManagerConfig; + $scope.reverse = false; + $scope.predicate = ['model.type', 'model.name']; + $scope.order = function(predicate) { + $scope.reverse = ($scope.predicate[1] === predicate) ? !$scope.reverse : false; + $scope.predicate[1] = predicate; + }; + + $scope.query = ''; + $scope.temp = new Item(); + $scope.policyNavigator = new PolicyNavigator(); + + $scope.setTemplate = function(name) { + $scope.viewTemplate = $cookies.viewTemplate = name; + }; + + $scope.touch = function(item) { + item = item instanceof Item ? item : new Item(); + item.revert(); + $scope.temp = item; + }; + + $scope.smartClick = function(item) { + if (item.isFolder()) { + return $scope.policyNavigator.folderClick(item); + } + if (item.isEditable()) { + return $scope.openEditItem(item); + } + }; + + $scope.openEditItem = function(item) { + item.getContent(); + $scope.modal('createNewPolicy'); + return $scope.touch(item); + }; + + $scope.modal = function(id, hide) { + return $('#' + id).modal(hide ? 'hide' : 'show'); + }; + + $scope.isInThisPath = function(path) { + var currentPath = $scope.policyNavigator.currentPath.join('/'); + return currentPath.indexOf(path) !== -1; + }; + + $scope.searchPolicy = function(searchContent){ + var deferred = $q.defer(); + var uuu = "searchPolicy"; + var postData = {searchdata : searchContent}; + $.ajax({ + type : 'POST', + url : uuu, + dataType: 'json', + contentType: 'application/json', + data: JSON.stringify(postData), + success : function(data){ + $scope.$apply(function(){ + var searchdata = data.result; + if(searchdata.length > 0){ + $scope.policyNavigator.searchrefresh(searchdata); + }else{ + Notification.info("No Matches Found with your Search"); + } + }); + }, + error : function(data){ + alert("Error while Searching."); + } + }); + }; + + $scope.refresh = function(searchData){ + $scope.policyNavigator.searchrefresh(null); + }; + + $scope.getQueryParam = function(param) { + var found; + window.location.search.substr(1).split('&').forEach(function(item) { + if (param === item.split('=')[0]) { + found = item.split('=')[1]; + return false; + } + }); + return found; + }; + + $scope.isWindows = $scope.getQueryParam('server') === 'Windows'; + $scope.policyNavigator.searchrefresh(null); + $scope.policyNavigator.setSearchModalActiveStatus(); + }]); diff --git a/POLICY-SDK-APP/src/main/webapp/app/policyApp/policy-models/Editor/js/entities/item.js b/POLICY-SDK-APP/src/main/webapp/app/policyApp/policy-models/Editor/js/entities/item.js index 2b1fd3469..21762ce77 100644 --- a/POLICY-SDK-APP/src/main/webapp/app/policyApp/policy-models/Editor/js/entities/item.js +++ b/POLICY-SDK-APP/src/main/webapp/app/policyApp/policy-models/Editor/js/entities/item.js @@ -170,7 +170,7 @@ angular.module('abs').factory('item', ['$http', '$q', 'policyManagerConfig', fun }; - Item.prototype.getContent = function() { + Item.prototype.getContent = function(policyNavigator) { var self = this; var deferred = $q.defer(); var data = {params: { @@ -185,6 +185,7 @@ angular.module('abs').factory('item', ['$http', '$q', 'policyManagerConfig', fun var json = data.result; var policy = JSON.parse(json); self.policy = policy; + self.itemContent = policyNavigator; console.log(policy); self.deferredHandler(data, deferred); }).error(function(data) { @@ -339,9 +340,5 @@ angular.module('abs').factory('item', ['$http', '$q', 'policyManagerConfig', fun return !this.isFolder() && policyManagerConfig.isEditableFilePattern.test(this.model.name); }; - /*Item.prototype.isImage = function() { - return policyManagerConfig.isImageFilePattern.test(this.model.name); - };*/ - return Item; }]); diff --git a/POLICY-SDK-APP/src/main/webapp/app/policyApp/policy-models/Editor/js/providers/config.js b/POLICY-SDK-APP/src/main/webapp/app/policyApp/policy-models/Editor/js/providers/config.js index 72fd84d53..6afabe136 100644 --- a/POLICY-SDK-APP/src/main/webapp/app/policyApp/policy-models/Editor/js/providers/config.js +++ b/POLICY-SDK-APP/src/main/webapp/app/policyApp/policy-models/Editor/js/providers/config.js @@ -42,6 +42,7 @@ addSubScopeUrl : 'fm/addSubScopeUrl', switchVersionUrl : 'fm/switchVersionUrl', exportUrl : 'fm/exportUrl', + searchListUrl : 'fm/searchListUrl', sidebar: true, breadcrumb: true, diff --git a/POLICY-SDK-APP/src/main/webapp/app/policyApp/policy-models/Editor/js/services/policynavigator.js b/POLICY-SDK-APP/src/main/webapp/app/policyApp/policy-models/Editor/js/services/policynavigator.js index bb76dd9d5..1435afe8a 100644 --- a/POLICY-SDK-APP/src/main/webapp/app/policyApp/policy-models/Editor/js/services/policynavigator.js +++ b/POLICY-SDK-APP/src/main/webapp/app/policyApp/policy-models/Editor/js/services/policynavigator.js @@ -30,8 +30,13 @@ this.currentPath = []; this.history = []; this.error = ''; + this.searchModalActive = false; }; + PolicyNavigator.prototype.setSearchModalActiveStatus = function(){ + this.searchModalActive = true; + }; + PolicyNavigator.prototype.deferredHandler = function(data, deferred, defaultMsg) { if (!data || typeof data !== 'object') { this.error = 'Bridge response error, please check the docs'; @@ -99,29 +104,49 @@ PolicyNavigator.prototype.refresh = function() { var self = this; var path = self.currentPath.join('/'); - return self.list().then(function(data) { - self.fileList = (data.result || []).map(function(file) { - return new Item(file, self.currentPath); - }); - self.buildTree(path); - }); + if(self.searchModalActive){ + return self.searchlist(null).then(function(data) { + self.fileList = (data.result || []).map(function(file) { + return new Item(file, self.currentPath); + }); + self.buildTree(path); + }); + }else{ + return self.list().then(function(data) { + self.fileList = (data.result || []).map(function(file) { + return new Item(file, self.currentPath); + }); + self.buildTree(path); + }); + } }; - PolicyNavigator.prototype.policylist = function(finalpath) { + PolicyNavigator.prototype.searchlist = function(policyList) { var self = this; var deferred = $q.defer(); - var path = finalpath; - var data = {params: { - mode: 'LIST', - onlyFolders: false, - path: '/' + path - }}; + var path = self.currentPath.join('/'); + var data; + if(policyList == null){ + data = {params: { + mode: 'SEARCHLIST', + onlyFolders: false, + path: '/' + path + }}; + }else{ + data = {params: { + mode: 'SEARCHLIST', + onlyFolders: false, + path: '/' + path, + policyList : policyList + }}; + } + self.requesting = true; self.fileList = []; self.error = ''; - $http.post(policyManagerConfig.listUrl, data).success(function(data) { + $http.post(policyManagerConfig.searchListUrl, data).success(function(data) { self.deferredHandler(data, deferred); }).error(function(data) { self.deferredHandler(data, deferred, 'Unknown error listing, check the response'); @@ -131,16 +156,15 @@ return deferred.promise; }; - PolicyNavigator.prototype.policyrefresh = function(finalpath) { - var self = this; - var path = finalpath; - self.currentPath = path; - return self.policylist(finalpath).then(function(data) { - self.fileList = (data.result || []).map(function(file) { - return new Item(file, self.currentPath); - }); - self.buildTree(path); - }); + PolicyNavigator.prototype.searchrefresh = function(policyList) { + var self = this; + var path = self.currentPath.join('/'); + return self.searchlist(policyList).then(function(data) { + self.fileList = (data.result || []).map(function(file) { + return new Item(file, self.currentPath); + }); + self.buildTree(path); + }); }; diff --git a/POLICY-SDK-APP/src/main/webapp/app/policyApp/policy-models/Editor/templates/item-context-menu.html b/POLICY-SDK-APP/src/main/webapp/app/policyApp/policy-models/Editor/templates/item-context-menu.html index 5ef11b219..3c41fbc1d 100644 --- a/POLICY-SDK-APP/src/main/webapp/app/policyApp/policy-models/Editor/templates/item-context-menu.html +++ b/POLICY-SDK-APP/src/main/webapp/app/policyApp/policy-models/Editor/templates/item-context-menu.html @@ -47,7 +47,7 @@ </a> </li> <li ng-show="config.allowedActions.edit && !temp.isFolder()"> - <a href="" tabindex="-1" data-toggle="modal" data-target="#createNewPolicy" ng-show="editPolicyId" ng-click="temp.getContent();"> + <a href="" tabindex="-1" data-toggle="modal" data-target="#createNewPolicy" ng-show="editPolicyId" ng-click="temp.getContent(policyNavigator);"> <i class="glyphicon glyphicon-pencil"></i> Edit Policy </a> </li> 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 f2b2b8d9d..6bd9587ef 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 @@ -4,17 +4,16 @@ <form ng-submit="remove(temp)"> <div class="modal-header"> <button type="button" class="close" data-dismiss="modal"> - <span aria-hidden="true">×</span> <span class="sr-only">Close</span> </button> <h4 class="modal-title">Confirm</h4> </div> - <div> + <div class="modal-body"> Are you Sure to delete <b>{{temp.model.name}}</b> ? <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-default" 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> @@ -28,12 +27,11 @@ <form ng-submit="removePolicy(temp)"> <div class="modal-header"> <button type="button" class="close" data-dismiss="modal"> - <span aria-hidden="true">×</span> <span class="sr-only">Close</span> </button> <h4 class="modal-title">Confirm</h4> </div> - <div>Are you Sure to delete <b>{{temp.model.name}}</b> ? + <div class="modal-body">Are you Sure to delete <b>{{temp.model.name}}</b> ? <div> <p> <input type = "radio" ng-model ="temp.model.versions" name = "radSize" id = "sizeSmall" value = "CURRENT" checked = "checked" /><label for = "sizeSmall">Are you sure you want to delete Current Version of Policy</label> @@ -44,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-disabled="temp.inprocess">Cancel</button> + <button type="button" class="btn btn-default" 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> @@ -58,16 +56,14 @@ <form ng-submit="rename(temp)"> <div class="modal-header"> <button type="button" class="close" data-dismiss="modal"> - <span aria-hidden="true">×</span> <span class="sr-only">Close</span> </button> <h4 class="modal-title">Rename</h4> </div> - <div> + <div class="modal-body"> <label class="radio">Enter New Name : <b>{{temp.model.name}}</b></label> <input class="form-control" ng-model="temp.tempModel.name" autofocus="autofocus"> - <div ng-include data-src="'path-selector'" class="clearfix"></div> <div ng-include data-src="'error-bar'" class="clearfix"></div> </div> <div class="modal-footer"> @@ -85,7 +81,6 @@ <form> <div class="modal-header"> <button type="button" class="close" data-dismiss="modal"> - <span aria-hidden="true">×</span> <span class="sr-only">Close</span> </button> <h4 class="modal-title">List of Policies</h4> @@ -107,12 +102,11 @@ <form ng-submit="move(temp)"> <div class="modal-header"> <button type="button" class="close" data-dismiss="modal"> - <span aria-hidden="true">×</span> <span class="sr-only">Close</span> </button> <h4 class="modal-title">Move Policy</h4> </div> - <div> + <div class="modal-body"> <div ng-include data-src="'path-selector'" class="clearfix"></div> <div ng-include data-src="'error-bar'" class="clearfix"></div> </div> @@ -131,16 +125,15 @@ <form ng-submit="switchVersion(temp)"> <div class="modal-header"> <button type="button" class="close" data-dismiss="modal"> - <span aria-hidden="true">×</span> <span class="sr-only">Close</span> </button> <h4 class="modal-title">Switch Version</h4> </div> - <div> + <div class="modal-body"> <label class="radio">Highest Version <b></b></label> <input class="form-control" ng-disabled="true" ng-model="temp.tempModel.content.highestVersion" autofocus="autofocus"> </div> - <div> + <div class="modal-body"> <label class="radio">Active Version <b></b></label> <select class="form-control" ng-model="temp.tempModel.content.activeVersion" ng-options="option for option in temp.tempModel.content.availableVersions" autofocus="autofocus"></select> <div ng-include data-src="'error-bar'" class="clearfix"></div> @@ -160,12 +153,11 @@ <form ng-submit="copy(temp)"> <div class="modal-header"> <button type="button" class="close" data-dismiss="modal"> - <span aria-hidden="true">×</span> <span class="sr-only">Close</span> </button> <h4 class="modal-title">Clone Policy</h4> </div> - <div> + <div class="modal-body"> <label class="radio">Enter new Policy Name to Clone <b>{{temp.model.name}}</b></label> <input class="form-control" ng-model="temp.tempModel.name" autofocus="autofocus"> @@ -187,12 +179,11 @@ <form ng-submit="createFolder(temp)"> <div class="modal-header"> <button type="button" class="close" data-dismiss="modal"> - <span aria-hidden="true">×</span> <span class="sr-only">Close</span> </button> <h4 class="modal-title">Add Scope</h4> </div> - <div> + <div class="modal-body"> <label class="radio">Scope Name</label> <input class="form-control" ng-model="temp.tempModel.name" autofocus="autofocus"> <div ng-include data-src="'error-bar'" class="clearfix"></div> @@ -212,12 +203,11 @@ <form ng-submit="subScopeFolder(temp)"> <div class="modal-header"> <button type="button" class="close" data-dismiss="modal"> - <span aria-hidden="true">×</span> <span class="sr-only">Close</span> </button> <h4 class="modal-title">Add Sub Scope</h4> </div> - <div> + <div class="modal-body"> <label class="radio">Scope Name</label> <input class="form-control" ng-model="temp.tempModel.subScopename" autofocus="autofocus"> <div ng-include data-src="'error-bar'" class="clearfix"></div> @@ -237,12 +227,11 @@ <form ng-submit="uploadFiles()"> <div class="modal-header"> <button type="button" class="close" data-dismiss="modal"> - <span aria-hidden="true">×</span> <span class="sr-only">Close</span> </button> <h4 class="modal-title">Import</h4> </div> - <div> + <div class="modal-body"> <label class="radio">Upload to</label> <input type="file" class="form-control" ng-file="$parent.uploadFileList" autofocus="autofocus" multiple="multiple"/> <div ng-include data-src="'error-bar'" class="clearfix"></div> @@ -266,7 +255,6 @@ <div class="modal-content"> <div class="modal-header"> <button type="button" class="close" data-dismiss="modal"> - <span aria-hidden="true">×</span> <span class="sr-only">Close</span> </button> <h4 class="modal-title">Select the Destination Scope</h4> 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 43eb5148b..72985a190 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 @@ -102,7 +102,7 @@ body { </div> </div> <div class="form-group row"> - <div class="form-group col-sm-6"> + <div class="form-group col-sm-6" ng-if="search.closedLooppolicyType == 'Config_PM'"> <label>D2 Service:</label><BR> <select class="form-control" ng-model="search.d2Service"> <option>Hosted Voice(Trinity)</option> @@ -112,18 +112,15 @@ body { <option>vDNS</option> </select> </div> - <div class="form-group col-sm-6"> - <label>Bind Text Search to:</label><BR> <select - class="form-control" ng-model="search.bindTextSearch"> - <option>Email Address</option> - <option>Trigger Signature</option> - <option>Connect All Traps</option> - <option>Verification Signature</option> - <option>Connect All Faults</option> - <option>Onset Message</option> - <option>Policy Name</option> - <option>Abatement Message</option> - <option>Geo Link</option> + <div class="form-group col-sm-6" + ng-if="search.closedLooppolicyType == 'Config_PM'"> + <label>Service Type:</label><BR> <select + class="form-control" ng-model="search.serviceType"> + <option>Registration Failure(Trinity)</option> + <option>International Fraud(Trinity)</option> + <option>No Dial Tone(Trinity)</option> + <option>Call Storm(Trinity)</option> + <option>Registration Storm(Trinity)</option> </select> </div> </div> @@ -150,15 +147,18 @@ body { class="form-control" ng-model="search.vproAction" ng-options="option for option in vsclActionDictionaryDatas track by option"></select> </div> - <div class="form-group col-sm-6" - ng-if="search.closedLooppolicyType == 'Config_PM'"> - <label>Service Type:</label><BR> <select - class="form-control" ng-model="search.serviceType"> - <option>Registration Failure(Trinity)</option> - <option>International Fraud(Trinity)</option> - <option>No Dial Tone(Trinity)</option> - <option>Call Storm(Trinity)</option> - <option>Registration Storm(Trinity)</option> + <div class="form-group col-sm-6" ng-if="search.closedLooppolicyType == 'Config_Fault'"> + <label>Bind Text Search to:</label><BR> <select + class="form-control" ng-model="search.bindTextSearch"> + <option>Email Address</option> + <option>Trigger Signature</option> + <option>Connect All Traps</option> + <option>Verification Signature</option> + <option>Connect All Faults</option> + <option>Onset Message</option> + <option>Policy Name</option> + <option>Abatement Message</option> + <option>Geo Link</option> </select> </div> </div> @@ -166,8 +166,12 @@ body { </form> </div> </div> + <button type="button" class="btn btn-default" + ng-click="refresh(search = null);"> + <span aria-hidden="true">Clear</span> + </button> <button type="button" class="btn btn-primary" - ng-click="search(search);"> + ng-click="searchPolicy(search);"> <span class="glyphicon glyphicon-search" aria-hidden="true"></span> </button> </div> |