CRecordUserDbGetRoleRecord
Get a role description from the user database.
This message belongs to the session manager API.
{ "id": "d248bf83-ca34-456b-988d-04c3d7a8916a", "name": "USER_DB_GET_ROLE_RECORD", "description": "Get a role.", "slots": [ { "key": "SessionToken", "name": "SESSION_TOKEN", "direction": "REQUEST", "mandatory": "true", "type": "UUID", "description": "The session token." }, { "key": "role", "name": "ROLE_ID", "direction": "REQUEST", "mandatory": "true", "type": "STRING", "description": "The role id." }, { "key": "record", "name": "ROLE_RECORD", "direction": "ANSWER", "mandatory": "false", "type": "RECORD", "description": "The role record." } ] }
Example of use of the class CRecordUserDbGetRoleRecord (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_GetRoleData
.
In addition, the role ID is required.
private void getRoleRecord(@NotNull final UUID aToken, @NotNull final String aRoleId) throws CException { final CEnvelope env = CEnvelope.forMicroService(SESSION_MICROSERVICE_ID); final CRecord record = CRecordUserDbGetRoleRecord.create(); CRecordUserDbGetRoleRecord.setSessionToken(record, aToken); CRecordUserDbGetRoleRecord.setRoleId(record, aRoleId); 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(CRecordUserDbGetRoleRecord.ID, this::asyncGetRoleRecord);
private boolean asyncGetRoleRecord(@NotNull final CEnvelope aEnvelope, @NotNull final CRecord aRecord) { if (aEnvelope.isAnswer()) { final int resultCode = aEnvelope.getResultCode(); if (resultCode == CResultCode.SUCCESS) { final String roleId1 = CRecordUserDbGetRoleRecord.getRoleId(aRecord, null); final CRecord roleRecord = CRecordUserDbGetRoleRecord.getRoleRecord(aRecord, null); if (roleRecord != null) { // same as roleId1 final String roleId2 = CRecordUserDbRoleRecord.getRoleId(roleRecord, null); final String description = CRecordUserDbRoleRecord.getDescription(roleRecord, null); final boolean isProtected = CRecordUserDbRoleRecord.getIsProtected(roleRecord, false); final String createdBy = CRecordUserDbRoleRecord.getCreatedBy(roleRecord, null); final LocalDateTime timeCreated = CRecordUserDbRoleRecord.getTimeCreated(roleRecord, null); // ... } // ... } return true; } return false; }