Changeset 790 for trunk/zoo-project/zoo-kernel/response_print.c
- Timestamp:
- Dec 19, 2016, 6:01:06 PM (7 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/zoo-project/zoo-kernel/response_print.c
r788 r790 1489 1489 1490 1490 xmlAddChild(nc2,nc3); 1491 }else{ 1492 if(e->child!=NULL && vid!=0){ 1493 printFullDescription(in,e->child,type,ns,ns_ows,nc2,vid); 1494 } 1491 1495 } 1492 1496 1493 xmlAddChild(nc1,nc2); 1497 if(e->child!=NULL && vid==0){ 1498 elements* children=dupElements(e->child); 1499 elements* cursor=children; 1500 while(cursor!=NULL){ 1501 char* tmp=strdup(cursor->name); 1502 free(cursor->name); 1503 cursor->name=(char*)malloc((strlen(cursor->name)+strlen(e->name)+2)*sizeof(char)); 1504 sprintf(cursor->name,"%s.%s",e->name,tmp); 1505 cursor=cursor->next; 1506 } 1507 printFullDescription(in,children,type,ns,ns_ows,nc2,vid); 1508 xmlAddChild(nc1,nc2); 1509 freeElements(&children); 1510 free(children); 1511 }else 1512 xmlAddChild(nc1,nc2); 1494 1513 1495 1514 e=e->next; … … 1958 1977 } 1959 1978 1960 /** 1961 * IO type Reference or full Data ? 1962 */ 1963 map *tmpMap=getMap(m->content,"Reference"); 1964 if(tmpMap==NULL){ 1965 nc2=xmlNewNode(ns_wps, BAD_CAST "Data"); 1966 if(e!=NULL && e->format!=NULL){ 1967 if(strncasecmp(e->format,"LiteralOutput",strlen(e->format))==0) 1968 nc3=xmlNewNode(ns_wps, BAD_CAST "LiteralData"); 1979 // IO type nested outputs 1980 if(m->child!=NULL){ 1981 maps* curs=m->child; 1982 elements* ecurs=getElements(e,(e!=NULL?e->name:m->name)); 1983 ecurs=ecurs->child; 1984 while(curs!=NULL && ecurs!=NULL){ 1985 map* inRequest=getMap(curs->content,"inRequest"); 1986 if(inRequest!=NULL && strncasecmp(inRequest->value,"true",4)==0) 1987 printIOType(doc,nc1,ns_wps,ns_ows,ns_xlink,ecurs,curs,type,vid); 1988 curs=curs->next; 1989 ecurs=ecurs->next; 1990 } 1991 } 1992 else{ 1993 map *tmpMap=getMap(m->content,"Reference"); 1994 if(tmpMap==NULL){ 1995 nc2=xmlNewNode(ns_wps, BAD_CAST "Data"); 1996 if(e!=NULL && e->format!=NULL){ 1997 if(strncasecmp(e->format,"LiteralOutput",strlen(e->format))==0) 1998 nc3=xmlNewNode(ns_wps, BAD_CAST "LiteralData"); 1999 else 2000 if(strncasecmp(e->format,"ComplexOutput",strlen(e->format))==0) 2001 nc3=xmlNewNode(ns_wps, BAD_CAST "ComplexData"); 2002 else if(strncasecmp(e->format,"BoundingBoxOutput",strlen(e->format))==0) 2003 nc3=xmlNewNode(ns_wps, BAD_CAST "BoundingBoxData"); 2004 else 2005 nc3=xmlNewNode(ns_wps, BAD_CAST e->format); 2006 } 2007 else { 2008 map* tmpV=getMapFromMaps(m,"format","value"); 2009 if(tmpV!=NULL) 2010 nc3=xmlNewNode(ns_wps, BAD_CAST tmpV->value); 2011 else 2012 nc3=xmlNewNode(ns_wps, BAD_CAST "LiteralData"); 2013 } 2014 tmp=m->content; 2015 2016 while(tmp!=NULL){ 2017 if(strcasecmp(tmp->name,"mimeType")==0 || 2018 strcasecmp(tmp->name,"encoding")==0 || 2019 strcasecmp(tmp->name,"schema")==0 || 2020 strcasecmp(tmp->name,"datatype")==0 || 2021 strcasecmp(tmp->name,"uom")==0) { 2022 2023 if(vid==0) 2024 xmlNewProp(nc3,BAD_CAST tmp->name,BAD_CAST tmp->value); 2025 else{ 2026 if(strcasecmp(tmp->name,"datatype")==0) 2027 xmlNewProp(nc2,BAD_CAST "mimeType",BAD_CAST "text/plain"); 2028 else 2029 if(strcasecmp(tmp->name,"uom")!=0) 2030 xmlNewProp(nc2,BAD_CAST tmp->name,BAD_CAST tmp->value); 2031 } 2032 } 2033 if(vid==0) 2034 xmlAddChild(nc2,nc3); 2035 tmp=tmp->next; 2036 } 2037 if(e!=NULL && e->format!=NULL && strcasecmp(e->format,"BoundingBoxData")==0) { 2038 map* bb=getMap(m->content,"value"); 2039 if(bb!=NULL) { 2040 map* tmpRes=parseBoundingBox(bb->value); 2041 printBoundingBox(ns_ows,nc3,tmpRes); 2042 freeMap(&tmpRes); 2043 free(tmpRes); 2044 } 2045 } 2046 else { 2047 if(e!=NULL) 2048 tmp=getMap(e->defaults->content,"mimeType"); 2049 else 2050 tmp=NULL; 2051 2052 map* tmp1=getMap(m->content,"encoding"); 2053 map* tmp2=getMap(m->content,"mimeType"); 2054 map* tmp3=getMap(m->content,"value"); 2055 int hasValue=1; 2056 if(tmp3==NULL){ 2057 tmp3=createMap("value",""); 2058 hasValue=-1; 2059 } 2060 2061 if( ( tmp1 != NULL && strncmp(tmp1->value,"base64",6) == 0 ) // if encoding is base64 2062 || // or if 2063 ( tmp2 != NULL && ( strstr(tmp2->value,"text") == NULL // mime type is not text 2064 && // nor 2065 strstr(tmp2->value,"xml") == NULL // xml 2066 && // nor 2067 strstr(tmp2->value,"javascript") == NULL // javascript 2068 && 2069 strstr(tmp2->value,"json") == NULL 2070 && 2071 strstr(tmp2->value,"ecmascript") == NULL 2072 && 2073 // include for backwards compatibility, 2074 // although correct mime type is ...kml+xml: 2075 strstr(tmp2->value,"google-earth.kml") == NULL ) 2076 ) 2077 ) { // then 2078 map* rs=getMap(m->content,"size"); // obtain size 2079 bool isSized=true; 2080 if(rs==NULL){ 2081 char tmp1[1024]; 2082 sprintf(tmp1,"%ld",strlen(tmp3->value)); 2083 rs=createMap("size",tmp1); 2084 isSized=false; 2085 } 2086 2087 xmlAddChild((vid==0?nc3:nc2),xmlNewText(BAD_CAST base64(tmp3->value, atoi(rs->value)))); // base 64 encode in XML 2088 2089 if(tmp1==NULL || (tmp1!=NULL && strncmp(tmp1->value,"base64",6)!=0)) { 2090 xmlAttrPtr ap = xmlHasProp((vid==0?nc3:nc2), BAD_CAST "encoding"); 2091 if (ap != NULL) { 2092 xmlRemoveProp(ap); 2093 } 2094 xmlNewProp((vid==0?nc3:nc2),BAD_CAST "encoding",BAD_CAST "base64"); 2095 } 2096 2097 if(!isSized){ 2098 freeMap(&rs); 2099 free(rs); 2100 } 2101 } 2102 else if (tmp2!=NULL) { // else (text-based format) 2103 if(strstr(tmp2->value, "javascript") != NULL || // if javascript put code in CDATA block 2104 strstr(tmp2->value, "json") != NULL || // (will not be parsed by XML reader) 2105 strstr(tmp2->value, "ecmascript") != NULL 2106 ) { 2107 xmlAddChild((vid==0?nc3:nc2),xmlNewCDataBlock(doc,BAD_CAST tmp3->value,strlen(tmp3->value))); 2108 } 2109 else { // else 2110 if (strstr(tmp2->value, "xml") != NULL || // if XML-based format 2111 // include for backwards compatibility, 2112 // although correct mime type is ...kml+xml: 2113 strstr(tmp2->value, "google-earth.kml") != NULL 2114 ) { 2115 2116 int li=zooXmlAddDoc(tmp3->value); 2117 xmlDocPtr doc = iDocs[li]; 2118 xmlNodePtr ir = xmlDocGetRootElement(doc); 2119 xmlAddChild((vid==0?nc3:nc2),ir); 2120 } 2121 else // else 2122 xmlAddChild((vid==0?nc3:nc2),xmlNewText(BAD_CAST tmp3->value)); // add text node 2123 } 2124 xmlAddChild(nc2,nc3); 2125 } 2126 else { 2127 xmlAddChild((vid==0?nc3:nc2),xmlNewText(BAD_CAST tmp3->value)); 2128 } 2129 2130 if(hasValue<0) { 2131 freeMap(&tmp3); 2132 free(tmp3); 2133 } 2134 } 2135 } 2136 else { // Reference 2137 tmpMap=getMap(m->content,"Reference"); 2138 nc3=nc2=xmlNewNode(ns_wps, BAD_CAST "Reference"); 2139 /* Special case to avoid failing to validate against the WPS 2.0 schema */ 2140 if(strcasecmp(type,"Output")==0 && vid==0) 2141 xmlNewProp(nc3,BAD_CAST "href",BAD_CAST tmpMap->value); 1969 2142 else 1970 if(strncasecmp(e->format,"ComplexOutput",strlen(e->format))==0) 1971 nc3=xmlNewNode(ns_wps, BAD_CAST "ComplexData"); 1972 else if(strncasecmp(e->format,"BoundingBoxOutput",strlen(e->format))==0) 1973 nc3=xmlNewNode(ns_wps, BAD_CAST "BoundingBoxData"); 1974 else 1975 nc3=xmlNewNode(ns_wps, BAD_CAST e->format); 1976 } 1977 else { 1978 map* tmpV=getMapFromMaps(m,"format","value"); 1979 if(tmpV!=NULL) 1980 nc3=xmlNewNode(ns_wps, BAD_CAST tmpV->value); 1981 else 1982 nc3=xmlNewNode(ns_wps, BAD_CAST "LiteralData"); 1983 } 1984 tmp=m->content; 1985 1986 while(tmp!=NULL){ 1987 if(strcasecmp(tmp->name,"mimeType")==0 || 1988 strcasecmp(tmp->name,"encoding")==0 || 1989 strcasecmp(tmp->name,"schema")==0 || 1990 strcasecmp(tmp->name,"datatype")==0 || 1991 strcasecmp(tmp->name,"uom")==0) { 1992 1993 if(vid==0) 1994 xmlNewProp(nc3,BAD_CAST tmp->name,BAD_CAST tmp->value); 1995 else{ 2143 xmlNewNsProp(nc3,ns_xlink,BAD_CAST "href",BAD_CAST tmpMap->value); 2144 2145 tmp=m->content; 2146 while(tmp!=NULL) { 2147 if(strcasecmp(tmp->name,"mimeType")==0 || 2148 strcasecmp(tmp->name,"encoding")==0 || 2149 strcasecmp(tmp->name,"schema")==0 || 2150 strcasecmp(tmp->name,"datatype")==0 || 2151 strcasecmp(tmp->name,"uom")==0){ 2152 1996 2153 if(strcasecmp(tmp->name,"datatype")==0) 1997 xmlNewProp(nc 2,BAD_CAST "mimeType",BAD_CAST "text/plain");2154 xmlNewProp(nc3,BAD_CAST "mimeType",BAD_CAST "text/plain"); 1998 2155 else 1999 if(strcasecmp(tmp->name,"uom")!=0) 2000 xmlNewProp(nc2,BAD_CAST tmp->name,BAD_CAST tmp->value); 2001 } 2002 } 2003 if(vid==0) 2156 xmlNewProp(nc3,BAD_CAST tmp->name,BAD_CAST tmp->value); 2157 } 2158 tmp=tmp->next; 2004 2159 xmlAddChild(nc2,nc3); 2005 tmp=tmp->next; 2006 } 2007 if(e!=NULL && e->format!=NULL && strcasecmp(e->format,"BoundingBoxData")==0) { 2008 map* bb=getMap(m->content,"value"); 2009 if(bb!=NULL) { 2010 map* tmpRes=parseBoundingBox(bb->value); 2011 printBoundingBox(ns_ows,nc3,tmpRes); 2012 freeMap(&tmpRes); 2013 free(tmpRes); 2014 } 2015 } 2016 else { 2017 if(e!=NULL) 2018 tmp=getMap(e->defaults->content,"mimeType"); 2019 else 2020 tmp=NULL; 2021 2022 map* tmp1=getMap(m->content,"encoding"); 2023 map* tmp2=getMap(m->content,"mimeType"); 2024 map* tmp3=getMap(m->content,"value"); 2025 int hasValue=1; 2026 if(tmp3==NULL){ 2027 tmp3=createMap("value",""); 2028 hasValue=-1; 2029 } 2030 2031 if( ( tmp1 != NULL && strncmp(tmp1->value,"base64",6) == 0 ) // if encoding is base64 2032 || // or if 2033 ( tmp2 != NULL && ( strstr(tmp2->value,"text") == NULL // mime type is not text 2034 && // nor 2035 strstr(tmp2->value,"xml") == NULL // xml 2036 && // nor 2037 strstr(tmp2->value,"javascript") == NULL // javascript 2038 && 2039 strstr(tmp2->value,"json") == NULL 2040 && 2041 strstr(tmp2->value,"ecmascript") == NULL 2042 && 2043 // include for backwards compatibility, 2044 // although correct mime type is ...kml+xml: 2045 strstr(tmp2->value,"google-earth.kml") == NULL ) 2046 ) 2047 ) { // then 2048 map* rs=getMap(m->content,"size"); // obtain size 2049 bool isSized=true; 2050 if(rs==NULL){ 2051 char tmp1[1024]; 2052 sprintf(tmp1,"%ld",strlen(tmp3->value)); 2053 rs=createMap("size",tmp1); 2054 isSized=false; 2055 } 2056 2057 xmlAddChild((vid==0?nc3:nc2),xmlNewText(BAD_CAST base64(tmp3->value, atoi(rs->value)))); // base 64 encode in XML 2058 2059 if(tmp1==NULL || (tmp1!=NULL && strncmp(tmp1->value,"base64",6)!=0)) { 2060 xmlAttrPtr ap = xmlHasProp((vid==0?nc3:nc2), BAD_CAST "encoding"); 2061 if (ap != NULL) { 2062 xmlRemoveProp(ap); 2063 } 2064 xmlNewProp((vid==0?nc3:nc2),BAD_CAST "encoding",BAD_CAST "base64"); 2065 } 2066 2067 if(!isSized){ 2068 freeMap(&rs); 2069 free(rs); 2070 } 2071 } 2072 else if (tmp2!=NULL) { // else (text-based format) 2073 if(strstr(tmp2->value, "javascript") != NULL || // if javascript put code in CDATA block 2074 strstr(tmp2->value, "json") != NULL || // (will not be parsed by XML reader) 2075 strstr(tmp2->value, "ecmascript") != NULL 2076 ) { 2077 xmlAddChild((vid==0?nc3:nc2),xmlNewCDataBlock(doc,BAD_CAST tmp3->value,strlen(tmp3->value))); 2078 } 2079 else { // else 2080 if (strstr(tmp2->value, "xml") != NULL || // if XML-based format 2081 // include for backwards compatibility, 2082 // although correct mime type is ...kml+xml: 2083 strstr(tmp2->value, "google-earth.kml") != NULL 2084 ) { 2085 2086 int li=zooXmlAddDoc(tmp3->value); 2087 xmlDocPtr doc = iDocs[li]; 2088 xmlNodePtr ir = xmlDocGetRootElement(doc); 2089 xmlAddChild((vid==0?nc3:nc2),ir); 2090 } 2091 else // else 2092 xmlAddChild((vid==0?nc3:nc2),xmlNewText(BAD_CAST tmp3->value)); // add text node 2093 } 2094 xmlAddChild(nc2,nc3); 2095 } 2096 else { 2097 xmlAddChild((vid==0?nc3:nc2),xmlNewText(BAD_CAST tmp3->value)); 2098 } 2099 2100 if(hasValue<0) { 2101 freeMap(&tmp3); 2102 free(tmp3); 2103 } 2104 } 2105 } 2106 else { // Reference 2107 tmpMap=getMap(m->content,"Reference"); 2108 nc3=nc2=xmlNewNode(ns_wps, BAD_CAST "Reference"); 2109 if(strcasecmp(type,"Output")==0) 2110 xmlNewProp(nc3,BAD_CAST "href",BAD_CAST tmpMap->value); 2111 else 2112 xmlNewNsProp(nc3,ns_xlink,BAD_CAST "href",BAD_CAST tmpMap->value); 2113 2114 tmp=m->content; 2115 while(tmp!=NULL) { 2116 if(strcasecmp(tmp->name,"mimeType")==0 || 2117 strcasecmp(tmp->name,"encoding")==0 || 2118 strcasecmp(tmp->name,"schema")==0 || 2119 strcasecmp(tmp->name,"datatype")==0 || 2120 strcasecmp(tmp->name,"uom")==0){ 2121 2122 if(strcasecmp(tmp->name,"datatype")==0) 2123 xmlNewProp(nc3,BAD_CAST "mimeType",BAD_CAST "text/plain"); 2124 else 2125 xmlNewProp(nc3,BAD_CAST tmp->name,BAD_CAST tmp->value); 2126 } 2127 tmp=tmp->next; 2128 xmlAddChild(nc2,nc3); 2129 } 2130 } 2131 xmlAddChild(nc1,nc2); 2160 } 2161 } 2162 xmlAddChild(nc1,nc2); 2163 } 2132 2164 xmlAddChild(nc,nc1); 2133 2165 } … … 2394 2426 sprintf(tmpMsg,_("Unable to create the file \"%s\" for storing the session maps."),session_file_path); 2395 2427 errorException(m,tmpMsg,"InternalError",NULL); 2396 2397 2428 return; 2398 2429 } … … 2437 2468 #endif 2438 2469 maps* tmpI=request_outputs; 2470 maps* stmpI=NULL; 2439 2471 map* usid=getMapFromMaps(m,"lenv","usid"); 2440 2472 int itn=0; 2473 NESTED0: 2441 2474 while(tmpI!=NULL){ 2475 if(tmpI->child!=NULL){ 2476 stmpI=tmpI; 2477 tmpI=tmpI->child; 2478 } 2442 2479 #ifdef USE_MS 2443 2480 map* testMap=getMap(tmpI->content,"useMapserver"); … … 2462 2499 { 2463 2500 elements* in=getElements(s->outputs,tmpI->name); 2501 if(in==NULL && s->outputs->child!=NULL){ 2502 in=getElements(s->outputs->child,tmpI->name); 2503 } 2464 2504 char *format=NULL; 2465 2505 if(in!=NULL && in->format!=NULL){ … … 2545 2585 #endif 2546 2586 tmpI=tmpI->next; 2587 } 2588 if(stmpI!=NULL){ 2589 tmpI=stmpI->next; 2590 stmpI=NULL; 2591 if(tmpI!=NULL) 2592 goto NESTED0; 2547 2593 } 2548 2594 #ifdef DEBUG
Note: See TracChangeset
for help on using the changeset viewer.