CRecordUserDbDeleteRight

This message deletes a user right in the user database.

This message belongs to the Session Manager API.
The Session Manager is part of the NY_Session2PlugIn plugin.

{
  "id": "0f385743-10f3-4383-90c3-0df4c10c8af8",
  "name": "USER_DB_DELETE_RIGHT",
  "description": "Delete right permanently.",
  "slots": [
    {
      "key": "1",
      "name": "RIGHT",
      "direction": "REQUEST",
      "mandatory": "true",
      "type": "STRING",
      "description": "The right to delete."
    }
  ]
}

Usage

Sending the request

You need the microservice ID of the session manager:

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

The own SessionToken is needed to verify the authorization for the change. You need the permission NY_DeleteRight. In addition, the right ID is required.

private void deleteRight(final byte[] aToken,
                         @NotNull final String aRight) throws CException
{
    final CEnvelope env = CEnvelope.forMicroService(SESSION_MICROSERVICE_ID);
    env.setSessionToken(aToken);

    final CRecord record = CRecordUserDbDeleteRight.create();
    CRecordUserDbDeleteRight.setRight(record,
                                      aRight);

    sendRequest(env,
                record);
}

Dealing with the response

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(CRecordUserDbDeleteRight.ID,
                  this::asyncDeleteRight);
private boolean asyncDeleteRight(@NotNull final CEnvelope aEnvelope,
                                 @NotNull final CRecord aRecord)
{
    if (aEnvelope.isAnswer())
    {
        final int resultCode = aEnvelope.getResultCode();
        if (resultCode == CResultCode.SUCCESS)
        {
            // ...
        }
        return true;
    }
    return false;
}