[Building Sakai] Resources Entity Broker

Adam Marshall adam.marshall at it.ox.ac.uk
Fri Sep 14 04:54:59 PDT 2012


We are able to call the API using CURL but get a 404 (or was it 401) error when posting a form. Sound familiar?

adam

-----Original Message-----
From: Jim Eng [mailto:jimeng at umich.edu] 
Sent: 10 September 2012 14:48
To: Adam Marshall
Cc: sakai-dev
Subject: Re: Resources Entity Broker

Hi Adam, 

We'll be looking at the docs project later this week and we'll try to provide additional information as we do that. 

The docs project focused first on trying to reimplement the existing resources tool UI with REST-like requests as much as possible and reducing or (if possible) eliminating reliance on server-side state.  As I recall, it was hard to do resources as pure CRUD because different kinds of resources and resource-collections have different kinds of actions associated with them, which needed to be reflected in the UI.  At some point, the demands of the tool layer required a lot of non-CRUD requests. We ended up with a hack -- defining user actions with respect to resources as entities (with their own EntityBroker implementation).  That allowed us to use REST-like requests to get information about actions available to a particular user w.r.t. a particular resource or resource-collection.  

I say "REST-like" here because it's been quite a while since I looked at that code and I'm not sure I can say they are actually RESTful.

Again, we'll try to get more info to you soon, but it may be a few days.

Jim



On Sep 10, 2012, at 8:33 AM, Adam Marshall wrote:

> We've done a bit of work on Resources EB. I have drafted this blog post but we don't really know what the difference is between modes and action IDs and we don't know how you know which to use. We used the code found at:
> 
> 	https://source.sakaiproject.org/contrib/resources/rsf/trunk/
> 
> and entity provider impl's:
> 
> 	https://source.sakaiproject.org/contrib/resources/rsf/trunk/impl/src/java/org/sakaiproject/resources/logic/entity/
> 
> Could any point me to other documentation or correct / edit my proposed post? I haven't been able to find much to crib from.
> 
> It would also be useful to know if any actions / modes are unimplemented.
> 
> Adam
> 
> ++++++++++++++++++++++++++++++
> 
> How to use Entity Broker API to Resources
> 	
> 
> Over the summer we added an Entity Broker API to the Resources (content hosting) tool. In short, this means one can use custom JavaScript to interact with the Resources tool.
> 
> If you continue reading you will notice very quickly that this is a very technical blog post!
> 
> Documentation
> 
> As with all Entity Broker APIs, documentation can be found via the '/describe' URL: https://weblearn.ox.ac.uk/direct/content/describe
> Create a resource
> 
> Example 1:
> 
>  curl -u "username:password" \
>       -F "mode=create" \
>       -F "actionId=" \
>       -F "type=org.sakaiproject.content.types.TextDocumentType" \
>       -F "containingCollectionId=/group/9c57..../myFolder/" \
>       -F "Filedata=@myLocalFolder/myFile.json" \
> 
> https://weblearn.ox.ac.uk/direct/contentActions?__auth=basic
> 
> NB The URL is obviously part of the curl command but for some reason Word Press inserts a blanks line
> 
> Example 2:
> 
>  curl -u "username:password" \
>       -F "mode=create" \
>       -F "actionId=" \
>       -F "type=org.sakaiproject.content.types.folder" \
>       -F "entity.name=myNewFolder" \
>       -F "containingCollectionId=/group/9c57..../myFolder/" \
> 
> https://weblearn.ox.ac.uk/direct/contentActions?__auth=basic
> 
> Delete a resource
> 
> Example 3
> 
>  curl -u "username:password" \
>       -X DELETE \
> 
> https://weblearn.ox.ac.uk/direct/contentActions/group/9c57..../myFolder/myFile.xml?__auth=basic
> 
> Example 4
> 
>  curl -u "username:password" \
>       -X DELETE \
> 
> https://weblearn.ox.ac.uk/direct/contentActions/group/9c57..../myFolder/?__auth=basic
> 
> Rename a resource
> 
> Example 5:
> 
>  curl -u "username:password" \
>       -F "actionId=properties" \
>       -F "entity.name=myTest.txt" \
> 
> https://weblearn.ox.ac.uk/direct/contentActions/group/9c57..../myFolder/departments.json?__auth=basic
> 
> Replace the contents of a resource
> 
> Example 6:
> 
>  curl -u "username:password" \
>       -F "actionId=replace" \
>       -F "Filedata=@Downloads/myNewFile.json" \
> 
> https://weblearn.ox.ac.uk/direct/contentActions/group/9c57..../myFolder/MyFile.txt?__auth=basic
> 
> Available types
> 
>    org.sakaiproject.content.types.HtmlDocmentType - an HTML file
>    org.sakaiproject.content.types.UrlResourceType - a web link
>    org.sakaiproject.content.types.TextDocumentType - a plain text file
>    org.sakaiproject.content.types.folder - a folder
>    org.sakaiproject.content.types.fileUpload - browse for file
> 
> Available Modes / ActionIDs
> 
> Warning: this is a little unclear and we need some experience before we can be confident that this section is correct.
> 
> We think there are a set of modes that relate (more or less) to classic CRUD operations
> 
>    create
>    copy
>    replace
>    revise (update)
>    delete
> 
> There are also a set of actions which operate upon the properties of a Resource
> 
>    properties
>    replace
>    access
>    info
>    duplicate
>    move
>    paste_moved
>    paste_copied
>    revise_permissions
>    revise_order
>    restore
>    expand
>    collapse
>    compress_zip_folder
>    expand_zip_archive
>    make_site_page
> 
> Further Work
> 
> A browser isn't currently able to make a DELETE request, we need to provide a workaround for browsers when making XmlHttpRequests so one can fake DELETE and PUT requests. This needs investigating.
> 
> 
> --
> Dr A C Marshall, WebLearn Service Manager, IT Services, University of Oxford.
> 
> 
> 



More information about the sakai-dev mailing list