WfsData.php 3.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384
  1. <?php
  2. Lib::loadClass('ApiRouteBase');
  3. Lib::loadClass('ApiDataSourceTodo');// TODO: @see Entity/Source/Mysql from feature-schema-install
  4. Lib::loadClass('Api_WfsException');
  5. Lib::loadClass('Api_WfsDataServer');
  6. Lib::loadClass('UserAcl');
  7. Lib::loadClass('Api_WfsLogger');
  8. Lib::loadClass('Api_WsdlServer');
  9. class Api_WfsData extends ApiRouteBase {// TODO: extends Api_WfsBase which extends ApiBase
  10. public $_apiUser;
  11. public $_apiBaseUri;
  12. public function execute($request) {
  13. $wfsLogger = new Api_WfsLogger();
  14. $this->setLogger($wfsLogger);
  15. $this->reqDBG($request);
  16. // /wfs-data.php/default_db/?... : $request->segments = ['default_db']
  17. // /wfs-data.php/filtr_proces_5040/default_db/?... : $request->segments = ['filtr_proces_5040', 'default_db']
  18. // /wfs-data.php?... : $request->segments = []
  19. // /wfs-data.php/filtr_proces_5040/?... : $request->segments = ['filtr_proces_5040']
  20. // /wfs-data.php/wsdl : $request->segments = ['wsdl']
  21. $serverClass = 'Api_WfsDataServer';
  22. if (!empty($request->segments) && 'wsdl' == $request->segments[0]) {
  23. $serverClass = 'Api_WsdlServer';
  24. }
  25. $idFiltrProces = null;
  26. foreach ($request->segments as $pathPart) {
  27. if ('filtr_proces_' == substr($pathPart, 0, 13)) {
  28. $idFiltrProces = (int)substr($pathPart, 13);
  29. if (!$idFiltrProces) throw new Api_WfsException("Wrong filtr process number");
  30. $this->DBG("filtr procesu({$idProcesFiltr})", __LINE__, __FUNCTION__, __CLASS__);
  31. }
  32. // if ('default_db' == $pathPart) continue;// skip 'default_db'
  33. // throw new Api_WfsException("Not implemented '{$pathPart}'", 501);// skip all - wsdl work on segments
  34. }
  35. try {
  36. $this->DBG("Api_WfsData->execute() START", __LINE__);
  37. //$userAcl = User::getAcl();
  38. 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>';}
  39. $userAcl = new UserAcl($this->_apiUser->getID(), $use_cache = true);
  40. $userAcl->fetchGroups();
  41. if ($idFiltrProces) {
  42. if (!$userAcl->canExecuteProcesInit($idFiltrProces)) {
  43. throw new Api_WfsException("Access Denied for given process");
  44. }
  45. $userAcl->fetchProcesPerms($idFiltrProces, true);
  46. } else {
  47. $userAcl->fetchAllPerms(true);
  48. }
  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. $e->sendResponseXml();
  58. } catch (Exception $e) {
  59. $wfsException = new Api_WfsException($e->getMessage(), $e->getCode(), $e);
  60. $wfsException->sendResponseXml();
  61. }
  62. $this->DBG("Api_WfsData->execute() END", __LINE__);
  63. exit;
  64. // return document tree - array of arrays
  65. }
  66. public function wfsServerAction($request) {
  67. }
  68. public function mainWpsAction($request) {
  69. return array('TODO:'=>'TODO: Show main WPS GetCapabilities');
  70. }
  71. }