* ============LICENSE_START=======================================================
* ONAP Policy Engine
* ================================================================================
- * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.
+ * Copyright (C) 2017-2018 AT&T Intellectual Property. All rights reserved.
* ================================================================================
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
import org.onap.policy.components.HumanPolicyComponent;
import org.onap.policy.controller.PolicyController;
import org.onap.policy.controller.PolicyExportAndImportController;
-import org.onap.policy.model.Roles;
import org.onap.policy.rest.XACMLRest;
import org.onap.policy.rest.XACMLRestProperties;
import org.onap.policy.rest.adapter.PolicyRestAdapter;
import org.onap.policy.rest.jpa.PolicyVersion;
import org.onap.policy.rest.jpa.UserInfo;
import org.onap.policy.utils.PolicyUtils;
+import org.onap.policy.utils.UserUtils.Pair;
import org.onap.policy.xacml.api.XACMLErrorConstants;
import org.onap.policy.xacml.util.XACMLPolicyScanner;
import org.onap.portalsdk.core.web.support.UserUtils;
try {
//Get the Login Id of the User from Request
String userId = UserUtils.getUserSession(request).getOrgUserId();
- //Check if the Role and Scope Size are Null get the values from db.
List<Object> userRoles = controller.getRoles(userId);
- roles = new ArrayList<>();
- scopes = new HashSet<>();
- for(Object role: userRoles){
- Roles userRole = (Roles) role;
- roles.add(userRole.getRole());
- if(userRole.getScope() != null){
- if(userRole.getScope().contains(",")){
- String[] multipleScopes = userRole.getScope().split(",");
- for(int i =0; i < multipleScopes.length; i++){
- scopes.add(multipleScopes[i]);
- }
- }else{
- scopes.add(userRole.getScope());
- }
- }
- }
+ Pair<Set<String>, List<String>> pair = org.onap.policy.utils.UserUtils.checkRoleAndScope(userRoles);
+ roles = pair.u;
+ scopes = pair.t;
if (roles.contains(ADMIN) || roles.contains(EDITOR) || roles.contains(GUEST) ) {
if(scopes.isEmpty()){
return error("No Scopes has been Assigned to the User. Please, Contact Super-Admin");
String activePolicy;
PolicyController controller = getPolicyControllerInstance();
- if(params.toString().contains("activeVersion")){
- String activeVersion = params.getString("activeVersion");
- String highestVersion = params.get("highestVersion").toString();
- if(Integer.parseInt(activeVersion) > Integer.parseInt(highestVersion)){
- return error("The Version shouldn't be greater than Highest Value");
- }else{
- activePolicy = policyName + "." + activeVersion + ".xml";
- String dbCheckName = activePolicy.replace("/", ".");
- if(dbCheckName.contains("Config_")){
- dbCheckName = dbCheckName.replace(".Config_", ":Config_");
- }else if(dbCheckName.contains("Action_")){
- dbCheckName = dbCheckName.replace(".Action_", ":Action_");
- }else if(dbCheckName.contains("Decision_")){
- dbCheckName = dbCheckName.replace(".Decision_", ":Decision_");
- }
- String[] splitDBCheckName = dbCheckName.split(":");
- String peQuery = "FROM PolicyEntity where policyName = :splitDBCheckName_1 and scope = :splitDBCheckName_0";
- SimpleBindings policyParams = new SimpleBindings();
- policyParams.put("splitDBCheckName_1", splitDBCheckName[1]);
- policyParams.put("splitDBCheckName_0", splitDBCheckName[0]);
- List<Object> policyEntity = controller.getDataByQuery(peQuery, policyParams);
- PolicyEntity pentity = (PolicyEntity) policyEntity.get(0);
- if(pentity.isDeleted()){
- return error("The Policy is Not Existing in Workspace");
- }else{
- if(policyName.contains("/")){
- policyName = policyName.replace("/", File.separator);
- }
- policyName = policyName.substring(policyName.indexOf(File.separator)+1);
- if(policyName.contains("\\")){
- policyName = policyName.replace(File.separator, "\\");
- }
- policyName = splitDBCheckName[0].replace(".", File.separator)+File.separator+policyName;
- String watchPolicyName = policyName;
- if(policyName.contains("/")){
- policyName = policyName.replace("/", File.separator);
- }
- if(policyName.contains("\\")){
- policyName = policyName.replace("\\", "\\\\");
- }
- String query = "update PolicyVersion set active_version='"+activeVersion+"' where policy_name ='"+policyName+"' and id >0";
- //query the database
- controller.executeQuery(query);
- //Policy Notification
- PolicyVersion entity = new PolicyVersion();
- entity.setPolicyName(watchPolicyName);
- entity.setActiveVersion(Integer.parseInt(activeVersion));
- entity.setModifiedBy(userId);
- controller.watchPolicyFunction(entity, activePolicy, "SwitchVersion");
- return success();
- }
- }
+ if(! params.toString().contains("activeVersion")){
+ return controller.switchVersionPolicyContent(policyName);
+ }
+ String activeVersion = params.getString("activeVersion");
+ String highestVersion = params.get("highestVersion").toString();
+ if(Integer.parseInt(activeVersion) > Integer.parseInt(highestVersion)){
+ return error("The Version shouldn't be greater than Highest Value");
+ }
+ activePolicy = policyName + "." + activeVersion + ".xml";
+ String dbCheckName = activePolicy.replace("/", ".");
+ if(dbCheckName.contains("Config_")){
+ dbCheckName = dbCheckName.replace(".Config_", ":Config_");
+ }else if(dbCheckName.contains("Action_")){
+ dbCheckName = dbCheckName.replace(".Action_", ":Action_");
+ }else if(dbCheckName.contains("Decision_")){
+ dbCheckName = dbCheckName.replace(".Decision_", ":Decision_");
+ }
+ String[] splitDBCheckName = dbCheckName.split(":");
+ String peQuery = "FROM PolicyEntity where policyName = :splitDBCheckName_1 and scope = :splitDBCheckName_0";
+ SimpleBindings policyParams = new SimpleBindings();
+ policyParams.put("splitDBCheckName_1", splitDBCheckName[1]);
+ policyParams.put("splitDBCheckName_0", splitDBCheckName[0]);
+ List<Object> policyEntity = controller.getDataByQuery(peQuery, policyParams);
+ PolicyEntity pentity = (PolicyEntity) policyEntity.get(0);
+ if(pentity.isDeleted()){
+ return error("The Policy is Not Existing in Workspace");
+ }
+ if(policyName.contains("/")){
+ policyName = policyName.replace("/", File.separator);
}
- return controller.switchVersionPolicyContent(policyName);
+ policyName = policyName.substring(policyName.indexOf(File.separator)+1);
+ if(policyName.contains("\\")){
+ policyName = policyName.replace(File.separator, "\\");
+ }
+ policyName = splitDBCheckName[0].replace(".", File.separator)+File.separator+policyName;
+ String watchPolicyName = policyName;
+ if(policyName.contains("/")){
+ policyName = policyName.replace("/", File.separator);
+ }
+ if(policyName.contains("\\")){
+ policyName = policyName.replace("\\", "\\\\");
+ }
+ String query = "update PolicyVersion set active_version='"+activeVersion+"' where policy_name ='"+policyName+"' and id >0";
+ //query the database
+ controller.executeQuery(query);
+ //Policy Notification
+ PolicyVersion entity = new PolicyVersion();
+ entity.setPolicyName(watchPolicyName);
+ entity.setActiveVersion(Integer.parseInt(activeVersion));
+ entity.setModifiedBy(userId);
+ controller.watchPolicyFunction(entity, activePolicy, "SwitchVersion");
+ return success();
}
//Describe Policy
}else{
queryData = controller.getDataByQuery(query, peParams);
}
- if(!queryData.isEmpty()){
- PolicyEntity entity = (PolicyEntity) queryData.get(0);
- File temp = null;
- BufferedWriter bw = null;
+ if(queryData.isEmpty()){
+ return error("Error Occured while Describing the Policy - query is empty");
+ }
+ PolicyEntity entity = (PolicyEntity) queryData.get(0);
+ File temp = null;
+ try {
+ temp = File.createTempFile(policyName, ".tmp");
+ } catch (IOException e) {
+ String message = "Failed to create temp file " + policyName + ".tmp";
+ LOGGER.error(message + e);
+ return error(message);
+ }
+ try (BufferedWriter bw = new BufferedWriter(new FileWriter(temp))) {
+ bw.write(entity.getPolicyData());
+ } catch (IOException e) {
+ LOGGER.error("Exception Occured while Describing the Policy"+e);
+ }
+ object = HumanPolicyComponent.DescribePolicy(temp);
+ if(temp != null){
try {
- temp = File.createTempFile(policyName, ".tmp");
- bw = new BufferedWriter(new FileWriter(temp));
- bw.write(entity.getPolicyData());
- bw.close();
- object = HumanPolicyComponent.DescribePolicy(temp);
+ Files.delete(temp.toPath());
} catch (IOException e) {
- LOGGER.error("Exception Occured while Describing the Policy"+e);
- }finally{
- if(temp != null){
- temp.delete();
- }
- if(bw != null){
- try {
- bw.close();
- } catch (IOException e) {
- LOGGER.error("Exception Occured while Closing the File Writer"+e);
- }
- }
+ LOGGER.warn("Failed to delete " + temp.getName() + e);
}
- }else{
- return error("Error Occured while Describing the Policy");
}
-
return object;
}
//Get the Login Id of the User from Request
String testUserID = getTestUserId();
String userId = testUserID != null ? testUserID : UserUtils.getUserSession(request).getOrgUserId();
- //Check if the Role and Scope Size are Null get the values from db.
List<Object> userRoles = controller.getRoles(userId);
- roles = new ArrayList<>();
- scopes = new HashSet<>();
- for(Object role: userRoles){
- Roles userRole = (Roles) role;
- roles.add(userRole.getRole());
- if(userRole.getScope() != null){
- if(userRole.getScope().contains(",")){
- String[] multipleScopes = userRole.getScope().split(",");
- for(int i =0; i < multipleScopes.length; i++){
- scopes.add(multipleScopes[i]);
- }
- }else{
- scopes.add(userRole.getScope());
- }
- }
- }
+ Pair<Set<String>, List<String>> pair = org.onap.policy.utils.UserUtils.checkRoleAndScope(userRoles);
+ roles = pair.u;
+ scopes = pair.t;
List<JSONObject> resultList = new ArrayList<>();
boolean onlyFolders = params.getBoolean("onlyFolders");
}
//Get Active Policy List based on Scope Selection form Policy Version table
- private void activePolicyList(String scopeName, List<JSONObject> resultList, List<String> roles, Set<String> scopes, boolean onlyFolders){
+ private void activePolicyList(String inScopeName, List<JSONObject> resultList, List<String> roles, Set<String> scopes, boolean onlyFolders){
PolicyController controller = getPolicyControllerInstance();
+ String scopeName = inScopeName;
if(scopeName.contains("/")){
scopeName = scopeName.replace("/", File.separator);
}
if(scopeName.contains("\\")){
- scopeName = scopeName.replace("\\", "\\\\\\\\");
+ scopeName = scopeName.replace("\\", "\\\\");
}
String query = "from PolicyVersion where POLICY_NAME like :scopeName";
String scopeNamequery = "from PolicyEditorScopes where SCOPENAME like :scopeName";
PolicyVersion policy = (PolicyVersion) list;
String scopeNameValue = policy.getPolicyName().substring(0, policy.getPolicyName().lastIndexOf(File.separator));
if(roles.contains(SUPERADMIN) || roles.contains(SUPEREDITOR) || roles.contains(SUPERGUEST)){
- if((scopeName.contains("\\\\"))){
+ if(scopeName.contains("\\\\")){
scopeNameCheck = scopeName.replace("\\\\", File.separator);
}else{
scopeNameCheck = scopeName;
String newPath = params.getString("newPath");
oldPath = oldPath.substring(oldPath.indexOf('/')+1);
newPath = newPath.substring(newPath.indexOf('/')+1);
+ String checkValidation = null;
if(oldPath.endsWith(".xml")){
+ checkValidation = newPath.replace(".xml", "");
+ checkValidation = checkValidation.substring(checkValidation.indexOf('_') + 1, checkValidation.lastIndexOf("."));
+ checkValidation = checkValidation.substring(checkValidation.lastIndexOf("/")+1);
+ if(!PolicyUtils.policySpecialCharValidator(checkValidation).contains("success")){
+ return error("Policy Rename Failed. The Name contains special characters.");
+ }
JSONObject result = policyRename(oldPath, newPath, userId);
if(!(Boolean)(result.getJSONObject("result").get("success"))){
return result;
scopeName = scopeName.replace("/", File.separator);
newScopeName = newScopeName.replace("/", File.separator);
}
- if(scopeName.contains("\\")){
- scopeName = scopeName.replace("\\", "\\\\\\\\");
- newScopeName = newScopeName.replace("\\", "\\\\\\\\");
- }
+ checkValidation = newScopeName.substring(newScopeName.lastIndexOf(File.separator)+1);
+ if(scopeName.contains("\\")){
+ scopeName = scopeName.replace("\\", "\\\\\\\\");
+ newScopeName = newScopeName.replace("\\", "\\\\\\\\");
+ }
+ if(!PolicyUtils.policySpecialCharValidator(checkValidation).contains("success")){
+ return error("Scope Rename Failed. The Name contains special characters.");
+ }
PolicyController controller = getPolicyControllerInstance();
String query = "from PolicyVersion where POLICY_NAME like :scopeName";
String scopeNamequery = "from PolicyEditorScopes where SCOPENAME like :scopeName";
}
}
- private void renameScope(List<Object> scopesList, String scopeName, String newScopeName, PolicyController controller){
+ private void renameScope(List<Object> scopesList, String inScopeName, String newScopeName, PolicyController controller){
for(Object object : scopesList){
PolicyEditorScopes editorScopeEntity = (PolicyEditorScopes) object;
+ String scopeName = inScopeName;
if(scopeName.contains("\\\\\\\\")){
scopeName = scopeName.replace("\\\\\\\\", File.separator);
newScopeName = newScopeName.replace("\\\\\\\\", File.separator);
}
for(int i=0; i<oldEntityData.size(); i++){
entity = (PolicyEntity) oldEntityData.get(i);
- checkOldPolicyEntryAndUpdate(entity, newPolicySplit[0] , newPolicySplit[1], oldPolicySplit[0], oldPolicySplit[1], policyName, newpolicyName, oldpolicyName, userId);
+ String checkEntityName = entity.getPolicyName().replace(".xml", "");
+ checkEntityName = checkEntityName.substring(0, checkEntityName.lastIndexOf('.'));
+ String originalPolicyName = oldpolicyName.substring(oldpolicyName.lastIndexOf(File.separator)+1);
+ if(checkEntityName.equals(originalPolicyName)){
+ checkOldPolicyEntryAndUpdate(entity, newPolicySplit[0] , newPolicySplit[1], oldPolicySplit[0], oldPolicySplit[1], policyName, newpolicyName, oldpolicyName, userId);
+ }
}
}else{
return error("Policy rename failed due to policy not able to retrieve from database. Please, contact super-admin.");
entity.setPolicyData(entity.getPolicyData().replace(oldScope +"."+oldPolicyNameWithoutExtension, newScope+"."+newPolicyNameWithoutExtension));
entity.setScope(newScope);
entity.setModifiedBy(userId);
+
+ String oldConfigurationName = null;
+ String newConfigurationName = null;
if(newpolicyName.contains("Config_")){
- String oldConfigurationName = configEntity.getConfigurationName();
+ oldConfigurationName = configEntity.getConfigurationName();
configEntity.setConfigurationName(configEntity.getConfigurationName().replace(oldScope +"."+oldPolicyNameWithoutExtension, newScope+"."+newPolicyNameWithoutExtension));
controller.updateData(configEntity);
- String newConfigurationName = configEntity.getConfigurationName();
+ newConfigurationName = configEntity.getConfigurationName();
File file = new File(PolicyController.getConfigHome() + File.separator + oldConfigurationName);
if(file.exists()){
File renamefile = new File(PolicyController.getConfigHome() + File.separator + newConfigurationName);
file.renameTo(renamefile);
}
}else if(newpolicyName.contains("Action_")){
- String oldConfigurationName = actionEntity.getActionBodyName();
+ oldConfigurationName = actionEntity.getActionBodyName();
actionEntity.setActionBody(actionEntity.getActionBody().replace(oldScope +"."+oldPolicyNameWithoutExtension, newScope+"."+newPolicyNameWithoutExtension));
controller.updateData(actionEntity);
- String newConfigurationName = actionEntity.getActionBodyName();
+ newConfigurationName = actionEntity.getActionBodyName();
File file = new File(PolicyController.getActionHome() + File.separator + oldConfigurationName);
if(file.exists()){
File renamefile = new File(PolicyController.getActionHome() + File.separator + newConfigurationName);
}
controller.updateData(entity);
+ PolicyRestController restController = new PolicyRestController();
+ restController.notifyOtherPAPSToUpdateConfigurations("rename", newConfigurationName, oldConfigurationName);
PolicyVersion versionEntity = (PolicyVersion) controller.getEntityItem(PolicyVersion.class, "policyName", oldpolicyName);
versionEntity.setPolicyName(policyName);
versionEntity.setModifiedBy(userId);
}
}
- private JSONObject cloneRecord(String newpolicyName, String oldScope, String removeoldPolicyExtension, String newScope, String removenewPolicyExtension, PolicyEntity entity, String userId) throws ServletException{
- FileWriter fw = null;
+ private JSONObject cloneRecord(String newpolicyName, String oldScope, String inRemoveoldPolicyExtension, String newScope, String inRemovenewPolicyExtension, PolicyEntity entity, String userId) throws ServletException{
String queryEntityName;
PolicyController controller = getPolicyControllerInstance();
PolicyEntity cloneEntity = new PolicyEntity();
cloneEntity.setPolicyName(newpolicyName);
+ String removeoldPolicyExtension = inRemoveoldPolicyExtension;
+ String removenewPolicyExtension = inRemovenewPolicyExtension;
removeoldPolicyExtension = removeoldPolicyExtension.replace(".xml", "");
removenewPolicyExtension = removenewPolicyExtension.replace(".xml", "");
cloneEntity.setPolicyData(entity.getPolicyData().replace(oldScope+"."+removeoldPolicyExtension, newScope+"."+removenewPolicyExtension));
cloneEntity.setScope(entity.getScope());
String oldConfigRemoveExtension = removeoldPolicyExtension.replace(".xml", "");
String newConfigRemoveExtension = removenewPolicyExtension.replace(".xml", "");
+ String newConfigurationName = null;
if(newpolicyName.contains("Config_")){
ConfigurationDataEntity configurationDataEntity = new ConfigurationDataEntity();
configurationDataEntity.setConfigurationName(entity.getConfigurationData().getConfigurationName().replace(oldScope+"."+oldConfigRemoveExtension, newScope+"."+newConfigRemoveExtension));
controller.saveData(configurationDataEntity);
ConfigurationDataEntity configEntiy = (ConfigurationDataEntity) controller.getEntityItem(ConfigurationDataEntity.class, "configurationName", queryEntityName);
cloneEntity.setConfigurationData(configEntiy);
- String newConfigurationName = configEntiy.getConfigurationName();
- try {
- fw = new FileWriter(PolicyController.getConfigHome() + File.separator + newConfigurationName);
- BufferedWriter bw = new BufferedWriter(fw);
+ newConfigurationName = configEntiy.getConfigurationName();
+ try (FileWriter fw = new FileWriter(PolicyController.getConfigHome() + File.separator + newConfigurationName);
+ BufferedWriter bw = new BufferedWriter(fw)){
bw.write(configEntiy.getConfigBody());
- bw.close();
} catch (IOException e) {
LOGGER.error("Exception Occured While cloning the configuration file"+e);
}
controller.saveData(actionBodyEntity);
ActionBodyEntity actionEntiy = (ActionBodyEntity) controller.getEntityItem(ActionBodyEntity.class, "actionBodyName", queryEntityName);
cloneEntity.setActionBodyEntity(actionEntiy);
- String newConfigurationName = actionEntiy.getActionBodyName();
- try {
- fw = new FileWriter(PolicyController.getActionHome() + File.separator + newConfigurationName);
- BufferedWriter bw = new BufferedWriter(fw);
- bw.write(actionEntiy.getActionBody());
- bw.close();
- } catch (IOException e) {
+ newConfigurationName = actionEntiy.getActionBodyName();
+ try (FileWriter fw = new FileWriter(PolicyController.getActionHome() + File.separator + newConfigurationName);
+ BufferedWriter bw = new BufferedWriter(fw)){
+ bw.write(actionEntiy.getActionBody());
+ } catch (IOException e) {
LOGGER.error("Exception Occured While cloning the configuration file"+e);
}
}
- if(fw != null){
- try {
- fw.close();
- } catch (IOException e) {
- LOGGER.error("Exception Occured While closing the File input stream"+e);
- }
- }
+
cloneEntity.setDeleted(entity.isDeleted());
cloneEntity.setCreatedBy(userId);
cloneEntity.setModifiedBy(userId);
controller.saveData(cloneEntity);
+ //Notify others paps regarding clone policy.
+ PolicyRestController restController = new PolicyRestController();
+ restController.notifyOtherPAPSToUpdateConfigurations("clonePolicy", newConfigurationName, null);
return success();
}
}else if(newPolicyCheck.contains("Decision_")){
newPolicyCheck = newPolicyCheck.replace(".Decision_", ":Decision_");
}
+ if(!newPolicyCheck.contains(":")){
+ return error("Policy Clone Failed. The Name contains special characters.");
+ }
String[] newPolicySplit = newPolicyCheck.split(":");
+ String checkValidation = newPolicySplit[1].replace(".xml", "");
+ checkValidation = checkValidation.substring(checkValidation.indexOf('_') + 1, checkValidation.lastIndexOf("."));
+ if(!PolicyUtils.policySpecialCharValidator(checkValidation).contains("success")){
+ return error("Policy Clone Failed. The Name contains special characters.");
+ }
+
String oldPolicyCheck = orignalPolicyName;
if(oldPolicyCheck.contains("Config_")){
oldPolicyCheck = oldPolicyCheck.replace(".Config_", ":Config_");
SimpleBindings peParams = new SimpleBindings();
peParams.put("oldPolicySplit_1", oldPolicySplit[1]);
peParams.put("oldPolicySplit_0", oldPolicySplit[0]);
- queryData = controller.getDataByQuery(policyEntityquery, peParams);
+ if(PolicyController.isjUnit()){
+ queryData = controller.getDataByQuery(policyEntityquery, null);
+ }else{
+ queryData = controller.getDataByQuery(policyEntityquery, peParams);
+ }
if(!queryData.isEmpty()){
entity = (PolicyEntity) queryData.get(0);
}
if(policyNamewithoutExtension.contains("Config_")){
Files.deleteIfExists(Paths.get(PolicyController.getConfigHome() + File.separator + policyEntity.getConfigurationData().getConfigurationName()));
controller.deleteData(policyEntity.getConfigurationData());
+ restController.notifyOtherPAPSToUpdateConfigurations("delete", null, policyEntity.getConfigurationData().getConfigurationName());
}else if(policyNamewithoutExtension.contains("Action_")){
Files.deleteIfExists(Paths.get(PolicyController.getActionHome() + File.separator + policyEntity.getActionBodyEntity().getActionBodyName()));
controller.deleteData(policyEntity.getActionBodyEntity());
+ restController.notifyOtherPAPSToUpdateConfigurations("delete", null, policyEntity.getActionBodyEntity().getActionBodyName());
}
}
}
if(policyNamewithoutExtension.contains("Config_")){
Files.deleteIfExists(Paths.get(PolicyController.getConfigHome() + File.separator + policyEntity.getConfigurationData().getConfigurationName()));
controller.deleteData(policyEntity.getConfigurationData());
+ restController.notifyOtherPAPSToUpdateConfigurations("delete", null, policyEntity.getConfigurationData().getConfigurationName());
}else if(policyNamewithoutExtension.contains("Action_")){
Files.deleteIfExists(Paths.get(PolicyController.getActionHome() + File.separator + policyEntity.getActionBodyEntity().getActionBodyName()));
controller.deleteData(policyEntity.getActionBodyEntity());
+ restController.notifyOtherPAPSToUpdateConfigurations("delete", null, policyEntity.getActionBodyEntity().getActionBodyName());
}
if(version > 1){
entity.setModifiedBy(userId);
controller.watchPolicyFunction(entity, policyNamewithExtension, "DeleteOne");
- String updatequery = "update PolicyVersion set active_version='"+highestVersion+"' , highest_version='"+highestVersion+"' where policy_name ='" +policyNamewithoutExtension.replace("\\", "\\\\")+"'";
+ String updatequery = "";
+ if(highestVersion != 0){
+ updatequery = "update PolicyVersion set active_version='"+highestVersion+"' , highest_version='"+highestVersion+"' where policy_name ='" +policyNamewithoutExtension.replace("\\", "\\\\")+"'";
+ }else{
+ updatequery = "delete from PolicyVersion where policy_name ='" +policyNamewithoutExtension.replace("\\", "\\\\")+"' and id >0";
+ }
controller.executeQuery(updatequery);
}else{
String policyVersionQuery = "delete from PolicyVersion where policy_name ='" +policyNamewithoutExtension.replace("\\", "\\\\")+"' and id >0";
}
}
}else{
- List<String> activePoliciesInPDP = new ArrayList<String>();
+ List<String> activePoliciesInPDP = new ArrayList<>();
if(!policyEntityobjects.isEmpty()){
for(Object object : policyEntityobjects){
policyEntity = (PolicyEntity) object;
if(policyNamewithoutExtension.contains("Config_")){
Files.deleteIfExists(Paths.get(PolicyController.getConfigHome() + File.separator + policyEntity.getConfigurationData().getConfigurationName()));
controller.deleteData(policyEntity.getConfigurationData());
+ restController.notifyOtherPAPSToUpdateConfigurations("delete", null, policyEntity.getConfigurationData().getConfigurationName());
}else if(policyNamewithoutExtension.contains("Action_")){
Files.deleteIfExists(Paths.get(PolicyController.getActionHome() + File.separator + policyEntity.getActionBodyEntity().getActionBodyName()));
controller.deleteData(policyEntity.getActionBodyEntity());
+ restController.notifyOtherPAPSToUpdateConfigurations("delete", null, policyEntity.getActionBodyEntity().getActionBodyName());
}
}
}