private LocalizedString ProtectionErrorChecks(GDPRProcessOptions options, ContentItem item)
        {
            // Check other error conditions: if any is found, write down the corresponding message
            LocalizedString msg = null;

            // Content items without a GDPRPart cannot be configured for anonymization/erasure
            if (item.As <GDPRPart>() == null)
            {
                msg = T("The item has no configuration saved for {0}.", options.ActionString);
            }
            return(msg);
        }
        private LocalizedString GDPRErrorChecks(GDPRProcessOptions options, ContentItem item)
        {
            // Check other error conditions: if any is found, write down the corresponding message
            LocalizedString msg = null;

            // Content items without a GDPRPart cannot be configured for anonymization/erasure
            if (item.As <GDPRPart>() == null)
            {
                msg = T("The item has no configuration saved for {0}.", options.ActionString);
            }
            // Protected Items should not be anonymized/erased
            if (msg == null && item.As <GDPRPart>().IsProtected)
            {
                msg = T("The item is protected and cannot be {0}.", options.ActedString);
            }
            // The actions can only be called on ProfileItems
            if (msg == null && !item.As <GDPRPart>().TypePartDefinition.Settings.GetModel <GDPRPartTypeSettings>().IsProfileItemType)
            {
                msg = T("The item is not a Profile.");
            }
            return(msg);
        }
        private ActionResult GDPRProcess(GDPRProcessOptions options)
        {
            var unauthorizedMessage = T("Unauthorized to manage {0} of contents.", options.ActionString);

            if (!_authorizer.Authorize(options.Permission, unauthorizedMessage))
            {
                return(new HttpUnauthorizedResult());
            }

            var item = _contentManager.Get(options.Id, VersionOptions.Latest);

            if (item == null)
            {
                return(HttpNotFound());
            }

            // earlier we checked the generic permission, here we check for the specific items
            if (!_authorizer.Authorize(options.Permission, item, unauthorizedMessage))
            {
                return(new HttpUnauthorizedResult());
            }

            // Check other error conditions: if any is found, write down the corresponding message
            LocalizedString msg = options.ErrorChecks(options, item);

            if (msg == null)
            {
                options.Process(item);
            }
            else
            {
                _notifier.Error(msg);
                Logger.Debug(msg.Text);
            }

            return(this.RedirectLocal(options.ReturnUrl, () => RedirectToAction("Index")));
        }