[Building Sakai] Resources Entity Broker
Adam Marshall
adam.marshall at it.ox.ac.uk
Mon Sep 10 05:33:26 PDT 2012
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