Ignore:
Timestamp:
Oct 21, 2020, 6:31:09 PM (4 years ago)
Author:
djay
Message:

Update OGC API - Processes documentation and implementation, providing a browsable User Interface to Processes.

File:
1 edited

Legend:

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

    r954 r962  
    22 * Author : Gérald FENOY
    33 *
    4  *  Copyright 2017-2019 GeoLabs SARL. All rights reserved.
     4 *  Copyright 2017-2020 GeoLabs SARL. All rights reserved.
    55 *
    66 * Permission is hereby granted, free of charge, to any person obtaining a copy
     
    223223      if(tmpMap1!=NULL){
    224224        json_object_object_add(prop2,"name",json_object_new_string(tmpMap1->value));
     225        char *tmp=(char*)malloc((strlen(tmpMap1->value)+35)*sizeof(char));
     226        sprintf(tmp,"http://www.w3.org/TR/xmlschema-2/#%s",tmpMap1->value);
     227        json_object_object_add(prop2,"reference",json_object_new_string(tmp));
     228        free(tmp);
    225229        json_object_object_add(prop1,"dataType",prop2);
    226230      }
     
    371375      tmpMap=getMap(in->content,"abstract");
    372376      if(tmpMap!=NULL)
    373         json_object_object_add(input,"abstract",json_object_new_string(tmpMap->value));
     377        json_object_object_add(input,"description",json_object_new_string(tmpMap->value));
    374378      if(strcmp(io,"input")==0){
    375379        tmpMap=getMap(in->content,"minOccurs");
    376380        if(tmpMap!=NULL)
    377           json_object_object_add(input,"minOccurs",json_object_new_string(tmpMap->value));
     381          json_object_object_add(input,"minOccurs",json_object_new_int(atoi(tmpMap->value)));
    378382        tmpMap=getMap(in->content,"maxOccurs");
    379         if(tmpMap!=NULL)
    380           json_object_object_add(input,"maxOccurs",json_object_new_string(tmpMap->value));
     383        if(tmpMap!=NULL){
     384          if(strncasecmp(tmpMap->value,"unbounded",9)==0)
     385            json_object_object_add(input,"maxOccurs",json_object_new_string(tmpMap->value));
     386          else
     387            json_object_object_add(input,"maxOccurs",json_object_new_int(atoi(tmpMap->value)));
     388        }
    381389      }
    382390      if(in->format!=NULL){
     
    439447    json_object* doc=(json_object*) doc0;
    440448    json_object* nc=(json_object*) nc0;
    441     json_object *res=json_object_new_object();
     449    json_object *res;
     450    if(doc!=NULL)
     451      res=json_object_new_object();
     452    else
     453      res=(json_object*) nc0;
     454     
    442455    map* tmpMap0=getMapFromMaps(m,"lenv","level");
    443456    char* rUrl=serv->name;
     
    486499      tmpMap=getMap(serv->content,"abstract");
    487500      if(tmpMap!=NULL){
    488         json_object_object_add(res,"abstract",json_object_new_string(tmpMap->value));
     501        json_object_object_add(res,"description",json_object_new_string(tmpMap->value));
    489502      }
    490503      tmpMap=getMap(serv->content,"processVersion");
     
    498511        else
    499512          json_object_object_add(res,"version",json_object_new_string(tmpMap->value));
    500       }
     513      }else
     514        json_object_object_add(res,"version",json_object_new_string("1.0.0"));
    501515      int limit=4;
    502516      int i=0;
     
    517531      json_object *res1=json_object_new_array();
    518532      json_object *res2=json_object_new_object();
    519       json_object_object_add(res2,"rel",json_object_new_string("canonical"));
     533      json_object *res3=json_object_new_object();
     534      map* pmTmp=getMapFromMaps(m,"lenv","requestType");
     535      if(pmTmp!=NULL && strncasecmp(pmTmp->value,"desc",4)==0)
     536        json_object_object_add(res2,"rel",json_object_new_string("process-desc"));
     537      else{
     538        json_object_object_add(res2,"rel",json_object_new_string("execute"));
     539        json_object_object_add(res3,"rel",json_object_new_string("alternate"));
     540        json_object_object_add(res3,"type",json_object_new_string("text/html"));
     541      }
    520542      json_object_object_add(res2,"type",json_object_new_string("application/json"));
    521543      json_object_object_add(res2,"title",json_object_new_string("Process Description"));
     
    525547      if(doc==NULL){
    526548        json_object_object_add(res2,"title",json_object_new_string("Execute End Point"));
     549        json_object_object_add(res3,"title",json_object_new_string("Execute End Point"));
    527550        char* tmpStr1=zStrdup(tmpStr);
    528551        tmpStr=(char*) realloc(tmpStr,(strlen(tmpStr)+6)*sizeof(char));
    529         sprintf(tmpStr,"%sjobs/",tmpStr1);
     552        sprintf(tmpStr,"%sjobs",tmpStr1);
    530553        free(tmpStr1);
     554        char* tmpStr3=(char*) malloc((strlen(tmpStr)+6)*sizeof(char));
     555        sprintf(tmpStr3,"%s.html",tmpStr);
     556        json_object_object_add(res3,"href",json_object_new_string(tmpStr3));
     557        free(tmpStr3);
    531558      }
    532559      json_object_object_add(res2,"href",json_object_new_string(tmpStr));
    533560      free(tmpStr);
    534561      json_object_array_add(res1,res2);
     562      tmpUrl=getMapFromMaps(m,"openapi","partial_html_support");
     563      if(tmpUrl!=NULL && strncasecmp(tmpUrl->value,"true",4)==0)
     564        json_object_array_add(res1,res3);
     565      else
     566        json_object_put(res3);
    535567      json_object_object_add(res,"links",res1);
    536568    }
     
    551583    if(doc!=NULL)
    552584      json_object_array_add(doc,res);
    553     else
    554       json_object_object_add(nc,"process",json_object_get(res));
    555 
    556585  }
    557586
     
    577606      if(strcmp(tmp->value,"OperationNotSupported")==0 ||
    578607         strcmp(tmp->value,"NoApplicableCode")==0)
    579         exceptionCode="501 Not Implemented";
     608        exceptionCode="500 Not Implemented";
    580609      else
    581610        if(strcmp(tmp->value,"MissingParameterValue")==0 ||
     
    586615          exceptionCode="400 Bad request";
    587616        else
    588           if(strcmp(tmp->value,"NotFound")==0)
     617          if(strcmp(tmp->value,"NotFound")==0 ||
     618             strcmp(tmp->value,"NoSuchProcess")==0 ||
     619             strcmp(tmp->value,"NoSuchJob")==0 ||
     620             strcmp(tmp->value,"ResultNotReady")==0)
    589621            exceptionCode="404 Not Found";
    590622          else
    591             exceptionCode="501 Internal Server Error";
     623            exceptionCode="500 Internal Server Error";
    592624      json_object_object_add(res,"code",json_object_new_string(tmp->value));
    593625    }
    594     else
    595       exceptionCode="501 Internal Server Error";
    596     printHeaders(m);
     626    else{
     627      exceptionCode="500 Internal Server Error";
     628      json_object_object_add(res,"code",json_object_new_string("NoApplicableCode"));
     629    }
     630    if(getMapFromMaps(m,"lenv","no-headers")==NULL)
     631      printHeaders(m);
    597632
    598633    tmp=getMapFromMaps(m,"lenv","status_code");
    599634    if(tmp!=NULL)
    600635      exceptionCode=tmp->value;
    601     if(m!=NULL){
    602       map *tmpSid=getMapFromMaps(m,"lenv","sid");
    603       if(tmpSid!=NULL){
    604         if( getpid()==atoi(tmpSid->value) ){
     636    if(getMapFromMaps(m,"lenv","no-headers")==NULL){
     637      if(m!=NULL){
     638        map *tmpSid=getMapFromMaps(m,"lenv","sid");
     639        if(tmpSid!=NULL){
     640          if( getpid()==atoi(tmpSid->value) ){
     641            printf("Status: %s\r\n\r\n",exceptionCode);
     642          }
     643        }
     644        else{
    605645          printf("Status: %s\r\n\r\n",exceptionCode);
    606646        }
    607       }
    608       else{
     647      }else{
    609648        printf("Status: %s\r\n\r\n",exceptionCode);
    610649      }
    611     }else{
    612       printf("Status: %s\r\n\r\n",exceptionCode);
    613650    }
    614651    tmp=getMap(s,"text");
     
    620657      json_object_object_add(res,"description",json_object_new_string(tmp->value));
    621658    const char* jsonStr=json_object_to_json_string_ext(res,JSON_C_TO_STRING_PLAIN);
     659    if(getMapFromMaps(m,"lenv","jsonStr")==NULL)
     660      setMapInMaps(m,"lenv","jsonStr",jsonStr);
     661    maps* pmsTmp=getMaps(m,"lenv");
    622662    printf(jsonStr);
    623663    if(m!=NULL)
     
    876916   * @param outputs the produced maps
    877917   */
    878   void parseJRequest(maps* conf, service* s,json_object* req,maps** inputs,maps** outputs){
     918  void parseJRequest(maps* conf, service* s,json_object* req, map* request_inputs, maps** inputs,maps** outputs){
    879919    elements* io=s->inputs;
    880920
     
    890930        parseJIO(conf,req,s->outputs,outputs,"outputs");
    891931      }
    892     }     
     932      json_io=NULL;
     933      if(json_object_object_get_ex(req,"mode",&json_io)!=FALSE){
     934        addToMap(request_inputs,"mode",json_object_get_string(json_io));
     935        setMapInMaps(conf,"request","mode",json_object_get_string(json_io));
     936      }
     937      json_io=NULL;
     938      if(json_object_object_get_ex(req,"response",&json_io)!=FALSE){
     939        addToMap(request_inputs,"response",json_object_get_string(json_io));
     940        setMapInMaps(conf,"request","response",json_object_get_string(json_io));
     941      }
     942      json_io=NULL;
     943      if(json_object_object_get_ex(req,"subscriber",&json_io)!=FALSE){
     944        maps* subscribers=createMaps("subscriber");
     945        json_object* json_subscriber=NULL;
     946        if(json_object_object_get_ex(json_io,"successUri",&json_subscriber)!=FALSE){
     947          subscribers->content=createMap("successUri",json_object_get_string(json_subscriber));
     948        }
     949        if(json_object_object_get_ex(json_io,"inProgressUri",&json_subscriber)!=FALSE){
     950          if(subscribers->content==NULL)
     951            subscribers->content=createMap("inProgressUri",json_object_get_string(json_subscriber));
     952          else
     953            addToMap(subscribers->content,"inProgressUri",json_object_get_string(json_subscriber));
     954        }
     955        if(json_object_object_get_ex(json_io,"failedUri",&json_subscriber)!=FALSE){
     956          if(subscribers->content==NULL)
     957            subscribers->content=createMap("failedUri",json_object_get_string(json_subscriber));
     958          else
     959            addToMap(subscribers->content,"failedUri",json_object_get_string(json_subscriber));
     960        }
     961        addMapsToMaps(&conf,subscribers);
     962        freeMaps(&subscribers);
     963        free(subscribers);
     964      }
     965    }
     966   
    893967  }
    894968
     
    9341008            if (jerr != json_tokener_success) {
    9351009              fprintf(stderr, "Error: %s\n", json_tokener_error_desc(jerr));
    936               return res;
     1010              return NULL;
    9371011            }
    9381012            if (tok->char_offset < slen){
    939               return res;
     1013              return NULL;
    9401014            }
    9411015            json_object_object_add(cjob,"infos",jobj);
     
    9511025    return res;
    9521026  }
    953 
     1027 
    9541028  /**
    9551029   * Print the result of an execution
     
    9581032   * @param s service pointer to metadata
    9591033   * @param result outputs of the service
    960    * @param res the status of executino SERVICE_FAILED/SERVICE_SUCCEEDED
     1034   * @param res the status of execution SERVICE_FAILED/SERVICE_SUCCEEDED
    9611035   * @return the JSON object pointer to the result
    9621036   */
    9631037  json_object* printJResult(maps* conf,service* s,maps* result,int res){
    964     printHeaders(conf);
    9651038    json_object* eres1=json_object_new_object();
     1039    if(res==SERVICE_FAILED){
     1040      char* pacTmp=produceErrorMessage(conf);
     1041      map* pamTmp=createMap("message",pacTmp);
     1042      free(pacTmp);
     1043      map* pmTmp=getMapFromMaps(conf,"lenv","code");
     1044      if(pmTmp!=NULL)
     1045        addToMap(pamTmp,"code",pmTmp->value);
     1046      printExceptionReportResponseJ(conf,pamTmp);
     1047      freeMap(&pamTmp);
     1048      free(pamTmp);
     1049      return NULL;
     1050    }
     1051    if(getMapFromMaps(conf,"lenv","no-headers")==NULL)
     1052      printHeaders(conf);
    9661053    json_object* eres=json_object_new_array();
    9671054    maps* resu=result;
     
    9701057      json_object* res1=json_object_new_object();
    9711058      json_object_object_add(res1,"id",json_object_new_string(resu->name));
    972       map* tmpMap=NULL;
     1059      map* tmpMap=getMap(resu->content,"mimeType");
     1060      json_object* res3=json_object_new_object();
     1061      if(tmpMap!=NULL)
     1062        json_object_object_add(res3,"mimeType",json_object_new_string(tmpMap->value));
    9731063      if((tmpMap=getMap(resu->content,"value"))!=NULL ||
    9741064         (getMap(resu->content,"generated_file"))!=NULL){
     
    9941084                return eres1;           
    9951085              }
     1086              json_object_object_add(res3,"encoding",json_object_new_string("utf-8"));
    9961087              json_object_object_add(res2,"inlineValue",jobj);
    997             }else
    998               json_object_object_add(res2,"inlineValue",json_object_new_string(tmpMap->value));
     1088            }else{
     1089              map* tmp1=getMapFromMaps(conf,"main","tmpPath");
     1090              map *gfile=getMap(resu->content,"generated_file");
     1091              if(gfile!=NULL){
     1092                gfile=getMap(resu->content,"expected_generated_file");
     1093                if(gfile==NULL){
     1094                  gfile=getMap(resu->content,"generated_file");
     1095                }
     1096                FILE* pfData=fopen(gfile->value,"rb");
     1097                if(pfData!=NULL){
     1098                  zStatStruct f_status;
     1099                  int s=zStat(gfile->value, &f_status);
     1100                  char* pcaTmp=(char*)malloc((f_status.st_size+1)*sizeof(char));
     1101                  fread(pcaTmp,1,f_status.st_size,pfData);
     1102                  pcaTmp[f_status.st_size]=0;       
     1103                  fclose(pfData);
     1104                  json_object_object_add(res2,"inlineValue",json_object_new_string(base64(pcaTmp,f_status.st_size)));
     1105                  json_object_object_add(res3,"encoding",json_object_new_string("base64"));
     1106                  free(pacTmp);
     1107                }
     1108              }else{
     1109                json_object_object_add(res3,"encoding",json_object_new_string("utf-8"));
     1110                json_object_object_add(res2,"inlineValue",json_object_new_string(tmpMap->value));
     1111              }
     1112            }
    9991113          }
    10001114          else{
     
    10981212        }
    10991213        json_object_object_add(res1,"value",res2);     
     1214        json_object_object_add(res1,"format",res3);     
    11001215        json_object_array_add(eres,res1);
    11011216      }
     
    11081223    map *cIdentifier = getMapFromMaps (conf, "lenv", "oIdentifier");
    11091224    map *sessId = getMapFromMaps (conf, "lenv", "usid");
    1110     char tmp[1024];
    1111     sprintf(tmp,"%s/%s_%s.json",
     1225    char *pacTmp=(char*)malloc((strlen(tmpPath->value)+strlen(cIdentifier->value)+strlen(sessId->value)+8)*sizeof(char));
     1226    sprintf(pacTmp,"%s/%s_%s.json",
    11121227            tmpPath->value,cIdentifier->value,sessId->value);
    1113     FILE* foutput=fopen(tmp,"w+");
    1114     if(foutput!=NULL){
    1115       fclose(foutput);
    1116       char tmpUrl[1024];
     1228    zStatStruct zsFStatus;
     1229    int iS=zStat(pacTmp, &zsFStatus);
     1230    if(iS==0 && zsFStatus.st_size>0){
    11171231      map* tmpPath1 = getMapFromMaps (conf, "main", "tmpUrl");
    1118       sprintf(tmpUrl,"%s/%s_%s.json",tmpPath1->value,
     1232      char* pacTmpUrl=(char*)malloc((strlen(tmpPath1->value)+strlen(cIdentifier->value)+strlen(sessId->value)+8)*sizeof(char));;
     1233      sprintf(pacTmpUrl,"%s/%s_%s.json",tmpPath1->value,
    11191234              cIdentifier->value,sessId->value);
    1120       setMapInMaps(conf,"headers","Location",tmpUrl);
    1121     }
     1235      if(getMapFromMaps(conf,"lenv","gs_location")==NULL)
     1236        setMapInMaps(conf,"headers","Location",pacTmpUrl);
     1237      free(pacTmpUrl);
     1238    }
     1239    free(pacTmp);
    11221240    if(res==3){
    1123       setMapInMaps(conf,"headers","Status","201 Created");
     1241      map* mode=getMapFromMaps(conf,"request","mode");
     1242      if(mode!=NULL && strncasecmp(mode->value,"async",5)==0)
     1243        setMapInMaps(conf,"headers","Status","201 Created");
     1244      else
     1245        setMapInMaps(conf,"headers","Status","200 Ok");
    11241246    }
    11251247    else{
    11261248      setMapInMaps(conf,"headers","Status","500 Issue running your service");
    11271249    }
    1128 
    11291250    return eres1;
    11301251  }
     
    11441265    map *cIdentifier = getMapFromMaps (conf, "lenv", "oIdentifier");
    11451266    map *sessId = getMapFromMaps (conf, "lenv", "usid");
     1267    if(sessId==NULL){
     1268      sessId = getMapFromMaps (conf, "lenv", "gs_usid");
     1269    }
    11461270    char *Url0=(char*) malloc((strlen(tmpPath->value)+
    11471271                               strlen(cIdentifier->value)+
     
    11531277            cIdentifier->value,
    11541278            sessId->value);
    1155     setMapInMaps(conf,"headers","Location",Url0);
     1279    if(getMapFromMaps(conf,"lenv","gs_location")==NULL)
     1280      setMapInMaps(conf,"headers","Location",Url0);
    11561281    json_object* val=json_object_new_object();
    1157     json_object_object_add(val,"Title",
     1282    json_object_object_add(val,"title",
    11581283                           json_object_new_string(_("Status location")));
     1284    json_object_object_add(val,"rel",
     1285                           json_object_new_string(_("status")));
     1286    json_object_object_add(val,"type",
     1287                           json_object_new_string(_("application/json")));
    11591288    json_object_object_add(val,"href",json_object_new_string(Url0));
    11601289    json_object_array_add(res,val);
     
    11641293                           strlen(cIdentifier->value)+strlen(sessId->value)+
    11651294                           25)*sizeof(char));
    1166       sprintf(Url0,"%s/processes/%s/jobs/%s/result",
     1295      sprintf(Url0,"%s/processes/%s/jobs/%s/results",
    11671296              tmpPath->value,
    11681297              cIdentifier->value,
    11691298              sessId->value);
    11701299      json_object* val1=json_object_new_object();
    1171       json_object_object_add(val1,"Title",
     1300      json_object_object_add(val1,"title",
    11721301                             json_object_new_string(_("Result location")));
     1302      json_object_object_add(val1,"rel",
     1303                             json_object_new_string(_("results")));
     1304      json_object_object_add(val1,"type",
     1305                             json_object_new_string(_("application/json")));
    11731306      json_object_object_add(val1,"href",json_object_new_string(Url0));
    11741307      json_object_array_add(res,val1);
     
    12041337      return NULL;
    12051338    }
    1206     free(tmp1);
    1207     tmp1=(char*) malloc((strlen(tmpPath->value)+
     1339    tmp1=(char*) realloc(tmp1,(strlen(tmpPath->value)+
    12081340                         strlen(cIdentifier->value)+
    1209                          strlen(sessId->value)+20)*sizeof(char));
     1341                         strlen(sessId->value)+21)*sizeof(char));
    12101342    int needResult=0;
    12111343    char *message, *rstatus;
     
    12141346            cIdentifier->value,
    12151347            sessId->value);
    1216    
    12171348    return tmp1;
    12181349  }
     1350
     1351  char* getResultPath(maps* conf,char* jobId){
     1352    map *tmpPath = getMapFromMaps (conf, "main", "tmpPath");
     1353    map *cIdentifier = getMapFromMaps (conf, "lenv", "oIdentifier");
     1354    char *pacUrl=(char*) malloc((strlen(tmpPath->value)+
     1355                                 strlen(cIdentifier->value)+
     1356                                 strlen(jobId)+8)*sizeof(char));
     1357    sprintf(pacUrl,"%s/%s_%s.json",tmpPath->value,
     1358            cIdentifier->value,jobId);
     1359    return pacUrl;
     1360  }
     1361
     1362  json_object* parseJson(maps* conf,char* myString){
     1363    json_object *pajObj = NULL;
     1364    enum json_tokener_error jerr;
     1365    struct json_tokener* tok=json_tokener_new();
     1366    int slen = 0;
     1367    do {
     1368      slen = strlen(myString);
     1369      pajObj = json_tokener_parse_ex(tok, myString, slen);
     1370    } while ((jerr = json_tokener_get_error(tok)) == json_tokener_continue);
     1371    if (jerr != json_tokener_success) {
     1372      setMapInMaps(conf,"lenv","message",json_tokener_error_desc(jerr));
     1373      fprintf(stderr, "Error: %s\n", json_tokener_error_desc(jerr));
     1374      return NULL;
     1375    }
     1376    if (tok->char_offset < slen){
     1377      return NULL;
     1378    }
     1379    return pajObj;
     1380  }
    12191381 
    1220   /**
    1221    * Create the status file
    1222    *
    1223    * @param conf the maps containing the settings of the main.cfg file
    1224    * @param status an integer (SERVICE_ACCEPTED,SERVICE_STARTED...)
    1225    * @return an integer (0 in case of success, 1 in case of failure)
    1226    */
    1227   int createStatusFile(maps* conf,int status){
     1382  json_object* json_readFile(maps* conf,char* filePath){
     1383    json_object *pajObj = NULL;
     1384    zStatStruct zsFStatus;
     1385    int iS=zStat(filePath, &zsFStatus);
     1386    if(iS==0 && zsFStatus.st_size>0){
     1387      FILE* cdat=fopen(filePath,"rb");
     1388      if(cdat!=NULL){
     1389        char* pacMyString=(char*)malloc((zsFStatus.st_size+1)*sizeof(char));
     1390        fread(pacMyString,1,zsFStatus.st_size,cdat);
     1391        pacMyString[zsFStatus.st_size]=0;
     1392        fclose(cdat);
     1393        pajObj=parseJson(conf,pacMyString);
     1394        free(pacMyString);
     1395      }
     1396      else
     1397        return NULL;
     1398    }else
     1399      return NULL;
     1400    return pajObj;
     1401  }
     1402 
     1403  json_object* createStatus(maps* conf,int status){
    12281404    int needResult=0;
    1229     const char *message, *rstatus;
    1230     char* tmp1=json_getStatusFilePath(conf);
     1405    const char *rstatus;
     1406    char *message;
    12311407    // Create statusInfo JSON object
    12321408    // cf. https://github.com/opengeospatial/wps-rest-binding/blob/master/core/
    12331409    //     openapi/schemas/statusInfo.yaml
    12341410    json_object* res=json_object_new_object();
    1235     json_object_object_add(res,"status",json_object_new_string("successful"));
    12361411    switch(status){
    12371412    case SERVICE_ACCEPTED:
     
    12441419      {
    12451420        message=_("ZOO-Kernel is currently running your service!");
     1421        map* pmStatus=getMapFromMaps(conf,"lenv","status");
     1422        if(pmStatus!=NULL)
     1423          setMapInMaps(conf,"lenv","PercentCompleted",pmStatus->value);
     1424        pmStatus=getMapFromMaps(conf,"lenv","message");
     1425        if(pmStatus!=NULL)
     1426          setMapInMaps(conf,"lenv","gs_message",pmStatus->value);
    12461427        rstatus="running";
    12471428        break;
     
    12571438        message=_("ZOO-Kernel successfully run your service!");
    12581439        rstatus="successful";
     1440        setMapInMaps(conf,"lenv","PercentCompleted","100");
    12591441        needResult=1;
    12601442        break;
    12611443      }
     1444    case SERVICE_DISMISSED:
     1445      {
     1446        message=_("ZOO-Kernel successfully dismissed your service!");
     1447        rstatus="dismissed";
     1448        needResult=1;
     1449        break;
     1450      }
    12621451    default:
    12631452      {
    1264         message=_("ZOO-Kernel failed to run your service!");
     1453        map* pmTmp=getMapFromMaps(conf,"lenv","force");
     1454        if(pmTmp==NULL || strncasecmp(pmTmp->value,"false",5)==0){
     1455          char* pacTmp=json_getStatusFilePath(conf);
     1456          json_object* pjoStatus=json_readFile(conf,pacTmp);
     1457          free(pacTmp);
     1458          if(pjoStatus!=NULL){
     1459            json_object* pjoMessage=NULL;
     1460            if(json_object_object_get_ex(pjoStatus,"message",&pjoMessage)!=FALSE){
     1461              message=(char*)json_object_get_string(pjoMessage);
     1462            }
     1463          }
     1464          // TODO: Error
     1465        }else{
     1466          map* mMap=getMapFromMaps(conf,"lenv","gs_message");
     1467          if(mMap!=NULL)
     1468            setMapInMaps(conf,"lenv","message",mMap->value);
     1469          message=produceErrorMessage(conf);
     1470          needResult=-1;
     1471        }
    12651472        rstatus="failed";
    12661473        break;
     
    12691476    setMapInMaps(conf,"lenv","message",message);
    12701477    setMapInMaps(conf,"lenv","status",rstatus);
    1271        
    1272     map* mess=getMapFromMaps(conf,"lenv","message");
    1273     if(mess!=NULL)
    1274       json_object_object_add(res,"message",json_object_new_string(mess->value));
    1275 
    1276     createStatusLinks(conf,needResult,res);
    1277    
     1478
     1479    map *sessId = getMapFromMaps (conf, "lenv", "usid");
     1480    if(sessId!=NULL){
     1481      sessId = getMapFromMaps (conf, "lenv", "gs_usid");
     1482      if(sessId==NULL)
     1483        sessId = getMapFromMaps (conf, "lenv", "usid");
     1484    }else
     1485      sessId = getMapFromMaps (conf, "lenv", "gs_usid");
     1486    if(sessId!=NULL)
     1487      json_object_object_add(res,"jobID",json_object_new_string(sessId->value));
     1488    json_object_object_add(res,"status",json_object_new_string(rstatus));
     1489    map* mMap=getMapFromMaps(conf,"lenv","gs_message");
     1490    if(mMap==NULL)
     1491      json_object_object_add(res,"message",json_object_new_string(message));
     1492    else{
     1493      json_object_object_add(res,"message",json_object_new_string(mMap->value));
     1494      if((mMap=getMapFromMaps(conf,"lenv","PercentCompleted"))!=NULL)
     1495        json_object_object_add(res,"progress",json_object_new_int(atoi(mMap->value)));
     1496    }
     1497    if(status!=SERVICE_DISMISSED)
     1498      createStatusLinks(conf,needResult,res);
     1499    else{
     1500      json_object* res1=json_object_new_array();
     1501      map *tmpPath = getMapFromMaps (conf, "openapi", "rootUrl");
     1502      map *cIdentifier = getMapFromMaps (conf, "lenv", "oIdentifier");
     1503      char *Url0=(char*) malloc((strlen(tmpPath->value)+
     1504                                 strlen(cIdentifier->value)+
     1505                                 17)*sizeof(char));
     1506      sprintf(Url0,"%s/processes/%s/jobs",           
     1507              tmpPath->value,
     1508              cIdentifier->value);
     1509      json_object* val=json_object_new_object();
     1510      json_object_object_add(val,"title",
     1511                             json_object_new_string(_("The job list for the current process")));
     1512      json_object_object_add(val,"rel",
     1513                             json_object_new_string(_("parent")));
     1514      json_object_object_add(val,"type",
     1515                             json_object_new_string(_("application/json")));
     1516      json_object_object_add(val,"href",json_object_new_string(Url0));
     1517      json_object_array_add(res1,val);
     1518      free(Url0);
     1519      json_object_object_add(res,"links",res1);
     1520    }
     1521    if(needResult<0)
     1522      free(message);
     1523    return res;
     1524  }
     1525 
     1526  /**
     1527   * Create the status file
     1528   *
     1529   * @param conf the maps containing the settings of the main.cfg file
     1530   * @param status an integer (SERVICE_ACCEPTED,SERVICE_STARTED...)
     1531   * @return an integer (0 in case of success, 1 in case of failure)
     1532   */
     1533  int createStatusFile(maps* conf,int status){
     1534    json_object* res=createStatus(conf,status);
     1535    char* tmp1=json_getStatusFilePath(conf);
    12781536    FILE* foutput1=fopen(tmp1,"w+");
    12791537    if(foutput1!=NULL){
     
    13031561    map* tmpMap=getMapFromMaps(conf,"lenv","gs_usid");
    13041562    if(tmpMap!=NULL){
    1305         char* tmpStr=_getStatus(conf,tmpMap->value);
    1306         if(tmpStr!=NULL && strncmp(tmpStr,"-1",2)!=0){
    1307           char *tmpStr1=zStrdup(tmpStr);
    1308           char *tmpStr0=zStrdup(strstr(tmpStr,"|")+1);
    1309           free(tmpStr);
    1310           tmpStr1[strlen(tmpStr1)-strlen(tmpStr0)-1]='\0';
    1311           setMapInMaps(conf,"lenv","PercentCompleted",tmpStr1);
    1312           setMapInMaps(conf,"lenv","gs_message",tmpStr0);
    1313           free(tmpStr0);
    1314           free(tmpStr1);
    1315         }
    1316       }
     1563      char* tmpStr=_getStatus(conf,tmpMap->value);
     1564      if(tmpStr!=NULL && strncmp(tmpStr,"-1",2)!=0){
     1565        char *tmpStr1=zStrdup(tmpStr);
     1566        char *tmpStr0=zStrdup(strstr(tmpStr,"|")+1);
     1567        free(tmpStr);
     1568        tmpStr1[strlen(tmpStr1)-strlen(tmpStr0)-1]='\0';
     1569        setMapInMaps(conf,"lenv","PercentCompleted",tmpStr1);
     1570        setMapInMaps(conf,"lenv","gs_message",tmpStr0);
     1571        free(tmpStr0);
     1572        free(tmpStr1);
     1573        return 0;
     1574      }else{
     1575         
     1576      }
     1577    }
    13171578  }
    13181579
     
    13711632
    13721633    json_object *res4=json_object_new_object();
    1373     tmpMap=getMapFromMaps(conf,"main","license_name");
     1634    tmpMap=getMapFromMaps(conf,"openapi","license_name");
    13741635    if(tmpMap!=NULL){
    13751636      json_object_object_add(res4,"name",json_object_new_string(tmpMap->value));
    1376       tmpMap=getMapFromMaps(conf,"main","license_url");
     1637      tmpMap=getMapFromMaps(conf,"openapi","license_url");
    13771638      if(tmpMap!=NULL){
    13781639        json_object_object_add(res4,"url",json_object_new_string(tmpMap->value));     
     
    13841645  }
    13851646
     1647  // addResponse(pmUseContent,cc3,vMap,tMap,"200","successful operation");
     1648  void addResponse(const map* useContent,json_object* res,const map* pmSchema,const map* pmType,const char* code,const char* msg){
     1649    json_object *cc=json_object_new_object();
     1650    if(pmSchema!=NULL)
     1651      json_object_object_add(cc,"$ref",json_object_new_string(pmSchema->value));
     1652    if(useContent!=NULL && strncasecmp(useContent->value,"true",4)!=0){
     1653        json_object_object_add(res,code,cc);
     1654    }else{
     1655        json_object *cc0=json_object_new_object();
     1656        if(pmSchema!=NULL)
     1657          json_object_object_add(cc0,"schema",cc);
     1658        json_object *cc1=json_object_new_object();
     1659        if(pmType!=NULL)
     1660          json_object_object_add(cc1,pmType->value,cc0);
     1661        else
     1662          json_object_object_add(cc1,"application/json",cc0);
     1663        json_object *cc2=json_object_new_object();
     1664        json_object_object_add(cc2,"content",cc1);
     1665        json_object_object_add(cc2,"description",json_object_new_string(msg));
     1666        json_object_object_add(res,code,cc2);
     1667    }
     1668  }
     1669
     1670  void addParameter(maps* conf,const char* oName,const char* fName,const char* in,json_object* res){
     1671    maps* tmpMaps1=getMaps(conf,oName);
     1672    json_object *res8=json_object_new_object();
     1673    if(tmpMaps1!=NULL){
     1674      map* tmpMap=getMap(tmpMaps1->content,"title");
     1675      if(tmpMap!=NULL)
     1676        json_object_object_add(res8,"x-internal-summary",json_object_new_string(tmpMap->value));
     1677      tmpMap=getMap(tmpMaps1->content,"abstract");
     1678      if(tmpMap!=NULL)
     1679        json_object_object_add(res8,"description",json_object_new_string(tmpMap->value));
     1680      tmpMap=getMap(tmpMaps1->content,"example");
     1681      if(tmpMap!=NULL)
     1682        json_object_object_add(res8,"example",json_object_new_string(tmpMap->value));
     1683      tmpMap=getMap(tmpMaps1->content,"required");
     1684      if(tmpMap!=NULL){
     1685        if(strcmp(tmpMap->value,"true")==0)
     1686          json_object_object_add(res8,"required",json_object_new_boolean(TRUE));
     1687        else
     1688          json_object_object_add(res8,"required",json_object_new_boolean(FALSE));
     1689      }
     1690      else
     1691        json_object_object_add(res8,"required",json_object_new_boolean(FALSE));
     1692      json_object_object_add(res8,"in",json_object_new_string(in));
     1693      json_object_object_add(res8,"name",json_object_new_string(fName));
     1694      json_object *res6=json_object_new_object();
     1695      tmpMap=getMap(tmpMaps1->content,"type");
     1696      if(tmpMap!=NULL)
     1697        json_object_object_add(res6,"type",json_object_new_string(tmpMap->value));
     1698      else
     1699        json_object_object_add(res6,"type",json_object_new_string("string"));
     1700       
     1701      json_object_object_add(res8,"schema",res6);
     1702       
     1703    }   
     1704    json_object_object_add(res,fName,res8);   
     1705  }
     1706 
    13861707  /**
    13871708   * Produce the JSON object for api parameter
     
    13971718    char *tmps12 = strtok_r (tmpMap2->value, ",", &saveptr12);
    13981719    while(tmps12!=NULL){
    1399       char* tmpId=(char*) malloc((strlen(tmps12)+3)*sizeof(char));
    1400       sprintf(tmpId,"{%s}",tmps12);
    1401       tmpMaps1=getMaps(conf,tmpId);
    1402       json_object *res8=json_object_new_object();
    1403       if(tmpMaps1!=NULL){
    1404         map* tmpMap=getMap(tmpMaps1->content,"title");
    1405         if(tmpMap!=NULL)
    1406           json_object_object_add(res8,"x-internal-summary",json_object_new_string(tmpMap->value));
    1407         tmpMap=getMap(tmpMaps1->content,"abstract");
    1408         if(tmpMap!=NULL)
    1409           json_object_object_add(res8,"description",json_object_new_string(tmpMap->value));
    1410         tmpMap=getMap(tmpMaps1->content,"example");
    1411         if(tmpMap!=NULL)
    1412           json_object_object_add(res8,"example",json_object_new_string(tmpMap->value));
    1413         tmpMap=getMap(tmpMaps1->content,"required");
    1414         if(tmpMap!=NULL){
    1415           if(strcmp(tmpMap->value,"true")==0)
    1416             json_object_object_add(res8,"required",json_object_new_boolean(TRUE));
    1417           else
    1418             json_object_object_add(res8,"required",json_object_new_boolean(FALSE));
    1419         }
    1420         else
    1421           json_object_object_add(res8,"required",json_object_new_boolean(FALSE));
    1422         json_object_object_add(res8,"in",json_object_new_string("path"));
    1423         json_object_object_add(res8,"name",json_object_new_string(tmps12));
    1424         json_object *res6=json_object_new_object();
    1425         json_object *res7=json_object_new_object();
    1426         tmpMap=getMap(tmpMaps1->content,"type");
    1427         if(tmpMap!=NULL)
    1428           json_object_object_add(res6,"type",json_object_new_string(tmpMap->value));
    1429         else
    1430           json_object_object_add(res6,"type",json_object_new_string("string"));
    1431        
    1432         json_object_object_add(res8,"schema",res6);
    1433        
    1434       }
    1435        
    1436       json_object_object_add(res9,tmps12,res8);
     1720      char* pacId=(char*) malloc((strlen(tmps12)+3)*sizeof(char));
     1721      sprintf(pacId,"{%s}",tmps12);
     1722      addParameter(conf,pacId,tmps12,"path",res9);
     1723      free(pacId);
    14371724      tmps12 = strtok_r (NULL, ",", &saveptr12);
    14381725    }   
    14391726    tmpMap2=getMapFromMaps(conf,"openapi","header_parameters");
    1440     char *saveptr13;
    1441     char *tmps13 = strtok_r (tmpMap2->value, ",", &saveptr13);
    1442     while(tmps13!=NULL){
    1443       char* tmpId=zStrdup(tmps13);
    1444       maps *tmpMaps2=getMaps(conf,tmpId);
    1445       json_object *res8=json_object_new_object();
    1446       if(tmpMaps2!=NULL){
    1447         map* tmpMap=getMap(tmpMaps2->content,"title");
    1448         if(tmpMap!=NULL)
    1449           json_object_object_add(res8,"x-internal-summary",json_object_new_string(tmpMap->value));
    1450         tmpMap=getMap(tmpMaps2->content,"abstract");
    1451         if(tmpMap!=NULL)
    1452           json_object_object_add(res8,"description",json_object_new_string(tmpMap->value));
    1453         tmpMap=getMap(tmpMaps2->content,"example");
    1454         if(tmpMap!=NULL)
    1455           json_object_object_add(res8,"example",json_object_new_string(tmpMap->value));
    1456         tmpMap=getMap(tmpMaps2->content,"required");
    1457         if(tmpMap!=NULL){
    1458           if(strcmp(tmpMap->value,"true")==0)
    1459             json_object_object_add(res8,"required",json_object_new_boolean(TRUE));
    1460           else
    1461             json_object_object_add(res8,"required",json_object_new_boolean(FALSE));
    1462         }
    1463         else
    1464           json_object_object_add(res8,"required",json_object_new_boolean(FALSE));
    1465         json_object_object_add(res8,"in",json_object_new_string("header"));
    1466         tmpMap=getMap(tmpMaps2->content,"name");
    1467         if(tmpMap!=NULL)
    1468           json_object_object_add(res8,"name",json_object_new_string(tmpMap->value));
    1469         json_object *res6=json_object_new_object();
    1470         json_object *res7=json_object_new_object();
    1471         tmpMap=getMap(tmpMaps2->content,"type");
    1472         if(tmpMap!=NULL)
    1473           json_object_object_add(res6,"type",json_object_new_string(tmpMap->value));
    1474         else
    1475           json_object_object_add(res6,"type",json_object_new_string("string"));
    1476 
    1477         {
    1478           tmpMap=getMap(tmpMaps2->content,"enum");
    1479           if(tmpMap!=NULL){
    1480             char *saveptr11;
    1481             char *tmps11 = strtok_r (tmpMap->value, ",", &saveptr11);
    1482             json_object *res71=json_object_new_array();
    1483             while(tmps11!=NULL){               
    1484               json_object_array_add(res71,json_object_new_string(tmps11));
    1485               tmps11 = strtok_r (NULL, ",", &saveptr11);
    1486             }
    1487             json_object_object_add(res6,"enum",res71);                           
    1488           }
    1489         }
    1490        
    1491         json_object_object_add(res8,"schema",res6);
    1492        
    1493       }
    1494        
    1495       json_object_object_add(res9,tmpId,res8);
    1496       tmps13 = strtok_r (NULL, ",", &saveptr13);
    1497     }
    1498     json_object_object_add(res,"parameters",res9);   
     1727    if(tmpMap2!=NULL){
     1728      char *saveptr13;
     1729      char *tmps13 = strtok_r (tmpMap2->value, ",", &saveptr13);
     1730      while(tmps13!=NULL){
     1731        char* pacId=zStrdup(tmps13);
     1732        addParameter(conf,pacId,pacId,"header",res9);
     1733        free(pacId);
     1734        tmps13 = strtok_r (NULL, ",", &saveptr13);
     1735      }
     1736    }
     1737    json_object_object_add(res,"parameters",res9);
     1738    maps* pmResponses=getMaps(conf,"responses");
     1739    if(pmResponses!=NULL){
     1740      json_object *cc=json_object_new_object();
     1741      map* pmLen=getMap(pmResponses->content,"length");
     1742      int iLen=atoi(pmLen->value);
     1743      map* pmUseContent=getMapFromMaps(conf,"openapi","use_content");
     1744      for(int i=0;i<iLen;i++){
     1745        map* cMap=getMapArray(pmResponses->content,"code",i);
     1746        map* vMap=getMapArray(pmResponses->content,"schema",i);
     1747        map* tMap=getMapArray(pmResponses->content,"type",i);
     1748        map* tMap0=getMapArray(pmResponses->content,"title",i);
     1749        if(vMap!=NULL)
     1750          addResponse(pmUseContent,cc,vMap,tMap,cMap->value,(tMap0==NULL)?"successful operation":tMap0->value);
     1751      }
     1752      json_object_object_add(res,"responses",cc);
     1753    }
    14991754  }
    15001755
     
    15041759    json_object_object_add(res,"components",res1);
    15051760  }
    1506 
     1761 
    15071762  /**
    15081763   * Produce the JSON object for /api
     
    15121767   */
    15131768  void produceApi(maps* conf,json_object* res){
     1769    // TODO: add 401 Gone for dismiss request
    15141770    json_object *res9=json_object_new_object();
    15151771    json_object *res10=json_object_new_object();
    15161772    maps* tmpMaps1=getMaps(conf,"{id}");
    1517 
    15181773    produceApiComponents(conf,res);
    15191774    json_object *res4=json_object_new_object();
     
    15621817            json_object *responses=json_object_new_object();
    15631818            json_object *cc3=json_object_new_object();
     1819            map* pmUseContent=getMapFromMaps(conf,"openapi","use_content");
    15641820            vMap=getMapArray(tmpMaps->content,"schema",i);
    15651821            if(vMap!=NULL){
    1566               json_object *cc=json_object_new_object();
    1567               json_object_object_add(cc,"$ref",json_object_new_string(vMap->value));
    1568               json_object *cc0=json_object_new_object();
    1569               json_object_object_add(cc0,"schema",cc);
    1570               json_object *cc1=json_object_new_object();
    1571               map* tmpMap3=getMapFromMaps(conf,tmps,"type");
    1572               if(tmpMap3!=NULL)
    1573                 json_object_object_add(cc1,tmpMap3->value,cc0);
    1574               else
    1575                 json_object_object_add(cc1,"application/json",cc0);
    1576               json_object *cc2=json_object_new_object();
    1577               json_object_object_add(cc2,"content",cc1);
    1578               json_object_object_add(cc2,"description",json_object_new_string("successful operation"));
    1579               if(i==1)
    1580                 json_object_object_add(cc3,"201",cc2);
    1581               else
    1582                 json_object_object_add(cc3,"200",cc2);
     1822              map* tMap=getMapArray(tmpMaps->content,"type",i);
     1823              addResponse(pmUseContent,cc3,vMap,tMap,"200","successful operation");
     1824              vMap=getMapArray(tmpMaps->content,"eschema",i);
     1825              if(vMap!=NULL && cMap!=NULL && strncasecmp(cMap->value,"post",4)==0)
     1826                addResponse(pmUseContent,cc3,vMap,tMap,"201","successful operation");
    15831827            }else{
    1584               json_object *cc1=json_object_new_object();
    1585               map* tmpMap3=getMapFromMaps(conf,tmps,"type");
    1586               if(tmpMap3!=NULL)
    1587                 json_object_object_add(cc1,tmpMap3->value,json_object_new_object());
    1588               else
    1589                 json_object_object_add(cc1,"application/json",json_object_new_object());
    1590               json_object *cc2=json_object_new_object();
    1591               json_object_object_add(cc2,"content",cc1);
    1592               json_object_object_add(cc2,"description",json_object_new_string("successful operation"));
    1593               if(i==1)
    1594                 json_object_object_add(cc3,"201",cc2);
    1595               else
    1596                 json_object_object_add(cc3,"200",cc2);
     1828              map* tMap=getMapFromMaps(conf,tmps,"type");
     1829              map* pMap=createMap("ok","true");
     1830              addResponse(pMap,cc3,vMap,tMap,"200","successful operation");
     1831              if(cMap!=NULL && strncasecmp(cMap->value,"post",4)==0)
     1832                addResponse(pmUseContent,cc3,vMap,tMap,"201","successful operation");
    15971833            }
    1598             if(strstr(tmps,"{id}")!=NULL){
    1599               vMap=getMapFromMaps(conf,"exception","schema");
    1600               json_object *cc=json_object_new_object();
    1601               json_object_object_add(cc,"$ref",json_object_new_string(vMap->value));
    1602               json_object *cc01=json_object_new_array();
    1603               json_object_array_add(cc01,cc);
    1604 
    1605               json_object *cc0=json_object_new_object();
    1606               json_object_object_add(cc0,"schema",cc);
    1607               json_object *cc1=json_object_new_object();
    1608               map* tmpMap3=getMapFromMaps(conf,"exception","type");
    1609               if(tmpMap3!=NULL)
    1610                 json_object_object_add(cc1,tmpMap3->value,cc0);
    1611               else
    1612                 json_object_object_add(cc1,"application/json",cc0);
    1613 
    1614               json_object *cc2=json_object_new_object();
    1615               json_object_object_add(cc2,"content",cc1);
    1616               if(strstr(tmps,"{jobID}")==NULL)
    1617                 json_object_object_add(cc2,"description",json_object_new_string("The process with id {id} does not exist."));
    1618               else
    1619                 json_object_object_add(cc2,"description",json_object_new_string("The process with id {id} or job with id {jobID} does not exist."));
    1620               json_object_object_add(cc3,"404",cc2);
    1621               json_object_object_add(cc3,"default",cc2);
     1834            vMap=getMapArray(tmpMaps->content,"ecode",i);
     1835            if(vMap!=NULL){
     1836              char *saveptr0;
     1837              char *tmps1 = strtok_r (vMap->value, ",", &saveptr0);
     1838              while(tmps1!=NULL){
     1839                char* tmpStr=(char*)malloc((strlen(tmps1)+24)*sizeof(char));
     1840                sprintf(tmpStr,"#/components/responses/%s",tmps1);
     1841                vMap=createMap("ok",tmpStr);
     1842                map* pMap=createMap("ok","false");
     1843                //TODO: fix successful operation with correct value
     1844                addResponse(pMap,cc3,vMap,NULL,tmps1,"successful operation");
     1845                tmps1 = strtok_r (NULL, ",", &saveptr0);
     1846              }
     1847            }else{
     1848              if(strstr(tmps,"{id}")!=NULL){
     1849                vMap=getMapFromMaps(conf,"exception","schema");
     1850                map* tMap=getMapFromMaps(conf,"exception","type");
     1851                if(vMap!=NULL)
     1852                  addResponse(pmUseContent,cc3,vMap,tMap,"404",
     1853                              (strstr(tmps,"{jobID}")==NULL)?"The process with id {id} does not exist.":"The process with id {id} or job with id {jobID} does not exist.");
     1854              }
    16221855            }
    16231856            json_object_object_add(methodc,"responses",cc3);
     
    16401873              json_object_object_add(methodc,"parameters",cc2);
    16411874            }
    1642             if(i==1){
     1875            if(i==1 && cMap!=NULL && strncasecmp(cMap->value,"post",4)==0){
    16431876              maps* tmpMaps1=getMaps(conf,"requestBody");
    16441877              if(tmpMaps1!=NULL){
     
    16631896                  json_object_object_add(methodc,"requestBody",cc2);
    16641897
     1898                }               
     1899              }
     1900              // TODO: callbacks
     1901              tmpMaps1=getMaps(conf,"callbacks");
     1902              if(tmpMaps1!=NULL){
     1903                map* pmTmp2=getMap(tmpMaps1->content,"length");
     1904                int iLen=atoi(pmTmp2->value);
     1905                json_object *pajRes=json_object_new_object();
     1906                for(int i=0;i<iLen;i++){
     1907                  map* pmState=getMapArray(tmpMaps1->content,"state",i);
     1908                  map* pmUri=getMapArray(tmpMaps1->content,"uri",i);
     1909                  map* pmSchema=getMapArray(tmpMaps1->content,"schema",i);
     1910                  map* pmType=getMapArray(tmpMaps1->content,"type",i);
     1911                  map* pmTitle=getMapArray(tmpMaps1->content,"title",i);
     1912                  json_object *pajSchema=json_object_new_object();
     1913                  if(pmSchema!=NULL)
     1914                    json_object_object_add(pajSchema,"$ref",json_object_new_string(pmSchema->value));
     1915                  json_object *pajType=json_object_new_object();
     1916                  json_object_object_add(pajType,"schema",pajSchema);
     1917                  json_object *pajContent=json_object_new_object();
     1918                  if(pmType!=NULL)
     1919                    json_object_object_add(pajContent,pmType->value,pajType);
     1920                  else           
     1921                    json_object_object_add(pajContent,"application/json",pajType);
     1922                  json_object *pajRBody=json_object_new_object();
     1923                  json_object_object_add(pajRBody,"content",pajContent);
     1924                 
     1925                  json_object *pajDescription=json_object_new_object();
     1926                  if(pmTitle!=NULL)
     1927                    json_object_object_add(pajDescription,"description",json_object_new_string(pmTitle->value));
     1928                  json_object *pajResponse=json_object_new_object();
     1929                  json_object_object_add(pajResponse,"200",pajDescription);
     1930
     1931                  json_object *pajPost=json_object_new_object();
     1932                  json_object_object_add(pajPost,"requestBody",pajRBody);
     1933                  json_object_object_add(pajPost,"responses",pajResponse);
     1934
     1935                  json_object *pajMethod=json_object_new_object();
     1936                  json_object_object_add(pajMethod,"post",pajPost);
     1937
     1938                 
     1939                  char* pacUri=(char*) malloc((strlen(pmUri->value)+29)*sizeof(char));
     1940                  sprintf(pacUri,"{$request.body#/subscriber/%s}",pmUri->value);
     1941
     1942                  json_object *pajFinal=json_object_new_object();
     1943                  json_object_object_add(pajFinal,pacUri,pajMethod);
     1944
     1945                  json_object_object_add(pajRes,pmState->value,pajFinal);
     1946
    16651947                }
     1948                json_object_object_add(methodc,"callbacks",pajRes);
    16661949              }
    16671950            }
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