Posted Nov 04 by Peng Qiu.
Updated Nov 04.

This article shows a series of JSON message samples to instruct how we can get, add or remove members for a group.

Last activity Nov 04 by Peng Qiu.
175 views. 0 comments.

Overview

There are 2 kinds of members for a group. One is user members and the other is sub group members. We can get these 2 kinds of members separately under a group resource.

For more detail about group resource CRUD, please check Tutorial : Manage Users and Groups in Documentum REST Services.

Get Group members

Assumed that you get a group resource.

GET http://localhost:8080/dctm-rest/repositories/repo/groups/demo-group
Accept: application/json

From the response, we'll find link relation http://identifiers.emc.com/linkrel/users and http://identifiers.emc.com/linkrel/groups, which point to the resources of user members and sub group members, respectively.

{
    "name": "group",
    "type": "dm_group",
    "definition": "http://localhost:8080/dctm-rest/repositories/repo/types/dm_group",
    "properties": {
        "group_name": "demo-group",
        ...
    },
    "links": [
        ...
        {
            "rel": "http://identifiers.emc.com/linkrel/groups",
            "href": "http://localhost:8080/dctm-rest/repositories/repo/groups/demo-group/groups"
        },
        {
            "rel": "http://identifiers.emc.com/linkrel/users",
            "href": "http://localhost:8080/dctm-rest/repositories/repo/groups/demo-group/users"
        }
    ]
}

Please get user members by the href of link relation http://identifiers.emc.com/linkrel/users.

GET http://localhost:8080/dctm-rest/repositories/repo/groups/demo-group/users
Accept: application/json

The user members is returned in the response as a feed.

{
    "id": "http://localhost:8080/dctm-rest/repositories/repo/groups/demo-group/users",
    "title": "Member users of group demo-group",
    ...
    "entries": [
        {
            "id": "http://localhost:8080/dctm-rest/repositories/repo/users/demo-user",
            "title": "demo-user",
            "summary": "",
            "updated": "2018-10-30T12:57:12.000+00:00",
            "published": "2018-10-30T12:57:12.000+00:00",
            "links": [
                {
                    "rel": "edit",
                    "href": "http://localhost:8080/dctm-rest/repositories/repo/users/demo-user"
                },
                ...
            ],
            ...
        }
    ]
}

Please get sub groups by the href of link relation http://identifiers.emc.com/linkrel/groups.

GET http://localhost:8080/dctm-rest/repositories/repo/groups/admingroup/groups
Accept: application/json

The sub groups is returned in the response as a feed.

{
    "id": "http://localhost:8080/dctm-rest/repositories/repo/groups/admingroup/groups",
    "title": "Member groups of group admingroup",
    ...
    "entries": [
        {
            "id": "http://localhost:8080/dctm-rest/repositories/repo/groups/demo-group",
            "title": "demo-group",
            ...
        }
    ]
}

By default, the user members resource only returns the direct user members of a group. If we need to get all users in this group, including the direct user members and the user members under sub groups, we can apply the parameter recursive on the user members resource to get all user members. The result of all user members in the feed representation is flatten.

GET http://localhost:8080/dctm-rest/repositories/repo/groups/demo-group/users?recursive=true
Accept: application/json

Add a User Member

In user members resource, we can add a user by making a POST request to the user members resource URI. The request body should be a resource URI of the user resource to add.

POST http://localhost:8080/dctm-rest/repositories/repo/groups/demo-group/users
Content-Type: application/json

{“href”: “http://localhost:8080/dctm-rest/repositories/repo/users/demo-user”}

The response adds this user to the target group. It returns status 201 with an empty response body. But we can find the link of the new membership in the response header Location.

HTTP 201 Created
Location: http://localhost:8080/dctm-rest/repositories/repo/groups/demo-group/users/demo-user

Add a Sub Group

In sub groups resource, we can add a sub group by making a POST request to the URI of sub groups resource. The request body should be the resource URI of the group to add.

POST http://localhost:8080/dctm-rest/repositories/repo/groups/admingroup/groups
Content-Type: application/json

{“href”: “http://localhost:8080/dctm-rest/repositories/repo/groups/demo-group”}

The response adds this group to the target group. It returns status 201 with an empty response body. But we can find the link of the new membership in header Location.

HTTP 201 Created
Location: http://localhost:8080/dctm-rest/repositories/repo/groups/admingroup/groups/demo-group

Remove a User Member

Group members resource representation uses the link relation http://identifiers.emc.com/linkrel/delete to indicate whether accessor has the permission to remove a specific member user or member group. On each member entry, If the accessor sees the entry link relation, it means that the accessor can remove this member from the group.

{
    "id": "http://localhost:8080/dctm-rest/repositories/repo/groups/demo-group/users",
    "title": "Member users of group demo-group",
    ...
    "entries": [
        {
            "id": "http://localhost:8080/dctm-rest/repositories/repo/users/demo-user",
            "title": "demo-user",
            ...
            "links": [
                ...
                {
                    "rel": "http://identifiers.emc.com/linkrel/delete",
                    "href": "http://localhost:8080/dctm-rest/repositories/repo/groups/demo-group/users/demo-user"
                }
            ],
            ...
        }
    ]
}

Now you can make a DELETE request on the href of this link relation to remove this member.

DELETE http://localhost:8080/dctm-rest/repositories/repo/groups/demo-group/users/demo-user
Accept: application/json

The response returns 204 if the delete is successful.

Remove a Sub Group

It's similar to removing a user member, if we are going to remove a sub group.

  • In sub groups resource, please find the atom entry for a specific sub group.
  • Please check the appearance of the link relation http://identifiers.emc.com/linkrel/delete.
  • If we can find this link relation, the accessor can remove the sub group by making a DELETE request to
    the link relation's href.
  • If we do not find this link relation, the accessor does not have the permission to remove this group.

Table of Contents

Your comment

To leave a comment, please sign in.