| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384 |
- <?php
- Lib::loadClass('ApiRouteBase');
- Lib::loadClass('ApiDataSourceTodo');// TODO: @see Entity/Source/Mysql from feature-schema-install
- Lib::loadClass('Api_WfsException');
- Lib::loadClass('Api_WfsDataServer');
- Lib::loadClass('UserAcl');
- Lib::loadClass('Api_WfsLogger');
- Lib::loadClass('Api_WsdlServer');
- class Api_WfsData extends ApiRouteBase {// TODO: extends Api_WfsBase which extends ApiBase
- public $_apiUser;
- public $_apiBaseUri;
- public function execute($request) {
- $wfsLogger = new Api_WfsLogger();
- $this->setLogger($wfsLogger);
- $this->reqDBG($request);
- // /wfs-data.php/default_db/?... : $request->segments = ['default_db']
- // /wfs-data.php/filtr_proces_5040/default_db/?... : $request->segments = ['filtr_proces_5040', 'default_db']
- // /wfs-data.php?... : $request->segments = []
- // /wfs-data.php/filtr_proces_5040/?... : $request->segments = ['filtr_proces_5040']
- // /wfs-data.php/wsdl : $request->segments = ['wsdl']
- $serverClass = 'Api_WfsDataServer';
- if (!empty($request->segments) && 'wsdl' == $request->segments[0]) {
- $serverClass = 'Api_WsdlServer';
- }
- $idFiltrProces = null;
- foreach ($request->segments as $pathPart) {
- if ('filtr_proces_' == substr($pathPart, 0, 13)) {
- $idFiltrProces = (int)substr($pathPart, 13);
- if (!$idFiltrProces) throw new Api_WfsException("Wrong filtr process number");
- $this->DBG("filtr procesu({$idProcesFiltr})", __LINE__, __FUNCTION__, __CLASS__);
- }
- // if ('default_db' == $pathPart) continue;// skip 'default_db'
- // throw new Api_WfsException("Not implemented '{$pathPart}'", 501);// skip all - wsdl work on segments
- }
- try {
- $this->DBG("Api_WfsData->execute() START", __LINE__);
- //$userAcl = User::getAcl();
- 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>';}
- $userAcl = new UserAcl($this->_apiUser->getID(), $use_cache = true);
- $userAcl->fetchGroups();
- if ($idFiltrProces) {
- if (!$userAcl->canExecuteProcesInit($idFiltrProces)) {
- throw new Api_WfsException("Access Denied for given process");
- }
- $userAcl->fetchProcesPerms($idFiltrProces, true);
- } else {
- $userAcl->fetchAllPerms(true);
- }
- 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>';}
- $this->DBG("usr:" . $this->_apiUser->getID(), __LINE__, __FUNCTION__, __CLASS__);
- $wfsServer = new $serverClass($userAcl);
- $wfsServer->setLogger($this->_logger);
- $wfsServer->setBaseUri($this->_apiBaseUri);
- $wfsServer->run($request);
- exit;// TODO:? return $document;
- } catch (Api_WfsException $e) {
- $e->sendResponseXml();
- } catch (Exception $e) {
- $wfsException = new Api_WfsException($e->getMessage(), $e->getCode(), $e);
- $wfsException->sendResponseXml();
- }
- $this->DBG("Api_WfsData->execute() END", __LINE__);
- exit;
- // return document tree - array of arrays
- }
- public function wfsServerAction($request) {
- }
- public function mainWpsAction($request) {
- return array('TODO:'=>'TODO: Show main WPS GetCapabilities');
- }
- }
|