public Space getOrganizationSpace() {
   try {
     return getWorkspacesManager().getOrganizationSpace(context);
   } catch (SpaceManagerException e) {
     context.put("haserror", "1");
     context.put("lasterror", e.getMessage());
     return null;
   }
 }
 /**
  * @param spaceName the wiki name of the workspace to count the members of
  * @return the numbers of members of the given workspace, that is the total number of
  *     XWiki.XWikiGroups objects in the space members group document of the workspace.
  */
 public int countMembers(String spaceName) {
   try {
     return getWorkspacesManager().countMembers(spaceName, context);
   } catch (SpaceManagerException e) {
     context.put("haserror", "1");
     context.put("lasterror", e.getMessage());
     return 0;
   }
 }
 /**
  * @see #getLastSpaces(int)
  * @param startAt the offset to start retrieving the latest workspaces at
  */
 public Collection getLastSpaces(int howMany, int startAt) {
   try {
     return getWorkspacesManager().getLastSpaces(howMany, startAt, context);
   } catch (SpaceManagerException e) {
     context.put("haserror", "1");
     context.put("lasterror", e.getMessage());
   }
   return Collections.EMPTY_LIST;
 }
 public Collection getWebsForSpace(String spaceName) {
   try {
     return getWorkspacesManager().getWebsForSpace(spaceName, context);
   } catch (SpaceManagerException e) {
     context.put("haserror", "1");
     context.put("lasterror", e.getMessage());
     return Collections.EMPTY_LIST;
   }
 }
 /**
  * @param web, the wiki space (a.k.a. web) to retrieve the root space for
  * @return the top level space (or web) for the workspace's given web, corresponding to the level
  *     the passed web inherits its rights from, through the 'parent' property of its
  *     WebPreference. As an example, the web 'Space_SomeSpace_Blog' will have 'Space_SomeSpace' as
  *     its workspace root space.
  */
 public Space getRootSpace(String web) {
   try {
     return getWorkspacesManager().getRootSpace(web, context);
   } catch (SpaceManagerException e) {
     context.put("haserror", "1");
     context.put("lasterror", e.getMessage());
   }
   return null;
 }
 /**
  * @param userName the wiki name of the user to find the userspace of
  * @return if, exists, the unique user workspace for the given user wikiname, null if it does not
  *     exists.
  */
 public Space getSpaceForUser(String userName) {
   try {
     return getWorkspacesManager().getSpaceForUser(userName, context);
   } catch (SpaceManagerException e) {
     context.put("haserror", "1");
     context.put("lasterror", e.getMessage());
   }
   return null;
 }
 /**
  * @return the list of {@link Workspace} in which the context user is a member and has a specific
  *     role (i.e. admin, reader or writer).
  */
 public Collection getMyMemberships() {
   try {
     // look over spaces in which the context user belongs to the member group
     return getWorkspacesManager().getSpaces(context.getUser(), null, context);
   } catch (SpaceManagerException e) {
     context.put("haserror", "1");
     context.put("lasterror", e.getMessage());
     return Collections.EMPTY_LIST;
   }
 }
 public boolean hasApplication(String spaceName, String appName) {
   try {
     return getWorkspacesManager()
         .getApplicationsForSpace(spaceName, context)
         .containsKey(appName);
   } catch (SpaceManagerException e) {
     context.put("haserror", "1");
     context.put("lasterror", e.getMessage());
     return false;
   }
 }
 /**
  * @param spaceName the workspace wiki name to retrieve the latest members for
  * @param howMany the number of members to retrieve
  * @return the latest added members of the space
  */
 public Collection getLastMembers(String spaceName, int howMany) {
   try {
     int startAt = 0;
     int totalMb = getWorkspacesManager().countMembers(spaceName, context);
     if (howMany < totalMb) startAt = totalMb - howMany;
     return getWorkspacesManager().getMembers(spaceName, howMany, startAt, context);
   } catch (SpaceManagerException e) {
     context.put("haserror", "1");
     context.put("lasterror", e.getMessage());
   }
   return Collections.EMPTY_LIST;
 }