Changeset 851
- Timestamp:
- Aug 31, 2017, 4:14:46 PM (7 years ago)
- Location:
- branches/prototype-v0/zoo-project/zoo-kernel
- Files:
-
- 9 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/prototype-v0/zoo-project/zoo-kernel/response_print.c
r850 r851 2667 2667 #endif 2668 2668 map *gfile=getMap(tmpI->content,"generated_file"); 2669 char *file_name ;2669 char *file_name=NULL; 2670 2670 if(gfile!=NULL){ 2671 2671 gfile=getMap(tmpI->content,"expected_generated_file"); … … 2676 2676 file_name=zStrdup((gfile->value)+strlen(tmp1->value)); 2677 2677 } 2678 2679 2678 toto=getMap(tmpI->content,"asReference"); 2680 2679 #ifdef USE_MS … … 2714 2713 getFileExtension(mtype != NULL ? mtype->value : NULL, file_ext, 32); 2715 2714 } 2716 2715 if(file_name!=NULL) 2716 free(file_name); 2717 2717 file_name=(char*)malloc((strlen(s->name)+strlen(usid->value)+strlen(file_ext)+strlen(tmpI->name)+45)*sizeof(char)); 2718 2718 sprintf(file_name,"%s_%s_%s_%d.%s",s->name,tmpI->name,usid->value,itn,file_ext); … … 2761 2761 free(file_name); 2762 2762 free(file_url); 2763 2763 file_name=NULL; 2764 2764 } 2765 2765 #ifdef USE_MS … … 2770 2770 } 2771 2771 #endif 2772 if(file_name!=NULL){ 2773 free(file_name); 2774 file_name=NULL; 2775 } 2772 2776 tmpI=tmpI->next; 2773 2777 } … … 2777 2781 if(tmpI!=NULL) 2778 2782 goto NESTED0; 2779 } 2783 } 2780 2784 #ifdef DEBUG 2781 2785 fprintf(stderr,"SERVICE : %s\n",s->name); -
branches/prototype-v0/zoo-project/zoo-kernel/service_callback.c
r850 r851 30 30 #include "service_json.h" 31 31 #include "service_internal_ms.h" 32 #include <pthread.h> 32 33 33 34 #ifdef __cplusplus … … 35 36 #endif 36 37 38 int nbThreads=0; 39 int cStep=0; 40 pthread_t* myThreads=NULL; 41 bool steps[7][2]={ 42 {false,false}, 43 {false,false}, 44 {false,false}, 45 {false,false}, 46 {false,false}, 47 {false,false}, 48 {false,false} 49 }; 50 37 51 /** 38 * Check if a service name is prohibited, meaning that we don't have to invoke39 * t he callback for this specific service.52 * Check if a service name is prohibited, meaning that the Kernel doesn't have 53 * to invoke the callback for this specific service. 40 54 * 55 * @param conf the main configuration file maps 56 * @param serviceName the serviceName 57 * @return a bool true if the service is prohibited, false in other case 41 58 */ 42 59 bool isProhibited(maps* conf,const char* serviceName){ … … 52 69 } 53 70 return false; 71 } 72 73 /** 74 * Parameter definition to be used for sending parameters to a thread. 75 */ 76 typedef struct { 77 maps *conf; //!< the main configuration file 78 map *url; //!< the callback url maps 79 json_object *res;//!< the JSON object to post 80 int step; //!< the current step [0,6] 81 int state; //!< the current state [0,1] 82 } local_params; 83 84 /** 85 * Verify if the URL should use a shared cache or not. 86 * 87 * In case the security section contains a key named "shared", then if the 88 * domain listed in the shared key are contained in the url given as parameter 89 * then it return "SHARED" in other cases, it returns "OTHER". 90 * 91 * @param conf the main configuration file maps 92 * @param url the URL to evaluate 93 * @return a string "SHARED" in case the host is in a domain listed in the 94 * shared key, "OTHER" in other cases. 95 */ 96 char* getProvenance(maps* conf,const char* url){ 97 map* sharedCache=getMapFromMaps(conf,"security","shared"); 98 if(sharedCache!=NULL){ 99 char *res=NULL; 100 char *hosts=sharedCache->value; 101 char *curs=strtok(hosts,","); 102 while(curs!=NULL){ 103 if(strstr(url,curs)==NULL) 104 res="OTHER"; 105 else{ 106 res="SHARED"; 107 return res; 108 } 109 } 110 return res; 111 } 112 return "OTHER"; 113 } 114 115 /** 116 * Practically invoke the callback, meaning sending the HTTP POST request. 117 * 118 * @param args local_params containing all the variables required 119 */ 120 void* _invokeCallback(void* args){ 121 local_params* arg=(local_params*)args; 122 HINTERNET hInternet,res1; 123 hInternet=InternetOpen("ZooWPSClient\0", 124 INTERNET_OPEN_TYPE_PRECONFIG, 125 NULL,NULL, 0); 126 if(!CHECK_INET_HANDLE(hInternet)){ 127 InternetCloseHandle (&hInternet); 128 return false; 129 } 130 char *URL=(char*)malloc((strlen(arg->url->value)+5)*sizeof(char)); 131 sprintf(URL,"%s%d_%d/",arg->url->value,arg->step,arg->state); 132 const char* jsonStr=json_object_to_json_string_ext(arg->res,JSON_C_TO_STRING_PLAIN); 133 hInternet.waitingRequests[0] = zStrdup(URL); 134 free(URL); 135 fprintf(stderr,"************************* From thread %d %s %d: REQUEST PARAMETERS\n",pthread_self(),__FILE__,__LINE__); 136 fprintf(stderr," * JSON: [%s] \n",jsonStr); 137 fprintf(stderr," * URL: %s/ \n\n",hInternet.waitingRequests[0]); 138 fprintf(stderr,"************************* From thread %d %s %d: REQUEST PARAMETERS\n",pthread_self(),__FILE__,__LINE__); 139 while( cStep!=7 && 140 ( cStep!=arg->step || (arg->state!=0 && steps[arg->step][0]==false) ) 141 ){ 142 sleep(1); 143 } 144 fprintf(stderr,"************************* From thread %d %s %d: REQUEST START\n\n",pthread_self(),__FILE__,__LINE__); 145 int i=0; 146 for(i=0;i<7;i++){ 147 fprintf(stderr,"%d) %d %d\n",i,steps[i][0],steps[i][1]); 148 fflush(stderr); 149 } 150 fprintf(stderr,"************************* From thread %d %s %d: REQUEST START\n",pthread_self(),__FILE__,__LINE__); 151 fflush(stderr); 152 res1 = InternetOpenUrl (&hInternet, 153 hInternet.waitingRequests[0], 154 (char*)jsonStr, strlen(jsonStr), 155 INTERNET_FLAG_NO_CACHE_WRITE, 156 0); 157 AddHeaderEntries(&hInternet,arg->conf); 158 //curl_easy_setopt(hInternet.ihandle[hInternet.nb].handle, CURLOPT_VERBOSE, 1);x 159 processDownloads(&hInternet); 160 fprintf(stderr,"************************* From thread %d %s %d: REQUEST END\n\n",pthread_self(),__FILE__,__LINE__); 161 fflush(stderr); 162 char *tmp = (char *) malloc ((hInternet.ihandle[0].nDataLen + 1) 163 * sizeof (char)); 164 if (tmp == NULL) 165 { 166 setMapInMaps(arg->conf,"lenv","message",_("Unable to allocate memory")); 167 setMapInMaps(arg->conf,"lenv","code","InternalError"); 168 return NULL; 169 } 170 size_t bRead; 171 InternetReadFile (hInternet.ihandle[0], 172 (LPVOID) tmp, 173 hInternet. 174 ihandle[0].nDataLen, 175 &bRead); 176 tmp[hInternet.ihandle[0].nDataLen] = 0; 177 json_object_put(arg->res); 178 InternetCloseHandle(&hInternet); 179 if(cStep==0 || cStep==6 || arg->state==1) 180 cStep=arg->step+1; 181 steps[arg->step][arg->state]=true; 182 fprintf(stderr,"************************* From thread %d %s %d: RESPONSE CONTENT\n",pthread_self(),__FILE__,__LINE__); 183 for(i=0;i<7;i++){ 184 fprintf(stderr,"%d) %d %d\n",i,steps[i][0],steps[i][1]); 185 } 186 fprintf(stderr,"Result: \n%s\n\n",tmp); 187 fprintf(stderr,"************************* From thread %d %s %d\n\n",pthread_self(),__FILE__,__LINE__); 188 fflush(stderr); 189 free(tmp); 190 free(args); 191 pthread_exit(NULL); 54 192 } 55 193 … … 72 210 * @return bool true in case of success, false in other cases 73 211 */ 74 bool invokeCallback(maps* m,maps* inputs,maps* outputs,int step,int state){75 map* url=getMapFromMaps( m,"callback","url");212 bool invokeCallback(maps* conf,maps* inputs,maps* outputs,int step,int state){ 213 map* url=getMapFromMaps(conf,"callback","url"); 76 214 if(url==NULL) 77 215 return false; 78 216 79 maps* lenv=getMaps( m,"lenv");217 maps* lenv=getMaps(conf,"lenv"); 80 218 map* sname=getMap(lenv->content,"identifier"); 81 if(sname!=NULL && isProhibited( m,sname->value))219 if(sname!=NULL && isProhibited(conf,sname->value)) 82 220 return false; 83 221 84 222 json_object *res=json_object_new_object(); 85 223 86 map* sid=getMapFromMaps( m,"lenv","usid");224 map* sid=getMapFromMaps(conf,"lenv","usid"); 87 225 if(sid!=NULL){ 88 226 json_object *jsStr=json_object_new_string(sid->value); 89 227 json_object_object_add(res,"jobid",jsStr); 90 228 } 229 const struct tm *tm; 230 size_t len; 231 time_t now; 232 char *tmp1; 233 map *tmpStatus; 234 235 now = time ( NULL ); 236 tm = localtime ( &now ); 237 238 tmp1 = (char*)malloc((TIME_SIZE+1)*sizeof(char)); 239 240 len = strftime ( tmp1, TIME_SIZE, "%Y-%m-%dT%I:%M:%SZ", tm ); 241 json_object *jsStr0=json_object_new_string(tmp1); 242 json_object_object_add(res,"datetime",jsStr0); 243 91 244 switch(step){ 92 245 case 0: { 93 246 // Create a new analyze 94 maps* lenv=getMaps( m,"lenv");95 sid=getMapFromMaps( m,"lenv","xrequest");247 maps* lenv=getMaps(conf,"lenv"); 248 sid=getMapFromMaps(conf,"lenv","xrequest"); 96 249 if(sid!=NULL){ 97 250 json_object *jsStr=json_object_new_string(sid->value); 98 251 json_object_object_add(res,"request_execute_content",jsStr); 99 252 } 100 sid=getMapFromMaps( m,"lenv","identifier");253 sid=getMapFromMaps(conf,"lenv","identifier"); 101 254 if(sid!=NULL){ 102 255 json_object *jsStr=json_object_new_string(sid->value); … … 108 261 // Fetching data inputs 109 262 maps* curs=inputs; 110 111 263 char *keys[8][2]={ 112 264 { … … 139 291 }, 140 292 { 141 " datatype",293 "geodatatype", 142 294 "datatype" 143 295 } … … 147 299 map* tmpMap=getMap(curs->content,"cache_file"); 148 300 sid=getMap(curs->content,"ref_wms_link"); 301 json_object *res2=json_object_new_object(); 149 302 if(tmpMap!=NULL && sid==NULL){ 150 303 addToMap(curs->content,"generated_file",tmpMap->value); 304 struct stat buf; 305 char timeStr[ 100 ] = ""; 306 if (stat(tmpMap->value, &buf)==0){ 307 strftime(timeStr, 100, "%d-%m-%Y %H:%M:%S", localtime( &buf.st_mtime)); 308 json_object *jsStr=json_object_new_string(timeStr); 309 json_object_object_add(res2,"creation_date",jsStr); 310 } 151 311 tmpMap=getMap(curs->content,"fmimeType"); 152 312 if(tmpMap!=NULL){ 153 313 addToMap(curs->content,"mimeType",tmpMap->value); 154 314 } 155 setReferenceUrl( m,curs);156 //outputMapfile( m,curs);315 setReferenceUrl(conf,curs); 316 //outputMapfile(conf,curs); 157 317 dumpMaps(curs); 158 318 } 159 json_object *res2=json_object_new_object();160 319 int i=0; 161 320 int hasRef=-1; … … 165 324 json_object *jsStr=json_object_new_string(sid->value); 166 325 json_object_object_add(res2,keys[i][1],jsStr); 167 if(i==0) 326 if(i==0){ 168 327 hasRef=1; 328 json_object *jsStr1=json_object_new_string(getProvenance(conf,url->value)); 329 json_object_object_add(res2,"dataOrigin",jsStr1); 330 } 169 331 } 170 332 } … … 176 338 } 177 339 json_object_object_add(res,"inputs",res1); 178 json_object* in=mapsToJson(inputs);179 if(in!=NULL){180 //json_object_object_add(res,"inputs",in);181 json_object_put(in);182 }183 340 break; 184 341 } 185 342 case 2: { 186 343 // Uploading data input to cluster 187 maps* in=getMaps( m,"uploadQueue");344 maps* in=getMaps(conf,"uploadQueue"); 188 345 if(in!=NULL){ 189 346 maps* curs=in; … … 216 373 case 3: { 217 374 // Generating job script 218 sid=getMapFromMaps( m,"lenv","local_script");375 sid=getMapFromMaps(conf,"lenv","local_script"); 219 376 if(sid!=NULL){ 220 377 json_object *jsStr=json_object_new_string(sid->value); … … 225 382 case 4: { 226 383 // Submitting job to cluster 227 sid=getMapFromMaps( m,"lenv","remote_script");384 sid=getMapFromMaps(conf,"lenv","remote_script"); 228 385 if(sid!=NULL){ 229 386 json_object *jsStr=json_object_new_string(sid->value); … … 234 391 case 5: { 235 392 // Downloading process outputs from cluster 236 json_object* in=mapsToJson(outputs); 237 if(in!=NULL){ 238 //json_object_object_add(res,"outputs",in); 239 json_object_put(in); 240 } 393 //json_object* in=mapsToJson(outputs); 394 dumpMaps(outputs); 395 maps* curs=outputs; 396 char *keys[8][2]={ 397 { 398 "Reference", 399 "ref" 400 }, 401 { 402 "storage", 403 "cachefile" 404 }, 405 { 406 "fmimeType", 407 "mimetype" 408 }, 409 { 410 "size", 411 "size" 412 }, 413 { 414 "ref_wms_link", 415 "ref_wms_link" 416 }, 417 { 418 "ref_wcs_link", 419 "ref_wcs_link" 420 }, 421 { 422 "ref_wfs_link", 423 "ref_wfs_link" 424 }, 425 { 426 "geodatatype", 427 "datatype" 428 } 429 }; 430 json_object *res1=json_object_new_object(); 431 while(curs!=NULL){ 432 map* tmpMap=getMap(curs->content,"cache_file"); 433 sid=getMap(curs->content,"ref_wms_link"); 434 json_object *res2=json_object_new_object(); 435 int i=0; 436 int hasRef=-1; 437 for(;i<8;i++){ 438 sid=getMap(curs->content,keys[i][0]); 439 if(sid!=NULL){ 440 json_object *jsStr=json_object_new_string(sid->value); 441 json_object_object_add(res2,keys[i][1],jsStr); 442 if(i==0) 443 hasRef=1; 444 } 445 } 446 if(hasRef>0) 447 json_object_object_add(res1,curs->name,res2); 448 else{ 449 maps* curs0=curs->child; 450 while(curs0!=NULL){ 451 json_object *res3=json_object_new_object(); 452 int i0=0; 453 int hasRef0=-1; 454 for(;i0<8;i0++){ 455 sid=getMap(curs0->content,keys[i0][0]); 456 if(sid!=NULL){ 457 json_object *jsStr=json_object_new_string(sid->value); 458 json_object_object_add(res3,keys[i0][1],jsStr); 459 //if(i0==0) 460 hasRef0=1; 461 } 462 } 463 if(hasRef0<0) 464 json_object_put(res3); 465 else 466 json_object_object_add(res2,curs0->name,res3); 467 curs0=curs0->next; 468 } 469 json_object_object_add(res1,curs->name,res2); 470 } 471 curs=curs->next; 472 } 473 json_object_object_add(res,"outputs",res1); 241 474 break; 242 475 } 243 476 case 6: { 244 477 // Finalize HPC 245 sid=getMapFromMaps( m,"lenv","local_script");478 sid=getMapFromMaps(conf,"lenv","local_script"); 246 479 if(sid!=NULL){ 247 480 json_object *jsStr=json_object_new_string(sid->value); … … 252 485 case 7: { 253 486 // Error or Dismiss 254 sid=getMapFromMaps( m,"lenv","message");487 sid=getMapFromMaps(conf,"lenv","message"); 255 488 if(sid!=NULL){ 256 489 json_object *jsStr=json_object_new_string(sid->value); … … 265 498 } 266 499 } 267 fprintf(stderr,"************************* %s %d\n\n",__FILE__,__LINE__); 268 fflush(stderr); 269 HINTERNET hInternet,res1; 270 hInternet=InternetOpen("ZooWPSClient\0", 271 INTERNET_OPEN_TYPE_PRECONFIG, 272 NULL,NULL, 0); 273 if(!CHECK_INET_HANDLE(hInternet)){ 274 InternetCloseHandle (&hInternet); 500 501 local_params* argumentsA=(local_params*)malloc(MAPS_SIZE+MAP_SIZE+sizeof(json_object*)+(2*sizeof(int))); 502 argumentsA->conf=conf; 503 argumentsA->url=url; 504 argumentsA->res=res; 505 argumentsA->step=step; 506 argumentsA->state=state; 507 //pthread_t p1; 508 if(myThreads==NULL) 509 myThreads=(pthread_t*)malloc((nbThreads+1)*sizeof(pthread_t)); 510 else 511 myThreads=(pthread_t*)realloc(myThreads,(nbThreads+1)*sizeof(pthread_t)); 512 if(pthread_create(&myThreads[nbThreads], NULL, _invokeCallback, (void*)argumentsA)==-1){ 513 setMapInMaps(conf,"lenv","message",_("Unable to create a new thread")); 275 514 return false; 276 515 } 277 fprintf(stderr," * JSON: [%s] \n",json_object_to_json_string_ext(res,JSON_C_TO_STRING_PLAIN)); 278 fprintf(stderr," * URL: %s%d_%d/ \n\n",url->value,step,state); 279 fflush(stderr); 280 char *URL=(char*)malloc((strlen(url->value)+5)*sizeof(char)); 281 sprintf(URL,"%s%d_%d/",url->value,step,state); 282 hInternet.waitingRequests[0] = zStrdup(URL); 283 free(URL); 284 const char* jsonStr=json_object_to_json_string_ext(res,JSON_C_TO_STRING_PLAIN); 285 res1 = InternetOpenUrl (&hInternet, 286 hInternet.waitingRequests[0], 287 (char*)jsonStr, strlen(jsonStr), 288 INTERNET_FLAG_NO_CACHE_WRITE, 289 0); 290 AddHeaderEntries(&hInternet,m); 291 //curl_easy_setopt(hInternet.ihandle[hInternet.nb].handle, CURLOPT_VERBOSE, 1); 292 processDownloads(&hInternet); 293 char *tmp = (char *) malloc ((hInternet.ihandle[0].nDataLen + 1) 294 * sizeof (char)); 295 if (tmp == NULL) 296 { 297 setMapInMaps(m,"lenv","message",_("Unable to allocate memory")); 298 setMapInMaps(m,"lenv","code","InternalError"); 299 return false; 300 } 301 size_t bRead; 302 InternetReadFile (hInternet.ihandle[0], 303 (LPVOID) tmp, 304 hInternet. 305 ihandle[0].nDataLen, 306 &bRead); 307 tmp[hInternet.ihandle[0].nDataLen] = 0; 308 fprintf(stderr,"Result: \n%s\n\n",tmp); 309 fprintf(stderr,"************************* %s %d\n\n",__FILE__,__LINE__); 310 fflush(stderr); 311 free(tmp); 312 json_object_put(res); 313 InternetCloseHandle(&hInternet); 516 //free(argumentsA); 517 nbThreads++; 314 518 return true; 519 } 520 521 void cleanupCallbackThreads(){ 522 int i=0; 523 for(i=0;i<nbThreads;i++){ 524 pthread_join(myThreads[i],NULL); 525 } 526 free(myThreads); 315 527 } 316 528 -
branches/prototype-v0/zoo-project/zoo-kernel/service_callback.h
r845 r851 43 43 44 44 bool invokeCallback(maps*,maps*,maps*,int,int); 45 45 void cleanupCallbackThreads(); 46 46 47 #ifdef __cplusplus 47 48 } -
branches/prototype-v0/zoo-project/zoo-kernel/service_internal_hpc.c
r850 r851 137 137 } 138 138 } 139 140 139 addToElements(&cur->child,tmp[0]); 141 140 addToElements(&cur->child,tmp[1]); … … 301 300 char *targetPath=(char*)malloc((strlen(targetPathMap->value)+strlen(targetName)+2)*sizeof(char)); 302 301 sprintf(targetPath,"%s/%s",targetPathMap->value,targetName); 302 free(targetName); 303 303 setMapInMaps(*real_outputs,input->name,"generated_file",targetPath); 304 304 // We should verify if any optional tag for output is required … … 337 337 char *targetPath=(char*)malloc((strlen(targetPathMap->value)+strlen(targetName)+2)*sizeof(char)); 338 338 sprintf(targetPath,"%s/%s",targetPathMap->value,targetName); 339 free(targetName); 339 340 addToMap(input->content,"generated_file",targetPath); 340 341 // We should verify if any optional tag for output is required … … 499 500 return -1; 500 501 } 502 free(targetPath); 501 503 fprintf(stderr,"************************* %s %d \n\n",__FILE__,__LINE__); 502 504 fflush(stderr); … … 591 593 setMapInMaps(output->child,"download_link","generated_file",targetPath); 592 594 setMapInMaps(output->child,"download_link","useMapserver","false"); 593 setMapInMaps(output->child,"WMS_LINK","generated_file",targetPath); 594 setMapInMaps(output->child,"WMS_LINK","useMapserver","true"); 595 setMapInMaps(output->child,"WCS_LINK","generated_file",targetPath); 596 setMapInMaps(output->child,"WCS_LINK","useMapserver","true"); 595 setMapInMaps(output->child,"wms_link","generated_file",targetPath); 596 setMapInMaps(output->child,"wms_link","useMapserver","true"); 597 setMapInMaps(output->child,"wms_link","msOgc","WMS"); 598 setMapInMaps(output->child,"wms_link","requestedMimeType","image/png"); 599 setMapInMaps(output->child,"wcs_link","generated_file",targetPath); 600 setMapInMaps(output->child,"wcs_link","useMapserver","true"); 597 601 } 602 free(targetPath); 598 603 } 599 604 } 600 605 input=input->next; 601 606 } 602 fprintf(stderr,"************************* %s %d \n\n",__FILE__,__LINE__);603 fflush(stderr);604 invokeCallback(m,NULL,outputs,5,1);605 fprintf(stderr,"************************* %s %d \n\n",__FILE__,__LINE__);606 fflush(stderr);607 607 } 608 608 //free(buf); -
branches/prototype-v0/zoo-project/zoo-kernel/service_internal_ms.c
r850 r851 194 194 195 195 char* webService_url=(char*)malloc((strlen(msUrl->value)+strlen(format->value)+strlen(tmpI->name)+strlen(width->value)+strlen(height->value)+strlen(extent->value)+256)*sizeof(char)); 196 map* datatype=getMap(tmpI->content," datatype");196 map* datatype=getMap(tmpI->content,"geodatatype"); 197 197 198 sprintf(webService_url,199 "%s?map=%s/%s_%s.map&request=%s&service=%s&version=%s&%s&format=%s&bbox=%s&crs=%s",200 msUrl->value,201 dataPath->value,202 tmpI->name,203 sid->value,204 options[proto][2],205 options[proto][0],206 protoVersion,207 layers,208 rformat->value,209 extent->value,210 crs->value211 );212 198 if(proto>0){ 213 addToMap(tmpI->content,"Reference",webService_url); 199 sprintf(webService_url, 200 "%s?map=%s/%s_%s.map&request=%s&service=%s&version=%s&%s&format=%s&bbox=%s&crs=%s", 201 msUrl->value, 202 dataPath->value, 203 tmpI->name, 204 sid->value, 205 options[proto][2], 206 options[proto][0], 207 protoVersion, 208 layers, 209 rformat->value, 210 extent->value, 211 crs->value 212 ); 213 if(datatype!=NULL && strncasecmp(datatype->value,"raster",6)==0){ 214 addToMap(tmpI->content,"ref_wcs_link",webService_url); 215 } 216 else{ 217 addToMap(tmpI->content,"ref_wfs_link",webService_url); 218 } 214 219 proto=0; 215 220 rformat=createMap("mimeType","image/png"); 216 221 } 217 222 else{ 223 sprintf(webService_url, 224 "%s?map=%s/%s_%s.map&request=%s&service=%s&version=%s&%s&width=%s&height=%s&format=%s&bbox=%s&crs=%s", 225 msUrl->value, 226 dataPath->value, 227 tmpI->name, 228 sid->value, 229 options[proto][2], 230 options[proto][0], 231 protoVersion, 232 layers, 233 width->value, 234 height->value, 235 rformat->value, 236 extent->value, 237 crs->value 238 ); 239 addToMap(tmpI->content,"ref_wms_link",webService_url); 218 240 if(datatype!=NULL && strncasecmp(datatype->value,"raster",6)==0){ 219 241 proto=2; … … 225 247 } 226 248 } 227 if(datatype!=NULL && strncasecmp(datatype->value,"raster",6)==0){ 228 addToMap(tmpI->content,"ref_wcs_link",webService_url); 229 } 230 else{ 231 addToMap(tmpI->content,"ref_wfs_link",webService_url); 232 } 249 addToMap(tmpI->content,"Reference",webService_url); 250 233 251 protoVersion=options[proto][1]; 234 252 extent=getMap(tmpI->content,options[proto][4]); 235 253 memset(webService_url,0,strlen(webService_url)); 236 sprintf(webService_url,237 "%s?map=%s/%s_%s.map&request=%s&service=%s&version=%s&%s&width=%s&height=%s&format=%s&bbox=%s&crs=%s",238 msUrl->value,239 dataPath->value,240 tmpI->name,241 sid->value,242 options[proto][2],243 options[proto][0],244 protoVersion,245 layers,246 width->value,247 height->value,248 rformat->value,249 extent->value,250 crs->value251 );252 254 if(proto>0){ 253 addToMap(tmpI->content,"Reference",webService_url); 254 } 255 addToMap(tmpI->content,"ref_wms_link",webService_url); 255 sprintf(webService_url, 256 "%s?map=%s/%s_%s.map&request=%s&service=%s&version=%s&%s&format=%s&bbox=%s&crs=%s", 257 msUrl->value, 258 dataPath->value, 259 tmpI->name, 260 sid->value, 261 options[proto][2], 262 options[proto][0], 263 protoVersion, 264 layers, 265 rformat->value, 266 extent->value, 267 crs->value 268 ); 269 if(datatype!=NULL && strncasecmp(datatype->value,"raster",6)==0){ 270 addToMap(tmpI->content,"ref_wcs_link",webService_url); 271 } 272 else{ 273 addToMap(tmpI->content,"ref_wfs_link",webService_url); 274 } 275 }else{ 276 sprintf(webService_url, 277 "%s?map=%s/%s_%s.map&request=%s&service=%s&version=%s&%s&width=%s&height=%s&format=%s&bbox=%s&crs=%s", 278 msUrl->value, 279 dataPath->value, 280 tmpI->name, 281 sid->value, 282 options[proto][2], 283 options[proto][0], 284 protoVersion, 285 layers, 286 width->value, 287 height->value, 288 rformat->value, 289 extent->value, 290 crs->value 291 ); 292 addToMap(tmpI->content,"ref_wms_link",webService_url); 293 } 256 294 if(hasCRS==0){ 257 295 freeMap(&crs); 258 296 free(crs); 259 297 } 298 freeMap(&rformat); 299 free(rformat); 260 300 free(webService_url); 301 dumpMaps(tmpI); 261 302 } 262 303 … … 552 593 i++; 553 594 } 595 OGR_DS_Destroy(poDS1); 554 596 } 555 597 free(sdsName); … … 572 614 } 573 615 574 addToMap(output->content," datatype","vector");616 addToMap(output->content,"geodatatype","vector"); 575 617 int iLayer = 0; 576 618 for( iLayer=0; iLayer < OGR_DS_GetLayerCount(poDS); iLayer++ ){ … … 744 786 } 745 787 746 //OGR_DS_Destroy(poDS);788 OGR_DS_Destroy(poDS); 747 789 //OGRCleanupAll(); 748 790 … … 774 816 fprintf(stderr,"Unable to access the DataSource %s \n",pszFilename); 775 817 #endif 818 addToMap(output->content,"geodatatype","other"); 776 819 setMapInMaps(conf,"lenv","message","gdalinfo failed - unable to open"); 777 820 GDALDestroyDriverManager(); … … 782 825 #endif 783 826 784 addToMap(output->content," datatype","raster");827 addToMap(output->content,"geodatatype","raster"); 785 828 /** 786 829 * Add a new layer set name, data … … 1018 1061 GDALClose( hDataset ); 1019 1062 GDALDestroyDriverManager(); 1020 1021 1063 CPLCleanupTLS(); 1022 1064 return 1; -
branches/prototype-v0/zoo-project/zoo-kernel/sqlapi.c
r850 r851 532 532 execSql(conf,zoo_ds_nb-1,sqlQuery); 533 533 cleanUpResultSet(conf,zoo_ds_nb-1); 534 close_sql(conf,zoo_ds_nb-1);534 //close_sql(conf,zoo_ds_nb-1); 535 535 free(sqlQuery); 536 536 end_sql(); … … 604 604 OGRFeature::DestroyFeature( poFeature ); 605 605 } 606 cleanUpResultSet(conf,zoo_ds_nb-1); 606 607 if(hasRes<0) 607 608 addToMap(statusInfo,"Status","Failed"); -
branches/prototype-v0/zoo-project/zoo-kernel/sshapi.c
r839 r851 337 337 sftp_handle = 338 338 libssh2_sftp_open(sessions[cnt]->sftp_session, targetPath, 339 340 339 LIBSSH2_FXF_WRITE|LIBSSH2_FXF_CREAT|LIBSSH2_FXF_TRUNC, 341 340 LIBSSH2_SFTP_S_IRUSR|LIBSSH2_SFTP_S_IWUSR| … … 513 512 sprintf(logPath,"%s/exec_out_%s",tmpPath->value,uuid->value); 514 513 FILE* logFile=fopen(logPath,"wb"); 514 free(logPath); 515 515 while(true){ 516 516 int rc; -
branches/prototype-v0/zoo-project/zoo-kernel/ulinet.c
r850 r851 344 344 free(handle.cookie); 345 345 } 346 fprintf(stderr,"%s%d\n",__FILE__,__LINE__); 347 fflush(stderr); 346 348 if(handle0->handle) 347 349 curl_multi_cleanup(handle0->handle); 350 fprintf(stderr,"%s%d\n",__FILE__,__LINE__); 351 fflush(stderr); 348 352 free(handle0->agent); 353 fprintf(stderr,"%s%d\n",__FILE__,__LINE__); 354 fflush(stderr); 349 355 for(i=handle0->nb-1;i>=0;i--){ 356 fprintf(stderr,"%s%d\n",__FILE__,__LINE__); 357 fflush(stderr); 350 358 free(handle0->waitingRequests[i]); 359 fprintf(stderr,"%s%d\n",__FILE__,__LINE__); 360 fflush(stderr); 351 361 } 352 362 } -
branches/prototype-v0/zoo-project/zoo-kernel/zoo_service_loader.c
r850 r851 2269 2269 _tmpMaps = createMaps("renv"); 2270 2270 for (; s; ei++) { 2271 int len=strlen(s); 2272 char* tmpName=zStrdup(s); 2273 char* tmpValue=strstr(s,"=")+1; 2274 char* tmpName1=(char*)malloc((1+(len-strlen(tmpValue)))*sizeof(char)); 2275 snprintf(tmpName1,(len-strlen(tmpValue))+1,"%s",tmpName); 2276 if(_tmpMaps->content == NULL) 2277 _tmpMaps->content = createMap (tmpName1,tmpValue); 2278 else 2279 addToMap (_tmpMaps->content,tmpName1,tmpValue); 2280 free(tmpName); 2281 free(tmpName1); 2271 if(strstr(s,"=")!=NULL && strlen(strstr(s,"="))>1){ 2272 int len=strlen(s); 2273 char* tmpName=zStrdup(s); 2274 char* tmpValue=strstr(s,"=")+1; 2275 char* tmpName1=(char*)malloc((1+(len-strlen(tmpValue)))*sizeof(char)); 2276 snprintf(tmpName1,(len-strlen(tmpValue))+1,"%s",tmpName); 2277 if(_tmpMaps->content == NULL) 2278 _tmpMaps->content = createMap (tmpName1,tmpValue); 2279 else 2280 addToMap (_tmpMaps->content,tmpName1,tmpValue); 2281 free(tmpName1); 2282 free(tmpName); 2283 } 2282 2284 s = *(orig+ei); 2283 2285 } … … 2353 2355 loadServiceAndRun (&m, s1, request_inputs, &request_input_real_format, 2354 2356 &request_output_real_format, &eres); 2357 #ifdef RELY_ON_DB 2358 #ifdef META_DB 2359 close_sql(m,1); 2360 //end_sql(); 2361 #endif 2362 close_sql(m,0); 2363 #endif 2355 2364 } 2356 2365 else … … 2586 2595 if (((int) getpid ()) != cpid || cgiSid != NULL) 2587 2596 { 2597 fprintf(stderr,"************************* %s %d \n\n",__FILE__,__LINE__); 2598 fflush(stderr); 2599 invokeCallback(m,NULL,request_output_real_format,5,1); 2600 fprintf(stderr,"************************* %s %d \n\n",__FILE__,__LINE__); 2601 fflush(stderr); 2602 2588 2603 fclose (stdout); 2589 2604 … … 2611 2626 recordResponse(m,fbkp1); 2612 2627 fprintf(stderr,"************************* %s %d \n\n",__FILE__,__LINE__); 2613 invokeCallback(m,NULL,request_output_real_format, 5,1);2628 invokeCallback(m,NULL,request_output_real_format,6,0); 2614 2629 fprintf(stderr,"************************* %s %d \n\n",__FILE__,__LINE__); 2615 2630 #endif … … 2617 2632 free(bmap); 2618 2633 unlink (fbkp1); 2634 unhandleStatus (m); 2635 #ifdef RELY_ON_DB 2636 #ifdef META_DB 2637 cleanupCallbackThreads(); 2638 close_sql(m,1); 2639 //end_sql(); 2640 #endif 2641 close_sql(m,0); 2642 #endif 2619 2643 unlink (flog); 2620 unhandleStatus (m);2621 #ifdef META_DB2622 close_sql(m,0);2623 //end_sql();2624 #endif2625 2644 free(fbkpid); 2626 2645 free(fbkpres); … … 2630 2649 if(cgiSid!=NULL) 2631 2650 free(cgiSid); 2632 //InternetCloseHandle (&hInternet); 2651 //InternetCloseHandle (&hInternet); 2633 2652 fprintf (stderr, "RUN IN BACKGROUND MODE %s %d \n",__FILE__,__LINE__); 2634 2653 fflush(stderr);
Note: See TracChangeset
for help on using the changeset viewer.