Changeset 654 for trunk/zoo-project
- Timestamp:
- Jun 15, 2015, 1:47:59 PM (10 years ago)
- Location:
- trunk/zoo-project
- Files:
-
- 2 added
- 12 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/zoo-project/HISTORY.txt
r652 r654 1 1 Version 1.5.0-dev 2 * Initial support for WPS 2.0.0 including the Dismiss extension 2 3 * Fix concurrency access to status informations 3 4 * Use simple file rather than shared memory for storing status informations -
trunk/zoo-project/zoo-kernel/request_parser.c
r640 r654 496 496 int k = 0; 497 497 int l = 0; 498 map* version=getMapFromMaps(*main_conf,"main","rversion"); 499 int vid=getVersionId(version->value); 498 500 for (k=0; k < nodes->nodeNr; k++) 499 501 { … … 504 506 { 505 507 // A specific Input node. 508 if(vid==1){ 509 tmpmaps = (maps *) malloc (MAPS_SIZE); 510 xmlChar *val = xmlGetProp (cur, BAD_CAST "id"); 511 tmpmaps->name = zStrdup ((char *) val); 512 tmpmaps->content = NULL; 513 tmpmaps->next = NULL; 514 } 515 506 516 xmlNodePtr cur2 = cur->children; 507 517 while (cur2 != NULL) … … 805 815 { 806 816 xmlNodePtr cur4 = cur2->children; 817 if(vid==1){ 818 // Get every dataEncodingAttributes from a Data node: 819 // mimeType, encoding, schema 820 const char *coms[3] = 821 { "mimeType", "encoding", "schema" }; 822 for (l = 0; l < 3; l++){ 823 xmlChar *val = 824 xmlGetProp (cur4, BAD_CAST coms[l]); 825 if (val != NULL && strlen ((char *) val) > 0){ 826 if (tmpmaps->content != NULL) 827 addToMap (tmpmaps->content,coms[l],(char *) val); 828 else 829 tmpmaps->content = 830 createMap (coms[l],(char *) val); 831 } 832 xmlFree (val); 833 } 834 while (cur4 != NULL){ 835 while(cur4 != NULL && 836 cur4->type != XML_CDATA_SECTION_NODE && 837 cur4->type != XML_TEXT_NODE) 838 cur4=cur4->next; 839 if(cur4!=NULL){ 840 if(cur4->content!=NULL) 841 if (tmpmaps->content != NULL) 842 addToMap (tmpmaps->content, "value", 843 (char *) cur4->content); 844 else 845 tmpmaps->content = 846 createMap ("value", (char *) cur4->content); 847 cur4=cur4->next; 848 } 849 } 850 } 851 852 807 853 while (cur4 != NULL) 808 854 { … … 897 943 while (cur5 != NULL 898 944 && cur5->type != XML_ELEMENT_NODE 899 && cur5->type != 900 XML_CDATA_SECTION_NODE) 945 && cur5->type != XML_CDATA_SECTION_NODE) 901 946 cur5 = cur5->next; 902 947 if (cur5 != NULL … … 995 1040 996 1041 /** 1042 * Parse outputs from XML nodes and store them in a maps (WPS version 2.0.0). 1043 * 1044 * @param main_conf the conf maps containing the main.cfg settings 1045 * @param request_inputs the map storing KVP raw value 1046 * @param request_output the maps to store the KVP pairs 1047 * @param doc the xmlDocPtr containing the original request 1048 * @param cur the xmlNodePtr corresponding to the ResponseDocument or RawDataOutput XML node 1049 * @param raw true if the node is RawDataOutput, false in case of ResponseDocument 1050 * @return 0 on success, -1 on failure 1051 */ 1052 int xmlParseOutputs2(maps** main_conf,map** request_inputs,maps** request_output,xmlDocPtr doc,xmlNodeSet* nodes){ 1053 int k = 0; 1054 int l = 0; 1055 for (k=0; k < nodes->nodeNr; k++){ 1056 maps *tmpmaps = NULL; 1057 xmlNodePtr cur = nodes->nodeTab[k]; 1058 if (cur->type == XML_ELEMENT_NODE){ 1059 maps *tmpmaps = (maps *) malloc (MAPS_SIZE); 1060 xmlChar *val = xmlGetProp (cur, BAD_CAST "id"); 1061 if(val!=NULL) 1062 tmpmaps->name = zStrdup ((char*)val); 1063 else 1064 tmpmaps->name = zStrdup ("unknownIdentifier"); 1065 tmpmaps->content = NULL; 1066 tmpmaps->next = NULL; 1067 const char ress[4][13] = 1068 { "mimeType", "encoding", "schema", "transmission" }; 1069 for (l = 0; l < 4; l++){ 1070 val = xmlGetProp (cur, BAD_CAST ress[l]); 1071 if (val != NULL && strlen ((char *) val) > 0) 1072 { 1073 if (tmpmaps->content != NULL) 1074 addToMap (tmpmaps->content, ress[l], 1075 (char *) val); 1076 else 1077 tmpmaps->content = 1078 createMap (ress[l], (char *) val); 1079 if(l==3 && strncasecmp((char*)val,"reference",xmlStrlen(val))==0) 1080 addToMap (tmpmaps->content,"asReference","true"); 1081 } 1082 xmlFree (val); 1083 } 1084 if (*request_output == NULL) 1085 *request_output = dupMaps(&tmpmaps); 1086 else 1087 addMapsToMaps(request_output,tmpmaps); 1088 } 1089 } 1090 } 1091 1092 /** 997 1093 * Parse outputs from XML nodes and store them in a maps. 998 1094 * … … 1225 1321 */ 1226 1322 int xmlParseRequest(maps** main_conf,const char* post,map** request_inputs,service* s,maps** inputs,maps** outputs,HINTERNET* hInternet){ 1323 1324 map* version=getMapFromMaps(*main_conf,"main","rversion"); 1325 int vid=getVersionId(version->value); 1326 1227 1327 xmlInitParser (); 1228 1328 xmlDocPtr doc = xmlParseMemory (post, cgiContentLength); … … 1232 1332 */ 1233 1333 xmlXPathObjectPtr tmpsptr = 1234 extractFromDoc (doc, "/*/*/*[local-name()='Input']");1334 extractFromDoc (doc, (vid==0?"/*/*/*[local-name()='Input']":"/*/*[local-name()='Input']")); 1235 1335 xmlNodeSet *tmps = tmpsptr->nodesetval; 1236 if( xmlParseInputs(main_conf,s,inputs,doc,tmps,hInternet)<0){1336 if(tmps==NULL || xmlParseInputs(main_conf,s,inputs,doc,tmps,hInternet)<0){ 1237 1337 xmlXPathFreeObject (tmpsptr); 1238 1338 xmlFreeDoc (doc); … … 1242 1342 xmlXPathFreeObject (tmpsptr); 1243 1343 1244 // Extract ResponseDocument / RawDataOutput from the XML Request 1245 tmpsptr = 1246 extractFromDoc (doc, "/*/*/*[local-name()='ResponseDocument']"); 1247 bool asRaw = false; 1248 tmps = tmpsptr->nodesetval; 1249 if (tmps->nodeNr == 0) 1250 { 1251 xmlXPathFreeObject (tmpsptr); 1252 tmpsptr = 1253 extractFromDoc (doc, "/*/*/*[local-name()='RawDataOutput']"); 1254 tmps = tmpsptr->nodesetval; 1255 asRaw = true; 1256 } 1257 if(tmps->nodeNr != 0){ 1258 if(xmlParseOutputs(main_conf,request_inputs,outputs,doc,tmps->nodeTab[0],asRaw)<0){ 1259 xmlXPathFreeObject (tmpsptr); 1260 xmlFreeDoc (doc); 1261 xmlCleanupParser (); 1262 return -1; 1344 if(vid==1){ 1345 tmpsptr = 1346 extractFromDoc (doc, "/*[local-name()='Execute']"); 1347 bool asRaw = false; 1348 tmps = tmpsptr->nodesetval; 1349 if(tmps->nodeNr > 0){ 1350 int k = 0; 1351 for (k=0; k < tmps->nodeNr; k++){ 1352 maps *tmpmaps = NULL; 1353 xmlNodePtr cur = tmps->nodeTab[k]; 1354 if (cur->type == XML_ELEMENT_NODE){ 1355 xmlChar *val = xmlGetProp (cur, BAD_CAST "mode"); 1356 if(val!=NULL) 1357 addToMap(*request_inputs,"mode",(char*)val); 1358 else 1359 addToMap(*request_inputs,"mode","auto"); 1360 val = xmlGetProp (cur, BAD_CAST "response"); 1361 if(val!=NULL){ 1362 addToMap(*request_inputs,"response",(char*)val); 1363 if(strncasecmp((char*)val,"raw",xmlStrlen(val))==0) 1364 addToMap(*request_inputs,"RawDataOutput",""); 1365 else 1366 addToMap(*request_inputs,"ResponseDocument",""); 1367 } 1368 else{ 1369 addToMap(*request_inputs,"response","document"); 1370 addToMap(*request_inputs,"ResponseDocument",""); 1371 } 1372 } 1373 } 1374 } 1375 xmlXPathFreeObject (tmpsptr); 1376 tmpsptr = 1377 extractFromDoc (doc, "/*/*[local-name()='Output']"); 1378 tmps = tmpsptr->nodesetval; 1379 if(tmps->nodeNr > 0){ 1380 if(xmlParseOutputs2(main_conf,request_inputs,outputs,doc,tmps)<0){ 1381 xmlXPathFreeObject (tmpsptr); 1382 xmlFreeDoc (doc); 1383 xmlCleanupParser (); 1384 return -1; 1385 } 1386 } 1387 } 1388 else{ 1389 // Extract ResponseDocument / RawDataOutput from the XML Request 1390 tmpsptr = 1391 extractFromDoc (doc, "/*/*/*[local-name()='ResponseDocument']"); 1392 bool asRaw = false; 1393 tmps = tmpsptr->nodesetval; 1394 if (tmps->nodeNr == 0) 1395 { 1396 xmlXPathFreeObject (tmpsptr); 1397 tmpsptr = 1398 extractFromDoc (doc, "/*/*/*[local-name()='RawDataOutput']"); 1399 tmps = tmpsptr->nodesetval; 1400 asRaw = true; 1401 } 1402 if(tmps->nodeNr != 0){ 1403 if(xmlParseOutputs(main_conf,request_inputs,outputs,doc,tmps->nodeTab[0],asRaw)<0){ 1404 xmlXPathFreeObject (tmpsptr); 1405 xmlFreeDoc (doc); 1406 xmlCleanupParser (); 1407 return -1; 1408 } 1263 1409 } 1264 1410 } -
trunk/zoo-project/zoo-kernel/response_print.c
r652 r654 1455 1455 1456 1456 doc = xmlNewDoc(BAD_CAST "1.0"); 1457 map* version=getMap(request,"version"); 1458 n = printWPSHeader(doc,m,"Execute","ExecuteResponse",(version!=NULL?version->value:"1.0.0"),2); 1459 int wpsId=zooXmlAddNs(NULL,"http://www.opengis.net/wps/1.0.0","wps"); 1457 map* version=getMapFromMaps(m,"main","rversion"); 1458 int vid=getVersionId(version->value); 1459 n = printWPSHeader(doc,m,"Execute",root_nodes[vid][2],(version!=NULL?version->value:"1.0.0"),2); 1460 int wpsId=zooXmlAddNs(NULL,schemas[vid][2],"wps"); 1460 1461 ns=usedNs[wpsId]; 1461 int owsId=zooXmlAddNs(NULL, "http://www.opengis.net/ows/1.1","ows");1462 int owsId=zooXmlAddNs(NULL,schemas[vid][1],"ows"); 1462 1463 ns_ows=usedNs[owsId]; 1463 1464 int xlinkId=zooXmlAddNs(NULL,"http://www.w3.org/1999/xlink","xlink"); 1464 1465 ns_xlink=usedNs[xlinkId]; 1465 1466 char tmp[256]; 1467 char url[1024]; 1466 bool hasStoredExecuteResponse=false; 1468 1467 char stored_path[1024]; 1469 memset(tmp,0,256);1470 memset(url,0,1024);1471 1468 memset(stored_path,0,1024); 1472 maps* tmp_maps=getMaps(m,"main"); 1473 if(tmp_maps!=NULL){ 1474 map* tmpm1=getMap(tmp_maps->content,"serverAddress"); 1475 /** 1476 * Check if the ZOO Service GetStatus is available in the local directory. 1477 * If yes, then it uses a reference to an URL which the client can access 1478 * to get information on the status of a running Service (using the 1479 * percentCompleted attribute). 1480 * Else fallback to the initial method using the xml file to write in ... 1481 */ 1482 char ntmp[1024]; 1469 1470 if(vid==0){ 1471 char tmp[256]; 1472 char url[1024]; 1473 memset(tmp,0,256); 1474 memset(url,0,1024); 1475 maps* tmp_maps=getMaps(m,"main"); 1476 if(tmp_maps!=NULL){ 1477 map* tmpm1=getMap(tmp_maps->content,"serverAddress"); 1478 /** 1479 * Check if the ZOO Service GetStatus is available in the local directory. 1480 * If yes, then it uses a reference to an URL which the client can access 1481 * to get information on the status of a running Service (using the 1482 * percentCompleted attribute). 1483 * Else fallback to the initial method using the xml file to write in ... 1484 */ 1485 char ntmp[1024]; 1483 1486 #ifndef WIN32 1484 getcwd(ntmp,1024);1487 getcwd(ntmp,1024); 1485 1488 #else 1486 _getcwd(ntmp,1024);1489 _getcwd(ntmp,1024); 1487 1490 #endif 1488 struct stat myFileInfo; 1489 int statRes; 1490 char file_path[1024]; 1491 sprintf(file_path,"%s/GetStatus.zcfg",ntmp); 1492 statRes=stat(file_path,&myFileInfo); 1493 if(statRes==0){ 1494 char currentSid[128]; 1495 map* tmpm=getMap(tmp_maps->content,"rewriteUrl"); 1496 map *tmp_lenv=NULL; 1497 tmp_lenv=getMapFromMaps(m,"lenv","usid"); 1498 if(tmp_lenv==NULL) 1499 sprintf(currentSid,"%i",pid); 1500 else 1501 sprintf(currentSid,"%s",tmp_lenv->value); 1502 if(tmpm==NULL || strcasecmp(tmpm->value,"false")==0){ 1503 sprintf(url,"%s?request=Execute&service=WPS&version=1.0.0&Identifier=GetStatus&DataInputs=sid=%s&RawDataOutput=Result",tmpm1->value,currentSid); 1491 struct stat myFileInfo; 1492 int statRes; 1493 char file_path[1024]; 1494 sprintf(file_path,"%s/GetStatus.zcfg",ntmp); 1495 statRes=stat(file_path,&myFileInfo); 1496 if(statRes==0){ 1497 char currentSid[128]; 1498 map* tmpm=getMap(tmp_maps->content,"rewriteUrl"); 1499 map *tmp_lenv=NULL; 1500 tmp_lenv=getMapFromMaps(m,"lenv","usid"); 1501 if(tmp_lenv==NULL) 1502 sprintf(currentSid,"%i",pid); 1503 else 1504 sprintf(currentSid,"%s",tmp_lenv->value); 1505 if(tmpm==NULL || strcasecmp(tmpm->value,"false")==0){ 1506 sprintf(url,"%s?request=Execute&service=WPS&version=1.0.0&Identifier=GetStatus&DataInputs=sid=%s&RawDataOutput=Result",tmpm1->value,currentSid); 1507 }else{ 1508 if(strlen(tmpm->value)>0) 1509 if(strcasecmp(tmpm->value,"true")!=0) 1510 sprintf(url,"%s/%s/GetStatus/%s",tmpm1->value,tmpm->value,currentSid); 1511 else 1512 sprintf(url,"%s/GetStatus/%s",tmpm1->value,currentSid); 1513 else 1514 sprintf(url,"%s/?request=Execute&service=WPS&version=1.0.0&Identifier=GetStatus&DataInputs=sid=%s&RawDataOutput=Result",tmpm1->value,currentSid); 1515 } 1504 1516 }else{ 1505 if(strlen(tmpm->value)>0) 1506 if(strcasecmp(tmpm->value,"true")!=0) 1507 sprintf(url,"%s/%s/GetStatus/%s",tmpm1->value,tmpm->value,currentSid); 1508 else 1509 sprintf(url,"%s/GetStatus/%s",tmpm1->value,currentSid); 1510 else 1511 sprintf(url,"%s/?request=Execute&service=WPS&version=1.0.0&Identifier=GetStatus&DataInputs=sid=%s&RawDataOutput=Result",tmpm1->value,currentSid); 1512 fprintf(stderr,"%s %d\n",__FILE__,__LINE__); 1513 } 1514 }else{ 1517 int lpid; 1518 map* tmpm2=getMapFromMaps(m,"lenv","usid"); 1519 map* tmpm3=getMap(tmp_maps->content,"tmpUrl"); 1520 if(tmpm1!=NULL && tmpm3!=NULL){ 1521 if( strncasecmp( tmpm3->value, "http://", 7) == 0 || 1522 strncasecmp( tmpm3->value, "https://", 8 ) == 0 ){ 1523 sprintf(url,"%s/%s_%s.xml",tmpm3->value,service,tmpm2->value); 1524 }else 1525 sprintf(url,"%s/%s_%s.xml",tmpm1->value,service,tmpm2->value); 1526 } 1527 } 1528 if(tmpm1!=NULL){ 1529 sprintf(tmp,"%s",tmpm1->value); 1530 } 1515 1531 int lpid; 1516 1532 map* tmpm2=getMapFromMaps(m,"lenv","usid"); 1517 map* tmpm3=getMap(tmp_maps->content,"tmpUrl"); 1518 if(tmpm1!=NULL && tmpm3!=NULL){ 1519 if( strncasecmp( tmpm3->value, "http://", 7) == 0 || 1520 strncasecmp( tmpm3->value, "https://", 8 ) == 0 ){ 1521 sprintf(url,"%s/%s_%s.xml",tmpm3->value,service,tmpm2->value); 1522 }else 1523 sprintf(url,"%s/%s_%s.xml",tmpm1->value,service,tmpm2->value); 1524 } 1525 } 1526 if(tmpm1!=NULL){ 1527 sprintf(tmp,"%s",tmpm1->value); 1528 } 1529 int lpid; 1530 map* tmpm2=getMapFromMaps(m,"lenv","usid"); 1531 tmpm1=getMapFromMaps(m,"main","TmpPath"); 1532 sprintf(stored_path,"%s/%s_%s.xml",tmpm1->value,service,tmpm2->value); 1533 } 1534 1535 xmlNewProp(n,BAD_CAST "serviceInstance",BAD_CAST tmp); 1536 map* test=getMap(request,"storeExecuteResponse"); 1537 bool hasStoredExecuteResponse=false; 1538 if(test!=NULL && strcasecmp(test->value,"true")==0){ 1539 xmlNewProp(n,BAD_CAST "statusLocation",BAD_CAST url); 1540 hasStoredExecuteResponse=true; 1541 } 1542 1543 nc = xmlNewNode(ns, BAD_CAST "Process"); 1544 map* tmp2=getMap(serv->content,"processVersion"); 1545 if(tmp2!=NULL) 1546 xmlNewNsProp(nc,ns,BAD_CAST "processVersion",BAD_CAST tmp2->value); 1533 tmpm1=getMapFromMaps(m,"main","TmpPath"); 1534 sprintf(stored_path,"%s/%s_%s.xml",tmpm1->value,service,tmpm2->value); 1535 } 1536 1537 xmlNewProp(n,BAD_CAST "serviceInstance",BAD_CAST tmp); 1538 map* test=getMap(request,"storeExecuteResponse"); 1539 if(test!=NULL && strcasecmp(test->value,"true")==0){ 1540 xmlNewProp(n,BAD_CAST "statusLocation",BAD_CAST url); 1541 hasStoredExecuteResponse=true; 1542 } 1543 1544 nc = xmlNewNode(ns, BAD_CAST "Process"); 1545 map* tmp2=getMap(serv->content,"processVersion"); 1546 if(tmp2!=NULL) 1547 xmlNewNsProp(nc,ns,BAD_CAST "processVersion",BAD_CAST tmp2->value); 1547 1548 1548 map* tmpI=getMapFromMaps(m,"lenv","oIdentifier");1549 printDescription(nc,ns_ows,tmpI->value,serv->content,0);1550 1551 xmlAddChild(n,nc);1552 1553 nc = xmlNewNode(ns, BAD_CAST "Status");1554 const struct tm *tm;1555 size_t len;1556 time_t now;1557 char *tmp1;1558 map *tmpStatus;1549 map* tmpI=getMapFromMaps(m,"lenv","oIdentifier"); 1550 printDescription(nc,ns_ows,tmpI->value,serv->content,0); 1551 1552 xmlAddChild(n,nc); 1553 1554 nc = xmlNewNode(ns, BAD_CAST "Status"); 1555 const struct tm *tm; 1556 size_t len; 1557 time_t now; 1558 char *tmp1; 1559 map *tmpStatus; 1559 1560 1560 now = time ( NULL );1561 tm = localtime ( &now );1562 1563 tmp1 = (char*)malloc((TIME_SIZE+1)*sizeof(char));1564 1565 len = strftime ( tmp1, TIME_SIZE, "%Y-%m-%dT%I:%M:%SZ", tm );1566 1567 xmlNewProp(nc,BAD_CAST "creationTime",BAD_CAST tmp1);1568 1569 char sMsg[2048];1570 switch(status){1571 case SERVICE_SUCCEEDED:1572 nc1 = xmlNewNode(ns, BAD_CAST "ProcessSucceeded");1573 sprintf(sMsg,_("The service \"%s\" ran successfully."),serv->name);1574 nc3=xmlNewText(BAD_CAST sMsg);1575 xmlAddChild(nc1,nc3);1576 break;1577 case SERVICE_STARTED:1578 nc1 = xmlNewNode(ns, BAD_CAST "ProcessStarted");1579 tmpStatus=getMapFromMaps(m,"lenv","status");1580 xmlNewProp(nc1,BAD_CAST "percentCompleted",BAD_CAST tmpStatus->value);1581 sprintf(sMsg,_("The ZOO service \"%s\" is currently running. Please reload this document to get the up-to-date status of the service."),serv->name);1582 nc3=xmlNewText(BAD_CAST sMsg);1583 xmlAddChild(nc1,nc3);1584 break;1585 case SERVICE_ACCEPTED:1586 nc1 = xmlNewNode(ns, BAD_CAST "ProcessAccepted");1587 sprintf(sMsg,_("The service \"%s\" was accepted by the ZOO kernel and is running as a background task. Please access the URL in the statusLocation attribute provided in this document to get the up-to-date status and results."),serv->name);1588 nc3=xmlNewText(BAD_CAST sMsg);1589 xmlAddChild(nc1,nc3);1590 break;1591 case SERVICE_FAILED:1592 nc1 = xmlNewNode(ns, BAD_CAST "ProcessFailed");1593 map *errorMap;1594 map *te;1595 te=getMapFromMaps(m,"lenv","code");1596 if(te!=NULL)1597 1598 else1599 1600 te=getMapFromMaps(m,"lenv","message");1601 if(te!=NULL)1602 1603 else1604 1605 nc3=createExceptionReportNode(m,errorMap,0);1606 freeMap(&errorMap);1607 free(errorMap);1608 xmlAddChild(nc1,nc3);1609 break;1610 default :1611 printf(_("error code not know : %i\n"),status);1612 //exit(1);1613 break;1614 }1615 xmlAddChild(nc,nc1);1616 xmlAddChild(n,nc);1617 free(tmp1);1561 now = time ( NULL ); 1562 tm = localtime ( &now ); 1563 1564 tmp1 = (char*)malloc((TIME_SIZE+1)*sizeof(char)); 1565 1566 len = strftime ( tmp1, TIME_SIZE, "%Y-%m-%dT%I:%M:%SZ", tm ); 1567 1568 xmlNewProp(nc,BAD_CAST "creationTime",BAD_CAST tmp1); 1569 1570 char sMsg[2048]; 1571 switch(status){ 1572 case SERVICE_SUCCEEDED: 1573 nc1 = xmlNewNode(ns, BAD_CAST "ProcessSucceeded"); 1574 sprintf(sMsg,_("The service \"%s\" ran successfully."),serv->name); 1575 nc3=xmlNewText(BAD_CAST sMsg); 1576 xmlAddChild(nc1,nc3); 1577 break; 1578 case SERVICE_STARTED: 1579 nc1 = xmlNewNode(ns, BAD_CAST "ProcessStarted"); 1580 tmpStatus=getMapFromMaps(m,"lenv","status"); 1581 xmlNewProp(nc1,BAD_CAST "percentCompleted",BAD_CAST tmpStatus->value); 1582 sprintf(sMsg,_("The ZOO service \"%s\" is currently running. Please reload this document to get the up-to-date status of the service."),serv->name); 1583 nc3=xmlNewText(BAD_CAST sMsg); 1584 xmlAddChild(nc1,nc3); 1585 break; 1586 case SERVICE_ACCEPTED: 1587 nc1 = xmlNewNode(ns, BAD_CAST "ProcessAccepted"); 1588 sprintf(sMsg,_("The service \"%s\" was accepted by the ZOO kernel and is running as a background task. Please access the URL in the statusLocation attribute provided in this document to get the up-to-date status and results."),serv->name); 1589 nc3=xmlNewText(BAD_CAST sMsg); 1590 xmlAddChild(nc1,nc3); 1591 break; 1592 case SERVICE_FAILED: 1593 nc1 = xmlNewNode(ns, BAD_CAST "ProcessFailed"); 1594 map *errorMap; 1595 map *te; 1596 te=getMapFromMaps(m,"lenv","code"); 1597 if(te!=NULL) 1598 errorMap=createMap("code",te->value); 1599 else 1600 errorMap=createMap("code","NoApplicableCode"); 1601 te=getMapFromMaps(m,"lenv","message"); 1602 if(te!=NULL) 1603 addToMap(errorMap,"text",_ss(te->value)); 1604 else 1605 addToMap(errorMap,"text",_("No more information available")); 1606 nc3=createExceptionReportNode(m,errorMap,0); 1607 freeMap(&errorMap); 1608 free(errorMap); 1609 xmlAddChild(nc1,nc3); 1610 break; 1611 default : 1612 printf(_("error code not know : %i\n"),status); 1613 //exit(1); 1614 break; 1615 } 1616 xmlAddChild(nc,nc1); 1617 xmlAddChild(n,nc); 1618 free(tmp1); 1618 1619 1619 1620 #ifdef DEBUG 1620 fprintf(stderr,"printProcessResponse 1 161\n");1621 fprintf(stderr,"printProcessResponse %d\n",__LINE__); 1621 1622 #endif 1622 1623 1623 map* lineage=getMap(request,"lineage"); 1624 if(lineage!=NULL && strcasecmp(lineage->value,"true")==0){ 1625 nc = xmlNewNode(ns, BAD_CAST "DataInputs"); 1626 maps* mcursor=inputs; 1627 elements* scursor=NULL; 1628 while(mcursor!=NULL /*&& scursor!=NULL*/){ 1629 scursor=getElements(serv->inputs,mcursor->name); 1630 printIOType(doc,nc,ns,ns_ows,ns_xlink,scursor,mcursor,"Input"); 1631 mcursor=mcursor->next; 1632 } 1633 xmlAddChild(n,nc); 1634 1635 #ifdef DEBUG 1636 fprintf(stderr,"printProcessResponse 1 177\n"); 1637 #endif 1638 1639 nc = xmlNewNode(ns, BAD_CAST "OutputDefinitions"); 1640 mcursor=outputs; 1641 scursor=NULL; 1642 while(mcursor!=NULL){ 1643 scursor=getElements(serv->outputs,mcursor->name); 1644 printOutputDefinitions(doc,nc,ns,ns_ows,scursor,mcursor,"Output"); 1645 mcursor=mcursor->next; 1646 } 1647 xmlAddChild(n,nc); 1648 } 1649 #ifdef DEBUG 1650 fprintf(stderr,"printProcessResponse 1 190\n"); 1651 #endif 1624 map* lineage=getMap(request,"lineage"); 1625 if(lineage!=NULL && strcasecmp(lineage->value,"true")==0){ 1626 nc = xmlNewNode(ns, BAD_CAST "DataInputs"); 1627 maps* mcursor=inputs; 1628 elements* scursor=NULL; 1629 while(mcursor!=NULL /*&& scursor!=NULL*/){ 1630 scursor=getElements(serv->inputs,mcursor->name); 1631 printIOType(doc,nc,ns,ns_ows,ns_xlink,scursor,mcursor,"Input",vid); 1632 mcursor=mcursor->next; 1633 } 1634 xmlAddChild(n,nc); 1635 1636 nc = xmlNewNode(ns, BAD_CAST "OutputDefinitions"); 1637 mcursor=outputs; 1638 scursor=NULL; 1639 while(mcursor!=NULL){ 1640 scursor=getElements(serv->outputs,mcursor->name); 1641 printOutputDefinitions(doc,nc,ns,ns_ows,scursor,mcursor,"Output"); 1642 mcursor=mcursor->next; 1643 } 1644 xmlAddChild(n,nc); 1645 } 1646 } 1652 1647 1653 1648 /** … … 1655 1650 */ 1656 1651 if(status==SERVICE_SUCCEEDED){ 1657 nc = xmlNewNode(ns, BAD_CAST "ProcessOutputs"); 1652 if(vid==0){ 1653 nc = xmlNewNode(ns, BAD_CAST "ProcessOutputs"); 1654 } 1658 1655 maps* mcursor=outputs; 1659 1656 elements* scursor=serv->outputs; … … 1665 1662 scursor=getElements(serv->outputs,mcursor->name); 1666 1663 if(scursor!=NULL){ 1667 if(testResponse==NULL || tmp0==NULL) 1668 printIOType(doc,nc,ns,ns_ows,ns_xlink,scursor,mcursor,"Output"); 1664 if(testResponse==NULL || tmp0==NULL){ 1665 if(vid==0) 1666 printIOType(doc,nc,ns,ns_ows,ns_xlink,scursor,mcursor,"Output",vid); 1667 else 1668 printIOType(doc,n,ns,ns_ows,ns_xlink,scursor,mcursor,"Output",vid); 1669 } 1669 1670 else 1670 if(tmp0!=NULL && strncmp(tmp0->value,"true",4)==0) 1671 printIOType(doc,nc,ns,ns_ows,ns_xlink,scursor,mcursor,"Output"); 1671 1672 if(tmp0!=NULL && strncmp(tmp0->value,"true",4)==0){ 1673 if(vid==0) 1674 printIOType(doc,nc,ns,ns_ows,ns_xlink,scursor,mcursor,"Output",vid); 1675 else 1676 printIOType(doc,n,ns,ns_ows,ns_xlink,scursor,mcursor,"Output",vid); 1677 } 1672 1678 }else 1673 1679 /** … … 1675 1681 * present in the service code 1676 1682 */ 1677 printIOType(doc,nc,ns,ns_ows,ns_xlink,scursor,mcursor,"Output"); 1683 if(vid==0) 1684 printIOType(doc,nc,ns,ns_ows,ns_xlink,scursor,mcursor,"Output",vid); 1685 else 1686 printIOType(doc,n,ns,ns_ows,ns_xlink,scursor,mcursor,"Output",vid); 1678 1687 mcursor=mcursor->next; 1679 1688 } 1680 xmlAddChild(n,nc); 1681 } 1682 1683 if(hasStoredExecuteResponse==true && status!=SERVICE_STARTED && status!=SERVICE_ACCEPTED){ 1689 if(vid==0) 1690 xmlAddChild(n,nc); 1691 } 1692 1693 if(vid==0 && hasStoredExecuteResponse==true && status!=SERVICE_STARTED && status!=SERVICE_ACCEPTED){ 1684 1694 #ifndef RELY_ON_DB 1685 1695 semid lid=acquireLock(m);//,1); … … 1822 1832 * @param type the type 1823 1833 */ 1824 void printIOType(xmlDocPtr doc,xmlNodePtr nc,xmlNsPtr ns_wps,xmlNsPtr ns_ows,xmlNsPtr ns_xlink,elements* e,maps* m,const char* type ){1834 void printIOType(xmlDocPtr doc,xmlNodePtr nc,xmlNsPtr ns_wps,xmlNsPtr ns_ows,xmlNsPtr ns_xlink,elements* e,maps* m,const char* type,int vid){ 1825 1835 1826 1836 xmlNodePtr nc1,nc2,nc3; … … 1832 1842 tmp=m->content; 1833 1843 1834 nc2=xmlNewNode(ns_ows, BAD_CAST "Identifier"); 1835 if(e!=NULL) 1836 nc3=xmlNewText(BAD_CAST e->name); 1837 else 1838 nc3=xmlNewText(BAD_CAST m->name); 1839 1840 xmlAddChild(nc2,nc3); 1841 xmlAddChild(nc1,nc2); 1842 xmlAddChild(nc,nc1); 1843 if(e!=NULL) 1844 tmp=getMap(e->content,"Title"); 1845 else 1846 tmp=getMap(m->content,"Title"); 1844 if(vid==0){ 1845 nc2=xmlNewNode(ns_ows, BAD_CAST "Identifier"); 1846 if(e!=NULL) 1847 nc3=xmlNewText(BAD_CAST e->name); 1848 else 1849 nc3=xmlNewText(BAD_CAST m->name); 1850 1851 xmlAddChild(nc2,nc3); 1852 xmlAddChild(nc1,nc2); 1847 1853 1848 if(tmp!=NULL){1849 nc2=xmlNewNode(ns_ows, BAD_CAST tmp->name);1850 nc3=xmlNewText(BAD_CAST _ss(tmp->value));1851 xmlAddChild(nc2,nc3);1852 xmlAddChild(nc1,nc2);1853 }1854 1855 if(e!=NULL)1856 tmp=getMap(e->content,"Abstract");1857 else1858 tmp=getMap(m->content,"Abstract");1859 1860 if(tmp!=NULL){1861 nc2=xmlNewNode(ns_ows, BAD_CAST tmp->name);1862 nc3=xmlNewText(BAD_CAST _ss(tmp->value));1863 xmlAddChild(nc2,nc3);1864 xmlAddChild(nc1,nc2);1865 1854 xmlAddChild(nc,nc1); 1855 1856 if(e!=NULL) 1857 tmp=getMap(e->content,"Title"); 1858 else 1859 tmp=getMap(m->content,"Title"); 1860 1861 if(tmp!=NULL){ 1862 nc2=xmlNewNode(ns_ows, BAD_CAST tmp->name); 1863 nc3=xmlNewText(BAD_CAST _ss(tmp->value)); 1864 xmlAddChild(nc2,nc3); 1865 xmlAddChild(nc1,nc2); 1866 } 1867 1868 if(e!=NULL) 1869 tmp=getMap(e->content,"Abstract"); 1870 else 1871 tmp=getMap(m->content,"Abstract"); 1872 1873 if(tmp!=NULL){ 1874 nc2=xmlNewNode(ns_ows, BAD_CAST tmp->name); 1875 nc3=xmlNewText(BAD_CAST _ss(tmp->value)); 1876 xmlAddChild(nc2,nc3); 1877 xmlAddChild(nc1,nc2); 1878 xmlAddChild(nc,nc1); 1879 } 1880 }else{ 1881 xmlNewProp(nc1,BAD_CAST "id",BAD_CAST (e!=NULL?e->name:m->name)); 1866 1882 } 1867 1883 … … 2155 2171 } 2156 2172 n = xmlNewNode(ns, BAD_CAST "ExceptionReport"); 2173 map* version=getMapFromMaps(m,"main","rversion"); 2174 int vid=getVersionId(version->value); 2157 2175 if(use_ns==1){ 2158 xmlNewNs(n,BAD_CAST "http://www.opengis.net/ows/1.1",BAD_CAST"ows");2176 xmlNewNs(n,BAD_CAST schemas[vid][1],BAD_CAST"ows"); 2159 2177 int xsiId=zooXmlAddNs(n,"http://www.w3.org/2001/XMLSchema-instance","xsi"); 2160 2178 ns_xsi=usedNs[xsiId]; 2161 xmlNewNsProp(n,ns_xsi,BAD_CAST "schemaLocation",BAD_CAST "http://www.opengis.net/ows/1.1 http://schemas.opengis.net/ows/1.1.0/owsExceptionReport.xsd"); 2179 char tmp[1024]; 2180 sprintf(tmp,"%s %s",schemas[vid][1],schemas[vid][5]); 2181 xmlNewNsProp(n,ns_xsi,BAD_CAST "schemaLocation",BAD_CAST tmp); 2162 2182 } 2163 2183 2164 2184 2165 2185 addLangAttr(n,m); 2166 xmlNewProp(n,BAD_CAST "version",BAD_CAST "1.1.0");2186 xmlNewProp(n,BAD_CAST "version",BAD_CAST schemas[vid][6]); 2167 2187 2168 2188 int length=1; … … 2247 2267 if(toto!=NULL) 2248 2268 asRaw=1; 2269 map* version=getMapFromMaps(m,"main","rversion"); 2270 int vid=getVersionId(version->value); 2249 2271 2250 2272 maps* tmpSess=getMaps(m,"senv"); … … 2309 2331 } 2310 2332 2333 if(res==SERVICE_ACCEPTED && vid==1){ 2334 map* statusInfo=createMap("Status","Accepted"); 2335 map *usid=getMapFromMaps(m,"lenv","usid"); 2336 addToMap(statusInfo,"JobID",usid->value); 2337 printStatusInfo(m,statusInfo,"Execute"); 2338 freeMap(&statusInfo); 2339 free(statusInfo); 2340 return; 2341 } 2311 2342 2312 2343 map *tmp1=getMapFromMaps(m,"main","tmpPath"); … … 2428 2459 tmpI=tmpI->next; 2429 2460 } 2430 map *r_inputs=getMap(s->content,"serviceProvider");2431 2461 #ifdef DEBUG 2432 fprintf(stderr,"SERVICE : %s\n", r_inputs->value);2462 fprintf(stderr,"SERVICE : %s\n",s->name); 2433 2463 dumpMaps(m); 2434 2464 #endif 2435 2465 printProcessResponse(m,request_inputs1,cpid, 2436 // s,r_inputs->value,res,2437 2466 s, s->name,res, // replace serviceProvider with serviceName in stored response file name 2438 2467 request_inputs, … … 2672 2701 } 2673 2702 2703 /** 2704 * Print a StatusInfo XML document. 2705 * a statusInfo map should contain the following keys: 2706 * * JobID corresponding to usid key from the lenv section 2707 * * Status the current state (Succeeded,Failed,Accepted,Running) 2708 * * PercentCompleted (optional) the percent completed 2709 * * Message (optional) any messages the service may wish to share 2710 * 2711 * @param conf the maps containing the settings of the main.cfg file 2712 * @param statusInfo the map containing the statusInfo definition 2713 * @param req the WPS requests (GetResult, GetStatus or Dismiss) 2714 */ 2715 void printStatusInfo(maps* conf,map* statusInfo,char* req){ 2716 rewind(stdout); 2717 xmlNodePtr n,n1; 2718 xmlDocPtr doc; 2719 xmlNsPtr ns; 2720 xmlChar *xmlbuff; 2721 int buffersize; 2722 char *encoding=getEncoding(conf); 2723 map *tmp; 2724 int pid=0; 2725 printf("Content-Type: text/xml; charset=%s\r\nStatus: 200 OK\r\n\r\n",encoding); 2726 2727 map* version=getMapFromMaps(conf,"main","rversion"); 2728 int vid=getVersionId(version->value); 2729 2730 doc = xmlNewDoc(BAD_CAST "1.0"); 2731 n1=printWPSHeader(doc,conf,req,"StatusInfo",version->value,1); 2732 2733 map* val=getMap(statusInfo,"JobID"); 2734 int wpsId=zooXmlAddNs(NULL,schemas[vid][2],"wps"); 2735 ns=usedNs[wpsId]; 2736 n = xmlNewNode(ns, BAD_CAST "JobID"); 2737 xmlAddChild(n,xmlNewText(BAD_CAST val->value)); 2738 2739 xmlAddChild(n1,n); 2740 2741 val=getMap(statusInfo,"Status"); 2742 n = xmlNewNode(ns, BAD_CAST "Status"); 2743 xmlAddChild(n,xmlNewText(BAD_CAST val->value)); 2744 2745 xmlAddChild(n1,n); 2746 2747 if(strncasecmp(val->value,"Failed",6)!=0 && 2748 strncasecmp(val->value,"Succeeded",9)!=0){ 2749 val=getMap(statusInfo,"PercentCompleted"); 2750 if(val!=NULL){ 2751 n = xmlNewNode(ns, BAD_CAST "PercentCompleted"); 2752 xmlAddChild(n,xmlNewText(BAD_CAST val->value)); 2753 xmlAddChild(n1,n); 2754 } 2755 2756 val=getMap(statusInfo,"Message"); 2757 if(val!=NULL){ 2758 xmlAddChild(n1,xmlNewComment(BAD_CAST val->value)); 2759 } 2760 } 2761 xmlDocSetRootElement(doc, n1); 2762 2763 xmlDocDumpFormatMemoryEnc(doc, &xmlbuff, &buffersize, encoding, 1); 2764 printf("%s",xmlbuff); 2765 2766 xmlFree(xmlbuff); 2767 xmlFreeDoc(doc); 2768 xmlCleanupParser(); 2769 zooXmlCleanupNs(); 2770 2771 } 2772 -
trunk/zoo-project/zoo-kernel/response_print.h
r641 r654 134 134 135 135 /** 136 * Definitions of acceptable final status 137 */ 138 static char wpsStatus[2][11]={ 139 "Succeeded", 140 "Failed" 141 }; 142 /** 136 143 * Definitions of schemas depending on the WPS version 137 144 */ 138 static const char* schemas[2][ 5]={139 {"1.0.0","http://www.opengis.net/ows/1.1","http://www.opengis.net/wps/1.0.0","http://schemas.opengis.net/wps/1.0.0","%s %s/wps%s_response.xsd" },140 {"2.0.0","http://www.opengis.net/ows/2.0","http://www.opengis.net/wps/2.0","http://schemas.opengis.net/wps/2.0","%s %s/wps%s.xsd" },145 static const char* schemas[2][7]={ 146 {"1.0.0","http://www.opengis.net/ows/1.1","http://www.opengis.net/wps/1.0.0","http://schemas.opengis.net/wps/1.0.0","%s %s/wps%s_response.xsd","http://schemas.opengis.net/ows/1.1.0/owsExceptionReport.xsd","1.1.0"}, 147 {"2.0.0","http://www.opengis.net/ows/2.0","http://www.opengis.net/wps/2.0","http://schemas.opengis.net/wps/2.0","%s %s/wps%s.xsd","http://schemas.opengis.net/ows/2.0/owsExceptionReport.xsd","2.0.2"}, 141 148 }; 142 149 /** … … 152 159 }; 153 160 /** 161 * Definitions requests requiring identifier (depending on the WPS version) 162 */ 163 static int nbReqIdentifier=2; 164 /** 165 * Definitions requests requiring jobid (only for WPS version 2.0.0) 166 */ 167 static int nbReqJob=3; 168 /** 154 169 * Definitions of root node for response depending on the request and the WPS version 155 170 */ 156 static const char * root_nodes[2][6]={157 {"ProcessOfferings","ProcessDescriptions", NULL},158 {"Contents","ProcessOfferings", NULL}171 static const char root_nodes[2][4][20]={ 172 {"ProcessOfferings","ProcessDescriptions","ExecuteResponse",NULL}, 173 {"Contents","ProcessOfferings","Result",NULL} 159 174 }; 160 175 … … 198 213 void printDocument(maps*,xmlDocPtr,int); 199 214 void printDescription(xmlNodePtr,xmlNsPtr,const char*,map*,int); 200 void printIOType(xmlDocPtr,xmlNodePtr,xmlNsPtr,xmlNsPtr,xmlNsPtr,elements*,maps*,const char* );215 void printIOType(xmlDocPtr,xmlNodePtr,xmlNsPtr,xmlNsPtr,xmlNsPtr,elements*,maps*,const char*,int); 201 216 map* parseBoundingBox(const char*); 202 217 void printBoundingBox(xmlNsPtr,xmlNodePtr,map*); 203 218 void printBoundingBoxDocument(maps*,maps*,FILE*); 204 219 void printOutputDefinitions(xmlDocPtr,xmlNodePtr,xmlNsPtr,xmlNsPtr,elements*,maps*,const char*); 220 void printStatusInfo(maps*,map*,char*); 205 221 206 222 void outputResponse(service*,maps*,maps*,map*,int,maps*,int); -
trunk/zoo-project/zoo-kernel/server_internal.c
r653 r654 24 24 25 25 #include "server_internal.h" 26 #include "service_internal.h" 26 27 #include "response_print.h" 27 28 #include "mimetypes.h" … … 785 786 } 786 787 787 788 788 #include <dirent.h> 789 #ifndef RELY_ON_DB 790 /** 791 * Read the Result file (.res). 792 * 793 * @param conf the maps containing the setting of the main.cfg file 794 * @param pid the service identifier (usid key from the [lenv] section) 795 */ 796 void readFinalRes(maps* conf,char* pid,map* statusInfo){ 797 map* r_inputs = getMapFromMaps (conf, "main", "tmpPath"); 798 char* fbkpid = 799 (char *) 800 malloc ((strlen (r_inputs->value) + strlen (pid) + 7) * sizeof (char)); 801 sprintf (fbkpid, "%s/%s.res", r_inputs->value, pid); 802 struct stat file_status; 803 int istat = stat (fbkpid, &file_status); 804 if (istat == 0 && file_status.st_size > 0) 805 { 806 maps *res = (maps *) malloc (MAPS_SIZE); 807 conf_read (fbkpid, res); 808 map* status=getMapFromMaps(res,"status","status"); 809 addToMap(statusInfo,"Status",status->value); 810 freeMaps(&res); 811 free(res); 812 } 813 else 814 addToMap(statusInfo,"Status","Failed"); 815 free(fbkpid); 816 } 817 818 /** 819 * Check if a service is running. 820 * 821 * @param conf the maps containing the setting of the main.cfg file 822 * @param pid the unique service identifier (usid from the lenv section) 823 * @return 1 in case the service is still running, 0 otherwise 824 */ 825 int isRunning(maps* conf,char* pid){ 826 int res=0; 827 map* r_inputs = getMapFromMaps (conf, "main", "tmpPath"); 828 char* fbkpid = 829 (char *) 830 malloc ((strlen (r_inputs->value) + strlen (pid) + 7) * sizeof (char)); 831 sprintf (fbkpid, "%s/%s.pid", r_inputs->value, pid); 832 FILE* f0 = fopen (fbkpid, "r"); 833 if(f0!=NULL){ 834 fclose(f0); 835 res=1; 836 } 837 free(fbkpid); 838 return res; 839 } 840 #else 841 #include "sqlapi.h" 842 #endif 843 844 /** 845 * Run GetStatus requests. 846 * 847 * @param conf the maps containing the setting of the main.cfg file 848 * @param pid the service identifier (usid key from the [lenv] section) 849 * @param req the request (GetStatus / GetResult) 850 */ 851 void runGetStatus(maps* conf,char* pid,char* req){ 852 map* r_inputs = getMapFromMaps (conf, "main", "tmpPath"); 853 char *sid=getStatusId(conf,pid); 854 if(sid==NULL){ 855 errorException (conf, _("The JobID from the request does not match any of the Jobs running on this server"), 856 "NoSuchJob", pid); 857 }else{ 858 map* statusInfo=createMap("JobID",pid); 859 if(isRunning(conf,pid)>0){ 860 if(strncasecmp(req,"GetResult",strlen(req))==0){ 861 errorException (conf, _("The result for the requested JobID has not yet been generated. "), 862 "ResultNotReady", pid); 863 return; 864 } 865 else 866 if(strncasecmp(req,"GetStatus",strlen(req))==0){ 867 addToMap(statusInfo,"Status","Running"); 868 char* tmpStr=_getStatus(conf,pid); 869 if(tmpStr!=NULL && strncmp(tmpStr,"-1",2)!=0){ 870 char *tmpStr1=strdup(tmpStr); 871 char *tmpStr0=strdup(strstr(tmpStr,"|")+1); 872 free(tmpStr); 873 tmpStr1[strlen(tmpStr1)-strlen(tmpStr0)-1]='\0'; 874 addToMap(statusInfo,"PercentCompleted",tmpStr1); 875 addToMap(statusInfo,"Message",tmpStr0); 876 free(tmpStr0); 877 free(tmpStr1); 878 } 879 } 880 } 881 else{ 882 if(strncasecmp(req,"GetResult",strlen(req))==0){ 883 char* result=_getStatusFile(conf,pid); 884 if(result!=NULL){ 885 char *encoding=getEncoding(conf); 886 fprintf(stdout,"Content-Type: text/xml; charset=%s\r\nStatus: 200 OK\r\n\r\n",encoding); 887 fprintf(stdout,"%s",result); 888 fflush(stdout); 889 freeMap(&statusInfo); 890 free(statusInfo); 891 return; 892 }else{ 893 errorException (conf, _("The result for the requested JobID has not yet been generated. "), 894 "ResultNotReady", pid); 895 freeMap(&statusInfo); 896 free(statusInfo); 897 return; 898 } 899 }else 900 if(strncasecmp(req,"GetStatus",strlen(req))==0){ 901 readFinalRes(conf,pid,statusInfo); 902 char* tmpStr=_getStatus(conf,pid); 903 if(tmpStr!=NULL && strncmp(tmpStr,"-1",2)!=0){ 904 char *tmpStr1=strdup(tmpStr); 905 char *tmpStr0=strdup(strstr(tmpStr,"|")+1); 906 free(tmpStr); 907 tmpStr1[strlen(tmpStr1)-strlen(tmpStr0)-1]='\0'; 908 addToMap(statusInfo,"PercentCompleted",tmpStr1); 909 addToMap(statusInfo,"Message",tmpStr0); 910 free(tmpStr0); 911 free(tmpStr1); 912 } 913 } 914 } 915 printStatusInfo(conf,statusInfo,req); 916 freeMap(&statusInfo); 917 free(statusInfo); 918 } 919 return; 920 } 921 922 /** 923 * Run Dismiss requests. 924 * 925 * @param conf the maps containing the setting of the main.cfg file 926 * @param pid the service identifier (usid key from the [lenv] section) 927 */ 928 void runDismiss(maps* conf,char* pid){ 929 map* r_inputs = getMapFromMaps (conf, "main", "tmpPath"); 930 char *sid=getStatusId(conf,pid); 931 if(sid==NULL){ 932 errorException (conf, _("The JobID from the request does not match any of the Jobs running on this server"), 933 "NoSuchJob", pid); 934 }else{ 935 // We should send the Dismiss request to the target host if it differs 936 char* fbkpid = 937 (char *) 938 malloc ((strlen (r_inputs->value) + strlen (pid) + 7) * sizeof (char)); 939 sprintf (fbkpid, "%s/%s.pid", r_inputs->value, pid); 940 FILE* f0 = fopen (fbkpid, "r"); 941 if(f0!=NULL){ 942 long flen; 943 char *fcontent; 944 fseek (f0, 0, SEEK_END); 945 flen = ftell (f0); 946 fseek (f0, 0, SEEK_SET); 947 fcontent = (char *) malloc ((flen + 1) * sizeof (char)); 948 fread(fcontent,flen,1,f0); 949 fcontent[flen]=0; 950 fclose(f0); 951 kill(atoi(fcontent),SIGKILL); 952 free(fcontent); 953 } 954 free(fbkpid); 955 struct dirent *dp; 956 DIR *dirp = opendir(r_inputs->value); 957 char fileName[1024]; 958 int hasFile=-1; 959 if(dirp!=NULL){ 960 while ((dp = readdir(dirp)) != NULL){ 961 #ifdef DEBUG 962 fprintf(stderr,"File : %s searched : %s\n",dp->d_name,tmp); 963 #endif 964 if(strstr(dp->d_name,pid)!=0){ 965 sprintf(fileName,"%s/%s",r_inputs->value,dp->d_name); 966 if(unlink(fileName)!=0){ 967 errorException (conf, _("The job cannot be removed, a file cannot be removed"), 968 "NoApplicableCode", NULL); 969 return; 970 } 971 } 972 } 973 } 974 #ifdef RELY_ON_DB 975 removeService(conf,pid); 976 #endif 977 map* statusInfo=createMap("JobID",pid); 978 addToMap(statusInfo,"Status","Dismissed"); 979 printStatusInfo(conf,statusInfo,"Dismiss"); 980 free(statusInfo); 981 } 982 return; 983 } -
trunk/zoo-project/zoo-kernel/server_internal.h
r652 r654 52 52 void parseIdentifier(maps*,char*,char*,char*); 53 53 void dumpMapsValuesToFiles(maps**,maps**); 54 void runDismiss(maps*,char*); 55 void runGetStatus(maps*,char*,char*); 54 56 55 57 int isValidLang(maps*,const char*); -
trunk/zoo-project/zoo-kernel/service_internal.c
r653 r654 276 276 FILE* fstatus=fopen(fbkpid,"w"); 277 277 if(fstatus!=NULL){ 278 fprintf(fstatus,"%s|%s \n",status->value,msg->value);278 fprintf(fstatus,"%s|%s",status->value,msg->value); 279 279 fflush(fstatus); 280 280 fclose(fstatus); -
trunk/zoo-project/zoo-kernel/service_internal.h
r652 r654 107 107 char* _getStatusFile(maps*,char*); 108 108 char* getStatus(int); 109 char* getStatusId(maps*,char*); 109 110 110 111 int updateStatus( maps*,const int,const char*); -
trunk/zoo-project/zoo-kernel/sqlapi.c
r652 r654 227 227 map *schema=getMapFromMaps(conf,"database","schema"); 228 228 char *sqlQuery=(char*)malloc((strlen(schema->value)+flen+strlen(sid->value)+51+1)*sizeof(char)); 229 sprintf(sqlQuery," UPDATE %s.services set response=$$%s$$ where uuid=$$%s$$;",schema->value,tmps,sid->value);229 sprintf(sqlQuery,"INSERT INTO %s.responses (content,uuid) VALUES ($$%s$$,$$%s$$);",schema->value,tmps,sid->value); 230 230 execSql(conf,sqlQuery); 231 231 cleanUpResultSet(conf); … … 292 292 char* _getStatusFile(maps* conf,char* pid){ 293 293 map *schema=getMapFromMaps(conf,"database","schema"); 294 char *sqlQuery=(char*)malloc((strlen(schema->value)+strlen(pid)+58+1)*sizeof(char)); 295 sprintf(sqlQuery,"select response from %s.services where uuid=$$%s$$;",schema->value,pid); 294 char *sqlQuery=(char*)malloc((strlen(schema->value)+strlen(pid)+82+1)*sizeof(char)); 295 sprintf(sqlQuery, 296 "select content from %s.responses where uuid=$$%s$$" 297 " order by creation_time desc limit 1",schema->value,pid); 296 298 if( zoo_DS == NULL ) 297 299 init_sql(conf); … … 318 320 319 321 /** 320 * Stop handling status repport.322 * Delete a service reference from the database. 321 323 * 322 324 * @param conf the map containing the setting of the main.cfg file 323 */ 324 void unhandleStatus(maps* conf){ 325 map *sid=getMapFromMaps(conf,"lenv","usid"); 326 char *sqlQuery=(char*)malloc((strlen(sid->value)+52+1)*sizeof(char)); 327 sprintf(sqlQuery,"UPDATE services set end_time=now() where uuid=$$%s$$;",sid->value); 325 * @param pid the service identifier (usid key from the [lenv] section) 326 */ 327 void removeService(maps* conf,char* pid){ 328 map *schema=getMapFromMaps(conf,"database","schema"); 329 char *sqlQuery=(char*) 330 malloc((strlen(pid)+strlen(schema->value)+38+1) 331 *sizeof(char)); 332 if( zoo_DS == NULL ) 333 init_sql(conf); 334 sprintf(sqlQuery, 335 "DELETE FROM %s.services where uuid=$$%s$$;", 336 schema->value,pid); 328 337 execSql(conf,sqlQuery); 329 338 cleanUpResultSet(conf); … … 332 341 } 333 342 343 /** 344 * Stop handling status repport. 345 * 346 * @param conf the map containing the setting of the main.cfg file 347 */ 348 void unhandleStatus(maps* conf){ 349 map *schema=getMapFromMaps(conf,"database","schema"); 350 map *sid=getMapFromMaps(conf,"lenv","usid"); 351 map *fstate=getMapFromMaps(conf,"lenv","fstate"); 352 char *sqlQuery=(char*)malloc((strlen(sid->value)+ 353 strlen(schema->value)+ 354 (fstate!=NULL? 355 strlen(fstate->value): 356 6) 357 +66+1)*sizeof(char)); 358 sprintf(sqlQuery, 359 "UPDATE %s.services set end_time=now(), fstate=$$%s$$" 360 " where uuid=$$%s$$;", 361 schema->value,(fstate!=NULL?fstate->value:"Failed"),sid->value); 362 execSql(conf,sqlQuery); 363 cleanUpResultSet(conf); 364 close_sql(conf); 365 end_sql(); 366 } 367 368 /** 369 * Read the sid identifier attached of a service if any 370 * 371 * @param conf the maps containing the setting of the main.cfg file 372 * @param pid the service identifier (usid key from the [lenv] section) 373 * @return the sid value 374 */ 375 char* getStatusId(maps* conf,char* pid){ 376 map *schema=getMapFromMaps(conf,"database","schema"); 377 char *sqlQuery=(char*)malloc((strlen(schema->value)+strlen(pid)+58+1)*sizeof(char)); 378 sprintf(sqlQuery, 379 "select osid from %s.services where uuid=$$%s$$", 380 schema->value,pid); 381 if( zoo_DS == NULL ) 382 init_sql(conf); 383 execSql(conf,sqlQuery); 384 OGRFeature *poFeature = NULL; 385 const char *tmp1; 386 int hasRes=-1; 387 while( (poFeature = zoo_ResultSet->GetNextFeature()) != NULL ){ 388 for( int iField = 0; iField < poFeature->GetFieldCount(); iField++ ){ 389 if( poFeature->IsFieldSet( iField ) ){ 390 tmp1=zStrdup(poFeature->GetFieldAsString( iField )); 391 hasRes=1; 392 break; 393 } 394 } 395 OGRFeature::DestroyFeature( poFeature ); 396 } 397 if(hasRes<0) 398 tmp1=NULL; 399 return (char*)tmp1; 400 } 401 402 /** 403 * Read the Result file (.res). 404 * 405 * @param conf the maps containing the setting of the main.cfg file 406 * @param pid the service identifier (usid key from the [lenv] section) 407 */ 408 void readFinalRes(maps* conf,char* pid,map* statusInfo){ 409 map *schema=getMapFromMaps(conf,"database","schema"); 410 char *sqlQuery=(char*)malloc((strlen(schema->value)+strlen(pid)+58+1)*sizeof(char)); 411 sprintf(sqlQuery, 412 "select fstate from %s.services where uuid=$$%s$$", 413 schema->value,pid); 414 if( zoo_DS == NULL ) 415 init_sql(conf); 416 execSql(conf,sqlQuery); 417 OGRFeature *poFeature = NULL; 418 int hasRes=-1; 419 while( (poFeature = zoo_ResultSet->GetNextFeature()) != NULL ){ 420 for( int iField = 0; iField < poFeature->GetFieldCount(); iField++ ){ 421 if( poFeature->IsFieldSet( iField ) ){ 422 addToMap(statusInfo,"Status",poFeature->GetFieldAsString( iField )); 423 hasRes=1; 424 break; 425 } 426 } 427 OGRFeature::DestroyFeature( poFeature ); 428 } 429 if(hasRes<0) 430 addToMap(statusInfo,"Status","Failed"); 431 return; 432 } 433 434 /** 435 * Check if a service is running. 436 * 437 * @param conf the maps containing the setting of the main.cfg file 438 * @param pid the unique service identifier (usid from the lenv section) 439 * @return 1 in case the service is still running, 0 otherwise 440 */ 441 int isRunning(maps* conf,char* pid){ 442 int res=0; 443 map *schema=getMapFromMaps(conf,"database","schema"); 444 char *sqlQuery=(char*)malloc((strlen(schema->value)+strlen(pid)+73+1)*sizeof(char)); 445 sprintf(sqlQuery,"select count(*) as t from %s.services where uuid=$$%s$$ and end_time is null;",schema->value,pid); 446 if( zoo_DS == NULL ) 447 init_sql(conf); 448 execSql(conf,sqlQuery); 449 OGRFeature *poFeature = NULL; 450 const char *tmp1; 451 while( (poFeature = zoo_ResultSet->GetNextFeature()) != NULL ){ 452 for( int iField = 0; iField < poFeature->GetFieldCount(); iField++ ){ 453 if( poFeature->IsFieldSet( iField ) && 454 atoi(poFeature->GetFieldAsString( iField ))>0 ){ 455 res=1; 456 break; 457 } 458 } 459 OGRFeature::DestroyFeature( poFeature ); 460 } 461 cleanUpResultSet(conf); 462 return res; 463 } 464 334 465 #endif -
trunk/zoo-project/zoo-kernel/sqlapi.h
r653 r654 1 /* *1 /* 2 2 * Author : David Saggiorato 3 3 * … … 39 39 void recordServiceStatus(maps*); 40 40 void recordResponse(maps*,char*); 41 void readFinalRes(maps*,char*,map*); 42 int isRunning(maps*,char*); 43 char* getStatusId(maps*,char*); 44 void removeService(maps*,char*); 41 45 #endif 42 46 -
trunk/zoo-project/zoo-kernel/zoo_loader.c
r648 r654 339 339 free(identifiers); 340 340 } 341 }else{ 342 idptr=extractFromDoc(doc,"/*/*[local-name()='JobID']"); 343 if(idptr!=NULL){ 344 xmlNodeSet* id=idptr->nodesetval; 345 if(id!=NULL){ 346 char* identifiers=NULL; 347 identifiers=(char*)calloc(cgiContentLength,sizeof(char)); 348 identifiers[0]=0; 349 for(int k=0;k<id->nodeNr;k++){ 350 xmlChar* content=xmlNodeListGetString(doc, id->nodeTab[k]->xmlChildrenNode,1); 351 if(strlen(identifiers)>0){ 352 char *tmp=zStrdup(identifiers); 353 snprintf(identifiers,strlen(tmp)+xmlStrlen(content)+2,"%s,%s",tmp,content); 354 free(tmp); 355 } 356 else{ 357 snprintf(identifiers,xmlStrlen(content)+1,"%s",content); 358 } 359 xmlFree(content); 360 } 361 xmlXPathFreeObject(idptr); 362 addToMap(tmpMap,"JobID",identifiers); 363 free(identifiers); 364 } 365 } 341 366 } 342 367 } -
trunk/zoo-project/zoo-kernel/zoo_service_loader.c
r652 r654 22 22 * THE SOFTWARE. 23 23 */ 24 25 26 24 27 25 extern "C" int yylex (); … … 1111 1109 1112 1110 if(strlen(cgiServerName)>0) 1113 {1114 char tmpUrl[1024];1111 { 1112 char tmpUrl[1024]; 1115 1113 1116 if ( getenv("HTTPS") != NULL && strncmp(getenv("HTTPS"), "on", 2) == 0 ) { // Knut: check if non-empty instead of "on"? 1117 if ( strncmp(cgiServerPort, "443", 3) == 0 ) { 1118 sprintf(tmpUrl, "https://%s%s", cgiServerName, cgiScriptName); 1119 } 1120 else { 1121 sprintf(tmpUrl, "https://%s:%s%s", cgiServerName, cgiServerPort, cgiScriptName); 1122 } 1114 if ( getenv("HTTPS") != NULL && strncmp(getenv("HTTPS"), "on", 2) == 0 ) { // Knut: check if non-empty instead of "on"? 1115 if ( strncmp(cgiServerPort, "443", 3) == 0 ) { 1116 sprintf(tmpUrl, "https://%s%s", cgiServerName, cgiScriptName); 1123 1117 } 1124 1118 else { 1125 if ( strncmp(cgiServerPort, "80", 2) == 0 ) { 1126 sprintf(tmpUrl, "http://%s%s", cgiServerName, cgiScriptName); 1127 } 1128 else { 1129 sprintf(tmpUrl, "http://%s:%s%s", cgiServerName, cgiServerPort, cgiScriptName); 1130 } 1119 sprintf(tmpUrl, "https://%s:%s%s", cgiServerName, cgiServerPort, cgiScriptName); 1131 1120 } 1132 #ifdef DEBUG 1133 fprintf(stderr,"*** %s ***\n",tmpUrl); 1134 #endif 1135 setMapInMaps(m,"main","serverAddress",tmpUrl); 1136 } 1137 1138 /** 1139 * Check for minimum inputs 1140 */ 1121 } 1122 else { 1123 if ( strncmp(cgiServerPort, "80", 2) == 0 ) { 1124 sprintf(tmpUrl, "http://%s%s", cgiServerName, cgiScriptName); 1125 } 1126 else { 1127 sprintf(tmpUrl, "http://%s:%s%s", cgiServerName, cgiServerPort, cgiScriptName); 1128 } 1129 } 1130 #ifdef DEBUG 1131 fprintf(stderr,"*** %s ***\n",tmpUrl); 1132 #endif 1133 setMapInMaps(m,"main","serverAddress",tmpUrl); 1134 } 1135 1136 //Check for minimum inputs 1137 map* version=getMap(request_inputs,"version"); 1138 if(version==NULL) 1139 version=getMapFromMaps(m,"main","version"); 1140 setMapInMaps(m,"main","rversion",version->value); 1141 int vid=getVersionId(version->value); 1142 if(vid<0) 1143 vid=0; 1141 1144 map* err=NULL; 1142 const char *vvr[]={ 1143 "GetCapabilities", 1144 "DescribeProcess", 1145 "Execute", 1146 NULL 1147 }; 1148 checkValidValue(request_inputs,&err,"request",(const char**)vvr,1); 1145 const char **vvr=(const char**)requests[vid]; 1146 checkValidValue(request_inputs,&err,"request",vvr,1); 1149 1147 const char *vvs[]={ 1150 1148 "WPS", … … 1174 1172 r_inputs = getMap (request_inputs, "Request"); 1175 1173 REQUEST = zStrdup (r_inputs->value); 1174 int reqId=-1; 1176 1175 if (strncasecmp (REQUEST, "GetCapabilities", 15) != 0){ 1177 1176 checkValidValue(request_inputs,&err,"version",(const char**)vvv,1); 1178 checkValidValue(request_inputs,&err,"identifier",NULL,1); 1177 int j=0; 1178 for(j=0;j<nbSupportedRequests;j++){ 1179 if(requests[vid][j]!=NULL && requests[vid][j+1]!=NULL){ 1180 if(j<nbReqIdentifier && strncasecmp(REQUEST,requests[vid][j+1],strlen(REQUEST))==0){ 1181 checkValidValue(request_inputs,&err,"identifier",NULL,1); 1182 reqId=j+1; 1183 break; 1184 } 1185 else 1186 if(j>=nbReqIdentifier && j<nbReqIdentifier+nbReqJob && 1187 strncasecmp(REQUEST,requests[vid][j+1],strlen(REQUEST))==0){ 1188 checkValidValue(request_inputs,&err,"jobid",NULL,1); 1189 reqId=j+1; 1190 break; 1191 } 1192 }else 1193 break; 1194 } 1179 1195 }else{ 1180 1196 checkValidValue(request_inputs,&err,"AcceptVersions",(const char**)vvv,-1); … … 1187 1203 } 1188 1204 } 1189 map* version=getMap(request_inputs,"version");1190 if(version==NULL)1191 version=getMapFromMaps(m,"main","version");1192 setMapInMaps(m,"main","rversion",version->value);1193 1205 if(err!=NULL){ 1194 1206 printExceptionReportResponse (m, err); … … 1293 1305 else 1294 1306 { 1295 r_inputs = getMap (request_inputs, "Identifier"); 1296 1297 struct dirent *dp; 1298 DIR *dirp = opendir (conf_dir); 1299 if (dirp == NULL) 1300 { 1301 errorException (m, _("The specified path path does not exist."), 1302 "InvalidParameterValue", conf_dir); 1303 freeMaps (&m); 1304 free (m); 1307 r_inputs = getMap (request_inputs, "JobId"); 1308 if(reqId>nbReqIdentifier){ 1309 if (strncasecmp (REQUEST, "GetStatus", strlen(REQUEST)) == 0 || 1310 strncasecmp (REQUEST, "GetResult", strlen(REQUEST)) == 0){ 1311 runGetStatus(m,r_inputs->value,REQUEST); 1312 freeMaps (&m); 1313 free (m); 1305 1314 if(zooRegistry!=NULL){ 1306 1315 freeRegistry(&zooRegistry); 1307 1316 free(zooRegistry); 1308 1317 } 1309 free (REQUEST); 1310 free (SERVICE_URL); 1311 return 0; 1312 } 1313 if (strncasecmp (REQUEST, "DescribeProcess", 15) == 0) 1314 { 1315 /** 1316 * Loop over Identifier list 1317 */ 1318 xmlDocPtr doc = xmlNewDoc (BAD_CAST "1.0"); 1319 r_inputs = NULL; 1320 r_inputs = getMap (request_inputs, "version"); 1321 map* version=getMapFromMaps(m,"main","rversion"); 1322 int vid=getVersionId(version->value); 1323 xmlNodePtr n = printWPSHeader(doc,m,"DescribeProcess", 1324 root_nodes[vid][1],(r_inputs!=NULL?r_inputs->value:"1.0.0"),1); 1325 1326 r_inputs = getMap (request_inputs, "Identifier"); 1327 1328 char *orig = zStrdup (r_inputs->value); 1329 1330 int saved_stdout = dup (fileno (stdout)); 1331 dup2 (fileno (stderr), fileno (stdout)); 1332 if (strcasecmp ("all", orig) == 0) 1333 { 1334 if (int res = 1335 recursReaddirF (m, zooRegistry, n, conf_dir, NULL, saved_stdout, 0, 1336 printDescribeProcessForProcess) < 0) 1337 return res; 1338 } 1339 else 1340 { 1341 char *saveptr; 1342 char *tmps = strtok_r (orig, ",", &saveptr); 1343 1344 char buff[256]; 1345 char buff1[1024]; 1346 while (tmps != NULL) 1347 { 1348 int hasVal = -1; 1349 char *corig = zStrdup (tmps); 1350 if (strstr (corig, ".") != NULL) 1351 { 1352 1353 parseIdentifier (m, conf_dir, corig, buff1); 1354 map *tmpMap = getMapFromMaps (m, "lenv", "metapath"); 1355 if (tmpMap != NULL) 1356 addToMap (request_inputs, "metapath", tmpMap->value); 1357 map *tmpMapI = getMapFromMaps (m, "lenv", "Identifier"); 1358 1359 s1 = (service *) malloc (SERVICE_SIZE); 1360 t = readServiceFile (m, buff1, &s1, tmpMapI->value); 1361 if (t < 0) 1362 { 1363 map *tmp00 = getMapFromMaps (m, "lenv", "message"); 1364 char tmp01[1024]; 1365 if (tmp00 != NULL) 1366 sprintf (tmp01, 1367 _ 1368 ("Unable to parse the ZCFG file for the following ZOO-Service: %s. Message: %s"), 1369 tmps, tmp00->value); 1370 else 1371 sprintf (tmp01, 1372 _ 1373 ("Unable to parse the ZCFG file for the following ZOO-Service: %s."), 1374 tmps); 1375 dup2 (saved_stdout, fileno (stdout)); 1376 errorException (m, tmp01, "InvalidParameterValue", 1377 "identifier"); 1378 freeMaps (&m); 1379 free (m); 1380 if(zooRegistry!=NULL){ 1381 freeRegistry(&zooRegistry); 1382 free(zooRegistry); 1318 free (REQUEST); 1319 free (SERVICE_URL); 1320 return 0; 1321 } 1322 else 1323 if (strncasecmp (REQUEST, "Dismiss", strlen(REQUEST)) == 0){ 1324 runDismiss(m,r_inputs->value); 1325 freeMaps (&m); 1326 free (m); 1327 if(zooRegistry!=NULL){ 1328 freeRegistry(&zooRegistry); 1329 free(zooRegistry); 1330 } 1331 free (REQUEST); 1332 free (SERVICE_URL); 1333 return 0; 1334 1335 } 1336 return 0; 1337 } 1338 if(reqId<=nbReqIdentifier){ 1339 r_inputs = getMap (request_inputs, "Identifier"); 1340 1341 struct dirent *dp; 1342 DIR *dirp = opendir (conf_dir); 1343 if (dirp == NULL) 1344 { 1345 errorException (m, _("The specified path path does not exist."), 1346 "InvalidParameterValue", conf_dir); 1347 freeMaps (&m); 1348 free (m); 1349 if(zooRegistry!=NULL){ 1350 freeRegistry(&zooRegistry); 1351 free(zooRegistry); 1352 } 1353 free (REQUEST); 1354 free (SERVICE_URL); 1355 return 0; 1356 } 1357 if (strncasecmp (REQUEST, "DescribeProcess", 15) == 0) 1358 { 1359 /** 1360 * Loop over Identifier list 1361 */ 1362 xmlDocPtr doc = xmlNewDoc (BAD_CAST "1.0"); 1363 r_inputs = NULL; 1364 r_inputs = getMap (request_inputs, "version"); 1365 map* version=getMapFromMaps(m,"main","rversion"); 1366 int vid=getVersionId(version->value); 1367 xmlNodePtr n = printWPSHeader(doc,m,"DescribeProcess", 1368 root_nodes[vid][1],(r_inputs!=NULL?r_inputs->value:"1.0.0"),1); 1369 1370 r_inputs = getMap (request_inputs, "Identifier"); 1371 1372 char *orig = zStrdup (r_inputs->value); 1373 1374 int saved_stdout = dup (fileno (stdout)); 1375 dup2 (fileno (stderr), fileno (stdout)); 1376 if (strcasecmp ("all", orig) == 0) 1377 { 1378 if (int res = 1379 recursReaddirF (m, zooRegistry, n, conf_dir, NULL, saved_stdout, 0, 1380 printDescribeProcessForProcess) < 0) 1381 return res; 1382 } 1383 else 1384 { 1385 char *saveptr; 1386 char *tmps = strtok_r (orig, ",", &saveptr); 1387 1388 char buff[256]; 1389 char buff1[1024]; 1390 while (tmps != NULL) 1391 { 1392 int hasVal = -1; 1393 char *corig = zStrdup (tmps); 1394 if (strstr (corig, ".") != NULL) 1395 { 1396 1397 parseIdentifier (m, conf_dir, corig, buff1); 1398 map *tmpMap = getMapFromMaps (m, "lenv", "metapath"); 1399 if (tmpMap != NULL) 1400 addToMap (request_inputs, "metapath", tmpMap->value); 1401 map *tmpMapI = getMapFromMaps (m, "lenv", "Identifier"); 1402 1403 s1 = (service *) malloc (SERVICE_SIZE); 1404 t = readServiceFile (m, buff1, &s1, tmpMapI->value); 1405 if (t < 0) 1406 { 1407 map *tmp00 = getMapFromMaps (m, "lenv", "message"); 1408 char tmp01[1024]; 1409 if (tmp00 != NULL) 1410 sprintf (tmp01, 1411 _ 1412 ("Unable to parse the ZCFG file for the following ZOO-Service: %s. Message: %s"), 1413 tmps, tmp00->value); 1414 else 1415 sprintf (tmp01, 1416 _ 1417 ("Unable to parse the ZCFG file for the following ZOO-Service: %s."), 1418 tmps); 1419 dup2 (saved_stdout, fileno (stdout)); 1420 errorException (m, tmp01, "InvalidParameterValue", 1421 "identifier"); 1422 freeMaps (&m); 1423 free (m); 1424 if(zooRegistry!=NULL){ 1425 freeRegistry(&zooRegistry); 1426 free(zooRegistry); 1427 } 1428 free (REQUEST); 1429 free (corig); 1430 free (orig); 1431 free (SERVICE_URL); 1432 free (s1); 1433 closedir (dirp); 1434 xmlFreeDoc (doc); 1435 xmlCleanupParser (); 1436 zooXmlCleanupNs (); 1437 return 1; 1383 1438 } 1384 free (REQUEST); 1385 free (corig); 1386 free (orig); 1387 free (SERVICE_URL); 1388 free (s1); 1389 closedir (dirp); 1390 xmlFreeDoc (doc); 1391 xmlCleanupParser (); 1392 zooXmlCleanupNs (); 1393 return 1; 1394 } 1395 #ifdef DEBUG 1396 dumpService (s1); 1397 #endif 1398 inheritance(zooRegistry,&s1); 1399 printDescribeProcessForProcess (m, n, s1); 1400 freeService (&s1); 1401 free (s1); 1402 s1 = NULL; 1403 scount++; 1404 hasVal = 1; 1405 setMapInMaps (m, "lenv", "level", "0"); 1406 } 1407 else 1408 { 1409 memset (buff, 0, 256); 1410 snprintf (buff, 256, "%s.zcfg", corig); 1411 memset (buff1, 0, 1024); 1412 #ifdef DEBUG 1413 printf ("\n#######%s\n########\n", buff); 1414 #endif 1415 while ((dp = readdir (dirp)) != NULL) 1416 { 1417 if (strcasecmp (dp->d_name, buff) == 0) 1418 { 1419 memset (buff1, 0, 1024); 1420 snprintf (buff1, 1024, "%s/%s", conf_dir, 1421 dp->d_name); 1422 s1 = (service *) malloc (SERVICE_SIZE); 1423 if (s1 == NULL) 1424 { 1425 dup2 (saved_stdout, fileno (stdout)); 1426 return errorException (m, 1427 _ 1428 ("Unable to allocate memory."), 1429 "InternalError", 1430 NULL); 1431 } 1432 #ifdef DEBUG 1433 printf 1434 ("#################\n(%s) %s\n#################\n", 1435 r_inputs->value, buff1); 1436 #endif 1437 char *tmp0 = zStrdup (dp->d_name); 1438 tmp0[strlen (tmp0) - 5] = 0; 1439 t = readServiceFile (m, buff1, &s1, tmp0); 1440 free (tmp0); 1441 if (t < 0) 1442 { 1443 map *tmp00 = 1444 getMapFromMaps (m, "lenv", "message"); 1445 char tmp01[1024]; 1446 if (tmp00 != NULL) 1447 sprintf (tmp01, 1448 _ 1449 ("Unable to parse the ZCFG file: %s (%s)"), 1450 dp->d_name, tmp00->value); 1451 else 1452 sprintf (tmp01, 1453 _ 1454 ("Unable to parse the ZCFG file: %s."), 1455 dp->d_name); 1456 dup2 (saved_stdout, fileno (stdout)); 1457 errorException (m, tmp01, "InternalError", 1458 NULL); 1459 freeMaps (&m); 1460 free (m); 1461 if(zooRegistry!=NULL){ 1462 freeRegistry(&zooRegistry); 1463 free(zooRegistry); 1439 #ifdef DEBUG 1440 dumpService (s1); 1441 #endif 1442 inheritance(zooRegistry,&s1); 1443 printDescribeProcessForProcess (m, n, s1); 1444 freeService (&s1); 1445 free (s1); 1446 s1 = NULL; 1447 scount++; 1448 hasVal = 1; 1449 setMapInMaps (m, "lenv", "level", "0"); 1450 } 1451 else 1452 { 1453 memset (buff, 0, 256); 1454 snprintf (buff, 256, "%s.zcfg", corig); 1455 memset (buff1, 0, 1024); 1456 #ifdef DEBUG 1457 printf ("\n#######%s\n########\n", buff); 1458 #endif 1459 while ((dp = readdir (dirp)) != NULL) 1460 { 1461 if (strcasecmp (dp->d_name, buff) == 0) 1462 { 1463 memset (buff1, 0, 1024); 1464 snprintf (buff1, 1024, "%s/%s", conf_dir, 1465 dp->d_name); 1466 s1 = (service *) malloc (SERVICE_SIZE); 1467 if (s1 == NULL) 1468 { 1469 dup2 (saved_stdout, fileno (stdout)); 1470 return errorException (m, 1471 _ 1472 ("Unable to allocate memory."), 1473 "InternalError", 1474 NULL); 1464 1475 } 1465 free (orig); 1466 free (REQUEST); 1467 closedir (dirp); 1468 xmlFreeDoc (doc); 1469 xmlCleanupParser (); 1470 zooXmlCleanupNs (); 1471 return 1; 1472 } 1473 #ifdef DEBUG 1474 dumpService (s1); 1475 #endif 1476 inheritance(zooRegistry,&s1); 1477 printDescribeProcessForProcess (m, n, s1); 1478 freeService (&s1); 1479 free (s1); 1480 s1 = NULL; 1481 scount++; 1482 hasVal = 1; 1483 } 1484 } 1485 } 1486 if (hasVal < 0) 1487 { 1488 map *tmp00 = getMapFromMaps (m, "lenv", "message"); 1489 char tmp01[1024]; 1490 if (tmp00 != NULL) 1491 sprintf (tmp01, 1492 _("Unable to parse the ZCFG file: %s (%s)"), 1493 buff, tmp00->value); 1494 else 1495 sprintf (tmp01, 1496 _("Unable to parse the ZCFG file: %s."), 1497 buff); 1498 dup2 (saved_stdout, fileno (stdout)); 1499 errorException (m, tmp01, "InvalidParameterValue", 1500 "Identifier"); 1501 freeMaps (&m); 1502 free (m); 1503 if(zooRegistry!=NULL){ 1504 freeRegistry(&zooRegistry); 1505 free(zooRegistry); 1476 #ifdef DEBUG 1477 printf 1478 ("#################\n(%s) %s\n#################\n", 1479 r_inputs->value, buff1); 1480 #endif 1481 char *tmp0 = zStrdup (dp->d_name); 1482 tmp0[strlen (tmp0) - 5] = 0; 1483 t = readServiceFile (m, buff1, &s1, tmp0); 1484 free (tmp0); 1485 if (t < 0) 1486 { 1487 map *tmp00 = 1488 getMapFromMaps (m, "lenv", "message"); 1489 char tmp01[1024]; 1490 if (tmp00 != NULL) 1491 sprintf (tmp01, 1492 _ 1493 ("Unable to parse the ZCFG file: %s (%s)"), 1494 dp->d_name, tmp00->value); 1495 else 1496 sprintf (tmp01, 1497 _ 1498 ("Unable to parse the ZCFG file: %s."), 1499 dp->d_name); 1500 dup2 (saved_stdout, fileno (stdout)); 1501 errorException (m, tmp01, "InternalError", 1502 NULL); 1503 freeMaps (&m); 1504 free (m); 1505 if(zooRegistry!=NULL){ 1506 freeRegistry(&zooRegistry); 1507 free(zooRegistry); 1508 } 1509 free (orig); 1510 free (REQUEST); 1511 closedir (dirp); 1512 xmlFreeDoc (doc); 1513 xmlCleanupParser (); 1514 zooXmlCleanupNs (); 1515 return 1; 1516 } 1517 #ifdef DEBUG 1518 dumpService (s1); 1519 #endif 1520 inheritance(zooRegistry,&s1); 1521 printDescribeProcessForProcess (m, n, s1); 1522 freeService (&s1); 1523 free (s1); 1524 s1 = NULL; 1525 scount++; 1526 hasVal = 1; 1527 } 1528 } 1506 1529 } 1507 free (orig); 1508 free (REQUEST); 1509 closedir (dirp); 1510 xmlFreeDoc (doc); 1511 xmlCleanupParser (); 1512 zooXmlCleanupNs (); 1513 return 1; 1514 } 1515 rewinddir (dirp); 1516 tmps = strtok_r (NULL, ",", &saveptr); 1517 if (corig != NULL) 1518 free (corig); 1519 } 1520 } 1521 closedir (dirp); 1522 fflush (stdout); 1523 dup2 (saved_stdout, fileno (stdout)); 1524 free (orig); 1525 printDocument (m, doc, getpid ()); 1526 freeMaps (&m); 1527 free (m); 1528 if(zooRegistry!=NULL){ 1529 freeRegistry(&zooRegistry); 1530 free(zooRegistry); 1530 if (hasVal < 0) 1531 { 1532 map *tmp00 = getMapFromMaps (m, "lenv", "message"); 1533 char tmp01[1024]; 1534 if (tmp00 != NULL) 1535 sprintf (tmp01, 1536 _("Unable to parse the ZCFG file: %s (%s)"), 1537 buff, tmp00->value); 1538 else 1539 sprintf (tmp01, 1540 _("Unable to parse the ZCFG file: %s."), 1541 buff); 1542 dup2 (saved_stdout, fileno (stdout)); 1543 errorException (m, tmp01, "InvalidParameterValue", 1544 "Identifier"); 1545 freeMaps (&m); 1546 free (m); 1547 if(zooRegistry!=NULL){ 1548 freeRegistry(&zooRegistry); 1549 free(zooRegistry); 1550 } 1551 free (orig); 1552 free (REQUEST); 1553 closedir (dirp); 1554 xmlFreeDoc (doc); 1555 xmlCleanupParser (); 1556 zooXmlCleanupNs (); 1557 return 1; 1558 } 1559 rewinddir (dirp); 1560 tmps = strtok_r (NULL, ",", &saveptr); 1561 if (corig != NULL) 1562 free (corig); 1563 } 1564 } 1565 closedir (dirp); 1566 fflush (stdout); 1567 dup2 (saved_stdout, fileno (stdout)); 1568 free (orig); 1569 printDocument (m, doc, getpid ()); 1570 freeMaps (&m); 1571 free (m); 1572 if(zooRegistry!=NULL){ 1573 freeRegistry(&zooRegistry); 1574 free(zooRegistry); 1575 } 1576 free (REQUEST); 1577 free (SERVICE_URL); 1578 fflush (stdout); 1579 return 0; 1531 1580 } 1532 free (REQUEST); 1533 free (SERVICE_URL); 1534 fflush (stdout); 1535 return 0; 1536 } 1537 else if (strncasecmp (REQUEST, "Execute", strlen (REQUEST)) != 0) 1538 { 1539 errorException (m, 1540 _ 1541 ("The <request> value was not recognized. Allowed values are GetCapabilities, DescribeProcess, and Execute."), 1542 "InvalidParameterValue", "request"); 1543 #ifdef DEBUG 1544 fprintf (stderr, "No request found %s", REQUEST); 1545 #endif 1546 closedir (dirp); 1547 freeMaps (&m); 1548 free (m); 1549 if(zooRegistry!=NULL){ 1550 freeRegistry(&zooRegistry); 1551 free(zooRegistry); 1581 else if (strncasecmp (REQUEST, "Execute", strlen (REQUEST)) != 0) 1582 { 1583 map* version=getMapFromMaps(m,"main","rversion"); 1584 int vid=getVersionId(version->value); 1585 int len,j=0; 1586 for(j=0;j<nbSupportedRequests;j++){ 1587 if(requests[vid][j]!=NULL) 1588 len+=strlen(requests[vid][j])+2; 1589 else{ 1590 len+=4; 1591 break; 1592 } 1593 } 1594 char *tmpStr=(char*)malloc(len*sizeof(char)); 1595 int it=0; 1596 for(j=0;j<nbSupportedRequests;j++){ 1597 if(requests[vid][j]!=NULL){ 1598 if(it==0){ 1599 sprintf(tmpStr,"%s",requests[vid][j]); 1600 it++; 1601 }else{ 1602 char *tmpS=zStrdup(tmpStr); 1603 if(j+1<nbSupportedRequests && requests[vid][j+1]==NULL){ 1604 sprintf(tmpStr,"%s and %s",tmpS,requests[vid][j]); 1605 }else{ 1606 sprintf(tmpStr,"%s, %s",tmpS,requests[vid][j]); 1607 1608 } 1609 free(tmpS); 1610 } 1611 } 1612 else{ 1613 len+=4; 1614 break; 1615 } 1616 } 1617 char* message=(char*)malloc((61+len)*sizeof(char)); 1618 sprintf(message,"The <request> value was not recognized. Allowed values are %s.",tmpStr); 1619 errorException (m,_(message),"InvalidParameterValue", "request"); 1620 #ifdef DEBUG 1621 fprintf (stderr, "No request found %s", REQUEST); 1622 #endif 1623 closedir (dirp); 1624 freeMaps (&m); 1625 free (m); 1626 if(zooRegistry!=NULL){ 1627 freeRegistry(&zooRegistry); 1628 free(zooRegistry); 1629 } 1630 free (REQUEST); 1631 free (SERVICE_URL); 1632 fflush (stdout); 1633 return 0; 1552 1634 } 1553 free (REQUEST); 1554 free (SERVICE_URL); 1555 fflush (stdout); 1556 return 0; 1557 } 1558 closedir (dirp); 1559 } 1560 1635 closedir (dirp); 1636 } 1637 } 1638 1639 map *postRequest = NULL; 1640 postRequest = getMap (request_inputs, "xrequest"); 1641 1642 if(vid==1 && postRequest==NULL){ 1643 errorException (m,_("Unable to run Execute request using the GET HTTP method"),"InvalidParameterValue", "request"); 1644 freeMaps (&m); 1645 free (m); 1646 if(zooRegistry!=NULL){ 1647 freeRegistry(&zooRegistry); 1648 free(zooRegistry); 1649 } 1650 free (REQUEST); 1651 free (SERVICE_URL); 1652 fflush (stdout); 1653 return 0; 1654 } 1655 1561 1656 s1 = NULL; 1562 1657 s1 = (service *) malloc (SERVICE_SIZE); … … 1645 1740 hInternet = InternetOpen ( 1646 1741 #ifndef WIN32 1647 1648 #endif 1649 1650 1742 (LPCTSTR) 1743 #endif 1744 "ZooWPSClient\0", 1745 INTERNET_OPEN_TYPE_PRECONFIG, NULL, NULL, 0); 1651 1746 1652 1747 #ifndef WIN32 … … 1730 1825 #endif 1731 1826 1732 // Need to check if we need to fork to load a status enabled1733 r_inputs = NULL;1734 map *store = getMap (request_inputs, "storeExecuteResponse");1735 1827 map *status = getMap (request_inputs, "status"); 1736 /** 1737 * 05-007r7 WPS 1.0.0 page 57 : 1738 * 'If status="true" and storeExecuteResponse is "false" then the service 1739 * shall raise an exception.' 1740 */ 1741 if (status != NULL && strcmp (status->value, "true") == 0 && 1742 store != NULL && strcmp (store->value, "false") == 0) 1743 { 1744 errorException (m, 1745 _ 1746 ("The status parameter cannot be set to true if storeExecuteResponse is set to false. Please modify your request parameters."), 1747 "InvalidParameterValue", "storeExecuteResponse"); 1748 freeService (&s1); 1749 free (s1); 1750 freeMaps (&m); 1751 free (m); 1752 1753 freeMaps (&request_input_real_format); 1754 free (request_input_real_format); 1755 1756 freeMaps (&request_output_real_format); 1757 free (request_output_real_format); 1758 1759 free (REQUEST); 1760 free (SERVICE_URL); 1761 return 1; 1762 } 1763 r_inputs = getMap (request_inputs, "storeExecuteResponse"); 1828 if(vid==0){ 1829 // Need to check if we need to fork to load a status enabled 1830 r_inputs = NULL; 1831 map *store = getMap (request_inputs, "storeExecuteResponse"); 1832 /** 1833 * 05-007r7 WPS 1.0.0 page 57 : 1834 * 'If status="true" and storeExecuteResponse is "false" then the service 1835 * shall raise an exception.' 1836 */ 1837 if (status != NULL && strcmp (status->value, "true") == 0 && 1838 store != NULL && strcmp (store->value, "false") == 0) 1839 { 1840 errorException (m, 1841 _ 1842 ("The status parameter cannot be set to true if storeExecuteResponse is set to false. Please modify your request parameters."), 1843 "InvalidParameterValue", "storeExecuteResponse"); 1844 freeService (&s1); 1845 free (s1); 1846 freeMaps (&m); 1847 free (m); 1848 1849 freeMaps (&request_input_real_format); 1850 free (request_input_real_format); 1851 1852 freeMaps (&request_output_real_format); 1853 free (request_output_real_format); 1854 1855 free (REQUEST); 1856 free (SERVICE_URL); 1857 return 1; 1858 } 1859 r_inputs = getMap (request_inputs, "storeExecuteResponse"); 1860 }else{ 1861 // Define status depending on the WPS 2.0.0 mode attribute 1862 status = getMap (request_inputs, "mode"); 1863 map* mode=getMap(s1->content,"mode"); 1864 if(strcasecmp(status->value,"async")==0){ 1865 if(mode!=NULL && strcasecmp(mode->value,"async")==0) 1866 addToMap(request_inputs,"status","true"); 1867 else{ 1868 if(mode!=NULL){ 1869 // see ref. http://docs.opengeospatial.org/is/14-065/14-065.html#61 1870 errorException (m,_("The process does not permit the desired execution mode."),"NoSuchMode", mode->value); 1871 fflush (stdout); 1872 freeMaps (&m); 1873 free (m); 1874 if(zooRegistry!=NULL){ 1875 freeRegistry(&zooRegistry); 1876 free(zooRegistry); 1877 } 1878 freeMaps (&request_input_real_format); 1879 free (request_input_real_format); 1880 freeMaps (&request_output_real_format); 1881 free (request_output_real_format); 1882 free (REQUEST); 1883 free (SERVICE_URL); 1884 return 0; 1885 }else 1886 addToMap(request_inputs,"status","true"); 1887 } 1888 } 1889 else{ 1890 if(strcasecmp(status->value,"auto")==0){ 1891 if(mode!=NULL){ 1892 if(strcasecmp(mode->value,"async")==0) 1893 addToMap(request_inputs,"status","false"); 1894 else 1895 addToMap(request_inputs,"status","true"); 1896 } 1897 else 1898 addToMap(request_inputs,"status","false"); 1899 }else 1900 addToMap(request_inputs,"status","false"); 1901 } 1902 status = getMap (request_inputs, "status"); 1903 } 1904 1764 1905 int eres = SERVICE_STARTED; 1765 1906 int cpid = getpid (); … … 1808 1949 else 1809 1950 addToMap (_tmpMaps->content, "soap", "false"); 1951 1952 // Parse the session file and add it to the main maps 1810 1953 if (cgiCookie != NULL && strlen (cgiCookie) > 0) 1811 1954 { … … 1883 2026 freeMaps (&_tmpMaps); 1884 2027 free (_tmpMaps); 1885 2028 maps* bmap=NULL; 1886 2029 #ifdef DEBUG 1887 2030 dumpMap (request_inputs); … … 1907 2050 } 1908 2051 #endif 1909 char *fbkp, *fbkpid, *fbkp 1, *flog;2052 char *fbkp, *fbkpid, *fbkpres, *fbkp1, *flog; 1910 2053 FILE *f0, *f1; 1911 2054 if (status != NULL) … … 1958 2101 if (pid > 0) 1959 2102 { 1960 1961 1962 1963 2103 /** 2104 * dady : 2105 * set status to SERVICE_ACCEPTED 2106 */ 1964 2107 #ifdef DEBUG 1965 2108 fprintf (stderr, "father pid continue (origin %d) %d ...\n", cpid, … … 1975 2118 */ 1976 2119 map* usid = getMapFromMaps (m, "lenv", "uusid"); 1977 r_inputs= getMapFromMaps (m, "lenv", "osid");1978 int cpid = atoi ( r_inputs->value);2120 map* tmpm = getMapFromMaps (m, "lenv", "osid"); 2121 int cpid = atoi (tmpm->value); 1979 2122 r_inputs = getMapFromMaps (m, "main", "tmpPath"); 1980 2123 map* r_inputs1 = createMap("ServiceName", s1->name); 1981 2124 2125 // Create the filename for the result file (.res) 2126 fbkpres = 2127 (char *) 2128 malloc ((strlen (r_inputs->value) + 2129 strlen (usid->value) + 7) * sizeof (char)); 2130 sprintf (fbkpres, "%s/%s.res", r_inputs->value, usid->value); 2131 bmap = (maps *) malloc (MAPS_SIZE); 2132 bmap->name=zStrdup("status"); 2133 bmap->content=createMap("usid",usid->value); 2134 bmap->next=NULL; 2135 addToMap(bmap->content,"sid",tmpm->value); 2136 addIntToMap(bmap->content,"pid",getpid()); 2137 1982 2138 // Create PID file referencing the OS process identifier 1983 2139 fbkpid = … … 1999 2155 2000 2156 FILE* f2 = fopen (fbkp, "w+"); 2001 map* tmpm=getMapFromMaps (m, "lenv", "osid");2002 2157 fprintf(f2,"%s",tmpm->value); 2003 2158 fflush(f2); … … 2025 2180 freopen (flog, "w+", stderr); 2026 2181 fflush (stderr); 2027 2028 2182 f0 = freopen (fbkp, "w+", stdout); 2183 rewind (stdout); 2029 2184 #ifndef WIN32 2030 fclose (stdin); 2031 #endif 2032 2033 /** 2034 * set status to SERVICE_STARTED and flush stdout to ensure full 2035 * content was outputed (the file used to store the ResponseDocument). 2036 * The rewind stdout to restart writing from the bgining of the file, 2037 * this way the data will be updated at the end of the process run. 2038 */ 2039 printProcessResponse (m, request_inputs, cpid, s1, r_inputs1->value, 2040 SERVICE_STARTED, request_input_real_format, 2041 request_output_real_format); 2042 fflush (stdout); 2185 fclose (stdin); 2186 #endif 2187 2043 2188 #ifdef RELY_ON_DB 2044 2189 init_sql(m); 2045 2190 recordServiceStatus(m); 2046 recordResponse(m,fbkp); 2047 #endif 2191 #endif 2192 if(vid==0){ 2193 /** 2194 * set status to SERVICE_STARTED and flush stdout to ensure full 2195 * content was outputed (the file used to store the ResponseDocument). 2196 * The rewind stdout to restart writing from the bgining of the file, 2197 * this way the data will be updated at the end of the process run. 2198 */ 2199 printProcessResponse (m, request_inputs, cpid, s1, r_inputs1->value, 2200 SERVICE_STARTED, request_input_real_format, 2201 request_output_real_format); 2202 fflush (stdout); 2203 #ifdef RELY_ON_DB 2204 recordResponse(m,fbkp); 2205 #endif 2206 } 2207 2048 2208 fflush (stderr); 2209 2049 2210 fbkp1 = 2050 2211 (char *) … … 2116 2277 { 2117 2278 fclose (stdout); 2118 fclose (stderr);2279 //fclose (stderr); 2119 2280 /** 2120 2281 * Dump back the final file fbkp1 to fbkp … … 2122 2283 fclose (f0); 2123 2284 fclose (f1); 2285 2124 2286 FILE *f2 = fopen (fbkp1, "rb"); 2125 2287 #ifndef RELY_ON_DB … … 2129 2291 lockShm (lid); 2130 2292 #endif 2293 fclose(f0); 2131 2294 FILE *f3 = fopen (fbkp, "wb+"); 2132 2295 free (fbkp); … … 2140 2303 fclose (f3); 2141 2304 unlink (fbkpid); 2305 switch(eres){ 2306 default: 2307 case SERVICE_FAILED: 2308 setMapInMaps(bmap,"status","status",wpsStatus[1]); 2309 setMapInMaps(m,"lenv","fstate",wpsStatus[1]); 2310 break; 2311 case SERVICE_SUCCEEDED: 2312 setMapInMaps(bmap,"status","status",wpsStatus[0]); 2313 setMapInMaps(m,"lenv","fstate",wpsStatus[0]); 2314 break; 2315 } 2142 2316 #ifndef RELY_ON_DB 2317 dumpMapsToFile(bmap,fbkpres); 2143 2318 removeShmLock (m, 1); 2144 2319 #else 2145 2320 recordResponse(m,fbkp1); 2146 2321 #endif 2322 freeMaps(&bmap); 2323 free(bmap); 2147 2324 unlink (fbkp1); 2148 2325 unlink (flog); 2149 2326 unhandleStatus (m); 2150 2327 free(fbkpid); 2328 free(fbkpres); 2151 2329 free (flog); 2152 2330 free (fbkp1);
Note: See TracChangeset
for help on using the changeset viewer.