[Building Sakai] EntityCustomAction problems
Stephen Marquard
stephen.marquard at uct.ac.za
Wed Jan 20 04:37:47 PST 2010
Here's an example of a VIEW_NEW custom action (calculate):
https://source.sakaiproject.org/contrib/sms/sms/trunk/impl/src/java/org/sakaiproject/sms/entity/SmsTaskEntityProviderImpl.java
For the case below, if you want to create a chat channel, you should rather use the standard REST semantics to create a new entity in the chat-channel provider, rather than a custom action.
Also when you are using EB, there is no tool placement, so this:
Placement placement = toolManager.getCurrentPlacement();
is not meaningful.
Regards
Stephen
>>> Adrian Fish <a.fish at lancaster.ac.uk> 2010/01/20 02:29 PM >>>
Does anybody have a working example of a VIEW_NEW EntityCustomAction
that accepts posted data? The code below throws a RuntimeException thus:
WARN Direct request failure: RuntimeException:Fatal error trying to
execute custom action method: create:new:create:Direct request failure:
RuntimeException:Fatal error trying to execute custom action method:
create:new:create:
@EntityCustomAction(action="create",viewKey=EntityView.VIEW_NEW)
public boolean create(EntityReference ref, Map<String, Object> params) {
try
{
String title = (String) params.get("title");
String description = (String) params.get("description");
LOG.debug("Title: " + title);
LOG.debug("Description: " + description);
Placement placement = toolManager.getCurrentPlacement();
String siteId = placement.getContext();
try {
chatManager.createNewChannel(siteId,title,false,true,placement.getId());
return true;
} catch(PermissionException pe) {
throw new SecurityException("You do not have permission to
create channels");
} catch(Exception e) {
LOG.error("Failed to create channel",e);
return false;
}
}
catch(Throwable t)
{
System.err.println("WHOOPS! ");
t.printStackTrace();
return false;
}
}
Cheers,
Adrian.
--
==================================
Adrian Fish
Software Engineer
Centre for e-Science
Bowland Tower South C Floor
Lancaster University
Lancaster
LA1 4YW
email: a.fish at lancaster.ac.uk
http://confluence.sakaiproject.org/display/YAFT/Yaft
http://confluence.sakaiproject.org/display/BLOG/Home
http://confluence.sakaiproject.org/display/AGORA/Home
More information about the sakai-dev
mailing list