Class EntityBuilder


  • public class EntityBuilder
    extends Object
    • Method Detail

      • buildEntityIdentity

        public static IdentityEntity buildEntityIdentity​(org.exoplatform.social.core.identity.model.Identity identity,
                                                         String restPath,
                                                         String expand)
        Get a IdentityEntity from an identity in order to build a json object for the rest service
        Parameters:
        identity - the provided identity
        restPath - base REST path
        expand - which fields to expand from profile or space
        Returns:
        a hash map
      • buildEntityProfile

        public static ProfileEntity buildEntityProfile​(org.exoplatform.social.core.space.model.Space space,
                                                       org.exoplatform.social.core.identity.model.Profile profile,
                                                       String path,
                                                       String expand)
      • buildEntityProfile

        public static ProfileEntity buildEntityProfile​(org.exoplatform.social.core.identity.model.Profile profile,
                                                       String restPath,
                                                       String expand)
      • buildPhoneEntities

        public static void buildPhoneEntities​(org.exoplatform.social.core.identity.model.Profile profile,
                                              ProfileEntity userEntity)
      • buildImEntities

        public static void buildImEntities​(org.exoplatform.social.core.identity.model.Profile profile,
                                           ProfileEntity userEntity)
      • buildUrlEntities

        public static void buildUrlEntities​(org.exoplatform.social.core.identity.model.Profile profile,
                                            ProfileEntity userEntity)
      • buildExperienceEntities

        public static void buildExperienceEntities​(org.exoplatform.social.core.identity.model.Profile profile,
                                                   ProfileEntity userEntity)
      • buildEntityFromSpace

        public static SpaceEntity buildEntityFromSpace​(org.exoplatform.social.core.space.model.Space space,
                                                       String userId,
                                                       String restPath,
                                                       String expand)
        Get a hash map from a space in order to build a json object for the rest service
        Parameters:
        space - the provided space
        userId - the user's remote id
        restPath - base REST path
        expand - which fields to expand from space
        Returns:
        a hash map
      • buildEntityFromSpaceMembership

        public static SpaceMembershipEntity buildEntityFromSpaceMembership​(org.exoplatform.social.core.space.model.Space space,
                                                                           String userId,
                                                                           String type,
                                                                           String restPath,
                                                                           String expand)
        Get a hash map from a space in order to build a json object for the rest service
        Parameters:
        space - the provided space
        userId - the user's remote id
        type - membership type
        restPath - base REST path
        expand - which fields to expand from space
        Returns:
        a hash map
      • buildEntityFromActivity

        public static ActivityEntity buildEntityFromActivity​(org.exoplatform.social.core.activity.model.ExoSocialActivity activity,
                                                             org.exoplatform.social.core.identity.model.Identity authentiatedUser,
                                                             String restPath,
                                                             String expand)
      • retrieveMetadataItems

        public static Map<String,​List<MetadataItemEntity>> retrieveMetadataItems​(org.exoplatform.social.core.activity.model.ExoSocialActivity activity,
                                                                                       org.exoplatform.social.core.identity.model.Identity authentiatedUser)
      • buildActivityFromEntity

        public static void buildActivityFromEntity​(ActivityEntity model,
                                                   org.exoplatform.social.core.activity.model.ExoSocialActivity activity)
      • buildActivityParamsFromEntity

        public static void buildActivityParamsFromEntity​(org.exoplatform.social.core.activity.model.ExoSocialActivity activity,
                                                         Map<String,​?> templateParams)
      • expandSubComments

        public static boolean expandSubComments​(String expand)
      • buildEntityFromComment

        public static CommentEntity buildEntityFromComment​(org.exoplatform.social.core.activity.model.ExoSocialActivity comment,
                                                           org.exoplatform.social.core.identity.model.Identity authentiatedUser,
                                                           String restPath,
                                                           String expand,
                                                           boolean isBuildList)
      • buildEntityFromComment

        public static List<DataEntity> buildEntityFromComment​(org.exoplatform.social.core.activity.model.ExoSocialActivity activity,
                                                              org.exoplatform.social.core.identity.model.Identity authentiatedUser,
                                                              String restPath,
                                                              String expand,
                                                              boolean sortDescending,
                                                              int offset,
                                                              int limit)
      • buildEntityFromLike

        public static List<DataEntity> buildEntityFromLike​(org.exoplatform.social.core.activity.model.ExoSocialActivity activity,
                                                           String restPath,
                                                           String expand,
                                                           int offset,
                                                           int limit)
      • buildEntityRelationship

        public static RelationshipEntity buildEntityRelationship​(org.exoplatform.social.core.relationship.model.Relationship relationship,
                                                                 String restPath,
                                                                 String expand,
                                                                 boolean isSymetric)
        Get a RelationshipEntity from a relationship in order to build a json object for the rest service
        Parameters:
        relationship - the provided relationship
        restPath - base REST path
        expand - which fields to expand from relationship and identities
        isSymetric - whether the relationship is semetric or not
        Returns:
        a RelationshipEntity
      • buildRelationshipEntities

        public static List<DataEntity> buildRelationshipEntities​(List<org.exoplatform.social.core.relationship.model.Relationship> relationships,
                                                                 javax.ws.rs.core.UriInfo uriInfo)
      • createSpaceMembershipForIgnoredStatus

        public static SpaceMembershipEntity createSpaceMembershipForIgnoredStatus​(org.exoplatform.social.core.space.model.Space space,
                                                                                  String userId,
                                                                                  String type,
                                                                                  String restPath,
                                                                                  String expand)
        update the SpaceMemberShip between the user and the space as ignored and then update also the MemberShipType used in SpaceMembershipRestResourcesV1.java
        Parameters:
        space - suggested space to ignore
        userId - user ignoring suggested space
        type - role to use for space membership
        restPath - base REST path
        expand - which fields to expand from relationship and identities
        Returns:
        built SpaceMembershipEntity
      • getCommentsActivityRestUrl

        public static String getCommentsActivityRestUrl​(String activityId,
                                                        String restPath)
        Get the rest url in order to load all comments of an activity
        Parameters:
        activityId - activity's id
        restPath - base REST path
        Returns:
        path to access comments of the activity
      • getLikesActivityRestUrl

        public static String getLikesActivityRestUrl​(String activityId,
                                                     String restPath)
        Get the rest url in order to load all likes of an activity
        Parameters:
        activityId - activity's id
        restPath - base REST path
        Returns:
        path to access likes of the activity
      • getResponseBuilder

        public static javax.ws.rs.core.Response.ResponseBuilder getResponseBuilder​(Object entity,
                                                                                   javax.ws.rs.core.UriInfo uriInfo,
                                                                                   javax.ws.rs.core.MediaType mediaType,
                                                                                   javax.ws.rs.core.Response.Status status)
        Gets the response builder 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:
        responseBuilder the response builder object
      • 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
      • buildLinkForHeader

        public static Object buildLinkForHeader​(Object entity,
                                                String requestPath)
        "https://localhost:8080/rest/users?offset=50&limit=25" Link: <https://localhost:8080/rest/users?offset=25&limit=25>; rel="previous", <https://localhost:8080/rest/users?offset=75&limit=25>; rel="next"
        Parameters:
        entity - entity to compute its link
        requestPath - Request base path
        Returns:
        Content of 'Link' header
      • buildEntityFromGroupSpaceBinding

        public static GroupSpaceBindingEntity buildEntityFromGroupSpaceBinding​(org.exoplatform.social.core.binding.model.GroupSpaceBinding binding)
        Build rest binding entity from GroupSpaceBinding object
        Parameters:
        binding - the GroupSpaceBinding object
        Returns:
        the GroupSpaceBindingEntity rest object
      • buildEntityFromGroup

        public static GroupNodeEntity buildEntityFromGroup​(org.exoplatform.services.organization.Group group)
        Build rest group entity from group object
        Parameters:
        group - the group object
        Returns:
        the groupNodeEntity rest object
      • buildEntityFromGroupId

        public static GroupNodeEntity buildEntityFromGroupId​(String group)
        Build rest group entity from group name
        Parameters:
        group - the group name
        Returns:
        the groupNodeEntity rest object
      • buildEntityFromGroupSpaceBindingOperationReport

        public static GroupSpaceBindingOperationReportEntity buildEntityFromGroupSpaceBindingOperationReport​(org.exoplatform.social.core.binding.model.GroupSpaceBindingOperationReport bindingOperationReport)
        Build rest bindingOperationReport entity from bindingOperationReport object
        Parameters:
        bindingOperationReport - the bindingOperationReport object
        Returns:
        the bindingOperationReport rest object
      • fromJsonString

        public static final <T> T fromJsonString​(String value,
                                                 Class<T> resultClass)
      • toJsonString

        public static String toJsonString​(Object object)
      • getActivityManager

        public static org.exoplatform.social.core.manager.ActivityManager getActivityManager()
      • getIdentityManager

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

        public static org.exoplatform.social.core.space.spi.SpaceService getSpaceService()
      • getOrganizationService

        public static org.exoplatform.services.organization.OrganizationService getOrganizationService()
      • getRelationshipManager

        public static org.exoplatform.social.core.manager.RelationshipManager getRelationshipManager()