CRecordUserDbDeleteUser
This message is used to delete a user entry in the user database.
This message belongs to the Session Manager API.
The Session Manager is part of the NY_Session2PlugIn plugin.
{
"id": "15ecca8a-8b1e-41f3-9b6b-a41230c8bd1d",
"name": "USER_DB_DELETE_USER",
"description": "Delete a user.",
"slots": [
{
"key": "1",
"name": "USER_ID",
"direction": "REQUEST",
"presenceConstraint": "MANDATORY",
"type": "STRING",
"description": "The user id."
}
]
}
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_DeleteUser. In addition, the user ID is required.
private void deleteUser(final byte[] aToken,
@NotNull final String aUserId) throws CException
{
final CEnvelope env = CEnvelope.forMicroService(SESSION_MICROSERVICE_ID);
env.setSessionToken(aToken);
final CRecord record = CRecordUserDbDeleteUser.create();
CRecordUserDbDeleteUser.setUserId(record,
aUserId);
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(CRecordUserDbDeleteUser.ID,
this::asyncDeleteUser);
private boolean asyncDeleteUser(@NotNull final CEnvelope aEnvelope,
@NotNull final CRecord aRecord)
{
if (aEnvelope.isAnswer())
{
final int resultCode = aEnvelope.getResultCode();
if (resultCode == CResultCode.SUCCESS)
{
// ...
}
return true;
}
return false;
}