...
- Trunk javadocs:
- Trunk source location: https://source.sakaiproject.org/svn/site/trunk/
Accessing the SiteService
- You can use Spring Framework to inject the service or use the cover
...
- Use the ToolManager service to get the current context
Code Block java java String currentContext = toolManager.getCurrentPlacement().getContext();
- Note: You could also retrieve the context in other ways, this is just the common one
- Use the SiteService to get the site reference from the context
Code Block java java String siteRef = siteService.siteReference(currentContext);
Getting the Site object for the site the current user is currently in
Use the ToolManager service to get the current context and then use the SiteService to get the Site
Code Block | ||||
---|---|---|---|---|
| ||||
Site site = null; try { site = siteService.getSite(toolManager.getCurrentPlacement().getContext()); } catch (Exception e) { // assume we are not in a site then and do something about it } |
Getting the membership for a Site
Use the SiteService to get the Site and then get the Members from the site
Code Block | ||||
---|---|---|---|---|
| ||||
Site site = null; try { site = siteService.getSite(toolManager.getCurrentPlacement().getContext()); } catch (Exception e) { // assume we are not in a site then and do something about it } |
Getting the workspace Site for a user (using the userId)
- Use the SiteService to get the siteId based on the userId
Code Block java java String siteId = siteService.getUserSiteId(userId);
- Use the SiteService to get the Site based on the siteId
Code Block java java Site workspaceSite = siteService.getSite(siteId);