Ignore:
Timestamp:
Dec 19, 2016, 6:01:06 PM (7 years ago)
Author:
djay
Message:

Add support for nested inputs and outputs.

File:
1 edited

Legend:

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

    r781 r790  
    6060  map *tmap = getMapType (tmpMaps->content);
    6161  elements *el = getElements (elem, mi->name);
     62  elements *cursor = elem;
     63  while(cursor!=NULL && el==NULL){
     64    if(cursor->child!=NULL)
     65      el = getElements (cursor->child, mi->name);
     66    cursor=cursor->next;
     67  }
    6268  int hasEl = 1;
    6369  if (el == NULL)
    6470    hasEl = -1;
     71
    6572  if (tmap == NULL)
    6673    {
     
    178185      }
    179186    }
     187    if(cursor->child!=NULL)
     188      ensureDecodedBase64(&cursor->child);
    180189    cursor=cursor->next;
    181190  }
     
    255264            if (tmpmaps == NULL)
    256265              {
    257                 tmpmaps = (maps *) malloc (MAPS_SIZE);
     266                tmpmaps = createMaps(tmpn);
    258267                if (tmpmaps == NULL)
    259268                  {
     
    263272                                           "InternalError", NULL);
    264273                  }
    265                 tmpmaps->name = zStrdup (tmpn);
    266274                if (tmpv != NULL)
    267275                  {
     
    433441                  if (tmp_output == NULL)
    434442                    {
    435                       tmp_output = (maps *) malloc (MAPS_SIZE);
     443                      tmp_output = createMaps(tmpc);
    436444                      if (tmp_output == NULL)
    437445                        {
     
    442450                                                 "InternalError", NULL);
    443451                        }
    444                       tmp_output->name = zStrdup (tmpc);
    445                       tmp_output->content = NULL;
    446                       tmp_output->next = NULL;
    447452                    }
    448453                }
     
    491496int defineMissingIdentifier(maps** main_conf,maps** mymaps){
    492497  if (*mymaps == NULL){
    493     *mymaps = (maps *) malloc (MAPS_SIZE);
     498    *mymaps = createMaps("missingIndetifier");
    494499    if (*mymaps == NULL){
    495500      return errorException (*main_conf,
     
    497502                             "InternalError", NULL);
    498503    }
    499     (*mymaps)->name = zStrdup ("missingIndetifier");
    500     (*mymaps)->content = NULL;
    501     (*mymaps)->next = NULL;
    502504  }
    503505  return 0;
     
    529531          // A specific Input node.
    530532          if(vid==1){
    531             tmpmaps = (maps *) malloc (MAPS_SIZE);
    532533            xmlChar *val = xmlGetProp (cur, BAD_CAST "id");
    533             tmpmaps->name = zStrdup ((char *) val);
    534             tmpmaps->content = NULL;
    535             tmpmaps->next = NULL;
     534            tmpmaps = createMaps((char *) val);
    536535          }
    537536
     
    552551                  if (tmpmaps == NULL && val!=NULL)
    553552                    {
    554                       tmpmaps = (maps *) malloc (MAPS_SIZE);
     553                      tmpmaps = createMaps((char*)val);
    555554                      if (tmpmaps == NULL)
    556555                        {
     
    560559                                                 "InternalError", NULL);
    561560                        }
    562                       tmpmaps->name = zStrdup ((char *) val);
    563                       tmpmaps->content = NULL;
    564                       tmpmaps->next = NULL;
    565561                      xmlFree (val);
    566562                    }
     
    586582                  }
    587583                }
    588               // InputDataFormChoice (Reference or Data ?)
    589               if (xmlStrcasecmp (cur2->name, BAD_CAST "Reference") == 0)
     584              // InputDataFormChoice (Reference or Data ?) / 2.0.0 DataInputType / Input
     585              if (xmlStrcasecmp (cur2->name, BAD_CAST "Input") == 0)
     586                {
     587                  char *xpathExpr=(char*)malloc(61+strlen(tmpmaps->name));
     588                  sprintf(xpathExpr,"/*/*[local-name()='Input' and @id='%s']/*[local-name()='Input']",tmpmaps->name);
     589                  xmlXPathObjectPtr tmpsptr = extractFromDoc (doc, xpathExpr);
     590                  xmlNodeSet *tmps = tmpsptr->nodesetval;
     591                  if(tmps!=NULL){
     592                    maps* request_output1=NULL;
     593                    if(xmlParseInputs(main_conf,s,&request_output1,doc,tmps,hInternet)<0)
     594                      return -1;
     595                    if(tmpmaps->child==NULL)
     596                      tmpmaps->child=dupMaps(&request_output1);
     597                    else
     598                      addMapsToMaps(&tmpmaps->child,request_output1);
     599                    freeMaps(&request_output1);
     600                    free(request_output1);
     601                  }
     602                  while(cur2->next!=NULL)
     603                    cur2=cur2->next;
     604                }
     605              else if (xmlStrcasecmp (cur2->name, BAD_CAST "Reference") == 0)
    590606                {
    591607                  defineMissingIdentifier(main_conf,&tmpmaps);
     
    848864                        cur4=cur4->next;
    849865                      if(cur4!=NULL){
    850                         if(cur4->content!=NULL)
     866                        if(cur4->content!=NULL){
    851867                          if (tmpmaps->content != NULL)
    852868                            addToMap (tmpmaps->content, "value",
     
    855871                            tmpmaps->content =
    856872                              createMap ("value", (char *) cur4->content);
     873                        }
    857874                        cur4=cur4->next;
    858875                      }
     
    955972                                     && cur5->type != XML_CDATA_SECTION_NODE)
    956973                                cur5 = cur5->next;
    957                               fprintf(stderr,"%s %d\n",__FILE__,__LINE__);
    958                               fflush(stderr);
    959974                              if (cur5 != NULL
    960975                                  && cur5->type != XML_CDATA_SECTION_NODE)
     
    10181033          {
    10191034            map* test=getMap(tmpmaps->content,"value");
    1020             if(test==NULL)
     1035            if(test==NULL && tmpmaps->child==NULL)
    10211036              addToMap(tmpmaps->content,"value","");
    1022             maps *testPresence =
    1023               getMaps (*request_output, tmpmaps->name);
     1037            maps *testPresence = getMaps (*request_output, tmpmaps->name);
     1038            maps *cursor=*request_output;
     1039            while(testPresence == NULL && cursor!=NULL){
     1040              if(cursor->child!=NULL){
     1041                testPresence = getMaps (cursor->child, tmpmaps->name);
     1042              }
     1043              cursor=cursor->next;
     1044            }
    10241045            if (testPresence != NULL)
    10251046              {
    10261047                elements *elem = getElements (s->inputs, tmpmaps->name);
     1048                elements *cursor=s->inputs;
     1049                while(elem == NULL && cursor!=NULL){
     1050                  if(cursor->child!=NULL){
     1051                    elem = getElements (cursor->child, tmpmaps->name);
     1052                  }
     1053                  cursor=cursor->next;
     1054                }
    10271055                if (elem != NULL)
    10281056                  {
    10291057                    if (appendMapsToMaps
    1030                         (*main_conf, *request_output, tmpmaps, elem) < 0)
     1058                        (*main_conf, testPresence, tmpmaps, elem) < 0)
    10311059                      {
    10321060                        return errorException (*main_conf,
     
    10661094    xmlNodePtr cur = nodes->nodeTab[k];
    10671095    if (cur->type == XML_ELEMENT_NODE){
    1068       maps *tmpmaps = (maps *) malloc (MAPS_SIZE);
     1096      maps *tmpmaps = NULL;
    10691097      xmlChar *val = xmlGetProp (cur, BAD_CAST "id");
    10701098      if(val!=NULL)
    1071         tmpmaps->name = zStrdup ((char*)val);
     1099        tmpmaps = createMaps((char *)val);
    10721100      else
    1073         tmpmaps->name = zStrdup ("unknownIdentifier");
    1074       tmpmaps->content = NULL;
    1075       tmpmaps->next = NULL;
     1101        tmpmaps = createMaps("unknownIdentifier");
    10761102      const char ress[4][13] =
    10771103        { "mimeType", "encoding", "schema", "transmission" };
     
    10911117        xmlFree (val);
    10921118      }
    1093       if (*request_output == NULL)
     1119      if(cur->children!=NULL){
     1120        xmlNodePtr ccur = cur->children;
     1121        while (ccur != NULL){
     1122          if(ccur->type == XML_ELEMENT_NODE){
     1123            char *xpathExpr=(char*)malloc(65+strlen(tmpmaps->name));
     1124            sprintf(xpathExpr,"/*/*[local-name()='Output' and @id='%s']/*[local-name()='Output']",tmpmaps->name);
     1125            xmlXPathObjectPtr tmpsptr = extractFromDoc (doc, xpathExpr);
     1126            xmlNodeSet* cnodes = tmpsptr->nodesetval;
     1127            xmlParseOutputs2(main_conf,request_inputs,&tmpmaps->child,doc,cnodes);
     1128            break;
     1129          }
     1130          ccur = ccur->next;
     1131        }
     1132      }
     1133      if (*request_output == NULL){
    10941134        *request_output = dupMaps(&tmpmaps);
    1095       else
     1135      }
     1136      else{
    10961137        addMapsToMaps(request_output,tmpmaps);
     1138      }
     1139      freeMaps(&tmpmaps);
     1140      free(tmpmaps);
    10971141    }
    10981142  }
     
    11191163        {
    11201164
    1121           maps *tmpmaps = (maps *) malloc (MAPS_SIZE);
     1165          maps *tmpmaps = createMaps("unknownIdentifier");
    11221166          if (tmpmaps == NULL)
    11231167            {
     
    11251169                                     "InternalError", NULL);
    11261170            }
    1127           tmpmaps->name = zStrdup ("unknownIdentifier");
    1128           tmpmaps->content = NULL;
    1129           tmpmaps->next = NULL;
    11301171
    11311172          // Get every attribute from a RawDataOutput node
     
    12101251            }
    12111252                               
    1212             maps *tmpmaps = (maps *) malloc (MAPS_SIZE); // one per Output node
     1253            maps *tmpmaps = createMaps("unknownIdentifier"); // one per Output node
    12131254            if (tmpmaps == NULL) {
    12141255              return errorException (*main_conf,
     
    12171258                                     "InternalError", NULL);
    12181259            }
    1219             tmpmaps->name = zStrdup ("unknownIdentifier");
    1220             tmpmaps->content = NULL;
    1221             tmpmaps->next = NULL;
    12221260                               
    12231261            xmlNodePtr elems = cur1->children;
     
    15131551  char *dfv1 =
    15141552    addDefaultValues (request_outputs, s->outputs, *main_conf, 1,&errO);
     1553
    15151554  if (strcmp (dfv1, "") != 0 || strcmp (dfv, "") != 0)
    15161555    {
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