[Building Sakai] Updating a Resource through Tool
Paul Dagnall
dagnalpb at notes.udayton.edu
Wed Aug 3 13:08:52 PDT 2011
Hi Stuart
If it works the first time but not the second something may not being
cleaned up. I agree that the commit should prevent this but sometimes things
don't cooperate. Try adding the below line to a couple spots just to see
what it does. Try it after you instantiate resource and/or after commit,
just to see if the behavior changes.
getContentHostingService().cancelResource(resource);
Give it a try and let me know what you get.
Good luck!
Paul Dagnall
Web Developer
University of Dayton
On Wed, Aug 3, 2011 at 3:52 PM, Stuart Childs <stuart.childs at scorm.com>wrote:
> Hello,
>
> I'm working on a Sakai Tool that allows users to create resources in their
> Sakai instance that link to external content through our service. I'm trying
> to add a feature to allow the user to update the reference to that external
> content through the resource manager tool. It's "working" but I've run into
> a locking issue that I can't seem to figure out.
>
> The relevant section of code (for reference, the full source for the tool
> is available on GitHub, package-update branch at
> https://github.com/RusticiSoftware/SCORMCloud_SakaiPlugin/tree/package-update
> ):
>
> private void updateResourceForScormCloudEntity(String
> contentEntityId, ScormCloudPackage pkg) throws Exception {
> log.debug("updateResource contentEntityId = " +
> contentEntityId);
> getContentHostingService().removeAllLocks(contentEntityId);
> ContentResourceEdit resource =
> getContentHostingService().editResource(contentEntityId);
>
> ResourcePropertiesEdit properties =
> resource.getPropertiesEdit();
>
> properties.removeProperty(ResourceProperties.PROP_DISPLAY_NAME);
> properties.addProperty(ResourceProperties.PROP_DISPLAY_NAME,
> pkg.getTitle());
> getContentHostingService().commitResource(resource);
> }
>
> The update process works without apparent error the first time it is run
> (either for a resource, or after restarting Tomcat) but if it is run again,
> an InUseException is thrown by ContentHostingService.editResource. An
> example exception with stack trace:
>
> org.sakaiproject.exception.InUseException
> id=/group/a156b4f3-79d0-40fc-af4b-96430a67d8cd/sakai-61a2d4d7-9942-4ec9-a7e2-06f533837eaa.scormcloud
>
> org.sakaiproject.content.impl.BaseContentService.editResource(BaseContentService.java:4082)
>
> com.rusticisoftware.scormcloud.tool.RequestController.updateResourceForScormCloudEntity(RequestController.java:951)
>
> com.rusticisoftware.scormcloud.tool.RequestController.processUpdatePackageRequest(RequestController.java:926)
>
> com.rusticisoftware.scormcloud.tool.RequestController.doGet(RequestController.java:179)
>
> com.rusticisoftware.scormcloud.tool.RequestController.doPost(RequestController.java:820)
> javax.servlet.http.HttpServlet.service(HttpServlet.java:647)
> javax.servlet.http.HttpServlet.service(HttpServlet.java:729)
> org.sakaiproject.util.RequestFilter.doFilter(RequestFilter.java:646)
>
> >From what I've been able to determine, this is caused by a lock on that
> entity. However, the problem still arises even after I added the silly
> removeAllLocks line above. Digging a bit into the Sakai source, it seems
> that commitResource should be enough to free that lock but obviously I must
> be doing something wrong. If it makes a difference, the Sakai instance this
> is running on was compiled from 2.7.0 sources with the 1.1.8 kernel.
>
> I'd really appreciate any comments or suggestions you might have about
> this.
>
> Thanks,
> Stuart Childs
> _______________________________________________
> sakai-dev mailing list
> 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 with a subject of
> "unsubscribe"
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://collab.sakaiproject.org/pipermail/sakai-dev/attachments/20110803/4d6417bf/attachment.html
More information about the sakai-dev
mailing list