Cancel deletes

Vote:
 

Hi,

we have a requirement to stop editors from deleting catalog entries.  I can't see a way of setting the access rights in the catalog.

I've tried cancelling the action in the deleting content event but it throws an exception.

private void DeletingContent(object sender, DeleteContentEventArgs e)
{
var content = baseDependencies.ContentRepository.Get(e.ContentLink);

if (!(content is EntryContentBase))
return;

e.CancelAction = true;
e.CancelReason = "Game products or variants can't be deleted";
}



I assume the exception is because its a CMS event. I've looked in the CatalogEventBroadcaster but no luck.

The exception is:

EPiServer.Core.EPiServerCancelException: Game products or variants can't be deleted
at EPiServer.Core.DefaultContentEvents.RaiseCancellableDeleteEvent(String key, String defaultReason, DeleteContentEventArgs eventArgs)
at EPiServer.Core.DefaultContentRepository.Delete(ContentReference contentLink, Boolean forceDelete, AccessLevel access)
at EPiServer.Commerce.Shell.Controllers.DeleteController.Delete(IEnumerable`1 contentReferences)
at lambda_method(Closure , ControllerBase , Object[] )
at System.Web.Mvc.ReflectedActionDescriptor.Execute(ControllerContext controllerContext, IDictionary`2 parameters)
at System.Web.Mvc.ControllerActionInvoker.InvokeActionMethod(ControllerContext controllerContext, ActionDescriptor actionDescriptor, IDictionary`2 parameters)
at System.Web.Mvc.ControllerActionInvoker.<>c__DisplayClass13.b__10()
at System.Web.Mvc.ControllerActionInvoker.InvokeActionMethodFilter(IActionFilter filter, ActionExecutingContext preContext, Func`1 continuation)
at System.Web.Mvc.ControllerActionInvoker.InvokeActionMethodFilter(IActionFilter filter, ActionExecutingContext preContext, Func`1 continuation)
at System.Web.Mvc.ControllerActionInvoker.InvokeAction(ControllerContext controllerContext, String actionName)
at System.Web.Mvc.Controller.ExecuteCore()
at System.Web.Mvc.ControllerBase.Execute(RequestContext requestContext)
at EPiServer.Shell.Web.Mvc.ModuleMvcHandler.ProcessController(IController controller)
at EPiServer.Shell.Web.Mvc.ModuleMvcHandler.BeginProcessRequest(HttpContextBase httpContext, AsyncCallback callback, Object state)
at System.Web.HttpApplication.CallHandlerExecutionStep.System.Web.HttpApplication.IExecutionStep.Execute()
at System.Web.HttpApplication.ExecuteStep(IExecutionStep step, Boolean& completedSynchronously)

Thanks 

#145805
Mar 12, 2016 11:38
Vote:
 

Hi,

Catalog content does not support setting access rights (yet). It has only all-or-nothing setting, a contact might have all the access to the catalog, or nothing at all.

And the problem you saw was because Catalog UI does not handle the exception from server.

Saying, I don't really have a solution for you - not an easy one. Sorry. You might contact our expert services for help.

Regards,

/Q

#145848
Mar 14, 2016 11:49
Vote:
 

A little hack can work,

Create a DeleteGroup and assign this group to users those required delete access including admins.

While deleting You can check the logged in user is part of DeleteGroup or not

/K

#145869
Mar 14, 2016 15:59
Vote:
 

Thanks for your replies.  I think the editors for now just needs to be careful not to delete anything in the catalog

#145871
Mar 14, 2016 16:10
* You are NOT allowed to include any hyperlinks in the post because your account hasn't associated to your company. User profile should be updated.