- Timestamp:
- Aug 7, 2017, 2:56:24 PM (7 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/prototype-v0/zoo-project/zoo-kernel/response_print.c
r822 r839 23 23 */ 24 24 25 #include "service.h" 25 26 #include "response_print.h" 26 27 #include "request_parser.h" … … 644 645 * @return the generated wps:ProcessOfferings xmlNodePtr 645 646 */ 646 void printGetCapabilitiesForProcess(registry *reg, maps* m,xml NodePtr nc,service* serv){647 void printGetCapabilitiesForProcess(registry *reg, maps* m,xmlDocPtr doc,xmlNodePtr nc,service* serv){ 647 648 xmlNsPtr ns,ns_ows,ns_xml,ns_xlink; 648 649 xmlNodePtr n=NULL,nc1,nc2,nc3; … … 692 693 tmp1=serv->metadata; 693 694 694 addMetadata(tmp1,nc1,ns_ows,ns_xlink); 695 696 /*while(tmp1!=NULL){ 697 nc2 = xmlNewNode(ns_ows, BAD_CAST "Metadata"); 698 if(strcmp(tmp1->name,"title")==0 || 699 strcmp(tmp1->name,"href")==0 || 700 strcmp(tmp1->name,"role")==0 || 701 strcmp(tmp1->name,"link_type")==0){ 702 xmlNewNsProp(nc2,ns_xlink,BAD_CAST tmp1->name,BAD_CAST tmp1->value); 703 xmlAddChild(nc1,nc2); 704 }else{ 705 if(nc3==NULL) 706 nc3 = xmlNewNode(ns_ows, BAD_CAST "AdditionalParameter"); 707 xmlNodePtr nc4 = xmlNewNode(ns_ows, BAD_CAST "Name"); 708 xmlAddChild(nc4,xmlNewText(BAD_CAST tmp1->name)); 709 xmlNodePtr nc5 = xmlNewNode(ns_ows, BAD_CAST "Value"); 710 xmlAddChild(nc5,xmlNewText(BAD_CAST tmp1->value)); 711 xmlAddChild(nc3,nc4); 712 xmlAddChild(nc3,nc5); 713 } 714 tmp1=tmp1->next; 715 }*/ 695 addMetadata(tmp1,doc,nc1,ns_ows,ns_xlink); 696 tmp1=serv->additional_parameters; 697 int fromDb=-1; 698 map* test=getMap(serv->content,"fromDb"); 699 if(test!=NULL && strncasecmp(test->value,"true",4)==0) 700 fromDb=1; 701 addAdditionalParameters(tmp1,doc,nc1,ns_ows,ns_xlink,fromDb); 702 716 703 if(nc3!=NULL) 717 704 xmlAddChild(nc1,nc3); … … 756 743 } 757 744 758 int addMetadata(map* meta,xml NodePtr nc,xmlNsPtr ns_ows,xmlNsPtr ns_xlink){745 int addMetadata(map* meta,xmlDocPtr doc,xmlNodePtr nc,xmlNsPtr ns_ows,xmlNsPtr ns_xlink){ 759 746 int hasTitle=-1; 760 747 int hasValue=-1; … … 830 817 } 831 818 819 820 int addAdditionalParameters(map* meta,xmlDocPtr doc,xmlNodePtr nc,xmlNsPtr ns_ows,xmlNsPtr ns_xlink,int fromDb){ 821 int hasTitle=-1; 822 int hasValue=-1; 823 xmlNodePtr nc1; 824 map* oMeta=meta; 825 int isAdditionalParameters=-1; 826 //if(count(oMeta)>=2){ 827 int level=0; 828 map* test=getMap(meta,"title"); 829 if(test!=NULL) 830 level+=1; 831 test=getMap(meta,"href"); 832 if(test!=NULL) 833 level+=1; 834 test=getMap(meta,"role"); 835 if(test!=NULL) 836 level+=1; 837 if(count(oMeta)>level+1) 838 isAdditionalParameters=1; 839 //} 840 char *ctitle=NULL; 841 while(meta!=NULL){ 842 if(hasTitle<0) 843 if(hasValue<0) 844 nc1 = xmlNewNode(ns_ows, BAD_CAST "AdditionalParameters"); 845 if(strncasecmp(meta->name,"title",5)==0 || 846 strcasecmp(meta->name,"href")==0 || 847 strcasecmp(meta->name,"role")==0 ){ 848 int index=5; 849 if(strncasecmp(meta->name,"title",5)==0){ 850 index=6; 851 hasTitle=1; 852 if(ctitle!=NULL && strcasecmp(meta->value,ctitle)!=0){ 853 xmlAddChild(nc,nc1); 854 nc1 = xmlNewNode(ns_ows, BAD_CAST "AdditionalParameters"); 855 free(ctitle); 856 ctitle=NULL; 857 } 858 if(ctitle==NULL){ 859 char *tmp=(char*)malloc((strlen(meta->name)+1)*sizeof(char)); 860 snprintf(tmp,index,"%s",meta->name); 861 xmlNewNsProp(nc1,ns_xlink,BAD_CAST tmp,BAD_CAST meta->value); 862 free(tmp); 863 } 864 if(ctitle!=NULL) 865 free(ctitle); 866 ctitle=zStrdup(meta->value); 867 } 868 }else{ 869 xmlNodePtr nc2 = xmlNewNode(ns_ows, BAD_CAST "AdditionalParameter"); 870 xmlNodePtr nc3 = xmlNewNode(ns_ows, BAD_CAST "Name"); 871 xmlAddChild(nc3,xmlNewText(BAD_CAST meta->name)); 872 xmlAddChild(nc2,nc3); 873 if(fromDb<0){ 874 char *mptr; 875 char* meta_values=strtok_r(meta->value,",",&mptr); 876 while(meta_values!=NULL){ 877 xmlNodePtr nc4 = xmlNewNode(ns_ows, BAD_CAST "Value"); 878 xmlAddChild(nc4,xmlNewText(BAD_CAST meta_values)); 879 xmlAddChild(nc2,nc4); 880 meta_values=strtok_r(NULL,",",&mptr); 881 } 882 }else{ 883 xmlNodePtr nc4 = xmlNewNode(ns_ows, BAD_CAST "Value"); 884 xmlAddChild(nc4,xmlNewCDataBlock(doc,BAD_CAST meta->value,strlen(meta->value))); 885 xmlAddChild(nc2,nc4); 886 } 887 xmlAddChild(nc1,nc2); 888 hasTitle=-1; 889 } 890 meta=meta->next; 891 if(hasTitle<0){ 892 xmlAddChild(nc,nc1); 893 hasValue=1; 894 } 895 } 896 if(oMeta!=NULL && hasValue<0 && nc1!=NULL){ 897 xmlAddChild(nc,nc1); 898 } 899 } 900 832 901 /** 833 902 * Add the ows:Metadata nodes relative to the profile registry … … 886 955 * @return the generated wps:ProcessOfferings xmlNodePtr 887 956 */ 888 void printDescribeProcessForProcess(registry *reg, maps* m,xml NodePtr nc,service* serv){957 void printDescribeProcessForProcess(registry *reg, maps* m,xmlDocPtr doc,xmlNodePtr nc,service* serv){ 889 958 xmlNsPtr ns,ns_ows,ns_xlink; 890 959 xmlNodePtr n,nc1; … … 892 961 map* version=getMapFromMaps(m,"main","rversion"); 893 962 int vid=getVersionId(version->value); 963 int fromDb=-1; 964 map* serviceType=getMap(serv->content,"serviceType"); 965 map* test=getMap(serv->content,"fromDb"); 966 if(test!=NULL && strncasecmp(test->value,"true",4)==0) 967 fromDb=1; 894 968 895 969 n=nc; … … 937 1011 tmp1=serv->metadata; 938 1012 while(tmp1!=NULL){ 939 addMetadata(tmp1, nc,ns_ows,ns_xlink);1013 addMetadata(tmp1,doc,nc,ns_ows,ns_xlink); 940 1014 /*nc1 = xmlNewNode(ns_ows, BAD_CAST "Metadata"); 941 1015 xmlNewNsProp(nc1,ns_xlink,BAD_CAST tmp1->name,BAD_CAST tmp1->value); … … 951 1025 }else{ 952 1026 tmp1=serv->metadata; 953 addMetadata(tmp1, nc,ns_ows,ns_xlink);1027 addMetadata(tmp1,doc,nc,ns_ows,ns_xlink); 954 1028 addInheritedMetadata(nc,ns_ows,ns_xlink,reg,m,serv); 1029 tmp1=serv->additional_parameters; 1030 addAdditionalParameters(tmp1,doc,nc,ns_ows,ns_xlink,fromDb); 955 1031 } 956 1032 … … 959 1035 if(vid==0){ 960 1036 nc1 = xmlNewNode(NULL, BAD_CAST "DataInputs"); 961 printFullDescription( 1,e,"Input",ns,ns_ows,nc1,vid);1037 printFullDescription(doc,1,e,"Input",ns,ns_ows,nc1,vid,fromDb,NULL); 962 1038 xmlAddChild(nc,nc1); 963 1039 } 964 1040 else{ 965 printFullDescription( 1,e,"wps:Input",ns,ns_ows,nc,vid);1041 printFullDescription(doc,1,e,"wps:Input",ns,ns_ows,nc,vid,fromDb,NULL); 966 1042 } 967 1043 } … … 970 1046 if(vid==0){ 971 1047 nc1 = xmlNewNode(NULL, BAD_CAST "ProcessOutputs"); 972 printFullDescription( 0,e,"Output",ns,ns_ows,nc1,vid);1048 printFullDescription(doc,0,e,"Output",ns,ns_ows,nc1,vid,fromDb,NULL); 973 1049 xmlAddChild(nc,nc1); 974 1050 } 975 1051 else{ 976 printFullDescription( 0,e,"wps:Output",ns,ns_ows,nc,vid);1052 printFullDescription(doc,0,e,"wps:Output",ns,ns_ows,nc,vid,fromDb,serviceType); 977 1053 } 978 1054 if(vid==0) … … 996 1072 * @param nc1 the XML node to use to add the created tree 997 1073 * @param vid the WPS version id (0 for 1.0.0, 1 for 2.0.0) 998 */ 999 void printFullDescription(int in,elements *elem,const char* type,xmlNsPtr ns,xmlNsPtr ns_ows,xmlNodePtr nc1,int vid){ 1074 * @param fromDb 1 in case the metadata comes from the DB, -1 in other cases 1075 * @param serviceType the serviceType found in the ZCFG file or the DB 1076 */ 1077 void printFullDescription(xmlDocPtr doc,int in,elements *elem,const char* type,xmlNsPtr ns,xmlNsPtr ns_ows,xmlNodePtr nc1,int vid,int fromDb,const map* serviceType){ 1000 1078 xmlNsPtr ns1=NULL; 1001 1079 if(vid==1) … … 1032 1110 1033 1111 if(e->format!=NULL){ 1112 #ifdef USE_HPC 1113 DEFAULT_OUT: 1114 #endif 1034 1115 const char orderedFields[13][14]={ 1035 1116 "mimeType", … … 1138 1219 char *tmps=strdup(token); 1139 1220 tmps[strlen(tmps)]=0; 1140 xmlAddChild(nc7,xmlNewText(BAD_CAST tmps)); 1221 nc8 = xmlNewText(BAD_CAST tmps); 1222 xmlAddChild(nc7,nc8); 1141 1223 free(tmps); 1142 1224 xmlAddChild(nc6,nc7); … … 1437 1519 xmlNsPtr ns_xlink=usedNs[xlinkId]; 1438 1520 1439 dumpMap(metadata); 1440 addMetadata(metadata,nc2,ns_ows,ns_xlink); 1521 //dumpMap(metadata); 1522 addMetadata(metadata,doc,nc2,ns_ows,ns_xlink); 1523 addAdditionalParameters(e->additional_parameters,doc,nc2,ns_ows,ns_xlink,fromDb); 1441 1524 1442 1525 } … … 1583 1666 xmlAddChild(nc2,nc3); 1584 1667 }else{ 1585 if(e->child!=NULL && vid!=0){ 1586 printFullDescription(in,e->child,type,ns,ns_ows,nc2,vid); 1587 } 1588 } 1589 1668 if(e->child!=NULL){ 1669 if(e->child!=NULL && vid!=0){ 1670 printFullDescription(doc,in,e->child,type,ns,ns_ows,nc2,vid,fromDb,NULL); 1671 } 1672 } 1673 } 1590 1674 if(e->child!=NULL && vid==0){ 1591 1675 elements* children=dupElements(e->child); … … 1598 1682 cursor=cursor->next; 1599 1683 } 1600 printFullDescription( in,children,type,ns,ns_ows,nc2,vid);1684 printFullDescription(doc,in,children,type,ns,ns_ows,nc2,vid,fromDb,serviceType); 1601 1685 xmlAddChild(nc1,nc2); 1602 1686 freeElements(&children); … … 1604 1688 }else 1605 1689 xmlAddChild(nc1,nc2); 1606 1607 1690 e=e->next; 1608 1691 } … … 2588 2671 toto=getMap(tmpI->content,"asReference"); 2589 2672 #ifdef USE_MS 2590 if(toto!=NULL && strcasecmp(toto->value,"true")==0 && testMap==NULL)2673 if(toto!=NULL && strcasecmp(toto->value,"true")==0 && (testMap==NULL || strncasecmp(testMap->value,"true",4)!=0) ) 2591 2674 #else 2592 2675 if(toto!=NULL && strcasecmp(toto->value,"true")==0)
Note: See TracChangeset
for help on using the changeset viewer.