org.exoplatform.social.service.rest
Class Util

java.lang.Object
  extended by org.exoplatform.social.service.rest.Util

public final class Util
extends Object

Util.java: utility class for rest
.

Since:
Jan 5, 2009
Author:
hoatle

Method Summary
static String buildAbsoluteAvatarURL(org.exoplatform.social.core.identity.model.Identity resultIdentity)
          Build absolute AvatarURL from in IndentityRestOut if avatar == null or "" use default avatar base on Identity's type
static void buildAbsoluteAvatarURL(IdentityRestOut resultIdentity)
          Build absolute AvatarURL from in IndentityRestOut if avatar == null or "" use default avatar base on Identity's type
static String convertTimestampToTimeString(long timestamp)
          Converts a timestamp string to time string by the pattern: EEE MMM d HH:mm:ss Z yyyy.
static org.exoplatform.social.core.manager.ActivityManager getActivityManager()
          Deprecated. Use getActivityManager(String) instead. Will be removed by 1.3.x
static org.exoplatform.social.core.manager.ActivityManager getActivityManager(String portalContainerName)
          Gets ActivityManager with specified portal container name.
static org.exoplatform.social.core.identity.model.Identity getAuthenticatedUserIdentity(String portalContainerName)
          Gets UserIdentity of authenticated user.
static String getBaseUrl()
          Gets base url (host + post) from a context uriInfo.
static org.exoplatform.social.core.manager.IdentityManager getIdentityManager()
          Deprecated. Use getIdentityManager(String) instead. Will be removed by 1.3.x
static org.exoplatform.social.core.manager.IdentityManager getIdentityManager(String portalContainerName)
          Gets IdentityManager with specified portal container name.
static javax.ws.rs.core.MediaType getMediaType(String format)
          Deprecated. User getMediaType(String, String[]) instead. Will be removed by 1.3.x
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.
static String getMimeTypeOfURL(String urlString)
          Try to guess the mime type of url using the Content-Type from header, the extension of filename or some bytes of content.
static org.exoplatform.social.core.identity.model.Identity getOwnerIdentityIdFromActivity(org.exoplatform.social.core.activity.model.ExoSocialActivity activity)
          Deprecated. Use getOwnerIdentityIdFromActivity(String, ExoSocialActivity) instead. Will be removed by 1.3.x
static org.exoplatform.social.core.identity.model.Identity getOwnerIdentityIdFromActivity(String portalContainerName, org.exoplatform.social.core.activity.model.ExoSocialActivity activity)
          Gets a owner identity Id from a provided activity.
static org.exoplatform.container.PortalContainer getPortalContainerByName(String portalContainerName)
          Gets a portal container by its name.
static org.exoplatform.social.core.manager.RelationshipManager getRelationshipManager()
          Deprecated. Use getRelationshipManager(String) instead. Will be removed by 1.3.x
static org.exoplatform.social.core.manager.RelationshipManager getRelationshipManager(String portalContainerName)
          Gets RelationshipManager with specified portal container name.
static javax.ws.rs.core.Response getResponse(Object entity, javax.ws.rs.core.UriInfo uriInfo, javax.ws.rs.core.MediaType mediaType, javax.ws.rs.core.Response.Status status)
          Gets the response object constructed from the provided params.
static org.exoplatform.social.core.space.spi.SpaceService getSpaceService()
          Deprecated. Use getSpaceService(String) instead. Will be removed by 1.3.x
static org.exoplatform.social.core.space.spi.SpaceService getSpaceService(String portalContainerName)
          Gets SpaceService with specified portal container name.
static org.exoplatform.social.core.identity.model.Identity getUserIdentity(String userName, boolean loadProfile)
          Deprecated. Use getUserIdentity(String, String, boolean) instead. Will be removed by 1.3.x
static org.exoplatform.social.core.identity.model.Identity getUserIdentity(String portalContainerName, String userName, boolean loadProfile)
          Gets identity from the remote id (user name)
static String getViewerId(javax.ws.rs.core.UriInfo uriInfo)
          Get viewerId from servlet request data information provided by OpenSocial signed request.
static org.exoplatform.social.core.identity.model.Identity getViewerIdentity(String viewerId)
          Deprecated. Use getViewerIdentity(String, String) instead. Will be removed by 1.3.x
static org.exoplatform.social.core.identity.model.Identity getViewerIdentity(String portalContainerName, String viewerId)
          Gets identity of viewer user (logged-in user).
static boolean isLikedByIdentity(String identityID, org.exoplatform.social.core.activity.model.ExoSocialActivity activity)
          Check if identityId contained in liked Identity, if yes return true else return false.
static boolean isValidURL(String link)
          Checks a url is in a valid form or not.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Method Detail

isValidURL

public static boolean isValidURL(String link)
Checks a url is in a valid form or not.

Parameters:
link -
Returns:

getResponse

public static javax.ws.rs.core.Response getResponse(Object entity,
                                                    javax.ws.rs.core.UriInfo uriInfo,
                                                    javax.ws.rs.core.MediaType mediaType,
                                                    javax.ws.rs.core.Response.Status status)
Gets the response object constructed from the provided params.

Parameters:
entity - the identity
uriInfo - the uri request info
mediaType - the media type to be returned
status - the status code
Returns:
response the response object

getMediaType

@Deprecated
public static javax.ws.rs.core.MediaType getMediaType(String format)
                                               throws javax.ws.rs.WebApplicationException
Deprecated. User getMediaType(String, String[]) instead. Will be removed by 1.3.x

Gets mediaType from string format. Currently supports json and xml only.

Parameters:
format -
Returns:
mediaType of matched or throw BAD_REQUEST exception
Throws:
javax.ws.rs.WebApplicationException

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 format
supportedFormats - the supported format array
Returns:
the associated media type

getViewerId

public static String getViewerId(javax.ws.rs.core.UriInfo uriInfo)
Get viewerId from servlet request data information provided by OpenSocial signed request.

Parameters:
uriInfo -
Returns:

getViewerIdentity

@Deprecated
public static org.exoplatform.social.core.identity.model.Identity getViewerIdentity(String viewerId)
Deprecated. Use getViewerIdentity(String, String) instead. Will be removed by 1.3.x

Gets identity of viewer user (logged-in user). Do not load profile.

Returns:
identity
Since:
1.2.0 GA

getViewerIdentity

public static org.exoplatform.social.core.identity.model.Identity getViewerIdentity(String portalContainerName,
                                                                                    String viewerId)
Gets identity of viewer user (logged-in user). Do not load profile.

Returns:
identity
Since:
1.2.3

getUserIdentity

@Deprecated
public static org.exoplatform.social.core.identity.model.Identity getUserIdentity(String userName,
                                                                                             boolean loadProfile)
Deprecated. Use getUserIdentity(String, String, boolean) instead. Will be removed by 1.3.x

Gets identity from the remote id (user name)

Parameters:
userName -
loadProfile -
Returns:
identity
Since:
1.2.0 GA

getUserIdentity

public static org.exoplatform.social.core.identity.model.Identity getUserIdentity(String portalContainerName,
                                                                                  String userName,
                                                                                  boolean loadProfile)
Gets identity from the remote id (user name)

Parameters:
portalContainerName -
userName -
loadProfile -
Returns:
identity
Since:
1.2.3

getIdentityManager

@Deprecated
public static final org.exoplatform.social.core.manager.IdentityManager getIdentityManager()
Deprecated. Use getIdentityManager(String) instead. Will be removed by 1.3.x

Gets identityManager with default portal container.

Returns:
identityManager
Since:
1.2.0 GA

getIdentityManager

public static final org.exoplatform.social.core.manager.IdentityManager getIdentityManager(String portalContainerName)
Gets IdentityManager with specified portal container name.

Parameters:
portalContainerName - the specified portal container name
Returns:
the identity manager
Since:
1.2.0-GA

getSpaceService

@Deprecated
public static final org.exoplatform.social.core.space.spi.SpaceService getSpaceService()
Deprecated. Use getSpaceService(String) instead. Will be removed by 1.3.x

Gets SpaceService with default portal container.

Returns:
the space service
Since:
1.2.0-GA

getSpaceService

public static final org.exoplatform.social.core.space.spi.SpaceService getSpaceService(String portalContainerName)
Gets SpaceService with specified portal container name.

Parameters:
portalContainerName - the specified portal container name
Returns:
the space service
Since:
1.2.0-GA

getActivityManager

@Deprecated
public static final org.exoplatform.social.core.manager.ActivityManager getActivityManager()
Deprecated. Use getActivityManager(String) instead. Will be removed by 1.3.x

Gets ActivityManager with default portal container.

Returns:
the activity manager
Since:
1.2.0-GA

getActivityManager

public static final org.exoplatform.social.core.manager.ActivityManager getActivityManager(String portalContainerName)
Gets ActivityManager with specified portal container name.

Parameters:
portalContainerName - the specified portal container
Returns:
the activity manager
Since:
1.2.0-GA

getRelationshipManager

@Deprecated
public static final org.exoplatform.social.core.manager.RelationshipManager getRelationshipManager()
Deprecated. Use getRelationshipManager(String) instead. Will be removed by 1.3.x

Gets RelationshipManager with default portal container.

Returns:
the relationship manager
Since:
1.2.0-GA

getRelationshipManager

public static final org.exoplatform.social.core.manager.RelationshipManager getRelationshipManager(String portalContainerName)
Gets RelationshipManager with specified portal container name.

Parameters:
portalContainerName - the specified portal container name
Returns:
the relationship manager
Since:
1.2.0-GA

getPortalContainerByName

public static final org.exoplatform.container.PortalContainer getPortalContainerByName(String portalContainerName)
Gets a portal container by its name.

Parameters:
portalContainerName - the specified portal container name
Returns:
the portal container name
Since:
1.2.3

convertTimestampToTimeString

public static final String convertTimestampToTimeString(long timestamp)
Converts a timestamp string to time string by the pattern: EEE MMM d HH:mm:ss Z yyyy.

Parameters:
timestamp - the timestamp to convert
Returns:
the time string

getOwnerIdentityIdFromActivity

@Deprecated
public static org.exoplatform.social.core.identity.model.Identity getOwnerIdentityIdFromActivity(org.exoplatform.social.core.activity.model.ExoSocialActivity activity)
Deprecated. Use getOwnerIdentityIdFromActivity(String, ExoSocialActivity) instead. Will be removed by 1.3.x

Gets a owner identity Id from a provided activity.

Parameters:
activity - the activity to gets its owner identity
Returns:
the owner identity
Since:
1.2.3

getOwnerIdentityIdFromActivity

public static org.exoplatform.social.core.identity.model.Identity getOwnerIdentityIdFromActivity(String portalContainerName,
                                                                                                 org.exoplatform.social.core.activity.model.ExoSocialActivity activity)
Gets a owner identity Id from a provided activity.

Parameters:
portalContainerName - the portal container name
activity - the activity to gets its owner identity
Returns:
the owner identity
Since:
1.2.0-GA

getBaseUrl

public static final String getBaseUrl()
Gets base url (host + post) from a context uriInfo.

For example: http://localhost:8080

Returns:
the base url (host + port)
Since:
1.2.3

buildAbsoluteAvatarURL

public static void buildAbsoluteAvatarURL(IdentityRestOut resultIdentity)
Build absolute AvatarURL from in IndentityRestOut if avatar == null or "" use default avatar base on Identity's type

Parameters:
resultIdentity -

buildAbsoluteAvatarURL

public static String buildAbsoluteAvatarURL(org.exoplatform.social.core.identity.model.Identity resultIdentity)
Build absolute AvatarURL from in IndentityRestOut if avatar == null or "" use default avatar base on Identity's type

Parameters:
resultIdentity -

getAuthenticatedUserIdentity

public static org.exoplatform.social.core.identity.model.Identity getAuthenticatedUserIdentity(String portalContainerName)
Gets UserIdentity of authenticated user.

Parameters:
portalContainerName - current portal container name
Returns:
Identity of user, if not authenticated return null

isLikedByIdentity

public static boolean isLikedByIdentity(String identityID,
                                        org.exoplatform.social.core.activity.model.ExoSocialActivity activity)
Check if identityId contained in liked Identity, if yes return true else return false.

Parameters:
identityID -
activity -
Returns:

getMimeTypeOfURL

public static String getMimeTypeOfURL(String urlString)
Try to guess the mime type of url using the Content-Type from header, the extension of filename or some bytes of content. This method can be wrong if server don't provide the Content-Type, wrong or unknown file extension. So use it as your risk.

Parameters:
urlString -
Returns:
Since:
1.2.7


Copyright © 2013 eXo Platform SAS. All Rights Reserved.