WfsData.php 3.3 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283
  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->setBaseUri($this->_apiBaseUri);
  53. $wfsServer->run($request);
  54. exit;// TODO:? return $document;
  55. } catch (Api_WfsException $e) {
  56. $e->sendResponseXml();
  57. } catch (Exception $e) {
  58. $wfsException = new Api_WfsException($e->getMessage(), $e->getCode(), $e);
  59. $wfsException->sendResponseXml();
  60. }
  61. $this->DBG("Api_WfsData->execute() END", __LINE__);
  62. exit;
  63. // return document tree - array of arrays
  64. }
  65. public function wfsServerAction($request) {
  66. }
  67. public function mainWpsAction($request) {
  68. return array('TODO:'=>'TODO: Show main WPS GetCapabilities');
  69. }
  70. }