Changeset 962 for trunk/zoo-project/zoo-kernel/service_json.c
- Timestamp:
- Oct 21, 2020, 6:31:09 PM (4 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/zoo-project/zoo-kernel/service_json.c
r954 r962 2 2 * Author : Gérald FENOY 3 3 * 4 * Copyright 2017-20 19GeoLabs SARL. All rights reserved.4 * Copyright 2017-2020 GeoLabs SARL. All rights reserved. 5 5 * 6 6 * Permission is hereby granted, free of charge, to any person obtaining a copy … … 223 223 if(tmpMap1!=NULL){ 224 224 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); 225 229 json_object_object_add(prop1,"dataType",prop2); 226 230 } … … 371 375 tmpMap=getMap(in->content,"abstract"); 372 376 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)); 374 378 if(strcmp(io,"input")==0){ 375 379 tmpMap=getMap(in->content,"minOccurs"); 376 380 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))); 378 382 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 } 381 389 } 382 390 if(in->format!=NULL){ … … 439 447 json_object* doc=(json_object*) doc0; 440 448 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 442 455 map* tmpMap0=getMapFromMaps(m,"lenv","level"); 443 456 char* rUrl=serv->name; … … 486 499 tmpMap=getMap(serv->content,"abstract"); 487 500 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)); 489 502 } 490 503 tmpMap=getMap(serv->content,"processVersion"); … … 498 511 else 499 512 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")); 501 515 int limit=4; 502 516 int i=0; … … 517 531 json_object *res1=json_object_new_array(); 518 532 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 } 520 542 json_object_object_add(res2,"type",json_object_new_string("application/json")); 521 543 json_object_object_add(res2,"title",json_object_new_string("Process Description")); … … 525 547 if(doc==NULL){ 526 548 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")); 527 550 char* tmpStr1=zStrdup(tmpStr); 528 551 tmpStr=(char*) realloc(tmpStr,(strlen(tmpStr)+6)*sizeof(char)); 529 sprintf(tmpStr,"%sjobs /",tmpStr1);552 sprintf(tmpStr,"%sjobs",tmpStr1); 530 553 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); 531 558 } 532 559 json_object_object_add(res2,"href",json_object_new_string(tmpStr)); 533 560 free(tmpStr); 534 561 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); 535 567 json_object_object_add(res,"links",res1); 536 568 } … … 551 583 if(doc!=NULL) 552 584 json_object_array_add(doc,res); 553 else554 json_object_object_add(nc,"process",json_object_get(res));555 556 585 } 557 586 … … 577 606 if(strcmp(tmp->value,"OperationNotSupported")==0 || 578 607 strcmp(tmp->value,"NoApplicableCode")==0) 579 exceptionCode="50 1Not Implemented";608 exceptionCode="500 Not Implemented"; 580 609 else 581 610 if(strcmp(tmp->value,"MissingParameterValue")==0 || … … 586 615 exceptionCode="400 Bad request"; 587 616 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) 589 621 exceptionCode="404 Not Found"; 590 622 else 591 exceptionCode="50 1Internal Server Error";623 exceptionCode="500 Internal Server Error"; 592 624 json_object_object_add(res,"code",json_object_new_string(tmp->value)); 593 625 } 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); 597 632 598 633 tmp=getMapFromMaps(m,"lenv","status_code"); 599 634 if(tmp!=NULL) 600 635 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{ 605 645 printf("Status: %s\r\n\r\n",exceptionCode); 606 646 } 607 } 608 else{ 647 }else{ 609 648 printf("Status: %s\r\n\r\n",exceptionCode); 610 649 } 611 }else{612 printf("Status: %s\r\n\r\n",exceptionCode);613 650 } 614 651 tmp=getMap(s,"text"); … … 620 657 json_object_object_add(res,"description",json_object_new_string(tmp->value)); 621 658 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"); 622 662 printf(jsonStr); 623 663 if(m!=NULL) … … 876 916 * @param outputs the produced maps 877 917 */ 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){ 879 919 elements* io=s->inputs; 880 920 … … 890 930 parseJIO(conf,req,s->outputs,outputs,"outputs"); 891 931 } 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 893 967 } 894 968 … … 934 1008 if (jerr != json_tokener_success) { 935 1009 fprintf(stderr, "Error: %s\n", json_tokener_error_desc(jerr)); 936 return res;1010 return NULL; 937 1011 } 938 1012 if (tok->char_offset < slen){ 939 return res;1013 return NULL; 940 1014 } 941 1015 json_object_object_add(cjob,"infos",jobj); … … 951 1025 return res; 952 1026 } 953 1027 954 1028 /** 955 1029 * Print the result of an execution … … 958 1032 * @param s service pointer to metadata 959 1033 * @param result outputs of the service 960 * @param res the status of executi noSERVICE_FAILED/SERVICE_SUCCEEDED1034 * @param res the status of execution SERVICE_FAILED/SERVICE_SUCCEEDED 961 1035 * @return the JSON object pointer to the result 962 1036 */ 963 1037 json_object* printJResult(maps* conf,service* s,maps* result,int res){ 964 printHeaders(conf);965 1038 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); 966 1053 json_object* eres=json_object_new_array(); 967 1054 maps* resu=result; … … 970 1057 json_object* res1=json_object_new_object(); 971 1058 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)); 973 1063 if((tmpMap=getMap(resu->content,"value"))!=NULL || 974 1064 (getMap(resu->content,"generated_file"))!=NULL){ … … 994 1084 return eres1; 995 1085 } 1086 json_object_object_add(res3,"encoding",json_object_new_string("utf-8")); 996 1087 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 } 999 1113 } 1000 1114 else{ … … 1098 1212 } 1099 1213 json_object_object_add(res1,"value",res2); 1214 json_object_object_add(res1,"format",res3); 1100 1215 json_object_array_add(eres,res1); 1101 1216 } … … 1108 1223 map *cIdentifier = getMapFromMaps (conf, "lenv", "oIdentifier"); 1109 1224 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", 1112 1227 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){ 1117 1231 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, 1119 1234 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); 1122 1240 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"); 1124 1246 } 1125 1247 else{ 1126 1248 setMapInMaps(conf,"headers","Status","500 Issue running your service"); 1127 1249 } 1128 1129 1250 return eres1; 1130 1251 } … … 1144 1265 map *cIdentifier = getMapFromMaps (conf, "lenv", "oIdentifier"); 1145 1266 map *sessId = getMapFromMaps (conf, "lenv", "usid"); 1267 if(sessId==NULL){ 1268 sessId = getMapFromMaps (conf, "lenv", "gs_usid"); 1269 } 1146 1270 char *Url0=(char*) malloc((strlen(tmpPath->value)+ 1147 1271 strlen(cIdentifier->value)+ … … 1153 1277 cIdentifier->value, 1154 1278 sessId->value); 1155 setMapInMaps(conf,"headers","Location",Url0); 1279 if(getMapFromMaps(conf,"lenv","gs_location")==NULL) 1280 setMapInMaps(conf,"headers","Location",Url0); 1156 1281 json_object* val=json_object_new_object(); 1157 json_object_object_add(val," Title",1282 json_object_object_add(val,"title", 1158 1283 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"))); 1159 1288 json_object_object_add(val,"href",json_object_new_string(Url0)); 1160 1289 json_object_array_add(res,val); … … 1164 1293 strlen(cIdentifier->value)+strlen(sessId->value)+ 1165 1294 25)*sizeof(char)); 1166 sprintf(Url0,"%s/processes/%s/jobs/%s/result ",1295 sprintf(Url0,"%s/processes/%s/jobs/%s/results", 1167 1296 tmpPath->value, 1168 1297 cIdentifier->value, 1169 1298 sessId->value); 1170 1299 json_object* val1=json_object_new_object(); 1171 json_object_object_add(val1," Title",1300 json_object_object_add(val1,"title", 1172 1301 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"))); 1173 1306 json_object_object_add(val1,"href",json_object_new_string(Url0)); 1174 1307 json_object_array_add(res,val1); … … 1204 1337 return NULL; 1205 1338 } 1206 free(tmp1); 1207 tmp1=(char*) malloc((strlen(tmpPath->value)+ 1339 tmp1=(char*) realloc(tmp1,(strlen(tmpPath->value)+ 1208 1340 strlen(cIdentifier->value)+ 1209 strlen(sessId->value)+2 0)*sizeof(char));1341 strlen(sessId->value)+21)*sizeof(char)); 1210 1342 int needResult=0; 1211 1343 char *message, *rstatus; … … 1214 1346 cIdentifier->value, 1215 1347 sessId->value); 1216 1217 1348 return tmp1; 1218 1349 } 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 } 1219 1381 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){ 1228 1404 int needResult=0; 1229 const char * message, *rstatus;1230 char * tmp1=json_getStatusFilePath(conf);1405 const char *rstatus; 1406 char *message; 1231 1407 // Create statusInfo JSON object 1232 1408 // cf. https://github.com/opengeospatial/wps-rest-binding/blob/master/core/ 1233 1409 // openapi/schemas/statusInfo.yaml 1234 1410 json_object* res=json_object_new_object(); 1235 json_object_object_add(res,"status",json_object_new_string("successful"));1236 1411 switch(status){ 1237 1412 case SERVICE_ACCEPTED: … … 1244 1419 { 1245 1420 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); 1246 1427 rstatus="running"; 1247 1428 break; … … 1257 1438 message=_("ZOO-Kernel successfully run your service!"); 1258 1439 rstatus="successful"; 1440 setMapInMaps(conf,"lenv","PercentCompleted","100"); 1259 1441 needResult=1; 1260 1442 break; 1261 1443 } 1444 case SERVICE_DISMISSED: 1445 { 1446 message=_("ZOO-Kernel successfully dismissed your service!"); 1447 rstatus="dismissed"; 1448 needResult=1; 1449 break; 1450 } 1262 1451 default: 1263 1452 { 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 } 1265 1472 rstatus="failed"; 1266 1473 break; … … 1269 1476 setMapInMaps(conf,"lenv","message",message); 1270 1477 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); 1278 1536 FILE* foutput1=fopen(tmp1,"w+"); 1279 1537 if(foutput1!=NULL){ … … 1303 1561 map* tmpMap=getMapFromMaps(conf,"lenv","gs_usid"); 1304 1562 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 } 1317 1578 } 1318 1579 … … 1371 1632 1372 1633 json_object *res4=json_object_new_object(); 1373 tmpMap=getMapFromMaps(conf," main","license_name");1634 tmpMap=getMapFromMaps(conf,"openapi","license_name"); 1374 1635 if(tmpMap!=NULL){ 1375 1636 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"); 1377 1638 if(tmpMap!=NULL){ 1378 1639 json_object_object_add(res4,"url",json_object_new_string(tmpMap->value)); … … 1384 1645 } 1385 1646 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 1386 1707 /** 1387 1708 * Produce the JSON object for api parameter … … 1397 1718 char *tmps12 = strtok_r (tmpMap2->value, ",", &saveptr12); 1398 1719 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); 1437 1724 tmps12 = strtok_r (NULL, ",", &saveptr12); 1438 1725 } 1439 1726 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 } 1499 1754 } 1500 1755 … … 1504 1759 json_object_object_add(res,"components",res1); 1505 1760 } 1506 1761 1507 1762 /** 1508 1763 * Produce the JSON object for /api … … 1512 1767 */ 1513 1768 void produceApi(maps* conf,json_object* res){ 1769 // TODO: add 401 Gone for dismiss request 1514 1770 json_object *res9=json_object_new_object(); 1515 1771 json_object *res10=json_object_new_object(); 1516 1772 maps* tmpMaps1=getMaps(conf,"{id}"); 1517 1518 1773 produceApiComponents(conf,res); 1519 1774 json_object *res4=json_object_new_object(); … … 1562 1817 json_object *responses=json_object_new_object(); 1563 1818 json_object *cc3=json_object_new_object(); 1819 map* pmUseContent=getMapFromMaps(conf,"openapi","use_content"); 1564 1820 vMap=getMapArray(tmpMaps->content,"schema",i); 1565 1821 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"); 1583 1827 }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"); 1597 1833 } 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 } 1622 1855 } 1623 1856 json_object_object_add(methodc,"responses",cc3); … … 1640 1873 json_object_object_add(methodc,"parameters",cc2); 1641 1874 } 1642 if(i==1 ){1875 if(i==1 && cMap!=NULL && strncasecmp(cMap->value,"post",4)==0){ 1643 1876 maps* tmpMaps1=getMaps(conf,"requestBody"); 1644 1877 if(tmpMaps1!=NULL){ … … 1663 1896 json_object_object_add(methodc,"requestBody",cc2); 1664 1897 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 1665 1947 } 1948 json_object_object_add(methodc,"callbacks",pajRes); 1666 1949 } 1667 1950 }
Note: See TracChangeset
for help on using the changeset viewer.