CRecordUserDbGetRightList
Fetch the list of oll known permissions from the user database.
This message belongs to the Session Manager API.
The Session Manager is part of the NY_Session2PlugIn plugin.
{
"id": "5950828d-2bac-40cb-aab7-84bfcd978f45",
"name": "USER_DB_GET_RIGHT_LIST",
"description": "Get a list of all rights.",
"slots": [
{
"key": "10",
"name": "RIGHTS",
"direction": "RESPONSE",
"presenceConstraint": "OPTIONAL",
"type": "RECORD_ARRAY",
"description": "The list of all known permissions."
}
]
}
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_GetListOfRights.
private void getRightList(final byte[] aToken) throws CException
{
final CEnvelope env = CEnvelope.forMicroService(SESSION_MICROSERVICE_ID);
env.setSessionToken(aToken);
final CRecord record = CRecordUserDbGetRightList.create();
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(CRecordUserDbGetRightList.ID,
this::asyncGetRightList);
private boolean asyncGetRightList(@NotNull final CEnvelope aEnvelope,
@NotNull final CRecord aRecord)
{
if (aEnvelope.isAnswer())
{
final int resultCode = aEnvelope.getResultCode();
if (resultCode == CResultCode.SUCCESS)
{
final CRecord[] rightRecords = CRecordUserDbGetRightList.getRights(aRecord,
null);
if (rightRecords != null)
{
for (final CRecord rightRecord : rightRecords)
{
final CRight right = CRight.fromRecord(rightRecord);
...
}
}
// ...
}
return true;
}
return false;
}