void IContentGDPRFilter.Anonymizing(AnonymizeContentContext context) { if (context.ContentItem.Is <GDPRPart>() && context.ContentItem.Is <TPart>()) { Anonymizing(context, context.ContentItem.As <TPart>()); } }
protected override void Anonymizing(AnonymizeContentContext context) { // this check is a trick to verify that the ContentItem has a GDPRPart and // that it is not protected or anything. if (context.ShouldProcess(context.GDPRPart)) { // go through every part in context.ContentItem foreach (var part in context.ContentItem.Parts) { // get the subset of all the part's fields that include those that need processing var fieldsToProcess = part.Fields.Where(fi => IsFieldToProcess(context, fi, set => set.AnonymizationPropertyValuePairs)); // we get the part's settings to check whether they areconfigured for reflection var partSettings = part.TypePartDefinition .Settings.GetModel <GDPRPartPartSettings>(); // Only do stuff if either the part should be processed and has a configuration for reflection, // or that is true for any of its fields. var IsPartToProcess = context.ShouldProcess(part) && ValidDictionary(partSettings.AnonymizationPropertyValuePairs); if (IsPartToProcess || fieldsToProcess.Any()) { // We will need this part's definition to look for it in previous versions of the // content item var partName = part.PartDefinition.Name; // we get all the versions of this part. We get this here before checking whether we // should process the part because we will need it if there are fields to process. var partVersions = context.AllVersions .Select(ci => ci.Parts.FirstOrDefault(pa => pa.PartDefinition.Name == partName)) .Where(pa => pa != null); var partVersionAction = new Action <ContentPart>(pv => { }); if (IsPartToProcess) { partVersionAction = pv => SetAllProperties(pv, partSettings.AnonymizationPropertyValuePairs); } var fieldVersionAction = new Action <ContentPart>((pv) => { }); if (fieldsToProcess.Any()) { fieldVersionAction = (pv) => { foreach (var field in fieldsToProcess) { // get the default setting for reflection (we verified it exists in IsFieldToProcess) var fieldSettings = field.PartFieldDefinition .Settings.GetModel <GDPRPartFieldSettings>(); //get the field var fieldVersion = pv.Fields .FirstOrDefault(fi => fi.Name == field.Name); // use reflection to set property values SetAllProperties(fieldVersion, fieldSettings.AnonymizationPropertyValuePairs); } }; } foreach (var partVersion in partVersions) { partVersionAction(partVersion); fieldVersionAction(partVersion); } } } } }
/* * In the methods below, the Actions should be called every time they exist, and the * checks on whether a part should actually be processed are left to the handlers. * This may seem weird, because for example at this stage we can already verify a lot * of information from the context: however, there are parts that should always be * processed, because they are designed to hold personal identifiable information. * We cannot know what those parts are beforehand, because we cannot go through all * of Orchard and mark each one in a clearly identifiable way. * */ protected override void Anonymizing(AnonymizeContentContext context, TPart instance) { if (OnAnonymizing != null) { OnAnonymizing(context, instance); } }
void IContentGDPRHandler.Anonymized(AnonymizeContentContext context) { foreach (var filter in Filters.OfType <IContentGDPRFilter>()) { filter.Anonymized(context); } Anonymized(context); }
protected override void Anonymized(AnonymizeContentContext context) { // this check returns true if the item has a GDPRPart. It should not be required // but it's there for safety if (context.ShouldProcess(context.GDPRPart)) { _workflowManager.TriggerEvent("ContentAnonymized", context.ContentItem, () => new Dictionary <string, object> { { "Content", context.ContentItem }, { "GDPRContentContext", context } }); } }
protected override void Anonymized(AnonymizeContentContext context) { context.Outcome = GDPRProcessOutcome.Anonymized; }
private void FieldsAnonymizing(AnonymizeContentContext context, GDPRPart part) { Processing(context, part, _contentGDPRManager.Anonymize); }
protected virtual void Anonymized(AnonymizeContentContext context, TPart instance) { }
protected virtual void Anonymized(AnonymizeContentContext context) { }