2 * ============LICENSE_START=======================================================
4 * ================================================================================
5 * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.
6 * ================================================================================
7 * Licensed under the Apache License, Version 2.0 (the "License");
8 * you may not use this file except in compliance with the License.
9 * You may obtain a copy of the License at
11 * http://www.apache.org/licenses/LICENSE-2.0
13 * Unless required by applicable law or agreed to in writing, software
14 * distributed under the License is distributed on an "AS IS" BASIS,
15 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16 * See the License for the specific language governing permissions and
17 * limitations under the License.
18 * ============LICENSE_END=========================================================
21 package org.openecomp.policy.pap.xacml.rest.controller;
28 import java.util.List;
30 import org.apache.commons.logging.Log;
31 import org.apache.commons.logging.LogFactory;
32 import org.hibernate.Criteria;
33 import org.hibernate.Session;
34 import org.hibernate.Transaction;
35 import org.hibernate.criterion.Restrictions;
36 import org.openecomp.policy.pap.xacml.rest.HibernateSession;
38 import org.openecomp.policy.xacml.api.XACMLErrorConstants;
40 public class CheckDictionaryDuplicateEntries {
42 private static final Log logger = LogFactory.getLog(CheckDictionaryDuplicateEntries.class);
44 @SuppressWarnings({ "unchecked", "rawtypes" })
45 public List<Object> CheckDuplicateEntry(String value, String columnName, Class class1) {
46 Session session = HibernateSession.getSessionFactory();
47 Transaction tx = session.beginTransaction();
48 List<Object> data = null;
50 Criteria cr = session.createCriteria(class1);
51 cr.add(Restrictions.eq(columnName,value));
54 } catch (Exception e) {
55 logger.error(XACMLErrorConstants.ERROR_PROCESS_FLOW + "Error While Querying for Duplicate Entries for Table"+e + class1);
60 logger.error(XACMLErrorConstants.ERROR_PROCESS_FLOW + "Error While Closing Connection/Statement"+e1);