try insert into DB in example (error during connection :(
authorMiloš Mulač <mulac@civ.zcu.cz>
Fri, 14 Oct 2005 13:01:11 +0000 (13:01 +0000)
committerMiloš Mulač <mulac@civ.zcu.cz>
Fri, 14 Oct 2005 13:01:11 +0000 (13:01 +0000)
org.glite.jp.index/Makefile
org.glite.jp.index/examples/jpis-test.c
org.glite.jp.index/src/context.c

index 75c1334..4ae02a0 100644 (file)
@@ -57,7 +57,7 @@ SRCS:= conf.c bones_server.c soap_ops.c soap_ps_calls.c \
        ${is_prefix}ServerLib.c \
        ${ps_prefix}ClientLib.c ${ps_prefix}C.c \
 
-EXA_SRCS:=jpis-test.c ${is_prefix}C.c ${is_prefix}Client.c context.c
+EXA_SRCS:=jpis-test.c ${is_prefix}C.c ${is_prefix}Client.c context.c db_ops.c conf.c
 
 OBJS:=${SRCS:.c=.o}
 EXA_OBJS:=${EXA_SRCS:.c=.o}
@@ -87,7 +87,7 @@ ${daemon}: ${OBJS}
        ${LINK} -o $@ -export-dynamic ${OBJS} ${BONESLIB} ${TRIOLIB} ${COMMONLIB} ${GSOAPLIB} ${GLOBUS_LIBS} ${MYSQLIB} ${SRVCOMMONLIB}
 
 ${example}: ${EXA_OBJS}
-       ${LINK} -o $@ ${EXA_OBJS} ${GSOAPLIB} ${GLOBUS_LIBS} ${COMMONLIB} ${TRIOLIB}
+       ${LINK} -o $@ ${EXA_OBJS} ${GSOAPLIB} ${GLOBUS_LIBS} ${COMMONLIB} ${TRIOLIB} ${MYSQLIB} ${SRVCOMMONLIB}
 
 jpis-db-internal: jpis-db-internal.o db_ops.o conf.o context.o
        ${LINK} -o $@ $+ ${COMMONLIB} ${SRVCOMMONLIB} ${GLOBUS_LIBS}
index d0842dc..86a1451 100644 (file)
@@ -8,8 +8,9 @@
 
 #include "jpis_H.h"
 #include "jpis_.nsmap"
+#include "db_ops.h"
+#include "conf.h"
 
-//#include "jptype_map.h"
 
 #include "soap_version.h"
 #if GSOAP_VERSION <= 20602
 #endif
 
 
+/* insert simulating FeedIndex call */
+#define INSERT "insert into feeds value ('93', '12345', '8', '0' , 'http://localhost:8901', '2005-10-14 10:48:27', 'COND2');" 
+
+
        
 static int check_fault(struct soap *soap,int err) {
        struct SOAP_ENV__Detail *detail;
@@ -72,7 +77,7 @@ int main(int argc,char *argv[])
        soap_set_namespaces(soap, jpis__namespaces);
 
        soap_register_plugin(soap,glite_gsplugin);
-goto query;
+//goto query;
        // test calls of server functions
        {
        // this call is issued by JPPS
@@ -83,8 +88,32 @@ goto query;
                memset(&in, 0, sizeof(in));
                memset(&out, 0, sizeof(out));
 
-//XXX : need to register feed with feedid in.feedId in DB
-//this one work only because such feed in conf.c (umbar)
+               //XXX : need to register feed with feedid in.feedId in DB
+               //      this one work only because such feed in conf.c (umbar)
+               {
+                       glite_jp_db_stmt_t      stmt;
+                       glite_jp_context_t      ctx;
+                       glite_jpis_context_t    isctx;
+                       glite_jp_is_conf        *conf;
+                       
+
+                       glite_jp_init_context(&ctx);
+                       glite_jp_get_conf(0, NULL, NULL, &conf);
+                       glite_jpis_init_context(&isctx, ctx, conf);
+                       if (glite_jpis_init_db(isctx) != 0) {
+                               fprintf(stderr, "Connect DB failed: %s (%s)\n", 
+                                       ctx->error->desc, ctx->error->source);
+                               goto end;
+                       }
+                       
+                       if (glite_jp_db_execstmt(isctx,
+                               INSERT, &stmt) < 0) goto end;
+               end:
+                       glite_jpis_free_context(isctx);
+                       glite_jp_free_context(ctx);
+                       glite_jp_free_conf(conf);
+               }
+
                //in.feedId = soap_strdup(soap, str2md5("http://localhost:8901"));
                in.feedId = soap_strdup(soap, "12345");
                in.feedDone = false_;
index 68a856c..092fe28 100644 (file)
@@ -15,7 +15,7 @@ int glite_jpis_init_context(glite_jpis_context_t *isctx, glite_jp_context_t jpct
                (*isctx)->jpctx = jpctx;
                (*isctx)->conf = conf;
                globus_libc_gethostname(hname, sizeof hname);
-               asprintf(&(*isctx)->hname, "https://%s:%s", hname, conf->port ? conf->port : GLITE_JPIS_DEFAULT_PORT_STR);
+               asprintf(&(*isctx)->hname, "https://%s:%s", hname, (conf && conf->port) ? conf->port : GLITE_JPIS_DEFAULT_PORT_STR);
                return 0;
        } else return ENOMEM;
 }