public void deleteSecSession( CFSecurityAuthorization Authorization, CFSecuritySecSessionBuff Buff) { final String S_ProcName = "CFSecurityRamSecSessionTable.deleteSecSession() "; CFSecuritySecSessionPKey pkey = schema.getFactorySecSession().newPKey(); pkey.setRequiredSecSessionId(Buff.getRequiredSecSessionId()); CFSecuritySecSessionBuff existing = dictByPKey.get(pkey); if (existing == null) { return; } if (existing.getRequiredRevision() != Buff.getRequiredRevision()) { throw CFLib.getDefaultExceptionFactory() .newCollisionDetectedException(getClass(), "deleteSecSession", pkey); } CFSecuritySecSessionBySecUserIdxKey keySecUserIdx = schema.getFactorySecSession().newSecUserIdxKey(); keySecUserIdx.setRequiredSecUserId(existing.getRequiredSecUserId()); CFSecuritySecSessionBySecDevIdxKey keySecDevIdx = schema.getFactorySecSession().newSecDevIdxKey(); keySecDevIdx.setRequiredSecUserId(existing.getRequiredSecUserId()); keySecDevIdx.setOptionalSecDevName(existing.getOptionalSecDevName()); CFSecuritySecSessionByStartIdxKey keyStartIdx = schema.getFactorySecSession().newStartIdxKey(); keyStartIdx.setRequiredSecUserId(existing.getRequiredSecUserId()); keyStartIdx.setRequiredStart(existing.getRequiredStart()); CFSecuritySecSessionByFinishIdxKey keyFinishIdx = schema.getFactorySecSession().newFinishIdxKey(); keyFinishIdx.setRequiredSecUserId(existing.getRequiredSecUserId()); keyFinishIdx.setOptionalFinish(existing.getOptionalFinish()); CFSecuritySecSessionBySecProxyIdxKey keySecProxyIdx = schema.getFactorySecSession().newSecProxyIdxKey(); keySecProxyIdx.setOptionalSecProxyId(existing.getOptionalSecProxyId()); // Validate reverse foreign keys // Delete is valid Map<CFSecuritySecSessionPKey, CFSecuritySecSessionBuff> subdict; dictByPKey.remove(pkey); subdict = dictBySecUserIdx.get(keySecUserIdx); subdict.remove(pkey); subdict = dictBySecDevIdx.get(keySecDevIdx); subdict.remove(pkey); dictByStartIdx.remove(keyStartIdx); subdict = dictByFinishIdx.get(keyFinishIdx); subdict.remove(pkey); subdict = dictBySecProxyIdx.get(keySecProxyIdx); subdict.remove(pkey); }
public void updateSecSession( CFSecurityAuthorization Authorization, CFSecuritySecSessionBuff Buff) { CFSecuritySecSessionPKey pkey = schema.getFactorySecSession().newPKey(); pkey.setRequiredSecSessionId(Buff.getRequiredSecSessionId()); CFSecuritySecSessionBuff existing = dictByPKey.get(pkey); if (existing == null) { throw CFLib.getDefaultExceptionFactory() .newStaleCacheDetectedException( getClass(), "updateSecSession", "Existing record not found", "SecSession", pkey); } if (existing.getRequiredRevision() != Buff.getRequiredRevision()) { throw CFLib.getDefaultExceptionFactory() .newCollisionDetectedException(getClass(), "updateSecSession", pkey); } Buff.setRequiredRevision(Buff.getRequiredRevision() + 1); CFSecuritySecSessionBySecUserIdxKey existingKeySecUserIdx = schema.getFactorySecSession().newSecUserIdxKey(); existingKeySecUserIdx.setRequiredSecUserId(existing.getRequiredSecUserId()); CFSecuritySecSessionBySecUserIdxKey newKeySecUserIdx = schema.getFactorySecSession().newSecUserIdxKey(); newKeySecUserIdx.setRequiredSecUserId(Buff.getRequiredSecUserId()); CFSecuritySecSessionBySecDevIdxKey existingKeySecDevIdx = schema.getFactorySecSession().newSecDevIdxKey(); existingKeySecDevIdx.setRequiredSecUserId(existing.getRequiredSecUserId()); existingKeySecDevIdx.setOptionalSecDevName(existing.getOptionalSecDevName()); CFSecuritySecSessionBySecDevIdxKey newKeySecDevIdx = schema.getFactorySecSession().newSecDevIdxKey(); newKeySecDevIdx.setRequiredSecUserId(Buff.getRequiredSecUserId()); newKeySecDevIdx.setOptionalSecDevName(Buff.getOptionalSecDevName()); CFSecuritySecSessionByStartIdxKey existingKeyStartIdx = schema.getFactorySecSession().newStartIdxKey(); existingKeyStartIdx.setRequiredSecUserId(existing.getRequiredSecUserId()); existingKeyStartIdx.setRequiredStart(existing.getRequiredStart()); CFSecuritySecSessionByStartIdxKey newKeyStartIdx = schema.getFactorySecSession().newStartIdxKey(); newKeyStartIdx.setRequiredSecUserId(Buff.getRequiredSecUserId()); newKeyStartIdx.setRequiredStart(Buff.getRequiredStart()); CFSecuritySecSessionByFinishIdxKey existingKeyFinishIdx = schema.getFactorySecSession().newFinishIdxKey(); existingKeyFinishIdx.setRequiredSecUserId(existing.getRequiredSecUserId()); existingKeyFinishIdx.setOptionalFinish(existing.getOptionalFinish()); CFSecuritySecSessionByFinishIdxKey newKeyFinishIdx = schema.getFactorySecSession().newFinishIdxKey(); newKeyFinishIdx.setRequiredSecUserId(Buff.getRequiredSecUserId()); newKeyFinishIdx.setOptionalFinish(Buff.getOptionalFinish()); CFSecuritySecSessionBySecProxyIdxKey existingKeySecProxyIdx = schema.getFactorySecSession().newSecProxyIdxKey(); existingKeySecProxyIdx.setOptionalSecProxyId(existing.getOptionalSecProxyId()); CFSecuritySecSessionBySecProxyIdxKey newKeySecProxyIdx = schema.getFactorySecSession().newSecProxyIdxKey(); newKeySecProxyIdx.setOptionalSecProxyId(Buff.getOptionalSecProxyId()); // Check unique indexes if (!existingKeyStartIdx.equals(newKeyStartIdx)) { if (dictByStartIdx.containsKey(newKeyStartIdx)) { throw CFLib.getDefaultExceptionFactory() .newUniqueIndexViolationException( getClass(), "updateSecSession", "SessionStartIdx", newKeyStartIdx); } } // Validate foreign keys { boolean allNull = true; if (allNull) { if (null == schema .getTableSecUser() .readDerivedByIdIdx(Authorization, Buff.getRequiredSecUserId())) { throw CFLib.getDefaultExceptionFactory() .newUnresolvedRelationException( getClass(), "updateSecSession", "Container", "SecSessionUser", "SecUser", null); } } } // Update is valid Map<CFSecuritySecSessionPKey, CFSecuritySecSessionBuff> subdict; dictByPKey.remove(pkey); dictByPKey.put(pkey, Buff); subdict = dictBySecUserIdx.get(existingKeySecUserIdx); if (subdict != null) { subdict.remove(pkey); } if (dictBySecUserIdx.containsKey(newKeySecUserIdx)) { subdict = dictBySecUserIdx.get(newKeySecUserIdx); } else { subdict = new HashMap<CFSecuritySecSessionPKey, CFSecuritySecSessionBuff>(); dictBySecUserIdx.put(newKeySecUserIdx, subdict); } subdict.put(pkey, Buff); subdict = dictBySecDevIdx.get(existingKeySecDevIdx); if (subdict != null) { subdict.remove(pkey); } if (dictBySecDevIdx.containsKey(newKeySecDevIdx)) { subdict = dictBySecDevIdx.get(newKeySecDevIdx); } else { subdict = new HashMap<CFSecuritySecSessionPKey, CFSecuritySecSessionBuff>(); dictBySecDevIdx.put(newKeySecDevIdx, subdict); } subdict.put(pkey, Buff); dictByStartIdx.remove(existingKeyStartIdx); dictByStartIdx.put(newKeyStartIdx, Buff); subdict = dictByFinishIdx.get(existingKeyFinishIdx); if (subdict != null) { subdict.remove(pkey); } if (dictByFinishIdx.containsKey(newKeyFinishIdx)) { subdict = dictByFinishIdx.get(newKeyFinishIdx); } else { subdict = new HashMap<CFSecuritySecSessionPKey, CFSecuritySecSessionBuff>(); dictByFinishIdx.put(newKeyFinishIdx, subdict); } subdict.put(pkey, Buff); subdict = dictBySecProxyIdx.get(existingKeySecProxyIdx); if (subdict != null) { subdict.remove(pkey); } if (dictBySecProxyIdx.containsKey(newKeySecProxyIdx)) { subdict = dictBySecProxyIdx.get(newKeySecProxyIdx); } else { subdict = new HashMap<CFSecuritySecSessionPKey, CFSecuritySecSessionBuff>(); dictBySecProxyIdx.put(newKeySecProxyIdx, subdict); } subdict.put(pkey, Buff); }