Class SpaceUtils
java.lang.Object
org.exoplatform.social.core.space.SpaceUtils
SpaceUtils Utility for working with space
-
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final Stringstatic final Stringstatic final Stringstatic final Stringstatic final Stringstatic final Stringstatic final Stringstatic final Stringstatic final Stringstatic final Stringstatic final Stringstatic final Stringstatic final Stringstatic final String -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionstatic voidaddCreatorToGroup(String creator, String groupId) When user chooses an existing group, that user will be added to that group as a managerstatic voidaddUserToGroupWithManagerMembership(String remoteId, String groupId) Adds the user to group with the membership (manager).static voidaddUserToGroupWithMemberMembership(String remoteId, String groupId) Adds the user to group with the membership (member).static voidaddUserToGroupWithPublisherMembership(String remoteId, String groupId) Adds the user to group with the membership (publisher).static voidaddUserToGroupWithRedactorMembership(String remoteId, String groupId) Adds the user to group with the membership (redactor).static StringbuildGroupId(String prettyName, String parentGroupId) Builds pretty name base on the basic name in case create more than one space with the same name.static StringbuildPrettyName(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.static voidchangeAppPageTitle(org.exoplatform.portal.mop.user.UserNode spacePageNode, String newSpaceName) Change the page title of the application referring to the current spacePageNodestatic voidchangeAppPortletPreference(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.static voidchangeMenuPortletPreference(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.static voidchangeSpaceUrlPreference(org.exoplatform.portal.mop.user.UserNode spacePageNode, org.exoplatform.social.core.space.model.Space space, String newSpaceName) change spaceUrl preferences for all applications in a pageNode.static voidcheckUserExisting(String userName) Checks if a user is removed or not.static StringcleanString(String str) Utility for cleaning space namestatic voidcomputeNavigationLabels(List<org.exoplatform.portal.mop.user.UserNode> navigations, Locale locale) static intcountMembers(org.exoplatform.social.core.space.model.Space space) Utility for counting the number of members in a spacestatic StringcreateGroup(String spaceName, String creator) Creates new group in /Spaces node and return groupIdstatic StringcreateGroup(String groupLabel, String spaceName, String creator) Creates new group in /Spaces node and return groupIdstatic org.exoplatform.services.organization.GroupcreateGroupFromExistingGroup(org.exoplatform.services.organization.Group parentGroup, org.exoplatform.services.organization.Group existingGroup, String name) Deprecated.to be removed by 1.2.xstatic org.exoplatform.portal.mop.navigation.NavigationContextcreateGroupNavigation(String groupId) Creates group navigation if not existed or return existing group navigation based on groupIdstatic voidfilterUnreachablePages(List<org.exoplatform.portal.mop.user.UserNode> nodes) static org.exoplatform.portal.config.model.ContainerfindContainerById(ArrayList<org.exoplatform.portal.config.model.ModelObject> children, String id) Finds container by idfindMembershipUsersByGroupAndTypes(String groupId, String... membershipTypes) Get users that have membership with group by input membership types.static StringUtility for getting absolute urlgetAppIdList(org.exoplatform.social.core.space.model.Space space) Gets all application id from a spacestatic org.exoplatform.social.core.space.ApplicationgetApplication(String appId) Gets application from portal containerstatic StringgetAppNodeName(org.exoplatform.social.core.space.model.Space space, String appId) Gets appNodeName in a space by its appIdstatic StringgetAppStatus(org.exoplatform.social.core.space.model.Space space, String appId) Gets app status in a spacestatic StringgetDisplayAppName(String appDisplayName) Get display application name in formal.static org.exoplatform.portal.mop.user.UserNavigationgetGroupNavigation(String groupId) Gets userNavigation by a space's groupIdstatic org.exoplatform.portal.mop.navigation.NavigationContextgetGroupNavigationContext(String groupId) Gets NavigationContext by a space's groupIdstatic org.exoplatform.portal.mop.user.UserNodegetHomeNode(org.exoplatform.portal.mop.user.UserNavigation userNavigation) Retrieving the UserNode base on the UserNavigationstatic org.exoplatform.portal.mop.user.UserNodegetHomeNode(org.exoplatform.portal.mop.user.UserNavigation userNavigation, String spaceUrl) This related to a bug from portal.static org.exoplatform.portal.mop.navigation.NodeContext<org.exoplatform.portal.mop.navigation.NodeContext<?>> getHomeNodeWithChildren(org.exoplatform.portal.mop.navigation.NavigationContext spaceNavCtx, String spaceUrl) static org.exoplatform.portal.mop.user.UserNodegetHomeNodeWithChildren(org.exoplatform.portal.mop.user.UserNavigation userNavigation, String spaceUrl) Retrieving the UserNode with Children base on the spaceUrl and UserNavigation.static org.exoplatform.portal.mop.service.LayoutServiceGets dataStoragestatic 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 orderstatic org.exoplatform.services.organization.OrganizationServiceGets Organization Servicestatic org.exoplatform.portal.mop.storage.PageStoragestatic org.exoplatform.portal.mop.user.UserNodeGet parent node of the current space.static StringgetResolvedAppLabel(org.exoplatform.portal.mop.user.UserNode userNode, ResourceBundle resourceBundle, Locale locale) static org.exoplatform.services.resources.ResourceBundleServicestatic ResourceBundlegetSharedResourceBundle(Locale locale) static String[]static org.exoplatform.social.core.space.model.Spacestatic org.exoplatform.social.core.identity.model.Identitystatic List<org.exoplatform.portal.mop.user.UserNode> getSpaceNavigations(org.exoplatform.social.core.space.model.Space space, Locale locale, String currentuser) static org.exoplatform.social.core.space.spi.SpaceServicestatic StringDeprecated.UsegetSpaceUrlByContext()instead.static StringGets the space url based on the current context.static org.exoplatform.portal.mop.user.UserNodegetSpaceUserNode(org.exoplatform.social.core.space.model.Space space) Retrieving the UserNode of Space when is given Space instancestatic org.exoplatform.portal.mop.user.UserNodegetSpaceUserNode(org.exoplatform.social.core.space.model.Space space, org.exoplatform.portal.mop.user.UserNodeFilterConfig filter) static List<org.exoplatform.portal.mop.user.UserNode> getSpaceUserNodeChildren(org.exoplatform.social.core.space.model.Space space) static StringgetUri(org.exoplatform.portal.mop.user.UserNode userNode) static org.exoplatform.portal.config.UserACLGets the UserACL which helps to get Membership role to avoid hard code.static org.exoplatform.portal.mop.user.UserPortalUsing this method to get the UserPortal make sure that the data is latest.static org.exoplatform.portal.config.UserPortalConfigGet user portal config.static org.exoplatform.portal.config.UserPortalConfigServicestatic org.exoplatform.portal.mop.user.UserPortalGets the UserPortal when uses the RestService.static booleanhasSettingPermission(org.exoplatform.social.core.space.model.Space space, String username) static booleanisHomeNavigation(org.exoplatform.portal.mop.user.UserNode node) static booleanisInstalledApp(org.exoplatform.social.core.space.model.Space space, String appId) Check an application is installed or not yet.static booleanisRemovableApp(org.exoplatform.social.core.space.model.Space space, String appId) Checks if an application is removable or not.static booleanCheck whether is being in a space context or not.static booleanisSpaceNameExisted(String spaceName) Checks if a space existsstatic booleanisUserHasMembershipTypesInGroup(String remoteId, String groupId, String membershipType) Checks if an specific user has membership in group group with input membership type.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) static voidRefreshes the current user portal (navigation caching refresh).static voidremoveGroup(org.exoplatform.social.core.space.model.Space space) Removes a group owning a spacestatic voidremoveGroupNavigation(String groupId) Removes group navigations.static voidremoveMembershipFromGroup(org.exoplatform.social.core.space.model.Space space) Removes membership of users with a deleted spaces.static voidremoveNavigation(org.exoplatform.portal.mop.user.UserNavigation nav) Utility for removing portal navigation.static voidremovePagesAndGroupNavigation(org.exoplatform.social.core.space.model.Space space) Remove pages and group navigation of space when delete space.static voidremoveUserFromGroupWithAnyMembership(String remoteId, String groupId) Removes the user from group with any(*) membership.static voidremoveUserFromGroupWithManagerMembership(String remoteId, String groupId) Removes the user from group with manager membership.static voidremoveUserFromGroupWithMemberMembership(String remoteId, String groupId) Removes the user from group with member membership.static voidremoveUserFromGroupWithPublisherMembership(String remoteId, String groupId) Removes the user from group with publisher membership.static voidremoveUserFromGroupWithRedactorMembership(String remoteId, String groupId) Removes the user from group with redactor membership.static voidrenameGroupLabel(org.exoplatform.social.core.space.model.Space space) Rename label groupstatic org.exoplatform.portal.mop.user.UserNoderenamePageNode(org.exoplatform.social.core.space.model.Space space) Rename page node.static voidcommit transaction and restart a new one.static voidsetNavigation(org.exoplatform.portal.mop.user.UserNavigation nav) Utility for setting navigation.static voidsetPageTitle(List<org.exoplatform.portal.mop.user.UserNode> navigations, javax.portlet.RenderRequest request, org.exoplatform.social.core.space.model.Space space, Locale locale) static voidupdateDefaultSpaceAvatar(org.exoplatform.social.core.space.model.Space space) update space default avatar when renaming the spacestatic voidUpdates working work space
-
Field Details
-
SPACE_GROUP
- See Also:
-
PLATFORM_USERS_GROUP
- See Also:
-
PLATFORM_PUBLISHER_GROUP
- See Also:
-
MANAGER
- See Also:
-
MEMBER
- See Also:
-
REDACTOR
- See Also:
-
PUBLISHER
- See Also:
-
PENDING
- See Also:
-
INVITED
- See Also:
-
IGNORED
- See Also:
-
MENU_CONTAINER
- See Also:
-
APPLICATION_CONTAINER
- See Also:
-
SPACE_URL
- See Also:
-
SPACE_SETTINGS_PAGE
- See Also:
-
-
Constructor Details
-
SpaceUtils
public SpaceUtils()
-
-
Method Details
-
createGroupFromExistingGroup
public static org.exoplatform.services.organization.Group createGroupFromExistingGroup(org.exoplatform.services.organization.Group parentGroup, org.exoplatform.services.organization.Group existingGroup, String name) throws Exception Deprecated.to be removed by 1.2.xCreates a new group from an existing group. This new group will get all data from existing group except for group name- Parameters:
parentGroup-existingGroup-name-- Returns:
- new Group
- Throws:
Exception
-
getApplication
Gets application from portal container- Parameters:
appId-- Returns:
- An application has name match input appId.
-
cleanString
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
Deprecated.UsegetSpaceUrlByContext()instead.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
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() -
getSpaceIdentityByContext
public static org.exoplatform.social.core.identity.model.Identity getSpaceIdentityByContext() -
changeSpaceUrlPreference
public static void changeSpaceUrlPreference(org.exoplatform.portal.mop.user.UserNode spacePageNode, org.exoplatform.social.core.space.model.Space space, String newSpaceName) throws Exception change spaceUrl preferences for all applications in a pageNode. This pageNode is the clonedPage of spacetemplate.- Parameters:
spacePageNode-space-- Throws:
Exception
-
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:
-
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- Stringcreator- 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
When user chooses an existing group, that user will be added to that group as a manager- Parameters:
creator- StringgroupId- String
-
addUserToGroupWithMemberMembership
Adds the user to group with the membership (member).- Parameters:
remoteId-groupId-- Since:
- 1.2.0-GA
-
addUserToGroupWithRedactorMembership
Adds the user to group with the membership (redactor).- Parameters:
remoteId-groupId-
-
addUserToGroupWithPublisherMembership
Adds the user to group with the membership (publisher).- Parameters:
remoteId-groupId-
-
addUserToGroupWithManagerMembership
Adds the user to group with the membership (manager).- Parameters:
remoteId-groupId-- Since:
- 1.2.0-GA
-
removeUserFromGroupWithMemberMembership
Removes the user from group with member membership.- Parameters:
remoteId-groupId-- Since:
- 1.2.0-GA
-
removeUserFromGroupWithRedactorMembership
Removes the user from group with redactor membership.- Parameters:
remoteId-groupId-
-
removeUserFromGroupWithPublisherMembership
Removes the user from group with publisher membership.- Parameters:
remoteId-groupId-
-
removeUserFromGroupWithManagerMembership
Removes the user from group with manager membership.- Parameters:
remoteId-groupId-- Since:
- 1.2.0-GA
-
removeUserFromGroupWithAnyMembership
Removes the user from group with any(*) membership.- Parameters:
remoteId- target user remote idgroupId- group id
-
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
Get parent node of the current space.- Returns:
- Throws:
Exception- Since:
- 1.2.8
-
getUserPortalForRest
Gets the UserPortal when uses the RestService.- Returns:
- Throws:
Exception
-
getUserPortalConfig
Get user portal config.- Returns:
- Throws:
Exception- Since:
- 1.2.9
-
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
Gets all application id from a space- Parameters:
space-- Returns:
-
getAbsoluteUrl
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
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
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
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
-
isUserHasMembershipTypesInGroup
public static boolean isUserHasMembershipTypesInGroup(String remoteId, String groupId, String membershipType) Checks if an specific user has membership in group group with input membership type.- Parameters:
remoteId- User to be checked.groupId- Group information.membershipType- input membership type to check.- Returns:
- true if user has membership in group with input type.
-
findMembershipUsersByGroupAndTypes
public static List<String> findMembershipUsersByGroupAndTypes(String groupId, String... membershipTypes) Get users that have membership with group by input membership types.- Parameters:
groupId- Group information.membershipTypes- membership types to be get.- Returns:
- List of users that have membership with group is input membership type.
-
getUri
-
hasSettingPermission
public static boolean hasSettingPermission(org.exoplatform.social.core.space.model.Space space, String username) -
getResolvedAppLabel
public static String getResolvedAppLabel(org.exoplatform.portal.mop.user.UserNode userNode, ResourceBundle resourceBundle, Locale locale) -
filterUnreachablePages
-
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() -
getResourceBundleService
public static org.exoplatform.services.resources.ResourceBundleService getResourceBundleService()
-