public void deleteSecDeviceByIdIdx(UUID SecUserId, String DevName) { CFSecuritySecDevicePKey pkey = ((ICFAsteriskSchema) schema.getBackingStore()).getFactorySecDevice().newPKey(); pkey.setRequiredSecUserId(SecUserId); pkey.setRequiredDevName(DevName); ICFSecuritySecDeviceObj obj = readSecDevice(pkey); if (obj != null) { ICFSecuritySecDeviceEditObj editObj = (ICFSecuritySecDeviceEditObj) obj.getEdit(); boolean editStarted; if (editObj == null) { editObj = (ICFSecuritySecDeviceEditObj) obj.beginEdit(); if (editObj != null) { editStarted = true; } else { editStarted = false; } } else { editStarted = false; } if (editObj != null) { editObj.delete(); if (editStarted) { editObj.endEdit(); } } obj.forget(true); } }
public void deleteSecDeviceByIdIdx( CFSecurityAuthorization Authorization, UUID argSecUserId, String argDevName) { CFSecuritySecDevicePKey key = schema.getFactorySecDevice().newPKey(); key.setRequiredSecUserId(argSecUserId); key.setRequiredDevName(argDevName); deleteSecDeviceByIdIdx(Authorization, key); }
public void deleteSecDevice(CFSecurityAuthorization Authorization, CFSecuritySecDeviceBuff Buff) { final String S_ProcName = "CFAsteriskRamSecDeviceTable.deleteSecDevice() "; CFSecuritySecDevicePKey pkey = schema.getFactorySecDevice().newPKey(); pkey.setRequiredSecUserId(Buff.getRequiredSecUserId()); pkey.setRequiredDevName(Buff.getRequiredDevName()); CFSecuritySecDeviceBuff existing = dictByPKey.get(pkey); if (existing == null) { return; } if (existing.getRequiredRevision() != Buff.getRequiredRevision()) { throw CFLib.getDefaultExceptionFactory() .newCollisionDetectedException(getClass(), "deleteSecDevice", pkey); } CFSecuritySecDeviceByUserIdxKey keyUserIdx = schema.getFactorySecDevice().newUserIdxKey(); keyUserIdx.setRequiredSecUserId(existing.getRequiredSecUserId()); // Validate reverse foreign keys // Delete is valid Map<CFSecuritySecDevicePKey, CFSecuritySecDeviceBuff> subdict; dictByPKey.remove(pkey); subdict = dictByUserIdx.get(keyUserIdx); subdict.remove(pkey); }
public void updateSecDevice(CFSecurityAuthorization Authorization, CFSecuritySecDeviceBuff Buff) { CFSecuritySecDevicePKey pkey = schema.getFactorySecDevice().newPKey(); pkey.setRequiredSecUserId(Buff.getRequiredSecUserId()); pkey.setRequiredDevName(Buff.getRequiredDevName()); CFSecuritySecDeviceBuff existing = dictByPKey.get(pkey); if (existing == null) { throw CFLib.getDefaultExceptionFactory() .newStaleCacheDetectedException( getClass(), "updateSecDevice", "Existing record not found", "SecDevice", pkey); } if (existing.getRequiredRevision() != Buff.getRequiredRevision()) { throw CFLib.getDefaultExceptionFactory() .newCollisionDetectedException(getClass(), "updateSecDevice", pkey); } Buff.setRequiredRevision(Buff.getRequiredRevision() + 1); CFSecuritySecDeviceByUserIdxKey existingKeyUserIdx = schema.getFactorySecDevice().newUserIdxKey(); existingKeyUserIdx.setRequiredSecUserId(existing.getRequiredSecUserId()); CFSecuritySecDeviceByUserIdxKey newKeyUserIdx = schema.getFactorySecDevice().newUserIdxKey(); newKeyUserIdx.setRequiredSecUserId(Buff.getRequiredSecUserId()); // Check unique indexes // Validate foreign keys { boolean allNull = true; if (allNull) { if (null == schema .getTableSecUser() .readDerivedByIdIdx(Authorization, Buff.getRequiredSecUserId())) { throw CFLib.getDefaultExceptionFactory() .newUnresolvedRelationException( getClass(), "updateSecDevice", "Container", "SecDeviceSecUser", "SecUser", null); } } } // Update is valid Map<CFSecuritySecDevicePKey, CFSecuritySecDeviceBuff> subdict; dictByPKey.remove(pkey); dictByPKey.put(pkey, Buff); subdict = dictByUserIdx.get(existingKeyUserIdx); if (subdict != null) { subdict.remove(pkey); } if (dictByUserIdx.containsKey(newKeyUserIdx)) { subdict = dictByUserIdx.get(newKeyUserIdx); } else { subdict = new HashMap<CFSecuritySecDevicePKey, CFSecuritySecDeviceBuff>(); dictByUserIdx.put(newKeyUserIdx, subdict); } subdict.put(pkey, Buff); }
public ICFSecuritySecDeviceObj readSecDeviceByIdIdx( UUID SecUserId, String DevName, boolean forceRead) { CFSecuritySecDevicePKey pkey = ((ICFAsteriskSchema) schema.getBackingStore()).getFactorySecDevice().newPKey(); pkey.setRequiredSecUserId(SecUserId); pkey.setRequiredDevName(DevName); ICFSecuritySecDeviceObj obj = readSecDevice(pkey, forceRead); return (obj); }
public CFSecuritySecDeviceBuff lockDerived( CFSecurityAuthorization Authorization, CFSecuritySecDevicePKey PKey) { final String S_ProcName = "CFAsteriskRamSecDevice.readDerived"; CFSecuritySecDevicePKey key = schema.getFactorySecDevice().newPKey(); key.setRequiredSecUserId(PKey.getRequiredSecUserId()); key.setRequiredDevName(PKey.getRequiredDevName()); CFSecuritySecDeviceBuff buff; if (dictByPKey.containsKey(key)) { buff = dictByPKey.get(key); } else { buff = null; } return (buff); }
public void forgetSecDeviceByIdIdx(UUID SecUserId, String DevName) { if (members == null) { return; } CFSecuritySecDevicePKey key = ((ICFAsteriskSchema) schema.getBackingStore()).getFactorySecDevice().newPKey(); key.setRequiredSecUserId(SecUserId); key.setRequiredDevName(DevName); if (members.containsKey(key)) { ICFSecuritySecDeviceObj probed = members.get(key); if (probed != null) { probed.forget(true); } } }
public void createSecDevice(CFSecurityAuthorization Authorization, CFSecuritySecDeviceBuff Buff) { final String S_ProcName = "createSecDevice"; CFSecuritySecDevicePKey pkey = schema.getFactorySecDevice().newPKey(); pkey.setRequiredSecUserId(Buff.getRequiredSecUserId()); pkey.setRequiredDevName(Buff.getRequiredDevName()); Buff.setRequiredSecUserId(pkey.getRequiredSecUserId()); Buff.setRequiredDevName(pkey.getRequiredDevName()); CFSecuritySecDeviceByUserIdxKey keyUserIdx = schema.getFactorySecDevice().newUserIdxKey(); keyUserIdx.setRequiredSecUserId(Buff.getRequiredSecUserId()); // Validate unique indexes if (dictByPKey.containsKey(pkey)) { throw CFLib.getDefaultExceptionFactory() .newPrimaryKeyNotNewException(getClass(), S_ProcName, pkey); } // Validate foreign keys { boolean allNull = true; allNull = false; if (!allNull) { if (null == schema .getTableSecUser() .readDerivedByIdIdx(Authorization, Buff.getRequiredSecUserId())) { throw CFLib.getDefaultExceptionFactory() .newUnresolvedRelationException( getClass(), S_ProcName, "Container", "SecDeviceSecUser", "SecUser", null); } } } // Proceed with adding the new record dictByPKey.put(pkey, Buff); Map<CFSecuritySecDevicePKey, CFSecuritySecDeviceBuff> subdictUserIdx; if (dictByUserIdx.containsKey(keyUserIdx)) { subdictUserIdx = dictByUserIdx.get(keyUserIdx); } else { subdictUserIdx = new HashMap<CFSecuritySecDevicePKey, CFSecuritySecDeviceBuff>(); dictByUserIdx.put(keyUserIdx, subdictUserIdx); } subdictUserIdx.put(pkey, Buff); }
public ICFSecuritySecDeviceObj readSecDevice(CFSecuritySecDevicePKey pkey, boolean forceRead) { ICFSecuritySecDeviceObj obj = null; if ((!forceRead) && members.containsKey(pkey)) { obj = members.get(pkey); } else { CFSecuritySecDeviceBuff readBuff = ((ICFAsteriskSchema) schema.getBackingStore()) .getTableSecDevice() .readDerivedByIdIdx( schema.getAuthorization(), pkey.getRequiredSecUserId(), pkey.getRequiredDevName()); if (readBuff != null) { obj = schema.getSecDeviceTableObj().newInstance(); obj.setPKey(((ICFAsteriskSchema) schema.getBackingStore()).getFactorySecDevice().newPKey()); obj.setBuff(readBuff); obj = (ICFSecuritySecDeviceObj) obj.realize(); } else if (schema.getCacheMisses()) { members.put(pkey, null); } } return (obj); }
public void deleteSecDeviceByIdIdx( CFSecurityAuthorization Authorization, CFSecuritySecDevicePKey argKey) { CFSecuritySecDeviceBuff cur; LinkedList<CFSecuritySecDeviceBuff> matchSet = new LinkedList<CFSecuritySecDeviceBuff>(); Iterator<CFSecuritySecDeviceBuff> values = dictByPKey.values().iterator(); while (values.hasNext()) { cur = values.next(); if (argKey.equals(cur)) { matchSet.add(cur); } } Iterator<CFSecuritySecDeviceBuff> iterMatch = matchSet.iterator(); while (iterMatch.hasNext()) { cur = iterMatch.next(); deleteSecDevice(Authorization, cur); } }