|
@@ -4,6 +4,7 @@ Lib::loadClass('Api_WfsException');
|
|
|
Lib::loadClass('Api_WfsGeomTypeConverter');
|
|
Lib::loadClass('Api_WfsGeomTypeConverter');
|
|
|
Lib::loadClass('Api_WfsNs');
|
|
Lib::loadClass('Api_WfsNs');
|
|
|
Lib::loadClass('Request');
|
|
Lib::loadClass('Request');
|
|
|
|
|
+Lib::loadClass('Core_AclHelper');
|
|
|
|
|
|
|
|
class Api_WfsServerBase {
|
|
class Api_WfsServerBase {
|
|
|
|
|
|
|
@@ -26,34 +27,17 @@ class Api_WfsServerBase {
|
|
|
return $this->_apiBaseUri;
|
|
return $this->_apiBaseUri;
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
- public function isAllowedFeatureType($nsPrefix, $type) {
|
|
|
|
|
- if ('p5_' != substr($nsPrefix, 0, 3)) return false;
|
|
|
|
|
- if ('p5_default_db' == $nsPrefix) {
|
|
|
|
|
- $typeName = "p5_default_db:{$type}";
|
|
|
|
|
- try {
|
|
|
|
|
- $acl = $this->getAclFromTypeName($typeName);
|
|
|
|
|
- } catch (Exception $e) {
|
|
|
|
|
- return false;
|
|
|
|
|
- }
|
|
|
|
|
- if ($acl) {
|
|
|
|
|
- return true;
|
|
|
|
|
- }
|
|
|
|
|
- } else if ('p5_objects' == $nsPrefix) {
|
|
|
|
|
- // TODO: generate class name like in: UserAcl->getObjectAcl($sourceName = $nsPrefix, $objName = $type)
|
|
|
|
|
- $objClassName = "Schema_{$type}StorageAcl";
|
|
|
|
|
- if (Lib::tryLoadClass($objClassName)) return true;
|
|
|
|
|
- }
|
|
|
|
|
- return false;
|
|
|
|
|
- }
|
|
|
|
|
-
|
|
|
|
|
/**
|
|
/**
|
|
|
* @param string $typeName - 'p5_default_db:TEST_PERMS'
|
|
* @param string $typeName - 'p5_default_db:TEST_PERMS'
|
|
|
*/
|
|
*/
|
|
|
public function getAclFromTypeName($typeName) {
|
|
public function getAclFromTypeName($typeName) {
|
|
|
$typeEx = explode(':', $typeName);
|
|
$typeEx = explode(':', $typeName);
|
|
|
|
|
+ $sourceName = null;
|
|
|
if (2 != count($typeEx)) throw new Api_WfsException("Could not get acl for '{$typeName}' - syntax error");
|
|
if (2 != count($typeEx)) throw new Api_WfsException("Could not get acl for '{$typeName}' - syntax error");
|
|
|
- if ('p5_' != substr($typeEx[0], 0, 3)) throw new Api_WfsException("Could not get acl for '{$typeName}' - prefix error");
|
|
|
|
|
- $sourceName = substr($typeEx[0], 3);
|
|
|
|
|
|
|
+ if ('p5_' == substr($typeEx[0], 0, 3)) $sourceName = substr($typeEx[0], 3);
|
|
|
|
|
+ else if ('default_db__x3A__' == substr($typeEx[0], 0, 17)) $sourceName = 'default_db';
|
|
|
|
|
+ else if ('default_objects' == $typeEx[0]) $sourceName = 'default_objects';
|
|
|
|
|
+ if (!$sourceName) throw new Api_WfsException("Type not found '{$typeName}'", 404);
|
|
|
$objName = $typeEx[1];
|
|
$objName = $typeEx[1];
|
|
|
$acl = $this->_usrAcl->getObjectAcl($sourceName, $objName);
|
|
$acl = $this->_usrAcl->getObjectAcl($sourceName, $objName);
|
|
|
if (!$acl) throw new Api_WfsException("Could not get acl for '{$typeName}'");
|
|
if (!$acl) throw new Api_WfsException("Could not get acl for '{$typeName}'");
|
|
@@ -150,7 +134,20 @@ class Api_WfsServerBase {
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
public function _getCapabilities($wfsServerUrl, $serviceTitle, $serviceDescription) {
|
|
public function _getCapabilities($wfsServerUrl, $serviceTitle, $serviceDescription) {
|
|
|
- echo '<?xml version="1.0" encoding="UTF-8"?>';
|
|
|
|
|
|
|
+ if (V::get('DBG_ACL', '', $_GET)) {
|
|
|
|
|
+ {
|
|
|
|
|
+ echo "Core_AclHelper::getAclList = [" . "\n";
|
|
|
|
|
+ foreach (Core_AclHelper::getAclList() as $typeName) {
|
|
|
|
|
+ echo "|\t{$typeName}" . "\n";
|
|
|
|
|
+ }
|
|
|
|
|
+ echo "]// .EOF Core_AclHelper::getAclList" . "\n";
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ $fullTblAclList = $this->_usrAcl->getTablesAcl();
|
|
|
|
|
+ print_r($fullTblAclList);
|
|
|
|
|
+ die("\n" . '.EOF - DBG_ACL');
|
|
|
|
|
+ }
|
|
|
|
|
+ echo '<?xml version="1.0" encoding="UTF-8"?>' . "\n";
|
|
|
?>
|
|
?>
|
|
|
<WFS_Capabilities
|
|
<WFS_Capabilities
|
|
|
xmlns="http://www.opengis.net/wfs"
|
|
xmlns="http://www.opengis.net/wfs"
|
|
@@ -170,12 +167,12 @@ class Api_WfsServerBase {
|
|
|
</Service>
|
|
</Service>
|
|
|
<Capability>
|
|
<Capability>
|
|
|
<Request>
|
|
<Request>
|
|
|
- <?php $this->_printGetCapabilitiesXml($wfsServerUrl); ?>
|
|
|
|
|
- <?php $this->_printDescribeFeatureTypeXml($wfsServerUrl); ?>
|
|
|
|
|
- <?php $this->_printGetFeatureXml($wfsServerUrl); ?>
|
|
|
|
|
- <?php $this->_printTransactionXml($wfsServerUrl); ?>
|
|
|
|
|
- <?php $this->_printLockFeatureXml($wfsServerUrl); ?>
|
|
|
|
|
- <?php $this->_printGetFeatureWithLockXml($wfsServerUrl); ?>
|
|
|
|
|
|
|
+<?php $this->_printGetCapabilitiesXml($wfsServerUrl); ?>
|
|
|
|
|
+<?php $this->_printDescribeFeatureTypeXml($wfsServerUrl); ?>
|
|
|
|
|
+<?php $this->_printGetFeatureXml($wfsServerUrl); ?>
|
|
|
|
|
+<?php $this->_printTransactionXml($wfsServerUrl); ?>
|
|
|
|
|
+<?php $this->_printLockFeatureXml($wfsServerUrl); ?>
|
|
|
|
|
+<?php $this->_printGetFeatureWithLockXml($wfsServerUrl); ?>
|
|
|
</Request>
|
|
</Request>
|
|
|
</Capability>
|
|
</Capability>
|
|
|
<FeatureTypeList>
|
|
<FeatureTypeList>
|
|
@@ -186,7 +183,7 @@ class Api_WfsServerBase {
|
|
|
<Delete />
|
|
<Delete />
|
|
|
<Lock />
|
|
<Lock />
|
|
|
</Operations>
|
|
</Operations>
|
|
|
- <?php $this->_printFeatureTypeListXml(); ?>
|
|
|
|
|
|
|
+<?php $this->_printFeatureTypeListXml(); ?>
|
|
|
</FeatureTypeList>
|
|
</FeatureTypeList>
|
|
|
<ogc:Filter_Capabilities>
|
|
<ogc:Filter_Capabilities>
|
|
|
<ogc:Spatial_Capabilities>
|
|
<ogc:Spatial_Capabilities>
|
|
@@ -585,13 +582,13 @@ class Api_WfsServerBase {
|
|
|
|
|
|
|
|
public function _printFeatureTypeListXml() {
|
|
public function _printFeatureTypeListXml() {
|
|
|
$featureTypes = array();
|
|
$featureTypes = array();
|
|
|
- $tblsAcl = $this->_getTableAclList();
|
|
|
|
|
- foreach ($tblsAcl as $tblAcl) {
|
|
|
|
|
|
|
+ foreach ($this->_getTableAclList() as $tblAcl) {
|
|
|
$dataSourceName = 'default_db';// TODO: getSourceName
|
|
$dataSourceName = 'default_db';// TODO: getSourceName
|
|
|
$tblName = $tblAcl->getName();
|
|
$tblName = $tblAcl->getName();
|
|
|
$usrObjList[] = array($dataSourceName, $tblName);
|
|
$usrObjList[] = array($dataSourceName, $tblName);
|
|
|
$featureType = array();
|
|
$featureType = array();
|
|
|
$featureType['ns'] = "p5_{$dataSourceName}";
|
|
$featureType['ns'] = "p5_{$dataSourceName}";
|
|
|
|
|
+ $featureType['Name'] = $tblAcl->getName();
|
|
|
$featureType['Title'] = $tblAcl->getRawLabel();
|
|
$featureType['Title'] = $tblAcl->getRawLabel();
|
|
|
$featureType['Abstract'] = $tblAcl->getRawOpis();
|
|
$featureType['Abstract'] = $tblAcl->getRawOpis();
|
|
|
$featureType['Keywords'] = array();
|
|
$featureType['Keywords'] = array();
|
|
@@ -605,23 +602,21 @@ class Api_WfsServerBase {
|
|
|
$featureType['LatLongBoundingBox']['miny'] = "38.8575126897477";
|
|
$featureType['LatLongBoundingBox']['miny'] = "38.8575126897477";
|
|
|
$featureType['LatLongBoundingBox']['maxx'] = "9.838674658246807";
|
|
$featureType['LatLongBoundingBox']['maxx'] = "9.838674658246807";
|
|
|
$featureType['LatLongBoundingBox']['maxy'] = "41.31378404137082";
|
|
$featureType['LatLongBoundingBox']['maxy'] = "41.31378404137082";
|
|
|
- $featureTypes[$tblName] = $featureType;
|
|
|
|
|
|
|
+ $featureTypes[] = $featureType;
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
- function __generateObjectFeatureType($name) {
|
|
|
|
|
|
|
+ foreach (Core_AclHelper::getAclList() as $typeName) {
|
|
|
|
|
+ $exTypeName = explode(':', $typeName);
|
|
|
$featureType = array();
|
|
$featureType = array();
|
|
|
- $featureType['ns'] = "p5_objects";
|
|
|
|
|
- $featureType['Title'] = $name;
|
|
|
|
|
- $featureType['Abstract'] = $name;
|
|
|
|
|
- $featureType['Keywords'] = $name;
|
|
|
|
|
|
|
+ $featureType['ns'] = $exTypeName[0];
|
|
|
|
|
+ $featureType['Name'] = $exTypeName[1];
|
|
|
|
|
+ $featureType['Title'] = $exTypeName[1];
|
|
|
|
|
+ $featureType['Abstract'] = $exTypeName[1];
|
|
|
|
|
+ $featureType['Keywords'] = $exTypeName[1];
|
|
|
$featureType['SRS'] = "EPSG:4326";
|
|
$featureType['SRS'] = "EPSG:4326";
|
|
|
- return $featureType;
|
|
|
|
|
|
|
+ $featureTypes[] = $featureType;
|
|
|
}
|
|
}
|
|
|
- $featureTypes['AccessOwner'] = __generateObjectFeatureType("AccessOwner");
|
|
|
|
|
- $featureTypes['AccessGroup'] = __generateObjectFeatureType("AccessGroup");
|
|
|
|
|
- $featureTypes['File'] = __generateObjectFeatureType("Pliki");
|
|
|
|
|
- $featureTypes['Korespondencja'] = __generateObjectFeatureType("Korespondencja");
|
|
|
|
|
- $featureTypes['TestPerms'] = __generateObjectFeatureType("TestPerms");
|
|
|
|
|
|
|
+
|
|
|
/*
|
|
/*
|
|
|
<FeatureType>
|
|
<FeatureType>
|
|
|
<Name>ppr06:AMBITIPAESAGGIO</Name>
|
|
<Name>ppr06:AMBITIPAESAGGIO</Name>
|
|
@@ -633,9 +628,10 @@ class Api_WfsServerBase {
|
|
|
</FeatureType>
|
|
</FeatureType>
|
|
|
*/
|
|
*/
|
|
|
$featureTypesXml = '';
|
|
$featureTypesXml = '';
|
|
|
- foreach ($featureTypes as $tblName => $feature) {
|
|
|
|
|
- $featureTypesXml .= " " . '<FeatureType>' . "\n";
|
|
|
|
|
- $featureTypesXml .= " " . '<Name>' . "{$feature['ns']}:{$tblName}" . '</Name>' . "\n";
|
|
|
|
|
|
|
+ foreach ($featureTypes as $feature) {
|
|
|
|
|
+ $nsUriFeature = Api_WfsNs::getNsUri($feature['ns']);
|
|
|
|
|
+ $featureTypesXml .= " " . '<FeatureType xmlns:' . $feature['ns'] . '="' . $nsUriFeature . '">' . "\n";
|
|
|
|
|
+ $featureTypesXml .= " " . '<Name>' . "{$feature['ns']}:{$feature['Name']}" . '</Name>' . "\n";
|
|
|
$featureTypesXml .= " " . '<Title>' . "{$feature['Title']}" . '</Title>' . "\n";
|
|
$featureTypesXml .= " " . '<Title>' . "{$feature['Title']}" . '</Title>' . "\n";
|
|
|
if (!empty($feature['Abstract'])) {
|
|
if (!empty($feature['Abstract'])) {
|
|
|
$featureTypesXml .= " " . '<Abstract>' . "{$feature['Abstract']}" . '</Abstract>' . "\n";
|
|
$featureTypesXml .= " " . '<Abstract>' . "{$feature['Abstract']}" . '</Abstract>' . "\n";
|
|
@@ -1392,9 +1388,6 @@ if($DBG){echo 'L.' . __LINE__ . ' $validateConvertedTransactionXsdString:';print
|
|
|
|
|
|
|
|
$typeName = "{$nsPrefix}:{$type}";
|
|
$typeName = "{$nsPrefix}:{$type}";
|
|
|
$acl = $this->getAclFromTypeName($typeName);
|
|
$acl = $this->getAclFromTypeName($typeName);
|
|
|
- if (!$this->isAllowedFeatureType($nsPrefix, $type)) {
|
|
|
|
|
- throw new Api_WfsException("Could not find type: " . htmlspecialchars($type));
|
|
|
|
|
- }
|
|
|
|
|
$typeName = $type . 'Type';
|
|
$typeName = $type . 'Type';
|
|
|
$fldList = $this->_getFieldListFromAcl($acl);
|
|
$fldList = $this->_getFieldListFromAcl($acl);
|
|
|
|
|
|
|
@@ -1553,7 +1546,7 @@ if($DBG){echo 'L.' . __LINE__ . ' $validateConvertedTransactionXsdString:';print
|
|
|
try {
|
|
try {
|
|
|
$acl = $this->getAclFromTypeName($typeName = "p5_{$dataSourceName}:{$tblName}");
|
|
$acl = $this->getAclFromTypeName($typeName = "p5_{$dataSourceName}:{$tblName}");
|
|
|
} catch (Exception $e) {
|
|
} catch (Exception $e) {
|
|
|
- // TODO: error log $e->getMessage();
|
|
|
|
|
|
|
+ // echo "Error for table({$tblName}): " . $e->getMessage() . "\n";
|
|
|
}
|
|
}
|
|
|
if (!$acl) {
|
|
if (!$acl) {
|
|
|
// TODO: error log msg
|
|
// TODO: error log msg
|