Java tutorial
// Description: Java 8 in-memory RAM DbIO implementation for SipConf. /* * Code Factory Asterisk 11 Configuration Model * * Copyright (c) 2014-2015 Mark Sobkow * * This program is available as free software under the GNU GPL v3, or * under a commercial license from Mark Sobkow. For commercial licensing * details, please contact msobkow@sasktel.net. * * Under the terms of the GPL: * * 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, or * (at your option) any later version. * * 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. If not, see <http://www.gnu.org/licenses/>. * */ package net.sourceforge.msscodefactory.cfasterisk.v2_4.CFAsteriskRam; import java.sql.*; 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.cfasterisk.v2_4.CFAsteriskObj.*; import net.sourceforge.msscodefactory.cfsecurity.v2_4.CFSecurityObj.*; import net.sourceforge.msscodefactory.cfinternet.v2_4.CFInternetObj.*; import net.sourceforge.msscodefactory.cfasterisk.v2_4.CFAsteriskObj.*; /* * CFAsteriskRamSipConfTable in-memory RAM DbIO implementation * for SipConf. */ public class CFAsteriskRamSipConfTable implements ICFAsteriskSipConfTable { private ICFAsteriskSchema schema; private Map<CFAsteriskConfigurationFilePKey, CFAsteriskSipConfBuff> dictByPKey = new HashMap<CFAsteriskConfigurationFilePKey, CFAsteriskSipConfBuff>(); private Map<CFAsteriskSipConfBySipClusterIdxKey, Map<CFAsteriskConfigurationFilePKey, CFAsteriskSipConfBuff>> dictBySipClusterIdx = new HashMap<CFAsteriskSipConfBySipClusterIdxKey, Map<CFAsteriskConfigurationFilePKey, CFAsteriskSipConfBuff>>(); public CFAsteriskRamSipConfTable(ICFAsteriskSchema argSchema) { schema = argSchema; } public void createSipConf(CFSecurityAuthorization Authorization, CFAsteriskSipConfBuff Buff) { final String S_ProcName = "createSipConf"; schema.getTableConfigurationFile().createConfigurationFile(Authorization, Buff); CFAsteriskConfigurationFilePKey pkey = schema.getFactoryConfigurationFile().newPKey(); pkey.setClassCode(Buff.getClassCode()); pkey.setRequiredClusterId(Buff.getRequiredClusterId()); pkey.setRequiredId(Buff.getRequiredId()); CFAsteriskSipConfBySipClusterIdxKey keySipClusterIdx = schema.getFactorySipConf().newSipClusterIdxKey(); keySipClusterIdx.setRequiredClusterId(Buff.getRequiredClusterId()); // Validate unique indexes if (dictByPKey.containsKey(pkey)) { throw CFLib.getDefaultExceptionFactory().newPrimaryKeyNotNewException(getClass(), S_ProcName, pkey); } // Validate foreign keys { boolean allNull = true; allNull = false; allNull = false; if (!allNull) { if (null == schema.getTableConfigurationFile().readDerivedByIdIdx(Authorization, Buff.getRequiredClusterId(), Buff.getRequiredId())) { throw CFLib.getDefaultExceptionFactory().newUnresolvedRelationException(getClass(), S_ProcName, "Superclass", "SuperClass", "ConfigurationFile", null); } } } // Proceed with adding the new record dictByPKey.put(pkey, Buff); Map<CFAsteriskConfigurationFilePKey, CFAsteriskSipConfBuff> subdictSipClusterIdx; if (dictBySipClusterIdx.containsKey(keySipClusterIdx)) { subdictSipClusterIdx = dictBySipClusterIdx.get(keySipClusterIdx); } else { subdictSipClusterIdx = new HashMap<CFAsteriskConfigurationFilePKey, CFAsteriskSipConfBuff>(); dictBySipClusterIdx.put(keySipClusterIdx, subdictSipClusterIdx); } subdictSipClusterIdx.put(pkey, Buff); } public CFAsteriskSipConfBuff readDerived(CFSecurityAuthorization Authorization, CFAsteriskConfigurationFilePKey PKey) { final String S_ProcName = "CFAsteriskRamSipConf.readDerived"; CFAsteriskConfigurationFilePKey key = schema.getFactoryConfigurationFile().newPKey(); key.setRequiredClusterId(PKey.getRequiredClusterId()); key.setRequiredId(PKey.getRequiredId()); CFAsteriskSipConfBuff buff; if (dictByPKey.containsKey(key)) { buff = dictByPKey.get(key); } else { buff = null; } return (buff); } public CFAsteriskSipConfBuff lockDerived(CFSecurityAuthorization Authorization, CFAsteriskConfigurationFilePKey PKey) { final String S_ProcName = "CFAsteriskRamSipConf.readDerived"; CFAsteriskConfigurationFilePKey key = schema.getFactoryConfigurationFile().newPKey(); key.setRequiredClusterId(PKey.getRequiredClusterId()); key.setRequiredId(PKey.getRequiredId()); CFAsteriskSipConfBuff buff; if (dictByPKey.containsKey(key)) { buff = dictByPKey.get(key); } else { buff = null; } return (buff); } public CFAsteriskSipConfBuff[] readAllDerived(CFSecurityAuthorization Authorization) { final String S_ProcName = "CFAsteriskRamSipConf.readAllDerived"; CFAsteriskSipConfBuff[] retList = new CFAsteriskSipConfBuff[dictByPKey.values().size()]; Iterator<CFAsteriskSipConfBuff> iter = dictByPKey.values().iterator(); int idx = 0; while (iter.hasNext()) { retList[idx++] = iter.next(); } return (retList); } public CFAsteriskSipConfBuff[] readDerivedByClusterIdx(CFSecurityAuthorization Authorization, long ClusterId) { final String S_ProcName = "CFAsteriskRamConfigurationFile.readDerivedByClusterIdx"; CFAsteriskConfigurationFileBuff buffList[] = schema.getTableConfigurationFile() .readDerivedByClusterIdx(Authorization, ClusterId); if (buffList == null) { return (null); } else { CFAsteriskConfigurationFileBuff buff; ArrayList<CFAsteriskSipConfBuff> filteredList = new ArrayList<CFAsteriskSipConfBuff>(); for (int idx = 0; idx < buffList.length; idx++) { buff = buffList[idx]; if ((buff != null) && (buff instanceof CFAsteriskSipConfBuff)) { filteredList.add((CFAsteriskSipConfBuff) buff); } } return (filteredList.toArray(new CFAsteriskSipConfBuff[0])); } } public CFAsteriskSipConfBuff[] readDerivedByHostIdx(CFSecurityAuthorization Authorization, long ClusterId, long HostNodeId) { final String S_ProcName = "CFAsteriskRamConfigurationFile.readDerivedByHostIdx"; CFAsteriskConfigurationFileBuff buffList[] = schema.getTableConfigurationFile() .readDerivedByHostIdx(Authorization, ClusterId, HostNodeId); if (buffList == null) { return (null); } else { CFAsteriskConfigurationFileBuff buff; ArrayList<CFAsteriskSipConfBuff> filteredList = new ArrayList<CFAsteriskSipConfBuff>(); for (int idx = 0; idx < buffList.length; idx++) { buff = buffList[idx]; if ((buff != null) && (buff instanceof CFAsteriskSipConfBuff)) { filteredList.add((CFAsteriskSipConfBuff) buff); } } return (filteredList.toArray(new CFAsteriskSipConfBuff[0])); } } public CFAsteriskSipConfBuff readDerivedByUNameIdx(CFSecurityAuthorization Authorization, long ClusterId, long HostNodeId, String FileFullName) { final String S_ProcName = "CFAsteriskRamConfigurationFile.readDerivedByUNameIdx"; CFAsteriskConfigurationFileBuff buff = schema.getTableConfigurationFile() .readDerivedByUNameIdx(Authorization, ClusterId, HostNodeId, FileFullName); if (buff == null) { return (null); } else if (buff instanceof CFAsteriskSipConfBuff) { return ((CFAsteriskSipConfBuff) buff); } else { return (null); } } public CFAsteriskSipConfBuff[] readDerivedBySipClusterIdx(CFSecurityAuthorization Authorization, long ClusterId) { final String S_ProcName = "CFAsteriskRamSipConf.readDerivedBySipClusterIdx"; CFAsteriskSipConfBySipClusterIdxKey key = schema.getFactorySipConf().newSipClusterIdxKey(); key.setRequiredClusterId(ClusterId); CFAsteriskSipConfBuff[] recArray; if (dictBySipClusterIdx.containsKey(key)) { Map<CFAsteriskConfigurationFilePKey, CFAsteriskSipConfBuff> subdictSipClusterIdx = dictBySipClusterIdx .get(key); recArray = new CFAsteriskSipConfBuff[subdictSipClusterIdx.size()]; Iterator<CFAsteriskSipConfBuff> iter = subdictSipClusterIdx.values().iterator(); int idx = 0; while (iter.hasNext()) { recArray[idx++] = iter.next(); } } else { Map<CFAsteriskConfigurationFilePKey, CFAsteriskSipConfBuff> subdictSipClusterIdx = new HashMap<CFAsteriskConfigurationFilePKey, CFAsteriskSipConfBuff>(); dictBySipClusterIdx.put(key, subdictSipClusterIdx); recArray = new CFAsteriskSipConfBuff[0]; } return (recArray); } public CFAsteriskSipConfBuff readDerivedByIdIdx(CFSecurityAuthorization Authorization, long ClusterId, long Id) { final String S_ProcName = "CFAsteriskRamConfigurationFile.readDerivedByIdIdx() "; CFAsteriskConfigurationFilePKey key = schema.getFactoryConfigurationFile().newPKey(); key.setRequiredClusterId(ClusterId); key.setRequiredId(Id); CFAsteriskSipConfBuff buff; if (dictByPKey.containsKey(key)) { buff = dictByPKey.get(key); } else { buff = null; } return (buff); } public CFAsteriskSipConfBuff readBuff(CFSecurityAuthorization Authorization, CFAsteriskConfigurationFilePKey PKey) { final String S_ProcName = "CFAsteriskRamSipConf.readBuff"; CFAsteriskSipConfBuff buff = readDerived(Authorization, PKey); if ((buff != null) && (!buff.getClassCode().equals("CSIP"))) { buff = null; } return (buff); } public CFAsteriskSipConfBuff lockBuff(CFSecurityAuthorization Authorization, CFAsteriskConfigurationFilePKey PKey) { final String S_ProcName = "lockBuff"; CFAsteriskSipConfBuff buff = readDerived(Authorization, PKey); if ((buff != null) && (!buff.getClassCode().equals("CSIP"))) { buff = null; } return (buff); } public CFAsteriskSipConfBuff[] readAllBuff(CFSecurityAuthorization Authorization) { final String S_ProcName = "CFAsteriskRamSipConf.readAllBuff"; CFAsteriskSipConfBuff buff; ArrayList<CFAsteriskSipConfBuff> filteredList = new ArrayList<CFAsteriskSipConfBuff>(); CFAsteriskSipConfBuff[] buffList = readAllDerived(Authorization); for (int idx = 0; idx < buffList.length; idx++) { buff = buffList[idx]; if ((buff != null) && buff.getClassCode().equals("CSIP")) { filteredList.add(buff); } } return (filteredList.toArray(new CFAsteriskSipConfBuff[0])); } public CFAsteriskSipConfBuff readBuffByIdIdx(CFSecurityAuthorization Authorization, long ClusterId, long Id) { final String S_ProcName = "CFAsteriskRamConfigurationFile.readBuffByIdIdx() "; CFAsteriskSipConfBuff buff = readDerivedByIdIdx(Authorization, ClusterId, Id); if ((buff != null) && buff.getClassCode().equals("CONF")) { return ((CFAsteriskSipConfBuff) buff); } else { return (null); } } public CFAsteriskSipConfBuff[] readBuffByClusterIdx(CFSecurityAuthorization Authorization, long ClusterId) { final String S_ProcName = "CFAsteriskRamConfigurationFile.readBuffByClusterIdx() "; CFAsteriskSipConfBuff buff; ArrayList<CFAsteriskSipConfBuff> filteredList = new ArrayList<CFAsteriskSipConfBuff>(); CFAsteriskSipConfBuff[] buffList = readDerivedByClusterIdx(Authorization, ClusterId); for (int idx = 0; idx < buffList.length; idx++) { buff = buffList[idx]; if ((buff != null) && buff.getClassCode().equals("CONF")) { filteredList.add((CFAsteriskSipConfBuff) buff); } } return (filteredList.toArray(new CFAsteriskSipConfBuff[0])); } public CFAsteriskSipConfBuff[] readBuffByHostIdx(CFSecurityAuthorization Authorization, long ClusterId, long HostNodeId) { final String S_ProcName = "CFAsteriskRamConfigurationFile.readBuffByHostIdx() "; CFAsteriskSipConfBuff buff; ArrayList<CFAsteriskSipConfBuff> filteredList = new ArrayList<CFAsteriskSipConfBuff>(); CFAsteriskSipConfBuff[] buffList = readDerivedByHostIdx(Authorization, ClusterId, HostNodeId); for (int idx = 0; idx < buffList.length; idx++) { buff = buffList[idx]; if ((buff != null) && buff.getClassCode().equals("CONF")) { filteredList.add((CFAsteriskSipConfBuff) buff); } } return (filteredList.toArray(new CFAsteriskSipConfBuff[0])); } public CFAsteriskSipConfBuff readBuffByUNameIdx(CFSecurityAuthorization Authorization, long ClusterId, long HostNodeId, String FileFullName) { final String S_ProcName = "CFAsteriskRamConfigurationFile.readBuffByUNameIdx() "; CFAsteriskSipConfBuff buff = readDerivedByUNameIdx(Authorization, ClusterId, HostNodeId, FileFullName); if ((buff != null) && buff.getClassCode().equals("CONF")) { return ((CFAsteriskSipConfBuff) buff); } else { return (null); } } public CFAsteriskSipConfBuff[] readBuffBySipClusterIdx(CFSecurityAuthorization Authorization, long ClusterId) { final String S_ProcName = "CFAsteriskRamSipConf.readBuffBySipClusterIdx() "; CFAsteriskSipConfBuff buff; ArrayList<CFAsteriskSipConfBuff> filteredList = new ArrayList<CFAsteriskSipConfBuff>(); CFAsteriskSipConfBuff[] buffList = readDerivedBySipClusterIdx(Authorization, ClusterId); for (int idx = 0; idx < buffList.length; idx++) { buff = buffList[idx]; if ((buff != null) && buff.getClassCode().equals("CSIP")) { filteredList.add((CFAsteriskSipConfBuff) buff); } } return (filteredList.toArray(new CFAsteriskSipConfBuff[0])); } public void updateSipConf(CFSecurityAuthorization Authorization, CFAsteriskSipConfBuff Buff) { schema.getTableConfigurationFile().updateConfigurationFile(Authorization, Buff); CFAsteriskConfigurationFilePKey pkey = schema.getFactoryConfigurationFile().newPKey(); pkey.setRequiredClusterId(Buff.getRequiredClusterId()); pkey.setRequiredId(Buff.getRequiredId()); CFAsteriskSipConfBuff existing = dictByPKey.get(pkey); if (existing == null) { throw CFLib.getDefaultExceptionFactory().newStaleCacheDetectedException(getClass(), "updateSipConf", "Existing record not found", "SipConf", pkey); } CFAsteriskSipConfBySipClusterIdxKey existingKeySipClusterIdx = schema.getFactorySipConf() .newSipClusterIdxKey(); existingKeySipClusterIdx.setRequiredClusterId(existing.getRequiredClusterId()); CFAsteriskSipConfBySipClusterIdxKey newKeySipClusterIdx = schema.getFactorySipConf().newSipClusterIdxKey(); newKeySipClusterIdx.setRequiredClusterId(Buff.getRequiredClusterId()); // Check unique indexes // Validate foreign keys { boolean allNull = true; if (allNull) { if (null == schema.getTableConfigurationFile().readDerivedByIdIdx(Authorization, Buff.getRequiredClusterId(), Buff.getRequiredId())) { throw CFLib.getDefaultExceptionFactory().newUnresolvedRelationException(getClass(), "updateSipConf", "Superclass", "SuperClass", "ConfigurationFile", null); } } } // Update is valid Map<CFAsteriskConfigurationFilePKey, CFAsteriskSipConfBuff> subdict; dictByPKey.remove(pkey); dictByPKey.put(pkey, Buff); subdict = dictBySipClusterIdx.get(existingKeySipClusterIdx); if (subdict != null) { subdict.remove(pkey); } if (dictBySipClusterIdx.containsKey(newKeySipClusterIdx)) { subdict = dictBySipClusterIdx.get(newKeySipClusterIdx); } else { subdict = new HashMap<CFAsteriskConfigurationFilePKey, CFAsteriskSipConfBuff>(); dictBySipClusterIdx.put(newKeySipClusterIdx, subdict); } subdict.put(pkey, Buff); } public void deleteSipConf(CFSecurityAuthorization Authorization, CFAsteriskSipConfBuff Buff) { final String S_ProcName = "CFAsteriskRamSipConfTable.deleteSipConf() "; CFAsteriskConfigurationFilePKey pkey = schema.getFactoryConfigurationFile().newPKey(); pkey.setRequiredClusterId(Buff.getRequiredClusterId()); pkey.setRequiredId(Buff.getRequiredId()); CFAsteriskSipConfBuff existing = dictByPKey.get(pkey); if (existing == null) { return; } if (existing.getRequiredRevision() != Buff.getRequiredRevision()) { throw CFLib.getDefaultExceptionFactory().newCollisionDetectedException(getClass(), "deleteSipConf", pkey); } CFAsteriskSipConfBySipClusterIdxKey keySipClusterIdx = schema.getFactorySipConf().newSipClusterIdxKey(); keySipClusterIdx.setRequiredClusterId(existing.getRequiredClusterId()); // Validate reverse foreign keys // Delete is valid Map<CFAsteriskConfigurationFilePKey, CFAsteriskSipConfBuff> subdict; dictByPKey.remove(pkey); subdict = dictBySipClusterIdx.get(keySipClusterIdx); subdict.remove(pkey); schema.getTableConfigurationFile().deleteConfigurationFile(Authorization, Buff); } public void deleteSipConfBySipClusterIdx(CFSecurityAuthorization Authorization, long argClusterId) { CFAsteriskSipConfBySipClusterIdxKey key = schema.getFactorySipConf().newSipClusterIdxKey(); key.setRequiredClusterId(argClusterId); deleteSipConfBySipClusterIdx(Authorization, key); } public void deleteSipConfBySipClusterIdx(CFSecurityAuthorization Authorization, CFAsteriskSipConfBySipClusterIdxKey argKey) { CFAsteriskSipConfBuff cur; LinkedList<CFAsteriskSipConfBuff> matchSet = new LinkedList<CFAsteriskSipConfBuff>(); Iterator<CFAsteriskSipConfBuff> values = dictByPKey.values().iterator(); while (values.hasNext()) { cur = values.next(); if (argKey.equals(cur)) { matchSet.add(cur); } } Iterator<CFAsteriskSipConfBuff> iterMatch = matchSet.iterator(); while (iterMatch.hasNext()) { cur = iterMatch.next(); deleteSipConf(Authorization, cur); } } public void deleteSipConfByIdIdx(CFSecurityAuthorization Authorization, long argClusterId, long argId) { CFAsteriskConfigurationFilePKey key = schema.getFactoryConfigurationFile().newPKey(); key.setRequiredClusterId(argClusterId); key.setRequiredId(argId); deleteSipConfByIdIdx(Authorization, key); } public void deleteSipConfByIdIdx(CFSecurityAuthorization Authorization, CFAsteriskConfigurationFilePKey argKey) { CFAsteriskSipConfBuff cur; LinkedList<CFAsteriskSipConfBuff> matchSet = new LinkedList<CFAsteriskSipConfBuff>(); Iterator<CFAsteriskSipConfBuff> values = dictByPKey.values().iterator(); while (values.hasNext()) { cur = values.next(); if (argKey.equals(cur)) { matchSet.add(cur); } } Iterator<CFAsteriskSipConfBuff> iterMatch = matchSet.iterator(); while (iterMatch.hasNext()) { cur = iterMatch.next(); deleteSipConf(Authorization, cur); } } public void deleteSipConfByClusterIdx(CFSecurityAuthorization Authorization, long argClusterId) { CFAsteriskConfigurationFileByClusterIdxKey key = schema.getFactoryConfigurationFile().newClusterIdxKey(); key.setRequiredClusterId(argClusterId); deleteSipConfByClusterIdx(Authorization, key); } public void deleteSipConfByClusterIdx(CFSecurityAuthorization Authorization, CFAsteriskConfigurationFileByClusterIdxKey argKey) { CFAsteriskSipConfBuff cur; LinkedList<CFAsteriskSipConfBuff> matchSet = new LinkedList<CFAsteriskSipConfBuff>(); Iterator<CFAsteriskSipConfBuff> values = dictByPKey.values().iterator(); while (values.hasNext()) { cur = values.next(); if (argKey.equals(cur)) { matchSet.add(cur); } } Iterator<CFAsteriskSipConfBuff> iterMatch = matchSet.iterator(); while (iterMatch.hasNext()) { cur = iterMatch.next(); deleteSipConf(Authorization, cur); } } public void deleteSipConfByHostIdx(CFSecurityAuthorization Authorization, long argClusterId, long argHostNodeId) { CFAsteriskConfigurationFileByHostIdxKey key = schema.getFactoryConfigurationFile().newHostIdxKey(); key.setRequiredClusterId(argClusterId); key.setRequiredHostNodeId(argHostNodeId); deleteSipConfByHostIdx(Authorization, key); } public void deleteSipConfByHostIdx(CFSecurityAuthorization Authorization, CFAsteriskConfigurationFileByHostIdxKey argKey) { CFAsteriskSipConfBuff cur; LinkedList<CFAsteriskSipConfBuff> matchSet = new LinkedList<CFAsteriskSipConfBuff>(); Iterator<CFAsteriskSipConfBuff> values = dictByPKey.values().iterator(); while (values.hasNext()) { cur = values.next(); if (argKey.equals(cur)) { matchSet.add(cur); } } Iterator<CFAsteriskSipConfBuff> iterMatch = matchSet.iterator(); while (iterMatch.hasNext()) { cur = iterMatch.next(); deleteSipConf(Authorization, cur); } } public void deleteSipConfByUNameIdx(CFSecurityAuthorization Authorization, long argClusterId, long argHostNodeId, String argFileFullName) { CFAsteriskConfigurationFileByUNameIdxKey key = schema.getFactoryConfigurationFile().newUNameIdxKey(); key.setRequiredClusterId(argClusterId); key.setRequiredHostNodeId(argHostNodeId); key.setRequiredFileFullName(argFileFullName); deleteSipConfByUNameIdx(Authorization, key); } public void deleteSipConfByUNameIdx(CFSecurityAuthorization Authorization, CFAsteriskConfigurationFileByUNameIdxKey argKey) { CFAsteriskSipConfBuff cur; LinkedList<CFAsteriskSipConfBuff> matchSet = new LinkedList<CFAsteriskSipConfBuff>(); Iterator<CFAsteriskSipConfBuff> values = dictByPKey.values().iterator(); while (values.hasNext()) { cur = values.next(); if (argKey.equals(cur)) { matchSet.add(cur); } } Iterator<CFAsteriskSipConfBuff> iterMatch = matchSet.iterator(); while (iterMatch.hasNext()) { cur = iterMatch.next(); deleteSipConf(Authorization, cur); } } public CFSecurityCursor openSipConfCursorAll(CFSecurityAuthorization Authorization) { CFSecurityCursor cursor = new CFAsteriskRamSipConfCursor(Authorization, schema, dictByPKey.values()); return (cursor); } public CFSecurityCursor openSipConfCursorBySipClusterIdx(CFSecurityAuthorization Authorization, long ClusterId) { CFSecurityCursor cursor; CFAsteriskSipConfBySipClusterIdxKey key = schema.getFactorySipConf().newSipClusterIdxKey(); key.setRequiredClusterId(ClusterId); if (dictBySipClusterIdx.containsKey(key)) { Map<CFAsteriskConfigurationFilePKey, CFAsteriskSipConfBuff> subdictSipClusterIdx = dictBySipClusterIdx .get(key); cursor = new CFAsteriskRamSipConfCursor(Authorization, schema, subdictSipClusterIdx.values()); } else { cursor = new CFAsteriskRamSipConfCursor(Authorization, schema, new ArrayList<CFAsteriskSipConfBuff>()); } return (cursor); } public void closeSipConfCursor(CFSecurityCursor Cursor) { // Cursor.DataReader.Close(); } public CFAsteriskSipConfBuff nextSipConfCursor(CFSecurityCursor Cursor) { CFAsteriskRamSipConfCursor cursor = (CFAsteriskRamSipConfCursor) Cursor; CFAsteriskSipConfBuff rec = cursor.getCursor().next(); cursor.setRowIdx(cursor.getRowIdx() + 1); return (rec); } public CFAsteriskSipConfBuff prevSipConfCursor(CFSecurityCursor Cursor) { int targetRowIdx = (Cursor.getRowIdx() > 1) ? Cursor.getRowIdx() - 1 : 1; CFAsteriskSipConfBuff rec = null; if (Cursor.getRowIdx() >= targetRowIdx) { Cursor.reset(); } while (Cursor.getRowIdx() < targetRowIdx) { rec = nextSipConfCursor(Cursor); } return (rec); } public CFAsteriskSipConfBuff firstSipConfCursor(CFSecurityCursor Cursor) { int targetRowIdx = 1; CFAsteriskSipConfBuff rec = null; Cursor.reset(); while (Cursor.getRowIdx() < targetRowIdx) { rec = nextSipConfCursor(Cursor); } return (rec); } public CFAsteriskSipConfBuff lastSipConfCursor(CFSecurityCursor Cursor) { throw CFLib.getDefaultExceptionFactory().newNotImplementedYetException(getClass(), "lastSipConfCursor"); } public CFAsteriskSipConfBuff nthSipConfCursor(CFSecurityCursor Cursor, int Idx) { int targetRowIdx = Idx; CFAsteriskSipConfBuff rec = null; if (Cursor.getRowIdx() >= targetRowIdx) { Cursor.reset(); } while (Cursor.getRowIdx() < targetRowIdx) { rec = nextSipConfCursor(Cursor); } return (rec); } public void releasePreparedStatements() { } }