X-Git-Url: https://gerrit.onap.org/r/gitweb?p=policy%2Fengine.git;a=blobdiff_plain;f=ONAP-PAP-REST%2Fsrc%2Fmain%2Fjava%2Forg%2Fonap%2Fpolicy%2Fpap%2Fxacml%2Frest%2Fdaoimpl%2FCommonClassDaoImpl.java;h=ee5c22f1c963544286a02521d8b3db34dc30ed31;hp=2688d7d3c74f53cd2ea0be86f63d7fd31785f692;hb=1e61676b77dd09659027b8984f050df7e8538526;hpb=f18fbfc026de9cf02126f57844c37abfee607394 diff --git a/ONAP-PAP-REST/src/main/java/org/onap/policy/pap/xacml/rest/daoimpl/CommonClassDaoImpl.java b/ONAP-PAP-REST/src/main/java/org/onap/policy/pap/xacml/rest/daoimpl/CommonClassDaoImpl.java index 2688d7d3c..ee5c22f1c 100644 --- a/ONAP-PAP-REST/src/main/java/org/onap/policy/pap/xacml/rest/daoimpl/CommonClassDaoImpl.java +++ b/ONAP-PAP-REST/src/main/java/org/onap/policy/pap/xacml/rest/daoimpl/CommonClassDaoImpl.java @@ -22,7 +22,9 @@ package org.onap.policy.pap.xacml.rest.daoimpl; import java.util.List; import java.util.Map; + import javax.script.SimpleBindings; + import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; import org.hibernate.Criteria; @@ -51,10 +53,8 @@ public class CommonClassDaoImpl implements CommonClassDao { private static final Log LOGGER = LogFactory.getLog(CommonClassDaoImpl.class); - private static SessionFactory sessionFactory; - @Autowired private CommonClassDaoImpl(SessionFactory sessionFactory) { CommonClassDaoImpl.sessionFactory = sessionFactory; @@ -78,14 +78,12 @@ public class CommonClassDaoImpl implements CommonClassDao { try { session.close(); } catch (Exception e) { - LOGGER.error(XACMLErrorConstants.ERROR_PROCESS_FLOW - + "Error While Closing Connection/Statement" + e); + LOGGER.error(XACMLErrorConstants.ERROR_PROCESS_FLOW + "Error While Closing Connection/Statement" + e); } } return data; } - @SuppressWarnings({"rawtypes", "unchecked"}) @Override public List getDataById(Class className, String columnName, String key) { @@ -109,8 +107,7 @@ public class CommonClassDaoImpl implements CommonClassDao { try { session.close(); } catch (Exception e1) { - LOGGER.error(XACMLErrorConstants.ERROR_PROCESS_FLOW - + "Error While Closing Connection/Statement" + e1); + LOGGER.error(XACMLErrorConstants.ERROR_PROCESS_FLOW + "Error While Closing Connection/Statement" + e1); } } return data; @@ -131,8 +128,7 @@ public class CommonClassDaoImpl implements CommonClassDao { try { session.close(); } catch (Exception e) { - LOGGER.error(XACMLErrorConstants.ERROR_PROCESS_FLOW - + "Error While Closing Connection/Statement" + e); + LOGGER.error(XACMLErrorConstants.ERROR_PROCESS_FLOW + "Error While Closing Connection/Statement" + e); } } return data; @@ -146,14 +142,12 @@ public class CommonClassDaoImpl implements CommonClassDao { session.persist(entity); tx.commit(); } catch (Exception e) { - LOGGER.error(XACMLErrorConstants.ERROR_PROCESS_FLOW - + "Error While Saving data to Table" + e); + LOGGER.error(XACMLErrorConstants.ERROR_PROCESS_FLOW + "Error While Saving data to Table" + e); } finally { try { session.close(); } catch (Exception e1) { - LOGGER.error(XACMLErrorConstants.ERROR_PROCESS_FLOW - + "Error While Closing Connection/Statement" + e1); + LOGGER.error(XACMLErrorConstants.ERROR_PROCESS_FLOW + "Error While Closing Connection/Statement" + e1); } } @@ -167,20 +161,17 @@ public class CommonClassDaoImpl implements CommonClassDao { session.delete(entity); tx.commit(); } catch (Exception e) { - LOGGER.error(XACMLErrorConstants.ERROR_PROCESS_FLOW - + "Error While Deleting data from Table" + e); + LOGGER.error(XACMLErrorConstants.ERROR_PROCESS_FLOW + "Error While Deleting data from Table" + e); } finally { try { session.close(); } catch (Exception e1) { - LOGGER.error(XACMLErrorConstants.ERROR_PROCESS_FLOW - + "Error While Closing Connection/Statement" + e1); + LOGGER.error(XACMLErrorConstants.ERROR_PROCESS_FLOW + "Error While Closing Connection/Statement" + e1); } } } - @Override public void update(Object entity) { Session session = sessionFactory.openSession(); @@ -189,20 +180,17 @@ public class CommonClassDaoImpl implements CommonClassDao { session.update(entity); tx.commit(); } catch (Exception e) { - LOGGER.error(XACMLErrorConstants.ERROR_PROCESS_FLOW - + "Error While Updating data to Table" + e); + LOGGER.error(XACMLErrorConstants.ERROR_PROCESS_FLOW + "Error While Updating data to Table" + e); } finally { try { session.close(); } catch (Exception e1) { - LOGGER.error(XACMLErrorConstants.ERROR_PROCESS_FLOW - + "Error While Closing Connection/Statement" + e1); + LOGGER.error(XACMLErrorConstants.ERROR_PROCESS_FLOW + "Error While Closing Connection/Statement" + e1); } } } - @SuppressWarnings({"unchecked", "rawtypes"}) @Override public List checkDuplicateEntry(String value, String columnName, Class className) { @@ -231,20 +219,18 @@ public class CommonClassDaoImpl implements CommonClassDao { data = cr.list(); tx.commit(); } catch (Exception e) { - LOGGER.error(XACMLErrorConstants.ERROR_PROCESS_FLOW - + "Error While Querying for Duplicate Entries for Table" + e + className); + LOGGER.error(XACMLErrorConstants.ERROR_PROCESS_FLOW + "Error While Querying for Duplicate Entries for Table" + + e + className); } finally { try { session.close(); } catch (Exception e1) { - LOGGER.error(XACMLErrorConstants.ERROR_PROCESS_FLOW - + "Error While Closing Connection/Statement" + e1); + LOGGER.error(XACMLErrorConstants.ERROR_PROCESS_FLOW + "Error While Closing Connection/Statement" + e1); } } return data; } - @SuppressWarnings("unchecked") @Override public List getDataByQuery(String query, SimpleBindings params) { @@ -263,21 +249,18 @@ public class CommonClassDaoImpl implements CommonClassDao { data = hbquery.list(); tx.commit(); } catch (Exception e) { - LOGGER.error(XACMLErrorConstants.ERROR_PROCESS_FLOW - + "Error While Querying Database Table" + e); + LOGGER.error(XACMLErrorConstants.ERROR_PROCESS_FLOW + "Error While Querying Database Table" + e); throw e; } finally { try { session.close(); } catch (HibernateException e1) { - LOGGER.error(XACMLErrorConstants.ERROR_PROCESS_FLOW - + "Error While Closing Connection/Statement", e1); + LOGGER.error(XACMLErrorConstants.ERROR_PROCESS_FLOW + "Error While Closing Connection/Statement", e1); } } return data; } - @Override public void updateQuery(String query) { Session session = sessionFactory.openSession(); @@ -287,19 +270,16 @@ public class CommonClassDaoImpl implements CommonClassDao { hbquery.executeUpdate(); tx.commit(); } catch (Exception e) { - LOGGER.error(XACMLErrorConstants.ERROR_PROCESS_FLOW - + "Error While Updating Database Table" + e); + LOGGER.error(XACMLErrorConstants.ERROR_PROCESS_FLOW + "Error While Updating Database Table" + e); } finally { try { session.close(); } catch (Exception e1) { - LOGGER.error(XACMLErrorConstants.ERROR_PROCESS_FLOW - + "Error While Closing Connection/Statement" + e1); + LOGGER.error(XACMLErrorConstants.ERROR_PROCESS_FLOW + "Error While Closing Connection/Statement" + e1); } } } - @SuppressWarnings("rawtypes") @Override public Object getEntityItem(Class className, String columnName, String key) { @@ -320,20 +300,17 @@ public class CommonClassDaoImpl implements CommonClassDao { data = cr.list().get(0); tx.commit(); } catch (Exception e) { - LOGGER.error(XACMLErrorConstants.ERROR_PROCESS_FLOW - + "Error While Querying Database Table" + e); + LOGGER.error(XACMLErrorConstants.ERROR_PROCESS_FLOW + "Error While Querying Database Table" + e); } finally { try { session.close(); } catch (Exception e1) { - LOGGER.error(XACMLErrorConstants.ERROR_PROCESS_FLOW - + "Error While Closing Connection/Statement" + e1); + LOGGER.error(XACMLErrorConstants.ERROR_PROCESS_FLOW + "Error While Closing Connection/Statement" + e1); } } return data; } - @SuppressWarnings("unchecked") @Override public List getUserRoles() { @@ -355,20 +332,17 @@ public class CommonClassDaoImpl implements CommonClassDao { rolesData = cr.add(disjunction).list(); tx.commit(); } catch (Exception e) { - LOGGER.error(XACMLErrorConstants.ERROR_PROCESS_FLOW - + "Error While Querying PolicyRoles Table" + e); + LOGGER.error(XACMLErrorConstants.ERROR_PROCESS_FLOW + "Error While Querying PolicyRoles Table" + e); } finally { try { session.close(); } catch (Exception e1) { - LOGGER.error(XACMLErrorConstants.ERROR_PROCESS_FLOW - + "Error While Closing Connection/Statement" + e1); + LOGGER.error(XACMLErrorConstants.ERROR_PROCESS_FLOW + "Error While Closing Connection/Statement" + e1); } } return rolesData; } - @SuppressWarnings("unchecked") @Override public void updateClAlarms(String clName, String alarms) { @@ -384,14 +358,12 @@ public class CommonClassDaoImpl implements CommonClassDao { session.update(closedloop); tx.commit(); } catch (Exception e) { - LOGGER.error(XACMLErrorConstants.ERROR_PROCESS_FLOW - + "Error While Updating ClosedLoops Table" + e); + LOGGER.error(XACMLErrorConstants.ERROR_PROCESS_FLOW + "Error While Updating ClosedLoops Table" + e); } finally { session.close(); } } - @SuppressWarnings("unchecked") @Override public void updateClYaml(String clName, String yaml) { @@ -407,14 +379,12 @@ public class CommonClassDaoImpl implements CommonClassDao { session.update(closedloop); tx.commit(); } catch (Exception e) { - LOGGER.error(XACMLErrorConstants.ERROR_PROCESS_FLOW - + "Error While Updating ClosedLoops Table" + e); + LOGGER.error(XACMLErrorConstants.ERROR_PROCESS_FLOW + "Error While Updating ClosedLoops Table" + e); } finally { session.close(); } } - @SuppressWarnings("unchecked") @Override public void deleteAll() { @@ -438,8 +408,8 @@ public class CommonClassDaoImpl implements CommonClassDao { tx.commit(); } catch (Exception e) { - LOGGER.error(XACMLErrorConstants.ERROR_PROCESS_FLOW - + "Error while deleting ClosedLoops from the table" + e); + LOGGER.error( + XACMLErrorConstants.ERROR_PROCESS_FLOW + "Error while deleting ClosedLoops from the table" + e); } finally { session.close(); } @@ -447,8 +417,7 @@ public class CommonClassDaoImpl implements CommonClassDao { @SuppressWarnings({"unchecked"}) @Override - public List checkExistingGroupListforUpdate(String groupListValue, - String groupNameValue) { + public List checkExistingGroupListforUpdate(String groupListValue, String groupNameValue) { Session session = sessionFactory.openSession(); Transaction tx = session.beginTransaction(); List data = null; @@ -461,23 +430,20 @@ public class CommonClassDaoImpl implements CommonClassDao { tx.commit(); } catch (Exception e) { LOGGER.error(XACMLErrorConstants.ERROR_PROCESS_FLOW - + "Error While Querying for Duplicate Entries for GroupPolicyScopeList Table" - + e); + + "Error While Querying for Duplicate Entries for GroupPolicyScopeList Table" + e); } finally { try { session.close(); } catch (Exception e1) { - LOGGER.error(XACMLErrorConstants.ERROR_PROCESS_FLOW - + "Error While Closing Connection/Statement" + e1); + LOGGER.error(XACMLErrorConstants.ERROR_PROCESS_FLOW + "Error While Closing Connection/Statement" + e1); } } return data; } - @Override - public List getMultipleDataOnAddingConjunction( - @SuppressWarnings("rawtypes") Class className, String columnName, List data) { + public List getMultipleDataOnAddingConjunction(@SuppressWarnings("rawtypes") Class className, + String columnName, List data) { return null; }