Kaynağa Gözat

added example ant wfs GetFeature

Piotr Labudda 9 yıl önce
ebeveyn
işleme
293a8b14da

+ 29 - 0
SE/schema/ant-url_action/default_db.in7_dziennik_koresp/test-get-wfs-xml/build.xml

@@ -0,0 +1,29 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<project basedir="." name="example wfs GetFeature" default="http_fist_input">
+
+    <!--<input addproperty="http_input" />-->
+    <!-- dane z apache requesty -->
+    <property name="uuid" value="${uuid}"/>
+    <property name="passwordBase64Basic" value="${passwordBase64Basic}"/>
+    <property name="url" value="${url}"/>
+
+    <target name="http_fist_input">
+        <exec executable="curl" outputproperty="wfs_output" errorproperty="wfs_error" resultproperty="wfs_result">
+            <arg line="-H 'Authorization: Basic ${passwordBase64Basic}' ${url}"/>
+        </exec>
+        <echo message="curl -H 'Authorization: Basic ${passwordBase64Basic}' '${url}'"/>
+        <echo message="OUTPUT__START"/>
+        <echo message="${wfs_output}"/>
+        <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>
+
+    <target name="http_fist_output"></target>
+</project>

+ 2 - 0
SE/se-lib/Route/Ant.php

@@ -16,6 +16,8 @@ Lib::loadClass('DBG');
  *  index.php?_route=Ant&_task=ant&path={$ant_tool_name}
  *  index.php?_route=UrlAction_Ant
  *  index.php?_route=UrlAction_Ant&_task=ant&path={$namespace_sep_by_dot}{$function_name}&featureID={featureID}&namespace={$namespace}
+ *
+ * @doc ant <exec> https://ant.apache.org/manual/Tasks/exec.html
  */
 class Route_Ant extends RouteBase {
 

+ 23 - 1
SE/se-lib/Route/UrlAction/Ant.php

@@ -3,6 +3,8 @@
 Lib::loadClass('RouteBase');
 Lib::loadClass('UI');
 Lib::loadClass('DBG');
+Lib::loadClass('Request');
+Lib::loadClass('Crypt');
 Lib::loadClass('Route_Ant');
 
 class Route_UrlAction_Ant extends Route_Ant {// @doc @see Route_Ant
@@ -51,10 +53,30 @@ class Route_UrlAction_Ant extends Route_Ant {// @doc @see Route_Ant
 
       echo UI::h('hr');
 
-      $cmd = "cd {$this->pathUrlActions}{$path} && {$this->antBin} 2>&1";// wymaga java jdk
+      $testUrl = Request::getPathUri() . "wfs-data.php/default_db/?SERVICE=WFS&VERSION=1.0.0&REQUEST=GetFeature&TYPENAME=p5_default_db:TEST_PERMS&SRSNAME=EPSG:3003&featureID=TEST_PERMS.63";
+      $cryptedPass = base64_encode(User::getLogin() . ":" . Crypt::decrypt($_SESSION['ADM_PASS_HASH']));
+      $cmd = "cd {$this->pathUrlActions}{$path} && {$this->antBin} -S  -Durl='{$testUrl}' -DpasswordBase64Basic='{$cryptedPass}' 2>&1";
       DBG::nicePrint(str_replace(APP_PATH_ROOT, 'SE', $cmd), 'command');
       V::exec($cmd, $out, $ret);
       DBG::nicePrint($out, 'output');
+      $html = []; $startRead = false;
+      foreach ($out as $line) {
+        if (!$startRead) {
+          if ('OUTPUT__START' == $line) {
+            $startRead = true;
+            continue;
+          }
+        } else {
+          if ('<!DOCTYPE' == substr($line, 0, strlen('<!DOCTYPE'))) continue;
+          if ('OUTPUT__END' == $line) {
+            break;
+          }
+          $html[]= $line;
+        }
+      }
+      echo UI::h('h3', [], "output:");
+      if (empty($html)) UI::alert('danger', "Empty output!");
+      echo UI::h('pre', [], htmlspecialchars(implode("\n", $html)));
     } catch (Exception $e) {
       UI::alert('danger', $e->getMessage());
       DBG::log($e);