X-Git-Url: https://gerrit.onap.org/r/gitweb?a=blobdiff_plain;f=ONAP-PAP-REST%2Fsrc%2Fmain%2Fjava%2Forg%2Fonap%2Fpolicy%2Fpap%2Fxacml%2Frest%2Fcomponents%2FPolicyDBDao.java;h=b2fb3e5a8d9f543f96a6495eeb1035cfb33f2ec6;hb=49c6b1bf604c3450b729dc348af36ee3af79589b;hp=7591781ffb57afe8ee1a05953bb488e9be54e563;hpb=b6bae924c4a794cd772ac1524089fc8739e310b1;p=policy%2Fengine.git diff --git a/ONAP-PAP-REST/src/main/java/org/onap/policy/pap/xacml/rest/components/PolicyDBDao.java b/ONAP-PAP-REST/src/main/java/org/onap/policy/pap/xacml/rest/components/PolicyDBDao.java index 7591781ff..b2fb3e5a8 100644 --- a/ONAP-PAP-REST/src/main/java/org/onap/policy/pap/xacml/rest/components/PolicyDBDao.java +++ b/ONAP-PAP-REST/src/main/java/org/onap/policy/pap/xacml/rest/components/PolicyDBDao.java @@ -69,7 +69,6 @@ import javax.xml.parsers.DocumentBuilderFactory; import javax.xml.xpath.XPath; import javax.xml.xpath.XPathFactory; -import org.apache.commons.io.FileUtils; import org.apache.commons.io.FilenameUtils; import org.apache.commons.io.IOUtils; import org.onap.policy.common.logging.eelf.MessageCodes; @@ -93,7 +92,6 @@ import org.onap.policy.xacml.api.pap.OnapPDPGroup; import org.onap.policy.xacml.api.pap.PAPPolicyEngine; import org.onap.policy.xacml.std.pap.StdPDPGroup; import org.onap.policy.xacml.std.pap.StdPDPPolicy; -import org.onap.policy.xacml.util.XACMLPolicyScanner; import org.onap.policy.xacml.util.XACMLPolicyWriter; import org.w3c.dom.Document; import org.xml.sax.InputSource; @@ -1219,13 +1217,12 @@ public class PolicyDBDao { groupQuery.setParameter("groupId", group.getId()); groupQuery.setParameter("deleted", false); List groupQueryList = groupQuery.getResultList(); - if(groupQueryList!=null){ + if(groupQueryList!=null && !groupQueryList.isEmpty()){ GroupEntity dbgroup = (GroupEntity)groupQueryList.get(0); updatedGroup = synchronizeGroupPoliciesInFileSystem(group, dbgroup); + logger.info("Group was updated during file system audit: " + updatedGroup.toString()); } - } catch (PAPException e) { - logger.error(e); - } catch (PolicyDBException e) { + } catch (PAPException | PolicyDBException e) { logger.error(e); } catch (Exception e) { logger.error(e); @@ -1236,7 +1233,6 @@ public class PolicyDBDao { em.getTransaction().commit(); em.close(); - logger.info("Group was updated during file system audit: " + updatedGroup.toString()); return updatedGroup; } @@ -2843,7 +2839,8 @@ public class PolicyDBDao { try{ while(policyIt.hasNext()){ PolicyEntity pol = policyIt.next(); - if(getPolicyNameAndVersionFromPolicyFileName(pol.getPolicyName())[0].equals(policyName)){ + if(policy.getScope().equals(pol.getScope()) && + getPolicyNameAndVersionFromPolicyFileName(pol.getPolicyName())[0].equals(policyName)) { policyIt.remove(); } }