Skip to content

Commit 18e3c78

Browse files
committed
Function cleanup
1 parent b0d2cdd commit 18e3c78

4 files changed

Lines changed: 73 additions & 105 deletions

File tree

src/main/webapp/static/com/atomgraph/linkeddatahub/xsl/bootstrap/2.3.2/client/block/query.xsl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -454,7 +454,7 @@ exclude-result-prefixes="#all"
454454
<ixsl:promise select="
455455
ixsl:http-request($context('request')) (: Step 1: send initial request :)
456456
=> ixsl:then(ldh:rethread-response($context, ?)) (: Step 2: attach response to context :)
457-
=> ixsl:then(ldh:handle-responseA#1) (: Step 3: handle 429s, etc. :)
457+
=> ixsl:then(ldh:handle-response#1) (: Step 3: handle 429s, etc. :)
458458
=> ixsl:then(ldh:row-form-patch-response#1)
459459
"/>
460460
</xsl:template>

src/main/webapp/static/com/atomgraph/linkeddatahub/xsl/bootstrap/2.3.2/client/block/view.xsl

Lines changed: 15 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -90,7 +90,7 @@ exclude-result-prefixes="#all"
9090
}"/>
9191
<ixsl:promise select="ixsl:http-request($context('request')) =>
9292
ixsl:then(ldh:rethread-response($context, ?)) =>
93-
ixsl:then(ldh:handle-responseA#1) =>
93+
ixsl:then(ldh:handle-response#1) =>
9494
ixsl:then(ldh:view-query-load#1)"
9595
on-failure="ldh:form-horizontal-submit-error#1"/>
9696
</xsl:template>
@@ -255,7 +255,7 @@ exclude-result-prefixes="#all"
255255
}"/>
256256
<ixsl:promise select="ixsl:http-request($context('request')) =>
257257
ixsl:then(ldh:rethread-response($context, ?)) =>
258-
ixsl:then(ldh:handle-responseA#1) =>
258+
ixsl:then(ldh:handle-response#1) =>
259259
ixsl:then(ldh:result-count-results-load#1)"
260260
on-failure="ldh:form-horizontal-submit-error#1"/>
261261
</xsl:template>
@@ -457,7 +457,7 @@ exclude-result-prefixes="#all"
457457
}"/>
458458
<ixsl:promise select="ixsl:http-request($context('request')) =>
459459
ixsl:then(ldh:rethread-response($context, ?)) =>
460-
ixsl:then(ldh:handle-responseA#1) =>
460+
ixsl:then(ldh:handle-response#1) =>
461461
ixsl:then(ldh:container-results-response#1)"
462462
on-failure="ldh:form-horizontal-submit-error#1"/>
463463
</xsl:template>
@@ -474,6 +474,10 @@ exclude-result-prefixes="#all"
474474
<xsl:param name="select-xml" as="document-node()"/>
475475
<xsl:param name="base-uri" as="xs:anyURI"/>
476476

477+
<xsl:for-each select="$block//div[contains-token(@class, 'bar')]">
478+
<ixsl:set-style name="width" select="'88%'" object="."/>
479+
</xsl:for-each>
480+
477481
<xsl:for-each select="$container">
478482
<xsl:result-document href="?." method="ixsl:replace-content">
479483
<xsl:call-template name="ldh:ViewModeChoice">
@@ -660,7 +664,7 @@ exclude-result-prefixes="#all"
660664
}"/>
661665
<ixsl:promise select="ixsl:http-request($context('request')) =>
662666
ixsl:then(ldh:rethread-response($context, ?)) =>
663-
ixsl:then(ldh:handle-responseA#1) =>
667+
ixsl:then(ldh:handle-response#1) =>
664668
ixsl:then(ldh:facet-filter-results-load#1)"
665669
on-failure="ldh:form-horizontal-submit-error#1"/>
666670
</xsl:if>
@@ -884,7 +888,7 @@ exclude-result-prefixes="#all"
884888
}"/>
885889
<ixsl:promise select="ixsl:http-request($context('request')) =>
886890
ixsl:then(ldh:rethread-response($context, ?)) =>
887-
ixsl:then(ldh:handle-responseA#1) =>
891+
ixsl:then(ldh:handle-response#1) =>
888892
ixsl:then(ldh:parallax-results-load#1)"
889893
on-failure="ldh:form-horizontal-submit-error#1"/>
890894
</xsl:if>
@@ -957,7 +961,7 @@ exclude-result-prefixes="#all"
957961
}"/>
958962
<ixsl:promise select="ixsl:http-request($context('request')) =>
959963
ixsl:then(ldh:rethread-response($context, ?)) =>
960-
ixsl:then(ldh:handle-responseA#1) =>
964+
ixsl:then(ldh:handle-response#1) =>
961965
ixsl:then(ldh:container-object-metadata-results-load#1)"
962966
on-failure="ldh:form-horizontal-submit-error#1"/>
963967
</xsl:template>
@@ -1199,7 +1203,7 @@ exclude-result-prefixes="#all"
11991203

12001204
<ixsl:promise select="ixsl:http-request($context('request')) =>
12011205
ixsl:then(ldh:rethread-response($context, ?)) =>
1202-
ixsl:then(ldh:handle-responseA#1) =>
1206+
ixsl:then(ldh:handle-response#1) =>
12031207
ixsl:then(ldh:facet-value-results-load#1)"
12041208
on-failure="ldh:form-horizontal-submit-error#1"/>
12051209
</xsl:for-each>
@@ -1559,7 +1563,7 @@ exclude-result-prefixes="#all"
15591563
}"/>
15601564
<ixsl:promise select="ixsl:http-request($context('request')) =>
15611565
ixsl:then(ldh:rethread-response($context, ?)) =>
1562-
ixsl:then(ldh:handle-responseA#1) =>
1566+
ixsl:then(ldh:handle-response#1) =>
15631567
ixsl:then(ldh:order-by-results-load#1)"
15641568
on-failure="ldh:form-horizontal-submit-error#1"/>
15651569
</xsl:if>
@@ -1584,7 +1588,7 @@ exclude-result-prefixes="#all"
15841588
}), map{ 'duplicates': 'use-last' })"/>
15851589
<ixsl:promise select="ixsl:http-request($context('request')) =>
15861590
ixsl:then(ldh:rethread-response($context, ?)) =>
1587-
ixsl:then(ldh:handle-responseA#1) =>
1591+
ixsl:then(ldh:handle-response#1) =>
15881592
ixsl:then(ldh:container-object-metadata-results-load#1)"
15891593
on-failure="ldh:form-horizontal-submit-error#1"/>
15901594

@@ -1698,7 +1702,7 @@ exclude-result-prefixes="#all"
16981702
), map{ 'duplicates': 'use-last' })"/>
16991703
<ixsl:promise select="ixsl:http-request($context('request')) =>
17001704
ixsl:then(ldh:rethread-response($context, ?)) =>
1701-
ixsl:then(ldh:handle-responseA#1) =>
1705+
ixsl:then(ldh:handle-response#1) =>
17021706
ixsl:then(ldh:parallax-property-load#1)"
17031707
on-failure="ldh:form-horizontal-submit-error#1"/>
17041708
</xsl:for-each-group>
@@ -1826,7 +1830,7 @@ exclude-result-prefixes="#all"
18261830
}"/>
18271831
<ixsl:promise select="ixsl:http-request($context('request')) =>
18281832
ixsl:then(ldh:rethread-response($context, ?)) =>
1829-
ixsl:then(ldh:handle-responseA#1) =>
1833+
ixsl:then(ldh:handle-response#1) =>
18301834
ixsl:then(ldh:facet-value-type-load#1)"
18311835
on-failure="ldh:form-horizontal-submit-error#1"/>
18321836
</xsl:for-each>
@@ -2014,10 +2018,6 @@ exclude-result-prefixes="#all"
20142018
<xsl:when test="?status = 200 and ?media-type = 'application/rdf+xml'">
20152019
<xsl:variable name="object-metadata" select="?body" as="document-node()"/>
20162020

2017-
<xsl:for-each select="$block//div[contains-token(@class, 'bar')]">
2018-
<ixsl:set-style name="width" select="'88%'" object="."/>
2019-
</xsl:for-each>
2020-
20212021
<xsl:call-template name="ldh:RenderViewMode">
20222022
<xsl:with-param name="block" select="$block"/>
20232023
<xsl:with-param name="container" select="$container"/>

src/main/webapp/static/com/atomgraph/linkeddatahub/xsl/bootstrap/2.3.2/client/form.xsl

Lines changed: 12 additions & 65 deletions
Original file line numberDiff line numberDiff line change
@@ -288,10 +288,10 @@ WHERE
288288
<ixsl:promise select="
289289
ixsl:http-request($context('request')) (: Step 1: send initial request :)
290290
=> ixsl:then(ldh:rethread-response($context, ?)) (: Step 2: attach response to context :)
291-
=> ixsl:then(ldh:handle-responseA#1) (: Step 3: handle 429s, etc. :)
291+
=> ixsl:then(ldh:handle-response#1) (: Step 3: handle 429s, etc. :)
292292
=> ixsl:then(ldh:load-edited-resource#1) (: Step 4: extract resource, build next request :)
293293
=> ixsl:then(ldh:http-request-threaded#1) (: Step 5: send next request and rethread :)
294-
=> ixsl:then(ldh:handle-responseA#1) (: Step 6: handle retry if needed :)
294+
=> ixsl:then(ldh:handle-response#1) (: Step 6: handle retry if needed :)
295295
=> ixsl:then(ldh:load-type-metadata#1) (: Step 7: final step using full context :)
296296
=> ixsl:then(ldh:render-row-form#1)
297297
"/>
@@ -344,70 +344,16 @@ WHERE
344344
<ixsl:promise select="
345345
ixsl:http-request($context('request')) (: Step 1: send initial request :)
346346
=> ixsl:then(ldh:rethread-response($context, ?)) (: Step 2: attach response to context :)
347-
=> ixsl:then(ldh:handle-responseA#1) (: Step 3: handle 429s, etc. :)
347+
=> ixsl:then(ldh:handle-response#1) (: Step 3: handle 429s, etc. :)
348348
=> ixsl:then(ldh:load-edited-resource#1) (: Step 4: extract resource, build next request :)
349349
=> ixsl:then(ldh:http-request-threaded#1) (: Step 5: send next request and rethread :)
350-
=> ixsl:then(ldh:handle-responseA#1) (: Step 6: handle retry if needed :)
350+
=> ixsl:then(ldh:handle-response#1) (: Step 6: handle retry if needed :)
351351
=> ixsl:then(ldh:load-type-metadata#1) (: Step 7: final step using full context :)
352352
=> ixsl:then(ldh:wrap-into-document#1)
353353
=> ixsl:then(ldh:render-form#1)
354354
"/>
355355
</xsl:template>
356356

357-
<xsl:function name="ldh:rethread-response" as="map(*)" ixsl:updating="no">
358-
<xsl:param name="context" as="map(*)"/>
359-
<xsl:param name="response" as="map(*)"/>
360-
361-
<xsl:sequence select="map:merge(($context, map{ 'response': $response }), map{ 'duplicates': 'use-last' })"/>
362-
</xsl:function>
363-
364-
<xsl:function name="ldh:http-request-threaded" as="map(*)" ixsl:updating="yes">
365-
<xsl:param name="context" as="map(*)"/>
366-
367-
<xsl:sequence select="
368-
ixsl:http-request($context('request'))
369-
=> ixsl:then(ldh:rethread-response($context, ?))
370-
"/>
371-
</xsl:function>
372-
373-
<xsl:function name="ldh:handle-responseA" as="item()*" ixsl:updating="yes">
374-
<xsl:param name="context" as="map(*)"/>
375-
376-
<xsl:variable name="request" select="$context('request')" as="map(*)"/>
377-
<xsl:variable name="response" select="$context('response')" as="map(*)"/>
378-
<xsl:variable name="default-retry-after" select="1" as="xs:integer"/>
379-
380-
<xsl:choose>
381-
<xsl:when test="$response?status = 429">
382-
<xsl:variable name="retry-after" select="
383-
if (map:contains($response?headers, 'Retry-After'))
384-
then xs:integer($response?headers('Retry-After'))
385-
else $default-retry-after"/>
386-
387-
<xsl:sequence select="
388-
ixsl:sleep($retry-after * 1000)
389-
=> ixsl:then(ldh:retry-requestA($context, ?))
390-
"/>
391-
</xsl:when>
392-
<xsl:otherwise>
393-
<xsl:sequence select="$context"/>
394-
</xsl:otherwise>
395-
</xsl:choose>
396-
</xsl:function>
397-
398-
<xsl:function name="ldh:retry-requestA" as="item()*" ixsl:updating="yes">
399-
<xsl:param name="context" as="map(*)"/>
400-
<xsl:param name="sleep-result" as="item()?"/>
401-
402-
<xsl:variable name="request" select="$context('request')"/>
403-
404-
<xsl:sequence select="
405-
ixsl:http-request($request)
406-
=> ixsl:then(ldh:rethread-response($context, ?))
407-
=> ixsl:then(ldh:handle-responseA#1)
408-
"/>
409-
</xsl:function>
410-
411357
<xsl:function name="ldh:load-edited-resource" as="map(*)" ixsl:updating="yes">
412358
<xsl:param name="context" as="map(*)"/>
413359
<xsl:variable name="response" select="$context('response')" as="map(*)"/>
@@ -442,8 +388,9 @@ WHERE
442388
</xsl:when>
443389
<!-- error response -->
444390
<xsl:otherwise>
445-
<ixsl:set-style name="cursor" select="'default'" object="ixsl:page()//body"/>
446-
<xsl:sequence select="ixsl:call(ixsl:window(), 'alert', [ ?message ])"/>
391+
<!-- <ixsl:set-style name="cursor" select="'default'" object="ixsl:page()//body"/>
392+
<xsl:sequence select="ixsl:call(ixsl:window(), 'alert', [ ?message ])"/>-->
393+
<xsl:sequence select="error(QName('&ldh;', 'ldh:ldh:load-edited-resource-error'), 'Could not load edited resource', map{ 'code': 999 })"/>
447394
</xsl:otherwise>
448395
</xsl:choose>
449396
</xsl:for-each>
@@ -691,7 +638,7 @@ WHERE
691638
<ixsl:promise select="
692639
ixsl:http-request($context('request')) (: Step 1: send initial request :)
693640
=> ixsl:then(ldh:rethread-response($context, ?)) (: Step 2: attach response to context :)
694-
=> ixsl:then(ldh:handle-responseA#1) (: Step 3: handle 429s, etc. :)
641+
=> ixsl:then(ldh:handle-response#1) (: Step 3: handle 429s, etc. :)
695642
=> ixsl:then(ldh:form-horizontal-response#1)
696643
"/>
697644
</xsl:otherwise>
@@ -747,7 +694,7 @@ WHERE
747694
<ixsl:promise select="
748695
ixsl:http-request($context('request')) (: Step 1: send initial request :)
749696
=> ixsl:then(ldh:rethread-response($context, ?)) (: Step 2: attach response to context :)
750-
=> ixsl:then(ldh:handle-responseA#1) (: Step 3: handle 429s, etc. :)
697+
=> ixsl:then(ldh:handle-response#1) (: Step 3: handle 429s, etc. :)
751698
=> ixsl:then(ldh:modal-form-patch-response#1)
752699
" on-failure="ldh:form-horizontal-submit-error#1"/>
753700
</xsl:template>
@@ -801,7 +748,7 @@ WHERE
801748
<ixsl:promise select="
802749
ixsl:http-request($context('request')) (: Step 1: send initial request :)
803750
=> ixsl:then(ldh:rethread-response($context, ?)) (: Step 2: attach response to context :)
804-
=> ixsl:then(ldh:handle-responseA#1) (: Step 3: handle 429s, etc. :)
751+
=> ixsl:then(ldh:handle-response#1) (: Step 3: handle 429s, etc. :)
805752
=> ixsl:then(ldh:row-form-patch-response#1)
806753
"/>
807754
</xsl:template>
@@ -1011,7 +958,7 @@ WHERE
1011958
<xsl:sequence select="
1012959
ixsl:http-request($context('request')) (: Step 1: send initial request :)
1013960
=> ixsl:then(ldh:rethread-response($context, ?)) (: Step 2: attach response to context :)
1014-
=> ixsl:then(ldh:handle-responseA#1) (: Step 3: handle 429s, etc. :)
961+
=> ixsl:then(ldh:handle-response#1) (: Step 3: handle 429s, etc. :)
1015962
=> ixsl:then(ldh:xhtml-document-loaded#1)
1016963
"/>
1017964
</xsl:for-each>
@@ -1034,7 +981,7 @@ WHERE
1034981
<xsl:sequence select="
1035982
ixsl:http-request($context('request')) (: Step 1: send initial request :)
1036983
=> ixsl:then(ldh:rethread-response($context, ?)) (: Step 2: attach response to context :)
1037-
=> ixsl:then(ldh:handle-responseA#1) (: Step 3: handle 429s, etc. :)
984+
=> ixsl:then(ldh:handle-response#1) (: Step 3: handle 429s, etc. :)
1038985
=> ixsl:then(ldh:xhtml-document-loaded#1)
1039986
"/>
1040987
</xsl:for-each>

src/main/webapp/static/com/atomgraph/linkeddatahub/xsl/bootstrap/2.3.2/client/functions.xsl

Lines changed: 45 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -450,36 +450,57 @@ exclude-result-prefixes="#all"
450450
<!-- generic HTTP client promises (SaxonJS 3) -->
451451

452452
<xsl:function name="ldh:handle-response" as="item()*" ixsl:updating="yes">
453-
<xsl:param name="request" as="map(*)"/>
454-
<xsl:param name="response" as="map(*)"/>
455-
<xsl:variable name="default-retry-after" select="1" as="xs:integer"/>
453+
<xsl:param name="context" as="map(*)"/>
456454

457-
<xsl:choose>
458-
<xsl:when test="$response?status = 429">
459-
<xsl:variable name="retry-after" select="
460-
if (map:contains($response?headers, 'Retry-After'))
461-
then xs:integer($response?headers('Retry-After'))
462-
else $default-retry-after"/>
455+
<xsl:variable name="request" select="$context('request')" as="map(*)"/>
456+
<xsl:variable name="response" select="$context('response')" as="map(*)"/>
457+
<xsl:variable name="default-retry-after" select="1" as="xs:integer"/>
463458

464-
<xsl:sequence select="
465-
ixsl:sleep($retry-after * 1000)
466-
=> ixsl:then(ldh:retry-request($request, ?))
467-
"/>
468-
</xsl:when>
469-
<xsl:otherwise>
470-
<xsl:sequence select="$response"/>
471-
</xsl:otherwise>
472-
</xsl:choose>
459+
<xsl:choose>
460+
<xsl:when test="$response?status = 429">
461+
<xsl:variable name="retry-after" select="
462+
if (map:contains($response?headers, 'Retry-After'))
463+
then xs:integer($response?headers('Retry-After'))
464+
else $default-retry-after"/>
465+
466+
<xsl:sequence select="
467+
ixsl:sleep($retry-after * 1000)
468+
=> ixsl:then(ldh:retry-request($context, ?))
469+
"/>
470+
</xsl:when>
471+
<xsl:otherwise>
472+
<xsl:sequence select="$context"/>
473+
</xsl:otherwise>
474+
</xsl:choose>
473475
</xsl:function>
474476

475477
<xsl:function name="ldh:retry-request" as="item()*" ixsl:updating="yes">
476-
<xsl:param name="request" as="map(*)"/>
477-
<xsl:param name="sleep-result" as="item()?"/>
478+
<xsl:param name="context" as="map(*)"/>
479+
<xsl:param name="sleep-result" as="item()?"/>
480+
481+
<xsl:variable name="request" select="$context('request')"/>
482+
483+
<xsl:sequence select="
484+
ixsl:http-request($request)
485+
=> ixsl:then(ldh:rethread-response($context, ?))
486+
=> ixsl:then(ldh:handle-response#1)
487+
"/>
488+
</xsl:function>
489+
490+
<xsl:function name="ldh:rethread-response" as="map(*)" ixsl:updating="no">
491+
<xsl:param name="context" as="map(*)"/>
492+
<xsl:param name="response" as="map(*)"/>
493+
494+
<xsl:sequence select="map:merge(($context, map{ 'response': $response }), map{ 'duplicates': 'use-last' })"/>
495+
</xsl:function>
496+
497+
<xsl:function name="ldh:http-request-threaded" as="map(*)" ixsl:updating="yes">
498+
<xsl:param name="context" as="map(*)"/>
478499

479-
<xsl:sequence select="
480-
ixsl:http-request($request)
481-
=> ixsl:then(ldh:handle-response($request, ?))
482-
"/>
500+
<xsl:sequence select="
501+
ixsl:http-request($context('request'))
502+
=> ixsl:then(ldh:rethread-response($context, ?))
503+
"/>
483504
</xsl:function>
484505

485506
</xsl:stylesheet>

0 commit comments

Comments
 (0)