[Building Sakai] Permissions Exception user modifying 'myworkspace' programmatically
David Wafula
davidwaf at gmail.com
Mon Jul 25 06:59:01 PDT 2011
Hi all,
I am still working on extending My Workspace, but decided to create a new
thread with a new question. So i settled on the following use case:.
1. User logs in, validated against LDAP. If first-time login, the user is
programmatically created.
2. After adding the user, we get the workspace site of the user.
3. We set the page to edit mode, and we attempt to add a tool to "my
workspace".
Now, in step 3, i get:
org.sakaiproject.exception.PermissionException user=null lock=site.upd
resource=/site/~4fedf98c-501d-43c3-b62e-d52f4322a157
Am meant to understand a user has full rights to thier own workspace, no?
Below is the code am using ..help fix the permissions;
//first ...add user
userDirectoryService.addUser(null, staffNumber,
lDAPUser.getGivenname(), lDAPUser.getSurname(),
lDAPUser.getEmail(), null, type, null);
//then get userid
String userid =
userDirectoryService.getUserByEid(staffNumber).getId();
String myWorkspaceId = siteService.getUserSiteId(userid);
Site siteEdit = null;
SitePage sitePageEdit = null;
try {
siteEdit = siteService.getSite(myWorkspaceId);
} catch (IdUnusedException e) {
M_log.error("No workspace for user: " + myWorkspaceId + ",
skipping...");
return;
}
String toolTitle = "Course Creator";
sitePageEdit = siteEdit.addPage();
sitePageEdit.setTitle(toolTitle);
sitePageEdit.setLayout(0);
int position = 0;
int numPages = siteEdit.getPages().size();
if (position > numPages) {
position = numPages - 1;
}
sitePageEdit.setPosition(position);
sitePageEdit.setPopup(false);
ToolConfiguration tool = sitePageEdit.addTool();
Tool t = tool.getTool();
String toolId = "sakai.coursecreator";
tool.setTool(toolId, toolManager.getTool(toolId));
tool.setTitle(toolTitle);
siteService.save(siteEdit);
siteService.save() results in Perminssions Exception.
Regards,
--
David Wafula
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://collab.sakaiproject.org/pipermail/sakai-dev/attachments/20110725/31189c47/attachment.html
More information about the sakai-dev
mailing list