CRecordUserDbUpdateUserRecord

This message is used to modify a user database record. The real name as well as the email address can be changed.

This message belongs to the session manager API.

{
  "id": "342cea5a-bd26-47a6-9925-8fb51dabe66a",
  "name": "USER_DB_UPDATE_USER_RECORD",
  "description": "Update user data.",
  "slots": [
    {
      "key": "SessionToken",
      "name": "SESSION_TOKEN",
      "direction": "REQUEST",
      "mandatory": "true",
      "type": "UUID",
      "description": "The session token."
    },
    {
      "key": "userId",
      "name": "USER_ID",
      "direction": "REQUEST",
      "mandatory": "true",
      "type": "STRING",
      "description": "The user id."
    },
    {
      "key": "realName",
      "name": "REAL_NAME",
      "direction": "REQUEST",
      "mandatory": "true",
      "type": "STRING",
      "description": "The real name of the user."
    },
    {
      "key": "email",
      "name": "EMAIL",
      "direction": "REQUEST",
      "mandatory": "true",
      "type": "STRING",
      "description": "The email of the user."
    }
  ]
}

Example of use of the class CRecordUserDbUpdateUserRecord (after generating)

You need the microservice ID of the session manager:

public static final IId SESSION_MICROSERVICE_ID = CIdFactory.fromObject("ccf168c1-f18b-4229-85f9-24461a19ee6a");

The UserId is needed to identify the record to be modified. The own SessionToken is needed to verify the authorization for the change. You need the permission NY_UpdateUser. Additionally, the changed data (real name, email) will be saved.

private void updateUserRecord(@NotNull final UUID aToken,
                              @NotNull final String aUserId,
                              @NotNull final String aRealName,
                              @NotNull final String aEmail) throws CException
{
    final CEnvelope env = CEnvelope.forMicroService(SESSION_MICROSERVICE_ID);

    final CRecord record = CRecordUserDbUpdateUserRecord.create();
    CRecordUserDbUpdateUserRecord.setSessionToken(record,
                                                  aToken);
    CRecordUserDbUpdateUserRecord.setUserId(record,
                                            aUserId);
    CRecordUserDbUpdateUserRecord.setRealName(record,
                                              aRealName);
    CRecordUserDbUpdateUserRecord.setEmail(record,
                                           aEmail);
    sendRequest(env,
                record);
}

To catch the response of the request, we need a message handler. We add it in the constructor of the message handler registry.

// constructor:
addMessageHandler(CRecordUserDbUpdateUserRecord.ID,
                  this::asyncUpdateUserRecord);
private boolean asyncUpdateUserRecord(@NotNull final CEnvelope aEnvelope,
                                      @NotNull final CRecord aRecord)
{
    if (aEnvelope.isAnswer())
    {
        final int resultCode = aEnvelope.getResultCode();
        if (resultCode == CResultCode.SUCCESS)
        {
            // ...
        }
        return true;
    }
    return false;
}

nyssr.net - Innovative Distributed System