dba/files  library module
R

Summary

Start job.
Tags

Author: Christian Grün, BaseX Team 2005-21, BSD License

__source : files/file-start.xqm

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
this
imports

Variables

3.1 $dba:CAT

Summary
Top category
Type
xs:string

Functions

4.1 dba:file-start

Arities: dba:file-start#1R

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

    PrefixUri
    configdba/config
    dbadba/files 2 3 4 5 6 7 8
    resthttp://exquery.org/ns/restxq

    6 RestXQ

    Paths defined 1.

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

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