diff options
Diffstat (limited to 'ECOMP-PAP-REST/src/main/java/org/openecomp/policy/pap/xacml/rest/daoimpl')
38 files changed, 432 insertions, 6019 deletions
diff --git a/ECOMP-PAP-REST/src/main/java/org/openecomp/policy/pap/xacml/rest/daoimpl/ActionListDaoImpl.java b/ECOMP-PAP-REST/src/main/java/org/openecomp/policy/pap/xacml/rest/daoimpl/ActionListDaoImpl.java deleted file mode 100644 index ba6c2c41e..000000000 --- a/ECOMP-PAP-REST/src/main/java/org/openecomp/policy/pap/xacml/rest/daoimpl/ActionListDaoImpl.java +++ /dev/null @@ -1,158 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * ECOMP-PAP-REST - * ================================================================================ - * Copyright (C) 2017 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. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============LICENSE_END========================================================= - */ - -package org.openecomp.policy.pap.xacml.rest.daoimpl; - -import java.util.ArrayList; -import java.util.List; - -import org.apache.commons.logging.Log; -import org.apache.commons.logging.LogFactory; -import org.hibernate.Criteria; -import org.hibernate.Session; -import org.hibernate.SessionFactory; -import org.hibernate.Transaction; -import org.openecomp.policy.pap.xacml.rest.HibernateSession; -import org.openecomp.policy.rest.dao.ActionListDao; -import org.openecomp.policy.rest.jpa.ActionList; -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.stereotype.Service; - -import org.openecomp.policy.xacml.api.XACMLErrorConstants; - -@Service("ActionListDao") -public class ActionListDaoImpl implements ActionListDao{ - - private static final Log logger = LogFactory.getLog(ActionListDaoImpl.class); - @Autowired - SessionFactory sessionfactory; - - public SessionFactory getSessionfactory() { - return sessionfactory; - } - - public void setSessionfactory(SessionFactory sessionfactory) { - this.sessionfactory = sessionfactory; - } - - @SuppressWarnings("unchecked") - @Override - public List<ActionList> getActionListData() { - Session session = HibernateSession.getSessionFactory(); - Transaction tx = session.beginTransaction(); - List<ActionList> actionListData = null; - try { - Criteria cr = session.createCriteria(ActionList.class); - actionListData = cr.list(); - tx.commit(); - } catch (Exception e) { - logger.error(XACMLErrorConstants.ERROR_PROCESS_FLOW + "Error While Querying ActionList Table"+e); - }finally{ - try{ - session.close(); - }catch(Exception e1){ - logger.error(XACMLErrorConstants.ERROR_PROCESS_FLOW + "Error While Closing Connection/Statement"+e1); - } - } - return actionListData; - - } - - @Override - public void Save(ActionList actionList) { - Session session = HibernateSession.getSessionFactory(); - Transaction tx = session.beginTransaction(); - try { - session.persist(actionList); - tx.commit(); - }catch(Exception e){ - logger.error(XACMLErrorConstants.ERROR_PROCESS_FLOW + "Error While Saving ActionList Table"+e); - }finally{ - try{ - session.close(); - }catch(Exception e1){ - logger.error(XACMLErrorConstants.ERROR_PROCESS_FLOW + "Error While Closing Connection/Statement"+e1); - } - } - - } - - @Override - public void delete(ActionList actionList) { - Session session = HibernateSession.getSessionFactory(); - Transaction tx = session.beginTransaction(); - try { - session.delete(actionList); - tx.commit(); - }catch(Exception e){ - logger.error(XACMLErrorConstants.ERROR_PROCESS_FLOW + "Error While Deleting ActionList Table"+e); - }finally{ - try{ - session.close(); - }catch(Exception e1){ - logger.error(XACMLErrorConstants.ERROR_PROCESS_FLOW + "Error While Closing Connection/Statement"+e1); - } - } - } - - @Override - public void update(ActionList actionList) { - Session session = HibernateSession.getSessionFactory(); - Transaction tx = session.beginTransaction(); - try { - session.update(actionList); - tx.commit(); - }catch(Exception e){ - logger.error(XACMLErrorConstants.ERROR_PROCESS_FLOW + "Error While Updating ActionList Table"+e); - }finally{ - try{ - session.close(); - }catch(Exception e1){ - logger.error(XACMLErrorConstants.ERROR_PROCESS_FLOW + "Error While Closing Connection/Statement"+e1); - } - } - - } - - @SuppressWarnings("unchecked") - @Override - public List<String> getActionListDataByName() { - Session session = HibernateSession.getSessionFactory(); - Transaction tx = session.beginTransaction(); - List<String> data = new ArrayList<String>(); - try { - Criteria cr = session.createCriteria(ActionList.class); - List<ActionList> actionListData = cr.list(); - for(int i = 0; i < actionListData.size(); i++){ - data.add(actionListData.get(i).getActionName()); - } - tx.commit(); - } catch (Exception e) { - logger.error(XACMLErrorConstants.ERROR_PROCESS_FLOW + "Error While Querying ActionList Table"+e); - }finally{ - try{ - session.close(); - }catch(Exception e1){ - logger.error(XACMLErrorConstants.ERROR_PROCESS_FLOW + "Error While Closing Connection/Statement"+e1); - } - } - return data; - } -} diff --git a/ECOMP-PAP-REST/src/main/java/org/openecomp/policy/pap/xacml/rest/daoimpl/ActionPolicyDictDaoImpl.java b/ECOMP-PAP-REST/src/main/java/org/openecomp/policy/pap/xacml/rest/daoimpl/ActionPolicyDictDaoImpl.java deleted file mode 100644 index 50d41fd02..000000000 --- a/ECOMP-PAP-REST/src/main/java/org/openecomp/policy/pap/xacml/rest/daoimpl/ActionPolicyDictDaoImpl.java +++ /dev/null @@ -1,185 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * ECOMP-PAP-REST - * ================================================================================ - * Copyright (C) 2017 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. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============LICENSE_END========================================================= - */ - -package org.openecomp.policy.pap.xacml.rest.daoimpl; - -import java.util.ArrayList; -import java.util.List; - -import org.apache.commons.logging.Log; -import org.apache.commons.logging.LogFactory; -import org.hibernate.Criteria; -import org.hibernate.Session; -import org.hibernate.SessionFactory; -import org.hibernate.Transaction; -import org.hibernate.criterion.Restrictions; -import org.openecomp.policy.pap.xacml.rest.HibernateSession; -import org.openecomp.policy.rest.dao.ActionPolicyDictDao; -import org.openecomp.policy.rest.jpa.ActionPolicyDict; -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.stereotype.Service; - -import org.openecomp.policy.xacml.api.XACMLErrorConstants; - - -@Service("ActionPolicyDictDao") -public class ActionPolicyDictDaoImpl implements ActionPolicyDictDao { - private static final Log logger = LogFactory.getLog(ActionPolicyDictDaoImpl.class); - @Autowired - SessionFactory sessionfactory; - - public SessionFactory getSessionfactory() { - return sessionfactory; - } - - public void setSessionfactory(SessionFactory sessionfactory) { - this.sessionfactory = sessionfactory; - } - - - @SuppressWarnings("unchecked") - @Override - public List<ActionPolicyDict> getActionDictData() { - Session session = HibernateSession.getSessionFactory(); - Transaction tx = session.beginTransaction(); - - List<ActionPolicyDict> actionDictData = null; - try { - Criteria cr = session.createCriteria(ActionPolicyDict.class); - actionDictData = cr.list(); - tx.commit(); - } catch (Exception e) { - logger.error(XACMLErrorConstants.ERROR_PROCESS_FLOW + "Error While Querying ActionDictionary Table"+e); - }finally{ - try{ - session.close(); - }catch(Exception e1){ - logger.error(XACMLErrorConstants.ERROR_PROCESS_FLOW + "Error While Closing Connection/Statement"+e1); - } - } - return actionDictData; - } - - @Override - public void Save(ActionPolicyDict action) { - Session session = HibernateSession.getSessionFactory(); - Transaction tx = session.beginTransaction(); - try { - session.persist(action); - tx.commit(); - }catch(Exception e){ - logger.error(XACMLErrorConstants.ERROR_PROCESS_FLOW + "Error While Saving ActionDictionary Table"+e); - }finally{ - try{ - session.close(); - }catch(Exception e1){ - logger.error(XACMLErrorConstants.ERROR_PROCESS_FLOW + "Error While Closing Connection/Statement"+e1); - } - } - } - - @Override - public void delete(ActionPolicyDict action) { - Session session = HibernateSession.getSessionFactory(); - Transaction tx = session.beginTransaction(); - try { - session.delete(action); - tx.commit(); - }catch(Exception e){ - logger.error(XACMLErrorConstants.ERROR_PROCESS_FLOW + "Error While Deleting ActionDictionary Table"+e); - }finally{ - try{ - session.close(); - }catch(Exception e1){ - logger.error(XACMLErrorConstants.ERROR_PROCESS_FLOW + "Error While Closing Connection/Statement"+e1); - } - } - } - - @Override - public void update(ActionPolicyDict action) { - Session session = HibernateSession.getSessionFactory(); - Transaction tx = session.beginTransaction(); - try { - session.update(action); - tx.commit(); - }catch(Exception e){ - logger.error(XACMLErrorConstants.ERROR_PROCESS_FLOW + "Error While Updating ActionDictionary Table"+e); - }finally{ - try{ - session.close(); - }catch(Exception e1){ - logger.error(XACMLErrorConstants.ERROR_PROCESS_FLOW + "Error While Closing Connection/Statement"+e1); - } - } - - } - - @SuppressWarnings("unchecked") - @Override - public List<String> getActionDictDataByName() { - Session session = HibernateSession.getSessionFactory(); - Transaction tx = session.beginTransaction(); - List<String> data = new ArrayList<String>(); - try { - Criteria cr = session.createCriteria(ActionPolicyDict.class); - List<ActionPolicyDict> attributeData = cr.list(); - for(int i = 0; i < attributeData.size(); i++){ - data.add(attributeData.get(i).getAttributeName()); - } - tx.commit(); - } catch (Exception e) { - logger.error(XACMLErrorConstants.ERROR_PROCESS_FLOW + "Error While Querying ActionDictionary Table"+e); - }finally{ - try{ - session.close(); - }catch(Exception e1){ - logger.error(XACMLErrorConstants.ERROR_PROCESS_FLOW + "Error While Closing Connection/Statement"+e1); - } - } - return data; - } - - @SuppressWarnings("unchecked") - @Override - public ActionPolicyDict getActionEntityDatabyId(String action) { - Session session = HibernateSession.getSessionFactory(); - Transaction tx = session.beginTransaction(); - ActionPolicyDict data = null; - try { - Criteria cr = session.createCriteria(ActionPolicyDict.class); - List<ActionPolicyDict> attributeData = cr.add(Restrictions.eq("attributeName", action)).list(); - for(Object entity : attributeData){ - data = (ActionPolicyDict) entity; - } - tx.commit(); - } catch (Exception e) { - logger.error(XACMLErrorConstants.ERROR_PROCESS_FLOW + "Error While Querying ActionDictionary Table"+e); - }finally{ - try{ - session.close(); - }catch(Exception e1){ - logger.error(XACMLErrorConstants.ERROR_PROCESS_FLOW + "Error While Closing Connection/Statement"+e1); - } - } - return data; - } - -} diff --git a/ECOMP-PAP-REST/src/main/java/org/openecomp/policy/pap/xacml/rest/daoimpl/AddressGroupDaoImpl.java b/ECOMP-PAP-REST/src/main/java/org/openecomp/policy/pap/xacml/rest/daoimpl/AddressGroupDaoImpl.java deleted file mode 100644 index 951a38a28..000000000 --- a/ECOMP-PAP-REST/src/main/java/org/openecomp/policy/pap/xacml/rest/daoimpl/AddressGroupDaoImpl.java +++ /dev/null @@ -1,157 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * ECOMP-PAP-REST - * ================================================================================ - * Copyright (C) 2017 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. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============LICENSE_END========================================================= - */ - -package org.openecomp.policy.pap.xacml.rest.daoimpl; - -import java.util.ArrayList; -import java.util.List; - -import org.apache.commons.logging.Log; -import org.apache.commons.logging.LogFactory; -import org.hibernate.Criteria; -import org.hibernate.Session; -import org.hibernate.SessionFactory; -import org.hibernate.Transaction; -import org.openecomp.policy.pap.xacml.rest.HibernateSession; -import org.openecomp.policy.rest.dao.AddressGroupDao; -import org.openecomp.policy.rest.jpa.AddressGroup; -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.stereotype.Service; - -import org.openecomp.policy.xacml.api.XACMLErrorConstants; - -@Service("AddressGroupDao") -public class AddressGroupDaoImpl implements AddressGroupDao{ - private static final Log logger = LogFactory.getLog(AddressGroupDaoImpl.class); - @Autowired - SessionFactory sessionfactory; - - public SessionFactory getSessionfactory() { - return sessionfactory; - } - - public void setSessionfactory(SessionFactory sessionfactory) { - this.sessionfactory = sessionfactory; - } - - @SuppressWarnings("unchecked") - @Override - public List<AddressGroup> getAddressGroupData() { - Session session = HibernateSession.getSessionFactory(); - Transaction tx = session.beginTransaction(); - List<AddressGroup> attributeData = null; - try { - Criteria cr = session.createCriteria(AddressGroup.class); - attributeData = cr.list(); - tx.commit(); - } catch (Exception e) { - logger.error(XACMLErrorConstants.ERROR_PROCESS_FLOW + "Error While Querying AddressGroup Table"+e); - }finally{ - try{ - session.close(); - }catch(Exception e1){ - logger.error(XACMLErrorConstants.ERROR_PROCESS_FLOW + "Error While Closing Connection/Statement"+e1); - } - } - return attributeData; - - } - - @Override - public void Save(AddressGroup attribute) { - Session session = HibernateSession.getSessionFactory(); - Transaction tx = session.beginTransaction(); - try { - session.persist(attribute); - tx.commit(); - }catch(Exception e){ - logger.error(XACMLErrorConstants.ERROR_PROCESS_FLOW + "Error While Saving AddressGroup Table"+e); - }finally{ - try{ - session.close(); - }catch(Exception e1){ - logger.error(XACMLErrorConstants.ERROR_PROCESS_FLOW + "Error While Closing Connection/Statement"+e1); - } - } - - } - - @Override - public void delete(AddressGroup attribute) { - Session session = HibernateSession.getSessionFactory(); - Transaction tx = session.beginTransaction(); - try { - session.delete(attribute); - tx.commit(); - }catch(Exception e){ - logger.error(XACMLErrorConstants.ERROR_PROCESS_FLOW + "Error While Deleting AddressGroup Table"+e); - }finally{ - try{ - session.close(); - }catch(Exception e1){ - logger.error(XACMLErrorConstants.ERROR_PROCESS_FLOW + "Error While Closing Connection/Statement"+e1); - } - } - } - - @Override - public void update(AddressGroup attribute) { - Session session = HibernateSession.getSessionFactory(); - Transaction tx = session.beginTransaction(); - try { - session.update(attribute); - tx.commit(); - }catch(Exception e){ - logger.error(XACMLErrorConstants.ERROR_PROCESS_FLOW + "Error While Updating AddressGroup Table"+e); - }finally{ - try{ - session.close(); - }catch(Exception e1){ - logger.error(XACMLErrorConstants.ERROR_PROCESS_FLOW + "Error While Closing Connection/Statement"+e1); - } - } - - } - - @SuppressWarnings("unchecked") - @Override - public List<String> getAddressGroupDataByName() { - Session session = HibernateSession.getSessionFactory(); - Transaction tx = session.beginTransaction(); - List<String> data = new ArrayList<String>(); - try { - Criteria cr = session.createCriteria(AddressGroup.class); - List<AddressGroup> attributeData = cr.list(); - for(int i = 0; i < attributeData.size(); i++){ - data.add(attributeData.get(i).getGroupName()); - } - tx.commit(); - } catch (Exception e) { - logger.error(XACMLErrorConstants.ERROR_PROCESS_FLOW + "Error While Querying AddressGroup Table"+e); - }finally{ - try{ - session.close(); - }catch(Exception e1){ - logger.error(XACMLErrorConstants.ERROR_PROCESS_FLOW + "Error While Closing Connection/Statement"+e1); - } - } - return data; - } -} diff --git a/ECOMP-PAP-REST/src/main/java/org/openecomp/policy/pap/xacml/rest/daoimpl/AttributeDaoImpl.java b/ECOMP-PAP-REST/src/main/java/org/openecomp/policy/pap/xacml/rest/daoimpl/AttributeDaoImpl.java deleted file mode 100644 index 7eb51d3f4..000000000 --- a/ECOMP-PAP-REST/src/main/java/org/openecomp/policy/pap/xacml/rest/daoimpl/AttributeDaoImpl.java +++ /dev/null @@ -1,157 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * ECOMP-PAP-REST - * ================================================================================ - * Copyright (C) 2017 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. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============LICENSE_END========================================================= - */ - -package org.openecomp.policy.pap.xacml.rest.daoimpl; - -import java.util.ArrayList; -import java.util.List; - -import org.apache.commons.logging.Log; -import org.apache.commons.logging.LogFactory; -import org.hibernate.Criteria; -import org.hibernate.Session; -import org.hibernate.SessionFactory; -import org.hibernate.Transaction; -import org.openecomp.policy.pap.xacml.rest.HibernateSession; -import org.openecomp.policy.rest.dao.AttributeDao; -import org.openecomp.policy.rest.jpa.Attribute; -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.stereotype.Service; - -import org.openecomp.policy.xacml.api.XACMLErrorConstants; - -@Service("AttributeDao") -public class AttributeDaoImpl implements AttributeDao { - private static final Log logger = LogFactory.getLog(AttributeDaoImpl.class); - @Autowired - SessionFactory sessionfactory; - - public SessionFactory getSessionfactory() { - return sessionfactory; - } - - public void setSessionfactory(SessionFactory sessionfactory) { - this.sessionfactory = sessionfactory; - } - - @SuppressWarnings("unchecked") - @Override - public List<Attribute> getData() { - Session session = HibernateSession.getSessionFactory(); - Transaction tx = session.beginTransaction(); - List<Attribute> attributeData = null; - try { - Criteria cr = session.createCriteria(Attribute.class); - attributeData = cr.list(); - tx.commit(); - } catch (Exception e) { - logger.error(XACMLErrorConstants.ERROR_PROCESS_FLOW + "Error While Querying Attribute Table"+e); - }finally{ - try{ - session.close(); - }catch(Exception e1){ - logger.error(XACMLErrorConstants.ERROR_PROCESS_FLOW + "Error While Closing Connection/Statement"+e1); - } - } - return attributeData; - - } - - @Override - public void Save(Attribute attribute) { - Session session = HibernateSession.getSessionFactory(); - Transaction tx = session.beginTransaction(); - try { - session.persist(attribute); - tx.commit(); - }catch(Exception e){ - logger.error(XACMLErrorConstants.ERROR_PROCESS_FLOW + "Error While Saving Attribute Table"+e); - }finally{ - try{ - session.close(); - }catch(Exception e1){ - logger.error(XACMLErrorConstants.ERROR_PROCESS_FLOW + "Error While Closing Connection/Statement"+e1); - } - } - - } - - @Override - public void delete(Attribute attribute) { - Session session = HibernateSession.getSessionFactory(); - Transaction tx = session.beginTransaction(); - try { - session.delete(attribute); - tx.commit(); - }catch(Exception e){ - logger.error(XACMLErrorConstants.ERROR_PROCESS_FLOW + "Error While Deleting Attribute Table"+e); - }finally{ - try{ - session.close(); - }catch(Exception e1){ - logger.error(XACMLErrorConstants.ERROR_PROCESS_FLOW + "Error While Closing Connection/Statement"+e1); - } - } - } - - @Override - public void update(Attribute attribute) { - Session session = HibernateSession.getSessionFactory(); - Transaction tx = session.beginTransaction(); - try { - session.update(attribute); - tx.commit(); - }catch(Exception e){ - logger.error(XACMLErrorConstants.ERROR_PROCESS_FLOW + "Error While Updating Attribute Table"+e); - }finally{ - try{ - session.close(); - }catch(Exception e1){ - logger.error(XACMLErrorConstants.ERROR_PROCESS_FLOW + "Error While Closing Connection/Statement"+e1); - } - } - } - - @SuppressWarnings("unchecked") - @Override - public List<String> getAttributeData() { - Session session = HibernateSession.getSessionFactory(); - Transaction tx = session.beginTransaction(); - List<String> data = new ArrayList<String>(); - try { - Criteria cr = session.createCriteria(Attribute.class); - List<Attribute> attributeData = cr.list(); - for(int i = 0; i < attributeData.size(); i++){ - data.add(attributeData.get(i).getXacmlId()); - } - tx.commit(); - } catch (Exception e) { - logger.error(XACMLErrorConstants.ERROR_PROCESS_FLOW + "Error While Querying Attribute Table"+e); - }finally{ - try{ - session.close(); - }catch(Exception e1){ - logger.error(XACMLErrorConstants.ERROR_PROCESS_FLOW + "Error While Closing Connection/Statement"+e1); - } - } - return data; - } - -} diff --git a/ECOMP-PAP-REST/src/main/java/org/openecomp/policy/pap/xacml/rest/daoimpl/BRMSParamTemplateDaoImpl.java b/ECOMP-PAP-REST/src/main/java/org/openecomp/policy/pap/xacml/rest/daoimpl/BRMSParamTemplateDaoImpl.java deleted file mode 100644 index 4f8478da6..000000000 --- a/ECOMP-PAP-REST/src/main/java/org/openecomp/policy/pap/xacml/rest/daoimpl/BRMSParamTemplateDaoImpl.java +++ /dev/null @@ -1,157 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * ECOMP-PAP-REST - * ================================================================================ - * Copyright (C) 2017 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. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============LICENSE_END========================================================= - */ - -package org.openecomp.policy.pap.xacml.rest.daoimpl; - -import java.util.ArrayList; -import java.util.List; - -import org.apache.commons.logging.Log; -import org.apache.commons.logging.LogFactory; -import org.hibernate.Criteria; -import org.hibernate.Session; -import org.hibernate.SessionFactory; -import org.hibernate.Transaction; -import org.openecomp.policy.pap.xacml.rest.HibernateSession; -import org.openecomp.policy.rest.dao.BRMSParamTemplateDao; -import org.openecomp.policy.rest.jpa.BRMSParamTemplate; -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.stereotype.Service; - -import org.openecomp.policy.xacml.api.XACMLErrorConstants; - -@Service("BRMSParamTemplateDao") -public class BRMSParamTemplateDaoImpl implements BRMSParamTemplateDao{ - private static final Log logger = LogFactory.getLog(BRMSParamTemplateDaoImpl.class); - @Autowired - SessionFactory sessionfactory; - - public SessionFactory getSessionfactory() { - return sessionfactory; - } - - public void setSessionfactory(SessionFactory sessionfactory) { - this.sessionfactory = sessionfactory; - } - - @SuppressWarnings("unchecked") - @Override - public List<BRMSParamTemplate> getBRMSParamTemplateData() { - Session session = HibernateSession.getSessionFactory(); - Transaction tx = session.beginTransaction(); - List<BRMSParamTemplate> attributeData =null; - try { - Criteria cr = session.createCriteria(BRMSParamTemplate.class); - attributeData = cr.list(); - tx.commit(); - } catch (Exception e) { - logger.error(XACMLErrorConstants.ERROR_PROCESS_FLOW + "Error While Querying BRMSParamTemplate Table"+e); - }finally{ - try{ - session.close(); - }catch(Exception e1){ - logger.error(XACMLErrorConstants.ERROR_PROCESS_FLOW + "Error While Closing Connection/Statement"+e1); - } - } - return attributeData; - - } - - @Override - public void Save(BRMSParamTemplate attribute) { - Session session = HibernateSession.getSessionFactory(); - Transaction tx = session.beginTransaction(); - try { - session.persist(attribute); - tx.commit(); - }catch(Exception e){ - logger.error(XACMLErrorConstants.ERROR_PROCESS_FLOW + "Error While Saving BRMSParamTemplate Table"+e); - }finally{ - try{ - session.close(); - }catch(Exception e1){ - logger.error(XACMLErrorConstants.ERROR_PROCESS_FLOW + "Error While Closing Connection/Statement"+e1); - } - } - - } - - @Override - public void delete(BRMSParamTemplate attribute) { - Session session = HibernateSession.getSessionFactory(); - Transaction tx = session.beginTransaction(); - try { - session.delete(attribute); - tx.commit(); - }catch(Exception e){ - logger.error(XACMLErrorConstants.ERROR_PROCESS_FLOW + "Error While Deleting BRMSParamTemplate Table"+e); - }finally{ - try{ - session.close(); - }catch(Exception e1){ - logger.error(XACMLErrorConstants.ERROR_PROCESS_FLOW + "Error While Closing Connection/Statement"+e1); - } - } - } - - @Override - public void update(BRMSParamTemplate attribute) { - Session session = HibernateSession.getSessionFactory(); - Transaction tx = session.beginTransaction(); - try { - session.update(attribute); - tx.commit(); - }catch(Exception e){ - logger.error(XACMLErrorConstants.ERROR_PROCESS_FLOW + "Error While Updating BRMSParamTemplate Table"+e); - }finally{ - try{ - session.close(); - }catch(Exception e1){ - logger.error(XACMLErrorConstants.ERROR_PROCESS_FLOW + "Error While Closing Connection/Statement"+e1); - } - } - - } - - @SuppressWarnings("unchecked") - @Override - public List<String> getBRMSParamDataByName() { - Session session = HibernateSession.getSessionFactory(); - Transaction tx = session.beginTransaction(); - List<String> data = new ArrayList<String>(); - try { - Criteria cr = session.createCriteria(BRMSParamTemplate.class); - List<BRMSParamTemplate> attributeData = cr.list(); - for(int i = 0; i < attributeData.size(); i++){ - data.add(attributeData.get(i).getRuleName()); - } - tx.commit(); - } catch (Exception e) { - logger.error(XACMLErrorConstants.ERROR_PROCESS_FLOW + "Error While Querying BRMSParamTemplate Table"+e); - }finally{ - try{ - session.close(); - }catch(Exception e1){ - logger.error(XACMLErrorConstants.ERROR_PROCESS_FLOW + "Error While Closing Connection/Statement"+e1); - } - } - return data; - } -} diff --git a/ECOMP-PAP-REST/src/main/java/org/openecomp/policy/pap/xacml/rest/daoimpl/CategoryDaoImpl.java b/ECOMP-PAP-REST/src/main/java/org/openecomp/policy/pap/xacml/rest/daoimpl/CategoryDaoImpl.java deleted file mode 100644 index f3fcbf152..000000000 --- a/ECOMP-PAP-REST/src/main/java/org/openecomp/policy/pap/xacml/rest/daoimpl/CategoryDaoImpl.java +++ /dev/null @@ -1,76 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * ECOMP-PAP-REST - * ================================================================================ - * Copyright (C) 2017 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. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============LICENSE_END========================================================= - */ - -package org.openecomp.policy.pap.xacml.rest.daoimpl; - -import java.util.List; - -import org.apache.commons.logging.Log; -import org.apache.commons.logging.LogFactory; -import org.hibernate.Criteria; -import org.hibernate.Session; -import org.hibernate.SessionFactory; -import org.hibernate.Transaction; -import org.openecomp.policy.pap.xacml.rest.HibernateSession; -import org.openecomp.policy.rest.dao.CategoryDao; -import org.openecomp.policy.rest.jpa.Category; -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.stereotype.Service; - -import org.openecomp.policy.xacml.api.XACMLErrorConstants; - -@Service("CategoryDao") -public class CategoryDaoImpl implements CategoryDao { - private static final Log logger = LogFactory.getLog(CategoryDaoImpl.class); - - @Autowired - SessionFactory sessionfactory; - - public SessionFactory getSessionfactory() { - return sessionfactory; - } - - public void setSessionfactory(SessionFactory sessionfactory) { - this.sessionfactory = sessionfactory; - } - - @SuppressWarnings("unchecked") - @Override - public List<Category> getCategoryListData() { - Session session = HibernateSession.getSessionFactory(); - Transaction tx = session.beginTransaction(); - List<Category> categoryListData = null; - try { - Criteria cr = session.createCriteria(Category.class); - categoryListData = cr.list(); - tx.commit(); - } catch (Exception e) { - logger.error(XACMLErrorConstants.ERROR_PROCESS_FLOW + "Error While Querying Category Table"+e); - }finally{ - try{ - session.close(); - }catch(Exception e1){ - logger.error(XACMLErrorConstants.ERROR_PROCESS_FLOW + "Error While Closing Connection/Statement"+e1); - } - } - return categoryListData; - } - -} diff --git a/ECOMP-PAP-REST/src/main/java/org/openecomp/policy/pap/xacml/rest/daoimpl/CommonClassDaoImpl.java b/ECOMP-PAP-REST/src/main/java/org/openecomp/policy/pap/xacml/rest/daoimpl/CommonClassDaoImpl.java new file mode 100644 index 000000000..256d75f4d --- /dev/null +++ b/ECOMP-PAP-REST/src/main/java/org/openecomp/policy/pap/xacml/rest/daoimpl/CommonClassDaoImpl.java @@ -0,0 +1,432 @@ +/*- + * ============LICENSE_START======================================================= + * ECOMP-PAP-REST + * ================================================================================ + * Copyright (C) 2017 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. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============LICENSE_END========================================================= + */ + +package org.openecomp.policy.pap.xacml.rest.daoimpl; + +import java.util.List; + +import org.apache.commons.logging.Log; +import org.apache.commons.logging.LogFactory; +import org.hibernate.Criteria; +import org.hibernate.Query; +import org.hibernate.Session; +import org.hibernate.Transaction; +import org.hibernate.criterion.Conjunction; +import org.hibernate.criterion.Criterion; +import org.hibernate.criterion.Disjunction; +import org.hibernate.criterion.Projections; +import org.hibernate.criterion.Restrictions; +import org.openecomp.policy.pap.xacml.rest.HibernateSession; +import org.openecomp.policy.rest.dao.CommonClassDao; +import org.openecomp.policy.rest.jpa.ClosedLoops; +import org.openecomp.policy.rest.jpa.GroupPolicyScopeList; +import org.openecomp.policy.rest.jpa.PolicyRoles; +import org.openecomp.policy.xacml.api.XACMLErrorConstants; +import org.springframework.stereotype.Service; + +@Service("CommonClassDao") +public class CommonClassDaoImpl implements CommonClassDao{ + + private static final Log LOGGER = LogFactory.getLog(CommonClassDaoImpl.class); + + + + @SuppressWarnings({ "unchecked", "rawtypes" }) + @Override + public List<Object> getData(Class className) { + Session session = HibernateSession.getSessionFactory(); + List<Object> data = null; + try{ + Criteria cr = session.createCriteria(className); + data = cr.list(); + }catch(Exception e){ + LOGGER.error(XACMLErrorConstants.ERROR_PROCESS_FLOW + "Error While Querying Table"+e); + }finally{ + try{ + session.close(); + }catch(Exception e){ + LOGGER.error(XACMLErrorConstants.ERROR_PROCESS_FLOW + "Error While Closing Connection/Statement"+e); + } + } + return data; + } + + + @SuppressWarnings({ "rawtypes", "unchecked" }) + @Override + public List<Object> getDataById(Class className, String columnName, String key) { + Session session = HibernateSession.getSessionFactory(); + List<Object> data = null; + try { + Criteria cr = session.createCriteria(className); + if(columnName.contains(":") && key.contains(":")){ + String[] columns = columnName.split(":"); + String[] keys = key.split(":"); + for(int i=0; i < columns.length; i++){ + cr.add(Restrictions.eq(columns[i], keys[i])); + } + }else{ + cr.add(Restrictions.eq(columnName, key)); + } + data = cr.list(); + } catch (Exception e) { + LOGGER.error(XACMLErrorConstants.ERROR_PROCESS_FLOW + "Error While Querying Table"+e); + }finally{ + try{ + session.close(); + }catch(Exception e1){ + LOGGER.error(XACMLErrorConstants.ERROR_PROCESS_FLOW + "Error While Closing Connection/Statement"+e1); + } + } + return data; + } + + @SuppressWarnings({ "unchecked", "rawtypes" }) + @Override + public List<String> getDataByColumn(Class className, String columnName) { + Session session = HibernateSession.getSessionFactory(); + List<String> data = null; + try{ + Criteria cr = session.createCriteria(className); + cr.setProjection(Projections.property(columnName)); + data = cr.list(); + }catch(Exception e){ + LOGGER.error(XACMLErrorConstants.ERROR_PROCESS_FLOW + "Error While Querying Table"+e); + }finally{ + try{ + session.close(); + }catch(Exception e){ + LOGGER.error(XACMLErrorConstants.ERROR_PROCESS_FLOW + "Error While Closing Connection/Statement"+e); + } + } + return data; + } + + @Override + public void save(Object entity) { + Session session = HibernateSession.getSessionFactory(); + Transaction tx = session.beginTransaction(); + try { + session.persist(entity); + tx.commit(); + }catch(Exception 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); + } + } + + } + + @Override + public void delete(Object entity) { + Session session = HibernateSession.getSessionFactory(); + Transaction tx = session.beginTransaction(); + try { + session.delete(entity); + tx.commit(); + }catch(Exception 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); + } + } + + } + + + @Override + public void update(Object entity) { + Session session = HibernateSession.getSessionFactory(); + Transaction tx = session.beginTransaction(); + try { + session.update(entity); + tx.commit(); + }catch(Exception 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); + } + } + + } + + + @SuppressWarnings({ "unchecked", "rawtypes" }) + @Override + public List<Object> checkDuplicateEntry(String value, String columnName, Class className) { + Session session = HibernateSession.getSessionFactory(); + Transaction tx = session.beginTransaction(); + List<Object> data = null; + + String[] columnNames = null; + if(columnName != null && columnName.contains(":")){ + columnNames = columnName.split(":"); + } + String[] values = null; + if(value != null && value.contains(":")){ + values = value.split(":"); + } + try { + Criteria cr = session.createCriteria(className); + if(columnNames != null && values != null && columnNames.length == values.length){ + for (int i = 0; i < columnNames.length; i++){ + cr.add(Restrictions.eq(columnNames[i],values[i])); + } + }else{ + cr.add(Restrictions.eq(columnName,value)); + } + + data = cr.list(); + tx.commit(); + } catch (Exception e) { + 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); + } + } + return data; + } + + + @SuppressWarnings("unchecked") + @Override + public List<Object> getDataByQuery(String query) { + Session session = HibernateSession.getSessionFactory(); + Transaction tx = session.beginTransaction(); + List<Object> data = null; + try { + Query hbquery = session.createQuery(query); + data = hbquery.list(); + tx.commit(); + } catch (Exception 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); + } + } + return data; + } + + + @Override + public void updateQuery(String query) { + Session session = HibernateSession.getSessionFactory(); + Transaction tx = session.beginTransaction(); + try { + Query hbquery = session.createQuery(query); + hbquery.executeUpdate(); + tx.commit(); + } catch (Exception 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); + } + } + } + + + @SuppressWarnings("rawtypes") + @Override + public Object getEntityItem(Class className, String columnName, String key) { + Session session = HibernateSession.getSessionFactory(); + Transaction tx = session.beginTransaction(); + Object data = null; + try { + Criteria cr = session.createCriteria(className); + if(columnName.contains(":") && key.contains(":")){ + String[] columns = columnName.split(":"); + String[] keys = key.split(":"); + for(int i=0; i < columns.length; i++){ + cr.add(Restrictions.eq(columns[i], keys[i])); + } + }else{ + cr.add(Restrictions.eq(columnName, key)); + } + data = cr.list().get(0); + tx.commit(); + } catch (Exception 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); + } + } + return data; + } + + + @SuppressWarnings("unchecked") + @Override + public List<PolicyRoles> getUserRoles() { + Session session = HibernateSession.getSessionFactory(); + Transaction tx = session.beginTransaction(); + List<PolicyRoles> rolesData = null; + try { + Criteria cr = session.createCriteria(PolicyRoles.class); + Disjunction disjunction = Restrictions.disjunction(); + Conjunction conjunction1 = Restrictions.conjunction(); + conjunction1.add(Restrictions.eq("role", "admin")); + Conjunction conjunction2 = Restrictions.conjunction(); + conjunction2.add(Restrictions.eq("role", "editor")); + Conjunction conjunction3 = Restrictions.conjunction(); + conjunction3.add(Restrictions.eq("role", "guest")); + disjunction.add(conjunction1); + disjunction.add(conjunction2); + disjunction.add(conjunction3); + rolesData = cr.add(disjunction).list(); + tx.commit(); + } catch (Exception 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); + } + } + return rolesData; + } + + + @SuppressWarnings("unchecked") + @Override + public void updateClAlarms(String clName, String alarms) { + Session session = HibernateSession.getSessionFactory(); + List<ClosedLoops> closedloopsdata = null; + Transaction tx = session.beginTransaction(); + try { + Criteria cr = session.createCriteria(ClosedLoops.class); + cr.add(Restrictions.eq("closedLoopControlName",clName)); + closedloopsdata = cr.list(); + ClosedLoops closedloop = closedloopsdata.get(0); + closedloop.setAlarmConditions(alarms); + session.update(closedloop); + tx.commit(); + }catch(Exception 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) { + Session session = HibernateSession.getSessionFactory(); + List<ClosedLoops> closedloopsdata = null; + Transaction tx = session.beginTransaction(); + try { + Criteria cr = session.createCriteria(ClosedLoops.class); + cr.add(Restrictions.eq("closedLoopControlName",clName)); + closedloopsdata = cr.list(); + ClosedLoops closedloop = closedloopsdata.get(0); + closedloop.setYaml(yaml); + session.update(closedloop); + tx.commit(); + }catch(Exception e){ + LOGGER.error(XACMLErrorConstants.ERROR_PROCESS_FLOW + "Error While Updating ClosedLoops Table"+e); + }finally{ + session.close(); + } + } + + + @SuppressWarnings("unchecked") + @Override + public void deleteAll() { + Session session = HibernateSession.getSessionFactory(); + Transaction tx = session.beginTransaction(); + List<ClosedLoops> closedloopsdata = null; + try { + Criteria cr = session.createCriteria(ClosedLoops.class); + closedloopsdata = cr.list(); + + if(closedloopsdata!=null && !closedloopsdata.isEmpty()) { + LOGGER.info("ClosedLoops exist in the database, we need to delete them in our first step to buildCache()."); + for(int i=0; i > closedloopsdata.size(); i++) { + ClosedLoops cl = closedloopsdata.get(i); + session.delete(cl); + } + } else { + LOGGER.info("No ClosedLoops exist in the database, no need to delete."); + } + + tx.commit(); + }catch(Exception e) { + LOGGER.error(XACMLErrorConstants.ERROR_PROCESS_FLOW + "Error while deleting ClosedLoops from the table"+e); + }finally{ + session.close(); + } + } + + @SuppressWarnings({ "unchecked"}) + @Override + public List<Object> checkExistingGroupListforUpdate(String groupListValue, String groupNameValue) { + Session session = HibernateSession.getSessionFactory(); + Transaction tx = session.beginTransaction(); + List<Object> data = null; + try { + Criteria cr = session.createCriteria(GroupPolicyScopeList.class); + cr.add(Restrictions.eq("groupList",groupListValue)); + Criterion expression = Restrictions.eq("name", groupNameValue); + cr.add(Restrictions.not(expression)); + data = cr.list(); + tx.commit(); + } catch (Exception e) { + LOGGER.error(XACMLErrorConstants.ERROR_PROCESS_FLOW + "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); + } + } + return data; + } + + + @Override + public List<Object> getMultipleDataOnAddingConjunction(@SuppressWarnings("rawtypes") Class className, String columnName, List<String> data) { + return null; + } + +}
\ No newline at end of file diff --git a/ECOMP-PAP-REST/src/main/java/org/openecomp/policy/pap/xacml/rest/daoimpl/DCAEUUIDDaoImpl.java b/ECOMP-PAP-REST/src/main/java/org/openecomp/policy/pap/xacml/rest/daoimpl/DCAEUUIDDaoImpl.java deleted file mode 100644 index ddd4606f9..000000000 --- a/ECOMP-PAP-REST/src/main/java/org/openecomp/policy/pap/xacml/rest/daoimpl/DCAEUUIDDaoImpl.java +++ /dev/null @@ -1,157 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * ECOMP-PAP-REST - * ================================================================================ - * Copyright (C) 2017 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. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============LICENSE_END========================================================= - */ - -package org.openecomp.policy.pap.xacml.rest.daoimpl; - -import java.util.ArrayList; -import java.util.List; - -import org.apache.commons.logging.Log; -import org.apache.commons.logging.LogFactory; -import org.hibernate.Criteria; -import org.hibernate.Session; -import org.hibernate.SessionFactory; -import org.hibernate.Transaction; -import org.openecomp.policy.pap.xacml.rest.HibernateSession; -import org.openecomp.policy.rest.dao.DCAEUUIDDao; -import org.openecomp.policy.rest.jpa.DCAEuuid; -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.stereotype.Service; - -import org.openecomp.policy.xacml.api.XACMLErrorConstants; - -@Service("DCAEUUIDDao") -public class DCAEUUIDDaoImpl implements DCAEUUIDDao{ - private static final Log logger = LogFactory.getLog(DCAEUUIDDaoImpl.class); - @Autowired - SessionFactory sessionfactory; - - public SessionFactory getSessionfactory() { - return sessionfactory; - } - - public void setSessionfactory(SessionFactory sessionfactory) { - this.sessionfactory = sessionfactory; - } - - @SuppressWarnings("unchecked") - @Override - public List<DCAEuuid> getDCAEuuidData() { - Session session = HibernateSession.getSessionFactory(); - Transaction tx = session.beginTransaction(); - List<DCAEuuid> attributeData = null; - try { - Criteria cr = session.createCriteria(DCAEuuid.class); - attributeData = cr.list(); - tx.commit(); - } catch (Exception e) { - logger.error(XACMLErrorConstants.ERROR_PROCESS_FLOW + "Error While Querying DCAEUUID Table"+e); - }finally{ - try{ - session.close(); - }catch(Exception e1){ - logger.error(XACMLErrorConstants.ERROR_PROCESS_FLOW + "Error While Closing Connection/Statement"+e1); - } - } - return attributeData; - - } - - @Override - public void Save(DCAEuuid attribute) { - Session session = HibernateSession.getSessionFactory(); - Transaction tx = session.beginTransaction(); - try { - session.persist(attribute); - tx.commit(); - }catch(Exception e){ - logger.error(XACMLErrorConstants.ERROR_PROCESS_FLOW + "Error While Saving DCAEUUID Table"+e); - }finally{ - try{ - session.close(); - }catch(Exception e1){ - logger.error(XACMLErrorConstants.ERROR_PROCESS_FLOW + "Error While Closing Connection/Statement"+e1); - } - } - - } - - @Override - public void delete(DCAEuuid attribute) { - Session session = HibernateSession.getSessionFactory(); - Transaction tx = session.beginTransaction(); - try { - session.delete(attribute); - tx.commit(); - }catch(Exception e){ - logger.error(XACMLErrorConstants.ERROR_PROCESS_FLOW + "Error While Deleting DCAEUUID Table"+e); - }finally{ - try{ - session.close(); - }catch(Exception e1){ - logger.error(XACMLErrorConstants.ERROR_PROCESS_FLOW + "Error While Closing Connection/Statement"+e1); - } - } - } - - @Override - public void update(DCAEuuid attribute) { - Session session = HibernateSession.getSessionFactory(); - Transaction tx = session.beginTransaction(); - try { - session.update(attribute); - tx.commit(); - }catch(Exception e){ - logger.error(XACMLErrorConstants.ERROR_PROCESS_FLOW + "Error While Updating DCAEUUID Table"+e); - }finally{ - try{ - session.close(); - }catch(Exception e1){ - logger.error(XACMLErrorConstants.ERROR_PROCESS_FLOW + "Error While Closing Connection/Statement"+e1); - } - } - - } - - @SuppressWarnings("unchecked") - @Override - public List<String> getDCAEuuidDataByName() { - Session session = HibernateSession.getSessionFactory(); - Transaction tx = session.beginTransaction(); - List<String> data = new ArrayList<String>(); - try { - Criteria cr = session.createCriteria(DCAEuuid.class); - List<DCAEuuid> attributeData = cr.list(); - for(int i = 0; i < attributeData.size(); i++){ - data.add(attributeData.get(i).getName()); - } - tx.commit(); - } catch (Exception e) { - logger.error(XACMLErrorConstants.ERROR_PROCESS_FLOW + "Error While Querying DCAEUUID Table"+e); - }finally{ - try{ - session.close(); - }catch(Exception e1){ - logger.error(XACMLErrorConstants.ERROR_PROCESS_FLOW + "Error While Closing Connection/Statement"+e1); - } - } - return data; - } -} diff --git a/ECOMP-PAP-REST/src/main/java/org/openecomp/policy/pap/xacml/rest/daoimpl/DecisionPolicyDaoImpl.java b/ECOMP-PAP-REST/src/main/java/org/openecomp/policy/pap/xacml/rest/daoimpl/DecisionPolicyDaoImpl.java deleted file mode 100644 index 9762e1d34..000000000 --- a/ECOMP-PAP-REST/src/main/java/org/openecomp/policy/pap/xacml/rest/daoimpl/DecisionPolicyDaoImpl.java +++ /dev/null @@ -1,158 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * ECOMP-PAP-REST - * ================================================================================ - * Copyright (C) 2017 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. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============LICENSE_END========================================================= - */ - -package org.openecomp.policy.pap.xacml.rest.daoimpl; - -import java.util.ArrayList; -import java.util.List; - -import org.apache.commons.logging.Log; -import org.apache.commons.logging.LogFactory; -import org.hibernate.Criteria; -import org.hibernate.Session; -import org.hibernate.SessionFactory; -import org.hibernate.Transaction; -import org.openecomp.policy.pap.xacml.rest.HibernateSession; -import org.openecomp.policy.rest.dao.DecisionPolicyDao; -import org.openecomp.policy.rest.jpa.DecisionSettings; -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.stereotype.Service; - -import org.openecomp.policy.xacml.api.XACMLErrorConstants; - -@Service("DecisionSettingsDao") -public class DecisionPolicyDaoImpl implements DecisionPolicyDao{ - private static final Log logger = LogFactory.getLog(DecisionPolicyDaoImpl.class); - @Autowired - SessionFactory sessionfactory; - - public SessionFactory getSessionfactory() { - return sessionfactory; - } - - public void setSessionfactory(SessionFactory sessionfactory) { - this.sessionfactory = sessionfactory; - } - - @SuppressWarnings("unchecked") - @Override - public List<DecisionSettings> getDecisionSettingsData() { - Session session = HibernateSession.getSessionFactory(); - Transaction tx = session.beginTransaction(); - List<DecisionSettings> decisionSettingsData = null; - try { - Criteria cr = session.createCriteria(DecisionSettings.class); - decisionSettingsData = cr.list(); - tx.commit(); - } catch (Exception e) { - logger.error(XACMLErrorConstants.ERROR_PROCESS_FLOW + "Error While Querying DecisionSettings Table"+e); - }finally{ - try{ - session.close(); - }catch(Exception e1){ - logger.error(XACMLErrorConstants.ERROR_PROCESS_FLOW + "Error While Closing Connection/Statement"+e1); - } - } - return decisionSettingsData; - - } - - @Override - public void Save(DecisionSettings decisionSettings) { - Session session = HibernateSession.getSessionFactory(); - Transaction tx = session.beginTransaction(); - try { - session.persist(decisionSettings); - tx.commit(); - }catch(Exception e){ - logger.error(XACMLErrorConstants.ERROR_PROCESS_FLOW + "Error While Saving DecisionSettings Table"+e); - }finally{ - try{ - session.close(); - }catch(Exception e1){ - logger.error(XACMLErrorConstants.ERROR_PROCESS_FLOW + "Error While Closing Connection/Statement"+e1); - } - } - - } - - @Override - public void delete(DecisionSettings decisionSettings) { - Session session = HibernateSession.getSessionFactory(); - Transaction tx = session.beginTransaction(); - try { - session.delete(decisionSettings); - tx.commit(); - }catch(Exception e){ - logger.error(XACMLErrorConstants.ERROR_PROCESS_FLOW + "Error While Deleting DecisionSettings Table"+e); - }finally{ - try{ - session.close(); - }catch(Exception e1){ - logger.error(XACMLErrorConstants.ERROR_PROCESS_FLOW + "Error While Closing Connection/Statement"+e1); - } - } - } - - @Override - public void update(DecisionSettings decisionSettings) { - Session session = HibernateSession.getSessionFactory(); - Transaction tx = session.beginTransaction(); - try { - session.update(decisionSettings); - tx.commit(); - }catch(Exception e){ - logger.error(XACMLErrorConstants.ERROR_PROCESS_FLOW + "Error While Updating DecisionSettings Table"+e); - }finally{ - try{ - session.close(); - }catch(Exception e1){ - logger.error(XACMLErrorConstants.ERROR_PROCESS_FLOW + "Error While Closing Connection/Statement"+e1); - } - } - } - - @SuppressWarnings("unchecked") - @Override - public List<String> getDecisionDataByName() { - Session session = HibernateSession.getSessionFactory(); - Transaction tx = session.beginTransaction(); - List<String> data = new ArrayList<String>(); - try { - Criteria cr = session.createCriteria(DecisionSettings.class); - List<DecisionSettings> decisionSettingsData = cr.list(); - for(int i = 0; i < decisionSettingsData.size(); i++){ - data.add(decisionSettingsData.get(i).getXacmlId()); - } - tx.commit(); - } catch (Exception e) { - logger.error(XACMLErrorConstants.ERROR_PROCESS_FLOW + "Error While Querying DecisionSettings Table"+e); - }finally{ - try{ - session.close(); - }catch(Exception e1){ - logger.error(XACMLErrorConstants.ERROR_PROCESS_FLOW + "Error While Closing Connection/Statement"+e1); - } - } - return data; - } - - -} diff --git a/ECOMP-PAP-REST/src/main/java/org/openecomp/policy/pap/xacml/rest/daoimpl/DescriptiveScopeDaoImpl.java b/ECOMP-PAP-REST/src/main/java/org/openecomp/policy/pap/xacml/rest/daoimpl/DescriptiveScopeDaoImpl.java deleted file mode 100644 index 8d286859c..000000000 --- a/ECOMP-PAP-REST/src/main/java/org/openecomp/policy/pap/xacml/rest/daoimpl/DescriptiveScopeDaoImpl.java +++ /dev/null @@ -1,182 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * ECOMP-PAP-REST - * ================================================================================ - * Copyright (C) 2017 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. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============LICENSE_END========================================================= - */ - -package org.openecomp.policy.pap.xacml.rest.daoimpl; - -import java.util.ArrayList; -import java.util.List; - -import org.apache.commons.logging.Log; -import org.apache.commons.logging.LogFactory; -import org.hibernate.Criteria; -import org.hibernate.Session; -import org.hibernate.SessionFactory; -import org.hibernate.Transaction; -import org.hibernate.criterion.Restrictions; -import org.openecomp.policy.pap.xacml.rest.HibernateSession; -import org.openecomp.policy.rest.dao.DescriptiveScopeDao; -import org.openecomp.policy.rest.jpa.DescriptiveScope; -import org.openecomp.policy.rest.jpa.PolicyVersion; -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.stereotype.Service; - -import org.openecomp.policy.xacml.api.XACMLErrorConstants; - -@Service("DescriptiveScopeDao") -public class DescriptiveScopeDaoImpl implements DescriptiveScopeDao{ - private static final Log logger = LogFactory.getLog(DescriptiveScopeDaoImpl.class); - @Autowired - SessionFactory sessionfactory; - - public SessionFactory getSessionfactory() { - return sessionfactory; - } - - public void setSessionfactory(SessionFactory sessionfactory) { - this.sessionfactory = sessionfactory; - } - - @SuppressWarnings("unchecked") - @Override - public List<DescriptiveScope> getDescriptiveScope() { - Session session = HibernateSession.getSessionFactory(); - Transaction tx = session.beginTransaction(); - List<DescriptiveScope> descriptiveScopeData = null; - try { - Criteria cr = session.createCriteria(DescriptiveScope.class); - descriptiveScopeData = cr.list(); - tx.commit(); - } catch (Exception e) { - logger.error(XACMLErrorConstants.ERROR_PROCESS_FLOW + "Error While Querying DescriptiveScope Table"+e); - }finally{ - try{ - session.close(); - }catch(Exception e1){ - logger.error(XACMLErrorConstants.ERROR_PROCESS_FLOW + "Error While Closing Connection/Statement"+e1); - } - } - return descriptiveScopeData; - } - - @Override - public void Save(DescriptiveScope descriptiveScope) { - Session session = HibernateSession.getSessionFactory(); - Transaction tx = session.beginTransaction(); - try { - session.persist(descriptiveScope); - tx.commit(); - }catch(Exception e){ - logger.error(XACMLErrorConstants.ERROR_PROCESS_FLOW + "Error While Saving DescriptiveScope Table"+e); - }finally{ - try{ - session.close(); - }catch(Exception e1){ - logger.error(XACMLErrorConstants.ERROR_PROCESS_FLOW + "Error While Closing Connection/Statement"+e1); - } - } - - } - - @Override - public void delete(DescriptiveScope descriptiveScope) { - Session session = HibernateSession.getSessionFactory(); - Transaction tx = session.beginTransaction(); - try { - session.delete(descriptiveScope); - tx.commit(); - }catch(Exception e){ - logger.error(XACMLErrorConstants.ERROR_PROCESS_FLOW + "Error While Deleting DescriptiveScope Table"+e); - }finally{ - try{ - session.close(); - }catch(Exception e1){ - logger.error(XACMLErrorConstants.ERROR_PROCESS_FLOW + "Error While Closing Connection/Statement"+e1); - } - } - - } - - @Override - public void update(DescriptiveScope descriptiveScope) { - Session session = HibernateSession.getSessionFactory(); - Transaction tx = session.beginTransaction(); - try { - session.update(descriptiveScope); - tx.commit(); - }catch(Exception e){ - logger.error(XACMLErrorConstants.ERROR_PROCESS_FLOW + "Error While Updating DescriptiveScope Table"+e); - }finally{ - try{ - session.close(); - }catch(Exception e1){ - logger.error(XACMLErrorConstants.ERROR_PROCESS_FLOW + "Error While Closing Connection/Statement"+e1); - } - } - - } - - @SuppressWarnings("unchecked") - @Override - public List<String> getDescriptiveScopeDataByName() { - Session session = HibernateSession.getSessionFactory(); - Transaction tx = session.beginTransaction(); - List<String> data = new ArrayList<String>(); - try { - Criteria cr = session.createCriteria(DescriptiveScope.class); - List<DescriptiveScope> descriptiveScopeData = cr.list(); - for(int i = 0; i < descriptiveScopeData.size(); i++){ - data.add(descriptiveScopeData.get(i).getScopeName()); - } - tx.commit(); - } catch (Exception e) { - logger.error(XACMLErrorConstants.ERROR_PROCESS_FLOW + "Error While Querying DescriptiveScope Table"+e); - }finally{ - try{ - session.close(); - }catch(Exception e1){ - logger.error(XACMLErrorConstants.ERROR_PROCESS_FLOW + "Error While Closing Connection/Statement"+e1); - } - } - return data; - } - - @Override - public DescriptiveScope getDescriptiveScopeById(String name) { - Session session = HibernateSession.getSessionFactory(); - Transaction tx = session.beginTransaction(); - DescriptiveScope data = null; - try { - Criteria cr = session.createCriteria(DescriptiveScope.class); - cr.add(Restrictions.eq("scopename",name)); - data = (DescriptiveScope) cr.list().get(0); - tx.commit(); - } catch (Exception e) { - logger.error(XACMLErrorConstants.ERROR_PROCESS_FLOW + "Error While Querying DescriptiveScope Table"+e); - }finally{ - try{ - session.close(); - }catch(Exception e1){ - logger.error(XACMLErrorConstants.ERROR_PROCESS_FLOW + "Error While Closing Connection/Statement"+e1); - } - } - return data; - } - -} diff --git a/ECOMP-PAP-REST/src/main/java/org/openecomp/policy/pap/xacml/rest/daoimpl/EcompNameDaoImpl.java b/ECOMP-PAP-REST/src/main/java/org/openecomp/policy/pap/xacml/rest/daoimpl/EcompNameDaoImpl.java deleted file mode 100644 index 9bafc3a5c..000000000 --- a/ECOMP-PAP-REST/src/main/java/org/openecomp/policy/pap/xacml/rest/daoimpl/EcompNameDaoImpl.java +++ /dev/null @@ -1,167 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * ECOMP-PAP-REST - * ================================================================================ - * Copyright (C) 2017 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. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============LICENSE_END========================================================= - */ - -package org.openecomp.policy.pap.xacml.rest.daoimpl; - -import java.util.ArrayList; -import java.util.List; - -import org.apache.commons.logging.Log; -import org.apache.commons.logging.LogFactory; -import org.hibernate.Criteria; -import org.hibernate.Session; -import org.hibernate.SessionFactory; -import org.hibernate.Transaction; -import org.openecomp.policy.pap.xacml.rest.HibernateSession; -import org.openecomp.policy.rest.dao.EcompNameDao; -import org.openecomp.policy.rest.jpa.EcompName; -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.stereotype.Service; - -import org.openecomp.policy.xacml.api.XACMLErrorConstants; - -@Service("EcompNameDao") -public class EcompNameDaoImpl implements EcompNameDao { - private static final Log logger = LogFactory.getLog(EcompNameDaoImpl.class); - @Autowired - SessionFactory sessionfactory; - - public SessionFactory getSessionfactory() { - return sessionfactory; - } - - public void setSessionfactory(SessionFactory sessionfactory) { - this.sessionfactory = sessionfactory; - } - - @SuppressWarnings("unchecked") - @Override - public List<EcompName> getEcompName() { - System.out.println("EcompNameDaoImpl: getEcompName() is called"); - logger.debug("EcompNameDaoImpl: getEcompName() is called"); - Session session = HibernateSession.getSessionFactory(); - Transaction tx = session.beginTransaction(); - List<EcompName> ecompNameData = null; - try { - Criteria cr = session.createCriteria(EcompName.class); - ecompNameData = cr.list(); - System.out.println("Data returned from ecompname table"+ecompNameData.toString()); - logger.debug("Data returned from ecompname table: " + ecompNameData.toString()); - tx.commit(); - } catch (Exception e) { - System.out.println("Exception Occured while Querying ecompname"+e); - logger.error(XACMLErrorConstants.ERROR_PROCESS_FLOW + "Error While Querying EcompName Table"+e); - }finally{ - try{ - session.close(); - }catch(Exception e1){ - logger.error(XACMLErrorConstants.ERROR_PROCESS_FLOW + "Error While Closing Connection/Statement"+e1); - } - } - return ecompNameData; - } - - @Override - public void Save(EcompName ecompName) { - System.out.println("EcompNameDaoImpl: Save() is called"); - logger.debug("EcompNameDaoImpl: Save() is called"); - Session session = HibernateSession.getSessionFactory(); - Transaction tx = session.beginTransaction(); - try { - session.persist(ecompName); - tx.commit(); - }catch(Exception e){ - logger.error(XACMLErrorConstants.ERROR_PROCESS_FLOW + "Error While Saving EcompName Table"+e); - }finally{ - try{ - session.close(); - }catch(Exception e1){ - logger.error(XACMLErrorConstants.ERROR_PROCESS_FLOW + "Error While Closing Connection/Statement"+e1); - } - } - - } - - @Override - public void delete(EcompName ecompName) { - Session session = HibernateSession.getSessionFactory(); - Transaction tx = session.beginTransaction(); - try { - session.delete(ecompName); - tx.commit(); - }catch(Exception e){ - logger.error(XACMLErrorConstants.ERROR_PROCESS_FLOW + "Error While Deleting EcompName Table"+e); - }finally{ - try{ - session.close(); - }catch(Exception e1){ - logger.error(XACMLErrorConstants.ERROR_PROCESS_FLOW + "Error While Closing Connection/Statement"+e1); - } - } - - } - - @Override - public void update(EcompName ecompName) { - Session session = HibernateSession.getSessionFactory(); - Transaction tx = session.beginTransaction(); - try { - session.update(ecompName); - tx.commit(); - }catch(Exception e){ - logger.error(XACMLErrorConstants.ERROR_PROCESS_FLOW + "Error While Updating EcompName Table"+e); - }finally{ - try{ - session.close(); - }catch(Exception e1){ - logger.error(XACMLErrorConstants.ERROR_PROCESS_FLOW + "Error While Closing Connection/Statement"+e1); - } - } - - } - - @SuppressWarnings("unchecked") - @Override - public List<String> getEcompNameDataByName() { - logger.info("getEcompNameDataByName is call from the DAO implementation class."); - Session session = HibernateSession.getSessionFactory(); - Transaction tx = session.beginTransaction(); - List<String> data = new ArrayList<String>(); - try { - Criteria cr = session.createCriteria(EcompName.class); - List<EcompName> ecompNameData = cr.list(); - for(int i = 0; i < ecompNameData.size(); i++){ - data.add(ecompNameData.get(i).getEcompName()); - } - logger.info("data retrieved: " + data.toString()); - tx.commit(); - } catch (Exception e) { - logger.error(XACMLErrorConstants.ERROR_PROCESS_FLOW + "Error While Querying EcompName Table"+e); - }finally{ - try{ - session.close(); - }catch(Exception e1){ - logger.error(XACMLErrorConstants.ERROR_PROCESS_FLOW + "Error While Closing Connection/Statement"+e1); - } - } - return data; - } - -} diff --git a/ECOMP-PAP-REST/src/main/java/org/openecomp/policy/pap/xacml/rest/daoimpl/EnforcerPolicyDaoImpl.java b/ECOMP-PAP-REST/src/main/java/org/openecomp/policy/pap/xacml/rest/daoimpl/EnforcerPolicyDaoImpl.java deleted file mode 100644 index ba621ab17..000000000 --- a/ECOMP-PAP-REST/src/main/java/org/openecomp/policy/pap/xacml/rest/daoimpl/EnforcerPolicyDaoImpl.java +++ /dev/null @@ -1,132 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * ECOMP-PAP-REST - * ================================================================================ - * Copyright (C) 2017 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. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============LICENSE_END========================================================= - */ - -package org.openecomp.policy.pap.xacml.rest.daoimpl; - -import java.util.List; - -import org.apache.commons.logging.Log; -import org.apache.commons.logging.LogFactory; -import org.hibernate.Criteria; -import org.hibernate.Session; -import org.hibernate.SessionFactory; -import org.hibernate.Transaction; -import org.openecomp.policy.pap.xacml.rest.HibernateSession; -import org.openecomp.policy.rest.dao.EnforcerPolicyDao; -import org.openecomp.policy.rest.jpa.EnforcingType; -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.stereotype.Service; - -import org.openecomp.policy.xacml.api.XACMLErrorConstants; - -@Service("EnforcerPolicyDao") -public class EnforcerPolicyDaoImpl implements EnforcerPolicyDao { - private static final Log logger = LogFactory.getLog(EnforcerPolicyDaoImpl.class); - @Autowired - SessionFactory sessionfactory; - - public SessionFactory getSessionfactory() { - return sessionfactory; - } - - public void setSessionfactory(SessionFactory sessionfactory) { - this.sessionfactory = sessionfactory; - } - - @SuppressWarnings("unchecked") - @Override - public List<EnforcingType> getEnforcingTypeData() { - Session session = HibernateSession.getSessionFactory(); - Transaction tx = session.beginTransaction(); - List<EnforcingType> enforcingTypeData = null; - try { - Criteria cr = session.createCriteria(EnforcingType.class); - enforcingTypeData = cr.list(); - tx.commit(); - } catch (Exception e) { - logger.error(XACMLErrorConstants.ERROR_PROCESS_FLOW + "Error While Querying EnforcingType Table"+e); - }finally{ - try{ - session.close(); - }catch(Exception e1){ - logger.error(XACMLErrorConstants.ERROR_PROCESS_FLOW + "Error While Closing Connection/Statement"+e1); - } - } - return enforcingTypeData; - - } - - @Override - public void Save(EnforcingType enforcingType) { - Session session = HibernateSession.getSessionFactory(); - Transaction tx = session.beginTransaction(); - try { - session.persist(enforcingType); - tx.commit(); - }catch(Exception e){ - logger.error(XACMLErrorConstants.ERROR_PROCESS_FLOW + "Error While Saving EnforcingType Table"+e); - }finally{ - try{ - session.close(); - }catch(Exception e1){ - logger.error(XACMLErrorConstants.ERROR_PROCESS_FLOW + "Error While Closing Connection/Statement"+e1); - } - } - - } - - @Override - public void delete(EnforcingType enforcingType) { - Session session = HibernateSession.getSessionFactory(); - Transaction tx = session.beginTransaction(); - try { - session.delete(enforcingType); - tx.commit(); - }catch(Exception e){ - logger.error(XACMLErrorConstants.ERROR_PROCESS_FLOW + "Error While Deleting EnforcingType Table"+e); - }finally{ - try{ - session.close(); - }catch(Exception e1){ - logger.error(XACMLErrorConstants.ERROR_PROCESS_FLOW + "Error While Closing Connection/Statement"+e1); - } - } - } - - @Override - public void update(EnforcingType enforcingType) { - Session session = HibernateSession.getSessionFactory(); - Transaction tx = session.beginTransaction(); - try { - session.update(enforcingType); - tx.commit(); - }catch(Exception e){ - logger.error(XACMLErrorConstants.ERROR_PROCESS_FLOW + "Error While Updating EnforcingType Table"+e); - }finally{ - try{ - session.close(); - }catch(Exception e1){ - logger.error(XACMLErrorConstants.ERROR_PROCESS_FLOW + "Error While Closing Connection/Statement"+e1); - } - } - - } - -} diff --git a/ECOMP-PAP-REST/src/main/java/org/openecomp/policy/pap/xacml/rest/daoimpl/FirewallDictionaryListDaoImpl.java b/ECOMP-PAP-REST/src/main/java/org/openecomp/policy/pap/xacml/rest/daoimpl/FirewallDictionaryListDaoImpl.java deleted file mode 100644 index b19a58b93..000000000 --- a/ECOMP-PAP-REST/src/main/java/org/openecomp/policy/pap/xacml/rest/daoimpl/FirewallDictionaryListDaoImpl.java +++ /dev/null @@ -1,202 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * ECOMP-PAP-REST - * ================================================================================ - * Copyright (C) 2017 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. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============LICENSE_END========================================================= - */ - -package org.openecomp.policy.pap.xacml.rest.daoimpl; - -import java.util.ArrayList; -import java.util.List; - -import org.hibernate.Criteria; -import org.hibernate.Query; -import org.hibernate.Session; -import org.hibernate.SessionFactory; -import org.hibernate.Transaction; -import org.hibernate.criterion.Restrictions; -import org.openecomp.policy.pap.xacml.rest.HibernateSession; -import org.openecomp.policy.rest.dao.FirewallDictionaryListDao; -import org.openecomp.policy.rest.jpa.FirewallDictionaryList; -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.stereotype.Service; - -import org.openecomp.policy.xacml.api.XACMLErrorConstants; - -import org.apache.commons.logging.Log; -import org.apache.commons.logging.LogFactory; - -@Service("FirewallDictionaryListDao") -public class FirewallDictionaryListDaoImpl implements FirewallDictionaryListDao { - private static final Log logger = LogFactory.getLog(FirewallDictionaryListDaoImpl.class); - @Autowired - SessionFactory sessionfactory; - - public SessionFactory getSessionfactory() { - return sessionfactory; - } - - public void setSessionfactory(SessionFactory sessionfactory) { - this.sessionfactory = sessionfactory; - } - - @Override - public List<FirewallDictionaryList> getFWDictionaryListData() { - Session session = HibernateSession.getSessionFactory(); - Transaction tx = session.beginTransaction(); - List<FirewallDictionaryList> attributeData = null; - try { - Criteria cr = session.createCriteria(FirewallDictionaryList.class); - attributeData = cr.list(); - tx.commit(); - } catch (Exception e) { - logger.error(XACMLErrorConstants.ERROR_PROCESS_FLOW + "Error While Querying FirewallDictionaryList Table"+e); - }finally{ - try{ - session.close(); - }catch(Exception e1){ - logger.error(XACMLErrorConstants.ERROR_PROCESS_FLOW + "Error While Closing Connection/Statement"+e1); - } - } - return attributeData; - - } - - @Override - public List<String> getFWDictionaryListDataByName() { - Session session = HibernateSession.getSessionFactory(); - Transaction tx = session.beginTransaction(); - List<String> data = new ArrayList<String>(); - try { - Criteria cr = session.createCriteria(FirewallDictionaryList.class); - List<FirewallDictionaryList> attributeData = cr.list(); - for(int i = 0; i < attributeData.size(); i++){ - data.add(attributeData.get(i).getParentItemName()); - } - tx.commit(); - } catch (Exception e) { - logger.error(XACMLErrorConstants.ERROR_PROCESS_FLOW + "Error While Querying FirewallDictionaryList Table"+e); - }finally{ - try{ - session.close(); - }catch(Exception e1){ - logger.error(XACMLErrorConstants.ERROR_PROCESS_FLOW + "Error While Closing Connection/Statement"+e1); - } - } - return data; - } - - @Override - public void Save(FirewallDictionaryList firewallDictionaryList) { - Session session = HibernateSession.getSessionFactory(); - Transaction tx = session.beginTransaction(); - try { - session.persist(firewallDictionaryList); - tx.commit(); - }catch(Exception e){ - logger.error(XACMLErrorConstants.ERROR_PROCESS_FLOW + "Error While Saving FirewallDictionaryList Table"+e); - }finally{ - try{ - session.close(); - }catch(Exception e1){ - logger.error(XACMLErrorConstants.ERROR_PROCESS_FLOW + "Error While Closing Connection/Statement"+e1); - } - } - - } - - @Override - public void delete(FirewallDictionaryList firewallDictionaryList) { - Session session = HibernateSession.getSessionFactory(); - Transaction tx = session.beginTransaction(); - try { - session.delete(firewallDictionaryList); - tx.commit(); - }catch(Exception e){ - logger.error(XACMLErrorConstants.ERROR_PROCESS_FLOW + "Error While Deleting FirewallDictionaryList Table"+e); - }finally{ - try{ - session.close(); - }catch(Exception e1){ - logger.error(XACMLErrorConstants.ERROR_PROCESS_FLOW + "Error While Closing Connection/Statement"+e1); - } - } - - } - - @Override - public void update(FirewallDictionaryList firewallDictionaryList) { - Session session = HibernateSession.getSessionFactory(); - Transaction tx = session.beginTransaction(); - try { - session.update(firewallDictionaryList); - tx.commit(); - }catch(Exception e){ - logger.error(XACMLErrorConstants.ERROR_PROCESS_FLOW + "Error While Updating FirewallDictionaryList Table"+e); - }finally{ - try{ - session.close(); - }catch(Exception e1){ - logger.error(XACMLErrorConstants.ERROR_PROCESS_FLOW + "Error While Closing Connection/Statement"+e1); - } - } - - } - - @Override - public void updateQuery(String query) { - Session session = HibernateSession.getSessionFactory(); - Transaction tx = session.beginTransaction(); - try { - Query hbquery = session.createQuery(query); - hbquery.executeUpdate(); - tx.commit(); - } catch (Exception e) { - logger.error(XACMLErrorConstants.ERROR_PROCESS_FLOW + "Error While Updating FirewallDictionaryList Table"+e); - }finally{ - try{ - session.close(); - }catch(Exception e1){ - logger.error(XACMLErrorConstants.ERROR_PROCESS_FLOW + "Error While Closing Connection/Statement"+e1); - } - } - - } - - @Override - public FirewallDictionaryList getFWDictionaryDataById(String value) { - Session session = HibernateSession.getSessionFactory(); - Transaction tx = session.beginTransaction(); - FirewallDictionaryList data = null; - try { - Criteria cr = session.createCriteria(FirewallDictionaryList.class); - cr = cr.add(Restrictions.eq("parentItemName",value)); - data = (FirewallDictionaryList) cr.list().get(0); - tx.commit(); - } catch (Exception e) { - logger.error(XACMLErrorConstants.ERROR_PROCESS_FLOW + "Error While Querying FirewallDictionaryList Table"+e); - }finally{ - try{ - session.close(); - }catch(Exception e1){ - logger.error(XACMLErrorConstants.ERROR_PROCESS_FLOW + "Error While Closing Connection/Statement"+e1); - } - } - return data; - } - -} diff --git a/ECOMP-PAP-REST/src/main/java/org/openecomp/policy/pap/xacml/rest/daoimpl/GroupPolicyScopeListDaoImpl.java b/ECOMP-PAP-REST/src/main/java/org/openecomp/policy/pap/xacml/rest/daoimpl/GroupPolicyScopeListDaoImpl.java deleted file mode 100644 index edc147fc2..000000000 --- a/ECOMP-PAP-REST/src/main/java/org/openecomp/policy/pap/xacml/rest/daoimpl/GroupPolicyScopeListDaoImpl.java +++ /dev/null @@ -1,182 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * ECOMP-PAP-REST - * ================================================================================ - * Copyright (C) 2017 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. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============LICENSE_END========================================================= - */ - -package org.openecomp.policy.pap.xacml.rest.daoimpl; - -import java.util.ArrayList; -import java.util.List; - -import org.apache.commons.logging.Log; -import org.apache.commons.logging.LogFactory; -import org.hibernate.Criteria; -import org.hibernate.Session; -import org.hibernate.SessionFactory; -import org.hibernate.Transaction; -import org.hibernate.criterion.Restrictions; -import org.openecomp.policy.pap.xacml.rest.HibernateSession; -import org.openecomp.policy.rest.dao.GroupPolicyScopeListDao; -import org.openecomp.policy.rest.jpa.GroupPolicyScopeList; -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.stereotype.Service; - -import org.openecomp.policy.xacml.api.XACMLErrorConstants; - -@Service("GroupPolicyScopeListDao") -public class GroupPolicyScopeListDaoImpl implements GroupPolicyScopeListDao { - private static final Log logger = LogFactory.getLog(GroupPolicyScopeListDaoImpl.class); - @Autowired - SessionFactory sessionfactory; - - public SessionFactory getSessionfactory() { - return sessionfactory; - } - - public void setSessionfactory(SessionFactory sessionfactory) { - this.sessionfactory = sessionfactory; - } - - @SuppressWarnings("unchecked") - @Override - public List<GroupPolicyScopeList> getGroupPolicyScopeListData() { - Session session = HibernateSession.getSessionFactory(); - Transaction tx = session.beginTransaction(); - List<GroupPolicyScopeList> attributeData = null; - try { - Criteria cr = session.createCriteria(GroupPolicyScopeList.class); - attributeData = cr.list(); - tx.commit(); - } catch (Exception e) { - logger.error(XACMLErrorConstants.ERROR_PROCESS_FLOW + "Error While Querying GroupPolicyScopeList Table"+e); - }finally{ - try{ - session.close(); - }catch(Exception e1){ - logger.error(XACMLErrorConstants.ERROR_PROCESS_FLOW + "Error While Closing Connection/Statement"+e1); - } - } - return attributeData; - } - - @SuppressWarnings("unchecked") - @Override - public List<String> getGroupPolicyScopeListDataByName() { - Session session = HibernateSession.getSessionFactory(); - Transaction tx = session.beginTransaction(); - List<String> data = new ArrayList<String>(); - try { - Criteria cr = session.createCriteria(GroupPolicyScopeList.class); - List<GroupPolicyScopeList> attributeData = cr.list(); - for(int i = 0; i < attributeData.size(); i++){ - data.add(attributeData.get(i).getGroupName()); - } - tx.commit(); - } catch (Exception e) { - logger.error(XACMLErrorConstants.ERROR_PROCESS_FLOW + "Error While Querying GroupPolicyScopeList Table"+e); - }finally{ - try{ - session.close(); - }catch(Exception e1){ - logger.error(XACMLErrorConstants.ERROR_PROCESS_FLOW + "Error While Closing Connection/Statement"+e1); - } - } - return data; - } - - @Override - public void Save(GroupPolicyScopeList attribute) { - Session session = HibernateSession.getSessionFactory(); - Transaction tx = session.beginTransaction(); - try { - session.persist(attribute); - tx.commit(); - }catch(Exception e){ - logger.error(XACMLErrorConstants.ERROR_PROCESS_FLOW + "Error While Saving GroupPolicyScopeList Table"+e); - }finally{ - try{ - session.close(); - }catch(Exception e1){ - logger.error(XACMLErrorConstants.ERROR_PROCESS_FLOW + "Error While Closing Connection/Statement"+e1); - } - } - - } - - @Override - public void delete(GroupPolicyScopeList attribute) { - Session session = HibernateSession.getSessionFactory(); - Transaction tx = session.beginTransaction(); - try { - session.delete(attribute); - tx.commit(); - }catch(Exception e){ - logger.error(XACMLErrorConstants.ERROR_PROCESS_FLOW + "Error While Deleting Attribute Table"+e); - }finally{ - try{ - session.close(); - }catch(Exception e1){ - logger.error(XACMLErrorConstants.ERROR_PROCESS_FLOW + "Error While Closing Connection/Statement"+e1); - } - } - - } - - @Override - public void update(GroupPolicyScopeList attribute) { - Session session = HibernateSession.getSessionFactory(); - Transaction tx = session.beginTransaction(); - try { - session.update(attribute); - tx.commit(); - }catch(Exception e){ - logger.error(XACMLErrorConstants.ERROR_PROCESS_FLOW + "Error While Updating Attribute Table"+e); - }finally{ - try{ - session.close(); - }catch(Exception e1){ - logger.error(XACMLErrorConstants.ERROR_PROCESS_FLOW + "Error While Closing Connection/Statement"+e1); - } - } - - } - - @SuppressWarnings("unchecked") - @Override - public List<GroupPolicyScopeList> CheckDuplicateEntry(String value) { - Session session = HibernateSession.getSessionFactory(); - Transaction tx = session.beginTransaction(); - List<GroupPolicyScopeList> data = null; - try { - Criteria cr = session.createCriteria(GroupPolicyScopeList.class); - cr.add(Restrictions.eq("name",value)); - data = cr.list(); - tx.commit(); - } catch (Exception e) { - logger.error(XACMLErrorConstants.ERROR_PROCESS_FLOW + "Error While Querying GroupPolicyScopeList Table"+e); - }finally{ - try{ - session.close(); - }catch(Exception e1){ - logger.error(XACMLErrorConstants.ERROR_PROCESS_FLOW + "Error While Closing Connection/Statement"+e1); - } - } - return data; - } - -} diff --git a/ECOMP-PAP-REST/src/main/java/org/openecomp/policy/pap/xacml/rest/daoimpl/MicroServiceConfigNameDaoImpl.java b/ECOMP-PAP-REST/src/main/java/org/openecomp/policy/pap/xacml/rest/daoimpl/MicroServiceConfigNameDaoImpl.java deleted file mode 100644 index fdee32cc9..000000000 --- a/ECOMP-PAP-REST/src/main/java/org/openecomp/policy/pap/xacml/rest/daoimpl/MicroServiceConfigNameDaoImpl.java +++ /dev/null @@ -1,158 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * ECOMP-PAP-REST - * ================================================================================ - * Copyright (C) 2017 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. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============LICENSE_END========================================================= - */ - -package org.openecomp.policy.pap.xacml.rest.daoimpl; - -import java.util.ArrayList; -import java.util.List; - -import org.apache.commons.logging.Log; -import org.apache.commons.logging.LogFactory; -import org.hibernate.Criteria; -import org.hibernate.Session; -import org.hibernate.SessionFactory; -import org.hibernate.Transaction; -import org.openecomp.policy.pap.xacml.rest.HibernateSession; -import org.openecomp.policy.rest.dao.MicroServiceConfigNameDao; -import org.openecomp.policy.rest.jpa.MicroServiceConfigName; -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.stereotype.Service; - -import org.openecomp.policy.xacml.api.XACMLErrorConstants; - -@Service("MicroServiceConfigNameDao") -public class MicroServiceConfigNameDaoImpl implements MicroServiceConfigNameDao{ - private static final Log logger = LogFactory.getLog(MicroServiceConfigNameDaoImpl.class); - @Autowired - SessionFactory sessionfactory; - - public SessionFactory getSessionfactory() { - return sessionfactory; - } - - public void setSessionfactory(SessionFactory sessionfactory) { - this.sessionfactory = sessionfactory; - } - - @SuppressWarnings("unchecked") - @Override - public List<MicroServiceConfigName> getMicroServiceConfigNameData() { - Session session = HibernateSession.getSessionFactory(); - Transaction tx = session.beginTransaction(); - List<MicroServiceConfigName> attributeData = null; - try { - Criteria cr = session.createCriteria(MicroServiceConfigName.class); - attributeData = cr.list(); - tx.commit(); - } catch (Exception e) { - logger.error(XACMLErrorConstants.ERROR_PROCESS_FLOW + "Error While Querying MicroServiceConfigName Table"+e); - }finally{ - try{ - session.close(); - }catch(Exception e1){ - logger.error(XACMLErrorConstants.ERROR_PROCESS_FLOW + "Error While Closing Connection/Statement"+e1); - } - } - return attributeData; - - } - - @Override - public void Save(MicroServiceConfigName attribute) { - Session session = HibernateSession.getSessionFactory(); - Transaction tx = session.beginTransaction(); - try { - session.persist(attribute); - tx.commit(); - }catch(Exception e){ - logger.error(XACMLErrorConstants.ERROR_PROCESS_FLOW + "Error While Saving MicroServiceConfigName Table"+e); - }finally{ - try{ - session.close(); - }catch(Exception e1){ - logger.error(XACMLErrorConstants.ERROR_PROCESS_FLOW + "Error While Closing Connection/Statement"+e1); - } - } - - } - - @Override - public void delete(MicroServiceConfigName attribute) { - Session session = HibernateSession.getSessionFactory(); - Transaction tx = session.beginTransaction(); - try { - session.delete(attribute); - tx.commit(); - }catch(Exception e){ - logger.error(XACMLErrorConstants.ERROR_PROCESS_FLOW + "Error While Deleting MicroServiceConfigName Table"+e); - }finally{ - try{ - session.close(); - }catch(Exception e1){ - logger.error(XACMLErrorConstants.ERROR_PROCESS_FLOW + "Error While Closing Connection/Statement"+e1); - } - } - } - - @Override - public void update(MicroServiceConfigName attribute) { - Session session = HibernateSession.getSessionFactory(); - Transaction tx = session.beginTransaction(); - try { - session.update(attribute); - tx.commit(); - }catch(Exception e){ - logger.error(XACMLErrorConstants.ERROR_PROCESS_FLOW + "Error While Updating MicroServiceConfigName Table"+e); - }finally{ - try{ - session.close(); - }catch(Exception e1){ - logger.error(XACMLErrorConstants.ERROR_PROCESS_FLOW + "Error While Closing Connection/Statement"+e1); - } - } - - } - - @SuppressWarnings("unchecked") - @Override - public List<String> getMSConfigDataByName() { - Session session = HibernateSession.getSessionFactory(); - Transaction tx = session.beginTransaction(); - List<String> data = new ArrayList<String>(); - try { - Criteria cr = session.createCriteria(MicroServiceConfigName.class); - List<MicroServiceConfigName> attributeData = cr.list(); - for(int i = 0; i < attributeData.size(); i++){ - data.add(attributeData.get(i).getName()); - } - tx.commit(); - } catch (Exception e) { - logger.error(XACMLErrorConstants.ERROR_PROCESS_FLOW + "Error While Querying MicroServiceConfigName Table"+e); - }finally{ - try{ - session.close(); - }catch(Exception e1){ - logger.error(XACMLErrorConstants.ERROR_PROCESS_FLOW + "Error While Closing Connection/Statement"+e1); - } - } - return data; - } - -} diff --git a/ECOMP-PAP-REST/src/main/java/org/openecomp/policy/pap/xacml/rest/daoimpl/MicroServiceLocationDaoImpl.java b/ECOMP-PAP-REST/src/main/java/org/openecomp/policy/pap/xacml/rest/daoimpl/MicroServiceLocationDaoImpl.java deleted file mode 100644 index 91a2f42cf..000000000 --- a/ECOMP-PAP-REST/src/main/java/org/openecomp/policy/pap/xacml/rest/daoimpl/MicroServiceLocationDaoImpl.java +++ /dev/null @@ -1,158 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * ECOMP-PAP-REST - * ================================================================================ - * Copyright (C) 2017 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. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============LICENSE_END========================================================= - */ - -package org.openecomp.policy.pap.xacml.rest.daoimpl; - -import java.util.ArrayList; -import java.util.List; - -import org.apache.commons.logging.Log; -import org.apache.commons.logging.LogFactory; -import org.hibernate.Criteria; -import org.hibernate.Session; -import org.hibernate.SessionFactory; -import org.hibernate.Transaction; -import org.openecomp.policy.pap.xacml.rest.HibernateSession; -import org.openecomp.policy.rest.dao.MicroServiceLocationDao; -import org.openecomp.policy.rest.jpa.MicroServiceLocation; -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.stereotype.Service; - -import org.openecomp.policy.xacml.api.XACMLErrorConstants; - -@Service("MicroServiceLocationDao") -public class MicroServiceLocationDaoImpl implements MicroServiceLocationDao{ - private static final Log logger = LogFactory.getLog(MicroServiceLocationDaoImpl.class); - @Autowired - SessionFactory sessionfactory; - - public SessionFactory getSessionfactory() { - return sessionfactory; - } - - public void setSessionfactory(SessionFactory sessionfactory) { - this.sessionfactory = sessionfactory; - } - - @SuppressWarnings("unchecked") - @Override - public List<MicroServiceLocation> getMicroServiceLocationData() { - Session session = HibernateSession.getSessionFactory(); - Transaction tx = session.beginTransaction(); - List<MicroServiceLocation> attributeData = null; - try { - Criteria cr = session.createCriteria(MicroServiceLocation.class); - attributeData = cr.list(); - tx.commit(); - } catch (Exception e) { - logger.error(XACMLErrorConstants.ERROR_PROCESS_FLOW + "Error While Querying MicroServiceLocation Table"+e); - }finally{ - try{ - session.close(); - }catch(Exception e1){ - logger.error(XACMLErrorConstants.ERROR_PROCESS_FLOW + "Error While Closing Connection/Statement"+e1); - } - } - return attributeData; - - } - - @Override - public void Save(MicroServiceLocation attribute) { - Session session = HibernateSession.getSessionFactory(); - Transaction tx = session.beginTransaction(); - try { - session.persist(attribute); - tx.commit(); - }catch(Exception e){ - logger.error(XACMLErrorConstants.ERROR_PROCESS_FLOW + "Error While Saving MicroServiceLocation Table"+e); - }finally{ - try{ - session.close(); - }catch(Exception e1){ - logger.error(XACMLErrorConstants.ERROR_PROCESS_FLOW + "Error While Closing Connection/Statement"+e1); - } - } - - } - - @Override - public void delete(MicroServiceLocation attribute) { - Session session = HibernateSession.getSessionFactory(); - Transaction tx = session.beginTransaction(); - try { - session.delete(attribute); - tx.commit(); - }catch(Exception e){ - logger.error(XACMLErrorConstants.ERROR_PROCESS_FLOW + "Error While Deleting MicroServiceLocation Table"+e); - }finally{ - try{ - session.close(); - }catch(Exception e1){ - logger.error(XACMLErrorConstants.ERROR_PROCESS_FLOW + "Error While Closing Connection/Statement"+e1); - } - } - } - - @Override - public void update(MicroServiceLocation attribute) { - Session session = HibernateSession.getSessionFactory(); - Transaction tx = session.beginTransaction(); - try { - session.update(attribute); - tx.commit(); - }catch(Exception e){ - logger.error(XACMLErrorConstants.ERROR_PROCESS_FLOW + "Error While Updating MicroServiceLocation Table"+e); - }finally{ - try{ - session.close(); - }catch(Exception e1){ - logger.error(XACMLErrorConstants.ERROR_PROCESS_FLOW + "Error While Closing Connection/Statement"+e1); - } - } - - } - - @SuppressWarnings("unchecked") - @Override - public List<String> getMSLocationDataByName() { - Session session = HibernateSession.getSessionFactory(); - Transaction tx = session.beginTransaction(); - List<String> data = new ArrayList<String>(); - try { - Criteria cr = session.createCriteria(MicroServiceLocation.class); - List<MicroServiceLocation> attributeData = cr.list(); - for(int i = 0; i < attributeData.size(); i++){ - data.add(attributeData.get(i).getName()); - } - tx.commit(); - } catch (Exception e) { - logger.error(XACMLErrorConstants.ERROR_PROCESS_FLOW + "Error While Querying MicroServiceLocation Table"+e); - }finally{ - try{ - session.close(); - }catch(Exception e1){ - logger.error(XACMLErrorConstants.ERROR_PROCESS_FLOW + "Error While Closing Connection/Statement"+e1); - } - } - return data; - } - -} diff --git a/ECOMP-PAP-REST/src/main/java/org/openecomp/policy/pap/xacml/rest/daoimpl/MicroServiceModelsDaoImpl.java b/ECOMP-PAP-REST/src/main/java/org/openecomp/policy/pap/xacml/rest/daoimpl/MicroServiceModelsDaoImpl.java deleted file mode 100644 index c4e66b5a3..000000000 --- a/ECOMP-PAP-REST/src/main/java/org/openecomp/policy/pap/xacml/rest/daoimpl/MicroServiceModelsDaoImpl.java +++ /dev/null @@ -1,161 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * ECOMP-PAP-REST - * ================================================================================ - * Copyright (C) 2017 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. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============LICENSE_END========================================================= - */ - -package org.openecomp.policy.pap.xacml.rest.daoimpl; - -import java.util.ArrayList; -import java.util.List; - -import org.apache.commons.logging.Log; -import org.apache.commons.logging.LogFactory; -import org.hibernate.Criteria; -import org.hibernate.Session; -import org.hibernate.SessionFactory; -import org.hibernate.Transaction; -import org.openecomp.policy.pap.xacml.rest.HibernateSession; -import org.openecomp.policy.rest.dao.MicroServiceModelsDao; -import org.openecomp.policy.rest.jpa.MicroServiceModels; -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.stereotype.Service; - -import org.openecomp.policy.xacml.api.XACMLErrorConstants; - -@Service("MicroServiceModelsDao") -public class MicroServiceModelsDaoImpl implements MicroServiceModelsDao{ - private static final Log logger = LogFactory.getLog(MicroServiceModelsDaoImpl.class); - @Autowired - SessionFactory sessionfactory; - - public SessionFactory getSessionfactory() { - return sessionfactory; - } - - public void setSessionfactory(SessionFactory sessionfactory) { - this.sessionfactory = sessionfactory; - } - - @SuppressWarnings("unchecked") - @Override - public List<MicroServiceModels> getMicroServiceModelsData() { - Session session = HibernateSession.getSessionFactory(); - Transaction tx = session.beginTransaction(); - List<MicroServiceModels> attributeData = null; - try { - Criteria cr = session.createCriteria(MicroServiceModels.class); - attributeData = cr.list(); - tx.commit(); - } catch (Exception e) { - logger.error(XACMLErrorConstants.ERROR_PROCESS_FLOW + "Error While Querying MicroServiceModels Table"+e); - }finally{ - try{ - session.close(); - }catch(Exception e1){ - logger.error(XACMLErrorConstants.ERROR_PROCESS_FLOW + "Error While Closing Connection/Statement"+e1); - } - } - return attributeData; - - } - - @Override - public void Save(MicroServiceModels attribute) { - Session session = HibernateSession.getSessionFactory(); - Transaction tx = session.beginTransaction(); - try { - session.persist(attribute); - tx.commit(); - }catch(Exception e){ - logger.error(XACMLErrorConstants.ERROR_PROCESS_FLOW + "Error While Saving MicroServiceModels Table"+e); - }finally{ - try{ - session.close(); - }catch(Exception e1){ - logger.error(XACMLErrorConstants.ERROR_PROCESS_FLOW + "Error While Closing Connection/Statement"+e1); - } - } - - } - - @Override - public void delete(MicroServiceModels attribute) { - Session session = HibernateSession.getSessionFactory(); - Transaction tx = session.beginTransaction(); - try { - session.delete(attribute); - tx.commit(); - }catch(Exception e){ - logger.error(XACMLErrorConstants.ERROR_PROCESS_FLOW + "Error While Deleting MicroServiceModels Table"+e); - }finally{ - try{ - session.close(); - }catch(Exception e1){ - logger.error(XACMLErrorConstants.ERROR_PROCESS_FLOW + "Error While Closing Connection/Statement"+e1); - } - } - } - - @Override - public void update(MicroServiceModels attribute) { - Session session = HibernateSession.getSessionFactory(); - Transaction tx = session.beginTransaction(); - try { - session.update(attribute); - tx.commit(); - }catch(Exception e){ - logger.error(XACMLErrorConstants.ERROR_PROCESS_FLOW + "Error While Updating MicroServiceModels Table"+e); - }finally{ - try{ - session.close(); - }catch(Exception e1){ - logger.error(XACMLErrorConstants.ERROR_PROCESS_FLOW + "Error While Closing Connection/Statement"+e1); - } - } - - } - - @SuppressWarnings("unchecked") - @Override - public List<String> getMSModelsDataByName() { - Session session = HibernateSession.getSessionFactory(); - Transaction tx = session.beginTransaction(); - List<String> data = new ArrayList<String>(); - try { - Criteria cr = session.createCriteria(MicroServiceModels.class); - List<MicroServiceModels> attributeData = cr.list(); - for(int i = 0; i < attributeData.size(); i++){ - if(attributeData.get(i).getVersion() == null || attributeData.get(i).getVersion().equals("")){ - data.add(attributeData.get(i).getModelName()); - }else{ - data.add(attributeData.get(i).getModelName() + "-v" + attributeData.get(i).getVersion()); - } - } - tx.commit(); - } catch (Exception e) { - logger.error(XACMLErrorConstants.ERROR_PROCESS_FLOW + "Error While Querying MicroServiceModels Table"+e); - }finally{ - try{ - session.close(); - }catch(Exception e1){ - logger.error(XACMLErrorConstants.ERROR_PROCESS_FLOW + "Error While Closing Connection/Statement"+e1); - } - } - return data; - } -} diff --git a/ECOMP-PAP-REST/src/main/java/org/openecomp/policy/pap/xacml/rest/daoimpl/PEPOptionsDaoImpl.java b/ECOMP-PAP-REST/src/main/java/org/openecomp/policy/pap/xacml/rest/daoimpl/PEPOptionsDaoImpl.java deleted file mode 100644 index 92b89e9e3..000000000 --- a/ECOMP-PAP-REST/src/main/java/org/openecomp/policy/pap/xacml/rest/daoimpl/PEPOptionsDaoImpl.java +++ /dev/null @@ -1,159 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * ECOMP-PAP-REST - * ================================================================================ - * Copyright (C) 2017 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. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============LICENSE_END========================================================= - */ - -package org.openecomp.policy.pap.xacml.rest.daoimpl; - -import java.util.ArrayList; -import java.util.List; - -import org.apache.commons.logging.Log; -import org.apache.commons.logging.LogFactory; -import org.hibernate.Criteria; -import org.hibernate.Session; -import org.hibernate.SessionFactory; -import org.hibernate.Transaction; -import org.openecomp.policy.pap.xacml.rest.HibernateSession; -import org.openecomp.policy.rest.dao.PEPOptionsDao; -import org.openecomp.policy.rest.jpa.PEPOptions; -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.stereotype.Service; - -import org.openecomp.policy.xacml.api.XACMLErrorConstants; - -@Service("PEPOptionsDao") -public class PEPOptionsDaoImpl implements PEPOptionsDao{ - private static final Log logger = LogFactory.getLog(PEPOptionsDaoImpl.class); - - @Autowired - SessionFactory sessionfactory; - - public SessionFactory getSessionfactory() { - return sessionfactory; - } - - public void setSessionfactory(SessionFactory sessionfactory) { - this.sessionfactory = sessionfactory; - } - - @SuppressWarnings("unchecked") - @Override - public List<PEPOptions> getPEPOptionsData() { - Session session = HibernateSession.getSessionFactory(); - Transaction tx = session.beginTransaction(); - List<PEPOptions> pepOptionsData = null; - try { - Criteria cr = session.createCriteria(PEPOptions.class); - pepOptionsData = cr.list(); - tx.commit(); - } catch (Exception e) { - logger.error(XACMLErrorConstants.ERROR_PROCESS_FLOW + "Error While Querying PEPOptions Table"+e); - }finally{ - try{ - session.close(); - }catch(Exception e1){ - logger.error(XACMLErrorConstants.ERROR_PROCESS_FLOW + "Error While Closing Connection/Statement"+e1); - } - } - return pepOptionsData; - - } - - @Override - public void Save(PEPOptions pepOptions) { - Session session = HibernateSession.getSessionFactory(); - Transaction tx = session.beginTransaction(); - try { - session.persist(pepOptions); - tx.commit(); - }catch(Exception e){ - logger.error(XACMLErrorConstants.ERROR_PROCESS_FLOW + "Error While Saving PEPOptions Table"+e); - }finally{ - try{ - session.close(); - }catch(Exception e1){ - logger.error(XACMLErrorConstants.ERROR_PROCESS_FLOW + "Error While Closing Connection/Statement"+e1); - } - } - - } - - @Override - public void delete(PEPOptions pepOptions) { - Session session = HibernateSession.getSessionFactory(); - Transaction tx = session.beginTransaction(); - try { - session.delete(pepOptions); - tx.commit(); - }catch(Exception e){ - logger.error(XACMLErrorConstants.ERROR_PROCESS_FLOW + "Error While Deleting PEPOptions Table"+e); - }finally{ - try{ - session.close(); - }catch(Exception e1){ - logger.error(XACMLErrorConstants.ERROR_PROCESS_FLOW + "Error While Closing Connection/Statement"+e1); - } - } - } - - @Override - public void update(PEPOptions pepOptions) { - Session session = HibernateSession.getSessionFactory(); - Transaction tx = session.beginTransaction(); - try { - session.update(pepOptions); - tx.commit(); - }catch(Exception e){ - logger.error(XACMLErrorConstants.ERROR_PROCESS_FLOW + "Error While Updating PEPOptions Table"+e); - }finally{ - try{ - session.close(); - }catch(Exception e1){ - logger.error(XACMLErrorConstants.ERROR_PROCESS_FLOW + "Error While Closing Connection/Statement"+e1); - } - } - - } - - @SuppressWarnings("unchecked") - @Override - public List<String> getPEPOptionsDataByName() { - Session session = HibernateSession.getSessionFactory(); - Transaction tx = session.beginTransaction(); - List<String> data = new ArrayList<String>(); - try { - Criteria cr = session.createCriteria(PEPOptions.class); - List<PEPOptions> pepOptionsData = cr.list(); - for(int i = 0; i < pepOptionsData.size(); i++){ - data.add(pepOptionsData.get(i).getPepName()); - } - tx.commit(); - } catch (Exception e) { - logger.error(XACMLErrorConstants.ERROR_PROCESS_FLOW + "Error While Querying PEPOptions Table"+e); - }finally{ - try{ - session.close(); - }catch(Exception e1){ - logger.error(XACMLErrorConstants.ERROR_PROCESS_FLOW + "Error While Closing Connection/Statement"+e1); - } - } - return data; - } - -} diff --git a/ECOMP-PAP-REST/src/main/java/org/openecomp/policy/pap/xacml/rest/daoimpl/PolicyScopeClosedLoopDaoImpl.java b/ECOMP-PAP-REST/src/main/java/org/openecomp/policy/pap/xacml/rest/daoimpl/PolicyScopeClosedLoopDaoImpl.java deleted file mode 100644 index 6ac3e5bc9..000000000 --- a/ECOMP-PAP-REST/src/main/java/org/openecomp/policy/pap/xacml/rest/daoimpl/PolicyScopeClosedLoopDaoImpl.java +++ /dev/null @@ -1,181 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * ECOMP-PAP-REST - * ================================================================================ - * Copyright (C) 2017 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. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============LICENSE_END========================================================= - */ - -package org.openecomp.policy.pap.xacml.rest.daoimpl; - -import java.util.ArrayList; -import java.util.List; - -import org.apache.commons.logging.Log; -import org.apache.commons.logging.LogFactory; -import org.hibernate.Criteria; -import org.hibernate.Session; -import org.hibernate.SessionFactory; -import org.hibernate.Transaction; -import org.hibernate.criterion.Restrictions; -import org.openecomp.policy.pap.xacml.rest.HibernateSession; -import org.openecomp.policy.rest.dao.PolicyScopeClosedLoopDao; -import org.openecomp.policy.rest.jpa.PolicyScopeClosedLoop; -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.stereotype.Service; - -import org.openecomp.policy.xacml.api.XACMLErrorConstants; - -@Service("PolicyScopeClosedLoopDao") -public class PolicyScopeClosedLoopDaoImpl implements PolicyScopeClosedLoopDao{ - private static final Log logger = LogFactory.getLog(PolicyScopeClosedLoopDaoImpl.class); - @Autowired - SessionFactory sessionfactory; - - public SessionFactory getSessionfactory() { - return sessionfactory; - } - - public void setSessionfactory(SessionFactory sessionfactory) { - this.sessionfactory = sessionfactory; - } - - @SuppressWarnings("unchecked") - @Override - public List<PolicyScopeClosedLoop> getPolicyScopeClosedLoopData() { - Session session = HibernateSession.getSessionFactory(); - Transaction tx = session.beginTransaction(); - List<PolicyScopeClosedLoop> attributeData = null; - try { - Criteria cr = session.createCriteria(PolicyScopeClosedLoop.class); - attributeData = cr.list(); - tx.commit(); - } catch (Exception e) { - logger.error(XACMLErrorConstants.ERROR_PROCESS_FLOW + "Error While Querying PolicyScopeClosedLoop Table"+e); - }finally{ - try{ - session.close(); - }catch(Exception e1){ - logger.error(XACMLErrorConstants.ERROR_PROCESS_FLOW + "Error While Closing Connection/Statement"+e1); - } - } - return attributeData; - } - - @SuppressWarnings("unchecked") - @Override - public List<String> getPolicyScopeClosedLoopDataByName() { - Session session = HibernateSession.getSessionFactory(); - Transaction tx = session.beginTransaction(); - List<String> data = new ArrayList<String>(); - try { - Criteria cr = session.createCriteria(PolicyScopeClosedLoop.class); - List<PolicyScopeClosedLoop> attributeData = cr.list(); - for(int i = 0; i < attributeData.size(); i++){ - data.add(attributeData.get(i).getName()); - } - tx.commit(); - } catch (Exception e) { - logger.error(XACMLErrorConstants.ERROR_PROCESS_FLOW + "Error While Querying PolicyScopeClosedLoop Table"+e); - }finally{ - try{ - session.close(); - }catch(Exception e1){ - logger.error(XACMLErrorConstants.ERROR_PROCESS_FLOW + "Error While Closing Connection/Statement"+e1); - } - } - return data; - } - - @Override - public void Save(PolicyScopeClosedLoop attribute) { - Session session = HibernateSession.getSessionFactory(); - Transaction tx = session.beginTransaction(); - try { - session.persist(attribute); - tx.commit(); - }catch(Exception e){ - logger.error(XACMLErrorConstants.ERROR_PROCESS_FLOW + "Error While Saving PolicyScopeClosedLoop Table"+e); - }finally{ - try{ - session.close(); - }catch(Exception e1){ - logger.error(XACMLErrorConstants.ERROR_PROCESS_FLOW + "Error While Closing Connection/Statement"+e1); - } - } - - } - - @Override - public void delete(PolicyScopeClosedLoop attribute) { - Session session = HibernateSession.getSessionFactory(); - Transaction tx = session.beginTransaction(); - try { - session.delete(attribute); - tx.commit(); - }catch(Exception e){ - logger.error(XACMLErrorConstants.ERROR_PROCESS_FLOW + "Error While Deleting PolicyScopeClosedLoop Table"+e); - }finally{ - try{ - session.close(); - }catch(Exception e1){ - logger.error(XACMLErrorConstants.ERROR_PROCESS_FLOW + "Error While Closing Connection/Statement"+e1); - } - } - } - - @Override - public void update(PolicyScopeClosedLoop attribute) { - Session session = HibernateSession.getSessionFactory(); - Transaction tx = session.beginTransaction(); - try { - session.update(attribute); - tx.commit(); - }catch(Exception e){ - logger.error(XACMLErrorConstants.ERROR_PROCESS_FLOW + "Error While Updating PolicyScopeClosedLoop Table"+e); - }finally{ - try{ - session.close(); - }catch(Exception e1){ - logger.error(XACMLErrorConstants.ERROR_PROCESS_FLOW + "Error While Closing Connection/Statement"+e1); - } - } - - } - - @SuppressWarnings("unchecked") - @Override - public List<PolicyScopeClosedLoop> CheckDuplicateEntry(String value) { - Session session = HibernateSession.getSessionFactory(); - Transaction tx = session.beginTransaction(); - List<PolicyScopeClosedLoop> data = null; - try { - Criteria cr = session.createCriteria(PolicyScopeClosedLoop.class); - cr.add(Restrictions.eq("name",value)); - data = cr.list(); - tx.commit(); - } catch (Exception e) { - logger.error(XACMLErrorConstants.ERROR_PROCESS_FLOW + "Error While Querying PolicyScopeClosedLoop Table"+e); - }finally{ - try{ - session.close(); - }catch(Exception e1){ - logger.error(XACMLErrorConstants.ERROR_PROCESS_FLOW + "Error While Closing Connection/Statement"+e1); - } - } - return data; - } - -} diff --git a/ECOMP-PAP-REST/src/main/java/org/openecomp/policy/pap/xacml/rest/daoimpl/PolicyScopeResourceDaoImpl.java b/ECOMP-PAP-REST/src/main/java/org/openecomp/policy/pap/xacml/rest/daoimpl/PolicyScopeResourceDaoImpl.java deleted file mode 100644 index 6fe91b112..000000000 --- a/ECOMP-PAP-REST/src/main/java/org/openecomp/policy/pap/xacml/rest/daoimpl/PolicyScopeResourceDaoImpl.java +++ /dev/null @@ -1,181 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * ECOMP-PAP-REST - * ================================================================================ - * Copyright (C) 2017 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. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============LICENSE_END========================================================= - */ - -package org.openecomp.policy.pap.xacml.rest.daoimpl; - -import java.util.ArrayList; -import java.util.List; - -import org.apache.commons.logging.Log; -import org.apache.commons.logging.LogFactory; -import org.hibernate.Criteria; -import org.hibernate.Session; -import org.hibernate.SessionFactory; -import org.hibernate.Transaction; -import org.hibernate.criterion.Restrictions; -import org.openecomp.policy.pap.xacml.rest.HibernateSession; -import org.openecomp.policy.rest.dao.PolicyScopeResourceDao; -import org.openecomp.policy.rest.jpa.PolicyScopeResource; -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.stereotype.Service; - -import org.openecomp.policy.xacml.api.XACMLErrorConstants; - -@Service("PolicyScopeResourceDao") -public class PolicyScopeResourceDaoImpl implements PolicyScopeResourceDao{ - private static final Log logger = LogFactory.getLog(PolicyScopeResourceDaoImpl.class); - @Autowired - SessionFactory sessionfactory; - - public SessionFactory getSessionfactory() { - return sessionfactory; - } - - public void setSessionfactory(SessionFactory sessionfactory) { - this.sessionfactory = sessionfactory; - } - - @SuppressWarnings("unchecked") - @Override - public List<PolicyScopeResource> getPolicyScopeResourceData() { - Session session = HibernateSession.getSessionFactory(); - Transaction tx = session.beginTransaction(); - List<PolicyScopeResource> attributeData = null; - try { - Criteria cr = session.createCriteria(PolicyScopeResource.class); - attributeData = cr.list(); - tx.commit(); - } catch (Exception e) { - logger.error(XACMLErrorConstants.ERROR_PROCESS_FLOW + "Error While Querying PolicyScopeResource Table"+e); - }finally{ - try{ - session.close(); - }catch(Exception e1){ - logger.error(XACMLErrorConstants.ERROR_PROCESS_FLOW + "Error While Closing Connection/Statement"+e1); - } - } - return attributeData; - } - - @SuppressWarnings("unchecked") - @Override - public List<String> getPolicyScopeResourceDataByName() { - Session session = HibernateSession.getSessionFactory(); - Transaction tx = session.beginTransaction(); - List<String> data = new ArrayList<String>(); - try { - Criteria cr = session.createCriteria(PolicyScopeResource.class); - List<PolicyScopeResource> attributeData = cr.list(); - for(int i = 0; i < attributeData.size(); i++){ - data.add(attributeData.get(i).getName()); - } - tx.commit(); - } catch (Exception e) { - logger.error(XACMLErrorConstants.ERROR_PROCESS_FLOW + "Error While Querying PolicyScopeResource Table"+e); - }finally{ - try{ - session.close(); - }catch(Exception e1){ - logger.error(XACMLErrorConstants.ERROR_PROCESS_FLOW + "Error While Closing Connection/Statement"+e1); - } - } - return data; - } - - @Override - public void Save(PolicyScopeResource attribute) { - Session session = HibernateSession.getSessionFactory(); - Transaction tx = session.beginTransaction(); - try { - session.persist(attribute); - tx.commit(); - }catch(Exception e){ - logger.error(XACMLErrorConstants.ERROR_PROCESS_FLOW + "Error While Saving PolicyScopeResource Table"+e); - }finally{ - try{ - session.close(); - }catch(Exception e1){ - logger.error(XACMLErrorConstants.ERROR_PROCESS_FLOW + "Error While Closing Connection/Statement"+e1); - } - } - } - - @Override - public void delete(PolicyScopeResource attribute) { - Session session = HibernateSession.getSessionFactory(); - Transaction tx = session.beginTransaction(); - try { - session.delete(attribute); - tx.commit(); - }catch(Exception e){ - logger.error(XACMLErrorConstants.ERROR_PROCESS_FLOW + "Error While Deleting PolicyScopeResource Table"+e); - }finally{ - try{ - session.close(); - }catch(Exception e1){ - logger.error(XACMLErrorConstants.ERROR_PROCESS_FLOW + "Error While Closing Connection/Statement"+e1); - } - } - - } - - @Override - public void update(PolicyScopeResource attribute) { - Session session = HibernateSession.getSessionFactory(); - Transaction tx = session.beginTransaction(); - try { - session.update(attribute); - tx.commit(); - }catch(Exception e){ - logger.error(XACMLErrorConstants.ERROR_PROCESS_FLOW + "Error While Updating PolicyScopeResource Table"+e); - }finally{ - try{ - session.close(); - }catch(Exception e1){ - logger.error(XACMLErrorConstants.ERROR_PROCESS_FLOW + "Error While Closing Connection/Statement"+e1); - } - } - - } - - @SuppressWarnings("unchecked") - @Override - public List<PolicyScopeResource> CheckDuplicateEntry(String value) { - Session session = HibernateSession.getSessionFactory(); - Transaction tx = session.beginTransaction(); - List<PolicyScopeResource> data = null; - try { - Criteria cr = session.createCriteria(PolicyScopeResource.class); - cr.add(Restrictions.eq("name",value)); - data = cr.list(); - tx.commit(); - } catch (Exception e) { - logger.error(XACMLErrorConstants.ERROR_PROCESS_FLOW + "Error While Querying PolicyScopeResource Table"+e); - }finally{ - try{ - session.close(); - }catch(Exception e1){ - logger.error(XACMLErrorConstants.ERROR_PROCESS_FLOW + "Error While Closing Connection/Statement"+e1); - } - } - return data; - } - -} diff --git a/ECOMP-PAP-REST/src/main/java/org/openecomp/policy/pap/xacml/rest/daoimpl/PolicyScopeServiceDaoImpl.java b/ECOMP-PAP-REST/src/main/java/org/openecomp/policy/pap/xacml/rest/daoimpl/PolicyScopeServiceDaoImpl.java deleted file mode 100644 index d90d5a014..000000000 --- a/ECOMP-PAP-REST/src/main/java/org/openecomp/policy/pap/xacml/rest/daoimpl/PolicyScopeServiceDaoImpl.java +++ /dev/null @@ -1,182 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * ECOMP-PAP-REST - * ================================================================================ - * Copyright (C) 2017 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. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============LICENSE_END========================================================= - */ - -package org.openecomp.policy.pap.xacml.rest.daoimpl; - -import java.util.ArrayList; -import java.util.List; - -import org.apache.commons.logging.Log; -import org.apache.commons.logging.LogFactory; -import org.hibernate.Criteria; -import org.hibernate.Session; -import org.hibernate.SessionFactory; -import org.hibernate.Transaction; -import org.hibernate.criterion.Restrictions; -import org.openecomp.policy.pap.xacml.rest.HibernateSession; -import org.openecomp.policy.rest.dao.PolicyScopeServiceDao; -import org.openecomp.policy.rest.jpa.PolicyScopeService; -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.stereotype.Service; - -import org.openecomp.policy.xacml.api.XACMLErrorConstants; - -@Service("PolicyScopeServiceDao") -public class PolicyScopeServiceDaoImpl implements PolicyScopeServiceDao{ - private static final Log logger = LogFactory.getLog(PolicyScopeServiceDaoImpl.class); - @Autowired - SessionFactory sessionfactory; - - public SessionFactory getSessionfactory() { - return sessionfactory; - } - - public void setSessionfactory(SessionFactory sessionfactory) { - this.sessionfactory = sessionfactory; - } - - @SuppressWarnings("unchecked") - @Override - public List<PolicyScopeService> getPolicyScopeServiceData() { - Session session = HibernateSession.getSessionFactory(); - Transaction tx = session.beginTransaction(); - List<PolicyScopeService> attributeData = null; - try { - Criteria cr = session.createCriteria(PolicyScopeService.class); - attributeData = cr.list(); - tx.commit(); - } catch (Exception e) { - logger.error(XACMLErrorConstants.ERROR_PROCESS_FLOW + "Error While Querying PolicyScopeService Table"+e); - }finally{ - try{ - session.close(); - }catch(Exception e1){ - logger.error(XACMLErrorConstants.ERROR_PROCESS_FLOW + "Error While Closing Connection/Statement"+e1); - } - } - return attributeData; - } - - @SuppressWarnings("unchecked") - @Override - public List<String> getPolicyScopeServiceDataByName() { - Session session = HibernateSession.getSessionFactory(); - Transaction tx = session.beginTransaction(); - List<String> data = new ArrayList<String>(); - try { - Criteria cr = session.createCriteria(PolicyScopeService.class); - List<PolicyScopeService> attributeData = cr.list(); - for(int i = 0; i < attributeData.size(); i++){ - data.add(attributeData.get(i).getName()); - } - tx.commit(); - } catch (Exception e) { - logger.error(XACMLErrorConstants.ERROR_PROCESS_FLOW + "Error While Querying PolicyScopeService Table"+e); - }finally{ - try{ - session.close(); - }catch(Exception e1){ - logger.error(XACMLErrorConstants.ERROR_PROCESS_FLOW + "Error While Closing Connection/Statement"+e1); - } - } - return data; - } - - @Override - public void Save(PolicyScopeService attribute) { - Session session = HibernateSession.getSessionFactory(); - Transaction tx = session.beginTransaction(); - try { - session.persist(attribute); - tx.commit(); - }catch(Exception e){ - logger.error(XACMLErrorConstants.ERROR_PROCESS_FLOW + "Error While Saving PolicyScopeService Table"+e); - }finally{ - try{ - session.close(); - }catch(Exception e1){ - logger.error(XACMLErrorConstants.ERROR_PROCESS_FLOW + "Error While Closing Connection/Statement"+e1); - } - } - - } - - @Override - public void delete(PolicyScopeService attribute) { - Session session = HibernateSession.getSessionFactory(); - Transaction tx = session.beginTransaction(); - try { - session.delete(attribute); - tx.commit(); - }catch(Exception e){ - logger.error(XACMLErrorConstants.ERROR_PROCESS_FLOW + "Error While Deleting PolicyScopeService Table"+e); - }finally{ - try{ - session.close(); - }catch(Exception e1){ - logger.error(XACMLErrorConstants.ERROR_PROCESS_FLOW + "Error While Closing Connection/Statement"+e1); - } - } - - } - - @Override - public void update(PolicyScopeService attribute) { - Session session = HibernateSession.getSessionFactory(); - Transaction tx = session.beginTransaction(); - try { - session.update(attribute); - tx.commit(); - }catch(Exception e){ - logger.error(XACMLErrorConstants.ERROR_PROCESS_FLOW + "Error While Updating PolicyScopeService Table"+e); - }finally{ - try{ - session.close(); - }catch(Exception e1){ - logger.error(XACMLErrorConstants.ERROR_PROCESS_FLOW + "Error While Closing Connection/Statement"+e1); - } - } - - } - - @SuppressWarnings("unchecked") - @Override - public List<PolicyScopeService> CheckDuplicateEntry(String value) { - Session session = HibernateSession.getSessionFactory(); - Transaction tx = session.beginTransaction(); - List<PolicyScopeService> data = null; - try { - Criteria cr = session.createCriteria(PolicyScopeService.class); - cr.add(Restrictions.eq("name",value)); - data = cr.list(); - tx.commit(); - } catch (Exception e) { - logger.error(XACMLErrorConstants.ERROR_PROCESS_FLOW + "Error While Querying PolicyScopeService Table"+e); - }finally{ - try{ - session.close(); - }catch(Exception e1){ - logger.error(XACMLErrorConstants.ERROR_PROCESS_FLOW + "Error While Closing Connection/Statement"+e1); - } - } - return data; - } - -} diff --git a/ECOMP-PAP-REST/src/main/java/org/openecomp/policy/pap/xacml/rest/daoimpl/PolicyScopeTypeDaoImpl.java b/ECOMP-PAP-REST/src/main/java/org/openecomp/policy/pap/xacml/rest/daoimpl/PolicyScopeTypeDaoImpl.java deleted file mode 100644 index 66317a4d0..000000000 --- a/ECOMP-PAP-REST/src/main/java/org/openecomp/policy/pap/xacml/rest/daoimpl/PolicyScopeTypeDaoImpl.java +++ /dev/null @@ -1,182 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * ECOMP-PAP-REST - * ================================================================================ - * Copyright (C) 2017 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. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============LICENSE_END========================================================= - */ - -package org.openecomp.policy.pap.xacml.rest.daoimpl; - -import java.util.ArrayList; -import java.util.List; - -import org.apache.commons.logging.Log; -import org.apache.commons.logging.LogFactory; -import org.hibernate.Criteria; -import org.hibernate.Session; -import org.hibernate.SessionFactory; -import org.hibernate.Transaction; -import org.hibernate.criterion.Restrictions; -import org.openecomp.policy.pap.xacml.rest.HibernateSession; -import org.openecomp.policy.rest.dao.PolicyScopeTypeDao; -import org.openecomp.policy.rest.jpa.PolicyScopeType; -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.stereotype.Service; - -import org.openecomp.policy.xacml.api.XACMLErrorConstants; - -@Service("PolicyScopeTypeDao") -public class PolicyScopeTypeDaoImpl implements PolicyScopeTypeDao{ - private static final Log logger = LogFactory.getLog(PolicyScopeTypeDaoImpl.class); - @Autowired - SessionFactory sessionfactory; - - public SessionFactory getSessionfactory() { - return sessionfactory; - } - - public void setSessionfactory(SessionFactory sessionfactory) { - this.sessionfactory = sessionfactory; - } - - @SuppressWarnings("unchecked") - @Override - public List<PolicyScopeType> getPolicyScopeTypeData() { - Session session = HibernateSession.getSessionFactory(); - Transaction tx = session.beginTransaction(); - List<PolicyScopeType> attributeData = null; - try { - Criteria cr = session.createCriteria(PolicyScopeType.class); - attributeData = cr.list(); - tx.commit(); - } catch (Exception e) { - logger.error(XACMLErrorConstants.ERROR_PROCESS_FLOW + "Error While Querying PolicyScopeType Table"+e); - }finally{ - try{ - session.close(); - }catch(Exception e1){ - logger.error(XACMLErrorConstants.ERROR_PROCESS_FLOW + "Error While Closing Connection/Statement"+e1); - } - } - return attributeData; - } - - @SuppressWarnings("unchecked") - @Override - public List<String> getPolicyScopeTypeDataByName() { - Session session = HibernateSession.getSessionFactory(); - Transaction tx = session.beginTransaction(); - List<String> data = new ArrayList<String>(); - try { - Criteria cr = session.createCriteria(PolicyScopeType.class); - List<PolicyScopeType> attributeData = cr.list(); - for(int i = 0; i < attributeData.size(); i++){ - data.add(attributeData.get(i).getName()); - } - tx.commit(); - } catch (Exception e) { - logger.error(XACMLErrorConstants.ERROR_PROCESS_FLOW + "Error While Querying PolicyScopeType Table"+e); - }finally{ - try{ - session.close(); - }catch(Exception e1){ - logger.error(XACMLErrorConstants.ERROR_PROCESS_FLOW + "Error While Closing Connection/Statement"+e1); - } - } - return data; - } - - @Override - public void Save(PolicyScopeType attribute) { - Session session = HibernateSession.getSessionFactory(); - Transaction tx = session.beginTransaction(); - try { - session.persist(attribute); - tx.commit(); - }catch(Exception e){ - logger.error(XACMLErrorConstants.ERROR_PROCESS_FLOW + "Error While Saving PolicyScopeType Table"+e); - }finally{ - try{ - session.close(); - }catch(Exception e1){ - logger.error(XACMLErrorConstants.ERROR_PROCESS_FLOW + "Error While Closing Connection/Statement"+e1); - } - } - - } - - @Override - public void delete(PolicyScopeType attribute) { - Session session = HibernateSession.getSessionFactory(); - Transaction tx = session.beginTransaction(); - try { - session.delete(attribute); - tx.commit(); - }catch(Exception e){ - logger.error(XACMLErrorConstants.ERROR_PROCESS_FLOW + "Error While Deleting PolicyScopeType Table"+e); - }finally{ - try{ - session.close(); - }catch(Exception e1){ - logger.error(XACMLErrorConstants.ERROR_PROCESS_FLOW + "Error While Closing Connection/Statement"+e1); - } - } - - } - - @Override - public void update(PolicyScopeType attribute) { - Session session = HibernateSession.getSessionFactory(); - Transaction tx = session.beginTransaction(); - try { - session.update(attribute); - tx.commit(); - }catch(Exception e){ - logger.error(XACMLErrorConstants.ERROR_PROCESS_FLOW + "Error While Updating PolicyScopeType Table"+e); - }finally{ - try{ - session.close(); - }catch(Exception e1){ - logger.error(XACMLErrorConstants.ERROR_PROCESS_FLOW + "Error While Closing Connection/Statement"+e1); - } - } - - } - - @SuppressWarnings("unchecked") - @Override - public List<PolicyScopeType> CheckDuplicateEntry(String value) { - Session session = HibernateSession.getSessionFactory(); - Transaction tx = session.beginTransaction(); - List<PolicyScopeType> data = null; - try { - Criteria cr = session.createCriteria(PolicyScopeType.class); - cr.add(Restrictions.eq("name",value)); - data = cr.list(); - tx.commit(); - } catch (Exception e) { - logger.error(XACMLErrorConstants.ERROR_PROCESS_FLOW + "Error While Querying PolicyScopeType Table"+e); - }finally{ - try{ - session.close(); - }catch(Exception e1){ - logger.error(XACMLErrorConstants.ERROR_PROCESS_FLOW + "Error While Closing Connection/Statement"+e1); - } - } - return data; - } - -} diff --git a/ECOMP-PAP-REST/src/main/java/org/openecomp/policy/pap/xacml/rest/daoimpl/PortListDaoImpl.java b/ECOMP-PAP-REST/src/main/java/org/openecomp/policy/pap/xacml/rest/daoimpl/PortListDaoImpl.java deleted file mode 100644 index a3139b2c6..000000000 --- a/ECOMP-PAP-REST/src/main/java/org/openecomp/policy/pap/xacml/rest/daoimpl/PortListDaoImpl.java +++ /dev/null @@ -1,158 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * ECOMP-PAP-REST - * ================================================================================ - * Copyright (C) 2017 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. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============LICENSE_END========================================================= - */ - -package org.openecomp.policy.pap.xacml.rest.daoimpl; - -import java.util.ArrayList; -import java.util.List; - -import org.apache.commons.logging.Log; -import org.apache.commons.logging.LogFactory; -import org.hibernate.Criteria; -import org.hibernate.Session; -import org.hibernate.SessionFactory; -import org.hibernate.Transaction; -import org.openecomp.policy.pap.xacml.rest.HibernateSession; -import org.openecomp.policy.rest.dao.PortListDao; -import org.openecomp.policy.rest.jpa.PortList; -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.stereotype.Service; - -import org.openecomp.policy.xacml.api.XACMLErrorConstants; - -@Service("PortListDao") -public class PortListDaoImpl implements PortListDao { - private static final Log logger = LogFactory.getLog(PortListDaoImpl.class); - @Autowired - SessionFactory sessionfactory; - - public SessionFactory getSessionfactory() { - return sessionfactory; - } - - public void setSessionfactory(SessionFactory sessionfactory) { - this.sessionfactory = sessionfactory; - } - - @SuppressWarnings("unchecked") - @Override - public List<PortList> getPortListData() { - Session session = HibernateSession.getSessionFactory(); - Transaction tx = session.beginTransaction(); - List<PortList> attributeData = null; - try { - Criteria cr = session.createCriteria(PortList.class); - attributeData = cr.list(); - tx.commit(); - } catch (Exception e) { - logger.error(XACMLErrorConstants.ERROR_PROCESS_FLOW + "Error While Querying PortList Table"+e); - }finally{ - try{ - session.close(); - }catch(Exception e1){ - logger.error(XACMLErrorConstants.ERROR_PROCESS_FLOW + "Error While Closing Connection/Statement"+e1); - } - } - return attributeData; - - } - - @Override - public void Save(PortList attribute) { - Session session = HibernateSession.getSessionFactory(); - Transaction tx = session.beginTransaction(); - try { - session.persist(attribute); - tx.commit(); - }catch(Exception e){ - logger.error(XACMLErrorConstants.ERROR_PROCESS_FLOW + "Error While Saving PortList Table"+e); - }finally{ - try{ - session.close(); - }catch(Exception e1){ - logger.error(XACMLErrorConstants.ERROR_PROCESS_FLOW + "Error While Closing Connection/Statement"+e1); - } - } - - } - - @Override - public void delete(PortList attribute) { - Session session = HibernateSession.getSessionFactory(); - Transaction tx = session.beginTransaction(); - try { - session.delete(attribute); - tx.commit(); - }catch(Exception e){ - logger.error(XACMLErrorConstants.ERROR_PROCESS_FLOW + "Error While Deleting PortList Table"+e); - }finally{ - try{ - session.close(); - }catch(Exception e1){ - logger.error(XACMLErrorConstants.ERROR_PROCESS_FLOW + "Error While Closing Connection/Statement"+e1); - } - } - } - - @Override - public void update(PortList attribute) { - Session session = HibernateSession.getSessionFactory(); - Transaction tx = session.beginTransaction(); - try { - session.update(attribute); - tx.commit(); - }catch(Exception e){ - logger.error(XACMLErrorConstants.ERROR_PROCESS_FLOW + "Error While Updating PortList Table"+e); - }finally{ - try{ - session.close(); - }catch(Exception e1){ - logger.error(XACMLErrorConstants.ERROR_PROCESS_FLOW + "Error While Closing Connection/Statement"+e1); - } - } - - } - - @SuppressWarnings("unchecked") - @Override - public List<String> getPortListDataByName() { - Session session = HibernateSession.getSessionFactory(); - Transaction tx = session.beginTransaction(); - List<String> data = new ArrayList<String>(); - try { - Criteria cr = session.createCriteria(PortList.class); - List<PortList> attributeData = cr.list(); - for(int i = 0; i < attributeData.size(); i++){ - data.add(attributeData.get(i).getPortName()); - } - tx.commit(); - } catch (Exception e) { - logger.error(XACMLErrorConstants.ERROR_PROCESS_FLOW + "Error While Querying PortList Table"+e); - }finally{ - try{ - session.close(); - }catch(Exception e1){ - logger.error(XACMLErrorConstants.ERROR_PROCESS_FLOW + "Error While Closing Connection/Statement"+e1); - } - } - return data; - } - -} diff --git a/ECOMP-PAP-REST/src/main/java/org/openecomp/policy/pap/xacml/rest/daoimpl/PrefixListDaoImpl.java b/ECOMP-PAP-REST/src/main/java/org/openecomp/policy/pap/xacml/rest/daoimpl/PrefixListDaoImpl.java deleted file mode 100644 index 2fecc7d88..000000000 --- a/ECOMP-PAP-REST/src/main/java/org/openecomp/policy/pap/xacml/rest/daoimpl/PrefixListDaoImpl.java +++ /dev/null @@ -1,158 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * ECOMP-PAP-REST - * ================================================================================ - * Copyright (C) 2017 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. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============LICENSE_END========================================================= - */ - -package org.openecomp.policy.pap.xacml.rest.daoimpl; - -import java.util.ArrayList; -import java.util.List; - -import org.apache.commons.logging.Log; -import org.apache.commons.logging.LogFactory; -import org.hibernate.Criteria; -import org.hibernate.Session; -import org.hibernate.SessionFactory; -import org.hibernate.Transaction; -import org.openecomp.policy.pap.xacml.rest.HibernateSession; -import org.openecomp.policy.rest.dao.PrefixListDao; -import org.openecomp.policy.rest.jpa.PREFIXLIST; -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.stereotype.Service; - -import org.openecomp.policy.xacml.api.XACMLErrorConstants; - -@Service("PrefixListDao") -public class PrefixListDaoImpl implements PrefixListDao{ - private static final Log logger = LogFactory.getLog(PrefixListDaoImpl.class); - @Autowired - SessionFactory sessionfactory; - - public SessionFactory getSessionfactory() { - return sessionfactory; - } - - public void setSessionfactory(SessionFactory sessionfactory) { - this.sessionfactory = sessionfactory; - } - - @SuppressWarnings("unchecked") - @Override - public List<PREFIXLIST> getPREFIXLISTData() { - Session session = HibernateSession.getSessionFactory(); - Transaction tx = session.beginTransaction(); - List<PREFIXLIST> attributeData = null; - try { - Criteria cr = session.createCriteria(PREFIXLIST.class); - attributeData = cr.list(); - tx.commit(); - } catch (Exception e) { - logger.error(XACMLErrorConstants.ERROR_PROCESS_FLOW + "Error While Querying PREFIXLIST Table"+e); - }finally{ - try{ - session.close(); - }catch(Exception e1){ - logger.error(XACMLErrorConstants.ERROR_PROCESS_FLOW + "Error While Closing Connection/Statement"+e1); - } - } - return attributeData; - - } - - @Override - public void Save(PREFIXLIST attribute) { - Session session = HibernateSession.getSessionFactory(); - Transaction tx = session.beginTransaction(); - try { - session.persist(attribute); - tx.commit(); - }catch(Exception e){ - logger.error(XACMLErrorConstants.ERROR_PROCESS_FLOW + "Error While Saving PREFIXLIST Table"+e); - }finally{ - try{ - session.close(); - }catch(Exception e1){ - logger.error(XACMLErrorConstants.ERROR_PROCESS_FLOW + "Error While Closing Connection/Statement"+e1); - } - } - - } - - @Override - public void delete(PREFIXLIST attribute) { - Session session = HibernateSession.getSessionFactory(); - Transaction tx = session.beginTransaction(); - try { - session.delete(attribute); - tx.commit(); - }catch(Exception e){ - logger.error(XACMLErrorConstants.ERROR_PROCESS_FLOW + "Error While Deleting PREFIXLIST Table"+e); - }finally{ - try{ - session.close(); - }catch(Exception e1){ - logger.error(XACMLErrorConstants.ERROR_PROCESS_FLOW + "Error While Closing Connection/Statement"+e1); - } - } - } - - @Override - public void update(PREFIXLIST attribute) { - Session session = HibernateSession.getSessionFactory(); - Transaction tx = session.beginTransaction(); - try { - session.update(attribute); - tx.commit(); - }catch(Exception e){ - logger.error(XACMLErrorConstants.ERROR_PROCESS_FLOW + "Error While Updating PREFIXLIST Table"+e); - }finally{ - try{ - session.close(); - }catch(Exception e1){ - logger.error(XACMLErrorConstants.ERROR_PROCESS_FLOW + "Error While Closing Connection/Statement"+e1); - } - } - - } - - @SuppressWarnings("unchecked") - @Override - public List<String> getPrefixListDataByName() { - Session session = HibernateSession.getSessionFactory(); - Transaction tx = session.beginTransaction(); - List<String> data = new ArrayList<String>(); - try { - Criteria cr = session.createCriteria(PREFIXLIST.class); - List<PREFIXLIST> attributeData = cr.list(); - for(int i = 0; i < attributeData.size(); i++){ - data.add(attributeData.get(i).getPrefixListName()); - } - tx.commit(); - } catch (Exception e) { - logger.error(XACMLErrorConstants.ERROR_PROCESS_FLOW + "Error While Querying PREFIXLIST Table"+e); - }finally{ - try{ - session.close(); - }catch(Exception e1){ - logger.error(XACMLErrorConstants.ERROR_PROCESS_FLOW + "Error While Closing Connection/Statement"+e1); - } - } - return data; - } - -} diff --git a/ECOMP-PAP-REST/src/main/java/org/openecomp/policy/pap/xacml/rest/daoimpl/ProtocolListDaoImpl.java b/ECOMP-PAP-REST/src/main/java/org/openecomp/policy/pap/xacml/rest/daoimpl/ProtocolListDaoImpl.java deleted file mode 100644 index 7d78d387a..000000000 --- a/ECOMP-PAP-REST/src/main/java/org/openecomp/policy/pap/xacml/rest/daoimpl/ProtocolListDaoImpl.java +++ /dev/null @@ -1,158 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * ECOMP-PAP-REST - * ================================================================================ - * Copyright (C) 2017 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. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============LICENSE_END========================================================= - */ - -package org.openecomp.policy.pap.xacml.rest.daoimpl; - -import java.util.ArrayList; -import java.util.List; - -import org.apache.commons.logging.Log; -import org.apache.commons.logging.LogFactory; -import org.hibernate.Criteria; -import org.hibernate.Session; -import org.hibernate.SessionFactory; -import org.hibernate.Transaction; -import org.openecomp.policy.pap.xacml.rest.HibernateSession; -import org.openecomp.policy.rest.dao.ProtocolListDao; -import org.openecomp.policy.rest.jpa.ProtocolList; -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.stereotype.Service; - -import org.openecomp.policy.xacml.api.XACMLErrorConstants; - -@Service("ProtocolListDao") -public class ProtocolListDaoImpl implements ProtocolListDao { - private static final Log logger = LogFactory.getLog(ProtocolListDaoImpl.class); - @Autowired - SessionFactory sessionfactory; - - public SessionFactory getSessionfactory() { - return sessionfactory; - } - - public void setSessionfactory(SessionFactory sessionfactory) { - this.sessionfactory = sessionfactory; - } - - @SuppressWarnings("unchecked") - @Override - public List<ProtocolList> getProtocolListData() { - Session session = HibernateSession.getSessionFactory(); - Transaction tx = session.beginTransaction(); - List<ProtocolList> attributeData = null; - try { - Criteria cr = session.createCriteria(ProtocolList.class); - attributeData = cr.list(); - tx.commit(); - } catch (Exception e) { - logger.error(XACMLErrorConstants.ERROR_PROCESS_FLOW + "Error While Querying ProtocolList Table"+e); - }finally{ - try{ - session.close(); - }catch(Exception e1){ - logger.error(XACMLErrorConstants.ERROR_PROCESS_FLOW + "Error While Closing Connection/Statement"+e1); - } - } - return attributeData; - - } - - @Override - public void Save(ProtocolList attribute) { - Session session = HibernateSession.getSessionFactory(); - Transaction tx = session.beginTransaction(); - try { - session.persist(attribute); - tx.commit(); - }catch(Exception e){ - logger.error(XACMLErrorConstants.ERROR_PROCESS_FLOW + "Error While Saving ProtocolList Table"+e); - }finally{ - try{ - session.close(); - }catch(Exception e1){ - logger.error(XACMLErrorConstants.ERROR_PROCESS_FLOW + "Error While Closing Connection/Statement"+e1); - } - } - - } - - @Override - public void delete(ProtocolList attribute) { - Session session = HibernateSession.getSessionFactory(); - Transaction tx = session.beginTransaction(); - try { - session.delete(attribute); - tx.commit(); - }catch(Exception e){ - logger.error(XACMLErrorConstants.ERROR_PROCESS_FLOW + "Error While Deleting ProtocolList Table"+e); - }finally{ - try{ - session.close(); - }catch(Exception e1){ - logger.error(XACMLErrorConstants.ERROR_PROCESS_FLOW + "Error While Closing Connection/Statement"+e1); - } - } - } - - @Override - public void update(ProtocolList attribute) { - Session session = HibernateSession.getSessionFactory(); - Transaction tx = session.beginTransaction(); - try { - session.update(attribute); - tx.commit(); - }catch(Exception e){ - logger.error(XACMLErrorConstants.ERROR_PROCESS_FLOW + "Error While Updating ProtocolList Table"+e); - }finally{ - try{ - session.close(); - }catch(Exception e1){ - logger.error(XACMLErrorConstants.ERROR_PROCESS_FLOW + "Error While Closing Connection/Statement"+e1); - } - } - - } - - @SuppressWarnings("unchecked") - @Override - public List<String> getProtocolListDataByName() { - Session session = HibernateSession.getSessionFactory(); - Transaction tx = session.beginTransaction(); - List<String> data = new ArrayList<String>(); - try { - Criteria cr = session.createCriteria(ProtocolList.class); - List<ProtocolList> attributeData = cr.list(); - for(int i = 0; i < attributeData.size(); i++){ - data.add(attributeData.get(i).getProtocolName()); - } - tx.commit(); - } catch (Exception e) { - logger.error(XACMLErrorConstants.ERROR_PROCESS_FLOW + "Error While Querying ProtocolList Table"+e); - }finally{ - try{ - session.close(); - }catch(Exception e1){ - logger.error(XACMLErrorConstants.ERROR_PROCESS_FLOW + "Error While Closing Connection/Statement"+e1); - } - } - return data; - } - -} diff --git a/ECOMP-PAP-REST/src/main/java/org/openecomp/policy/pap/xacml/rest/daoimpl/RiskTypeDaoImpl.java b/ECOMP-PAP-REST/src/main/java/org/openecomp/policy/pap/xacml/rest/daoimpl/RiskTypeDaoImpl.java deleted file mode 100644 index 1318f82fa..000000000 --- a/ECOMP-PAP-REST/src/main/java/org/openecomp/policy/pap/xacml/rest/daoimpl/RiskTypeDaoImpl.java +++ /dev/null @@ -1,167 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * ECOMP-PAP-REST - * ================================================================================ - * Copyright (C) 2017 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. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============LICENSE_END========================================================= - */ - -package org.openecomp.policy.pap.xacml.rest.daoimpl; - -import java.util.ArrayList; -import java.util.List; - -import org.apache.commons.logging.Log; -import org.apache.commons.logging.LogFactory; -import org.hibernate.Criteria; -import org.hibernate.Session; -import org.hibernate.SessionFactory; -import org.hibernate.Transaction; -import org.openecomp.policy.pap.xacml.rest.HibernateSession; -import org.openecomp.policy.rest.dao.EcompNameDao; -import org.openecomp.policy.rest.dao.RiskTypeDao; -import org.openecomp.policy.rest.jpa.EcompName; -import org.openecomp.policy.rest.jpa.RiskType; -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.stereotype.Service; - -import org.openecomp.policy.xacml.api.XACMLErrorConstants; - -@Service("RiskTypeDao") -public class RiskTypeDaoImpl implements RiskTypeDao { - private static final Log logger = LogFactory.getLog(RiskTypeDaoImpl.class); - @Autowired - SessionFactory sessionfactory; - - public SessionFactory getSessionfactory() { - return sessionfactory; - } - - public void setSessionfactory(SessionFactory sessionfactory) { - this.sessionfactory = sessionfactory; - } - - @SuppressWarnings("unchecked") - @Override - public List<RiskType> getRiskName() { - System.out.println("RiskTypeDaoImpl: getRiskName() is called"); - logger.debug("RiskTypeDaoImpl: getRiskName() is called"); - Session session = HibernateSession.getSessionFactory(); - Transaction tx = session.beginTransaction(); - List<RiskType> riskTypeData = null; - try { - Criteria cr = session.createCriteria(RiskType.class); - riskTypeData = cr.list(); - logger.debug("Data returned from RiskType table: " + riskTypeData.toString()); - tx.commit(); - } catch (Exception e) { - logger.error(XACMLErrorConstants.ERROR_PROCESS_FLOW + "Error While Querying RiskType Table"+e); - }finally{ - try{ - session.close(); - }catch(Exception e1){ - logger.error(XACMLErrorConstants.ERROR_PROCESS_FLOW + "Error While Closing Connection/Statement"+e1); - } - } - return riskTypeData; - } - - @Override - public void Save(RiskType riskName) { - System.out.println("RiskTypeDaoImpl: Save() is called"); - logger.debug("RiskTypeDaoImpl: Save() is called"); - Session session = HibernateSession.getSessionFactory(); - Transaction tx = session.beginTransaction(); - try { - session.persist(riskName); - tx.commit(); - }catch(Exception e){ - logger.error(XACMLErrorConstants.ERROR_PROCESS_FLOW + "Error While Saving RiskType Table"+e); - }finally{ - try{ - session.close(); - }catch(Exception e1){ - logger.error(XACMLErrorConstants.ERROR_PROCESS_FLOW + "Error While Closing Connection/Statement"+e1); - } - } - - } - - @Override - public void delete(RiskType riskName) { - Session session = HibernateSession.getSessionFactory(); - Transaction tx = session.beginTransaction(); - try { - session.delete(riskName); - tx.commit(); - }catch(Exception e){ - logger.error(XACMLErrorConstants.ERROR_PROCESS_FLOW + "Error While Deleting RiskType Table"+e); - }finally{ - try{ - session.close(); - }catch(Exception e1){ - logger.error(XACMLErrorConstants.ERROR_PROCESS_FLOW + "Error While Closing Connection/Statement"+e1); - } - } - - } - - @Override - public void update(RiskType riskName) { - Session session = HibernateSession.getSessionFactory(); - Transaction tx = session.beginTransaction(); - try { - session.update(riskName); - tx.commit(); - }catch(Exception e){ - logger.error(XACMLErrorConstants.ERROR_PROCESS_FLOW + "Error While Updating RiskType Table"+e); - }finally{ - try{ - session.close(); - }catch(Exception e1){ - logger.error(XACMLErrorConstants.ERROR_PROCESS_FLOW + "Error While Closing Connection/Statement"+e1); - } - } - - } - - @SuppressWarnings("unchecked") - @Override - public List<String> getRiskTypeDataByName() { - logger.info("getRiskTypeDataByName is call from the DAO implementation class."); - Session session = HibernateSession.getSessionFactory(); - Transaction tx = session.beginTransaction(); - List<String> data = new ArrayList<String>(); - try { - Criteria cr = session.createCriteria(RiskType.class); - List<RiskType> riskTypeData = cr.list(); - for(int i = 0; i < riskTypeData.size(); i++){ - data.add(riskTypeData.get(i).getRiskName()); - } - logger.info("data retrieved: " + data.toString()); - tx.commit(); - } catch (Exception e) { - logger.error(XACMLErrorConstants.ERROR_PROCESS_FLOW + "Error While Querying RiskType Table"+e); - }finally{ - try{ - session.close(); - }catch(Exception e1){ - logger.error(XACMLErrorConstants.ERROR_PROCESS_FLOW + "Error While Closing Connection/Statement"+e1); - } - } - return data; - } - -} diff --git a/ECOMP-PAP-REST/src/main/java/org/openecomp/policy/pap/xacml/rest/daoimpl/SafePolicyWarningDaoImpl.java b/ECOMP-PAP-REST/src/main/java/org/openecomp/policy/pap/xacml/rest/daoimpl/SafePolicyWarningDaoImpl.java deleted file mode 100644 index 37a77f9b5..000000000 --- a/ECOMP-PAP-REST/src/main/java/org/openecomp/policy/pap/xacml/rest/daoimpl/SafePolicyWarningDaoImpl.java +++ /dev/null @@ -1,181 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * ECOMP-PAP-REST - * ================================================================================ - * Copyright (C) 2017 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. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============LICENSE_END========================================================= - */ - -package org.openecomp.policy.pap.xacml.rest.daoimpl; - -import java.util.ArrayList; -import java.util.List; - -import org.apache.commons.logging.Log; -import org.apache.commons.logging.LogFactory; -import org.hibernate.Criteria; -import org.hibernate.Session; -import org.hibernate.SessionFactory; -import org.hibernate.Transaction; -import org.hibernate.criterion.Restrictions; -import org.openecomp.policy.pap.xacml.rest.HibernateSession; -import org.openecomp.policy.rest.dao.SafePolicyWarningDao; -import org.openecomp.policy.rest.jpa.SafePolicyWarning; -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.stereotype.Service; - -import org.openecomp.policy.xacml.api.XACMLErrorConstants; - -@Service("SafePolicyWarningDao") -public class SafePolicyWarningDaoImpl implements SafePolicyWarningDao { - private static final Log logger = LogFactory.getLog(SafePolicyWarningDaoImpl.class); - @Autowired - SessionFactory sessionfactory; - - public SessionFactory getSessionfactory() { - return sessionfactory; - } - - public void setSessionfactory(SessionFactory sessionfactory) { - this.sessionfactory = sessionfactory; - } - - @SuppressWarnings("unchecked") - @Override - public List<SafePolicyWarning> getSafePolicyWarningData() { - Session session = HibernateSession.getSessionFactory(); - Transaction tx = session.beginTransaction(); - List<SafePolicyWarning> attributeData = null; - try { - Criteria cr = session.createCriteria(SafePolicyWarning.class); - attributeData = cr.list(); - tx.commit(); - } catch (Exception e) { - logger.error(XACMLErrorConstants.ERROR_PROCESS_FLOW + "Error While Querying SafePolicyWarning Table"+e); - }finally{ - try{ - session.close(); - }catch(Exception e1){ - logger.error(XACMLErrorConstants.ERROR_PROCESS_FLOW + "Error While Closing Connection/Statement"+e1); - } - } - return attributeData; - } - - @SuppressWarnings("unchecked") - @Override - public List<String> getSafePolicyWarningDataByName() { - Session session = HibernateSession.getSessionFactory(); - Transaction tx = session.beginTransaction(); - List<String> data = new ArrayList<String>(); - try { - Criteria cr = session.createCriteria(SafePolicyWarning.class); - List<SafePolicyWarning> attributeData = cr.list(); - for(int i = 0; i < attributeData.size(); i++){ - data.add(attributeData.get(i).getName()); - } - tx.commit(); - } catch (Exception e) { - logger.error(XACMLErrorConstants.ERROR_PROCESS_FLOW + "Error While Querying SafePolicyWarning Table"+e); - }finally{ - try{ - session.close(); - }catch(Exception e1){ - logger.error(XACMLErrorConstants.ERROR_PROCESS_FLOW + "Error While Closing Connection/Statement"+e1); - } - } - return data; - } - - @Override - public void Save(SafePolicyWarning attribute) { - Session session = HibernateSession.getSessionFactory(); - Transaction tx = session.beginTransaction(); - try { - session.persist(attribute); - tx.commit(); - }catch(Exception e){ - logger.error(XACMLErrorConstants.ERROR_PROCESS_FLOW + "Error While Saving SafePolicyWarning Table"+e); - }finally{ - try{ - session.close(); - }catch(Exception e1){ - logger.error(XACMLErrorConstants.ERROR_PROCESS_FLOW + "Error While Closing Connection/Statement"+e1); - } - } - - } - - @Override - public void delete(SafePolicyWarning attribute) { - Session session = HibernateSession.getSessionFactory(); - Transaction tx = session.beginTransaction(); - try { - session.delete(attribute); - tx.commit(); - }catch(Exception e){ - logger.error(XACMLErrorConstants.ERROR_PROCESS_FLOW + "Error While Deleting Attribute Table"+e); - }finally{ - try{ - session.close(); - }catch(Exception e1){ - logger.error(XACMLErrorConstants.ERROR_PROCESS_FLOW + "Error While Closing Connection/Statement"+e1); - } - } - - } - - @Override - public void update(SafePolicyWarning attribute) { - Session session = HibernateSession.getSessionFactory(); - Transaction tx = session.beginTransaction(); - try { - session.update(attribute); - tx.commit(); - }catch(Exception e){ - logger.error(XACMLErrorConstants.ERROR_PROCESS_FLOW + "Error While Updating Attribute Table"+e); - }finally{ - try{ - session.close(); - }catch(Exception e1){ - logger.error(XACMLErrorConstants.ERROR_PROCESS_FLOW + "Error While Closing Connection/Statement"+e1); - } - } - - } - - @Override - public SafePolicyWarning getSafePolicyWarningDataById(String riskType) { - Session session = HibernateSession.getSessionFactory(); - Transaction tx = session.beginTransaction(); - SafePolicyWarning data = null; - try { - Criteria cr = session.createCriteria(SafePolicyWarning.class); - cr.add(Restrictions.eq("name",riskType)); - data = (SafePolicyWarning) cr.list().get(0); - tx.commit(); - } catch (Exception e) { - logger.error(XACMLErrorConstants.ERROR_PROCESS_FLOW + "Error While Querying SafePolicyWarning Table"+e); - }finally{ - try{ - session.close(); - }catch(Exception e1){ - logger.error(XACMLErrorConstants.ERROR_PROCESS_FLOW + "Error While Closing Connection/Statement"+e1); - } - } - return data; - } - -} diff --git a/ECOMP-PAP-REST/src/main/java/org/openecomp/policy/pap/xacml/rest/daoimpl/SecurityZoneDaoImpl.java b/ECOMP-PAP-REST/src/main/java/org/openecomp/policy/pap/xacml/rest/daoimpl/SecurityZoneDaoImpl.java deleted file mode 100644 index 9c79773dd..000000000 --- a/ECOMP-PAP-REST/src/main/java/org/openecomp/policy/pap/xacml/rest/daoimpl/SecurityZoneDaoImpl.java +++ /dev/null @@ -1,157 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * ECOMP-PAP-REST - * ================================================================================ - * Copyright (C) 2017 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. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============LICENSE_END========================================================= - */ - -package org.openecomp.policy.pap.xacml.rest.daoimpl; - -import java.util.ArrayList; -import java.util.List; - -import org.apache.commons.logging.Log; -import org.apache.commons.logging.LogFactory; -import org.hibernate.Criteria; -import org.hibernate.Session; -import org.hibernate.SessionFactory; -import org.hibernate.Transaction; -import org.openecomp.policy.pap.xacml.rest.HibernateSession; -import org.openecomp.policy.rest.dao.SecurityZoneDao; -import org.openecomp.policy.rest.jpa.SecurityZone; -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.stereotype.Service; - -import org.openecomp.policy.xacml.api.XACMLErrorConstants; - -@Service("SecurityZoneDao") -public class SecurityZoneDaoImpl implements SecurityZoneDao{ - private static final Log logger = LogFactory.getLog(SecurityZoneDaoImpl.class); - @Autowired - SessionFactory sessionfactory; - - public SessionFactory getSessionfactory() { - return sessionfactory; - } - - public void setSessionfactory(SessionFactory sessionfactory) { - this.sessionfactory = sessionfactory; - } - - @SuppressWarnings("unchecked") - @Override - public List<SecurityZone> getSecurityZoneData() { - Session session = HibernateSession.getSessionFactory(); - Transaction tx = session.beginTransaction(); - List<SecurityZone> attributeData = null; - try { - Criteria cr = session.createCriteria(SecurityZone.class); - attributeData = cr.list(); - tx.commit(); - } catch (Exception e) { - logger.error(XACMLErrorConstants.ERROR_PROCESS_FLOW + "Error While Querying SecurityZone Table"+e); - }finally{ - try{ - session.close(); - }catch(Exception e1){ - logger.error(XACMLErrorConstants.ERROR_PROCESS_FLOW + "Error While Closing Connection/Statement"+e1); - } - } - return attributeData; - - } - - @Override - public void Save(SecurityZone attribute) { - Session session = HibernateSession.getSessionFactory(); - Transaction tx = session.beginTransaction(); - try { - session.persist(attribute); - tx.commit(); - }catch(Exception e){ - logger.error(XACMLErrorConstants.ERROR_PROCESS_FLOW + "Error While Saving SecurityZone Table"+e); - }finally{ - try{ - session.close(); - }catch(Exception e1){ - logger.error(XACMLErrorConstants.ERROR_PROCESS_FLOW + "Error While Closing Connection/Statement"+e1); - } - } - } - - @Override - public void delete(SecurityZone attribute) { - Session session = HibernateSession.getSessionFactory(); - Transaction tx = session.beginTransaction(); - try { - session.delete(attribute); - tx.commit(); - }catch(Exception e){ - logger.error(XACMLErrorConstants.ERROR_PROCESS_FLOW + "Error While Deleting SecurityZone Table"+e); - }finally{ - try{ - session.close(); - }catch(Exception e1){ - logger.error(XACMLErrorConstants.ERROR_PROCESS_FLOW + "Error While Closing Connection/Statement"+e1); - } - } - } - - @Override - public void update(SecurityZone attribute) { - Session session = HibernateSession.getSessionFactory(); - Transaction tx = session.beginTransaction(); - try { - session.update(attribute); - tx.commit(); - }catch(Exception e){ - logger.error(XACMLErrorConstants.ERROR_PROCESS_FLOW + "Error While Updating SecurityZone Table"+e); - }finally{ - try{ - session.close(); - }catch(Exception e1){ - logger.error(XACMLErrorConstants.ERROR_PROCESS_FLOW + "Error While Closing Connection/Statement"+e1); - } - } - - } - - @SuppressWarnings("unchecked") - @Override - public List<String> getSecurityZoneDataByName() { - Session session = HibernateSession.getSessionFactory(); - Transaction tx = session.beginTransaction(); - List<String> data = new ArrayList<String>(); - try { - Criteria cr = session.createCriteria(SecurityZone.class); - List<SecurityZone> attributeData = cr.list(); - for(int i = 0; i < attributeData.size(); i++){ - data.add(attributeData.get(i).getZoneName()); - } - tx.commit(); - } catch (Exception e) { - logger.error(XACMLErrorConstants.ERROR_PROCESS_FLOW + "Error While Querying SecurityZone Table"+e); - }finally{ - try{ - session.close(); - }catch(Exception e1){ - logger.error(XACMLErrorConstants.ERROR_PROCESS_FLOW + "Error While Closing Connection/Statement"+e1); - } - } - return data; - } - -} diff --git a/ECOMP-PAP-REST/src/main/java/org/openecomp/policy/pap/xacml/rest/daoimpl/ServiceDictionaryDaoImpl.java b/ECOMP-PAP-REST/src/main/java/org/openecomp/policy/pap/xacml/rest/daoimpl/ServiceDictionaryDaoImpl.java deleted file mode 100644 index 226c50060..000000000 --- a/ECOMP-PAP-REST/src/main/java/org/openecomp/policy/pap/xacml/rest/daoimpl/ServiceDictionaryDaoImpl.java +++ /dev/null @@ -1,157 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * ECOMP-PAP-REST - * ================================================================================ - * Copyright (C) 2017 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. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============LICENSE_END========================================================= - */ - -package org.openecomp.policy.pap.xacml.rest.daoimpl; - -import java.util.ArrayList; -import java.util.List; - -import org.apache.commons.logging.Log; -import org.apache.commons.logging.LogFactory; -import org.hibernate.Criteria; -import org.hibernate.Session; -import org.hibernate.SessionFactory; -import org.hibernate.Transaction; -import org.openecomp.policy.pap.xacml.rest.HibernateSession; -import org.openecomp.policy.rest.dao.ServiceDictionaryDao; -import org.openecomp.policy.rest.jpa.ClosedLoopD2Services; -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.stereotype.Service; - -import org.openecomp.policy.xacml.api.XACMLErrorConstants; - -@Service("ServiceDictionaryDao") -public class ServiceDictionaryDaoImpl implements ServiceDictionaryDao { - private static final Log logger = LogFactory.getLog(ServiceDictionaryDaoImpl.class); - @Autowired - SessionFactory sessionfactory; - - public SessionFactory getSessionfactory() { - return sessionfactory; - } - - public void setSessionfactory(SessionFactory sessionfactory) { - this.sessionfactory = sessionfactory; - } - - @SuppressWarnings("unchecked") - @Override - public List<ClosedLoopD2Services> getClosedLoopD2ServicesData() { - Session session = HibernateSession.getSessionFactory(); - Transaction tx = session.beginTransaction(); - List<ClosedLoopD2Services> closedLoopD2ServicesData = null; - try { - Criteria cr = session.createCriteria(ClosedLoopD2Services.class); - closedLoopD2ServicesData = cr.list(); - tx.commit(); - } catch (Exception e) { - logger.error(XACMLErrorConstants.ERROR_PROCESS_FLOW + "Error While Querying ClosedLoopD2Services Table"+e); - }finally{ - try{ - session.close(); - }catch(Exception e1){ - logger.error(XACMLErrorConstants.ERROR_PROCESS_FLOW + "Error While Closing Connection/Statement"+e1); - } - } - return closedLoopD2ServicesData; - - } - - @Override - public void Save(ClosedLoopD2Services closedLoopD2Services) { - Session session = HibernateSession.getSessionFactory(); - Transaction tx = session.beginTransaction(); - try { - session.persist(closedLoopD2Services); - tx.commit(); - }catch(Exception e){ - logger.error(XACMLErrorConstants.ERROR_PROCESS_FLOW + "Error While Saving ClosedLoopD2Services Table"+e); - }finally{ - try{ - session.close(); - }catch(Exception e1){ - logger.error(XACMLErrorConstants.ERROR_PROCESS_FLOW + "Error While Closing Connection/Statement"+e1); - } - } - - } - - @Override - public void delete(ClosedLoopD2Services closedLoopD2Services) { - Session session = HibernateSession.getSessionFactory(); - Transaction tx = session.beginTransaction(); - try { - session.delete(closedLoopD2Services); - tx.commit(); - }catch(Exception e){ - logger.error(XACMLErrorConstants.ERROR_PROCESS_FLOW + "Error While Deleting ClosedLoopD2Services Table"+e); - }finally{ - try{ - session.close(); - }catch(Exception e1){ - logger.error(XACMLErrorConstants.ERROR_PROCESS_FLOW + "Error While Closing Connection/Statement"+e1); - } - } - } - - @Override - public void update(ClosedLoopD2Services closedLoopD2Services) { - Session session = HibernateSession.getSessionFactory(); - Transaction tx = session.beginTransaction(); - try { - session.update(closedLoopD2Services); - tx.commit(); - }catch(Exception e){ - logger.error(XACMLErrorConstants.ERROR_PROCESS_FLOW + "Error While Updating ClosedLoopD2Services Table"+e); - }finally{ - try{ - session.close(); - }catch(Exception e1){ - logger.error(XACMLErrorConstants.ERROR_PROCESS_FLOW + "Error While Closing Connection/Statement"+e1); - } - } - } - - @SuppressWarnings("unchecked") - @Override - public List<String> getCLServiceDictDataByName() { - Session session = HibernateSession.getSessionFactory(); - Transaction tx = session.beginTransaction(); - List<String> data = new ArrayList<String>(); - try { - Criteria cr = session.createCriteria(ClosedLoopD2Services.class); - List<ClosedLoopD2Services> closedLoopD2ServicesData = cr.list(); - for(int i = 0; i < closedLoopD2ServicesData.size(); i++){ - data.add(closedLoopD2ServicesData.get(i).getServiceName()); - } - tx.commit(); - } catch (Exception e) { - logger.error(XACMLErrorConstants.ERROR_PROCESS_FLOW + "Error While Querying ClosedLoopD2Services Table"+e); - }finally{ - try{ - session.close(); - }catch(Exception e1){ - logger.error(XACMLErrorConstants.ERROR_PROCESS_FLOW + "Error While Closing Connection/Statement"+e1); - } - } - return data; - } - -} diff --git a/ECOMP-PAP-REST/src/main/java/org/openecomp/policy/pap/xacml/rest/daoimpl/ServiceGroupDaoImpl.java b/ECOMP-PAP-REST/src/main/java/org/openecomp/policy/pap/xacml/rest/daoimpl/ServiceGroupDaoImpl.java deleted file mode 100644 index 725631306..000000000 --- a/ECOMP-PAP-REST/src/main/java/org/openecomp/policy/pap/xacml/rest/daoimpl/ServiceGroupDaoImpl.java +++ /dev/null @@ -1,158 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * ECOMP-PAP-REST - * ================================================================================ - * Copyright (C) 2017 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. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============LICENSE_END========================================================= - */ - -package org.openecomp.policy.pap.xacml.rest.daoimpl; - -import java.util.ArrayList; -import java.util.List; - -import org.apache.commons.logging.Log; -import org.apache.commons.logging.LogFactory; -import org.hibernate.Criteria; -import org.hibernate.Session; -import org.hibernate.SessionFactory; -import org.hibernate.Transaction; -import org.openecomp.policy.pap.xacml.rest.HibernateSession; -import org.openecomp.policy.rest.dao.ServiceGroupDao; -import org.openecomp.policy.rest.jpa.GroupServiceList; -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.stereotype.Service; - -import org.openecomp.policy.xacml.api.XACMLErrorConstants; - -@Service("ServiceGroupDao") -public class ServiceGroupDaoImpl implements ServiceGroupDao{ - private static final Log logger = LogFactory.getLog(ServiceGroupDaoImpl.class); - @Autowired - SessionFactory sessionfactory; - - public SessionFactory getSessionfactory() { - return sessionfactory; - } - - public void setSessionfactory(SessionFactory sessionfactory) { - this.sessionfactory = sessionfactory; - } - - @SuppressWarnings("unchecked") - @Override - public List<GroupServiceList> getGroupServiceListData() { - Session session = HibernateSession.getSessionFactory(); - Transaction tx = session.beginTransaction(); - List<GroupServiceList> attributeData = null; - try { - Criteria cr = session.createCriteria(GroupServiceList.class); - attributeData = cr.list(); - tx.commit(); - } catch (Exception e) { - logger.error(XACMLErrorConstants.ERROR_PROCESS_FLOW + "Error While Querying GroupServiceList Table"+e); - }finally{ - try{ - session.close(); - }catch(Exception e1){ - logger.error(XACMLErrorConstants.ERROR_PROCESS_FLOW + "Error While Closing Connection/Statement"+e1); - } - } - return attributeData; - - } - - @Override - public void Save(GroupServiceList attribute) { - Session session = HibernateSession.getSessionFactory(); - Transaction tx = session.beginTransaction(); - try { - session.persist(attribute); - tx.commit(); - }catch(Exception e){ - logger.error(XACMLErrorConstants.ERROR_PROCESS_FLOW + "Error While Saving GroupServiceList Table"+e); - }finally{ - try{ - session.close(); - }catch(Exception e1){ - logger.error(XACMLErrorConstants.ERROR_PROCESS_FLOW + "Error While Closing Connection/Statement"+e1); - } - } - - } - - @Override - public void delete(GroupServiceList attribute) { - Session session = HibernateSession.getSessionFactory(); - Transaction tx = session.beginTransaction(); - try { - session.delete(attribute); - tx.commit(); - }catch(Exception e){ - logger.error(XACMLErrorConstants.ERROR_PROCESS_FLOW + "Error While Deleting GroupServiceList Table"+e); - }finally{ - try{ - session.close(); - }catch(Exception e1){ - logger.error(XACMLErrorConstants.ERROR_PROCESS_FLOW + "Error While Closing Connection/Statement"+e1); - } - } - } - - @Override - public void update(GroupServiceList attribute) { - Session session = HibernateSession.getSessionFactory(); - Transaction tx = session.beginTransaction(); - try { - session.update(attribute); - tx.commit(); - }catch(Exception e){ - logger.error(XACMLErrorConstants.ERROR_PROCESS_FLOW + "Error While Updating GroupServiceList Table"+e); - }finally{ - try{ - session.close(); - }catch(Exception e1){ - logger.error(XACMLErrorConstants.ERROR_PROCESS_FLOW + "Error While Closing Connection/Statement"+e1); - } - } - - } - - @SuppressWarnings("unchecked") - @Override - public List<String> getGroupServiceDataByName() { - Session session = HibernateSession.getSessionFactory(); - Transaction tx = session.beginTransaction(); - List<String> data = new ArrayList<String>(); - try { - Criteria cr = session.createCriteria(GroupServiceList.class); - List<GroupServiceList> attributeData = cr.list(); - for(int i = 0; i < attributeData.size(); i++){ - data.add(attributeData.get(i).getGroupName()); - } - tx.commit(); - } catch (Exception e) { - logger.error(XACMLErrorConstants.ERROR_PROCESS_FLOW + "Error While Querying GroupServiceList Table"+e); - }finally{ - try{ - session.close(); - }catch(Exception e1){ - logger.error(XACMLErrorConstants.ERROR_PROCESS_FLOW + "Error While Closing Connection/Statement"+e1); - } - } - return data; - } - -} diff --git a/ECOMP-PAP-REST/src/main/java/org/openecomp/policy/pap/xacml/rest/daoimpl/ServiceListDaoImpl.java b/ECOMP-PAP-REST/src/main/java/org/openecomp/policy/pap/xacml/rest/daoimpl/ServiceListDaoImpl.java deleted file mode 100644 index 01ff3e4fc..000000000 --- a/ECOMP-PAP-REST/src/main/java/org/openecomp/policy/pap/xacml/rest/daoimpl/ServiceListDaoImpl.java +++ /dev/null @@ -1,159 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * ECOMP-PAP-REST - * ================================================================================ - * Copyright (C) 2017 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. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============LICENSE_END========================================================= - */ - -package org.openecomp.policy.pap.xacml.rest.daoimpl; - -import java.util.ArrayList; -import java.util.List; - -import org.apache.commons.logging.Log; -import org.apache.commons.logging.LogFactory; -import org.hibernate.Criteria; -import org.hibernate.Session; -import org.hibernate.SessionFactory; -import org.hibernate.Transaction; -import org.openecomp.policy.pap.xacml.rest.HibernateSession; -import org.openecomp.policy.rest.dao.ServiceListDao; -import org.openecomp.policy.rest.jpa.ServiceList; -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.stereotype.Service; - -import org.openecomp.policy.xacml.api.XACMLErrorConstants; - -@Service("ServiceListDao") -public class ServiceListDaoImpl implements ServiceListDao { - private static final Log logger = LogFactory.getLog(ServiceListDaoImpl.class); - @Autowired - SessionFactory sessionfactory; - - public SessionFactory getSessionfactory() { - return sessionfactory; - } - - public void setSessionfactory(SessionFactory sessionfactory) { - this.sessionfactory = sessionfactory; - } - - @SuppressWarnings("unchecked") - @Override - public List<ServiceList> getServiceListData() { - Session session = HibernateSession.getSessionFactory(); - Transaction tx = session.beginTransaction(); - List<ServiceList> attributeData = null; - try { - Criteria cr = session.createCriteria(ServiceList.class); - attributeData = cr.list(); - tx.commit(); - } catch (Exception e) { - logger.error(XACMLErrorConstants.ERROR_PROCESS_FLOW + "Error While Querying ServiceList Table"+e); - }finally{ - try{ - session.close(); - }catch(Exception e1){ - logger.error(XACMLErrorConstants.ERROR_PROCESS_FLOW + "Error While Closing Connection/Statement"+e1); - } - } - return attributeData; - - } - - @Override - public void Save(ServiceList attribute) { - Session session = HibernateSession.getSessionFactory(); - Transaction tx = session.beginTransaction(); - try { - session.persist(attribute); - tx.commit(); - }catch(Exception e){ - logger.error(XACMLErrorConstants.ERROR_PROCESS_FLOW + "Error While Saving ServiceList Table"+e); - }finally{ - try{ - session.close(); - }catch(Exception e1){ - logger.error(XACMLErrorConstants.ERROR_PROCESS_FLOW + "Error While Closing Connection/Statement"+e1); - } - } - - } - - @Override - public void delete(ServiceList attribute) { - Session session = HibernateSession.getSessionFactory(); - Transaction tx = session.beginTransaction(); - try { - session.delete(attribute); - tx.commit(); - }catch(Exception e){ - logger.error(XACMLErrorConstants.ERROR_PROCESS_FLOW + "Error While Deleting ServiceList Table"+e); - }finally{ - try{ - session.close(); - }catch(Exception e1){ - logger.error(XACMLErrorConstants.ERROR_PROCESS_FLOW + "Error While Closing Connection/Statement"+e1); - } - } - } - - @Override - public void update(ServiceList attribute) { - Session session = HibernateSession.getSessionFactory(); - Transaction tx = session.beginTransaction(); - try { - session.update(attribute); - tx.commit(); - }catch(Exception e){ - logger.error(XACMLErrorConstants.ERROR_PROCESS_FLOW + "Error While Updating ServiceList Table"+e); - }finally{ - try{ - session.close(); - }catch(Exception e1){ - logger.error(XACMLErrorConstants.ERROR_PROCESS_FLOW + "Error While Closing Connection/Statement"+e1); - } - } - - } - - @SuppressWarnings("unchecked") - @Override - public List<String> getServiceListDataByName() { - Session session = HibernateSession.getSessionFactory(); - Transaction tx = session.beginTransaction(); - List<String> data = new ArrayList<String>(); - try { - Criteria cr = session.createCriteria(ServiceList.class); - List<ServiceList> attributeData = cr.list(); - for(int i = 0; i < attributeData.size(); i++){ - data.add(attributeData.get(i).getServiceName()); - } - tx.commit(); - } catch (Exception e) { - logger.error(XACMLErrorConstants.ERROR_PROCESS_FLOW + "Error While Querying ServiceList Table"+e); - }finally{ - try{ - session.close(); - }catch(Exception e1){ - logger.error(XACMLErrorConstants.ERROR_PROCESS_FLOW + "Error While Closing Connection/Statement"+e1); - } - } - return data; - - } - -} diff --git a/ECOMP-PAP-REST/src/main/java/org/openecomp/policy/pap/xacml/rest/daoimpl/SiteDictionaryDaoImpl.java b/ECOMP-PAP-REST/src/main/java/org/openecomp/policy/pap/xacml/rest/daoimpl/SiteDictionaryDaoImpl.java deleted file mode 100644 index 3b2a75176..000000000 --- a/ECOMP-PAP-REST/src/main/java/org/openecomp/policy/pap/xacml/rest/daoimpl/SiteDictionaryDaoImpl.java +++ /dev/null @@ -1,159 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * ECOMP-PAP-REST - * ================================================================================ - * Copyright (C) 2017 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. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============LICENSE_END========================================================= - */ - -package org.openecomp.policy.pap.xacml.rest.daoimpl; - -import java.util.ArrayList; -import java.util.List; - -import org.apache.commons.logging.Log; -import org.apache.commons.logging.LogFactory; -import org.hibernate.Criteria; -import org.hibernate.Session; -import org.hibernate.SessionFactory; -import org.hibernate.Transaction; -import org.openecomp.policy.pap.xacml.rest.HibernateSession; -import org.openecomp.policy.rest.dao.SiteDictionaryDao; -import org.openecomp.policy.rest.jpa.ClosedLoopSite; -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.stereotype.Service; - -import org.openecomp.policy.xacml.api.XACMLErrorConstants; - - -@Service("SiteDictionaryDao") -public class SiteDictionaryDaoImpl implements SiteDictionaryDao { - private static final Log logger = LogFactory.getLog(SiteDictionaryDaoImpl.class); - @Autowired - SessionFactory sessionfactory; - - public SessionFactory getSessionfactory() { - return sessionfactory; - } - - public void setSessionfactory(SessionFactory sessionfactory) { - this.sessionfactory = sessionfactory; - } - - @SuppressWarnings("unchecked") - @Override - public List<ClosedLoopSite> getClosedLoopSiteData() { - Session session = HibernateSession.getSessionFactory(); - Transaction tx = session.beginTransaction(); - List<ClosedLoopSite> closedLoopSiteData = null; - try { - Criteria cr = session.createCriteria(ClosedLoopSite.class); - closedLoopSiteData = cr.list(); - tx.commit(); - } catch (Exception e) { - logger.error(XACMLErrorConstants.ERROR_PROCESS_FLOW + "Error While Querying ClosedLoopSite Table"+e); - }finally{ - try{ - session.close(); - }catch(Exception e1){ - logger.error(XACMLErrorConstants.ERROR_PROCESS_FLOW + "Error While Closing Connection/Statement"+e1); - } - } - return closedLoopSiteData; - - } - - @Override - public void Save(ClosedLoopSite closedLoopSite) { - Session session = HibernateSession.getSessionFactory(); - Transaction tx = session.beginTransaction(); - try { - session.persist(closedLoopSite); - tx.commit(); - }catch(Exception e){ - logger.error(XACMLErrorConstants.ERROR_PROCESS_FLOW + "Error While Saving ClosedLoopSite Table"+e); - }finally{ - try{ - session.close(); - }catch(Exception e1){ - logger.error(XACMLErrorConstants.ERROR_PROCESS_FLOW + "Error While Closing Connection/Statement"+e1); - } - } - - } - - @Override - public void delete(ClosedLoopSite closedLoopSite) { - Session session = HibernateSession.getSessionFactory(); - Transaction tx = session.beginTransaction(); - try { - session.delete(closedLoopSite); - tx.commit(); - }catch(Exception e){ - logger.error(XACMLErrorConstants.ERROR_PROCESS_FLOW + "Error While Deleting ClosedLoopSite Table"+e); - }finally{ - try{ - session.close(); - }catch(Exception e1){ - logger.error(XACMLErrorConstants.ERROR_PROCESS_FLOW + "Error While Closing Connection/Statement"+e1); - } - } - } - - @Override - public void update(ClosedLoopSite closedLoopSite) { - Session session = HibernateSession.getSessionFactory(); - Transaction tx = session.beginTransaction(); - try { - session.update(closedLoopSite); - tx.commit(); - }catch(Exception e){ - logger.error(XACMLErrorConstants.ERROR_PROCESS_FLOW + "Error While Updating ClosedLoopSite Table"+e); - }finally{ - try{ - session.close(); - }catch(Exception e1){ - logger.error(XACMLErrorConstants.ERROR_PROCESS_FLOW + "Error While Closing Connection/Statement"+e1); - } - } - - } - - @SuppressWarnings("unchecked") - @Override - public List<String> getCLSiteDataByName() { - Session session = HibernateSession.getSessionFactory(); - Transaction tx = session.beginTransaction(); - List<String> data = new ArrayList<String>(); - try { - Criteria cr = session.createCriteria(ClosedLoopSite.class); - List<ClosedLoopSite> closedLoopSiteData = cr.list(); - for(int i = 0; i < closedLoopSiteData.size(); i++){ - data.add(closedLoopSiteData.get(i).getSiteName()); - } - tx.commit(); - } catch (Exception e) { - logger.error(XACMLErrorConstants.ERROR_PROCESS_FLOW + "Error While Querying ClosedLoopSite Table"+e); - }finally{ - try{ - session.close(); - }catch(Exception e1){ - logger.error(XACMLErrorConstants.ERROR_PROCESS_FLOW + "Error While Closing Connection/Statement"+e1); - } - } - return data; - } - -} diff --git a/ECOMP-PAP-REST/src/main/java/org/openecomp/policy/pap/xacml/rest/daoimpl/TermListDaoImpl.java b/ECOMP-PAP-REST/src/main/java/org/openecomp/policy/pap/xacml/rest/daoimpl/TermListDaoImpl.java deleted file mode 100644 index 7568d60b0..000000000 --- a/ECOMP-PAP-REST/src/main/java/org/openecomp/policy/pap/xacml/rest/daoimpl/TermListDaoImpl.java +++ /dev/null @@ -1,181 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * ECOMP-PAP-REST - * ================================================================================ - * Copyright (C) 2017 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. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============LICENSE_END========================================================= - */ - -package org.openecomp.policy.pap.xacml.rest.daoimpl; - -import java.util.ArrayList; -import java.util.List; - -import org.apache.commons.logging.Log; -import org.apache.commons.logging.LogFactory; -import org.hibernate.Criteria; -import org.hibernate.Session; -import org.hibernate.SessionFactory; -import org.hibernate.Transaction; -import org.hibernate.criterion.Restrictions; -import org.openecomp.policy.pap.xacml.rest.HibernateSession; -import org.openecomp.policy.rest.dao.TermListDao; -import org.openecomp.policy.rest.jpa.TermList; -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.stereotype.Service; - -import org.openecomp.policy.xacml.api.XACMLErrorConstants; - -@Service("TermListDao") -public class TermListDaoImpl implements TermListDao{ - private static final Log logger = LogFactory.getLog(TermListDaoImpl.class); - @Autowired - SessionFactory sessionfactory; - - public SessionFactory getSessionfactory() { - return sessionfactory; - } - - public void setSessionfactory(SessionFactory sessionfactory) { - this.sessionfactory = sessionfactory; - } - - @SuppressWarnings("unchecked") - @Override - public List<TermList> getTermListData() { - Session session = HibernateSession.getSessionFactory(); - Transaction tx = session.beginTransaction(); - List<TermList> attributeData = null; - try { - Criteria cr = session.createCriteria(TermList.class); - attributeData = cr.list(); - tx.commit(); - } catch (Exception e) { - logger.error(XACMLErrorConstants.ERROR_PROCESS_FLOW + "Error While Querying TermList Table"+e); - }finally{ - try{ - session.close(); - }catch(Exception e1){ - logger.error(XACMLErrorConstants.ERROR_PROCESS_FLOW + "Error While Closing Connection/Statement"+e1); - } - } - return attributeData; - - } - - @Override - public void Save(TermList attribute) { - Session session = HibernateSession.getSessionFactory(); - Transaction tx = session.beginTransaction(); - try { - session.persist(attribute); - tx.commit(); - }catch(Exception e){ - logger.error(XACMLErrorConstants.ERROR_PROCESS_FLOW + "Error While Saving TermList Table"+e); - }finally{ - try{ - session.close(); - }catch(Exception e1){ - logger.error(XACMLErrorConstants.ERROR_PROCESS_FLOW + "Error While Closing Connection/Statement"+e1); - } - } - - } - - @Override - public void delete(TermList attribute) { - Session session = HibernateSession.getSessionFactory(); - Transaction tx = session.beginTransaction(); - try { - session.delete(attribute); - tx.commit(); - }catch(Exception e){ - logger.error(XACMLErrorConstants.ERROR_PROCESS_FLOW + "Error While Deleting TermList Table"+e); - }finally{ - try{ - session.close(); - }catch(Exception e1){ - logger.error(XACMLErrorConstants.ERROR_PROCESS_FLOW + "Error While Closing Connection/Statement"+e1); - } - } - } - - @Override - public void update(TermList attribute) { - Session session = HibernateSession.getSessionFactory(); - Transaction tx = session.beginTransaction(); - try { - session.update(attribute); - tx.commit(); - }catch(Exception e){ - logger.error(XACMLErrorConstants.ERROR_PROCESS_FLOW + "Error While Updating TermList Table"+e); - }finally{ - try{ - session.close(); - }catch(Exception e1){ - logger.error(XACMLErrorConstants.ERROR_PROCESS_FLOW + "Error While Closing Connection/Statement"+e1); - } - } - - } - - @SuppressWarnings("unchecked") - @Override - public List<String> getTermListDataByName() { - Session session = HibernateSession.getSessionFactory(); - Transaction tx = session.beginTransaction(); - List<String> data = new ArrayList<String>(); - try { - Criteria cr = session.createCriteria(TermList.class); - List<TermList> attributeData = cr.list(); - for(int i = 0; i < attributeData.size(); i++){ - data.add(attributeData.get(i).getTermName()); - } - tx.commit(); - } catch (Exception e) { - logger.error(XACMLErrorConstants.ERROR_PROCESS_FLOW + "Error While Querying TermList Table"+e); - }finally{ - try{ - session.close(); - }catch(Exception e1){ - logger.error(XACMLErrorConstants.ERROR_PROCESS_FLOW + "Error While Closing Connection/Statement"+e1); - } - } - return data; - } - - @Override - public TermList getTermListValueByName(String name) { - Session session = HibernateSession.getSessionFactory(); - Transaction tx = session.beginTransaction(); - TermList data = null; - try { - Criteria cr = session.createCriteria(TermList.class); - cr.add(Restrictions.eq("termName",name)); - data = (TermList) cr.list().get(0); - tx.commit(); - } catch (Exception e) { - logger.error(XACMLErrorConstants.ERROR_PROCESS_FLOW + "Error While Querying TermList Table"+e); - }finally{ - try{ - session.close(); - }catch(Exception e1){ - logger.error(XACMLErrorConstants.ERROR_PROCESS_FLOW + "Error While Closing Connection/Statement"+e1); - } - } - return data; - } - -} diff --git a/ECOMP-PAP-REST/src/main/java/org/openecomp/policy/pap/xacml/rest/daoimpl/UserInfoDaoImpl.java b/ECOMP-PAP-REST/src/main/java/org/openecomp/policy/pap/xacml/rest/daoimpl/UserInfoDaoImpl.java deleted file mode 100644 index 04ad69c1a..000000000 --- a/ECOMP-PAP-REST/src/main/java/org/openecomp/policy/pap/xacml/rest/daoimpl/UserInfoDaoImpl.java +++ /dev/null @@ -1,138 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * ECOMP-PAP-REST - * ================================================================================ - * Copyright (C) 2017 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. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============LICENSE_END========================================================= - */ - -package org.openecomp.policy.pap.xacml.rest.daoimpl; - -import java.util.List; - -import org.apache.commons.logging.Log; -import org.apache.commons.logging.LogFactory; -import org.hibernate.Criteria; -import org.hibernate.Session; -import org.hibernate.SessionFactory; -import org.hibernate.Transaction; -import org.hibernate.criterion.Restrictions; -import org.openecomp.policy.pap.xacml.rest.HibernateSession; -import org.openecomp.policy.rest.dao.UserInfoDao; -import org.openecomp.policy.rest.jpa.UserInfo; -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.stereotype.Service; - -import org.openecomp.policy.xacml.api.XACMLErrorConstants; - - -@Service("UserInfoDao") -public class UserInfoDaoImpl implements UserInfoDao{ - private static final Log logger = LogFactory.getLog(UserInfoDaoImpl.class); - @Autowired - SessionFactory sessionfactory; - - public SessionFactory getSessionfactory() { - return sessionfactory; - } - - public void setSessionfactory(SessionFactory sessionfactory) { - this.sessionfactory = sessionfactory; - } - - @Override - public void save(UserInfo userInfo) { - Session session = HibernateSession.getSessionFactory(); - Transaction tx = session.beginTransaction(); - try { - session.persist(userInfo); - tx.commit(); - }catch(Exception e){ - logger.error(XACMLErrorConstants.ERROR_PROCESS_FLOW + "Error While Saving UserInfo Table"+e); - }finally{ - try{ - session.close(); - }catch(Exception e1){ - logger.error(XACMLErrorConstants.ERROR_PROCESS_FLOW + "Error While Closing Connection/Statement"+e1); - } - } - } - - @SuppressWarnings("unchecked") - @Override - public List<UserInfo> getUserInfo() { - System.out.println("UserInfoDaoImpl: getUserInfo().. getting user info before save()"); - Session session = HibernateSession.getSessionFactory(); - Transaction tx = session.beginTransaction(); - List<UserInfo> userData = null; - try { - Criteria cr = session.createCriteria(UserInfo.class); - userData = cr.list(); - tx.commit(); - } catch (Exception e) { - logger.error(XACMLErrorConstants.ERROR_PROCESS_FLOW + "Error While Querying UserInfo Table"+e); - }finally{ - try{ - session.close(); - }catch(Exception e1){ - logger.error(XACMLErrorConstants.ERROR_PROCESS_FLOW + "Error While Closing Connection/Statement"+e1); - } - } - return userData; - } - - @Override - public String getUserName(String loginid) { - Session session = HibernateSession.getSessionFactory(); - Transaction tx = session.beginTransaction(); - UserInfo user = null; - try { - user = (UserInfo) session.get(UserInfo.class, loginid); - tx.commit(); - } catch (Exception e) { - logger.error(XACMLErrorConstants.ERROR_PROCESS_FLOW + "Error While Querying UserInfo Table"+e); - }finally{ - try{ - session.close(); - }catch(Exception e1){ - logger.error(XACMLErrorConstants.ERROR_PROCESS_FLOW + "Error While Closing Connection/Statement"+e1); - } - } - return user.getUserName().toString(); - } - - @Override - public UserInfo getUserInfoByLoginId(String loginid) { - Session session = HibernateSession.getSessionFactory(); - Transaction tx = session.beginTransaction(); - UserInfo userData = null; - try { - Criteria cr = session.createCriteria(UserInfo.class); - cr.add(Restrictions.eq("userLoginId", loginid)); - userData = (UserInfo) cr.list().get(0); - tx.commit(); - } catch (Exception e) { - logger.error(XACMLErrorConstants.ERROR_PROCESS_FLOW + "Error While Querying UserInfo Table"+e); - }finally{ - try{ - session.close(); - }catch(Exception e1){ - logger.error(XACMLErrorConstants.ERROR_PROCESS_FLOW + "Error While Closing Connection/Statement"+e1); - } - } - return userData; - } - -} diff --git a/ECOMP-PAP-REST/src/main/java/org/openecomp/policy/pap/xacml/rest/daoimpl/VNFTypeDaoImpl.java b/ECOMP-PAP-REST/src/main/java/org/openecomp/policy/pap/xacml/rest/daoimpl/VNFTypeDaoImpl.java deleted file mode 100644 index 4d424fa9f..000000000 --- a/ECOMP-PAP-REST/src/main/java/org/openecomp/policy/pap/xacml/rest/daoimpl/VNFTypeDaoImpl.java +++ /dev/null @@ -1,158 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * ECOMP-PAP-REST - * ================================================================================ - * Copyright (C) 2017 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. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============LICENSE_END========================================================= - */ - -package org.openecomp.policy.pap.xacml.rest.daoimpl; - -import java.util.ArrayList; -import java.util.List; - -import org.apache.commons.logging.Log; -import org.apache.commons.logging.LogFactory; -import org.hibernate.Criteria; -import org.hibernate.Session; -import org.hibernate.SessionFactory; -import org.hibernate.Transaction; -import org.openecomp.policy.pap.xacml.rest.HibernateSession; -import org.openecomp.policy.rest.dao.VNFTypeDao; -import org.openecomp.policy.rest.jpa.VNFType; -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.stereotype.Service; - -import org.openecomp.policy.xacml.api.XACMLErrorConstants; - -@Service("VNFTypeDao") -public class VNFTypeDaoImpl implements VNFTypeDao { - private static final Log logger = LogFactory.getLog(VNFTypeDaoImpl.class); - @Autowired - SessionFactory sessionfactory; - - public SessionFactory getSessionfactory() { - return sessionfactory; - } - - public void setSessionfactory(SessionFactory sessionfactory) { - this.sessionfactory = sessionfactory; - } - - @SuppressWarnings("unchecked") - @Override - public List<VNFType> getVNFTypeData() { - Session session = HibernateSession.getSessionFactory(); - Transaction tx = session.beginTransaction(); - List<VNFType> vnfTypeData = null; - try { - Criteria cr = session.createCriteria(VNFType.class); - vnfTypeData = cr.list(); - tx.commit(); - } catch (Exception e) { - logger.error(XACMLErrorConstants.ERROR_PROCESS_FLOW + "Error While Querying VNFType Table"+e); - }finally{ - try{ - session.close(); - }catch(Exception e1){ - logger.error(XACMLErrorConstants.ERROR_PROCESS_FLOW + "Error While Closing Connection/Statement"+e1); - } - } - return vnfTypeData; - - } - - @Override - public void Save(VNFType vnfType) { - Session session = HibernateSession.getSessionFactory(); - Transaction tx = session.beginTransaction(); - try { - session.persist(vnfType); - tx.commit(); - }catch(Exception e){ - logger.error(XACMLErrorConstants.ERROR_PROCESS_FLOW + "Error While Saving VNFType Table"+e); - }finally{ - try{ - session.close(); - }catch(Exception e1){ - logger.error(XACMLErrorConstants.ERROR_PROCESS_FLOW + "Error While Closing Connection/Statement"+e1); - } - } - - } - - @Override - public void delete(VNFType vnfType) { - Session session = HibernateSession.getSessionFactory(); - Transaction tx = session.beginTransaction(); - try { - session.delete(vnfType); - tx.commit(); - }catch(Exception e){ - logger.error(XACMLErrorConstants.ERROR_PROCESS_FLOW + "Error While Deleting VNFType Table"+e); - }finally{ - try{ - session.close(); - }catch(Exception e1){ - logger.error(XACMLErrorConstants.ERROR_PROCESS_FLOW + "Error While Closing Connection/Statement"+e1); - } - } - } - - @Override - public void update(VNFType vnfType) { - Session session = HibernateSession.getSessionFactory(); - Transaction tx = session.beginTransaction(); - try { - session.update(vnfType); - tx.commit(); - }catch(Exception e){ - logger.error(XACMLErrorConstants.ERROR_PROCESS_FLOW + "Error While Updating VNFType Table"+e); - }finally{ - try{ - session.close(); - }catch(Exception e1){ - logger.error(XACMLErrorConstants.ERROR_PROCESS_FLOW + "Error While Closing Connection/Statement"+e1); - } - } - - } - - @SuppressWarnings("unchecked") - @Override - public List<String> getVNFTypeDataByName() { - Session session = HibernateSession.getSessionFactory(); - Transaction tx = session.beginTransaction(); - List<String> data = new ArrayList<String>(); - try { - Criteria cr = session.createCriteria(VNFType.class); - List<VNFType> vnfTypeData = cr.list(); - for(int i = 0; i < vnfTypeData.size(); i++){ - data.add(vnfTypeData.get(i).getVnftype()); - } - tx.commit(); - } catch (Exception e) { - logger.error(XACMLErrorConstants.ERROR_PROCESS_FLOW + "Error While Querying VNFType Table"+e); - }finally{ - try{ - session.close(); - }catch(Exception e1){ - logger.error(XACMLErrorConstants.ERROR_PROCESS_FLOW + "Error While Closing Connection/Statement"+e1); - } - } - return data; - - } -} diff --git a/ECOMP-PAP-REST/src/main/java/org/openecomp/policy/pap/xacml/rest/daoimpl/VSCLActionDaoImpl.java b/ECOMP-PAP-REST/src/main/java/org/openecomp/policy/pap/xacml/rest/daoimpl/VSCLActionDaoImpl.java deleted file mode 100644 index 8ab6bfd19..000000000 --- a/ECOMP-PAP-REST/src/main/java/org/openecomp/policy/pap/xacml/rest/daoimpl/VSCLActionDaoImpl.java +++ /dev/null @@ -1,158 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * ECOMP-PAP-REST - * ================================================================================ - * Copyright (C) 2017 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. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============LICENSE_END========================================================= - */ - -package org.openecomp.policy.pap.xacml.rest.daoimpl; - -import java.util.ArrayList; -import java.util.List; - -import org.apache.commons.logging.Log; -import org.apache.commons.logging.LogFactory; -import org.hibernate.Criteria; -import org.hibernate.Session; -import org.hibernate.SessionFactory; -import org.hibernate.Transaction; -import org.openecomp.policy.pap.xacml.rest.HibernateSession; -import org.openecomp.policy.rest.dao.VSCLActionDao; -import org.openecomp.policy.rest.jpa.VSCLAction; -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.stereotype.Service; - -import org.openecomp.policy.xacml.api.XACMLErrorConstants; - -@Service("VSCLActionDao") -public class VSCLActionDaoImpl implements VSCLActionDao{ - private static final Log logger = LogFactory.getLog(VSCLActionDaoImpl.class); - @Autowired - SessionFactory sessionfactory; - - public SessionFactory getSessionfactory() { - return sessionfactory; - } - - public void setSessionfactory(SessionFactory sessionfactory) { - this.sessionfactory = sessionfactory; - } - - @SuppressWarnings("unchecked") - @Override - public List<VSCLAction> getVSCLActionData() { - Session session = HibernateSession.getSessionFactory(); - Transaction tx = session.beginTransaction(); - List<VSCLAction> vSCLActionData = null; - try { - Criteria cr = session.createCriteria(VSCLAction.class); - vSCLActionData = cr.list(); - tx.commit(); - } catch (Exception e) { - logger.error(XACMLErrorConstants.ERROR_PROCESS_FLOW + "Error While Querying VSCLAction Table"+e); - }finally{ - try{ - session.close(); - }catch(Exception e1){ - logger.error(XACMLErrorConstants.ERROR_PROCESS_FLOW + "Error While Closing Connection/Statement"+e1); - } - } - return vSCLActionData; - - } - - @Override - public void Save(VSCLAction vSCLAction) { - Session session = HibernateSession.getSessionFactory(); - Transaction tx = session.beginTransaction(); - try { - session.persist(vSCLAction); - tx.commit(); - }catch(Exception e){ - logger.error(XACMLErrorConstants.ERROR_PROCESS_FLOW + "Error While Saving VSCLAction Table"+e); - }finally{ - try{ - session.close(); - }catch(Exception e1){ - logger.error(XACMLErrorConstants.ERROR_PROCESS_FLOW + "Error While Closing Connection/Statement"+e1); - } - } - - } - - @Override - public void delete(VSCLAction vSCLAction) { - Session session = HibernateSession.getSessionFactory(); - Transaction tx = session.beginTransaction(); - try { - session.delete(vSCLAction); - tx.commit(); - }catch(Exception e){ - logger.error(XACMLErrorConstants.ERROR_PROCESS_FLOW + "Error While Deleting VSCLAction Table"+e); - }finally{ - try{ - session.close(); - }catch(Exception e1){ - logger.error(XACMLErrorConstants.ERROR_PROCESS_FLOW + "Error While Closing Connection/Statement"+e1); - } - } - } - - @Override - public void update(VSCLAction vSCLAction) { - Session session = HibernateSession.getSessionFactory(); - Transaction tx = session.beginTransaction(); - try { - session.update(vSCLAction); - tx.commit(); - }catch(Exception e){ - logger.error(XACMLErrorConstants.ERROR_PROCESS_FLOW + "Error While Updating VSCLAction Table"+e); - }finally{ - try{ - session.close(); - }catch(Exception e1){ - logger.error(XACMLErrorConstants.ERROR_PROCESS_FLOW + "Error While Closing Connection/Statement"+e1); - } - } - - } - - @SuppressWarnings("unchecked") - @Override - public List<String> getVsclActionDataByName() { - Session session = HibernateSession.getSessionFactory(); - Transaction tx = session.beginTransaction(); - List<String> data = new ArrayList<String>(); - try { - Criteria cr = session.createCriteria(VSCLAction.class); - List<VSCLAction> vSCLActionData = cr.list(); - for(int i = 0; i < vSCLActionData.size(); i++){ - data.add(vSCLActionData.get(i).getVsclaction()); - } - tx.commit(); - } catch (Exception e) { - logger.error(XACMLErrorConstants.ERROR_PROCESS_FLOW + "Error While Querying VSCLAction Table"+e); - }finally{ - try{ - session.close(); - }catch(Exception e1){ - logger.error(XACMLErrorConstants.ERROR_PROCESS_FLOW + "Error While Closing Connection/Statement"+e1); - } - } - return data; - } - -} diff --git a/ECOMP-PAP-REST/src/main/java/org/openecomp/policy/pap/xacml/rest/daoimpl/VarbindDictionaryDaoImpl.java b/ECOMP-PAP-REST/src/main/java/org/openecomp/policy/pap/xacml/rest/daoimpl/VarbindDictionaryDaoImpl.java deleted file mode 100644 index dba3a0d57..000000000 --- a/ECOMP-PAP-REST/src/main/java/org/openecomp/policy/pap/xacml/rest/daoimpl/VarbindDictionaryDaoImpl.java +++ /dev/null @@ -1,181 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * ECOMP-PAP-REST - * ================================================================================ - * Copyright (C) 2017 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. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============LICENSE_END========================================================= - */ - -package org.openecomp.policy.pap.xacml.rest.daoimpl; - -import java.util.ArrayList; -import java.util.List; - -import org.apache.commons.logging.Log; -import org.apache.commons.logging.LogFactory; -import org.hibernate.Criteria; -import org.hibernate.Session; -import org.hibernate.SessionFactory; -import org.hibernate.Transaction; -import org.hibernate.criterion.Restrictions; -import org.openecomp.policy.pap.xacml.rest.HibernateSession; -import org.openecomp.policy.rest.dao.VarbindDictionaryDao; -import org.openecomp.policy.rest.jpa.VarbindDictionary; -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.stereotype.Service; - -import org.openecomp.policy.xacml.api.XACMLErrorConstants; - -@Service("VarbindDictionaryDao") -public class VarbindDictionaryDaoImpl implements VarbindDictionaryDao { - private static final Log logger = LogFactory.getLog(VarbindDictionaryDaoImpl.class); - @Autowired - SessionFactory sessionfactory; - - public SessionFactory getSessionfactory() { - return sessionfactory; - } - - public void setSessionfactory(SessionFactory sessionfactory) { - this.sessionfactory = sessionfactory; - } - - @SuppressWarnings("unchecked") - @Override - public List<VarbindDictionary> getVarbindDictionaryData() { - Session session = HibernateSession.getSessionFactory(); - Transaction tx = session.beginTransaction(); - List<VarbindDictionary> varbindDictionaryData = null; - try { - Criteria cr = session.createCriteria(VarbindDictionary.class); - varbindDictionaryData = cr.list(); - tx.commit(); - } catch (Exception e) { - logger.error(XACMLErrorConstants.ERROR_PROCESS_FLOW + "Error While Querying VarbindDictionary Table"+e); - }finally{ - try{ - session.close(); - }catch(Exception e1){ - logger.error(XACMLErrorConstants.ERROR_PROCESS_FLOW + "Error While Closing Connection/Statement"+e1); - } - } - return varbindDictionaryData; - - } - - @Override - public void Save(VarbindDictionary varbindDictionary) { - Session session = HibernateSession.getSessionFactory(); - Transaction tx = session.beginTransaction(); - try { - session.persist(varbindDictionary); - tx.commit(); - }catch(Exception e){ - logger.error(XACMLErrorConstants.ERROR_PROCESS_FLOW + "Error While Saving VarbindDictionary Table"+e); - }finally{ - try{ - session.close(); - }catch(Exception e1){ - logger.error(XACMLErrorConstants.ERROR_PROCESS_FLOW + "Error While Closing Connection/Statement"+e1); - } - } - - } - - @Override - public void delete(VarbindDictionary varbindDictionary) { - Session session = HibernateSession.getSessionFactory(); - Transaction tx = session.beginTransaction(); - try { - session.delete(varbindDictionary); - tx.commit(); - }catch(Exception e){ - logger.error(XACMLErrorConstants.ERROR_PROCESS_FLOW + "Error While Deleting VarbindDictionary Table"+e); - }finally{ - try{ - session.close(); - }catch(Exception e1){ - logger.error(XACMLErrorConstants.ERROR_PROCESS_FLOW + "Error While Closing Connection/Statement"+e1); - } - } - } - - @Override - public void update(VarbindDictionary varbindDictionary) { - Session session = HibernateSession.getSessionFactory(); - Transaction tx = session.beginTransaction(); - try { - session.update(varbindDictionary); - tx.commit(); - }catch(Exception e){ - logger.error(XACMLErrorConstants.ERROR_PROCESS_FLOW + "Error While Updating VarbindDictionary Table"+e); - }finally{ - try{ - session.close(); - }catch(Exception e1){ - logger.error(XACMLErrorConstants.ERROR_PROCESS_FLOW + "Error While Closing Connection/Statement"+e1); - } - } - - } - - @SuppressWarnings("unchecked") - @Override - public List<String> getVarbindDataByName() { - Session session = HibernateSession.getSessionFactory(); - Transaction tx = session.beginTransaction(); - List<String> data = new ArrayList<String>(); - try { - Criteria cr = session.createCriteria(VarbindDictionary.class); - List<VarbindDictionary> varbindDictionaryData = cr.list(); - for(int i = 0; i < varbindDictionaryData.size(); i++){ - data.add(varbindDictionaryData.get(i).getVarbindName()); - } - tx.commit(); - } catch (Exception e) { - logger.error(XACMLErrorConstants.ERROR_PROCESS_FLOW + "Error While Querying VarbindDictionary Table"+e); - }finally{ - try{ - session.close(); - }catch(Exception e1){ - logger.error(XACMLErrorConstants.ERROR_PROCESS_FLOW + "Error While Closing Connection/Statement"+e1); - } - } - return data; - } - - @Override - public List<VarbindDictionary> getVarbindEntityByName(String value) { - Session session = HibernateSession.getSessionFactory(); - Transaction tx = session.beginTransaction(); - List<VarbindDictionary> data = null; - try { - Criteria cr = session.createCriteria(VarbindDictionary.class); - cr.add(Restrictions.eq("varbindName",value)); - data = cr.list(); - tx.commit(); - } catch (Exception e) { - logger.error(XACMLErrorConstants.ERROR_PROCESS_FLOW + "Error While Querying VarbindDictionary Table"+e); - }finally{ - try{ - session.close(); - }catch(Exception e1){ - logger.error(XACMLErrorConstants.ERROR_PROCESS_FLOW + "Error While Closing Connection/Statement"+e1); - } - } - return data; - } - -} diff --git a/ECOMP-PAP-REST/src/main/java/org/openecomp/policy/pap/xacml/rest/daoimpl/ZoneDaoImpl.java b/ECOMP-PAP-REST/src/main/java/org/openecomp/policy/pap/xacml/rest/daoimpl/ZoneDaoImpl.java deleted file mode 100644 index 865a08516..000000000 --- a/ECOMP-PAP-REST/src/main/java/org/openecomp/policy/pap/xacml/rest/daoimpl/ZoneDaoImpl.java +++ /dev/null @@ -1,159 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * ECOMP-PAP-REST - * ================================================================================ - * Copyright (C) 2017 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. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============LICENSE_END========================================================= - */ - -package org.openecomp.policy.pap.xacml.rest.daoimpl; - -import java.util.ArrayList; -import java.util.List; - -import org.apache.commons.logging.Log; -import org.apache.commons.logging.LogFactory; -import org.hibernate.Criteria; -import org.hibernate.Session; -import org.hibernate.SessionFactory; -import org.hibernate.Transaction; -import org.openecomp.policy.pap.xacml.rest.HibernateSession; -import org.openecomp.policy.rest.dao.ZoneDao; -import org.openecomp.policy.rest.jpa.Zone; -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.stereotype.Service; - -import org.openecomp.policy.xacml.api.XACMLErrorConstants; - -@Service("ZoneDao") -public class ZoneDaoImpl implements ZoneDao{ - private static final Log logger = LogFactory.getLog(ZoneDaoImpl.class); - @Autowired - SessionFactory sessionfactory; - - public SessionFactory getSessionfactory() { - return sessionfactory; - } - - public void setSessionfactory(SessionFactory sessionfactory) { - this.sessionfactory = sessionfactory; - } - - @SuppressWarnings("unchecked") - @Override - public List<Zone> getZoneData() { - Session session = HibernateSession.getSessionFactory(); - Transaction tx = session.beginTransaction(); - List<Zone> attributeData = null; - try { - Criteria cr = session.createCriteria(Zone.class); - attributeData = cr.list(); - tx.commit(); - } catch (Exception e) { - logger.error(XACMLErrorConstants.ERROR_PROCESS_FLOW + "Error While Querying Zone Table"+e); - }finally{ - try{ - session.close(); - }catch(Exception e1){ - logger.error(XACMLErrorConstants.ERROR_PROCESS_FLOW + "Error While Closing Connection/Statement"+e1); - } - } - return attributeData; - - } - - @Override - public void Save(Zone attribute) { - Session session = HibernateSession.getSessionFactory(); - Transaction tx = session.beginTransaction(); - try { - session.persist(attribute); - tx.commit(); - }catch(Exception e){ - logger.error(XACMLErrorConstants.ERROR_PROCESS_FLOW + "Error While Saving Zone Table"+e); - }finally{ - try{ - session.close(); - }catch(Exception e1){ - logger.error(XACMLErrorConstants.ERROR_PROCESS_FLOW + "Error While Closing Connection/Statement"+e1); - } - } - - } - - @Override - public void delete(Zone attribute) { - Session session = HibernateSession.getSessionFactory(); - Transaction tx = session.beginTransaction(); - try { - session.delete(attribute); - tx.commit(); - }catch(Exception e){ - logger.error(XACMLErrorConstants.ERROR_PROCESS_FLOW + "Error While Deleting Zone Table"+e); - }finally{ - try{ - session.close(); - }catch(Exception e1){ - logger.error(XACMLErrorConstants.ERROR_PROCESS_FLOW + "Error While Closing Connection/Statement"+e1); - } - } - } - - @Override - public void update(Zone attribute) { - Session session = HibernateSession.getSessionFactory(); - Transaction tx = session.beginTransaction(); - try { - session.update(attribute); - tx.commit(); - }catch(Exception e){ - logger.error(XACMLErrorConstants.ERROR_PROCESS_FLOW + "Error While Updating Zone Table"+e); - }finally{ - try{ - session.close(); - }catch(Exception e1){ - logger.error(XACMLErrorConstants.ERROR_PROCESS_FLOW + "Error While Closing Connection/Statement"+e1); - } - } - - } - - @SuppressWarnings("unchecked") - @Override - public List<String> getZoneDataByName() { - Session session = HibernateSession.getSessionFactory(); - Transaction tx = session.beginTransaction(); - List<String> data = new ArrayList<String>(); - try { - Criteria cr = session.createCriteria(Zone.class); - List<Zone> attributeData = cr.list(); - - for(int i = 0; i < attributeData.size(); i++){ - data.add(attributeData.get(i).getZoneName()); - } - tx.commit(); - } catch (Exception e) { - logger.error(XACMLErrorConstants.ERROR_PROCESS_FLOW + "Error While Querying Zone Table"+e); - }finally{ - try{ - session.close(); - }catch(Exception e1){ - logger.error(XACMLErrorConstants.ERROR_PROCESS_FLOW + "Error While Closing Connection/Statement"+e1); - } - } - return data; - } - -} |