- new operation for plugins has been added -- it can process file when it is commited
authorJiří Filipovič <fila@ics.muni.cz>
Fri, 26 Jan 2007 15:48:00 +0000 (15:48 +0000)
committerJiří Filipovič <fila@ics.muni.cz>
Fri, 26 Jan 2007 15:48:00 +0000 (15:48 +0000)
org.glite.jp.primary/Makefile
org.glite.jp.primary/interface/file_plugin.h
org.glite.jp.primary/src/classad_plugin.c
org.glite.jp.primary/src/sandbox_plugin.c
org.glite.jp.primary/src/soap_ops.c

index 8fd9074..fd3fad8 100644 (file)
@@ -56,7 +56,7 @@ ps_prefix:=jpps_
 is_prefix:=jpis_
 sample_jobs:=sample_job_aborted  sample_job_cleared  sample_job_tagged_done  sample_job_waiting
 
-plugins:=glite-jp-tags.la glite-jp-ftpdauth.la glite-jp-classad.la glite-jp-sandbox.la
+plugins:=glite-jp-ftpdauth.la glite-jp-classad.la glite-jp-sandbox.la
 
 HDRS_I=file_plugin.h
 HDRS_S=builtin_plugins.h backend.h feed.h
@@ -64,6 +64,7 @@ HDRS_S=builtin_plugins.h backend.h feed.h
 SRCS:= bones_server.c soap_ops.c \
        new_ftp_backend.c mysql.c file_plugin.c \
        feed.c authz.c attrs.c\
+       tags.c\
        is_client.c \
        soap_switch.c
 
index dba7303..6959c5e 100644 (file)
@@ -25,6 +25,9 @@ typedef struct _glite_jpps_fplug_op_t {
 /** Close the file. Free data associated to a handle */
        int     (*close)(void *fpctx,void *handle);
 
+/** "Preprocess" the file -- this function is called once after the file is commited */
+       int     (*filecom)(void *fpctx,void *handle);
+
 /** Retrieve value(s) of an attribute.
 \param[in] fpctx       Plugin context.
 \param[in] handle      Handle of the opened file.
index b8baad7..da9e559 100644 (file)
@@ -37,6 +37,7 @@ static int classad_query(void *fpctx, void *handle, const char *ns, const char *
 static int classad_open(void *fpctx, void *bhandle, const char *uri, void **handle);
 static int classad_open_str(void *fpctx, const char *str, const char *uri, const char *ns, void **handle);
 static int classad_close(void *fpctx, void *handle);
+static int classad_filecom(void *fpctx, void *handle);
 
 int init(glite_jp_context_t ctx, glite_jpps_fplug_data_t *data) {
        data->fpctx = ctx;
@@ -54,6 +55,7 @@ int init(glite_jp_context_t ctx, glite_jpps_fplug_data_t *data) {
        data->ops.close = classad_close;
        data->ops.attr  = classad_query;
        data->ops.open_str = classad_open_str;
+       data->ops.filecom = classad_filecom;
 
 #ifdef PLUGIN_DEBUG
         fprintf(stderr,"classad_plugin: init OK\n");
@@ -199,4 +201,8 @@ static int classad_query(void *fpctx,void *handle, const char* ns, const char *a
                return glite_jp_stack_error(ctx,&err);
        }
 }
+
+static int classad_filecom(void *fpctx, void *handle){
+       return -1;
+}
  
index b13afe7..6219247 100644 (file)
@@ -37,7 +37,7 @@ static struct {
 static int sandbox_open(void *,void *,const char *uri,void **);
 static int sandbox_close(void *,void *);
 static int sandbox_attr(void *,void *,const char*,const char *,glite_jp_attrval_t **);
-
+static int sandbox_filecom(void *,void *);
 
 int init(glite_jp_context_t ctx, glite_jpps_fplug_data_t *data)
 {
@@ -57,6 +57,7 @@ int init(glite_jp_context_t ctx, glite_jpps_fplug_data_t *data)
        data->ops.open = sandbox_open;
        data->ops.close = sandbox_close;
        data->ops.attr = sandbox_attr;
+       data->ops.filecom = sandbox_filecom;
        
        printf("sandbox_plugin: URI: \"%s\"\n",GLITE_JP_FILETYPE_ISB);
 
@@ -187,3 +188,7 @@ static int sandbox_attr(void *fpctx,void *handle,const char *ns,const char *attr
        return glite_jp_stack_error(ctx,&err);
 }
 
+static int sandbox_filecom(void *fpctx,void *handle){
+       return -1;
+}
+
index 40b9cea..ea1970b 100644 (file)
@@ -182,6 +182,27 @@ SOAP_FMAC5 int SOAP_FMAC6 __jpsrv__CommitUpload(
        /* XXX: ignore errors but don't fail silenty */
        glite_jpps_match_file(ctx,job,class,name);
 
+       // apply plugins to commited file
+        glite_jpps_fplug_data_t *pd;
+       int i, j;
+       void *beh, *ph;
+        if (ctx->plugins)
+                for (i = 0; ctx->plugins[i]; i++) {
+                        pd = ctx->plugins[i];
+                        if (pd->classes)
+                                for (j = 0; pd->classes[j]; j++)
+                                       if (strcmp(class, pd->classes[j]) == 0){
+                                               if (! glite_jppsbe_open_file(ctx,job,class, name, O_RDONLY, &beh)) {
+                                                       if (!pd->ops.open(pd->fpctx,beh,pd->uris[j],&ph)) {
+                                                               pd->ops.filecom(pd->fpctx, ph);
+                                                               pd->ops.close(pd->fpctx, ph);
+                                                       }
+                                                       glite_jppsbe_close_file(ctx,beh);
+                                               }
+
+                                       }
+                }
+
        free(job); free(class); free(name);
 
        return SOAP_OK;