- html and text interface of conditions
authorJiří Filipovič <fila@ics.muni.cz>
Fri, 31 Oct 2008 11:56:05 +0000 (11:56 +0000)
committerJiří Filipovič <fila@ics.muni.cz>
Fri, 31 Oct 2008 11:56:05 +0000 (11:56 +0000)
- /notif/ changed to /NOTIF: in html and text interface
- job attributes in text interface named like in  edg_wll_JobStat structure
TODO: remove quadratic complexity in strings compositions (many asprintfs)

org.glite.lb.server/src/cond_dump.c [new file with mode: 0644]
org.glite.lb.server/src/cond_dump.h [new file with mode: 0644]
org.glite.lb.server/src/lb_html.c
org.glite.lb.server/src/lb_html.h
org.glite.lb.server/src/lb_proto.c
org.glite.lb.server/src/lb_text.c
org.glite.lb.server/src/lb_text.h

diff --git a/org.glite.lb.server/src/cond_dump.c b/org.glite.lb.server/src/cond_dump.c
new file mode 100644 (file)
index 0000000..ade2912
--- /dev/null
@@ -0,0 +1,210 @@
+#ident "$Header$"
+
+#include "glite/lb/context-int.h"
+#include "lb_proto.h"
+
+#include <string.h>
+#include <stdio.h>
+#include <stdlib.h>
+#include <time.h>
+#include <assert.h>
+
+#define TR(name,type,field)             \
+        if (field) {            \
+                asprintf(&pomA,"%s<tr><th align=\"left\">" name ":</th>"        \
+                        "<td>" type "</td></tr>",pomB,(field)); \
+                free(pomB);                                     \
+                pomB = pomA;                                    \
+        }
+
+#define GS(string){    \
+       asprintf(&pomA, "%s %s", pomB, (string)); \
+       free(pomB); \
+       pomB = pomA; \
+}
+
+int edg_wll_Condition_Dump(notifInfo *ni, char **output, int oneline){
+       if (! ni->conditions){
+               *output = strdup("");
+               return -1;
+       }
+
+       char *pomA = NULL, *pomB;
+       pomB = strdup("");
+
+       edg_wll_QueryRec **l1;
+       edg_wll_QueryRec *l2;
+       for (l1 = ni->conditions; *l1; l1++){
+               if (l1 != ni->conditions)
+                       GS ("and");
+               if (oneline)
+                       GS("(");
+               l2 = *l1;
+               switch (l2->attr){
+                       case EDG_WLL_QUERY_ATTR_JOBID: GS("jobId");
+                               break;
+                       case EDG_WLL_QUERY_ATTR_OWNER: GS("owner");
+                               break;
+                       case EDG_WLL_QUERY_ATTR_STATUS: GS("status");
+                               break;
+                       case EDG_WLL_QUERY_ATTR_LOCATION: GS("location");
+                               break;
+                        case EDG_WLL_QUERY_ATTR_DESTINATION: GS("destination");
+                               break;
+                       case EDG_WLL_QUERY_ATTR_DONECODE: GS("donecode");
+                               break;
+                       case EDG_WLL_QUERY_ATTR_USERTAG: GS("usertag");
+                               break;
+                       case EDG_WLL_QUERY_ATTR_TIME: GS("time");
+                               break;
+                       case EDG_WLL_QUERY_ATTR_LEVEL: GS("level");
+                               break;
+                       case EDG_WLL_QUERY_ATTR_HOST: GS("host");
+                               break;
+                        case EDG_WLL_QUERY_ATTR_SOURCE: GS("source");
+                               break;
+                        case EDG_WLL_QUERY_ATTR_INSTANCE: GS("instance");
+                               break;
+                        case EDG_WLL_QUERY_ATTR_EVENT_TYPE: GS("eventtype");
+                               break;
+                       case EDG_WLL_QUERY_ATTR_CHKPT_TAG: GS("chkpttag");
+                               break;
+                       case EDG_WLL_QUERY_ATTR_RESUBMITTED: GS("resubmitted");
+                               break;
+                       case EDG_WLL_QUERY_ATTR_PARENT: GS("parent_job");
+                               break;
+                       case EDG_WLL_QUERY_ATTR_EXITCODE: GS("exitcode");
+                               break;
+                       case EDG_WLL_QUERY_ATTR_JDL_ATTR: 
+                               GS(l2->attr_id.tag);  //get JDL attribute name
+                               break;
+                       case EDG_WLL_QUERY_ATTR_STATEENTERTIME: GS("stateentertime");
+                               break;
+                       case EDG_WLL_QUERY_ATTR_LASTUPDATETIME: GS("lastupdatetime");
+                               break;
+                       case EDG_WLL_QUERY_ATTR_NETWORK_SERVER: GS("networkserver");
+                               break;
+                       default:
+                               assert(! "Unknown attribute!");
+                               break;
+               }
+               for (l2 = *l1; l2->attr; l2++){
+                       if (l2 != *l1 && !oneline) GS ("        or");
+                       if (l2 != *l1 && oneline) GS("or");
+                       switch(l2->op){
+                               case EDG_WLL_QUERY_OP_EQUAL: GS("=");
+                                       break;
+                               case EDG_WLL_QUERY_OP_LESS: GS ("<");
+                                       break;
+                               case EDG_WLL_QUERY_OP_GREATER: GS ("<");
+                                       break;
+                               case EDG_WLL_QUERY_OP_WITHIN: GS ("within");
+                                       break;
+                               case EDG_WLL_QUERY_OP_UNEQUAL: GS ("!=");
+                       }
+                       char *buf;
+                       switch (l2->attr){
+                               case EDG_WLL_QUERY_ATTR_JOBID:
+                               case EDG_WLL_QUERY_ATTR_PARENT:
+                                       GS(edg_wlc_JobIdUnparse(l2->value.j));
+                                       break;
+                               case EDG_WLL_QUERY_ATTR_DESTINATION:
+                               case EDG_WLL_QUERY_ATTR_LOCATION:
+                               case EDG_WLL_QUERY_ATTR_OWNER:
+                               case EDG_WLL_QUERY_ATTR_HOST:
+                               case EDG_WLL_QUERY_ATTR_INSTANCE:
+                               case EDG_WLL_QUERY_ATTR_JDL_ATTR:
+                               case EDG_WLL_QUERY_ATTR_NETWORK_SERVER:
+                                       GS(l2->value.c);
+                                       break;
+                               case EDG_WLL_QUERY_ATTR_STATUS:
+                                       if (l2->op == EDG_WLL_QUERY_OP_WITHIN)
+                                                asprintf(&buf, "%i and %i",
+                                                        edg_wll_StatToString((edg_wll_JobStatCode)l2->value.i), 
+                                                       edg_wll_StatToString((edg_wll_JobStatCode)l2->value2.i));
+                                       else
+                                               asprintf(&buf, "%i", edg_wll_StatToString((edg_wll_JobStatCode)l2->value.i));
+                                       GS(buf);
+                                       free(buf);
+                                       break;
+                               case EDG_WLL_QUERY_ATTR_DONECODE:
+                               case EDG_WLL_QUERY_ATTR_EXITCODE:
+                                       if (l2->op == EDG_WLL_QUERY_OP_WITHIN)
+                                               asprintf(&buf, "%i and %i",
+                                                        l2->value.i, l2->value2.i);
+                                       else
+                                               asprintf(&buf, "%i", l2->value.i);
+                                        GS(buf);
+                                        free(buf);
+                                       break;
+                               case EDG_WLL_QUERY_ATTR_EVENT_TYPE:
+                                       if (l2->op == EDG_WLL_QUERY_OP_WITHIN)
+                                               asprintf(&buf, "%s and %s", 
+                                                       edg_wll_EventToString((edg_wll_EventCode)l2->value.i),
+                                                       edg_wll_EventToString((edg_wll_EventCode)l2->value2.i));
+                                       else
+                                               asprintf(&buf, "%i", 
+                                                       edg_wll_EventToString((edg_wll_EventCode)l2->value.i));
+                                       GS(buf);
+                                       free(buf);
+                                        break;
+                               case EDG_WLL_QUERY_ATTR_USERTAG:
+                                       GS(l2->attr_id.tag);
+                                       break;
+                               case EDG_WLL_QUERY_ATTR_TIME:
+                               case EDG_WLL_QUERY_ATTR_STATEENTERTIME:
+                                case EDG_WLL_QUERY_ATTR_LASTUPDATETIME:
+                                       buf = ctime(&(l2->value.t.tv_sec));
+                                       if (l2->op == EDG_WLL_QUERY_OP_WITHIN){
+                                               buf[strlen(buf)-1] = 0; // cut out '\n'
+                                               asprintf(&buf, " and %s", ctime(&(l2->value2.t.tv_sec)));
+                                               GS(buf);
+                                       }
+                                       else
+                                               GS(buf);
+                                       free(buf);
+                                       break;
+                               case EDG_WLL_QUERY_ATTR_LEVEL:
+                                       if (l2->op == EDG_WLL_QUERY_OP_WITHIN)
+                                               asprintf(&buf, "%i and %i",
+                                                       l2->value.i, l2->value2.i);
+                                       else
+                                               asprintf(&buf, "%i", l2->value.i);
+                                       GS(buf);        
+                                       free(buf);
+                                       break;
+                               case EDG_WLL_QUERY_ATTR_SOURCE:
+                                       buf = edg_wll_SourceToString(l2->value.i);
+                                       GS(buf);
+                                       free(buf);
+                                       if (l2->op == EDG_WLL_QUERY_OP_WITHIN){
+                                               GS("and");
+                                               buf = edg_wll_SourceToString(l2->value2.i);
+                                               GS(buf);
+                                               free(buf);
+                                       }
+                                       break;
+                               case EDG_WLL_QUERY_ATTR_CHKPT_TAG:
+                                       //XXX: what kind of data is it?
+                                       break;
+                               case EDG_WLL_QUERY_ATTR_RESUBMITTED:
+                                       asprintf(&buf, "%i", l2->value.i);
+                                       GS(buf);
+                                        free(buf);
+                                       break;
+                               default:
+                                       assert(! "Unknown condition attribute!");
+                                       break;
+                       }
+                       if (! oneline)
+                               GS("\n");
+               }
+               if (oneline)
+                       GS(")");
+       }
+
+       *output = pomA;
+
+       return 0;
+}
+
diff --git a/org.glite.lb.server/src/cond_dump.h b/org.glite.lb.server/src/cond_dump.h
new file mode 100644 (file)
index 0000000..7a31251
--- /dev/null
@@ -0,0 +1,9 @@
+#ifndef GLITE_NOPTIF_DUMP_H
+#define GLITE_NOTIF_DUMP_H
+
+#include "lb_proto.h"
+
+int edg_wll_Condition_Dump(notifInfo *ni, char **output, int oneline);
+
+#endif /* GLITE_NOTIF_DUMP */
+
index a1c3c50..ce6baaa 100644 (file)
@@ -2,6 +2,7 @@
 
 #include "lb_html.h"
 #include "lb_proto.h"
+#include "cond_dump.h"
 
 #include "glite/lb/context-int.h"
 
@@ -9,6 +10,7 @@
 #include <stdio.h>
 #include <stdlib.h>
 #include <time.h>
+#include <assert.h>
 
 #ifdef __GNUC__
 #define UNUSED_VAR __attribute__((unused))
@@ -99,7 +101,7 @@ int edg_wll_UserNotifsToHTML(edg_wll_Context ctx UNUSED_VAR, char **notifids, ch
 
        int i = 0;
         while(notifids && notifids[i]){
-                asprintf(&pomA, "%s\t\t <li> <a href=\"/notif/%s\">%s</a>\r\n",
+                asprintf(&pomA, "%s\t\t <li> <a href=\"/NOTIF:%s\">%s</a>\r\n",
                                 pomB,
                                 notifids[i],
                                 notifids[i]
@@ -139,7 +141,7 @@ int edg_wll_UserNotifsToHTML(edg_wll_Context ctx UNUSED_VAR, char **notifids, ch
 }
 
 int edg_wll_NotificationToHTML(edg_wll_Context ctx UNUSED_VAR, notifInfo *ni, char **message){
-       char *pomA = NULL, *pomB, *flags;
+       char *pomA = NULL, *pomB, *flags, *cond;
 
 
        pomB = strdup("");
@@ -149,162 +151,14 @@ printf("flags %d - %s", ni->flags, flags);
        TR("Destination", "%s", ni->destination);
        TR("Valid until", "%s", ni->valid);
 
-/*     // Fake the ni->conditions content
-       ni->conditions = malloc(3*sizeof(*(ni->conditions)));
-       ni->conditions[0] = malloc(2*sizeof(*(ni->conditions[0])));
-       ni->conditions[0][0].attr = EDG_WLL_QUERY_ATTR_OWNER;
-       ni->conditions[0][0].op = EDG_WLL_QUERY_OP_EQUAL;
-       ni->conditions[0][0].value.c = strdup("fila");
-       ni->conditions[0][1].attr = EDG_WLL_QUERY_ATTR_UNDEF;
-       ni->conditions[1] = malloc(3*sizeof(*(ni->conditions[1])));
-       ni->conditions[1][0].attr = EDG_WLL_QUERY_ATTR_OWNER;
-        ni->conditions[1][0].op = EDG_WLL_QUERY_OP_EQUAL;
-        ni->conditions[1][0].value.c = strdup("fila");
-       ni->conditions[1][1].attr = EDG_WLL_QUERY_ATTR_OWNER;
-        ni->conditions[1][1].op = EDG_WLL_QUERY_OP_EQUAL;
-        ni->conditions[1][1].value.c = strdup("sauron");
-        ni->conditions[1][2].attr = EDG_WLL_QUERY_ATTR_UNDEF;
-       ni->conditions[2] = NULL;*/
-
-/*     edg_wll_QueryRec **l1;
-       edg_wll_QueryRec *l2;
-       for (l1 = ni->conditions; *l1; l1++){
-               if (l1 != ni->conditions)
-                       GS ("and");
-               l2 = *l1;
-               switch (l2->attr){
-                       case EDG_WLL_QUERY_ATTR_JOBID: GS("jobId");
-                               break;
-                       case EDG_WLL_QUERY_ATTR_OWNER: GS("owner");
-                               break;
-                       case EDG_WLL_QUERY_ATTR_STATUS: GS("status");
-                               break;
-                       case EDG_WLL_QUERY_ATTR_LOCATION: GS("location");
-                               break;
-                        case EDG_WLL_QUERY_ATTR_DESTINATION: GS("destination");
-                               break;
-                       case EDG_WLL_QUERY_ATTR_DONECODE: GS("donecode");
-                               break;
-                       case EDG_WLL_QUERY_ATTR_USERTAG: GS("usertag");
-                               break;
-                       case EDG_WLL_QUERY_ATTR_TIME: GS("time");
-                               break;
-                       case EDG_WLL_QUERY_ATTR_LEVEL: GS("level");
-                               break;
-                       case EDG_WLL_QUERY_ATTR_HOST: GS("host");
-                               break;
-                        case EDG_WLL_QUERY_ATTR_SOURCE: GS("source");
-                               break;
-                        case EDG_WLL_QUERY_ATTR_INSTANCE: GS("instance");
-                               break;
-                        case EDG_WLL_QUERY_ATTR_EVENT_TYPE: GS("eventtype");
-                               break;
-                       case EDG_WLL_QUERY_ATTR_CHKPT_TAG: GS("chkpttag");
-                               break;
-                       case EDG_WLL_QUERY_ATTR_RESUBMITTED: GS("resubmitted");
-                               break;
-                       case EDG_WLL_QUERY_ATTR_PARENT: GS("parent_job");
-                               break;
-                       case EDG_WLL_QUERY_ATTR_EXITCODE: GS("exitcode");
-                               break;
-                       case EDG_WLL_QUERY_ATTR_JDL_ATTR: GS("jdl");
-                               break;
-                       case EDG_WLL_QUERY_ATTR_STATEENTERTIME: GS("stateentertime");
-                               break;
-                       case EDG_WLL_QUERY_ATTR_LASTUPDATETIME: GS("lastupdatetime");
-                               break;
-                       case EDG_WLL_QUERY_ATTR_NETWORK_SERVER: GS("networkserver");
-                               break;
-               }
-               for (l2 = *l1; l2->attr; l2++){
-                       if (l2 != *l1) GS ("or");
-                       switch(l2->op){
-                               case EDG_WLL_QUERY_OP_EQUAL: GS("=");
-                                       break;
-                               case EDG_WLL_QUERY_OP_LESS: GS ("<");
-                                       break;
-                               case EDG_WLL_QUERY_OP_GREATER: GS ("<");
-                                       break;
-                               case EDG_WLL_QUERY_OP_WITHIN: GS ("within");
-                                       break;
-                               case EDG_WLL_QUERY_OP_UNEQUAL: GS ("!=");
-                                       break;
-                               case EDG_WLL_QUERY_OP_CHANGED: GS ("changed");
-                                       break;
-                       }
-                       char *buf;
-                       switch (l2->attr){
-                               case EDG_WLL_QUERY_ATTR_JOBID:
-                                       GS(edg_wlc_JobIdUnparse(l2->value.j));
-                                       break;
-                               case EDG_WLL_QUERY_ATTR_DESTINATION:
-                               case EDG_WLL_QUERY_ATTR_LOCATION:
-                               case EDG_WLL_QUERY_ATTR_OWNER:
-                                       GS(l2->value.c);
-                                       break;
-                               case EDG_WLL_QUERY_ATTR_STATUS:
-                                       //XXX: need interpretation!
-                                       asprintf(&buf, "%i", l2->value.i);
-                                       GS(buf);
-                                       free(buf);
-                                       break;
-                               case EDG_WLL_QUERY_ATTR_DONECODE:
-                                       //XXX: need interpretation!
-                                        asprintf(&buf, "%i", l2->value.i);
-                                        GS(buf);
-                                        free(buf);
-                                       break;
-                               case EDG_WLL_QUERY_ATTR_USERTAG:
-                                       GS(l2->attr_id.tag);
-                                       break;
-                               case EDG_WLL_QUERY_ATTR_TIME:
-                                       buf = ctime(&(l2->value.t.tv_sec));
-                                       if (l2->op == EDG_WLL_QUERY_OP_WITHIN){
-                                               buf[strlen(buf)-1] = 0; // cut out '\n'
-                                               asprintf(&buf, " and %s", ctime(&(l2->value2.t.tv_sec)));
-                                               GS(buf);
-                                       }
-                                       else
-                                               GS(buf);
-                                       free(buf);
-                                       break;
-                               case EDG_WLL_QUERY_ATTR_LEVEL:
-                                       break;
-                               case EDG_WLL_QUERY_ATTR_HOST:
-                                       break;
-                               case EDG_WLL_QUERY_ATTR_SOURCE:
-                                       break;
-                               case EDG_WLL_QUERY_ATTR_INSTANCE:
-                                       break;
-                               case EDG_WLL_QUERY_ATTR_EVENT_TYPE:
-                                       break;
-                               case EDG_WLL_QUERY_ATTR_CHKPT_TAG:
-                                       break;
-                               case EDG_WLL_QUERY_ATTR_RESUBMITTED:
-                                       break;
-                               case EDG_WLL_QUERY_ATTR_PARENT:
-                                       break;
-                               case EDG_WLL_QUERY_ATTR_EXITCODE:
-                                       break;
-                               case EDG_WLL_QUERY_ATTR_JDL_ATTR:
-                                       break;
-                               case EDG_WLL_QUERY_ATTR_STATEENTERTIME:
-                                       break;
-                               case EDG_WLL_QUERY_ATTR_LASTUPDATETIME:
-                                       break;
-                               case EDG_WLL_QUERY_ATTR_NETWORK_SERVER:
-                                       break;
-                       }
-                       GS("\n");
-               }
-       }*/
-
-       char *cond = xmlToHTML(ni->conditions_text);
-       asprintf(&pomA, "%s<h3>Conditions</h3>\r\n<pre>%s</pre>\r\n",
-               pomB, cond);
+       if (! edg_wll_Condition_Dump(ni, &cond, 0)){
+               asprintf(&pomA, "%s<h3>Conditions</h3>\r\n<pre>%s</pre>\r\n",
+                       pomB, cond);
+               free(pomB);
+               pomB = pomA;
+       }
        free(cond);
-       free(pomB);
-       pomB = pomA;
+
        TR("Flags", "%s", flags);
        free(flags);
 
index 23bd87d..ac1d0e1 100644 (file)
@@ -6,10 +6,13 @@
 #include "glite/lb/context.h"
 #include "glite/lb/events.h"
 #include "glite/lb/jobstat.h"
+#include "lb_proto.h"
 
 int edg_wll_QueryToHTML(edg_wll_Context,edg_wll_Event *,char **);
 int edg_wll_JobStatusToHTML(edg_wll_Context, edg_wll_JobStat, char **);
 int edg_wll_UserInfoToHTML(edg_wll_Context, edg_wlc_JobId *, char **);
+int edg_wll_UserNotifsToHTML(edg_wll_Context ctx, char **notifids, char **message);
+int edg_wll_NotificationToHTML(edg_wll_Context ctx, notifInfo *ni, char **message);
 char *edg_wll_ErrorToHTML(edg_wll_Context,int);
 
 #endif /* GLITE_LB_HTML_H */
index 6b927f8..f171438 100644 (file)
@@ -266,7 +266,7 @@ static int getNotifInfo(edg_wll_Context ctx, char *notifId, notifInfo *ni){
        return 0;
 
 err:
-       return  edg_wll_Error(ctx, NULL, NULL);
+       return  -1;
 }
 
 static void freeNotifInfo(notifInfo *ni){
@@ -531,12 +531,6 @@ edg_wll_ErrorCode edg_wll_Proto(edg_wll_Context ctx,
                        
                        flags = (requestPTR[1]=='?') ? edg_wll_string_to_stat_flags(requestPTR + 2) : 0;
 
-                       //char **notifids = NULL;
-                       char *can_peername = edg_wll_gss_normalize_subj(ctx->peerName, 0);
-                       /*char *userid = strmd5(can_peername, NULL);
-                       free(can_peername);
-                       getUserNotifications(ctx, userid, &notifids);*/
-
 // FIXME: edg_wll_UserJobs should take flags as parameter
                        switch (edg_wll_UserJobsServer(ctx,&jobsOut,NULL)) {
                                case 0: if (text)
@@ -562,9 +556,9 @@ edg_wll_ErrorCode edg_wll_Proto(edg_wll_Context ctx,
 
        /* GET /[jobId]: Job Status */
                else if (*requestPTR=='/' 
-                       && strncmp(requestPTR, "/notif", strlen("/notif"))
-                       && *(requestPTR+strlen("/notif")-1) != '/'
-                       && !isspace(*(requestPTR+strlen("/notif")-1))) {
+                       && strncmp(requestPTR, "/NOTIF", strlen("/NOTIF"))
+                       && *(requestPTR+strlen("/NOTIF")-1) != ':'
+                       && !isspace(*(requestPTR+strlen("/NOTIF")-1))) {
                        edg_wlc_JobId jobId = NULL;
                        char *pom1,*fullid = NULL;
                        edg_wll_JobStat stat;
@@ -607,10 +601,9 @@ edg_wll_ErrorCode edg_wll_Proto(edg_wll_Context ctx,
                        free(fullid);
                        edg_wlc_JobIdFree(jobId);
                        edg_wll_FreeStatus(&stat);
-       /*GET /notif[/]: All user's notifications*/
-               } else if (strncmp(requestPTR, "/notif", strlen("/notif")) == 0 
-                       && (*(requestPTR+strlen("/notif/")-1) == '/' && isspace(*(requestPTR+strlen("/notif/"))))
-                       || isspace(*(requestPTR+strlen("/notif/")-1))){
+       /*GET /NOTIF: All user's notifications*/
+               } else if (strncmp(requestPTR, "/NOTIF", strlen("/NOTIF")) == 0                         && (isspace(*(requestPTR+strlen("/NOTIF")))
+                       || isspace(*(requestPTR+strlen("/NOTIF:"))))){
                        char **notifids = NULL;
                        char *can_peername = edg_wll_gss_normalize_subj(ctx->peerName, 0);
                         char *userid = strmd5(can_peername, NULL);
@@ -622,15 +615,17 @@ edg_wll_ErrorCode edg_wll_Proto(edg_wll_Context ctx,
                                edg_wll_UserNotifsToHTML(ctx, notifids, &message);
                         else ret = HTTP_OK;
 
-       /*GET /notif/[notifId]: Notification info*/
-               } else if (strncmp(requestPTR, "/notif/", strlen("/notif/")) == 0){
+       /*GET /NOTIF:[notifId]: Notification info*/
+               } else if (strncmp(requestPTR, "/NOTIF:", strlen("/NOTIF:")) == 0){
                        notifInfo ni;
                        char *pomCopy, *pom;
                        pomCopy = strdup(requestPTR + 1);
                         for (pom=pomCopy; *pom && !isspace(*pom); pom++);
                         *pom = 0;
-                       getNotifInfo(ctx, strrchr(pomCopy, '/')+1, &ni);
-                       //TODO handle error
+                       if (getNotifInfo(ctx, strrchr(pomCopy, ':')+1, &ni)){
+                               ret = HTTP_NOTFOUND;
+                               goto err;
+                       }
                        free(pomCopy);
 
                        if (text)
index d69d18d..e0b1c9b 100644 (file)
@@ -2,6 +2,7 @@
 
 #include "lb_text.h"
 #include "lb_proto.h"
+#include "cond_dump.h"
 
 #include "glite/lb/context-int.h"
 #include "glite/lb/xml_conversions.h"
@@ -55,36 +56,6 @@ int edg_wll_QueryToText(edg_wll_Context ctx UNUSED_VAR, edg_wll_Event *eventsOut
        return -1;
 }
 
-/* construct Message-Body of Response-Line for edg_wll_UserJobs */
-/*int edg_wll_UserJobsToText(edg_wll_Context ctx, edg_wlc_JobId *jobsOut, char **message)
-{
-       char *a, *b;
-       int i = 0;
-       b = strdup("");
-
-       while (jobsOut[i]){
-               char *chid = edg_wlc_JobIdUnparse(jobsOut[i]);
-
-               if (i == 0)
-                       asprintf(&a, "%s%s", b, chid);
-               else
-                       asprintf(&a, "%s,%s", b, chid);
-
-               free(chid);
-               free(b);
-               b = a;
-               i++;
-       }
-
-       asprintf(&a, "User_jobs=%s\n"
-                    "User_subject=%s\n",
-               b, ctx->peerName ? ctx->peerName: "<anonymous>");
-
-        *message = a;
-
-        return 0;
-}*/
-
 #define TR(name,type,field) \
         if (field) { \
                 asprintf(&a,"%s%s=" type "\n", \
@@ -146,19 +117,21 @@ int edg_wll_UserNotifsToText(edg_wll_Context ctx, char **notifids, char **messag
                asprintf(&a, "User_notifications=%s\n", b);
 
        *message = a;
+
+       return 0;
 }
 
 int edg_wll_NotificationToText(edg_wll_Context ctx UNUSED_VAR, notifInfo *ni, char **message){
-       char *a = NULL, *b;
+       char *a = NULL, *b, *cond, *flags;
        b = strdup("");
 
        TR("Notif_id", "%s", ni->notifid);
        TR("Destination", "%s", ni->destination);
        TR("Valid_until", "%s", ni->valid);
-       char *cond = escape_text(ni->conditions_text);
-       TR("Conditions", "%s", cond);
+       if (! edg_wll_Condition_Dump(ni, &cond, 1))
+               TR("Conditions", "%s", cond);
        free(cond);
-       char *flags = edg_wll_stat_flags_to_string(ni->flags);
+       flags = edg_wll_stat_flags_to_string(ni->flags);
        TR("Flags", "%s", flags);
        free(flags);
 
@@ -184,42 +157,42 @@ int edg_wll_JobStatusToText(edg_wll_Context ctx UNUSED_VAR, edg_wll_JobStat stat
        TR("Status","%s",(chstat = edg_wll_StatToString(stat.state)));
        free(chstat);
        TR("owner","%s",stat.owner);
-       TR("Condor_Id","%s",stat.condorId);
-       TR("Globus_Id","%s",stat.globusId);
-       TR("Local_Id","%s",stat.localId);
-       TR("Reason","%s",stat.reason);
+       TR("condorId","%s",stat.condorId);
+       TR("globusId","%s",stat.globusId);
+       TR("localId","%s",stat.localId);
+       TR("reason","%s",stat.reason);
        if ( (stat.stateEnterTime.tv_sec) || (stat.stateEnterTime.tv_usec) ) {
                time_t  time = stat.stateEnterTime.tv_sec;
                //TR("State_entered","%s",ctime(&time));
-               asprintf(&a, "%sState_entered=%s", b, ctime(&time));
+               asprintf(&a, "%sstateEnterTime=%s", b, ctime(&time));
                free(b); b = a;
        }
         if ( (stat.lastUpdateTime.tv_sec) || (stat.lastUpdateTime.tv_usec) ) {
                time_t  time = stat.lastUpdateTime.tv_sec;
                //TR("Last_update","%s",ctime(&time));
-               asprintf(&a, "%sLast_update=%s", b, ctime(&time));
+               asprintf(&a, "%slastUpdateTime=%s", b, ctime(&time));
                 free(b); b = a;
        }
-       TR("Expect_update","%s",stat.expectUpdate ? "YES" : "NO");
-       TR("Expect_update_from","%s",stat.expectFrom);
-       TR("Location","%s",stat.location);
-       TR("Destination","%s",stat.destination);
-       TR("Cancelling","%s",stat.cancelling>0 ? "YES" : "NO");
+       TR("expectUpdate","%s",stat.expectUpdate ? "YES" : "NO");
+       TR("expectFrom","%s",stat.expectFrom);
+       TR("location","%s",stat.location);
+       TR("destination","%s",stat.destination);
+       TR("cancelling","%s",stat.cancelling>0 ? "YES" : "NO");
        if (stat.cancelReason != NULL) {
-               TR("Cancel_reason","%s",stat.cancelReason);
+               TR("cancelReason","%s",stat.cancelReason);
        }
-       TR("CPU_time","%d",stat.cpuTime);
+       TR("cpuTime","%d",stat.cpuTime);
 
        
-       TR("Done_code","%d",stat.done_code);
-       TR("Exit_code","%d",stat.exit_code);
+       TR("done_code","%d",stat.done_code);
+       TR("exit_code","%d",stat.exit_code);
 
         if (stat.jdl){
                char* my_jdl = escape_text(stat.jdl);
-               asprintf(&jdl,"Job_description=%s\n", my_jdl);
+               asprintf(&jdl,"jdl=%s\n", my_jdl);
                free(my_jdl);
        }
-       if (stat.rsl) asprintf(&rsl,"RSL=%s\n", stat.rsl);
+       if (stat.rsl) asprintf(&rsl,"rsl=%s\n", stat.rsl);
 
         asprintf(&a, "Job=%s\n"
                        "%s"
index 2b65834..c72de74 100644 (file)
@@ -4,10 +4,13 @@
 #include "glite/lb/context.h"
 #include "glite/lb/events.h"
 #include "glite/lb/jobstat.h"
+#include "lb_proto.h"
 
 int edg_wll_QueryToText(edg_wll_Context,edg_wll_Event *,char **);
 int edg_wll_JobStatusToText(edg_wll_Context, edg_wll_JobStat, char **);
 int edg_wll_UserInfoToText(edg_wll_Context, edg_wlc_JobId *, char **);
+int edg_wll_UserNotifsToText(edg_wll_Context ctx, char **notifids, char **message);
+int edg_wll_NotificationToText(edg_wll_Context ctx, notifInfo *ni, char **message);
 char *edg_wll_ErrorToText(edg_wll_Context,int);
 
 #endif /* GLITE_LB_TEXT */