RepositoryPermissionException Class

Assembly: CodeEffects.Rule.Repository.dll
Namespace: CodeEffects.Rule.Repository

Summary

The exception that Context.GetResponse(..) throws when the permissions of the current user do not allow what a request asks for.

Syntax

public class RepositoryPermissionException : CodeEffects.Rule.Repository.RepositoryException

Remarks

You never create this exception. The repository checks every request against the permissions that your repository configuration grants the current user, before it does any other work, and throws this exception when the request needs a permission that the user does not have. A few permissions can only be decided once the repository has read the record that the request names, such as whether a draft becomes a new rule or a new version of one, and the repository checks those at that point. It is not an error. The repository understood the request and refused it. Its control number is always CE10219.

The repository browser client turns off what the permissions do not allow, so a refusal usually means that a request was built some other way, that a page was left open while the role of the user changed, or that someone is trying to do what they may not. Refusals are worth logging for your audit.

Catch the exception before RepositoryException, log it as a warning, and return its ResponseJson property as the result of your endpoint. The response is a warning, not an error, in the language of your user interface. It carries the control number and the current permissions of the user, so that the client can turn off whatever it still showed as allowed. The Message of the exception is in English and names the permission that was refused. It is meant for your log. The user sees the text in ResponseJson, which does not name the permission.

A permission set that is not complete is not a refusal. It fails every request with a RepositoryException that carries the control number CE10218. See Context.ValidatePermissions(..).

Properties

  • Action

    Type: CodeEffects.Rule.Common.Models.ActionPermissionType

    Gets the permission that the request needed and that the current user does not have. The property is read-only.

Inherited Properties

  • ControlNumber

    Type: System.String

    Gets the support control number of this exception, which is CE10219.

  • ReindexResult

    Type: CodeEffects.Rule.Repository.ReindexResult

    Always null for this exception.

  • ResponseJson

    Type: System.String

    Gets the warning to return to the browser, with the current permissions of the user.

  • SyncResult

    Type: CodeEffects.Rule.Repository.SyncResult

    Always null for this exception.

Example

using CodeEffects.Rule.Repository;

try
{
	return Context.GetResponse(config, dbProvider, requestJson);
}
catch (RepositoryPermissionException ex)
{
	// A refusal: worth auditing, not an error.
	logger.LogWarning("Rule Repository refused {Action}: {Message}", ex.Action, ex.Message);
	return ex.ResponseJson;
}

Inheritance

Ask on Stack Overflow - Yes, it's still active
Ask in GitHub Discussions

p102

l097 --

l102

p101

×