class UserNamespaceAuthorizationServiceImpl implements UserNamespaceAuthorizationService {

    @PublishNotificationMessages
    @NamespacePermission(fields = "#key?.namespace", permissions = NamespacePermissionEnum.GRANT)
    @Override
    public UserNamespaceAuthorization deleteUserNamespaceAuthorization(UserNamespaceAuthorizationKey key)
    {
        // Validate and trim the key.
        validateUserNamespaceAuthorizationKey(key);

        // Retrieve and ensure that a user namespace authorization exists with the specified key.
        UserNamespaceAuthorizationEntity userNamespaceAuthorizationEntity = getUserNamespaceAuthorizationEntity(key);

        // Delete the business object definition.
        userNamespaceAuthorizationDao.delete(userNamespaceAuthorizationEntity);

        // Create a user namespace authorization change notification to be sent on delete user namespace authorization event.
        messageNotificationEventService.processUserNamespaceAuthorizationChangeNotificationEvent(key);

        // Create and return the user namespace authorization object from the deleted entity.
        return createUserNamespaceAuthorizationFromEntity(userNamespaceAuthorizationEntity);
    }

}