Changeset 57 for trunk


Ignore:
Timestamp:
Jan 5, 2011, 3:20:01 PM (13 years ago)
Author:
djay
Message:

Adding contains and getIoTypeFromElement functions in service.h. Remove memory leaks from the Service Configuration Parser, add the support for multiple supported formats as before. Small modification of the ZOO-Kernel Java Support, adding the capability to access the modified main_conf HashMap? from the Kernel to let lenv message map pass when an error occurs and it is handled in the Service code. Adding same capability for the ZOO-Kernel Python Support. Use strcasecmp in service.h rather than strlen+strncasecmp. Ensure that only OWS compliant informations are available for Contact.Phone and Contact.Adress. Remove memory leak in createExceptionReportNode. Correction of the addDefaultValues function to add the default format using the informations from DataInputs? if present, this should correct the behavior of the ZOO-Kernel when choosing the extension value which should now point to the corresponding zcfg value if present. Don't set the NULL value for inputs not provided in the DataInputs?, still set NULL as default value for outputs. Avoid segfault in freeElements when some zcfg values was not set correctly. Link against the client libjvm.so file rather than the server one.

Location:
trunk/zoo-kernel
Files:
9 edited

Legend:

Unmodified
Added
Removed
  • trunk/zoo-kernel/configure.ac

    r46 r57  
    288288        if test -d "$JDKHOME/jre/lib/i386";
    289289        then
    290                 JAVA_LDFLAGS="-L$JDKHOME/jre/lib/i386/server/ -ljvm -lpthread"
     290                JAVA_LDFLAGS="-L$JDKHOME/jre/lib/i386/client/ -ljvm -lpthread"
    291291                JAVA_CPPFLAGS="-I$JDKHOME/include -I$JDKHOME/include/linux"
    292292        else
    293                 JAVA_LDFLAGS="-L$JDKHOME/jre/lib/amd64/server/ -ljvm -lpthread"
     293                JAVA_LDFLAGS="-L$JDKHOME/jre/lib/amd64/client/ -ljvm -lpthread"
    294294                JAVA_CPPFLAGS="-I$JDKHOME/include -I$JDKHOME/include/linux"
    295295        fi
  • trunk/zoo-kernel/service.h

    r56 r57  
    133133    map* tmp=m;
    134134    while(tmp!=NULL){
    135       if(strlen(tmp->name)==strlen(key) && strncasecmp(tmp->name,key,strlen(key))==0)
     135      if(strcasecmp(tmp->name,key)==0)
    136136        return true;
    137137      tmp=tmp->next;
     
    146146    maps* tmp=m;
    147147    while(tmp!=NULL){
    148       if(strlen(tmp->name)==strlen(key) && strncasecmp(tmp->name,key,strlen(key))==0){
     148      if(strcasecmp(tmp->name,key)==0){
    149149        return tmp;
    150150      }
     
    157157    map* tmp=m;
    158158    while(tmp!=NULL){
    159       if(strlen(tmp->name)==strlen(key) && strncasecmp(tmp->name,key,strlen(key))==0){
     159      if(strcasecmp(tmp->name,key)==0){
    160160        return tmp;
    161161      }
     
    239239    elements* tmp=e;
    240240    while(tmp!=NULL){
    241       if(strlen(tmp->name)==strlen(key) && strncasecmp(key,tmp->name,strlen(key))==0)
     241      if(strcasecmp(key,tmp->name)==0)
    242242        return true;
    243243      tmp=tmp->next;
     
    249249    elements* tmp=m;
    250250    while(tmp!=NULL){
    251       if(strlen(tmp->name)==strlen(key) && strncasecmp(tmp->name,key,strlen(tmp->name))==0)
     251      if(strcasecmp(tmp->name,key)==0)
    252252        return tmp;
    253253      tmp=tmp->next;
     
    260260    iotype* _cursor=*i;
    261261    if(_cursor!=NULL){
    262       freeMap(&_cursor->content);
    263       free(_cursor->content);
    264262      if(_cursor->next!=NULL){
    265263        freeIOType(&_cursor->next);
    266264        free(_cursor->next);
    267265      }
     266      freeMap(&_cursor->content);
     267      free(_cursor->content);
    268268    }
    269269  }
     
    272272    elements* tmp=*e;
    273273    if(tmp!=NULL){
    274       free(tmp->name);
     274      if(tmp->name!=NULL)
     275        free(tmp->name);
    275276      freeMap(&tmp->content);
    276       free(tmp->content);
     277      if(tmp->content!=NULL)
     278        free(tmp->content);
    277279      freeMap(&tmp->metadata);
    278       free(tmp->metadata);
    279       free(tmp->format);
     280      if(tmp->metadata!=NULL)
     281        free(tmp->metadata);
     282      if(tmp->format!=NULL)
     283        free(tmp->format);
    280284      freeIOType(&tmp->defaults);
    281285      if(tmp->defaults!=NULL)
    282286        free(tmp->defaults);
    283287      freeIOType(&tmp->supported);
    284       if(tmp->supported!=NULL)
     288      if(tmp->supported!=NULL){
    285289        free(tmp->supported);
     290      }
    286291      freeElements(&tmp->next);
    287292    }
     
    361366  static void addMapToIoType(iotype** io,map* mi){
    362367    iotype* tmp=*io;
    363     while(tmp!=NULL){
    364 #ifdef DEBUG
    365       fprintf(stderr,">> CURRENT MAP");
    366       dumpMap(tmp->content);
    367 #endif
    368       tmp=tmp->next;
    369     }
    370 #ifdef DEBUG
    371     fprintf(stderr,">> %s %i\n",__FILE__,__LINE__);
    372     fflush(stderr);
    373 #endif
    374     tmp=(iotype*)malloc(IOTYPE_SIZE);
    375 #ifdef DEBUG
    376     fprintf(stderr,">> %s %i\n",__FILE__,__LINE__);
    377     fflush(stderr);
    378 #endif
    379     tmp->content=NULL;
    380 #ifdef DEBUG
    381     fprintf(stderr,">> %s %i\n",__FILE__,__LINE__);
    382     fflush(stderr);
    383 #endif
    384     addMapToMap(&tmp->content,mi);
    385 #ifdef DEBUG
    386     fprintf(stderr,">> %s %i\n",__FILE__,__LINE__);
    387     fflush(stderr);
    388 #endif
    389     dumpMap(tmp->content);
    390     tmp->next=NULL;
    391   }
    392 
     368    while(tmp->next!=NULL){
     369      tmp=tmp->next;
     370    }
     371    tmp->next=(iotype*)malloc(IOTYPE_SIZE);
     372    tmp->next->content=NULL;
     373    addMapToMap(&tmp->next->content,mi);
     374    tmp->next->next=NULL;
     375  }
     376
     377  static bool contains(map* m,map* i){
     378    while(i!=NULL){     
     379      if(strcasecmp(i->name,"value")!=0 &&
     380         strcasecmp(i->name,"xlink:href")!=0){
     381        map *tmp;
     382        if(hasKey(m,i->name) && (tmp=getMap(m,i->name))!=NULL &&
     383           strcasecmp(i->value,tmp->value)!=0)
     384          return false;
     385      }
     386      i=i->next;
     387    }
     388    return true;
     389  }
     390
     391  static iotype* getIoTypeFromElement(elements* e,char *name, map* values){
     392    elements* cursor=e;
     393    while(cursor!=NULL){
     394      if(strcasecmp(cursor->name,name)==0){
     395        if(contains(cursor->defaults->content,values)==true)
     396          return cursor->defaults;
     397        else{
     398          iotype* tmp=cursor->supported;
     399          while(tmp!=NULL){
     400            if(contains(tmp->content,values)==true)
     401              return tmp;           
     402            tmp=tmp->next;
     403          }
     404        }
     405      }
     406      cursor=cursor->next;
     407    }
     408    return NULL;
     409  }
    393410
    394411  static maps* dupMaps(maps** mo){
     
    434451        free(_ztmpm->value);
    435452        _ztmpm->value=strdup(value);
    436         dumpMap(_ztmpm);
    437453      }else{
    438454        addToMap(_tmpm->content,subkey,value);
     
    502518        tmp->supported=(iotype*)malloc(IOTYPE_SIZE);
    503519        tmp->supported->content=NULL;
     520        addMapToMap(&tmp->supported->content,e->supported->content);
    504521        tmp->supported->next=NULL;
    505         addMapToMap(&tmp->supported->content,e->supported->content);
    506         iotype *etmp=*(&tmp->supported->next) ;
    507522        iotype *tmp2=e->supported->next;
    508523        while(tmp2!=NULL){
    509           etmp=(iotype*)malloc(IOTYPE_SIZE);
    510           etmp->content=NULL;
    511           addMapToMap(&etmp->content,tmp2->content);
    512           etmp->next=NULL;
     524          addMapToIoType(&tmp->supported,tmp2->content);
    513525#ifdef DEBUG
    514526          fprintf(stderr,">> %s %i\n",__FILE__,__LINE__);
     
    516528#endif
    517529          tmp2=tmp2->next;
    518           etmp=etmp->next;
    519530        }
    520531      }
     
    532543      *m=dupElements(tmp);
    533544    }else{
    534       while(_cursor->next!=NULL)
    535         _cursor=_cursor->next;
    536       _cursor->next=dupElements(tmp);
     545      addToElements(&(*m)->next,tmp);
    537546    }
    538547  }
  • trunk/zoo-kernel/service_conf.l

    r13 r57  
    109109
    110110
    111 <DANSBALISE>{Name}                      {srlval.chaine=strdup(yytext);return ID;}
     111<DANSBALISE>{Name}{newline}*                    {memmove(srlval.chaine,yytext,(strlen(yytext)+1)*sizeof(char));return ID;}
    112112
    113113
  • trunk/zoo-kernel/service_conf.y

    r20 r57  
    133133 : STag contentetoile ETag     
    134134{
    135   free($3);
    136135}
    137136
     
    210209          my_service->inputs->next=NULL;
    211210        }
    212         else
     211        else if(current_element!=NULL && current_element->name!=NULL){
    213212          addToElements(&my_service->inputs,current_element);
     213        }
    214214#ifdef DEBUG_SERVICE_CONF
    215215        fprintf(stderr,"CURRENT_ELEMENT\n");
     
    267267              addMapToMap(&current_element->metadata,current_content);
    268268              current_element->next=NULL;
    269               current_element->format=$2;
     269              current_element->format=strdup($2);
    270270              current_element->defaults=NULL;
    271271              current_element->supported=NULL;
     
    280280            current_element->metadata=NULL;
    281281            current_element->next=NULL;
    282             current_element->format=$2;
     282            current_element->format=strdup($2);
    283283            current_element->defaults=NULL;
    284284            current_element->supported=NULL;
     
    297297              if(wait_defaults==true){
    298298                defaultsc++;
    299                 freeMap(&current_content);
    300                 current_content=NULL;
     299                /*freeMap(&current_content);
     300                  current_content=NULL;*/
    301301              }
    302302              current_data=5;
     
    305305  printf("* Identifiant : %s\n",$2);
    306306#endif
    307   /* et on renvoie l'identifiant de balise afin de pouvoir le comparer */
    308   /* avec la balise jumelle fermante ! */
    309   $$ = $2 ;
    310307}
    311308 ;
     
    338335  printf ("attribute : %s\n",$1) ;
    339336#endif
    340   free($1);
    341337}
    342338 ;
     
    391387    current_content=NULL;
    392388    current_element->supported=NULL;
     389    current_element->next=NULL;
    393390  }
    394391  if(strcmp($3,"Supported")==0){
    395392    current_data=previous_data;
    396393    if(current_element->supported==NULL){
    397       //addMapToIoType(&current_element->supported,current_content);
    398       current_element->supported=(iotype*)malloc(IOTYPE_SIZE);
    399       current_element->supported->content=NULL;
    400       addMapToMap(&current_element->supported->content,current_content);
    401       freeMap(&current_content);
    402       free(current_content);
    403       current_element->supported->next=NULL;
    404       current_content=NULL;
     394      if(current_content!=NULL){
     395        current_element->supported=(iotype*)malloc(IOTYPE_SIZE);
     396        current_element->supported->content=NULL;
     397        addMapToMap(&current_element->supported->content,current_content);
     398        freeMap(&current_content);
     399        free(current_content);
     400        current_element->supported->next=NULL;
     401        current_content=NULL;
     402      }else{
     403        current_element->supported=NULL;
     404        current_element->next=NULL;
     405      }
    405406    }
    406407    else{
    407 #ifdef DEBUG
    408       // Currently we support only one supported format
     408#ifdef DEBUG_SERVICE_CONF
    409409      fprintf(stderr,"SECOND SUPPORTED FORMAT !!!!\n");
    410410#endif
    411       //addMapToIoType(&current_element->supported,current_content);
    412       /*iotype* iotmp=*(&current_element->supported);
    413       while(iotmp!=NULL){
    414         dumpMap(iotmp->content);
    415         iotmp=iotmp->next;
    416       }
    417       iotmp=(iotype*)malloc(IOTYPE_SIZE);
    418       iotmp->content=NULL;
    419       addMapToMap(&iotmp->content,current_content);
    420       iotmp->next=NULL;
    421       dumpElements(current_element);
    422       fprintf(stderr,"SECOND SUPPORTED FORMAT MAP START !!!!\n");
    423       dumpMap(current_content);
    424       fprintf(stderr,"SECOND SUPPORTED FORMAT MAP END !!!!\n");*/
     411      addMapToIoType(&current_element->supported,current_content);
    425412      freeMap(&current_content);
    426413      free(current_content);
    427414      current_content=NULL;
    428       /*freeMap(&iotmp->content);
    429       free(&iotmp->content);
    430       free(iotype);*/
    431 #ifdef DEBUG
    432       // Currently we support only one supported format
     415#ifdef DEBUG_SERVICE_CONF
     416      dumpElements(current_element);
    433417      fprintf(stderr,"SECOND SUPPORTED FORMAT !!!!\n");
    434418#endif
     
    436420    current_content=NULL;
    437421  }
    438   /* on renvoie l'identifiant de la balise pour pouvoir comparer les 2 */
    439   /* /!\ une balise fermante n'a pas d'attributs (c.f. : W3C) */
    440   $$ = $3;
    441422}
    442423 ;
     
    610591      if(current_data==2){
    611592        if(wait_inputs==true){
    612           fprintf(stderr,"dup INPUTS\n");
    613           if(current_element->name!=NULL){
     593          if(current_element!=NULL && current_element->name!=NULL){
    614594            if(my_service->inputs==NULL){
    615595              my_service->inputs=dupElements(current_element);
     
    661641          }
    662642          wait_inputs=false;
    663           dumpMap(current_content);
    664643          current_content=NULL;
    665644        }
     
    755734  int resultatYYParse = srparse() ;
    756735 
    757   if(wait_outputs==true && current_element->name!=NULL){
     736  if(wait_outputs==true && current_element!=NULL && current_element->name!=NULL){
    758737    if(my_service->outputs==NULL){     
    759738#ifdef DEBUG_SERVICE_CONF
     
    762741      my_service->outputs=dupElements(current_element);
    763742      my_service->outputs->next=NULL;
    764       freeElements(&current_element);
    765       free(current_element);
    766       current_element=NULL;
    767743    }
    768744    else{
     
    778754    free(current_element);
    779755    current_element=NULL;
     756#ifdef DEBUG_SERVICE_CONF
     757    fprintf(stderr,"(DATAOUTPUTS - 631) FREE current_element\n");
     758#endif
    780759  }
    781760  if(current_element!=NULL){
    782761    freeElements(&current_element);
    783     fprintf(stderr,"LINE 709");
    784762    free(current_element);
    785763    current_element=NULL;
     
    787765  if(current_content!=NULL){
    788766    freeMap(&current_content);
    789     fprintf(stderr,"LINE 715");
    790767    free(current_content);
    791768    current_content=NULL;
  • trunk/zoo-kernel/service_internal.c

    r52 r57  
    309309    map* tmp2=tmp4->content;
    310310    while(tmp2!=NULL){
    311       if(strncasecmp(tmp2->name,"keywords",8)!=0 &&
    312          strncasecmp(tmp2->name,"serverAddress",13)!=0 &&
    313          strncasecmp(tmp2->name,"lang",4)!=0 &&
    314          strncasecmp(tmp2->name,"encoding",8)!=0 &&
    315          strncasecmp(tmp2->name,"version",7)!=0){
     311      if(strcasecmp(tmp2->name,"abstract")==0 ||
     312         strcasecmp(tmp2->name,"title")==0 ||
     313         strcasecmp(tmp2->name,"accessConstraints")==0 ||
     314         strcasecmp(tmp2->name,"fess")==0){
    316315        tmp2->name[0]=toupper(tmp2->name[0]);
    317316        nc1 = xmlNewNode(ns_ows, BAD_CAST tmp2->name);
     
    370369  if(tmp4!=NULL){
    371370    map* tmp2=tmp4->content;
     371    char *tmpAddress[6];
     372    tmpAddress[0]="addressDeliveryPoint";
     373    tmpAddress[1]="addressCity";
     374    tmpAddress[2]="addressAdministrativeArea";
     375    tmpAddress[3]="addressPostalCode";
     376    tmpAddress[4]="addressCountry";
     377    tmpAddress[5]="addressElectronicMailAddress";
     378    char *tmpPhone[2];
     379    tmpPhone[0]="phoneVoice";
     380    tmpPhone[1]="phoneFacsimile";
    372381    while(tmp2!=NULL){
    373382      if(strcmp(tmp2->name,"keywords")!=0 &&
     
    395404            else
    396405              if(strncmp(tmp2->name,"Phone",5)==0){
    397                 char *toto=NULL;
    398                 char *toto1=tmp2->name;
    399                 toto=strstr(toto1,"Phone");
    400                 nc1 = xmlNewNode(ns_ows, BAD_CAST toto1+5);
    401                 xmlAddChild(nc1,xmlNewText(BAD_CAST tmp2->value));
    402                 xmlAddChild(nc5,nc1);
     406                int j;
     407                for(j=0;j<2;j++)
     408                  if(strlen(tmp2->name)==strlen(tmpPhone[j]) && strncasecmp(tmp2->name,tmpPhone[j],strlen(tmp2->name))==0){
     409                    char *toto=NULL;
     410                    char *toto1=tmp2->name;
     411                    toto=strstr(toto1,"Phone");
     412                    nc1 = xmlNewNode(ns_ows, BAD_CAST toto1+5);
     413                    xmlAddChild(nc1,xmlNewText(BAD_CAST tmp2->value));
     414                    xmlAddChild(nc5,nc1);
     415                  }
    403416              }
    404417              else
    405418                if(strncmp(tmp2->name,"Address",7)==0){
    406                   char *toto=NULL;
    407                   char *toto1=tmp2->name;
    408                   toto=strstr(toto1,"Address");
    409                   nc1 = xmlNewNode(ns_ows, BAD_CAST toto1+7);
    410                   xmlAddChild(nc1,xmlNewText(BAD_CAST tmp2->value));
    411                   xmlAddChild(nc6,nc1);
     419                  int j;
     420                  for(j=0;j<6;j++)
     421                    if(strlen(tmp2->name)==strlen(tmpAddress[j]) && strncasecmp(tmp2->name,tmpAddress[j],strlen(tmp2->name))==0){
     422                      char *toto=NULL;
     423                      char *toto1=tmp2->name;
     424                      toto=strstr(toto1,"Address");
     425                      nc1 = xmlNewNode(ns_ows, BAD_CAST toto1+7);
     426                      xmlAddChild(nc1,xmlNewText(BAD_CAST tmp2->value));
     427                      xmlAddChild(nc6,nc1);
     428                    }
    412429                }
    413430        }
     
    10841101    te=getMapFromMaps(m,"lenv","message");
    10851102    if(te!=NULL)
    1086       addToMap(errorMap,"text",te->value);
     1103      addToMap(errorMap,"text",_ss(te->value));
    10871104    else
    10881105      addToMap(errorMap,"text",_("No more information available"));
     
    13641381    if(tmp1!=NULL){
    13651382      nc2 = xmlNewNode(ns_ows, BAD_CAST tmp2[j]);
    1366       fprintf(stderr,"[%s] \n[%s]\n",tmp1->value,_ss(tmp1->value));
    13671383      xmlAddChild(nc2,xmlNewText(BAD_CAST _ss(tmp1->value)));
    13681384      xmlAddChild(root,nc2);
     
    13981414
    13991415void printExceptionReportResponse(maps* m,map* s){
    1400  
    14011416  int buffersize;
    14021417  xmlDocPtr doc;
     
    14251440  xmlFree(xmlbuff);
    14261441  xmlCleanupParser();
     1442  zooXmlCleanupNs();
    14271443}
    14281444
     
    14361452  maps* tmpMap=getMaps(m,"main");
    14371453
    1438   ns=xmlNewNs(NULL,BAD_CAST "http://www.opengis.net/ows/1.1",BAD_CAST "ows");
     1454  int nsid=zooXmlAddNs(NULL,BAD_CAST "http://www.opengis.net/ows/1.1",BAD_CAST "ows");
     1455  ns=usedNs[nsid];
    14391456  n = xmlNewNode(ns, BAD_CAST "ExceptionReport");
    14401457
     
    14931510    if(toto!=NULL && strcasecmp(toto->value,"true")==0){
    14941511      toto=getMap(request_outputs->content,"extension");
    1495       /* put gml extension if the extension is defined as .js and the result will be a gml file */
    1496       map* mtype=getMap(request_outputs->content,"mimeType");
    1497       if (strcasecmp(toto->value,"js")==0 && strcasecmp(mtype->value,"text/xml")==0) {
    1498         toto->value="gml";
    1499       }
    15001512      map *tmp1=getMapFromMaps(m,"main","tmpPath");
    1501       char *file_name=(char*)malloc((strlen(tmp1->value)+strlen(s->name)+strlen(toto->value)+13)*sizeof(char));
     1513      char *file_name;
     1514      bool hasExt=true;
     1515      if(toto==NULL){
     1516        // We can fallback to a default list of supported formats using
     1517        // mimeType information if present here. Maybe we can add more formats
     1518        // here.
     1519        // If mimeType was not found, we then set txt as the default extension.
     1520        map* mtype=getMap(request_outputs->content,"mimeType");
     1521        if(mtype!=NULL){
     1522          if(strcasecmp(mtype->value,"text/xml")==0)
     1523            toto=createMap("extension","xml");
     1524          else
     1525            toto=createMap("extension","txt");
     1526        }
     1527        if(toto==NULL)
     1528          toto=createMap("extension","txt");
     1529        hasExt=false;
     1530      }
     1531      file_name=(char*)malloc((strlen(tmp1->value)+strlen(s->name)+strlen(toto->value)+13)*sizeof(char));
    15021532      sprintf(file_name,"%s/%s_%i.%s",tmp1->value,s->name,cpid+100000,toto->value);
    15031533      FILE *ofile=fopen(file_name,"w");
     1534      if(ofile==NULL)
     1535        fprintf(stderr,"Unable to create file on disk implying segfault ! \n");
    15041536      map *tmp2=getMapFromMaps(m,"main","tmpUrl");
    15051537      map *tmp3=getMapFromMaps(m,"main","serverAddress");
    1506       char *file_url=(char*)malloc((strlen(tmp3->value)+strlen(tmp2->value)+strlen(s->name)+strlen(toto->value)+13)*sizeof(char));
     1538      char *file_url;
     1539      file_url=(char*)malloc((strlen(tmp3->value)+strlen(tmp2->value)+strlen(s->name)+strlen(toto->value)+13)*sizeof(char));
    15071540      sprintf(file_url,"%s/%s/%s_%i.%s",tmp3->value,tmp2->value,s->name,cpid+100000,toto->value);
    15081541      addToMap(request_outputs->content,"Reference",file_url);
     1542      if(hasExt!=true){
     1543        freeMap(&toto);
     1544        free(toto);
     1545      }
    15091546      toto=getMap(request_outputs->content,"value");
    1510       if(toto!=NULL)
    1511         fwrite(toto->value,sizeof(char),strlen(toto->value),ofile);
     1547      if(toto!=NULL && toto->value!=NULL)
     1548        fwrite(toto->value,1,(strlen(toto->value)+1)*sizeof(char),ofile);
    15121549      fclose(ofile);
    15131550      free(file_name);
     
    16011638  BIO_free_all(b64);
    16021639
    1603   fprintf(stderr,"BASE64 [%s] \n",buff);
    16041640  return buff;
    16051641}
     
    16101646  while(tmpInputs!=NULL){
    16111647    maps *tmpMaps=getMaps(out1,tmpInputs->name);
     1648    /*fprintf(stderr,"IN LOOP\n");
     1649    dumpElements(tmpInputs);
     1650    dumpMaps(tmpMaps);
     1651    fprintf(stderr,"/ IN LOOP\n");*/
    16121652    if(tmpMaps==NULL){
    16131653      map* tmpMap1=getMap(tmpInputs->content,"minOccurs");
     
    16171657        }
    16181658      maps* tmpMaps2=(maps*)malloc(MAPS_SIZE);
    1619       tmpMaps2->name=strdup((char*)tmpInputs->name);
     1659      tmpMaps2->name=strdup(tmpInputs->name);
    16201660      tmpMaps2->content=NULL;
    16211661      tmpMaps2->next=NULL;
     
    16251665        tmpIoType=tmpIoType->next;
    16261666      }
    1627       map *tmpMap=getMap(tmpMaps2->content,"value");
    1628       if(tmpMap==NULL)
    1629         addToMap(tmpMaps2->content,"value","NULL");
     1667      if(strncmp(type,"outputs",7)==0){
     1668        map *tmpMap=getMap(tmpMaps2->content,"value");
     1669        if(tmpMap==NULL)
     1670          addToMap(tmpMaps2->content,"value","NULL");
     1671      }
    16301672      if(out1==NULL){
    16311673        *out=dupMaps(&tmpMaps2);
     
    16381680    }
    16391681    else{
    1640       map* tmpContent=tmpInputs->defaults->content;
    1641      
    1642       map* cval=NULL;
    1643      
    1644       while(tmpContent!=NULL){
    1645         if((cval=getMap(tmpMaps->content,tmpContent->name))==NULL){
    1646 #ifdef DEBUG
    1647           fprintf(stderr,"addDefaultValues %s => %s\n",tmpContent->name,tmpContent->value);
    1648 #endif
    1649           if(tmpMaps->content==NULL)
    1650             tmpMaps->content=createMap(tmpContent->name,tmpContent->value);
    1651           else
    1652             addToMap(tmpMaps->content,tmpContent->name,tmpContent->value);
     1682      iotype* tmpIoType=getIoTypeFromElement(tmpInputs,tmpInputs->name,
     1683                                             tmpMaps->content);
     1684      if(tmpIoType!=NULL){
     1685        map* tmpContent=tmpIoType->content;
     1686        map* cval=NULL;
     1687
     1688        while(tmpContent!=NULL){
     1689          if((cval=getMap(tmpMaps->content,tmpContent->name))==NULL){
     1690#ifdef DEBUG
     1691            fprintf(stderr,"addDefaultValues %s => %s\n",tmpContent->name,tmpContent->value);
     1692#endif
     1693              if(tmpMaps->content==NULL)
     1694                tmpMaps->content=createMap(tmpContent->name,tmpContent->value);
     1695              else
     1696                addToMap(tmpMaps->content,tmpContent->name,tmpContent->value);
     1697          }
     1698          tmpContent=tmpContent->next;
    16531699        }
    1654         tmpContent=tmpContent->next;
    16551700      }
    16561701    }
  • trunk/zoo-kernel/service_internal_java.c

    r9 r57  
    104104      fprintf(stderr,"Function successfully loaded\n");
    105105#endif
     106      jclass scHashMapClass,scHashMap_class;
     107      jmethodID scHashMap_constructor;
     108      scHashMapClass = (*env)->FindClass(env, "java/util/HashMap");
     109      scHashMap_class = (*env)->NewGlobalRef(env, scHashMapClass);
     110      scHashMap_constructor = (*env)->GetMethodID(env, scHashMap_class, "<init>", "()V");
    106111      /**
    107112       * The 3 standard parameter for each services
    108113       */
    109       jobject arg1=HashMap_FromMaps(env,m);
    110       jobject arg2=HashMap_FromMaps(env,inputs);
    111       jobject arg3=HashMap_FromMaps(env,outputs);
     114      jobject arg1=HashMap_FromMaps(env,m,scHashMapClass,scHashMap_class,scHashMap_constructor);
     115      jobject arg2=HashMap_FromMaps(env,inputs,scHashMapClass,scHashMap_class,scHashMap_constructor);
     116      jobject arg3=HashMap_FromMaps(env,outputs,scHashMapClass,scHashMap_class,scHashMap_constructor);
    112117      jint pValue=0;
    113118
     
    115120      if (pValue != NULL){
    116121        res=pValue;
    117         //inputs=mapsFromHashMap(env,arg2);
    118         outputs=mapsFromHashMap(env,arg3);
     122        m=mapsFromHashMap(env,arg1,scHashMapClass);
     123        *main_conf=m;
     124        outputs=mapsFromHashMap(env,arg3,scHashMapClass);
    119125        *real_outputs=outputs;
    120126
     
    123129        dumpMaps(inputs);
    124130        dumpMaps(outputs);
    125         /*fprintf(stderr,"printProcessResponse(%i,\"%s\",%i,inputs,outputs);",
    126           getpid(),tmp->value,PyInt_AsLong(pValue));*/
    127131#endif
    128132      }else{     
     
    180184}
    181185
    182 jobject HashMap_FromMaps(JNIEnv *env,maps* t){
    183   jclass scHashMapClass,scHashMap_class;
    184   jmethodID scHashMap_constructor;
     186jobject HashMap_FromMaps(JNIEnv *env,maps* t,jclass scHashMapClass,jclass scHashMap_class,jmethodID scHashMap_constructor){
    185187  jobject scObject,scObject1;
    186   scHashMapClass = (*env)->FindClass(env, "java/util/HashMap");
    187   scHashMap_class = (*env)->NewGlobalRef(env, scHashMapClass);
    188   scHashMap_constructor = (*env)->GetMethodID(env, scHashMap_class, "<init>", "()V");   
    189188  if(scHashMap_constructor!=NULL){
    190189    scObject = (*env)->NewObject(env, scHashMap_class, scHashMap_constructor);
     
    204203      (*env)->CallObjectMethod(env,scObject, put_mid, (*env)->NewStringUTF(env,tmp->name), scObject1);
    205204      tmp=tmp->next;
    206     } 
     205    }
    207206    return scObject;
    208207  }
     
    211210}
    212211
    213 maps* mapsFromHashMap(JNIEnv *env,jobject t){
     212maps* mapsFromHashMap(JNIEnv *env,jobject t,jclass scHashMapClass){
    214213#ifdef DEBUG
    215214  fprintf(stderr,"mapsFromHashMap start\n");
     
    224223   * }
    225224   */
    226   jclass scHashMapClass,scHashMap_class,scSetClass,scIteratorClass,scMapEntryClass,scSet_class,scMapClass;
     225  jclass scHashMap_class,scSetClass,scIteratorClass,scMapEntryClass,scSet_class,scMapClass;
    227226  jmethodID entrySet_mid,iterator_mid,hasNext_mid,next_mid,getKey_mid,getValue_mid;
    228227  jobject scObject,scObject1;
    229   scHashMapClass=(*env)->GetObjectClass(env,t);
    230   //scMapClass=(*env)->FindClass(env, "java/util/HashMap");
    231   //scHashMapClass = (*env)->FindClass(env, "java/util/HashMap");
    232228  if(scHashMapClass==NULL){
    233229    fprintf(stderr,"Unable to load java.util.HashMap\n");
     
    276272  maps* final_res=NULL;
    277273  map* res=NULL;
    278 #ifdef DEBUG
    279   int i=0;
    280 #endif
    281274  while((*env)->CallBooleanMethod(env,final_iterator,hasNext_mid)){
    282 #ifdef DEBUG
    283     fprintf(stderr,"mapsFromHashMap loop %d\n",i);
    284     i++;
    285 #endif
    286275    jobject tmp=(*env)->CallObjectMethod(env,final_iterator,next_mid);
    287276
     
    289278    jobject set=(*env)->CallObjectMethod(env,imap,entrySet_mid);
    290279    jobject iterator=(*env)->CallObjectMethod(env,set,iterator_mid);
    291 #ifdef DEBUG
    292     int j=0;
    293 #endif
     280
    294281    while((*env)->CallBooleanMethod(env,iterator,hasNext_mid)){
    295 #ifdef DEBUG
    296       fprintf(stderr,"mapsFromHashMap internal loop %d\n",j);
    297       j++;
    298 #endif
    299282      jobject tmp1=(*env)->CallObjectMethod(env,iterator,next_mid);
    300283      jobject jk=(*env)->CallObjectMethod(env,tmp1,getKey_mid);
     
    310293        res=createMap((*env)->GetStringUTFChars(env, jk, NULL),
    311294                      (*env)->GetStringUTFChars(env, jv, NULL));
    312       }else
     295      }else{
    313296        addToMap(res,(*env)->GetStringUTFChars(env, jk, NULL),
    314297                 (*env)->GetStringUTFChars(env, jv, NULL));
     298      }
    315299    }
    316300    jobject jk=(*env)->CallObjectMethod(env,tmp,getKey_mid);
    317301    maps* cmap=(maps*)malloc(sizeof(maps));
    318302    cmap->name=(*env)->GetStringUTFChars(env, jk, NULL);
     303#ifdef DEBUG
     304    fprintf(stderr," / %s \n",cmap->name);
     305#endif
    319306    cmap->content=res;
    320307    cmap->next=NULL;
    321     if(final_res==NULL){
     308    if(final_res==NULL)
    322309      final_res=dupMaps(&cmap);
    323     }else
     310    else
    324311      addMapsToMaps(&final_res,cmap);
    325     final_res->next=NULL;
    326312    freeMaps(&cmap);
    327313    free(cmap);
  • trunk/zoo-kernel/service_internal_java.h

    r1 r57  
    3535extern "C" {
    3636#endif
    37 jobject HashMap_FromMaps(JNIEnv*,maps* t);
    38 
    39 maps* mapsFromHashMap(JNIEnv*,jobject t);
    40 
    41 int zoo_java_support(maps**,map*,service*,maps**,maps**);
     37  jobject HashMap_FromMaps(JNIEnv*,maps*,jclass,jclass,jmethodID);
     38 
     39  maps* mapsFromHashMap(JNIEnv*,jobject,jclass);
     40 
     41  int zoo_java_support(maps**,map*,service*,maps**,maps**);
    4242
    4343#ifdef __cplusplus
  • trunk/zoo-kernel/service_internal_python.c

    r45 r57  
    108108        //*real_inputs=mapsFromPyDict(arg2);
    109109        //createMapsFromPyDict(real_outputs,arg3);
     110        *main_conf=mapsFromPyDict(arg1);
    110111        *real_outputs=mapsFromPyDict(arg3);
    111112#ifdef DEBUG
  • trunk/zoo-kernel/zoo_service_loader.c

    r53 r57  
    177177#endif
    178178#ifdef DEBUG
    179 #ifdef WIN32<
     179#ifdef WIN32
    180180    DWORD errstr;
    181181    errstr = GetLastError();
     
    340340                *eres=-1;
    341341              }
     342  *myMap=m;
    342343  *ioutputs=request_output_real_format;
    343344}
     
    850851      free(REQUEST);
    851852      free(SERVICE_URL);
     853      InternetCloseHandle(hInternet);
     854      freeService(&s1);
     855      free(s1);
    852856      return 0;
    853857    }
     
    17881792  freeService(&s1);
    17891793  free(s1);
    1790   freeMaps(&m);
     1794  //For Python language support only
     1795  //freeMaps(&m);
    17911796  free(m);
    17921797 
Note: See TracChangeset for help on using the changeset viewer.

Search

Context Navigation

ZOO Sponsors

http://www.zoo-project.org/trac/chrome/site/img/geolabs-logo.pnghttp://www.zoo-project.org/trac/chrome/site/img/neogeo-logo.png http://www.zoo-project.org/trac/chrome/site/img/apptech-logo.png http://www.zoo-project.org/trac/chrome/site/img/3liz-logo.png http://www.zoo-project.org/trac/chrome/site/img/gateway-logo.png

Become a sponsor !

Knowledge partners

http://www.zoo-project.org/trac/chrome/site/img/ocu-logo.png http://www.zoo-project.org/trac/chrome/site/img/gucas-logo.png http://www.zoo-project.org/trac/chrome/site/img/polimi-logo.png http://www.zoo-project.org/trac/chrome/site/img/fem-logo.png http://www.zoo-project.org/trac/chrome/site/img/supsi-logo.png http://www.zoo-project.org/trac/chrome/site/img/cumtb-logo.png

Become a knowledge partner

Related links

http://zoo-project.org/img/ogclogo.png http://zoo-project.org/img/osgeologo.png