List of usage examples for java.util SortedMap remove
V remove(Object key);
From source file:net.sourceforge.msscodefactory.cfsecurity.v2_0.CFSecurityRam.CFSecurityRamSecGroupIncludeTable.java
public void deleteSecGroupInclude(CFSecurityAuthorization Authorization, CFSecuritySecGroupIncludeBuff Buff) { final String S_ProcName = "CFSecurityRamSecGroupIncludeTable.deleteSecGroupInclude() "; CFSecuritySecGroupIncludePKey pkey = schema.getFactorySecGroupInclude().newPKey(); pkey.setRequiredClusterId(Buff.getRequiredClusterId()); pkey.setRequiredSecGroupIncludeId(Buff.getRequiredSecGroupIncludeId()); CFSecuritySecGroupIncludeBuff existing = dictByPKey.get(pkey); if (existing == null) { return;//from w ww. j a v a 2 s . c o m } if (existing.getRequiredRevision() != Buff.getRequiredRevision()) { throw CFLib.getDefaultExceptionFactory().newCollisionDetectedException(getClass(), "deleteSecGroupInclude", pkey); } CFSecuritySecGroupIncludeByClusterIdxKey keyClusterIdx = schema.getFactorySecGroupInclude() .newClusterIdxKey(); keyClusterIdx.setRequiredClusterId(existing.getRequiredClusterId()); CFSecuritySecGroupIncludeByGroupIdxKey keyGroupIdx = schema.getFactorySecGroupInclude().newGroupIdxKey(); keyGroupIdx.setRequiredClusterId(existing.getRequiredClusterId()); keyGroupIdx.setRequiredSecGroupId(existing.getRequiredSecGroupId()); CFSecuritySecGroupIncludeByIncludeIdxKey keyIncludeIdx = schema.getFactorySecGroupInclude() .newIncludeIdxKey(); keyIncludeIdx.setRequiredClusterId(existing.getRequiredClusterId()); keyIncludeIdx.setRequiredIncludeGroupId(existing.getRequiredIncludeGroupId()); CFSecuritySecGroupIncludeByUIncludeIdxKey keyUIncludeIdx = schema.getFactorySecGroupInclude() .newUIncludeIdxKey(); keyUIncludeIdx.setRequiredClusterId(existing.getRequiredClusterId()); keyUIncludeIdx.setRequiredSecGroupId(existing.getRequiredSecGroupId()); keyUIncludeIdx.setRequiredIncludeGroupId(existing.getRequiredIncludeGroupId()); // Validate reverse foreign keys // Delete is valid SortedMap<CFSecuritySecGroupIncludePKey, CFSecuritySecGroupIncludeBuff> subdict; dictByPKey.remove(pkey); subdict = dictByClusterIdx.get(keyClusterIdx); subdict.remove(pkey); subdict = dictByGroupIdx.get(keyGroupIdx); subdict.remove(pkey); subdict = dictByIncludeIdx.get(keyIncludeIdx); subdict.remove(pkey); dictByUIncludeIdx.remove(keyUIncludeIdx); }
From source file:net.sourceforge.msscodefactory.cfsecurity.v2_0.CFSecurityRam.CFSecurityRamSecGroupMemberTable.java
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); }//from w ww . j a va 2s. com 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 SortedMap<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 TreeMap<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 TreeMap<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 TreeMap<CFSecuritySecGroupMemberPKey, CFSecuritySecGroupMemberBuff>(); dictByUserIdx.put(newKeyUserIdx, subdict); } subdict.put(pkey, Buff); dictByUUserIdx.remove(existingKeyUUserIdx); dictByUUserIdx.put(newKeyUUserIdx, Buff); }
From source file:net.sourceforge.msscodefactory.cfsecurity.v2_0.CFSecurityRam.CFSecurityRamSecGroupMemberTable.java
public void deleteSecGroupMember(CFSecurityAuthorization Authorization, CFSecuritySecGroupMemberBuff Buff) { final String S_ProcName = "CFSecurityRamSecGroupMemberTable.deleteSecGroupMember() "; CFSecuritySecGroupMemberPKey pkey = schema.getFactorySecGroupMember().newPKey(); pkey.setRequiredClusterId(Buff.getRequiredClusterId()); pkey.setRequiredSecGroupMemberId(Buff.getRequiredSecGroupMemberId()); CFSecuritySecGroupMemberBuff existing = dictByPKey.get(pkey); if (existing == null) { return;// w w w. java2s . com } 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 SortedMap<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); }
From source file:net.sourceforge.msscodefactory.cfsecurity.v2_0.CFSecurityRam.CFSecurityRamSecGroupTable.java
public void updateSecGroup(CFSecurityAuthorization Authorization, CFSecuritySecGroupBuff Buff) { CFSecuritySecGroupPKey pkey = schema.getFactorySecGroup().newPKey(); pkey.setRequiredClusterId(Buff.getRequiredClusterId()); pkey.setRequiredSecGroupId(Buff.getRequiredSecGroupId()); CFSecuritySecGroupBuff existing = dictByPKey.get(pkey); if (existing == null) { throw CFLib.getDefaultExceptionFactory().newStaleCacheDetectedException(getClass(), "updateSecGroup", "Existing record not found", "SecGroup", pkey); }//from ww w . ja va 2 s . c o m if (existing.getRequiredRevision() != Buff.getRequiredRevision()) { throw CFLib.getDefaultExceptionFactory().newCollisionDetectedException(getClass(), "updateSecGroup", pkey); } Buff.setRequiredRevision(Buff.getRequiredRevision() + 1); CFSecuritySecGroupByClusterIdxKey existingKeyClusterIdx = schema.getFactorySecGroup().newClusterIdxKey(); existingKeyClusterIdx.setRequiredClusterId(existing.getRequiredClusterId()); CFSecuritySecGroupByClusterIdxKey newKeyClusterIdx = schema.getFactorySecGroup().newClusterIdxKey(); newKeyClusterIdx.setRequiredClusterId(Buff.getRequiredClusterId()); CFSecuritySecGroupByUNameIdxKey existingKeyUNameIdx = schema.getFactorySecGroup().newUNameIdxKey(); existingKeyUNameIdx.setRequiredClusterId(existing.getRequiredClusterId()); existingKeyUNameIdx.setRequiredName(existing.getRequiredName()); CFSecuritySecGroupByUNameIdxKey newKeyUNameIdx = schema.getFactorySecGroup().newUNameIdxKey(); newKeyUNameIdx.setRequiredClusterId(Buff.getRequiredClusterId()); newKeyUNameIdx.setRequiredName(Buff.getRequiredName()); // Check unique indexes if (!existingKeyUNameIdx.equals(newKeyUNameIdx)) { if (dictByUNameIdx.containsKey(newKeyUNameIdx)) { throw CFLib.getDefaultExceptionFactory().newUniqueIndexViolationException(getClass(), "updateSecGroup", "SecGroupUNameIdx", newKeyUNameIdx); } } // Validate foreign keys { boolean allNull = true; if (allNull) { if (null == schema.getTableCluster().readDerivedByIdIdx(Authorization, Buff.getRequiredClusterId())) { throw CFLib.getDefaultExceptionFactory().newUnresolvedRelationException(getClass(), "updateSecGroup", "Container", "SecGroupCluster", "Cluster", null); } } } // Update is valid SortedMap<CFSecuritySecGroupPKey, CFSecuritySecGroupBuff> 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 TreeMap<CFSecuritySecGroupPKey, CFSecuritySecGroupBuff>(); dictByClusterIdx.put(newKeyClusterIdx, subdict); } subdict.put(pkey, Buff); dictByUNameIdx.remove(existingKeyUNameIdx); dictByUNameIdx.put(newKeyUNameIdx, Buff); }
From source file:net.sourceforge.msscodefactory.cfsecurity.v2_0.CFSecurityRam.CFSecurityRamSecGroupTable.java
public void deleteSecGroup(CFSecurityAuthorization Authorization, CFSecuritySecGroupBuff Buff) { final String S_ProcName = "CFSecurityRamSecGroupTable.deleteSecGroup() "; CFSecuritySecGroupPKey pkey = schema.getFactorySecGroup().newPKey(); pkey.setRequiredClusterId(Buff.getRequiredClusterId()); pkey.setRequiredSecGroupId(Buff.getRequiredSecGroupId()); CFSecuritySecGroupBuff existing = dictByPKey.get(pkey); if (existing == null) { return;//ww w. j a v a 2s. co m } if (existing.getRequiredRevision() != Buff.getRequiredRevision()) { throw CFLib.getDefaultExceptionFactory().newCollisionDetectedException(getClass(), "deleteSecGroup", pkey); } CFSecuritySecGroupByClusterIdxKey keyClusterIdx = schema.getFactorySecGroup().newClusterIdxKey(); keyClusterIdx.setRequiredClusterId(existing.getRequiredClusterId()); CFSecuritySecGroupByUNameIdxKey keyUNameIdx = schema.getFactorySecGroup().newUNameIdxKey(); keyUNameIdx.setRequiredClusterId(existing.getRequiredClusterId()); keyUNameIdx.setRequiredName(existing.getRequiredName()); // Validate reverse foreign keys // Delete is valid schema.getTableSecGroupInclude().deleteSecGroupIncludeByGroupIdx(Authorization, Buff.getRequiredClusterId(), Buff.getRequiredSecGroupId()); schema.getTableSecGroupMember().deleteSecGroupMemberByGroupIdx(Authorization, Buff.getRequiredClusterId(), Buff.getRequiredSecGroupId()); schema.getTableSecGroupInclude().deleteSecGroupIncludeByIncludeIdx(Authorization, Buff.getRequiredClusterId(), Buff.getRequiredSecGroupId()); schema.getTableSecGroupForm().deleteSecGroupFormByGroupIdx(Authorization, Buff.getRequiredClusterId(), Buff.getRequiredSecGroupId()); SortedMap<CFSecuritySecGroupPKey, CFSecuritySecGroupBuff> subdict; dictByPKey.remove(pkey); subdict = dictByClusterIdx.get(keyClusterIdx); subdict.remove(pkey); dictByUNameIdx.remove(keyUNameIdx); }
From source file:net.sourceforge.msscodefactory.cfsecurity.v2_0.CFSecurityRam.CFSecurityRamSecSessionTable.java
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); }/*from w ww . j a va 2s. co m*/ 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()); 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()); // 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 SortedMap<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 TreeMap<CFSecuritySecSessionPKey, CFSecuritySecSessionBuff>(); dictBySecUserIdx.put(newKeySecUserIdx, 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 TreeMap<CFSecuritySecSessionPKey, CFSecuritySecSessionBuff>(); dictByFinishIdx.put(newKeyFinishIdx, subdict); } subdict.put(pkey, Buff); }
From source file:net.sourceforge.msscodefactory.cfsecurity.v2_0.CFSecurityRam.CFSecurityRamSecSessionTable.java
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;/*from w w w .j a v a 2 s.c o m*/ } if (existing.getRequiredRevision() != Buff.getRequiredRevision()) { throw CFLib.getDefaultExceptionFactory().newCollisionDetectedException(getClass(), "deleteSecSession", pkey); } CFSecuritySecSessionBySecUserIdxKey keySecUserIdx = schema.getFactorySecSession().newSecUserIdxKey(); keySecUserIdx.setRequiredSecUserId(existing.getRequiredSecUserId()); 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()); // Validate reverse foreign keys // Delete is valid SortedMap<CFSecuritySecSessionPKey, CFSecuritySecSessionBuff> subdict; dictByPKey.remove(pkey); subdict = dictBySecUserIdx.get(keySecUserIdx); subdict.remove(pkey); dictByStartIdx.remove(keyStartIdx); subdict = dictByFinishIdx.get(keyFinishIdx); subdict.remove(pkey); }
From source file:net.sourceforge.msscodefactory.cfsecurity.v2_0.CFSecurityRam.CFSecurityRamServiceTable.java
public void updateService(CFSecurityAuthorization Authorization, CFSecurityServiceBuff Buff) { CFSecurityServicePKey pkey = schema.getFactoryService().newPKey(); pkey.setRequiredClusterId(Buff.getRequiredClusterId()); pkey.setRequiredServiceId(Buff.getRequiredServiceId()); CFSecurityServiceBuff existing = dictByPKey.get(pkey); if (existing == null) { throw CFLib.getDefaultExceptionFactory().newStaleCacheDetectedException(getClass(), "updateService", "Existing record not found", "Service", pkey); }// w w w . j av a2s . co m if (existing.getRequiredRevision() != Buff.getRequiredRevision()) { throw CFLib.getDefaultExceptionFactory().newCollisionDetectedException(getClass(), "updateService", pkey); } Buff.setRequiredRevision(Buff.getRequiredRevision() + 1); CFSecurityServiceByClusterIdxKey existingKeyClusterIdx = schema.getFactoryService().newClusterIdxKey(); existingKeyClusterIdx.setRequiredClusterId(existing.getRequiredClusterId()); CFSecurityServiceByClusterIdxKey newKeyClusterIdx = schema.getFactoryService().newClusterIdxKey(); newKeyClusterIdx.setRequiredClusterId(Buff.getRequiredClusterId()); CFSecurityServiceByHostIdxKey existingKeyHostIdx = schema.getFactoryService().newHostIdxKey(); existingKeyHostIdx.setRequiredClusterId(existing.getRequiredClusterId()); existingKeyHostIdx.setRequiredHostNodeId(existing.getRequiredHostNodeId()); CFSecurityServiceByHostIdxKey newKeyHostIdx = schema.getFactoryService().newHostIdxKey(); newKeyHostIdx.setRequiredClusterId(Buff.getRequiredClusterId()); newKeyHostIdx.setRequiredHostNodeId(Buff.getRequiredHostNodeId()); CFSecurityServiceByTypeIdxKey existingKeyTypeIdx = schema.getFactoryService().newTypeIdxKey(); existingKeyTypeIdx.setRequiredServiceTypeId(existing.getRequiredServiceTypeId()); CFSecurityServiceByTypeIdxKey newKeyTypeIdx = schema.getFactoryService().newTypeIdxKey(); newKeyTypeIdx.setRequiredServiceTypeId(Buff.getRequiredServiceTypeId()); CFSecurityServiceByUTypeIdxKey existingKeyUTypeIdx = schema.getFactoryService().newUTypeIdxKey(); existingKeyUTypeIdx.setRequiredClusterId(existing.getRequiredClusterId()); existingKeyUTypeIdx.setRequiredHostNodeId(existing.getRequiredHostNodeId()); existingKeyUTypeIdx.setRequiredServiceTypeId(existing.getRequiredServiceTypeId()); CFSecurityServiceByUTypeIdxKey newKeyUTypeIdx = schema.getFactoryService().newUTypeIdxKey(); newKeyUTypeIdx.setRequiredClusterId(Buff.getRequiredClusterId()); newKeyUTypeIdx.setRequiredHostNodeId(Buff.getRequiredHostNodeId()); newKeyUTypeIdx.setRequiredServiceTypeId(Buff.getRequiredServiceTypeId()); CFSecurityServiceByUHostPortIdxKey existingKeyUHostPortIdx = schema.getFactoryService() .newUHostPortIdxKey(); existingKeyUHostPortIdx.setRequiredClusterId(existing.getRequiredClusterId()); existingKeyUHostPortIdx.setRequiredHostNodeId(existing.getRequiredHostNodeId()); existingKeyUHostPortIdx.setRequiredHostPort(existing.getRequiredHostPort()); CFSecurityServiceByUHostPortIdxKey newKeyUHostPortIdx = schema.getFactoryService().newUHostPortIdxKey(); newKeyUHostPortIdx.setRequiredClusterId(Buff.getRequiredClusterId()); newKeyUHostPortIdx.setRequiredHostNodeId(Buff.getRequiredHostNodeId()); newKeyUHostPortIdx.setRequiredHostPort(Buff.getRequiredHostPort()); // Check unique indexes if (!existingKeyUTypeIdx.equals(newKeyUTypeIdx)) { if (dictByUTypeIdx.containsKey(newKeyUTypeIdx)) { throw CFLib.getDefaultExceptionFactory().newUniqueIndexViolationException(getClass(), "updateService", "ServiceUTypeIdx", newKeyUTypeIdx); } } if (!existingKeyUHostPortIdx.equals(newKeyUHostPortIdx)) { if (dictByUHostPortIdx.containsKey(newKeyUHostPortIdx)) { throw CFLib.getDefaultExceptionFactory().newUniqueIndexViolationException(getClass(), "updateService", "ServiceUHostPort", newKeyUHostPortIdx); } } // Validate foreign keys { boolean allNull = true; if (allNull) { if (null == schema.getTableCluster().readDerivedByIdIdx(Authorization, Buff.getRequiredClusterId())) { throw CFLib.getDefaultExceptionFactory().newUnresolvedRelationException(getClass(), "updateService", "Owner", "ServiceCluster", "Cluster", null); } } } // Update is valid SortedMap<CFSecurityServicePKey, CFSecurityServiceBuff> 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 TreeMap<CFSecurityServicePKey, CFSecurityServiceBuff>(); dictByClusterIdx.put(newKeyClusterIdx, subdict); } subdict.put(pkey, Buff); subdict = dictByHostIdx.get(existingKeyHostIdx); if (subdict != null) { subdict.remove(pkey); } if (dictByHostIdx.containsKey(newKeyHostIdx)) { subdict = dictByHostIdx.get(newKeyHostIdx); } else { subdict = new TreeMap<CFSecurityServicePKey, CFSecurityServiceBuff>(); dictByHostIdx.put(newKeyHostIdx, subdict); } subdict.put(pkey, Buff); subdict = dictByTypeIdx.get(existingKeyTypeIdx); if (subdict != null) { subdict.remove(pkey); } if (dictByTypeIdx.containsKey(newKeyTypeIdx)) { subdict = dictByTypeIdx.get(newKeyTypeIdx); } else { subdict = new TreeMap<CFSecurityServicePKey, CFSecurityServiceBuff>(); dictByTypeIdx.put(newKeyTypeIdx, subdict); } subdict.put(pkey, Buff); dictByUTypeIdx.remove(existingKeyUTypeIdx); dictByUTypeIdx.put(newKeyUTypeIdx, Buff); dictByUHostPortIdx.remove(existingKeyUHostPortIdx); dictByUHostPortIdx.put(newKeyUHostPortIdx, Buff); }
From source file:net.sourceforge.msscodefactory.cfsecurity.v2_0.CFSecurityRam.CFSecurityRamServiceTable.java
public void deleteService(CFSecurityAuthorization Authorization, CFSecurityServiceBuff Buff) { final String S_ProcName = "CFSecurityRamServiceTable.deleteService() "; CFSecurityServicePKey pkey = schema.getFactoryService().newPKey(); pkey.setRequiredClusterId(Buff.getRequiredClusterId()); pkey.setRequiredServiceId(Buff.getRequiredServiceId()); CFSecurityServiceBuff existing = dictByPKey.get(pkey); if (existing == null) { return;//from w w w .j a v a 2s . c o m } if (existing.getRequiredRevision() != Buff.getRequiredRevision()) { throw CFLib.getDefaultExceptionFactory().newCollisionDetectedException(getClass(), "deleteService", pkey); } CFSecurityServiceByClusterIdxKey keyClusterIdx = schema.getFactoryService().newClusterIdxKey(); keyClusterIdx.setRequiredClusterId(existing.getRequiredClusterId()); CFSecurityServiceByHostIdxKey keyHostIdx = schema.getFactoryService().newHostIdxKey(); keyHostIdx.setRequiredClusterId(existing.getRequiredClusterId()); keyHostIdx.setRequiredHostNodeId(existing.getRequiredHostNodeId()); CFSecurityServiceByTypeIdxKey keyTypeIdx = schema.getFactoryService().newTypeIdxKey(); keyTypeIdx.setRequiredServiceTypeId(existing.getRequiredServiceTypeId()); CFSecurityServiceByUTypeIdxKey keyUTypeIdx = schema.getFactoryService().newUTypeIdxKey(); keyUTypeIdx.setRequiredClusterId(existing.getRequiredClusterId()); keyUTypeIdx.setRequiredHostNodeId(existing.getRequiredHostNodeId()); keyUTypeIdx.setRequiredServiceTypeId(existing.getRequiredServiceTypeId()); CFSecurityServiceByUHostPortIdxKey keyUHostPortIdx = schema.getFactoryService().newUHostPortIdxKey(); keyUHostPortIdx.setRequiredClusterId(existing.getRequiredClusterId()); keyUHostPortIdx.setRequiredHostNodeId(existing.getRequiredHostNodeId()); keyUHostPortIdx.setRequiredHostPort(existing.getRequiredHostPort()); // Validate reverse foreign keys // Delete is valid SortedMap<CFSecurityServicePKey, CFSecurityServiceBuff> subdict; dictByPKey.remove(pkey); subdict = dictByClusterIdx.get(keyClusterIdx); subdict.remove(pkey); subdict = dictByHostIdx.get(keyHostIdx); subdict.remove(pkey); subdict = dictByTypeIdx.get(keyTypeIdx); subdict.remove(pkey); dictByUTypeIdx.remove(keyUTypeIdx); dictByUHostPortIdx.remove(keyUHostPortIdx); }
From source file:net.sourceforge.msscodefactory.cfsecurity.v2_0.CFSecurityRam.CFSecurityRamTenantTable.java
public void updateTenant(CFSecurityAuthorization Authorization, CFSecurityTenantBuff Buff) { CFSecurityTenantPKey pkey = schema.getFactoryTenant().newPKey(); pkey.setRequiredId(Buff.getRequiredId()); CFSecurityTenantBuff existing = dictByPKey.get(pkey); if (existing == null) { throw CFLib.getDefaultExceptionFactory().newStaleCacheDetectedException(getClass(), "updateTenant", "Existing record not found", "Tenant", pkey); }/* w w w . ja va2 s . c o m*/ if (existing.getRequiredRevision() != Buff.getRequiredRevision()) { throw CFLib.getDefaultExceptionFactory().newCollisionDetectedException(getClass(), "updateTenant", pkey); } Buff.setRequiredRevision(Buff.getRequiredRevision() + 1); CFSecurityTenantByClusterIdxKey existingKeyClusterIdx = schema.getFactoryTenant().newClusterIdxKey(); existingKeyClusterIdx.setRequiredClusterId(existing.getRequiredClusterId()); CFSecurityTenantByClusterIdxKey newKeyClusterIdx = schema.getFactoryTenant().newClusterIdxKey(); newKeyClusterIdx.setRequiredClusterId(Buff.getRequiredClusterId()); CFSecurityTenantByUNameIdxKey existingKeyUNameIdx = schema.getFactoryTenant().newUNameIdxKey(); existingKeyUNameIdx.setRequiredClusterId(existing.getRequiredClusterId()); existingKeyUNameIdx.setRequiredTenantName(existing.getRequiredTenantName()); CFSecurityTenantByUNameIdxKey newKeyUNameIdx = schema.getFactoryTenant().newUNameIdxKey(); newKeyUNameIdx.setRequiredClusterId(Buff.getRequiredClusterId()); newKeyUNameIdx.setRequiredTenantName(Buff.getRequiredTenantName()); // Check unique indexes if (!existingKeyUNameIdx.equals(newKeyUNameIdx)) { if (dictByUNameIdx.containsKey(newKeyUNameIdx)) { throw CFLib.getDefaultExceptionFactory().newUniqueIndexViolationException(getClass(), "updateTenant", "TenantUNameIdx", newKeyUNameIdx); } } // Validate foreign keys { boolean allNull = true; if (allNull) { if (null == schema.getTableCluster().readDerivedByIdIdx(Authorization, Buff.getRequiredClusterId())) { throw CFLib.getDefaultExceptionFactory().newUnresolvedRelationException(getClass(), "updateTenant", "Container", "TenantCluster", "Cluster", null); } } } // Update is valid SortedMap<CFSecurityTenantPKey, CFSecurityTenantBuff> 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 TreeMap<CFSecurityTenantPKey, CFSecurityTenantBuff>(); dictByClusterIdx.put(newKeyClusterIdx, subdict); } subdict.put(pkey, Buff); dictByUNameIdx.remove(existingKeyUNameIdx); dictByUNameIdx.put(newKeyUNameIdx, Buff); }