Sfoglia il codice sorgente

fixed Not Implemented ogc tag error message in wfs

Piotr Labudda 9 anni fa
parent
commit
1aeb1d1e12
2 ha cambiato i file con 7 aggiunte e 36 eliminazioni
  1. 3 33
      SE/se-lib/Api/WfsData.php
  2. 4 3
      SE/se-lib/ParseOgcFilter.php

+ 3 - 33
SE/se-lib/Api/WfsData.php

@@ -21,17 +21,6 @@ class Api_WfsData extends ApiRouteBase {// TODO: extends Api_WfsBase which exten
 		$this->setLogger($wfsLogger);
 		$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)) {
 			//$this->mainWpsAction($request);// show list of posible data source
 			throw new HttpException("Bad Request", 400);
@@ -41,13 +30,10 @@ class Api_WfsData extends ApiRouteBase {// TODO: extends Api_WfsBase which exten
 			try {
 				$this->dataSourceAction($request);
 			} catch (Api_WfsException $e) {
-				$responseDocument = $this->wfsExceptionAction($e);
-				header('Content-type: application/xml');
-				echo $responseDocument;
+				$e->sendResponseXml();
 			} 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("dataSourceAction() END", __LINE__);
 		}
@@ -59,22 +45,6 @@ class Api_WfsData extends ApiRouteBase {// TODO: extends Api_WfsBase which exten
 	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) {
 		$document = '';
 		//$userAcl = User::getAcl();

+ 4 - 3
SE/se-lib/ParseOgcFilter.php

@@ -1,6 +1,7 @@
 <?php
 
 Lib::loadClass('SqlQueryWhereBuilder');
+Lib::loadClass('Api_WfsException');
 
 /**
  * @usage:
@@ -23,8 +24,8 @@ class ParseOgcFilter {
 	}
 
 	public function convertToSqlQueryWhereBuilder() {
-		$ogcFilterXmlString = <<<OGC_FILTER_XML_FILE
-<?xml version="1.0" encoding="UTF-8"?>
+		$ogcFilterXmlString = '<?xml version="1.0" encoding="UTF-8"?>' . "\n";
+		$ogcFilterXmlString .= <<<OGC_FILTER_XML_FILE
 <filter xmlns="https://biuro.biall-net.pl/SE/version-git/schema/filter.xsd"
         xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
         xmlns:ogc="http://www.opengis.net/ogc">
@@ -128,7 +129,7 @@ OGC_FILTER_XML_FILE;
 				case 'not_implemented_tag': {
 					$tagName = V::get('name', '', $tag['attributes']);
 					DBG::_('DBG_DS_OGC', '>1', "Not Implemented tag '{$tagName}'", $queryWhereBuilder, __CLASS__, __FUNCTION__, __LINE__);
-					throw new HttpException("Not Implemented tag '{$tagName}'", 501);
+					throw new Api_WfsException("Not Implemented tag '{$tagName}'", 501, null, 'NotImplementedOgcTag', 'request');
 				}
 					break;
 				default: {