Ignore:
Timestamp:
Apr 1, 2014, 11:32:29 PM (10 years ago)
Author:
djay
Message:

Initial introduction of Value and Range in AllowedValues?, update zcfg documentation. Return valid Status code when returning ExceptionRepport?.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/zoo-project/zoo-kernel/service_internal.c

    r458 r459  
    883883
    884884void printFullDescription(elements *elem,const char* type,xmlNsPtr ns_ows,xmlNodePtr nc1){
    885   char *orderedFields[7];
     885  char *orderedFields[12];
    886886  orderedFields[0]="mimeType";
    887887  orderedFields[1]="encoding";
     
    891891  orderedFields[5]="CRS";
    892892  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;
    895900  elements* e=elem;
    896901  map* tmp1=NULL;
     
    956961      int dcnt=0;
    957962      int oI=0;
    958       for(oI=0;oI<7;oI++)
     963      for(oI=0;oI<12;oI++)
    959964        if((tmp1=getMap(_tmp->content,orderedFields[oI]))!=NULL){
    960965          //while(tmp1!=NULL){
     
    977982             strcasecmp(tmp1->name,"extension")!=0 &&
    978983             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){
    980986            if(datatype!=1){
    981987              char *tmp2=zCapitalize1(tmp1->name);
     
    993999          }else
    9941000            if(strncmp(type,"Input",5)==0){
     1001
    9951002              if(strcmp(tmp1->name,"value")==0){
    9961003                nc7 = xmlNewNode(NULL, BAD_CAST "DefaultValue");
    9971004                xmlAddChild(nc7,xmlNewText(BAD_CAST tmp1->value));
    9981005                default1=1;
     1006                hasDefault=true;
    9991007              }
    10001008              if(strncasecmp(tmp1->name,"AllowedValues",13)==0){
    10011009                nc6 = xmlNewNode(ns_ows, BAD_CAST "AllowedValues");
    1002                 fprintf(stderr,"ALLOWED VALUE %s\n",tmp1->value);
    10031010                char *token,*saveptr1;
    10041011                token=strtok_r(tmp1->value,",",&saveptr1);
     
    10081015                  tmps[strlen(tmps)]=0;
    10091016                  xmlAddChild(nc7,xmlNewText(BAD_CAST tmps));
    1010                   fprintf(stderr,"strgin : %s\n",tmps);
    10111017                  xmlAddChild(nc6,nc7);
    10121018                  token=strtok_r(NULL,",",&saveptr1);
    10131019                }
     1020                if(getMap(_tmp->content,"rangeMin")!=NULL ||
     1021                   getMap(_tmp->content,"rangeMax")!=NULL ||
     1022                   getMap(_tmp->content,"rangeClosure")!=NULL )
     1023                  goto doRange;
    10141024                xmlAddChild(nc3,nc6);
    10151025                isAnyValue=-1;
    10161026              }
    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              }
    10181075            }
    10191076          tmp1=tmp1->next;
     
    10261083            xmlAddChild(nc3,nc5);
    10271084          }
    1028          
    10291085          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){
    10361087              xmlAddChild(nc3,nc7);
    10371088            }
    10381089          }
    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      }
    10401099    }
    10411100
     
    11191178      xmlAddChild(nc3,nc4);
    11201179      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)
    11231182        xmlAddChild(nc3,xmlNewNode(ns_ows, BAD_CAST "AnyValue"));
    1124     }
     1183        }*/
    11251184   
    11261185    xmlAddChild(nc1,nc2);
     
    17721831  maps* tmpMap=getMaps(m,"main");
    17731832  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
    17741855  if(m!=NULL){
    17751856    map *tmpSid=getMapFromMaps(m,"lenv","sid");
     
    17771858      if( getpid()==atoi(tmpSid->value) ){
    17781859        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);
    17801861      }
    17811862    }
    17821863    else{
    17831864      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);
    17851866    }
    17861867  }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);
    17881869  }
    17891870  n=createExceptionReportNode(m,s,1);
     
    18291910  else
    18301911    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
    18311917
    18321918  tmp=getMap(s,"text");
     
    26302716    fcontent=(char*)malloc((res.nDataLen+1)*sizeof(char));
    26312717    if(fcontent == NULL){
    2632       return errorException(m, _("Unable to allocate memory."), "InternalError");
     2718      return errorException(m, _("Unable to allocate memory."), "InternalError",NULL);
    26332719    }
    26342720    size_t dwRead;
     
    26392725  }
    26402726  if(fsize==0){
    2641     return errorException(m, _("Unable to download the file."), "InternalError");
     2727    return errorException(m, _("Unable to download the file."), "InternalError",NULL);
    26422728  }
    26432729
     
    26682754}
    26692755
    2670 int errorException(maps *m, const char *message, const char *errorcode)
     2756int errorException(maps *m, const char *message, const char *errorcode, const char *locator)
    26712757{
    26722758  map* errormap = createMap("text", message);
    26732759  addToMap(errormap,"code", errorcode);
     2760  if(locator!=NULL)
     2761    addToMap(errormap,"locator", locator);
     2762  else
     2763    addToMap(errormap,"locator", "NULL");
    26742764  printExceptionReportResponse(m,errormap);
    26752765  freeMap(&errormap);
Note: See TracChangeset for help on using the changeset viewer.

Search

Context Navigation

ZOO Sponsors

http://www.zoo-project.org/trac/chrome/site/img/geolabs-logo.pnghttp://www.zoo-project.org/trac/chrome/site/img/neogeo-logo.png http://www.zoo-project.org/trac/chrome/site/img/apptech-logo.png http://www.zoo-project.org/trac/chrome/site/img/3liz-logo.png http://www.zoo-project.org/trac/chrome/site/img/gateway-logo.png

Become a sponsor !

Knowledge partners

http://www.zoo-project.org/trac/chrome/site/img/ocu-logo.png http://www.zoo-project.org/trac/chrome/site/img/gucas-logo.png http://www.zoo-project.org/trac/chrome/site/img/polimi-logo.png http://www.zoo-project.org/trac/chrome/site/img/fem-logo.png http://www.zoo-project.org/trac/chrome/site/img/supsi-logo.png http://www.zoo-project.org/trac/chrome/site/img/cumtb-logo.png

Become a knowledge partner

Related links

http://zoo-project.org/img/ogclogo.png http://zoo-project.org/img/osgeologo.png