Package org.exoplatform.social.rest.api
Class RestUtils
java.lang.Object
org.exoplatform.social.rest.api.RestUtils
-
Field Summary
Fields -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionstatic DataEntityextractInfo(DataEntity inEntity, List<String> returnedProperties) static StringformatISO8601(Date date) static StringGet base url of rest servicestatic longgetBaseTime(String baseDateTime) static StringGet base url of rest servicestatic final Stringstatic final org.exoplatform.social.core.identity.model.Identitystatic final longstatic org.exoplatform.social.core.manager.IdentityManagerstatic IntegergetIntegerValue(javax.ws.rs.core.UriInfo uriInfo, String name) static javax.ws.rs.core.MediaTypeGets the json media typestatic intgetLimit(javax.ws.rs.core.UriInfo uriInfo) static LonggetLongValue(javax.ws.rs.core.UriInfo uriInfo, String name) static javax.ws.rs.core.MediaTypegetMediaType(String expectedFormat, String[] supportedFormats) Gets the media type from an expected format string (usually the input) and an array of supported format strings.static intgetOffset(javax.ws.rs.core.UriInfo uriInfo) static org.exoplatform.social.core.identity.model.Identity[]getOnlineIdentities(org.exoplatform.services.user.UserStateService userStateService, String userId, int limit) gets online identities.static org.exoplatform.social.core.identity.model.Identity[]getOnlineIdentitiesOfSpace(org.exoplatform.services.user.UserStateService userStateService, String userId, org.exoplatform.social.core.space.model.Space space, int limit) gets online identities who are members of a space.static StringgetPathParam(javax.ws.rs.core.UriInfo uriInfo, String name) static StringgetQueryParam(javax.ws.rs.core.UriInfo uriInfo, String name) static StringgetRestUrl(String type, String id, String restPath) Get base url of rest servicestatic final org.exoplatform.social.core.identity.model.IdentitygetUserIdentity(String user) static booleanCheck if the current user is authenticatedstatic booleanCheck if the authenticated user is a member of the admin groupstatic booleanCheck if the authenticated user is a member of the delegated groupstatic booleanisReturnSize(javax.ws.rs.core.UriInfo uriInfo)
-
Field Details
-
DEFAULT_LIMIT
public static final int DEFAULT_LIMIT- See Also:
-
DEFAULT_OFFSET
public static final int DEFAULT_OFFSET- See Also:
-
HARD_LIMIT
public static final int HARD_LIMIT- See Also:
-
SUPPORT_TYPE
- See Also:
-
ADMIN_GROUP
- See Also:
-
DELEGATED_GROUP
- See Also:
-
INVISIBLE
- See Also:
-
-
Constructor Details
-
RestUtils
public RestUtils()
-
-
Method Details
-
formatISO8601
-
getJsonMediaType
public static javax.ws.rs.core.MediaType getJsonMediaType()Gets the json media type- Returns:
- a media type
-
getMediaType
public static javax.ws.rs.core.MediaType getMediaType(String expectedFormat, String[] supportedFormats) Gets the media type from an expected format string (usually the input) and an array of supported format strings. If expectedFormat is not found in the supported format array, Status.UNSUPPORTED_MEDIA_TYPE is thrown. The supported format must include one of those format: json, xml, atom or rss, otherwise Status.NOT_ACCEPTABLE could be thrown.- Parameters:
expectedFormat- the expected input formatsupportedFormats- the supported format array- Returns:
- the associated media type
-
isMemberOfAdminGroup
public static boolean isMemberOfAdminGroup()Check if the authenticated user is a member of the admin group- Returns:
-
isMemberOfDelegatedGroup
public static boolean isMemberOfDelegatedGroup()Check if the authenticated user is a member of the delegated group- Returns:
-
getRestUrl
Get base url of rest service- Parameters:
type- the type of rest serviceid- the id of object- Returns:
- base rest url like : http://localhost:8080/rest/v1/social/users/123456
-
getBaseRestUrl
Get base url of rest service- Returns:
- base rest url like : https://localhost:8080/rest
-
getBaseUrl
Get base url of rest service- Returns:
- base rest url like : https://localhost:8080
-
isAnonymous
public static boolean isAnonymous()Check if the current user is authenticated- Returns:
- true if user not authenticated
-
getPathParam
-
getQueryParam
-
getLimit
public static int getLimit(javax.ws.rs.core.UriInfo uriInfo) -
getOffset
public static int getOffset(javax.ws.rs.core.UriInfo uriInfo) -
getIntegerValue
-
getLongValue
-
isReturnSize
public static boolean isReturnSize(javax.ws.rs.core.UriInfo uriInfo) -
extractInfo
-
getBaseTime
- Throws:
ParseException
-
getUserIdentity
public static final org.exoplatform.social.core.identity.model.Identity getUserIdentity(String user) -
getCurrentUserIdentity
public static final org.exoplatform.social.core.identity.model.Identity getCurrentUserIdentity() -
getCurrentUserIdentityId
public static final long getCurrentUserIdentityId() -
getCurrentUser
-
getOnlineIdentitiesOfSpace
public static org.exoplatform.social.core.identity.model.Identity[] getOnlineIdentitiesOfSpace(org.exoplatform.services.user.UserStateService userStateService, String userId, org.exoplatform.social.core.space.model.Space space, int limit) gets online identities who are members of a space.- Parameters:
userStateService-UserStateServiceuserId- The current user.space- The space of which extract members.limit- Maximum number of identities to return.- Returns:
- identity array.
-
getOnlineIdentities
public static org.exoplatform.social.core.identity.model.Identity[] getOnlineIdentities(org.exoplatform.services.user.UserStateService userStateService, String userId, int limit) gets online identities.- Parameters:
userStateService-UserStateServiceuserId- The current user.limit- Maximum number of identities to return.- Returns:
- identity array.
-
getIdentityManager
public static org.exoplatform.social.core.manager.IdentityManager getIdentityManager()
-