-
Notifications
You must be signed in to change notification settings - Fork 2
/
jnlp.xq
70 lines (61 loc) · 2.92 KB
/
jnlp.xq
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
xquery version "3.1";
declare namespace output = "http://www.w3.org/2010/xslt-xquery-serialization";
declare option output:method "xml";
declare option output:media-type "application/x-java-jnlp-file";
(: Get external URL, fix for strange response of Tomcat :)
let $url := replace(replace(request:get-url(), "/rest/db/", "/"), ".xq", ".jnlp")
let $href := tokenize($url, "/")[last()]
(: Codebase is the base URL to be able to download all other resources :)
let $codebase := substring-before($url, $href)
(: For XMLRPC we need the part after http(s):// :)
let $xmlrpc := substring-after(substring-before($codebase, request:get-attribute("prefix") || request:get-attribute("controller")),"://")
(: Get eXist-db version :)
let $versionDoc := doc("exist-config.xml")
let $version := data(doc("exist-config.xml")//version)
(: Determine the location of the jar files :)
let $jarsCollection := util:collection-name($versionDoc) || "/jars"
return
<jnlp spec="7.0" codebase="{ $codebase }" href="{ $href }" version="{ $version }">
<information>
<title>eXist-db client ({$version})</title>
<vendor>eXist Native XML Database</vendor>
<homepage href="http://exist-db.org"/>
<description>Integrated command-line and gui client, entirely based on the
XML:DB API and provides commands for most database related tasks,
like creating and removing collections, user management, batch-loading XML data
or querying.</description>
<description kind="short">Java client for the eXist Native XML Database.</description>
<description kind="tooltip">eXist-db client</description>
<icon kind="splash" href="resources/images/jnlp_splash.png"/>
<icon href="resources/images/jnlp_icon_64x64.png" width="64" height="64"/>
<icon href="resources/images/jnlp_icon_16x16.png" width="16" height="16"/>
<icon href="resources/images/jnlp_icon_32x32.png" width="32" height="32"/>
<offline-allowed/>
</information>
<security>
<all-permissions/>
</security>
<resources>
<property name="jnlp.packEnabled" value="true"/>
<java version="1.8+"/>
{
for $resource in sort(xmldb:get-child-resources($jarsCollection))
let $strippedName := replace($resource, "jar.pack.gz", "jar")
return
<jar href="jars/{ $strippedName }" size="{ xmldb:size($jarsCollection, $resource) }">
{ if(starts-with($strippedName, 'exist-')) then attribute main {"true"} else () }
</jar>
}
</resources>
<application-desc main-class="org.exist.client.InteractiveClient">
<argument>-ouri=xmldb:exist://{ $xmlrpc }/xmlrpc</argument>
<argument>--no-embedded-mode</argument>
{
if(starts-with($codebase, "https:"))
then
<argument>--use-ssl</argument>
else
()
}
</application-desc>
</jnlp>