add notification flags to DB schema
authorMiloš Mulač <mulac@civ.zcu.cz>
Wed, 22 Oct 2008 09:39:40 +0000 (09:39 +0000)
committerMiloš Mulač <mulac@civ.zcu.cz>
Wed, 22 Oct 2008 09:39:40 +0000 (09:39 +0000)
- store it in DB and return back to client notification info requested
- no server implementation yet

org.glite.lb.common/interface/xml_conversions.h
org.glite.lb.server/config/glite-lb-dbsetup.sql
org.glite.lb.server/config/glite-lb-migrate_db2version20
org.glite.lb.server/src/lb_html.c
org.glite.lb.server/src/lb_proto.c
org.glite.lb.server/src/lb_proto.h
org.glite.lb.server/src/lb_text.c
org.glite.lb.server/src/notification.c

index 6517d6b..2c9910d 100644 (file)
@@ -3,6 +3,8 @@
 
 #ident "$Header$"
 
+#include <expat.h>
+
 #include "glite/jobid/cjobid.h"
 
 #ifdef BUILDING_LB_COMMON
index 449d0b8..72513ba 100644 (file)
@@ -113,6 +113,7 @@ create table notif_registrations (
        valid           datetime        not null,
        userid          char(32)        binary not null,
        conditions      mediumblob      not null,
+       flags           int             not null,
 
        `STD_owner`     varchar(200)    null,
        `STD_network_server`    varchar(200)    null,
index 54143e1..b28f9da 100644 (file)
@@ -107,6 +107,8 @@ create table events_flesh (\
 
 
 # notif_registrations UPDATE
+mysql -u lbserver $DB_NAME -e "ALTER TABLE notif_registrations ADD flags int not null"
+
 mysql -u lbserver $DB_NAME -e "ALTER TABLE notif_registrations ADD STD_owner varchar(200) null" && \
 mysql -u lbserver $DB_NAME -e "ALTER TABLE notif_registrations ADD index(STD_owner)"
 
index d4bdb1f..ceab196 100644 (file)
@@ -126,8 +126,12 @@ int edg_wll_UserInfoToHTML(edg_wll_Context ctx UNUSED_VAR, edg_wlc_JobId *jobsOu
         }
 
 int edg_wll_NotificationToHTML(edg_wll_Context ctx UNUSED_VAR, notifInfo *ni, char **message){
-       char *pomA, *pomB;
+       char *pomA, *pomB, *flags;
+
+
        pomB = strdup("");
+       flags = edg_wll_stat_flags_to_string(ni->flags);
+printf("flags %d - %s", ni->flags, flags);
 
        TR("Destination", "%s", ni->destination);
        TR("Valid until", "%s", ni->valid);
@@ -137,6 +141,8 @@ int edg_wll_NotificationToHTML(edg_wll_Context ctx UNUSED_VAR, notifInfo *ni, ch
        free(cond);
        free(pomB);
        pomB = pomA;
+       TR("Flags", "%s", flags);
+       free(flags);
        if (ni->JDL_VirtualOrganisation && ni->JDL_VirtualOrganisation[0])
                TR("JDL VirtualOrganisation", "%s", ni->JDL_VirtualOrganisation);
        if (ni->STD_owner && ni->STD_owner[0])
@@ -145,7 +151,7 @@ int edg_wll_NotificationToHTML(edg_wll_Context ctx UNUSED_VAR, notifInfo *ni, ch
                TR("STD network server", "%s", ni->STD_network_server);
 
        asprintf(&pomA, "<html>\r\n\t<body>\r\n"
-               "<h2>Norification %s</h2>\r\n"
+               "<h2>Notification %s</h2>\r\n"
                "<table halign=\"left\">%s</table>"
                "\t</body>\r\n</html>",
                ni->notifid, pomB);
index d90447b..4d2c041 100644 (file)
@@ -243,9 +243,9 @@ err:
 static int getNotifInfo(edg_wll_Context ctx, char *notifId, notifInfo *ni){
        char *q = NULL;
         glite_lbu_Statement notif = NULL;
-       char *notifc[6] = {NULL, NULL, NULL, NULL, NULL, NULL};
+       char *notifc[7] = {NULL, NULL, NULL, NULL, NULL, NULL, NULL};
 
-       trio_asprintf(&q, "select destination, valid, conditions, "
+       trio_asprintf(&q, "select destination, valid, conditions, flags, "
                "JDL_VirtualOrganisation, STD_owner, STD_network_server "
                 "from notif_registrations "
                 "where notifid='%s'",
@@ -258,15 +258,14 @@ static int getNotifInfo(edg_wll_Context ctx, char *notifId, notifInfo *ni){
                ni->destination = notifc[0];
                ni->valid = notifc[1];
                ni->conditions = notifc[2];
-               ni->JDL_VirtualOrganisation = notifc[3];
-               ni->STD_owner = notifc[4];
-               ni->STD_network_server = notifc[5];
+               ni->flags = atoi(notifc[3]);
+               ni->JDL_VirtualOrganisation = notifc[4];
+               ni->STD_owner = notifc[5];
+               ni->STD_network_server = notifc[6];
        }
        else 
                goto err;
 
-       printf("%s\n%s\n", ni->destination, ni->valid);
-
        return 0;
 
 err:
@@ -607,7 +606,7 @@ edg_wll_ErrorCode edg_wll_Proto(edg_wll_Context ctx,
                        free(fullid);
                        edg_wlc_JobIdFree(jobId);
                        edg_wll_FreeStatus(&stat);
-       /*GET /notif/[notifId]: Norification info*/
+       /*GET /notif/[notifId]: Notification info*/
                } else if (strncmp(requestPTR, "/notif/", strlen("/notif/")) == 0){
                        notifInfo ni;
                        char *pomCopy, *pom;
index 412f931..b726f6b 100644 (file)
@@ -25,6 +25,7 @@ typedef struct _notifInfo{
         char *destination;
         char *valid;
         char *conditions;
+       int  flags;
         char *JDL_VirtualOrganisation;
         char *STD_owner;
         char *STD_network_server;
index 0a9b5ee..fcbb71d 100644 (file)
@@ -4,6 +4,7 @@
 #include "lb_proto.h"
 
 #include "glite/lb/context-int.h"
+#include "glite/lb/xml_conversions.h"
 #include "glite/lbu/trio.h"
 #include "glite/lbu/db.h"
 
@@ -141,20 +142,29 @@ int edg_wll_UserInfoToText(edg_wll_Context ctx, edg_wlc_JobId *jobsOut, char **n
 int edg_wll_NotificationToText(edg_wll_Context ctx UNUSED_VAR, notifInfo *ni, char **message){
        char *a = NULL, *b = NULL;
        asprintf(&a, "Notif_id=%s\n", ni->notifid);
-       asprintf(&b, "%sDestination=%s\n", a, ni->destination);
-       asprintf(&a, "%sValid_until=%s\n", b, ni->valid);
+       asprintf(&b, "%sDestination=%s\n", a, ni->destination); free(a);
+       asprintf(&a, "%sValid_until=%s\n", b, ni->valid); free(b);
        char *cond = escape_text(ni->conditions);
-       asprintf(&b, "%sConditions=%s\n", a, cond);
+       asprintf(&b, "%sConditions=%s\n", a, cond); free(a);
        free(cond);
-       a = b;
-       if (ni->JDL_VirtualOrganisation && ni->JDL_VirtualOrganisation[0])
-               asprintf(&a, "%sJDL_VirtualOrganisation=%s\n", b, ni->JDL_VirtualOrganisation);
+       char *flags = edg_wll_stat_flags_to_string(ni->flags);
+       asprintf(&a, "%sFlags=%s\n", b, flags); free(b);
+       free(flags);
        b = a;
-       if (ni->STD_owner && ni->STD_owner[0])
+       if (ni->JDL_VirtualOrganisation && ni->JDL_VirtualOrganisation[0]) {
+               asprintf(&a, "%sJDL_VirtualOrganisation=%s\n", b, ni->JDL_VirtualOrganisation); 
+               free(b);
+       }
+       b = a;
+       if (ni->STD_owner && ni->STD_owner[0]) {
                asprintf(&a, "%sSTD_owner=%s\n", b, ni->STD_owner);
+               free(b);
+       }
        b = a;
-       if (ni->STD_network_server && ni->STD_network_server[0])
-               asprintf(&a, "%sSTD_network_server=%s\n", b, ni->STD_network_server);
+       if (ni->STD_network_server && ni->STD_network_server[0]) {
+               asprintf(&a, "%sSTD_network_server=%s\n", b, ni->STD_network_server); 
+               free(b);
+       }
        *message = a;
 
        return 0;
index 21da94f..c495381 100644 (file)
@@ -115,9 +115,9 @@ int edg_wll_NotifNewServer(
                /*      Format DB insert statement
                 */
                trio_asprintf(&q,
-                                       "insert into notif_registrations(notifid,destination,valid,userid,conditions) "
-                                       "values ('%|Ss','%|Ss',%s,'%|Ss', '<and>%|Ss</and>')",
-                                       nid_s, addr_s? addr_s: address_override, time_s, owner, xml_conds);
+                                       "insert into notif_registrations(notifid,destination,valid,userid,conditions,flags) "
+                                       "values ('%|Ss','%|Ss',%s,'%|Ss', '<and>%|Ss</and>', '%d')",
+                                       nid_s, addr_s? addr_s: address_override, time_s, owner, xml_conds, flags);
 
                if ( edg_wll_ExecSQL(ctx, q, NULL) < 0 )
                        goto rollback;