AnsweredAssumed Answered

REST API. Update of User/UserGr. not possible (5.11)

Question asked by udoderk on Mar 7, 2013
Latest reply on May 23, 2013 by augustus
Hi activiti core team:-)

Introduction
——————-
User Guide (currently 5.12) describes, that POST http method must be used to create an user or an user group. But i found such githubentry:
The user guide (5.9-5.12) lists the creation of user and groups going through the POST http method, however the code is written to use the PUT method.
i look at this classes
UserCreateResource.java

GroupCreateResource.java
Thay have actually "Put" Annotation.
User Guide has such text:
Create group
Creates a new group.
    Request: POST /group
    {
      "id": "admin",
      "name": "System administrator",
      "type": "security-role"
    }
    API: identityService.newGroup(); identityService.saveGroup();
——————-

Base Part
Currenlty is it not possible, to change, for instance, the user first or surename or name of the user group using REST API.
If i try to deploly the user group with same user group id, the exception will be thrown. The realisation.
    if (identityService.createGroupQuery().groupId(groupInfo.getId()).count() == 0) {
      Group group = identityService.newGroup(groupInfo.getId());
      group.setName(groupInfo.getName());
      if (groupInfo.getType() != null) {
        group.setType(groupInfo.getType());
      } else {
        group.setType("assignment");
      }
      identityService.saveGroup(group);
    } else {
      throw new ActivitiException("group id must be unique");
    }
    return new StateResponse().setSuccess(true);

IMHO, the exception is fully correctly according the semantic of a class with name, containing "Create" infix.

Are you planning to realize "update" operations for an user /an user group in REST API?
——————-

Conclusion, CRUD operations and REST

After googling, i found different reviews, related to mapping of http methods to CRUD operations using REST.
What understand activiti developers under  PUT / POST related to CRUD operations?

P.S The googling results:
1
CRUD    HTTP
Create    POST
Retrieve    GET
Update    PUT
Delete    DELETE

CRUD    HTTP
Create    PUT
Retrieve    GET
Update    PUT
Delete    DELETE
2
After that discussion, a more realistic mapping would seem to be:

    Create = PUT iff you are sending the full content of the specified resource (URL).
    Create = POST if you are sending a command to the server to create a subordinate of the specified resource, using some server-side algorithm.
    Retrieve = GET.
    Update = PUT iff you are updating the full content of the specified resource.
    Update = POST if you are requesting the server to update one or more subordinates of the specified resource.
    Delete = DELETE.

——————-

Outcomes