comparison software/eXist/webapp/mpdl/doc/doc-operation-result.xql @ 7:5589d865af7a

Erstellung XQL/XSL Applikation
author Josef Willenborg <jwillenborg@mpiwg-berlin.mpg.de>
date Tue, 08 Feb 2011 15:16:46 +0100
parents
children
comparison
equal deleted inserted replaced
6:2396a569e446 7:5589d865af7a
1 xquery version "1.0";
2
3 import module namespace mpdl-time = "http://www.mpiwg-berlin.mpg.de/ns/mpdl/util/time" at "../util/time.xql";
4
5 declare namespace file = "http://exist-db.org/xquery/file";
6 declare namespace request="http://exist-db.org/xquery/request";
7 declare namespace session="http://exist-db.org/xquery/session";
8 declare namespace util = "http://exist-db.org/xquery/util";
9 declare namespace xmldb = "http://exist-db.org/xquery/xmldb";
10
11 let $login := xmldb:authenticate("xmldb:exist:///db", "admin", "")
12
13 let $operation := request:get-parameter("operation", "")
14 let $docBase := request:get-parameter("docBase", "")
15 let $language := request:get-parameter("language", "")
16 let $fileName := request:get-parameter("fileName", "")
17
18 let $eSciDocCookieId := session:get-attribute("eSciDocCookieId")
19
20 let $srcLocalFileName := request:get-uploaded-file-name("srcLocalFileName")
21 let $srcExistUploadFileJavaObject := request:get-uploaded-file("srcLocalFileName")
22 let $srcExistUploadFileName := string(<b>{$srcExistUploadFileJavaObject}</b>)
23 let $srcExistUploadFileUrl := concat("file://", $srcExistUploadFileName)
24
25 let $reqSrcUrl := request:get-parameter("srcUrl", "")
26 let $srcUrl :=
27 if ($reqSrcUrl = '')
28 then $srcExistUploadFileUrl
29 else $reqSrcUrl
30
31 let $error :=
32 if ($eSciDocCookieId = '' or empty($eSciDocCookieId))
33 then <bla>No login context available. Please <a href="login.xql">login</a> before you do an operation</bla>
34 else if(($operation = 'create' or $operation = 'update') and ($srcUrl = ''))
35 then "please specify your source"
36 else if(($operation = 'create' or $operation = 'update' or $operation = 'delete') and ($fileName = ''))
37 then "please specify your destination document name"
38 else "no"
39
40 let $jobId :=
41 if($error = 'no' and ($operation = 'create' or $operation = 'update'))
42 then mpdldoc:do($operation, $srcUrl, $srcLocalFileName, $docBase, $language, $fileName, $eSciDocCookieId)
43 else if($error = 'no' and ($operation = 'delete'))
44 then mpdldoc:do($operation, 'empty', 'empty', $docBase, $language, $fileName, $eSciDocCookieId)
45 else ()
46 let $redirectUrl := <a href="../scheduler/get-jobs.xql?id={$jobId}">here</a>
47 let $resultHtml :=
48 if ($error = 'no')
49 then <div>See the status of your document operation {$redirectUrl}</div>
50 else <div><b>Error in your document operation:</b> {$error}</div>
51
52 let $title := "MPDL: eXist/eSciDoc document management"
53 return
54 <html>
55 <head>
56 <title>{$title}</title>
57 </head>
58 <body>
59 <h1>{$title}</h1>
60 {$resultHtml}
61 <br/>
62 <br/>
63 <br/>
64 <hr/>
65 Back to <a href="doc-operation.xql">document operation page</a>, see the <a href="doc-operation-result.xql?_source=yes">XQuery source</a> of this page, if you find a bug <a href="https://itgroup.mpiwg-berlin.mpg.de:8080/tracs/mpdl-project-software/newticket">let us know</a>
66 </body>
67 </html>