public void deleteDomainBySubDomIdx(long TenantId, long SubDomainOfId) {
   CFInternetDomainBySubDomIdxKey key =
       ((ICFBamSchema) schema.getBackingStore()).getFactoryDomain().newSubDomIdxKey();
   key.setRequiredTenantId(TenantId);
   key.setRequiredSubDomainOfId(SubDomainOfId);
   if (indexBySubDomIdx == null) {
     indexBySubDomIdx =
         new HashMap<
             CFInternetDomainBySubDomIdxKey,
             Map<CFInternetDomainBasePKey, ICFInternetDomainObj>>();
   }
   if (indexBySubDomIdx.containsKey(key)) {
     Map<CFInternetDomainBasePKey, ICFInternetDomainObj> dict = indexBySubDomIdx.get(key);
     ((ICFBamSchema) schema.getBackingStore())
         .getTableDomain()
         .deleteDomainBySubDomIdx(schema.getAuthorization(), TenantId, SubDomainOfId);
     Iterator<ICFInternetDomainObj> iter = dict.values().iterator();
     ICFInternetDomainObj obj;
     List<ICFInternetDomainObj> toForget = new LinkedList<ICFInternetDomainObj>();
     while (iter.hasNext()) {
       obj = iter.next();
       toForget.add(obj);
     }
     iter = toForget.iterator();
     while (iter.hasNext()) {
       obj = iter.next();
       obj.forget(true);
     }
     indexBySubDomIdx.remove(key);
   } else {
     ((ICFBamSchema) schema.getBackingStore())
         .getTableDomain()
         .deleteDomainBySubDomIdx(schema.getAuthorization(), TenantId, SubDomainOfId);
   }
 }
 public void deleteDomain(ICFInternetDomainObj Obj) {
   ICFInternetDomainObj obj = Obj;
   ((ICFBamSchema) schema.getBackingStore())
       .getTableDomain()
       .deleteDomain(schema.getAuthorization(), obj.getDomainBuff());
   obj.forget(true);
 }
 public ICFInternetDomainObj readDomainByNameIdx(
     long TenantId, long SubDomainOfId, String Name, boolean forceRead) {
   if (indexByNameIdx == null) {
     indexByNameIdx = new HashMap<CFInternetDomainByNameIdxKey, ICFInternetDomainObj>();
   }
   CFInternetDomainByNameIdxKey key =
       ((ICFBamSchema) schema.getBackingStore()).getFactoryDomain().newNameIdxKey();
   key.setRequiredTenantId(TenantId);
   key.setRequiredSubDomainOfId(SubDomainOfId);
   key.setRequiredName(Name);
   ICFInternetDomainObj obj = null;
   if ((!forceRead) && indexByNameIdx.containsKey(key)) {
     obj = indexByNameIdx.get(key);
   } else {
     CFInternetDomainBuff buff =
         ((ICFBamSchema) schema.getBackingStore())
             .getTableDomain()
             .readDerivedByNameIdx(schema.getAuthorization(), TenantId, SubDomainOfId, Name);
     if (buff != null) {
       obj =
           (ICFInternetDomainObj)
               schema.getDomainBaseTableObj().constructByClassCode(buff.getClassCode());
       obj.setPKey(((ICFBamSchema) schema.getBackingStore()).getFactoryDomainBase().newPKey());
       obj.setBuff(buff);
       obj = (ICFInternetDomainObj) obj.realize();
     } else if (schema.getCacheMisses()) {
       indexByNameIdx.put(key, null);
     }
   }
   return (obj);
 }
 public ICFInternetDomainObj updateDomain(ICFInternetDomainObj Obj) {
   ICFInternetDomainObj obj = Obj;
   ((ICFBamSchema) schema.getBackingStore())
       .getTableDomain()
       .updateDomain(schema.getAuthorization(), Obj.getDomainBuff());
   if (Obj.getClassCode().equals("DOMN")) {
     obj = (ICFInternetDomainObj) Obj.realize();
   }
   return (obj);
 }
 public ICFInternetDomainObj createDomain(ICFInternetDomainObj Obj) {
   ICFInternetDomainObj obj = Obj;
   CFInternetDomainBuff buff = obj.getDomainBuff();
   ((ICFBamSchema) schema.getBackingStore())
       .getTableDomain()
       .createDomain(schema.getAuthorization(), buff);
   obj.copyBuffToPKey();
   if (obj.getPKey().getClassCode().equals("DOMN")) {
     obj = (ICFInternetDomainObj) (obj.realize());
   }
   return (obj);
 }
 public void deleteDomainByNameIdx(long TenantId, long SubDomainOfId, String Name) {
   if (indexByNameIdx == null) {
     indexByNameIdx = new HashMap<CFInternetDomainByNameIdxKey, ICFInternetDomainObj>();
   }
   CFInternetDomainByNameIdxKey key =
       ((ICFBamSchema) schema.getBackingStore()).getFactoryDomain().newNameIdxKey();
   key.setRequiredTenantId(TenantId);
   key.setRequiredSubDomainOfId(SubDomainOfId);
   key.setRequiredName(Name);
   ICFInternetDomainObj obj = null;
   if (indexByNameIdx.containsKey(key)) {
     obj = indexByNameIdx.get(key);
     ((ICFBamSchema) schema.getBackingStore())
         .getTableDomain()
         .deleteDomainByNameIdx(schema.getAuthorization(), TenantId, SubDomainOfId, Name);
     obj.forget(true);
   } else {
     ((ICFBamSchema) schema.getBackingStore())
         .getTableDomain()
         .deleteDomainByNameIdx(schema.getAuthorization(), TenantId, SubDomainOfId, Name);
   }
 }
 public ICFInternetDomainObj lockDomain(CFInternetDomainBasePKey pkey) {
   ICFInternetDomainObj locked = null;
   CFInternetDomainBuff lockBuff =
       ((ICFBamSchema) schema.getBackingStore())
           .getTableDomain()
           .lockDerived(schema.getAuthorization(), pkey);
   if (lockBuff != null) {
     locked =
         (ICFInternetDomainObj)
             schema.getDomainBaseTableObj().constructByClassCode(lockBuff.getClassCode());
     locked.setPKey(((ICFBamSchema) schema.getBackingStore()).getFactoryDomainBase().newPKey());
     locked.setBuff(lockBuff);
     locked = (ICFInternetDomainObj) locked.realize();
   } else {
     throw CFLib.getDefaultExceptionFactory()
         .newCollisionDetectedException(getClass(), "lockDomain", pkey);
   }
   return (locked);
 }
 public ICFInternetDomainObj readDomain(CFInternetDomainBasePKey pkey, boolean forceRead) {
   ICFInternetDomainObj obj = null;
   if ((!forceRead) && members.containsKey(pkey)) {
     obj = members.get(pkey);
   } else {
     CFInternetDomainBuff readBuff =
         ((ICFBamSchema) schema.getBackingStore())
             .getTableDomain()
             .readDerivedByIdIdx(
                 schema.getAuthorization(), pkey.getRequiredTenantId(), pkey.getRequiredId());
     if (readBuff != null) {
       obj =
           (ICFInternetDomainObj)
               schema.getDomainBaseTableObj().constructByClassCode(readBuff.getClassCode());
       obj.setPKey(((ICFBamSchema) schema.getBackingStore()).getFactoryDomainBase().newPKey());
       obj.setBuff(readBuff);
       obj = (ICFInternetDomainObj) obj.realize();
     } else if (schema.getCacheMisses()) {
       members.put(pkey, null);
     }
   }
   return (obj);
 }
  /** @see HttpServlet#doGet(HttpServletRequest request, HttpServletResponse response) */
  protected void doGet(HttpServletRequest request, HttpServletResponse response)
      throws ServletException, IOException {
    final String S_ProcName = "doGet";
    ICFInternetSchemaObj schemaObj;
    HttpSession sess = request.getSession(false);
    if (sess == null) {
      sess = request.getSession(true);
      schemaObj = new CFInternetSchemaPooledObj();
      sess.setAttribute("SchemaObj", schemaObj);
    } else {
      schemaObj = (ICFInternetSchemaObj) sess.getAttribute("SchemaObj");
      if (schemaObj == null) {
        schemaObj = new CFInternetSchemaPooledObj();
        sess.setAttribute("SchemaObj", schemaObj);
      }
    }

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

      dbSchema = (ICFInternetSchema) CFInternetSchemaPool.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("CFInternetSMWarSetSystemPasswordHtml");
        return;
      }

      ICFSecuritySysClusterObj sysCluster =
          schemaObj.getSysClusterTableObj().readSysClusterByIdIdx(1, false);
      if (sysCluster == null) {
        throw CFLib.getDefaultExceptionFactory()
            .newNullArgumentException(getClass(), S_ProcName, 0, "sysCluster");
      }

      ICFSecurityClusterObj resolvedCluster = sysCluster.getRequiredContainerCluster();
      if (resolvedCluster == null) {
        throw CFLib.getDefaultExceptionFactory()
            .newNullArgumentException(getClass(), S_ProcName, "resolvedCluster");
      }
      String clusterDomainName = resolvedCluster.getRequiredFullDomainName();
      String clusterDescription = resolvedCluster.getRequiredDescription();

      String confirmationUUIDStr = (String) request.getParameter("ConfirmationUUID");
      if ((confirmationUUIDStr == null) || (confirmationUUIDStr.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=\"CFInternetSMWarConfirmEMailAddressHtml\">");
        out.println(
            "<H1 style=\"text-align:center\">" + clusterDescription + " Security Manager</H1>");
        out.println("<H2 style=\"text-align:center\">ERROR</H2>");
        out.println("<p>");
        out.println("<center>");
        out.println("<p>");
        out.println(
            "The ConfirmationUUID parameter was missing in your request.  Please use the link provided by your confirmation email.");
        out.println("</BODY>");
        out.println("</HTML>");
        return;
      }

      UUID confirmationUUID = UUID.fromString(confirmationUUIDStr);
      if (confirmationUUID == 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=\"CFInternetSMWarConfirmEMailAddressHtml\">");
        out.println(
            "<H1 style=\"text-align:center\">" + clusterDescription + " Security Manager</H1>");
        out.println("<H2 style=\"text-align:center\">ERROR</H2>");
        out.println("<p>");
        out.println("<center>");
        out.println("<p>");
        out.println(
            "Invalid ConfirmationUUID \""
                + confirmationUUIDStr
                + "\".  Please use the link provided by your confirmation email.");
        out.println("</BODY>");
        out.println("</HTML>");
        return;
      }

      ICFSecuritySecUserObj confirmUser = null;
      Iterator<ICFSecuritySecUserObj> secUserForUUID =
          schemaObj.getSecUserTableObj().readSecUserByEMConfIdx(confirmationUUID).iterator();
      if (secUserForUUID.hasNext()) {
        confirmUser = secUserForUUID.next();
        if (secUserForUUID.hasNext()) {
          throw CFLib.getDefaultExceptionFactory()
              .newRuntimeException(
                  getClass(),
                  S_ProcName,
                  "Multiple SecUser instances found for ConfirmationUUID \""
                      + confirmationUUIDStr
                      + "\"");
        }
      } else {
        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=\"CFInternetSMWarConfirmEMailAddressHtml\">");
        out.println(
            "<H1 style=\"text-align:center\">" + clusterDescription + " Security Manager</H1>");
        out.println("<H2 style=\"text-align:center\">ERROR</H2>");
        out.println("<p>");
        out.println("<center>");
        out.println("<p>");
        out.println(
            "Invalid ConfirmationUUID \""
                + confirmationUUIDStr
                + "\".  Please use the link provided by your confirmation email.");
        out.println("</BODY>");
        out.println("</HTML>");
        return;
      }

      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 editConfirmUser = confirmUser.beginEdit();
      editConfirmUser.setOptionalEMailConfirmationUuid(null);
      editConfirmUser.update();
      editConfirmUser.endEdit();

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

      schemaObj.commit();

      schemaObj.setAuthorization(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=\"CFInternetSMWarConfirmEMailAddressHtml\">");
      out.println(
          "<H1 style=\"text-align:center\">" + clusterDescription + " Security Manager</H1>");
      out.println("<H2 style=\"text-align:center\">EMail Address Confirmed</H2>");
      out.println("<p>");
      out.println("<center>");
      out.println("<table style=\"width:75%\">");
      out.println(
          "<tr><th style=\"text-align:left\">Confirmation UUID:</th><td><input type=\"text\" name=\"ConfirmationUUID\" value=\""
              + confirmationUUID.toString()
              + "\"/></td></tr>");
      out.println(
          "<tr><td colSpan=\"2\" style=\"text-align:center\">You may now <A HRef=\"CFInternetSMWarLoginHtml\">log in</A> to the "
              + clusterDescription
              + " Security Manager</td></tr>");
      out.println("</table>");
      out.println("</center>");
      out.println("</form>");
      out.println("</BODY>");
      out.println("</HTML>");
    } 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);
        CFInternetSchemaPool.getSchemaPool().releaseInstance(dbSchema);
      }
    }
  }
 public List<ICFInternetDomainObj> readDomainBySubDomIdx(
     long TenantId, long SubDomainOfId, boolean forceRead) {
   final String S_ProcName = "readDomainBySubDomIdx";
   CFInternetDomainBySubDomIdxKey key =
       ((ICFBamSchema) schema.getBackingStore()).getFactoryDomain().newSubDomIdxKey();
   key.setRequiredTenantId(TenantId);
   key.setRequiredSubDomainOfId(SubDomainOfId);
   Map<CFInternetDomainBasePKey, ICFInternetDomainObj> dict;
   if (indexBySubDomIdx == null) {
     indexBySubDomIdx =
         new HashMap<
             CFInternetDomainBySubDomIdxKey,
             Map<CFInternetDomainBasePKey, ICFInternetDomainObj>>();
   }
   if ((!forceRead) && indexBySubDomIdx.containsKey(key)) {
     dict = indexBySubDomIdx.get(key);
   } else {
     dict = new HashMap<CFInternetDomainBasePKey, ICFInternetDomainObj>();
     // Allow other threads to dirty-read while we're loading
     indexBySubDomIdx.put(key, dict);
     ICFInternetDomainObj obj;
     CFInternetDomainBuff[] buffList =
         ((ICFBamSchema) schema.getBackingStore())
             .getTableDomain()
             .readDerivedBySubDomIdx(schema.getAuthorization(), TenantId, SubDomainOfId);
     CFInternetDomainBuff buff;
     for (int idx = 0; idx < buffList.length; idx++) {
       buff = buffList[idx];
       obj =
           (ICFInternetDomainObj)
               schema.getDomainBaseTableObj().constructByClassCode(buff.getClassCode());
       obj.setPKey(((ICFBamSchema) schema.getBackingStore()).getFactoryDomainBase().newPKey());
       obj.setBuff(buff);
       ICFInternetDomainObj realized = (ICFInternetDomainObj) obj.realize();
     }
   }
   Comparator<ICFInternetDomainObj> cmp =
       new Comparator<ICFInternetDomainObj>() {
         public int compare(ICFInternetDomainObj lhs, ICFInternetDomainObj rhs) {
           if (lhs == null) {
             if (rhs == null) {
               return (0);
             } else {
               return (-1);
             }
           } else if (rhs == null) {
             return (1);
           } else {
             CFInternetDomainBasePKey lhsPKey = lhs.getPKey();
             CFInternetDomainBasePKey rhsPKey = rhs.getPKey();
             int ret = lhsPKey.compareTo(rhsPKey);
             return (ret);
           }
         }
       };
   int len = dict.size();
   ICFInternetDomainObj arr[] = new ICFInternetDomainObj[len];
   Iterator<ICFInternetDomainObj> valIter = dict.values().iterator();
   int idx = 0;
   while ((idx < len) && valIter.hasNext()) {
     arr[idx++] = valIter.next();
   }
   if (idx < len) {
     throw CFLib.getDefaultExceptionFactory()
         .newArgumentUnderflowException(getClass(), S_ProcName, 0, "idx", idx, len);
   } else if (valIter.hasNext()) {
     throw CFLib.getDefaultExceptionFactory()
         .newArgumentOverflowException(getClass(), S_ProcName, 0, "idx", idx, len);
   }
   Arrays.sort(arr, cmp);
   ArrayList<ICFInternetDomainObj> arrayList = new ArrayList<ICFInternetDomainObj>(len);
   for (idx = 0; idx < len; idx++) {
     arrayList.add(arr[idx]);
   }
   List<ICFInternetDomainObj> sortedList = arrayList;
   return (sortedList);
 }
 public List<ICFInternetDomainObj> readAllDomain(boolean forceRead) {
   final String S_ProcName = "readAllDomain";
   if ((allDomain == null) || forceRead) {
     Map<CFInternetDomainBasePKey, ICFInternetDomainObj> map =
         new HashMap<CFInternetDomainBasePKey, ICFInternetDomainObj>();
     allDomain = map;
     CFInternetDomainBuff[] buffList =
         ((ICFBamSchema) schema.getBackingStore())
             .getTableDomain()
             .readAllDerived(schema.getAuthorization());
     CFInternetDomainBuff buff;
     ICFInternetDomainObj obj;
     for (int idx = 0; idx < buffList.length; idx++) {
       buff = buffList[idx];
       obj =
           (ICFInternetDomainObj)
               schema.getDomainBaseTableObj().constructByClassCode(buff.getClassCode());
       obj.setPKey(((ICFBamSchema) schema.getBackingStore()).getFactoryDomainBase().newPKey());
       obj.setBuff(buff);
       ICFInternetDomainObj realized = (ICFInternetDomainObj) obj.realize();
     }
   }
   Comparator<ICFInternetDomainObj> cmp =
       new Comparator<ICFInternetDomainObj>() {
         public int compare(ICFInternetDomainObj lhs, ICFInternetDomainObj rhs) {
           if (lhs == null) {
             if (rhs == null) {
               return (0);
             } else {
               return (-1);
             }
           } else if (rhs == null) {
             return (1);
           } else {
             CFInternetDomainBasePKey lhsPKey = lhs.getPKey();
             CFInternetDomainBasePKey rhsPKey = rhs.getPKey();
             int ret = lhsPKey.compareTo(rhsPKey);
             return (ret);
           }
         }
       };
   int len = allDomain.size();
   ICFInternetDomainObj arr[] = new ICFInternetDomainObj[len];
   Iterator<ICFInternetDomainObj> valIter = allDomain.values().iterator();
   int idx = 0;
   while ((idx < len) && valIter.hasNext()) {
     arr[idx++] = valIter.next();
   }
   if (idx < len) {
     throw CFLib.getDefaultExceptionFactory()
         .newArgumentUnderflowException(getClass(), S_ProcName, 0, "idx", idx, len);
   } else if (valIter.hasNext()) {
     throw CFLib.getDefaultExceptionFactory()
         .newArgumentOverflowException(getClass(), S_ProcName, 0, "idx", idx, len);
   }
   Arrays.sort(arr, cmp);
   ArrayList<ICFInternetDomainObj> arrayList = new ArrayList<ICFInternetDomainObj>(len);
   for (idx = 0; idx < len; idx++) {
     arrayList.add(arr[idx]);
   }
   List<ICFInternetDomainObj> sortedList = arrayList;
   return (sortedList);
 }