Skip to end of metadata
Go to start of metadata

WebEngine

WebEngine provides us a new way to build Web Applications based on JAX-RS.

JAX-RS is a specification which aims at making much easier building REST applications, via a sets of JAVA annotations.

You can find more informations more informations on REST at http://en.wikipedia.org/wiki/Representational_State_Transfer.

As REST service is based on using http, calling a REST service is as easy as making an http call on a particular url. Therefore , REST services can be accessed easily with any languages, or even with a navigator (for GET calls).

REST services usually involves several of the 8 http methods (GET,POST,HEAD,PUT,DELETE,TRACE,CONNECT,OPTIONS). see http://en.wikipedia.org/wiki/HTTP#Request_methods for more informations.

Nuxeo is packaged with WebEngine (Since 5.2m4), test it at http://localhost:8080/nuxeo/site/, which is fully rendered with WebEngine, with the use of REST services.

Purpose of this document

The purpose of this document is not to learn how to build REST services with WebEngine, but how you can already already use the existing one to create, update or delete documents in the repository.

Usage

Through WEBEngine, each document is represented by an url where you can see his content; composed as follow :

Managing documents with WebEngine simply involves to use these http methods :

  • GET : to consult a document
  • POST : to create
  • PUT : to update
  • DELETE : to delete

For the tutorial, i will use a workspace "accountancy" in the default-domain. You just have to create it or adapt the url in each example.

Create a document

Just POST to the url of a folder or workspace where you want to create a document with the following inputs :

  • name : Technical name of the document, will be use in the url.
  • doctype : Choose as you need.
  • dc:title (optionnal) : Title of the document
  • dc:description (optionnal) : Description of the document
  • Any others simples properties that you want to set.

For the example i will create a file document assetAccount2008 in the workspace accountancy.

Just do POST on http://localhost:8080/nuxeo/site/admin/repository/default-domain/workspaces/accountancy.

You can also use this page : http://localhost:8080/nuxeo/site/admin/repository/default-domain/workspaces/accountancy/@views/create.

Just check the result in http://localhost:8080/nuxeo/site/admin/repository/default-domain/workspaces/accountancy/.

update a document

update simple properties

To update a document, you have to send the new properties with a PUT to the document's url. You can also POST to this adress by adding @put in the end.
So in you example this will be :

A post to http://localhost:8080/nuxeo/site/admin/repository/default-domain/workspaces/accountancy/assetAccount2008/@put

Or a put to http://localhost:8080/nuxeo/site/admin/repository/default-domain/workspaces/accountancy/assetAccount2008/

update content's document by uploading a file.

Just post to the document's url by adding @file. Your file input property need to named files:files.
You can use or customize this HTML forms to test it [WebEngineTutorial-UploadForms].

Search in the repository

Just add @search?fullText={Your query} after the url of the document from where you cant to do your search.

Example : http://localhost:8080/nuxeo/site/admin/repository/default-domain/workspaces/accountancy/@search?fullText=account

Delete a document

Simply send an http DELETE to a document's url.
Or add @delete at the end of the docuement's url.

example : http://localhost:8080/nuxeo/site/admin/repository/default-domain/workspaces/accountancy/assetAccount2008/@delete

TO DO

  • How to handle connection when you access REST services from outside a browser.
  • How to get a result search in XML or ATOM.
Labels:
None
Enter labels to add to this page:
Please wait 
Looking for a label? Just start typing.