CRecordUserDbUpdateRoleRecord
This message saves changed data of a user role in the user database.
This message belongs to the Session Manager API.
The Session Manager is part of the NY_Session2PlugIn plugin.
{ "id": "5ee05db9-792e-4db7-b860-2f465cf520a0", "name": "USER_DB_UPDATE_ROLE_RECORD ", "description": "Update role data.", "slots": [ { "key": "1", "name": "ROLE_ID", "direction": "REQUEST", "mandatory": "true", "type": "STRING", "description": "The role id." }, { "key": "2", "name": "DESCRIPTION", "direction": "REQUEST", "mandatory": "true", "type": "STRING", "description": "The description of the role." } ] }
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");
To update a role record, we need the role ID.
Additionally, we need the session token of the current user to check the right to this request.
The executing user needs the NY_EditRole
permission.
private void updateRight(final byte[] aToken, @NotNull final String aRoleId, @NotNull final String aDescription) throws CException { final CEnvelope env = CEnvelope.forMicroService(SESSION_MICROSERVICE_ID ); env.setSessionToken(aToken); final CRecord record =CRecordUserDbUpdateRoleRecord .create();CRecordUserDbUpdateRoleRecord .setRoleId(record, aRoleId);CRecordUserDbUpdateRoleRecord .setDescription(record, aDescription); 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(CRecordUserDbUpdateRoleRecord .ID, this::asyncUpdateRoleRecord );
private booleanasyncUpdateRoleRecord (@NotNull final CEnvelope aEnvelope, @NotNull final CRecord aRecord) { if (aEnvelope.isAnswer()) { final int resultCode = aEnvelope.getResultCode(); if (resultCode == CResultCode.SUCCESS) { final String roleId =CRecordUserDbUpdateRoleRecord .getRoleId(aRecord, null); // ... } return true; } return false; }