Class RestUtils

java.lang.Object
org.exoplatform.social.rest.api.RestUtils

public class RestUtils extends Object
  • Field Details

  • Constructor Details

    • RestUtils

      public RestUtils()
  • Method Details

    • formatISO8601

      public static String formatISO8601(Date date)
    • 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 format
      supportedFormats - 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 service
      id - 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
    • getPathParam

      public static String getPathParam(javax.ws.rs.core.UriInfo uriInfo, String name)
    • getQueryParam

      public static String getQueryParam(javax.ws.rs.core.UriInfo uriInfo, String name)
    • 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)
    • getLongValue

      public static Long getLongValue(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 org.exoplatform.social.core.identity.model.Identity getUserIdentity(String user)
    • getCurrentUserIdentity

      public static org.exoplatform.social.core.identity.model.Identity getCurrentUserIdentity()
    • getCurrentUserIdentityId

      public static long getCurrentUserIdentityId()
    • getCurrentUserAclIdentity

      public static org.exoplatform.services.security.Identity getCurrentUserAclIdentity()
    • getCurrentUser

      public static String 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 - UserStateService
      userId - 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 - UserStateService
      userId - The current user.
      limit - Maximum number of identities to return.
      Returns:
      identity array.
    • canAccessAnonymousResources

      public static boolean canAccessAnonymousResources()
    • canAccessAnonymousResources

      public static boolean canAccessAnonymousResources(io.meeds.portal.security.service.SecuritySettingService securitySettingService)
    • canAccessAnonymousResources

      public static boolean canAccessAnonymousResources(String settingName)
    • canAccessAnonymousResources

      public static boolean canAccessAnonymousResources(io.meeds.social.space.service.SpaceDirectoryService spaceDirectoryService, String settingName)
    • canAccessAnonymousResources

      public static boolean canAccessAnonymousResources(io.meeds.social.space.service.SpaceDirectoryService spaceDirectoryService, String settingName, List<Long> categoryIds, List<Long> templateIds)
    • getIdentityManager

      public static org.exoplatform.social.core.manager.IdentityManager getIdentityManager()