Adding a mechanism to avoid to archive multiple times the same resource for a single archive set.

This commit is contained in:
Eric van der Vlist 2012-04-13 13:05:25 +02:00
parent cf97a98416
commit 3d18e9d8a4
1 changed files with 234 additions and 169 deletions

View File

@ -2,6 +2,67 @@
<p:param name="data" type="input"/> <p:param name="data" type="input"/>
<!-- Look if the resource has already been archived for that set -->
<p:processor name="oxf:pipeline">
<p:input name="config" href="/data-access.xpl"/>
<p:input name="data" transform="oxf:xslt" href="#data">
<config xsl:version="2.0">
<relpath>
<xsl:value-of select="/action/@directory"/>
<xsl:text>index.xml</xsl:text>
</relpath>
<operation>read</operation>
<type>xquery</type>
<parameter name="url" type="string">
<xsl:value-of select="/action/@url"/>
</parameter>
</config>
</p:input>
<p:input name="param">
<xquery><![CDATA[
boolean(//archive[@url = $(url)])
]]></xquery>
</p:input>
<p:output name="data" id="duplicate" debug="duplicate"/>
</p:processor>
<p:choose href="#duplicate">
<p:when test="/*/* = 'true'">
<!-- Already archived, nothing to do -->
<!-- Update the queue -->
<p:processor name="oxf:pipeline">
<p:input name="config" href="/data-access.xpl"/>
<p:input name="data" transform="oxf:xslt" href="#data">
<config xsl:version="2.0">
<relpath>queue.xml</relpath>
<operation>write</operation>
<type>xquery</type>
<parameter name="uuid" type="string">
<xsl:value-of select="/action/@uuid"/>
</parameter>
</config>
</p:input>
<p:input name="param">
<xquery><![CDATA[
for $a in /queue/action where $a/@uuid = $(uuid) return
update
delete $a
]]></xquery>
</p:input>
<p:output name="data" id="response4" debug="response"/>
</p:processor>
<p:processor name="oxf:null-serializer">
<p:input name="data" href="#response4"/>
</p:processor>
</p:when>
<p:otherwise>
<!-- Otherwise, archive the resource... -->
<!-- Fetch the resource --> <!-- Fetch the resource -->
<p:processor name="oxf:url-generator"> <p:processor name="oxf:url-generator">
<p:input name="config" transform="oxf:xslt" href="#data"> <p:input name="config" transform="oxf:xslt" href="#data">
@ -251,5 +312,9 @@ for $a in /queue/action where $a/@uuid = $(uuid) return
</p:otherwise> </p:otherwise>
</p:choose> </p:choose>
</p:otherwise>
</p:choose>
</p:config> </p:config>