From 87c95be02a8a4d77e165dede90777e811b59dcae Mon Sep 17 00:00:00 2001 From: Ravindra Bakkamanthala Date: Tue, 23 May 2017 14:56:12 -0400 Subject: Commit includes ControlLoopPolicy API and bugfixes Change-Id: I3e18bb8b4c31a0d908bb0cff4c85e2a3fb450a63 Signed-off-by: Ravindra Bakkamanthala --- .../policy/admin/PolicyManagerServlet.java | 274 +++++++++-------- .../policy/admin/PolicyNotificationMail.java | 42 +-- .../policy/admin/PolicyRestController.java | 14 +- .../policy/admin/PolicyUserInfoController.java | 2 +- .../openecomp/policy/admin/RESTfulPAPEngine.java | 2 +- .../policy/components/HumanPolicyComponent.java | 7 +- .../policy/components/PolicyImportWindow.java | 16 +- .../openecomp/policy/conf/HibernateSession.java | 11 +- .../policy/controller/ActionPolicyController.java | 10 +- .../policy/controller/AdminTabController.java | 2 +- .../policy/controller/AutoPushController.java | 16 +- .../controller/CreateBRMSParamController.java | 10 +- .../policy/controller/CreateBRMSRawController.java | 2 +- .../CreateClosedLoopFaultController.java | 4 +- .../CreateDcaeMicroServiceController.java | 341 ++++++++++----------- .../controller/CreateFirewallController.java | 103 ++++--- .../policy/controller/CreatePolicyController.java | 4 +- .../policy/controller/DashboardController.java | 16 +- .../controller/DecisionPolicyController.java | 14 +- .../openecomp/policy/controller/PDPController.java | 20 +- .../policy/controller/PolicyController.java | 23 +- .../PolicyExportAndImportController.java | 6 +- .../policy/controller/PolicyRolesController.java | 6 +- .../controller/PolicyValidationController.java | 20 +- .../policy/daoImp/CommonClassDaoImpl.java | 2 +- .../openecomp/policy/model/PDPGroupContainer.java | 2 +- .../openecomp/policy/model/PDPPolicyContainer.java | 2 +- .../main/webapp/app/policyApp/CSS/b2b-angular.css | 231 +++++++++++++- .../attributeDictController.js | 2 +- .../ActionPolicyController.js | 1 + .../BRMSParamPolicyController.js | 37 +-- .../BRMSRawPolicyController.js | 1 + .../BaseConfigPolicyController.js | 1 + .../ClosedLoopFaultController.js | 1 + .../ClosedLoopPMController.js | 1 + .../DCAEMicroServicePolicyController.js | 1 + .../DecisionPolicyController.js | 1 + .../FirewallPolicyController.js | 1 + .../PolicyTemplates/BRMSParamPolicyTemplate.html | 8 + .../PolicyTemplates/BRMSShowParamRuleModal.html | 16 - .../policy-models/Editor/templates/modals.html | 4 +- .../Editor/templates/search-main-table.html | 74 +++++ .../policy-models/policy_SearchFilter.html | 2 +- 43 files changed, 846 insertions(+), 507 deletions(-) delete mode 100644 POLICY-SDK-APP/src/main/webapp/app/policyApp/policy-models/Editor/PolicyTemplates/BRMSShowParamRuleModal.html create mode 100644 POLICY-SDK-APP/src/main/webapp/app/policyApp/policy-models/Editor/templates/search-main-table.html (limited to 'POLICY-SDK-APP/src') 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 aa8a227d3..a3f4ada0a 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 @@ -115,7 +115,7 @@ public class PolicyManagerServlet extends HttpServlet { PolicyManagerServlet.policyNames = policyNames; } - private static List serviceTypeNamesList = new ArrayList(); + private static List serviceTypeNamesList = new ArrayList<>(); private List policyData; public static List getServiceTypeNamesList() { @@ -142,20 +142,26 @@ public class PolicyManagerServlet extends HttpServlet { String location = closedLoopJsonLocation.toString(); try { inputStream = new FileInputStream(location); + if (location.endsWith("json")) { + JsonReader jsonReader = null; + jsonReader = Json.createReader(inputStream); + policyNames = jsonReader.readArray(); + serviceTypeNamesList = new ArrayList<>(); + for (int i = 0; i < policyNames.size(); i++) { + javax.json.JsonObject policyName = policyNames.getJsonObject(i); + String name = policyName.getJsonString("serviceTypePolicyName").getString(); + serviceTypeNamesList.add(name); + } + jsonReader.close(); + } } catch (FileNotFoundException e) { LOGGER.error("Exception Occured while initializing the JSONConfig file"+e); - } - if (location.endsWith("json")) { - JsonReader jsonReader = null; - jsonReader = Json.createReader(inputStream); - policyNames = jsonReader.readArray(); - serviceTypeNamesList = new ArrayList(); - for (int i = 0; i < policyNames.size(); i++) { - javax.json.JsonObject policyName = policyNames.getJsonObject(i); - String name = policyName.getJsonString("serviceTypePolicyName").getString(); - serviceTypeNamesList.add(name); + }finally{ + try { + inputStream.close(); + } catch (IOException e) { + LOGGER.error("Exception Occured while closing the File InputStream"+e); } - jsonReader.close(); } } @@ -185,6 +191,7 @@ public class PolicyManagerServlet extends HttpServlet { out.print(responseJsonObject); out.flush(); } catch (Exception x) { + LOGGER.error("Exception Occured"+x); response.sendError(HttpStatus.SC_INTERNAL_SERVER_ERROR, x.getMessage()); } } @@ -193,7 +200,7 @@ public class PolicyManagerServlet extends HttpServlet { private void uploadFile(HttpServletRequest request, HttpServletResponse response) throws ServletException { try { String newFile; - Map files = new HashMap(); + Map files = new HashMap<>(); List items = new ServletFileUpload(new DiskFileItemFactory()).parseRequest(request); for (FileItem item : items) { @@ -218,7 +225,7 @@ public class PolicyManagerServlet extends HttpServlet { JSONObject responseJsonObject = null; responseJsonObject = this.success(); - response.setContentType("application/json"); + response.setContentType(CONTENTTYPE); PrintWriter out = response.getWriter(); out.print(responseJsonObject); out.flush(); @@ -286,7 +293,7 @@ public class PolicyManagerServlet extends HttpServlet { LOGGER.error(XACMLErrorConstants.ERROR_DATA_ISSUE + "Exception Occured While doing File Operation" + e); responseJsonObject = error(e.getMessage()); } - response.setContentType("application/json"); + response.setContentType(CONTENTTYPE); PrintWriter out = response.getWriter(); out.print(responseJsonObject); out.flush(); @@ -295,20 +302,20 @@ public class PolicyManagerServlet extends HttpServlet { private JSONObject searchPolicyList(JSONObject params, HttpServletRequest request) { Set scopes = null; List roles = null; - policyData = new ArrayList(); + policyData = new ArrayList<>(); JSONArray policyList = null; if(params.has("policyList")){ policyList = (JSONArray) params.get("policyList"); } PolicyController controller = new PolicyController(); - List resultList = new ArrayList(); + List resultList = new ArrayList<>(); 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 userRoles = PolicyController.getRoles(userId); - roles = new ArrayList(); - scopes = new HashSet(); + roles = new ArrayList<>(); + scopes = new HashSet<>(); for(Object role: userRoles){ Roles userRole = (Roles) role; roles.add(userRole.getRole()); @@ -352,7 +359,7 @@ public class PolicyManagerServlet extends HttpServlet { } } }else{ - if (roles.contains("super-admin") || roles.contains("super-editor") || roles.contains("super-guest") ){ + if (roles.contains(SUPERADMIN) || roles.contains(SUPEREDITOR) || roles.contains(SUPERGUEST) ){ policyData = controller.getData(PolicyVersion.class); }else{ List filterdatas = controller.getData(PolicyVersion.class); @@ -494,7 +501,9 @@ public class PolicyManagerServlet extends HttpServlet { } catch (IOException e) { LOGGER.error("Exception Occured while Describing the Policy"+e); }finally{ - temp.delete(); + if(temp != null){ + temp.delete(); + } } }else{ return error("Error Occured while Describing the Policy"); @@ -512,8 +521,8 @@ public class PolicyManagerServlet extends HttpServlet { String userId = UserUtils.getUserSession(request).getOrgUserId(); //Check if the Role and Scope Size are Null get the values from db. List userRoles = PolicyController.getRoles(userId); - roles = new ArrayList(); - scopes = new HashSet(); + roles = new ArrayList<>(); + scopes = new HashSet<>(); for(Object role: userRoles){ Roles userRole = (Roles) role; roles.add(userRole.getRole()); @@ -534,7 +543,7 @@ public class PolicyManagerServlet extends HttpServlet { } } - List resultList = new ArrayList(); + List resultList = new ArrayList<>(); boolean onlyFolders = params.getBoolean("onlyFolders"); String path = params.getString("path"); if(path.contains("..xml")){ @@ -680,7 +689,7 @@ public class PolicyManagerServlet extends HttpServlet { PolicyController controller = new PolicyController(); UserInfo userInfo = (UserInfo) controller.getEntityItem(UserInfo.class, "userLoginId", loginId); if(userInfo == null){ - return "super-admin"; + return SUPERADMIN; } return userInfo.getUserName(); } @@ -688,13 +697,19 @@ public class PolicyManagerServlet extends HttpServlet { //Rename Policy private JSONObject rename(JSONObject params, HttpServletRequest request) throws ServletException { try { + boolean isActive = false; + List policyActiveInPDP = new ArrayList<>(); + Set scopeOfPolicyActiveInPDP = new HashSet<>(); String userId = UserUtils.getUserSession(request).getOrgUserId(); String oldPath = params.getString("path"); String newPath = params.getString("newPath"); oldPath = oldPath.substring(oldPath.indexOf("/")+1); newPath = newPath.substring(newPath.indexOf("/")+1); if(oldPath.endsWith(".xml")){ - policyRename(oldPath, newPath, userId); + JSONObject result = policyRename(oldPath, newPath, userId); + if(!(Boolean)(result.getJSONObject("result").get("success"))){ + return result; + } }else{ String scopeName = oldPath; String newScopeName = newPath; @@ -715,18 +730,36 @@ public class PolicyManagerServlet extends HttpServlet { PolicyVersion activeVersion = (PolicyVersion) object; String policyOldPath = activeVersion.getPolicyName().replace(File.separator, "/") + "." + activeVersion.getActiveVersion() + ".xml"; String policyNewPath = policyOldPath.replace(oldPath, newPath); - policyRename(policyOldPath, policyNewPath, userId); + JSONObject result = policyRename(policyOldPath, policyNewPath, userId); + if(!(Boolean)(result.getJSONObject("result").get("success"))){ + isActive = true; + policyActiveInPDP.add(policyOldPath); + String scope = policyOldPath.substring(0, policyOldPath.lastIndexOf("/")); + scopeOfPolicyActiveInPDP.add(scope.replace("/", File.separator)); + } + } + boolean rename = false; + if(activePolicies.size() != policyActiveInPDP.size()){ + rename = true; } - for(Object object : scopesList){ - PolicyEditorScopes editorScopeEntity = (PolicyEditorScopes) object; - if(scopeName.contains("\\\\\\\\")){ - scopeName = scopeName.replace("\\\\\\\\", File.separator); - newScopeName = newScopeName.replace("\\\\\\\\", File.separator); + + UserInfo userInfo = new UserInfo(); + userInfo.setUserLoginId(userId); + if(policyActiveInPDP.size() == 0){ + renameScope(scopesList, scopeName, newScopeName, controller); + }else if(rename){ + renameScope(scopesList, scopeName, newScopeName, controller); + for(String scope : scopeOfPolicyActiveInPDP){ + PolicyEditorScopes editorScopeEntity = new PolicyEditorScopes(); + editorScopeEntity.setScopeName(scope.replace("\\", "\\\\\\\\")); + editorScopeEntity.setUserCreatedBy(userInfo); + editorScopeEntity.setUserModifiedBy(userInfo); + controller.saveData(editorScopeEntity); } - String scope = editorScopeEntity.getScopeName().replace(scopeName, newScopeName); - editorScopeEntity.setScopeName(scope); - controller.updateData(editorScopeEntity); } + if(isActive){ + return error("The Following policies rename failed. Since they are active in PDP Groups" +policyActiveInPDP); + } } return success(); } catch (Exception e) { @@ -735,11 +768,24 @@ public class PolicyManagerServlet extends HttpServlet { } } + private void renameScope(List scopesList, String scopeName, String newScopeName, PolicyController controller){ + for(Object object : scopesList){ + PolicyEditorScopes editorScopeEntity = (PolicyEditorScopes) object; + if(scopeName.contains("\\\\\\\\")){ + scopeName = scopeName.replace("\\\\\\\\", File.separator); + newScopeName = newScopeName.replace("\\\\\\\\", File.separator); + } + String scope = editorScopeEntity.getScopeName().replace(scopeName, newScopeName); + editorScopeEntity.setScopeName(scope); + controller.updateData(editorScopeEntity); + } + } + private JSONObject policyRename(String oldPath, String newPath, String userId) throws ServletException { try { PolicyEntity entity = null; PolicyController controller = new PolicyController(); - + String policyVersionName = newPath.replace(".xml", ""); String policyName = policyVersionName.substring(0, policyVersionName.lastIndexOf(".")).replace("/", File.separator); @@ -767,51 +813,42 @@ public class PolicyManagerServlet extends HttpServlet { oldPolicyCheck = oldPolicyCheck.replace(".Decision_", ":Decision_"); } String[] oldPolicySplit = oldPolicyCheck.split(":"); - + //Check PolicyEntity table with newPolicy Name String policyEntityquery = "FROM PolicyEntity where policyName = '"+newPolicySplit[1]+"' and scope ='"+newPolicySplit[0]+"'"; - System.out.println(policyEntityquery); List queryData = controller.getDataByQuery(policyEntityquery); if(!queryData.isEmpty()){ entity = (PolicyEntity) queryData.get(0); + return error("Policy rename failed. Since, the policy with same name already exists."); } - - if(entity != null){ - //if a policy exists with new name check if it is deleted or not - if(entity.isDeleted()){ - //Check Policy Group Entity table if policy has been pushed or not - String query = "from PolicyGroupEntity where policyid = '"+entity.getPolicyId()+"'"; - List object = controller.getDataByQuery(query); - if(object.isEmpty()){ - //if PolicyGroupEntity data is empty delete the entry from database - controller.deleteData(entity); - //Query the Policy Entity with oldPolicy Name - String oldpolicyEntityquery = "FROM PolicyEntity where policyName = '"+oldPolicySplit[1]+"' and scope ='"+oldPolicySplit[0]+"'"; - System.out.println(oldpolicyEntityquery); - List oldEntityData = controller.getDataByQuery(oldpolicyEntityquery); - if(!oldEntityData.isEmpty()){ - entity = (PolicyEntity) oldEntityData.get(0); - } - checkOldPolicyEntryAndUpdate(entity, newPolicySplit[0], newPolicySplit[1], oldPolicySplit[0], oldPolicySplit[1], policyName, newpolicyName, oldpolicyName, userId); + + //Query the Policy Entity with oldPolicy Name + String policyEntityCheck = oldPolicySplit[1].substring(0, oldPolicySplit[1].indexOf(".")); + String oldpolicyEntityquery = "FROM PolicyEntity where policyName like '"+policyEntityCheck+"%' and scope ='"+oldPolicySplit[0]+"'"; + List oldEntityData = controller.getDataByQuery(oldpolicyEntityquery); + if(!oldEntityData.isEmpty()){ + String groupQuery = "FROM PolicyGroupEntity where ("; + for(int i=0; i oldEntityData = controller.getDataByQuery(oldpolicyEntityquery); - if(!oldEntityData.isEmpty()){ - for(int i=0; i groupEntityData = controller.getDataByQuery(groupQuery); + if(groupEntityData.size() > 0){ + return error("Policy rename failed. Since the policy or its version is active in PDP Groups."); } + for(int i=0; i object = controller.getDataByQuery(query); - if(object.isEmpty()){ - String oldPolicyNameWithoutExtension = removeoldPolicyExtension; - String newPolicyNameWithoutExtension = removenewPolicyExtension; - if(removeoldPolicyExtension.endsWith(".xml")){ - oldPolicyNameWithoutExtension = oldPolicyNameWithoutExtension.substring(0, oldPolicyNameWithoutExtension.indexOf(".")); - newPolicyNameWithoutExtension = newPolicyNameWithoutExtension.substring(0, newPolicyNameWithoutExtension.indexOf(".")); - } - entity.setPolicyName(entity.getPolicyName().replace(oldPolicyNameWithoutExtension, newPolicyNameWithoutExtension)); - entity.setPolicyData(entity.getPolicyData().replace(oldScope +"."+oldPolicyNameWithoutExtension, newScope+"."+newPolicyNameWithoutExtension)); - entity.setScope(newScope); - entity.setModifiedBy(userId); - if(newpolicyName.contains("Config_")){ - configEntity.setConfigurationName(configEntity.getConfigurationName().replace(oldScope +"."+oldPolicyNameWithoutExtension, newScope+"."+newPolicyNameWithoutExtension)); - controller.updateData(configEntity); - }else if(newpolicyName.contains("Action_")){ - actionEntity.setActionBody(actionEntity.getActionBody().replace(oldScope +"."+oldPolicyNameWithoutExtension, newScope+"."+newPolicyNameWithoutExtension)); - controller.updateData(actionEntity); - } - controller.updateData(entity); - }else{ - //Mark as Deleted in PolicyEntiy table - entity.setDeleted(true); - controller.updateData(entity); - //Mark as Deleted in ConfigurationDataEntity table - configEntity.setDeleted(true); - controller.updateData(configEntity); - //Mark as Deleted in ActionDataEntity table - actionEntity.setDeleted(true); - controller.updateData(actionEntity); - //Clone New Copy - cloneRecord(newpolicyName, oldScope, removeoldPolicyExtension, newScope, removenewPolicyExtension, entity, userId); - } - PolicyVersion versionEntity = (PolicyVersion) controller.getEntityItem(PolicyVersion.class, "policyName", oldpolicyName); - versionEntity.setPolicyName(policyName); - versionEntity.setModifiedBy(userId); - controller.updateData(versionEntity); - String movePolicyCheck = policyName.substring(policyName.lastIndexOf(File.separator)+1); - String moveOldPolicyCheck = oldpolicyName.substring(oldpolicyName.lastIndexOf(File.separator)+1); - if(movePolicyCheck.equals(moveOldPolicyCheck)){ - controller.watchPolicyFunction(versionEntity, oldpolicyName, "Move"); - }else{ - controller.watchPolicyFunction(versionEntity, oldpolicyName, "Rename"); + String oldPolicyNameWithoutExtension = removeoldPolicyExtension; + String newPolicyNameWithoutExtension = removenewPolicyExtension; + if(removeoldPolicyExtension.endsWith(".xml")){ + oldPolicyNameWithoutExtension = oldPolicyNameWithoutExtension.substring(0, oldPolicyNameWithoutExtension.indexOf(".")); + newPolicyNameWithoutExtension = newPolicyNameWithoutExtension.substring(0, newPolicyNameWithoutExtension.indexOf(".")); + } + entity.setPolicyName(entity.getPolicyName().replace(oldPolicyNameWithoutExtension, newPolicyNameWithoutExtension)); + entity.setPolicyData(entity.getPolicyData().replace(oldScope +"."+oldPolicyNameWithoutExtension, newScope+"."+newPolicyNameWithoutExtension)); + entity.setScope(newScope); + entity.setModifiedBy(userId); + if(newpolicyName.contains("Config_")){ + String oldConfigurationName = configEntity.getConfigurationName(); + configEntity.setConfigurationName(configEntity.getConfigurationName().replace(oldScope +"."+oldPolicyNameWithoutExtension, newScope+"."+newPolicyNameWithoutExtension)); + controller.updateData(configEntity); + String newConfigurationName = configEntity.getConfigurationName(); + File file = new File(PolicyController.configHome + File.separator + oldConfigurationName); + if(file.exists()){ + File renamefile = new File(PolicyController.configHome + File.separator + newConfigurationName); + file.renameTo(renamefile); + } + }else if(newpolicyName.contains("Action_")){ + String oldConfigurationName = actionEntity.getActionBodyName(); + actionEntity.setActionBody(actionEntity.getActionBody().replace(oldScope +"."+oldPolicyNameWithoutExtension, newScope+"."+newPolicyNameWithoutExtension)); + controller.updateData(actionEntity); + String newConfigurationName = actionEntity.getActionBodyName(); + File file = new File(PolicyController.actionHome + File.separator + oldConfigurationName); + if(file.exists()){ + File renamefile = new File(PolicyController.actionHome + File.separator + newConfigurationName); + file.renameTo(renamefile); } } + controller.updateData(entity); + + PolicyVersion versionEntity = (PolicyVersion) controller.getEntityItem(PolicyVersion.class, "policyName", oldpolicyName); + versionEntity.setPolicyName(policyName); + versionEntity.setModifiedBy(userId); + controller.updateData(versionEntity); + String movePolicyCheck = policyName.substring(policyName.lastIndexOf(File.separator)+1); + String moveOldPolicyCheck = oldpolicyName.substring(oldpolicyName.lastIndexOf(File.separator)+1); + if(movePolicyCheck.equals(moveOldPolicyCheck)){ + controller.watchPolicyFunction(versionEntity, oldpolicyName, "Move"); + }else{ + controller.watchPolicyFunction(versionEntity, oldpolicyName, "Rename"); + } return success(); } catch (Exception e) { LOGGER.error("Exception Occured"+e); @@ -970,7 +1001,6 @@ public class PolicyManagerServlet extends HttpServlet { //Check PolicyEntity table with newPolicy Name String policyEntityquery = "FROM PolicyEntity where policyName = '"+newPolicySplit[1]+"' and scope ='"+newPolicySplit[0]+"'"; - System.out.println(policyEntityquery); List queryData = controller.getDataByQuery(policyEntityquery); if(!queryData.isEmpty()){ entity = (PolicyEntity) queryData.get(0); @@ -986,7 +1016,6 @@ public class PolicyManagerServlet extends HttpServlet { controller.deleteData(entity); //Query the Policy Entity with oldPolicy Name policyEntityquery = "FROM PolicyEntity where policyName = '"+oldPolicySplit[1]+"' and scope ='"+oldPolicySplit[0]+"'"; - System.out.println(policyEntityquery); queryData = controller.getDataByQuery(policyEntityquery); if(!queryData.isEmpty()){ entity = (PolicyEntity) queryData.get(0); @@ -1004,7 +1033,6 @@ public class PolicyManagerServlet extends HttpServlet { }else{ //Query the Policy Entity with oldPolicy Name policyEntityquery = "FROM PolicyEntity where policyName = '"+oldPolicySplit[1]+"' and scope ='"+oldPolicySplit[0]+"'"; - System.out.println(policyEntityquery); queryData = controller.getDataByQuery(policyEntityquery); if(!queryData.isEmpty()){ entity = (PolicyEntity) queryData.get(0); diff --git a/POLICY-SDK-APP/src/main/java/org/openecomp/policy/admin/PolicyNotificationMail.java b/POLICY-SDK-APP/src/main/java/org/openecomp/policy/admin/PolicyNotificationMail.java index 3aee634fd..5d8460bf6 100644 --- a/POLICY-SDK-APP/src/main/java/org/openecomp/policy/admin/PolicyNotificationMail.java +++ b/POLICY-SDK-APP/src/main/java/org/openecomp/policy/admin/PolicyNotificationMail.java @@ -63,7 +63,6 @@ public class PolicyNotificationMail{ return mailSender; } - @SuppressWarnings("resource") public void sendMail(PolicyVersion entityItem, String policyName, String mode, CommonClassDao policyNotificationDao) throws MessagingException { String from = PolicyController.smtpUsername; String to = ""; @@ -71,37 +70,37 @@ public class PolicyNotificationMail{ String message = ""; DateFormat dateFormat = new SimpleDateFormat("yyyy/MM/dd HH:mm:ss"); Date date = new Date(); - if(mode.equalsIgnoreCase("EditPolicy")){ + if("EditPolicy".equalsIgnoreCase(mode)){ subject = "Policy has been Updated : "+entityItem.getPolicyName(); message = "The Policy Which you are watching in " + PolicyController.smtpApplicationName + " has been Updated" + '\n' + '\n' + '\n'+ "Scope + Policy Name : " + policyName + '\n' + "Active Version : " +entityItem.getActiveVersion() + '\n' + '\n' + "Modified By : " +entityItem.getModifiedBy() + '\n' + "Modified Time : " +dateFormat.format(date) + '\n' + '\n' + '\n' + '\n' + "Policy Notification System (please don't respond to this email)"; } - if(mode.equalsIgnoreCase("Rename")){ + if("Rename".equalsIgnoreCase(mode)){ subject = "Policy has been Renamed : "+entityItem.getPolicyName(); message = "The Policy Which you are watching in " + PolicyController.smtpApplicationName + " has been Renamed" + '\n' + '\n' + '\n'+ "Scope + Policy Name : " + policyName + '\n' + "Active Version : " +entityItem.getActiveVersion() + '\n' + '\n' + "Renamed By : " +entityItem.getModifiedBy() + '\n' + "Renamed Time : " +dateFormat.format(date) + '\n' + '\n' + '\n' + '\n' + "Policy Notification System (please don't respond to this email)"; } - if(mode.equalsIgnoreCase("DeleteAll")){ + if("DeleteAll".equalsIgnoreCase(mode)){ subject = "Policy has been Deleted : "+entityItem.getPolicyName(); message = "The Policy Which you are watching in " + PolicyController.smtpApplicationName + " has been Deleted with All Versions" + '\n' + '\n' + '\n'+ "Scope + Policy Name : " + policyName + '\n' + '\n' + '\n' + "Deleted By : " +entityItem.getModifiedBy() + '\n' + "Deleted Time : " +dateFormat.format(date) + '\n' + '\n' + '\n' + '\n' + "Policy Notification System (please don't respond to this email)"; } - if(mode.equalsIgnoreCase("DeleteOne")){ + if("DeleteOne".equalsIgnoreCase(mode)){ subject = "Policy has been Deleted : "+entityItem.getPolicyName(); message = "The Policy Which you are watching in " + PolicyController.smtpApplicationName + " has been Deleted" + '\n' + '\n' + '\n'+ "Scope + Policy Name : " + policyName + '\n' +"Policy Version : " +entityItem.getActiveVersion() + '\n' + '\n' + "Deleted By : " +entityItem.getModifiedBy() + '\n' + "Deleted Time : " +dateFormat.format(date) + '\n' + '\n' + '\n' + '\n' + "Policy Notification System (please don't respond to this email)"; } - if(mode.equalsIgnoreCase("DeleteScope")){ + if("DeleteScope".equalsIgnoreCase(mode)){ subject = "Scope has been Deleted : "+entityItem.getPolicyName(); message = "The Scope Which you are watching in " + PolicyController.smtpApplicationName + " has been Deleted" + '\n' + '\n' + '\n'+ "Scope + Scope Name : " + policyName + '\n' + '\n' + '\n' + "Deleted By : " +entityItem.getModifiedBy() + '\n' + "Deleted Time : " +dateFormat.format(date) + '\n' + '\n' + '\n' + '\n' + "Policy Notification System (please don't respond to this email)"; } - if(mode.equalsIgnoreCase("SwitchVersion")){ + if("SwitchVersion".equalsIgnoreCase(mode)){ subject = "Policy has been SwitchedVersion : "+entityItem.getPolicyName(); message = "The Policy Which you are watching in " + PolicyController.smtpApplicationName + " has been SwitchedVersion" + '\n' + '\n' + '\n'+ "Scope + Policy Name : " + policyName + '\n' + "Active Version : " +entityItem.getActiveVersion() + '\n' + '\n' + "Switched By : " +entityItem.getModifiedBy() + '\n' + "Switched Time : " +dateFormat.format(date) + '\n' + '\n' + '\n' + '\n' + "Policy Notification System (please don't respond to this email)"; } - if(mode.equalsIgnoreCase("Move")){ + if("Move".equalsIgnoreCase(mode)){ subject = "Policy has been Moved to Other Scope : "+entityItem.getPolicyName(); message = "The Policy Which you are watching in " + PolicyController.smtpApplicationName + " has been Moved to Other Scope" + '\n' + '\n' + '\n'+ "Scope + Policy Name : " + policyName + '\n' + "Active Version : " +entityItem.getActiveVersion() + '\n' + '\n' + "Moved By : " +entityItem.getModifiedBy() + '\n' + "Moved Time : " +dateFormat.format(date) + '\n' + '\n' + '\n' + '\n' + "Policy Notification System (please don't respond to this email)"; @@ -141,23 +140,26 @@ public class PolicyNotificationMail{ sendFlag = true; } if(sendFlag){ - to = list.getLoginIds()+"@"+PolicyController.smtpEmailExtension; - to = to.trim(); - AnnotationConfigApplicationContext ctx = new AnnotationConfigApplicationContext(); - ctx.register(PolicyNotificationMail.class); - ctx.refresh(); - JavaMailSenderImpl mailSender = ctx.getBean(JavaMailSenderImpl.class); - MimeMessage mimeMessage = mailSender.createMimeMessage(); - MimeMessageHelper mailMsg = new MimeMessageHelper(mimeMessage); + AnnotationConfigApplicationContext ctx = null; try { + to = list.getLoginIds()+"@"+PolicyController.smtpEmailExtension; + to = to.trim(); + ctx = new AnnotationConfigApplicationContext(); + ctx.register(PolicyNotificationMail.class); + ctx.refresh(); + JavaMailSenderImpl mailSender = ctx.getBean(JavaMailSenderImpl.class); + MimeMessage mimeMessage = mailSender.createMimeMessage(); + MimeMessageHelper mailMsg = new MimeMessageHelper(mimeMessage); mailMsg.setFrom(new InternetAddress(from, "Policy Notification System")); + mailMsg.setTo(to); + mailMsg.setSubject(subject); + mailMsg.setText(message); + mailSender.send(mimeMessage); } catch (Exception e) { LOGGER.error(XACMLErrorConstants.ERROR_PROCESS_FLOW+"Exception Occured in Policy Notification" +e); + }finally{ + ctx.close(); } - mailMsg.setTo(to); - mailMsg.setSubject(subject); - mailMsg.setText(message); - mailSender.send(mimeMessage); } } } 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 75e3d0b8a..4f0710b3e 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 @@ -246,7 +246,7 @@ public class PolicyRestController extends RestrictedBaseController{ String newFile = file.toString(); uri = uri +"&dictionaryName="+newFile; } catch (Exception e2) { - e2.printStackTrace(); + LOGGER.error("Exception Occured while calling PAP with import dictionary request"+e2); } } @@ -270,7 +270,7 @@ public class PolicyRestController extends RestrictedBaseController{ try { root = mapper.readTree(request.getReader()); }catch (Exception e1) { - e1.printStackTrace(); + LOGGER.error("Exception Occured while calling PAP"+e1); } ObjectMapper mapper1 = new ObjectMapper(); @@ -281,7 +281,7 @@ public class PolicyRestController extends RestrictedBaseController{ Object content = new ByteArrayInputStream(json.getBytes()); - if (content != null && (content instanceof InputStream)) { + if (content instanceof InputStream) { // send current configuration try (OutputStream os = connection.getOutputStream()) { int count = IOUtils.copy((InputStream) content, os); @@ -300,7 +300,9 @@ public class PolicyRestController extends RestrictedBaseController{ boundary = "===" + System.currentTimeMillis() + "==="; connection.setRequestProperty("Content-Type","multipart/form-data; boundary=" + boundary); try (OutputStream os = connection.getOutputStream()) { - IOUtils.copy((InputStream) item.getInputStream(), os); + if(item != null){ + IOUtils.copy((InputStream) item.getInputStream(), os); + } } } } @@ -385,7 +387,7 @@ public class PolicyRestController extends RestrictedBaseController{ String uri = request.getRequestURI(); String body = callPAP(request, response, "POST", uri.replaceFirst("/", "").trim()); if(body.contains("CouldNotConnectException")){ - List data = new ArrayList(); + List data = new ArrayList<>(); data.add("Elastic Search Server is down"); resultList = data; }else{ @@ -411,7 +413,7 @@ public class PolicyRestController extends RestrictedBaseController{ try{ resultList = json.get("policyresult"); }catch(Exception e){ - List data = new ArrayList(); + List data = new ArrayList<>(); data.add("Elastic Search Server is down"); resultList = data; } diff --git a/POLICY-SDK-APP/src/main/java/org/openecomp/policy/admin/PolicyUserInfoController.java b/POLICY-SDK-APP/src/main/java/org/openecomp/policy/admin/PolicyUserInfoController.java index a170b34aa..4e6201880 100644 --- a/POLICY-SDK-APP/src/main/java/org/openecomp/policy/admin/PolicyUserInfoController.java +++ b/POLICY-SDK-APP/src/main/java/org/openecomp/policy/admin/PolicyUserInfoController.java @@ -48,7 +48,7 @@ public class PolicyUserInfoController extends RestrictedBaseController{ JsonMessage msg = null; try { String userId = UserUtils.getUserSession(request).getOrgUserId(); - Map model = new HashMap(); + Map model = new HashMap<>(); ObjectMapper mapper = new ObjectMapper(); model.put("userid", userId); msg = new JsonMessage(mapper.writeValueAsString(model)); diff --git a/POLICY-SDK-APP/src/main/java/org/openecomp/policy/admin/RESTfulPAPEngine.java b/POLICY-SDK-APP/src/main/java/org/openecomp/policy/admin/RESTfulPAPEngine.java index d9fe9fa11..6c970ad59 100644 --- a/POLICY-SDK-APP/src/main/java/org/openecomp/policy/admin/RESTfulPAPEngine.java +++ b/POLICY-SDK-APP/src/main/java/org/openecomp/policy/admin/RESTfulPAPEngine.java @@ -438,7 +438,7 @@ public class RESTfulPAPEngine extends StdPDPItemSetChangeNotifier implements PAP LOGGER.info("Success. We have a return object."); String isValidData = connection.getHeaderField("isValidData"); String isSuccess = connection.getHeaderField("successMapKey"); - Map successMap = new HashMap(); + Map successMap = new HashMap<>(); if (isValidData != null && isValidData.equalsIgnoreCase("true")){ LOGGER.info("Policy Data is valid."); return true; diff --git a/POLICY-SDK-APP/src/main/java/org/openecomp/policy/components/HumanPolicyComponent.java b/POLICY-SDK-APP/src/main/java/org/openecomp/policy/components/HumanPolicyComponent.java index c80ccd6a6..f788fb673 100644 --- a/POLICY-SDK-APP/src/main/java/org/openecomp/policy/components/HumanPolicyComponent.java +++ b/POLICY-SDK-APP/src/main/java/org/openecomp/policy/components/HumanPolicyComponent.java @@ -121,12 +121,9 @@ public class HumanPolicyComponent{ JSONObject result = new JSONObject(); result.put("html", html); return result; - //ByteArrayInputStream is = new ByteArrayInputStream(html.getBytes(StandardCharsets.UTF_8)); } catch (IllegalArgumentException e) { LOGGER.error(XACMLErrorConstants.ERROR_DATA_ISSUE + "cannot build html area por policy", e); - /*AdminNotification.warn("An error has occurred. Cannot describe this policy: " + - e.getMessage());*/ } return null; } @@ -179,7 +176,7 @@ class HtmlProcessor extends SimpleCallback { private static Map function2human; static { - function2human = new HashMap(); + function2human = new HashMap<>(); function2human.put(HumanPolicyComponent.FUNCTION_STRING_EQUAL, "equal"); function2human.put(HumanPolicyComponent.FUNCTION_STRING_EQUAL_IGNORE, "equal"); function2human.put(HumanPolicyComponent.FUNCTION_STRING_ONE_AND_ONLY, "one-and-only"); @@ -189,7 +186,7 @@ class HtmlProcessor extends SimpleCallback { private static Map combiningAlgo2human; static { - combiningAlgo2human = new HashMap(); + combiningAlgo2human = new HashMap<>(); combiningAlgo2human.put("deny-overrides", "to deny if any $placeholder$ below evaluates to deny"); combiningAlgo2human.put("permit-overrides", "to permit if any $placeholder$ below evaluates to permit"); diff --git a/POLICY-SDK-APP/src/main/java/org/openecomp/policy/components/PolicyImportWindow.java b/POLICY-SDK-APP/src/main/java/org/openecomp/policy/components/PolicyImportWindow.java index 6e40c2be2..f5cc5d0fa 100644 --- a/POLICY-SDK-APP/src/main/java/org/openecomp/policy/components/PolicyImportWindow.java +++ b/POLICY-SDK-APP/src/main/java/org/openecomp/policy/components/PolicyImportWindow.java @@ -86,11 +86,11 @@ public class PolicyImportWindow{ try { extractFile = new TarArchiveInputStream (new FileInputStream(this.newfile.toFile())); } catch (FileNotFoundException e1) { - e1.printStackTrace(); + LOGGER.error(XACMLErrorConstants.ERROR_PROCESS_FLOW+"Exception while Importing Polcies"+e1); } //Create a loop to read every single entry in TAR file try { - while ((entry = extractFile.getNextTarEntry()) != null) { + while (extractFile!=null && (entry = extractFile.getNextTarEntry()) != null) { this.superadmin = true; try{ copyFileToLocation(extractFile, entry, xacmlFiles, null, superadmin); @@ -100,6 +100,14 @@ public class PolicyImportWindow{ } } catch (IOException e) { LOGGER.error("Exception Occured"+e); + }finally{ + try { + if(extractFile != null){ + extractFile.close(); + } + } catch (IOException e) { + LOGGER.error("Exception Occured"+e); + } } } @@ -149,7 +157,9 @@ public class PolicyImportWindow{ // Close Output Stream try { - outputFile.close(); + if(outputFile != null){ + outputFile.close(); + } } catch (IOException e) { LOGGER.info("IOException:" +e); LOGGER.error("Exception Occured"+e); diff --git a/POLICY-SDK-APP/src/main/java/org/openecomp/policy/conf/HibernateSession.java b/POLICY-SDK-APP/src/main/java/org/openecomp/policy/conf/HibernateSession.java index b3db51df4..9f7659d15 100644 --- a/POLICY-SDK-APP/src/main/java/org/openecomp/policy/conf/HibernateSession.java +++ b/POLICY-SDK-APP/src/main/java/org/openecomp/policy/conf/HibernateSession.java @@ -26,16 +26,19 @@ package org.openecomp.policy.conf; * */ import java.util.Properties; -import org.hibernate.HibernateException; import org.hibernate.Session; import org.hibernate.SessionFactory; import org.hibernate.cfg.Configuration; +import org.openecomp.policy.common.logging.flexlogger.FlexLogger; +import org.openecomp.policy.common.logging.flexlogger.Logger; import org.openecomp.policy.controller.PolicyController; import org.openecomp.policy.rest.jpa.SystemLogDB; @SuppressWarnings("deprecation") public class HibernateSession{ + private static final Logger LOGGER = FlexLogger.getLogger(HibernateSession.class); + private static SessionFactory logSessionFactory; static { @@ -49,11 +52,11 @@ public class HibernateSession{ prop.setProperty("show_sql", "false"); logSessionFactory = new Configuration().addPackage("org.openecomp.policy.*").addProperties(prop) .addAnnotatedClass(SystemLogDB.class).buildSessionFactory(); - } catch (Throwable ex) { - throw new ExceptionInInitializerError(ex); + } catch (Exception ex) { + LOGGER.error("Exception Occured while creating Log database Hibernate session"+ex); } } - public static Session getSession() throws HibernateException { + public static Session getSession(){ return logSessionFactory.openSession(); } diff --git a/POLICY-SDK-APP/src/main/java/org/openecomp/policy/controller/ActionPolicyController.java b/POLICY-SDK-APP/src/main/java/org/openecomp/policy/controller/ActionPolicyController.java index b0bbaf9cf..2c68df65f 100644 --- a/POLICY-SDK-APP/src/main/java/org/openecomp/policy/controller/ActionPolicyController.java +++ b/POLICY-SDK-APP/src/main/java/org/openecomp/policy/controller/ActionPolicyController.java @@ -63,12 +63,12 @@ public class ActionPolicyController extends RestrictedBaseController{ private ArrayList attributeList; protected LinkedList ruleAlgoirthmTracker; public static final String PERFORMER_ATTRIBUTEID = "performer"; - protected Map performer = new HashMap(); + protected Map performer = new HashMap<>(); private ArrayList ruleAlgorithmList; public void prePopulateActionPolicyData(PolicyRestAdapter policyAdapter, PolicyEntity entity) { - attributeList = new ArrayList(); - ruleAlgorithmList = new ArrayList(); + attributeList = new ArrayList<>(); + ruleAlgorithmList = new ArrayList<>(); performer.put("PDP", "PDPAction"); performer.put("PEP", "PEPAction"); @@ -116,7 +116,7 @@ public class ActionPolicyController extends RestrictedBaseController{ String attributeId = designator.getAttributeId(); // Component attributes are saved under Target here we are fetching them back. // One row is default so we are not adding dynamic component at index 0. - Map attribute = new HashMap(); + Map attribute = new HashMap<>(); attribute.put("key", attributeId); attribute.put("value", value); attributeList.add(attribute); @@ -137,7 +137,7 @@ public class ActionPolicyController extends RestrictedBaseController{ if (condition != null) { int index = 0; ApplyType actionApply = (ApplyType) condition.getExpression().getValue(); - ruleAlgoirthmTracker = new LinkedList(); + ruleAlgoirthmTracker = new LinkedList<>(); // Populating Rule Algorithms starting from compound. prePopulateCompoundRuleAlgorithm(index, actionApply); } diff --git a/POLICY-SDK-APP/src/main/java/org/openecomp/policy/controller/AdminTabController.java b/POLICY-SDK-APP/src/main/java/org/openecomp/policy/controller/AdminTabController.java index 46fb2bbfe..6824101df 100644 --- a/POLICY-SDK-APP/src/main/java/org/openecomp/policy/controller/AdminTabController.java +++ b/POLICY-SDK-APP/src/main/java/org/openecomp/policy/controller/AdminTabController.java @@ -57,7 +57,7 @@ public class AdminTabController extends RestrictedBaseController{ @RequestMapping(value={"/get_LockDownData"}, method={org.springframework.web.bind.annotation.RequestMethod.GET} , produces=MediaType.APPLICATION_JSON_VALUE) public void getAdminTabEntityData(HttpServletRequest request, HttpServletResponse response){ try{ - Map model = new HashMap(); + Map model = new HashMap<>(); ObjectMapper mapper = new ObjectMapper(); model.put("lockdowndata", mapper.writeValueAsString(commonClassDao.getData(GlobalRoleSettings.class))); JsonMessage msg = new JsonMessage(mapper.writeValueAsString(model)); 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 8751d735c..17e8f89f2 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 @@ -108,11 +108,11 @@ public class AutoPushController extends RestrictedBaseController{ List roles = null; data = new ArrayList(); String userId = UserUtils.getUserSession(request).getOrgUserId(); - Map model = new HashMap(); + Map model = new HashMap<>(); ObjectMapper mapper = new ObjectMapper(); List userRoles = PolicyController.getRoles(userId); - roles = new ArrayList(); - scopes = new HashSet(); + roles = new ArrayList<>(); + scopes = new HashSet<>(); for(Object role: userRoles){ Roles userRole = (Roles) role; roles.add(userRole.getRole()); @@ -161,8 +161,8 @@ public class AutoPushController extends RestrictedBaseController{ @RequestMapping(value={"/auto_Push/PushPolicyToPDP.htm"}, method={org.springframework.web.bind.annotation.RequestMethod.POST}) public ModelAndView PushPolicyToPDPGroup(HttpServletRequest request, HttpServletResponse response) throws Exception { try { - ArrayList selectedPDPS = new ArrayList(); - ArrayList selectedPoliciesInUI = new ArrayList(); + ArrayList selectedPDPS = new ArrayList<>(); + ArrayList selectedPoliciesInUI = new ArrayList<>(); this.groups.addAll(PolicyController.getPapEngine().getEcompPDPGroups()); ObjectMapper mapper = new ObjectMapper(); this.container = new PDPGroupContainer(PolicyController.getPapEngine()); @@ -185,8 +185,8 @@ public class AutoPushController extends RestrictedBaseController{ } for (Object pdpDestinationGroupId : selectedPDPS) { - Set currentPoliciesInGroup = new HashSet(); - Set selectedPolicies = new HashSet(); + Set currentPoliciesInGroup = new HashSet<>(); + Set selectedPolicies = new HashSet<>(); for (String policyId : selectedPoliciesInUI) { logger.debug("Handlepolicies..." + pdpDestinationGroupId + policyId); @@ -329,7 +329,7 @@ public class AutoPushController extends RestrictedBaseController{ String data = removePolicyData.get(i).toString(); AutoPushController.policyContainer.removeItem(data); } - Set changedPolicies = new HashSet(); + Set changedPolicies = new HashSet<>(); changedPolicies.addAll((Collection) AutoPushController.policyContainer.getItemIds()); StdPDPGroup updatedGroupObject = new StdPDPGroup(group.getId(), group.isDefaultGroup(), group.getName(), group.getDescription(),null); updatedGroupObject.setPolicies(changedPolicies); diff --git a/POLICY-SDK-APP/src/main/java/org/openecomp/policy/controller/CreateBRMSParamController.java b/POLICY-SDK-APP/src/main/java/org/openecomp/policy/controller/CreateBRMSParamController.java index 265b7b7b2..daab6e378 100644 --- a/POLICY-SDK-APP/src/main/java/org/openecomp/policy/controller/CreateBRMSParamController.java +++ b/POLICY-SDK-APP/src/main/java/org/openecomp/policy/controller/CreateBRMSParamController.java @@ -88,7 +88,7 @@ public class CreateBRMSParamController extends RestrictedBaseController { @RequestMapping(value={"/policyController/getBRMSTemplateData.htm"}, method={org.springframework.web.bind.annotation.RequestMethod.POST}) public ModelAndView getBRMSParamPolicyRuleData(HttpServletRequest request, HttpServletResponse response) throws Exception{ - dynamicLayoutMap = new HashMap(); + dynamicLayoutMap = new HashMap<>(); ObjectMapper mapper = new ObjectMapper(); mapper.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false); JsonNode root = mapper.readTree(request.getReader()); @@ -211,8 +211,8 @@ public class CreateBRMSParamController extends RestrictedBaseController { @SuppressWarnings("unchecked") public void prePopulateBRMSParamPolicyData(PolicyRestAdapter policyAdapter, PolicyEntity entity) { - attributeList = new ArrayList(); - dynamicLayoutMap = new HashMap(); + attributeList = new ArrayList<>(); + dynamicLayoutMap = new HashMap<>(); if (policyAdapter.getPolicyData() instanceof PolicyType) { PolicyType policy = (PolicyType) policyAdapter.getPolicyData(); policyAdapter.setOldPolicyFileName(policyAdapter.getPolicyName()); @@ -235,7 +235,7 @@ public class CreateBRMSParamController extends RestrictedBaseController { for( AdviceExpressionType adviceExpression: expressionTypes.getAdviceExpression()){ for(AttributeAssignmentExpressionType attributeAssignment: adviceExpression.getAttributeAssignmentExpression()){ if(attributeAssignment.getAttributeId().startsWith("key:")){ - Map attribute = new HashMap(); + Map attribute = new HashMap<>(); String key = attributeAssignment.getAttributeId().replace("key:", ""); attribute.put("key", key); JAXBElement attributevalue = (JAXBElement) attributeAssignment.getExpression(); @@ -258,7 +258,7 @@ public class CreateBRMSParamController extends RestrictedBaseController { // Get the target data under policy. policyAdapter.setDynamicLayoutMap(dynamicLayoutMap); if(policyAdapter.getDynamicLayoutMap().size() > 0){ - LinkedHashMap drlRule = new LinkedHashMap(); + LinkedHashMap drlRule = new LinkedHashMap<>(); for(Object keyValue: policyAdapter.getDynamicLayoutMap().keySet()){ drlRule.put(keyValue.toString(), policyAdapter.getDynamicLayoutMap().get(keyValue).toString()); } diff --git a/POLICY-SDK-APP/src/main/java/org/openecomp/policy/controller/CreateBRMSRawController.java b/POLICY-SDK-APP/src/main/java/org/openecomp/policy/controller/CreateBRMSRawController.java index b31f70297..67945e1b9 100644 --- a/POLICY-SDK-APP/src/main/java/org/openecomp/policy/controller/CreateBRMSRawController.java +++ b/POLICY-SDK-APP/src/main/java/org/openecomp/policy/controller/CreateBRMSRawController.java @@ -80,7 +80,7 @@ public class CreateBRMSRawController{ for( AdviceExpressionType adviceExpression: expressionTypes.getAdviceExpression()){ for(AttributeAssignmentExpressionType attributeAssignment: adviceExpression.getAttributeAssignmentExpression()){ if(attributeAssignment.getAttributeId().startsWith("key:")){ - Map attribute = new HashMap(); + Map attribute = new HashMap<>(); String key = attributeAssignment.getAttributeId().replace("key:", ""); attribute.put("key", key); JAXBElement attributevalue = (JAXBElement) attributeAssignment.getExpression(); diff --git a/POLICY-SDK-APP/src/main/java/org/openecomp/policy/controller/CreateClosedLoopFaultController.java b/POLICY-SDK-APP/src/main/java/org/openecomp/policy/controller/CreateClosedLoopFaultController.java index d2a2845e8..ccecf5d7f 100644 --- a/POLICY-SDK-APP/src/main/java/org/openecomp/policy/controller/CreateClosedLoopFaultController.java +++ b/POLICY-SDK-APP/src/main/java/org/openecomp/policy/controller/CreateClosedLoopFaultController.java @@ -83,11 +83,11 @@ public class CreateClosedLoopFaultController extends RestrictedBaseController{ ClosedLoopGridJSONData policyJsonData = mapper.readValue(root.get("policyData").get("policy").toString(), ClosedLoopGridJSONData.class); ClosedLoopFaultBody jsonBody = mapper.readValue(root.get("policyData").get("policy").get("jsonBodyData").toString(), ClosedLoopFaultBody.class); - ArrayList trapSignatureDatas = new ArrayList(); + ArrayList trapSignatureDatas = new ArrayList<>(); if(trapDatas.getTrap1() != null){ trapSignatureDatas.add(trapDatas); } - ArrayList faultSignatureDatas = new ArrayList(); + ArrayList faultSignatureDatas = new ArrayList<>(); if(faultDatas.getTrap1() != null){ faultSignatureDatas.add(faultDatas); } 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 ce6531f38..c3daf6d94 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 @@ -101,23 +101,23 @@ import oasis.names.tc.xacml._3_0.core.schema.wd_17.TargetType; @Controller @RequestMapping("/") public class CreateDcaeMicroServiceController extends RestrictedBaseController { - private static final Logger logger = FlexLogger.getLogger(CreateDcaeMicroServiceController.class); + private static final Logger LOGGER = FlexLogger.getLogger(CreateDcaeMicroServiceController.class); private static CommonClassDao commonClassDao; private MicroServiceModels newModel; private String newFile; private String directory; - private List modelList = new ArrayList(); - private List dirDependencyList = new ArrayList(); - private HashMap classMap = new HashMap(); + private List modelList = new ArrayList<>(); + private List dirDependencyList = new ArrayList<>(); + private HashMap classMap = new HashMap<>(); //Tosca Model related Datastructure. String referenceAttributes; String attributeString; String listConstraints; String subAttributeString; - HashMap retmap = new HashMap(); - Set uniqueKeys= new HashSet(); - Set uniqueDataKeys= new HashSet(); + HashMap retmap = new HashMap<>(); + Set uniqueKeys= new HashSet<>(); + Set uniqueDataKeys= new HashSet<>(); @Autowired private CreateDcaeMicroServiceController(CommonClassDao commonClassDao){ @@ -128,8 +128,8 @@ public class CreateDcaeMicroServiceController extends RestrictedBaseController { protected PolicyRestAdapter policyAdapter = null; private int priorityCount; - private Map attributesListRefMap = new HashMap(); - private Map> arrayTextList = new HashMap>(); + private Map attributesListRefMap = new HashMap<>(); + private Map> arrayTextList = new HashMap<>(); public PolicyRestAdapter setDataToPolicyRestAdapter(PolicyRestAdapter policyData, JsonNode root) { @@ -138,7 +138,7 @@ public class CreateDcaeMicroServiceController extends RestrictedBaseController { jsonContent = decodeContent(root.get("policyJSON")).toString(); constructJson(policyData, jsonContent); }catch(Exception e){ - logger.error("Error while decoding microservice content"); + LOGGER.error("Error while decoding microservice content"); } return policyData; @@ -202,9 +202,9 @@ public class CreateDcaeMicroServiceController extends RestrictedBaseController { try { json = om.writeValueAsString(microServiceObject); } catch (JsonProcessingException e) { - logger.error("Error writing out the object"); + LOGGER.error("Error writing out the object"); } - logger.info(json); + LOGGER.info(json); String cleanJson = cleanUPJson(json); cleanJson = removeNullAttributes(cleanJson); policyAdapter.setJsonBody(cleanJson); @@ -232,7 +232,7 @@ public class CreateDcaeMicroServiceController extends RestrictedBaseController { cleanJson = returnNode.toString(); } } catch (IOException e) { - logger.error("Error writing out the JsonNode"); + LOGGER.error("Error writing out the JsonNode"); } return cleanJson; } @@ -268,14 +268,14 @@ public class CreateDcaeMicroServiceController extends RestrictedBaseController { try { is = new FileInputStream(newConfiguration); } catch (FileNotFoundException e) { - logger.error(e); + LOGGER.error(e); } Yaml yaml = new Yaml(); @SuppressWarnings("unchecked") Map yamlMap = (Map) yaml.load(is); StringBuilder sb = new StringBuilder(); - Map settings = new HashMap(); + Map settings = new HashMap<>(); if (yamlMap == null) { return settings; } @@ -348,12 +348,11 @@ public class CreateDcaeMicroServiceController extends RestrictedBaseController { public void parseTosca (String fileName){ - Map map= new HashMap(); + Map map= new HashMap<>(); try { map=load(fileName); for(String key:map.keySet()){ - if(key.contains("policy.nodes.Root")) - { + if(key.contains("policy.nodes.Root")){ continue; } else if(key.contains("policy.nodes")){ @@ -369,21 +368,11 @@ public class CreateDcaeMicroServiceController extends RestrictedBaseController { String subNodeString= key.substring(indexForPolicyNode+12, key.length()); stringBetweenDotsForDataFields(subNodeString,map.get(key)); - Iterator 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("%"); @@ -405,7 +394,6 @@ public class CreateDcaeMicroServiceController extends RestrictedBaseController { } } } - } if(userDefinedString!=""){ userDefinedString=userDefinedString+","+userDefinedIndividualString; @@ -414,9 +402,9 @@ public class CreateDcaeMicroServiceController extends RestrictedBaseController { } userDefinedIndividualString=""; } - logger.info("userDefinedString :"+userDefinedString); + LOGGER.info("userDefinedString :"+userDefinedString); - HashMap> mapKey= new HashMap>(); + HashMap> mapKeyUserdefined= new HashMap<>(); String secondPartString=""; String firstPartString=""; for(String value: userDefinedString.split(",")){ @@ -424,30 +412,27 @@ public class CreateDcaeMicroServiceController extends RestrictedBaseController { secondPartString=splitWithEquals[0].substring(splitWithEquals[0].indexOf("%")+1); firstPartString=splitWithEquals[0].substring(0, splitWithEquals[0].indexOf("%")); ArrayList list; - if(mapKey.containsKey(firstPartString)){ - list = mapKey.get(firstPartString); + if(mapKeyUserdefined.containsKey(firstPartString)){ + list = mapKeyUserdefined.get(firstPartString); list.add(secondPartString+"<"+splitWithEquals[1]); } else { list = new ArrayList(); list.add(secondPartString+"<"+splitWithEquals[1]); - mapKey.put(firstPartString, list); + mapKeyUserdefined.put(firstPartString, list); } } JSONObject mainObject= new JSONObject();; JSONObject json; - for(String s: mapKey.keySet()){ + for(String s: mapKeyUserdefined.keySet()){ json= new JSONObject(); - List value=mapKey.get(s); + List value=mapKeyUserdefined.get(s); for(String listValue:value){ String[] splitValue=listValue.split("<"); json.put(splitValue[0], splitValue[1]); } mainObject.put(s,json); } - - logger.info(mainObject); - Iterator keysItr = mainObject.keys(); while(keysItr.hasNext()) { String key = keysItr.next(); @@ -455,138 +440,116 @@ public class CreateDcaeMicroServiceController extends RestrictedBaseController { retmap.put(key, value); } - for(String str:retmap.keySet()){ - logger.info(str+":"+retmap.get(str)); - } + LOGGER.info("#############################################################################"); + LOGGER.info(mainObject); + LOGGER.info("###############################################################################"); - String typeValueFromKey=""; - boolean userDefinedDataType=false; - boolean isList=false; + HashMap> mapKey= new HashMap<>(); for(String uniqueKey: uniqueKeys){ - List constraints= new ArrayList(); - logger.info("===================="); - attributeIndividualString=attributeIndividualString+uniqueKey+"="; - attributeIndividualString=attributeIndividualString+"#A:defaultValue-#B:required-#C:MANY-false"; + HashMap hm; - 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)); + if(key.contains(uniqueKey)){ + if(mapKey.containsKey(uniqueKey)){ + hm = mapKey.get(uniqueKey); + String keyStr= key.substring(key.lastIndexOf(".")+1); + String valueStr= map.get(key); + if(keyStr.equals("type")){ + if(!key.contains("entry_schema")){ + hm.put(keyStr,valueStr); } - else if(key.contains("type")){ - String typeValue= map.get(key); - attributeIndividualString=attributeIndividualString.replace("#A", typeValue); - } + }else{ + hm.put(keyStr,valueStr); } - 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"; + } else { + hm = new HashMap<>(); + String keyStr= key.substring(key.lastIndexOf(".")+1); + String valueStr= map.get(key); + if(keyStr.equals("type")){ + if(!key.contains("entry_schema")){ + hm.put(keyStr,valueStr); } - attributeIndividualString=""; + }else{ + hm.put(keyStr,valueStr); } + mapKey.put(uniqueKey, hm); } } } + } + StringBuilder attributeStringBuilder= new StringBuilder(); + StringBuilder referenceStringBuilder= new StringBuilder(); + StringBuilder listBuffer= new StringBuilder(); + + List constraints= new ArrayList<>(); + for(String keySetString: mapKey.keySet()){ + HashMap keyValues=mapKey.get(keySetString); + if(keyValues.get("type").equalsIgnoreCase("string")|| keyValues.get("type").equalsIgnoreCase("integer")){ + StringBuilder attributeIndividualStringBuilder= new StringBuilder(); + attributeIndividualStringBuilder.append(keySetString+"="); + attributeIndividualStringBuilder.append(keyValues.get("type")+":defaultValue-"); + attributeIndividualStringBuilder.append(keyValues.get("default")+":required-"); + attributeIndividualStringBuilder.append(keyValues.get("required")+":MANY-false"); + attributeStringBuilder.append(attributeIndividualStringBuilder+","); + } + else if(keyValues.get("type").equalsIgnoreCase("list")){ + //List Datatype + Set keys= keyValues.keySet(); + Iterator itr=keys.iterator(); + while(itr.hasNext()){ + String key= itr.next().toString(); + if((!key.equals("type"))){ + String value= keyValues.get(key); + //The "." in the value determines if its a string or a user defined type. + if (!value.contains(".")){ + //This is string + constraints.add(keyValues.get(key)); + }else{ + //This is user defined string + String trimValue=value.substring(value.lastIndexOf(".")+1); + StringBuilder referenceIndividualStringBuilder= new StringBuilder(); + referenceIndividualStringBuilder.append(keySetString+"="+trimValue+":MANY-true"); + referenceStringBuilder.append(referenceIndividualStringBuilder+","); + } + } + } + }else{ + //User defined Datatype. + String value=keyValues.get("type"); + String trimValue=value.substring(value.lastIndexOf(".")+1); + StringBuilder referenceIndividualStringBuilder= new StringBuilder(); + referenceIndividualStringBuilder.append(keySetString+"="+trimValue+":MANY-false"); + referenceStringBuilder.append(referenceIndividualStringBuilder+","); + } if(constraints!=null &&constraints.isEmpty()==false){ //List handling. - listConstraints=uniqueKey.toUpperCase()+"=["; - isList=true; + listBuffer.append(keySetString.toUpperCase()+"=["); for(String str:constraints){ - listConstraints=listConstraints+str+","; + listBuffer.append(str+","); } - listConstraints+="],"; - logger.info(listConstraints); - attributeIndividualString=""; - referenceIndividualAttributes=referenceIndividualAttributes+uniqueKey+"="+uniqueKey.toUpperCase()+":MANY-false"; - constraints=null; + listBuffer.append("]#"); + LOGGER.info(listBuffer); - } - 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); + StringBuilder referenceIndividualStringBuilder= new StringBuilder(); + referenceIndividualStringBuilder.append(keySetString+"="+keySetString.toUpperCase()+":MANY-false"); + referenceStringBuilder.append(referenceIndividualStringBuilder+","); + constraints.clear(); + } + } - attributeIndividualString=""; - referenceIndividualAttributes=""; - userDefinedDataType=false; - isList=false; + LOGGER.info("$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$"); + LOGGER.info("Whole attribute String is:"+attributeStringBuilder); + LOGGER.info("Whole reference String is:"+referenceStringBuilder); + LOGGER.info("List String is:"+listBuffer); + LOGGER.info("$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$"); + this.listConstraints=listBuffer.toString(); + this.referenceAttributes=referenceStringBuilder.toString(); + this.attributeString=attributeStringBuilder.toString(); - } - this.listConstraints=listConstraints; - this.referenceAttributes=referenceAttributes; - this.attributeString=attributeString; } catch (IOException e) { - logger.error(e); + LOGGER.error(e); } } @@ -611,7 +574,7 @@ public class CreateDcaeMicroServiceController extends RestrictedBaseController { private JSONObject decodeContent(JsonNode jsonNode){ Iterator jsonElements = jsonNode.elements(); Iterator jsonKeys = jsonNode.fieldNames(); - Map element = new TreeMap(); + Map element = new TreeMap<>(); while(jsonElements.hasNext() && jsonKeys.hasNext()){ element.put(jsonKeys.next(), jsonElements.next().toString()); } @@ -634,7 +597,7 @@ public class CreateDcaeMicroServiceController extends RestrictedBaseController { presKey = key; } // first check if we are different from old. - logger.info(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); @@ -664,7 +627,7 @@ public class CreateDcaeMicroServiceController extends RestrictedBaseController { isArray = true; jsonArray = new JSONArray(); } - if(arryKey.equals(nodeKey.substring(0,nodeKey.indexOf("@")))){ + if(jsonArray != null && arryKey.equals(nodeKey.substring(0,nodeKey.indexOf("@")))){ jsonArray.put(decodeContent(node)); } if(key.contains("@") && !arryKey.equals(key.substring(0,nodeKey.indexOf("@")))){ @@ -696,7 +659,7 @@ public class CreateDcaeMicroServiceController extends RestrictedBaseController { isArray = true; jsonArray = new JSONArray(); } - if(arryKey.equals(nodeKey.substring(0,nodeKey.indexOf("@")))){ + if(jsonArray != null && arryKey.equals(nodeKey.substring(0,nodeKey.indexOf("@")))){ jsonArray.put(decodeContent(node)); } jsonResult.put(arryKey, jsonArray); @@ -811,8 +774,8 @@ public class CreateDcaeMicroServiceController extends RestrictedBaseController { @SuppressWarnings({ "unchecked", "rawtypes" }) private String createMicroSeriveJson(MicroServiceModels returnModel) { - Map attributeMap = new HashMap(); - Map refAttributeMap = new HashMap(); + Map attributeMap = new HashMap<>(); + Map refAttributeMap = new HashMap<>(); String attribute = returnModel.getAttributes(); if(attribute != null){ attribute = attribute.trim(); @@ -882,7 +845,7 @@ public class CreateDcaeMicroServiceController extends RestrictedBaseController { @SuppressWarnings("unchecked") private JSONObject recursiveReference(String name, Map subAttributeMap, String enumAttribute) { JSONObject object = new JSONObject(); - Map map = new HashMap(); + Map map = new HashMap<>(); Object returnClass = subAttributeMap.get(name); map = (Map) returnClass; JSONArray array = new JSONArray(); @@ -935,7 +898,7 @@ public class CreateDcaeMicroServiceController extends RestrictedBaseController { private Set getVersionList(String name) { MicroServiceModels workingModel = new MicroServiceModels(); - Set list = new HashSet(); + Set list = new HashSet<>(); List microServiceModelsData = commonClassDao.getDataById(MicroServiceModels.class, "modelName", name); for (int i = 0; i < microServiceModelsData.size(); i++) { workingModel = (MicroServiceModels) microServiceModelsData.get(i); @@ -972,9 +935,9 @@ public class CreateDcaeMicroServiceController extends RestrictedBaseController { @RequestMapping(value={"/get_DCAEPriorityValues"}, method={org.springframework.web.bind.annotation.RequestMethod.GET} , produces=MediaType.APPLICATION_JSON_VALUE) public void getDCAEPriorityValuesData(HttpServletRequest request, HttpServletResponse response){ try{ - Map model = new HashMap(); + Map model = new HashMap<>(); ObjectMapper mapper = new ObjectMapper(); - List priorityList = new ArrayList(); + List priorityList = new ArrayList<>(); priorityCount = 10; for (int i = 1; i < priorityCount; i++) { priorityList.add(String.valueOf(i)); @@ -985,7 +948,7 @@ public class CreateDcaeMicroServiceController extends RestrictedBaseController { response.getWriter().write(j.toString()); } catch (Exception e){ - logger.error(e); + LOGGER.error(e); } } @@ -1079,7 +1042,7 @@ public class CreateDcaeMicroServiceController extends RestrictedBaseController { } public static Map convert(String str, String split) { - Map map = new HashMap(); + Map map = new HashMap<>(); for(final String entry : str.split(split)) { String[] parts = entry.split("="); map.put(parts[0], parts[1]); @@ -1106,14 +1069,14 @@ public class CreateDcaeMicroServiceController extends RestrictedBaseController { policyAdapter.setServiceType(msBody.getService()); } if(msBody.getContent() != null){ - LinkedHashMap data = new LinkedHashMap(); + LinkedHashMap data = new LinkedHashMap<>(); LinkedHashMap map = (LinkedHashMap) msBody.getContent(); readRecursivlyJSONContent(map, data); policyAdapter.setRuleData(data); } } catch (Exception e) { - logger.error(e); + LOGGER.error(e); } } @@ -1124,7 +1087,7 @@ public class CreateDcaeMicroServiceController extends RestrictedBaseController { Object key = iterator.next(); Object value = map.get(key); if(value instanceof LinkedHashMap){ - LinkedHashMap secondObjec = new LinkedHashMap(); + LinkedHashMap secondObjec = new LinkedHashMap<>(); readRecursivlyJSONContent((LinkedHashMap) value, secondObjec); for(String objKey: secondObjec.keySet()){ data.put(key+"." +objKey, secondObjec.get(objKey)); @@ -1134,7 +1097,7 @@ public class CreateDcaeMicroServiceController extends RestrictedBaseController { for(int i = 0; i < jsonArrayVal.size(); i++){ Object arrayvalue = jsonArrayVal.get(i); if(arrayvalue instanceof LinkedHashMap){ - LinkedHashMap newData = new LinkedHashMap(); + LinkedHashMap newData = new LinkedHashMap<>(); readRecursivlyJSONContent((LinkedHashMap) arrayvalue, newData); for(String objKey: newData.keySet()){ data.put(key+"@"+i+"." +objKey, newData.get(objKey)); @@ -1171,7 +1134,7 @@ public class CreateDcaeMicroServiceController extends RestrictedBaseController { //Convert the map values and set into JSON body public Map convertMap(Map attributesMap, Map attributesRefMap) { - Map attribute = new HashMap(); + Map attribute = new HashMap<>(); String temp = null; String key; String value; @@ -1236,12 +1199,12 @@ public class CreateDcaeMicroServiceController extends RestrictedBaseController { } }catch(Exception e){ - logger.error("Upload error : " + e); + LOGGER.error("Upload error : " + e); } } } - List fileList = new ArrayList();; + List fileList = new ArrayList<>();; this.directory = "model"; if (zip){ extractFolder(this.newFile); @@ -1256,7 +1219,7 @@ public class CreateDcaeMicroServiceController extends RestrictedBaseController { if(yml==false){ modelType="xmi"; //Process Main Model file first - classMap = new HashMap(); + classMap = new HashMap<>(); for (File file : fileList) { if(!file.isDirectory() && file.getName().endsWith(".xmi")){ retreiveDependency(file.toString(), true); @@ -1274,25 +1237,30 @@ public class CreateDcaeMicroServiceController extends RestrictedBaseController { MSAttributeObject msAttributes= new MSAttributeObject(); msAttributes.setClassName(className); - HashMap returnAttributeList =new HashMap(); + HashMap returnAttributeList =new HashMap<>(); returnAttributeList.put(className, this.attributeString); msAttributes.setAttribute(returnAttributeList); msAttributes.setSubClass(this.retmap); - HashMap returnReferenceList =new HashMap(); + HashMap returnReferenceList =new HashMap<>(); //String[] referenceArray=this.referenceAttributes.split("="); returnReferenceList.put(className, this.referenceAttributes); msAttributes.setRefAttribute(returnReferenceList); if(this.listConstraints!=""){ - HashMap enumList =new HashMap(); - String[] listArray=this.listConstraints.split("="); - enumList.put(listArray[0], listArray[1]); + HashMap enumList =new HashMap<>(); + String[] listArray=this.listConstraints.split("#"); + for(String str:listArray){ + String[] strArr= str.split("="); + if(strArr.length>1){ + enumList.put(strArr[0], strArr[1]); + } + } msAttributes.setEnumType(enumList); } - classMap=new HashMap(); + classMap=new HashMap<>(); classMap.put(className, msAttributes); } @@ -1319,7 +1287,7 @@ public class CreateDcaeMicroServiceController extends RestrictedBaseController { int BUFFER = 2048; File file = new File(zipFile); - ZipFile zip; + ZipFile zip = null; try { zip = new ZipFile(file); String newPath = "model" + File.separator + zipFile.substring(0, zipFile.length() - 4); @@ -1357,19 +1325,26 @@ public class CreateDcaeMicroServiceController extends RestrictedBaseController { } } } catch (IOException e) { - logger.error("Failed to unzip model file " + zipFile); + LOGGER.error("Failed to unzip model file " + zipFile); + }finally{ + try { + if(zip != null) + zip.close(); + } catch (IOException e) { + LOGGER.error("Exception Occured While closing zipfile " + e); + } } } private void retreiveDependency(String workingFile, Boolean modelClass) { MSModelUtils utils = new MSModelUtils(PolicyController.msEcompName, PolicyController.msPolicyName); - HashMap tempMap = new HashMap(); + HashMap tempMap = new HashMap<>(); tempMap = utils.processEpackage(workingFile, MODEL_TYPE.XMI); classMap.putAll(tempMap); - logger.info(tempMap); + LOGGER.info(tempMap); return; @@ -1377,7 +1352,7 @@ public class CreateDcaeMicroServiceController extends RestrictedBaseController { private List listModelFiles(String directoryName) { File directory = new File(directoryName); - List resultList = new ArrayList(); + List resultList = new ArrayList<>(); File[] fList = directory.listFiles(); for (File file : fList) { if (file.isFile()) { @@ -1395,7 +1370,7 @@ public class CreateDcaeMicroServiceController extends RestrictedBaseController { try { FileUtils.forceDelete(new File(path)); } catch (IOException e) { - logger.error("Failed to delete folder " + path); + LOGGER.error("Failed to delete folder " + path); } } } @@ -1409,7 +1384,7 @@ public class CreateDcaeMicroServiceController extends RestrictedBaseController { } private List createList() { - List list = new ArrayList(); + List list = new ArrayList<>(); for (Entry cMap : classMap.entrySet()){ if (cMap.getValue().isPolicyTempalate()){ list.add(cMap.getKey()); 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 1326aba7d..4aea6370b 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 @@ -41,6 +41,7 @@ import org.openecomp.policy.rest.adapter.AddressGroupJson; import org.openecomp.policy.rest.adapter.AddressJson; import org.openecomp.policy.rest.adapter.AddressMembers; import org.openecomp.policy.rest.adapter.DeployNowJson; +import org.openecomp.policy.rest.adapter.IdMap; import org.openecomp.policy.rest.adapter.PolicyRestAdapter; import org.openecomp.policy.rest.adapter.PrefixIPList; import org.openecomp.policy.rest.adapter.ServiceGroupJson; @@ -51,6 +52,7 @@ import org.openecomp.policy.rest.adapter.TagDefines; import org.openecomp.policy.rest.adapter.Tags; import org.openecomp.policy.rest.adapter.Term; import org.openecomp.policy.rest.adapter.TermCollector; +import org.openecomp.policy.rest.adapter.VendorSpecificData; import org.openecomp.policy.rest.dao.CommonClassDao; import org.openecomp.policy.rest.jpa.AddressGroup; import org.openecomp.policy.rest.jpa.FWTagPicker; @@ -94,8 +96,8 @@ public class CreateFirewallController extends RestrictedBaseController { private List tagCollectorList; private String jsonBody; - List expandablePrefixIPList = new ArrayList(); - List expandableServicesList= new ArrayList(); + List expandablePrefixIPList = new ArrayList<>(); + List expandableServicesList= new ArrayList<>(); @Autowired private CreateFirewallController(CommonClassDao commonClassDao){ CreateFirewallController.commonClassDao = commonClassDao; @@ -122,9 +124,8 @@ public class CreateFirewallController extends RestrictedBaseController { } } jsonBody = constructJson(policyData); - if (jsonBody != null || jsonBody.equalsIgnoreCase("")) { + if (jsonBody != null && !jsonBody.equalsIgnoreCase("")) { policyData.setJsonBody(jsonBody); - } else { policyData.setJsonBody("{}"); } @@ -136,7 +137,7 @@ public class CreateFirewallController extends RestrictedBaseController { private List mapping(String expandableList) { String value = new String(); String desc = new String(); - List valueDesc= new ArrayList(); + List valueDesc= new ArrayList<>(); List prefixListData = commonClassDao.getData(PrefixList.class); for (int i = 0; i< prefixListData.size(); i++) { PrefixList prefixList = (PrefixList) prefixListData.get(i); @@ -190,7 +191,7 @@ public class CreateFirewallController extends RestrictedBaseController { } public void prePopulateFWPolicyData(PolicyRestAdapter policyAdapter, PolicyEntity entity) { - attributeList = new ArrayList(); + attributeList = new ArrayList<>(); if (policyAdapter.getPolicyData() instanceof PolicyType) { Object policyData = policyAdapter.getPolicyData(); PolicyType policy = (PolicyType) policyData; @@ -232,14 +233,15 @@ public class CreateFirewallController extends RestrictedBaseController { } Map termTagMap=null; - - for(int i=0;i(); - String ruleName= tc1.getFirewallRuleList().get(i).getRuleName(); - String tagPickerName=tc1.getRuleToTag().get(i).getTagPickerName(); - termTagMap.put("key", ruleName); - termTagMap.put("value", tagPickerName); - attributeList.add(termTagMap); + if(tc1 != null){ + for(int i=0;i(); + String ruleName= tc1.getFirewallRuleList().get(i).getRuleName(); + String tagPickerName=tc1.getRuleToTag().get(i).getTagPickerName(); + termTagMap.put("key", ruleName); + termTagMap.put("value", tagPickerName); + attributeList.add(termTagMap); + } } policyAdapter.setAttributes(attributeList); // Get the target data under policy. @@ -317,7 +319,7 @@ public class CreateFirewallController extends RestrictedBaseController { @RequestMapping(value={"/policyController/ViewFWPolicyRule.htm"}, method={org.springframework.web.bind.annotation.RequestMethod.POST}) public ModelAndView setFWViewRule(HttpServletRequest request, HttpServletResponse response) throws Exception{ try { - termCollectorList = new ArrayList(); + termCollectorList = new ArrayList<>(); ObjectMapper mapper = new ObjectMapper(); mapper.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false); JsonNode root = mapper.readTree(request.getReader()); @@ -336,7 +338,7 @@ public class CreateFirewallController extends RestrictedBaseController { String ruleSrcPort=null; String ruleDestPort=null; String ruleAction=null; - List valueDesc= new ArrayList(); + List valueDesc= new ArrayList<>(); StringBuffer displayString = new StringBuffer(); for (String id : termCollectorList) { List tmList = commonClassDao.getDataById(TermList.class, "termName", id); @@ -497,14 +499,14 @@ public class CreateFirewallController extends RestrictedBaseController { String json = null; - List expandableList = new ArrayList(); + List expandableList = new ArrayList<>(); TermList jpaTermList; TermCollector tc = new TermCollector(); SecurityZone jpaSecurityZone; - List termList = new ArrayList(); + List termList = new ArrayList<>(); Tags tags=null; - ListtagsList= new ArrayList(); + ListtagsList= new ArrayList<>(); TagDefines tagDefine= new TagDefines(); List tagList=null; @@ -519,7 +521,7 @@ public class CreateFirewallController extends RestrictedBaseController { FWTagPicker jpaTagPickerList=(FWTagPicker) tagListData.get(tagCounter); if (jpaTagPickerList.getTagPickerName().equals(tag) ){ String tagValues=jpaTagPickerList.getTagValues(); - tagList= new ArrayList(); + tagList= new ArrayList<>(); for(String val:tagValues.split("#")) { int index=val.indexOf(":"); String keyToStore=val.substring(0,index); @@ -561,46 +563,46 @@ public class CreateFirewallController extends RestrictedBaseController { ruleFromZone=jpaTermList.getFromZone(); if ((ruleFromZone != null) && (!ruleFromZone.isEmpty())){ - fromZone_map = new HashMap(); + fromZone_map = new HashMap<>(); fromZone_map.put(tl, ruleFromZone); } ruleToZone=jpaTermList.getToZone(); if ((ruleToZone != null) && (!ruleToZone.isEmpty())){ - toZone_map = new HashMap(); + toZone_map = new HashMap<>(); toZone_map.put(tl, ruleToZone); } ruleSrcPrefixList=jpaTermList.getSrcIPList(); if ((ruleSrcPrefixList != null) && (!ruleSrcPrefixList.isEmpty())){ - srcIP_map = new HashMap(); + srcIP_map = new HashMap<>(); srcIP_map.put(tl, ruleSrcPrefixList); } ruleDestPrefixList= jpaTermList.getDestIPList(); if ((ruleDestPrefixList != null) && (!ruleDestPrefixList.isEmpty())){ - destIP_map = new HashMap(); + destIP_map = new HashMap<>(); destIP_map.put(tl, ruleDestPrefixList); } ruleSrcPort=jpaTermList.getSrcPortList(); if (ruleSrcPort != null && (!ruleSrcPort.isEmpty())){ - srcPort_map = new HashMap(); + srcPort_map = new HashMap<>(); srcPort_map.put(tl, ruleSrcPort); } ruleDestPort= jpaTermList.getDestPortList(); if (ruleDestPort!= null && (!jpaTermList.getDestPortList().isEmpty())){ - destPort_map = new HashMap(); + destPort_map = new HashMap<>(); destPort_map.put(tl, ruleDestPort); } ruleAction=jpaTermList.getAction(); if (( ruleAction!= null) && (!ruleAction.isEmpty())){ - action_map = new HashMap(); + action_map = new HashMap<>(); action_map.put(tl, ruleAction); } } @@ -616,7 +618,7 @@ public class CreateFirewallController extends RestrictedBaseController { //FromZone arrays if(fromZone_map!=null){ - List fromZone= new ArrayList(); + List fromZone= new ArrayList<>(); for(String fromZoneStr:fromZone_map.get(tl).split(",") ){ fromZone.add(fromZoneStr); } @@ -625,7 +627,7 @@ public class CreateFirewallController extends RestrictedBaseController { //ToZone arrays if(toZone_map!=null){ - List toZone= new ArrayList(); + List toZone= new ArrayList<>(); for(String toZoneStr:toZone_map.get(tl).split(",") ){ toZone.add(toZoneStr); } @@ -634,7 +636,7 @@ public class CreateFirewallController extends RestrictedBaseController { //Destination Services. if(destPort_map!=null){ - Set destServicesJsonList= new HashSet(); + Set destServicesJsonList= new HashSet<>(); for(String destServices:destPort_map.get(tl).split(",") ){ ServicesJson destServicesJson= new ServicesJson(); destServicesJson.setType("REFERENCE"); @@ -665,7 +667,7 @@ public class CreateFirewallController extends RestrictedBaseController { if(srcIP_map!=null){ //Source List - List sourceListArrayJson= new ArrayList(); + List sourceListArrayJson= new ArrayList<>(); for(String srcList:srcIP_map.get(tl).split(",") ){ AddressJson srcListJson= new AddressJson(); if(srcList.equals("ANY")){ @@ -686,7 +688,7 @@ public class CreateFirewallController extends RestrictedBaseController { } if(destIP_map!=null){ //Destination List - List destListArrayJson= new ArrayList(); + List destListArrayJson= new ArrayList<>(); for(String destList:destIP_map.get(tl).split(",")){ AddressJson destListJson= new AddressJson(); if(destList.equals("ANY")){ @@ -727,25 +729,32 @@ public class CreateFirewallController extends RestrictedBaseController { jpaSecurityZone = (SecurityZone) securityZoneData.get(j); if (jpaSecurityZone.getZoneName().equals(policyData.getSecurityZone())){ tc.setSecurityZoneId(jpaSecurityZone.getZoneValue()); - //setParentSecurityZone(jpaSecurityZone.getZoneValue());//For storing the securityZone IDs to the DB + IdMap idMapInstance= new IdMap(); + idMapInstance.setAstraId(jpaSecurityZone.getZoneValue()); + idMapInstance.setVendorId("deviceGroup:dev"); + + List idMap = new ArrayList(); + idMap.add(idMapInstance); + + VendorSpecificData vendorStructure= new VendorSpecificData(); + vendorStructure.setIdMap(idMap); + tc.setVendorSpecificData(vendorStructure); break; } } tc.setServiceTypeId("/v0/firewall/pan"); tc.setConfigName(policyData.getConfigName()); + tc.setVendorServiceId("vipr"); - //Astra is rejecting the packet when it sees a new JSON field, so removing it for now. - //tc.setTemplateVersion(XACMLProperties.getProperty(XACMLRestProperties.TemplateVersion_FW)); - DeployNowJson deployNow= new DeployNowJson(); deployNow.setDeployNow(false); tc.setDeploymentOption(deployNow); - Set servListArray = new HashSet(); - Set servGroupArray= new HashSet(); - Set addrGroupArray= new HashSet(); + Set servListArray = new HashSet<>(); + Set servGroupArray= new HashSet<>(); + Set addrGroupArray= new HashSet<>(); ServiceGroupJson targetSg= null; AddressGroupJson addressSg=null; @@ -801,7 +810,7 @@ public class CreateFirewallController extends RestrictedBaseController { String name=sg.getGroupName(); //Removing the "Group_" prepending string before packing the JSON targetSg.setName(name.substring(6,name.length())); - List servMembersList= new ArrayList(); + List servMembersList= new ArrayList<>(); for(String groupString: sg.getServiceList().split(",")){ ServiceMembers serviceMembers= new ServiceMembers(); @@ -828,13 +837,13 @@ public class CreateFirewallController extends RestrictedBaseController { } } - Set prefixIPList = new HashSet(); + Set prefixIPList = new HashSet<>(); for(String prefixList:expandablePrefixIPList){ for(String prefixIP: prefixList.split(",")){ if((!prefixIP.startsWith("Group_"))){ if(!prefixIP.equals("ANY")){ - List addMembersList= new ArrayList(); - List valueDesc= new ArrayList(); + List addMembersList= new ArrayList<>(); + List valueDesc= new ArrayList<>(); PrefixIPList targetAddressList = new PrefixIPList(); AddressMembers addressMembers= new AddressMembers(); targetAddressList.setName(prefixIP); @@ -866,9 +875,9 @@ public class CreateFirewallController extends RestrictedBaseController { //Removing the "Group_" prepending string before packing the JSON addressSg.setName(name.substring(6,name.length())); - List addrMembersList= new ArrayList(); + List addrMembersList= new ArrayList<>(); for(String groupString: ag.getPrefixList().split(",")){ - List valueDesc= new ArrayList(); + List valueDesc= new ArrayList<>(); AddressMembers addressMembers= new AddressMembers(); valueDesc= mapping (groupString); if(valueDesc.size() > 0){ @@ -886,7 +895,7 @@ public class CreateFirewallController extends RestrictedBaseController { } } - Set serviceGroup= new HashSet(); + Set serviceGroup= new HashSet<>(); for(Object obj1:servGroupArray){ serviceGroup.add(obj1); @@ -896,7 +905,7 @@ public class CreateFirewallController extends RestrictedBaseController { serviceGroup.add(obj); } - Set addressGroup= new HashSet(); + Set addressGroup= new HashSet<>(); for(Object addObj:prefixIPList){ addressGroup.add(addObj); diff --git a/POLICY-SDK-APP/src/main/java/org/openecomp/policy/controller/CreatePolicyController.java b/POLICY-SDK-APP/src/main/java/org/openecomp/policy/controller/CreatePolicyController.java index bca63eb0f..5049d2652 100644 --- a/POLICY-SDK-APP/src/main/java/org/openecomp/policy/controller/CreatePolicyController.java +++ b/POLICY-SDK-APP/src/main/java/org/openecomp/policy/controller/CreatePolicyController.java @@ -67,7 +67,7 @@ public class CreatePolicyController extends RestrictedBaseController{ } public void prePopulateBaseConfigPolicyData(PolicyRestAdapter policyAdapter, PolicyEntity entity) { - attributeList = new ArrayList(); + attributeList = new ArrayList<>(); if (policyAdapter.getPolicyData() instanceof PolicyType) { Object policyData = policyAdapter.getPolicyData(); PolicyType policy = (PolicyType) policyData; @@ -136,7 +136,7 @@ public class CreatePolicyController extends RestrictedBaseController{ // After Ecomp and Config it is optional to have attributes, so // check weather dynamic values or there or not. if (index >= 7) { - Map attribute = new HashMap(); + Map attribute = new HashMap<>(); attribute.put("key", attributeId); attribute.put("value", value); attributeList.add(attribute); diff --git a/POLICY-SDK-APP/src/main/java/org/openecomp/policy/controller/DashboardController.java b/POLICY-SDK-APP/src/main/java/org/openecomp/policy/controller/DashboardController.java index 7ba1e847c..707a65d62 100644 --- a/POLICY-SDK-APP/src/main/java/org/openecomp/policy/controller/DashboardController.java +++ b/POLICY-SDK-APP/src/main/java/org/openecomp/policy/controller/DashboardController.java @@ -91,7 +91,7 @@ public class DashboardController extends RestrictedBaseController{ @RequestMapping(value={"/get_DashboardLoggingData"}, method={org.springframework.web.bind.annotation.RequestMethod.GET} , produces=MediaType.APPLICATION_JSON_VALUE) public void getData(HttpServletRequest request, HttpServletResponse response){ try{ - Map model = new HashMap(); + Map model = new HashMap<>(); ObjectMapper mapper = new ObjectMapper(); model.put("availableLoggingDatas", mapper.writeValueAsString(systemDAO.getLoggingData())); JsonMessage msg = new JsonMessage(mapper.writeValueAsString(model)); @@ -106,7 +106,7 @@ public class DashboardController extends RestrictedBaseController{ @RequestMapping(value={"/get_DashboardSystemAlertData"}, method={org.springframework.web.bind.annotation.RequestMethod.GET} , produces=MediaType.APPLICATION_JSON_VALUE) public void getSystemAlertData(HttpServletRequest request, HttpServletResponse response){ try{ - Map model = new HashMap(); + Map model = new HashMap<>(); ObjectMapper mapper = new ObjectMapper(); model.put("systemAlertsTableDatas", mapper.writeValueAsString(systemDAO.getSystemAlertData())); JsonMessage msg = new JsonMessage(mapper.writeValueAsString(model)); @@ -121,7 +121,7 @@ public class DashboardController extends RestrictedBaseController{ @RequestMapping(value={"/get_DashboardPAPStatusData"}, method={org.springframework.web.bind.annotation.RequestMethod.GET} , produces=MediaType.APPLICATION_JSON_VALUE) public void getPAPStatusData(HttpServletRequest request, HttpServletResponse response){ try{ - Map model = new HashMap(); + Map model = new HashMap<>(); ObjectMapper mapper = new ObjectMapper(); mapper.setVisibility(PropertyAccessor.FIELD, Visibility.ANY); addPAPToTable(); @@ -138,7 +138,7 @@ public class DashboardController extends RestrictedBaseController{ @RequestMapping(value={"/get_DashboardPDPStatusData"}, method={org.springframework.web.bind.annotation.RequestMethod.GET} , produces=MediaType.APPLICATION_JSON_VALUE) public void getPDPStatusData(HttpServletRequest request, HttpServletResponse response){ try{ - Map model = new HashMap(); + Map model = new HashMap<>(); ObjectMapper mapper = new ObjectMapper(); mapper.setVisibility(PropertyAccessor.FIELD, Visibility.ANY); this.pdpConatiner = new PDPGroupContainer(PolicyController.getPapEngine()); @@ -156,7 +156,7 @@ public class DashboardController extends RestrictedBaseController{ @RequestMapping(value={"/get_DashboardPolicyActivityData"}, method={org.springframework.web.bind.annotation.RequestMethod.GET} , produces=MediaType.APPLICATION_JSON_VALUE) public void getPolicyActivityData(HttpServletRequest request, HttpServletResponse response){ try{ - Map model = new HashMap(); + Map model = new HashMap<>(); ObjectMapper mapper = new ObjectMapper(); mapper.setVisibility(PropertyAccessor.FIELD, Visibility.ANY); this.pdpConatiner = new PDPGroupContainer(PolicyController.getPapEngine()); @@ -175,7 +175,7 @@ public class DashboardController extends RestrictedBaseController{ * Add the PAP information to the PAP Table */ public void addPAPToTable(){ - papStatusData = new ArrayList(); + papStatusData = new ArrayList<>(); String papStatus = null; try { Set groups = PolicyController.getPapEngine().getEcompPDPGroups(); @@ -205,7 +205,7 @@ public class DashboardController extends RestrictedBaseController{ */ public void addPDPToTable(){ pdpCount = 0; - pdpStatusData = new ArrayList(); + pdpStatusData = new ArrayList<>(); long naCount; long denyCount = 0; long permitCount = 0; @@ -305,7 +305,7 @@ public class DashboardController extends RestrictedBaseController{ * Add the information to the Policy Table */ private void addPolicyToTable() { - policyActivityData = new ArrayList(); + policyActivityData = new ArrayList<>(); int i = 1; String policyID = null; int policyFireCount = 0; 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 82fc24b40..2fecd7eea 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 @@ -68,9 +68,9 @@ public class DecisionPolicyController extends RestrictedBaseController { @SuppressWarnings("unchecked") public void prePopulateDecisionPolicyData(PolicyRestAdapter policyAdapter, PolicyEntity entity) { - attributeList = new ArrayList(); - decisionList = new ArrayList(); - ruleAlgorithmList = new ArrayList(); + attributeList = new ArrayList<>(); + decisionList = new ArrayList<>(); + ruleAlgorithmList = new ArrayList<>(); if (policyAdapter.getPolicyData() instanceof PolicyType) { Object policyData = policyAdapter.getPolicyData(); PolicyType policy = (PolicyType) policyData; @@ -121,7 +121,7 @@ public class DecisionPolicyController extends RestrictedBaseController { // Component attributes are saved under Target here we are fetching them back. // One row is default so we are not adding dynamic component at index 0. if (index >= 1) { - Map attribute = new HashMap(); + Map attribute = new HashMap<>(); attribute.put("key", attributeId); attribute.put("value", value); attributeList.add(attribute); @@ -165,7 +165,7 @@ public class DecisionPolicyController extends RestrictedBaseController { if (condition != null) { ApplyType decisionApply = (ApplyType) condition.getExpression().getValue(); decisionApply = (ApplyType) decisionApply.getExpression().get(0).getValue(); - ruleAlgoirthmTracker = new LinkedList(); + ruleAlgoirthmTracker = new LinkedList<>(); if(policyAdapter.getRuleProvider()!=null && policyAdapter.getRuleProvider().equals("GUARD_YAML")){ YAMLParams yamlParams = new YAMLParams(); for(int i=0; i> jaxbDecisionTypes) { - Map ruleMap = new HashMap(); + Map ruleMap = new HashMap<>(); ruleMap.put("id", "A" + (index +1)); Map dropDownMap = PolicyController.getDropDownMap(); for (String key : dropDownMap.keySet()) { @@ -262,7 +262,7 @@ public class DecisionPolicyController extends RestrictedBaseController { if (logger.isDebugEnabled()) { logger.debug("Prepopulating Compound rule algorithm: " + index); } - Map rule = new HashMap(); + Map rule = new HashMap<>(); for (String key : PolicyController.getDropDownMap().keySet()) { String keyValue = PolicyController.getDropDownMap().get(key); if (keyValue.equals(decisionApply.getFunctionId())) { diff --git a/POLICY-SDK-APP/src/main/java/org/openecomp/policy/controller/PDPController.java b/POLICY-SDK-APP/src/main/java/org/openecomp/policy/controller/PDPController.java index 87b32206e..80820c129 100644 --- a/POLICY-SDK-APP/src/main/java/org/openecomp/policy/controller/PDPController.java +++ b/POLICY-SDK-APP/src/main/java/org/openecomp/policy/controller/PDPController.java @@ -26,6 +26,7 @@ import java.io.PrintWriter; import java.util.ArrayList; import java.util.Collections; import java.util.HashSet; +import java.util.Iterator; import java.util.List; import java.util.Set; @@ -71,13 +72,13 @@ public class PDPController extends RestrictedBaseController { synchronized(this.groups) { this.groups.clear(); try { - Set filteredPolicies = new HashSet(); + Set filteredPolicies = new HashSet<>(); Set scopes = null; List roles = null; String userId = UserUtils.getUserSession(request).getOrgUserId(); List userRoles = PolicyController.getRoles(userId); - roles = new ArrayList(); - scopes = new HashSet(); + roles = new ArrayList<>(); + scopes = new HashSet<>(); for(Object role: userRoles){ Roles userRole = (Roles) role; roles.add(userRole.getRole()); @@ -98,8 +99,11 @@ public class PDPController extends RestrictedBaseController { if(!userRoles.isEmpty()){ if(!scopes.isEmpty()){ this.groups.addAll(PolicyController.getPapEngine().getEcompPDPGroups()); + List tempGroups = new ArrayList(); if(!groups.isEmpty()){ - for(EcompPDPGroup group : groups){ + Iterator pdpGroup = groups.iterator(); + while(pdpGroup.hasNext()){ + EcompPDPGroup group = pdpGroup.next(); Set policies = group.getPolicies(); for(PDPPolicy policy : policies){ for(String scope : scopes){ @@ -117,11 +121,13 @@ public class PDPController extends RestrictedBaseController { } } } - groups.remove(group); + pdpGroup.remove(); StdPDPGroup newGroup = (StdPDPGroup) group; newGroup.setPolicies(filteredPolicies); - groups.add(newGroup); - } + tempGroups.add(newGroup); + } + groups.clear(); + groups = tempGroups; } } } 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 a9eb40b4f..42e4483ca 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 @@ -85,7 +85,7 @@ public class PolicyController extends RestrictedBaseController { public static String logTableLimit; public static String systemAlertTableLimit; - protected static Map dropDownMap = new HashMap(); + protected static Map dropDownMap = new HashMap<>(); public static Map getDropDownMap() { return dropDownMap; } @@ -134,6 +134,10 @@ public class PolicyController extends RestrictedBaseController { //MicroService Model Properties public static String msEcompName; public static String msPolicyName; + + //WebApp directories + public static String configHome; + public static String actionHome; @Autowired private PolicyController(CommonClassDao commonClassDao){ @@ -179,6 +183,9 @@ public class PolicyController extends RestrictedBaseController { //Micro Service Properties msEcompName=prop.getProperty("xacml.policy.msEcompName"); msPolicyName=prop.getProperty("xacml.policy.msPolicyName"); + //WebApp directories + configHome = prop.getProperty("xacml.rest.config.webapps") + "Config"; + actionHome = prop.getProperty("xacml.rest.config.webapps") + "Action"; //Get the Property Values for Dashboard tab Limit try{ logTableLimit = prop.getProperty("xacml.ecomp.dashboard.logTableLimit"); @@ -231,8 +238,8 @@ public class PolicyController extends RestrictedBaseController { } private static void buildFunctionMaps() { - mapDatatype2Function = new HashMap>(); - mapID2Function = new HashMap(); + mapDatatype2Function = new HashMap<>(); + mapID2Function = new HashMap<>(); List functiondefinitions = commonClassDao.getData(FunctionDefinition.class); for (int i = 0; i < functiondefinitions.size(); i ++) { FunctionDefinition value = (FunctionDefinition) functiondefinitions.get(i); @@ -247,7 +254,7 @@ public class PolicyController extends RestrictedBaseController { @RequestMapping(value={"/get_FunctionDefinitionDataByName"}, method={org.springframework.web.bind.annotation.RequestMethod.GET} , produces=MediaType.APPLICATION_JSON_VALUE) public void getFunctionDefinitionData(HttpServletRequest request, HttpServletResponse response){ try{ - Map model = new HashMap(); + Map model = new HashMap<>(); ObjectMapper mapper = new ObjectMapper(); model.put("functionDefinitionDatas", mapper.writeValueAsString(commonClassDao.getDataByColumn(FunctionDefinition.class, "shortname"))); JsonMessage msg = new JsonMessage(mapper.writeValueAsString(model)); @@ -267,7 +274,7 @@ public class PolicyController extends RestrictedBaseController { } public static Map getUserRoles(String userId) { - Map scopes = new HashMap(); + Map scopes = new HashMap<>(); List roles = commonClassDao.getDataById(Roles.class, "loginId", userId); if (roles != null && roles.size() > 0) { for (Object role : roles) { @@ -295,7 +302,7 @@ public class PolicyController extends RestrictedBaseController { public void getUserRolesEntityData(HttpServletRequest request, HttpServletResponse response){ try{ String userId = UserUtils.getUserSession(request).getOrgUserId(); - Map model = new HashMap(); + Map model = new HashMap<>(); ObjectMapper mapper = new ObjectMapper(); model.put("userRolesDatas", mapper.writeValueAsString(getRolesOfUser(userId))); JsonMessage msg = new JsonMessage(mapper.writeValueAsString(model)); @@ -320,7 +327,7 @@ public class PolicyController extends RestrictedBaseController { } catch (Exception e) { LOGGER.error(XACMLErrorConstants.ERROR_SYSTEM_ERROR+"Exception Occured while loading PAP"+e); } - Map model = new HashMap(); + Map model = new HashMap<>(); return new ModelAndView("policy_Editor","model", model); } @@ -404,7 +411,7 @@ public class PolicyController extends RestrictedBaseController { String[] splitDBCheckName = dbCheckName.split(":"); String query = "FROM PolicyEntity where policyName like'"+splitDBCheckName[1]+"%' and scope ='"+splitDBCheckName[0]+"'"; List policyEntity = commonClassDao.getDataByQuery(query); - List av = new ArrayList(); + List av = new ArrayList<>(); for(Object entity : policyEntity){ PolicyEntity pEntity = (PolicyEntity) entity; String removeExtension = pEntity.getPolicyName().replace(".xml", ""); diff --git a/POLICY-SDK-APP/src/main/java/org/openecomp/policy/controller/PolicyExportAndImportController.java b/POLICY-SDK-APP/src/main/java/org/openecomp/policy/controller/PolicyExportAndImportController.java index b6899e041..68a65fc5e 100644 --- a/POLICY-SDK-APP/src/main/java/org/openecomp/policy/controller/PolicyExportAndImportController.java +++ b/POLICY-SDK-APP/src/main/java/org/openecomp/policy/controller/PolicyExportAndImportController.java @@ -101,7 +101,7 @@ public class PolicyExportAndImportController extends RestrictedBaseController { public void ExportPolicy(HttpServletRequest request, HttpServletResponse response) throws Exception{ try{ String file = null; - selectedPolicy = new ArrayList(); + selectedPolicy = new ArrayList<>(); ObjectMapper mapper = new ObjectMapper(); mapper.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false); JsonNode root = mapper.readTree(request.getReader()); @@ -196,8 +196,8 @@ public class PolicyExportAndImportController extends RestrictedBaseController { //Check if the Role and Scope Size are Null get the values from db. List userRoles = PolicyController.getRoles(userId); - roles = new ArrayList(); - scopes = new HashSet(); + roles = new ArrayList<>(); + scopes = new HashSet<>(); for(Object role: userRoles){ Roles userRole = (Roles) role; roles.add(userRole.getRole()); diff --git a/POLICY-SDK-APP/src/main/java/org/openecomp/policy/controller/PolicyRolesController.java b/POLICY-SDK-APP/src/main/java/org/openecomp/policy/controller/PolicyRolesController.java index 9a4f52dbb..219342063 100644 --- a/POLICY-SDK-APP/src/main/java/org/openecomp/policy/controller/PolicyRolesController.java +++ b/POLICY-SDK-APP/src/main/java/org/openecomp/policy/controller/PolicyRolesController.java @@ -65,7 +65,7 @@ public class PolicyRolesController extends RestrictedBaseController{ @RequestMapping(value={"/get_RolesData"}, method={org.springframework.web.bind.annotation.RequestMethod.GET} , produces=MediaType.APPLICATION_JSON_VALUE) public void getPolicyRolesEntityData(HttpServletRequest request, HttpServletResponse response){ try{ - Map model = new HashMap(); + Map model = new HashMap<>(); ObjectMapper mapper = new ObjectMapper(); model.put("rolesDatas", mapper.writeValueAsString(commonClassDao.getUserRoles())); JsonMessage msg = new JsonMessage(mapper.writeValueAsString(model)); @@ -117,8 +117,8 @@ public class PolicyRolesController extends RestrictedBaseController{ @RequestMapping(value={"/get_PolicyRolesScopeData"}, method={org.springframework.web.bind.annotation.RequestMethod.GET} , produces=MediaType.APPLICATION_JSON_VALUE) public void getPolicyScopesEntityData(HttpServletRequest request, HttpServletResponse response){ try{ - scopelist = new ArrayList(); - Map model = new HashMap(); + scopelist = new ArrayList<>(); + Map model = new HashMap<>(); ObjectMapper mapper = new ObjectMapper(); mapper.setVisibility(PropertyAccessor.FIELD, Visibility.ANY); List scopesData = commonClassDao.getDataByColumn(PolicyEditorScopes.class, "scopeName"); 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 d9d0fc97b..ff91e9381 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 @@ -90,8 +90,8 @@ public class PolicyValidationController extends RestrictedBaseController { private Pattern pattern; private Matcher matcher; - private static Map rangeMap = new HashMap(); - private static Map mapAttribute = new HashMap(); + private static Map rangeMap = new HashMap<>(); + private static Map mapAttribute = new HashMap<>(); private static final String EMAIL_PATTERN = "^[_A-Za-z0-9-\\+]+(\\.[_A-Za-z0-9-]+)*@" @@ -642,14 +642,24 @@ public class PolicyValidationController extends RestrictedBaseController { // Validation for json. protected static boolean isJSONValid(String data) { + InputStream stream = null; + JsonReader jsonReader = null; try { new JSONObject(data); - InputStream stream = new ByteArrayInputStream(data.getBytes(StandardCharsets.UTF_8)); - JsonReader jsonReader = Json.createReader(stream); - System.out.println("Json Value is: " + jsonReader.read().toString() ); + stream = new ByteArrayInputStream(data.getBytes(StandardCharsets.UTF_8)); + jsonReader = Json.createReader(stream); } catch (Exception e) { LOGGER.error("Exception Occured"+e); return false; + }finally{ + try { + if(stream != null && jsonReader != null){ + jsonReader.close(); + stream.close(); + } + } catch (IOException e) { + LOGGER.error("Exception Occured while closing the input stream"+e); + } } return true; } 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 9cb41eeab..477850a11 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 @@ -353,7 +353,7 @@ public class CommonClassDaoImpl implements CommonClassDao{ try { Criteria cr = session.createCriteria(className); Disjunction disjunction = Restrictions.disjunction(); - List conjunctionList = new ArrayList(); + List conjunctionList = new ArrayList<>(); String[] columNames = columnName.split(":"); for(int i =0; i < data.size(); i++){ String[] entiySplit = data.get(i).split(":"); diff --git a/POLICY-SDK-APP/src/main/java/org/openecomp/policy/model/PDPGroupContainer.java b/POLICY-SDK-APP/src/main/java/org/openecomp/policy/model/PDPGroupContainer.java index 9d001b3ab..a0b47bb7d 100644 --- a/POLICY-SDK-APP/src/main/java/org/openecomp/policy/model/PDPGroupContainer.java +++ b/POLICY-SDK-APP/src/main/java/org/openecomp/policy/model/PDPGroupContainer.java @@ -208,7 +208,7 @@ public class PDPGroupContainer extends PolicyItemSetChangeNotifier implements Po @Override public Collection getItemIds() { - final Collection items = new ArrayList(); + final Collection items = new ArrayList<>(); items.addAll(this.groups); if (LOGGER.isTraceEnabled()) { LOGGER.trace("getItemIds: " + items); diff --git a/POLICY-SDK-APP/src/main/java/org/openecomp/policy/model/PDPPolicyContainer.java b/POLICY-SDK-APP/src/main/java/org/openecomp/policy/model/PDPPolicyContainer.java index 353a903be..372a416c6 100644 --- a/POLICY-SDK-APP/src/main/java/org/openecomp/policy/model/PDPPolicyContainer.java +++ b/POLICY-SDK-APP/src/main/java/org/openecomp/policy/model/PDPPolicyContainer.java @@ -177,7 +177,7 @@ public class PDPPolicyContainer extends PolicyItemSetChangeNotifier implements P @Override public Collection getItemIds() { - final Collection items = new ArrayList(); + final Collection items = new ArrayList<>(); items.addAll(this.policies); return Collections.unmodifiableCollection(items); } diff --git a/POLICY-SDK-APP/src/main/webapp/app/policyApp/CSS/b2b-angular.css b/POLICY-SDK-APP/src/main/webapp/app/policyApp/CSS/b2b-angular.css index 284a8d4dc..a894691ca 100644 --- a/POLICY-SDK-APP/src/main/webapp/app/policyApp/CSS/b2b-angular.css +++ b/POLICY-SDK-APP/src/main/webapp/app/policyApp/CSS/b2b-angular.css @@ -685,4 +685,233 @@ top: 4px; right: 3px; height: 16px; - width: 16px; } \ No newline at end of file + width: 16px; } + +.b2b-header-tabs .icon-primary-att-globe { + color: #0568ae; + font-size: 34px; } + +.b2b-header-tabs .globe-text { + margin-left: 20px; + font-size: 2rem; } + +.b2b-header-tabs .header__items { + width: 980px; + margin: 0 auto; + display: block; + list-style: none; + border-spacing: 30px 0; + padding: 3px 0px 0px 0px; } + +.b2b-header-tabs .header__item { + display: inline-block; + text-align: left; + width: auto; + font-size: 14px; + font-family: "Omnes-ECOMP-W02", Arial; + cursor: pointer; + padding: 0 15px 4px 15px; + /*margin-top:-3px;*/ + color: #fff; } + +.b2b-header-tabs .header__item.b2b-headermenu { + padding: 0; } + +.b2b-header-tabs .header__item.b2b-headermenu a.menu__item { + color: #fff; + text-decoration: none; + display: inline-block; + padding: 8px 15px 12px 15px; + font-size: 16px; } + +.b2b-header-tabs .header__item.active { + background-color: #fff; + border-radius: 2px; + border-bottom-left-radius: 0; + border-bottom-right-radius: 0; } + +.b2b-header-tabs .header__item.active a.menu__item { + color: #0578ae; } + +.b2b-header-tabs li:focus { + outline: 2px solid #0578ae; } + +/** profile pop Over **/ +.b2b-header-tabs .header__item.profile { + position: relative; + float: right; } + +/** Secondary Menu **/ +.b2b-header-tabs .header__item .header-secondary-wrapper, .b2b-header-tabs .header__item .header-tertiary-wrapper { + background-color: #fff; + position: absolute; + width: 100%; + left: 0; + top: 42px; + border-bottom: solid 1px #ccc; + -webkit-box-shadow: 0px 2px 2px 0px rgba(0, 0, 0, 0.16); + -moz-box-shadow: 0px 2px 2px 0px rgba(0, 0, 0, 0.16); + box-shadow: 0px 2px 2px 0px rgba(0, 0, 0, 0.16); + display: none; + z-index: 111; } + +.b2b-header-tabs .header-secondary, .b2b-header-tabs .header-tertiary { + background-color: #fff; + width: 980px; + margin: 0 auto; } + +.b2b-header-tabs .header__item.active .header-secondary-wrapper, +.b2b-header-tabs .header-secondary .header-subitem.active .header-tertiary-wrapper { + display: block; } + +.b2b-header-tabs .header-secondary .header-subitem { + display: inline-block; + width: auto; + margin: 0 15px; } + +.b2b-header-tabs .header-secondary .header-subitem a.menu__item { + display: inline-block; + padding: 15px 0; + color: #333; + font-size: 14px; } + +.b2b-header-tabs .header-secondary .header-subitem a.menu__item:hover, .b2b-header-tabs .header-secondary .header-subitem a.menu__item:focus { + color: #0578ae; } + +.b2b-label-hide { + position: absolute; + clip: rect(1px, 1px, 1px, 1px); } + +/** Tertiary Level Menu **/ +.b2b-header-tabs .header-secondary .header-subitem.active i.menuCaret:after, +.b2b-header-tabs .header-secondary .header-subitem.active i.menuCaret:before { + content: ''; + border-left: 8px solid transparent; + border-right: 8px solid transparent; + position: absolute; + -webkit-transition: left .2s ease-out; + -moz-transition: left .2s ease-out; + transition: left .2s ease-out; } + +.b2b-header-tabs .header-secondary .header-subitem.active i.menuCaret { + position: absolute; + z-index: 111; + top: 25px; } + +.b2b-header-tabs .header-secondary .header-subitem.active i.menuCaret:after { + border-bottom: 8px solid #fff; + top: 10px; } + +.b2b-header-tabs .header-secondary .header-subitem.active i.menuCaret:before { + border-bottom: 8px solid #ccc; + top: 9px; } + +/** Tertiary Level Menu **/ +.b2b-header-tabs .header-secondary .header-subitem.active .header-tertiary { + border-top: solid 1px #ccc; } + +.b2b-header-tabs .header-tertiary:after { + content: ''; + clear: both; + display: block; } + +.b2b-header-tabs .header-tertiary li { + display: inline-block; + padding: 0; + float: left; } + +.b2b-header-tabs .header-tertiary li a { + color: #333; + display: block; + padding: 7px 15px; + max-width: 228px; } + +.b2b-header-tabs .header-tertiary li label { + text-align: left; + display: block; + font-size: 14px !important; + font-weight: bold; + color: #857B7B; + padding: 15px 0 0 15px; } + +/** Quarternary Level Menu **/ +.b2b-header-tabs .header-quarternary { + width: 100%; + float: left; } + +.b2b-header-tabs .header-quarternary li { + padding-left: 15px; + font-family: "Omnes-ECOMP-W02", Arial; + display: none; } + +.b2b-header-tabs .header-quarternary li.active { + display: block; } + +.b2b-header-tabs .header-quarternary li a { + color: #666666; + font-size: 14px; + padding: 0px 10px 10px 10px; } + +/** Skip Navigation**/ +.b2b-header-tabs .header__item.skip { + padding: 0; + display: inline-block; + cursor: default !important; } + +.b2b-header-tabs .header__item.skip a { + color: transparent; + font-size: 12px; + line-height: 15px; + text-decoration: none; } + +.b2b-header-tabs .header__item.skip a:focus { + color: #fff; + outline: 2px solid #0578ae; } + +/** Dropdown css inside Header ****/ +.b2b-header-tabs .selectWrap { + min-width: 150px; } + +.b2b-header-tabs .selectWrap button.awd-select, .b2b-header-tabs .selectWrap input.awd-select { + height: 36px; + line-height: 8px; + font-size: 1rem; + display: inline-block; } + +.b2b-header-tabs .selectWrap .awd-select-list { + background-color: #fff; + color: #333; + -webkit-transition: opacity .2s ease-out; + -moz-transition: opacity .2s ease-out; + transition: opacity .2s ease-out; + box-shadow: 0 6px 12px rgba(0, 0, 0, 0.176); } + +/* + * responsive header media queries + */ +@media screen and (max-width: 1100px) { + .b2b-header-tabs .globe-text { + display: none; } + .b2b-header-tabs .header__item.profile { + padding-left: 15px; + float: none; } + .b2b-header-tabs .header__items { + padding-top: 0px; } } + +@media screen and (max-width: 950px) { + .header__item.profile { + top: 20px; } + .b2b-header-tabs { + height: 90px; } + .selectWrap { + bottom: 15px; } + .b2b-header-tabs .header__items { + padding-top: 25px; } + .b2b-header-tabs .header__item .header-secondary-wrapper, .b2b-header-tabs .header__item .header-tertiary-wrapper { + top: 80px; } + .b2b-header-tabs .header-secondary .header-subitem.active i.menuCaret { + top: 35px; } + .b2b-header-tabs .header__item.b2b-headermenu a.menu__item { + padding-bottom: 30px; } + .b2b-header-tabs .header-secondary .header-subitem.active .header-tertiary { + margin-top: -28px; } } \ No newline at end of file diff --git a/POLICY-SDK-APP/src/main/webapp/app/policyApp/controller/dictionaryController/attributeDictController.js b/POLICY-SDK-APP/src/main/webapp/app/policyApp/controller/dictionaryController/attributeDictController.js index 51909162a..db81da0e5 100644 --- a/POLICY-SDK-APP/src/main/webapp/app/policyApp/controller/dictionaryController/attributeDictController.js +++ b/POLICY-SDK-APP/src/main/webapp/app/policyApp/controller/dictionaryController/attributeDictController.js @@ -27,7 +27,7 @@ app.controller('editAttributeController' ,function ($scope, $modalInstance, mess $scope.disableCd=true; var headers = message.attributeDictionaryData.attributeValue; var splitEqual = ','; - if(headers != null){ + if(headers != null && headers != ""){ if (headers.indexOf(splitEqual) >= 0) { var splitValue = headers.split(splitEqual); for(i = 0; i < splitValue.length; i++){ 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 6ca9dfd93..0bfcd3c01 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 @@ -29,6 +29,7 @@ app.controller('actionPolicyController', ['$scope', 'PolicyAppService', 'policyN $scope.policyNavigator.refresh(); } $scope.modal('createNewPolicy', true); + $scope.temp.policy = ""; }; $scope.modal = function(id, hide) { 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 b37685739..323a9bfa0 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 @@ -29,6 +29,7 @@ angular.module('abs').controller('brmsParamPolicyController', ['$scope', '$windo $scope.policyNavigator.refresh(); } $scope.modal('createNewPolicy', true); + $scope.temp.policy = ""; }; $scope.modal = function(id, hide) { @@ -106,6 +107,8 @@ angular.module('abs').controller('brmsParamPolicyController', ['$scope', '$windo } }; + $scope.showbrmsrule = true; + $scope.ShowRule = function(policy){ console.log(policy); var uuu = "policyController/ViewBRMSParamPolicyRule.htm"; @@ -117,21 +120,10 @@ angular.module('abs').controller('brmsParamPolicyController', ['$scope', '$windo contentType: 'application/json', data: JSON.stringify(postData), success : function(data){ + $scope.showbrmsrule = false; + $scope.validateSuccess = true; $scope.$apply(function(){ $scope.datarule = data.policyData; - var modalInstance = $modal.open({ - backdrop: 'static', keyboard: false, - templateUrl : 'app/policyApp/policy-models/Editor/PolicyTemplates/BRMSShowParamRuleModal.html', - controller: 'showrulecontroller', - resolve: { - message: function () { - var message = { - datas: $scope.datarule - }; - return message; - } - } - }); }); }, error : function(data){ @@ -140,6 +132,12 @@ angular.module('abs').controller('brmsParamPolicyController', ['$scope', '$windo }); }; + $scope.hideRule = function(){ + $scope.showbrmsrule = true; + $scope.validateSuccess = false; + $scope.apply(); + }; + $scope.saveBrmsParamPolicy = function(policy){ if(policy.itemContent != undefined){ $scope.refreshCheck = true; @@ -247,15 +245,4 @@ angular.module('abs').controller('brmsParamPolicyController', ['$scope', '$windo 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){ - $scope.datarule=message.datas; - } - - $scope.close = function() { - $modalInstance.close(); - }; - -}); \ 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/BRMSRawPolicyController.js b/POLICY-SDK-APP/src/main/webapp/app/policyApp/policy-models/Editor/PolicyTemplateController/BRMSRawPolicyController.js index 97f6d2997..ecf3dec30 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 @@ -29,6 +29,7 @@ angular.module('abs').controller('brmsRawPolicyController', ['$scope', '$window' $scope.policyNavigator.refresh(); } $scope.modal('createNewPolicy', true); + $scope.temp.policy = ""; }; $scope.modal = function(id, hide) { 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 20287baf1..9dc7e9247 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 @@ -30,6 +30,7 @@ app.controller('baseConfigController', ['$scope', 'PolicyAppService', 'policyNav $scope.policyNavigator.refresh(); } $scope.modal('createNewPolicy', true); + $scope.temp.policy = ""; }; $scope.modal = function(id, hide) { 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 11254742a..8f054edd1 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 @@ -29,6 +29,7 @@ angular.module("abs").controller('clFaultController', ['$scope', '$window', 'Pol $scope.policyNavigator.refresh(); } $scope.modal('createNewPolicy', true); + $scope.temp.policy = ""; }; $scope.modal = function(id, hide) { 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 393780705..b74f1b39b 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 @@ -29,6 +29,7 @@ angular.module("abs").controller('clPMController', ['$scope', '$window', '$timeo $scope.policyNavigator.refresh(); } $scope.modal('createNewPolicy', true); + $scope.temp.policy = ""; }; $scope.modal = function(id, hide) { 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 b87299cbd..5e602ae12 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 @@ -30,6 +30,7 @@ angular.module('abs').controller('dcaeMicroServiceController', ['$scope', '$wind $scope.policyNavigator.refresh(); } $scope.modal('createNewPolicy', true); + $scope.temp.policy = ""; }; $scope.modal = function(id, hide) { 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 d0c72682b..ce27e04e0 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 @@ -29,6 +29,7 @@ angular.module('abs').controller('decisionPolicyController', ['$scope', 'PolicyA $scope.policyNavigator.refresh(); } $scope.modal('createNewPolicy', true); + $scope.temp.policy = ""; }; $scope.modal = function(id, hide) { 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 46b6711cd..2978a43fa 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 @@ -29,6 +29,7 @@ angular.module('abs').controller('fwPolicyController', ['$scope', '$window', 'Po $scope.policyNavigator.refresh(); } $scope.modal('createNewPolicy', true); + $scope.temp.policy = ""; }; $scope.modal = function(id, hide) { 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 2aa3b23d9..0e7a4b35d 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 @@ -124,6 +124,14 @@
+
+
+

Rule Preview:

+

+ + +
+

diff --git a/POLICY-SDK-APP/src/main/webapp/app/policyApp/policy-models/Editor/templates/search-main-table.html b/POLICY-SDK-APP/src/main/webapp/app/policyApp/policy-models/Editor/templates/search-main-table.html new file mode 100644 index 000000000..e72992180 --- /dev/null +++ b/POLICY-SDK-APP/src/main/webapp/app/policyApp/policy-models/Editor/templates/search-main-table.html @@ -0,0 +1,74 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
+ + Name + + +
+
+
+ No Policy's in Scope... +
+ {{ policyNavigator.error }} +
+ + + + {{item.model.name | strLimit : 64}} + +
\ No newline at end of file diff --git a/POLICY-SDK-APP/src/main/webapp/app/policyApp/policy-models/policy_SearchFilter.html b/POLICY-SDK-APP/src/main/webapp/app/policyApp/policy-models/policy_SearchFilter.html index a4fe1af49..c8072a312 100644 --- a/POLICY-SDK-APP/src/main/webapp/app/policyApp/policy-models/policy_SearchFilter.html +++ b/POLICY-SDK-APP/src/main/webapp/app/policyApp/policy-models/policy_SearchFilter.html @@ -27,7 +27,7 @@
- +
-- cgit 1.2.3-korg