Skip to content

Commit

Permalink
fix: check if document already exists before trying to add a document…
Browse files Browse the repository at this point in the history
… to allow for retries
  • Loading branch information
MLenterman committed May 27, 2024
1 parent e8f2111 commit c2836d2
Show file tree
Hide file tree
Showing 2 changed files with 99 additions and 5 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
<xsl:stylesheet exclude-result-prefixes="xs xsl zgw" version="3.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
xmlns:xs="http://www.w3.org/2001/XMLSchema"
xmlns:zgw="http://google.com/zgw"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:document="http://www.emaxx.org/functional/cases/document"
xmlns:cases="http://www.emaxx.org/functional/cases"
>
<xsl:output method="xml" version="1.0" encoding="UTF-8" indent="yes" omit-xml-declaration="yes" exclude-result-prefixes="xsi"/>
<xsl:include href="../../BpelFunctionsBase.xslt" />

<!-- Map -->
<xsl:param name="ZgwEnkelvoudigInformatieObject" as="node()"><ZgwEnkelvoudigInformatieObject /></xsl:param>

<!-- Create/Enrich -->
<xsl:param name="Document" as="node()"><document:document /></xsl:param>

<xsl:param name="ReferenceNumber" select="''" as="xs:string" />
<xsl:param name="Provider" as="node()"><document:provider /></xsl:param>
<xsl:param name="TargetSystems" as="node()"><document:document /></xsl:param>

<xsl:template match="/">
<document:readDocument>
<document:documentIdMessage>
<xsl:copy-of select="zgw:WrapNullOrSkip('document:referenceNumber', 'empty', zgw:FromOrderedSource(
$ReferenceNumber,
$Document//document:referenceNumber,
$ZgwEnkelvoudigInformatieObject//identificatie,
//document:referenceNumber),
'http://www.emaxx.org/functional/cases/document')"/>
<xsl:copy-of select="zgw:ObjectFromOrderedSource(
$Provider,
$Document//document:provider,
'',
//document:provider)"/>
<document:targetSystem>
<document:code />
<document:referenceNumber />
</document:targetSystem>
</document:documentIdMessage>
</document:readDocument>
</xsl:template>
</xsl:stylesheet>
Original file line number Diff line number Diff line change
Expand Up @@ -102,9 +102,51 @@
<Param name="Taal" xpathExpression="concat(concat($Alpha2, '_'), upper-case($Alpha2))">
<Param name="Alpha2" sessionKey="Alpha2" />
</Param>
<Forward name="success" path="CreateAddDocumentRequestMessage"/>
<Forward name="success" path="CreateReadDocumentRequestMessage"/>
</XsltPipe>

<XsltPipe
name="CreateReadDocumentRequestMessage"
getInputFromFixedValue="&lt;dummy/&gt;"
styleSheetName="Bpel/Documents/Model/ReadDocumentRequestMessage.xslt"
storeResultInSessionKey="ReadDocumentRequestMessage"
>
<Param name="ZgwEnkelvoudigInformatieObject" sessionKey="ZgwEnkelvoudigInformatieObject" type="DOMDOC" />
<Param name="Provider" sessionKey="Provider" type="DOMDOC" />
<Forward name="success" path="BpelDocumentsPostReadDocumentSender" />
<Forward name="exception" path="CreateAddDocumentRequestMessage" />
</XsltPipe>

<SenderPipe
name="BpelDocumentsPostReadDocumentSender"
storeResultInSessionKey="ReadDocumentResponseMessage"
>
<IbisLocalSender
name="BpelDocumentsPostReadDocumentLocalSender"
javaListener="Bpel_Documents_Post"
>
<Param name="soapAction" value="documents:readDocument" />
</IbisLocalSender>
<Forward name="success" path="DocumentReferenceAlreadyExists_Condition" />
<Forward name="exception" path="CreateAddDocumentRequestMessage" />
</SenderPipe>

<XmlIfPipe
name="DocumentReferenceAlreadyExists_Condition"
xpathExpression="string-length(//*:readDocumentResponse/*:documentSessionMessage/*:document) gt 0"
>
<Forward name="then" path="StoreSessionIdAndDocument_DocumentReferenceAlreadyExists" />
<Forward name="else" path="CreateAddDocumentRequestMessage" />
</XmlIfPipe>

<PutInSessionPipe
name="StoreSessionIdAndDocument_DocumentReferenceAlreadyExists"
>
<Param name="SessionId" xpathExpression="//*:sessionId" />
<Param name="Document" sessionKey="ReadDocumentResponseMessage" type="DOMDOC" />
<Forward name="success" path="CreateAddDocumentMtomRequestMessage" />
</PutInSessionPipe>

<XsltPipe
name="CreateAddDocumentRequestMessage"
getInputFromFixedValue="&lt;dummy/&gt;"
Expand All @@ -124,19 +166,28 @@
>
<IbisLocalSender
name="BpelDocumentsPostAddDocumentLocalSender"
javaListener="Bpel_Documents_PostAddDocument"
javaListener="Bpel_Documents_Post"
>
<Param name="soapAction" value="documents:addDocument" />
</IbisLocalSender>
<Forward name="success" path="CreateAddDocumentMtomRequestMessage" />
<Forward name="success" path="StoreSessionIdAndDocument" />
</SenderPipe>

<PutInSessionPipe
name="StoreSessionIdAndDocument"
>
<Param name="SessionId" xpathExpression="//*:sessionId" />
<Param name="Document" sessionKey="AddDocumentRequestMessage" type="DOMDOC" />
<Forward name="success" path="CreateAddDocumentMtomRequestMessage" />
</PutInSessionPipe>

<XsltPipe
name="CreateAddDocumentMtomRequestMessage"
getInputFromFixedValue="&lt;dummy/&gt;"
styleSheetName="Bpel/Mtom/Model/AddDocumentRequestMessage.xslt"
storeResultInSessionKey="AddDocumentMtomRequestMessage"
>
<Param name="SessionId" sessionKey="AddDocumentResponseMessage" xpathExpression="//*:sessionId" />
<Param name="SessionId" sessionKey="SessionId" />
<Param name="ContentType" sessionKey="ZgwEnkelvoudigInformatieObject" xpathExpression="tokenize(//formaat, '/')[last()]" />
<Param name="Document" sessionKey="ZgwEnkelvoudigInformatieObjectInhoud" />
<Forward name="success" path="BpelMtomPostAddDocumentSender" />
Expand All @@ -160,7 +211,7 @@
styleSheetName="Bpel/BasicStatusUpdate/Model/DocumentStatusRequestMessage.xslt"
storeResultInSessionKey="DocumentStatusRequestMessage"
>
<Param name="Document" sessionKey="AddDocumentRequestMessage" type="DOMDOC" />
<Param name="Document" sessionKey="Document" type="DOMDOC" />
<Param name="ReferenceNumber" sessionKey="CaseReferenceNumber" />
<Param name="Status_Code" value="FORWARDED" />
<Forward name="success" path="BpelBasicStatusUpdateDocumentStatusSender" />
Expand Down

0 comments on commit c2836d2

Please sign in to comment.