public void chose(ICFLibAnyObj value) {
   final String S_ProcName = "chose";
   Node cont;
   ICFAsteriskSchemaObj schemaObj = (ICFAsteriskSchemaObj) javafxSchema.getSchema();
   ICFAsteriskExtensionsConfObj focus = getJavaFXFocusAsExtensionsConf();
   ICFAsteriskExtensionsConfEditObj editObj = (ICFAsteriskExtensionsConfEditObj) focus.getEdit();
   if (editObj != null) {
     focus = editObj;
   }
   ICFSecurityHostNodeObj referencedObj =
       (ICFSecurityHostNodeObj) javafxReferenceParentHostNode.getReferencedObject();
   java.util.List<ICFSecurityHostNodeObj> listOfHostNode = null;
   CFSecurityAuthorization auth = schemaObj.getAuthorization();
   long containingClusterId = auth.getSecClusterId();
   listOfHostNode =
       schemaObj.getHostNodeTableObj().readHostNodeByClusterIdx(containingClusterId);
   if (listOfHostNode == null) {
     throw CFLib.getDefaultExceptionFactory()
         .newNullArgumentException(getClass(), S_ProcName, 0, "listOfHostNode");
   }
   Collection<ICFSecurityHostNodeObj> cltn = listOfHostNode;
   CFBorderPane form =
       javafxSchema
           .getHostNodeFactory()
           .newPickerForm(
               cfFormManager, referencedObj, null, cltn, new CallbackHostNodeChosen());
   ((ICFSecurityJavaFXHostNodePaneCommon) form).setPaneMode(CFPane.PaneMode.View);
   cfFormManager.pushForm(form);
 }
 public void deleteTenantByUNameIdx(
     CFSecurityAuthorization Authorization, long ClusterId, String TenantName) {
   final String S_ProcName = "deleteTenantByUNameIdx";
   if (!schema.isTransactionOpen()) {
     throw CFLib.getDefaultExceptionFactory()
         .newUsageException(getClass(), S_ProcName, "Transaction not open");
   }
   ResultSet resultSet = null;
   try {
     Connection cnx = schema.getCnx();
     String sql = "exec sp_delete_tenant_by_unameidx ?, ?, ?, ?, ?" + ", " + "?" + ", " + "?";
     if (stmtDeleteByUNameIdx == null) {
       stmtDeleteByUNameIdx = cnx.prepareStatement(sql);
     }
     int argIdx = 1;
     stmtDeleteByUNameIdx.setLong(
         argIdx++, (Authorization == null) ? 0 : Authorization.getSecClusterId());
     stmtDeleteByUNameIdx.setString(
         argIdx++, (Authorization == null) ? "" : Authorization.getSecUserId().toString());
     stmtDeleteByUNameIdx.setString(
         argIdx++, (Authorization == null) ? "" : Authorization.getSecSessionId().toString());
     stmtDeleteByUNameIdx.setLong(
         argIdx++, (Authorization == null) ? 0 : Authorization.getSecClusterId());
     stmtDeleteByUNameIdx.setLong(
         argIdx++, (Authorization == null) ? 0 : Authorization.getSecTenantId());
     stmtDeleteByUNameIdx.setLong(argIdx++, ClusterId);
     stmtDeleteByUNameIdx.setString(argIdx++, TenantName);
     Object stuff = null;
     boolean moreResults = stmtDeleteByUNameIdx.execute();
     while (stuff == null) {
       try {
         moreResults = stmtDeleteByUNameIdx.getMoreResults();
       } catch (SQLException e) {
         throw CFLib.getDefaultExceptionFactory().newDbException(getClass(), S_ProcName, e);
       }
       if (moreResults) {
         try {
           stuff = stmtDeleteByUNameIdx.getResultSet();
         } catch (SQLException e) {
         }
       } else if (-1 == stmtDeleteByUNameIdx.getUpdateCount()) {
         break;
       }
     }
   } catch (SQLException e) {
     throw CFLib.getDefaultExceptionFactory().newDbException(getClass(), S_ProcName, e);
   } finally {
     if (resultSet != null) {
       try {
         resultSet.close();
       } catch (SQLException e) {
       }
       resultSet = null;
     }
   }
 }
  public void deleteSysCluster(
      CFSecurityAuthorization Authorization, CFSecuritySysClusterBuff Buff) {
    final String S_ProcName = "deleteSysCluster";
    ResultSet resultSet = null;
    try {
      Connection cnx = schema.getCnx();
      int SingletonId = Buff.getRequiredSingletonId();

      final String sql = "CALL sp_delete_sysclus( ?, ?, ?, ?, ?" + ", " + "?" + ", " + "?" + " )";
      if (stmtDeleteByPKey == null) {
        stmtDeleteByPKey = cnx.prepareStatement(sql);
      }
      int argIdx = 1;
      stmtDeleteByPKey.setLong(
          argIdx++, (Authorization == null) ? 0 : Authorization.getSecClusterId());
      stmtDeleteByPKey.setString(
          argIdx++, (Authorization == null) ? "" : Authorization.getSecUserId().toString());
      stmtDeleteByPKey.setString(
          argIdx++, (Authorization == null) ? "" : Authorization.getSecSessionId().toString());
      stmtDeleteByPKey.setLong(
          argIdx++, (Authorization == null) ? 0 : Authorization.getSecClusterId());
      stmtDeleteByPKey.setLong(
          argIdx++, (Authorization == null) ? 0 : Authorization.getSecTenantId());
      stmtDeleteByPKey.setInt(argIdx++, SingletonId);
      stmtDeleteByPKey.setInt(argIdx++, Buff.getRequiredRevision());
      ;
      resultSet = stmtDeleteByPKey.executeQuery();
      if (resultSet.next()) {
        int deleteFlag = resultSet.getInt(1);
        if (resultSet.next()) {
          resultSet.last();
          throw CFLib.getDefaultExceptionFactory()
              .newRuntimeException(
                  getClass(),
                  S_ProcName,
                  "Did not expect multi-record response, " + resultSet.getRow() + " rows selected");
        }
      } else {
        throw CFLib.getDefaultExceptionFactory()
            .newRuntimeException(
                getClass(),
                S_ProcName,
                "Expected 1 record result set to be returned by delete, not 0 rows");
      }
    } catch (SQLException e) {
      throw CFLib.getDefaultExceptionFactory().newDbException(getClass(), S_ProcName, e);
    } finally {
      if (resultSet != null) {
        try {
          resultSet.close();
        } catch (SQLException e) {
        }
        resultSet = null;
      }
    }
  }
 public void deleteISOLanguageByCode2Idx(
     CFSecurityAuthorization Authorization, String argISO6391Code) {
   final String S_ProcName = "deleteISOLanguageByCode2Idx";
   ResultSet resultSet = null;
   try {
     Connection cnx = schema.getCnx();
     final String sql = "CALL sp_delete_iso_lang_by_code2idx( ?, ?, ?, ?, ?" + ", " + "?" + " )";
     if (stmtDeleteByCode2Idx == null) {
       stmtDeleteByCode2Idx = cnx.prepareStatement(sql);
     }
     int argIdx = 1;
     stmtDeleteByCode2Idx.setLong(
         argIdx++, (Authorization == null) ? 0 : Authorization.getSecClusterId());
     stmtDeleteByCode2Idx.setString(
         argIdx++, (Authorization == null) ? "" : Authorization.getSecUserId().toString());
     stmtDeleteByCode2Idx.setString(
         argIdx++, (Authorization == null) ? "" : Authorization.getSecSessionId().toString());
     stmtDeleteByCode2Idx.setLong(
         argIdx++, (Authorization == null) ? 0 : Authorization.getSecClusterId());
     stmtDeleteByCode2Idx.setLong(
         argIdx++, (Authorization == null) ? 0 : Authorization.getSecTenantId());
     if (argISO6391Code != null) {
       stmtDeleteByCode2Idx.setString(argIdx++, argISO6391Code);
     } else {
       stmtDeleteByCode2Idx.setNull(argIdx++, java.sql.Types.VARCHAR);
     }
     resultSet = stmtDeleteByCode2Idx.executeQuery();
     if (resultSet.next()) {
       int deleteFlag = resultSet.getInt(1);
       if (resultSet.next()) {
         resultSet.last();
         throw CFLib.getDefaultExceptionFactory()
             .newRuntimeException(
                 getClass(),
                 S_ProcName,
                 "Did not expect multi-record response, " + resultSet.getRow() + " rows selected");
       }
     } else {
       throw CFLib.getDefaultExceptionFactory()
           .newRuntimeException(
               getClass(),
               S_ProcName,
               "Expected 1 record result set to be returned by delete, not 0 rows");
     }
   } catch (SQLException e) {
     throw CFLib.getDefaultExceptionFactory().newDbException(getClass(), S_ProcName, e);
   } finally {
     if (resultSet != null) {
       try {
         resultSet.close();
       } catch (SQLException e) {
       }
       resultSet = null;
     }
   }
 }
 public CFSecurityTenantBuff lockBuff(
     CFSecurityAuthorization Authorization, CFSecurityTenantPKey PKey) {
   final String S_ProcName = "lockBuff";
   if (!schema.isTransactionOpen()) {
     throw CFLib.getDefaultExceptionFactory()
         .newUsageException(getClass(), S_ProcName, "Transaction not open");
   }
   ResultSet resultSet = null;
   try {
     Connection cnx = schema.getCnx();
     long Id = PKey.getRequiredId();
     String sql = "exec sp_lock_tenant ?, ?, ?, ?, ?" + ", " + "?";
     if (stmtLockBuffByPKey == null) {
       stmtLockBuffByPKey = cnx.prepareStatement(sql);
     }
     int argIdx = 1;
     stmtLockBuffByPKey.setLong(
         argIdx++, (Authorization == null) ? 0 : Authorization.getSecClusterId());
     stmtLockBuffByPKey.setString(
         argIdx++, (Authorization == null) ? "" : Authorization.getSecUserId().toString());
     stmtLockBuffByPKey.setString(
         argIdx++, (Authorization == null) ? "" : Authorization.getSecSessionId().toString());
     stmtLockBuffByPKey.setLong(
         argIdx++, (Authorization == null) ? 0 : Authorization.getSecClusterId());
     stmtLockBuffByPKey.setLong(
         argIdx++, (Authorization == null) ? 0 : Authorization.getSecTenantId());
     stmtLockBuffByPKey.setLong(argIdx++, Id);
     resultSet = stmtLockBuffByPKey.executeQuery();
     if (resultSet.next()) {
       CFSecurityTenantBuff buff = unpackTenantResultSetToBuff(resultSet);
       if (resultSet.next()) {
         resultSet.last();
         throw CFLib.getDefaultExceptionFactory()
             .newRuntimeException(
                 getClass(),
                 S_ProcName,
                 "Did not expect multi-record response, " + resultSet.getRow() + " rows selected");
       }
       return (buff);
     } else {
       return (null);
     }
   } catch (SQLException e) {
     throw CFLib.getDefaultExceptionFactory().newDbException(getClass(), S_ProcName, e);
   } finally {
     if (resultSet != null) {
       try {
         resultSet.close();
       } catch (SQLException e) {
       }
       resultSet = null;
     }
   }
 }
 public CFSecurityISOLanguageBuff[] readBuffByCode2Idx(
     CFSecurityAuthorization Authorization, String ISO6391Code) {
   final String S_ProcName = "readBuffByCode2Idx";
   ResultSet resultSet = null;
   try {
     Connection cnx = schema.getCnx();
     final String sql = "CALL sp_read_iso_lang_by_code2idx( ?, ?, ?, ?, ?" + ", " + "?" + " )";
     if (stmtReadBuffByCode2Idx == null) {
       stmtReadBuffByCode2Idx = cnx.prepareStatement(sql);
     }
     int argIdx = 1;
     stmtReadBuffByCode2Idx.setLong(
         argIdx++, (Authorization == null) ? 0 : Authorization.getSecClusterId());
     stmtReadBuffByCode2Idx.setString(
         argIdx++, (Authorization == null) ? "" : Authorization.getSecUserId().toString());
     stmtReadBuffByCode2Idx.setString(
         argIdx++, (Authorization == null) ? "" : Authorization.getSecSessionId().toString());
     stmtReadBuffByCode2Idx.setLong(
         argIdx++, (Authorization == null) ? 0 : Authorization.getSecClusterId());
     stmtReadBuffByCode2Idx.setLong(
         argIdx++, (Authorization == null) ? 0 : Authorization.getSecTenantId());
     if (ISO6391Code != null) {
       stmtReadBuffByCode2Idx.setString(argIdx++, ISO6391Code);
     } else {
       stmtReadBuffByCode2Idx.setNull(argIdx++, java.sql.Types.VARCHAR);
     }
     resultSet = stmtReadBuffByCode2Idx.executeQuery();
     List<CFSecurityISOLanguageBuff> buffList = new LinkedList<CFSecurityISOLanguageBuff>();
     while (resultSet.next()) {
       CFSecurityISOLanguageBuff buff = unpackISOLanguageResultSetToBuff(resultSet);
       buffList.add(buff);
     }
     int idx = 0;
     CFSecurityISOLanguageBuff[] retBuff = new CFSecurityISOLanguageBuff[buffList.size()];
     Iterator<CFSecurityISOLanguageBuff> iter = buffList.iterator();
     while (iter.hasNext()) {
       retBuff[idx++] = iter.next();
     }
     return (retBuff);
   } catch (SQLException e) {
     throw CFLib.getDefaultExceptionFactory().newDbException(getClass(), S_ProcName, e);
   } finally {
     if (resultSet != null) {
       try {
         resultSet.close();
       } catch (SQLException e) {
       }
       resultSet = null;
     }
   }
 }
 public CFSecurityTenantBuff readBuffByUNameIdx(
     CFSecurityAuthorization Authorization, long ClusterId, String TenantName) {
   final String S_ProcName = "readBuffByUNameIdx";
   ResultSet resultSet = null;
   try {
     Connection cnx = schema.getCnx();
     String sql = "exec sp_read_tenant_by_unameidx ?, ?, ?, ?, ?" + ", " + "?" + ", " + "?";
     if (stmtReadBuffByUNameIdx == null) {
       stmtReadBuffByUNameIdx = cnx.prepareStatement(sql);
     }
     int argIdx = 1;
     stmtReadBuffByUNameIdx.setLong(
         argIdx++, (Authorization == null) ? 0 : Authorization.getSecClusterId());
     stmtReadBuffByUNameIdx.setString(
         argIdx++, (Authorization == null) ? "" : Authorization.getSecUserId().toString());
     stmtReadBuffByUNameIdx.setString(
         argIdx++, (Authorization == null) ? "" : Authorization.getSecSessionId().toString());
     stmtReadBuffByUNameIdx.setLong(
         argIdx++, (Authorization == null) ? 0 : Authorization.getSecClusterId());
     stmtReadBuffByUNameIdx.setLong(
         argIdx++, (Authorization == null) ? 0 : Authorization.getSecTenantId());
     stmtReadBuffByUNameIdx.setLong(argIdx++, ClusterId);
     stmtReadBuffByUNameIdx.setString(argIdx++, TenantName);
     resultSet = stmtReadBuffByUNameIdx.executeQuery();
     if (resultSet.next()) {
       CFSecurityTenantBuff buff = unpackTenantResultSetToBuff(resultSet);
       if (resultSet.next()) {
         resultSet.last();
         throw CFLib.getDefaultExceptionFactory()
             .newRuntimeException(
                 getClass(),
                 S_ProcName,
                 "Did not expect multi-record response, " + resultSet.getRow() + " rows selected");
       }
       return (buff);
     } else {
       return (null);
     }
   } catch (SQLException e) {
     throw CFLib.getDefaultExceptionFactory().newDbException(getClass(), S_ProcName, e);
   } finally {
     if (resultSet != null) {
       try {
         resultSet.close();
       } catch (SQLException e) {
       }
       resultSet = null;
     }
   }
 }
 public CFSecurityTenantBuff[] readAllBuff(CFSecurityAuthorization Authorization) {
   final String S_ProcName = "readAllBuff";
   if (!schema.isTransactionOpen()) {
     throw CFLib.getDefaultExceptionFactory()
         .newUsageException(getClass(), S_ProcName, "Transaction not open");
   }
   ResultSet resultSet = null;
   try {
     Connection cnx = schema.getCnx();
     String sql = "exec sp_read_tenant_all ?, ?, ?, ?, ?";
     if (stmtReadAllBuff == null) {
       stmtReadAllBuff = cnx.prepareStatement(sql);
     }
     int argIdx = 1;
     stmtReadAllBuff.setLong(
         argIdx++, (Authorization == null) ? 0 : Authorization.getSecClusterId());
     stmtReadAllBuff.setString(
         argIdx++, (Authorization == null) ? "" : Authorization.getSecUserId().toString());
     stmtReadAllBuff.setString(
         argIdx++, (Authorization == null) ? "" : Authorization.getSecSessionId().toString());
     stmtReadAllBuff.setLong(
         argIdx++, (Authorization == null) ? 0 : Authorization.getSecClusterId());
     stmtReadAllBuff.setLong(
         argIdx++, (Authorization == null) ? 0 : Authorization.getSecTenantId());
     resultSet = stmtReadAllBuff.executeQuery();
     List<CFSecurityTenantBuff> buffList = new LinkedList<CFSecurityTenantBuff>();
     while (resultSet.next()) {
       CFSecurityTenantBuff buff = unpackTenantResultSetToBuff(resultSet);
       buffList.add(buff);
     }
     int idx = 0;
     CFSecurityTenantBuff[] retBuff = new CFSecurityTenantBuff[buffList.size()];
     Iterator<CFSecurityTenantBuff> iter = buffList.iterator();
     while (iter.hasNext()) {
       retBuff[idx++] = iter.next();
     }
     return (retBuff);
   } catch (SQLException e) {
     throw CFLib.getDefaultExceptionFactory().newDbException(getClass(), S_ProcName, e);
   } finally {
     if (resultSet != null) {
       try {
         resultSet.close();
       } catch (SQLException e) {
       }
       resultSet = null;
     }
   }
 }
  public void deleteTenant(CFSecurityAuthorization Authorization, CFSecurityTenantBuff Buff) {
    final String S_ProcName = "deleteTenant";
    try {
      Connection cnx = schema.getCnx();
      long Id = Buff.getRequiredId();

      String sql = "exec sp_delete_tenant ?, ?, ?, ?, ?" + ", " + "?" + ", " + "?";
      if (stmtDeleteByPKey == null) {
        stmtDeleteByPKey = cnx.prepareStatement(sql);
      }
      int argIdx = 1;
      stmtDeleteByPKey.setLong(
          argIdx++, (Authorization == null) ? 0 : Authorization.getSecClusterId());
      stmtDeleteByPKey.setString(
          argIdx++, (Authorization == null) ? "" : Authorization.getSecUserId().toString());
      stmtDeleteByPKey.setString(
          argIdx++, (Authorization == null) ? "" : Authorization.getSecSessionId().toString());
      stmtDeleteByPKey.setLong(
          argIdx++, (Authorization == null) ? 0 : Authorization.getSecClusterId());
      stmtDeleteByPKey.setLong(
          argIdx++, (Authorization == null) ? 0 : Authorization.getSecTenantId());
      stmtDeleteByPKey.setLong(argIdx++, Id);
      stmtDeleteByPKey.setInt(argIdx++, Buff.getRequiredRevision());
      ;
      Object stuff = null;
      boolean moreResults = stmtDeleteByPKey.execute();
      while (stuff == null) {
        try {
          moreResults = stmtDeleteByPKey.getMoreResults();
        } catch (SQLException e) {
          throw CFLib.getDefaultExceptionFactory().newDbException(getClass(), S_ProcName, e);
        }
        if (moreResults) {
          try {
            stuff = stmtDeleteByPKey.getResultSet();
          } catch (SQLException e) {
          }
        } else if (-1 == stmtDeleteByPKey.getUpdateCount()) {
          break;
        }
      }
    } catch (SQLException e) {
      throw CFLib.getDefaultExceptionFactory().newDbException(getClass(), S_ProcName, e);
    }
  }
 public void updateTenant(CFSecurityAuthorization Authorization, CFSecurityTenantBuff Buff) {
   final String S_ProcName = "updateTenant";
   ResultSet resultSet = null;
   try {
     long ClusterId = Buff.getRequiredClusterId();
     long Id = Buff.getRequiredId();
     String TenantName = Buff.getRequiredTenantName();
     int Revision = Buff.getRequiredRevision();
     Connection cnx = schema.getCnx();
     String sql =
         "exec sp_update_tenant ?, ?, ?, ?, ?, ?"
             + ", "
             + "?"
             + ", "
             + "?"
             + ", "
             + "?"
             + ", "
             + "?";
     if (stmtUpdateByPKey == null) {
       stmtUpdateByPKey = cnx.prepareStatement(sql);
     }
     int argIdx = 1;
     stmtUpdateByPKey.setLong(
         argIdx++, (Authorization == null) ? 0 : Authorization.getSecClusterId());
     stmtUpdateByPKey.setString(
         argIdx++, (Authorization == null) ? "" : Authorization.getSecUserId().toString());
     stmtUpdateByPKey.setString(
         argIdx++, (Authorization == null) ? "" : Authorization.getSecSessionId().toString());
     stmtUpdateByPKey.setLong(
         argIdx++, (Authorization == null) ? 0 : Authorization.getSecClusterId());
     stmtUpdateByPKey.setLong(
         argIdx++, (Authorization == null) ? 0 : Authorization.getSecTenantId());
     stmtUpdateByPKey.setString(argIdx++, "TENT");
     stmtUpdateByPKey.setLong(argIdx++, ClusterId);
     stmtUpdateByPKey.setLong(argIdx++, Id);
     stmtUpdateByPKey.setString(argIdx++, TenantName);
     stmtUpdateByPKey.setInt(argIdx++, Revision);
     resultSet = stmtUpdateByPKey.executeQuery();
     if (resultSet.next()) {
       CFSecurityTenantBuff updatedBuff = unpackTenantResultSetToBuff(resultSet);
       if (resultSet.next()) {
         resultSet.last();
         throw CFLib.getDefaultExceptionFactory()
             .newRuntimeException(
                 getClass(),
                 S_ProcName,
                 "Did not expect multi-record response, " + resultSet.getRow() + " rows selected");
       }
       Buff.setRequiredClusterId(updatedBuff.getRequiredClusterId());
       Buff.setRequiredTenantName(updatedBuff.getRequiredTenantName());
       Buff.setRequiredRevision(updatedBuff.getRequiredRevision());
     } else {
       throw CFLib.getDefaultExceptionFactory()
           .newRuntimeException(
               getClass(),
               S_ProcName,
               "Expected a single-record response, " + resultSet.getRow() + " rows selected");
     }
   } catch (SQLException e) {
     throw CFLib.getDefaultExceptionFactory().newDbException(getClass(), S_ProcName, e);
   } finally {
     if (resultSet != null) {
       try {
         resultSet.close();
       } catch (SQLException e) {
       }
       resultSet = null;
     }
   }
 }
 public void createSysCluster(
     CFSecurityAuthorization Authorization, CFSecuritySysClusterBuff Buff) {
   final String S_ProcName = "createSysCluster";
   if (!schema.isTransactionOpen()) {
     throw CFLib.getDefaultExceptionFactory()
         .newUsageException(getClass(), S_ProcName, "Transaction not open");
   }
   ResultSet resultSet = null;
   try {
     int SingletonId = Buff.getRequiredSingletonId();
     long ClusterId = Buff.getRequiredClusterId();
     Connection cnx = schema.getCnx();
     final String sql =
         "CALL sp_create_sysclus( ?, ?, ?, ?, ?, ?" + ", " + "?" + ", " + "?" + " )";
     if (stmtCreateByPKey == null) {
       stmtCreateByPKey = cnx.prepareStatement(sql);
     }
     int argIdx = 1;
     stmtCreateByPKey.setLong(
         argIdx++, (Authorization == null) ? 0 : Authorization.getSecClusterId());
     stmtCreateByPKey.setString(
         argIdx++, (Authorization == null) ? "" : Authorization.getSecUserId().toString());
     stmtCreateByPKey.setString(
         argIdx++, (Authorization == null) ? "" : Authorization.getSecSessionId().toString());
     stmtCreateByPKey.setLong(
         argIdx++, (Authorization == null) ? 0 : Authorization.getSecClusterId());
     stmtCreateByPKey.setLong(
         argIdx++, (Authorization == null) ? 0 : Authorization.getSecTenantId());
     stmtCreateByPKey.setString(argIdx++, "SYSC");
     stmtCreateByPKey.setInt(argIdx++, SingletonId);
     stmtCreateByPKey.setLong(argIdx++, ClusterId);
     resultSet = stmtCreateByPKey.executeQuery();
     if (resultSet.next()) {
       CFSecuritySysClusterBuff createdBuff = unpackSysClusterResultSetToBuff(resultSet);
       if (resultSet.next()) {
         resultSet.last();
         throw CFLib.getDefaultExceptionFactory()
             .newRuntimeException(
                 getClass(),
                 S_ProcName,
                 "Did not expect multi-record response, " + resultSet.getRow() + " rows selected");
       }
       Buff.setRequiredSingletonId(createdBuff.getRequiredSingletonId());
       Buff.setRequiredClusterId(createdBuff.getRequiredClusterId());
       Buff.setRequiredRevision(createdBuff.getRequiredRevision());
     } else {
       throw CFLib.getDefaultExceptionFactory()
           .newRuntimeException(
               getClass(),
               S_ProcName,
               "Expected a single-record response, " + resultSet.getRow() + " rows selected");
     }
   } catch (SQLException e) {
     throw CFLib.getDefaultExceptionFactory().newDbException(getClass(), S_ProcName, e);
   } finally {
     if (resultSet != null) {
       try {
         resultSet.close();
       } catch (SQLException e) {
       }
       resultSet = null;
     }
   }
 }
  /** @see HttpServlet#doPost(HttpServletRequest request, HttpServletResponse response) */
  protected void doPost(HttpServletRequest request, HttpServletResponse response)
      throws ServletException, IOException {
    final String S_ProcName = "doPost";

    ICFAsteriskSchemaObj schemaObj;
    HttpSession sess = request.getSession(false);
    if (sess == null) {
      sess = request.getSession(true);
      schemaObj = new CFAsteriskSchemaPooledObj();
      sess.setAttribute("SchemaObj", schemaObj);
    } else {
      schemaObj = (ICFAsteriskSchemaObj) sess.getAttribute("SchemaObj");
      if (schemaObj == null) {
        throw CFLib.getDefaultExceptionFactory()
            .newNullArgumentException(getClass(), S_ProcName, 0, "schemaObj");
      }
    }

    ICFAsteriskSchema dbSchema = null;
    try {
      CFSecurityAuthorization auth = schemaObj.getAuthorization();
      if (auth != null) {
        response.sendRedirect("CFAsteriskSMWarSecurityMainHtml");
        return;
      }

      dbSchema = (ICFAsteriskSchema) CFAsteriskSchemaPool.getSchemaPool().getInstance();
      schemaObj.setBackingStore(dbSchema);
      schemaObj.beginTransaction();
      ICFSecuritySecUserObj systemUser =
          schemaObj.getSecUserTableObj().readSecUserByULoginIdx("system");
      String passwordHash = systemUser.getRequiredPasswordHash();
      if ((passwordHash == null)
          || (passwordHash.length() <= 0)
          || passwordHash.equals("bootstrap")) {
        response.sendRedirect("CFAsteriskSMWarSetSystemPasswordHtml");
      }

      ICFSecurityClusterObj resolvedCluster;
      ICFSecuritySysClusterObj sysCluster =
          schemaObj.getSysClusterTableObj().readSysClusterByIdIdx(1, false);
      if (sysCluster == null) {
        throw CFLib.getDefaultExceptionFactory()
            .newNullArgumentException(getClass(), S_ProcName, 0, "sysCluster");
      }
      resolvedCluster = sysCluster.getRequiredContainerCluster();
      if (resolvedCluster == null) {
        throw CFLib.getDefaultExceptionFactory()
            .newNullArgumentException(getClass(), S_ProcName, "resolvedCluster");
      }
      String clusterDomainName = resolvedCluster.getRequiredFullDomainName();
      String clusterDescription = resolvedCluster.getRequiredDescription();

      String loginId = (String) request.getParameter("LoginId");
      if ((loginId == null) || (loginId.length() <= 0)) {
        response.setContentType("text/html");
        PrintWriter out = response.getWriter();
        out.println("<!DOCTYPE HTML PUBLIC \"-//W3C//DTD HTML 4.01//EN\">");
        out.println("<HTML>");
        out.println("<BODY>");
        out.println(
            "<form method=\"post\" formaction=\"CFAsteriskSMWarRequestResetPasswordHtml\">");
        out.println(
            "<H1 style=\"text-align:center\">" + clusterDescription + " Security Manager</H1>");
        out.println("<H2 style=\"text-align:center\">ERROR</H2>");
        out.println("<p style=\"text-align:center\">");
        out.println("You must specify a login id to reset.");
        out.println("<p style=\"text-align:center\">");
        out.println("Enter the login you'd like to request a password reset for.");
        out.println("<p>");
        out.println("<center>");
        out.println("<table style=\"width:60%\">");
        out.println(
            "<tr><th style=\"text-align:left\">Login Id:</th><td><input type=\"text\" name=\"LoginId\"/></td></tr>");
        out.println(
            "<tr><td colspan=\"2\" style=\"text-align:center\"><button type=\"submit\" name=\"Ok, Request Password Reset\"\">Ok</button></td></tr>");
        out.println(
            "<tr><td colSpan=\"2\" style=\"text-align:center\"><A HRef=\"CFAsteriskSMWarLoginHtml\">Back to "
                + clusterDescription
                + " Security Manager Login</A></td></tr>");
        out.println("</table>");
        out.println("</center>");
        out.println("</form>");
        out.println("</BODY>");
        out.println("</HTML>");
        return;
      }

      ICFSecuritySecUserObj authenticatingUser =
          schemaObj.getSecUserTableObj().readSecUserByULoginIdx(loginId, true);
      if (authenticatingUser == null) {
        response.setContentType("text/html");
        PrintWriter out = response.getWriter();
        out.println("<!DOCTYPE HTML PUBLIC \"-//W3C//DTD HTML 4.01//EN\">");
        out.println("<HTML>");
        out.println("<BODY>");
        out.println(
            "<form method=\"post\" formaction=\"CFAsteriskSMWarRequestResetPasswordHtml\">");
        out.println(
            "<H1 style=\"text-align:center\">" + clusterDescription + " Security Manager</H1>");
        out.println("<H2 style=\"text-align:center\">ERROR</H2>");
        out.println("<p style=\"text-align:center\">");
        out.println("Login id not found.");
        out.println("<p style=\"text-align:center\">");
        out.println("Enter the login you'd like to request a password reset for.");
        out.println("<p>");
        out.println("<center>");
        out.println("<table style=\"width:60%\">");
        out.println(
            "<tr><th style=\"text-align:left\">Login Id:</th><td><input type=\"text\" name=\"LoginId\"/></td></tr>");
        out.println(
            "<tr><td colspan=\"2\" style=\"text-align:center\"><button type=\"submit\" name=\"Ok, Request Password Reset\"\">Ok</button></td></tr>");
        out.println(
            "<tr><td colSpan=\"2\" style=\"text-align:center\"><A HRef=\"CFAsteriskSMWarLoginHtml\">Back to "
                + clusterDescription
                + " Security Manager Login</A></td></tr>");
        out.println("</table>");
        out.println("</center>");
        out.println("</form>");
        out.println("</BODY>");
        out.println("</HTML>");
        return;
      }

      if (null != authenticatingUser.getOptionalPasswordResetUuid()) {

        sendPasswordResetEMail(request, authenticatingUser, resolvedCluster);

        response.setContentType("text/html");
        PrintWriter out = response.getWriter();
        out.println("<!DOCTYPE HTML PUBLIC \"-//W3C//DTD HTML 4.01//EN\">");
        out.println("<HTML>");
        out.println("<BODY>");
        out.println(
            "<form method=\"post\" formaction=\"CFAsteriskSMWarRequestResetPasswordHtml\">");
        out.println(
            "<H1 style=\"text-align:center\">" + clusterDescription + " Security Manager</H1>");
        out.println("<H2 style=\"text-align:center\">INFO</H2>");
        out.println("<p style=\"text-align:center\">");
        out.println("Password reset email resent.");
        out.println("<center>");
        out.println("<table style=\"width:60%\">");
        out.println(
            "<tr><td colSpan=\"2\" style=\"text-align:center\"><A HRef=\"CFAsteriskSMWarLoginHtml\">Back to "
                + clusterDescription
                + " Security Manager Login</A></td></tr>");
        out.println("</table>");
        out.println("</center>");
        out.println("</form>");
        out.println("</BODY>");
        out.println("</HTML>");
      }

      ICFSecurityClusterObj systemCluster =
          schemaObj.getClusterTableObj().readClusterByUDomainNameIdx("system");
      ICFSecurityTenantObj systemTenant =
          schemaObj
              .getTenantTableObj()
              .readTenantByUNameIdx(systemCluster.getRequiredId(), "system");
      ICFSecuritySecSessionObj systemSession = schemaObj.getSecSessionTableObj().newInstance();
      ICFSecuritySecSessionEditObj editSystemSession =
          (ICFSecuritySecSessionEditObj) systemSession.beginEdit();
      editSystemSession.setRequiredContainerSecUser(systemUser);
      editSystemSession.setRequiredStart(Calendar.getInstance());
      systemSession = editSystemSession.create();
      editSystemSession.endEdit();

      auth = new CFSecurityAuthorization();
      auth.setSecCluster(systemCluster);
      auth.setSecTenant(systemTenant);
      auth.setSecSession(systemSession);
      schemaObj.setAuthorization(auth);

      ICFSecuritySecUserEditObj editAuthenticatingUser = authenticatingUser.beginEdit();
      editAuthenticatingUser.setOptionalPasswordResetUuid(UUID.randomUUID());
      editAuthenticatingUser.update();
      editAuthenticatingUser.endEdit();

      editSystemSession = (ICFSecuritySecSessionEditObj) systemSession.beginEdit();
      editSystemSession.setOptionalFinish(Calendar.getInstance());
      editSystemSession.update();
      editSystemSession.endEdit();

      schemaObj.setAuthorization(null);

      schemaObj.commit();

      sendPasswordResetEMail(request, authenticatingUser, resolvedCluster);

      response.setContentType("text/html");
      PrintWriter out = response.getWriter();
      out.println("<!DOCTYPE HTML PUBLIC \"-//W3C//DTD HTML 4.01//EN\">");
      out.println("<HTML>");
      out.println("<BODY>");
      out.println("<form method=\"post\" formaction=\"CFAsteriskSMWarRequestResetPasswordHtml\">");
      out.println(
          "<H1 style=\"text-align:center\">" + clusterDescription + " Security Manager</H1>");
      out.println("<H2 style=\"text-align:center\">INFO</H2>");
      out.println("<p style=\"text-align:center\">");
      out.println(
          "Password reset email sent.  Please use the links in the email to set a new password or to cancel the request.");
      out.println("<center>");
      out.println("<table style=\"width:60%\">");
      out.println(
          "<tr><td colSpan=\"2\" style=\"text-align:center\"><A HRef=\"CFAsteriskSMWarLoginHtml\">Back to "
              + clusterDescription
              + " Security Manager Login</A></td></tr>");
      out.println("</table>");
      out.println("</center>");
      out.println("</form>");
      out.println("</BODY>");
      out.println("</HTML>");
    } catch (MessagingException e) {
      throw CFLib.getDefaultExceptionFactory()
          .newRuntimeException(
              getClass(), S_ProcName, "Caught MessagingException -- " + e.getMessage(), e);
    } catch (NamingException e) {
      throw CFLib.getDefaultExceptionFactory()
          .newRuntimeException(
              getClass(), S_ProcName, "Caught NamingException -- " + e.getMessage(), e);
    } catch (RuntimeException e) {
      throw CFLib.getDefaultExceptionFactory()
          .newRuntimeException(
              getClass(), S_ProcName, "Caught RuntimeException -- " + e.getMessage(), e);
    } finally {
      if (dbSchema != null) {
        try {
          if (schemaObj.isTransactionOpen()) {
            schemaObj.rollback();
          }
        } catch (RuntimeException e) {
        }
        schemaObj.setBackingStore(null);
        CFAsteriskSchemaPool.getSchemaPool().releaseInstance(dbSchema);
      }
    }
  }
 public void updateISOLanguage(
     CFSecurityAuthorization Authorization, CFSecurityISOLanguageBuff Buff) {
   final String S_ProcName = "updateISOLanguage";
   if ("ISLN".equals(Buff.getClassCode()) && (!schema.isSystemUser(Authorization))) {
     throw CFLib.getDefaultExceptionFactory()
         .newRuntimeException(
             getClass(),
             S_ProcName,
             "Permission denied -- only system user can modify ISOLanguage data");
   }
   ResultSet resultSet = null;
   try {
     short ISOLanguageId = Buff.getRequiredISOLanguageId();
     String ISO6392Code = Buff.getRequiredISO6392Code();
     String ISO6391Code = Buff.getOptionalISO6391Code();
     String EnglishName = Buff.getRequiredEnglishName();
     int Revision = Buff.getRequiredRevision();
     Connection cnx = schema.getCnx();
     final String sql =
         "CALL sp_update_iso_lang( ?, ?, ?, ?, ?, ?"
             + ", "
             + "?"
             + ", "
             + "?"
             + ", "
             + "?"
             + ", "
             + "?"
             + ", "
             + "?"
             + " )";
     if (stmtUpdateByPKey == null) {
       stmtUpdateByPKey = cnx.prepareStatement(sql);
     }
     int argIdx = 1;
     stmtUpdateByPKey.setLong(
         argIdx++, (Authorization == null) ? 0 : Authorization.getSecClusterId());
     stmtUpdateByPKey.setString(
         argIdx++, (Authorization == null) ? "" : Authorization.getSecUserId().toString());
     stmtUpdateByPKey.setString(
         argIdx++, (Authorization == null) ? "" : Authorization.getSecSessionId().toString());
     stmtUpdateByPKey.setLong(
         argIdx++, (Authorization == null) ? 0 : Authorization.getSecClusterId());
     stmtUpdateByPKey.setLong(
         argIdx++, (Authorization == null) ? 0 : Authorization.getSecTenantId());
     stmtUpdateByPKey.setString(argIdx++, "ISLN");
     stmtUpdateByPKey.setShort(argIdx++, ISOLanguageId);
     stmtUpdateByPKey.setString(argIdx++, ISO6392Code);
     if (ISO6391Code != null) {
       stmtUpdateByPKey.setString(argIdx++, ISO6391Code);
     } else {
       stmtUpdateByPKey.setNull(argIdx++, java.sql.Types.VARCHAR);
     }
     stmtUpdateByPKey.setString(argIdx++, EnglishName);
     stmtUpdateByPKey.setInt(argIdx++, Revision);
     resultSet = stmtUpdateByPKey.executeQuery();
     if (resultSet.next()) {
       CFSecurityISOLanguageBuff updatedBuff = unpackISOLanguageResultSetToBuff(resultSet);
       if (resultSet.next()) {
         resultSet.last();
         throw CFLib.getDefaultExceptionFactory()
             .newRuntimeException(
                 getClass(),
                 S_ProcName,
                 "Did not expect multi-record response, " + resultSet.getRow() + " rows selected");
       }
       Buff.setRequiredISO6392Code(updatedBuff.getRequiredISO6392Code());
       Buff.setOptionalISO6391Code(updatedBuff.getOptionalISO6391Code());
       Buff.setRequiredEnglishName(updatedBuff.getRequiredEnglishName());
       Buff.setRequiredRevision(updatedBuff.getRequiredRevision());
     } else {
       throw CFLib.getDefaultExceptionFactory()
           .newRuntimeException(
               getClass(),
               S_ProcName,
               "Expected a single-record response, " + resultSet.getRow() + " rows selected");
     }
   } catch (SQLException e) {
     throw CFLib.getDefaultExceptionFactory().newDbException(getClass(), S_ProcName, e);
   } finally {
     if (resultSet != null) {
       try {
         resultSet.close();
       } catch (SQLException e) {
       }
       resultSet = null;
     }
   }
 }