public void deleteSecGroupMember( CFSecurityAuthorization Authorization, CFSecuritySecGroupMemberBuff Buff) { final String S_ProcName = "CFFreeSwitchRamSecGroupMemberTable.deleteSecGroupMember() "; CFSecuritySecGroupMemberPKey pkey = schema.getFactorySecGroupMember().newPKey(); pkey.setRequiredClusterId(Buff.getRequiredClusterId()); pkey.setRequiredSecGroupMemberId(Buff.getRequiredSecGroupMemberId()); CFSecuritySecGroupMemberBuff existing = dictByPKey.get(pkey); if (existing == null) { return; } if (existing.getRequiredRevision() != Buff.getRequiredRevision()) { throw CFLib.getDefaultExceptionFactory() .newCollisionDetectedException(getClass(), "deleteSecGroupMember", pkey); } CFSecuritySecGroupMemberByClusterIdxKey keyClusterIdx = schema.getFactorySecGroupMember().newClusterIdxKey(); keyClusterIdx.setRequiredClusterId(existing.getRequiredClusterId()); CFSecuritySecGroupMemberByGroupIdxKey keyGroupIdx = schema.getFactorySecGroupMember().newGroupIdxKey(); keyGroupIdx.setRequiredClusterId(existing.getRequiredClusterId()); keyGroupIdx.setRequiredSecGroupId(existing.getRequiredSecGroupId()); CFSecuritySecGroupMemberByUserIdxKey keyUserIdx = schema.getFactorySecGroupMember().newUserIdxKey(); keyUserIdx.setRequiredSecUserId(existing.getRequiredSecUserId()); CFSecuritySecGroupMemberByUUserIdxKey keyUUserIdx = schema.getFactorySecGroupMember().newUUserIdxKey(); keyUUserIdx.setRequiredClusterId(existing.getRequiredClusterId()); keyUUserIdx.setRequiredSecGroupId(existing.getRequiredSecGroupId()); keyUUserIdx.setRequiredSecUserId(existing.getRequiredSecUserId()); // Validate reverse foreign keys // Delete is valid Map<CFSecuritySecGroupMemberPKey, CFSecuritySecGroupMemberBuff> subdict; dictByPKey.remove(pkey); subdict = dictByClusterIdx.get(keyClusterIdx); subdict.remove(pkey); subdict = dictByGroupIdx.get(keyGroupIdx); subdict.remove(pkey); subdict = dictByUserIdx.get(keyUserIdx); subdict.remove(pkey); dictByUUserIdx.remove(keyUUserIdx); }
public CFSecuritySecGroupMemberBuff lockDerived( CFSecurityAuthorization Authorization, CFSecuritySecGroupMemberPKey PKey) { final String S_ProcName = "CFFreeSwitchRamSecGroupMember.readDerived"; CFSecuritySecGroupMemberPKey key = schema.getFactorySecGroupMember().newPKey(); key.setRequiredClusterId(PKey.getRequiredClusterId()); key.setRequiredSecGroupMemberId(PKey.getRequiredSecGroupMemberId()); CFSecuritySecGroupMemberBuff buff; if (dictByPKey.containsKey(key)) { buff = dictByPKey.get(key); } else { buff = null; } return (buff); }
public CFSecuritySecGroupMemberBuff readDerivedByUUserIdx( CFSecurityAuthorization Authorization, long ClusterId, int SecGroupId, UUID SecUserId) { final String S_ProcName = "CFFreeSwitchRamSecGroupMember.readDerivedByUUserIdx"; CFSecuritySecGroupMemberByUUserIdxKey key = schema.getFactorySecGroupMember().newUUserIdxKey(); key.setRequiredClusterId(ClusterId); key.setRequiredSecGroupId(SecGroupId); key.setRequiredSecUserId(SecUserId); CFSecuritySecGroupMemberBuff buff; if (dictByUUserIdx.containsKey(key)) { buff = dictByUUserIdx.get(key); } else { buff = null; } return (buff); }
public void updateSecGroupMember( CFSecurityAuthorization Authorization, CFSecuritySecGroupMemberBuff Buff) { CFSecuritySecGroupMemberPKey pkey = schema.getFactorySecGroupMember().newPKey(); pkey.setRequiredClusterId(Buff.getRequiredClusterId()); pkey.setRequiredSecGroupMemberId(Buff.getRequiredSecGroupMemberId()); CFSecuritySecGroupMemberBuff existing = dictByPKey.get(pkey); if (existing == null) { throw CFLib.getDefaultExceptionFactory() .newStaleCacheDetectedException( getClass(), "updateSecGroupMember", "Existing record not found", "SecGroupMember", pkey); } if (existing.getRequiredRevision() != Buff.getRequiredRevision()) { throw CFLib.getDefaultExceptionFactory() .newCollisionDetectedException(getClass(), "updateSecGroupMember", pkey); } Buff.setRequiredRevision(Buff.getRequiredRevision() + 1); CFSecuritySecGroupMemberByClusterIdxKey existingKeyClusterIdx = schema.getFactorySecGroupMember().newClusterIdxKey(); existingKeyClusterIdx.setRequiredClusterId(existing.getRequiredClusterId()); CFSecuritySecGroupMemberByClusterIdxKey newKeyClusterIdx = schema.getFactorySecGroupMember().newClusterIdxKey(); newKeyClusterIdx.setRequiredClusterId(Buff.getRequiredClusterId()); CFSecuritySecGroupMemberByGroupIdxKey existingKeyGroupIdx = schema.getFactorySecGroupMember().newGroupIdxKey(); existingKeyGroupIdx.setRequiredClusterId(existing.getRequiredClusterId()); existingKeyGroupIdx.setRequiredSecGroupId(existing.getRequiredSecGroupId()); CFSecuritySecGroupMemberByGroupIdxKey newKeyGroupIdx = schema.getFactorySecGroupMember().newGroupIdxKey(); newKeyGroupIdx.setRequiredClusterId(Buff.getRequiredClusterId()); newKeyGroupIdx.setRequiredSecGroupId(Buff.getRequiredSecGroupId()); CFSecuritySecGroupMemberByUserIdxKey existingKeyUserIdx = schema.getFactorySecGroupMember().newUserIdxKey(); existingKeyUserIdx.setRequiredSecUserId(existing.getRequiredSecUserId()); CFSecuritySecGroupMemberByUserIdxKey newKeyUserIdx = schema.getFactorySecGroupMember().newUserIdxKey(); newKeyUserIdx.setRequiredSecUserId(Buff.getRequiredSecUserId()); CFSecuritySecGroupMemberByUUserIdxKey existingKeyUUserIdx = schema.getFactorySecGroupMember().newUUserIdxKey(); existingKeyUUserIdx.setRequiredClusterId(existing.getRequiredClusterId()); existingKeyUUserIdx.setRequiredSecGroupId(existing.getRequiredSecGroupId()); existingKeyUUserIdx.setRequiredSecUserId(existing.getRequiredSecUserId()); CFSecuritySecGroupMemberByUUserIdxKey newKeyUUserIdx = schema.getFactorySecGroupMember().newUUserIdxKey(); newKeyUUserIdx.setRequiredClusterId(Buff.getRequiredClusterId()); newKeyUUserIdx.setRequiredSecGroupId(Buff.getRequiredSecGroupId()); newKeyUUserIdx.setRequiredSecUserId(Buff.getRequiredSecUserId()); // Check unique indexes if (!existingKeyUUserIdx.equals(newKeyUUserIdx)) { if (dictByUUserIdx.containsKey(newKeyUUserIdx)) { throw CFLib.getDefaultExceptionFactory() .newUniqueIndexViolationException( getClass(), "updateSecGroupMember", "SecGroupMemberUUserIdx", newKeyUUserIdx); } } // Validate foreign keys { boolean allNull = true; if (allNull) { if (null == schema .getTableCluster() .readDerivedByIdIdx(Authorization, Buff.getRequiredClusterId())) { throw CFLib.getDefaultExceptionFactory() .newUnresolvedRelationException( getClass(), "updateSecGroupMember", "Owner", "SecGroupMemberCluster", "Cluster", null); } } } { boolean allNull = true; if (allNull) { if (null == schema .getTableSecGroup() .readDerivedByIdIdx( Authorization, Buff.getRequiredClusterId(), Buff.getRequiredSecGroupId())) { throw CFLib.getDefaultExceptionFactory() .newUnresolvedRelationException( getClass(), "updateSecGroupMember", "Container", "SecGroupMemberGroup", "SecGroup", null); } } } // Update is valid Map<CFSecuritySecGroupMemberPKey, CFSecuritySecGroupMemberBuff> subdict; dictByPKey.remove(pkey); dictByPKey.put(pkey, Buff); subdict = dictByClusterIdx.get(existingKeyClusterIdx); if (subdict != null) { subdict.remove(pkey); } if (dictByClusterIdx.containsKey(newKeyClusterIdx)) { subdict = dictByClusterIdx.get(newKeyClusterIdx); } else { subdict = new HashMap<CFSecuritySecGroupMemberPKey, CFSecuritySecGroupMemberBuff>(); dictByClusterIdx.put(newKeyClusterIdx, subdict); } subdict.put(pkey, Buff); subdict = dictByGroupIdx.get(existingKeyGroupIdx); if (subdict != null) { subdict.remove(pkey); } if (dictByGroupIdx.containsKey(newKeyGroupIdx)) { subdict = dictByGroupIdx.get(newKeyGroupIdx); } else { subdict = new HashMap<CFSecuritySecGroupMemberPKey, CFSecuritySecGroupMemberBuff>(); dictByGroupIdx.put(newKeyGroupIdx, subdict); } subdict.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<CFSecuritySecGroupMemberPKey, CFSecuritySecGroupMemberBuff>(); dictByUserIdx.put(newKeyUserIdx, subdict); } subdict.put(pkey, Buff); dictByUUserIdx.remove(existingKeyUUserIdx); dictByUUserIdx.put(newKeyUUserIdx, Buff); }