Package org.exoplatform.social.rest.api
Class RestUtils
- java.lang.Object
-
- org.exoplatform.social.rest.api.RestUtils
-
public class RestUtils extends Object
-
-
Field Summary
Fields Modifier and Type Field Description static StringADMIN_GROUPstatic intDEFAULT_LIMITstatic intDEFAULT_OFFSETstatic StringDELEGATED_GROUPstatic intHARD_LIMITstatic StringSUPPORT_TYPE
-
Constructor Summary
Constructors Constructor Description RestUtils()
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description static DataEntityextractInfo(DataEntity inEntity, List<String> returnedProperties)static StringformatISO8601(Date date)static StringgetBaseRestUrl()Get base url of rest servicestatic longgetBaseTime(String baseDateTime)static StringgetBaseUrl()Get base url of rest servicestatic StringgetCurrentUser()static org.exoplatform.social.core.identity.model.IdentitygetCurrentUserIdentity()static org.exoplatform.social.core.manager.IdentityManagergetIdentityManager()static IntegergetIntegerValue(javax.ws.rs.core.UriInfo uriInfo, String name)static javax.ws.rs.core.MediaTypegetJsonMediaType()Gets 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 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 org.exoplatform.social.core.identity.model.IdentitygetUserIdentity(String user)static booleanisAnonymous()Check if the current user is authenticatedstatic booleanisMemberOfAdminGroup()Check if the authenticated user is a member of the admin groupstatic booleanisMemberOfDelegatedGroup()Check if the authenticated user is a member of the delegated groupstatic booleanisReturnSize(javax.ws.rs.core.UriInfo uriInfo)
-
-
-
Field Detail
-
DEFAULT_LIMIT
public static final int DEFAULT_LIMIT
- See Also:
- Constant Field Values
-
DEFAULT_OFFSET
public static final int DEFAULT_OFFSET
- See Also:
- Constant Field Values
-
HARD_LIMIT
public static final int HARD_LIMIT
- See Also:
- Constant Field Values
-
SUPPORT_TYPE
public static final String SUPPORT_TYPE
- See Also:
- Constant Field Values
-
ADMIN_GROUP
public static final String ADMIN_GROUP
- See Also:
- Constant Field Values
-
DELEGATED_GROUP
public static final String DELEGATED_GROUP
- See Also:
- Constant Field Values
-
-
Method Detail
-
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
public static String getRestUrl(String type, String id, String restPath)
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
public static String getBaseRestUrl()
Get base url of rest service- Returns:
- base rest url like : https://localhost:8080/rest
-
getBaseUrl
public static String 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
-
getLimit
public static int getLimit(javax.ws.rs.core.UriInfo uriInfo)
-
getOffset
public static int getOffset(javax.ws.rs.core.UriInfo uriInfo)
-
getIntegerValue
public static Integer getIntegerValue(javax.ws.rs.core.UriInfo uriInfo, String name)
-
isReturnSize
public static boolean isReturnSize(javax.ws.rs.core.UriInfo uriInfo)
-
extractInfo
public static DataEntity extractInfo(DataEntity inEntity, List<String> returnedProperties)
-
getBaseTime
public static long getBaseTime(String baseDateTime) throws ParseException
- 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()
-
getCurrentUser
public static final String getCurrentUser()
-
getIdentityManager
public static org.exoplatform.social.core.manager.IdentityManager getIdentityManager()
-
-