Kaynağa Gözat

added reinstall Ant objects, added test TestPermsAnt build

Piotr Labudda 9 yıl önce
ebeveyn
işleme
4a818c9df4

+ 49 - 0
SE/schema/ant-object/default_db.TEST_PERMS/TestPermsAnt/build.xml

@@ -0,0 +1,49 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<project basedir="." name="test default_db/TEST_PERMS">
+    <description>
+        Test 'default_db/TEST_PERMS' storage acl by Ant
+    </description>
+
+    <property name="uuid" value="${uuid}"/>
+    <property name="passwordBase64Basic" value="${passwordBase64Basic}"/>
+    <property name="url" value="${url}"/>
+    <property name="php_session_id" value="${php_session_id}"/>
+    <property name="webRootUrl" value="${webRootUrl}"/>
+
+    <target name="DescribeFeatureType" description="URL_TASK Target DescribeFeatureType">
+        <echo message="OUTPUT__TYPE__XML"/>
+        <echo message="OUTPUT__START"/>
+        <!-- <echo message="${wfs_output}"/> -->
+        <echoxml>
+            <project default="foo">
+                <target name="foo">
+                    <echo>foo</echo>
+                </target>
+            </project>
+        </echoxml>
+        <echo message="OUTPUT__END"/>
+    </target>
+
+    <target name="GetFeature" description="URL_TASK Target GetFeature">
+        <echo message="FETCHING '${url}' ..."/>
+        <exec executable="curl" outputproperty="wfs_output" errorproperty="wfs_error" resultproperty="wfs_result">
+            <arg line="--cookie 'PHPSESSID=${php_session_id}' '${url}&amp;REQUEST=GetFeature'"/>
+        </exec>
+        <echo message="OUTPUT__TYPE__XML"/>
+        <echo message="OUTPUT__START"/>
+        <echo message="${wfs_output}"/>
+
+        <echo message="webRootUrl"></echo>
+        <echo message="${webRootUrl}"></echo>
+
+        <echo message="OUTPUT__END"/>
+
+        <echo message="RESULT__START"/>
+        <echo message="${wfs_result}"/>
+        <echo message="RESULT__END"/>
+
+        <echo message="ERROR__START"/>
+        <echo message="${wfs_error}"/>
+        <echo message="ERROR__END"/>
+    </target>
+</project>

+ 31 - 0
SE/se-lib/AntAclBase.php

@@ -0,0 +1,31 @@
+<?php
+
+/**
+ * SE/schema/ant-object/default_db.{lower(rootTableName)}/{name}/build.xml
+ */
+class AntAclBase extends Core_AclBase {
+
+  public $_zasobID = '';
+
+  public function __construct($zasobID = 0) {
+    $this->_zasobID = $zasobID;
+  }
+  public function getName() { return $this->_name; }
+  public function getNamespace() { return 'default_db/' . $this->getName(); }
+  public function getSourceName() { return 'default_db'; }
+  public function getRootTableName() { throw new Exception("TODO: " . get_class($this) . "::F." . __FUNCTION__); }
+
+  public static function buildInstance($idZasob, $conf = []) {
+    static $_cache;
+		if (!$_cache) $_cache = array();
+		if (array_key_exists($idZasob, $_cache)) {
+			return $_cache[$idZasob];
+		}
+
+		if (empty($conf)) throw new Exception("Brak danych konfiguracyjnych do obiektu ant nr {$idZasob}");
+    DBG::nicePrint($conf, 'AntAclBase::buildInstance $conf');
+    $_cache[$idZasob] = new AntAclBase($idZasob);
+    return $_cache[$idZasob];
+  }
+
+}

+ 37 - 0
SE/se-lib/Schema/SystemObjectStorageAcl.php

@@ -202,6 +202,43 @@ class Schema_SystemObjectStorageAcl extends Core_AclSimpleSchemaBase {
       }
       }
     }
     }
 
 
+    // Ant objects in: SE/schema/ant-object/
+    foreach (glob(APP_PATH_SCHEMA . "/ant-object/*/*/build.xml", GLOB_NOSORT) as $file) {
+      // SE/schema/ant-object/default_db.test_perms/TestPermsAnt/build.xml
+      $file = substr($file, strlen(APP_PATH_SCHEMA . '/ant-object/'), -1 * strlen('/build.xml'));
+      DBG::nicePrint($file, '$file');
+      list($partSource, $name) = explode('/', $file);
+      list($sourceName, $rootTableName) = explode('.', $partSource);
+      DBG::nicePrint([$sourceName, $rootTableName, $name], '[$lowerSource, $rootTableName, $name]');
+      // $clsName = substr(basename($file), 0, -1 * strlen('StorageAcl.php'));
+      try {
+        Lib::loadClass('AntAclBase');
+        $acl = AntAclBase::buildInstance(0, [
+          'source' => $sourceName,
+          'rootTableName' => $rootTableName,
+          'name' => $name
+        ]);
+        // $acl = SchemaFactory::loadDefaultObject($clsName);
+        // $namespace = $acl->getNamespace();
+        // $name = $acl->getName();
+        $sqlNsPrefix = "{$sourceName}__x3A__{$rootTableName}";
+        $sqlName = $name;
+        DB::getPDO()->execSql("
+          insert ignore into `{$this->_rootTableName}` (nsPrefix, idDatabase, _type, name, description, isActive)
+            values (
+              '{$sqlNsPrefix}'
+              , '0'
+              , 'AntAcl'
+              , '{$sqlName}'
+              , ''
+              , '1'
+            )
+        ");
+      } catch (Exception $e) {
+        UI::alert('danger', $e->getMessage());
+      }
+    }
+
     // // foreach ... DB::getPDO($idDatabase)->fetchAll(select real _rootTableName)
     // // foreach ... DB::getPDO($idDatabase)->fetchAll(select real _rootTableName)
     // foreach (Core_AclHelper::getAclList() as $typeName) {
     // foreach (Core_AclHelper::getAclList() as $typeName) {
     //   $ns = Core_AclHelper::parseTypeName($typeName);
     //   $ns = Core_AclHelper::parseTypeName($typeName);