Changeset 76
- Timestamp:
- Jan 15, 2011, 10:47:38 PM (14 years ago)
- Location:
- trunk/zoo-kernel
- Files:
-
- 4 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/zoo-kernel/service_conf.y
r73 r76 261 261 else 262 262 if(strncasecmp($2,"ComplexData",11)==0 || strncasecmp($2,"LiteralData",10)==0 263 || strncasecmp($2,"ComplexOutput",13)==0 || strncasecmp($2,"LiteralOutput",12)==0){ 263 || strncasecmp($2,"ComplexOutput",13)==0 || strncasecmp($2,"LiteralOutput",12)==0 264 || strncasecmp($2,"BoundingBoxOutput",13)==0 || strncasecmp($2,"BoundingBoxData",12)==0){ 264 265 current_data=4; 265 266 if(wait_metadata==true){ -
trunk/zoo-kernel/service_internal.c
r72 r76 698 698 699 699 nc1 = xmlNewNode(NULL, BAD_CAST "DataInputs"); 700 701 700 elements* e=serv->inputs; 701 printFullDescription(e,"Input",ns_ows,nc1); 702 xmlAddChild(nc,nc1); 703 704 nc1 = xmlNewNode(NULL, BAD_CAST "ProcessOutputs"); 705 e=serv->outputs; 706 printFullDescription(e,"Output",ns_ows,nc1); 707 xmlAddChild(nc,nc1); 708 709 xmlAddChild(n,nc); 710 711 } 712 713 void printFullDescription(elements *elem,char* type,xmlNsPtr ns_ows,xmlNodePtr nc1){ 714 char *orderedFields[7]; 715 orderedFields[0]="mimeType"; 716 orderedFields[1]="encoding"; 717 orderedFields[2]="schema"; 718 orderedFields[3]="dataType"; 719 orderedFields[4]="uom"; 720 orderedFields[5]="CRS"; 721 orderedFields[6]="value"; 722 723 xmlNodePtr nc2,nc3,nc4,nc5,nc6,nc7; 724 elements* e=elem; 725 map* tmp1=NULL; 702 726 while(e!=NULL){ 703 nc2 = xmlNewNode(NULL, BAD_CAST "Input"); 727 int default1=0; 728 int isAnyValue=1; 729 nc2 = xmlNewNode(NULL, BAD_CAST type); 704 730 tmp1=getMap(e->content,"minOccurs"); 705 731 if(tmp1){ … … 713 739 printDescription(nc2,ns_ows,e->name,e->content); 714 740 715 716 nc3 = xmlNewNode(NULL, BAD_CAST e->format); 741 if(strncmp(type,"Output",6)==0){ 742 if(strncasecmp(e->format,"LITERALDATA",strlen(e->format))==0) 743 nc3 = xmlNewNode(NULL, BAD_CAST "LiteralOutput"); 744 else if(strncasecmp(e->format,"COMPLEXDATA",strlen(e->format))==0) 745 nc3 = xmlNewNode(NULL, BAD_CAST "ComplexOutput"); 746 else if(strncasecmp(e->format,"BOUNDINGBOXDATA",strlen(e->format))==0) 747 nc3 = xmlNewNode(NULL, BAD_CAST "BoundingBoxOutput"); 748 else 749 nc3 = xmlNewNode(NULL, BAD_CAST e->format); 750 }else{ 751 if(strncasecmp(e->format,"LITERALDATA",strlen(e->format))==0) 752 nc3 = xmlNewNode(NULL, BAD_CAST "LiteralData"); 753 else if(strncasecmp(e->format,"COMPLEXDATA",strlen(e->format))==0) 754 nc3 = xmlNewNode(NULL, BAD_CAST "ComplexData"); 755 else if(strncasecmp(e->format,"BOUNDINGBOXDATA",strlen(e->format))==0) 756 nc3 = xmlNewNode(NULL, BAD_CAST "BoundingBoxData"); 757 else 758 nc3 = xmlNewNode(NULL, BAD_CAST e->format); 759 } 717 760 iotype* _tmp=e->defaults; 718 761 int datatype=0; 719 762 if(_tmp!=NULL){ 720 int isAnyValue=1; 721 if(strcmp(e->format,"LiteralData")!=0){ 722 nc4 = xmlNewNode(NULL, BAD_CAST "Default"); 723 nc5 = xmlNewNode(NULL, BAD_CAST "Format"); 724 } 725 else{ 763 if(strcmp(e->format,"LiteralOutput")==0 || 764 strcmp(e->format,"LiteralData")==0){ 765 datatype=1; 726 766 nc4 = xmlNewNode(NULL, BAD_CAST "UOMs"); 727 767 nc5 = xmlNewNode(NULL, BAD_CAST "Default"); 728 datatype=1; 729 } 768 } 769 else if(strcmp(e->format,"BoundingBoxOutput")==0 || 770 strcmp(e->format,"BoundingBoxData")==0){ 771 datatype=2; 772 //nc4 = xmlNewNode(NULL, BAD_CAST "BoundingBoxOutput"); 773 nc5 = xmlNewNode(NULL, BAD_CAST "Default"); 774 } 775 else{ 776 nc4 = xmlNewNode(NULL, BAD_CAST "Default"); 777 nc5 = xmlNewNode(NULL, BAD_CAST "Format"); 778 } 779 780 tmp1=_tmp->content; 781 int avcnt=0; 782 int dcnt=0; 783 int oI=0; 784 for(oI=0;oI<7;oI++) 785 if((tmp1=getMap(_tmp->content,orderedFields[oI]))!=NULL){ 786 //while(tmp1!=NULL){ 787 #ifdef DEBUG 788 printf("DATATYPE DEFAULT ? %s\n",tmp1->name); 789 #endif 790 if(strncasecmp(tmp1->name,"DataType",8)==0){ 791 nc6 = xmlNewNode(ns_ows, BAD_CAST "DataType"); 792 xmlAddChild(nc6,xmlNewText(BAD_CAST tmp1->value)); 793 char tmp[1024]; 794 sprintf(tmp,"http://www.w3.org/TR/xmlschema-2/#%s",tmp1->value); 795 xmlNewNsProp(nc6,ns_ows,BAD_CAST "reference",BAD_CAST tmp); 796 xmlAddChild(nc3,nc6); 797 tmp1=tmp1->next; 798 datatype=1; 799 continue; 800 } 801 if(strcmp(tmp1->name,"asReference")!=0 && 802 strncasecmp(tmp1->name,"DataType",8)!=0 && 803 strcasecmp(tmp1->name,"extension")!=0 && 804 strcasecmp(tmp1->name,"value")!=0 && 805 strncasecmp(tmp1->name,"AllowedValues",13)!=0){ 806 if(datatype!=1){ 807 char *tmp2=zCapitalize1(tmp1->name); 808 nc6 = xmlNewNode(NULL, BAD_CAST tmp2); 809 free(tmp2); 810 } 811 else{ 812 char *tmp2=zCapitalize(tmp1->name); 813 nc6 = xmlNewNode(ns_ows, BAD_CAST tmp2); 814 free(tmp2); 815 } 816 xmlAddChild(nc6,xmlNewText(BAD_CAST tmp1->value)); 817 xmlAddChild(nc5,nc6); 818 }else 819 if(strncmp(type,"Input",5)==0){ 820 if(strcmp(tmp1->name,"value")==0){ 821 nc7 = xmlNewNode(NULL, BAD_CAST "DefaultValue"); 822 xmlAddChild(nc7,xmlNewText(BAD_CAST tmp1->value)); 823 default1=1; 824 } 825 if(strncasecmp(tmp1->name,"AllowedValues",13)==0){ 826 nc6 = xmlNewNode(ns_ows, BAD_CAST "AllowedValues"); 827 char *token,*saveptr1; 828 token=strtok_r(tmp1->value,",",&saveptr1); 829 while(token!=NULL){ 830 nc7 = xmlNewNode(ns_ows, BAD_CAST "Value"); 831 char *tmps=strdup(token); 832 tmps[strlen(tmps)]=0; 833 xmlAddChild(nc7,xmlNewText(BAD_CAST tmps)); 834 fprintf(stderr,"strgin : %s\n",tmps); 835 xmlAddChild(nc6,nc7); 836 token=strtok_r(NULL,",",&saveptr1); 837 } 838 xmlAddChild(nc3,nc6); 839 isAnyValue=-1; 840 } 841 } 842 tmp1=tmp1->next; 843 if(datatype!=2){ 844 xmlAddChild(nc4,nc5); 845 xmlAddChild(nc3,nc4); 846 }else{ 847 fprintf(stderr,"OK \n"); 848 xmlAddChild(nc3,nc5); 849 fprintf(stderr,"OK \n"); 850 } 851 852 if(strncmp(type,"Input",5)==0){ 853 if(datatype==1 && isAnyValue==1 && avcnt==0){ 854 xmlAddChild(nc3,xmlNewNode(ns_ows, BAD_CAST "AnyValue")); 855 avcnt++; 856 } 857 if(datatype==1 && default1>0){ 858 xmlAddChild(nc3,nc7); 859 } 860 } 861 } 862 } 863 _tmp=e->supported; 864 int hasSupported=-1; 865 while(_tmp!=NULL){ 866 if(hasSupported<0){ 867 if(datatype==0){ 868 nc4 = xmlNewNode(NULL, BAD_CAST "Supported"); 869 nc5 = xmlNewNode(NULL, BAD_CAST "Format"); 870 } 871 else 872 nc5 = xmlNewNode(NULL, BAD_CAST "Supported"); 873 hasSupported=0; 874 }else 875 if(datatype==0) 876 nc5 = xmlNewNode(NULL, BAD_CAST "Format"); 730 877 tmp1=_tmp->content; 731 int default1=0;732 xmlNodePtr nc7;733 char *orderedFields[5];734 orderedFields[0]="mimeType";735 orderedFields[1]="encoding";736 orderedFields[2]="schema";737 orderedFields[3]="dataType";738 orderedFields[4]="uom";739 878 int oI=0; 740 for(oI=0;oI< 5;oI++)879 for(oI=0;oI<6;oI++) 741 880 if((tmp1=getMap(_tmp->content,orderedFields[oI]))!=NULL){ 742 881 #ifdef DEBUG 743 printf("DATATYPE DEFAULT ? %s\n",tmp1->name); 744 #endif 745 if(strncasecmp(tmp1->name,"DataType",8)==0){ 746 nc6 = xmlNewNode(ns_ows, BAD_CAST "DataType"); 747 xmlAddChild(nc6,xmlNewText(BAD_CAST tmp1->value)); 748 char tmp[1024]; 749 sprintf(tmp,"http://www.w3.org/TR/xmlschema-2/#%s",tmp1->value); 750 xmlNewNsProp(nc6,ns_ows,BAD_CAST "reference",BAD_CAST tmp); 751 xmlAddChild(nc3,nc6); 752 tmp1=tmp1->next; 753 continue; 754 } 755 if(strcasecmp(tmp1->name,"asReference")!=0 && 756 strcasecmp(tmp1->name,"DataType")!=0 && 757 strncasecmp(tmp1->name,"AllowedValues",13)!=0 && 758 strcasecmp(tmp1->name,"value")!=0 && 882 printf("DATATYPE SUPPORTED ? %s\n",tmp1->name); 883 #endif 884 if(strcmp(tmp1->name,"asReference")!=0 && 885 strcmp(tmp1->name,"DataType")!=0 && 759 886 strcasecmp(tmp1->name,"extension")!=0){ 760 if(datatype ==0){887 if(datatype!=1){ 761 888 char *tmp2=zCapitalize1(tmp1->name); 762 889 nc6 = xmlNewNode(NULL, BAD_CAST tmp2); … … 768 895 free(tmp2); 769 896 } 770 xmlAddChild(nc6,xmlNewText(BAD_CAST tmp1->value)); 771 xmlAddChild(nc5,nc6); 772 } 773 else{ 774 if(strcmp(tmp1->name,"value")==0){ 775 nc7 = xmlNewNode(NULL, BAD_CAST "DefaultValue"); 776 xmlAddChild(nc7,xmlNewText(BAD_CAST tmp1->value)); 777 default1=1; 897 if(datatype==2){ 898 char *tmpv,*tmps; 899 tmps=strtok_r(tmp1->value,",",&tmpv); 900 while(tmps){ 901 fprintf(stderr,"Element %s\n",tmps); 902 xmlAddChild(nc6,xmlNewText(BAD_CAST tmps)); 903 xmlAddChild(nc5,nc6); 904 tmps=strtok_r(NULL,",",&tmpv); 905 if(tmps){ 906 char *tmp2=zCapitalize1(tmp1->name); 907 nc6 = xmlNewNode(NULL, BAD_CAST tmp2); 908 free(tmp2); 909 } 910 } 911 //free(tmpv); 778 912 } 779 if(strncasecmp(tmp1->name,"AllowedValues",13)==0){ 780 nc6 = xmlNewNode(ns_ows, BAD_CAST "AllowedValues"); 781 char *token,*saveptr1; 782 token=strtok_r(tmp1->value,",",&saveptr1); 783 while(token!=NULL){ 784 nc7 = xmlNewNode(ns_ows, BAD_CAST "Value"); 785 char *tmps=strdup(token); 786 tmps[strlen(tmps)]=0; 787 xmlAddChild(nc7,xmlNewText(BAD_CAST tmps)); 788 fprintf(stderr,"strgin : %s\n",tmps); 789 xmlAddChild(nc6,nc7); 790 token=strtok_r(NULL,",",&saveptr1); 791 } 792 xmlAddChild(nc3,nc6); 793 isAnyValue=-1; 913 else{ 914 xmlAddChild(nc6,xmlNewText(BAD_CAST tmp1->value)); 915 xmlAddChild(nc5,nc6); 794 916 } 795 917 } 796 918 tmp1=tmp1->next; 797 919 } 798 xmlAddChild(nc4,nc5);799 xmlAddChild(nc3,nc4);800 if(datatype==1 && isAnyValue==1){801 xmlAddChild(nc3,xmlNewNode(ns_ows, BAD_CAST "AnyValue"));802 if(default1>0)803 xmlAddChild(nc3,nc7);804 }805 if(datatype==1 && default1>0)806 xmlAddChild(nc3,nc7);807 }808 xmlAddChild(nc2,nc3);809 810 _tmp=e->supported;811 int hasSupported=-1;812 while(_tmp!=NULL){813 if(hasSupported<0){814 if(datatype==0){815 nc4 = xmlNewNode(NULL, BAD_CAST "Supported");816 nc5 = xmlNewNode(NULL, BAD_CAST "Format");817 }818 else{819 nc5 = xmlNewNode(NULL, BAD_CAST "Supported");820 }821 hasSupported=0;822 }else{823 nc5 = xmlNewNode(NULL, BAD_CAST "Format");824 }825 tmp1=_tmp->content;826 char *orderedFields[5];827 orderedFields[0]="mimeType";828 orderedFields[1]="encoding";829 orderedFields[2]="schema";830 orderedFields[3]="dataType";831 orderedFields[4]="uom";832 int oI=0;833 for(oI=0;oI<5;oI++)834 if((tmp1=getMap(_tmp->content,orderedFields[oI]))!=NULL){835 if(datatype==0){836 char *tmp2=zCapitalize1(tmp1->name);837 nc6 = xmlNewNode(NULL, BAD_CAST tmp2);838 free(tmp2);839 }840 else{841 char *tmp2=zCapitalize(tmp1->name);842 nc6 = xmlNewNode(ns_ows, BAD_CAST tmp2);843 free(tmp2);844 }845 xmlAddChild(nc6,xmlNewText(BAD_CAST tmp1->value));846 xmlAddChild(nc5,nc6);847 tmp1=tmp1->next;848 }849 920 if(hasSupported<=0){ 850 if(datatype==0){ 851 xmlAddChild(nc4,nc5); 852 xmlAddChild(nc3,nc4); 853 }else{ 854 xmlAddChild(nc4,nc5); 855 } 856 hasSupported=1; 857 }else{ 858 xmlAddChild(nc4,nc5); 859 } 860 _tmp=_tmp->next; 861 if(strcmp(e->format,"LiteralData")!=0){ 862 xmlAddChild(nc2,nc3); 863 } 864 } 865 xmlAddChild(nc1,nc2); 866 867 868 e=e->next; 869 } 870 xmlAddChild(nc,nc1); 871 872 nc1 = xmlNewNode(NULL, BAD_CAST "ProcessOutputs"); 873 874 e=serv->outputs; 875 while(e!=NULL){ 876 nc2 = xmlNewNode(NULL, BAD_CAST "Output"); 877 tmp1=getMap(e->content,"minOccurs"); 878 if(tmp1){ 879 xmlNewProp(nc2,BAD_CAST tmp1->name,BAD_CAST tmp1->value); 880 } 881 tmp1=getMap(e->content,"maxOccurs"); 882 if(tmp1){ 883 xmlNewProp(nc2,BAD_CAST tmp1->name,BAD_CAST tmp1->value); 884 } 885 886 printDescription(nc2,ns_ows,e->name,e->content); 887 888 if(strncasecmp(e->format,"LITERALDATA",strlen(e->format))==0) 889 nc3 = xmlNewNode(NULL, BAD_CAST "LiteralOutput"); 890 else 891 if(strncasecmp(e->format,"COMPLEXDATA",strlen(e->format))==0) 892 nc3 = xmlNewNode(NULL, BAD_CAST "ComplexOutput"); 893 else 894 nc3 = xmlNewNode(NULL, BAD_CAST e->format); 895 iotype* _tmp=e->defaults; 896 int datatype=0; 897 if(_tmp!=NULL){ 898 if(strcmp(e->format,"LiteralOutput")==0 || 899 strcmp(e->format,"LiteralData")==0){ 900 datatype=1; 901 nc4 = xmlNewNode(NULL, BAD_CAST "UOMs"); 902 nc5 = xmlNewNode(NULL, BAD_CAST "Default"); 903 } 904 else{ 905 nc4 = xmlNewNode(NULL, BAD_CAST "Default"); 906 nc5 = xmlNewNode(NULL, BAD_CAST "Format"); 907 } 908 tmp1=_tmp->content; 909 while(tmp1!=NULL){ 910 #ifdef DEBUG 911 printf("DATATYPE DEFAULT ? %s\n",tmp1->name); 912 #endif 913 if(strncasecmp(tmp1->name,"DataType",8)==0){ 914 nc6 = xmlNewNode(ns_ows, BAD_CAST "DataType"); 915 xmlAddChild(nc6,xmlNewText(BAD_CAST tmp1->value)); 916 char tmp[1024]; 917 sprintf(tmp,"http://www.w3.org/TR/xmlschema-2/#%s",tmp1->value); 918 xmlNewNsProp(nc6,ns_ows,BAD_CAST "reference",BAD_CAST tmp); 919 xmlAddChild(nc3,nc6); 920 tmp1=tmp1->next; 921 datatype=1; 922 continue; 923 } 924 if(strcmp(tmp1->name,"asReference")!=0 && 925 strncasecmp(tmp1->name,"DataType",8)!=0 && 926 strcasecmp(tmp1->name,"extension")!=0){ 927 if(datatype==0){ 928 char *tmp2=zCapitalize1(tmp1->name); 929 nc6 = xmlNewNode(NULL, BAD_CAST tmp2); 930 free(tmp2); 931 } 932 else{ 933 char *tmp2=zCapitalize(tmp1->name); 934 nc6 = xmlNewNode(ns_ows, BAD_CAST tmp2); 935 free(tmp2); 936 } 937 xmlAddChild(nc6,xmlNewText(BAD_CAST tmp1->value)); 938 xmlAddChild(nc5,nc6); 939 } 940 tmp1=tmp1->next; 941 } 942 xmlAddChild(nc4,nc5); 943 xmlAddChild(nc3,nc4); 944 } 945 _tmp=e->supported; 946 int hasSupported=-1; 947 while(_tmp!=NULL){ 948 if(hasSupported<0){ 949 if(datatype==0){ 950 nc4 = xmlNewNode(NULL, BAD_CAST "Supported"); 951 nc5 = xmlNewNode(NULL, BAD_CAST "Format"); 952 } 953 else 954 nc5 = xmlNewNode(NULL, BAD_CAST "Supported"); 955 hasSupported=0; 956 }else 957 nc5 = xmlNewNode(NULL, BAD_CAST "Format"); 958 tmp1=_tmp->content; 959 char *orderedFields[5]; 960 orderedFields[0]="mimeType"; 961 orderedFields[1]="encoding"; 962 orderedFields[2]="schema"; 963 orderedFields[3]="dataType"; 964 orderedFields[4]="uom"; 965 int oI=0; 966 for(oI=0;oI<5;oI++) 967 if((tmp1=getMap(_tmp->content,orderedFields[oI]))!=NULL){ 968 #ifdef DEBUG 969 printf("DATATYPE SUPPORTED ? %s\n",tmp1->name); 970 #endif 971 if(strcmp(tmp1->name,"asReference")!=0 && 972 strcmp(tmp1->name,"DataType")!=0 && 973 strcasecmp(tmp1->name,"extension")!=0){ 974 if(datatype==0){ 975 char *tmp2=zCapitalize1(tmp1->name); 976 nc6 = xmlNewNode(NULL, BAD_CAST tmp2); 977 free(tmp2); 978 } 979 else{ 980 char *tmp2=zCapitalize(tmp1->name); 981 nc6 = xmlNewNode(ns_ows, BAD_CAST tmp2); 982 free(tmp2); 983 } 984 xmlAddChild(nc6,xmlNewText(BAD_CAST tmp1->value)); 985 xmlAddChild(nc5,nc6); 986 } 987 tmp1=tmp1->next; 988 } 989 _tmp=_tmp->next; 990 if(hasSupported<=0){ 991 if(datatype==0){ 921 if(datatype!=2){ 992 922 xmlAddChild(nc4,nc5); 993 923 xmlAddChild(nc3,nc4); 994 924 }else 925 xmlAddChild(nc3,nc5); 926 fprintf(stderr,"OK \n"); 927 hasSupported=1; 928 } 929 else 930 if(datatype!=2){ 995 931 xmlAddChild(nc4,nc5); 996 hasSupported=1;997 } 998 else 999 xmlAddChild(nc4,nc5);932 } 933 else 934 xmlAddChild(nc3,nc5); 935 _tmp=_tmp->next; 1000 936 } 1001 937 xmlAddChild(nc2,nc3); 1002 1003 xmlAddChild(nc3,nc4);1004 1005 938 1006 xmlAddChild(nc2,nc3); 939 if(datatype!=2){ 940 xmlAddChild(nc3,nc4); 941 xmlAddChild(nc2,nc3); 942 } 1007 943 1008 944 xmlAddChild(nc1,nc2); … … 1010 946 e=e->next; 1011 947 } 1012 xmlAddChild(nc,nc1);1013 1014 xmlAddChild(n,nc);1015 1016 948 } 1017 949 … … 1204 1136 while(mcursor!=NULL /*&& scursor!=NULL*/){ 1205 1137 scursor=getElements(serv->inputs,mcursor->name); 1206 printIOType(doc,nc,ns,ns_ows, scursor,mcursor,"Input");1138 printIOType(doc,nc,ns,ns_ows,ns_xlink,scursor,mcursor,"Input"); 1207 1139 mcursor=mcursor->next; 1208 1140 } … … 1236 1168 while(mcursor!=NULL){ 1237 1169 scursor=getElements(serv->outputs,mcursor->name); 1238 printIOType(doc,nc,ns,ns_ows, scursor,mcursor,"Output");1170 printIOType(doc,nc,ns,ns_ows,ns_xlink,scursor,mcursor,"Output"); 1239 1171 mcursor=mcursor->next; 1240 1172 } … … 1245 1177 #endif 1246 1178 xmlDocSetRootElement(doc, n); 1247 if(hasStoredExecuteResponse ){1179 if(hasStoredExecuteResponse==true){ 1248 1180 /* We need to write the ExecuteResponse Document somewhere */ 1249 1181 FILE* output=fopen(stored_path,"w"); … … 1347 1279 } 1348 1280 1349 void printIOType(xmlDocPtr doc,xmlNodePtr nc,xmlNsPtr ns_wps,xmlNsPtr ns_ows, elements* e,maps* m,char* type){1281 void printIOType(xmlDocPtr doc,xmlNodePtr nc,xmlNsPtr ns_wps,xmlNsPtr ns_ows,xmlNsPtr ns_xlink,elements* e,maps* m,char* type){ 1350 1282 xmlNodePtr nc1,nc2,nc3; 1351 1283 nc1=xmlNewNode(ns_wps, BAD_CAST type); … … 1403 1335 nc2=xmlNewNode(ns_wps, BAD_CAST "Data"); 1404 1336 if(e!=NULL){ 1405 if(strncasecmp(e->format,"L ITERALOUTPUT",strlen(e->format))==0)1337 if(strncasecmp(e->format,"LiteralOutput",strlen(e->format))==0) 1406 1338 nc3=xmlNewNode(ns_wps, BAD_CAST "LiteralData"); 1407 1339 else 1408 if(strncasecmp(e->format,"C OMPLEXOUTPUT",strlen(e->format))==0)1340 if(strncasecmp(e->format,"ComplexOutput",strlen(e->format))==0) 1409 1341 nc3=xmlNewNode(ns_wps, BAD_CAST "ComplexData"); 1342 else if(strncasecmp(e->format,"BoundingBoxOutput",strlen(e->format))==0) 1343 nc3=xmlNewNode(ns_wps, BAD_CAST "BoundingBoxData"); 1410 1344 else 1411 1345 nc3=xmlNewNode(ns_wps, BAD_CAST e->format); … … 1417 1351 else 1418 1352 nc3=xmlNewNode(ns_wps, BAD_CAST "LitteralData"); 1419 } 1353 } 1420 1354 tmp=m->content; 1421 1355 while(tmp!=NULL){ … … 1429 1363 xmlAddChild(nc2,nc3); 1430 1364 } 1431 if(e!=NULL) 1432 tmp=getMap(e->defaults->content,"mimeType"); 1433 else 1434 tmp=NULL; 1435 map* tmp1=getMap(m->content,"encoding"); 1436 map* tmp2=getMap(m->content,"mimeType"); 1437 map* toto=getMap(m->content,"value"); 1438 if((tmp1!=NULL && strncmp(tmp1->value,"base64",6)==0) 1439 || (tmp2!=NULL && (strncmp(tmp2->value,"image/",6)==0 1440 || strncmp(tmp2->value,"application/",6)==0)) ){ 1441 map* rs=getMap(m->content,"size"); 1442 bool isSized=true; 1443 if(rs==NULL){ 1444 char tmp1[1024]; 1445 sprintf(tmp1,"%d",strlen(toto->value)); 1446 rs=createMap("z",tmp1); 1447 isSized=false; 1448 } 1449 xmlAddChild(nc3,xmlNewText(BAD_CAST base64((const unsigned char*)toto->value,atoi(rs->value)))); 1450 if(!isSized){ 1451 freeMap(&rs); 1452 free(rs); 1453 } 1454 } 1455 else if(tmp!=NULL){ 1456 if(strncmp(tmp->value,"text/js",4)==0 || 1457 strncmp(tmp->value,"application/js",14)==0) 1458 xmlAddChild(nc3,xmlNewCDataBlock(doc,BAD_CAST toto->value,strlen(toto->value))); 1365 if(e!=NULL && e->format!=NULL && strcasecmp(e->format,"BoundingBoxData")==0){ 1366 map* bb=getMap(m->content,"value"); 1367 if(bb!=NULL){ 1368 map* tmpRes=parseBoundingBox(bb->value); 1369 printBoundingBox(ns_ows,nc3,tmpRes); 1370 freeMap(&tmpRes); 1371 free(tmpRes); 1372 } 1373 }else{ 1374 if(e!=NULL) 1375 tmp=getMap(e->defaults->content,"mimeType"); 1376 else 1377 tmp=NULL; 1378 map* tmp1=getMap(m->content,"encoding"); 1379 map* tmp2=getMap(m->content,"mimeType"); 1380 map* toto=getMap(m->content,"value"); 1381 if((tmp1!=NULL && strncmp(tmp1->value,"base64",6)==0) 1382 || (tmp2!=NULL && (strncmp(tmp2->value,"image/",6)==0 || 1383 (strncmp(tmp2->value,"application/",12)==0) && 1384 strncmp(tmp2->value,"application/json",16)!=0))) { 1385 map* rs=getMap(m->content,"size"); 1386 bool isSized=true; 1387 if(rs==NULL){ 1388 char tmp1[1024]; 1389 sprintf(tmp1,"%d",strlen(toto->value)); 1390 rs=createMap("z",tmp1); 1391 isSized=false; 1392 } 1393 xmlAddChild(nc3,xmlNewText(BAD_CAST base64((const unsigned char*)toto->value,atoi(rs->value)))); 1394 if(!isSized){ 1395 freeMap(&rs); 1396 free(rs); 1397 } 1398 } 1399 else if(tmp!=NULL){ 1400 if(strncmp(tmp->value,"text/js",4)==0 || 1401 strncmp(tmp->value,"application/js",14)==0) 1402 xmlAddChild(nc3,xmlNewCDataBlock(doc,BAD_CAST toto->value,strlen(toto->value))); 1403 else 1404 xmlAddChild(nc3,xmlNewText(BAD_CAST toto->value)); 1405 xmlAddChild(nc2,nc3); 1406 } 1459 1407 else 1460 1408 xmlAddChild(nc3,xmlNewText(BAD_CAST toto->value)); 1461 xmlAddChild(nc2,nc3); 1462 } 1463 else 1464 xmlAddChild(nc3,xmlNewText(BAD_CAST toto->value)); 1409 } 1465 1410 } 1466 1411 else{ 1467 1412 nc3=nc2=xmlNewNode(ns_wps, BAD_CAST "Reference"); 1468 xmlNewProp(nc3,BAD_CAST "href",BAD_CAST tmpMap->value); 1413 if(strcasecmp(type,"Output")==0) 1414 xmlNewProp(nc3,BAD_CAST "href",BAD_CAST tmpMap->value); 1415 else 1416 xmlNewNsProp(nc3,ns_xlink,BAD_CAST "href",BAD_CAST tmpMap->value); 1469 1417 tmp=m->content; 1470 1418 while(tmp!=NULL){ … … 1628 1576 toto=getMap(tmpI->content,"asReference"); 1629 1577 if(toto!=NULL && strcasecmp(toto->value,"true")==0){ 1630 1631 toto=getMap(tmpI->content,"extension"); 1578 elements* in=getElements(s->outputs,tmpI->name); 1579 char *format=NULL; 1580 if(in!=NULL){ 1581 format=strdup(in->format); 1582 }else 1583 format=strdup("LiteralData"); 1584 if(strcasecmp(format,"BoundingBoxData")==0){ 1585 addToMap(tmpI->content,"extension","xml"); 1586 addToMap(tmpI->content,"mimeType","text/xml"); 1587 addToMap(tmpI->content,"encoding","UTF-8"); 1588 addToMap(tmpI->content,"schema","http://schemas.opengis.net/ows/1.1.0/owsCommon.xsd"); 1589 } 1590 map *ext=getMap(tmpI->content,"extension"); 1632 1591 map *tmp1=getMapFromMaps(m,"main","tmpPath"); 1633 1592 char *file_name; 1634 1593 bool hasExt=true; 1635 if(toto==NULL){ 1636 dumpMaps(tmpI); 1594 if(ext==NULL){ 1637 1595 // We can fallback to a default list of supported formats using 1638 1596 // mimeType information if present here. Maybe we can add more formats … … 1642 1600 if(mtype!=NULL){ 1643 1601 if(strcasecmp(mtype->value,"text/xml")==0) 1644 toto=createMap("extension","xml");1602 ext=createMap("extension","xml"); 1645 1603 else if(strcasecmp(mtype->value,"application/json")==0) 1646 toto=createMap("extension","js");1604 ext=createMap("extension","js"); 1647 1605 else 1648 toto=createMap("extension","txt");1606 ext=createMap("extension","txt"); 1649 1607 } 1650 1608 else 1651 toto=createMap("extension","txt");1609 ext=createMap("extension","txt"); 1652 1610 hasExt=false; 1653 1611 } 1654 file_name=(char*)malloc((strlen(tmp1->value)+strlen(s->name)+strlen( toto->value)+strlen(tmpI->name)+13)*sizeof(char));1655 sprintf(file_name,"%s/%s_%s_%i.%s",tmp1->value,s->name,tmpI->name,cpid+100000, toto->value);1612 file_name=(char*)malloc((strlen(tmp1->value)+strlen(s->name)+strlen(ext->value)+strlen(tmpI->name)+13)*sizeof(char)); 1613 sprintf(file_name,"%s/%s_%s_%i.%s",tmp1->value,s->name,tmpI->name,cpid+100000,ext->value); 1656 1614 FILE *ofile=fopen(file_name,"w"); 1657 1615 if(ofile==NULL) … … 1660 1618 map *tmp3=getMapFromMaps(m,"main","serverAddress"); 1661 1619 char *file_url; 1662 file_url=(char*)malloc((strlen(tmp3->value)+strlen(tmp2->value)+strlen(s->name)+strlen( toto->value)+strlen(tmpI->name)+13)*sizeof(char));1663 sprintf(file_url,"%s/%s/%s_%s_%i.%s",tmp3->value,tmp2->value,s->name,tmpI->name,cpid+100000, toto->value);1620 file_url=(char*)malloc((strlen(tmp3->value)+strlen(tmp2->value)+strlen(s->name)+strlen(ext->value)+strlen(tmpI->name)+13)*sizeof(char)); 1621 sprintf(file_url,"%s/%s/%s_%s_%i.%s",tmp3->value,tmp2->value,s->name,tmpI->name,cpid+100000,ext->value); 1664 1622 addToMap(tmpI->content,"Reference",file_url); 1665 1623 if(hasExt!=true){ 1666 freeMap(& toto);1667 free( toto);1624 freeMap(&ext); 1625 free(ext); 1668 1626 } 1669 1627 toto=getMap(tmpI->content,"value"); 1670 map* size=getMap(tmpI->content,"size"); 1671 if(size!=NULL && toto!=NULL) 1672 fwrite(toto->value,1,atoi(size->value)*sizeof(char),ofile); 1673 else 1674 if(toto!=NULL && toto->value!=NULL) 1675 fwrite(toto->value,1,strlen(toto->value)*sizeof(char),ofile); 1628 if(strcasecmp(format,"BoundingBoxData")!=0){ 1629 map* size=getMap(tmpI->content,"size"); 1630 if(size!=NULL && toto!=NULL) 1631 fwrite(toto->value,1,atoi(size->value)*sizeof(char),ofile); 1632 else 1633 if(toto!=NULL && toto->value!=NULL) 1634 fwrite(toto->value,1,strlen(toto->value)*sizeof(char),ofile); 1635 }else{ 1636 printBoundingBoxDocument(m,tmpI,ofile); 1637 } 1638 free(format); 1676 1639 fclose(ofile); 1677 1640 free(file_name); 1678 free(file_url); 1641 free(file_url); 1679 1642 } 1680 1643 tmpI=tmpI->next; … … 1703 1666 if(tmpI==NULL) 1704 1667 tmpI=request_outputs; 1705 toto=getMap(tmpI->content,"value"); 1706 if(toto==NULL){ 1707 map * errormap = createMap("text",_("Unable to fetch any result")); 1708 addToMap(errormap,"code", "InternalError"); 1709 printExceptionReportResponse(m,errormap); 1710 freeMap(&errormap); 1711 free(errormap); 1712 } 1713 char mime[1024]; 1714 map* mi=getMap(tmpI->content,"mimeType"); 1715 #ifdef DEBUG 1716 fprintf(stderr,"SERVICE OUTPUTS\n"); 1717 dumpMaps(request_outputs); 1718 fprintf(stderr,"SERVICE OUTPUTS\n"); 1719 #endif 1720 map* en=getMap(tmpI->content,"encoding"); 1721 if(mi!=NULL && en!=NULL) 1722 sprintf(mime, 1723 "Content-Type: %s; charset=%s\r\nStatus: 200 OK\r\n\r\n", 1724 mi->value,en->value); 1725 else 1726 if(mi!=NULL) 1668 elements* e=getElements(s->outputs,tmpI->name); 1669 if(e!=NULL && strcasecmp(e->format,"BoundingBoxData")==0){ 1670 printBoundingBoxDocument(m,tmpI,NULL); 1671 }else{ 1672 toto=getMap(tmpI->content,"value"); 1673 if(toto==NULL){ 1674 char tmpMsg[1024]; 1675 sprintf(tmpMsg,_("Wrong RawDataOutput parameter, unable to fetch any result for the name your provided : \"%s\"."),tmpI->name); 1676 map * errormap = createMap("text",tmpMsg); 1677 addToMap(errormap,"code", "InvalidParameterValue"); 1678 printExceptionReportResponse(m,errormap); 1679 freeMap(&errormap); 1680 free(errormap); 1681 return 1; 1682 } 1683 char mime[1024]; 1684 map* mi=getMap(tmpI->content,"mimeType"); 1685 #ifdef DEBUG 1686 fprintf(stderr,"SERVICE OUTPUTS\n"); 1687 dumpMaps(request_outputs); 1688 fprintf(stderr,"SERVICE OUTPUTS\n"); 1689 #endif 1690 map* en=getMap(tmpI->content,"encoding"); 1691 if(mi!=NULL && en!=NULL) 1727 1692 sprintf(mime, 1728 "Content-Type: %s; charset= UTF-8\r\nStatus: 200 OK\r\n\r\n",1729 mi->value );1693 "Content-Type: %s; charset=%s\r\nStatus: 200 OK\r\n\r\n", 1694 mi->value,en->value); 1730 1695 else 1731 sprintf(mime,"Content-Type: text/plain; charset=utf-8\r\nStatus: 200 OK\r\n\r\n"); 1732 printf("%s",mime); 1733 if(mi!=NULL && strncmp(mi->value,"image",5)==0){ 1734 map* rs=getMapFromMaps(tmpI,tmpI->name,"size"); 1735 fwrite(toto->value,atoi(rs->value),1,stdout); 1736 } 1737 else 1738 printf("%s",toto->value); 1739 #ifdef DEBUG 1740 dumpMap(toto); 1741 #endif 1696 if(mi!=NULL) 1697 sprintf(mime, 1698 "Content-Type: %s; charset=UTF-8\r\nStatus: 200 OK\r\n\r\n", 1699 mi->value); 1700 else 1701 sprintf(mime,"Content-Type: text/plain; charset=utf-8\r\nStatus: 200 OK\r\n\r\n"); 1702 printf("%s",mime); 1703 if(mi!=NULL && strncmp(mi->value,"image",5)==0){ 1704 map* rs=getMapFromMaps(tmpI,tmpI->name,"size"); 1705 fwrite(toto->value,atoi(rs->value),1,stdout); 1706 } 1707 else 1708 printf("%s",toto->value); 1709 #ifdef DEBUG 1710 dumpMap(toto); 1711 #endif 1712 } 1742 1713 }else{ 1743 1714 char tmp[1024]; … … 1845 1816 1846 1817 if(type==0) { 1818 /** 1819 * In case of an Input maps, then add the minOccurs and maxOccurs to the 1820 * content map. 1821 */ 1847 1822 map* tmpMap1=getMap(tmpInputs->content,"minOccurs"); 1848 1823 if(tmpMap1!=NULL){ … … 1859 1834 addToMap(tmpMaps->content,"maxOccurs",tmpMap1->value); 1860 1835 } 1836 /** 1837 * Parsing BoundingBoxData, fill the following map and then add it to 1838 * the content map of the Input maps: 1839 * lowerCorner, upperCorner, srs and dimensions 1840 * cf. parseBoundingBox 1841 */ 1842 if(strcasecmp(tmpInputs->format,"BoundingBoxData")==0){ 1843 maps* tmpI=getMaps(*out,tmpInputs->name); 1844 if(tmpI!=NULL){ 1845 map* tmpV=getMap(tmpI->content,"value"); 1846 if(tmpV!=NULL){ 1847 char *tmpVS=strdup(tmpV->value); 1848 map* tmp=parseBoundingBox(tmpVS); 1849 free(tmpVS); 1850 map* tmpC=tmp; 1851 while(tmpC!=NULL){ 1852 addToMap(tmpMaps->content,tmpC->name,tmpC->value); 1853 tmpC=tmpC->next; 1854 } 1855 freeMap(&tmp); 1856 free(tmp); 1857 } 1858 } 1859 } 1861 1860 } 1862 1861 … … 1883 1882 return ""; 1884 1883 } 1884 1885 /** 1886 * parseBoundingBox : parse a BoundingBox string 1887 * 1888 * OGC 06-121r3 : 10.2 Bounding box 1889 * 1890 * value is provided as : lowerCorner,upperCorner,crs,dimension 1891 * exemple : 189000,834000,285000,962000,urn:ogc:def:crs:OGC:1.3:CRS84 1892 * 1893 * Need to create a map to store boundingbox informations : 1894 * - lowerCorner : double,double (minimum within this bounding box) 1895 * - upperCorner : double,double (maximum within this bounding box) 1896 * - crs : URI (Reference to definition of the CRS) 1897 * - dimensions : int 1898 * 1899 * Note : support only 2D bounding box. 1900 */ 1901 map* parseBoundingBox(char* value){ 1902 map *res=NULL; 1903 if(value!=NULL){ 1904 char *cv,*cvp; 1905 cv=strtok_r(value,",",&cvp); 1906 int cnt=0; 1907 int icnt=0; 1908 char *currentValue=NULL; 1909 while(cv){ 1910 if(cnt<2) 1911 if(currentValue!=NULL){ 1912 char *finalValue=(char*)malloc((strlen(currentValue)+strlen(cv)+1)*sizeof(char)); 1913 sprintf(finalValue,"%s%s",currentValue,cv); 1914 switch(cnt){ 1915 case 0: 1916 res=createMap("lowerCorner",finalValue); 1917 break; 1918 case 1: 1919 addToMap(res,"upperCorner",finalValue); 1920 icnt=-1; 1921 break; 1922 } 1923 cnt++; 1924 free(currentValue); 1925 currentValue=NULL; 1926 free(finalValue); 1927 } 1928 else{ 1929 currentValue=(char*)malloc((strlen(cv)+2)*sizeof(char)); 1930 sprintf(currentValue,"%s ",cv); 1931 } 1932 else 1933 if(cnt==2){ 1934 addToMap(res,"crs",cv); 1935 cnt++; 1936 } 1937 else 1938 addToMap(res,"dimensions",cv); 1939 icnt++; 1940 cv=strtok_r(NULL,",",&cvp); 1941 } 1942 } 1943 return res; 1944 } 1945 1946 /** 1947 * printBoundingBox : fill a BoundingBox node (ows:BoundingBox or 1948 * wps:BoundingBoxData). Set crs and dimensions attributes, add 1949 * Lower/UpperCorner nodes to a pre-existing XML node. 1950 */ 1951 void printBoundingBox(xmlNsPtr ns_ows,xmlNodePtr n,map* boundingbox){ 1952 1953 xmlNodePtr bb,lw,uc; 1954 1955 map* tmp=getMap(boundingbox,"value"); 1956 1957 tmp=getMap(boundingbox,"lowerCorner"); 1958 if(tmp!=NULL){ 1959 lw=xmlNewNode(ns_ows,BAD_CAST "LowerCorner"); 1960 xmlAddChild(lw,xmlNewText(BAD_CAST tmp->value)); 1961 } 1962 1963 tmp=getMap(boundingbox,"upperCorner"); 1964 if(tmp!=NULL){ 1965 uc=xmlNewNode(ns_ows,BAD_CAST "UpperCorner"); 1966 xmlAddChild(uc,xmlNewText(BAD_CAST tmp->value)); 1967 } 1968 1969 tmp=getMap(boundingbox,"crs"); 1970 if(tmp!=NULL) 1971 xmlNewProp(n,BAD_CAST "crs",BAD_CAST tmp->value); 1972 1973 tmp=getMap(boundingbox,"dimensions"); 1974 if(tmp!=NULL) 1975 xmlNewProp(n,BAD_CAST "dimensions",BAD_CAST tmp->value); 1976 1977 xmlAddChild(n,lw); 1978 xmlAddChild(n,uc); 1979 1980 } 1981 1982 void printBoundingBoxDocument(maps* m,maps* boundingbox,FILE* file){ 1983 if(file==NULL) 1984 rewind(stdout); 1985 xmlNodePtr n; 1986 xmlDocPtr doc; 1987 xmlNsPtr ns_ows,ns_xsi; 1988 xmlChar *xmlbuff; 1989 int buffersize; 1990 char *encoding=getEncoding(m); 1991 map *tmp; 1992 if(file==NULL){ 1993 int pid=0; 1994 tmp=getMapFromMaps(m,"lenv","sid"); 1995 if(tmp!=NULL) 1996 pid=atoi(tmp->value); 1997 if(pid==getpid()){ 1998 printf("Content-Type: text/xml; charset=%s\r\nStatus: 200 OK\r\n\r\n",encoding); 1999 } 2000 fflush(stdout); 2001 } 2002 2003 doc = xmlNewDoc(BAD_CAST "1.0"); 2004 int owsId=zooXmlAddNs(NULL,"http://www.opengis.net/ows/1.1","ows"); 2005 ns_ows=usedNs[owsId]; 2006 n = xmlNewNode(ns_ows, BAD_CAST "BoundingBox"); 2007 xmlNewNs(n,BAD_CAST "http://www.opengis.net/ows/1.1","ows"); 2008 int xsiId=zooXmlAddNs(n,"http://www.w3.org/2001/XMLSchema-instance","xsi"); 2009 ns_xsi=usedNs[xsiId]; 2010 xmlNewNsProp(n,ns_xsi,BAD_CAST "schemaLocation",BAD_CAST "http://www.opengis.net/ows/1.1 http://schemas.opengis.net/ows/1.1.0/owsCommon.xsd"); 2011 map *tmp1=getMap(boundingbox->content,"value"); 2012 tmp=parseBoundingBox(tmp1->value); 2013 printBoundingBox(ns_ows,n,tmp); 2014 xmlDocSetRootElement(doc, n); 2015 2016 xmlDocDumpFormatMemoryEnc(doc, &xmlbuff, &buffersize, encoding, 1); 2017 if(file==NULL) 2018 printf((char *) xmlbuff); 2019 else{ 2020 fprintf(file,"%s",xmlbuff); 2021 } 2022 2023 if(tmp!=NULL){ 2024 freeMap(&tmp); 2025 free(tmp); 2026 } 2027 xmlFree(xmlbuff); 2028 xmlFreeDoc(doc); 2029 xmlCleanupParser(); 2030 zooXmlCleanupNs(); 2031 2032 } -
trunk/zoo-kernel/service_internal.h
r63 r76 2 2 * Author : Gérald FENOY 3 3 * 4 * Copyright (c) 2009-201 0GeoLabs SARL4 * Copyright (c) 2009-2011 GeoLabs SARL 5 5 * 6 6 * Permission is hereby granted, free of charge, to any person obtaining a copy … … 95 95 xmlNodePtr printDescribeProcessHeader(xmlDocPtr,char*,maps*); 96 96 void printDescribeProcessForProcess(maps*,xmlNodePtr,service*,int); 97 void printFullDescription(elements*,char*,xmlNsPtr,xmlNodePtr); 97 98 void printDocument(maps*,xmlDocPtr,int); 98 99 void printDescription(xmlNodePtr,xmlNsPtr,char*,map*); 99 void printIOType(xmlDocPtr,xmlNodePtr,xmlNsPtr,xmlNsPtr,elements*,maps*,char*); 100 void printIOType(xmlDocPtr,xmlNodePtr,xmlNsPtr,xmlNsPtr,xmlNsPtr,elements*,maps*,char*); 101 map* parseBoundingBox(char*); 102 void printBoundingBox(xmlNsPtr,xmlNodePtr,map*); 103 void printBoundingBoxDocument(maps*,maps*,FILE*); 100 104 void printOutputDefinitions1(xmlDocPtr,xmlNodePtr,xmlNsPtr,xmlNsPtr,elements*,maps*,char*); 101 105 -
trunk/zoo-kernel/zoo_service_loader.c
r72 r76 969 969 } 970 970 addToMap(tmpmaps->content,tmpn1,tmpv1+1); 971 addToMap(tmpmaps->content,"Reference",tmpv1+1); 971 972 } 972 973 tmpc=strtok(NULL,"@");
Note: See TracChangeset
for help on using the changeset viewer.