dba/files
library moduleR
Summary
Start job.
- Tags
Author: Christian Grün, BaseX Team 2005-21, BSD License
__source : files/file-start.xqm
Imports
This module is imported by 0 modules. It imports 1 modules.
Variables
Functions
4.1 dba:file-start
Arities: dba:file-start#1R
dba:file-start
(
$file
as
xs:string
)
as
element(rest:response)
- file
as
xs:string
file name
element(rest:response)
redirection
Invokes 6 functions from 5 modules
- config:directory#0
- {http://basex.org/modules/jobs}invoke#3
- {http://basex.org/modules/jobs}stop#1
- {http://basex.org/modules/prof}void#1
- {http://basex.org/modules/web}redirect#2
- {http://www.w3.org/2005/xpath-functions}replace#3
Invoked by 0 functions from 0 modules
Annotations
%rest:GET | () |
%rest:path | ('/dba/file-start') |
%rest:query-param | ('file','{$file}','') |
Source ( 14 lines)
function dba:file-start(
$file as xs:string
) as element(rest:response) {
let $id := replace($file, '\.\.+|/|\\', '')
let $params := try {
(: stop running job before starting new job :)
jobs:stop($id),
prof:void(jobs:invoke(config:directory() || $id, (), map { 'cache': 'true', 'id': $file })),
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 |
rest | http://exquery.org/ns/restxq |
Source Code
(:~
: Start job.
:
: @author Christian Grün, BaseX Team 2005-21, 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 $params := try {
(: stop running job before starting new job :)
jobs:stop($id),
prof:void(jobs:invoke(config:directory() || $id, (), map { 'cache': 'true', 'id': $file })),
map { 'info': 'Job was started.', 'job': $id }
} catch * {
map { 'error': $err:description }
}
return web:redirect($dba:CAT, $params)
};