EXPath

File Transfer Client Module 1.0

EXPath Candidate Module 28 September 2011

This version:
http://expath.org/spec/ft-client/20110928
Latest version:
http://expath.org/spec/ft-client
Editor:
Claudius Teodorescu, XML Consultant

This document is also available in these non-normative formats: XML.


Abstract

This proposal provides a File Transfer Client interface for XPath 3.0. It defines functions covering the operations needed to manage (remote) resources (files and directories). It has been designed to be compatible with XQuery 3.0 and XSLT 3.0, as well as any other standard based on XPath 3.0.

Table of Contents

1 Introduction
1.1 Namespace conventions
1.2 Error management
2 The ft-client:connect function
3 The ft-client:list-resources function
3.1 The ft-client:resource-list element
3.2 The ft-client:resource element
4 The ft-client:store-resource function
5 The ft-client:retrieve-resource function
6 The ft-client:rename-resource function
7 The ft-client:copy-resource function
8 The ft-client:move-resource function
9 The ft-client:delete-resource function
10 The ft-client:get-resource-metadata function
11 The ft-client:set-resource-metadata function
12 The ft-client:disconnect function

Appendices

A References
B Summary of Error Conditions


1 Introduction

This File Transfer Client interface allows using of various file transfer protocols, including well-known ones, such as FTP, SFTP (SSH File Transfer Protocol), FTPS (FTP over implicit SSL/TLS), FTPES (FTP over explicit SSL/TLS), WebDAV (Web-based Distributed Authoring and Versioning), and WebDAVS (WebDAV encrypted via SSL), as well as custom defined protocols.

The specification was made so that to cover the operations involved as to managing (remote) resources (files and directories).

A custom protocol can make use of any number of the operations over files described below, in this manner assuring a very elastic approach of the (remote) resources (files and directories) management.

The convention for the directory paths is that they have to end with '/'.

1.1 Namespace conventions

The module defined by this document defines functions and elements in the namespace http://expath.org/ns/ft-client. In this document, the ft-client prefix, when used, is bound to this namespace URI.

Error codes are defined in the namespace http://expath.org/ns/error. In this document, the err prefix, when used, is bound to this namespace URI.

1.2 Error management

Error conditions are identified by a code (a QName). When such an error condition is reached during the execution of the function, a dynamic error is thrown, with the corresponding error code (as if the standard XPath function error had been called).

2 The ft-client:connect function

This function is used to open a connection. It returns an xs:long representing the connection handle.

All data connections should originate from an authorized party (host and port). In case when a data connection originated from an unauthorized party, this is an error [err:FTC001].

In case when a server closes a connection, an error [err:FTC002] will be raised.

In case when credentials used (username, password, or private key) are wrong, an error [err:FTC005] will be raised.

In case when the protocol used is not supported, an error [err:FTC006] will be raised.

ft-client:connect($remote-host-uri as xs:anyURI) as xs:long
            
ft-client:connect($remote-host-uri as xs:anyURI,
		$options as xs:anyAtomicType) as xs:long
            

3 The ft-client:list-resources function

This function gets the list of resources (files and directories) inside the directory indicated by $remote-directory-path.

ft-client:list-resources($connection-handle as xs:long,
	$remote-directory-path as xs:string) as element(ft-client:resources-list)
            

3.1 The ft-client:resource-list element

The ft-client:resource-list element represents the data sent back by the host as response to the command of listing a directory:

<ft-client:resource-list>
	(ft-client:resource*)
</ft-client:resource-list>

3.2 The ft-client:resource element

The ft-client:resource element contains details about each resource (directory, file, link) one can find within the directory.

The content of the resource is returned as the content of this element.

<ft-client:resource
    name = xs:string
    type = "directory" | "file" | "link"
    last-modified = xs:dateTime
    size = xs:integer
    human-readable-size = xs:string
    user = xs:string
    user-group = xs:string
    permissions = xs:string
    link-to = xs:string?>
    xs:string?
</ft-client:resource>
  • name is the name of the resource.

  • type is the type of the resource.

  • last-modified is the date and time of the last modification of the resource.

  • size is the size of the resource, expressed in bytes.

  • human-readable-size is the size of the resource, expressed in a human readable format.

  • user is the name of the resource's owner.

  • user-group is the name of the group of the resource's owner.

  • permissions is the resource's permissions.

  • link-to is the resource the current resource points to.

4 The ft-client:store-resource function

This function stores a resource (directory, file). It returns true if successfully completed, false if not.

This function is designated to accomplish the following tasks:

  1. store a directory on the host, when $remote-resource-path ends with '/'; if the directory already exists, it will be overwritten;

  2. store a file on the host, when $remote-resource-path does not end with '/'; if the file already exists, it is overwritten; the file's contents is passed through the $resource-contents parameter; in case when this parameter is empty or missing, the file will be empty;

ft-client:store-resource($connection-handle as xs:long,
	$remote-resource-path as xs:string,
	$resource-contents as xs:anyAtomicType?) as xs:boolean
		

5 The ft-client:retrieve-resource function

This function retrieves a resource from the host. It returns the resource retrieved, as content of the ft-client:resource element.

ft-client:retrieve-resource($connection-handle as xs:long,
	$remote-resource-path as xs:string) as element(ft-client:resource)
            

6 The ft-client:rename-resource function

This function renames a resource (directory, file, or link). It returns true if successfully completed, false if not.

ft-client:rename-resource($connection-handle as xs:long,
  $remote-resource-path as xs:string,
  $new-name as xs:string) as xs:boolean
            

7 The ft-client:copy-resource function

This function renames a resource (directory, file, or link). It returns true if successfully completed, false if not.

ft-client:copy-resource($connection-handle as xs:long,
  $remote-resource-path as xs:string,
  $new-name as xs:string) as xs:boolean
		

8 The ft-client:move-resource function

This function renames a resource (directory, file, or link). It returns true if successfully completed, false if not.

ft-client:move-resource($connection-handle as xs:long,
  $remote-resource-path as xs:string,
  $new-name as xs:string) as xs:boolean
		

9 The ft-client:delete-resource function

This function deletes a resource (directory (if empty), file, or link). It returns true if successfully completed, false if not.

ft-client:delete-resource($connection-handle as xs:long,
  $remote-resource-path as xs:string) as xs:boolean
            

10 The ft-client:get-resource-metadata function

This function is used for getting the metadata of a resource (directory, file, or link). It returns the resource metadata as attributes of the ft-client:resource element.

ft-client:get-resource-metadata($connection-handle as xs:long,
	$remote-resource-path as xs:string) as element(ft-client:resource)
		

11 The ft-client:set-resource-metadata function

This function is used for setting the metadata of a resource (directory, file, or link). It returns true if successfully completed, false if not.

ft-client:set-resource-metadata($connection-handle as xs:long,
	$remote-resource-path as xs:string,
	$new-resource-metadata as element(ft-client:resource)) as xs:boolean
		

12 The ft-client:disconnect function

This function closes an opened connection. Returns true or false indicating the success of closing the connection.

ft-client:disconnect($connection-handle as xs:long) as xs:boolean
		

A References

XPath 3.0
XML Path Language (XPath) 3.0. Jonathan Robie, Don Chamberlin, Michael Dyck, John Snelson, editors. W3C Working Draft, 13 December 2011.
XSLT 3.0
XSL Transformations (XSLT) Version 3.0. Michael Kay, editor. W3C Working Draft, 10 July 2012.
XQuery 3.0
XQuery 3.0: An XML Query Language. Jonathan Robie, Don Chamberlin, Michael Dyck, John Snelson, editors. W3C Working Draft, 13 December 2011.
XPath and XQuery Functions and Operators 3.0
XPath and XQuery Functions and Operators 3.0. Michael Kay, editor. W3C Working Draft, 13 December 2011.
XQuery and XPath Data Model 3.0
XQuery and XPath Data Model 3.0. Norman Walsh, Anders Berglund, John Snelson, editors. W3C Working Draft, 13 December 2011.
RFC 959
RFC 959: FILE TRANSFER PROTOCOL (FTP). J. Postel, J. Reynolds editors. Network Working Group. October 1985.
RFC 2577
RFC 2577: FTP Security Considerations. M. Allman, S. Ostermann editors. Network Working Group. May 1999.
draft-yevstifeyev-ftp-uri-scheme-08
The 'ftp' URI Scheme. M. Yevstifeyev editor. Internet Engineering Task Force. September 25, 20114.
RFC 3986
Uniform Resource Identifiers (URI): Generic Syntax. T. Berners-Lee, R. Fielding, L. Masinter, editors. Network Working Group. January 2005.
RFC 4918
HTTP Extensions for Web Distributed Authoring and Versioning (WebDAV). L. Dusseault, editors. Network Working Group. June 2007.

B Summary of Error Conditions

err:FTC001
An unauthorized party initiated a data connection. The current session will be halted.
err:FTC002
The connection was closed by server.
err:FTC003
The remote resource does not exist.
err:FTC004
The user has no rights to access the remote resource.
err:FTC005
Authentication failed. The username, password, or private key is wrong.
err:FTC006
The protocol is not supported.
err:FTC007
The current operation failed.
err:FTC008
The directory path must end with '/'.