[Building Sakai] Updating a Resource through Tool

Steve Swinsburg steve.swinsburg at gmail.com
Wed Aug 3 17:34:26 PDT 2011


Hi,

Sounds like some locks are being cleared.

Just before your CHS.commit() try adding add:

resource.getPropertiesEdit().set(properties);

That is from some code I use to create resources and it is the only thing different to yours.

cheers,
Steve


On 04/08/2011, at 5:52 AM, Stuart Childs 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/20110804/5727d082/attachment.html 


More information about the sakai-dev mailing list