Class SpaceUtils

java.lang.Object
org.exoplatform.social.core.space.SpaceUtils

public class SpaceUtils extends Object
SpaceUtils Utility for working with space
  • Field Details

  • Constructor Details

    • SpaceUtils

      public SpaceUtils()
  • Method Details

    • getApplication

      public static org.exoplatform.social.core.space.Application getApplication(String appId)
      Gets application from portal container
      Parameters:
      appId -
      Returns:
      An application has name match input appId.
    • cleanString

      public static String cleanString(String str)
      Utility for cleaning space name
      Parameters:
      str -
      Returns:
      cleaned string
    • renameGroupLabel

      public static void renameGroupLabel(org.exoplatform.social.core.space.model.Space space)
      Rename label group
      Parameters:
      space -
    • updateDefaultSpaceAvatar

      public static void updateDefaultSpaceAvatar(org.exoplatform.social.core.space.model.Space space)
      update space default avatar when renaming the space
      Parameters:
      space -
    • renamePageNode

      public static org.exoplatform.portal.mop.user.UserNode renamePageNode(org.exoplatform.social.core.space.model.Space space)
      Rename page node.
      Parameters:
      space -
      Returns:
      UserNode
    • getSpaceUrl

      public static String getSpaceUrl()
      Deprecated.
      Gets spaceName by portletPreference.
      Returns:
    • isSpaceContext

      public static boolean isSpaceContext()
      Check whether is being in a space context or not.
      Returns:
      Since:
      4.0.0-RC2
    • getSpaceUrlByContext

      public static String getSpaceUrlByContext()
      Gets the space url based on the current context.
      Returns:
      Since:
      4.0.0-RC2
    • getSpaceByContext

      public static org.exoplatform.social.core.space.model.Space getSpaceByContext()
    • setSpaceByContext

      public static void setSpaceByContext(org.exoplatform.portal.application.PortalRequestContext context, Object space)
    • getSpaceIdentityByContext

      public static org.exoplatform.social.core.identity.model.Identity getSpaceIdentityByContext()
    • removePagesAndGroupNavigation

      public static void removePagesAndGroupNavigation(org.exoplatform.social.core.space.model.Space space) throws org.exoplatform.social.core.space.SpaceException
      Remove pages and group navigation of space when delete space.
      Parameters:
      space -
      Throws:
      org.exoplatform.social.core.space.SpaceException
      Since:
      1.2.8
    • changeAppPageTitle

      public static void changeAppPageTitle(org.exoplatform.portal.mop.user.UserNode spacePageNode, String newSpaceName) throws Exception
      Change the page title of the application referring to the current spacePageNode
      Parameters:
      spacePageNode -
      newSpaceName -
      Throws:
      Exception
    • changeMenuPortletPreference

      public static void changeMenuPortletPreference(org.exoplatform.portal.config.model.Container menuContainer, org.exoplatform.portal.mop.service.LayoutService layoutService, org.exoplatform.social.core.space.model.Space space)
      Change menu portlet preference.
      Parameters:
      menuContainer -
      layoutService -
      space -
      Since:
      1.2.8
    • changeAppPortletPreference

      public static void changeAppPortletPreference(org.exoplatform.portal.config.model.Container applicationContainer, org.exoplatform.portal.mop.service.LayoutService layoutService, org.exoplatform.social.core.space.model.Space space)
      Change application portlet preference.
      Parameters:
      applicationContainer -
      layoutService -
      space -
      Since:
      1.2.8
    • restartRequest

      public static void restartRequest()
      commit transaction and restart a new one.
    • findContainerById

      public static org.exoplatform.portal.config.model.Container findContainerById(ArrayList<org.exoplatform.portal.config.model.ModelObject> children, String id)
      Finds container by id
      Parameters:
      children -
      id -
      Returns:
    • setNavigation

      public static void setNavigation(org.exoplatform.portal.mop.user.UserNavigation nav)
      Utility for setting navigation. Set pageNavigation, if existed in portal navigations, reset; if not, added to portal navigations.
      Parameters:
      nav - TODO This method which uses to cache the Navigation. Maybe remove this method because it uses to cache for UI
    • removeNavigation

      public static void removeNavigation(org.exoplatform.portal.mop.user.UserNavigation nav) throws Exception
      Utility for removing portal navigation.
      Parameters:
      nav -
      Throws:
      Exception
    • updateWorkingWorkSpace

      public static void updateWorkingWorkSpace()
      Updates working work space
    • createGroup

      public static String createGroup(String spaceName, String creator) throws org.exoplatform.social.core.space.SpaceException
      Creates new group in /Spaces node and return groupId
      Parameters:
      spaceName - String
      creator - String
      Returns:
      groupId String
      Throws:
      org.exoplatform.social.core.space.SpaceException
    • createGroup

      public static String createGroup(String groupLabel, String spaceName, String creator) throws org.exoplatform.social.core.space.SpaceException
      Creates new group in /Spaces node and return groupId
      Parameters:
      groupLabel - Space Display name.
      spaceName - Space name.
      creator - Name of user who creating space.
      Returns:
      groupId Id of created space group.
      Throws:
      org.exoplatform.social.core.space.SpaceException
    • removeGroup

      public static void removeGroup(org.exoplatform.social.core.space.model.Space space) throws org.exoplatform.social.core.space.SpaceException
      Removes a group owning a space
      Parameters:
      space -
      Throws:
      org.exoplatform.social.core.space.SpaceException
    • removeMembershipFromGroup

      public static void removeMembershipFromGroup(org.exoplatform.social.core.space.model.Space space)
      Removes membership of users with a deleted spaces.
      Parameters:
      space -
    • isSpaceNameExisted

      public static boolean isSpaceNameExisted(String spaceName) throws org.exoplatform.social.core.space.SpaceException
      Checks if a space exists
      Parameters:
      spaceName -
      Returns:
      boolean if existed return true, else return false
      Throws:
      org.exoplatform.social.core.space.SpaceException - with code INTERNAL_SERVER_ERROR
    • addCreatorToGroup

      public static void addCreatorToGroup(String creator, String groupId)
      When user chooses an existing group, that user will be added to that group as a manager
      Parameters:
      creator - String
      groupId - String
    • addUserToGroupWithMemberMembership

      public static void addUserToGroupWithMemberMembership(String remoteId, String groupId)
      Adds the user to group with the membership (member).
      Parameters:
      remoteId -
      groupId -
      Since:
      1.2.0-GA
    • addUserToGroupWithRedactorMembership

      public static void addUserToGroupWithRedactorMembership(String remoteId, String groupId)
      Adds the user to group with the membership (redactor).
      Parameters:
      remoteId -
      groupId -
    • addUserToGroupWithPublisherMembership

      public static void addUserToGroupWithPublisherMembership(String remoteId, String groupId)
      Adds the user to group with the membership (publisher).
      Parameters:
      remoteId -
      groupId -
    • addUserToGroupWithManagerMembership

      public static void addUserToGroupWithManagerMembership(String remoteId, String groupId)
      Adds the user to group with the membership (manager).
      Parameters:
      remoteId -
      groupId -
      Since:
      1.2.0-GA
    • removeUserFromGroupWithMemberMembership

      public static void removeUserFromGroupWithMemberMembership(String remoteId, String groupId)
      Removes the user from group with member membership.
      Parameters:
      remoteId -
      groupId -
      Since:
      1.2.0-GA
    • removeUserFromGroupWithRedactorMembership

      public static void removeUserFromGroupWithRedactorMembership(String remoteId, String groupId)
      Removes the user from group with redactor membership.
      Parameters:
      remoteId -
      groupId -
    • removeUserFromGroupWithPublisherMembership

      public static void removeUserFromGroupWithPublisherMembership(String remoteId, String groupId)
      Removes the user from group with publisher membership.
      Parameters:
      remoteId -
      groupId -
    • removeUserFromGroupWithManagerMembership

      public static void removeUserFromGroupWithManagerMembership(String remoteId, String groupId)
      Removes the user from group with manager membership.
      Parameters:
      remoteId -
      groupId -
      Since:
      1.2.0-GA
    • removeUserFromGroupWithAnyMembership

      public static void removeUserFromGroupWithAnyMembership(String remoteId, String groupId)
      Removes the user from group with any(*) membership.
      Parameters:
      remoteId - target user remote id
      groupId - group id
    • createGroupNavigation

      public static org.exoplatform.portal.mop.navigation.NavigationContext createGroupNavigation(String groupId) throws org.exoplatform.social.core.space.SpaceException
      Creates group navigation if not existed or return existing group navigation based on groupId
      Parameters:
      groupId - String
      Returns:
      spaceNav PageNavigation
      Throws:
      org.exoplatform.social.core.space.SpaceException
    • refreshNavigation

      public static void refreshNavigation()
      Refreshes the current user portal (navigation caching refresh).
      Since:
      1.2.8
    • getUserPortal

      public static org.exoplatform.portal.mop.user.UserPortal getUserPortal()
      Using this method to get the UserPortal make sure that the data is latest. It's will remove the caching.
      Returns:
    • getParentNode

      public static org.exoplatform.portal.mop.user.UserNode getParentNode() throws Exception
      Get parent node of the current space.
      Returns:
      Throws:
      Exception
      Since:
      1.2.8
    • getUserPortalForRest

      public static org.exoplatform.portal.mop.user.UserPortal getUserPortalForRest() throws Exception
      Gets the UserPortal when uses the RestService.
      Returns:
      Throws:
      Exception
    • getUserPortalConfig

      public static org.exoplatform.portal.config.UserPortalConfig getUserPortalConfig() throws Exception
      Get user portal config.
      Returns:
      Throws:
      Exception
      Since:
      1.2.9
    • removeGroupNavigation

      public static void removeGroupNavigation(String groupId) throws org.exoplatform.social.core.space.SpaceException
      Removes group navigations.
      Parameters:
      groupId -
      Throws:
      org.exoplatform.social.core.space.SpaceException
    • getGroupNavigationContext

      public static org.exoplatform.portal.mop.navigation.NavigationContext getGroupNavigationContext(String groupId)
      Gets NavigationContext by a space's groupId
      Parameters:
      groupId -
    • getGroupNavigation

      public static org.exoplatform.portal.mop.user.UserNavigation getGroupNavigation(String groupId)
      Gets userNavigation by a space's groupId
      Parameters:
      groupId -
    • getHomeNode

      public static org.exoplatform.portal.mop.user.UserNode getHomeNode(org.exoplatform.portal.mop.user.UserNavigation userNavigation, String spaceUrl)
      This related to a bug from portal. When this bug is resolved, use userNavigation.getNode(space.getUrl());
      Parameters:
      userNavigation -
      spaceUrl -
      Returns:
    • getHomeNode

      public static org.exoplatform.portal.mop.user.UserNode getHomeNode(org.exoplatform.portal.mop.user.UserNavigation userNavigation)
      Retrieving the UserNode base on the UserNavigation
      Parameters:
      userNavigation -
      Returns:
    • getHomeNodeWithChildren

      public static org.exoplatform.portal.mop.navigation.NodeContext<org.exoplatform.portal.mop.navigation.NodeContext<?>> getHomeNodeWithChildren(org.exoplatform.portal.mop.navigation.NavigationContext spaceNavCtx, String spaceUrl)
      Parameters:
      spaceNavCtx -
      spaceUrl -
      Returns:
    • getHomeNodeWithChildren

      public static org.exoplatform.portal.mop.user.UserNode getHomeNodeWithChildren(org.exoplatform.portal.mop.user.UserNavigation userNavigation, String spaceUrl)
      Retrieving the UserNode with Children base on the spaceUrl and UserNavigation. When user can use this method to get homeNode, you can not call the update node to getChildren()
      Parameters:
      userNavigation -
      spaceUrl -
      Returns:
    • getSpaceUserNode

      public static org.exoplatform.portal.mop.user.UserNode getSpaceUserNode(org.exoplatform.social.core.space.model.Space space) throws Exception
      Retrieving the UserNode of Space when is given Space instance
      Parameters:
      space - space
      Returns:
      Throws:
      Exception
    • getSpaceUserNode

      public static org.exoplatform.portal.mop.user.UserNode getSpaceUserNode(org.exoplatform.social.core.space.model.Space space, org.exoplatform.portal.mop.user.UserNodeFilterConfig filter) throws Exception
      Throws:
      Exception
    • getSpaceUserNodeChildren

      public static List<org.exoplatform.portal.mop.user.UserNode> getSpaceUserNodeChildren(org.exoplatform.social.core.space.model.Space space) throws Exception
      Throws:
      Exception
    • getOrderedSpaces

      public static List<org.exoplatform.social.core.space.model.Space> getOrderedSpaces(List<org.exoplatform.social.core.space.model.Space> spaces)
      Sorts spaces list by priority and alphabet order
      Parameters:
      spaces -
      Returns:
      ordered spaces list
    • countMembers

      public static int countMembers(org.exoplatform.social.core.space.model.Space space) throws org.exoplatform.social.core.space.SpaceException
      Utility for counting the number of members in a space
      Parameters:
      space -
      Returns:
      the number of members
      Throws:
      org.exoplatform.social.core.space.SpaceException
    • getAppStatus

      public static String getAppStatus(org.exoplatform.social.core.space.model.Space space, String appId)
      Gets app status in a space
      Parameters:
      space -
      appId -
      Returns:
      appStatus
    • getAppNodeName

      public static String getAppNodeName(org.exoplatform.social.core.space.model.Space space, String appId)
      Gets appNodeName in a space by its appId
      Parameters:
      space -
      appId -
      Returns:
    • isRemovableApp

      public static boolean isRemovableApp(org.exoplatform.social.core.space.model.Space space, String appId)
      Checks if an application is removable or not. Default will return true.
      Parameters:
      space -
      appId -
    • getAppIdList

      public static List<String> getAppIdList(org.exoplatform.social.core.space.model.Space space)
      Gets all application id from a space
      Parameters:
      space -
      Returns:
    • getAbsoluteUrl

      public static String getAbsoluteUrl() throws org.exoplatform.social.core.space.SpaceException
      Utility for getting absolute url
      Returns:
      absolute url
      Throws:
      org.exoplatform.social.core.space.SpaceException
    • checkUserExisting

      public static void checkUserExisting(String userName) throws org.exoplatform.social.core.space.SpaceException
      Checks if a user is removed or not.
      Parameters:
      userName - User name for checking.
      Throws:
      org.exoplatform.social.core.space.SpaceException - if user is removed.
    • isInstalledApp

      public static boolean isInstalledApp(org.exoplatform.social.core.space.model.Space space, String appId)
      Check an application is installed or not yet.
      Parameters:
      space -
      appId -
      Returns:
    • getDisplayAppName

      public static String getDisplayAppName(String appDisplayName)
      Get display application name in formal.
      Parameters:
      appDisplayName -
      Returns:
    • getOrganizationService

      public static org.exoplatform.services.organization.OrganizationService getOrganizationService()
      Gets Organization Service
      Returns:
    • getLayoutService

      public static org.exoplatform.portal.mop.service.LayoutService getLayoutService()
      Gets dataStorage
      Returns:
    • buildGroupId

      public static String buildGroupId(String prettyName, String parentGroupId)
      Builds pretty name base on the basic name in case create more than one space with the same name.
      Parameters:
      prettyName -
      parentGroupId -
      Returns:
      Since:
      1.2.8
    • buildPrettyName

      public static String buildPrettyName(org.exoplatform.social.core.space.model.Space space)
      Builds pretty name base on the basic name in case create more than one space with the same name.
      Parameters:
      space -
      Returns:
    • getUserACL

      public static org.exoplatform.portal.config.UserACL getUserACL()
      Gets the UserACL which helps to get Membership role to avoid hard code.
      Returns:
      UserACL object
    • loadNode

      public static org.exoplatform.portal.mop.navigation.NodeContext<org.exoplatform.portal.mop.navigation.NodeContext<?>> loadNode(org.exoplatform.portal.mop.service.NavigationService navigationService, org.exoplatform.portal.mop.navigation.NavigationContext navigation, String navUri)
    • getSpaceNavigations

      public static List<org.exoplatform.portal.mop.user.UserNode> getSpaceNavigations(org.exoplatform.social.core.space.model.Space space, Locale locale, String currentuser)
    • getUri

      public static String getUri(org.exoplatform.portal.mop.user.UserNode userNode)
    • computeNavigationLabels

      public static void computeNavigationLabels(List<org.exoplatform.portal.mop.user.UserNode> navigations, Locale locale)
    • hasSettingPermission

      public static boolean hasSettingPermission(org.exoplatform.social.core.space.model.Space space, String username)
    • isHomeNavigation

      public static boolean isHomeNavigation(org.exoplatform.portal.mop.user.UserNode node)
    • getResolvedAppLabel

      public static String getResolvedAppLabel(org.exoplatform.portal.mop.user.UserNode userNode, ResourceBundle resourceBundle, Locale locale)
    • filterUnreachablePages

      public static void filterUnreachablePages(List<org.exoplatform.portal.mop.user.UserNode> nodes)
    • setPageTitle

      public static void setPageTitle(List<org.exoplatform.portal.mop.user.UserNode> navigations, javax.portlet.RenderRequest request, org.exoplatform.social.core.space.model.Space space, Locale locale) throws Exception
      Throws:
      Exception
    • getUserPortalConfigService

      public static org.exoplatform.portal.config.UserPortalConfigService getUserPortalConfigService()
    • getPageStorage

      public static org.exoplatform.portal.mop.storage.PageStorage getPageStorage()
    • getSpaceService

      public static org.exoplatform.social.core.space.spi.SpaceService getSpaceService()
    • getSharedResourceBundle

      public static ResourceBundle getSharedResourceBundle(Locale locale)
    • getResourceBundleService

      public static org.exoplatform.services.resources.ResourceBundleService getResourceBundleService()
    • getSharedResources

      public static String[] getSharedResources()