Class Utils
java.lang.Object
org.exoplatform.social.webui.Utils
Contains some common methods for using as utility.
-
Field Summary
Fields -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionstatic StringGet Resource bundle.static final 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 StringGet activity's idstatic final org.exoplatform.social.core.manager.ActivityManagerGets activityManagerstatic StringGet focused comment's idstatic StringgetCookies(String key) getEnableUsers(String[] users) Get only users who are enablestatic final org.exoplatform.social.common.router.ExoRouterGets ExoRouterstatic StringGets the header parameterstatic final org.exoplatform.social.core.manager.IdentityManagerGets identityManagerstatic longgetLastVisited(String key, String mode) static List<org.exoplatform.social.core.identity.model.Identity> Gets list of friends of owner userstatic org.exoplatform.social.core.identity.model.IdentityGets identity of owner user.static org.exoplatform.social.core.identity.model.IdentitygetOwnerIdentity(boolean loadProfile) Gets identity of owner user.static Stringstatic StringGets remote id of owner user (depends on URL: .../remoteId).static org.exoplatform.social.core.identity.model.IdentityGets space identity of the owner space (from remote id)static LonggetPreviewSpaceId(jakarta.servlet.http.HttpServletRequest request) Reads the id of the space a site template page is previewed withstatic final org.exoplatform.social.core.relationship.model.RelationshipgetRelationship(org.exoplatform.social.core.identity.model.Identity identity) static final org.exoplatform.social.core.manager.RelationshipManagerGets relationshipManagerstatic StringGets selected node name.static org.exoplatform.social.core.space.model.SpaceDeprecated, for removal: This API element is subject to removal in a future version.static StringgetSpaceHomeURL(org.exoplatform.social.core.space.model.Space space) Gets the space home url of a space.static StringDeprecated, for removal: This API element is subject to removal in a future version.static org.exoplatform.social.core.identity.model.IdentitygetSpaceIdentity(String spaceName, boolean loadProfile) Gets identity from the remote id (space name)static final org.exoplatform.social.core.space.spi.SpaceServiceGets spaceServicestatic StringgetSpaceURL(org.exoplatform.portal.mop.user.UserNode node) Get the space url.static StringDeprecated, for removal: This API element is subject to removal in a future version.static StringGet the uri.static org.exoplatform.social.core.identity.model.IdentitygetUserIdentity(String userName) Retrieve Social Identity of userstatic org.exoplatform.social.core.identity.model.IdentitygetUserIdentity(String userName, boolean loadProfile) Deprecated, for removal: This API element is subject to removal in a future version.static StringgetValueFromRequestParam(String param) static List<org.exoplatform.social.core.identity.model.Identity> Gets list of friends of viewer userstatic org.exoplatform.social.core.identity.model.IdentityGets 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 Stringstatic StringGets remote id of viewer user.static TimeZonestatic intstatic booleanhasCookies(String key) static booleanisEnableUser(String userName) Check if an user is enable/disable from the remote id (user name)static booleanCheck 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 booleanCheck the request param of url to verify if need focus to comment boxstatic booleanCheck the request param of url to verify if need focus to comment reply boxstatic booleanDetermines current displayed page is Home or not base on selected node.static booleanisOwner()Checks if the owner user is the viewer user.static booleanDeprecated, for removal: This API element is subject to removal in a future version.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 StringtoScriptArray(Collection<?> values) Builds the JavaScript array literal of values printed in an inline script block, each element written bytoScriptString(Object)static StringtoScriptString(Object value) Builds the JavaScript string literal, quotes included, of a value printed in an inline script block: JSON string escaping, plus every '<' written as its JavaScript unicode escape, so that the value can neither close the block nor open an HTML comment in it.static final StringTruncates large Strings showing a portion of the String's head and tail with the head cut out and replaced with '...'.static voidUpdates working work space.
-
Field Details
-
ACTIVITY_STREAM_TAB_SELECTED_COOKIED
-
ACTIVITY_STREAM_VISITED_PREFIX_COOKIED
- See Also:
-
LAST_UPDATED_ACTIVITIES_NUM
- See Also:
-
FROM
- See Also:
-
OLD_FROM
- See Also:
-
TO
- See Also:
-
NOT_SEEN_ACTIVITIES_COOKIES
-
SEEN_ACTIVITIES_COOKIES
- See Also:
-
PREVIEW_SPACE_ID_PARAM
Request parameter carrying the space a site template page is previewed with- See Also:
-
-
Constructor Details
-
Utils
public Utils()
-
-
Method Details
-
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
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
-
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
-
getViewerTimezoneDSTSavings
public static int getViewerTimezoneDSTSavings() -
getViewerIdentityId
-
getUserIdentity
@Deprecated(forRemoval=true, since="6.5.0") public static org.exoplatform.social.core.identity.model.Identity getUserIdentity(String userName, boolean loadProfile) Deprecated, for removal: This API element is subject to removal in a future version.Gets identity from the remote id (user name)- Parameters:
userName-loadProfile-- Returns:
- identity
- Since:
- 1.2.0 GA
-
getUserIdentity
Retrieve Social Identity of user- Parameters:
userName- User name- Returns:
Identity
-
isEnableUser
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
-
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
-
getViewerFriends
-
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
-
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
-
getActivityID
-
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
-
getValueFromRequestParam
-
getHeader
-
getURI
-
getSelectedNode
-
getSpaceURL
Get the space url.- Parameters:
node-- Returns:
- Since:
- 1.2.1
-
getSpaceHomeURL
Gets the space home url of a space.- Parameters:
space-- Returns:
- Since:
- 1.2.1
-
setCookies
-
getCookies
-
hasCookies
-
getLastVisited
-
setLastVisited
-
listToString
-
isHomePage
public static boolean isHomePage()Determines current displayed page is Home or not base on selected node.- Returns:
-
centerTrunc
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
-
normalizeString
-
isSpaceContext
Deprecated, for removal: This API element is subject to removal in a future version.Check whether is being in a space context or not.- Returns:
- Since:
- 4.0.0-RC2
-
getSpaceUrlByContext
Deprecated, for removal: This API element is subject to removal in a future version.Gets the space url based on the current context.- Returns:
- Since:
- 4.0.0-RC2
-
getSpaceIdByContext
Deprecated, for removal: This API element is subject to removal in a future version.- Returns:
- the space id based on the current context.
-
getSpaceByContext
@Deprecated(forRemoval=true, since="7.0") public static org.exoplatform.social.core.space.model.Space getSpaceByContext()Deprecated, for removal: This API element is subject to removal in a future version.should useSpaceUtils.getSpaceByContext()instead- Returns:
- Current
Space
-
appRes
-
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
-
getPreviewSpaceId
Reads the id of the space a site template page is previewed with- Parameters:
request- the current request- Returns:
- the value of the "previewSpaceId" parameter when it holds ASCII digits only and fits a long, else null
-
toScriptString
Builds the JavaScript string literal, quotes included, of a value printed in an inline script block: JSON string escaping, plus every '<' written as its JavaScript unicode escape, so that the value can neither close the block nor open an HTML comment in it. The literal evaluates to the same string as the value.- Parameters:
value- the value to print, null being printed as "null"- Returns:
- a double-quoted JavaScript string literal
-
toScriptArray
Builds the JavaScript array literal of values printed in an inline script block, each element written bytoScriptString(Object)- Parameters:
values- the values to print, in their iteration order- Returns:
- a JavaScript array literal of string literals
-
SpaceUtils.getSpaceByContext()instead