| 1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889 |
- <?php
- Lib::loadClass('ApiRouteBase');
- Lib::loadClass('Api_WfsException');
- Lib::loadClass('Api_WpsV1_Server');
- Lib::loadClass('UserAcl');
- Lib::loadClass('Api_WfsLogger');
- Lib::loadClass('Api_WsdlServer');
- Lib::loadClass('Type_ApiRequest');
- class Api_Wps extends ApiRouteBase {// TODO: extends Api_WfsBase which extends ApiBase
- public $_apiUser;
- public $_apiBaseUri;
- public function execute(Type_ApiRequest $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 = '';
- $version = V::get('version', '1.0.0', $request);
- $version = (!$version) ? '1.0.0' : $version;
- switch ($version) {
- case '1.0.0': $serverClass = 'Api_WpsV1_Server'; break;
- default: throw new Exception("WPS API version {$request->version} not supported");
- }
- // 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);
- } else {
- $userAcl->fetchAllPerms();
- }
- User::getAcl($userAcl);// force set acl
- 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); // Api_WpsV1_Server, TODO: Api_WpsV2_Server
- $wfsServer->setLogger($this->_logger);
- $wfsServer->setBaseUri($this->_apiBaseUri);
- $wfsServer->run($request);
- exit;// TODO:? return $document;
- } catch (Api_OwsException $e) {
- DBG::logAuth($e);
- $e->sendResponseXml();
- } catch (Api_WfsException $e) {
- DBG::logAuth($e);
- $e->sendResponseXml();
- } catch (Exception $e) {
- DBG::logAuth($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
- }
- }
|