Sfoglia il codice sorgente

fixed targetNamespace in WFS - use from Acl

Piotr Labudda 9 anni fa
parent
commit
69dd418f56

+ 2 - 1
SE/se-lib/Api/WfsNs.php

@@ -9,7 +9,7 @@ class Api_WfsNs {
     $listNs = array();
     $baseNsUri = self::getBaseWfsUri();
     $listNs["{$baseNsUri}"] = 'p5';
-		$listNs["{$baseNsUri}/default_db"] = 'p5_default_db';
+		$listNs["{$baseNsUri}/default_db"] = 'default_db';
 		$listNs["{$baseNsUri}/default_objects"] = 'default_objects';
 		$listNs["{$baseNsUri}/objects"] = 'p5_objects';
 		return $listNs;
@@ -21,6 +21,7 @@ class Api_WfsNs {
     $nsMap = array_flip($listNs);
     $nsUri = V::get($nsPrefix, null, $nsMap);
     if (!$nsUri) {
+      if ('p5_default_db' == $nsPrefix) return V::get('default_db', null, $nsMap);
       if ('default_objects' == $nsPrefix) return V::get('p5_objects', null, $nsMap);
       if ('default_db__x3A__' == substr($nsPrefix, 0, 17)) return $nsMap['p5_default_db'] . "/" . substr($nsPrefix, 17);
     }

+ 4 - 7
SE/se-lib/Api/WfsServerBase.php

@@ -1374,7 +1374,7 @@ if($DBG){echo 'L.' . __LINE__ . ' $validateConvertedTransactionXsdString:';print
 			$rootNode->setAttributeNS('http://www.w3.org/2000/xmlns/', "xmlns:{$prefix}", $uri);
 		}
 		$rootNode->setAttribute('elementFormDefault', 'qualified');
-		$rootNode->setAttribute('targetNamespace', Api_WfsNs::getNsUri('p5_default_db'));// TODO:? what targetNamespace if showing types from p5_objects and p5_default_db
+		// $rootNode->setAttribute('targetNamespace', Api_WfsNs::getNsUri('p5_default_db'));// TODO:? what targetNamespace if showing types from p5_objects and p5_default_db
 		{// <xsd:import namespace="http://www.opengis.net/gml" schemaLocation="...../gml/2.1.2/feature.xsd"/>
 			$elNode = $dom->createElementNS('http://www.w3.org/2001/XMLSchema', 'xsd:import');
 			$rootNode->appendChild($elNode);
@@ -1388,6 +1388,7 @@ if($DBG){echo 'L.' . __LINE__ . ' $validateConvertedTransactionXsdString:';print
 
 			$typeName = "{$nsPrefix}:{$type}";
 			$acl = $this->getAclFromTypeName($typeName);
+			$rootNode->setAttribute('targetNamespace', Api_WfsNs::getNsUri($acl->getSourceName()));
 			$typeName = $type . 'Type';
 			$fldList = $this->_getFieldListFromAcl($acl);
 
@@ -1420,7 +1421,6 @@ if($DBG){echo 'L.' . __LINE__ . ' $validateConvertedTransactionXsdString:';print
 				}
 				$elNode->setAttribute('minOccurs', $minOccurs);
 				$elNode->setAttribute('maxOccurs', '1');
-				$elNode->setAttribute('nillable', 'true');
 				$fldType = $acl->getXsdFieldType($fldName);
 				if (!$simple && $acl->isEnumerationField($fldName)) {
 					$fldType = "{$nsPrefix}:{$fldName}Type";
@@ -1437,6 +1437,7 @@ if($DBG){echo 'L.' . __LINE__ . ' $validateConvertedTransactionXsdString:';print
 				} else {
 					$elNode->setAttribute('name', $fldName);
 					$elNode->setAttribute('type', $fldType);
+					$elNode->setAttribute('nillable', 'true');// nillable not allowed in ref
 				}
 
 				if (!$simple) {
@@ -1456,11 +1457,7 @@ if($DBG){echo 'L.' . __LINE__ . ' $validateConvertedTransactionXsdString:';print
 			$rootNode->appendChild($elNode);
 			$elNode->setAttribute('name', $type);
 			$elNode->setAttribute('type', $nsPrefix . ':' . $typeName);// TODO: $acl->getSourceName() != $nsPrefix
-			if ($simple) {
-				$elNode->setAttribute('substitutionGroup', 'gml:_Feature');
-			} else {
-				$elNode->setAttribute('substitutionGroup', 'gml:AbstractFeature');
-			}
+			$elNode->setAttribute('substitutionGroup', 'gml:_Feature');// gml:AbstractFeature in gml 3
 
 			foreach ($fldList as $fldName) {
 				$fldType = $acl->getXsdFieldType($fldName);

+ 1 - 1
SE/se-lib/Schema/TestPermsStorageAcl.php

@@ -10,7 +10,7 @@ class Schema_TestPermsStorageAcl extends Core_AclBase {
     // DBG::_(true, true, "parentAcl", $this->parentAcl, __CLASS__, __FUNCTION__, __LINE__);
   }
   public function getNamespace() { return 'default_objects/' . $this->getName(); }
-  public function getSourceName() { return 'objects'; }
+  public function getSourceName() { return 'default_objects'; }
   public function init($force = false) {}
   public function isInitialized() { return true; }
   public function getName() { return 'TestPerms'; }