CRecordUserDbGetRoleRecord
Get a role description from the user database.
This message belongs to the Session Manager API.
The Session Manager is part of the NY_Session2PlugIn plugin.
{
"id": "d248bf83-ca34-456b-988d-04c3d7a8916a",
"name": "USER_DB_GET_ROLE_RECORD ",
"description": "Get a role.",
"slots": [
{
"key": "1",
"name": "ROLE_ID",
"direction": "REQUEST",
"mandatory": "true",
"type": "STRING",
"description": "The role id."
},
{
"key": "10",
"name": "ROLE_RECORD",
"direction": "ANSWER",
"mandatory": "false",
"type": "RECORD",
"description": "The role record."
}
]
}
Usage
Sending the request
You need the microservice ID of the session manager:
public static final IIdSESSION_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(final byte[] aToken,
@NotNull final String aRoleId) throws CException
{
final CEnvelope env = CEnvelope.forMicroService(SESSION_MICROSERVICE_ID );
env.setSessionToken(aToken);
final CRecord record = CRecordUserDbGetRoleRecord .create();
CRecordUserDbGetRoleRecord .setRoleId(record,
aRoleId);
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(CRecordUserDbGetRoleRecord .ID, this::asyncGetRoleRecord );
private booleanasyncGetRoleRecord (@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; }