ec3a6524ca5074c26e5b0addc2310071259cc93b
hiram
  Sun Apr 28 09:42:45 2019 -0700
eliminating the db= argument everywhere, only need genome= refs #18869

diff --git src/hg/hubApi/list.c src/hg/hubApi/list.c
index 1bf49dd..9449565 100644
--- src/hg/hubApi/list.c
+++ src/hg/hubApi/list.c
@@ -181,67 +181,67 @@
     jsonWriteObjectStart(jw, "chromosomes");
     for ( ; el; el = el->next )
 	{
 	jsonWriteNumber(jw, el->name, (long long)el->size);
 	}
     jsonWriteObjectEnd(jw);	/* chromosomes */
     }
 else
     {
     struct chromInfo *ci = NULL;
     /* might be a track hub on a UCSC database */
     if (isEmpty(foundGenome->twoBitPath))
 	{
 	struct sqlConnection *conn = hAllocConnMaybe(foundGenome->trackHub->defaultDb);
 	if (NULL == conn)
-	    apiErrAbort(err400, err400Msg, "can not find database 'genome=%s' for endpoint '/list/chromosomes", foundGenome->trackHub->defaultDb);
+	    apiErrAbort(err400, err400Msg, "can not find 'genome=%s' for endpoint '/list/chromosomes", foundGenome->trackHub->defaultDb);
 	else
 	    hFreeConn(&conn);
 	ci = createChromInfoList(NULL, foundGenome->trackHub->defaultDb);
 	}
     else
 	{
 	ci = trackHubAllChromInfo(foundGenome->name);
 	}
     slSort(ci, chromInfoCmp);
     jsonWriteNumber(jw, "chromCount", (long long)slCount(ci));
     jsonWriteObjectStart(jw, "chromosomes");
     struct chromInfo *el = ci;
     for ( ; el != NULL; el = el->next )
 	{
 	jsonWriteNumber(jw, el->chrom, (long long)el->size);
 	}
     jsonWriteObjectEnd(jw);	/* chromosomes */
     }
 apiFinishOutput(0, NULL, jw);
 }
 
 static void chromInfoJsonOutput(FILE *f, char *db)
 /* for given db, if there is a track, list the chromosomes in that track,
  * for no track, simply list the chromosomes in the sequence
  */
 {
 char *table = cgiOptionalString("track");
 struct sqlConnection *conn = hAllocConnMaybe(db);
 if (NULL == conn)
-    apiErrAbort(err400, err400Msg, "can not find database 'db=%s' for endpoint '/list/chromosomes", db);
+    apiErrAbort(err400, err400Msg, "can not find 'genome=%s' for endpoint '/list/chromosomes", db);
 
 /* in trackDb language: track == table */
 if (table)
     {
     if (! sqlTableExists(conn, table))
-	apiErrAbort(err400, err400Msg, "can not find specified 'track=%s' for endpoint: /list/chromosomes?db=%s;track=%s", table, db, table);
+	apiErrAbort(err400, err400Msg, "can not find specified 'track=%s' for endpoint: /list/chromosomes?genome=%s;track=%s", table, db, table);
     if (sqlColumnExists(conn, table, "chrom"))
 	{
 	char *dataTime = sqlTableUpdate(conn, table);
 	time_t dataTimeStamp = sqlDateToUnixTime(dataTime);
 	replaceChar(dataTime, ' ', 'T');	/* ISO 8601 */
         struct jsonWrite *jw = apiStartOutput();
 	jsonWriteString(jw, "genome", db);
 	jsonWriteString(jw, "track", table);
 	jsonWriteString(jw, "dataTime", dataTime);
 	jsonWriteNumber(jw, "dataTimeStamp", (long long)dataTimeStamp);
 	freeMem(dataTime);
         struct slPair *list = NULL;
 	char query[2048];
         sqlSafef(query, sizeof(query), "select distinct chrom from %s", table);
 	struct sqlResult *sr = sqlGetResult(conn, query);
@@ -347,31 +347,31 @@
 int dif = strcmp(a->track, b->track);
 if (dif < 0)
    return -1;
 else if (dif == 0.0)
    return strcasecmp(a->shortLabel, b->shortLabel);
 else
    return 1;
 }
 #endif
 
 static void trackDbJsonOutput(char *db, FILE *f)
 /* return track list from specified UCSC database name */
 {
 struct sqlConnection *conn = hAllocConnMaybe(db);
 if (NULL == conn)
-    apiErrAbort(err400, err400Msg, "can not find database 'db=%s' for endpoint '/list/tracks", db);
+    apiErrAbort(err400, err400Msg, "can not find 'genome=%s' for endpoint '/list/tracks", db);
 
 char *dataTime = sqlTableUpdate(conn, "trackDb");
 time_t dataTimeStamp = sqlDateToUnixTime(dataTime);
 replaceChar(dataTime, ' ', 'T');	/* ISO 8601 */
 hFreeConn(&conn);
 struct trackDb *tdbList = obtainTdb(NULL, db);
 struct jsonWrite *jw = apiStartOutput();
 jsonWriteString(jw, "db", db);
 jsonWriteString(jw, "dataTime", dataTime);
 jsonWriteNumber(jw, "dataTimeStamp", (long long)dataTimeStamp);
 freeMem(dataTime);
 struct trackDb *el = NULL;
 for (el = tdbList; el != NULL; el = el->next )
     {
     recursiveTrackList(jw, el);
@@ -408,84 +408,84 @@
 	    jsonWriteString(jw, "trackDbFile", el->trackDbFile);
 	    jsonWriteString(jw, "twoBitPath", el->twoBitPath);
 	    jsonWriteString(jw, "groups", el->groups);
 	    jsonWriteString(jw, "defaultPos", el->defaultPos);
 	    jsonWriteNumber(jw, "orderKey", el->orderKey);
 	    jsonWriteObjectEnd(jw);
 	    }
 	jsonWriteObjectEnd(jw);
 	apiFinishOutput(0, NULL, jw);
 	}
     }
 else if (sameWord("tracks", words[1]))
     {
     char *hubUrl = cgiOptionalString("hubUrl");
     char *genome = cgiOptionalString("genome");
-    char *db = cgiOptionalString("db");
-    if (isNotEmpty(db))
+    char *db = cgiOptionalString("genome");
+    if (isEmpty(hubUrl) && isNotEmpty(db))
 	{
 	struct sqlConnection *conn = hAllocConnMaybe(db);
         if (NULL == conn)
-	    apiErrAbort(err400, err400Msg, "can not find database 'db=%s' for endpoint '/list/tracks", db);
+	    apiErrAbort(err400, err400Msg, "can not find 'genome=%s' for endpoint '/list/tracks", db);
 	else
 	    hFreeConn(&conn);
 	}
     if (isEmpty(hubUrl) && isEmpty(db))
-      apiErrAbort(err400, err400Msg, "ERROR: missing hubUrl or db name for endpoint /list/tracks");
+      apiErrAbort(err400, err400Msg, "missing hubUrl or genome name for endpoint /list/tracks");
     if (isEmpty(hubUrl))	// missing hubUrl implies UCSC database
 	{
         trackDbJsonOutput(db, stdout);	// only need db for this function
 	return;
 	}
     if (isEmpty(genome) || isEmpty(hubUrl))
 	{
         if (isEmpty(genome))
-	    apiErrAbort(err400, err400Msg, "ERROR: must supply genome='someName' the name of a genome in a hub for /list/tracks\n");
+	    apiErrAbort(err400, err400Msg, "must supply genome='someName' the name of a genome in a hub for /list/tracks\n");
 	if (isEmpty(hubUrl))
-            apiErrAbort(err400, err400Msg, "ERROR: must supply hubUrl='http:...' some URL to a hub for /list/tracks");
+            apiErrAbort(err400, err400Msg, "must supply hubUrl='http:...' some URL to a hub for /list/tracks");
 	}
     struct trackHub *hub = errCatchTrackHubOpen(hubUrl);
     struct trackHubGenome *hubGenome = findHubGenome(hub, genome,
 	"/list/tracks", hubUrl);
     struct trackDb *tdbList = obtainTdb(hubGenome, NULL);
 //	slSort(tdbList, trackDbTrackCmp);
     struct jsonWrite *jw = apiStartOutput();
     jsonWriteString(jw, "hubUrl", hubUrl);
     jsonWriteObjectStart(jw, genome);
     struct trackDb *el = NULL;
     for (el = tdbList; el != NULL; el = el->next )
 	    {
 	    recursiveTrackList(jw, el);
 	    }
     jsonWriteObjectEnd(jw);
     apiFinishOutput(0, NULL, jw);
     }
 else if (sameWord("chromosomes", words[1]))
     {
     char *hubUrl = cgiOptionalString("hubUrl");
     char *genome = cgiOptionalString("genome");
-    char *db = cgiOptionalString("db");
-    if (isNotEmpty(db))
+    char *db = cgiOptionalString("genome");
+    if (isEmpty(hubUrl) && isNotEmpty(db))
 	{
 	struct sqlConnection *conn = hAllocConnMaybe(db);
         if (NULL == conn)
-	    apiErrAbort(err400, err400Msg, "can not find database 'db=%s' for endpoint '/list/chromosomes", db);
+	    apiErrAbort(err400, err400Msg, "can not find 'genome=%s' for endpoint '/list/chromosomes", db);
 	else
 	    hFreeConn(&conn);
 	}
     if (isEmpty(hubUrl) && isEmpty(db))
-        apiErrAbort(err400, err400Msg, "must supply hubUrl or db name for endpoint '/list/chromosomes", hubUrl, db);
+        apiErrAbort(err400, err400Msg, "must supply hubUrl or genome name for endpoint '/list/chromosomes", hubUrl, db);
 
     if (isEmpty(hubUrl))	// missing hubUrl implies UCSC database
 	{
         chromInfoJsonOutput(stdout, db);
 	return;
 	}
     else
 	{
         hubChromInfoJsonOutput(stdout, hubUrl, genome);
 	return;
 	}
     }
 else
     apiErrAbort(err400, err400Msg, "do not recognize endpoint function: '/%s/%s'", words[0], words[1]);
 }	/*	void apiList(char *words[MAX_PATH_INFO])        */