Fixed WITHIN test.
authorFrantišek Dvořák <valtri@civ.zcu.cz>
Mon, 2 Apr 2007 17:27:08 +0000 (17:27 +0000)
committerFrantišek Dvořák <valtri@civ.zcu.cz>
Mon, 2 Apr 2007 17:27:08 +0000 (17:27 +0000)
Check for valid attributes to get better error msg.

org.glite.jp.index/examples/query-tests/run-test.sh
org.glite.jp.index/src/soap_ops.c

index 9c0335a..32388a0 100755 (executable)
@@ -291,6 +291,6 @@ echo -n "WITHIN test.......... "
 create_db;
 run_is "-n";
 import_db $GLITE_LOCATION/examples/query-tests/dump1.sql;
-run_test_query $GLITE_LOCATION/examples/query-tests/within_query.in $GLITE_LOCATION/examples/query-tests/exists_query.out;
+run_test_query $GLITE_LOCATION/examples/query-tests/within_query.in $GLITE_LOCATION/examples/query-tests/within_query.out;
 drop_db;
 kill_is;
index 000082d..af6d24b 100644 (file)
@@ -161,6 +161,21 @@ end:
 }
 
 
+static int checkConditions(glite_jpis_context_t ctx, struct _jpelem__QueryJobs *in) {
+       int i, j;
+       char *attr;
+
+       for (i = 0; i < in->__sizeconditions; i++) {
+               attr = GLITE_SECURITY_GSOAP_LIST_GET(in->conditions, i)->attr;
+               if (!attr) return 1;
+               for (j = 0; ctx->conf->attrs[j] && strcasecmp(ctx->conf->attrs[j], attr) != 0; j++);
+               if (!ctx->conf->attrs[j]) return 1;
+       }
+
+       return 0;
+}
+
+
 /* adds attr table name to the list (null terminated) , iff unigue */
 static void add_attr_table(char *new, char ***attr_tables) 
 {
@@ -586,12 +601,18 @@ SOAP_FMAC5 int SOAP_FMAC6 __jpsrv__QueryJobs(
        puts(__FUNCTION__);
        memset(out, 0, sizeof(*out));
        
-       /* test whether there is any indexed aatribudet in the condition */
+       /* test whether there is any indexed attribudes in the condition */
        if ( checkIndexedConditions(ctx, in) ) {
                fprintf(stderr, "No indexed attribute in query\n");
                return SOAP_ERR;
        }
 
+       /* test whether there is known attribudes in the condition */
+       if ( checkConditions(ctx, in) ) {
+               fprintf(stderr, "Unknown attribute in query\n");
+               return SOAP_ERR;
+       }
+
        /* get all jobids matching the conditions */
        if ( get_jobids(soap, ctx, in, &jobids, &ps_list) ) {
                return SOAP_ERR;