public void deleteSecFormBySecAppIdx(
     CFSecurityAuthorization Authorization, long argClusterId, int argSecAppId) {
   CFSecuritySecFormBySecAppIdxKey key = schema.getFactorySecForm().newSecAppIdxKey();
   key.setRequiredClusterId(argClusterId);
   key.setRequiredSecAppId(argSecAppId);
   deleteSecFormBySecAppIdx(Authorization, key);
 }
 public void deleteSecGroupFormByIdIdx(
     CFSecurityAuthorization Authorization, long argClusterId, long argSecGroupFormId) {
   CFSecuritySecGroupFormPKey key = schema.getFactorySecGroupForm().newPKey();
   key.setRequiredClusterId(argClusterId);
   key.setRequiredSecGroupFormId(argSecGroupFormId);
   deleteSecGroupFormByIdIdx(Authorization, key);
 }
  public CFSecuritySecGroupFormBuff[] readDerivedByFormIdx(
      CFSecurityAuthorization Authorization, long ClusterId, int SecFormId) {
    final String S_ProcName = "CFInternetRamSecGroupForm.readDerivedByFormIdx";
    CFSecuritySecGroupFormByFormIdxKey key = schema.getFactorySecGroupForm().newFormIdxKey();
    key.setRequiredClusterId(ClusterId);
    key.setRequiredSecFormId(SecFormId);

    CFSecuritySecGroupFormBuff[] recArray;
    if (dictByFormIdx.containsKey(key)) {
      Map<CFSecuritySecGroupFormPKey, CFSecuritySecGroupFormBuff> subdictFormIdx =
          dictByFormIdx.get(key);
      recArray = new CFSecuritySecGroupFormBuff[subdictFormIdx.size()];
      Iterator<CFSecuritySecGroupFormBuff> iter = subdictFormIdx.values().iterator();
      int idx = 0;
      while (iter.hasNext()) {
        recArray[idx++] = iter.next();
      }
    } else {
      Map<CFSecuritySecGroupFormPKey, CFSecuritySecGroupFormBuff> subdictFormIdx =
          new HashMap<CFSecuritySecGroupFormPKey, CFSecuritySecGroupFormBuff>();
      dictByFormIdx.put(key, subdictFormIdx);
      recArray = new CFSecuritySecGroupFormBuff[0];
    }
    return (recArray);
  }
  public void createISOLanguage(
      CFSecurityAuthorization Authorization, CFSecurityISOLanguageBuff Buff) {
    final String S_ProcName = "createISOLanguage";
    CFSecurityISOLanguagePKey pkey = schema.getFactoryISOLanguage().newPKey();
    pkey.setRequiredISOLanguageId(schema.nextISOLanguageIdGen());
    Buff.setRequiredISOLanguageId(pkey.getRequiredISOLanguageId());
    CFSecurityISOLanguageByCode3IdxKey keyCode3Idx =
        schema.getFactoryISOLanguage().newCode3IdxKey();
    keyCode3Idx.setRequiredISO6392Code(Buff.getRequiredISO6392Code());

    CFSecurityISOLanguageByCode2IdxKey keyCode2Idx =
        schema.getFactoryISOLanguage().newCode2IdxKey();
    keyCode2Idx.setOptionalISO6391Code(Buff.getOptionalISO6391Code());

    // Validate unique indexes

    if (dictByPKey.containsKey(pkey)) {
      throw CFLib.getDefaultExceptionFactory()
          .newPrimaryKeyNotNewException(getClass(), S_ProcName, pkey);
    }

    if (dictByCode3Idx.containsKey(keyCode3Idx)) {
      throw CFLib.getDefaultExceptionFactory()
          .newUniqueIndexViolationException(
              getClass(), S_ProcName, "ISOLanguage6392Idx", keyCode3Idx);
    }

    // Validate foreign keys

    // Proceed with adding the new record

    dictByPKey.put(pkey, Buff);

    dictByCode3Idx.put(keyCode3Idx, Buff);

    Map<CFSecurityISOLanguagePKey, CFSecurityISOLanguageBuff> subdictCode2Idx;
    if (dictByCode2Idx.containsKey(keyCode2Idx)) {
      subdictCode2Idx = dictByCode2Idx.get(keyCode2Idx);
    } else {
      subdictCode2Idx = new HashMap<CFSecurityISOLanguagePKey, CFSecurityISOLanguageBuff>();
      dictByCode2Idx.put(keyCode2Idx, subdictCode2Idx);
    }
    subdictCode2Idx.put(pkey, Buff);
  }
  public void deleteSecForm(CFSecurityAuthorization Authorization, CFSecuritySecFormBuff Buff) {
    final String S_ProcName = "CFInternetRamSecFormTable.deleteSecForm() ";
    CFSecuritySecFormPKey pkey = schema.getFactorySecForm().newPKey();
    pkey.setRequiredClusterId(Buff.getRequiredClusterId());
    pkey.setRequiredSecFormId(Buff.getRequiredSecFormId());
    CFSecuritySecFormBuff existing = dictByPKey.get(pkey);
    if (existing == null) {
      return;
    }
    if (existing.getRequiredRevision() != Buff.getRequiredRevision()) {
      throw CFLib.getDefaultExceptionFactory()
          .newCollisionDetectedException(getClass(), "deleteSecForm", pkey);
    }
    CFSecuritySecFormByClusterIdxKey keyClusterIdx = schema.getFactorySecForm().newClusterIdxKey();
    keyClusterIdx.setRequiredClusterId(existing.getRequiredClusterId());

    CFSecuritySecFormBySecAppIdxKey keySecAppIdx = schema.getFactorySecForm().newSecAppIdxKey();
    keySecAppIdx.setRequiredClusterId(existing.getRequiredClusterId());
    keySecAppIdx.setRequiredSecAppId(existing.getRequiredSecAppId());

    CFSecuritySecFormByUJEEServletIdxKey keyUJEEServletIdx =
        schema.getFactorySecForm().newUJEEServletIdxKey();
    keyUJEEServletIdx.setRequiredClusterId(existing.getRequiredClusterId());
    keyUJEEServletIdx.setRequiredSecAppId(existing.getRequiredSecAppId());
    keyUJEEServletIdx.setRequiredJEEServletMapName(existing.getRequiredJEEServletMapName());

    // Validate reverse foreign keys

    // Delete is valid

    Map<CFSecuritySecFormPKey, CFSecuritySecFormBuff> subdict;

    dictByPKey.remove(pkey);

    subdict = dictByClusterIdx.get(keyClusterIdx);
    subdict.remove(pkey);

    subdict = dictBySecAppIdx.get(keySecAppIdx);
    subdict.remove(pkey);

    dictByUJEEServletIdx.remove(keyUJEEServletIdx);
  }
 public void deleteSecFormByUJEEServletIdx(
     CFSecurityAuthorization Authorization,
     long argClusterId,
     int argSecAppId,
     String argJEEServletMapName) {
   CFSecuritySecFormByUJEEServletIdxKey key = schema.getFactorySecForm().newUJEEServletIdxKey();
   key.setRequiredClusterId(argClusterId);
   key.setRequiredSecAppId(argSecAppId);
   key.setRequiredJEEServletMapName(argJEEServletMapName);
   deleteSecFormByUJEEServletIdx(Authorization, key);
 }
 public CFSecurityISOLanguageBuff lockDerived(
     CFSecurityAuthorization Authorization, CFSecurityISOLanguagePKey PKey) {
   final String S_ProcName = "CFInternetRamISOLanguage.readDerived";
   CFSecurityISOLanguagePKey key = schema.getFactoryISOLanguage().newPKey();
   key.setRequiredISOLanguageId(PKey.getRequiredISOLanguageId());
   CFSecurityISOLanguageBuff buff;
   if (dictByPKey.containsKey(key)) {
     buff = dictByPKey.get(key);
   } else {
     buff = null;
   }
   return (buff);
 }
  public CFSecurityISOLanguageBuff readDerivedByCode3Idx(
      CFSecurityAuthorization Authorization, String ISO6392Code) {
    final String S_ProcName = "CFInternetRamISOLanguage.readDerivedByCode3Idx";
    CFSecurityISOLanguageByCode3IdxKey key = schema.getFactoryISOLanguage().newCode3IdxKey();
    key.setRequiredISO6392Code(ISO6392Code);

    CFSecurityISOLanguageBuff buff;
    if (dictByCode3Idx.containsKey(key)) {
      buff = dictByCode3Idx.get(key);
    } else {
      buff = null;
    }
    return (buff);
  }
 public CFSecuritySecFormBuff lockDerived(
     CFSecurityAuthorization Authorization, CFSecuritySecFormPKey PKey) {
   final String S_ProcName = "CFInternetRamSecForm.readDerived";
   CFSecuritySecFormPKey key = schema.getFactorySecForm().newPKey();
   key.setRequiredClusterId(PKey.getRequiredClusterId());
   key.setRequiredSecFormId(PKey.getRequiredSecFormId());
   CFSecuritySecFormBuff buff;
   if (dictByPKey.containsKey(key)) {
     buff = dictByPKey.get(key);
   } else {
     buff = null;
   }
   return (buff);
 }
  public void deleteISOLanguage(
      CFSecurityAuthorization Authorization, CFSecurityISOLanguageBuff Buff) {
    final String S_ProcName = "CFInternetRamISOLanguageTable.deleteISOLanguage() ";
    CFSecurityISOLanguagePKey pkey = schema.getFactoryISOLanguage().newPKey();
    pkey.setRequiredISOLanguageId(Buff.getRequiredISOLanguageId());
    CFSecurityISOLanguageBuff existing = dictByPKey.get(pkey);
    if (existing == null) {
      return;
    }
    if (existing.getRequiredRevision() != Buff.getRequiredRevision()) {
      throw CFLib.getDefaultExceptionFactory()
          .newCollisionDetectedException(getClass(), "deleteISOLanguage", pkey);
    }
    CFSecurityISOLanguageByCode3IdxKey keyCode3Idx =
        schema.getFactoryISOLanguage().newCode3IdxKey();
    keyCode3Idx.setRequiredISO6392Code(existing.getRequiredISO6392Code());

    CFSecurityISOLanguageByCode2IdxKey keyCode2Idx =
        schema.getFactoryISOLanguage().newCode2IdxKey();
    keyCode2Idx.setOptionalISO6391Code(existing.getOptionalISO6391Code());

    // Validate reverse foreign keys

    // Delete is valid

    schema
        .getTableISOCountryLanguage()
        .deleteISOCountryLanguageByLanguageIdx(Authorization, Buff.getRequiredISOLanguageId());
    Map<CFSecurityISOLanguagePKey, CFSecurityISOLanguageBuff> subdict;

    dictByPKey.remove(pkey);

    dictByCode3Idx.remove(keyCode3Idx);

    subdict = dictByCode2Idx.get(keyCode2Idx);
    subdict.remove(pkey);
  }
  public CFSecuritySecGroupFormBuff readDerivedByIdIdx(
      CFSecurityAuthorization Authorization, long ClusterId, long SecGroupFormId) {
    final String S_ProcName = "CFInternetRamSecGroupForm.readDerivedByIdIdx() ";
    CFSecuritySecGroupFormPKey key = schema.getFactorySecGroupForm().newPKey();
    key.setRequiredClusterId(ClusterId);
    key.setRequiredSecGroupFormId(SecGroupFormId);

    CFSecuritySecGroupFormBuff buff;
    if (dictByPKey.containsKey(key)) {
      buff = dictByPKey.get(key);
    } else {
      buff = null;
    }
    return (buff);
  }
  public CFSecurityCursor openSecFormCursorBySecAppIdx(
      CFSecurityAuthorization Authorization, long ClusterId, int SecAppId) {
    CFSecurityCursor cursor;
    CFSecuritySecFormBySecAppIdxKey key = schema.getFactorySecForm().newSecAppIdxKey();
    key.setRequiredClusterId(ClusterId);
    key.setRequiredSecAppId(SecAppId);

    if (dictBySecAppIdx.containsKey(key)) {
      Map<CFSecuritySecFormPKey, CFSecuritySecFormBuff> subdictSecAppIdx = dictBySecAppIdx.get(key);
      cursor = new CFInternetRamSecFormCursor(Authorization, schema, subdictSecAppIdx.values());
    } else {
      cursor =
          new CFInternetRamSecFormCursor(
              Authorization, schema, new ArrayList<CFSecuritySecFormBuff>());
    }
    return (cursor);
  }
  public CFSecurityCursor openISOLanguageCursorByCode2Idx(
      CFSecurityAuthorization Authorization, String ISO6391Code) {
    CFSecurityCursor cursor;
    CFSecurityISOLanguageByCode2IdxKey key = schema.getFactoryISOLanguage().newCode2IdxKey();
    key.setOptionalISO6391Code(ISO6391Code);

    if (dictByCode2Idx.containsKey(key)) {
      Map<CFSecurityISOLanguagePKey, CFSecurityISOLanguageBuff> subdictCode2Idx =
          dictByCode2Idx.get(key);
      cursor = new CFInternetRamISOLanguageCursor(Authorization, schema, subdictCode2Idx.values());
    } else {
      cursor =
          new CFInternetRamISOLanguageCursor(
              Authorization, schema, new ArrayList<CFSecurityISOLanguageBuff>());
    }
    return (cursor);
  }
  public CFSecuritySecFormBuff readDerivedByUJEEServletIdx(
      CFSecurityAuthorization Authorization,
      long ClusterId,
      int SecAppId,
      String JEEServletMapName) {
    final String S_ProcName = "CFInternetRamSecForm.readDerivedByUJEEServletIdx";
    CFSecuritySecFormByUJEEServletIdxKey key = schema.getFactorySecForm().newUJEEServletIdxKey();
    key.setRequiredClusterId(ClusterId);
    key.setRequiredSecAppId(SecAppId);
    key.setRequiredJEEServletMapName(JEEServletMapName);

    CFSecuritySecFormBuff buff;
    if (dictByUJEEServletIdx.containsKey(key)) {
      buff = dictByUJEEServletIdx.get(key);
    } else {
      buff = null;
    }
    return (buff);
  }
  public CFSecurityISOLanguageBuff[] readDerivedByCode2Idx(
      CFSecurityAuthorization Authorization, String ISO6391Code) {
    final String S_ProcName = "CFInternetRamISOLanguage.readDerivedByCode2Idx";
    CFSecurityISOLanguageByCode2IdxKey key = schema.getFactoryISOLanguage().newCode2IdxKey();
    key.setOptionalISO6391Code(ISO6391Code);

    CFSecurityISOLanguageBuff[] recArray;
    if (dictByCode2Idx.containsKey(key)) {
      Map<CFSecurityISOLanguagePKey, CFSecurityISOLanguageBuff> subdictCode2Idx =
          dictByCode2Idx.get(key);
      recArray = new CFSecurityISOLanguageBuff[subdictCode2Idx.size()];
      Iterator<CFSecurityISOLanguageBuff> iter = subdictCode2Idx.values().iterator();
      int idx = 0;
      while (iter.hasNext()) {
        recArray[idx++] = iter.next();
      }
    } else {
      Map<CFSecurityISOLanguagePKey, CFSecurityISOLanguageBuff> subdictCode2Idx =
          new HashMap<CFSecurityISOLanguagePKey, CFSecurityISOLanguageBuff>();
      dictByCode2Idx.put(key, subdictCode2Idx);
      recArray = new CFSecurityISOLanguageBuff[0];
    }
    return (recArray);
  }
 public void deleteISOLanguageByCode2Idx(
     CFSecurityAuthorization Authorization, String argISO6391Code) {
   CFSecurityISOLanguageByCode2IdxKey key = schema.getFactoryISOLanguage().newCode2IdxKey();
   key.setOptionalISO6391Code(argISO6391Code);
   deleteISOLanguageByCode2Idx(Authorization, key);
 }
 public void deleteISOLanguageByIdIdx(
     CFSecurityAuthorization Authorization, short argISOLanguageId) {
   CFSecurityISOLanguagePKey key = schema.getFactoryISOLanguage().newPKey();
   key.setRequiredISOLanguageId(argISOLanguageId);
   deleteISOLanguageByIdIdx(Authorization, key);
 }
  public void updateISOLanguage(
      CFSecurityAuthorization Authorization, CFSecurityISOLanguageBuff Buff) {
    CFSecurityISOLanguagePKey pkey = schema.getFactoryISOLanguage().newPKey();
    pkey.setRequiredISOLanguageId(Buff.getRequiredISOLanguageId());
    CFSecurityISOLanguageBuff existing = dictByPKey.get(pkey);
    if (existing == null) {
      throw CFLib.getDefaultExceptionFactory()
          .newStaleCacheDetectedException(
              getClass(), "updateISOLanguage", "Existing record not found", "ISOLanguage", pkey);
    }
    if (existing.getRequiredRevision() != Buff.getRequiredRevision()) {
      throw CFLib.getDefaultExceptionFactory()
          .newCollisionDetectedException(getClass(), "updateISOLanguage", pkey);
    }
    Buff.setRequiredRevision(Buff.getRequiredRevision() + 1);
    CFSecurityISOLanguageByCode3IdxKey existingKeyCode3Idx =
        schema.getFactoryISOLanguage().newCode3IdxKey();
    existingKeyCode3Idx.setRequiredISO6392Code(existing.getRequiredISO6392Code());

    CFSecurityISOLanguageByCode3IdxKey newKeyCode3Idx =
        schema.getFactoryISOLanguage().newCode3IdxKey();
    newKeyCode3Idx.setRequiredISO6392Code(Buff.getRequiredISO6392Code());

    CFSecurityISOLanguageByCode2IdxKey existingKeyCode2Idx =
        schema.getFactoryISOLanguage().newCode2IdxKey();
    existingKeyCode2Idx.setOptionalISO6391Code(existing.getOptionalISO6391Code());

    CFSecurityISOLanguageByCode2IdxKey newKeyCode2Idx =
        schema.getFactoryISOLanguage().newCode2IdxKey();
    newKeyCode2Idx.setOptionalISO6391Code(Buff.getOptionalISO6391Code());

    // Check unique indexes

    if (!existingKeyCode3Idx.equals(newKeyCode3Idx)) {
      if (dictByCode3Idx.containsKey(newKeyCode3Idx)) {
        throw CFLib.getDefaultExceptionFactory()
            .newUniqueIndexViolationException(
                getClass(), "updateISOLanguage", "ISOLanguage6392Idx", newKeyCode3Idx);
      }
    }

    // Validate foreign keys

    // Update is valid

    Map<CFSecurityISOLanguagePKey, CFSecurityISOLanguageBuff> subdict;

    dictByPKey.remove(pkey);
    dictByPKey.put(pkey, Buff);

    dictByCode3Idx.remove(existingKeyCode3Idx);
    dictByCode3Idx.put(newKeyCode3Idx, Buff);

    subdict = dictByCode2Idx.get(existingKeyCode2Idx);
    if (subdict != null) {
      subdict.remove(pkey);
    }
    if (dictByCode2Idx.containsKey(newKeyCode2Idx)) {
      subdict = dictByCode2Idx.get(newKeyCode2Idx);
    } else {
      subdict = new HashMap<CFSecurityISOLanguagePKey, CFSecurityISOLanguageBuff>();
      dictByCode2Idx.put(newKeyCode2Idx, subdict);
    }
    subdict.put(pkey, Buff);
  }
  public void createSecForm(CFSecurityAuthorization Authorization, CFSecuritySecFormBuff Buff) {
    final String S_ProcName = "createSecForm";
    CFSecuritySecFormPKey pkey = schema.getFactorySecForm().newPKey();
    pkey.setRequiredClusterId(Buff.getRequiredClusterId());
    pkey.setRequiredSecFormId(
        ((CFInternetRamClusterTable) schema.getTableCluster())
            .nextSecFormIdGen(Authorization, Buff.getRequiredClusterId()));
    Buff.setRequiredClusterId(pkey.getRequiredClusterId());
    Buff.setRequiredSecFormId(pkey.getRequiredSecFormId());
    CFSecuritySecFormByClusterIdxKey keyClusterIdx = schema.getFactorySecForm().newClusterIdxKey();
    keyClusterIdx.setRequiredClusterId(Buff.getRequiredClusterId());

    CFSecuritySecFormBySecAppIdxKey keySecAppIdx = schema.getFactorySecForm().newSecAppIdxKey();
    keySecAppIdx.setRequiredClusterId(Buff.getRequiredClusterId());
    keySecAppIdx.setRequiredSecAppId(Buff.getRequiredSecAppId());

    CFSecuritySecFormByUJEEServletIdxKey keyUJEEServletIdx =
        schema.getFactorySecForm().newUJEEServletIdxKey();
    keyUJEEServletIdx.setRequiredClusterId(Buff.getRequiredClusterId());
    keyUJEEServletIdx.setRequiredSecAppId(Buff.getRequiredSecAppId());
    keyUJEEServletIdx.setRequiredJEEServletMapName(Buff.getRequiredJEEServletMapName());

    // Validate unique indexes

    if (dictByPKey.containsKey(pkey)) {
      throw CFLib.getDefaultExceptionFactory()
          .newPrimaryKeyNotNewException(getClass(), S_ProcName, pkey);
    }

    if (dictByUJEEServletIdx.containsKey(keyUJEEServletIdx)) {
      throw CFLib.getDefaultExceptionFactory()
          .newUniqueIndexViolationException(
              getClass(), S_ProcName, "SecFormUJEEServletIdx", keyUJEEServletIdx);
    }

    // Validate foreign keys

    {
      boolean allNull = true;
      allNull = false;
      if (!allNull) {
        if (null
            == schema
                .getTableCluster()
                .readDerivedByIdIdx(Authorization, Buff.getRequiredClusterId())) {
          throw CFLib.getDefaultExceptionFactory()
              .newUnresolvedRelationException(
                  getClass(), S_ProcName, "Owner", "SecFormCluster", "Cluster", null);
        }
      }
    }

    {
      boolean allNull = true;
      allNull = false;
      allNull = false;
      if (!allNull) {
        if (null
            == schema
                .getTableSecApp()
                .readDerivedByIdIdx(
                    Authorization, Buff.getRequiredClusterId(), Buff.getRequiredSecAppId())) {
          throw CFLib.getDefaultExceptionFactory()
              .newUnresolvedRelationException(
                  getClass(), S_ProcName, "Container", "SecFormApplication", "SecApp", null);
        }
      }
    }

    // Proceed with adding the new record

    dictByPKey.put(pkey, Buff);

    Map<CFSecuritySecFormPKey, CFSecuritySecFormBuff> subdictClusterIdx;
    if (dictByClusterIdx.containsKey(keyClusterIdx)) {
      subdictClusterIdx = dictByClusterIdx.get(keyClusterIdx);
    } else {
      subdictClusterIdx = new HashMap<CFSecuritySecFormPKey, CFSecuritySecFormBuff>();
      dictByClusterIdx.put(keyClusterIdx, subdictClusterIdx);
    }
    subdictClusterIdx.put(pkey, Buff);

    Map<CFSecuritySecFormPKey, CFSecuritySecFormBuff> subdictSecAppIdx;
    if (dictBySecAppIdx.containsKey(keySecAppIdx)) {
      subdictSecAppIdx = dictBySecAppIdx.get(keySecAppIdx);
    } else {
      subdictSecAppIdx = new HashMap<CFSecuritySecFormPKey, CFSecuritySecFormBuff>();
      dictBySecAppIdx.put(keySecAppIdx, subdictSecAppIdx);
    }
    subdictSecAppIdx.put(pkey, Buff);

    dictByUJEEServletIdx.put(keyUJEEServletIdx, Buff);
  }
  public void updateSecForm(CFSecurityAuthorization Authorization, CFSecuritySecFormBuff Buff) {
    CFSecuritySecFormPKey pkey = schema.getFactorySecForm().newPKey();
    pkey.setRequiredClusterId(Buff.getRequiredClusterId());
    pkey.setRequiredSecFormId(Buff.getRequiredSecFormId());
    CFSecuritySecFormBuff existing = dictByPKey.get(pkey);
    if (existing == null) {
      throw CFLib.getDefaultExceptionFactory()
          .newStaleCacheDetectedException(
              getClass(), "updateSecForm", "Existing record not found", "SecForm", pkey);
    }
    if (existing.getRequiredRevision() != Buff.getRequiredRevision()) {
      throw CFLib.getDefaultExceptionFactory()
          .newCollisionDetectedException(getClass(), "updateSecForm", pkey);
    }
    Buff.setRequiredRevision(Buff.getRequiredRevision() + 1);
    CFSecuritySecFormByClusterIdxKey existingKeyClusterIdx =
        schema.getFactorySecForm().newClusterIdxKey();
    existingKeyClusterIdx.setRequiredClusterId(existing.getRequiredClusterId());

    CFSecuritySecFormByClusterIdxKey newKeyClusterIdx =
        schema.getFactorySecForm().newClusterIdxKey();
    newKeyClusterIdx.setRequiredClusterId(Buff.getRequiredClusterId());

    CFSecuritySecFormBySecAppIdxKey existingKeySecAppIdx =
        schema.getFactorySecForm().newSecAppIdxKey();
    existingKeySecAppIdx.setRequiredClusterId(existing.getRequiredClusterId());
    existingKeySecAppIdx.setRequiredSecAppId(existing.getRequiredSecAppId());

    CFSecuritySecFormBySecAppIdxKey newKeySecAppIdx = schema.getFactorySecForm().newSecAppIdxKey();
    newKeySecAppIdx.setRequiredClusterId(Buff.getRequiredClusterId());
    newKeySecAppIdx.setRequiredSecAppId(Buff.getRequiredSecAppId());

    CFSecuritySecFormByUJEEServletIdxKey existingKeyUJEEServletIdx =
        schema.getFactorySecForm().newUJEEServletIdxKey();
    existingKeyUJEEServletIdx.setRequiredClusterId(existing.getRequiredClusterId());
    existingKeyUJEEServletIdx.setRequiredSecAppId(existing.getRequiredSecAppId());
    existingKeyUJEEServletIdx.setRequiredJEEServletMapName(existing.getRequiredJEEServletMapName());

    CFSecuritySecFormByUJEEServletIdxKey newKeyUJEEServletIdx =
        schema.getFactorySecForm().newUJEEServletIdxKey();
    newKeyUJEEServletIdx.setRequiredClusterId(Buff.getRequiredClusterId());
    newKeyUJEEServletIdx.setRequiredSecAppId(Buff.getRequiredSecAppId());
    newKeyUJEEServletIdx.setRequiredJEEServletMapName(Buff.getRequiredJEEServletMapName());

    // Check unique indexes

    if (!existingKeyUJEEServletIdx.equals(newKeyUJEEServletIdx)) {
      if (dictByUJEEServletIdx.containsKey(newKeyUJEEServletIdx)) {
        throw CFLib.getDefaultExceptionFactory()
            .newUniqueIndexViolationException(
                getClass(), "updateSecForm", "SecFormUJEEServletIdx", newKeyUJEEServletIdx);
      }
    }

    // Validate foreign keys

    {
      boolean allNull = true;

      if (allNull) {
        if (null
            == schema
                .getTableCluster()
                .readDerivedByIdIdx(Authorization, Buff.getRequiredClusterId())) {
          throw CFLib.getDefaultExceptionFactory()
              .newUnresolvedRelationException(
                  getClass(), "updateSecForm", "Owner", "SecFormCluster", "Cluster", null);
        }
      }
    }

    {
      boolean allNull = true;

      if (allNull) {
        if (null
            == schema
                .getTableSecApp()
                .readDerivedByIdIdx(
                    Authorization, Buff.getRequiredClusterId(), Buff.getRequiredSecAppId())) {
          throw CFLib.getDefaultExceptionFactory()
              .newUnresolvedRelationException(
                  getClass(), "updateSecForm", "Container", "SecFormApplication", "SecApp", null);
        }
      }
    }

    // Update is valid

    Map<CFSecuritySecFormPKey, CFSecuritySecFormBuff> 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<CFSecuritySecFormPKey, CFSecuritySecFormBuff>();
      dictByClusterIdx.put(newKeyClusterIdx, subdict);
    }
    subdict.put(pkey, Buff);

    subdict = dictBySecAppIdx.get(existingKeySecAppIdx);
    if (subdict != null) {
      subdict.remove(pkey);
    }
    if (dictBySecAppIdx.containsKey(newKeySecAppIdx)) {
      subdict = dictBySecAppIdx.get(newKeySecAppIdx);
    } else {
      subdict = new HashMap<CFSecuritySecFormPKey, CFSecuritySecFormBuff>();
      dictBySecAppIdx.put(newKeySecAppIdx, subdict);
    }
    subdict.put(pkey, Buff);

    dictByUJEEServletIdx.remove(existingKeyUJEEServletIdx);
    dictByUJEEServletIdx.put(newKeyUJEEServletIdx, Buff);
  }