Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP

Fetching latest commit…

Octocat-spinner-32-eaf2f5

Cannot retrieve the latest commit at this time

..
Octocat-spinner-32 dropbox
Octocat-spinner-32 filesystem
Octocat-spinner-32 lib
Octocat-spinner-32 node_modules
Octocat-spinner-32 php_localFiles
Octocat-spinner-32 README.md
Octocat-spinner-32 dropbox.bat
Octocat-spinner-32 fsLocal.js
Octocat-spinner-32 fsLocal.spec.js
README.md

Hermes

Hermes is the file storage component of the Ares IDE. It provides a consistent file-system abstraction API, whatever backend storage system is in use.

Hermes Protocol

Verbs

Hermes file-system providers use verbs that closely mimic the semantics defined by WebDAV (RFC4918): although Hermes reuses the same HTTP verbs (GET, PUT, PROPFIND, MKCOL, DELETE ...), it differs in terms of carried data. Many (if not most) of the HTTP clients implement only the GET and POST HTTP verbs: Hermes uses the same HTTP Method Overrides as WebDAV usually do (tunnel every requests but GET into POST requests that include a special _method query parameter)

  • PROPFIND lists properties of a resource. It recurses into the collections according to the depth parameter, which may be 0, 1, … etc plus infinity. For example, the following directory structure:

    $ tree 1/
    1/
    ├── 0
    └── 1
    

… corresponds to the following JSON object returned by PROPFIND.

    $ curl "http://127.0.0.1:9009/id/%2F?_method=PROPFIND&depth=10"
    {
        "isDir": true, 
        "path": "/", 
        "name": "", 
        "contents": [
            {
                "isDir": false, 
                "path": "/0", 
                "name": "0", 
                "id": "%2F0"
            }, 
            {
                "isDir": false, 
                "path": "/1", 
                "name": "1", 
                "id": "%2F1"
            }
        ], 
        "id": "%2F"
    }
  • MKCOL create a collection (a folder) into the given collection, as name passed as a query parameter (and therefore URL-encoded):

    $ curl -d "" "http://127.0.0.1:9009/id/%2F?_method=MKCOL&name=tata"
    
  • PUT creates or overwrite a file resource.

  • DELETE delete a resource (a file), which might be a collection (a folder). Status codes:

  • COPY reccursively copies a resource as a new name or path provided in the query string (one of them is required). The optionnal query parameter overwrite defines whether the COPY should try to overwrite an existing resource or not. The method returns the new status (PROPFIND) of the target resource.

    • 201/Created success, a new resource is created
    • 200/Ok success, an existing resource was successfully overwritten (query parameter overwrite was set to true)
    • 412/Precondition-Failed failure, not allowed to copy onto an exising resource
  • MOVE has the exact same parameters and return codes as COPY

Parameters

Path parameters

    http://127.0.0.1:{port}/{urlPrefix}/id/{id}
  • port TCP port
  • urlPrefix server path
  • id resource IDs. Even when readable, those resources need to be handled as if they were opaque values.

Query parameters

  • name File or folder name, for creation methods (MKCOL, PUT, COPY, MOVE). This is required, as the resource id is not (yet) known.
  • folderId target folder id used by COPY and MOVE methods.
  • overwrite when set to true with the COPY, MOVE and PUT methods, causes the target resource to be overwritten (not merged) in case it already exists. When absent, overwrite defaults to false.
  • depth is only valid with the PROPFIND method. It defines the recursion level of the request in the folder tree. When omitted, it defaults to 1 (list immediate child resources of a folder). The special value infinity causes the methods to recurse to the deepest possible level in the folder tree.

Debug

It is possible to debug an Hermes services by commenting-out the command property of the service to be debugged & start it manually along with --debug or --debug-brk to later connect a node-inspector.

Start the file server:

$ node ares-project/hermes/filesystem/index.js 9010 hermes/filesystem/root

Debugging: The following sequence (to be run in separated terminals) opens the ARES local file server in debug-mode using node-inspector.

$ node --debug ares-project/hermes/filesystem/index.js 9010 hermes/filesystem/root

...then start node-inspector & the browser windows from a separated terminal:

$ open -a Chromium http://localhost:9010/ide/ares/index.html
$ node-inspector &
$ open -a Chromium http://localhost:8080/debug?port=5858

Run Test Suite

New the test suite does not cover the former verbs used by Hermes, and implemented into filesystem/index.js.

So far, only hermes local filesystem access comes with a (small) test suite, that relies on Mocha and Should.js. Run it using:

$ hermes/node_modules/mocha/bin/mocha hermes/fsLocal.spec.js

References

Something went wrong with that request. Please try again.