Changeset 888 for branches


Ignore:
Timestamp:
Nov 16, 2018, 3:09:05 PM (5 years ago)
Author:
djay
Message:

Add support for output style definition depending on geometry type (msStylePoly, msStylePoint, msStrylLine). Upload shared data in remote_persitent_data_path rather than remote_data_path (used for not shared data). In case output data should be published and the data is empty (nb_pixels or nb_features is set to 0) then, the ZOO-Kernel returns an ExceptionReport? with an Exception for every output.

Location:
branches/prototype-v0/zoo-project/zoo-kernel
Files:
5 edited

Legend:

Unmodified
Added
Removed
  • branches/prototype-v0/zoo-project/zoo-kernel/caching.c

    r886 r888  
    411411    char *mimeType=NULL;
    412412    int fsize=0;
     413    char oriname[12];
    413414    char cname[15];
    414415    char vname[11];
     
    430431      sprintf(cname,"cache_file_%d",i);
    431432      tmp1=getMap(content->content,cname);
     433      sprintf(oriname,"origin_%d",i);
    432434      sprintf(vname,"value_%d",i);
    433435      sprintf(sname,"size_%d",i);
     
    441443    }else{
    442444      sprintf(cname,"cache_file");
     445      sprintf(oriname,"origin");
    443446      sprintf(vname,"value");
    444447      sprintf(sname,"size");
     
    539542        addToMap((*in)->content,sname,ltmp1);
    540543        addToMap((*in)->content,mname,mimeType);
     544        char* origin=getProvenance(*m,request);
     545        addToMap((*in)->content,oriname,origin);
    541546        if(memUse==NULL || strcasecmp(memUse->value,"load")==0){
    542547          addToCache(*m,request,fcontent,mimeType,fsize, NULL, 0);
     
    632637  char* cached=isInCache(*m,url);
    633638  char *mimeType=NULL;
     639  char *origin=NULL;
    634640  int fsize=0;
    635641  map* memUse=getMapFromMaps(*m,"main","memory");
     
    674680      unlockFile(*m,lck);
    675681    }
     682    cached[strlen(cached)-1]='p';
     683    s=stat(cached, &f_status);
     684    if(s==0){
     685      zooLock* lck=lockFile(*m,cached,'r');
     686      if(lck==NULL)
     687        return -1;
     688      origin=(char*)malloc(sizeof(char)*(f_status.st_size+1));
     689      FILE* f=fopen(cached,"rb");
     690      fread(origin,f_status.st_size,1,f);
     691      mimeType[f_status.st_size]=0;
     692      fclose(f);
     693      unlockFile(*m,lck);
     694    }
    676695  }else{   
    677696    addRequestToQueue(m,hInternet,url,true);
     
    683702  if(mimeType!=NULL){
    684703    addToMap(*content,"fmimeType",mimeType);
     704  }
     705  if(origin!=NULL){
     706    addToMap(*content,"origin",origin);
    685707  }
    686708
  • branches/prototype-v0/zoo-project/zoo-kernel/response_print.c

    r877 r888  
    3333#include "cpl_vsi.h"
    3434#endif
     35#ifdef USE_HPC
     36#include "service_callback.h"
     37#endif
    3538
    3639#ifndef TRUE
     
    362365      nc4 = xmlNewNode(ns_ows, BAD_CAST "Language");
    363366      xmlAddChild(nc4,xmlNewText(BAD_CAST buff));             
    364         if(vid==0)
    365           xmlAddChild(nc3,nc4);
    366         else
    367           xmlAddChild(nc1,nc4);
     367      if(vid==0)
     368        xmlAddChild(nc3,nc4);
     369      else
     370        xmlAddChild(nc1,nc4);
    368371    }
    369372  }
     
    753756 */
    754757void addMetadata(map* meta,xmlDocPtr doc,xmlNodePtr nc,xmlNsPtr ns_ows,xmlNsPtr ns_xlink,int vid){
    755     int hasTitle=-1;
    756     int hasValue=-1;
    757     xmlNodePtr nc1;
    758     map* oMeta=meta;
    759     int isAdditionalParameters=-1;
    760     int level=0;
    761     map* test=getMap(meta,"title");
    762     if(test!=NULL)
    763       level+=1;
    764     test=getMap(meta,"href");
    765     if(test!=NULL)
    766       level+=1;
    767     test=getMap(meta,"role");
    768     if(test!=NULL)
    769       level+=1;
    770     if(count(oMeta)>level+1)
    771       isAdditionalParameters=1;
    772     char *ctitle=NULL;
    773     while(meta!=NULL){
    774       if(hasTitle<0)
    775         if(isAdditionalParameters<0)
    776           nc1 = xmlNewNode(ns_ows, BAD_CAST "Metadata");
    777         else
    778           if(hasValue<0)
    779             nc1 = xmlNewNode(ns_ows, BAD_CAST "AdditionalParameters");
    780       if(strncasecmp(meta->name,"title",5)==0 ||
    781         strcasecmp(meta->name,"href")==0 ||
    782         strcasecmp(meta->name,"role")==0 ){
    783         int index=5;
    784         if(strncasecmp(meta->name,"title",5)==0){
    785           index=6;
    786           hasTitle=1;
    787           if(ctitle!=NULL && strcasecmp(meta->value,ctitle)!=0){
    788               xmlAddChild(nc,nc1);
    789               nc1 = xmlNewNode(ns_ows, BAD_CAST "AdditionalParameters");
    790               free(ctitle);
    791               ctitle=NULL;
    792           }
    793           if(ctitle==NULL){
    794             char *tmp=(char*)malloc((strlen(meta->name)+1)*sizeof(char));
    795             snprintf(tmp,index,"%s",meta->name);
    796             xmlNewNsProp(nc1,ns_xlink,BAD_CAST tmp,BAD_CAST meta->value);
    797             free(tmp);
    798           }       
    799           if(ctitle!=NULL)
    800             free(ctitle);
    801           ctitle=zStrdup(meta->value);
    802         }
    803       }else{
    804         xmlNodePtr nc2 = xmlNewNode(ns_ows, BAD_CAST "AdditionalParameter");
    805         xmlNodePtr nc3 = xmlNewNode(ns_ows, BAD_CAST "Name");
    806         xmlAddChild(nc3,xmlNewText(BAD_CAST meta->name));
    807         xmlNodePtr nc4 = xmlNewNode(ns_ows, BAD_CAST "Value");
    808         xmlAddChild(nc4,xmlNewText(BAD_CAST meta->value));
    809         xmlAddChild(nc2,nc3);
    810         xmlAddChild(nc2,nc4);
    811         xmlAddChild(nc1,nc2);
    812         hasTitle=-1;
    813       }
    814       meta=meta->next;
    815       if(hasTitle<0){
    816         hasValue=1;
    817         if(isAdditionalParameters){
    818           if(vid==0){
    819             meta=NULL;
    820             break;
    821           }else
    822             xmlAddChild(nc,nc1);
    823         }
    824       }
    825     }
    826     if(oMeta!=NULL && hasValue<0 && nc1!=NULL){
    827       xmlAddChild(nc,nc1);
    828     }
     758  int hasTitle=-1;
     759  int hasValue=-1;
     760  xmlNodePtr nc1;
     761  map* oMeta=meta;
     762  int isAdditionalParameters=-1;
     763  int level=0;
     764  map* test=getMap(meta,"title");
     765  if(test!=NULL)
     766    level+=1;
     767  test=getMap(meta,"href");
     768  if(test!=NULL)
     769    level+=1;
     770  test=getMap(meta,"role");
     771  if(test!=NULL)
     772    level+=1;
     773  if(count(oMeta)>level+1)
     774    isAdditionalParameters=1;
     775  char *ctitle=NULL;
     776  while(meta!=NULL){
     777    if(hasTitle<0)
     778      if(isAdditionalParameters<0)
     779        nc1 = xmlNewNode(ns_ows, BAD_CAST "Metadata");
     780      else
     781        if(hasValue<0)
     782          nc1 = xmlNewNode(ns_ows, BAD_CAST "AdditionalParameters");
     783    if(strncasecmp(meta->name,"title",5)==0 ||
     784      strcasecmp(meta->name,"href")==0 ||
     785      strcasecmp(meta->name,"role")==0 ){
     786      int index=5;
     787      if(strncasecmp(meta->name,"title",5)==0){
     788        index=6;
     789        hasTitle=1;
     790        if(ctitle!=NULL && strcasecmp(meta->value,ctitle)!=0){
     791          xmlAddChild(nc,nc1);
     792          nc1 = xmlNewNode(ns_ows, BAD_CAST "AdditionalParameters");
     793          free(ctitle);
     794          ctitle=NULL;
     795        }
     796        if(ctitle==NULL){
     797          char *tmp=(char*)malloc((strlen(meta->name)+1)*sizeof(char));
     798          snprintf(tmp,index,"%s",meta->name);
     799          xmlNewNsProp(nc1,ns_xlink,BAD_CAST tmp,BAD_CAST meta->value);
     800          free(tmp);
     801        }         
     802        if(ctitle!=NULL)
     803          free(ctitle);
     804        ctitle=zStrdup(meta->value);
     805      }
     806    }else{
     807      xmlNodePtr nc2 = xmlNewNode(ns_ows, BAD_CAST "AdditionalParameter");
     808      xmlNodePtr nc3 = xmlNewNode(ns_ows, BAD_CAST "Name");
     809      xmlAddChild(nc3,xmlNewText(BAD_CAST meta->name));
     810      xmlNodePtr nc4 = xmlNewNode(ns_ows, BAD_CAST "Value");
     811      xmlAddChild(nc4,xmlNewText(BAD_CAST meta->value));
     812      xmlAddChild(nc2,nc3);
     813      xmlAddChild(nc2,nc4);
     814      xmlAddChild(nc1,nc2);
     815      hasTitle=-1;
     816    }
     817    meta=meta->next;
     818    if(hasTitle<0){
     819      hasValue=1;
     820      if(isAdditionalParameters){
     821        if(vid==0){
     822          meta=NULL;
     823          break;
     824        }else
     825          xmlAddChild(nc,nc1);
     826      }
     827    }
     828  }
     829  if(oMeta!=NULL && hasValue<0 && nc1!=NULL){
     830    xmlAddChild(nc,nc1);
     831  }
    829832}
    830833
     
    840843 */
    841844void addAdditionalParameters(map* meta,xmlDocPtr doc,xmlNodePtr nc,xmlNsPtr ns_ows,xmlNsPtr ns_xlink,int fromDb){
    842     int hasTitle=-1;
    843     int hasValue=-1;
    844     int toAddAtEnd=-1;
    845     int cnt=0;
    846     xmlNodePtr* ncr=NULL;
    847     xmlNodePtr nc1;
    848     map* oMeta=meta;
    849     int isAdditionalParameters=-1;
    850     int level=0;
    851     map* test=getMap(meta,"title");
    852     map* otitle=getMap(meta,"title");
    853     map* length=getMap(meta,"length");
    854     int len=0;
    855     char *ctitle=NULL;
     845  int hasTitle=-1;
     846  int hasValue=-1;
     847  int toAddAtEnd=-1;
     848  int cnt=0;
     849  xmlNodePtr* ncr=NULL;
     850  xmlNodePtr nc1;
     851  map* oMeta=meta;
     852  int isAdditionalParameters=-1;
     853  int level=0;
     854  map* test=getMap(meta,"title");
     855  map* otitle=getMap(meta,"title");
     856  map* length=getMap(meta,"length");
     857  int len=0;
     858  char *ctitle=NULL;
    856859   
    857     if(test!=NULL)
    858       level+=1;
    859     test=getMap(meta,"href");
    860     if(test!=NULL)
    861       level+=1;
    862     test=getMap(meta,"role");
    863     if(test!=NULL)
    864       level+=1;
    865     if(count(oMeta)>level+1)
    866       isAdditionalParameters=1;
    867 
    868     while(meta!=NULL){
    869       if(hasTitle<0 && hasValue<0){
    870         nc1 = xmlNewNode(ns_ows, BAD_CAST "AdditionalParameters");
    871       }
    872       if(strncasecmp(meta->name,"title",5)==0 ||
    873          strcasecmp(meta->name,"href")==0 ||
    874          strcasecmp(meta->name,"role")==0 ){
    875         int index=5;
    876         if(strncasecmp(meta->name,"title",5)==0){
    877           index=6;
    878           hasTitle=1;
    879           if(ctitle!=NULL && strcasecmp(meta->value,ctitle)!=0){
    880             xmlNodePtr ncTmp = xmlDocCopyNodeList(doc,nc1);
    881             xmlAddChild(nc,ncTmp);
    882             xmlFreeNode(nc1);
    883             toAddAtEnd=1;
    884             cnt++;
    885             nc1 = xmlNewNode(ns_ows, BAD_CAST "AdditionalParameters");
    886             free(ctitle);
    887             ctitle=NULL;
    888           }
    889           if(ctitle==NULL){
    890             char *tmp=(char*)malloc((strlen(meta->name)+1)*sizeof(char));
    891             snprintf(tmp,index,"%s",meta->name);
    892             xmlNewNsProp(nc1,ns_xlink,BAD_CAST tmp,BAD_CAST meta->value);
    893             free(tmp);
    894           }       
    895           if(ctitle!=NULL)
    896             free(ctitle);
    897           ctitle=zStrdup(meta->value);
     860  if(test!=NULL)
     861    level+=1;
     862  test=getMap(meta,"href");
     863  if(test!=NULL)
     864    level+=1;
     865  test=getMap(meta,"role");
     866  if(test!=NULL)
     867    level+=1;
     868  if(count(oMeta)>level+1)
     869    isAdditionalParameters=1;
     870
     871  while(meta!=NULL){
     872    if(hasTitle<0 && hasValue<0){
     873      nc1 = xmlNewNode(ns_ows, BAD_CAST "AdditionalParameters");
     874    }
     875    if(strncasecmp(meta->name,"title",5)==0 ||
     876       strcasecmp(meta->name,"href")==0 ||
     877       strcasecmp(meta->name,"role")==0 ){
     878      int index=5;
     879      if(strncasecmp(meta->name,"title",5)==0){
     880        index=6;
     881        hasTitle=1;
     882        if(ctitle!=NULL && strcasecmp(meta->value,ctitle)!=0){
     883          xmlNodePtr ncTmp = xmlDocCopyNodeList(doc,nc1);
     884          xmlAddChild(nc,ncTmp);
     885          xmlFreeNode(nc1);
     886          toAddAtEnd=1;
     887          cnt++;
     888          nc1 = xmlNewNode(ns_ows, BAD_CAST "AdditionalParameters");
     889          free(ctitle);
     890          ctitle=NULL;
     891        }
     892        if(ctitle==NULL){
     893          char *tmp=(char*)malloc((strlen(meta->name)+1)*sizeof(char));
     894          snprintf(tmp,index,"%s",meta->name);
     895          xmlNewNsProp(nc1,ns_xlink,BAD_CAST tmp,BAD_CAST meta->value);
     896          free(tmp);
     897        }         
     898        if(ctitle!=NULL)
     899          free(ctitle);
     900        ctitle=zStrdup(meta->value);
     901      }else{
     902        xmlNewNsProp(nc1,ns_xlink,BAD_CAST meta->name,BAD_CAST meta->value);
     903      }
     904    }else{
     905      if(strncasecmp(meta->name,"length",6)!=0 && strncasecmp(meta->name,"fromDb",6)!=0){
     906        xmlNodePtr nc2 = xmlNewNode(ns_ows, BAD_CAST "AdditionalParameter");
     907        xmlNodePtr nc3 = xmlNewNode(ns_ows, BAD_CAST "Name");
     908        xmlAddChild(nc3,xmlNewText(BAD_CAST meta->name));
     909        xmlAddChild(nc2,nc3);
     910        if(fromDb<0){
     911          char *mptr;
     912          char* meta_values=strtok_r(meta->value,",",&mptr);
     913          while(meta_values!=NULL){
     914            xmlNodePtr nc4 = xmlNewNode(ns_ows, BAD_CAST "Value");
     915            xmlAddChild(nc4,xmlNewText(BAD_CAST meta_values));
     916            xmlAddChild(nc2,nc4);
     917            meta_values=strtok_r(NULL,",",&mptr);
     918          }
    898919        }else{
    899           xmlNewNsProp(nc1,ns_xlink,BAD_CAST meta->name,BAD_CAST meta->value);
    900         }
    901       }else{
    902         if(strncasecmp(meta->name,"length",6)!=0 && strncasecmp(meta->name,"fromDb",6)!=0){
    903           xmlNodePtr nc2 = xmlNewNode(ns_ows, BAD_CAST "AdditionalParameter");
    904           xmlNodePtr nc3 = xmlNewNode(ns_ows, BAD_CAST "Name");
    905           xmlAddChild(nc3,xmlNewText(BAD_CAST meta->name));
    906           xmlAddChild(nc2,nc3);
    907           if(fromDb<0){
    908             char *mptr;
    909             char* meta_values=strtok_r(meta->value,",",&mptr);
    910             while(meta_values!=NULL){
    911               xmlNodePtr nc4 = xmlNewNode(ns_ows, BAD_CAST "Value");
    912               xmlAddChild(nc4,xmlNewText(BAD_CAST meta_values));
    913               xmlAddChild(nc2,nc4);
    914               meta_values=strtok_r(NULL,",",&mptr);
    915             }
    916           }else{
    917             xmlNodePtr nc4 = xmlNewNode(ns_ows, BAD_CAST "Value");
    918             xmlAddChild(nc4,xmlNewCDataBlock(doc,BAD_CAST meta->value,strlen(meta->value)));
    919             xmlAddChild(nc2,nc4);
    920           }
    921           xmlAddChild(nc1,nc2);
    922         }
    923         hasTitle=-1;
    924       }
    925       meta=meta->next;
    926       if(hasTitle<0){
    927         //xmlAddChild(nc,nc1);
    928         hasValue=1;
    929       }/*else
    930         if(ctitle!=NULL)
    931         free(ctitle);*/
    932     }
    933     if(length!=NULL)
    934       len=atoi(length->value);
    935     if(otitle!=NULL)
    936       len=1;
    937     if(cnt<len){
    938       xmlAddChild(nc,nc1);
    939       free(ctitle);
    940     }
     920          xmlNodePtr nc4 = xmlNewNode(ns_ows, BAD_CAST "Value");
     921          xmlAddChild(nc4,xmlNewCDataBlock(doc,BAD_CAST meta->value,strlen(meta->value)));
     922          xmlAddChild(nc2,nc4);
     923        }
     924        xmlAddChild(nc1,nc2);
     925      }
     926      hasTitle=-1;
     927    }
     928    meta=meta->next;
     929    if(hasTitle<0){
     930      //xmlAddChild(nc,nc1);
     931      hasValue=1;
     932    }/*else
     933       if(ctitle!=NULL)
     934       free(ctitle);*/
     935  }
     936  if(length!=NULL)
     937    len=atoi(length->value);
     938  if(otitle!=NULL)
     939    len=1;
     940  if(cnt<len){
     941    xmlAddChild(nc,nc1);
     942    free(ctitle);
     943  }
    941944}
    942945
     
    19992002        if(testResponse==NULL || tmp0==NULL){
    20002003          if(vid==0)
    2001               printIOType(doc,nc,ns,ns_ows,ns_xlink,scursor,mcursor,"Output",vid);
     2004            printIOType(doc,nc,ns,ns_ows,ns_xlink,scursor,mcursor,"Output",vid);
    20022005          else
    2003               printIOType(doc,n,ns,ns_ows,ns_xlink,scursor,mcursor,"Output",vid);
     2006            printIOType(doc,n,ns,ns_ows,ns_xlink,scursor,mcursor,"Output",vid);
    20042007        }
    20052008        else
     
    21372140  else{
    21382141    /*
    2139     dumpElements(e);
     2142      dumpElements(e);
    21402143    */
    21412144    return;
     
    21462149       || strncasecmp(tmp->name,"SCHEMA",strlen(tmp->name))==0
    21472150       || strncasecmp(tmp->name,"UOM",strlen(tmp->name))==0)
    2148     xmlNewProp(nc1,BAD_CAST tmp->name,BAD_CAST tmp->value);
     2151      xmlNewProp(nc1,BAD_CAST tmp->name,BAD_CAST tmp->value);
    21492152    tmp=tmp->next;
    21502153  }
     
    23522355             strstr(tmp2->value, "json") != NULL ||            //    (will not be parsed by XML reader)
    23532356             strstr(tmp2->value, "ecmascript") != NULL
    2354            ) {
     2357             ) {
    23552358            xmlAddChild((vid==0?nc3:nc2),xmlNewCDataBlock(doc,BAD_CAST tmp3->value,strlen(tmp3->value)));
    23562359          }   
     
    23582361            if (strstr(tmp2->value, "xml") != NULL ||                 // if XML-based format
    23592362                // include for backwards compatibility,
    2360               // although correct mime type is ...kml+xml:                 
     2363                // although correct mime type is ...kml+xml:               
    23612364                strstr(tmp2->value, "google-earth.kml") != NULL
    23622365                ) {
     
    25802583
    25812584    tmp=getMapArray(s,"text",cnt);
     2585    if(tmp==NULL)
     2586      tmp=getMapArray(s,"message",cnt);
    25822587    nc1 = xmlNewNode(ns, BAD_CAST "ExceptionText");
    25832588    if(tmp!=NULL){
     
    27412746    map* usid=getMapFromMaps(m,"lenv","usid");
    27422747    int itn=0;
     2748    int error=-1;
    27432749  NESTED0:
    27442750    while(tmpI!=NULL){
     
    27682774          (geodatatype!=NULL && strcasecmp(geodatatype->value,"other")==0) ) )
    27692775#else
    2770       if(toto!=NULL && strcasecmp(toto->value,"true")==0)
     2776        if(toto!=NULL && strcasecmp(toto->value,"true")==0)
    27712777#endif
    2772         {
    2773           elements* in=getElements(s->outputs,tmpI->name);
    2774           if(in==NULL && s->outputs->child!=NULL){
    2775             in=getElements(s->outputs->child,tmpI->name);
    2776           }
    2777           char *format=NULL;
    2778           if(in!=NULL && in->format!=NULL){
    2779             format=in->format;
    2780           }else
    2781             format=(char*)"LiteralData";
    2782           if(format!=NULL && strcasecmp(format,"BoundingBoxData")==0){
    2783             addToMap(tmpI->content,"extension","xml");
    2784             addToMap(tmpI->content,"mimeType","text/xml");
    2785             addToMap(tmpI->content,"encoding","UTF-8");
    2786             addToMap(tmpI->content,"schema","http://schemas.opengis.net/ows/1.1.0/owsCommon.xsd");
    2787           }
    2788 
    2789           char *file_path=NULL;
    2790           if(gfile==NULL) {
    2791             map *ext=getMap(tmpI->content,"extension");
    2792             char file_ext[32];
     2778          {
     2779            elements* in=getElements(s->outputs,tmpI->name);
     2780            if(in==NULL && s->outputs->child!=NULL){
     2781              in=getElements(s->outputs->child,tmpI->name);
     2782            }
     2783            char *format=NULL;
     2784            if(in!=NULL && in->format!=NULL){
     2785              format=in->format;
     2786            }else
     2787              format=(char*)"LiteralData";
     2788            if(format!=NULL && strcasecmp(format,"BoundingBoxData")==0){
     2789              addToMap(tmpI->content,"extension","xml");
     2790              addToMap(tmpI->content,"mimeType","text/xml");
     2791              addToMap(tmpI->content,"encoding","UTF-8");
     2792              addToMap(tmpI->content,"schema","http://schemas.opengis.net/ows/1.1.0/owsCommon.xsd");
     2793            }
     2794
     2795            char *file_path=NULL;
     2796            if(gfile==NULL) {
     2797              map *ext=getMap(tmpI->content,"extension");
     2798              char file_ext[32];
    27932799           
    2794             if( ext != NULL && ext->value != NULL) {
    2795               strncpy(file_ext, ext->value, 32);
     2800              if( ext != NULL && ext->value != NULL) {
     2801                strncpy(file_ext, ext->value, 32);
     2802              }
     2803              else {
     2804                // Obtain default file extension (see mimetypes.h).           
     2805                // If the MIME type is not recognized, txt is used as the default extension
     2806                map* mtype=getMap(tmpI->content,"mimeType");
     2807                getFileExtension(mtype != NULL ? mtype->value : NULL, file_ext, 32);
     2808              }
     2809              if(file_name!=NULL)
     2810                free(file_name);
     2811              file_name=(char*)malloc((strlen(s->name)+strlen(usid->value)+strlen(file_ext)+strlen(tmpI->name)+45)*sizeof(char));
     2812              sprintf(file_name,"ZOO_DATA_%s_%s_%s_%d.%s",s->name,tmpI->name,usid->value,itn,file_ext);
     2813              itn++;
     2814              file_path=(char*)malloc((strlen(tmp1->value)+strlen(file_name)+2)*sizeof(char));
     2815              sprintf(file_path,"%s/%s",tmp1->value,file_name);
     2816
     2817              FILE *ofile=fopen(file_path,"wb");
     2818              if(ofile==NULL){
     2819                char tmpMsg[1024];
     2820                sprintf(tmpMsg,_("Unable to create the file \"%s\" for storing the %s final result."),file_name,tmpI->name);
     2821                errorException(m,tmpMsg,"InternalError",NULL);
     2822                free(file_name);
     2823                free(file_path);
     2824                return;
     2825              }
     2826
     2827              toto=getMap(tmpI->content,"value");
     2828              if(toto==NULL){
     2829                char tmpMsg[1024];
     2830                sprintf(tmpMsg,_("No value found for the requested output %s."),tmpI->name);
     2831                errorException(m,tmpMsg,"InternalError",NULL);
     2832                fclose(ofile);
     2833                free(file_name);
     2834                free(file_path);
     2835                return;
     2836              }
     2837              if(strcasecmp(format,"BoundingBoxData")!=0){
     2838                map* size=getMap(tmpI->content,"size");
     2839                if(size!=NULL && toto!=NULL)
     2840                  fwrite(toto->value,1,(atoi(size->value))*sizeof(char),ofile);
     2841                else
     2842                  if(toto!=NULL && toto->value!=NULL)
     2843                    fwrite(toto->value,1,strlen(toto->value)*sizeof(char),ofile);
     2844              }else{
     2845                printBoundingBoxDocument(m,tmpI,ofile);
     2846              }
     2847              fclose(ofile);
    27962848            }
    2797             else {
    2798               // Obtain default file extension (see mimetypes.h).             
    2799               // If the MIME type is not recognized, txt is used as the default extension
    2800               map* mtype=getMap(tmpI->content,"mimeType");
    2801               getFileExtension(mtype != NULL ? mtype->value : NULL, file_ext, 32);
     2849
     2850            map *tmp2=getMapFromMaps(m,"main","tmpUrl");
     2851            map *tmp3=getMapFromMaps(m,"main","serverAddress");
     2852            char *file_url=NULL;
     2853            if(strncasecmp(tmp2->value,"http://",7)==0 ||
     2854               strncasecmp(tmp2->value,"https://",8)==0){
     2855              file_url=(char*)malloc((strlen(tmp2->value)+strlen(file_name)+2)*sizeof(char));
     2856              sprintf(file_url,"%s/%s",tmp2->value,file_name);
     2857            }else{
     2858              file_url=(char*)malloc((strlen(tmp3->value)+strlen(tmp2->value)+strlen(file_name)+3)*sizeof(char));
     2859              sprintf(file_url,"%s/%s/%s",tmp3->value,tmp2->value,file_name);
    28022860            }
     2861            addToMap(tmpI->content,"Reference",file_url);
    28032862            if(file_name!=NULL)
    28042863              free(file_name);
    2805             file_name=(char*)malloc((strlen(s->name)+strlen(usid->value)+strlen(file_ext)+strlen(tmpI->name)+45)*sizeof(char));
    2806             sprintf(file_name,"ZOO_DATA_%s_%s_%s_%d.%s",s->name,tmpI->name,usid->value,itn,file_ext);
    2807             itn++;
    2808             file_path=(char*)malloc((strlen(tmp1->value)+strlen(file_name)+2)*sizeof(char));
    2809             sprintf(file_path,"%s/%s",tmp1->value,file_name);
    2810 
    2811             FILE *ofile=fopen(file_path,"wb");
    2812             if(ofile==NULL){
    2813               char tmpMsg[1024];
    2814               sprintf(tmpMsg,_("Unable to create the file \"%s\" for storing the %s final result."),file_name,tmpI->name);
    2815               errorException(m,tmpMsg,"InternalError",NULL);
    2816               free(file_name);
    2817               free(file_path);
    2818               return;
    2819             }
    2820 
    2821             toto=getMap(tmpI->content,"value");
    2822             if(toto==NULL){
    2823               char tmpMsg[1024];
    2824               sprintf(tmpMsg,_("No value found for the requested output %s."),tmpI->name);
    2825               errorException(m,tmpMsg,"InternalError",NULL);
    2826               fclose(ofile);
    2827               free(file_name);
    2828               free(file_path);
    2829               return;
    2830             }
    2831             if(strcasecmp(format,"BoundingBoxData")!=0){
    2832               map* size=getMap(tmpI->content,"size");
    2833               if(size!=NULL && toto!=NULL)
    2834                 fwrite(toto->value,1,(atoi(size->value))*sizeof(char),ofile);
    2835               else
    2836                 if(toto!=NULL && toto->value!=NULL)
    2837                   fwrite(toto->value,1,strlen(toto->value)*sizeof(char),ofile);
    2838             }else{
    2839               printBoundingBoxDocument(m,tmpI,ofile);
    2840             }
    2841             fclose(ofile);
    2842           }
    2843 
    2844           map *tmp2=getMapFromMaps(m,"main","tmpUrl");
    2845           map *tmp3=getMapFromMaps(m,"main","serverAddress");
    2846           char *file_url=NULL;
    2847           if(strncasecmp(tmp2->value,"http://",7)==0 ||
    2848              strncasecmp(tmp2->value,"https://",8)==0){
    2849             file_url=(char*)malloc((strlen(tmp2->value)+strlen(file_name)+2)*sizeof(char));
    2850             sprintf(file_url,"%s/%s",tmp2->value,file_name);
    2851           }else{
    2852             file_url=(char*)malloc((strlen(tmp3->value)+strlen(tmp2->value)+strlen(file_name)+3)*sizeof(char));
    2853             sprintf(file_url,"%s/%s/%s",tmp3->value,tmp2->value,file_name);
    2854           }
    2855           addToMap(tmpI->content,"Reference",file_url);
    2856           if(file_name!=NULL)
    2857             free(file_name);
    2858           if(file_url!=NULL)
    2859             free(file_url);
    2860           file_name=NULL;
    2861         }
     2864            if(file_url!=NULL)
     2865              free(file_url);
     2866            file_name=NULL;
     2867          }
    28622868#ifdef USE_MS
    2863       else{
     2869        else{
    28642870          if(testMap!=NULL){
     2871            map* nbFeatures;
    28652872            setMapInMaps(m,"lenv","state","out");
    28662873            setReferenceUrl(m,tmpI);
     2874            nbFeatures=getMap(tmpI->content,"nb_features");
    28672875            geodatatype=getMap(tmpI->content,"geodatatype");
    2868             if(geodatatype!=NULL && strcasecmp(geodatatype->value,"other")==0)
     2876            if((nbFeatures!=NULL && atoi(nbFeatures->value)==0) ||
     2877               (geodatatype!=NULL && strcasecmp(geodatatype->value,"other")==0))
     2878              error=1;
    28692879              res=SERVICE_FAILED;
    28702880          }
     
    28872897    dumpMaps(m);
    28882898#endif
    2889     printProcessResponse(m,request_inputs1,cpid,
    2890                          s, s->name,res,  // replace serviceProvider with serviceName in stored response file name
    2891                          request_inputs,
    2892                          request_outputs);
     2899    if(error<0)
     2900      printProcessResponse(m,request_inputs1,cpid,
     2901                           s, s->name,res,  // replace serviceProvider with serviceName in stored response file name
     2902                           request_inputs,
     2903                           request_outputs);
     2904    else{
     2905      maps* tmpMaps=getMaps(m,"lenv");
     2906      dumpMap(tmpMaps->content);
     2907#ifdef USE_HPC
     2908      invokeCallback(m,NULL,NULL,7,0);
     2909#endif
     2910      printExceptionReportResponse(m,tmpMaps->content);
     2911    }
    28932912  }
    28942913  else{
  • branches/prototype-v0/zoo-project/zoo-kernel/service_internal_hpc.c

    r887 r888  
    320320
    321321  map* targetPathMap=getMapFromMaps(*main_conf,configurationId,"remote_data_path");
     322  map* targetPersistentPathMap=getMapFromMaps(*main_conf,configurationId,"remote_persistent_data_path");
    322323 
    323324  pthread_t threads_pool[50];
     
    362363          for(i=0;i<len;i++){
    363364            map* tmp=getMapArray(input->content,"cache_file",i);
     365            map* origin=getMapArray(input->content,"origin",i);
    364366            char* targetName=strrchr(tmp->value,'/');
    365             char *targetPath=(char*)malloc((strlen(targetPathMap->value)+strlen(targetName)+2)*sizeof(char));
    366             sprintf(targetPath,"%s/%s",targetPathMap->value,targetName);
     367            char *targetPath;
     368            if(origin!=NULL && strcasecmp(origin->value,"SHARED")==0 && targetPersistentPathMap!=NULL){
     369              targetPath=(char*)malloc((strlen(targetPersistentPathMap->value)+strlen(targetName)+2)*sizeof(char));
     370              sprintf(targetPath,"%s/%s",targetPersistentPathMap->value,targetName);
     371            }
     372            else{
     373              targetPath=(char*)malloc((strlen(targetPathMap->value)+strlen(targetName)+2)*sizeof(char));
     374              sprintf(targetPath,"%s/%s",targetPathMap->value,targetName);
     375            }
    367376            setMapArray(input->content,"targetPath",i,targetPath);
    368377            setMapArray(input->content,"localPath",i,tmp->value);
  • branches/prototype-v0/zoo-project/zoo-kernel/service_internal_ms.c

    r886 r888  
    185185    map* useMs=getMap(tmpI->content,"useMapserver");
    186186    if((minNb==NULL || atoi(minNb->value)>=1) && useMs!=NULL && strncasecmp(useMs->value,"true",4)==0){
     187      int lIndex=0;
     188      maps* lenv=getMaps(m,"lenv");
     189      if(getMapFromMaps(m,"lenv","mapErrorNb")==NULL)
     190        setMapInMaps(m,"lenv","mapErrorNb","0");
     191      else{
     192        map* tmpV=getMapFromMaps(m,"lenv","mapErrorNb");
     193        lIndex=atoi(tmpV->value)+1;
     194        addIntToMap(lenv->content,"mapErrorNb",lIndex);
     195      }
    187196      setMapInMaps(m,"lenv","mapError","true");
    188       setMapInMaps(m,"lenv","locator",tmpI->name);
     197      setMapArray(lenv->content,"locator",lIndex,tmpI->name);
    189198      if(nbElements==NULL)
    190         setMapInMaps(m,"lenv","message",_("The ZOO-Kernel was able to retrieve the data but could not read it as geographic data."));
     199        setMapArray(lenv->content,"message",lIndex,_("The ZOO-Kernel was able to retrieve the data but could not read it as geographic data."));
    191200      else
    192         setMapInMaps(m,"lenv","message",_("The ZOO-Kernel was able to retrieve the data but could not access any feature or pixel in te resulting file."));
     201        setMapArray(lenv->content,"message",lIndex,_("The ZOO-Kernel was able to retrieve the data but could not access any feature or pixel in te resulting file."));
    193202      if(getMapFromMaps(m,"lenv","state")==NULL)
    194203        errorException (m, _("Unable to find any geographic data"), "WrongInputData", tmpI->name);
     
    889898       */
    890899      tmpMap=getMap(output->content,"msStyle");
     900      if(tmpMap==NULL){
     901        switch(myLayer->type){
     902        case MS_LAYER_POLYGON:
     903          tmpMap=getMapFromMaps(conf,"main","msStylePoly");
     904          break;
     905        case MS_LAYER_LINE:
     906          tmpMap=getMapFromMaps(conf,"main","msStyleLine");
     907          break;
     908        default:
     909          tmpMap=getMapFromMaps(conf,"main","msStylePoint");
     910          break;
     911        }
     912      }
    891913      if(tmpMap!=NULL)
    892914        msUpdateStyleFromString(myLayer->CLASS[myLayer->numclasses]->styles[myLayer->CLASS[myLayer->numclasses]->numstyles],tmpMap->value,0);
     
    11351157    CPLErrorReset();
    11361158    GDALGetRasterStatistics( hBand, TRUE, TRUE, &pdfMin, &pdfMax, &pdfMean, &pdfStdDev);
    1137     //GDALComputeRasterStatistics( hBand, TRUE, &pdfMin, &pdfMax, &pdfMean, &pdfStdDev, NULL,NULL);
    11381159    char tmpN[21];
    11391160    sprintf(tmpN,"Band%d",iBand+1);
  • branches/prototype-v0/zoo-project/zoo-kernel/sshapi.c

    r886 r888  
    653653int fileMd5Check(maps** conf,const char* localPath,const char* targetPath){
    654654  if(strstr(localPath,".zca")!=NULL){
    655     char *logPath=NULL;
    656     char *command=(char*)malloc((strlen(targetPath)+27)*sizeof(char));
    657     sprintf(command,"md5sum %s | awk {'print $1'}",targetPath);
     655    char *logPath=NULL;   
     656    char *command=(char*)malloc(((2*strlen(targetPath))+42)*sizeof(char));
     657    sprintf(command,"(md5sum %s | awk {'print $1'}) && touch %s",targetPath,targetPath);
    658658    if(ssh_exec(*conf,command,ssh_get_cnt(*conf))<=0){
    659659      return -1;
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