build_get_wfs.xml 26 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488
  1. <?xml version="1.0" encoding="UTF-8"?>
  2. <project xmlns:ogc="http://www.opengis.net/ogc"
  3. xmlns:get_wfs="http://biuro.biall-net.pl/WPS_Functions/get_wfs/get_wfs.xsd"
  4. basedir="../../." name="get_wfs" default="http_first_input">
  5. <description>
  6. Based on ant-url-action module to ordinary retrieve feature from WMF
  7. To be called from CRM_PROCES_Tree etc
  8. </description>
  9. <!-- file:/SE/schema/ant-url_action/default_db.in7_dziennik_koresp/test-get-wfs-xml/build.xml -->
  10. <!-- sample URL which call this exact variables in this ANT build -->
  11. <!-- przykladowy URL ktory przekazuje parametry do tego ANT -->
  12. <!--https://biuro.biall-net.pl/SE/version-git/index.php?_route=UrlAction_Ant&_task=ant&
  13. path=${default_db.in7_dziennik_koresp/test-get-wfs-xml} - this is the place to keep ant build (directory name with build.xml)
  14. &namespace=p5_default_db:Rozdzielcza_test_bzyk_PE&featureID=123 - this is setting the <property name="url" value="${url}"/> - to point what is record/table to download
  15. <property name="uuid" value="${uuid}"/> it is automatically also set to enable uinque transaction and to allow to save data with user
  16. <property name="passwordBase64Basic" value="${passwordBase64Basic}"/> - this is also set - to enable communicate with API -
  17. <property name="DwebRootUrl" value="${$webRootUrl}"/> - this is the place where script is localized to easyli to target user GUI by href to generated output
  18. />
  19. -->
  20. <include file="build.get_wfs.PRODUCT.xml" as="PRODUCT"/>
  21. <include file="build.get_wfs.SYSTEM.xml" as="SYSTEM"/>
  22. <include file="build.get_wfs.OBSOLETE-FIXME.xml" as="OBSOLETE-FIXME"/>
  23. <include file="../username_and_pass_from_passwordBase64Basic/build.build_username_and_pass_from_passwordBase64Basic.PRODUCT.xml"/>
  24. <!-- modules WPS_Functions - to be copied to any module needed -->
  25. <!-- <property name="WPS_Functions" location="${basedir}/WPS_Functions"/>
  26. <property name="build_WPS_Functions.xml" location="${WPS_Functions}/build_WPS_Functions.xml"/> <!-\- call it to get properties -\->
  27. <property name="build_WPS_Functions.xml.properties" location="${WPS_Functions.build}.properties"/>-->
  28. <!-- eof modules WPS_Functions -->
  29. <!-- module local properties -->
  30. <condition property="uuid" value="${uuid}">
  31. <isset property="uuid"/>
  32. </condition>
  33. <!--<property name="uuid" value="${uuid}"/>-->
  34. <tempfile property="wfs_error.xml.temp" destdir="${get_wfs.temp}" prefix="wfs_error" suffix=".xml" deleteonexit="yes"/>
  35. <tempfile property="wfs_result.xml.temp" destdir="${get_wfs.temp}" prefix="wfs_result" suffix=".xml" deleteonexit="yes"/>
  36. <tempfile property="wfs_error.xml.temp" destdir="${get_wfs.temp}" prefix="wfs_error" suffix=".xml" deleteonexit="yes"/>
  37. <tempfile property="wfs_timestamp.temp" destdir="${get_wfs.temp}" prefix="wfs_timestamp" suffix=".xml" deleteonexit="yes"/>
  38. <tempfile property="wfs_input.xml.temp" destdir="${get_wfs.temp}" prefix="wfs_input" suffix=".xml" deleteonexit="yes"/>
  39. <condition property="wfs_error.xml" value="${wfs_error.xml.temp}">
  40. <isset property="uuid"/>
  41. </condition>
  42. <condition property="wfs_result.xml" value="${wfs_result.xml.temp}">
  43. <isset property="uuid"/>
  44. </condition>
  45. <condition property="wfs_error.xml" value="${wfs_error.xml.temp}">
  46. <isset property="uuid"/>
  47. </condition>
  48. <condition property="wfs_timestamp.xml" value="${wfs_timestamp.temp}">
  49. <isset property="uuid"/>
  50. </condition>
  51. <condition property="wfs_input.xml" value="${wfs_input.xml.temp}">
  52. <isset property="uuid"/>
  53. </condition>
  54. <property name="wfs_output.xml" location="${get_wfs.temp}/${uuid}.wfs_output.xml"/>
  55. <property name="wfs_result.xml" location="${get_wfs.temp}/${uuid}.wfs_result.xml"/>
  56. <property name="wfs_error.xml" location="${get_wfs.temp}/${uuid}.wfs_error.xml"/>
  57. <property name="wfs_timestamp.xml" location="${get_wfs.temp}/${uuid}.wfs_timestamp.xml"/>
  58. <!-- for sending xml - param inputs -->
  59. <property name="wfs_input.xml" location="${get_wfs.temp}/${uuid}.wfs_input.xml"/>
  60. <!-- eof module local properties -->
  61. <!--<property name="passwordBase64Basic" value="${passwordBase64Basic}"/>-->
  62. <!--<property name="url" value="${url}"/>-->
  63. <!--<property name="api_url" value="${api_url}"/>-->
  64. <!--<property name="typeName" value="${typeName}" />-->
  65. <!--<property name="xpath" value="${xpath}"/>-->
  66. <!--<property name="xpath_value" value="${xpath_value}" />-->
  67. <property name="php_session_id" value="${php_session_id}"/>
  68. <property name="webRootUrl" value="${webRootUrl}"/>
  69. <target name="write_child_props_to_config_dir" > <!-- R depends="read_build_properties" -->
  70. <echoproperties destfile="${build_get_wfs.childproperties}"/>
  71. </target>
  72. <!--<target name="read_build_properties" >
  73. <ant antfile="${WPS_Functions.build}" target="save_build_properties"/>
  74. <loadproperties srcfile="${WPS_Functions.properties}"/>
  75. <echo level="debug">$api_url to ${api_url} $namespace_prefix ${namespace_prefix}
  76. passwordBase64Basic=${passwordBase64Basic}
  77. </echo>
  78. </target>-->
  79. <target name="clean" description="Clean all output and temp files">
  80. <delete dir="${get_wfs.temp}" failonerror="false"/>
  81. </target>
  82. <target name="create_tempdir">
  83. <mkdir dir="${get_wfs.temp}"/>
  84. </target>
  85. <target name="http_first_input">
  86. <echo message="FETCHING '${url}' ..."/>
  87. <exec executable="curl" outputproperty="wfs_output" errorproperty="wfs_error" resultproperty="wfs_result">
  88. <arg line="--cookie 'PHPSESSID=${php_session_id}' '${url}&amp;REQUEST=GetFeature'"/>
  89. </exec>
  90. <echo message="OUTPUT__TYPE__XML"/>
  91. <echo message="OUTPUT__START"/>
  92. <echo message="${wfs_output}"/>
  93. <echo message="webRootUrl"></echo>
  94. <echo message="${webRootUrl}"></echo>
  95. <echo message="OUTPUT__END"/>
  96. <echo message="RESULT__START"/>
  97. <echo message="${wfs_result}"/>
  98. <echo message="RESULT__END"/>
  99. <echo message="ERROR__START"/>
  100. <echo message="${wfs_error}"/>
  101. <echo message="ERROR__END"/>
  102. </target>
  103. <target name="DescribeFeatureType" description="URL_TASK Target DescribeFeatureType">
  104. <echo message="FETCHING '${url}' ..." level="debug"/>
  105. <exec executable="curl" outputproperty="wfs_output" errorproperty="wfs_error" resultproperty="wfs_result">
  106. <arg line="-H 'Authorization: Basic ${passwordBase64Basic}' &#34;${url}&amp;REQUEST=DescribeFeatureType&#34;"/>
  107. </exec>
  108. <echo message="OUTPUT__TYPE__XML"/>
  109. <echo message="OUTPUT__START"/>
  110. <echo message="${wfs_output}"/>
  111. <echo message="webRootUrl"></echo>
  112. <echo message="${webRootUrl}"></echo>
  113. <echo message="OUTPUT__END"/>
  114. <echo message="RESULT__START"/>
  115. <echo message="${wfs_result}"/>
  116. <echo message="RESULT__END"/>
  117. <echo message="ERROR__START"/>
  118. <echo message="${wfs_error}"/>
  119. <echo message="ERROR__END"/>
  120. </target>
  121. <target name="Filter_cond">
  122. <condition property="Filter_cond" taskname="Filter_check">
  123. <or>
  124. <equals arg1="${xpath}" arg2=""/>
  125. <equals arg1="${xpath}" arg2="$${uuid}"/>
  126. </or>
  127. </condition>
  128. </target>
  129. <target name="Filter_check" depends="Filter_cond,Filter_fail,Filter_ok"/>
  130. <target name="Filter_ok" unless="${Filter_cond}">
  131. <!--<mkdir dir="${get_wfs.temp}"/>
  132. <tempfile destdir="${get_wfs.temp}" suffix=".xml" prefix="Filter_ok" property="Filter.xml"/>
  133. <echoxml file="${Filter.xml}"></echoxml>
  134. <loadfile property="Filter.xml_file" srcfile="${Filter.xml}"/>-->
  135. <property name="Filter" value="&amp;Filter=&lt;ogc:Filter&gt;&lt;ogc:PropertyIsEqualTo&gt;&lt;ogc:PropertyName&gt;${xpath}&lt;/ogc:PropertyName&gt;&lt;ogc:Literal&gt;${xpath_value}&lt;/ogc:Literal&gt;&lt;/ogc:PropertyIsEqualTo&gt;&lt;/ogc:Filter&gt;"/>
  136. </target>
  137. <target name="Filter_fail" if="${Filter_cond}">
  138. <echo level="debug">#94 filter not set</echo>
  139. </target>
  140. <target name="GetFeature" description="URL_TASK Target GetFeature" depends="Filter_check"> <!-- R read_build_properties, -->
  141. <property name="get_url" value="${api_url}/${namespace_prefix}?SERVICE=WFS&amp;VERSION=1.0.0&amp;REQUEST=GetFeature&amp;typeName=${typeName}&amp;${Filter}"/>
  142. <echo message="FETCHING '${get_url}'" /> <!-- level="debug" -->
  143. <tstamp>
  144. <format property="wfs.timestamp" pattern="yyyy-MM-dd HH:mm:ss"/>
  145. </tstamp>
  146. <exec executable="curl" outputproperty="wfs_output" errorproperty="wfs_error" resultproperty="wfs_result">
  147. <arg line="-H 'Authorization: Basic ${passwordBase64Basic}' '${get_url}'"/><!-- ${Filter} -->
  148. </exec>
  149. <!--<echo message="${wfs_output}" />-->
  150. <echo file="${wfs_output.xml}" message="${wfs_output}"/>
  151. <echo file="${wfs_result.xml}" message="${wfs_result}"/>
  152. <echo file="${wfs_error.xml}" message="${wfs_error}"/>
  153. <echoxml file="${wfs_timestamp.xml}"><wfs_timestamp>${wfs.timestamp}</wfs_timestamp></echoxml>
  154. </target>
  155. <target name="GetFeature.local" description="To get local data from WFS easyli like POSTMAN" depends="php_session_id_check">
  156. <!--<input addproperty="typeName.local" message="Type object typeName.local"/>-->
  157. <input addproperty="Query.xml.local" />
  158. <!--<input addproperty="Filter.local" />-->
  159. <input addproperty="typeName.object.local"/>
  160. <input addproperty="wfs_output.xml.local" message="wfs_output.xml.local"/>
  161. <input addproperty="wfs_result.xml.local" message="wfs_result.xml.local"/>
  162. <input addproperty="wfs_error.xml.local" message="wfs_error.xml.local"/>
  163. <input addproperty="wfs_timestamp.xml.local"/>
  164. <local name="get_url.local"/>
  165. <property name="get_url.local" value="${api_url}/${namespace_prefix}?SERVICE=WFS&amp;REQUEST=GetFeature&amp;VERSION=1.0.0&amp;TYPENAME=${typeName.object.local}&amp;MaxFeatures=3"/>
  166. <echo message="FETCHING '${get_url.local}'"/> <!-- level="debug" -->
  167. <tstamp>
  168. <format property="wfs.timestamp" pattern="yyyy-MM-dd HH:mm:ss"/>
  169. </tstamp>
  170. <local name="wfs_error.local"/>
  171. <local name="wfs_result.local"/>
  172. <local name="wfs_output.local"/>
  173. <local name="wfs_timestamp.xml.local"/>
  174. <echo> command:
  175. ${curl} ${php_session_id_tested} -XPOST -H "Content-type: text/xml" -d @${Query.xml.local} &apos;${get_url.local}&apos;
  176. </echo>
  177. <!--<echo> command:
  178. ${curl} ${php_session_id_tested} &apos;${get_url.local}&apos;
  179. </echo>-->
  180. <exec executable="curl" outputproperty="wfs_output.local" errorproperty="wfs_error.local" resultproperty="wfs_result.local">
  181. <!--<arg line="-H 'Authorization: Basic ${passwordBase64Basic}' -\-data@${Filter.xml.local} '${get_url.local}'"/>--><!-- ${Filter} -->
  182. <!--<arg line="${php_session_id_tested} &apos;${get_url.local}&apos;"/>-->
  183. <arg line="${php_session_id_tested} -XPOST -H &apos;Content-type: text/xml&apos; --data @${Query.xml.local} &apos;${get_url.local}&apos;"/>
  184. <!--<arg line="${php_session_id_tested} &apos;${get_url.local}&apos;"/>-->
  185. </exec>
  186. <!--<echo message="${wfs_output}" />-->
  187. <echo file="${wfs_output.xml.local}" message="${wfs_output.local}"/>
  188. <echo file="${wfs_result.xml.local}" message="${wfs_result.local}"/>
  189. <echo file="${wfs_error.xml.local}" message="${wfs_error.local}"/>
  190. <echoxml file="${wfs_timestamp.xml.local}"><wfs_timestamp>${wfs.timestamp}</wfs_timestamp></echoxml>
  191. </target>
  192. <taskdef resource="net/sf/antcontrib/antlib.xml"/> <!-- metoda post wymaga ant contrib -->
  193. <target name="GetPropertyValue" description="To parse WFS output to Ant Property">
  194. <input addproperty="wfs_output.xml.local"/>
  195. <input addproperty="PropertyName.local"/>
  196. <input addproperty="setPropertyName.local"/>
  197. <input addproperty="GetPropertyValue.properties.local"/>
  198. <GetPropertyValue GetPropertyValue.properties.local="${GetPropertyValue.properties.local}" wfsoutputxml="${wfs_output.xml.local}" PropertyName="${PropertyName.local}" setPropertyName="${setPropertyName.local}" />
  199. </target>
  200. <macrodef name="GetPropertyValue">
  201. <attribute name="wfsoutputxml"/>
  202. <attribute name="PropertyName"/>
  203. <attribute name="setPropertyName"/>
  204. <attribute name="GetPropertyValue.properties.local"/>
  205. <element name="GetPropertyValue"/>
  206. <sequential>
  207. <xslt style="${get_wfs.propertyName.xsl}" in="@{wfsoutputxml}" destdir="./" out="@{GetPropertyValue.properties.local}" >
  208. <factory name="net.sf.saxon.TransformerFactoryImpl">
  209. <attribute name="http://saxon.sf.net/feature/xinclude-aware" value="true"/>
  210. <!--<attribute name="http://saxon.sf.net/feature/initialMode" value="{http://biuro.biall-net.pl/xmlschema_procesy5/default_db_xml_cache/typespecial_to_ref/typespecial_to_ref.xsd}typespecial_refererences"/>-->
  211. </factory>
  212. <param name="propertyName" expression="@{PropertyName}"/>
  213. <param name="set.propertyName" expression="@{setPropertyName}"/>
  214. <classpath location="/opt/local/share/java/saxon9he.jar"/>
  215. </xslt>
  216. <!--<exec executable="open">
  217. <arg value="${@{localremote}.sync.obj.@{obj}.lastid.properties}"/>
  218. </exec>-->
  219. <loadproperties srcfile="@{wfsoutputxml}" />
  220. <!--<echo> loaded {@{localremote}.sync.obj.@{obj}.lastid} = ${@{localremote}.sync.obj.@{obj}.lastid} </echo>-->
  221. <echo>#240 TODO load poperties @{GetPropertyValue.properties.local}</echo>
  222. </sequential>
  223. </macrodef>
  224. <target name="PostXmlTransaction" description="TODO to post transaction based on build__for_post_to_wfs and curl_post_wfst">
  225. <local name="wfs_input.xml.local"/>
  226. <local name="api_url.local"/>
  227. <input addproperty="wfs_input.xml.local" defaultvalue="${wfs_input.xml}"/>
  228. <input addproperty="api_url.local" defaultvalue="${api_url}"/>
  229. <exec executable="curl" outputproperty="wfs_output" errorproperty="wfs_error" resultproperty="wfs_result" failonerror="true">
  230. <arg value="-H 'Authorization: Basic ${passwordBase64Basic_tested}'"/>
  231. <arg value="-X"/>
  232. <arg value="POST"/>
  233. <arg value="-d"/>
  234. <arg value="${wfs_input.xml.local}"/>
  235. <arg value="'${api_url}'"/>
  236. <!--<arg value="-\-user {$Types__x3A__wfs:username}:{$Types__x3A__wfs:username-pass} "/>-->
  237. <arg value="-v"/>
  238. <arg value="--insecure"/>
  239. <!--<arg value="-O"/>
  240. <arg value="{@Target_file}"/>-->
  241. </exec>
  242. <echo file="${wfs_output.xml}" message="${wfs_output}"/>
  243. <echo file="${wfs_result.xml}" message="${wfs_result}"/>
  244. <echo file="${wfs_error.xml}" message="${wfs_error}"/>
  245. </target>
  246. <target name="PostHttpForm" description="TODO to post just by using default ant engine - to post properties" depends="php_session_id_check">
  247. <!--<local name="get_wfs.PostHttpForm.local"/>-->
  248. <!--<local name="api_url.local"/>-->
  249. <input addproperty="get_wfs.PostHttpForm.local" message="podaj get_wfs.PostHttpForm.local"/>
  250. <input addproperty="api_url.local" defaultvalue="${api_url}" message="podaj api_url.local"/>
  251. <input addproperty="wfs_output.xml.local"/>
  252. <echo > Posting TO $api_url.local = ${api_url.local} level="verbose"
  253. $passwordBase64Basic_tested = ${passwordBase64Basic_tested}
  254. $php_session_id_tested = ${php_session_id_tested}
  255. $get_wfs.PostHttpForm.local = ${get_wfs.PostHttpForm.local}
  256. $cookie_curl_option = ${cookie_curl_option}
  257. $wfs_output.xml.local = ${wfs_output.xml.local}
  258. ${curl} ${php_session_id_tested} -d "${get_wfs.PostHttpForm.local}" '${api_url.local}'
  259. </echo>
  260. <exec executable="${curl}" outputproperty="wfs_output" errorproperty="wfs_error" resultproperty="wfs_result" failonerror="true">
  261. <arg line="${php_session_id_tested} -d &apos;${get_wfs.PostHttpForm.local}&apos; &apos;${api_url.local}&apos;"/>
  262. <!--<arg value="-H 'Authorization: Basic ${passwordBase64Basic_tested}'"/>
  263. <arg value="-\-data"/> <!-\- -F -\->
  264. <arg value="&apos;${get_wfs.PostHttpForm.local}&apos;"/>
  265. <arg value="${api_url.local}"/>
  266. <!-\-<arg value="-\\-user {$Types__x3A__wfs:username}:{$Types__x3A__wfs:username-pass} "/>-\->
  267. <arg value="-v"/>
  268. <arg value="-\-insecure"/>-->
  269. <!--<arg value="-O"/>
  270. <arg value="{@Target_file}"/>-->
  271. </exec>
  272. <!--<echo>#result $wfs_error = ${wfs_error} $outputproperty = ${outputproperty} </echo>-->
  273. <echo file="${wfs_output.xml.local}" message="${wfs_output}"/>
  274. <echo file="${wfs_result.xml}" message="${wfs_result}"/>
  275. <echo file="${wfs_error.xml}" message="${wfs_error}"/>
  276. <echo>#304 exec done!</echo>
  277. </target>
  278. <target name="GetFeatureByLastMod" description="URL_TASK Target GetFeatureByLastMod - should do incremental retrievement" depends="Filter_check"/><!-- R read_build_properties, -->
  279. <target name="GetXmlByUrlVerifyRetry" description="To use from recruse ant and be verified">
  280. <!--<echo>GetXmlByUrlVerifyRetry #154 we used </echo>-->
  281. <exec executable="curl" output="${output}" errorproperty="wfs_error">
  282. <arg line="${cookie_curl_option} &quot;${url}&quot;"/>
  283. <arg line="--connect-timeout 5"/>
  284. <arg line="--max-time 240"/>
  285. <arg line="--retry 5"/>
  286. <arg line="--retry-max-time 1200"/>
  287. </exec>
  288. <!--<echo message="ERROR__START"/>-->
  289. <!--<echo>${wfs_error}</echo>-->
  290. <!--<echo message="ERROR__END"/>-->
  291. <antcall target="GetXmlByUrlVerifyRetry.validate_length"/>
  292. <!--<antcall target="GetXmlByUrlVerifyRetry_verify"/>
  293. <echo> Validate $GetXmlByUrlVerifyRetry_verify: ${GetXmlByUrlVerifyRetry_verify}</echo>
  294. <echo> Validate $warn: ${warn}</echo>-->
  295. </target>
  296. <target name="GetXmlByUrlVerifyRetry.validate_length.condition" description="To verify if downloaded file is correct" >
  297. <length file="${output}" property="output.length"/>
  298. <!--<echo> $output.length = ${output.length}</echo>-->
  299. <condition property="output.length.failed" taskname="GetXmlByUrlVerifyRetry.validate_length">
  300. <equals arg1="${output.length}" arg2="128"/>
  301. </condition>
  302. <condition property="output.length.failed.0" taskname="GetXmlByUrlVerifyRetry.validate_length.0">
  303. <equals arg1="${output.length}" arg2="0"/>
  304. </condition>
  305. </target>
  306. <target name="GetXmlByUrlVerifyRetry.validate_length" depends="GetXmlByUrlVerifyRetry.validate_length.condition">
  307. <antcall target="GetXmlByUrlVerifyRetry.validate_length.failed"/>
  308. <antcall target="GetXmlByUrlVerifyRetry.validate_length.failed.0"/>
  309. </target>
  310. <target name="GetXmlByUrlVerifyRetry.validate_length.failed" if="${output.length.failed}">
  311. <echo>GetXmlByUrlVerifyRetry.validate_length.failed #182 - first retry ! </echo>
  312. <delete file="${output}" quiet="true"/>
  313. <exec executable="curl" output="${output}" errorproperty="wfs_error">
  314. <arg line="${cookie_curl_option} &quot;${url}&quot;"/>
  315. <arg line="--connect-timeout 5"/>
  316. <arg line="--max-time 240"/>
  317. <arg line="--retry 5"/>
  318. <arg line="--retry-max-time 1200"/>
  319. </exec>
  320. <length file="${output}" property="output.length.try1"/>
  321. <echo> $output.length.try1 = ${output.length.try1}</echo>
  322. </target>
  323. <target name="GetXmlByUrlVerifyRetry.validate_length.failed.0" if="${output.length.failed.0}">
  324. <echo>GetXmlByUrlVerifyRetry.validate_length.failed #198 - first retry - zero length ! </echo>
  325. <delete file="${output}" quiet="true"/>
  326. <exec executable="curl" output="${output}" errorproperty="wfs_error">
  327. <arg line="${cookie_curl_option} &quot;${url}&quot;"/>
  328. <arg line="--connect-timeout 5"/>
  329. <arg line="--max-time 240"/>
  330. <arg line="--retry 5"/>
  331. <arg line="--retry-max-time 1200"/>
  332. </exec>
  333. <length file="${output}" property="output.length.try.0"/>
  334. <echo> $output.length.try.0 = ${output.length.try.0}</echo>
  335. </target>
  336. <target name="GetXmlByUrlVerifyRetry_verify" description="To verify if downloaded file is correct" >
  337. <xmlvalidate file="${output}" lenient="yes" failonerror="false" warn="warn" />
  338. <echo>#169 after validated ? not set any?</echo>
  339. </target>
  340. <target name="GetFeature.WithVerifyUnauthorized" depends="GetFeature"> <!-- GetFeature.VerifyUnauthorized.failed -->
  341. <loadfile property="GetFeature.WithVerifyUnauthorized.srcfile" srcfile="${wfs_output.xml}" />
  342. <condition property="GetFeature.VerifyUnauthorized.condition" taskname="GetFeature.VerifyUnauthorized.failed">
  343. <contains string="${GetFeature.WithVerifyUnauthorized.srcfile}" substring="Unauthorized" />
  344. </condition>
  345. </target>
  346. <target name="GetFeature.VerifyUnauthorized.failed" if="${GetFeature.VerifyUnauthorized.condition}">
  347. <fail>
  348. #258 Cannot properly download ${get_url}
  349. Propably unset -DpasswordBase64Basic parameter!
  350. generate it with :
  351. echo "username:password" |base64
  352. </fail>
  353. </target>
  354. <!-- @2017-12-14 copied from recurse_ant to be there only! -->
  355. <target name="php_session_id_cond">
  356. <condition property="php_session_id_fail" taskname="php_session_id_check">
  357. <or>
  358. <equals arg1="${php_session_id}" arg2=""/>
  359. <equals arg1="${php_session_id}" arg2="$${php_session_id}"/>
  360. </or>
  361. </condition>
  362. </target>
  363. <target name="php_session_id_check" depends="php_session_id_cond,php_session_id_ok,php_session_id_fail" description="To create property php_session_id_tested for use in api calls"/>
  364. <target name="php_session_id_ok" unless="php_session_id_fail" description="use php_session_id from parameter ">
  365. <property name="php_session_id_tested" value="--cookie 'PHPSESSID=${php_session_id}'"/>
  366. </target>
  367. <target name="php_session_id_fail" if="php_session_id_fail" unless="php_session_id_tested" description="retrieve php_session_id from API to use it after for fasten api requests" depends="create_tempdir"><!-- R read_build_properties, -->
  368. <tempfile destdir="${get_wfs.temp}" prefix="usernameandpass" deleteonexit="yes" property="username_and_pass_from_passwordBase64Basic.properties" />
  369. <ant antfile="${username_and_pass_from_passwordBase64Basic.build}" target="username_and_pass_from_passwordBase64Basic.properties"/>
  370. <loadproperties srcfile="${username_and_pass_from_passwordBase64Basic.properties}"/>
  371. <echo> retrieved $username=${username}
  372. php_session_id_check.properties=${php_session_id_check.properties}
  373. $api_url = ${api_url}
  374. </echo>
  375. <!-- retrieve new properties -username , username.pass -->
  376. <property name="cookie_file" value="${get_wfs.temp}/${username}.cookie"/>
  377. <!--<property name="cookie_file" value="${get_wfs.temp}/${username}.cookie"/>-->
  378. <delete file="${cookie_file}" failonerror="no"/>
  379. <exec executable="curl"> <!-- errorproperty="wfs_error" resultproperty="wfs_result" -->
  380. <arg line=" -c ${cookie_file} -H 'Authorization: Basic ${passwordBase64Basic_tested}' &#34;${api_url}&#34;"/> <!-- /default_db/?SERVICE=WFS&amp;VERSION=1.0.0&amp;REQUEST=GetCapabilities&#34; -->
  381. </exec>
  382. <echo> runned: curl -c ${cookie_file} -H 'Authorization: Basic ${passwordBase64Basic_tested}' &#34;${api_url}&#34;</echo>
  383. <property name="php_session_id_tested" value=" -b ${cookie_file}"/>
  384. <!-- detecting from cookie file just phpsesssid string
  385. # Netscape HTTP Cookie File
  386. # https://curl.haxx.se/docs/http-cookies.html
  387. # This file was generated by libcurl! Edit at your own risk.
  388. biuro.biall-net.pl FALSE / FALSE 0 PHPSESSID ndosk8faaskrfvdcbge8ki571l0oukdqtg7bmjht43b0cslohpbua2g5ouoi3b2vm6l14avvgna8bq6j6ufranhu77mtjplc1dthat2
  389. -->
  390. <loadfile property="php_session_id_tested.loadfile" srcfile="${cookie_file}" />
  391. <exec executable="bash" outputproperty="php_session_id_ok.string" >
  392. <arg value="-c" />
  393. <arg value="echo '${php_session_id_tested.loadfile}'|grep PHPSESSID |sed 's/.*PHPSESSID[ |\t]*//'"/>
  394. </exec>
  395. <property name="php_session_id_ok.string.test" value="test"/>
  396. <echo> #289 we set php_session_id_tested=(${php_session_id_tested})
  397. $php_session_id_ok.string = ${php_session_id_ok.string};
  398. $cookie_file = ${cookie_file}
  399. $username = ${username}
  400. </echo>
  401. </target>
  402. <target name="php_session_id_check.properties" depends="php_session_id_check">
  403. <echo>#329 saving properties to ${php_session_id_check.properties}</echo>
  404. <echoproperties destfile="${php_session_id_check.properties}" regex="(php_session_id_ok*)|(username*)"/>
  405. <echoproperties destfile="${get_wfs.php_session_id_check.properties}" regex="(php_session_id_ok*)|(username*)|(php_session_id_tested)"/>
  406. </target>
  407. </project>