Java tutorial
// Description: Java 8 DB/2 LUW 10.5 Jdbc DbIO implementation for SecUser. /* * Code Factory Asterisk 11 Configuration Model * * Copyright (c) 2014-2015 Mark Sobkow * * 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. * */ package net.sourceforge.msscodefactory.cfasterisk.v2_4.CFAsteriskDb2LUW; import java.math.*; import java.sql.*; import java.text.*; import java.util.*; import org.apache.commons.codec.binary.Base64; import net.sourceforge.msscodefactory.cflib.v2_3.CFLib.*; import net.sourceforge.msscodefactory.cfsecurity.v2_4.CFSecurity.*; import net.sourceforge.msscodefactory.cfinternet.v2_4.CFInternet.*; import net.sourceforge.msscodefactory.cfasterisk.v2_4.CFAsterisk.*; import net.sourceforge.msscodefactory.cfsecurity.v2_4.CFSecurityObj.*; import net.sourceforge.msscodefactory.cfinternet.v2_4.CFInternetObj.*; import net.sourceforge.msscodefactory.cfasterisk.v2_4.CFAsteriskObj.*; /* * CFAsteriskDb2LUWSecUserTable DB/2 LUW 10.5 Jdbc DbIO implementation * for SecUser. */ public class CFAsteriskDb2LUWSecUserTable implements ICFAsteriskSecUserTable { private CFAsteriskDb2LUWSchema schema; protected PreparedStatement stmtReadBuffByPKey = null; protected PreparedStatement stmtLockBuffByPKey = null; protected PreparedStatement stmtCreateByPKey = null; protected PreparedStatement stmtUpdateByPKey = null; protected PreparedStatement stmtDeleteByPKey = null; protected PreparedStatement stmtReadAllBuff = null; protected PreparedStatement stmtReadBuffByIdIdx = null; protected PreparedStatement stmtReadBuffByULoginIdx = null; protected PreparedStatement stmtReadBuffByEMConfIdx = null; protected PreparedStatement stmtReadBuffByPwdResetIdx = null; protected PreparedStatement stmtReadBuffByDefDevIdx = null; protected PreparedStatement stmtDeleteByIdIdx = null; protected PreparedStatement stmtDeleteByULoginIdx = null; protected PreparedStatement stmtDeleteByEMConfIdx = null; protected PreparedStatement stmtDeleteByPwdResetIdx = null; protected PreparedStatement stmtDeleteByDefDevIdx = null; public CFAsteriskDb2LUWSecUserTable(CFAsteriskDb2LUWSchema argSchema) { schema = argSchema; } public void createSecUser(CFSecurityAuthorization Authorization, CFSecuritySecUserBuff Buff) { final String S_ProcName = "createSecUser"; if (!schema.isTransactionOpen()) { throw CFLib.getDefaultExceptionFactory().newUsageException(getClass(), S_ProcName, "Transaction not open"); } ResultSet resultSet = null; try { String LoginId = Buff.getRequiredLoginId(); String EMailAddress = Buff.getRequiredEMailAddress(); UUID EMailConfirmationUuid = Buff.getOptionalEMailConfirmationUuid(); UUID DefaultDevSecUserId = Buff.getOptionalDefaultDevSecUserId(); String DefaultDevName = Buff.getOptionalDefaultDevName(); String PasswordHash = Buff.getRequiredPasswordHash(); UUID PasswordResetUuid = Buff.getOptionalPasswordResetUuid(); UUID SecUserId = UUID.randomUUID(); Connection cnx = schema.getCnx(); final String sql = "CALL sp_create_secuser( ?, ?, ?, ?, ?, ?" + ", " + "?" + ", " + "?" + ", " + "?" + ", " + "?" + ", " + "?" + ", " + "?" + ", " + "?" + ", " + "?" + " )"; if (stmtCreateByPKey == null) { stmtCreateByPKey = cnx.prepareStatement(sql); } int argIdx = 1; stmtCreateByPKey.setLong(argIdx++, (Authorization == null) ? 0 : Authorization.getSecClusterId()); stmtCreateByPKey.setString(argIdx++, (Authorization == null) ? "" : Authorization.getSecUserId().toString()); stmtCreateByPKey.setString(argIdx++, (Authorization == null) ? "" : Authorization.getSecSessionId().toString()); stmtCreateByPKey.setLong(argIdx++, (Authorization == null) ? 0 : Authorization.getSecClusterId()); stmtCreateByPKey.setLong(argIdx++, (Authorization == null) ? 0 : Authorization.getSecTenantId()); stmtCreateByPKey.setString(argIdx++, "SUSR"); stmtCreateByPKey.setString(argIdx++, SecUserId.toString()); stmtCreateByPKey.setString(argIdx++, LoginId); stmtCreateByPKey.setString(argIdx++, EMailAddress); if (EMailConfirmationUuid != null) { stmtCreateByPKey.setString(argIdx++, EMailConfirmationUuid.toString()); } else { stmtCreateByPKey.setNull(argIdx++, java.sql.Types.VARCHAR); } if (DefaultDevSecUserId != null) { stmtCreateByPKey.setString(argIdx++, DefaultDevSecUserId.toString()); } else { stmtCreateByPKey.setNull(argIdx++, java.sql.Types.VARCHAR); } if (DefaultDevName != null) { stmtCreateByPKey.setString(argIdx++, DefaultDevName); } else { stmtCreateByPKey.setNull(argIdx++, java.sql.Types.VARCHAR); } stmtCreateByPKey.setString(argIdx++, PasswordHash); if (PasswordResetUuid != null) { stmtCreateByPKey.setString(argIdx++, PasswordResetUuid.toString()); } else { stmtCreateByPKey.setNull(argIdx++, java.sql.Types.VARCHAR); } resultSet = stmtCreateByPKey.executeQuery(); if (resultSet.next()) { CFSecuritySecUserBuff createdBuff = unpackSecUserResultSetToBuff(resultSet); if (resultSet.next()) { resultSet.last(); throw CFLib.getDefaultExceptionFactory().newRuntimeException(getClass(), S_ProcName, "Did not expect multi-record response, " + resultSet.getRow() + " rows selected"); } Buff.setRequiredSecUserId(createdBuff.getRequiredSecUserId()); Buff.setRequiredLoginId(createdBuff.getRequiredLoginId()); Buff.setRequiredEMailAddress(createdBuff.getRequiredEMailAddress()); Buff.setOptionalEMailConfirmationUuid(createdBuff.getOptionalEMailConfirmationUuid()); Buff.setOptionalDefaultDevSecUserId(createdBuff.getOptionalDefaultDevSecUserId()); Buff.setOptionalDefaultDevName(createdBuff.getOptionalDefaultDevName()); Buff.setRequiredPasswordHash(createdBuff.getRequiredPasswordHash()); Buff.setOptionalPasswordResetUuid(createdBuff.getOptionalPasswordResetUuid()); Buff.setRequiredRevision(createdBuff.getRequiredRevision()); Buff.setCreatedByUserId(createdBuff.getCreatedByUserId()); Buff.setCreatedAt(createdBuff.getCreatedAt()); Buff.setUpdatedByUserId(createdBuff.getUpdatedByUserId()); Buff.setUpdatedAt(createdBuff.getUpdatedAt()); } else { throw CFLib.getDefaultExceptionFactory().newRuntimeException(getClass(), S_ProcName, "Expected a single-record response, " + resultSet.getRow() + " rows selected"); } } catch (SQLException e) { throw CFLib.getDefaultExceptionFactory().newDbException(getClass(), S_ProcName, e); } finally { if (resultSet != null) { try { resultSet.close(); } catch (SQLException e) { } resultSet = null; } } } protected static String S_sqlSelectSecUserDistinctClassCode = null; public String getSqlSelectSecUserDistinctClassCode() { if (S_sqlSelectSecUserDistinctClassCode == null) { S_sqlSelectSecUserDistinctClassCode = "SELECT " + "DISTINCT susr.ClassCode " + "FROM " + schema.getLowerDbSchemaName() + ".SecUser AS susr "; } return (S_sqlSelectSecUserDistinctClassCode); } protected static String S_sqlSelectSecUserBuff = null; public String getSqlSelectSecUserBuff() { if (S_sqlSelectSecUserBuff == null) { S_sqlSelectSecUserBuff = "SELECT " + "susr.SecUserId, " + "susr.login_id, " + "susr.email_addr, " + "susr.em_confuuid, " + "susr.DefDevUserId, " + "susr.DefDevName, " + "susr.pwd_hash, " + "susr.pwdrstuuid, " + "susr.Revision " + "FROM " + schema.getLowerDbSchemaName() + ".SecUser AS susr "; } return (S_sqlSelectSecUserBuff); } protected CFSecuritySecUserBuff unpackSecUserResultSetToBuff(ResultSet resultSet) throws SQLException { final String S_ProcName = "unpackSecUserResultSetToBuff"; int idxcol = 1; CFSecuritySecUserBuff buff = schema.getFactorySecUser().newBuff(); { String colString = resultSet.getString(idxcol); if (resultSet.wasNull()) { buff.setCreatedByUserId(null); } else if ((colString == null) || (colString.length() <= 0)) { buff.setCreatedByUserId(null); } else { buff.setCreatedByUserId(UUID.fromString(colString)); } idxcol++; colString = resultSet.getString(idxcol); if (resultSet.wasNull()) { buff.setCreatedAt(null); } else if ((colString == null) || (colString.length() <= 0)) { buff.setCreatedAt(null); } else { buff.setCreatedAt(CFAsteriskDb2LUWSchema.convertTimestampString(colString)); } idxcol++; colString = resultSet.getString(idxcol); if (resultSet.wasNull()) { buff.setUpdatedByUserId(null); } else if ((colString == null) || (colString.length() <= 0)) { buff.setUpdatedByUserId(null); } else { buff.setUpdatedByUserId(UUID.fromString(colString)); } idxcol++; colString = resultSet.getString(idxcol); if (resultSet.wasNull()) { buff.setUpdatedAt(null); } else if ((colString == null) || (colString.length() <= 0)) { buff.setUpdatedAt(null); } else { buff.setUpdatedAt(CFAsteriskDb2LUWSchema.convertTimestampString(colString)); } idxcol++; } buff.setRequiredSecUserId(CFAsteriskDb2LUWSchema.convertUuidString(resultSet.getString(idxcol))); idxcol++; buff.setRequiredLoginId(resultSet.getString(idxcol)); idxcol++; buff.setRequiredEMailAddress(resultSet.getString(idxcol)); idxcol++; { UUID colVal = CFAsteriskDb2LUWSchema.convertUuidString(resultSet.getString(idxcol)); if (resultSet.wasNull()) { buff.setOptionalEMailConfirmationUuid(null); } else { buff.setOptionalEMailConfirmationUuid(colVal); } } idxcol++; { UUID colVal = CFAsteriskDb2LUWSchema.convertUuidString(resultSet.getString(idxcol)); if (resultSet.wasNull()) { buff.setOptionalDefaultDevSecUserId(null); } else { buff.setOptionalDefaultDevSecUserId(colVal); } } idxcol++; { String colVal = resultSet.getString(idxcol); if (resultSet.wasNull()) { buff.setOptionalDefaultDevName(null); } else { buff.setOptionalDefaultDevName(colVal); } } idxcol++; buff.setRequiredPasswordHash(resultSet.getString(idxcol)); idxcol++; { UUID colVal = CFAsteriskDb2LUWSchema.convertUuidString(resultSet.getString(idxcol)); if (resultSet.wasNull()) { buff.setOptionalPasswordResetUuid(null); } else { buff.setOptionalPasswordResetUuid(colVal); } } idxcol++; buff.setRequiredRevision(resultSet.getInt(idxcol)); return (buff); } public CFSecuritySecUserBuff readDerived(CFSecurityAuthorization Authorization, CFSecuritySecUserPKey PKey) { final String S_ProcName = "readDerived"; if (!schema.isTransactionOpen()) { throw CFLib.getDefaultExceptionFactory().newUsageException(getClass(), S_ProcName, "Transaction not open"); } CFSecuritySecUserBuff buff; buff = readBuff(Authorization, PKey); return (buff); } public CFSecuritySecUserBuff lockDerived(CFSecurityAuthorization Authorization, CFSecuritySecUserPKey PKey) { final String S_ProcName = "lockDerived"; if (!schema.isTransactionOpen()) { throw CFLib.getDefaultExceptionFactory().newUsageException(getClass(), S_ProcName, "Transaction not open"); } CFSecuritySecUserBuff buff; buff = lockBuff(Authorization, PKey); return (buff); } public CFSecuritySecUserBuff[] readAllDerived(CFSecurityAuthorization Authorization) { final String S_ProcName = "readAllDerived"; CFSecuritySecUserBuff[] buffArray; if (!schema.isTransactionOpen()) { throw CFLib.getDefaultExceptionFactory().newUsageException(getClass(), S_ProcName, "Transaction not open"); } buffArray = readAllBuff(Authorization); return (buffArray); } public CFSecuritySecUserBuff readDerivedByIdIdx(CFSecurityAuthorization Authorization, UUID SecUserId) { final String S_ProcName = "CFAsteriskDb2LUWSecUserTable.readDerivedByIdIdx() "; CFSecuritySecUserBuff buff; if (!schema.isTransactionOpen()) { throw CFLib.getDefaultExceptionFactory().newUsageException(getClass(), S_ProcName, "Transaction not open"); } buff = readBuffByIdIdx(Authorization, SecUserId); return (buff); } public CFSecuritySecUserBuff readDerivedByULoginIdx(CFSecurityAuthorization Authorization, String LoginId) { final String S_ProcName = "CFAsteriskDb2LUWSecUserTable.readDerivedByULoginIdx() "; CFSecuritySecUserBuff buff; if (!schema.isTransactionOpen()) { throw CFLib.getDefaultExceptionFactory().newUsageException(getClass(), S_ProcName, "Transaction not open"); } buff = readBuffByULoginIdx(Authorization, LoginId); return (buff); } public CFSecuritySecUserBuff[] readDerivedByEMConfIdx(CFSecurityAuthorization Authorization, UUID EMailConfirmationUuid) { final String S_ProcName = "readDerivedByEMConfIdx"; if (!schema.isTransactionOpen()) { throw CFLib.getDefaultExceptionFactory().newUsageException(getClass(), S_ProcName, "Transaction not open"); } CFSecuritySecUserBuff[] buffList = readBuffByEMConfIdx(Authorization, EMailConfirmationUuid); return (buffList); } public CFSecuritySecUserBuff[] readDerivedByPwdResetIdx(CFSecurityAuthorization Authorization, UUID PasswordResetUuid) { final String S_ProcName = "readDerivedByPwdResetIdx"; if (!schema.isTransactionOpen()) { throw CFLib.getDefaultExceptionFactory().newUsageException(getClass(), S_ProcName, "Transaction not open"); } CFSecuritySecUserBuff[] buffList = readBuffByPwdResetIdx(Authorization, PasswordResetUuid); return (buffList); } public CFSecuritySecUserBuff readDerivedByDefDevIdx(CFSecurityAuthorization Authorization, UUID DefaultDevSecUserId, String DefaultDevName) { final String S_ProcName = "CFAsteriskDb2LUWSecUserTable.readDerivedByDefDevIdx() "; CFSecuritySecUserBuff buff; if (!schema.isTransactionOpen()) { throw CFLib.getDefaultExceptionFactory().newUsageException(getClass(), S_ProcName, "Transaction not open"); } buff = readBuffByDefDevIdx(Authorization, DefaultDevSecUserId, DefaultDevName); return (buff); } public CFSecuritySecUserBuff readBuff(CFSecurityAuthorization Authorization, CFSecuritySecUserPKey PKey) { final String S_ProcName = "readBuff"; if (!schema.isTransactionOpen()) { throw CFLib.getDefaultExceptionFactory().newUsageException(getClass(), S_ProcName, "Transaction not open"); } ResultSet resultSet = null; try { Connection cnx = schema.getCnx(); UUID SecUserId = PKey.getRequiredSecUserId(); final String sql = "CALL sp_read_secuser( ?, ?, ?, ?, ?" + ", " + "?" + " )"; if (stmtReadBuffByPKey == null) { stmtReadBuffByPKey = cnx.prepareStatement(sql); } int argIdx = 1; stmtReadBuffByPKey.setLong(argIdx++, (Authorization == null) ? 0 : Authorization.getSecClusterId()); stmtReadBuffByPKey.setString(argIdx++, (Authorization == null) ? "" : Authorization.getSecUserId().toString()); stmtReadBuffByPKey.setString(argIdx++, (Authorization == null) ? "" : Authorization.getSecSessionId().toString()); stmtReadBuffByPKey.setLong(argIdx++, (Authorization == null) ? 0 : Authorization.getSecClusterId()); stmtReadBuffByPKey.setLong(argIdx++, (Authorization == null) ? 0 : Authorization.getSecTenantId()); stmtReadBuffByPKey.setString(argIdx++, SecUserId.toString()); resultSet = stmtReadBuffByPKey.executeQuery(); if (resultSet.next()) { CFSecuritySecUserBuff buff = unpackSecUserResultSetToBuff(resultSet); if (resultSet.next()) { resultSet.last(); throw CFLib.getDefaultExceptionFactory().newRuntimeException(getClass(), S_ProcName, "Did not expect multi-record response, " + resultSet.getRow() + " rows selected"); } return (buff); } else { return (null); } } catch (SQLException e) { throw CFLib.getDefaultExceptionFactory().newDbException(getClass(), S_ProcName, e); } finally { if (resultSet != null) { try { resultSet.close(); } catch (SQLException e) { } resultSet = null; } } } public CFSecuritySecUserBuff lockBuff(CFSecurityAuthorization Authorization, CFSecuritySecUserPKey PKey) { final String S_ProcName = "lockBuff"; if (!schema.isTransactionOpen()) { throw CFLib.getDefaultExceptionFactory().newUsageException(getClass(), S_ProcName, "Transaction not open"); } ResultSet resultSet = null; try { Connection cnx = schema.getCnx(); UUID SecUserId = PKey.getRequiredSecUserId(); final String sql = "CALL sp_lock_secuser( ?, ?, ?, ?, ?" + ", " + "?" + " )"; if (stmtLockBuffByPKey == null) { stmtLockBuffByPKey = cnx.prepareStatement(sql); } int argIdx = 1; stmtLockBuffByPKey.setLong(argIdx++, (Authorization == null) ? 0 : Authorization.getSecClusterId()); stmtLockBuffByPKey.setString(argIdx++, (Authorization == null) ? "" : Authorization.getSecUserId().toString()); stmtLockBuffByPKey.setString(argIdx++, (Authorization == null) ? "" : Authorization.getSecSessionId().toString()); stmtLockBuffByPKey.setLong(argIdx++, (Authorization == null) ? 0 : Authorization.getSecClusterId()); stmtLockBuffByPKey.setLong(argIdx++, (Authorization == null) ? 0 : Authorization.getSecTenantId()); stmtLockBuffByPKey.setString(argIdx++, SecUserId.toString()); resultSet = stmtLockBuffByPKey.executeQuery(); if (resultSet.next()) { CFSecuritySecUserBuff buff = unpackSecUserResultSetToBuff(resultSet); if (resultSet.next()) { resultSet.last(); throw CFLib.getDefaultExceptionFactory().newRuntimeException(getClass(), S_ProcName, "Did not expect multi-record response, " + resultSet.getRow() + " rows selected"); } return (buff); } else { return (null); } } catch (SQLException e) { throw CFLib.getDefaultExceptionFactory().newDbException(getClass(), S_ProcName, e); } finally { if (resultSet != null) { try { resultSet.close(); } catch (SQLException e) { } resultSet = null; } } } public CFSecuritySecUserBuff[] readAllBuff(CFSecurityAuthorization Authorization) { final String S_ProcName = "readAllBuff"; if (!schema.isTransactionOpen()) { throw CFLib.getDefaultExceptionFactory().newUsageException(getClass(), S_ProcName, "Transaction not open"); } ResultSet resultSet = null; try { Connection cnx = schema.getCnx(); final String sql = "CALL sp_read_secuser_all( ?, ?, ?, ?, ? )"; if (stmtReadAllBuff == null) { stmtReadAllBuff = cnx.prepareStatement(sql); } int argIdx = 1; stmtReadAllBuff.setLong(argIdx++, (Authorization == null) ? 0 : Authorization.getSecClusterId()); stmtReadAllBuff.setString(argIdx++, (Authorization == null) ? "" : Authorization.getSecUserId().toString()); stmtReadAllBuff.setString(argIdx++, (Authorization == null) ? "" : Authorization.getSecSessionId().toString()); stmtReadAllBuff.setLong(argIdx++, (Authorization == null) ? 0 : Authorization.getSecClusterId()); stmtReadAllBuff.setLong(argIdx++, (Authorization == null) ? 0 : Authorization.getSecTenantId()); resultSet = stmtReadAllBuff.executeQuery(); List<CFSecuritySecUserBuff> buffList = new LinkedList<CFSecuritySecUserBuff>(); while (resultSet.next()) { CFSecuritySecUserBuff buff = unpackSecUserResultSetToBuff(resultSet); buffList.add(buff); } int idx = 0; CFSecuritySecUserBuff[] retBuff = new CFSecuritySecUserBuff[buffList.size()]; Iterator<CFSecuritySecUserBuff> iter = buffList.iterator(); while (iter.hasNext()) { retBuff[idx++] = iter.next(); } return (retBuff); } catch (SQLException e) { throw CFLib.getDefaultExceptionFactory().newDbException(getClass(), S_ProcName, e); } finally { if (resultSet != null) { try { resultSet.close(); } catch (SQLException e) { } resultSet = null; } } } public CFSecuritySecUserBuff readBuffByIdIdx(CFSecurityAuthorization Authorization, UUID SecUserId) { final String S_ProcName = "readBuffByIdIdx"; ResultSet resultSet = null; try { Connection cnx = schema.getCnx(); final String sql = "CALL sp_read_secuser_by_ididx( ?, ?, ?, ?, ?" + ", " + "?" + " )"; if (stmtReadBuffByIdIdx == null) { stmtReadBuffByIdIdx = cnx.prepareStatement(sql); } int argIdx = 1; stmtReadBuffByIdIdx.setLong(argIdx++, (Authorization == null) ? 0 : Authorization.getSecClusterId()); stmtReadBuffByIdIdx.setString(argIdx++, (Authorization == null) ? "" : Authorization.getSecUserId().toString()); stmtReadBuffByIdIdx.setString(argIdx++, (Authorization == null) ? "" : Authorization.getSecSessionId().toString()); stmtReadBuffByIdIdx.setLong(argIdx++, (Authorization == null) ? 0 : Authorization.getSecClusterId()); stmtReadBuffByIdIdx.setLong(argIdx++, (Authorization == null) ? 0 : Authorization.getSecTenantId()); stmtReadBuffByIdIdx.setString(argIdx++, SecUserId.toString()); resultSet = stmtReadBuffByIdIdx.executeQuery(); if (resultSet.next()) { CFSecuritySecUserBuff buff = unpackSecUserResultSetToBuff(resultSet); if (resultSet.next()) { resultSet.last(); throw CFLib.getDefaultExceptionFactory().newRuntimeException(getClass(), S_ProcName, "Did not expect multi-record response, " + resultSet.getRow() + " rows selected"); } return (buff); } else { return (null); } } catch (SQLException e) { throw CFLib.getDefaultExceptionFactory().newDbException(getClass(), S_ProcName, e); } finally { if (resultSet != null) { try { resultSet.close(); } catch (SQLException e) { } resultSet = null; } } } public CFSecuritySecUserBuff readBuffByULoginIdx(CFSecurityAuthorization Authorization, String LoginId) { final String S_ProcName = "readBuffByULoginIdx"; ResultSet resultSet = null; try { Connection cnx = schema.getCnx(); final String sql = "CALL sp_read_secuser_by_uloginidx( ?, ?, ?, ?, ?" + ", " + "?" + " )"; if (stmtReadBuffByULoginIdx == null) { stmtReadBuffByULoginIdx = cnx.prepareStatement(sql); } int argIdx = 1; stmtReadBuffByULoginIdx.setLong(argIdx++, (Authorization == null) ? 0 : Authorization.getSecClusterId()); stmtReadBuffByULoginIdx.setString(argIdx++, (Authorization == null) ? "" : Authorization.getSecUserId().toString()); stmtReadBuffByULoginIdx.setString(argIdx++, (Authorization == null) ? "" : Authorization.getSecSessionId().toString()); stmtReadBuffByULoginIdx.setLong(argIdx++, (Authorization == null) ? 0 : Authorization.getSecClusterId()); stmtReadBuffByULoginIdx.setLong(argIdx++, (Authorization == null) ? 0 : Authorization.getSecTenantId()); stmtReadBuffByULoginIdx.setString(argIdx++, LoginId); resultSet = stmtReadBuffByULoginIdx.executeQuery(); if (resultSet.next()) { CFSecuritySecUserBuff buff = unpackSecUserResultSetToBuff(resultSet); if (resultSet.next()) { resultSet.last(); throw CFLib.getDefaultExceptionFactory().newRuntimeException(getClass(), S_ProcName, "Did not expect multi-record response, " + resultSet.getRow() + " rows selected"); } return (buff); } else { return (null); } } catch (SQLException e) { throw CFLib.getDefaultExceptionFactory().newDbException(getClass(), S_ProcName, e); } finally { if (resultSet != null) { try { resultSet.close(); } catch (SQLException e) { } resultSet = null; } } } public CFSecuritySecUserBuff[] readBuffByEMConfIdx(CFSecurityAuthorization Authorization, UUID EMailConfirmationUuid) { final String S_ProcName = "readBuffByEMConfIdx"; ResultSet resultSet = null; try { Connection cnx = schema.getCnx(); final String sql = "CALL sp_read_secuser_by_emconfidx( ?, ?, ?, ?, ?" + ", " + "?" + " )"; if (stmtReadBuffByEMConfIdx == null) { stmtReadBuffByEMConfIdx = cnx.prepareStatement(sql); } int argIdx = 1; stmtReadBuffByEMConfIdx.setLong(argIdx++, (Authorization == null) ? 0 : Authorization.getSecClusterId()); stmtReadBuffByEMConfIdx.setString(argIdx++, (Authorization == null) ? "" : Authorization.getSecUserId().toString()); stmtReadBuffByEMConfIdx.setString(argIdx++, (Authorization == null) ? "" : Authorization.getSecSessionId().toString()); stmtReadBuffByEMConfIdx.setLong(argIdx++, (Authorization == null) ? 0 : Authorization.getSecClusterId()); stmtReadBuffByEMConfIdx.setLong(argIdx++, (Authorization == null) ? 0 : Authorization.getSecTenantId()); if (EMailConfirmationUuid != null) { stmtReadBuffByEMConfIdx.setString(argIdx++, EMailConfirmationUuid.toString()); } else { stmtReadBuffByEMConfIdx.setNull(argIdx++, java.sql.Types.VARCHAR); } resultSet = stmtReadBuffByEMConfIdx.executeQuery(); List<CFSecuritySecUserBuff> buffList = new LinkedList<CFSecuritySecUserBuff>(); while (resultSet.next()) { CFSecuritySecUserBuff buff = unpackSecUserResultSetToBuff(resultSet); buffList.add(buff); } int idx = 0; CFSecuritySecUserBuff[] retBuff = new CFSecuritySecUserBuff[buffList.size()]; Iterator<CFSecuritySecUserBuff> iter = buffList.iterator(); while (iter.hasNext()) { retBuff[idx++] = iter.next(); } return (retBuff); } catch (SQLException e) { throw CFLib.getDefaultExceptionFactory().newDbException(getClass(), S_ProcName, e); } finally { if (resultSet != null) { try { resultSet.close(); } catch (SQLException e) { } resultSet = null; } } } public CFSecuritySecUserBuff[] readBuffByPwdResetIdx(CFSecurityAuthorization Authorization, UUID PasswordResetUuid) { final String S_ProcName = "readBuffByPwdResetIdx"; ResultSet resultSet = null; try { Connection cnx = schema.getCnx(); final String sql = "CALL sp_read_secuser_by_pwdresetidx( ?, ?, ?, ?, ?" + ", " + "?" + " )"; if (stmtReadBuffByPwdResetIdx == null) { stmtReadBuffByPwdResetIdx = cnx.prepareStatement(sql); } int argIdx = 1; stmtReadBuffByPwdResetIdx.setLong(argIdx++, (Authorization == null) ? 0 : Authorization.getSecClusterId()); stmtReadBuffByPwdResetIdx.setString(argIdx++, (Authorization == null) ? "" : Authorization.getSecUserId().toString()); stmtReadBuffByPwdResetIdx.setString(argIdx++, (Authorization == null) ? "" : Authorization.getSecSessionId().toString()); stmtReadBuffByPwdResetIdx.setLong(argIdx++, (Authorization == null) ? 0 : Authorization.getSecClusterId()); stmtReadBuffByPwdResetIdx.setLong(argIdx++, (Authorization == null) ? 0 : Authorization.getSecTenantId()); if (PasswordResetUuid != null) { stmtReadBuffByPwdResetIdx.setString(argIdx++, PasswordResetUuid.toString()); } else { stmtReadBuffByPwdResetIdx.setNull(argIdx++, java.sql.Types.VARCHAR); } resultSet = stmtReadBuffByPwdResetIdx.executeQuery(); List<CFSecuritySecUserBuff> buffList = new LinkedList<CFSecuritySecUserBuff>(); while (resultSet.next()) { CFSecuritySecUserBuff buff = unpackSecUserResultSetToBuff(resultSet); buffList.add(buff); } int idx = 0; CFSecuritySecUserBuff[] retBuff = new CFSecuritySecUserBuff[buffList.size()]; Iterator<CFSecuritySecUserBuff> iter = buffList.iterator(); while (iter.hasNext()) { retBuff[idx++] = iter.next(); } return (retBuff); } catch (SQLException e) { throw CFLib.getDefaultExceptionFactory().newDbException(getClass(), S_ProcName, e); } finally { if (resultSet != null) { try { resultSet.close(); } catch (SQLException e) { } resultSet = null; } } } public CFSecuritySecUserBuff readBuffByDefDevIdx(CFSecurityAuthorization Authorization, UUID DefaultDevSecUserId, String DefaultDevName) { final String S_ProcName = "readBuffByDefDevIdx"; ResultSet resultSet = null; try { Connection cnx = schema.getCnx(); final String sql = "CALL sp_read_secuser_by_defdevidx( ?, ?, ?, ?, ?" + ", " + "?" + ", " + "?" + " )"; if (stmtReadBuffByDefDevIdx == null) { stmtReadBuffByDefDevIdx = cnx.prepareStatement(sql); } int argIdx = 1; stmtReadBuffByDefDevIdx.setLong(argIdx++, (Authorization == null) ? 0 : Authorization.getSecClusterId()); stmtReadBuffByDefDevIdx.setString(argIdx++, (Authorization == null) ? "" : Authorization.getSecUserId().toString()); stmtReadBuffByDefDevIdx.setString(argIdx++, (Authorization == null) ? "" : Authorization.getSecSessionId().toString()); stmtReadBuffByDefDevIdx.setLong(argIdx++, (Authorization == null) ? 0 : Authorization.getSecClusterId()); stmtReadBuffByDefDevIdx.setLong(argIdx++, (Authorization == null) ? 0 : Authorization.getSecTenantId()); if (DefaultDevSecUserId != null) { stmtReadBuffByDefDevIdx.setString(argIdx++, DefaultDevSecUserId.toString()); } else { stmtReadBuffByDefDevIdx.setNull(argIdx++, java.sql.Types.VARCHAR); } if (DefaultDevName != null) { stmtReadBuffByDefDevIdx.setString(argIdx++, DefaultDevName); } else { stmtReadBuffByDefDevIdx.setNull(argIdx++, java.sql.Types.VARCHAR); } resultSet = stmtReadBuffByDefDevIdx.executeQuery(); if (resultSet.next()) { CFSecuritySecUserBuff buff = unpackSecUserResultSetToBuff(resultSet); if (resultSet.next()) { resultSet.last(); throw CFLib.getDefaultExceptionFactory().newRuntimeException(getClass(), S_ProcName, "Did not expect multi-record response, " + resultSet.getRow() + " rows selected"); } return (buff); } else { return (null); } } catch (SQLException e) { throw CFLib.getDefaultExceptionFactory().newDbException(getClass(), S_ProcName, e); } finally { if (resultSet != null) { try { resultSet.close(); } catch (SQLException e) { } resultSet = null; } } } public void updateSecUser(CFSecurityAuthorization Authorization, CFSecuritySecUserBuff Buff) { final String S_ProcName = "updateSecUser"; if ("SUSR".equals(Buff.getClassCode()) && (!schema.isSystemUser(Authorization))) { throw CFLib.getDefaultExceptionFactory().newRuntimeException(getClass(), S_ProcName, "Permission denied -- only system user can modify SecUser data"); } ResultSet resultSet = null; try { UUID SecUserId = Buff.getRequiredSecUserId(); String LoginId = Buff.getRequiredLoginId(); String EMailAddress = Buff.getRequiredEMailAddress(); UUID EMailConfirmationUuid = Buff.getOptionalEMailConfirmationUuid(); UUID DefaultDevSecUserId = Buff.getOptionalDefaultDevSecUserId(); String DefaultDevName = Buff.getOptionalDefaultDevName(); String PasswordHash = Buff.getRequiredPasswordHash(); UUID PasswordResetUuid = Buff.getOptionalPasswordResetUuid(); int Revision = Buff.getRequiredRevision(); Connection cnx = schema.getCnx(); final String sql = "CALL sp_update_secuser( ?, ?, ?, ?, ?, ?" + ", " + "?" + ", " + "?" + ", " + "?" + ", " + "?" + ", " + "?" + ", " + "?" + ", " + "?" + ", " + "?" + ", " + "?" + " )"; if (stmtUpdateByPKey == null) { stmtUpdateByPKey = cnx.prepareStatement(sql); } int argIdx = 1; stmtUpdateByPKey.setLong(argIdx++, (Authorization == null) ? 0 : Authorization.getSecClusterId()); stmtUpdateByPKey.setString(argIdx++, (Authorization == null) ? "" : Authorization.getSecUserId().toString()); stmtUpdateByPKey.setString(argIdx++, (Authorization == null) ? "" : Authorization.getSecSessionId().toString()); stmtUpdateByPKey.setLong(argIdx++, (Authorization == null) ? 0 : Authorization.getSecClusterId()); stmtUpdateByPKey.setLong(argIdx++, (Authorization == null) ? 0 : Authorization.getSecTenantId()); stmtUpdateByPKey.setString(argIdx++, "SUSR"); stmtUpdateByPKey.setString(argIdx++, SecUserId.toString()); stmtUpdateByPKey.setString(argIdx++, LoginId); stmtUpdateByPKey.setString(argIdx++, EMailAddress); if (EMailConfirmationUuid != null) { stmtUpdateByPKey.setString(argIdx++, EMailConfirmationUuid.toString()); } else { stmtUpdateByPKey.setNull(argIdx++, java.sql.Types.VARCHAR); } if (DefaultDevSecUserId != null) { stmtUpdateByPKey.setString(argIdx++, DefaultDevSecUserId.toString()); } else { stmtUpdateByPKey.setNull(argIdx++, java.sql.Types.VARCHAR); } if (DefaultDevName != null) { stmtUpdateByPKey.setString(argIdx++, DefaultDevName); } else { stmtUpdateByPKey.setNull(argIdx++, java.sql.Types.VARCHAR); } stmtUpdateByPKey.setString(argIdx++, PasswordHash); if (PasswordResetUuid != null) { stmtUpdateByPKey.setString(argIdx++, PasswordResetUuid.toString()); } else { stmtUpdateByPKey.setNull(argIdx++, java.sql.Types.VARCHAR); } stmtUpdateByPKey.setInt(argIdx++, Revision); resultSet = stmtUpdateByPKey.executeQuery(); if (resultSet.next()) { CFSecuritySecUserBuff updatedBuff = unpackSecUserResultSetToBuff(resultSet); if (resultSet.next()) { resultSet.last(); throw CFLib.getDefaultExceptionFactory().newRuntimeException(getClass(), S_ProcName, "Did not expect multi-record response, " + resultSet.getRow() + " rows selected"); } Buff.setRequiredLoginId(updatedBuff.getRequiredLoginId()); Buff.setRequiredEMailAddress(updatedBuff.getRequiredEMailAddress()); Buff.setOptionalEMailConfirmationUuid(updatedBuff.getOptionalEMailConfirmationUuid()); Buff.setOptionalDefaultDevSecUserId(updatedBuff.getOptionalDefaultDevSecUserId()); Buff.setOptionalDefaultDevName(updatedBuff.getOptionalDefaultDevName()); Buff.setRequiredPasswordHash(updatedBuff.getRequiredPasswordHash()); Buff.setOptionalPasswordResetUuid(updatedBuff.getOptionalPasswordResetUuid()); Buff.setRequiredRevision(updatedBuff.getRequiredRevision()); } else { throw CFLib.getDefaultExceptionFactory().newRuntimeException(getClass(), S_ProcName, "Expected a single-record response, " + resultSet.getRow() + " rows selected"); } } catch (SQLException e) { throw CFLib.getDefaultExceptionFactory().newDbException(getClass(), S_ProcName, e); } finally { if (resultSet != null) { try { resultSet.close(); } catch (SQLException e) { } resultSet = null; } } } public void deleteSecUser(CFSecurityAuthorization Authorization, CFSecuritySecUserBuff Buff) { final String S_ProcName = "deleteSecUser"; ResultSet resultSet = null; try { Connection cnx = schema.getCnx(); UUID SecUserId = Buff.getRequiredSecUserId(); final String sql = "CALL sp_delete_secuser( ?, ?, ?, ?, ?" + ", " + "?" + ", " + "?" + " )"; if (stmtDeleteByPKey == null) { stmtDeleteByPKey = cnx.prepareStatement(sql); } int argIdx = 1; stmtDeleteByPKey.setLong(argIdx++, (Authorization == null) ? 0 : Authorization.getSecClusterId()); stmtDeleteByPKey.setString(argIdx++, (Authorization == null) ? "" : Authorization.getSecUserId().toString()); stmtDeleteByPKey.setString(argIdx++, (Authorization == null) ? "" : Authorization.getSecSessionId().toString()); stmtDeleteByPKey.setLong(argIdx++, (Authorization == null) ? 0 : Authorization.getSecClusterId()); stmtDeleteByPKey.setLong(argIdx++, (Authorization == null) ? 0 : Authorization.getSecTenantId()); stmtDeleteByPKey.setString(argIdx++, SecUserId.toString()); stmtDeleteByPKey.setInt(argIdx++, Buff.getRequiredRevision()); ; resultSet = stmtDeleteByPKey.executeQuery(); if (resultSet.next()) { int deleteFlag = resultSet.getInt(1); if (resultSet.next()) { resultSet.last(); throw CFLib.getDefaultExceptionFactory().newRuntimeException(getClass(), S_ProcName, "Did not expect multi-record response, " + resultSet.getRow() + " rows selected"); } } else { throw CFLib.getDefaultExceptionFactory().newRuntimeException(getClass(), S_ProcName, "Expected 1 record result set to be returned by delete, not 0 rows"); } } catch (SQLException e) { throw CFLib.getDefaultExceptionFactory().newDbException(getClass(), S_ProcName, e); } finally { if (resultSet != null) { try { resultSet.close(); } catch (SQLException e) { } resultSet = null; } } } public void deleteSecUserByIdIdx(CFSecurityAuthorization Authorization, UUID argSecUserId) { final String S_ProcName = "deleteSecUserByIdIdx"; ResultSet resultSet = null; try { Connection cnx = schema.getCnx(); final String sql = "CALL sp_delete_secuser_by_ididx( ?, ?, ?, ?, ?" + ", " + "?" + " )"; if (stmtDeleteByIdIdx == null) { stmtDeleteByIdIdx = cnx.prepareStatement(sql); } int argIdx = 1; stmtDeleteByIdIdx.setLong(argIdx++, (Authorization == null) ? 0 : Authorization.getSecClusterId()); stmtDeleteByIdIdx.setString(argIdx++, (Authorization == null) ? "" : Authorization.getSecUserId().toString()); stmtDeleteByIdIdx.setString(argIdx++, (Authorization == null) ? "" : Authorization.getSecSessionId().toString()); stmtDeleteByIdIdx.setLong(argIdx++, (Authorization == null) ? 0 : Authorization.getSecClusterId()); stmtDeleteByIdIdx.setLong(argIdx++, (Authorization == null) ? 0 : Authorization.getSecTenantId()); stmtDeleteByIdIdx.setString(argIdx++, argSecUserId.toString()); resultSet = stmtDeleteByIdIdx.executeQuery(); if (resultSet.next()) { int deleteFlag = resultSet.getInt(1); if (resultSet.next()) { resultSet.last(); throw CFLib.getDefaultExceptionFactory().newRuntimeException(getClass(), S_ProcName, "Did not expect multi-record response, " + resultSet.getRow() + " rows selected"); } } else { throw CFLib.getDefaultExceptionFactory().newRuntimeException(getClass(), S_ProcName, "Expected 1 record result set to be returned by delete, not 0 rows"); } } catch (SQLException e) { throw CFLib.getDefaultExceptionFactory().newDbException(getClass(), S_ProcName, e); } finally { if (resultSet != null) { try { resultSet.close(); } catch (SQLException e) { } resultSet = null; } } } public void deleteSecUserByIdIdx(CFSecurityAuthorization Authorization, CFSecuritySecUserPKey argKey) { deleteSecUserByIdIdx(Authorization, argKey.getRequiredSecUserId()); } public void deleteSecUserByULoginIdx(CFSecurityAuthorization Authorization, String argLoginId) { final String S_ProcName = "deleteSecUserByULoginIdx"; ResultSet resultSet = null; try { Connection cnx = schema.getCnx(); final String sql = "CALL sp_delete_secuser_by_uloginidx( ?, ?, ?, ?, ?" + ", " + "?" + " )"; if (stmtDeleteByULoginIdx == null) { stmtDeleteByULoginIdx = cnx.prepareStatement(sql); } int argIdx = 1; stmtDeleteByULoginIdx.setLong(argIdx++, (Authorization == null) ? 0 : Authorization.getSecClusterId()); stmtDeleteByULoginIdx.setString(argIdx++, (Authorization == null) ? "" : Authorization.getSecUserId().toString()); stmtDeleteByULoginIdx.setString(argIdx++, (Authorization == null) ? "" : Authorization.getSecSessionId().toString()); stmtDeleteByULoginIdx.setLong(argIdx++, (Authorization == null) ? 0 : Authorization.getSecClusterId()); stmtDeleteByULoginIdx.setLong(argIdx++, (Authorization == null) ? 0 : Authorization.getSecTenantId()); stmtDeleteByULoginIdx.setString(argIdx++, argLoginId); resultSet = stmtDeleteByULoginIdx.executeQuery(); if (resultSet.next()) { int deleteFlag = resultSet.getInt(1); if (resultSet.next()) { resultSet.last(); throw CFLib.getDefaultExceptionFactory().newRuntimeException(getClass(), S_ProcName, "Did not expect multi-record response, " + resultSet.getRow() + " rows selected"); } } else { throw CFLib.getDefaultExceptionFactory().newRuntimeException(getClass(), S_ProcName, "Expected 1 record result set to be returned by delete, not 0 rows"); } } catch (SQLException e) { throw CFLib.getDefaultExceptionFactory().newDbException(getClass(), S_ProcName, e); } finally { if (resultSet != null) { try { resultSet.close(); } catch (SQLException e) { } resultSet = null; } } } public void deleteSecUserByULoginIdx(CFSecurityAuthorization Authorization, CFSecuritySecUserByULoginIdxKey argKey) { deleteSecUserByULoginIdx(Authorization, argKey.getRequiredLoginId()); } public void deleteSecUserByEMConfIdx(CFSecurityAuthorization Authorization, UUID argEMailConfirmationUuid) { final String S_ProcName = "deleteSecUserByEMConfIdx"; ResultSet resultSet = null; try { Connection cnx = schema.getCnx(); final String sql = "CALL sp_delete_secuser_by_emconfidx( ?, ?, ?, ?, ?" + ", " + "?" + " )"; if (stmtDeleteByEMConfIdx == null) { stmtDeleteByEMConfIdx = cnx.prepareStatement(sql); } int argIdx = 1; stmtDeleteByEMConfIdx.setLong(argIdx++, (Authorization == null) ? 0 : Authorization.getSecClusterId()); stmtDeleteByEMConfIdx.setString(argIdx++, (Authorization == null) ? "" : Authorization.getSecUserId().toString()); stmtDeleteByEMConfIdx.setString(argIdx++, (Authorization == null) ? "" : Authorization.getSecSessionId().toString()); stmtDeleteByEMConfIdx.setLong(argIdx++, (Authorization == null) ? 0 : Authorization.getSecClusterId()); stmtDeleteByEMConfIdx.setLong(argIdx++, (Authorization == null) ? 0 : Authorization.getSecTenantId()); if (argEMailConfirmationUuid != null) { stmtDeleteByEMConfIdx.setString(argIdx++, argEMailConfirmationUuid.toString()); } else { stmtDeleteByEMConfIdx.setNull(argIdx++, java.sql.Types.VARCHAR); } resultSet = stmtDeleteByEMConfIdx.executeQuery(); if (resultSet.next()) { int deleteFlag = resultSet.getInt(1); if (resultSet.next()) { resultSet.last(); throw CFLib.getDefaultExceptionFactory().newRuntimeException(getClass(), S_ProcName, "Did not expect multi-record response, " + resultSet.getRow() + " rows selected"); } } else { throw CFLib.getDefaultExceptionFactory().newRuntimeException(getClass(), S_ProcName, "Expected 1 record result set to be returned by delete, not 0 rows"); } } catch (SQLException e) { throw CFLib.getDefaultExceptionFactory().newDbException(getClass(), S_ProcName, e); } finally { if (resultSet != null) { try { resultSet.close(); } catch (SQLException e) { } resultSet = null; } } } public void deleteSecUserByEMConfIdx(CFSecurityAuthorization Authorization, CFSecuritySecUserByEMConfIdxKey argKey) { deleteSecUserByEMConfIdx(Authorization, argKey.getOptionalEMailConfirmationUuid()); } public void deleteSecUserByPwdResetIdx(CFSecurityAuthorization Authorization, UUID argPasswordResetUuid) { final String S_ProcName = "deleteSecUserByPwdResetIdx"; ResultSet resultSet = null; try { Connection cnx = schema.getCnx(); final String sql = "CALL sp_delete_secuser_by_pwdresetidx( ?, ?, ?, ?, ?" + ", " + "?" + " )"; if (stmtDeleteByPwdResetIdx == null) { stmtDeleteByPwdResetIdx = cnx.prepareStatement(sql); } int argIdx = 1; stmtDeleteByPwdResetIdx.setLong(argIdx++, (Authorization == null) ? 0 : Authorization.getSecClusterId()); stmtDeleteByPwdResetIdx.setString(argIdx++, (Authorization == null) ? "" : Authorization.getSecUserId().toString()); stmtDeleteByPwdResetIdx.setString(argIdx++, (Authorization == null) ? "" : Authorization.getSecSessionId().toString()); stmtDeleteByPwdResetIdx.setLong(argIdx++, (Authorization == null) ? 0 : Authorization.getSecClusterId()); stmtDeleteByPwdResetIdx.setLong(argIdx++, (Authorization == null) ? 0 : Authorization.getSecTenantId()); if (argPasswordResetUuid != null) { stmtDeleteByPwdResetIdx.setString(argIdx++, argPasswordResetUuid.toString()); } else { stmtDeleteByPwdResetIdx.setNull(argIdx++, java.sql.Types.VARCHAR); } resultSet = stmtDeleteByPwdResetIdx.executeQuery(); if (resultSet.next()) { int deleteFlag = resultSet.getInt(1); if (resultSet.next()) { resultSet.last(); throw CFLib.getDefaultExceptionFactory().newRuntimeException(getClass(), S_ProcName, "Did not expect multi-record response, " + resultSet.getRow() + " rows selected"); } } else { throw CFLib.getDefaultExceptionFactory().newRuntimeException(getClass(), S_ProcName, "Expected 1 record result set to be returned by delete, not 0 rows"); } } catch (SQLException e) { throw CFLib.getDefaultExceptionFactory().newDbException(getClass(), S_ProcName, e); } finally { if (resultSet != null) { try { resultSet.close(); } catch (SQLException e) { } resultSet = null; } } } public void deleteSecUserByPwdResetIdx(CFSecurityAuthorization Authorization, CFSecuritySecUserByPwdResetIdxKey argKey) { deleteSecUserByPwdResetIdx(Authorization, argKey.getOptionalPasswordResetUuid()); } public void deleteSecUserByDefDevIdx(CFSecurityAuthorization Authorization, UUID argDefaultDevSecUserId, String argDefaultDevName) { final String S_ProcName = "deleteSecUserByDefDevIdx"; ResultSet resultSet = null; try { Connection cnx = schema.getCnx(); final String sql = "CALL sp_delete_secuser_by_defdevidx( ?, ?, ?, ?, ?" + ", " + "?" + ", " + "?" + " )"; if (stmtDeleteByDefDevIdx == null) { stmtDeleteByDefDevIdx = cnx.prepareStatement(sql); } int argIdx = 1; stmtDeleteByDefDevIdx.setLong(argIdx++, (Authorization == null) ? 0 : Authorization.getSecClusterId()); stmtDeleteByDefDevIdx.setString(argIdx++, (Authorization == null) ? "" : Authorization.getSecUserId().toString()); stmtDeleteByDefDevIdx.setString(argIdx++, (Authorization == null) ? "" : Authorization.getSecSessionId().toString()); stmtDeleteByDefDevIdx.setLong(argIdx++, (Authorization == null) ? 0 : Authorization.getSecClusterId()); stmtDeleteByDefDevIdx.setLong(argIdx++, (Authorization == null) ? 0 : Authorization.getSecTenantId()); if (argDefaultDevSecUserId != null) { stmtDeleteByDefDevIdx.setString(argIdx++, argDefaultDevSecUserId.toString()); } else { stmtDeleteByDefDevIdx.setNull(argIdx++, java.sql.Types.VARCHAR); } if (argDefaultDevName != null) { stmtDeleteByDefDevIdx.setString(argIdx++, argDefaultDevName); } else { stmtDeleteByDefDevIdx.setNull(argIdx++, java.sql.Types.VARCHAR); } resultSet = stmtDeleteByDefDevIdx.executeQuery(); if (resultSet.next()) { int deleteFlag = resultSet.getInt(1); if (resultSet.next()) { resultSet.last(); throw CFLib.getDefaultExceptionFactory().newRuntimeException(getClass(), S_ProcName, "Did not expect multi-record response, " + resultSet.getRow() + " rows selected"); } } else { throw CFLib.getDefaultExceptionFactory().newRuntimeException(getClass(), S_ProcName, "Expected 1 record result set to be returned by delete, not 0 rows"); } } catch (SQLException e) { throw CFLib.getDefaultExceptionFactory().newDbException(getClass(), S_ProcName, e); } finally { if (resultSet != null) { try { resultSet.close(); } catch (SQLException e) { } resultSet = null; } } } public void deleteSecUserByDefDevIdx(CFSecurityAuthorization Authorization, CFSecuritySecUserByDefDevIdxKey argKey) { deleteSecUserByDefDevIdx(Authorization, argKey.getOptionalDefaultDevSecUserId(), argKey.getOptionalDefaultDevName()); } public CFSecurityCursor openSecUserCursorAll(CFSecurityAuthorization Authorization) { String sql = getSqlSelectSecUserBuff() + "ORDER BY " + "susr.SecUserId ASC"; CFAsteriskCursor cursor = new CFAsteriskDb2LUWCursor(Authorization, schema, sql); return (cursor); } public CFSecurityCursor openSecUserCursorByEMConfIdx(CFSecurityAuthorization Authorization, UUID EMailConfirmationUuid) { String sql = getSqlSelectSecUserBuff() + "WHERE " + ((EMailConfirmationUuid == null) ? "susr.em_confuuid is null " : "susr.em_confuuid = '" + EMailConfirmationUuid.toString() + "' ") + "ORDER BY " + "susr.SecUserId ASC"; CFAsteriskCursor cursor = new CFAsteriskDb2LUWCursor(Authorization, schema, sql); return (cursor); } public CFSecurityCursor openSecUserCursorByPwdResetIdx(CFSecurityAuthorization Authorization, UUID PasswordResetUuid) { String sql = getSqlSelectSecUserBuff() + "WHERE " + ((PasswordResetUuid == null) ? "susr.pwdrstuuid is null " : "susr.pwdrstuuid = '" + PasswordResetUuid.toString() + "' ") + "ORDER BY " + "susr.SecUserId ASC"; CFAsteriskCursor cursor = new CFAsteriskDb2LUWCursor(Authorization, schema, sql); return (cursor); } public void closeSecUserCursor(CFSecurityCursor Cursor) { try { Cursor.getResultSet().close(); } catch (SQLException e) { throw CFLib.getDefaultExceptionFactory().newDbException(getClass(), "closeSecUserCursor", e); } } public CFSecuritySecUserBuff nextSecUserCursor(CFSecurityCursor Cursor) { final String S_ProcName = "nextSecUserCursor"; try { ResultSet resultSet = Cursor.getResultSet(); if (!resultSet.next()) { throw CFLib.getDefaultExceptionFactory().newRuntimeException(getClass(), S_ProcName, "No more results available"); } CFSecuritySecUserBuff buff = unpackSecUserResultSetToBuff(resultSet); return (buff); } catch (SQLException e) { throw CFLib.getDefaultExceptionFactory().newDbException(getClass(), S_ProcName, e); } } public CFSecuritySecUserBuff prevSecUserCursor(CFSecurityCursor Cursor) { int targetRowIdx = (Cursor.getRowIdx() > 1) ? Cursor.getRowIdx() - 1 : 1; CFSecuritySecUserBuff buff = null; if (Cursor.getRowIdx() >= targetRowIdx) { Cursor.reset(); } while (Cursor.getRowIdx() < targetRowIdx) { buff = nextSecUserCursor(Cursor); } return (buff); } public CFSecuritySecUserBuff firstSecUserCursor(CFSecurityCursor Cursor) { int targetRowIdx = 1; CFSecuritySecUserBuff buff = null; Cursor.reset(); while (Cursor.getRowIdx() < targetRowIdx) { buff = nextSecUserCursor(Cursor); } return (buff); } public CFSecuritySecUserBuff lastSecUserCursor(CFSecurityCursor Cursor) { throw CFLib.getDefaultExceptionFactory().newNotImplementedYetException(getClass(), "lastSecUserCursor"); } public CFSecuritySecUserBuff nthSecUserCursor(CFSecurityCursor Cursor, int Idx) { int targetRowIdx = Idx; CFSecuritySecUserBuff buff = null; if (Cursor.getRowIdx() >= targetRowIdx) { Cursor.reset(); } while (Cursor.getRowIdx() < targetRowIdx) { buff = nextSecUserCursor(Cursor); } return (buff); } /** * Release the prepared statements. * <p> * When the schema changes connections, the prepared statements * have to be released because they contain connection-specific * information for most databases. */ public void releasePreparedStatements() { final String S_ProcName = "releasePreparedStatements"; S_sqlSelectSecUserDistinctClassCode = null; S_sqlSelectSecUserBuff = null; if (stmtReadBuffByPKey != null) { try { stmtReadBuffByPKey.close(); } catch (SQLException e) { } stmtReadBuffByPKey = null; } if (stmtReadAllBuff != null) { try { stmtReadAllBuff.close(); } catch (SQLException e) { } stmtReadAllBuff = null; } if (stmtLockBuffByPKey != null) { try { stmtLockBuffByPKey.close(); } catch (SQLException e) { } stmtLockBuffByPKey = null; } if (stmtCreateByPKey != null) { try { stmtCreateByPKey.close(); } catch (SQLException e) { } stmtCreateByPKey = null; } if (stmtUpdateByPKey != null) { try { stmtUpdateByPKey.close(); } catch (SQLException e) { } stmtUpdateByPKey = null; } if (stmtDeleteByPKey != null) { try { stmtDeleteByPKey.close(); } catch (SQLException e) { } stmtDeleteByPKey = null; } if (stmtDeleteByIdIdx != null) { try { stmtDeleteByIdIdx.close(); } catch (SQLException e) { } stmtDeleteByIdIdx = null; } if (stmtDeleteByULoginIdx != null) { try { stmtDeleteByULoginIdx.close(); } catch (SQLException e) { } stmtDeleteByULoginIdx = null; } if (stmtDeleteByEMConfIdx != null) { try { stmtDeleteByEMConfIdx.close(); } catch (SQLException e) { } stmtDeleteByEMConfIdx = null; } if (stmtDeleteByPwdResetIdx != null) { try { stmtDeleteByPwdResetIdx.close(); } catch (SQLException e) { } stmtDeleteByPwdResetIdx = null; } if (stmtDeleteByDefDevIdx != null) { try { stmtDeleteByDefDevIdx.close(); } catch (SQLException e) { } stmtDeleteByDefDevIdx = null; } if (stmtReadAllBuff != null) { try { stmtReadAllBuff.close(); } catch (SQLException e) { } stmtReadAllBuff = null; } if (stmtReadBuffByIdIdx != null) { try { stmtReadBuffByIdIdx.close(); } catch (SQLException e) { } stmtReadBuffByIdIdx = null; } if (stmtReadBuffByULoginIdx != null) { try { stmtReadBuffByULoginIdx.close(); } catch (SQLException e) { } stmtReadBuffByULoginIdx = null; } if (stmtReadBuffByEMConfIdx != null) { try { stmtReadBuffByEMConfIdx.close(); } catch (SQLException e) { } stmtReadBuffByEMConfIdx = null; } if (stmtReadBuffByPwdResetIdx != null) { try { stmtReadBuffByPwdResetIdx.close(); } catch (SQLException e) { } stmtReadBuffByPwdResetIdx = null; } if (stmtReadBuffByDefDevIdx != null) { try { stmtReadBuffByDefDevIdx.close(); } catch (SQLException e) { } stmtReadBuffByDefDevIdx = null; } } }