view software/eXist/webapp/mpdl/doc/doc-operation-result.xql @ 15:e99964f390e4

diverse Fehlerbehebungen
author Josef Willenborg <jwillenborg@mpiwg-berlin.mpg.de>
date Mon, 29 Aug 2011 17:40:19 +0200
parents 5589d865af7a
children
line wrap: on
line source

xquery version "1.0";

import module namespace mpdl-time = "http://www.mpiwg-berlin.mpg.de/ns/mpdl/util/time" at "../util/time.xql";

declare namespace file = "http://exist-db.org/xquery/file";
declare namespace request="http://exist-db.org/xquery/request";
declare namespace session="http://exist-db.org/xquery/session";
declare namespace util = "http://exist-db.org/xquery/util";
declare namespace xmldb = "http://exist-db.org/xquery/xmldb";

let $login := xmldb:authenticate("xmldb:exist:///db", "admin", "")

let $operation := request:get-parameter("operation", "")
let $docBase := request:get-parameter("docBase", "")
let $language := request:get-parameter("language", "")
let $fileName := request:get-parameter("fileName", "")

let $eSciDocCookieId := session:get-attribute("eSciDocCookieId")

let $srcLocalFileName := request:get-uploaded-file-name("srcLocalFileName")
let $srcExistUploadFileJavaObject := request:get-uploaded-file("srcLocalFileName")
let $srcExistUploadFileName := string(<b>{$srcExistUploadFileJavaObject}</b>)
let $srcExistUploadFileUrl := concat("file://", $srcExistUploadFileName)

let $reqSrcUrl := request:get-parameter("srcUrl", "")
let $srcUrl :=
  if ($reqSrcUrl = '')
  then $srcExistUploadFileUrl
  else $reqSrcUrl

let $error :=
  if ($eSciDocCookieId = '' or empty($eSciDocCookieId))
  then <bla>No login context available. Please <a href="login.xql">login</a> before you do an operation</bla>
  else if(($operation = 'create' or $operation = 'update') and ($srcUrl = ''))
  then "please specify your source"
  else if(($operation = 'create' or $operation = 'update' or $operation = 'delete') and ($fileName = ''))
  then "please specify your destination document name"
  else "no"

let $jobId := 
  if($error = 'no' and ($operation = 'create' or $operation = 'update'))
  then mpdldoc:do($operation, $srcUrl, $srcLocalFileName, $docBase, $language, $fileName, $eSciDocCookieId)
  else if($error = 'no' and ($operation = 'delete'))
  then mpdldoc:do($operation, 'empty', 'empty', $docBase, $language, $fileName, $eSciDocCookieId)
  else ()
let $redirectUrl := <a href="../scheduler/get-jobs.xql?id={$jobId}">here</a>
let $resultHtml := 
  if ($error = 'no')
  then <div>See the status of your document operation {$redirectUrl}</div>
  else <div><b>Error in your document operation:</b> {$error}</div> 

let $title := "MPDL: eXist/eSciDoc document management"
return
<html>
<head>
<title>{$title}</title>
</head>
<body>
  <h1>{$title}</h1>
  {$resultHtml} 
  <br/>
  <br/>
  <br/>
  <hr/>
  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>
</body>
</html>