Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

...

  1. 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
  2. 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
java
java
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)

  1. Use the SiteService to get the siteId based on the userId
    Code Block
    java
    java
    
    String siteId = siteService.getUserSiteId(userId);
    
  2. Use the SiteService to get the Site based on the siteId
    Code Block
    java
    java
    
    Site workspaceSite = siteService.getSite(siteId);