WfsData.php 3.3 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586
  1. <?php
  2. Lib::loadClass('ApiRouteBase');
  3. Lib::loadClass('Api_WfsException');
  4. Lib::loadClass('Api_WfsDataServer');
  5. Lib::loadClass('UserAcl');
  6. Lib::loadClass('Api_WfsLogger');
  7. Lib::loadClass('Api_WsdlServer');
  8. class Api_WfsData extends ApiRouteBase {// TODO: extends Api_WfsBase which extends ApiBase
  9. public $_apiUser;
  10. public $_apiBaseUri;
  11. public function execute($request) {
  12. $wfsLogger = new Api_WfsLogger();
  13. $this->setLogger($wfsLogger);
  14. $this->reqDBG($request);
  15. // /wfs-data.php/default_db/?... : $request->segments = ['default_db']
  16. // /wfs-data.php/filtr_proces_5040/default_db/?... : $request->segments = ['filtr_proces_5040', 'default_db']
  17. // /wfs-data.php?... : $request->segments = []
  18. // /wfs-data.php/filtr_proces_5040/?... : $request->segments = ['filtr_proces_5040']
  19. // /wfs-data.php/wsdl : $request->segments = ['wsdl']
  20. $serverClass = 'Api_WfsDataServer';
  21. if (!empty($request->segments) && 'wsdl' == $request->segments[0]) {
  22. $serverClass = 'Api_WsdlServer';
  23. }
  24. $idFiltrProces = null;
  25. foreach ($request->segments as $pathPart) {
  26. if ('filtr_proces_' == substr($pathPart, 0, 13)) {
  27. $idFiltrProces = (int)substr($pathPart, 13);
  28. if (!$idFiltrProces) throw new Api_WfsException("Wrong filtr process number");
  29. $this->DBG("filtr procesu({$idProcesFiltr})", __LINE__, __FUNCTION__, __CLASS__);
  30. }
  31. // if ('default_db' == $pathPart) continue;// skip 'default_db'
  32. // throw new Api_WfsException("Not implemented '{$pathPart}'", 501);// skip all - wsdl work on segments
  33. }
  34. try {
  35. $this->DBG("Api_WfsData->execute() START", __LINE__);
  36. //$userAcl = User::getAcl();
  37. IF(V::get('DBG','',$_GET)){echo'<pre style="max-height:200px;overflow:auto;border:1px solid red;text-align:left;">user (' . __CLASS__ . '::' . __FUNCTION__ . ':' . __LINE__ . '): ';print_r($this->_apiUser);echo'</pre>';}
  38. $userAcl = new UserAcl($this->_apiUser->getID(), $use_cache = true);
  39. $userAcl->fetchGroups();
  40. if ($idFiltrProces) {
  41. if (!$userAcl->canExecuteProcesInit($idFiltrProces)) {
  42. throw new Api_WfsException("Access Denied for given process");
  43. }
  44. $userAcl->fetchProcesPerms($idFiltrProces);
  45. } else {
  46. $userAcl->fetchAllPerms();
  47. }
  48. User::getAcl($userAcl);// force set acl
  49. IF(V::get('DBG','',$_GET)){echo'<pre style="max-height:200px;overflow:auto;border:1px solid red;text-align:left;">$userAcl (' . __CLASS__ . '::' . __FUNCTION__ . ':' . __LINE__ . '): ';print_r($userAcl);echo'</pre>';}
  50. $this->DBG("usr:" . $this->_apiUser->getID(), __LINE__, __FUNCTION__, __CLASS__);
  51. $wfsServer = new $serverClass($userAcl);
  52. $wfsServer->setLogger($this->_logger);
  53. $wfsServer->setBaseUri($this->_apiBaseUri);
  54. $wfsServer->run($request);
  55. exit;// TODO:? return $document;
  56. } catch (Api_WfsException $e) {
  57. DBG::logAuth($e);
  58. $e->sendResponseXml();
  59. } catch (Exception $e) {
  60. DBG::logAuth($e);
  61. $wfsException = new Api_WfsException($e->getMessage(), $e->getCode(), $e);
  62. $wfsException->sendResponseXml();
  63. }
  64. $this->DBG("Api_WfsData->execute() END", __LINE__);
  65. exit;
  66. // return document tree - array of arrays
  67. }
  68. public function wfsServerAction($request) {
  69. }
  70. public function mainWpsAction($request) {
  71. return array('TODO:'=>'TODO: Show main WPS GetCapabilities');
  72. }
  73. }