979a6409ad7d171eeb48d44b5a0d2cba0d304059 hiram Thu Jun 27 13:43:01 2019 -0700 checking for supported table and avoid container tracks on requests refs #23589 diff --git src/hg/hubApi/dataApi.h src/hg/hubApi/dataApi.h index d40e8c9..b8e64df 100644 --- src/hg/hubApi/dataApi.h +++ src/hg/hubApi/dataApi.h @@ -24,39 +24,44 @@ #include "obscure.h" #include "errCatch.h" #include "vcf.h" #include "bedTabix.h" #include "bamFile.h" #include "jsonParse.h" #include "jsonWrite.h" #include "chromInfo.h" #include "wiggle.h" #include "hubPublic.h" #ifdef USE_HAL #include "halBlockViz.h" #endif +/* reference for these error codes: + * https://www.restapitutorial.com/httpstatuscodes.html + */ /* error return codes */ #define err301 301 #define err301Msg "Moved Permanently" #define err400 400 #define err400Msg "Bad Request" #define err403 403 #define err403Msg "Forbidden" #define err404 404 #define err404Msg "Not Found" +#define err415 415 +#define err415Msg "Unsupported track type" #define err429 429 #define err429Msg "Too Many Requests" /* list of all potential arguments */ #define argHubUrl "hubUrl" #define argGenome "genome" #define argTrackLeavesOnly "trackLeavesOnly" #define argTrack "track" #define argChrom "chrom" #define argStart "start" #define argEnd "end" #define argMaxItemsOutput "maxItemsOutput" #define argJsonOutputArrays "jsonOutputArrays" /* valid argument listings to verify extraneous arguments @@ -75,56 +80,63 @@ */ #define MAX_PATH_INFO 32 /* maximum amount of DNA allowed in a get sequence request */ #define MAX_DNA_LENGTH 499999999 /* this size is directly related to the max limit in needMem used in * jsonWriteString */ extern long enteredMainTime; /* will become = clock1000() on entry */ /* limit amount of output to a maximum to avoid overload */ extern int maxItemsOutput; /* can be set in URL maxItemsOutput=N */ extern long long itemsReturned; /* for getData functions, number of items returned */ extern boolean reachedMaxItems; /* during getData, signal to return */ + +/* supportedTypes will be initialized to a known supported set */ +extern struct slName *supportedTypes; + /* for debugging purpose, current bot delay value */ extern int botDelay; boolean debug; /* can be set in URL debug=1, to turn off: debug=0 */ /* default is to list all trackDb entries, composite containers too. * This option will limit to only the actual track entries with data */ extern boolean trackLeavesOnly; /* set by CGI parameter 'trackLeavesOnly' */ /* this selects output type 'arrays', where the default type is: objects */ extern boolean jsonOutputArrays; /* set by CGI parameter 'jsonOutputArrays' */ extern boolean measureTiming; /* set by CGI parameters */ /* functions in hubApi.c */ struct hubPublic *hubPublicDbLoadAll(); struct dbDb *ucscDbDb(); /* return the dbDb table as an slList */ char *verifyLegalArgs(char *validArgList[]); /* validArgList is an array of strings for valid arguments * returning string of any other arguments not on that list found in * cgiVarList(), NULL when none found. */ +boolean isSupportedType(char *type); +/* is given type in the supportedTypes list ? */ + /* ######################################################################### */ /* functions in apiUtils.c */ void startProcessTiming(); /* for measureTiming, beginning processing */ void apiFinishOutput(int errorCode, char *errorString, struct jsonWrite *jw); /* finish json output, potential output an error code other than 200 */ void apiErrAbort(int errorCode, char *errString, char *format, ...); /* Issue an error message in json format, and exit(0) */ struct jsonWrite *apiStartOutput(); /* begin json output with standard header information for all requests */ @@ -167,28 +179,31 @@ */ /* temporarily from table browser until proven works, then move to library */ struct asObject *asForTable(struct sqlConnection *conn, char *table, struct trackDb *tdb); /* Get autoSQL description if any associated with table. */ /* Wrap some error catching around asForTable. */ struct trackHubGenome *findHubGenome(struct trackHub *hub, char *genome, char *endpoint, char *hubUrl); /* given open 'hub', find the specified 'genome' called from 'endpoint' */ struct dbDb *ucscDbDb(); /* return the dbDb table as an slList */ +boolean isSupportedType(char *type); +/* is given type in the supportedTypes list ? */ + /* ######################################################################### */ /* functions in getData.c */ void apiGetData(char *words[MAX_PATH_INFO]); /* 'getData' function, words[1] is the subCommand */ /* ######################################################################### */ /* functions in list.c */ void apiList(char *words[MAX_PATH_INFO]); /* 'list' function words[1] is the subCommand */ #endif /* DATAAPH_H */