- Timestamp:
- Nov 21, 2017, 10:24:14 AM (6 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/prototype-v0/zoo-project/zoo-kernel/response_print.c
r851 r854 743 743 } 744 744 745 int addMetadata(map* meta,xmlDocPtr doc,xmlNodePtr nc,xmlNsPtr ns_ows,xmlNsPtr ns_xlink){ 745 /** 746 * Add a Metadata node to any existing node. 747 * @param meta the map defining the additional parameters 748 * @param doc the XML document used 749 * @param nb the node to add the additional parameters 750 * @param ns_ows the OWS namespace 751 * @param ns_xlink the xlink namespace 752 */ 753 void addMetadata(map* meta,xmlDocPtr doc,xmlNodePtr nc,xmlNsPtr ns_ows,xmlNsPtr ns_xlink){ 746 754 int hasTitle=-1; 747 755 int hasValue=-1; … … 817 825 } 818 826 819 820 int addAdditionalParameters(map* meta,xmlDocPtr doc,xmlNodePtr nc,xmlNsPtr ns_ows,xmlNsPtr ns_xlink,int fromDb){ 827 /** 828 * Add AdditionalParameters nodes to any existing node. 829 * @param meta the map defining the additional parameters 830 * @param doc the XML document used 831 * @param nb the node to add the additional parameters 832 * @param ns_ows the OWS namespace 833 * @param ns_xlink the xlink namespace 834 * @param fromDb 1 if the metadata has been extracted from the metadb, 835 * 0 otherwise 836 */ 837 void addAdditionalParameters(map* meta,xmlDocPtr doc,xmlNodePtr nc,xmlNsPtr ns_ows,xmlNsPtr ns_xlink,int fromDb){ 821 838 int hasTitle=-1; 822 839 int hasValue=-1; 840 int toAddAtEnd=-1; 841 int cnt=0; 842 xmlNodePtr* ncr=NULL; 823 843 xmlNodePtr nc1; 824 844 map* oMeta=meta; 825 845 int isAdditionalParameters=-1; 826 //if(count(oMeta)>=2){827 846 int level=0; 828 847 map* test=getMap(meta,"title"); 848 map* otitle=getMap(meta,"title"); 849 map* length=getMap(meta,"length"); 850 int len=0; 851 char *ctitle=NULL; 852 829 853 if(test!=NULL) 830 854 level+=1; … … 837 861 if(count(oMeta)>level+1) 838 862 isAdditionalParameters=1; 839 //} 840 char *ctitle=NULL; 863 841 864 while(meta!=NULL){ 842 if(hasTitle<0 )843 if(hasValue<0)844 nc1 = xmlNewNode(ns_ows, BAD_CAST "AdditionalParameters"); 865 if(hasTitle<0 && hasValue<0){ 866 nc1 = xmlNewNode(ns_ows, BAD_CAST "AdditionalParameters"); 867 } 845 868 if(strncasecmp(meta->name,"title",5)==0 || 846 869 strcasecmp(meta->name,"href")==0 || … … 851 874 hasTitle=1; 852 875 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; 876 xmlNodePtr ncTmp = xmlDocCopyNodeList(doc,nc1); 877 xmlAddChild(nc,ncTmp); 878 xmlFreeNode(nc1); 879 toAddAtEnd=1; 880 cnt++; 881 nc1 = xmlNewNode(ns_ows, BAD_CAST "AdditionalParameters"); 882 free(ctitle); 883 ctitle=NULL; 857 884 } 858 885 if(ctitle==NULL){ … … 865 892 free(ctitle); 866 893 ctitle=zStrdup(meta->value); 894 }else{ 895 xmlNewNsProp(nc1,ns_xlink,BAD_CAST meta->name,BAD_CAST meta->value); 867 896 } 868 897 }else{ … … 892 921 meta=meta->next; 893 922 if(hasTitle<0){ 894 xmlAddChild(nc,nc1);923 //xmlAddChild(nc,nc1); 895 924 hasValue=1; 896 }else 897 free(ctitle); 898 } 899 if(oMeta!=NULL && hasValue<0 && nc1!=NULL){ 925 }/*else 926 if(ctitle!=NULL) 927 free(ctitle);*/ 928 } 929 if(length!=NULL) 930 len=atoi(length->value); 931 if(otitle!=NULL) 932 len=1; 933 if(cnt<len){ 900 934 xmlAddChild(nc,nc1); 935 free(ctitle); 901 936 } 902 937 } … … 1406 1441 } 1407 1442 } 1408 else 1443 else{ 1409 1444 xmlFreeNode(nc9); 1445 } 1410 1446 if(strcasecmp(tmp1->name,"uom")==0) 1411 1447 hasUOM1=true; … … 1428 1464 if(hasUOM1==false && vid==0){ 1429 1465 xmlFreeNode(nc5); 1430 if(datatype==1) 1466 if(datatype==1){ 1431 1467 xmlFreeNode(nc4); 1468 } 1432 1469 } 1433 1470 else … … 1440 1477 if(datatype!=1 && default1<0){ 1441 1478 xmlFreeNode(nc5); 1442 if(datatype!=2) 1479 if(datatype!=2){ 1443 1480 xmlFreeNode(nc4); 1481 } 1444 1482 } 1445 1483 … … 1603 1641 if(vid==0 || oI!=4) 1604 1642 xmlAddChild(nc5,nc6); 1605 else 1643 else{ 1606 1644 xmlFreeNode(nc6); 1645 } 1607 1646 } 1608 else 1647 else{ 1609 1648 xmlFreeNode(nc6); 1649 } 1610 1650 } 1611 1651 tmp1=tmp1->next; … … 1634 1674 } 1635 1675 else{ 1636 xmlFreeNode(nc4);1637 1676 xmlAddChild(nc3,nc5); 1638 1677 } … … 1648 1687 1649 1688 if(hasSupported==0){ 1650 if(datatype==0 && vid!=0) 1689 if(datatype==0 && vid!=0){ 1651 1690 xmlFreeNode(nc4); 1691 } 1652 1692 xmlFreeNode(nc5); 1653 1693 } … … 2678 2718 toto=getMap(tmpI->content,"asReference"); 2679 2719 #ifdef USE_MS 2680 if(toto!=NULL && strcasecmp(toto->value,"true")==0 && (testMap==NULL || strncasecmp(testMap->value,"true",4)!=0) ) 2720 restartNoMS: 2721 map* geodatatype=getMap(tmpI->content,"geodatatype"); 2722 2723 if(toto!=NULL && strcasecmp(toto->value,"true")==0 && 2724 (testMap==NULL || 2725 strncasecmp(testMap->value,"true",4)!=0 || 2726 (geodatatype!=NULL && strcasecmp(geodatatype->value,"other")==0) ) ) 2681 2727 #else 2682 2728 if(toto!=NULL && strcasecmp(toto->value,"true")==0) … … 2699 2745 } 2700 2746 2747 char *file_path=NULL; 2701 2748 if(gfile==NULL) { 2702 2749 map *ext=getMap(tmpI->content,"extension"); 2703 char *file_path;2704 2750 char file_ext[32]; 2705 2751 … … 2716 2762 free(file_name); 2717 2763 file_name=(char*)malloc((strlen(s->name)+strlen(usid->value)+strlen(file_ext)+strlen(tmpI->name)+45)*sizeof(char)); 2718 sprintf(file_name," %s_%s_%s_%d.%s",s->name,tmpI->name,usid->value,itn,file_ext);2764 sprintf(file_name,"ZOO_DATA_%s_%s_%s_%d.%s",s->name,tmpI->name,usid->value,itn,file_ext); 2719 2765 itn++; 2720 2766 file_path=(char*)malloc((strlen(tmp1->value)+strlen(file_name)+2)*sizeof(char)); … … 2730 2776 return; 2731 2777 } 2732 free(file_path);2733 2778 2734 2779 toto=getMap(tmpI->content,"value"); … … 2744 2789 } 2745 2790 fclose(ofile); 2746 2747 2791 } 2748 2792 2749 2793 map *tmp2=getMapFromMaps(m,"main","tmpUrl"); 2750 2794 map *tmp3=getMapFromMaps(m,"main","serverAddress"); 2751 char *file_url ;2795 char *file_url=NULL; 2752 2796 if(strncasecmp(tmp2->value,"http://",7)==0 || 2753 2797 strncasecmp(tmp2->value,"https://",8)==0){ … … 2759 2803 } 2760 2804 addToMap(tmpI->content,"Reference",file_url); 2761 free(file_name); 2762 free(file_url); 2805 /*maps* curs=tmpI; 2806 curs=curs->next; 2807 map* test=getMap(tmpI->content,"replicateStorageNext"); 2808 if(test!=NULL && strncasecmp(test->value,"true",4)==0) 2809 while(curs!=NULL){ 2810 addToMap(curs->content,"storage",file_path); 2811 curs=curs->next; 2812 } 2813 if(file_path!=NULL) 2814 free(file_path);*/ 2815 if(file_name!=NULL) 2816 free(file_name); 2817 if(file_url!=NULL) 2818 free(file_url); 2763 2819 file_name=NULL; 2764 2820 } … … 2766 2822 else{ 2767 2823 if(testMap!=NULL){ 2824 setMapInMaps(m,"lenv","state","out"); 2768 2825 setReferenceUrl(m,tmpI); 2826 geodatatype=getMap(tmpI->content,"geodatatype"); 2827 if(geodatatype!=NULL && strcasecmp(geodatatype->value,"other")==0) 2828 goto restartNoMS; 2769 2829 } 2770 2830 }
Note: See TracChangeset
for help on using the changeset viewer.