Package org.exoplatform.social.webui
Class Utils
- java.lang.Object
-
- org.exoplatform.social.webui.Utils
-
public class Utils extends Object
Contains some common methods for using as utility.
-
-
Field Summary
Fields Modifier and Type Field Description static StringACTIVITY_STREAM_TAB_SELECTED_COOKIED.static StringACTIVITY_STREAM_VISITED_PREFIX_COOKIEDstatic StringFROMstatic StringLAST_UPDATED_ACTIVITIES_NUMstatic StringNOT_SEEN_ACTIVITIES_COOKIES.static StringOLD_FROMstatic StringSEEN_ACTIVITIES_COOKIESstatic StringTO
-
Constructor Summary
Constructors Constructor Description Utils()
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description static StringappRes(String msgKey)Get Resource bundle.static StringcenterTrunc(String str, int head, int tail)Truncates large Strings showing a portion of the String's head and tail with the center cut out and replaced with '...'.static voidclearCacheOnUserPopup()Clears cached user data on user profile popup.static voidclearUserProfilePopup()Clear user profile popup.static voiddisplayFeedbackMessageInline(String parentId)Display the feedback message inline instead of show on popupstatic StringgetActivityID()Get activity's idstatic org.exoplatform.social.core.manager.ActivityManagergetActivityManager()Gets activityManagerstatic StringgetCommentID()Get focused comment's idstatic StringgetCookies(String key)static List<String>getEnableUsers(String[] users)Get only users who are enablestatic org.exoplatform.social.common.router.ExoRoutergetExoRouter()Gets ExoRouterstatic StringgetHeader(String param)Gets the header parameterstatic org.exoplatform.social.core.manager.IdentityManagergetIdentityManager()Gets identityManagerstatic longgetLastVisited(String key, String mode)static List<org.exoplatform.social.core.identity.model.Identity>getOwnerFriends()Gets list of friends of owner userstatic org.exoplatform.social.core.identity.model.IdentitygetOwnerIdentity()Gets identity of owner user.static org.exoplatform.social.core.identity.model.IdentitygetOwnerIdentity(boolean loadProfile)Gets identity of owner user.static StringgetOwnerIdentityId()static StringgetOwnerRemoteId()Gets remote id of owner user (depends on URL: .../remoteId).static org.exoplatform.social.core.identity.model.IdentitygetOwnerSpaceIdentity()Gets space identity of the owner space (from remote id)static org.exoplatform.social.core.relationship.model.RelationshipgetRelationship(org.exoplatform.social.core.identity.model.Identity identity)static org.exoplatform.social.core.manager.RelationshipManagergetRelationshipManager()Gets relationshipManagerstatic StringgetResolvedAppLabel(org.exoplatform.portal.mop.user.UserNode userNode)Gets resolved application label by input user node.static StringgetSelectedNode()Gets selected node name.static org.exoplatform.social.core.space.model.SpacegetSpaceByContext()static StringgetSpaceHomeURL(org.exoplatform.social.core.space.model.Space space)Gets the space home url of a space.static StringgetSpaceIdByContext()static org.exoplatform.social.core.identity.model.IdentitygetSpaceIdentity(String spaceName, boolean loadProfile)Gets identity from the remote id (space name)static org.exoplatform.social.core.space.spi.SpaceServicegetSpaceService()Gets spaceServicestatic StringgetSpaceURL(org.exoplatform.portal.mop.user.UserNode node)Get the space url.static StringgetSpaceUrlByContext()Gets the space url based on the current context.static StringgetURI(String url)Get the uri.static org.exoplatform.social.core.identity.model.IdentitygetUserIdentity(String userName, boolean loadProfile)Gets identity from the remote id (user name)static StringgetValueFromRefererURI(String param)Gets query value from Referer URI in request header.static StringgetValueFromRequestParam(String param)static List<org.exoplatform.social.core.identity.model.Identity>getViewerFriends()Gets list of friends of viewer userstatic org.exoplatform.social.core.identity.model.IdentitygetViewerIdentity()Gets identity of viewer user (logged-in user).static org.exoplatform.social.core.identity.model.IdentitygetViewerIdentity(boolean loadProfile)Gets identity of viewer user (logged-in user).static StringgetViewerIdentityId()static StringgetViewerRemoteId()Gets remote id of viewer user.static TimeZonegetViewerTimezone()static intgetViewerTimezoneDSTSavings()static booleanhasCookies(String key)static voidinitConfirmationPopup(String componentId)Initializes confirmation popup.static voidinitUserProfilePopup(String uiActivityId)Initializes user profile popup.static booleanisEnableUser(String userName)Check if an user is enable/disable from the remote id (user name)static booleanisExpandLikers()Check the request param of url to verify if need expand all likersstatic booleanisExternal(org.exoplatform.social.core.identity.model.Identity userIdentity)Check if the user is externalstatic booleanisFocusCommentBox()Check the request param of url to verify if need focus to comment boxstatic booleanisFocusCommentReplyBox()Check the request param of url to verify if need focus to comment reply boxstatic booleanisHomePage()Determines current displayed page is Home or not base on selected node.static booleanisOwner()Checks if the owner user is the viewer user.static booleanisSpaceContext()Check whether is being in a space context or not.static booleanisUserBoundToSpace(String username, String spaceId)static StringlistToString(List<String> list, String separator)static StringnormalizeString(String str)Trim space characters at the beginning and end of string.static voidsetCookies(String key, String value)static voidsetLastVisited(String mode)static Stringtrunc(String str, int head)Truncates large Strings showing a portion of the String's head and tail with the head cut out and replaced with '...'.static voidupdateWorkingWorkSpace()Updates working work space.
-
-
-
Field Detail
-
ACTIVITY_STREAM_TAB_SELECTED_COOKIED
public static final String ACTIVITY_STREAM_TAB_SELECTED_COOKIED
.- See Also:
- Constant Field Values
-
ACTIVITY_STREAM_VISITED_PREFIX_COOKIED
public static final String ACTIVITY_STREAM_VISITED_PREFIX_COOKIED
- See Also:
- Constant Field Values
-
LAST_UPDATED_ACTIVITIES_NUM
public static final String LAST_UPDATED_ACTIVITIES_NUM
- See Also:
- Constant Field Values
-
FROM
public static final String FROM
- See Also:
- Constant Field Values
-
OLD_FROM
public static final String OLD_FROM
- See Also:
- Constant Field Values
-
TO
public static final String TO
- See Also:
- Constant Field Values
-
NOT_SEEN_ACTIVITIES_COOKIES
public static final String NOT_SEEN_ACTIVITIES_COOKIES
.- See Also:
- Constant Field Values
-
SEEN_ACTIVITIES_COOKIES
public static final String SEEN_ACTIVITIES_COOKIES
- See Also:
- Constant Field Values
-
-
Method Detail
-
getOwnerRemoteId
public static String getOwnerRemoteId()
Gets remote id of owner user (depends on URL: .../remoteId). If owner user is null, return viewer remote id- Returns:
- remoteId of owner user
- Since:
- 1.2.0 GA
-
getViewerRemoteId
public static String getViewerRemoteId()
Gets remote id of viewer user.- Returns:
- remote id
- Since:
- 1.2.0 GA
-
isOwner
public static boolean isOwner()
Checks if the owner user is the viewer user.- Returns:
- true if the viewer user is the same as owner user.
- Since:
- 1.2.0 GA
-
getOwnerIdentity
public static org.exoplatform.social.core.identity.model.Identity getOwnerIdentity(boolean loadProfile)
Gets identity of owner user.- Parameters:
loadProfile-- Returns:
- identity
- Since:
- 1.2.0 GA
-
getViewerIdentity
public static org.exoplatform.social.core.identity.model.Identity getViewerIdentity(boolean loadProfile)
Gets identity of viewer user (logged-in user).- Parameters:
loadProfile-- Returns:
- identity
- Since:
- 1.2.0 GA
-
getOwnerIdentity
public static org.exoplatform.social.core.identity.model.Identity getOwnerIdentity()
Gets identity of owner user. Do not load profile.- Returns:
- identity
- Since:
- 1.2.0 GA
-
getOwnerIdentityId
public static String getOwnerIdentityId()
-
getViewerIdentity
public static org.exoplatform.social.core.identity.model.Identity getViewerIdentity()
Gets identity of viewer user (logged-in user). Do not load profile.- Returns:
- identity
- Since:
- 1.2.0 GA
-
getViewerTimezone
public static TimeZone getViewerTimezone()
-
getViewerTimezoneDSTSavings
public static int getViewerTimezoneDSTSavings()
-
getViewerIdentityId
public static String getViewerIdentityId()
-
getUserIdentity
public static org.exoplatform.social.core.identity.model.Identity getUserIdentity(String userName, boolean loadProfile)
Gets identity from the remote id (user name)- Parameters:
userName-loadProfile-- Returns:
- identity
- Since:
- 1.2.0 GA
-
isEnableUser
public static boolean isEnableUser(String userName)
Check if an user is enable/disable from the remote id (user name)- Parameters:
userName-- Returns:
- true if user is enable else return false
-
getEnableUsers
public static List<String> getEnableUsers(String[] users)
Get only users who are enable- Parameters:
users- list of all users- Returns:
- list of enable users
-
getSpaceIdentity
public static org.exoplatform.social.core.identity.model.Identity getSpaceIdentity(String spaceName, boolean loadProfile)
Gets identity from the remote id (space name)- Parameters:
spaceName-loadProfile-- Returns:
- space identity
- Since:
- 4.1-RC1
-
getOwnerSpaceIdentity
public static org.exoplatform.social.core.identity.model.Identity getOwnerSpaceIdentity()
Gets space identity of the owner space (from remote id)- Returns:
- space identity
- Since:
- 1.2.0 GA
-
getOwnerFriends
public static List<org.exoplatform.social.core.identity.model.Identity> getOwnerFriends() throws Exception
Gets list of friends of owner user- Returns:
- list of friends
- Throws:
Exception- Since:
- 1.2.0 GA
-
getViewerFriends
public static List<org.exoplatform.social.core.identity.model.Identity> getViewerFriends() throws Exception
Gets list of friends of viewer user- Returns:
- list of friends
- Throws:
Exception- Since:
- 1.2.0 GA
-
updateWorkingWorkSpace
public static void updateWorkingWorkSpace()
Updates working work space.- Since:
- 1.2.0 GA
-
getActivityManager
public static final org.exoplatform.social.core.manager.ActivityManager getActivityManager()
Gets activityManager- Returns:
- activityManager
- Since:
- 1.2.0 GA
-
getIdentityManager
public static final org.exoplatform.social.core.manager.IdentityManager getIdentityManager()
Gets identityManager- Returns:
- identityManager
- Since:
- 1.2.0 GA
-
getRelationshipManager
public static final org.exoplatform.social.core.manager.RelationshipManager getRelationshipManager()
Gets relationshipManager- Returns:
- relationshipManager
- Since:
- 1.2.0 GA
-
getRelationship
public static final org.exoplatform.social.core.relationship.model.Relationship getRelationship(org.exoplatform.social.core.identity.model.Identity identity) throws Exception- Parameters:
identity-- Returns:
- Throws:
Exception
-
getSpaceService
public static final org.exoplatform.social.core.space.spi.SpaceService getSpaceService()
Gets spaceService- Returns:
- spaceService
- Since:
- 1.2.0 GA
-
getExoRouter
public static final org.exoplatform.social.common.router.ExoRouter getExoRouter()
Gets ExoRouter- Returns:
- ExoRouter
-
getCommentID
public static String getCommentID()
Get focused comment's id- Returns:
-
getActivityID
public static String getActivityID()
Get activity's id- Returns:
-
isFocusCommentBox
public static boolean isFocusCommentBox()
Check the request param of url to verify if need focus to comment box- Returns:
- true if need focus to comment box
-
isFocusCommentReplyBox
public static boolean isFocusCommentReplyBox()
Check the request param of url to verify if need focus to comment reply box- Returns:
- true if need focus to comment reply box
-
isExpandLikers
public static boolean isExpandLikers()
Check the request param of url to verify if need expand all likers- Returns:
- true if need expand all likers
-
getHeader
public static String getHeader(String param)
Gets the header parameter- Parameters:
param-- Returns:
-
getValueFromRefererURI
public static String getValueFromRefererURI(String param)
Gets query value from Referer URI in request header.- Parameters:
param-- Returns:
-
displayFeedbackMessageInline
public static void displayFeedbackMessageInline(String parentId)
Display the feedback message inline instead of show on popup
-
getURI
public static String getURI(String url)
Get the uri.- Parameters:
url-- Returns:
- Since:
- 1.2.1
-
getSelectedNode
public static String getSelectedNode()
Gets selected node name.- Returns:
- Since:
- 1.2.2
-
getSpaceURL
public static String getSpaceURL(org.exoplatform.portal.mop.user.UserNode node)
Get the space url.- Parameters:
node-- Returns:
- Since:
- 1.2.1
-
getSpaceHomeURL
public static String getSpaceHomeURL(org.exoplatform.social.core.space.model.Space space)
Gets the space home url of a space.- Parameters:
space-- Returns:
- Since:
- 1.2.1
-
hasCookies
public static boolean hasCookies(String key)
-
setLastVisited
public static void setLastVisited(String mode)
-
isHomePage
public static boolean isHomePage()
Determines current displayed page is Home or not base on selected node.- Returns:
-
centerTrunc
public static final String centerTrunc(String str, int head, int tail)
Truncates large Strings showing a portion of the String's head and tail with the center cut out and replaced with '...'. Also displays the total length of the truncated string so size of '...' can be interpreted. Useful for large strings in UIs or hex dumps to log files.- Parameters:
str- the string to truncatehead- the amount of the head to displaytail- the amount of the tail to display- Returns:
- the center truncated string
-
trunc
public static final String trunc(String str, int head)
Truncates large Strings showing a portion of the String's head and tail with the head cut out and replaced with '...'.- Parameters:
str- the string to truncatehead- the amount of the head to display- Returns:
- the head truncated string
-
normalizeString
public static String normalizeString(String str)
Trim space characters at the beginning and end of string. Replace multiple spaces by a single space character.- Parameters:
str-- Returns:
- Since:
- 4.0.0-RC1
-
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
-
getSpaceIdByContext
public static String getSpaceIdByContext()
- Returns:
- the space id based on the current context.
-
initUserProfilePopup
public static void initUserProfilePopup(String uiActivityId)
Initializes user profile popup.- Parameters:
uiActivityId- Id of activity component.- Since:
- 4.0.0-GA
-
clearUserProfilePopup
public static void clearUserProfilePopup()
Clear user profile popup.- Since:
- 4.1.x
-
getSpaceByContext
public static org.exoplatform.social.core.space.model.Space getSpaceByContext()
-
clearCacheOnUserPopup
public static void clearCacheOnUserPopup()
Clears cached user data on user profile popup.- Since:
- 4.1.x
-
appRes
public static String appRes(String msgKey)
Get Resource bundle. If failure, log it in developer mode- Parameters:
msgKey- key to get resource bundle- Returns:
- Localized value for msgKey. null if value is not found
-
getResolvedAppLabel
public static String getResolvedAppLabel(org.exoplatform.portal.mop.user.UserNode userNode)
Gets resolved application label by input user node.- Parameters:
userNode- user node- Returns:
- label value of input user node. null be returned in case of node has no label.
- Since:
- 4.1-RC1
-
initConfirmationPopup
public static void initConfirmationPopup(String componentId) throws Exception
Initializes confirmation popup.- Parameters:
componentId- Target component.- Throws:
Exception
-
isExternal
public static boolean isExternal(org.exoplatform.social.core.identity.model.Identity userIdentity)
Check if the user is external- Parameters:
userIdentity-- Returns:
- true if the user is external
-
-