- if(!policyEntityobjects.isEmpty()){
- for(Object object : policyEntityobjects){
- policyEntity = (PolicyEntity) object;
- String groupEntityquery = "from PolicyGroupEntity where policyid = :policyEntityId";
- SimpleBindings geParams = new SimpleBindings();
- geParams.put("policyEntityId", policyEntity.getPolicyId());
- List<Object> groupobject = controller.getDataByQuery(groupEntityquery, geParams);
- if(!groupobject.isEmpty()){
- pdpCheck = true;
- activePoliciesInPDP.add(policyEntity.getScope()+"."+policyEntity.getPolicyName());
- }else{
- //Delete the entity from Elastic Search Database
- String searchFileName = policyEntity.getScope() + "." + policyEntity.getPolicyName();
- restController.deleteElasticData(searchFileName);
- //Delete the entity from Policy Entity table
- controller.deleteData(policyEntity);
- policyNamewithoutExtension = policyEntity.getPolicyName();
- 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(policyEntityobjects.isEmpty()){
+ String policyScopeQuery = "delete PolicyEditorScopes where SCOPENAME like '"+path.replace(BACKSLASH, ESCAPE_BACKSLASH)+"%' and id >0";
+ controller.executeQuery(policyScopeQuery);
+ return success();
+ }
+ for(Object object : policyEntityobjects){
+ policyEntity = (PolicyEntity) object;
+ String groupEntityquery = "from PolicyGroupEntity where policyid = :policyEntityId";
+ SimpleBindings geParams = new SimpleBindings();
+ geParams.put("policyEntityId", policyEntity.getPolicyId());
+ List<Object> groupobject = controller.getDataByQuery(groupEntityquery, geParams);
+ if(!groupobject.isEmpty()){
+ pdpCheck = true;
+ activePoliciesInPDP.add(policyEntity.getScope()+"."+policyEntity.getPolicyName());
+ }else{
+ //Delete the entity from Elastic Search Database
+ String searchFileName = policyEntity.getScope() + "." + policyEntity.getPolicyName();
+ restController.deleteElasticData(searchFileName);
+ //Delete the entity from Policy Entity table
+ controller.deleteData(policyEntity);
+ policyNamewithoutExtension = policyEntity.getPolicyName();
+ 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());