- Timestamp:
- Sep 27, 2010, 10:09:32 PM (14 years ago)
- Location:
- trunk
- Files:
-
- 1 added
- 5 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/zoo-kernel/service_internal.c
r26 r32 80 80 } 81 81 conf=mapsFromJSObject(cx,argv[0]); 82 dumpMaps(conf);83 82 if(JS_ValueToInt32(cx,argv[1],&istatus)==JS_TRUE){ 84 83 char tmpStatus[4]; … … 350 349 else{ 351 350 fprintf(stderr,"TMP4 NOT FOUND !!"); 352 //dumpMaps(tmp4);353 351 return NULL; 354 352 } … … 439 437 else{ 440 438 fprintf(stderr,"TMP4 NOT FOUND !!"); 441 //dumpMaps(tmp4);442 439 } 443 440 xmlAddChild(nc4,nc5); … … 964 961 maps* tmp_maps=getMaps(m,"main"); 965 962 if(tmp_maps!=NULL){ 966 dumpMaps(getMaps(m,"lenv"));967 963 map* tmpm1=getMap(tmp_maps->content,"serverAddress"); 968 964 /** … … 1285 1281 while(tmp!=NULL){ 1286 1282 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 && 1287 1287 strncasecmp(tmp->name,"extension",strlen(tmp->name))!=0) 1288 1288 xmlNewProp(nc3,BAD_CAST tmp->name,BAD_CAST tmp->value); … … 1306 1306 } 1307 1307 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) 1309 1310 xmlAddChild(nc3,xmlNewCDataBlock(doc,BAD_CAST toto->value,strlen(toto->value))); 1310 1311 else … … 1394 1395 maps* tmpMap=getMaps(m,"main"); 1395 1396 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 1398 1406 printf("Content-Type: text/xml; charset=%s\r\nStatus: 200 OK\r\n\r\n",encoding); 1399 1407 … … 1534 1542 * We get the first output only !! 1535 1543 */ 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 } 1536 1553 char mime[1024]; 1537 1554 map* mi=getMap(request_outputs->content,"mimeType"); … … 1554 1571 sprintf(mime,"Content-Type: text/plain; charset=utf-8\r\nStatus: 200 OK\r\n\r\n"); 1555 1572 printf("%s",mime); 1556 toto=getMap(request_outputs->content,"value");1557 1573 if(mi!=NULL && strncmp(mi->value,"image",5)==0){ 1558 1574 map* rs=getMapFromMaps(request_outputs,request_outputs->name,"size"); … … 1575 1591 errormap = createMap("text",tmp); 1576 1592 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"); 1578 1594 printExceptionReportResponse(m,errormap); 1579 1595 freeMap(&errormap); -
trunk/zoo-kernel/zoo_loader.c
r19 r32 54 54 int errorException(maps *m, const char *message, const char *errorcode) 55 55 { 56 map 56 map* errormap = createMap("text", message); 57 57 addToMap(errormap,"code", errorcode); 58 58 printExceptionReportResponse(m,errormap); -
trunk/zoo-kernel/zoo_service_loader.c
r30 r32 44 44 #include "service.h" 45 45 #include "service_internal.h" 46 47 48 #ifdef USE_PYTHON49 46 #include "service_internal_python.h" 50 #endif51 47 52 48 #ifdef USE_JAVA … … 182 178 freeMaps(&m); 183 179 free(m); 184 freeMap(&request_inputs);185 free(request_inputs);186 180 return 1; 187 181 } … … 194 188 freeMaps(&m); 195 189 free(m); 196 freeMap(&request_inputs);197 free(request_inputs);198 190 free(REQUEST); 199 191 return 1; … … 418 410 s1=(service*)calloc(1,SERVICE_SIZE); 419 411 if(s1 == NULL){ 412 freeMaps(&m); 413 free(m); 414 free(REQUEST); 415 free(SERVICE_URL); 420 416 return errorException(m, "Unable to allocate memory.","InternalError"); 421 417 } … … 437 433 fflush(stdout); 438 434 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; 442 446 } 443 //s[0]=s1;447 close(saved_stdout); 444 448 445 449 #ifdef DEBUG … … 483 487 if(r_inputs==NULL) r_inputs=getMap(request_inputs,"RawDataOutput"); 484 488 485 //#ifdef DEBUG489 #ifdef DEBUG 486 490 fprintf(stderr,"OUTPUT Parsing ... \n"); 487 //#endif491 #endif 488 492 if(r_inputs!=NULL){ 489 //#ifdef DEBUG493 #ifdef DEBUG 490 494 fprintf(stderr,"OUTPUT Parsing start now ... \n"); 491 //#endif495 #endif 492 496 char current_output_as_string[10240]; 493 497 char cursor_output[10240]; … … 765 769 #endif 766 770 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) 769 773 cur2=cur2->next; 774 if(cur2==NULL) 775 break; 770 776 /** 771 777 * Indentifier … … 1024 1030 #endif 1025 1031 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) 1028 1034 cur4=cur4->next; 1029 1035 if(cur4==NULL) 1036 break; 1030 1037 if(xmlStrcasecmp(cur4->name, BAD_CAST "LiteralData")==0){ 1031 1038 /** … … 1103 1110 dumpMaps(request_input_real_format); 1104 1111 #endif 1105 tmpmaps=tmpmaps->next; 1106 1112 freeMaps(&tmpmaps); 1113 free(tmpmaps); 1114 tmpmaps=NULL; 1107 1115 } 1108 1116 #ifdef DEBUG … … 1427 1435 int eres=SERVICE_STARTED; 1428 1436 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 1429 1449 #ifdef DEBUG 1430 1450 dumpMap(request_inputs); … … 1588 1608 } 1589 1609 else{ 1590 #ifdef USE_PYTHON1591 1610 if(strncasecmp(r_inputs->value,"PYTHON",6)==0){ 1592 1611 eres=zoo_python_support(&m,request_inputs,s1,&request_input_real_format,&request_output_real_format); 1593 1612 } 1594 1613 else 1595 #endif1596 1614 1597 1615 #ifdef USE_JAVA … … 1660 1678 r_inputs=getMapFromMaps(m,"main","tmpPath"); 1661 1679 map* r_inputs1=getMap(s1->content,"ServiceProvider"); 1662 char* fbkp=(char*)malloc((strlen(r_inputs->value)+strlen(r_inputs1->value)+1 6)*sizeof(char));1680 char* fbkp=(char*)malloc((strlen(r_inputs->value)+strlen(r_inputs1->value)+100)*sizeof(char)); 1663 1681 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)); 1665 1683 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);1667 1684 #ifdef DEBUG 1668 1685 fprintf(stderr,"RUN IN BACKGROUND MODE \n"); … … 1675 1692 free(fbkp); 1676 1693 free(flog); 1694 if(setsid()<0) 1695 return errorException(m, "Unable to run the child process properly", "InternalError"); 1677 1696 /** 1678 1697 * set status to SERVICE_STARTED and flush stdout to ensure full … … 1681 1700 * this way the data will be updated at the end of the process run. 1682 1701 */ 1702 updateStatus(m); 1683 1703 printProcessResponse(m,request_inputs,cpid, 1684 s1,r_inputs ->value,SERVICE_STARTED,1704 s1,r_inputs1->value,SERVICE_STARTED, 1685 1705 request_input_real_format, 1686 1706 request_output_real_format); … … 1810 1830 } 1811 1831 } else{ 1812 1813 #ifdef USE_PYTHON1814 1832 if(strncasecmp(r_inputs->value,"PYTHON",6)==0){ 1815 1833 eres=zoo_python_support(&m,request_inputs,s1,&request_input_real_format,&request_output_real_format); 1816 1834 } 1817 1835 else 1818 #endif1819 1836 1820 1837 #ifdef USE_JAVA … … 1853 1870 } 1854 1871 1855 //res=execute(&m,&request_input_real_format,&request_output_real_format);1856 1872 } else { 1857 1873 /** … … 1873 1889 cpid,m,eres); 1874 1890 1875 //if(getpid()==cpid){ 1891 if(((int)getpid())!=cpid){ 1892 fclose(stdout); 1893 fclose(stderr); 1894 unhandleStatus(m); 1895 } 1896 1876 1897 freeService(&s1); 1877 1898 free(s1); 1878 1899 freeMaps(&m); 1879 1900 free(m); 1880 freeMaps(&tmpmaps);1881 free(tmpmaps);1882 1901 1883 1902 freeMaps(&request_input_real_format); 1884 1903 free(request_input_real_format); 1885 1904 1886 //freeMap(&request_inputs);1887 //free(request_inputs);1888 1889 1905 /* The following is requested but get issue using with Python support :/ */ 1890 1906 /* freeMaps(&request_output_real_format); 1891 free(request_output_real_format); 1892 */ 1907 free(request_output_real_format);*/ 1893 1908 1894 1909 free(REQUEST); … … 1899 1914 fflush(stderr); 1900 1915 #endif 1901 //}1902 1916 1903 1917 return 0; -
trunk/zoo-services/ogr/base-vect-ops/service.c
r26 r32 246 246 OGRGeometryH geometry,res; 247 247 map* tmp=getMapFromMaps(inputs,"InputPolygon","value"); 248 if(tmp==NULL) 248 if(tmp==NULL){ 249 setMapInMaps(conf,"lenv","message","Unable to fetch input geometry"); 249 250 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 } 250 256 map* tmp1=getMapFromMaps(inputs,"InputPolygon","mimeType"); 251 257 if(strncmp(tmp1->value,"application/json",16)==0) -
trunk/zoo-services/utils/status/service.c
r26 r32 64 64 DIR *dirp = opendir(tmpTmap->value); 65 65 char fileName[1024],xslFileName[1024]; 66 int hasFile=-1; 66 67 if(dirp!=NULL){ 67 68 char tmp[128]; 68 69 sprintf(tmp,"_%s.xml",tmpMap->value); 69 70 while ((dp = readdir(dirp)) != NULL) 70 if(strstr(dp->d_name,tmp)!=0) 71 if(strstr(dp->d_name,tmp)!=0){ 71 72 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); 74 85 return SERVICE_FAILED; 75 86 } … … 94 105 xmlFree(xmlbuff); 95 106 } 96 else{ 107 else{ 97 108 char tmp[1024]; 98 sprintf(tmp,"ZOO GetStatus Service was unable to find orparse 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); 99 110 setMapInMaps(conf,"lenv","message",tmp); 100 111 return SERVICE_FAILED;
Note: See TracChangeset
for help on using the changeset viewer.