- Timestamp:
- Feb 3, 2015, 12:59:21 PM (10 years ago)
- Location:
- trunk
- Files:
-
- 6 added
- 11 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/zoo-project/HISTORY.txt
r546 r550 1 Version 1.5.0-dev 2 * Add Orfeo Toolbox support for applications as a service 3 * Add the otb2zcfg utility to produce zcfg for otb applications 4 * Fix maxOccurs handling 5 * Fix gesture of downloaded inputs when multiple values are given 6 * Add detection of generated_file key in outputs to read the file generated by a service 7 1 8 Version 1.4.0 2 9 * Small fix for mimeType of results for CGAL services -
trunk/zoo-project/zoo-kernel/Makefile.in
r527 r550 45 45 g++ ${XML2CFLAGS} ${PYTHONCFLAGS} ${CFLAGS} -c service_internal_python.c 46 46 47 service_internal_otb.o: service_internal_otb.c service.h 48 g++ ${OTBCFLAGS} ${CFLAGS} -c service_internal_otb.c 49 50 otbRunner.o: otbRunner.cxx otbRunner.h service.h 51 g++ ${OTBCFLAGS} ${CFLAGS} -c otbRunner.cxx 52 53 otbZooWatcher.o: otbZooWatcher.cxx otbZooWatcher.h service.h 54 g++ ${OTBCFLAGS} ${CFLAGS} -c otbZooWatcher.cxx 55 47 56 service_internal_php.o: service_internal_php.c service.h 48 57 g++ -c ${XML2CFLAGS} ${PHPCFLAGS} ${CFLAGS} ${PHP_ENABLED} service_internal_php.c … … 64 73 65 74 zoo_service_loader.o: zoo_service_loader.c service.h 66 g++ -g -O2 ${XML2CFLAGS} ${CFLAGS} ${ PYTHONCFLAGS} ${JAVACFLAGS} ${JSCFLAGS} ${PERLCFLAGS} ${PHPCFLAGS} ${PYTHON_ENABLED} ${JS_ENABLED} ${PHP_ENABLED} ${PERL_ENABLED} ${JAVA_ENABLED} -c zoo_service_loader.c -fno-common -DPIC -o zoo_service_loader.o75 g++ -g -O2 ${XML2CFLAGS} ${CFLAGS} ${OTBCFLAGS} ${PYTHONCFLAGS} ${JAVACFLAGS} ${JSCFLAGS} ${PERLCFLAGS} ${PHPCFLAGS} ${OTB_ENABLED} ${PYTHON_ENABLED} ${JS_ENABLED} ${PHP_ENABLED} ${PERL_ENABLED} ${JAVA_ENABLED} -c zoo_service_loader.c -fno-common -DPIC -o zoo_service_loader.o 67 76 68 zoo_loader.cgi: version.h zoo_loader.c zoo_service_loader.o ulinet.o service.h lex.sr.o service_conf.tab.o service_conf.y ulinet.o main_conf_read.tab.o lex.cr.o service_internal.o ${MS_FILE} ${PYTHON_FILE} ${PHP_FILE} ${JAVA_FILE} ${JS_FILE} ${PERL_FILE} ${RUBY_FILE} ${YAML_FILE} 77 zoo_loader.cgi: version.h zoo_loader.c zoo_service_loader.o ulinet.o service.h lex.sr.o service_conf.tab.o service_conf.y ulinet.o main_conf_read.tab.o lex.cr.o service_internal.o ${MS_FILE} ${PYTHON_FILE} ${PHP_FILE} ${JAVA_FILE} ${JS_FILE} ${PERL_FILE} ${RUBY_FILE} ${YAML_FILE} ${OTB_FILE} 69 78 g++ -g -O2 ${JSCFLAGS} ${PHPCFLAGS} ${PERLCFLAGS} ${RUBYCFLAGS} ${JAVACFLAGS} ${XML2CFLAGS} ${PYTHONCFLAGS} ${CFLAGS} -c zoo_loader.c -fno-common -DPIC -o zoo_loader.o 70 g++ ${JSCFLAGS} ${ GDAL_CFLAGS} ${XML2CFLAGS} ${PHPCFLAGS} ${PERLCFLAGS} ${JAVACFLAGS} ${PYTHONCFLAGS} ${CFLAGS} zoo_loader.o zoo_service_loader.o service_internal.o ${MS_FILE} ${PYTHON_FILE} ${PERL_FILE} ${PHP_FILE} ${JS_FILE} ${JAVA_FILE} ${YAML_FILE} ulinet.o lex.cr.o lex.sr.o service_conf.tab.o main_conf_read.tab.o -o zoo_loader.cgi ${LDFLAGS}79 g++ ${JSCFLAGS} ${OTBCFLAGS} ${GDAL_CFLAGS} ${XML2CFLAGS} ${PHPCFLAGS} ${PERLCFLAGS} ${JAVACFLAGS} ${PYTHONCFLAGS} ${CFLAGS} zoo_loader.o zoo_service_loader.o service_internal.o ${MS_FILE} ${PYTHON_FILE} ${PERL_FILE} ${PHP_FILE} ${JS_FILE} ${JAVA_FILE} ${YAML_FILE} ${OTB_FILE} ulinet.o lex.cr.o lex.sr.o service_conf.tab.o main_conf_read.tab.o -o zoo_loader.cgi ${LDFLAGS} 71 80 72 81 zcfg2yaml: zcfg2yaml.c ulinet.o service.h lex.sr.o service_conf.tab.o service_conf.y ulinet.o main_conf_read.tab.o lex.cr.o service_internal.o ${MS_FILE} ${JS_FILE} ${RUBY_FILE} ${YAML_FILE} -
trunk/zoo-project/zoo-kernel/ZOOMakefile.opts.in
r534 r550 69 69 PERL_FILE=@PERL_FILE@ 70 70 71 OTBCFLAGS=@OTB_CPPFLAGS@ 72 OTBLDFLAGS=@OTB_LDFLAGS@ 73 OTB_ENABLED=@OTB_ENABLED@ 74 OTB_FILE=@OTB_FILE@ 75 71 76 CFLAGS=@DEB_DEF@ -fpic ${YAML_CFLAGS} ${MACOS_CFLAGS} ${MS_CFLAGS} -I../../thirds/cgic206 -I. -DLINUX_FREE_ISSUE #-DDEBUG #-DDEBUG_SERVICE_CONF 72 LDFLAGS=-lcurl -L../../thirds/cgic206 -lcgic ${GDAL_LIBS} ${XML2LDFLAGS} ${PYTHONLDFLAGS} ${PERLLDFLAGS} ${PHPLDFLAGS} ${JAVALDFLAGS} ${JSLDFLAGS} -lfcgi -lcrypto ${MS_LDFLAGS} ${MACOS_LD_FLAGS} ${MACOS_LD_NET_FLAGS} ${YAML_LDFLAGS} 77 LDFLAGS=-lcurl -L../../thirds/cgic206 -lcgic ${GDAL_LIBS} ${XML2LDFLAGS} ${PYTHONLDFLAGS} ${PERLLDFLAGS} ${PHPLDFLAGS} ${JAVALDFLAGS} ${JSLDFLAGS} -lfcgi -lcrypto ${MS_LDFLAGS} ${MACOS_LD_FLAGS} ${MACOS_LD_NET_FLAGS} ${YAML_LDFLAGS} ${OTBLDFLAGS} 73 78 -
trunk/zoo-project/zoo-kernel/configure.ac
r544 r550 1 AC_INIT([ZOO Kernel], [1.5.0 ], [bugs@zoo-project.org])1 AC_INIT([ZOO Kernel], [1.5.0-dev], [bugs@zoo-project.org]) 2 2 3 3 # Checks for programs. … … 84 84 85 85 # =========================================================================== 86 # Detect if otb is available 87 # =========================================================================== 88 89 AC_ARG_WITH([otb], 90 [AS_HELP_STRING([--with-otb=PATH], [specify an alternative location for the otb library])], 91 [OTBPATH="$withval"], [OTBPATH=""]) 92 93 if test -z "$OTBPATH" 94 then 95 OTB_LDFLAGS="" 96 OTB_CPPFLAGS="" 97 OTB_FILE="" 98 OTB_ENABLED="" 99 else 100 101 OTB_ENABLED="-DUSE_OTB" 102 OTB_LDFLAGS="-L$OTBPATH/lib/otb -lOTBIO -lOTBCommon -lOTBApplicationEngine -lITKBiasCorrection-4.5 -lITKCommon-4.5 -lITKIOImageBase-4.5 -lITKKLMRegionGrowing-4.5 -lITKLabelMap-4.5 -lITKMesh-4.5 -lITKMetaIO-4.5 -lITKOptimizers-4.5 -lITKPath-4.5 -lITKPolynomials-4.5 -lITKQuadEdgeMesh-4.5 -lITKSpatialObjects-4.5 -lITKStatistics-4.5 -lITKVNLInstantiation-4.5 -lITKWatersheds-4.5 -litkNetlibSlatec-4.5 -litksys-4.5 -litkdouble-conversion-4.5 -litkv3p_lsqr-4.5 -litkv3p_netlib-4.5 -litkvcl-4.5 -litkvnl-4.5 -litkvnl_algo-4.5 -litkzlib-4.5" 103 OTB_CPPFLAGS="-I$OTBPATH/include/otb/ApplicationEngine -I$OTBPATH/include/otb/Common -I$OTBPATH/include/otb/Utilities/ITK -I$OTBPATH/include/otb/ -I$OTBPATH/include/otb/IO -I$OTBPATH/include/otb/UtilitiesAdapters/OssimAdapters -I$OTBPATH/include/otb/UtilitiesAdapters/CurlAdapters -I$OTBPATH/include/otb/Utilities/BGL -I$OTBPATH/include/otb/UtilitiesAdapters/ITKPendingPatches -I$OTBPATH/include/otb/Utilities/otbconfigfile" 104 OTB_FILE="service_internal_otb.o" #otbZooWatcher.o otbRunner.o" 105 106 AC_LANG_PUSH([C++]) 107 # Check headers file 108 CPPFLAGS_SAVE="$CPPFLAGS" 109 CPPFLAGS="$OTB_CPPFLAGS" 110 LDFLAGS_SAVE="$LDFLAGS" 111 LDFLAGS="$OTB_LDFLAGS" 112 for i in otbWrapperApplication.h otbWrapperInputImageListParameter.h otbWrapperApplicationRegistry.h; do 113 AC_CHECK_HEADERS([$i], 114 [], [AC_MSG_ERROR([could not find header file $i related to OTB])]) 115 done 116 AC_LANG_POP([C++]) 117 ##,otbWrapperInputImageListParameter,otbFilterWatcherBase.h,itksys/SystemTools.hxx,itkCommand.h,itkProcessObject.h,itkTimeProbe.h 118 fi 119 AC_SUBST([OTB_CPPFLAGS]) 120 AC_SUBST([OTB_LDFLAGS]) 121 AC_SUBST([OTB_FILE]) 122 AC_SUBST([OTB_ENABLED]) 123 124 # =========================================================================== 86 125 # Detect if libyaml is available 87 126 # =========================================================================== 88 127 89 128 AC_ARG_WITH([yaml], 90 [AS_HELP_STRING([--with-yaml=PATH], [specify an alternative location for the fastcgilibrary])],129 [AS_HELP_STRING([--with-yaml=PATH], [specify an alternative location for the yaml library])], 91 130 [YAMLPATH="$withval"], [YAMLPATH=""]) 92 131 -
trunk/zoo-project/zoo-kernel/service.h
r514 r550 566 566 } 567 567 568 static void loadMapBinary(map** out,map* in,int pos){ 569 map* size=getMap(in,"size"); 570 map *lout=*out; 571 if(size!=NULL && pos>0){ 572 char tmp[11]; 573 sprintf(tmp,"size_%d",pos); 574 size=getMap(in,tmp); 575 sprintf(tmp,"value_%d",pos); 576 map* tmpVin=getMap(in,tmp); 577 map* tmpVout=getMap(lout,tmp); 578 free(tmpVout->value); 579 tmpVout->value=(char*)malloc((atoi(size->value)+1)*sizeof(char)); 580 memmove(tmpVout->value,tmpVin->value,atoi(size->value)*sizeof(char)); 581 tmpVout->value[atoi(size->value)]=0; 582 }else{ 583 if(size!=NULL){ 584 map* tmpVin=getMap(in,"value"); 585 map* tmpVout=getMap(lout,"value"); 586 free(tmpVout->value); 587 tmpVout->value=(char*)malloc((atoi(size->value)+1)*sizeof(char)); 588 memmove(tmpVout->value,tmpVin->value,atoi(size->value)*sizeof(char)); 589 tmpVout->value[atoi(size->value)]=0; 590 } 591 } 592 } 593 594 static void loadMapBinaries(map** out,map* in){ 595 map* size=getMap(in,"size"); 596 map* length=getMap(in,"length"); 597 if(length!=NULL){ 598 int len=atoi(length->value); 599 int i=0; 600 for(i=0;i<len;i++){ 601 loadMapBinary(out,in,i); 602 } 603 } 604 else 605 if(size!=NULL) 606 loadMapBinary(out,in,-1); 607 char* tmpSized=NULL; 608 609 } 610 568 611 static maps* dupMaps(maps** mo){ 569 612 maps* _cursor=*mo; … … 575 618 res->next=NULL; 576 619 map* mc=_cursor->content; 577 map* tmp=getMap(mc,"size");578 char* tmpSized=NULL;579 if(tmp!=NULL){580 map* tmpV=getMap(mc,"value");581 tmpSized=(char*)malloc((atoi(tmp->value)+1)*sizeof(char));582 memmove(tmpSized,tmpV->value,atoi(tmp->value)*sizeof(char));583 }584 620 if(mc!=NULL){ 585 621 addMapToMap(&res->content,mc); 586 } 587 if(tmp!=NULL){ 588 map* tmpV=getMap(res->content,"value"); 589 free(tmpV->value); 590 tmpV->value=(char*)malloc((atoi(tmp->value)+1)*sizeof(char)); 591 memmove(tmpV->value,tmpSized,atoi(tmp->value)*sizeof(char)); 592 tmpV->value[atoi(tmp->value)]=0; 593 free(tmpSized); 622 loadMapBinaries(&res->content,mc); 594 623 } 595 624 res->next=dupMaps(&_cursor->next); … … 643 672 else 644 673 sprintf(tmp,"%s",key); 645 map* tmpSize=getMapArray(m, (char*)"size",index);674 map* tmpSize=getMapArray(m,"size",index); 646 675 if(tmpSize!=NULL && strncasecmp(key,"value",5)==0){ 647 676 #ifdef DEBUG … … 685 714 } 686 715 687 char *tmpV[ 8]={716 char *tmpV[11]={ 688 717 (char*)"size", 689 718 (char*)"value", 690 719 (char*)"uom", 691 720 (char*)"Reference", 721 (char*)"cache_file", 722 (char*)"fmimeType", 692 723 (char*)"xlink:href", 693 724 typ, 694 725 (char*)"schema", 695 (char*)"encoding" 726 (char*)"encoding", 727 (char*)"isCached" 696 728 }; 697 729 sprintf(tmpLen,"%d",len+1); 698 730 addToMap(_cursor->content,"length",tmpLen); 699 731 int i=0; 700 for(i=0;i< 8;i++){732 for(i=0;i<11;i++){ 701 733 map* tmpVI=getMap(tmp->content,tmpV[i]); 702 734 if(tmpVI!=NULL){ … … 704 736 fprintf(stderr,"%s = %s\n",tmpV[i],tmpVI->value); 705 737 #endif 706 if(i< 5)738 if(i<7) 707 739 setMapArray(_cursor->content,tmpV[i],len,tmpVI->value); 708 740 else 709 if(strncasecmp(tmpV[ 5],"mimeType",8)==0)741 if(strncasecmp(tmpV[7],"mimeType",8)==0) 710 742 setMapArray(_cursor->content,tmpV[i],len,tmpVI->value); 711 743 } -
trunk/zoo-project/zoo-kernel/service_conf.l
r539 r550 40 40 chardata [^<]* 41 41 42 attname [a-zA-Z0-9 _\-]+43 attvalue1 [ \^\*\+,;@a-zA-Z0-9%_\-::.:" "\"\'/\\\(\)\t\|\$\&>\[\]]+42 attname [a-zA-Z0-9._\-]+ 43 attvalue1 [°²θé#\^\*\+,;@a-zA-Z0-9%_\-::.:" "\"\'/\\\(\)\t\|\$\&>\[\]]+ 44 44 45 45 attvalue \"[^"]*\"|\'[^']*\'\(\) -
trunk/zoo-project/zoo-kernel/service_internal.c
r542 r550 2432 2432 nc1 = xmlNewNode(ns, BAD_CAST "ExceptionText"); 2433 2433 if(tmp!=NULL){ 2434 xmlNodeSetContent(nc1, BAD_CAST tmp->value); 2434 xmlNodePtr txt=xmlNewText(BAD_CAST tmp->value); 2435 xmlAddChild(nc1,txt); 2435 2436 } 2436 2437 else{ … … 2442 2443 } 2443 2444 2445 /************************************************************************/ 2446 /* readGeneratedFile() */ 2447 /************************************************************************/ 2448 2449 /** 2450 * Read a file generated by a service. 2451 * 2452 * @param m the conf maps 2453 * @param content the output item 2454 * @param filename the file to read 2455 */ 2456 void readGeneratedFile(maps* m,map* content,char* filename){ 2457 FILE * file=fopen(filename,"rb"); 2458 fseek(file, 0, SEEK_END); 2459 long count = ftell(file); 2460 rewind(file); 2461 struct stat file_status; 2462 stat(filename, &file_status); 2463 if(file==NULL){ 2464 fprintf(stderr,"Failed to open file %s for reading purpose.\n",filename); 2465 setMapInMaps(m,"lenv","message","Unable to read produced file. Please try again later"); 2466 return ; 2467 } 2468 map* tmpMap1=getMap(content,"value"); 2469 if(tmpMap1==NULL){ 2470 addToMap(content,"value",""); 2471 tmpMap1=getMap(content,"value"); 2472 } 2473 free(tmpMap1->value); 2474 tmpMap1->value=(char*) malloc((count+1)*sizeof(char)); 2475 fread(tmpMap1->value,1,count*sizeof(char),file); 2476 fclose(file); 2477 char rsize[100]; 2478 sprintf(rsize,"%d",count*sizeof(char)); 2479 addToMap(tmpMap1,"size",rsize); 2480 } 2444 2481 2445 2482 void outputResponse(service* s,maps* request_inputs,maps* request_outputs, … … 2503 2540 } 2504 2541 2542 if(res==SERVICE_FAILED){ 2543 map * errormap; 2544 map *lenv; 2545 lenv=getMapFromMaps(m,"lenv","message"); 2546 char *tmp0; 2547 if(lenv!=NULL){ 2548 tmp0=(char*)malloc((strlen(lenv->value)+strlen(_("Unable to run the Service. The message returned back by the Service was the following: "))+1)*sizeof(char)); 2549 sprintf(tmp0,_("Unable to run the Service. The message returned back by the Service was the following: %s"),lenv->value); 2550 } 2551 else{ 2552 tmp0=(char*)malloc((strlen(_("Unable to run the Service. No more information was returned back by the Service."))+1)*sizeof(char)); 2553 sprintf(tmp0,_("Unable to run the Service. No more information was returned back by the Service.")); 2554 } 2555 errormap = createMap("text",tmp0); 2556 free(tmp0); 2557 addToMap(errormap,"code", "InternalError"); 2558 dumpMap(errormap); 2559 printExceptionReportResponse(m,errormap); 2560 freeMap(&errormap); 2561 free(errormap); 2562 return; 2563 } 2564 2505 2565 2506 2566 if(asRaw==0){ … … 2521 2581 #endif 2522 2582 { 2523 elements* in=getElements(s->outputs,tmpI->name); 2524 char *format=NULL; 2525 if(in!=NULL){ 2526 format=strdup(in->format); 2527 }else 2528 format=strdup("LiteralData"); 2529 if(strcasecmp(format,"BoundingBoxData")==0){ 2530 addToMap(tmpI->content,"extension","xml"); 2531 addToMap(tmpI->content,"mimeType","text/xml"); 2532 addToMap(tmpI->content,"encoding","UTF-8"); 2533 addToMap(tmpI->content,"schema","http://schemas.opengis.net/ows/1.1.0/owsCommon.xsd"); 2534 } 2535 map *ext=getMap(tmpI->content,"extension"); 2536 map *tmp1=getMapFromMaps(m,"main","tmpPath"); 2537 char *file_name,*file_path; 2538 bool hasExt=true; 2539 if(ext==NULL){ 2540 // We can fallback to a default list of supported formats using 2541 // mimeType information if present here. Maybe we can add more formats 2542 // here. 2543 // If mimeType was not found, we then set txt as the default extension 2544 map* mtype=getMap(tmpI->content,"mimeType"); 2545 if(mtype!=NULL){ 2546 if(strcasecmp(mtype->value,"text/xml")==0) 2547 ext=createMap("extension","xml"); 2548 else if(strcasecmp(mtype->value,"application/json")==0) 2549 ext=createMap("extension","js"); 2550 else if(strncmp(mtype->value,"application/vnd.google-earth.kml",32)==0) 2551 ext=createMap("extension","kml"); 2552 else if(strncmp(mtype->value,"image/",6)==0) 2553 ext=createMap("extension",strstr(mtype->value,"/")+1); 2554 else 2555 ext=createMap("extension","txt"); 2583 elements* in=getElements(s->outputs,tmpI->name); 2584 char *format=NULL; 2585 if(in!=NULL){ 2586 format=strdup(in->format); 2587 }else 2588 format=strdup("LiteralData"); 2589 if(strcasecmp(format,"BoundingBoxData")==0){ 2590 addToMap(tmpI->content,"extension","xml"); 2591 addToMap(tmpI->content,"mimeType","text/xml"); 2592 addToMap(tmpI->content,"encoding","UTF-8"); 2593 addToMap(tmpI->content,"schema","http://schemas.opengis.net/ows/1.1.0/owsCommon.xsd"); 2556 2594 } 2557 else 2558 ext=createMap("extension","txt"); 2559 hasExt=false; 2560 } 2561 file_name=(char*)malloc((strlen(s->name)+strlen(ext->value)+strlen(tmpI->name)+1024)*sizeof(char)); 2562 int cpid0=cpid+time(NULL); 2563 sprintf(file_name,"%s_%s_%i.%s",s->name,tmpI->name,cpid0,ext->value); 2564 file_path=(char*)malloc((strlen(tmp1->value)+strlen(file_name)+2)*sizeof(char)); 2565 sprintf(file_path,"%s/%s",tmp1->value,file_name); 2566 FILE *ofile=fopen(file_path,"wb"); 2567 if(ofile==NULL){ 2568 char tmpMsg[1024]; 2569 sprintf(tmpMsg,_("Unable to create the file : \"%s\" for storing the %s final result."),file_name,tmpI->name); 2570 map * errormap = createMap("text",tmpMsg); 2571 addToMap(errormap,"code", "InternalError"); 2572 printExceptionReportResponse(m,errormap); 2573 freeMap(&errormap); 2574 free(errormap); 2595 2596 map *tmp1=getMapFromMaps(m,"main","tmpPath"); 2597 2598 map *gfile=getMap(tmpI->content,"generated_file"); 2599 char *file_name; 2600 if(gfile!=NULL){ 2601 readGeneratedFile(m,tmpI->content,gfile->value); 2602 file_name=(char*)malloc((strlen(gfile->value)+strlen(tmp1->value)+1)*sizeof(char)); 2603 for(int i=0;i<strlen(gfile->value);i++) 2604 file_name[i]=gfile->value[i+strlen(tmp1->value)]; 2605 } 2606 else{ 2607 map *ext=getMap(tmpI->content,"extension"); 2608 char *file_path; 2609 bool hasExt=true; 2610 if(ext==NULL){ 2611 // We can fallback to a default list of supported formats using 2612 // mimeType information if present here. Maybe we can add more formats 2613 // here. 2614 // If mimeType was not found, we then set txt as the default extension 2615 map* mtype=getMap(tmpI->content,"mimeType"); 2616 if(mtype!=NULL) { 2617 if(strncasecmp(mtype->value,"text/xml",8)==0) 2618 ext=createMap("extension","xml"); 2619 else if(strncasecmp(mtype->value,"application/zip",15)==0) 2620 ext=createMap("extension","zip"); 2621 else if(strncasecmp(mtype->value,"application/json",16)==0) 2622 ext=createMap("extension","js"); 2623 else if(strncmp(mtype->value,"application/vnd.google-earth.kml",32)==0) 2624 ext=createMap("extension","kml"); 2625 else if(strncmp(mtype->value,"image/",6)==0) 2626 ext=createMap("extension",strstr(mtype->value,"/")+1); 2627 else 2628 ext=createMap("extension","txt"); 2629 } 2630 else 2631 ext=createMap("extension","txt"); 2632 hasExt=false; 2633 } 2634 file_name=(char*)malloc((strlen(s->name)+strlen(ext->value)+strlen(tmpI->name)+1024)*sizeof(char)); 2635 int cpid0=cpid+time(NULL); 2636 sprintf(file_name,"%s_%s_%i.%s",s->name,tmpI->name,cpid0,ext->value); 2637 file_path=(char*)malloc((strlen(tmp1->value)+strlen(file_name)+2)*sizeof(char)); 2638 sprintf(file_path,"%s/%s",tmp1->value,file_name); 2639 FILE *ofile=fopen(file_path,"wb"); 2640 if(ofile==NULL){ 2641 char tmpMsg[1024]; 2642 sprintf(tmpMsg,_("Unable to create the file : \"%s\" for storing the %s final result."),file_name,tmpI->name); 2643 map * errormap = createMap("text",tmpMsg); 2644 addToMap(errormap,"code", "InternalError"); 2645 printExceptionReportResponse(m,errormap); 2646 freeMap(&errormap); 2647 free(errormap); 2648 free(file_name); 2649 free(file_path); 2650 return; 2651 } 2652 free(file_path); 2653 if(!hasExt){ 2654 freeMap(&ext); 2655 free(ext); 2656 } 2657 toto=getMap(tmpI->content,"value"); 2658 if(strcasecmp(format,"BoundingBoxData")!=0){ 2659 map* size=getMap(tmpI->content,"size"); 2660 if(size!=NULL && toto!=NULL) 2661 fwrite(toto->value,1,atoi(size->value)*sizeof(char),ofile); 2662 else 2663 if(toto!=NULL && toto->value!=NULL) 2664 fwrite(toto->value,1,strlen(toto->value)*sizeof(char),ofile); 2665 }else{ 2666 printBoundingBoxDocument(m,tmpI,ofile); 2667 } 2668 fclose(ofile); 2669 2670 } 2671 map *tmp2=getMapFromMaps(m,"main","tmpUrl"); 2672 map *tmp3=getMapFromMaps(m,"main","serverAddress"); 2673 char *file_url; 2674 if(strncasecmp(tmp2->value,"http://",7)==0 || 2675 strncasecmp(tmp2->value,"https://",8)==0){ 2676 file_url=(char*)malloc((strlen(tmp2->value)+strlen(file_name)+2)*sizeof(char)); 2677 sprintf(file_url,"%s/%s",tmp2->value,file_name); 2678 }else{ 2679 file_url=(char*)malloc((strlen(tmp3->value)+strlen(tmp2->value)+strlen(file_name)+3)*sizeof(char)); 2680 sprintf(file_url,"%s/%s/%s",tmp3->value,tmp2->value,file_name); 2681 } 2682 addToMap(tmpI->content,"Reference",file_url); 2683 free(format); 2575 2684 free(file_name); 2576 free(file_path); 2577 return; 2578 } 2579 free(file_path); 2580 map *tmp2=getMapFromMaps(m,"main","tmpUrl"); 2581 map *tmp3=getMapFromMaps(m,"main","serverAddress"); 2582 char *file_url; 2583 if(strncasecmp(tmp2->value,"http://",7)==0 || 2584 strncasecmp(tmp2->value,"https://",8)==0){ 2585 file_url=(char*)malloc((strlen(tmp2->value)+strlen(file_name)+2)*sizeof(char)); 2586 sprintf(file_url,"%s/%s",tmp2->value,file_name); 2587 }else{ 2588 file_url=(char*)malloc((strlen(tmp3->value)+strlen(tmp2->value)+strlen(file_name)+3)*sizeof(char)); 2589 sprintf(file_url,"%s/%s/%s",tmp3->value,tmp2->value,file_name); 2590 } 2591 addToMap(tmpI->content,"Reference",file_url); 2592 if(!hasExt){ 2593 freeMap(&ext); 2594 free(ext); 2595 } 2596 toto=getMap(tmpI->content,"value"); 2597 if(strcasecmp(format,"BoundingBoxData")!=0){ 2598 map* size=getMap(tmpI->content,"size"); 2599 if(size!=NULL && toto!=NULL) 2600 fwrite(toto->value,1,atoi(size->value)*sizeof(char),ofile); 2601 else 2602 if(toto!=NULL && toto->value!=NULL) 2603 fwrite(toto->value,1,strlen(toto->value)*sizeof(char),ofile); 2604 }else{ 2605 printBoundingBoxDocument(m,tmpI,ofile); 2606 } 2607 free(format); 2608 fclose(ofile); 2609 free(file_name); 2610 free(file_url); 2685 free(file_url); 2686 2611 2687 } 2612 2688 #ifdef USE_MS … … 2628 2704 request_inputs, 2629 2705 request_outputs); 2630 } 2631 else{ 2632 if(res==SERVICE_FAILED){ 2633 map * errormap; 2634 map *lenv; 2635 lenv=getMapFromMaps(m,"lenv","message"); 2636 char *tmp0; 2637 if(lenv!=NULL){ 2638 tmp0=(char*)malloc((strlen(lenv->value)+strlen(_("Unable to run the Service. The message returned back by the Service was the following: "))+1)*sizeof(char)); 2639 sprintf(tmp0,_("Unable to run the Service. The message returned back by the Service was the following: %s"),lenv->value); 2640 } 2641 else{ 2642 tmp0=(char*)malloc((strlen(_("Unable to run the Service. No more information was returned back by the Service."))+1)*sizeof(char)); 2643 sprintf(tmp0,_("Unable to run the Service. No more information was returned back by the Service.")); 2644 } 2645 errormap = createMap("text",tmp0); 2646 free(tmp0); 2647 addToMap(errormap,"code", "InternalError"); 2706 } 2707 else{ 2708 /** 2709 * We get the requested output or fallback to the first one if the 2710 * requested one is not present in the resulting outputs maps. 2711 */ 2712 maps* tmpI=NULL; 2713 map* tmpIV=getMap(request_inputs1,"RawDataOutput"); 2714 if(tmpIV!=NULL){ 2715 tmpI=getMaps(request_outputs,tmpIV->value); 2716 } 2717 if(tmpI==NULL) 2718 tmpI=request_outputs; 2719 elements* e=getElements(s->outputs,tmpI->name); 2720 if(e!=NULL && strcasecmp(e->format,"BoundingBoxData")==0){ 2721 printBoundingBoxDocument(m,tmpI,NULL); 2722 }else{ 2723 map *gfile=getMap(tmpI->content,"generated_file"); 2724 if(gfile!=NULL){ 2725 readGeneratedFile(m,tmpI->content,gfile->value); 2726 } 2727 toto=getMap(tmpI->content,"value"); 2728 if(toto==NULL){ 2729 char tmpMsg[1024]; 2730 sprintf(tmpMsg,_("Wrong RawDataOutput parameter, unable to fetch any result for the name your provided : \"%s\"."),tmpI->name); 2731 map * errormap = createMap("text",tmpMsg); 2732 addToMap(errormap,"code", "InvalidParameterValue"); 2648 2733 printExceptionReportResponse(m,errormap); 2649 2734 freeMap(&errormap); … … 2651 2736 return; 2652 2737 } 2653 /** 2654 * We get the requested output or fallback to the first one if the 2655 * requested one is not present in the resulting outputs maps. 2656 */ 2657 maps* tmpI=NULL; 2658 map* tmpIV=getMap(request_inputs1,"RawDataOutput"); 2659 if(tmpIV!=NULL){ 2660 tmpI=getMaps(request_outputs,tmpIV->value); 2661 } 2662 if(tmpI==NULL) 2663 tmpI=request_outputs; 2664 elements* e=getElements(s->outputs,tmpI->name); 2665 if(e!=NULL && strcasecmp(e->format,"BoundingBoxData")==0){ 2666 printBoundingBoxDocument(m,tmpI,NULL); 2667 }else{ 2668 toto=getMap(tmpI->content,"value"); 2669 if(toto==NULL){ 2670 char tmpMsg[1024]; 2671 sprintf(tmpMsg,_("Wrong RawDataOutput parameter, unable to fetch any result for the name your provided : \"%s\"."),tmpI->name); 2672 map * errormap = createMap("text",tmpMsg); 2673 addToMap(errormap,"code", "InvalidParameterValue"); 2674 printExceptionReportResponse(m,errormap); 2675 freeMap(&errormap); 2676 free(errormap); 2677 return; 2678 } 2679 map* fname=getMapFromMaps(tmpI,tmpI->name,"filename"); 2680 if(fname!=NULL) 2681 printf("Content-Disposition: attachment; filename=\"%s\"\r\n",fname->value); 2682 map* rs=getMapFromMaps(tmpI,tmpI->name,"size"); 2683 if(rs!=NULL) 2684 printf("Content-Length: %s\r\n",rs->value); 2685 printHeaders(m); 2686 char mime[1024]; 2687 map* mi=getMap(tmpI->content,"mimeType"); 2688 #ifdef DEBUG 2689 fprintf(stderr,"SERVICE OUTPUTS\n"); 2690 dumpMaps(request_outputs); 2691 fprintf(stderr,"SERVICE OUTPUTS\n"); 2692 #endif 2693 map* en=getMap(tmpI->content,"encoding"); 2694 if(mi!=NULL && en!=NULL) 2738 map* fname=getMapFromMaps(tmpI,tmpI->name,"filename"); 2739 if(fname!=NULL) 2740 printf("Content-Disposition: attachment; filename=\"%s\"\r\n",fname->value); 2741 map* rs=getMapFromMaps(tmpI,tmpI->name,"size"); 2742 if(rs!=NULL) 2743 printf("Content-Length: %s\r\n",rs->value); 2744 printHeaders(m); 2745 char mime[1024]; 2746 map* mi=getMap(tmpI->content,"mimeType"); 2747 #ifdef DEBUG 2748 fprintf(stderr,"SERVICE OUTPUTS\n"); 2749 dumpMaps(request_outputs); 2750 fprintf(stderr,"SERVICE OUTPUTS\n"); 2751 #endif 2752 map* en=getMap(tmpI->content,"encoding"); 2753 if(mi!=NULL && en!=NULL) 2754 sprintf(mime, 2755 "Content-Type: %s; charset=%s\r\nStatus: 200 OK\r\n\r\n", 2756 mi->value,en->value); 2757 else 2758 if(mi!=NULL) 2695 2759 sprintf(mime, 2696 "Content-Type: %s; charset= %s\r\nStatus: 200 OK\r\n\r\n",2697 mi->value ,en->value);2760 "Content-Type: %s; charset=UTF-8\r\nStatus: 200 OK\r\n\r\n", 2761 mi->value); 2698 2762 else 2699 if(mi!=NULL) 2700 sprintf(mime, 2701 "Content-Type: %s; charset=UTF-8\r\nStatus: 200 OK\r\n\r\n", 2702 mi->value); 2703 else 2704 sprintf(mime,"Content-Type: text/plain; charset=utf-8\r\nStatus: 200 OK\r\n\r\n"); 2705 printf("%s",mime); 2706 if(rs!=NULL) 2707 fwrite(toto->value,1,atoi(rs->value),stdout); 2708 else 2709 fwrite(toto->value,1,strlen(toto->value),stdout); 2710 #ifdef DEBUG 2711 dumpMap(toto); 2712 #endif 2713 } 2714 } 2763 sprintf(mime,"Content-Type: text/plain; charset=utf-8\r\nStatus: 200 OK\r\n\r\n"); 2764 printf("%s",mime); 2765 if(rs!=NULL) 2766 fwrite(toto->value,1,atoi(rs->value),stdout); 2767 else 2768 fwrite(toto->value,1,strlen(toto->value),stdout); 2769 #ifdef DEBUG 2770 dumpMap(toto); 2771 #endif 2772 } 2773 } 2715 2774 } 2716 2775 … … 3220 3279 int index=0; 3221 3280 while(content!=NULL){ 3222 if((tmp1=getMap(content->content,"href")) || 3223 (tmp1=getMap(content->content,"xlink:href"))){ 3224 if(getMap(content->content,"isCached")==NULL){ 3225 char* fcontent; 3226 char *mimeType=NULL; 3227 int fsize=0; 3228 3229 fcontent=(char*)malloc((hInternet->ihandle[index].nDataLen+1)*sizeof(char)); 3230 if(fcontent == NULL){ 3231 return errorException(*m, _("Unable to allocate memory."), "InternalError",NULL); 3281 3282 map* length=getMap(content->content,"length"); 3283 int shouldClean=-1; 3284 if(length==NULL){ 3285 length=createMap("length","1"); 3286 shouldClean=1; 3287 } 3288 for(int i=0;i<atoi(length->value);i++){ 3289 3290 char* fcontent; 3291 char *mimeType=NULL; 3292 int fsize=0; 3293 char cname[15]; 3294 char vname[11]; 3295 char vname1[11]; 3296 char sname[9]; 3297 char icname[14]; 3298 char xname[16]; 3299 if(index>0) 3300 sprintf(vname1,"value_%d",index); 3301 else 3302 sprintf(vname1,"value"); 3303 3304 if(i>0){ 3305 tmp1=getMap(content->content,cname); 3306 sprintf(cname,"cache_file_%d",i); 3307 sprintf(vname,"value_%d",i); 3308 sprintf(sname,"size_%d",i); 3309 sprintf(icname,"isCached_%d",i); 3310 sprintf(xname,"Reference_%d",i); 3311 }else{ 3312 sprintf(cname,"cache_file"); 3313 sprintf(vname,"value"); 3314 sprintf(icname,"isCached"); 3315 sprintf(sname,"size"); 3316 sprintf(xname,"Reference"); 3317 } 3318 3319 map* tmap=getMapFromMaps(*m,"orequests",vname1); 3320 if((tmp1=getMap(content->content,xname))!=NULL && strcasecmp(tmap->value,tmp1->value)==0 ){ 3321 if(getMap(content->content,icname)==NULL){ 3322 3323 fcontent=(char*)malloc((hInternet->ihandle[index].nDataLen+1)*sizeof(char)); 3324 if(fcontent == NULL){ 3325 return errorException(*m, _("Unable to allocate memory."), "InternalError",NULL); 3326 } 3327 size_t dwRead; 3328 InternetReadFile(hInternet->ihandle[index], 3329 (LPVOID)fcontent, 3330 hInternet->ihandle[index].nDataLen, 3331 &dwRead); 3332 fcontent[hInternet->ihandle[index].nDataLen]=0; 3333 fsize=hInternet->ihandle[index].nDataLen; 3334 if(hInternet->ihandle[index].mimeType==NULL) 3335 mimeType=strdup("none"); 3336 else 3337 mimeType=strdup((char*)hInternet->ihandle[index].mimeType); 3338 3339 map* tmpMap=getMapOrFill(&content->content,vname,""); 3340 free(tmpMap->value); 3341 tmpMap->value=(char*)malloc((fsize+1)*sizeof(char)); 3342 if(tmpMap->value==NULL){ 3343 return errorException(*m, _("Unable to allocate memory."), "InternalError",NULL); 3344 } 3345 memcpy(tmpMap->value,fcontent,(fsize+1)*sizeof(char)); 3346 3347 char ltmp1[256]; 3348 sprintf(ltmp1,"%d",fsize); 3349 map* tmp=getMapFromMaps(*m,"main","cacheDir"); 3350 if(tmp!=NULL){ 3351 char* md5str=getMd5(tmp1->value); 3352 char* fname=(char*)malloc(sizeof(char)*(strlen(tmp->value)+strlen(md5str)+6)); 3353 sprintf(fname,"%s/%s.zca",tmp->value,md5str); 3354 addToMap(content->content,cname,fname); 3355 free(fname); 3356 } 3357 addToMap(content->content,sname,ltmp1); 3358 addToCache(*m,tmp1->value,fcontent,mimeType,fsize); 3359 free(fcontent); 3360 free(mimeType); 3361 dumpMaps(content); 3362 index++; 3363 3232 3364 } 3233 size_t dwRead;3234 InternetReadFile(hInternet->ihandle[index],3235 (LPVOID)fcontent,3236 hInternet->ihandle[index].nDataLen,3237 &dwRead);3238 fcontent[hInternet->ihandle[index].nDataLen]=0;3239 fsize=hInternet->ihandle[index].nDataLen;3240 if(hInternet->ihandle[index].mimeType==NULL)3241 mimeType=strdup("none");3242 else3243 mimeType=strdup((char*)hInternet->ihandle[index].mimeType);3244 3245 map* tmpMap=getMapOrFill(&content->content,"value","");3246 free(tmpMap->value);3247 tmpMap->value=(char*)malloc((fsize+1)*sizeof(char));3248 if(tmpMap->value==NULL){3249 return errorException(*m, _("Unable to allocate memory."), "InternalError",NULL);3250 }3251 memcpy(tmpMap->value,fcontent,(fsize+1)*sizeof(char));3252 3253 char ltmp1[256];3254 sprintf(ltmp1,"%d",fsize);3255 addToMap(content->content,"size",ltmp1);3256 addToCache(*m,tmp1->value,fcontent,mimeType,fsize);3257 free(fcontent);3258 free(mimeType);3259 3365 } 3260 index++; 3261 } 3366 } 3367 if(shouldClean>0){ 3368 freeMap(&length); 3369 free(length); 3370 } 3371 3262 3372 content=content->next; 3263 3373 } 3374 3264 3375 } 3265 3376 } … … 3274 3385 char *mimeType=NULL; 3275 3386 int fsize=0; 3387 3388 map* t=getMap(*content,"xlink:href"); 3389 if(t==NULL){ 3390 t=getMap((*content),"href"); 3391 addToMap(*content,"xlink:href",url); 3392 } 3393 3276 3394 if(cached!=NULL){ 3395 3277 3396 struct stat f_status; 3278 3397 int s=stat(cached, &f_status); … … 3284 3403 fcontent[fsize]=0; 3285 3404 fclose(f); 3405 addToMap(*content,"cache_file",cached); 3286 3406 } 3287 3407 cached[strlen(cached)-1]='m'; … … 3294 3414 fclose(f); 3295 3415 } 3416 3296 3417 }else{ 3297 3418 hInternet->waitingRequests[hInternet->nb]=strdup(url); 3298 3419 InternetOpenUrl(hInternet,hInternet->waitingRequests[hInternet->nb],NULL,0,INTERNET_FLAG_NO_CACHE_WRITE,0); 3420 maps *oreq=getMaps(*m,"orequests"); 3421 if(oreq==NULL){ 3422 oreq=(maps*)malloc(MAPS_SIZE); 3423 oreq->name=zStrdup("orequests"); 3424 oreq->content=createMap("value",url); 3425 oreq->next=NULL; 3426 addMapsToMaps(m,oreq); 3427 freeMaps(&oreq); 3428 free(oreq); 3429 }else{ 3430 setMapArray(oreq->content,"value",hInternet->nb-1,url); 3431 } 3299 3432 return 0; 3300 3433 } … … 3309 3442 3310 3443 free(tmpMap->value); 3444 3311 3445 tmpMap->value=(char*)malloc((fsize+1)*sizeof(char)); 3312 3446 if(tmpMap->value==NULL) 3313 3447 return errorException(*m, _("Unable to allocate memory."), "InternalError",NULL); 3314 3448 memcpy(tmpMap->value,fcontent,(fsize+1)*sizeof(char)); 3315 3449 3316 3450 char ltmp1[256]; 3317 3451 sprintf(ltmp1,"%d",fsize); 3318 3452 addToMap(*content,"size",ltmp1); 3319 if(cached==NULL) 3453 if(cached==NULL){ 3320 3454 addToCache(*m,url,fcontent,mimeType,fsize); 3321 else 3455 } 3456 else{ 3322 3457 addToMap(*content,"isCached","true"); 3458 3459 map* tmp=getMapFromMaps(*m,"main","cacheDir"); 3460 if(tmp!=NULL){ 3461 map *c=getMap((*content),"xlink:href"); 3462 char* md5str=getMd5(c->value); 3463 char* fname=(char*)malloc(sizeof(char)*(strlen(tmp->value)+strlen(md5str)+6)); 3464 sprintf(fname,"%s/%s.zca",tmp->value,md5str); 3465 addToMap(*content,"cache_file",fname); 3466 free(fname); 3467 } 3468 } 3323 3469 free(fcontent); 3324 3470 free(mimeType); -
trunk/zoo-project/zoo-kernel/service_internal.h
r509 r550 120 120 #endif 121 121 122 void readGeneratedFile(maps*,map*,char*); 123 122 124 void URLDecode(char *); 123 125 char *url_encode(char *); -
trunk/zoo-project/zoo-kernel/service_internal_ms.c
r492 r550 931 931 sprintf(pszDataSource,"%s/ZOO_DATA_%s_%s.%s",tmpMap->value,outputs->name,sidMap->value,ext); 932 932 int f=zOpen(pszDataSource,O_WRONLY|O_CREAT,S_IRUSR|S_IWUSR|S_IRGRP|S_IWGRP|S_IROTH|S_IWOTH); 933 map *gfile=getMap(outputs->content,"generated_file"); 934 if(gfile!=NULL){ 935 readGeneratedFile(conf,outputs->content,gfile->value); 936 } 933 937 map* sizeMap=getMap(outputs->content,"size"); 934 938 map* vData=getMap(outputs->content,"value"); -
trunk/zoo-project/zoo-kernel/zcfg2yaml.c
r469 r550 23 23 */ 24 24 25 #include "service_internal.h" 25 26 #include "service.h" 26 #include "service_internal.h"27 27 28 28 extern int getServiceFromFile(maps*,const char*,service**); -
trunk/zoo-project/zoo-kernel/zoo_service_loader.c
r541 r550 23 23 */ 24 24 25 #define length(x) (sizeof(x) / sizeof(x[0])) 25 26 26 27 27 extern "C" int yylex (); 28 28 extern "C" int crlex (); 29 30 #ifdef USE_OTB 31 #include "service_internal_otb.h" 32 #else 33 #define length(x) (sizeof(x) / sizeof(x[0])) 34 #endif 29 35 30 36 #include "cgic.h" … … 177 183 && atoi (testMap->value) > 1) 178 184 { 179 if (addMapsArrayToMaps (&mo, mi, tmap->name) < 0) 185 addMapsArrayToMaps (&mo, mi, tmap->name); 186 map* nb=getMapFromMaps(mo,mi->name,"length"); 187 if (nb!=NULL && atoi(nb->value)>atoi(testMap->value)) 180 188 { 181 189 char emsg[1024]; 182 190 sprintf (emsg, 183 _ 184 ("You set maximum occurences for <%s> as %i but you tried to use it more than the limit you set. Please correct your ZCFG file or your request."), 191 _("You set maximum occurences for <%s> as %i but you tried to use it more than the limit you set. Please correct your ZCFG file or your request."), 185 192 mi->name, atoi (testMap->value)); 186 193 errorException (m, emsg, "InternalError", NULL); … … 609 616 } 610 617 else 618 619 #ifdef USE_OTB 620 if (strncasecmp (r_inputs->value, "OTB", 6) == 0) 621 { 622 *eres = 623 zoo_otb_support (&m, request_inputs, s1, 624 &request_input_real_format, 625 &request_output_real_format); 626 } 627 else 628 #endif 629 611 630 #ifdef USE_PYTHON 612 631 if (strncasecmp (r_inputs->value, "PYTHON", 6) == 0)
Note: See TracChangeset
for help on using the changeset viewer.