Changeset 888 for branches/prototype-v0
- Timestamp:
- Nov 16, 2018, 3:09:05 PM (6 years ago)
- 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 411 411 char *mimeType=NULL; 412 412 int fsize=0; 413 char oriname[12]; 413 414 char cname[15]; 414 415 char vname[11]; … … 430 431 sprintf(cname,"cache_file_%d",i); 431 432 tmp1=getMap(content->content,cname); 433 sprintf(oriname,"origin_%d",i); 432 434 sprintf(vname,"value_%d",i); 433 435 sprintf(sname,"size_%d",i); … … 441 443 }else{ 442 444 sprintf(cname,"cache_file"); 445 sprintf(oriname,"origin"); 443 446 sprintf(vname,"value"); 444 447 sprintf(sname,"size"); … … 539 542 addToMap((*in)->content,sname,ltmp1); 540 543 addToMap((*in)->content,mname,mimeType); 544 char* origin=getProvenance(*m,request); 545 addToMap((*in)->content,oriname,origin); 541 546 if(memUse==NULL || strcasecmp(memUse->value,"load")==0){ 542 547 addToCache(*m,request,fcontent,mimeType,fsize, NULL, 0); … … 632 637 char* cached=isInCache(*m,url); 633 638 char *mimeType=NULL; 639 char *origin=NULL; 634 640 int fsize=0; 635 641 map* memUse=getMapFromMaps(*m,"main","memory"); … … 674 680 unlockFile(*m,lck); 675 681 } 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 } 676 695 }else{ 677 696 addRequestToQueue(m,hInternet,url,true); … … 683 702 if(mimeType!=NULL){ 684 703 addToMap(*content,"fmimeType",mimeType); 704 } 705 if(origin!=NULL){ 706 addToMap(*content,"origin",origin); 685 707 } 686 708 -
branches/prototype-v0/zoo-project/zoo-kernel/response_print.c
r877 r888 33 33 #include "cpl_vsi.h" 34 34 #endif 35 #ifdef USE_HPC 36 #include "service_callback.h" 37 #endif 35 38 36 39 #ifndef TRUE … … 362 365 nc4 = xmlNewNode(ns_ows, BAD_CAST "Language"); 363 366 xmlAddChild(nc4,xmlNewText(BAD_CAST buff)); 364 365 366 367 367 if(vid==0) 368 xmlAddChild(nc3,nc4); 369 else 370 xmlAddChild(nc1,nc4); 368 371 } 369 372 } … … 753 756 */ 754 757 void addMetadata(map* meta,xmlDocPtr doc,xmlNodePtr nc,xmlNsPtr ns_ows,xmlNsPtr ns_xlink,int vid){ 755 756 757 758 759 760 761 762 763 764 765 766 767 768 769 770 771 772 773 774 775 776 777 778 779 780 781 782 783 784 785 786 787 788 789 790 791 792 793 794 795 796 797 798 799 800 801 802 803 804 805 806 807 808 809 810 811 812 813 814 815 816 817 818 819 820 821 822 823 824 825 826 827 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 } 829 832 } 830 833 … … 840 843 */ 841 844 void addAdditionalParameters(map* meta,xmlDocPtr doc,xmlNodePtr nc,xmlNsPtr ns_ows,xmlNsPtr ns_xlink,int fromDb){ 842 843 844 845 846 847 848 849 850 851 852 853 854 855 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; 856 859 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 } 898 919 }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 } 941 944 } 942 945 … … 1999 2002 if(testResponse==NULL || tmp0==NULL){ 2000 2003 if(vid==0) 2001 2004 printIOType(doc,nc,ns,ns_ows,ns_xlink,scursor,mcursor,"Output",vid); 2002 2005 else 2003 2006 printIOType(doc,n,ns,ns_ows,ns_xlink,scursor,mcursor,"Output",vid); 2004 2007 } 2005 2008 else … … 2137 2140 else{ 2138 2141 /* 2139 dumpElements(e);2142 dumpElements(e); 2140 2143 */ 2141 2144 return; … … 2146 2149 || strncasecmp(tmp->name,"SCHEMA",strlen(tmp->name))==0 2147 2150 || 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); 2149 2152 tmp=tmp->next; 2150 2153 } … … 2352 2355 strstr(tmp2->value, "json") != NULL || // (will not be parsed by XML reader) 2353 2356 strstr(tmp2->value, "ecmascript") != NULL 2354 ) {2357 ) { 2355 2358 xmlAddChild((vid==0?nc3:nc2),xmlNewCDataBlock(doc,BAD_CAST tmp3->value,strlen(tmp3->value))); 2356 2359 } … … 2358 2361 if (strstr(tmp2->value, "xml") != NULL || // if XML-based format 2359 2362 // include for backwards compatibility, 2360 2363 // although correct mime type is ...kml+xml: 2361 2364 strstr(tmp2->value, "google-earth.kml") != NULL 2362 2365 ) { … … 2580 2583 2581 2584 tmp=getMapArray(s,"text",cnt); 2585 if(tmp==NULL) 2586 tmp=getMapArray(s,"message",cnt); 2582 2587 nc1 = xmlNewNode(ns, BAD_CAST "ExceptionText"); 2583 2588 if(tmp!=NULL){ … … 2741 2746 map* usid=getMapFromMaps(m,"lenv","usid"); 2742 2747 int itn=0; 2748 int error=-1; 2743 2749 NESTED0: 2744 2750 while(tmpI!=NULL){ … … 2768 2774 (geodatatype!=NULL && strcasecmp(geodatatype->value,"other")==0) ) ) 2769 2775 #else 2770 2776 if(toto!=NULL && strcasecmp(toto->value,"true")==0) 2771 2777 #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 }else2781 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]; 2793 2799 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); 2796 2848 } 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); 2802 2860 } 2861 addToMap(tmpI->content,"Reference",file_url); 2803 2862 if(file_name!=NULL) 2804 2863 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 } 2862 2868 #ifdef USE_MS 2863 2869 else{ 2864 2870 if(testMap!=NULL){ 2871 map* nbFeatures; 2865 2872 setMapInMaps(m,"lenv","state","out"); 2866 2873 setReferenceUrl(m,tmpI); 2874 nbFeatures=getMap(tmpI->content,"nb_features"); 2867 2875 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; 2869 2879 res=SERVICE_FAILED; 2870 2880 } … … 2887 2897 dumpMaps(m); 2888 2898 #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 } 2893 2912 } 2894 2913 else{ -
branches/prototype-v0/zoo-project/zoo-kernel/service_internal_hpc.c
r887 r888 320 320 321 321 map* targetPathMap=getMapFromMaps(*main_conf,configurationId,"remote_data_path"); 322 map* targetPersistentPathMap=getMapFromMaps(*main_conf,configurationId,"remote_persistent_data_path"); 322 323 323 324 pthread_t threads_pool[50]; … … 362 363 for(i=0;i<len;i++){ 363 364 map* tmp=getMapArray(input->content,"cache_file",i); 365 map* origin=getMapArray(input->content,"origin",i); 364 366 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 } 367 376 setMapArray(input->content,"targetPath",i,targetPath); 368 377 setMapArray(input->content,"localPath",i,tmp->value); -
branches/prototype-v0/zoo-project/zoo-kernel/service_internal_ms.c
r886 r888 185 185 map* useMs=getMap(tmpI->content,"useMapserver"); 186 186 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 } 187 196 setMapInMaps(m,"lenv","mapError","true"); 188 setMap InMaps(m,"lenv","locator",tmpI->name);197 setMapArray(lenv->content,"locator",lIndex,tmpI->name); 189 198 if(nbElements==NULL) 190 setMap InMaps(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.")); 191 200 else 192 setMap InMaps(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.")); 193 202 if(getMapFromMaps(m,"lenv","state")==NULL) 194 203 errorException (m, _("Unable to find any geographic data"), "WrongInputData", tmpI->name); … … 889 898 */ 890 899 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 } 891 913 if(tmpMap!=NULL) 892 914 msUpdateStyleFromString(myLayer->CLASS[myLayer->numclasses]->styles[myLayer->CLASS[myLayer->numclasses]->numstyles],tmpMap->value,0); … … 1135 1157 CPLErrorReset(); 1136 1158 GDALGetRasterStatistics( hBand, TRUE, TRUE, &pdfMin, &pdfMax, &pdfMean, &pdfStdDev); 1137 //GDALComputeRasterStatistics( hBand, TRUE, &pdfMin, &pdfMax, &pdfMean, &pdfStdDev, NULL,NULL);1138 1159 char tmpN[21]; 1139 1160 sprintf(tmpN,"Band%d",iBand+1); -
branches/prototype-v0/zoo-project/zoo-kernel/sshapi.c
r886 r888 653 653 int fileMd5Check(maps** conf,const char* localPath,const char* targetPath){ 654 654 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); 658 658 if(ssh_exec(*conf,command,ssh_get_cnt(*conf))<=0){ 659 659 return -1;
Note: See TracChangeset
for help on using the changeset viewer.