From: Zdeněk Šustr Date: Fri, 3 Aug 2012 14:59:18 +0000 (+0000) Subject: Query attribute name definitions moved from lb.server to lb.common X-Git-Tag: glite-lbjp-common-gss_R_3_2_4_1~44 X-Git-Url: http://scientific.zcu.cz/git/?a=commitdiff_plain;h=e826ff7743d29ce5a81331b57bb6bb5c65b564e0;p=jra1mw.git Query attribute name definitions moved from lb.server to lb.common - At least three other places where the names are used can be rid of duplicate literals Stub for the "?query" query string in URLs --- diff --git a/org.glite.lb.common/interface/query_rec.h b/org.glite.lb.common/interface/query_rec.h index bffe71a..9c1623b 100644 --- a/org.glite.lb.common/interface/query_rec.h +++ b/org.glite.lb.common/interface/query_rec.h @@ -78,6 +78,15 @@ typedef enum _edg_wll_QueryAttr{ /* if adding new attribute, add conversion string to common/xml_conversions.c too !! */ } edg_wll_QueryAttr; +/** + * Names for the predefined types of query attributes + */ +extern char *edg_wll_QueryAttrNames[]; + +/** + * Names for the predefined types of query operands + */ +extern char *edg_wll_QueryOpNames[]; /** * Predefined types for query operands diff --git a/org.glite.lb.common/src/query_rec.c b/org.glite.lb.common/src/query_rec.c index d4e6be3..e7de9bb 100644 --- a/org.glite.lb.common/src/query_rec.c +++ b/org.glite.lb.common/src/query_rec.c @@ -26,6 +26,21 @@ limitations under the License. #include "glite/jobid/cjobid.h" #include "query_rec.h" +/** + * Names for the predefined types of query attributes + */ +char *edg_wll_QueryAttrNames[] = { "jobid","owner","status","location","destination", + "donecode","usertag","time","level","host","source", + "instance","type","chkpt_tag", "resubmitted", "parent_job", + "exitcode", "jdl", "stateentertime", "lastupdatetime", + "networkserver" }; + +/** + * Names for the predefined types of query operands + */ +char *edg_wll_QueryOpNames[] = { "equal","less","greater","within","unequal","changed" }; + + /* * edg_wll_QueryRec manipulation routines */ diff --git a/org.glite.lb.server/src/lb_proto.c b/org.glite.lb.server/src/lb_proto.c index 950f10d..b0d9708 100644 --- a/org.glite.lb.server/src/lb_proto.c +++ b/org.glite.lb.server/src/lb_proto.c @@ -677,7 +677,7 @@ edg_wll_ErrorCode edg_wll_Proto(edg_wll_Context ctx, char **response,char ***headersOut,char **bodyOut, int *httpErr) { - char *requestPTR = NULL, *message = NULL, *requestMeat = NULL; + char *requestPTR = NULL, *message = NULL, *requestMeat = NULL, *querystr, *queryconds = NULL; int ret = HTTP_OK; int html = outputHTML(headers); int text = 0; //XXX: Plain text communication is special case of html here, hence when text=1, html=1 too @@ -737,6 +737,16 @@ edg_wll_ErrorCode edg_wll_Proto(edg_wll_Context ctx, if (check_request_for_query(requestPTR, "?all")) adm_opt = HTTP_ADMIN_OPTION_ALL; else if (check_request_for_query(requestPTR, "?foreign")) adm_opt = HTTP_ADMIN_OPTION_FOREIGN; + if ((querystr = strstr(requestPTR, "?query="))) { + int len = strcspn(querystr+strlen("?query="),"? \f\n\r\t\v"); + if (len) { + extra_opt = HTTP_EXTRA_OPTION_QUERY; + queryconds = (char*)calloc((len+1),sizeof(char)); + queryconds = strncpy(queryconds, querystr+strlen("?query="), len); + glite_common_log(LOG_CATEGORY_LB_SERVER, LOG_PRIORITY_DEBUG, + "Query over HTML \"%s\"", queryconds); + } + } strip_request_of_queries(requestPTR); } @@ -750,7 +760,7 @@ edg_wll_ErrorCode edg_wll_Proto(edg_wll_Context ctx, } /* GET /: Current User Jobs */ - else if ((!strcmp(requestMeat, "/")) && (extra_opt == HTTP_EXTRA_OPTION_NONE)) { + else if ((!strcmp(requestMeat, "/")) && ((extra_opt == HTTP_EXTRA_OPTION_NONE) || ( extra_opt == HTTP_EXTRA_OPTION_QUERY))) { edg_wlc_JobId *jobsOut = NULL; edg_wll_JobStat *statesOut = NULL; int i, flags; @@ -1492,6 +1502,8 @@ err: asprintf(response,"HTTP/1.1 %d %s",ret,edg_wll_HTTPErrorMessage(ret)); else *bodyOut = message; + free(queryconds); + if (requestPTR) free(requestPTR); if (requestMeat) free(requestMeat); diff --git a/org.glite.lb.server/src/lb_proto.h b/org.glite.lb.server/src/lb_proto.h index b55f59b..b56410d 100644 --- a/org.glite.lb.server/src/lb_proto.h +++ b/org.glite.lb.server/src/lb_proto.h @@ -65,6 +65,7 @@ typedef enum _http_extra_option{ HTTP_EXTRA_OPTION_VERSION, HTTP_EXTRA_OPTION_CONFIGURATION, HTTP_EXTRA_OPTION_STATS, + HTTP_EXTRA_OPTION_QUERY, HTTP_EXTRA_OPTION_LAST } http_extra_option; diff --git a/org.glite.lb.server/src/lb_xml_parse.c.T b/org.glite.lb.server/src/lb_xml_parse.c.T index afde05d..f6b3c04 100644 --- a/org.glite.lb.server/src/lb_xml_parse.c.T +++ b/org.glite.lb.server/src/lb_xml_parse.c.T @@ -29,6 +29,7 @@ limitations under the License. #include "glite/lb/context-int.h" #include "glite/lb/xml_conversions.h" +#include "glite/lb/query_rec.h" #include "lb_xml_parse.h" @@ -63,14 +64,6 @@ limitations under the License. #define USERJOBS_BEGIN "\r\n" - -static char *ops[] = { "equal","less","greater","within","unequal","changed" }, - *attrs[] = { "jobid","owner","status","location","destination", - "donecode","usertag","time","level","host","source", - "instance","type","chkpt_tag", "resubmitted", "parent_job", - "exitcode", "jdl", "stateentertime", "lastupdatetime", - "networkserver" }; - static const struct timeval null_timeval = {0,0}; #define unexp() {\ @@ -108,9 +101,9 @@ static void startJobQueryRec(void *data, const char *el, const char **attr) } break; case 2: - for (i=0; ijob_conditions) break; @@ -122,9 +115,9 @@ static void startJobQueryRec(void *data, const char *el, const char **attr) XMLCtx->bound = 0; } break; - case 3: for (i=0; ijob_conditions) break; if (!XMLCtx->job_conditions[XMLCtx->row]) break; @@ -231,9 +224,9 @@ static void startQueryEventsRequest(void *data, const char *el, const char **att else unexp() break; case 3: - for (i=0; itype == EDG_WLL_QUERY_TYPE_JOB_CONDITION) { if (!XMLCtx->job_conditions) break; @@ -255,9 +248,9 @@ static void startQueryEventsRequest(void *data, const char *el, const char **att } break; - case 4: for (i=0; itype == EDG_WLL_QUERY_TYPE_JOB_CONDITION) { if (!XMLCtx->job_conditions[XMLCtx->row]) break; if ( (i+1) == EDG_WLL_QUERY_ATTR_USERTAG) {