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.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • 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    }
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