4fc19c01ff119c7075ec8d474e37e6bfc8519792 braney Mon Apr 29 14:56:59 2024 -0700 allow Genark hubs to be specified as "db" diff --git src/hg/lib/cart.c src/hg/lib/cart.c index dec0d6e..221c6cd 100644 --- src/hg/lib/cart.c +++ src/hg/lib/cart.c @@ -23,30 +23,31 @@ #include "customFactory.h" #include "googleAnalytics.h" #include "wikiLink.h" #endif /* GBROWSE */ #include "hgMaf.h" #include "hui.h" #include "geoMirror.h" #include "hubConnect.h" #include "trackHub.h" #include "cgiApoptosis.h" #include "customComposite.h" #include "regexHelper.h" #include "windowsToAscii.h" #include "jsonWrite.h" #include "verbose.h" +#include "genark.h" static char *sessionVar = "hgsid"; /* Name of cgi variable session is stored in. */ static char *positionCgiName = "position"; DbConnector cartDefaultConnector = hConnectCart; DbDisconnect cartDefaultDisconnector = hDisconnectCart; static boolean cartDidContentType = FALSE; struct slPair *httpHeaders = NULL; // A list of headers to output before the content-type static void hashUpdateDynamicVal(struct hash *hash, char *name, void *val) /* Val is a dynamically allocated (freeMem-able) entity to put * in hash. Override existing hash item with that name if any. * Otherwise make new hash item. */ { @@ -1383,30 +1384,52 @@ struct trackDb *tdb = hTrackDb(db); for(; tdb; tdb = tdb->next) { struct trackDb *parent = tdb->parent; if (parent && parent->isShow) hideIfNotInCart(cart, parent->track); if (tdb->visibility != tvHide) hideIfNotInCart(cart, tdb->track); } // Don't do this again until someone sets this variable, // presumably on session load. cartRemove(cart, CART_HAS_DEFAULT_VISIBILITY); } +static void fixUpDb(struct cart *cart) +// we want to load Genark hubs or error out if db is not available +{ +char *db = cartOptionalString(cart,"db"); + +if ((db == NULL) || startsWith("hub_", db)) + return; +else if (startsWith("GCA_", db) || startsWith("GCF_", db)) + { + char *url = genarkUrl(db); + + if (url != NULL) + { + cartSetString(cart, "genome", db); + cartSetString(cart, "hubUrl", url); + cartRemove(cart, "db"); + } + } +else if (!hDbIsActive(db)) + errAbort("Can not find database '%s'", db); +} + struct cart *cartNew(char *userId, char *sessionId, char **exclude, struct hash *oldVars) /* Load up cart from user & session id's. Exclude is a null-terminated list of * strings to not include */ { cgiApoptosisSetup(); if (cfgOptionBooleanDefault("showEarlyErrors", FALSE)) errAbortSetDoContentType(TRUE); if (cfgOptionBooleanDefault("suppressVeryEarlyErrors", FALSE)) htmlSuppressErrors(); setUdcCacheDir(); netSetTimeoutErrorMsg("A connection timeout means that either the server is offline or its firewall, the UCSC firewall or any router between the two blocks the connection."); @@ -1426,30 +1449,32 @@ if (sessionIdFound) cartParseOverHash(cart, cart->sessionInfo->contents); else if (userIdFound) cartParseOverHash(cart, cart->userInfo->contents); else { char *defaultCartContents = getDefaultCart(conn); cartParseOverHash(cart, defaultCartContents); } char when[1024]; safef(when, sizeof(when), "open %s %s", userId, sessionId); cartTrace(cart, when, conn); loadCgiOverHash(cart, oldVars); +fixUpDb(cart); // now is the time to see if someone is loading a Genark hub or specified a bad database. + // I think this is the place to justify old and new values cartJustify(cart, oldVars); #ifndef GBROWSE /* If some CGI other than hgSession been passed hgSession loading instructions, * apply those to cart before we do anything else. (If this is hgSession, * let it handle the settings so it can display feedback to the user.) */ boolean didSessionLoad = FALSE; if (! (cgiScriptName() && endsWith(cgiScriptName(), "hgSession"))) { if (cartVarExists(cart, hgsDoOtherUser)) { char *otherUser = cartString(cart, hgsOtherUserName); char *sessionName = cartString(cart, hgsOtherUserSessionName); boolean mergeCart = cartUsualBoolean(cart, hgsMergeCart, FALSE);