Class UserProfileResource

  • All Implemented Interfaces:
    ProtectedWebResource, WebAuthenticationValidation, WebAuthorizationValidation, SilverpeasWebResource

    @WebService
    @Path("profile/users")
    @Authenticated
    public class UserProfileResource
    extends RESTWebService
    A REST-based Web service that acts on the user profiles in Silverpeas. Each provided method is a way to access a representation of one or several user profile. This representation is vehiculed as a Web entity in the HTTP requests and responses.

    The users that are published depend on some parameters whose the domain isolation and the profile of the user behind the requesting. The domain isolation defines the visibility of a user or a group of users in a given domain to the others domains in Silverpeas.

    • Field Detail

      • RESPONSE_HEADER_USERSIZE

        public static final String RESPONSE_HEADER_USERSIZE
        The HTTP header parameter that provides the real size of the user profiles that match a query. This parameter is useful for clients that use the pagination to filter the count of user profiles to sent back.
        See Also:
        Constant Field Values
      • QUERY_ALL_GROUPS

        public static final String QUERY_ALL_GROUPS
        Specific identifier of a user group meaning all the user groups in Silverpeas. In that case, only the users part of a user group will be fetched.
        See Also:
        Constant Field Values
    • Constructor Detail

      • UserProfileResource

        public UserProfileResource()
    • Method Detail

      • checkUserToken

        @GET
        @Path("token")
        @Produces("application/json")
        public UserProfileEntity checkUserToken()
        Gets the profile of the user whose the API token is either passed in the Authorization HTTP header (Bearer authentication scheme, IETF RFC 6750) or with the query parameter access_token (see IETF RFC 6750).

        This endpoint works also with a basic authentication instead of a bearer one.

        Returns:
        The user entity corresponding to the token specified in the request.
      • getUsers

        @GET
        @Produces("application/json")
        public javax.ws.rs.core.Response getUsers​(@QueryParam("id")
                                                  Set<String> userIds,
                                                  @QueryParam("group")
                                                  List<String> groupIds,
                                                  @QueryParam("name")
                                                  String name,
                                                  @QueryParam("page")
                                                  String page,
                                                  @QueryParam("domain")
                                                  List<String> domainIds,
                                                  @QueryParam("accessLevel")
                                                  Set<UserAccessLevel> accessLevels,
                                                  @QueryParam("userStatesToExclude")
                                                  Set<UserState> userStatesToExclude,
                                                  @QueryParam("includeRemoved")
                                                  boolean includeRemovedUsers)
        Gets the users defined in Silverpeas and that matches the specified optional query parameters. If no query parameters are set, then all the users in Silverpeas are sent back.

        The users to sent back can be filtered by a pattern their name has to satisfy, by the group they must belong to, and by some pagination parameters.

        In the response is indicated as an HTTP header (named X-Silverpeas-UserSize) the real size of the users that matches the query. This is usefull for clients that use the pagination to filter the count of the answered users.

        Parameters:
        userIds - requested user identifiers
        groupIds - the identifier of the groups the users must belong to. The particular identifier "all" means all user groups.
        name - a pattern the name of the users has to satisfy. The wildcard * means anything string of characters.
        page - the pagination parameters formatted as "page number;item count in the page". From this parameter is computed the part of users to sent back: those between ((page number - 1) * item count in the page) and ((page number - 1) * item count in the page + item count in the page).
        domainIds - the identifier of the domains the users have to be related.
        accessLevels - filters the users by the access level in Silverpeas.
        userStatesToExclude - the user states that users taken into account must not be in.
        includeRemovedUsers - the removed users should be also sent back.
        Returns:
        the JSON serialization of the array with the user profiles that matches the query.
      • getUser

        @GET
        @Path("{userId}")
        @Produces("application/json")
        public UserProfileEntity getUser​(@PathParam("userId")
                                         String userId,
                                         @QueryParam("extended")
                                         boolean extended)
        Gets the profile on the user that is identified by the unique identifier refered by the URI. The unique identifier in the URI accepts also the specific term me to refers the current user of the session within which the request is received.
        Parameters:
        userId - the unique identifier of the user.
        extended - more user details (full details).
        Returns:
        the profile of the user in a JSON representation.
      • getApplicationUsers

        @GET
        @Path("application/{instanceId}")
        public javax.ws.rs.core.Response getApplicationUsers​(@PathParam("instanceId")
                                                             String instanceId,
                                                             @QueryParam("group")
                                                             String groupId,
                                                             @QueryParam("roles")
                                                             String roles,
                                                             @QueryParam("matchingAllRoles")
                                                             boolean matchingAllRoles,
                                                             @QueryParam("resource")
                                                             String resource,
                                                             @QueryParam("name")
                                                             String name,
                                                             @QueryParam("page")
                                                             String page,
                                                             @QueryParam("userStatesToExclude")
                                                             Set<UserState> userStatesToExclude,
                                                             @QueryParam("includeRemoved")
                                                             boolean includeRemovedUsers)
        Gets the profiles of the users that have access to the specified Silverpeas component instance and that matches the specified optional query parameters. If no query parameters are set, then all the users with the rights to access the component instance are sent back.

        The users to sent back can be filtered by a pattern their name has to satisfy, by the group they must belong to, and by some pagination parameters.

        In the response is indicated as an HTTP header (named X-Silverpeas-UserSize) the real size of the users that matches the query. This is usefull for clients that use the pagination to filter the count of the answered users.

        Parameters:
        instanceId - the unique identifier of the component instance the users should have access to.
        groupId - the unique identifier of the group the users must belong to. The particular identifier "all" means all user groups.
        roles - the name of the roles the users must play either for the component instance or for a given resource of the component instance.
        matchingAllRoles - boolean at true if the users must play all the roles, false otherwise.
        resource - the unique identifier of the resource in the component instance the users to get must have enough rights to access. This query filter is coupled with the roles one. If it is not set, by default the resource refered is the whole component instance. As for component instance identifier, a resource one is defined by its type followed by its identifier.
        name - a pattern the name of the users has to satisfy. The wildcard * means anything string of characters.
        page - the pagination parameters formatted as "page number;item count in the page". From this parameter is computed the part of users to sent back: those between ((page number - 1) * item count in the page) and ((page number - 1) * item count in the page + item count in the page).
        userStatesToExclude - the user states that users taken into account must not be in.
        includeRemovedUsers - the removed users should be also sent back.
        Returns:
        the JSON serialization of the array with the user profiles that can access the Silverpeas component and that matches the query.
      • getUserContacts

        @GET
        @Path("{userId}/contacts")
        @Produces("application/json")
        public javax.ws.rs.core.Response getUserContacts​(@PathParam("userId")
                                                         String userId,
                                                         @QueryParam("instance")
                                                         String instanceId,
                                                         @QueryParam("roles")
                                                         String roles,
                                                         @QueryParam("matchingAllRoles")
                                                         boolean matchingAllRoles,
                                                         @QueryParam("resource")
                                                         String resource,
                                                         @QueryParam("name")
                                                         String name,
                                                         @QueryParam("page")
                                                         String page,
                                                         @QueryParam("domain")
                                                         String domain,
                                                         @QueryParam("userStatesToExclude")
                                                         Set<UserState> userStatesToExclude,
                                                         @QueryParam("includeRemoved")
                                                         boolean includeRemovedUsers)
        Gets the profile on the user that is identified by the unique identifier refered by the URI. The unique identifier in the URI accepts also the specific term me to refers the current user of the session within which the request is received.
        Parameters:
        userId - the unique identifier of the user or me to refers the current user at the origin of the request.
        instanceId - the unique identifier of the component instance the users should have access to.
        roles - the name of the roles the users must play either for the component instance or for a given resource of the component instance.
        matchingAllRoles - boolean at true if the users must play all the roles, false otherwise.
        resource - the unique identifier of the resource in the component instance the users to get must have enough rights to access. This query filter is coupled with the roles one. If it is not set, by default the resource refered is the whole component instance. As for component instance identifier, a resource one is defined by its type followed by its identifier.
        name - a pattern the name of the users has to satisfy. The wildcard * means anything string of characters.
        page - the pagination parameters formatted as "page number;item count in the page". From this parameter is computed the part of users to sent back: those between ((page number - 1) * item count in the page) and ((page number - 1) * item count in the page + item count in the page).
        domain - the unique identifier of the domain the users have to be related.
        userStatesToExclude - the user states that users taken into account must not be in.
        includeRemovedUsers - the removed users should be also sent back.
        Returns:
        the profile of the user in a JSON representation.
      • getComponentId

        public String getComponentId()
        Description copied from interface: SilverpeasWebResource
        Gets the identifier of the component instance to which the requested resource belongs to.
        Returns:
        the identifier of the Silverpeas component instance.
      • locatedAt

        protected static URI locatedAt​(URI uri)
      • identifiedBy

        protected static URI identifiedBy​(URI uri)