|
@@ -11,6 +11,7 @@ class Api_WfsQgis extends ApiRouteBase {// TODO: extends Api_WfsBase which exten
|
|
|
|
|
|
|
|
public $_apiUser;
|
|
public $_apiUser;
|
|
|
public $_apiBaseUri;
|
|
public $_apiBaseUri;
|
|
|
|
|
+ public $_idFiltrProces;
|
|
|
public $_dataSourceName;
|
|
public $_dataSourceName;
|
|
|
public $_tblName;
|
|
public $_tblName;
|
|
|
public $_tblSchema;
|
|
public $_tblSchema;
|
|
@@ -21,33 +22,27 @@ class Api_WfsQgis extends ApiRouteBase {// TODO: extends Api_WfsBase which exten
|
|
|
$this->setLogger($wfsLogger);
|
|
$this->setLogger($wfsLogger);
|
|
|
$this->reqDBG($request);
|
|
$this->reqDBG($request);
|
|
|
|
|
|
|
|
- /* TODO: return response xml document
|
|
|
|
|
- $responseDocument = null;
|
|
|
|
|
- try {
|
|
|
|
|
- $responseDocument = $this->wfsServerAction($request);
|
|
|
|
|
- } catch (Api_WfsException $e) {// TODO: create WfsException - http://schemas.opengis.net/wfs/1.0.0/OGC-exception.xsd
|
|
|
|
|
- //} catch (Exception $e) {// TODO: create WfsException - http://schemas.opengis.net/wfs/1.0.0/OGC-exception.xsd
|
|
|
|
|
- $responseDocument = $this->wfsExceptionAction($request, $e);
|
|
|
|
|
- }
|
|
|
|
|
- return $responseDocument;
|
|
|
|
|
- */
|
|
|
|
|
-
|
|
|
|
|
if (empty($request->segments)) {
|
|
if (empty($request->segments)) {
|
|
|
//$this->mainWpsAction($request);// show list of posible data source
|
|
//$this->mainWpsAction($request);// show list of posible data source
|
|
|
throw new HttpException("Bad Request", 400);
|
|
throw new HttpException("Bad Request", 400);
|
|
|
} else {
|
|
} else {
|
|
|
- $this->_dataSourceName = array_shift($request->segments);
|
|
|
|
|
|
|
+ $pathPart = array_shift($request->segments);
|
|
|
|
|
+ if ('filtr_proces_' == substr($pathPart, 0, 13)) {
|
|
|
|
|
+ $this->_idFiltrProces = (int)substr($pathPart, 13);
|
|
|
|
|
+ if (!$this->_idFiltrProces) throw new Api_WfsException("Wrong filtr process number");
|
|
|
|
|
+ $this->DBG("filtr procesu({$idProcesFiltr})", __LINE__, __FUNCTION__, __CLASS__);
|
|
|
|
|
+
|
|
|
|
|
+ $pathPart = array_shift($request->segments);
|
|
|
|
|
+ }
|
|
|
|
|
+ $this->_dataSourceName = $pathPart;
|
|
|
$this->DBG("_dataSourceName:$this->_dataSourceName", __LINE__, __FUNCTION__, __CLASS__);
|
|
$this->DBG("_dataSourceName:$this->_dataSourceName", __LINE__, __FUNCTION__, __CLASS__);
|
|
|
try {
|
|
try {
|
|
|
$this->dataSourceAction($request);
|
|
$this->dataSourceAction($request);
|
|
|
} catch (Api_WfsException $e) {
|
|
} catch (Api_WfsException $e) {
|
|
|
- $responseDocument = $this->wfsExceptionAction($e);
|
|
|
|
|
- header('Content-type: application/xml');
|
|
|
|
|
- echo $responseDocument;
|
|
|
|
|
|
|
+ $e->sendResponseXml();
|
|
|
} catch (Exception $e) {
|
|
} catch (Exception $e) {
|
|
|
- $responseDocument = $this->wfsExceptionAction($e);
|
|
|
|
|
- header('Content-type: application/xml');
|
|
|
|
|
- echo $responseDocument;
|
|
|
|
|
|
|
+ $wfsException = new Api_WfsException($e->getMessage(), $e->getCode(), $e);
|
|
|
|
|
+ $wfsException->sendResponseXml();
|
|
|
}
|
|
}
|
|
|
$this->DBG("END", __LINE__, __FUNCTION__, __CLASS__);
|
|
$this->DBG("END", __LINE__, __FUNCTION__, __CLASS__);
|
|
|
}
|
|
}
|
|
@@ -59,29 +54,21 @@ class Api_WfsQgis extends ApiRouteBase {// TODO: extends Api_WfsBase which exten
|
|
|
public function wfsServerAction($request) {
|
|
public function wfsServerAction($request) {
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
- public function wfsExceptionAction($e) {
|
|
|
|
|
- $dom = new DOMDocument('1.0', 'utf-8');
|
|
|
|
|
- $dom->formatOutput = true;
|
|
|
|
|
- $dom->preserveWhiteSpace = false;
|
|
|
|
|
- $rootNode = $dom->createElementNS('http://www.opengis.net/ogc', 'ServiceExceptionReport');
|
|
|
|
|
- $dom->appendChild($rootNode);
|
|
|
|
|
- $rootNode->setAttributeNS('http://www.w3.org/2000/xmlns/', 'xmlns:xsi', 'http://www.w3.org/2001/XMLSchema-instance');
|
|
|
|
|
- $rootNode->setAttributeNS('http://www.w3.org/2001/XMLSchema-instance', 'schemaLocation', 'http://www.opengis.net/ogc http://schemas.opengis.net/wfs/1.0.0/OGC-exception.xsd');
|
|
|
|
|
- $rootNode->setAttribute('version', '1.2.0');
|
|
|
|
|
-
|
|
|
|
|
- $srvExNode = $dom->createElement('ServiceException', $e->getMessage());
|
|
|
|
|
- $rootNode->appendChild($srvExNode);
|
|
|
|
|
-
|
|
|
|
|
- return $dom->saveXML();
|
|
|
|
|
- }
|
|
|
|
|
-
|
|
|
|
|
public function dataSourceAction($request) {
|
|
public function dataSourceAction($request) {
|
|
|
$document = '';
|
|
$document = '';
|
|
|
//$userAcl = User::getAcl();
|
|
//$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>';}
|
|
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 = new UserAcl($this->_apiUser->getID(), $use_cache = true);
|
|
|
$userAcl->fetchGroups();
|
|
$userAcl->fetchGroups();
|
|
|
- $userAcl->fetchAllPerms(true);
|
|
|
|
|
|
|
+ if ($this->_idFiltrProces) {
|
|
|
|
|
+ if (!$userAcl->canExecuteProcesInit($this->_idFiltrProces)) {
|
|
|
|
|
+ throw new Api_WfsException("Access Denied for given process");
|
|
|
|
|
+ }
|
|
|
|
|
+ $userAcl->fetchProcesPerms($this->_idFiltrProces, true);
|
|
|
|
|
+ } else {
|
|
|
|
|
+ $userAcl->fetchAllPerms(true);
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
DBG::_('DBG', '>2', 'userAcl', $userAcl, __CLASS__, __FUNCTION__, __LINE__);
|
|
DBG::_('DBG', '>2', 'userAcl', $userAcl, __CLASS__, __FUNCTION__, __LINE__);
|
|
|
|
|
|
|
|
$this->DBG("usr:" . $this->_apiUser->getID(), __LINE__, __FUNCTION__, __CLASS__);
|
|
$this->DBG("usr:" . $this->_apiUser->getID(), __LINE__, __FUNCTION__, __CLASS__);
|