CRecordUserDbDeleteRight
Delete a permission.
This message belongs to the session manager API.
{ "id": "0f385743-10f3-4383-90c3-0df4c10c8af8", "name": "USER_DB_DELETE_RIGHT", "description": "Delete right permanently.", "slots": [ { "key": "SessionToken", "name": "SESSION_TOKEN", "direction": "REQUEST", "mandatory": "true", "type": "UUID", "description": "The session token." }, { "key": "right", "name": "RIGHT", "direction": "REQUEST", "mandatory": "true", "type": "STRING", "description": "The right to delete." } ] }
Example of use of the class CRecordUserDbDeleteRight (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 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(@NotNull final UUID aToken, @NotNull final String aRight) throws CException { final CEnvelope env = CEnvelope.forMicroService(SESSION_MICROSERVICE_ID); final CRecord record = CRecordUserDbDeleteRight.create(); CRecordUserDbDeleteRight.setSessionToken(record, aToken); CRecordUserDbDeleteRight.setRight(record, aRight); 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(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; }