public void deleteCluster(CFSecurityAuthorization Authorization, CFSecurityClusterBuff Buff) { final String S_ProcName = "CFDbTestRamClusterTable.deleteCluster() "; CFSecurityClusterPKey pkey = schema.getFactoryCluster().newPKey(); pkey.setRequiredId(Buff.getRequiredId()); CFSecurityClusterBuff existing = dictByPKey.get(pkey); if (existing == null) { return; } if (existing.getRequiredRevision() != Buff.getRequiredRevision()) { throw CFLib.getDefaultExceptionFactory() .newCollisionDetectedException(getClass(), "deleteCluster", pkey); } CFSecurityClusterByUDomainNameIdxKey keyUDomainNameIdx = schema.getFactoryCluster().newUDomainNameIdxKey(); keyUDomainNameIdx.setRequiredFullDomainName(existing.getRequiredFullDomainName()); CFSecurityClusterByUDescrIdxKey keyUDescrIdx = schema.getFactoryCluster().newUDescrIdxKey(); keyUDescrIdx.setRequiredDescription(existing.getRequiredDescription()); // Validate reverse foreign keys // Delete is valid schema.getTableHostNode().deleteHostNodeByClusterIdx(Authorization, Buff.getRequiredId()); schema.getTableTenant().deleteTenantByClusterIdx(Authorization, Buff.getRequiredId()); schema.getTableSecApp().deleteSecAppByClusterIdx(Authorization, Buff.getRequiredId()); schema.getTableSecGroup().deleteSecGroupByClusterIdx(Authorization, Buff.getRequiredId()); schema.getTableSysCluster().deleteSysClusterByClusterIdx(Authorization, Buff.getRequiredId()); Map<CFSecurityClusterPKey, CFSecurityClusterBuff> subdict; dictByPKey.remove(pkey); dictByUDomainNameIdx.remove(keyUDomainNameIdx); dictByUDescrIdx.remove(keyUDescrIdx); }
public void updateCluster(CFSecurityAuthorization Authorization, CFSecurityClusterBuff Buff) { CFSecurityClusterPKey pkey = schema.getFactoryCluster().newPKey(); pkey.setRequiredId(Buff.getRequiredId()); CFSecurityClusterBuff existing = dictByPKey.get(pkey); if (existing == null) { throw CFLib.getDefaultExceptionFactory() .newStaleCacheDetectedException( getClass(), "updateCluster", "Existing record not found", "Cluster", pkey); } if (existing.getRequiredRevision() != Buff.getRequiredRevision()) { throw CFLib.getDefaultExceptionFactory() .newCollisionDetectedException(getClass(), "updateCluster", pkey); } Buff.setRequiredRevision(Buff.getRequiredRevision() + 1); CFSecurityClusterByUDomainNameIdxKey existingKeyUDomainNameIdx = schema.getFactoryCluster().newUDomainNameIdxKey(); existingKeyUDomainNameIdx.setRequiredFullDomainName(existing.getRequiredFullDomainName()); CFSecurityClusterByUDomainNameIdxKey newKeyUDomainNameIdx = schema.getFactoryCluster().newUDomainNameIdxKey(); newKeyUDomainNameIdx.setRequiredFullDomainName(Buff.getRequiredFullDomainName()); CFSecurityClusterByUDescrIdxKey existingKeyUDescrIdx = schema.getFactoryCluster().newUDescrIdxKey(); existingKeyUDescrIdx.setRequiredDescription(existing.getRequiredDescription()); CFSecurityClusterByUDescrIdxKey newKeyUDescrIdx = schema.getFactoryCluster().newUDescrIdxKey(); newKeyUDescrIdx.setRequiredDescription(Buff.getRequiredDescription()); // Check unique indexes if (!existingKeyUDomainNameIdx.equals(newKeyUDomainNameIdx)) { if (dictByUDomainNameIdx.containsKey(newKeyUDomainNameIdx)) { throw CFLib.getDefaultExceptionFactory() .newUniqueIndexViolationException( getClass(), "updateCluster", "ClusterUDomainNameIdx", newKeyUDomainNameIdx); } } if (!existingKeyUDescrIdx.equals(newKeyUDescrIdx)) { if (dictByUDescrIdx.containsKey(newKeyUDescrIdx)) { throw CFLib.getDefaultExceptionFactory() .newUniqueIndexViolationException( getClass(), "updateCluster", "ClusterUDescrNameIdx", newKeyUDescrIdx); } } // Validate foreign keys // Update is valid Map<CFSecurityClusterPKey, CFSecurityClusterBuff> subdict; dictByPKey.remove(pkey); dictByPKey.put(pkey, Buff); dictByUDomainNameIdx.remove(existingKeyUDomainNameIdx); dictByUDomainNameIdx.put(newKeyUDomainNameIdx, Buff); dictByUDescrIdx.remove(existingKeyUDescrIdx); dictByUDescrIdx.put(newKeyUDescrIdx, Buff); }