make it build wrt. current jp.common & jp.ws-interface
authorAleš Křenek <ljocha@ics.muni.cz>
Mon, 8 Aug 2005 14:12:44 +0000 (14:12 +0000)
committerAleš Křenek <ljocha@ics.muni.cz>
Mon, 8 Aug 2005 14:12:44 +0000 (14:12 +0000)
org.glite.jp.primary/interface/file_plugin.h
org.glite.jp.primary/src/authz.c
org.glite.jp.primary/src/feed.c
org.glite.jp.primary/src/feed.h
org.glite.jp.primary/src/new_ftp_backend.c
org.glite.jp.primary/src/soap_ops.c
org.glite.jp.primary/src/tags.h

index b3cec8a..eae219d 100644 (file)
@@ -27,7 +27,7 @@ typedef struct _glite_jpps_fplug_op_t {
 \retval ENOSYS this attribute is not defined by this type of file
 \retval ENOENT no value is present 
 */
-       int     (*attr)(void *fpctx,void *handle,glite_jp_attr_t attr,glite_jp_attrval_t **attrval);
+       int     (*attr)(void *fpctx,void *handle,const char *attr,glite_jp_attrval_t **attrval);
 
 /** File type specific operation. 
 \param[in] fpctx       Plugin context.
@@ -45,6 +45,7 @@ typedef struct _glite_jpps_fplug_data_t {
                                        handled by the plugin. */
        char    **classes;      /**< The same as uris but filesystem-friendly
                                        (can be used to construct file names).*/
+       char    **namespaces;   /**< Which attribute namespaces this plugin handles. */
 
        glite_jpps_fplug_op_t ops;      /**< Plugin operations. */
 } glite_jpps_fplug_data_t;
index edaaef4..3ceba02 100644 (file)
@@ -29,7 +29,8 @@ int glite_jpps_authz(glite_jp_context_t ctx,int op,const char *job,const char *o
                        err.desc = "you are not a trusted peer";
                        return glite_jp_stack_error(ctx,&err);
 
-               case SOAP_TYPE___jpsrv__GetJob:
+               case SOAP_TYPE___jpsrv__GetJobFiles:
+               case SOAP_TYPE___jpsrv__GetJobAttributes:
                        assert(owner);
                        return strcmp(owner,ctx->peer) ? glite_jp_stack_error(ctx,&err) : 0;
                        break;
index c4a4578..1c80a8e 100644 (file)
@@ -28,18 +28,13 @@ static int check_qry_item(
        int     cmp,cmp2;
        long    scmp,ucmp;
 
-       switch (qry->attr.type) {
-               case GLITE_JP_ATTR_OWNER:
-               case GLITE_JP_ATTR_TAG:
-                       cmp = strcmp(attr->value.s,qry->value.s);
-                       break;
-               case GLITE_JP_ATTR_TIME:
-                       scmp = (ucmp = attr->value.time.tv_usec - qry->value.time.tv_usec) > 0 ? 0 : -1;
-                       ucmp -= 1000000 * scmp;
-                       scmp += attr->value.time.tv_sec - qry->value.time.tv_sec;
-                       cmp = scmp ? scmp : ucmp;
-                       break;
-       }
+       if (strcmp(qry->attr,attr->name)) return 0;
+
+       if (qry->origin && qry->origin != attr->origin) return 0;
+
+       /* FIXME: fallback only, loop over type plugins and use plugin compare function */
+       cmp = strcmp(attr->value,qry->value);
+
        switch (qry->op) {
                case GLITE_JP_QUERYOP_EQUAL: return !cmp;
                case GLITE_JP_QUERYOP_UNEQUAL: return cmp;
@@ -47,18 +42,8 @@ static int check_qry_item(
                case GLITE_JP_QUERYOP_GREATER: return cmp > 0;
 
                case GLITE_JP_QUERYOP_WITHIN:
-                       switch (qry->attr.type) {
-                       case GLITE_JP_ATTR_OWNER:
-                       case GLITE_JP_ATTR_TAG:
-                               cmp2 = strcmp(attr->value.s,qry->value2.s);
-                               break;
-                       case GLITE_JP_ATTR_TIME:
-                               scmp = (ucmp = attr->value.time.tv_usec - qry->value2.time.tv_usec) > 0 ? 0 : -1;
-                               ucmp -= 1000000 * scmp;
-                               scmp += attr->value.time.tv_sec - qry->value2.time.tv_sec;
-                               cmp2 = scmp ? scmp : ucmp;
-                               break;
-                       }
+                       /* FIXME: the same */
+                       cmp2 = strcmp(attr->value,qry->value);
                        return cmp >= 0 && cmp2 <= 0;
        }
 }
@@ -70,47 +55,54 @@ static int match_feed(
                glite_jp_context_t ctx,
                const struct jpfeed *feed,
                const char *job,
-               const glite_jp_attrval_t attrs[] /* XXX: not checked for correctness */
+
+/* XXX: not checked for correctness,
+       assuming single occurence only */
+               const glite_jp_attrval_t attrs[] 
 )
 {
        int     i;
-       int     attri[GLITE_JP_ATTR__LAST];
        int     qi[QUERY_MAX];
 
        glite_jp_attrval_t *newattr = NULL;
 
        glite_jp_clear_error(ctx);
 
-       for (i=0; i<GLITE_JP_ATTR__LAST; i++) attri[i] = -1;
-       for (i=0; attrs[i].attr.type; i++) attri[attrs[i].attr.type] = i;
-
        if (feed->qry) {
                int     j,complete = 1;
 
                memset(qi,0,sizeof qi);
-               for (i=0; feed->qry[i].attr.type; i++) {
+               for (i=0; feed->qry[i].attr; i++) {
+                       int     sat = 0;
                        assert(i<QUERY_MAX);
-                       if ((j=attri[feed->qry[i].attr.type]) >=0) {
-                               if (check_qry_item(ctx,feed->qry+i,attrs+j))
-                                       qi[i] = 1; /* matched */
-                               else return 0;  /* can't be satisfied */
-                       }
-                       else complete = 0;
+                       for (j=0; !sat && attrs[j].name; j++)
+                               if (!strcmp(attrs[j].name,feed->qry[i].attr)) {
+                                       if (check_qry_item(ctx,feed->qry+i,attrs+j)) { 
+                                               qi[i] = 1;
+                                               sat = 1; /* matched, needn't loop further */
+                                       }
+                                       else return 0;  /* can't be satisfied either */
+                               }
+
+                       if (!sat) complete = 0;
                }
 
                /* not all attributes in query are known from input 
                 * we have to retrieve job metadata from the backend
+                * 
+                * XXX: It is not optimal to retrieve it here without sharing
+                * over multiple invocations of match_feed() for the same job.
                 */
                if (!complete) {
-                       glite_jp_attrval_t      meta[GLITE_JP_ATTR__LAST+1];
-                       int     qai[GLITE_JP_ATTR__LAST];
+                       glite_jp_attrval_t      meta[QUERY_MAX+1];
+                       int     qi2[QUERY_MAX];
 
                        memset(meta,0,sizeof meta);
                        j=0;
-                       for (i=0; feed->qry[i].attr.type; i++) if (!qi[i]) {
-                               meta[j].attr.type = feed->qry[i].attr.type;
-                               meta[j].attr.name = feed->qry[i].attr.name;
-                               qai[feed->qry[i].attr.type] = i;
+                       for (i=0; feed->qry[i].attr; i++) if (!qi[i]) {
+                               assert(j<QUERY_MAX);
+                               meta[j].name = feed->qry[i].attr;
+                               qi2[j] = i;
                                j++;
                        }
 
@@ -123,8 +115,8 @@ static int match_feed(
                                return glite_jp_stack_error(ctx,&err);
                        }
 
-                       for (i=0; j=meta[i].attr.type; i++)
-                               if (!check_qry_item(ctx,feed->qry+qai[j],meta+i))
+                       for (i=0; meta[i].name; i++)
+                               if (!check_qry_item(ctx,feed->qry+qi2[i],meta+i))
                                        return 0;
                }
        }
@@ -141,44 +133,51 @@ int glite_jpps_match_attr(
 )
 {
        struct jpfeed   *f = (struct jpfeed *) ctx->feeds;
-       int     i,j;
-       int     attri[GLITE_JP_ATTR__LAST];
-
-       glite_jp_clear_error(ctx);
+       int     i,j,doit;
 
-       for (i=0; i<GLITE_JP_ATTR__LAST; i++) attri[i] = -1;
-       for (i=0; attrs[i].attr.type; i++) {
-               if (attrs[i].attr.type >= GLITE_JP_ATTR__LAST ||
-                               attrs[i].attr.type <= 0)
-               {
-                       glite_jp_error_t        err;
-                       memset(&err,0,sizeof err);
-                       err.code = EINVAL;
-                       err.source = __FUNCTION__;
-                       err.desc = "unknown attribute";
-                       return glite_jp_stack_error(ctx,&err);
-               }
-               if (attri[attrs[i].attr.type] >= 0) {
-                       glite_jp_error_t        err;
-                       memset(&err,0,sizeof err);
-                       err.code = EINVAL;
-                       err.source = __FUNCTION__;
-                       err.desc = "double attribute change";
-                       return glite_jp_stack_error(ctx,&err);
-               }
+       for (;f; f = f->next) {
+               doit = 0;
 
-               attri[attrs[i].attr.type] = i;
-       }
+               for (i=0; !doit && f->attrs[i]; i++) 
+                       for (j=0; !doit && attrs[j].name; j++)
+                               if (!strcmp(f->attrs[i],attrs[j].name)) doit = 1;
 
-       for (;f; f = f->next) {
-               for (i=0; f->attrs[i].type && attri[f->attrs[i].type] == -1; i++);
                /* XXX: ignore any errors */
-               if (f->attrs[i].type) match_feed(ctx,f,job,attrs);
+               if (doit) match_feed(ctx,f,job,attrs);
        }
 
        return glite_jp_clear_error(ctx);
 }
 
+static int attr_void_cmp(const void *a, const void *b)
+{
+       char const * const *ca = (char const * const *) a;
+       char const * const *cb = (char const * const *) b;
+       return strcmp(*ca,*cb);
+}
+
+static void attr_union(char **a, char **b, char ***c)
+{
+       int     ca = 0,cb = 0,cnt,i,j;
+       char    **out;
+
+       if (a) for (ca = 0; a[ca]; ca++);
+       if (b) for (cb = 0; b[cb]; cb++);
+       out = malloc((ca+cb+1) * sizeof *out);
+       if (a) memcpy(out,a,ca * sizeof *out);
+       if (b) memcpy(out+ca,b,cb * sizeof *out);
+       out[cnt = ca+cb] = NULL;
+       qsort(out,cnt,sizeof *out,attr_void_cmp);
+
+       for (i=0; i<cnt; i++) {
+               for (j=i; j<cnt && !strcmp(out[i],out[j]); j++);
+               if (j < cnt && j > i+1) memmove(out+i+1,out+j,(cnt-j) * sizeof *out);
+               cnt -= j-i-1;
+       }
+
+       *c = out;
+}
+
 int glite_jpps_match_file(
        glite_jp_context_t ctx,
        const char *job,
@@ -193,7 +192,7 @@ int glite_jpps_match_file(
        struct  jpfeed  *f = ctx->feeds;
 
        int     nvals = 0,j,i;
-       glite_jp_attr_t         *attrs = NULL, *attrs2;
+       char            **attrs = NULL, **attrs2;
        glite_jp_attrval_t      *vals = NULL,*oneval;
 
        fprintf(stderr,"%s: %s %s %s\n",__FUNCTION__,job,class,name);
@@ -206,8 +205,8 @@ int glite_jpps_match_file(
        }
 
        for (;f;f=f->next) {
-               glite_jp_attr_union(attrs,f->attrs,&attrs2);
-               glite_jp_attrset_free(attrs,1);
+               attr_union(attrs,f->attrs,&attrs2);
+               free(attrs);
                attrs = attrs2;
        }
 
@@ -227,28 +226,29 @@ int glite_jpps_match_file(
                                continue;
                        }
 
-                       for (i=0; attrs[i].type; i++) 
+                       for (i=0; attrs[i]; i++) 
                                if (!pd[pi]->ops.attr(pd[pi]->fpctx,ph,attrs[i],&oneval)) {
                                /* XXX: ignore error */
-                                       for (j=0; oneval[j].attr.type; j++);
+                                       for (j=0; oneval[j].name; j++);
                                        vals = realloc(vals,(nvals+j+1) * sizeof *vals);
                                        memcpy(vals+nvals,oneval,(j+1) * sizeof *vals);
                                        nvals += j;
+                                       free(oneval);
                                }
 
                        pd[pi]->ops.close(pd[pi]->fpctx,ph);
                }
        }
 
-       glite_jp_attrset_free(attrs,1);
+       free(attrs);
 
        for (f = ctx->feeds; f; f=f->next) {
                int     k;
                glite_jp_attrval_t      * fattr = malloc((nvals+1) * sizeof *fattr);
 
                j = 0;
-               for (i=0; i<nvals; i++) for (k=0; f->attrs[k].type; k++)
-                       if (!glite_jp_attr_cmp(f->attrs+k,&vals[i].attr))
+               for (i=0; i<nvals; i++) for (k=0; f->attrs[k]; k++)
+                       if (!strcmp(f->attrs[k],vals[i].name))
                                memcpy(fattr+j++,vals+i,sizeof *fattr);
 
                memset(fattr+j,0,sizeof *fattr);
@@ -256,7 +256,7 @@ int glite_jpps_match_file(
                free(fattr);
        }
 
-       for (i=0; vals[i].attr.type; i++) glite_jp_attrval_free(vals+i,0);
+       for (i=0; vals[i].name; i++) glite_jp_attrval_free(vals+i,0);
        free(vals);
 
        if (bh) glite_jppsbe_close_file(ctx,bh);
@@ -265,16 +265,6 @@ int glite_jpps_match_file(
        return 0;
 }
 
-int glite_jpps_match_tag(
-       glite_jp_context_t ctx,
-       const char *job,
-       const glite_jp_tagval_t *tag
-)
-{
-       fprintf(stderr,"%s: \n",__FUNCTION__);
-       return 0;
-}
-
 static char *generate_feedid(void)
 {
        char    hname[200],buf[1000];
@@ -289,7 +279,7 @@ static char *generate_feedid(void)
 int glite_jpps_run_feed(
        glite_jp_context_t ctx,
        const char *destination,
-       const glite_jp_attr_t *attrs,
+       char const * const *attrs,
        const glite_jp_query_rec_t *qry,
        char **feed_id)
 {
@@ -314,7 +304,7 @@ static int register_feed_deferred(glite_jp_context_t ctx,void *feed)
 int glite_jpps_register_feed(
        glite_jp_context_t ctx,
        const char *destination,
-       const glite_jp_attr_t *attrs,
+       char const *const *attrs,
        const glite_jp_query_rec_t *qry,
        char **feed_id,
        time_t *expires)
@@ -328,12 +318,12 @@ int glite_jpps_register_feed(
        f->id = strdup(*feed_id);
        f->destination = strdup(destination);
        f->expires = *expires;
-       for (i=0; attrs[i].type; i++) {
+       for (i=0; attrs[i]; i++) {
                f->attrs = realloc(f->attrs,(i+2) * sizeof *f->attrs);
-               glite_jp_attr_copy(f->attrs+i,attrs+i);
-               memset(f->attrs+i+1,0,sizeof *f->attrs);
+               f->attrs[i] = strdup(attrs[i]);
+               f->attrs[i+1] = NULL;
        }
-       for (i=0; qry[i].attr.type; i++) {
+       for (i=0; qry[i].attr; i++) {
                f->qry = realloc(f->qry,(i+2) * sizeof *f->qry);
                glite_jp_queryrec_copy(f->qry+i,qry+i);
                memset(f->qry+i+1,0,sizeof *f->qry);
index c3c2461..d141c5b 100644 (file)
@@ -5,7 +5,7 @@
 struct jpfeed {
        char    *id,*destination;
        time_t  expires;
-       glite_jp_attr_t *attrs;
+       char    **attrs;
        glite_jp_query_rec_t    *qry;
        struct jpfeed   *next;
 };
@@ -13,9 +13,9 @@ struct jpfeed {
 
 int glite_jpps_match_attr(glite_jp_context_t,const char *,const glite_jp_attrval_t[]);
 int glite_jpps_match_file(glite_jp_context_t,const char *,const char *,const char *);
-int glite_jpps_match_tag(glite_jp_context_t,const char *,const glite_jp_tagval_t *);
-int glite_jpps_run_feed(glite_jp_context_t,const char *,const glite_jp_attr_t *,const glite_jp_query_rec_t *,char **);
-int glite_jpps_register_feed(glite_jp_context_t,const char *,const glite_jp_attr_t *,const glite_jp_query_rec_t *,char **,time_t *);
+int glite_jpps_match_tag(glite_jp_context_t,const char *,const char *,const char *);
+int glite_jpps_run_feed(glite_jp_context_t,const char *,char const * const *,const glite_jp_query_rec_t *,char **);
+int glite_jpps_register_feed(glite_jp_context_t,const char *,char const * const *,const glite_jp_query_rec_t *,char **,time_t *);
 
 #endif
 
index b3a23d1..c94f20f 100644 (file)
@@ -769,7 +769,7 @@ int glite_jppsbe_get_job_url(
 
        glite_jp_db_freestmt(&db_res);
 
-       if (glite_jpps_authz(ctx,SOAP_TYPE___jpsrv__GetJob,job,db_row[2])) {
+       if (glite_jpps_authz(ctx,SOAP_TYPE___jpsrv__GetJobFiles,job,db_row[2])) {
                err.code = EPERM;
                goto error_out;
        }
@@ -1228,9 +1228,11 @@ int glite_jppsbe_get_job_metadata(
        int got_info = 0;
        struct timeval tv_reg;
        char *owner = NULL;
+/* do in plugin
        int got_tags = 0;
        void *tags_handle = NULL;
        glite_jp_tagval_t* tags = NULL;
+*/
        int i,j;
        glite_jp_error_t err;
 
@@ -1241,13 +1243,11 @@ int glite_jppsbe_get_job_metadata(
        memset(&err,0,sizeof err);
        err.source = __FUNCTION__;
 
-       for (i = 0; attrs_inout[i].attr.type != GLITE_JP_ATTR_UNDEF; i++) {
-               switch (attrs_inout[i].attr.type) {
-               case GLITE_JP_ATTR_OWNER:
-
+       for (i = 0; attrs_inout[i].name; i++) {
 /* must be implemented via filetype plugin
                case GLITE_JP_ATTR_TIME:
 */
+               if (!strcmp(attrs_inout[i].name,GLITE_JP_ATTR_OWNER)) {
                        if (!got_info) {
                                if (get_job_info(ctx, job, &owner, &tv_reg)) {
                                        err.code = ctx->error->code;
@@ -1256,7 +1256,7 @@ int glite_jppsbe_get_job_metadata(
                                }
                                got_info = 1;
                        }
-                       break;
+               }
 
 /* must be implemented via filetype plugin
                case GLITE_JP_ATTR_TAG:
@@ -1278,25 +1278,32 @@ int glite_jppsbe_get_job_metadata(
                        }
                        break;
 */
-               default:
+               else {
                        err.code = EINVAL;
                        err.desc = "Invalid attribute type";
                        goto error_out;
                        break;
                }
 
-               switch (attrs_inout[i].attr.type) {
-               case GLITE_JP_ATTR_OWNER:
-                       attrs_inout[i].value.s = strdup(owner);
-                       if (!attrs_inout[i].value.s) {
+               if (!strcmp(attrs_inout[i].name,GLITE_JP_ATTR_OWNER)) {
+                       attrs_inout[i].value = strdup(owner);
+                       if (!attrs_inout[i].value) {
                                err.code = ENOMEM;
                                err.desc = "Cannot copy owner string";
                                goto error_out;
                        }       
-                       break;
+                       attrs_inout[i].origin = GLITE_JP_ATTR_ORIG_SYSTEM;
+                       attrs_inout[i].origin_detail = NULL;
+
+                       /* FIXME: we must store job registration time somewhere */
+                       attrs_inout[i].timestamp = 0;
+               }
+       
+/* TODO:
                case GLITE_JP_ATTR_TIME:
                        attrs_inout[i].value.time = tv_reg;
                        break;
+*/
 
 /* must be implemented via filetype plugin
                case GLITE_JP_ATTR_TAG:
@@ -1314,32 +1321,22 @@ int glite_jppsbe_get_job_metadata(
                        if (!tags[j].name) attrs_inout[i].value.tag.name = NULL;
                        break;
 */
-               default:
-                       break;
-               }
        }
 
 error_out:
        free(owner);
+/* plugin
        if (tags) for (j = 0; tags[j].name != NULL; j++) {
                free(tags[j].name);
                free(tags[j].value);
        }
        free(tags);
+*/
        
        if (err.code) {
                while (i > 0) {
                        i--;
-                       switch (attrs_inout[i].attr.type) {
-                       case GLITE_JP_ATTR_OWNER:
-                               free(attrs_inout[i].value.s);
-                               break;
-                       case GLITE_JP_ATTR_TAG:
-                               free(attrs_inout[i].value.tag.name);
-                               free(attrs_inout[i].value.tag.value);
-                       default:
-                               break;
-                       }
+                       glite_jp_attrval_free(attrs_inout+i,0);
                }
                return glite_jp_stack_error(ctx,&err);
        } else {
index 3e95c26..d49d112 100644 (file)
@@ -54,32 +54,6 @@ static void err2fault(const glite_jp_context_t ctx,struct soap *soap)
        else soap->fault->detail = detail;
 }
 
-/* deprecated 
-static glite_jp_fileclass_t s2jp_fileclass(enum jptype__UploadClass class)
-{
-       switch (class) {
-               case INPUT_SANDBOX: return GLITE_JP_FILECLASS_INPUT;
-               case OUTPUT_SANDBOX: return GLITE_JP_FILECLASS_OUTPUT;
-               case JOB_LOG: return GLITE_JP_FILECLASS_LBLOG;
-               default: return GLITE_JP_FILECLASS_UNDEF;
-       }
-}
-*/
-
-static void s2jp_tag(const struct jptype__tagValue *stag,glite_jp_tagval_t *jptag)
-{
-       memset(jptag,0,sizeof *jptag);
-       jptag->name = strdup(stag->name);
-       jptag->sequence = stag->sequence ? *stag->sequence : 0;
-       jptag->timestamp = stag->timestamp ? *stag->timestamp : 0;
-       if (stag->stringValue) jptag->value = strdup(stag->stringValue);
-       else if (stag->blobValue) {
-               jptag->binary = 1;
-               jptag->size = stag->blobValue->__size;
-               jptag->value = (char *) stag->blobValue->__ptr;
-       }
-}
-
 #define CONTEXT_FROM_SOAP(soap,ctx) glite_jp_context_t ctx = (glite_jp_context_t) ((soap)->user)
 
 SOAP_FMAC5 int SOAP_FMAC6 __jpsrv__RegisterJob(
@@ -98,9 +72,12 @@ SOAP_FMAC5 int SOAP_FMAC6 __jpsrv__RegisterJob(
                return SOAP_FAULT;
        }
 
-       owner_val[0].attr.type = GLITE_JP_ATTR_OWNER;
-       owner_val[0].value.s = in->owner;
-       owner_val[1].attr.type = GLITE_JP_ATTR_UNDEF;
+       owner_val[0].name = GLITE_JP_ATTR_OWNER;
+       owner_val[0].value = in->owner;
+       owner_val[0].origin = GLITE_JP_ATTR_ORIG_SYSTEM;
+       owner_val[0].timestamp = time(NULL);
+       owner_val[0].origin_detail = NULL;
+       owner_val[1].name = NULL;
 
 /* XXX: errrors should be ingored but not silently */
        glite_jpps_match_attr(ctx,in->job,owner_val); 
@@ -198,8 +175,7 @@ SOAP_FMAC5 int SOAP_FMAC6 __jpsrv__RecordTag(
        CONTEXT_FROM_SOAP(soap,ctx);
        void    *file_be,*file_p;
        glite_jpps_fplug_data_t **pd = NULL;
-
-       glite_jp_tagval_t       mytag;
+       glite_jp_attrval_t      attr[2];
 
        file_be = file_p = NULL;
 
@@ -216,11 +192,9 @@ SOAP_FMAC5 int SOAP_FMAC6 __jpsrv__RecordTag(
                return SOAP_FAULT;
        }
 
-       s2jp_tag(in->tag,&mytag);
-
        /* XXX: assuming tag plugin handles just one type */
        if (pd[0]->ops.open(pd[0]->fpctx,file_be,GLITE_JP_FILETYPE_TAGS,&file_p)
-               || pd[0]->ops.generic(pd[0]->fpctx,file_p,GLITE_JP_FPLUG_TAGS_APPEND,&mytag))
+               || pd[0]->ops.generic(pd[0]->fpctx,file_p,GLITE_JP_FPLUG_TAGS_APPEND,in->tag->name,in->tag->value))
        {
                err2fault(ctx,soap);
                if (file_p) pd[0]->ops.close(pd[0]->fpctx,file_p);
@@ -237,69 +211,41 @@ SOAP_FMAC5 int SOAP_FMAC6 __jpsrv__RecordTag(
                return SOAP_FAULT;
        }
 
+       attr[0].name = in->tag->name;
+       attr[0].value = in->tag->value;
+       attr[0].origin = GLITE_JP_ATTR_ORIG_USER;
+       attr[0].timestamp = time(NULL);
+       attr[0].origin_detail = NULL;   /* XXX */
+
        /* XXX: ignore errors but don't fail silenty */
-       glite_jpps_match_tag(ctx,in->jobid,&mytag);
+       glite_jpps_match_attr(ctx,in->jobid,attr);
 
        free(pd);
        return SOAP_OK;
 }
 
-extern char *glite_jp_default_namespace;
-
-/* XXX: should be public */
-#define GLITE_JP_TAGS_NAMESPACE "http://glite.org/services/jp/tags"
-
-static void s2jp_attr(const char *in,glite_jp_attr_t *out)
+static void s2jp_qval(const struct jptype__stringOrBlob *in, char **value, int *binary, size_t *size)
 {
-       char    *buf = strdup(in),*name = strchr(buf,':'),*ns = NULL;
-
-       if (name) {
-               ns = buf; 
-               *name++ = 0;
+       if (in->string) {
+               *value = in->string;
+               *binary = 0;
+               *size = 0;
        }
        else {
-               name = buf; 
-               ns = glite_jp_default_namespace;
-       }
-
-       memset(out,0,sizeof *out);
-
-       if (strcmp(ns,glite_jp_default_namespace))
-               out->type = strcmp(ns,GLITE_JP_TAGS_NAMESPACE) ?
-                       GLITE_JP_ATTR_GENERIC : GLITE_JP_ATTR_TAG;
-       else {
-               if (!strcmp(name,"owner")) out->type = GLITE_JP_ATTR_OWNER;
-               else if (!strcmp(name,"time")) out->type = GLITE_JP_ATTR_OWNER;
-
-       }
-
-       if (out->type) {
-               out->name = strdup(name);
-               out->namespace = strdup(ns);
-       }
-}
-
-static void s2jp_queryval(
-               const char *in,
-               glite_jp_attrtype_t type,
-               union _glite_jp_query_rec_val *out)
-{
-       switch (type) {
-               case GLITE_JP_ATTR_OWNER:
-               case GLITE_JP_ATTR_TAG:
-               case GLITE_JP_ATTR_GENERIC:
-                       out->s = strdup(in);
-                       break;
-               case GLITE_JP_ATTR_TIME:
-                       out->time.tv_sec = atoi(in);
-                       break;
+               assert(in->blob);       /* XXX: should report error instead */
+               *value = in->blob->__ptr;
+               *binary = 1;
+               *size = in->blob->__size;
        }
 }
 
 static void s2jp_query(const struct jptype__primaryQuery *in, glite_jp_query_rec_t *out)
 {
-       s2jp_attr(in->attr,&out->attr);
+       int     b;
 
+       out->attr = in->attr;
+
+       s2jp_qval(in->value,&out->value,&out->binary,&out->size);
        switch (in->op) {
                case EQUAL: out->op = GLITE_JP_QUERYOP_EQUAL; break;
                case UNEQUAL: out->op = GLITE_JP_QUERYOP_UNEQUAL; break;
@@ -307,11 +253,18 @@ static void s2jp_query(const struct jptype__primaryQuery *in, glite_jp_query_rec
                case GREATER: out->op = GLITE_JP_QUERYOP_GREATER; break;
                case WITHIN:
                        out->op = GLITE_JP_QUERYOP_WITHIN;
-                       s2jp_queryval(in->value2,out->attr.type,&out->value2);
+                       s2jp_qval(in->value2,&out->value2,&b,&out->size2);
+                       assert(out->binary == b);       /* XXX: report error instead */
+
                        break;
        }
 
-       s2jp_queryval(in->value,out->attr.type,&out->value);
+       if (in->origin) switch (*in->origin) {
+               case jptype__attrOrig__SYSTEM: out->origin = GLITE_JP_ATTR_ORIG_SYSTEM; break;
+               case jptype__attrOrig__USER: out->origin = GLITE_JP_ATTR_ORIG_USER; break;
+               case jptype__attrOrig__FILE_: out->origin = GLITE_JP_ATTR_ORIG_FILE; break;
+       }
+       else out->origin = GLITE_JP_ATTR_ORIG_ANY;
 }
 
 SOAP_FMAC5 int SOAP_FMAC6 __jpsrv__FeedIndex(
@@ -332,13 +285,13 @@ SOAP_FMAC5 int SOAP_FMAC6 __jpsrv__FeedIndex(
        time_t  expires = 0;
        int     ret = SOAP_OK;
 
-       glite_jp_attr_t *attrs = calloc(in->__sizeattributes+1,sizeof *attrs);
+       char    const **attrs = calloc(in->__sizeattributes+1,sizeof *attrs);
        glite_jp_query_rec_t    *qry = calloc(in->__sizeconditions+1,sizeof *qry);
        int     i;
 
        glite_jp_clear_error(ctx);
 
-       for (i = 0; i<in->__sizeattributes; i++) s2jp_attr(in->attributes[i],attrs+i);
+       memcpy(attrs,in->attributes,sizeof *attrs * in->__sizeattributes);
        for (i = 0; i<in->__sizeconditions; i++) s2jp_query(in->conditions[i],qry+i);
 
        if (in->history) {
@@ -374,9 +327,7 @@ SOAP_FMAC5 int SOAP_FMAC6 __jpsrv__FeedIndex(
 
 cleanup:
        free(feed_id);
-       for (i=0; attrs[i].type; i++) free(attrs[i].name);
        free(attrs);
-       for (i=0; qry[i].attr.type; i++) glite_jp_free_query_rec(qry+i);
        free(qry);
 
        return ret;
@@ -391,10 +342,10 @@ SOAP_FMAC5 int SOAP_FMAC6 __jpsrv__FeedIndexRefresh(
        abort();
 }
 
-SOAP_FMAC5 int SOAP_FMAC6 __jpsrv__GetJob(
+SOAP_FMAC5 int SOAP_FMAC6 __jpsrv__GetJobFiles(
                struct soap *soap,
-               struct _jpelem__GetJob *in,
-               struct _jpelem__GetJobResponse *out)
+               struct _jpelem__GetJobFiles *in,
+               struct _jpelem__GetJobFilesResponse *out)
 {
        CONTEXT_FROM_SOAP(soap,ctx);
        char    *url;
@@ -452,3 +403,13 @@ SOAP_FMAC5 int SOAP_FMAC6 __jpsrv__GetJob(
        return SOAP_OK;
 }
 
+SOAP_FMAC5 int SOAP_FMAC6 __jpsrv__GetJobAttributes(
+               struct soap *soap,
+               struct _jpelem__GetJobAttributes *in,
+               struct _jpelem__GetJobAttributesResponse *out)
+{
+       CONTEXT_FROM_SOAP(soap,ctx);
+
+       /* TODO */
+       abort();
+}
index 0d8afa8..3aade74 100644 (file)
@@ -1 +1 @@
-int glite_jpps_tag_append(glite_jp_context_t,void *,const glite_jp_tagval_t *);
+int glite_jpps_tag_append(glite_jp_context_t,void *,const char *, const char *);