dba/files 
                    library moduleR
Summary
Start job.
- Authors
 - Christian Grün, BaseX Team 2005-23, BSD License
 
Imports
This module is imported by 0 modules. It imports 1 modules.
Variables
Functions
4.1 dba:file-start
Arities: #1R
dba:file-start
		  ( 
			$file as xs:string ) as element(rest:response)- file
asxs:stringfile name 
element(rest:response)redirection
Invoked by 0 functions from 0 modules
Annotations (3)
%rest:GET | () | 
%rest:path | ('/dba/file-start') | 
%rest:query-param | ('file','{$file}','') | 
Source ( 16 lines)
function dba:file-start(
  $file  as xs:string
) as element(rest:response) {
  let $id := replace($file, '\.\.+|/|\\', '')
  let $uri := xs:anyURI(config:directory() || $id)
  let $params := try {
    (: stop running job before starting new job :)
    job:remove($id),
    job:wait($id),
    prof:void(job:eval($uri, (), map { 'cache': 'true', 'id': $id, 'log': 'DBA job' })),
    map { 'info': 'Job was started.', 'job': $id }
  } catch * {
    map { 'error': $err:description }
  }
  return web:redirect($dba:CAT, $params)
}Namespaces
The following namespaces are defined:
| Prefix | Uri | 
|---|---|
| config | dba/config | 
| dba | dba/files 2 3 4 5 6 7 8 | 
| err | http://www.w3.org/2005/xqt-errors | 
| prof | http://basex.org/modules/prof | 
| rest | http://exquery.org/ns/restxq | 
| web | http://basex.org/modules/web | 
| xs | http://www.w3.org/2001/XMLSchema | 
Source Code
(:~
 : Start job.
 :
 : @author Christian Grün, BaseX Team 2005-23, BSD License
 :)
module namespace dba = 'dba/files';
import module namespace config = 'dba/config' at '../lib/config.xqm';
(:~ Top category :)
declare variable $dba:CAT := 'files';
(:~
 : Starts a job.
 : @param  $file  file name
 : @return redirection
 :)
declare
  %rest:GET
  %rest:path('/dba/file-start')
  %rest:query-param('file', '{$file}', '')
function dba:file-start(
  $file  as xs:string
) as element(rest:response) {
  let $id := replace($file, '\.\.+|/|\\', '')
  let $uri := xs:anyURI(config:directory() || $id)
  let $params := try {
    (: stop running job before starting new job :)
    job:remove($id),
    job:wait($id),
    prof:void(job:eval($uri, (), map { 'cache': 'true', 'id': $id, 'log': 'DBA job' })),
    map { 'info': 'Job was started.', 'job': $id }
  } catch * {
    map { 'error': $err:description }
  }
  return web:redirect($dba:CAT, $params)
};