0f349359a8bebbd67c7bd7bb732285dee71905fc
chmalee
  Tue May 7 08:43:51 2024 -0700
Start of requiring hub,genome,and file type with each file submission

diff --git src/hg/hgHubConnect/trackHubWizard.c src/hg/hgHubConnect/trackHubWizard.c
index ad39379..a3fe480 100644
--- src/hg/hgHubConnect/trackHubWizard.c
+++ src/hg/hgHubConnect/trackHubWizard.c
@@ -5,53 +5,90 @@
 
 #include "common.h"
 #include "cart.h"
 #include "cheapcgi.h"
 #include "hdb.h"
 #include "hgConfig.h"
 #include "md5.h"
 #include "trashDir.h"
 #include "hgHubConnect.h"
 #include "jsHelper.h"
 #include "web.h"
 #include "wikiLink.h"
 #include "customTrack.h"
 #include "userdata.h"
 #include "jsonWrite.h"
+#include "cartJson.h"
 
-void doRemoveFile()
-/* Process the request to remove a file */
+void removeOneFile(char *userName, char *cgiFileName)
+/* Remove one single file for userName */
 {
-char *userName = getUserName();
-if (userName)
-    {
-    char *cgiFileName = cgiOptionalString("deleteFile");
 char *fileName = prefixUserFile(userName, cgiFileName);
 if (fileExists(fileName))
     {
     fprintf(stderr, "deleting file: '%s'\n", fileName);
     removeFileForUser(fileName, userName);
+    fflush(stderr);
+    }
+}
+
+void doRemoveFile(struct cartJson *cj, struct hash *paramHash)
+/* Process the request to remove a file */
+{
+char *userName = getUserName();
+if (userName)
+    {
+    struct jsonWrite *errors = jsonWriteNew();
+    // verify the argument is present:
+    (void)cartJsonRequiredParam(paramHash, "deleteFile", errors, "doRemoveFile");
+    struct jsonElement *deleteJson = hashFindVal(paramHash, "deleteFile");
+    struct slRef *ele, *deleteList = deleteJson->val.jeList;
+    for (ele = deleteList; ele != NULL; ele = ele->next)
+        {
+        struct jsonElement *jsonVal = ele->val;
+        removeOneFile(userName, jsonVal->val.jeString);
+        }
     fprintf(stdout, "Status: 204 No Content\n\n");
     fflush(stdout);
     exit(0);
     }
-    }
 fprintf(stdout, "Status: 404 Not Found\n\n");
 fflush(stdout);
 exit(0);
 }
 
+void doCreateHub(struct cartJson *cj, struct hash *paramHash)
+/* Make a new hub.txt with the parameters from the JSON request */
+{
+char *userName = getUserName();
+if (userName)
+    {
+    struct jsonWrite *errors = jsonWriteNew();
+    // verify the arguments:
+    (void)cartJsonRequiredParam(paramHash, "createHub", errors, "doCreateHub");
+    // params is an object with everything necessary to create a hub: name and assembly
+    struct hash *params = jsonObjectVal(hashFindVal(paramHash, "createHub"), "createHub");
+    char *db = hashFindVal(params, "db");
+    char *name = hashFindVal(params, "name");
+    fprintf(stderr, "creating hub '%s' for db '%s'\n", name, db);
+    fflush(stderr);
+    }
+fprintf(stderr, "Status: 204 No Content\n\n");
+fflush(stdout);
+exit(0);
+}
+
 static void outFilesForUser()
 /* List out the currently stored files for the user and their sizes */
 {
 char *userName = getUserName();
 struct jsonWrite *jw = jsonWriteNew(); // the JSON to return for the client javascript
 jsonWriteObjectStart(jw, NULL);
 if (userName)
     {
     // the url for this user:
     jsonWriteString(jw, "userUrl", webDataDir(userName));
     struct userHubs *hub, *hubList = listHubsForUser(userName);
     // unpack hub directories into a flat list of files
     jsonWriteListStart(jw, "fileList");
     for (hub = hubList; hub != NULL; hub = hub->next)
         {
@@ -117,43 +154,20 @@
     "<li><a href=\"../goldenPath/help/publicHubGuidelines.html\" style='color:#121E9A' target=_blank>Guidelines for Submitting a Public Hub</a></li>\n"
     "</ul>\n"
     "<BR>You may also <a href='../contacts.html' style='color:#121E9A'>contact us</a> if you have any "
     "issues or questions on hub development.");
 puts("</div>"); // .tabSection
 puts("</div>\n"); // col-md-6
 puts("</div>\n"); // row
 
 puts("<div id='chosenFilesSection' style=\"display: none\" class='col-md-6 tabSection'>");
 puts("<h4>Your uploaded hubs</h4>");
 webIncludeFile("inc/hgMyData.html");
 puts("</div>\n");
 puts("</div>\n"); // row
 puts("</div>\n"); // row
 
+// get the current files stored for this user
 outFilesForUser();
 jsInline("$(document).ready(function() {\nhubCreate.init();\n})");
 puts("</div>");
-// get the current files stored for this user
-}
-
-#define FILEVAR "userFile__filename"
-#define FILEVARBIN "userFile__binary"
-void doCreateHub(struct cart *cart)
-/* Called asynchronously when the user has submitted some files, return a json response of where 
- * the files live and the new quota */
-{
-// cheapcgi.c renames form variables as var__filename or var__binary for binary data, why?
-char *fileName = cartOptionalString(cart, FILEVAR);
-/*
-struct hashEl *hel, *helList = hashElListHash(cart->hash);
-for (hel = helList; hel != NULL; hel = hel->next)
-{
-fprintf(stderr, "hashEl name: '%s', value: '%s'\n", (char *)hel->name, (char *)hel->val);
-}
-*/
-fprintf(stderr, "fileName is: %s\n", fileName);
-fflush(stderr);
-char *pathToFile = "tempPath"; //prepBigData(cart, fileName, FILEVARBIN, FILEVAR);
-puts("Content-Type:text/javascript\n");
-printf("{\"status\": \"%s is uploaded to %s\"}\n", cgiOptionalString("userFile__filename"), pathToFile);
-fflush(stdout);
 }