#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
*/
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
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);
}
}
/* 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;
else
*bodyOut = message;
+ free(queryconds);
+
if (requestPTR) free(requestPTR);
if (requestMeat) free(requestMeat);
#include "glite/lb/context-int.h"
#include "glite/lb/xml_conversions.h"
+#include "glite/lb/query_rec.h"
#include "lb_xml_parse.h"
#define USERJOBS_BEGIN "<edg_wll_UserJobs"
#define USERJOBS_END "</edg_wll_UserJobs>\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() {\
}
break;
case 2:
- for (i=0; i<sizeof(ops)/sizeof(ops[0]); i++)
- if (!strcasecmp(el,ops[i])) break;
- if (i == sizeof(ops)/sizeof(ops[0])) unexp()
+ for (i=0; i<sizeof(edg_wll_QueryOpNames)/sizeof(edg_wll_QueryOpNames[0]); i++)
+ if (!strcasecmp(el,edg_wll_QueryOpNames[i])) break;
+ if (i == sizeof(edg_wll_QueryOpNames)/sizeof(edg_wll_QueryOpNames[0])) unexp()
else {
if (!XMLCtx->job_conditions) break;
XMLCtx->bound = 0;
}
break;
- case 3: for (i=0; i<sizeof(attrs)/sizeof(attrs[0]) &&
- strcasecmp(el,attrs[i]); i++);
- if (i == sizeof(attrs)/sizeof(attrs[0])) unexp()
+ case 3: for (i=0; i<sizeof(edg_wll_QueryAttrNames)/sizeof(edg_wll_QueryAttrNames[0]) &&
+ strcasecmp(el,edg_wll_QueryAttrNames[i]); i++);
+ if (i == sizeof(edg_wll_QueryAttrNames)/sizeof(edg_wll_QueryAttrNames[0])) unexp()
else {
if (!XMLCtx->job_conditions) break;
if (!XMLCtx->job_conditions[XMLCtx->row]) break;
else unexp()
break;
case 3:
- for (i=0; i<sizeof(ops)/sizeof(ops[0]); i++)
- if (!strcasecmp(el,ops[i])) break;
- if (i == sizeof(ops)/sizeof(ops[0])) unexp()
+ for (i=0; i<sizeof(edg_wll_QueryOpNames)/sizeof(edg_wll_QueryOpNames[0]); i++)
+ if (!strcasecmp(el,edg_wll_QueryOpNames[i])) break;
+ if (i == sizeof(edg_wll_QueryOpNames)/sizeof(edg_wll_QueryOpNames[0])) unexp()
else if (XMLCtx->type == EDG_WLL_QUERY_TYPE_JOB_CONDITION) {
if (!XMLCtx->job_conditions) break;
}
break;
- case 4: for (i=0; i<sizeof(attrs)/sizeof(attrs[0]) &&
- strcasecmp(el,attrs[i]); i++);
- if (i == sizeof(attrs)/sizeof(attrs[0])) unexp()
+ case 4: for (i=0; i<sizeof(edg_wll_QueryAttrNames)/sizeof(edg_wll_QueryAttrNames[0]) &&
+ strcasecmp(el,edg_wll_QueryAttrNames[i]); i++);
+ if (i == sizeof(edg_wll_QueryAttrNames)/sizeof(edg_wll_QueryAttrNames[0])) unexp()
else if (XMLCtx->type == EDG_WLL_QUERY_TYPE_JOB_CONDITION) {
if (!XMLCtx->job_conditions[XMLCtx->row]) break;
if ( (i+1) == EDG_WLL_QUERY_ATTR_USERTAG) {