[Building Sakai] Bulk changes to content resources

Raad Al-Rawi Raad.Al-Rawi at admin.cam.ac.uk
Fri Feb 3 07:06:06 PST 2012


Hi Sam

Ah, JWS - cool!
I keep forgetting it's there, thanks for reminding me.

I'll test your code for you ;-)

Cheers

Raad

From: Sam Ottenhoff [mailto:ottenhoff at longsight.com]
Sent: 03 February 2012 15:01
To: Raad Al-Rawi
Cc: Sakai-Dev
Subject: Re: [Building Sakai] Bulk changes to content resources

Hi Raad,

I find web services the easiest way to accomplish tasks like this.  Here is some untested code you can add to Axis SakaiScript.jws:


public String setContentResourceType (String sessionid, String resourceid, String resourcetype) throws AxisFault

{

    Session session = establishSession(sessionid);



    try {

        System.out.println("editing resource: " + resourceid);

        ContentResourceEdit cre = contentHostingService.editResource(resourceid);

        cre.setContentType(resourcetype);

        contentHostingService.commitResource(cre);

    }

    catch (Exception e) {

        LOG.error("WS setContentResourceType(): " + e.getClass().getName() + " : " + e.getMessage());

        return e.getClass().getName() + " : " + e.getMessage();

    }

    return "success";

}

On Fri, Feb 3, 2012 at 9:31 AM, Raad Al-Rawi <Raad.Al-Rawi at admin.cam.ac.uk<mailto:Raad.Al-Rawi at admin.cam.ac.uk>> wrote:
Hello All

My understanding of content hosting on Sakai 2.7 is that metadata for content is serialised in the BINARY_ENTITY field in CONTENT_RESOURCE
I would like to make a bulk change to a given attribute (mime type), but of course this is not possible with a straight text replace operation at the db level (unless the change happens to perfectly preserve the block affected, which mine doesn't).

So, I'm guessing it's a case of writing some java code.
Has anyone done this sort of operation, and if so, is there some code that I could reuse?

Cheers

Raad

(incidentally, this has been brought about by a change in Google Chrome, which no longer supports the "x-pdf" mime type, displaying a blank page if one is clicked on in Resources. I have over 46,000 of these in our system, so I'd really like to fix them!)

~~
Raad Al-Rawi
CamTools Operations Analyst
University of Cambridge

Management Information Services Division
Greenwich House
Madingley Rise
Cambridge
CB3 0TX
UK

Tel: +44 (0)1223 760905

_______________________________________________
sakai-dev mailing list
sakai-dev at collab.sakaiproject.org<mailto:sakai-dev at collab.sakaiproject.org>
http://collab.sakaiproject.org/mailman/listinfo/sakai-dev

TO UNSUBSCRIBE: send email to sakai-dev-unsubscribe at collab.sakaiproject.org<mailto:sakai-dev-unsubscribe at collab.sakaiproject.org> with a subject of "unsubscribe"

-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://collab.sakaiproject.org/pipermail/sakai-dev/attachments/20120203/0cf991b2/attachment.html 


More information about the sakai-dev mailing list