Friday, November 7, 2008

Uploading to Sakai 2.4 foo

reverse engineering Sakai's Resource tool uploading. I'll be doing this from outside Sakai so I want to see what the URLs are like.

first it looks like there is a POST to set the folder / location

POST /portal/tool/0ed2a194-16d0-425f-8022-1250ca000fe1?panel=Main HTTP/1.1

Host: localhost:9595

User-Agent: Mozilla/5.0 (Macintosh; U; PPC Mac OS X 10.4; en-US; rv:1.9.0.3) Gecko/2008092414 Firefox/3.0.3

Accept: text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8

Accept-Language: en-us,en;q=0.5

Accept-Encoding: gzip,deflate

Accept-Charset: ISO-8859-1,utf-8;q=0.7,*;q=0.7

Keep-Alive: 300

Connection: keep-alive

Referer: http://localhost:9595/portal/tool/0ed2a194-16d0-425f-8022-1250ca000fe1?panel=Main

Cookie: JSESSIONID=388ce121-9b5d-4bbe-8098-e904e98e0477.santoku

Content-Type: application/x-www-form-urlencoded

Content-Length: 217

source=0&collectionId=%2Fgroup%2FF08-SOPI-101%2F&navRoot=&criteria=title&sakai_action=doDispatchAction&rt_action=org.sakaiproject.content.types.fileUpload%3Acreate&selectedItemId=%2Fgroup%2FF08-SOPI-101%2FResponses%2F

then a POST multipart to get the stuff up:

http://localhost:9595/portal/tool/0ed2a194-16d0-425f-8022-1250ca000fe1/sakai.resource.type.helper.helper?sakai_action=doUpload&flow=save



POST /portal/tool/0ed2a194-16d0-425f-8022-1250ca000fe1/sakai.resource.type.helper.helper?sakai_action=doUpload&flow=save HTTP/1.1

Host: localhost:9595

User-Agent: Mozilla/5.0 (Macintosh; U; PPC Mac OS X 10.4; en-US; rv:1.9.0.3) Gecko/2008092414 Firefox/3.0.3

Accept: text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8

Accept-Language: en-us,en;q=0.5

Accept-Encoding: gzip,deflate

Accept-Charset: ISO-8859-1,utf-8;q=0.7,*;q=0.7

Keep-Alive: 300

Connection: keep-alive

Referer: http://localhost:9595/portal/tool/0ed2a194-16d0-425f-8022-1250ca000fe1/sakai.resource.type.helper.helper

Cookie: JSESSIONID=388ce121-9b5d-4bbe-8098-e904e98e0477.santoku

Content-Type: multipart/form-data; boundary=---------------------------126032761616950317512028061602

Content-Length: 3839

-----------------------------126032761616950317512028061602

Content-Disposition: form-data; name="fileCount"



1

-----------------------------126032761616950317512028061602

Content-Disposition: form-data; name="lastIndex"



0

-----------------------------126032761616950317512028061602

Content-Disposition: form-data; name="exists_0"

( I cut off the rest of this... )

3 comments:

Steve Swinsburg said...

Hey Casey, how come the reverse engineering of the ContentHostingService? Need an integration? I can point you to a good set of webservices for this if you're interested.

cheers.

Charles Severance said...

Casey - Before you get too far - take a look at support in AccesServlet for uploading. I seem to remember Chuck Hedrick adding it somewhere.

caseyd said...

hey guys;

I'm working in 2.4.foo, a hairy Stanford branch. I assumed that there isn't much modern Sakai goodness in this version.

I'm happily using the AccessServlet from my java Swing (SAF actually ) application - I use WS to login, to find some Sites with a custom property and yank out content.

Very handy, and Chuck your blog helped out with the session bits. love it.

For uploading files I though I would just take a look at what the Resources tool did. I've done plenty of screen scraping in the day so I thought "what the heck." After doing all the dorky multipart Http stuff of course I find that the Resource tool wants a session ID for the context in the Site. Since my application only has a session id from WS it blows out of the water with a NPE when it tries to gather some magic pipes.

The 2.4 Access Servlet doesn't seem, in the half hour I spent today, to have a Put method that does much more than reroute through login.

( the access servlet would be great, since I'm already using it for pulling the content. I may hack up the put to accept my uploaded files but would rather go with what I can find in this build. )

Stephen, the ContentHosting.jws looks like it may be where I go next. Would the 2.4 version be what you were thinking of? I can see that you contributed some code? to Nortons work. For some reason I am feeling leery of turning Quicktime movies to long gigantic strings.

But if you can throw me a line of research that would be great.

My last planned resort is to look at the various OS WebDAV clients.

The Business logic of this project is hairy. The Instructors are prohibited from seeing Assessment materials. However they can review the results. Unless the Instructor works for a Language Co-ordinator who preempts their reviewing of the results. But the Coordinator is prohibited from seeing the Instructors materials... and there's more gah.