Changeset 654 for trunk/zoo-project/zoo-kernel/response_print.c
- Timestamp:
- Jun 15, 2015, 1:47:59 PM (9 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
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
Note: See TracChangeset
for help on using the changeset viewer.