Changeset 459 for trunk/zoo-project/zoo-kernel/service_internal.c
- Timestamp:
- Apr 1, 2014, 11:32:29 PM (9 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/zoo-project/zoo-kernel/service_internal.c
r458 r459 883 883 884 884 void printFullDescription(elements *elem,const char* type,xmlNsPtr ns_ows,xmlNodePtr nc1){ 885 char *orderedFields[ 7];885 char *orderedFields[12]; 886 886 orderedFields[0]="mimeType"; 887 887 orderedFields[1]="encoding"; … … 891 891 orderedFields[5]="CRS"; 892 892 orderedFields[6]="value"; 893 894 xmlNodePtr nc2,nc3,nc4,nc5,nc6,nc7; 893 orderedFields[7]="AllowedValues"; 894 orderedFields[8]="rangeMin"; 895 orderedFields[9]="rangeMax"; 896 orderedFields[10]="rangeClosure"; 897 orderedFields[11]="rangeSpace"; 898 899 xmlNodePtr nc2,nc3,nc4,nc5,nc6,nc7,nc8; 895 900 elements* e=elem; 896 901 map* tmp1=NULL; … … 956 961 int dcnt=0; 957 962 int oI=0; 958 for(oI=0;oI< 7;oI++)963 for(oI=0;oI<12;oI++) 959 964 if((tmp1=getMap(_tmp->content,orderedFields[oI]))!=NULL){ 960 965 //while(tmp1!=NULL){ … … 977 982 strcasecmp(tmp1->name,"extension")!=0 && 978 983 strcasecmp(tmp1->name,"value")!=0 && 979 strncasecmp(tmp1->name,"AllowedValues",13)!=0){ 984 strncasecmp(tmp1->name,"AllowedValues",13)!=0&& 985 strncasecmp(tmp1->name,"range",5)!=0){ 980 986 if(datatype!=1){ 981 987 char *tmp2=zCapitalize1(tmp1->name); … … 993 999 }else 994 1000 if(strncmp(type,"Input",5)==0){ 1001 995 1002 if(strcmp(tmp1->name,"value")==0){ 996 1003 nc7 = xmlNewNode(NULL, BAD_CAST "DefaultValue"); 997 1004 xmlAddChild(nc7,xmlNewText(BAD_CAST tmp1->value)); 998 1005 default1=1; 1006 hasDefault=true; 999 1007 } 1000 1008 if(strncasecmp(tmp1->name,"AllowedValues",13)==0){ 1001 1009 nc6 = xmlNewNode(ns_ows, BAD_CAST "AllowedValues"); 1002 fprintf(stderr,"ALLOWED VALUE %s\n",tmp1->value);1003 1010 char *token,*saveptr1; 1004 1011 token=strtok_r(tmp1->value,",",&saveptr1); … … 1008 1015 tmps[strlen(tmps)]=0; 1009 1016 xmlAddChild(nc7,xmlNewText(BAD_CAST tmps)); 1010 fprintf(stderr,"strgin : %s\n",tmps);1011 1017 xmlAddChild(nc6,nc7); 1012 1018 token=strtok_r(NULL,",",&saveptr1); 1013 1019 } 1020 if(getMap(_tmp->content,"rangeMin")!=NULL || 1021 getMap(_tmp->content,"rangeMax")!=NULL || 1022 getMap(_tmp->content,"rangeClosure")!=NULL ) 1023 goto doRange; 1014 1024 xmlAddChild(nc3,nc6); 1015 1025 isAnyValue=-1; 1016 1026 } 1017 hasDefault=true; 1027 if(strncasecmp(tmp1->name,"range",5)==0){ 1028 if(isAnyValue==1){ 1029 nc6 = xmlNewNode(ns_ows, BAD_CAST "AllowedValues"); 1030 doRange: 1031 nc8 = xmlNewNode(ns_ows, BAD_CAST "Range"); 1032 map *tmp0=getMap(tmp1,"rangeMin"); 1033 if(tmp0!=NULL){ 1034 nc7 = xmlNewNode(ns_ows, BAD_CAST "MinimumValue"); 1035 xmlAddChild(nc7,xmlNewText(BAD_CAST tmp0->value)); 1036 xmlAddChild(nc8,nc7); 1037 }else{ 1038 nc7 = xmlNewNode(ns_ows, BAD_CAST "MinimumValue"); 1039 xmlAddChild(nc8,nc7); 1040 } 1041 tmp0=getMap(tmp1,"rangeMax"); 1042 if(tmp0!=NULL){ 1043 nc7 = xmlNewNode(ns_ows, BAD_CAST "MaximumValue"); 1044 xmlAddChild(nc7,xmlNewText(BAD_CAST tmp0->value)); 1045 xmlAddChild(nc8,nc7); 1046 }else{ 1047 nc7 = xmlNewNode(ns_ows, BAD_CAST "MaximumValue"); 1048 xmlAddChild(nc8,nc7); 1049 } 1050 tmp0=getMap(tmp1,"rangeSpacing"); 1051 if(tmp0!=NULL){ 1052 nc7 = xmlNewNode(ns_ows, BAD_CAST "Spacing"); 1053 xmlAddChild(nc7,xmlNewText(BAD_CAST tmp0->value)); 1054 xmlAddChild(nc8,nc7); 1055 } 1056 tmp0=getMap(tmp1,"rangeClosure"); 1057 if(tmp0!=NULL){ 1058 char *tmp="closed"; 1059 if(strcasecmp(tmp0->value,"co")==0) 1060 tmp="closed-open"; 1061 else 1062 if(strcasecmp(tmp0->value,"oc")==0) 1063 tmp="open-closed"; 1064 else 1065 if(strcasecmp(tmp0->value,"o")==0) 1066 tmp="open"; 1067 xmlNewNsProp(nc8,ns_ows,BAD_CAST "rangeClosure",BAD_CAST tmp); 1068 }else 1069 xmlNewNsProp(nc8,ns_ows,BAD_CAST "rangeClosure",BAD_CAST "closed"); 1070 } 1071 xmlAddChild(nc6,nc8); 1072 xmlAddChild(nc3,nc6); 1073 isAnyValue=-1; 1074 } 1018 1075 } 1019 1076 tmp1=tmp1->next; … … 1026 1083 xmlAddChild(nc3,nc5); 1027 1084 } 1028 1029 1085 if(strncmp(type,"Input",5)==0){ 1030 if(datatype==1 && isAnyValue==1 && avcnt==0){ 1031 xmlAddChild(nc3,xmlNewNode(ns_ows, BAD_CAST "AnyValue")); 1032 hasDefault=true; 1033 avcnt++; 1034 } 1035 if(datatype==1 && default1>0){ 1086 if(datatype==1 && isAnyValue==1 && default1>0){ 1036 1087 xmlAddChild(nc3,nc7); 1037 1088 } 1038 1089 } 1039 } 1090 1091 } 1092 if(strncmp(type,"Input",5)==0){ 1093 if(datatype==1 && isAnyValue==1 && avcnt==0){ 1094 xmlAddChild(nc3,xmlNewNode(ns_ows, BAD_CAST "AnyValue")); 1095 hasDefault=true; 1096 avcnt++; 1097 } 1098 } 1040 1099 } 1041 1100 … … 1119 1178 xmlAddChild(nc3,nc4); 1120 1179 xmlAddChild(nc2,nc3); 1121 } else if(datatype!=2){1122 if(hasDefault!=true && strncmp(type,"Input",5)==0 )1180 }/*else if(datatype!=2){ 1181 if(hasDefault!=true && strncmp(type,"Input",5)==0 && isAnyValue==1) 1123 1182 xmlAddChild(nc3,xmlNewNode(ns_ows, BAD_CAST "AnyValue")); 1124 } 1183 }*/ 1125 1184 1126 1185 xmlAddChild(nc1,nc2); … … 1772 1831 maps* tmpMap=getMaps(m,"main"); 1773 1832 char *encoding=getEncoding(tmpMap); 1833 char *exceptionCode; 1834 1835 map* tmp=getMap(s,"code"); 1836 if(tmp!=NULL){ 1837 if(strcmp(tmp->value,"OperationNotSupported")==0) 1838 exceptionCode="501 Not Implemented"; 1839 else 1840 if(strcmp(tmp->value,"MissingParameterValue")==0 || 1841 strcmp(tmp->value,"InvalidUpdateSequence")==0 || 1842 strcmp(tmp->value,"OptionNotSupported")==0 || 1843 strcmp(tmp->value,"VersionNegotiationFailed")==0 || 1844 strcmp(tmp->value,"InvalidParameterValue")==0) 1845 exceptionCode="400 Bad request"; 1846 else 1847 if(strcmp(tmp->value,"NoApplicableCode")==0) 1848 exceptionCode="501 Internal Server Error"; 1849 else 1850 exceptionCode="501 Internal Server Error"; 1851 } 1852 else 1853 exceptionCode="501 Internal Server Error"; 1854 1774 1855 if(m!=NULL){ 1775 1856 map *tmpSid=getMapFromMaps(m,"lenv","sid"); … … 1777 1858 if( getpid()==atoi(tmpSid->value) ){ 1778 1859 printHeaders(m); 1779 printf("Content-Type: text/xml; charset=%s\r\nStatus: 200 OK\r\n\r\n",encoding);1860 printf("Content-Type: text/xml; charset=%s\r\nStatus: %s\r\n\r\n",encoding,exceptionCode); 1780 1861 } 1781 1862 } 1782 1863 else{ 1783 1864 printHeaders(m); 1784 printf("Content-Type: text/xml; charset=%s\r\nStatus: 200 OK\r\n\r\n",encoding);1865 printf("Content-Type: text/xml; charset=%s\r\nStatus: %s\r\n\r\n",encoding,exceptionCode); 1785 1866 } 1786 1867 }else{ 1787 printf("Content-Type: text/xml; charset=%s\r\nStatus: 200 OK\r\n\r\n",encoding);1868 printf("Content-Type: text/xml; charset=%s\r\nStatus: %s\r\n\r\n",encoding,exceptionCode); 1788 1869 } 1789 1870 n=createExceptionReportNode(m,s,1); … … 1829 1910 else 1830 1911 xmlNewProp(nc,BAD_CAST "exceptionCode",BAD_CAST "NoApplicableCode"); 1912 1913 tmp=getMap(s,"locator"); 1914 if(tmp!=NULL && strcasecmp(tmp->value,"NULL")!=0) 1915 xmlNewProp(nc,BAD_CAST "locator",BAD_CAST tmp->value); 1916 1831 1917 1832 1918 tmp=getMap(s,"text"); … … 2630 2716 fcontent=(char*)malloc((res.nDataLen+1)*sizeof(char)); 2631 2717 if(fcontent == NULL){ 2632 return errorException(m, _("Unable to allocate memory."), "InternalError" );2718 return errorException(m, _("Unable to allocate memory."), "InternalError",NULL); 2633 2719 } 2634 2720 size_t dwRead; … … 2639 2725 } 2640 2726 if(fsize==0){ 2641 return errorException(m, _("Unable to download the file."), "InternalError" );2727 return errorException(m, _("Unable to download the file."), "InternalError",NULL); 2642 2728 } 2643 2729 … … 2668 2754 } 2669 2755 2670 int errorException(maps *m, const char *message, const char *errorcode )2756 int errorException(maps *m, const char *message, const char *errorcode, const char *locator) 2671 2757 { 2672 2758 map* errormap = createMap("text", message); 2673 2759 addToMap(errormap,"code", errorcode); 2760 if(locator!=NULL) 2761 addToMap(errormap,"locator", locator); 2762 else 2763 addToMap(errormap,"locator", "NULL"); 2674 2764 printExceptionReportResponse(m,errormap); 2675 2765 freeMap(&errormap);
Note: See TracChangeset
for help on using the changeset viewer.