Changeset 70 for trunk


Ignore:
Timestamp:
Jan 13, 2011, 4:11:31 AM (14 years ago)
Author:
djay
Message:

Small fix in ExecuteResponse? XML output. Store file for multiple/binary outputs with asReference set to true.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/zoo-kernel/service_internal.c

    r66 r70  
    13351335    tmp=m->content;
    13361336    while(tmp!=NULL){
    1337       if(strncasecmp(tmp->name,"value",strlen(tmp->name))!=0 &&
    1338          strncasecmp(tmp->name,"extension",strlen(tmp->name))!=0 &&
    1339          strncasecmp(tmp->name,"asReference",strlen(tmp->name))!=0 &&
    1340          strncasecmp(tmp->name,"status",strlen(tmp->name))!=0 &&
    1341          strncasecmp(tmp->name,"storeExecuteResponse",strlen(tmp->name))!=0 &&
    1342          strncasecmp(tmp->name,"extension",strlen(tmp->name))!=0 &&
    1343          strncasecmp(tmp->name,"format",strlen(tmp->name))!=0 &&
    1344          strncasecmp(tmp->name,"Title",strlen(tmp->name))!=0 &&
    1345          strncasecmp(tmp->name,"Abstract",strlen(tmp->name))!=0 &&
    1346          strncasecmp(tmp->name,"size",strlen(tmp->name))!=0)
     1337      if(strcasecmp(tmp->name,"mimeType")==0 ||
     1338         strcasecmp(tmp->name,"encoding")==0 ||
     1339         strcasecmp(tmp->name,"schema")==0 ||
     1340         strcasecmp(tmp->name,"datatype")==0 ||
     1341         strcasecmp(tmp->name,"uom")==0)
    13471342        xmlNewProp(nc3,BAD_CAST tmp->name,BAD_CAST tmp->value);
    13481343      tmp=tmp->next;
     
    13891384    tmp=m->content;
    13901385    while(tmp!=NULL){
    1391       if(strncasecmp(tmp->name,"value",strlen(tmp->name))!=0 &&
    1392          strncasecmp(tmp->name,"extension",strlen(tmp->name))!=0 &&
    1393          strncasecmp(tmp->name,"asReference",strlen(tmp->name))!=0 &&
    1394          strncasecmp(tmp->name,"status",strlen(tmp->name))!=0 &&
    1395          strncasecmp(tmp->name,"storeExecuteResponse",strlen(tmp->name))!=0 &&
    1396          strncasecmp(tmp->name,"extension",strlen(tmp->name))!=0 &&
    1397          strncasecmp(tmp->name,"format",strlen(tmp->name))!=0 &&
    1398          strncasecmp(tmp->name,"Title",strlen(tmp->name))!=0 &&
    1399          strncasecmp(tmp->name,"Abstract",strlen(tmp->name))!=0 &&
    1400          strncasecmp(tmp->name,"size",strlen(tmp->name))!=0)
     1386      if(strcasecmp(tmp->name,"mimeType")==0 ||
     1387         strcasecmp(tmp->name,"encoding")==0 ||
     1388         strcasecmp(tmp->name,"schema")==0 ||
     1389         strcasecmp(tmp->name,"datatype")==0 ||
     1390         strcasecmp(tmp->name,"uom")==0)
    14011391        xmlNewProp(nc3,BAD_CAST tmp->name,BAD_CAST tmp->value);
    14021392      tmp=tmp->next;
     
    15491539    dumpMaps(request_outputs);
    15501540#endif
    1551     toto=getMap(request_outputs->content,"asReference");
    1552     if(toto!=NULL && strcasecmp(toto->value,"true")==0){
    1553       toto=getMap(request_outputs->content,"extension");
    1554       map *tmp1=getMapFromMaps(m,"main","tmpPath");
    1555       char *file_name;
    1556       bool hasExt=true;
    1557       if(toto==NULL){
    1558         // We can fallback to a default list of supported formats using
    1559         // mimeType information if present here. Maybe we can add more formats
    1560         // here.
    1561         // If mimeType was not found, we then set txt as the default extension.
    1562         map* mtype=getMap(request_outputs->content,"mimeType");
    1563         if(mtype!=NULL){
    1564           if(strcasecmp(mtype->value,"text/xml")==0)
    1565             toto=createMap("extension","xml");
     1541    maps* tmpI=request_outputs;
     1542    while(tmpI!=NULL){
     1543      toto=getMap(tmpI->content,"asReference");
     1544      if(toto!=NULL && strcasecmp(toto->value,"true")==0){
     1545
     1546        toto=getMap(tmpI->content,"extension");
     1547        map *tmp1=getMapFromMaps(m,"main","tmpPath");
     1548        char *file_name;
     1549        bool hasExt=true;
     1550        if(toto==NULL){
     1551          dumpMaps(tmpI);
     1552          // We can fallback to a default list of supported formats using
     1553          // mimeType information if present here. Maybe we can add more formats
     1554          // here.
     1555          // If mimeType was not found, we then set txt as the default extension.
     1556          map* mtype=getMap(tmpI->content,"mimeType");
     1557          if(mtype!=NULL){
     1558            if(strcasecmp(mtype->value,"text/xml")==0)
     1559              toto=createMap("extension","xml");
     1560            else if(strcasecmp(mtype->value,"application/json")==0)
     1561              toto=createMap("extension","js");
     1562            else
     1563              toto=createMap("extension","txt");
     1564          }
    15661565          else
    15671566            toto=createMap("extension","txt");
    1568         }
     1567          hasExt=false;
     1568        }
     1569        file_name=(char*)malloc((strlen(tmp1->value)+strlen(s->name)+strlen(toto->value)+strlen(tmpI->name)+13)*sizeof(char));
     1570        sprintf(file_name,"%s/%s_%s_%i.%s",tmp1->value,s->name,tmpI->name,cpid+100000,toto->value);
     1571        FILE *ofile=fopen(file_name,"w");
     1572        if(ofile==NULL)
     1573          fprintf(stderr,"Unable to create file on disk implying segfault ! \n");
     1574        map *tmp2=getMapFromMaps(m,"main","tmpUrl");
     1575        map *tmp3=getMapFromMaps(m,"main","serverAddress");
     1576        char *file_url;
     1577        file_url=(char*)malloc((strlen(tmp3->value)+strlen(tmp2->value)+strlen(s->name)+strlen(toto->value)+strlen(tmpI->name)+13)*sizeof(char));
     1578        sprintf(file_url,"%s/%s/%s_%s_%i.%s",tmp3->value,tmp2->value,s->name,tmpI->name,cpid+100000,toto->value);
     1579        addToMap(tmpI->content,"Reference",file_url);
     1580        if(hasExt!=true){
     1581          freeMap(&toto);
     1582          free(toto);
     1583        }
     1584        toto=getMap(tmpI->content,"value");
     1585        map* size=getMap(tmpI->content,"size");
     1586        if(size!=NULL && toto!=NULL)
     1587          fwrite(toto->value,1,atoi(size->value)*sizeof(char),ofile);
    15691588        else
    1570           toto=createMap("extension","txt");
    1571         hasExt=false;
    1572       }
    1573       file_name=(char*)malloc((strlen(tmp1->value)+strlen(s->name)+strlen(toto->value)+13)*sizeof(char));
    1574       sprintf(file_name,"%s/%s_%i.%s",tmp1->value,s->name,cpid+100000,toto->value);
    1575       FILE *ofile=fopen(file_name,"w");
    1576       if(ofile==NULL)
    1577         fprintf(stderr,"Unable to create file on disk implying segfault ! \n");
    1578       map *tmp2=getMapFromMaps(m,"main","tmpUrl");
    1579       map *tmp3=getMapFromMaps(m,"main","serverAddress");
    1580       char *file_url;
    1581       file_url=(char*)malloc((strlen(tmp3->value)+strlen(tmp2->value)+strlen(s->name)+strlen(toto->value)+13)*sizeof(char));
    1582       sprintf(file_url,"%s/%s/%s_%i.%s",tmp3->value,tmp2->value,s->name,cpid+100000,toto->value);
    1583       addToMap(request_outputs->content,"Reference",file_url);
    1584       if(hasExt!=true){
    1585         freeMap(&toto);
    1586         free(toto);
    1587       }
    1588       toto=getMap(request_outputs->content,"value");
    1589       if(toto!=NULL && toto->value!=NULL)
    1590         fwrite(toto->value,1,(strlen(toto->value)+1)*sizeof(char),ofile);
    1591       fclose(ofile);
    1592       free(file_name);
    1593       free(file_url);
     1589        if(toto!=NULL && toto->value!=NULL)
     1590          fwrite(toto->value,1,strlen(toto->value)*sizeof(char),ofile);
     1591        fclose(ofile);
     1592        free(file_name);
     1593        free(file_url);
     1594      }
     1595      tmpI=tmpI->next;
    15941596    }
    15951597    map *r_inputs=getMap(s->content,"serviceProvider");
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