|
@@ -37,12 +37,10 @@ class Api_WfsServerBase {
|
|
|
if ($acl) {
|
|
if ($acl) {
|
|
|
return true;
|
|
return true;
|
|
|
}
|
|
}
|
|
|
- } else if ('p5_objects' == $nsPrefix && 'File' == $type) {
|
|
|
|
|
- return true;
|
|
|
|
|
- } else if ('p5_objects' == $nsPrefix && 'TestPerms' == $type) {
|
|
|
|
|
- return true;
|
|
|
|
|
- } else if ('p5_objects' == $nsPrefix && 'Korespondencja' == $type) {
|
|
|
|
|
- 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;
|
|
return false;
|
|
|
}
|
|
}
|
|
@@ -591,9 +589,7 @@ class Api_WfsServerBase {
|
|
|
public function _parseTransactionXmlStruct($requestXml, $requestXmlTags) {
|
|
public function _parseTransactionXmlStruct($requestXml, $requestXmlTags) {
|
|
|
$DBG = V::get('DBG_XML', 0, $_GET, 'int');// TODO: Profiler
|
|
$DBG = V::get('DBG_XML', 0, $_GET, 'int');// TODO: Profiler
|
|
|
$rootTagName = V::get('tag', '', $requestXmlTags[0]);
|
|
$rootTagName = V::get('tag', '', $requestXmlTags[0]);
|
|
|
- if ('Transaction' != $rootTagName) {
|
|
|
|
|
- throw new Api_WfsException("Parse Request XML Error - Missing Transaction as root xml tag", __LINE__, null, 'TransactionParseError', 'request');
|
|
|
|
|
- }
|
|
|
|
|
|
|
+ if ('Transaction' != $rootTagName) throw new Api_WfsException("Parse Request XML Error - Missing Transaction as root xml tag", __LINE__, null, 'TransactionParseError', 'request');
|
|
|
|
|
|
|
|
// TODO: special actions if action on nested objects
|
|
// TODO: special actions if action on nested objects
|
|
|
// 1. convert request: wfs.transaction.convert-wfs-request.xsl
|
|
// 1. convert request: wfs.transaction.convert-wfs-request.xsl
|
|
@@ -679,16 +675,10 @@ class Api_WfsServerBase {
|
|
|
}
|
|
}
|
|
|
$action['typeName'] = $typeName;
|
|
$action['typeName'] = $typeName;
|
|
|
$actionXmlTags[$actionIdx] = $action;
|
|
$actionXmlTags[$actionIdx] = $action;
|
|
|
- // $lvl = $action['tags'][0]['level'];
|
|
|
|
|
- // for ($i = 1, $cnt = count($action['tags']); $i < $cnt - 1; $i++) {
|
|
|
|
|
- // $tag = $action['tags'][$i];
|
|
|
|
|
- // // if($DBG){echo 'L.' . __LINE__ . " actionXmlTags loop({$i}) \$tag:";print_r($tag);echo "\n";}
|
|
|
|
|
- // // if ($tag['level'] > $lvl) $isDeepStructure = true;
|
|
|
|
|
- // }
|
|
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
- {
|
|
|
|
|
|
|
+ {// validate
|
|
|
// if($DBG){echo 'L.' . __LINE__ . ' before validate $actionXmlTags:';print_r($actionXmlTags);echo "\n";}
|
|
// if($DBG){echo 'L.' . __LINE__ . ' before validate $actionXmlTags:';print_r($actionXmlTags);echo "\n";}
|
|
|
foreach ($actionXmlTags as $actionIdx => $action) {
|
|
foreach ($actionXmlTags as $actionIdx => $action) {
|
|
|
if ('Insert' == $action['action']) {
|
|
if ('Insert' == $action['action']) {
|
|
@@ -708,6 +698,9 @@ class Api_WfsServerBase {
|
|
|
}
|
|
}
|
|
|
// continue;// TODO: validate all by type
|
|
// continue;// TODO: validate all by type
|
|
|
}
|
|
}
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ {// execute
|
|
|
$returnIds = array();
|
|
$returnIds = array();
|
|
|
$changesList = array();
|
|
$changesList = array();
|
|
|
foreach ($actionXmlTags as $actionIdx => $action) {
|
|
foreach ($actionXmlTags as $actionIdx => $action) {
|
|
@@ -730,326 +723,7 @@ class Api_WfsServerBase {
|
|
|
} else throw new Exception("TODO: {$action['action']} action not implemented", 501);
|
|
} else throw new Exception("TODO: {$action['action']} action not implemented", 501);
|
|
|
}
|
|
}
|
|
|
if($DBG){echo 'L.' . __LINE__ . ' $changesList:';print_r($changesList);echo "\n";}
|
|
if($DBG){echo 'L.' . __LINE__ . ' $changesList:';print_r($changesList);echo "\n";}
|
|
|
-
|
|
|
|
|
- return $this->_transactionResponse($changesList);
|
|
|
|
|
-
|
|
|
|
|
- if($DBG){echo 'L.' . __LINE__ . ' $actionXmlTags:';print_r($actionXmlTags);echo "\n";}
|
|
|
|
|
- $requestNsUriList = array();// [ uri, ... ]
|
|
|
|
|
- $requestNsUriToPrefixMap = array();// uri => prefix
|
|
|
|
|
- $requestNsPrefixToUriMap = array();// prefix => uri
|
|
|
|
|
- {
|
|
|
|
|
- $tag = reset($requestXmlTags);// first tag: 'Transaction'
|
|
|
|
|
- $itemsNsList = Api_WfsNs::getNsList();
|
|
|
|
|
- if($DBG){echo 'L.' . __LINE__ . ' $itemsNsList:';print_r($itemsNsList);echo "\n";}
|
|
|
|
|
- foreach ($tag['attributes'] as $attrName => $attrVal) {
|
|
|
|
|
- if ('xmlns:' !== substr($attrName, 0, 6)) continue;
|
|
|
|
|
- if ('xmlns:xsi' === $attrName) continue;
|
|
|
|
|
- if ('xmlns:gml' === $attrName) continue;
|
|
|
|
|
- if (array_key_exists($attrVal, $itemsNsList)) {
|
|
|
|
|
- $requestNsUriList[$attrVal] = true;// ns uri used
|
|
|
|
|
- $prefixNS = substr($attrName, 6);
|
|
|
|
|
- $requestNsUriToPrefixMap[$attrVal] = $prefixNS;
|
|
|
|
|
- $requestNsPrefixToUriMap[$prefixNS] = $attrVal;
|
|
|
|
|
- }
|
|
|
|
|
- echo "NS List: loop({$attrName}) isItemNsList(".(array_key_exists($attrVal, $itemsNsList)).") \t val:";var_dump($attrVal);echo"\n";
|
|
|
|
|
- }
|
|
|
|
|
- }
|
|
|
|
|
- if($DBG){echo 'L.' . __LINE__ . ' $requestNsUriList:'.json_encode($requestNsUriList);echo "\n";}
|
|
|
|
|
- if($DBG){echo 'L.' . __LINE__ . ' $requestNsUriToPrefixMap:'.json_encode($requestNsUriToPrefixMap);echo "\n";}
|
|
|
|
|
- if($DBG){echo 'L.' . __LINE__ . ' $requestNsPrefixToUriMap:'.json_encode($requestNsPrefixToUriMap);echo "\n";}
|
|
|
|
|
- // fix Insert tag - get typeName from first tag under Insert
|
|
|
|
|
- foreach ($actionXmlTags as $actionIdx => $action) {
|
|
|
|
|
- if ('Insert' !== $action['action']) continue;
|
|
|
|
|
- $tag = reset($action['tags']);
|
|
|
|
|
- $name = $tag['tag'];
|
|
|
|
|
- // <p5_objects:File... or <File xmlns=".../wfs/objects"...
|
|
|
|
|
- // V::get('xmlns', '', $tag['attributes']);
|
|
|
|
|
- $actionXmlTags[$actionIdx]['ns_uri'] = V::get('xmlns', '', $tag['attributes']);
|
|
|
|
|
- }
|
|
|
|
|
- // fix ns_uri by @typeName prefix or @xmlns
|
|
|
|
|
- }
|
|
|
|
|
-
|
|
|
|
|
- $usedSourceNsList = array();
|
|
|
|
|
- $sourceNsList = $this->_getSourceNsList();
|
|
|
|
|
- if($DBG>3){echo 'L.' . __LINE__ . ' $requestXmlTags:';print_r($requestXmlTags);echo "\n";}
|
|
|
|
|
- if($DBG>3){echo 'L.' . __LINE__ . ' $sourceNsList:';print_r($sourceNsList);echo "\n";}
|
|
|
|
|
- {// get used typeNames
|
|
|
|
|
- $usedTypeNames = array();
|
|
|
|
|
- foreach ($actionXmlTags as $action) {
|
|
|
|
|
- if ('Delete' == $action['action']) {
|
|
|
|
|
- foreach ($sourceNsList as $nsInd => $ns) {
|
|
|
|
|
- if ("p5_{$ns[0]}:{$ns[1]}" == $action['typeName']) {
|
|
|
|
|
- $usedSourceNsList[$nsInd] = $ns;
|
|
|
|
|
- }
|
|
|
|
|
- }
|
|
|
|
|
- } else if ('Update' == $action['action']) {
|
|
|
|
|
- foreach ($sourceNsList as $nsInd => $ns) {
|
|
|
|
|
- if ("p5_{$ns[0]}:{$ns[1]}" == $action['typeName']) {
|
|
|
|
|
- $usedSourceNsList[$nsInd] = $ns;
|
|
|
|
|
- }
|
|
|
|
|
- }
|
|
|
|
|
- } else if ('Insert' == $action['action']) {
|
|
|
|
|
- foreach ($action['tags'] as $tag) {
|
|
|
|
|
- if ('open' != $tag['type']) continue;
|
|
|
|
|
- foreach ($sourceNsList as $nsInd => $ns) {
|
|
|
|
|
- if ("{$ns[1]}" == $tag['tag']) {
|
|
|
|
|
- $usedSourceNsList[$nsInd] = $ns;
|
|
|
|
|
- }
|
|
|
|
|
- }
|
|
|
|
|
- }
|
|
|
|
|
- }
|
|
|
|
|
- }
|
|
|
|
|
- if($DBG){echo 'L.' . __LINE__ . ' $usedSourceNsList after analyze split action tags:';print_r($usedSourceNsList);echo "\n";}
|
|
|
|
|
- if($DBG){echo 'L.' . __LINE__ . ' exit';exit;}
|
|
|
|
|
-
|
|
|
|
|
- // <Update xmlns="http://www.opengis.net/wfs" typeName="p5_default_db:TEST_PERMS">
|
|
|
|
|
- foreach ($requestXmlTags as $tag) {
|
|
|
|
|
- if ('Update' == $tag['tag'] && 'open' == $tag['type']) {
|
|
|
|
|
- $typeName = $tag['attributes']['typeName'];
|
|
|
|
|
- foreach ($sourceNsList as $nsInd => $ns) {
|
|
|
|
|
- if ("p5_{$ns[0]}:{$ns[1]}" == $typeName) {
|
|
|
|
|
- $usedSourceNsList[$nsInd] = $ns;
|
|
|
|
|
- }
|
|
|
|
|
- }
|
|
|
|
|
- }
|
|
|
|
|
- }
|
|
|
|
|
- if($DBG){echo 'L.' . __LINE__ . ' $usedSourceNsList after Update:';print_r($usedSourceNsList);echo "\n";}
|
|
|
|
|
- // TODO: check: <Transaction xmlns:p5_default_db="https://biuro.biall-net.pl/wfs/default_db/TEST_PERMS"
|
|
|
|
|
- // <Insert xmlns="http://www.opengis.net/wfs">
|
|
|
|
|
- // <TEST_PERMS xmlns="https://biuro.biall-net.pl/wfs/default_db/TEST_PERMS">
|
|
|
|
|
- $lastTagName = '';
|
|
|
|
|
- foreach ($requestXmlTags as $tag) {
|
|
|
|
|
- if ('Insert' == $lastTagName) {
|
|
|
|
|
- $typeName = $tag['tag'];
|
|
|
|
|
- if($DBG && 'File' == $typeName){echo 'L.' . __LINE__ . ' loop Insert: $typeName(File):';print_r($tag);echo "\n";}
|
|
|
|
|
- foreach ($sourceNsList as $nsInd => $ns) {
|
|
|
|
|
- if ("{$ns[1]}" == $typeName) {
|
|
|
|
|
- $usedSourceNsList[$nsInd] = $ns;
|
|
|
|
|
- }
|
|
|
|
|
- }
|
|
|
|
|
- }
|
|
|
|
|
- $lastTagName = $tag['tag'];
|
|
|
|
|
- }
|
|
|
|
|
- if($DBG){echo 'L.' . __LINE__ . ' $usedSourceNsList after Insert:';print_r($usedSourceNsList);echo "\n";}
|
|
|
|
|
-
|
|
|
|
|
- // <Delete xmlns="http://www.opengis.net/wfs" typeName="p5_default_db:TEST_GEOM_POINT">
|
|
|
|
|
- foreach ($requestXmlTags as $tag) {
|
|
|
|
|
- if ('Delete' == $tag['tag'] && 'open' == $tag['type']) {
|
|
|
|
|
- $typeName = $tag['attributes']['typeName'];
|
|
|
|
|
- foreach ($sourceNsList as $nsInd => $ns) {
|
|
|
|
|
- if ("p5_{$ns[0]}:{$ns[1]}" == $typeName) {
|
|
|
|
|
- $usedSourceNsList[$nsInd] = $ns;
|
|
|
|
|
- }
|
|
|
|
|
- }
|
|
|
|
|
- }
|
|
|
|
|
- }
|
|
|
|
|
- if($DBG){echo 'L.' . __LINE__ . ' $usedSourceNsList after Delete:';print_r($usedSourceNsList);echo "\n";}
|
|
|
|
|
- }
|
|
|
|
|
- if (empty($usedSourceNsList)) {
|
|
|
|
|
- throw new Api_WfsException("Parse Request XML Error - Empty source NS list", __LINE__, null, 'TransactionParseError', 'request');
|
|
|
|
|
- }
|
|
|
|
|
-
|
|
|
|
|
- $convertedTransaction = $this->_convertTransactionXml($requestXml, $usedSourceNsList);
|
|
|
|
|
-if($DBG){echo 'L.' . __LINE__ . ' $convertedTransaction:';print_r($convertedTransaction);echo "\n";}
|
|
|
|
|
- if (empty($convertedTransaction)) {
|
|
|
|
|
- throw new Api_WfsException("Parse Request XML Error - Empty transaction", __LINE__, null, 'TransactionParseError', 'request');
|
|
|
|
|
- }
|
|
|
|
|
- if (!$this->_validateConvertedTransactionXml($convertedTransaction, $usedSourceNsList)) {
|
|
|
|
|
- // <Transaction version="1.0.0" service="WFS">
|
|
|
|
|
- // <InsertNs0 typeName="TEST_PERMS">
|
|
|
|
|
- // <ID>41</ID>
|
|
|
|
|
- // <ADM_ADMIN_LEVEL>3</ADM_ADMIN_LEVEL>
|
|
|
|
|
- // </InsertNs0>
|
|
|
|
|
- // </Transaction>
|
|
|
|
|
- $transXml = @simplexml_load_string($convertedTransaction);
|
|
|
|
|
- foreach ($transXml->children() as $funcXml) {
|
|
|
|
|
- $funcName = substr($funcXml->getName(), 0, 6);// Insert... , Update... , Delete...
|
|
|
|
|
- if (empty($funcXml['typeName'][0])) throw new Api_WfsException("Missing typeName for function '{$funcName}'", __LINE__, null, 'MissingTypeName', 'request');
|
|
|
|
|
- $typeName = $funcXml['typeName'][0];
|
|
|
|
|
- $acl = $this->getAclFromTypeName("p5_default_db:{$typeName}");
|
|
|
|
|
- $primaryKey = $acl->getPrimaryKeyField();
|
|
|
|
|
- $pkObject = null;
|
|
|
|
|
- foreach ($funcXml->children() as $fieldXml) {
|
|
|
|
|
- if ($primaryKey == $fieldXml->getName()) $pkObject = $fieldXml[0];
|
|
|
|
|
- }
|
|
|
|
|
- if ('Insert' == $funcName && $pkObject) $funcName = 'Update';
|
|
|
|
|
-
|
|
|
|
|
- if ('Update' == $funcName) {// check perm W - skip $primaryKey
|
|
|
|
|
- if (!$pkObject) throw new Api_WfsException("Missing primary key ({$primaryKey}) for action Update", __LINE__, null, 'MissingPrimaryKey', 'request');
|
|
|
|
|
- $toUpdateFields = array();
|
|
|
|
|
- foreach ($funcXml->children() as $fieldXml) {
|
|
|
|
|
- if ($primaryKey == $fieldXml->getName()) continue;// skip primary key
|
|
|
|
|
- $toUpdateFields[] = $fieldXml->getName();
|
|
|
|
|
- }
|
|
|
|
|
- if (empty($toUpdateFields)) throw new Api_WfsException("Missing fields to update", __LINE__, null, 'MissingFieldToUpdate', 'request');
|
|
|
|
|
- $oldObject = $acl->getItem($pkObject);
|
|
|
|
|
- if (!$oldObject) throw new Api_WfsException("Object '{$typeName}.{$pkObject}' not exists", __LINE__, null, 'ObjectNotExists', 'request');
|
|
|
|
|
- if (!$acl->canWriteRecord($oldObject) && !$acl->hasPermSuperWrite()) {
|
|
|
|
|
- throw new Api_WfsException("Access Denied to Update object '{$typeName}.{$pkObject}'", __LINE__, null, 'MissingObjectPermUpdate', 'request');
|
|
|
|
|
- }
|
|
|
|
|
- foreach ($toUpdateFields as $fieldName) {
|
|
|
|
|
- $aclIdFld = $acl->getFieldIdByName($fieldName);
|
|
|
|
|
- if (!$acl->isAllowed($aclIdFld, 'W', $oldObject)) {
|
|
|
|
|
- throw new Api_WfsException("Access Denied to Update field '{$fieldName}' in object '{$typeName}.{$pkObject}'", __LINE__, null, 'MissingFieldPermWrite', 'request');
|
|
|
|
|
- }
|
|
|
|
|
- }
|
|
|
|
|
- } else if ('Insert' == $funcName) {// check perm C
|
|
|
|
|
- foreach ($funcXml->children() as $fieldXml) {
|
|
|
|
|
- $fieldName = $fieldXml->getName();
|
|
|
|
|
- $aclIdFld = $acl->getFieldIdByName($fieldXml->getName());
|
|
|
|
|
- if (!$acl->isAllowed($aclIdFld, 'C')) {
|
|
|
|
|
- throw new Api_WfsException("Access Denied to Create field '{$fieldName}' in object '{$typeName}.{$pkObject}'", __LINE__, null, 'MissingFieldPermCreate', 'request');
|
|
|
|
|
- }
|
|
|
|
|
- }
|
|
|
|
|
- } else {
|
|
|
|
|
- // TODO: Delete, ... ?
|
|
|
|
|
- }
|
|
|
|
|
- }
|
|
|
|
|
- throw new Exception("Parse Request xml error #" . __LINE__ . ": schema validation failed");
|
|
|
|
|
- }
|
|
|
|
|
-
|
|
|
|
|
- $parserXml = xml_parser_create();
|
|
|
|
|
- xml_parser_set_option($parserXml, XML_OPTION_CASE_FOLDING, 0);
|
|
|
|
|
- xml_parser_set_option($parserXml, XML_OPTION_SKIP_WHITE, 1);
|
|
|
|
|
- if (0 == xml_parse_into_struct($parserXml, $convertedTransaction, $tags)) {
|
|
|
|
|
- throw new Exception("Parse Request xml error #" . __LINE__ . ": parse converted transaction failed");
|
|
|
|
|
- }
|
|
|
|
|
- xml_parser_free($parserXml);
|
|
|
|
|
- if (empty($tags)) {
|
|
|
|
|
- throw new Exception("Parse Request xml error #" . __LINE__ . ": parse converted transaction returns empty structure");
|
|
|
|
|
- }
|
|
|
|
|
-
|
|
|
|
|
- // [{"tag":"Transaction","type":"open","level":1,"attributes":{"version":"1.0.0","service":"WFS"}},
|
|
|
|
|
- // {"tag":"Update","type":"open","level":2,"attributes":
|
|
|
|
|
- // {"typeName":"p5_default_db_13051:TEST_PERMS","featureId":"TEST_PERMS.25"}},
|
|
|
|
|
- // {"tag":"PARENT_ID","type":"complete","level":3,"value":"0"},
|
|
|
|
|
- // {"tag":"Update","type":"close","level":2},
|
|
|
|
|
- // {"tag":"Transaction","type":"close","level":1}]
|
|
|
|
|
- if($DBG){echo "\ntags L." . __LINE__ . ":\n"; print_r($tags);echo "\n";}
|
|
|
|
|
- $actionTag = null;
|
|
|
|
|
- $prevTagName = '';
|
|
|
|
|
- $theGeomField = 'the_geom';// TODO: get the geom field name from acl
|
|
|
|
|
- $itemPatchs = array();
|
|
|
|
|
- foreach ($tags as $tag) {
|
|
|
|
|
- switch (substr($tag['tag'], 0, 6)) {
|
|
|
|
|
- case 'Transa': continue; break;// Transaction
|
|
|
|
|
- case 'Update':
|
|
|
|
|
- case 'Insert':
|
|
|
|
|
- case 'Delete':
|
|
|
|
|
- case 'Native':
|
|
|
|
|
- if ('open' == $tag['type'] // Insert, Update
|
|
|
|
|
- || 'complete' == $tag['type'] // Delete
|
|
|
|
|
- ) {
|
|
|
|
|
- if($DBG){echo "\ntags loop 1 - tag: L." . __LINE__ . ":\n"; print_r($tag);echo "\n";}
|
|
|
|
|
- $actionTag = array();
|
|
|
|
|
- $actionTag['tag'] = substr($tag['tag'], 0, 6);
|
|
|
|
|
- $actionTag['typeName'] = $tag['attributes']['typeName'];
|
|
|
|
|
- if ('Insert' == substr($tag['tag'], 0, 6)) {
|
|
|
|
|
- $typeNsPrefix = 'p5_default_db';
|
|
|
|
|
- if (!empty($tag['attributes']['typeNsUri'])) {
|
|
|
|
|
- $baseNsUri = Api_WfsNs::getBaseWfsUri();
|
|
|
|
|
- if ("{$baseNsUri}/objects" == $tag['attributes']['typeNsUri']) {
|
|
|
|
|
- $typeNsPrefix = 'p5_objects';
|
|
|
|
|
- }
|
|
|
|
|
- }
|
|
|
|
|
- $actionTag['typeName'] = "{$typeNsPrefix}:{$tag['attributes']['typeName']}";
|
|
|
|
|
- }
|
|
|
|
|
- $featureEx = explode('.', $tag['attributes']['featureId'], 2);
|
|
|
|
|
- $actionTag['featureId'] = $featureEx[1];
|
|
|
|
|
- if ('Update' == substr($tag['tag'], 0, 6) && empty($actionTag['featureId'])) {
|
|
|
|
|
- throw new Api_WfsException("Syntax error - could not read feature id!");
|
|
|
|
|
- }
|
|
|
|
|
- if ('Delete' == substr($tag['tag'], 0, 6) && empty($actionTag['featureId'])) {
|
|
|
|
|
- throw new Api_WfsException("Syntax error - could not read feature id!");
|
|
|
|
|
- }
|
|
|
|
|
-
|
|
|
|
|
- if ('complete' == $tag['type']) {
|
|
|
|
|
- $itemPatchs[] = $actionTag;
|
|
|
|
|
- $actionTag = null;
|
|
|
|
|
- } else {
|
|
|
|
|
- $actionTag['itemPatch'] = array();
|
|
|
|
|
- }
|
|
|
|
|
- } else {
|
|
|
|
|
- $itemPatchs[] = $actionTag;
|
|
|
|
|
- $actionTag = null;
|
|
|
|
|
- }
|
|
|
|
|
- break;
|
|
|
|
|
- default: {// fields
|
|
|
|
|
- if($DBG){echo "\ntags loop 2 - tag: L." . __LINE__ . ":\n"; print_r($tag);echo "\n";}
|
|
|
|
|
- if (3 != $tag['level'] && 'close' == $tag['type']) {
|
|
|
|
|
- $actionTag = null;
|
|
|
|
|
- }
|
|
|
|
|
- if (3 != $tag['level']) continue;
|
|
|
|
|
- if (empty($actionTag)) continue;
|
|
|
|
|
- if ('Update' == $actionTag['tag']) {
|
|
|
|
|
- if ($theGeomField == $tag['tag']) {
|
|
|
|
|
- $actionTag['itemPatch'][$tag['tag']] = $this->_typeConverter->convertGmlCoordinatesToWkt($tag['value']);
|
|
|
|
|
- } else {
|
|
|
|
|
- $actionTag['itemPatch'][$tag['tag']] = $tag['value'];
|
|
|
|
|
- }
|
|
|
|
|
- }
|
|
|
|
|
- else if ('Insert' == $actionTag['tag']) {
|
|
|
|
|
- if ($theGeomField == $tag['tag']) {
|
|
|
|
|
- $actionTag['itemPatch'][$tag['tag']] = $this->_typeConverter->convertGmlCoordinatesToWkt($tag['value']);
|
|
|
|
|
- } else {
|
|
|
|
|
- $actionTag['itemPatch'][$tag['tag']] = $tag['value'];
|
|
|
|
|
- }
|
|
|
|
|
- }
|
|
|
|
|
- else if ('Delete' == $actionTag['tag']) {
|
|
|
|
|
- }
|
|
|
|
|
- }
|
|
|
|
|
- }
|
|
|
|
|
-
|
|
|
|
|
- if (empty($prevTagName)) $prevTagName = $tag['tag'];
|
|
|
|
|
- }
|
|
|
|
|
-
|
|
|
|
|
- if($DBG){echo "\nTODO: itemPatchs L." . __LINE__ . ":\n"; print_r($itemPatchs);echo "\n";}
|
|
|
|
|
- if($DBG){echo "\nTODO: _user_id L." . __LINE__ . " '{$this->_usrAcl->_user_id}'" . "\n";}
|
|
|
|
|
- $changesList = array();
|
|
|
|
|
- if (!empty($itemPatchs)) {
|
|
|
|
|
- foreach ($itemPatchs as $itemPatchInfo) {
|
|
|
|
|
- if($DBG){echo "L." . __LINE__ . " itemPatchInfo: {typeName:'{$itemPatchInfo['typeName']}'}:\n";print_r($itemPatchInfo);}
|
|
|
|
|
- $acl = $this->getAclFromTypeName($itemPatchInfo['typeName']);
|
|
|
|
|
- if ('Delete' == $itemPatchInfo['tag']) {
|
|
|
|
|
- $itemPatch = array();
|
|
|
|
|
- $itemPatch[$acl->getPrimaryKeyField()] = $itemPatchInfo['featureId'];
|
|
|
|
|
- $itemPatch['the_geom'] = 'NULL';
|
|
|
|
|
- } else {
|
|
|
|
|
- if (empty($itemPatchInfo['itemPatch'])) continue;
|
|
|
|
|
- $itemPatch = $itemPatchInfo['itemPatch'];
|
|
|
|
|
- if ('Update' == $itemPatchInfo['tag']) {
|
|
|
|
|
- $itemPatch[$acl->getPrimaryKeyField()] = $itemPatchInfo['featureId'];
|
|
|
|
|
- }
|
|
|
|
|
- else if ('Insert' == $itemPatchInfo['tag']) {
|
|
|
|
|
- if (!empty($itemPatch[$acl->getPrimaryKeyField()])) {
|
|
|
|
|
- $itemPatchInfo['featureId'] = $itemPatch[$acl->getPrimaryKeyField()];
|
|
|
|
|
- }
|
|
|
|
|
- else {
|
|
|
|
|
- //throw new Exception("TODO: Insert #" . __LINE__ . ": Create new record");
|
|
|
|
|
- }
|
|
|
|
|
- }
|
|
|
|
|
- }
|
|
|
|
|
-
|
|
|
|
|
- if($DBG){echo "L." . __LINE__ . " TODO '" . ($itemPatchInfo['tag'])? 'Insert' : 'Update' . "' itemPatch:\n";print_r($itemPatch);}
|
|
|
|
|
- if ('Insert' == $itemPatchInfo['tag'] && empty($itemPatch[$acl->getPrimaryKeyField()])) {
|
|
|
|
|
- $newId = $acl->addItem($itemPatch);
|
|
|
|
|
- $changesList[$newId] = array('Status'=>(($newId > 0)? 'SUCCESS' : 'FAILED'), 'Message'=>"created {$newId}.");
|
|
|
|
|
- if ($newId > 0) {
|
|
|
|
|
- $changesList[$newId]['fid'] = $acl->getName() . '.' . $newId;
|
|
|
|
|
- }
|
|
|
|
|
- if($DBG){echo "created {$newId}.\n";}
|
|
|
|
|
- } else {
|
|
|
|
|
- $affected = $acl->updateItem($itemPatch);
|
|
|
|
|
- $changesList[$itemPatchInfo['featureId']] = array('Status'=>(($affected >= 0)? 'SUCCESS' : 'FAILED'), 'Message'=>"affected {$affected}.");
|
|
|
|
|
- if($DBG){echo "affected {$affected}.\n";}
|
|
|
|
|
- }
|
|
|
|
|
- }
|
|
|
|
|
- //throw new Exception("TODO: run query #" . __LINE__ . " \nitemPatchs:\n" . json_encode($itemPatchs) . " \ntags:\n" . json_encode($tags) . "\n");
|
|
|
|
|
- }
|
|
|
|
|
- else {
|
|
|
|
|
- throw new Exception("Parse Request xml error #" . __LINE__ . ": Nothing to change");
|
|
|
|
|
}
|
|
}
|
|
|
-
|
|
|
|
|
return $this->_transactionResponse($changesList);
|
|
return $this->_transactionResponse($changesList);
|
|
|
}
|
|
}
|
|
|
|
|
|
|
@@ -1673,7 +1347,7 @@ if($DBG){echo 'L.' . __LINE__ . ' $validateConvertedTransactionXsdString:';print
|
|
|
// <xsd:element maxOccurs="1" minOccurs="0" name="{$fldName}" nillable="true" type="xsd:integer"/>
|
|
// <xsd:element maxOccurs="1" minOccurs="0" name="{$fldName}" nillable="true" type="xsd:integer"/>
|
|
|
$pKeyField = $acl->getPrimaryKeyField();
|
|
$pKeyField = $acl->getPrimaryKeyField();
|
|
|
$p5Attributes = ($simple)? array() : $acl->getAttributesFromZasoby();
|
|
$p5Attributes = ($simple)? array() : $acl->getAttributesFromZasoby();
|
|
|
- foreach ($fldList as $idZasob => $fldName) {
|
|
|
|
|
|
|
+ foreach ($fldList as $fldName) {
|
|
|
$elNode = $dom->createElementNS('http://www.w3.org/2001/XMLSchema', 'xsd:element');
|
|
$elNode = $dom->createElementNS('http://www.w3.org/2001/XMLSchema', 'xsd:element');
|
|
|
$seqNode->appendChild($elNode);
|
|
$seqNode->appendChild($elNode);
|
|
|
$minOccurs = 0;
|
|
$minOccurs = 0;
|
|
@@ -1691,8 +1365,13 @@ if($DBG){echo 'L.' . __LINE__ . ' $validateConvertedTransactionXsdString:';print
|
|
|
}
|
|
}
|
|
|
if ('ref:' == substr($fldType, 0, 4)) {
|
|
if ('ref:' == substr($fldType, 0, 4)) {
|
|
|
$elNode->setAttribute('ref', substr($fldType, 4));
|
|
$elNode->setAttribute('ref', substr($fldType, 4));
|
|
|
|
|
+ $elNode->setAttributeNS($rootWfsNsUri, "{$rootWfsNs}:name", $fldName);
|
|
|
} else if ('local_ref:' == substr($fldType, 0, 10)) {
|
|
} else if ('local_ref:' == substr($fldType, 0, 10)) {
|
|
|
$elNode->setAttribute('type', "{$fldName}Type");
|
|
$elNode->setAttribute('type', "{$fldName}Type");
|
|
|
|
|
+ $elNode->setAttributeNS($rootWfsNsUri, "{$rootWfsNs}:name", $fldName);
|
|
|
|
|
+ } else if ('alias_ref:' == substr($fldType, 0, 10)) {
|
|
|
|
|
+ $elNode->setAttribute('ref', "p5_" . $acl->getSourceName() . ":" . $acl->getName() . "__x3A__{$fldName}");
|
|
|
|
|
+ $elNode->setAttributeNS($rootWfsNsUri, "{$rootWfsNs}:name", $fldName);
|
|
|
} else {
|
|
} else {
|
|
|
$elNode->setAttribute('name', $fldName);
|
|
$elNode->setAttribute('name', $fldName);
|
|
|
$elNode->setAttribute('type', $fldType);
|
|
$elNode->setAttribute('type', $fldType);
|
|
@@ -1705,9 +1384,9 @@ if($DBG){echo 'L.' . __LINE__ . ' $validateConvertedTransactionXsdString:';print
|
|
|
if (!empty($p5attrs['label'])) $elNode->setAttributeNS($rootWfsNsUri, "{$rootWfsNs}:label", $p5attrs['label']);
|
|
if (!empty($p5attrs['label'])) $elNode->setAttributeNS($rootWfsNsUri, "{$rootWfsNs}:label", $p5attrs['label']);
|
|
|
if (!empty($p5attrs['description'])) $elNode->setAttributeNS($rootWfsNsUri, "{$rootWfsNs}:description", $p5attrs['description']);
|
|
if (!empty($p5attrs['description'])) $elNode->setAttributeNS($rootWfsNsUri, "{$rootWfsNs}:description", $p5attrs['description']);
|
|
|
}
|
|
}
|
|
|
- if ($acl->hasFieldPerm($idZasob, 'W')) $elNode->setAttributeNS($rootWfsNsUri, "{$rootWfsNs}:allow_write", "true");
|
|
|
|
|
- if ($acl->hasFieldPerm($idZasob, 'C')) $elNode->setAttributeNS($rootWfsNsUri, "{$rootWfsNs}:allow_create", "true");
|
|
|
|
|
- if (!$acl->hasFieldPerm($idZasob, 'R')) $elNode->setAttributeNS($rootWfsNsUri, "{$rootWfsNs}:allow_read", "false");
|
|
|
|
|
|
|
+ if ($acl->canWriteField($fldName)) $elNode->setAttributeNS($rootWfsNsUri, "{$rootWfsNs}:allow_write", "true");
|
|
|
|
|
+ if ($acl->canCreateField($fldName)) $elNode->setAttributeNS($rootWfsNsUri, "{$rootWfsNs}:allow_create", "true");
|
|
|
|
|
+ if (!$acl->canReadField($fldName)) $elNode->setAttributeNS($rootWfsNsUri, "{$rootWfsNs}:allow_read", "false");
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|
|
|
|
|
|
|
@@ -1721,9 +1400,16 @@ if($DBG){echo 'L.' . __LINE__ . ' $validateConvertedTransactionXsdString:';print
|
|
|
$elNode->setAttribute('substitutionGroup', 'gml:AbstractFeature');
|
|
$elNode->setAttribute('substitutionGroup', 'gml:AbstractFeature');
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
- foreach ($fldList as $idZasob => $fldName) {
|
|
|
|
|
|
|
+ foreach ($fldList as $fldName) {
|
|
|
$fldType = $acl->getXsdFieldType($fldName);
|
|
$fldType = $acl->getXsdFieldType($fldName);
|
|
|
- if ('local_ref:' == substr($fldType, 0, 10)) {
|
|
|
|
|
|
|
+ if ('alias_ref:' == substr($fldType, 0, 10)) {
|
|
|
|
|
+ $localRefType = substr($fldType, 10);
|
|
|
|
|
+ // <xsd:element name="{$fldName}" ref="{$localRefType}">
|
|
|
|
|
+ $ctNode = $dom->createElementNS('http://www.w3.org/2001/XMLSchema', 'xsd:element');
|
|
|
|
|
+ $rootNode->appendChild($ctNode);
|
|
|
|
|
+ $ctNode->setAttribute('name', $acl->getName() . "__x3A__{$fldName}");
|
|
|
|
|
+ $ctNode->setAttribute('type', "{$localRefType}");
|
|
|
|
|
+ } else if ('local_ref:' == substr($fldType, 0, 10)) {
|
|
|
$localRefType = substr($fldType, 10);
|
|
$localRefType = substr($fldType, 10);
|
|
|
// <xsd:complexType name="produkt_Type">
|
|
// <xsd:complexType name="produkt_Type">
|
|
|
// <xsd:sequence>
|
|
// <xsd:sequence>
|