dba/files  library module
R

Summary

Start job.
Authors
  • Christian Grün, BaseX Team 2005-23, BSD License
Related documents
ViewDescriptionFormat
xqdocxqDoc xml file from the source modulexml
xqparsexqparse xml file from the source modulexml

Imports

This module is imported by 0 modules. It imports 1 modules.

(None)
imports
dba/files
imports

Variables

3.1 $dba:CAT

Summary
Top category
Type
Source ( 1 lines)
variable $dba:CAT := 'files'

Functions

4.1 dba:file-start

Arities: #1R

Summary
Starts a job.
Signatures
dba:file-start ( $file as xs:string ) as element(rest:response)
Parameters
  • file as xs:string file name
Return
  • 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:

    PrefixUri
    configdba/config
    dbadba/files 2 3 4 5 6 7 8
    errhttp://www.w3.org/2005/xqt-errors
    profhttp://basex.org/modules/prof
    resthttp://exquery.org/ns/restxq
    webhttp://basex.org/modules/web
    xshttp://www.w3.org/2001/XMLSchema

    6 RestXQ

    Paths defined 1.

    PathMethodFunction
    /dba/file-startGETdba:file-start#1

    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)
    };