<commit_before>/*
 * Tigase Jabber/XMPP Server
 * Copyright (C) 2004-2007 "<NAME>" <<EMAIL>>
 *
 * This program is free software: you can redistribute it and/or modify
 * it under the terms of the GNU General Public License as published by
 * the Free Software Foundation, either version 3 of the License.
 *
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License
 * along with this program. Look for COPYING file in the top folder.
 * If not, see http://www.gnu.org/licenses/.
 *
 * $Rev$
 * Last modified by $Author$
 * $Date$
 */

package tigase.db.jdbc;

//~--- non-JDK imports --------------------------------------------------------

import tigase.db.AuthRepository;
import tigase.db.AuthRepositoryImpl;
import tigase.db.AuthorizationException;
import tigase.db.DBInitException;
import tigase.db.DataRepository;
import tigase.db.RepositoryFactory;
import tigase.db.TigaseDBException;
import tigase.db.UserExistsException;
import tigase.db.UserNotFoundException;
import tigase.db.UserRepository;

import tigase.util.SimpleCache;

import tigase.xmpp.BareJID;

//~--- JDK imports ------------------------------------------------------------

import java.sql.PreparedStatement;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.sql.Statement;
import java.sql.Types;

import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collections;
import java.util.Iterator;
import java.util.List;
import java.util.Map;
import java.util.StringTokenizer;
import java.util.logging.Level;
import java.util.logging.Logger;

//~--- classes ----------------------------------------------------------------

/**
 * Not synchronized implementation! Musn't be used by more than one thread at
 * the same time.
 * <p>
 * Thanks to Daniele for better unique IDs handling. Created: Thu Oct 26
 * 11:48:53 2006
 * </p>
 * 
 * @author <a href="mailto:<EMAIL>"><NAME></a>
 * @author <a href="mailto:<EMAIL>">Daniele</a>
 * @version $Rev$
 */
public class JDBCRepository implements AuthRepository, UserRepository {
	private static final Logger log = Logger.getLogger(JDBCRepository.class.getName());

	/** Field description */
	public static final String DEF_USERS_TBL = "tig_users";

	/** Field description */
	public static final String DEF_NODES_TBL = "tig_nodes";

	/** Field description */
	public static final String DEF_PAIRS_TBL = "tig_pairs";

	/** Field description */
	public static final String DEF_MAXIDS_TBL = "tig_max_ids";

	/** Field description */
	public static final String DEF_ROOT_NODE = "root";
	private static final String USER_STR = "User: ";
	private static final String GET_USER_DB_UID_QUERY = "{ call TigGetUserDBUid(?) }";
	private static final String GET_USERS_COUNT_QUERY = "{ call TigAllUsersCount() }";
	private static final String DEF_GET_USERS_QUERY = "{ TigAllUsers() }";
	private static final String PGSQL_GET_USERS_QUERY = "select TigAllUsers()";
	private static final String ADD_USER_PLAIN_PW_QUERY =
			"{ call TigAddUserPlainPw(?, ?) }";
	private static final String REMOVE_USER_QUERY = "{ call TigRemoveUser(?) }";
	private static final String ADD_NODE_QUERY = "{ call TigAddNode(?, ?, ?) }";
	private static final String COUNT_USERS_FOR_DOMAIN_QUERY =
			"select count(*) from tig_users where user_id like ?";
	private static final String DATA_FOR_NODE_QUERY = "select pval from " + DEF_PAIRS_TBL
			+ " where (nid = ?) AND (pkey = ?)";<commit_msg>Fixed missing call in TigAllUsers query<commit_after>/*
 * Tigase Jabber/XMPP Server
 * Copyright (C) 2004-2007 "<NAME>" <<EMAIL>>
 *
 * This program is free software: you can redistribute it and/or modify
 * it under the terms of the GNU General Public License as published by
 * the Free Software Foundation, either version 3 of the License.
 *
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License
 * along with this program. Look for COPYING file in the top folder.
 * If not, see http://www.gnu.org/licenses/.
 *
 * $Rev$
 * Last modified by $Author$
 * $Date$
 */

package tigase.db.jdbc;

//~--- non-JDK imports --------------------------------------------------------

import tigase.db.AuthRepository;
import tigase.db.AuthRepositoryImpl;
import tigase.db.AuthorizationException;
import tigase.db.DBInitException;
import tigase.db.DataRepository;
import tigase.db.RepositoryFactory;
import tigase.db.TigaseDBException;
import tigase.db.UserExistsException;
import tigase.db.UserNotFoundException;
import tigase.db.UserRepository;

import tigase.util.SimpleCache;

import tigase.xmpp.BareJID;

//~--- JDK imports ------------------------------------------------------------

import java.sql.PreparedStatement;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.sql.Statement;
import java.sql.Types;

import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collections;
import java.util.Iterator;
import java.util.List;
import java.util.Map;
import java.util.StringTokenizer;
import java.util.logging.Level;
import java.util.logging.Logger;

//~--- classes ----------------------------------------------------------------

/**
 * Not synchronized implementation! Musn't be used by more than one thread at
 * the same time.
 * <p>
 * Thanks to Daniele for better unique IDs handling. Created: Thu Oct 26
 * 11:48:53 2006
 * </p>
 * 
 * @author <a href="mailto:<EMAIL>"><NAME></a>
 * @author <a href="mailto:<EMAIL>">Daniele</a>
 * @version $Rev$
 */
public class JDBCRepository implements AuthRepository, UserRepository {
	private static final Logger log = Logger.getLogger(JDBCRepository.class.getName());

	/** Field description */
	public static final String DEF_USERS_TBL = "tig_users";

	/** Field description */
	public static final String DEF_NODES_TBL = "tig_nodes";

	/** Field description */
	public static final String DEF_PAIRS_TBL = "tig_pairs";

	/** Field description */
	public static final String DEF_MAXIDS_TBL = "tig_max_ids";

	/** Field description */
	public static final String DEF_ROOT_NODE = "root";
	private static final String USER_STR = "User: ";
	private static final String GET_USER_DB_UID_QUERY = "{ call TigGetUserDBUid(?) }";
	private static final String GET_USERS_COUNT_QUERY = "{ call TigAllUsersCount() }";
	private static final String DEF_GET_USERS_QUERY = "{ call TigAllUsers() }";
	private static final String PGSQL_GET_USERS_QUERY = "select TigAllUsers()";
	private static final String ADD_USER_PLAIN_PW_QUERY =
			"{ call TigAddUserPlainPw(?, ?) }";
	private static final String REMOVE_USER_QUERY = "{ call TigRemoveUser(?) }";
	private static final String ADD_NODE_QUERY = "{ call TigAddNode(?, ?, ?) }";
	private static final String COUNT_USERS_FOR_DOMAIN_QUERY =
			"select count(*) from tig_users where user_id like ?";
	private static final String DATA_FOR_NODE_QUERY = "select pval from " + DEF_PAIRS_TBL
			+ " where (nid = ?) AND (pkey = ?)";
{'fraction_non_alphanumeric': 0.14959880320957433, 'fraction_numerical': 0.005711954304365565, 'mean_word_length': 3.576228998133167, 'pattern_counts': {'":': 0, '<': 27, '<?xml version=': 0, '>': 27, 'https://': 0, 'lorem ipsum': 0, 'www.': 2, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '5037566', 'n_tokens_mistral': 2253, 'n_tokens_neox': 2172, 'n_words': 694}