Changeset 32 for trunk


Ignore:
Timestamp:
Sep 27, 2010, 10:09:32 PM (14 years ago)
Author:
djay
Message:

Add missing updated code from 26 ...

Location:
trunk
Files:
1 added
5 edited

Legend:

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

    r26 r32  
    8080  }
    8181  conf=mapsFromJSObject(cx,argv[0]);
    82   dumpMaps(conf);
    8382  if(JS_ValueToInt32(cx,argv[1],&istatus)==JS_TRUE){
    8483    char tmpStatus[4];
     
    350349  else{
    351350    fprintf(stderr,"TMP4 NOT FOUND !!");
    352     //dumpMaps(tmp4);
    353351    return NULL;
    354352  }
     
    439437  else{
    440438    fprintf(stderr,"TMP4 NOT FOUND !!");
    441     //dumpMaps(tmp4);
    442439  }
    443440  xmlAddChild(nc4,nc5);
     
    964961  maps* tmp_maps=getMaps(m,"main");
    965962  if(tmp_maps!=NULL){
    966     dumpMaps(getMaps(m,"lenv"));
    967963    map* tmpm1=getMap(tmp_maps->content,"serverAddress");
    968964    /**
     
    12851281    while(tmp!=NULL){
    12861282      if(strncasecmp(tmp->name,"value",strlen(tmp->name))!=0 &&
     1283         strncasecmp(tmp->name,"extension",strlen(tmp->name))!=0 &&
     1284         strncasecmp(tmp->name,"asReference",strlen(tmp->name))!=0 &&
     1285         strncasecmp(tmp->name,"status",strlen(tmp->name))!=0 &&
     1286         strncasecmp(tmp->name,"storeExecuteResponse",strlen(tmp->name))!=0 &&
    12871287         strncasecmp(tmp->name,"extension",strlen(tmp->name))!=0)
    12881288        xmlNewProp(nc3,BAD_CAST tmp->name,BAD_CAST tmp->value);
     
    13061306    }
    13071307    else if(tmp!=NULL){
    1308       if(strcmp(tmp->value,"text/js")==0)
     1308      if(strncmp(tmp->value,"text/js",4)==0 ||
     1309         strncmp(tmp->value,"application/js",14)==0)
    13091310        xmlAddChild(nc3,xmlNewCDataBlock(doc,BAD_CAST toto->value,strlen(toto->value)));
    13101311      else
     
    13941395  maps* tmpMap=getMaps(m,"main");
    13951396  char *encoding=getEncoding(tmpMap);
    1396   map *tmpSid=getMapFromMaps(m,"lenv","sid");
    1397   if(tmpSid==NULL)
     1397  if(m!=NULL){
     1398    map *tmpSid=getMapFromMaps(m,"lenv","sid");
     1399    if(tmpSid!=NULL){
     1400      if( getpid()==atoi(tmpSid->value) )
     1401        printf("Content-Type: text/xml; charset=%s\r\nStatus: 200 OK\r\n\r\n",encoding);
     1402    }
     1403    else
     1404      printf("Content-Type: text/xml; charset=%s\r\nStatus: 200 OK\r\n\r\n",encoding);
     1405  }else
    13981406    printf("Content-Type: text/xml; charset=%s\r\nStatus: 200 OK\r\n\r\n",encoding);
    13991407
     
    15341542       * We get the first output only !!
    15351543       */
     1544      toto=getMap(request_outputs->content,"value");
     1545      if(toto==NULL){
     1546        map * errormap = createMap("text","Unable to fetch any result");
     1547        addToMap(errormap,"code", "InternalError");
     1548        fprintf(stderr,"DISPLAY ERROR MESSAGE !!!\n");
     1549        printExceptionReportResponse(m,errormap);
     1550        freeMap(&errormap);
     1551        free(errormap);
     1552      }
    15361553      char mime[1024];
    15371554      map* mi=getMap(request_outputs->content,"mimeType");
     
    15541571          sprintf(mime,"Content-Type: text/plain; charset=utf-8\r\nStatus: 200 OK\r\n\r\n");
    15551572      printf("%s",mime);
    1556       toto=getMap(request_outputs->content,"value");
    15571573      if(mi!=NULL && strncmp(mi->value,"image",5)==0){
    15581574        map* rs=getMapFromMaps(request_outputs,request_outputs->name,"size");
     
    15751591      errormap = createMap("text",tmp);     
    15761592      addToMap(errormap,"code", "InternalError");
    1577       printf("Content-Type: text/xml; charset=utf-8\r\nStatus: 200 OK\r\n\r\n");
     1593      fprintf(stderr,"DISPLAY ERROR MSG !!!!\n");
    15781594      printExceptionReportResponse(m,errormap);
    15791595      freeMap(&errormap);
  • trunk/zoo-kernel/zoo_loader.c

    r19 r32  
    5454int errorException(maps *m, const char *message, const char *errorcode)
    5555{
    56   map * errormap = createMap("text", message);
     56  map* errormap = createMap("text", message);
    5757  addToMap(errormap,"code", errorcode);
    5858  printExceptionReportResponse(m,errormap);
  • trunk/zoo-kernel/zoo_service_loader.c

    r30 r32  
    4444#include "service.h"
    4545#include "service_internal.h"
    46 
    47 
    48 #ifdef USE_PYTHON
    4946#include "service_internal_python.h"
    50 #endif
    5147
    5248#ifdef USE_JAVA
     
    182178    freeMaps(&m);
    183179    free(m);
    184     freeMap(&request_inputs);
    185     free(request_inputs);
    186180    return 1;
    187181  }
     
    194188      freeMaps(&m);
    195189      free(m);
    196       freeMap(&request_inputs);
    197       free(request_inputs);
    198190      free(REQUEST);
    199191      return 1;
     
    418410  s1=(service*)calloc(1,SERVICE_SIZE);
    419411  if(s1 == NULL){
     412    freeMaps(&m);
     413    free(m);
     414    free(REQUEST);
     415    free(SERVICE_URL);
    420416    return errorException(m, "Unable to allocate memory.","InternalError");
    421417  }
     
    437433  fflush(stdout);
    438434  dup2(saved_stdout,fileno(stdout));
    439   if(t==22){
    440     errorException(m, "The value for <indetifier> seems to be wrong. Please, ensure that the process exsits using the GetCapabilities request.", "InvalidParameterValue");
    441     exit(0);
     435  if(t<0){
     436    char tmpMsg[2048+strlen(r_inputs->value)];
     437    sprintf(tmpMsg,"The value for <indetifier> seems to be wrong (%s). Please, ensure that the process exist using the GetCapabilities request.",r_inputs->value);
     438    errorException(m, tmpMsg, "InvalidParameterValue");
     439    freeService(&s1);
     440    free(s1);
     441    freeMaps(&m);
     442    free(m);
     443    free(REQUEST);
     444    free(SERVICE_URL);
     445    return 0;
    442446  }
    443   //s[0]=s1;
     447  close(saved_stdout);
    444448
    445449#ifdef DEBUG
     
    483487    if(r_inputs==NULL) r_inputs=getMap(request_inputs,"RawDataOutput");
    484488   
    485     //#ifdef DEBUG
     489#ifdef DEBUG
    486490    fprintf(stderr,"OUTPUT Parsing ... \n");
    487     //#endif
     491#endif
    488492    if(r_inputs!=NULL){
    489       //#ifdef DEBUG
     493#ifdef DEBUG
    490494      fprintf(stderr,"OUTPUT Parsing start now ... \n");
    491       //#endif
     495#endif
    492496      char current_output_as_string[10240];
    493497      char cursor_output[10240];
     
    765769#endif
    766770        xmlNodePtr cur2=cur->children;
    767         while(cur2){
    768           while(cur2->type!=XML_ELEMENT_NODE)
     771        while(cur2!=NULL){
     772          while(cur2!=NULL && cur2->type!=XML_ELEMENT_NODE)
    769773            cur2=cur2->next;
     774          if(cur2==NULL)
     775            break;
    770776          /**
    771777           * Indentifier
     
    10241030#endif
    10251031            xmlNodePtr cur4=cur2->children;
    1026             while(cur4){
    1027               while(cur4->type!=XML_ELEMENT_NODE)
     1032            while(cur4!=NULL){
     1033              while(cur4!=NULL &&cur4->type!=XML_ELEMENT_NODE)
    10281034                cur4=cur4->next;
    1029 
     1035              if(cur4==NULL)
     1036                break;
    10301037              if(xmlStrcasecmp(cur4->name, BAD_CAST "LiteralData")==0){
    10311038                /**
     
    11031110        dumpMaps(request_input_real_format);
    11041111#endif
    1105         tmpmaps=tmpmaps->next;
    1106              
     1112        freeMaps(&tmpmaps);
     1113        free(tmpmaps);
     1114        tmpmaps=NULL;         
    11071115      }
    11081116#ifdef DEBUG
     
    14271435  int eres=SERVICE_STARTED;
    14281436  int cpid=getpid();
     1437 
     1438  maps *_tmpMaps=(maps*)malloc(MAPS_SIZE);
     1439  _tmpMaps->name=strdup("lenv");
     1440  char tmpBuff[100];
     1441  sprintf(tmpBuff,"%i",cpid);
     1442  _tmpMaps->content=createMap("sid",tmpBuff);
     1443  _tmpMaps->next=NULL;
     1444  addToMap(_tmpMaps->content,"status","0");
     1445  addMapsToMaps(&m,_tmpMaps);
     1446  freeMaps(&_tmpMaps);
     1447  free(_tmpMaps);
     1448
    14291449#ifdef DEBUG
    14301450  dumpMap(request_inputs);
     
    15881608    }
    15891609    else{
    1590 #ifdef USE_PYTHON
    15911610      if(strncasecmp(r_inputs->value,"PYTHON",6)==0){
    15921611        eres=zoo_python_support(&m,request_inputs,s1,&request_input_real_format,&request_output_real_format);
    15931612      }
    15941613      else
    1595 #endif
    15961614       
    15971615#ifdef USE_JAVA
     
    16601678      r_inputs=getMapFromMaps(m,"main","tmpPath");
    16611679      map* r_inputs1=getMap(s1->content,"ServiceProvider");
    1662       char* fbkp=(char*)malloc((strlen(r_inputs->value)+strlen(r_inputs1->value)+16)*sizeof(char));
     1680      char* fbkp=(char*)malloc((strlen(r_inputs->value)+strlen(r_inputs1->value)+100)*sizeof(char));
    16631681      sprintf(fbkp,"%s/%s_%d.xml",r_inputs->value,r_inputs1->value,cpid);
    1664       char* flog=(char*)malloc((strlen(r_inputs->value)+strlen(r_inputs1->value)+22)*sizeof(char));
     1682      char* flog=(char*)malloc((strlen(r_inputs->value)+strlen(r_inputs1->value)+100)*sizeof(char));
    16651683      sprintf(flog,"%s/%s_%d_error.log",r_inputs->value,r_inputs1->value,cpid);
    1666       fprintf(stderr,"File to use as backup %s\n",fbkp);
    16671684#ifdef DEBUG
    16681685      fprintf(stderr,"RUN IN BACKGROUND MODE \n");
     
    16751692      free(fbkp);
    16761693      free(flog);
     1694      if(setsid()<0)
     1695        return errorException(m, "Unable to run the child process properly", "InternalError");
    16771696      /**
    16781697       * set status to SERVICE_STARTED and flush stdout to ensure full
     
    16811700       * this way the data will be updated at the end of the process run.
    16821701       */
     1702      updateStatus(m);
    16831703      printProcessResponse(m,request_inputs,cpid,
    1684                             s1,r_inputs->value,SERVICE_STARTED,
     1704                            s1,r_inputs1->value,SERVICE_STARTED,
    16851705                            request_input_real_format,
    16861706                            request_output_real_format);
     
    18101830        }
    18111831      } else{
    1812 
    1813 #ifdef USE_PYTHON
    18141832        if(strncasecmp(r_inputs->value,"PYTHON",6)==0){
    18151833          eres=zoo_python_support(&m,request_inputs,s1,&request_input_real_format,&request_output_real_format);
    18161834        }
    18171835        else
    1818 #endif
    18191836
    18201837#ifdef USE_JAVA
     
    18531870      }
    18541871 
    1855       //res=execute(&m,&request_input_real_format,&request_output_real_format);
    18561872    } else {
    18571873      /**
     
    18731889                   cpid,m,eres);
    18741890
    1875   //if(getpid()==cpid){
     1891  if(((int)getpid())!=cpid){
     1892    fclose(stdout);
     1893    fclose(stderr);
     1894    unhandleStatus(m);
     1895  }
     1896
    18761897  freeService(&s1);
    18771898  free(s1);
    18781899  freeMaps(&m);
    18791900  free(m);
    1880   freeMaps(&tmpmaps);
    1881   free(tmpmaps);
    18821901 
    18831902  freeMaps(&request_input_real_format);
    18841903  free(request_input_real_format);
    18851904 
    1886   //freeMap(&request_inputs);
    1887   //free(request_inputs);
    1888    
    18891905  /* The following is requested but get issue using with Python support :/ */
    18901906  /* freeMaps(&request_output_real_format);
    1891      free(request_output_real_format);
    1892   */
     1907     free(request_output_real_format);*/
    18931908 
    18941909  free(REQUEST);
     
    18991914  fflush(stderr);
    19001915#endif
    1901     //}
    19021916
    19031917  return 0;
  • trunk/zoo-services/ogr/base-vect-ops/service.c

    r26 r32  
    246246   OGRGeometryH geometry,res;
    247247   map* tmp=getMapFromMaps(inputs,"InputPolygon","value");
    248    if(tmp==NULL)
     248   if(tmp==NULL){
     249     setMapInMaps(conf,"lenv","message","Unable to fetch input geometry");
    249250     return SERVICE_FAILED;
     251   }else
     252     if(strlen(tmp->value)<=0){
     253       setMapInMaps(conf,"lenv","message","Unable to fetch input geometry");
     254       return SERVICE_FAILED;
     255     }
    250256   map* tmp1=getMapFromMaps(inputs,"InputPolygon","mimeType");
    251257   if(strncmp(tmp1->value,"application/json",16)==0)
  • trunk/zoo-services/utils/status/service.c

    r26 r32  
    6464    DIR *dirp = opendir(tmpTmap->value);
    6565    char fileName[1024],xslFileName[1024];
     66    int hasFile=-1;
    6667    if(dirp!=NULL){
    6768      char tmp[128];
    6869      sprintf(tmp,"_%s.xml",tmpMap->value);
    6970      while ((dp = readdir(dirp)) != NULL)
    70         if(strstr(dp->d_name,tmp)!=0)
     71        if(strstr(dp->d_name,tmp)!=0){
    7172          sprintf(fileName,"%s/%s",tmpTmap->value,dp->d_name);
    72     }else{ 
    73       setMapInMaps(conf,"lenv","message","GetStatus was unable to use the tmpPath value set in main.cfg file.");
     73          hasFile=1;
     74        }
     75    }else{
     76      char tmp[1024];
     77      snprintf(tmp,1024,"GetStatus was unable to use the tmpPath value set in main.cfg file as directory %s.",tmpTmap->value);
     78      setMapInMaps(conf,"lenv","message",tmp);
     79      return SERVICE_FAILED;
     80    }
     81    if(hasFile<0){
     82      char tmp[1024];
     83      snprintf(tmp,1024,"GetStatus was unable to find any cache file for Service ID %s.",tmpMap->value);
     84      setMapInMaps(conf,"lenv","message",tmp);
    7485      return SERVICE_FAILED;
    7586    }
     
    94105      xmlFree(xmlbuff);
    95106    }
    96     else{   
     107    else{
    97108      char tmp[1024];
    98       sprintf(tmp,"ZOO GetStatus Service was unable to find or parse the cache xml file available for the Service ID %s.",tmpMap->value);
     109      sprintf(tmp,"ZOO GetStatus Service was unable to parse the cache xml file available for the Service ID %s.",tmpMap->value);
    99110      setMapInMaps(conf,"lenv","message",tmp);
    100111      return SERVICE_FAILED;
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