void IContentGDPRFilter.Erasing(EraseContentContext context)
 {
     if (context.ContentItem.Is <GDPRPart>() && context.ContentItem.Is <TPart>())
     {
         Erasing(context, context.ContentItem.As <TPart>());
     }
 }
 protected override void Erased(EraseContentContext context, TPart instance)
 {
     if (OnErased != null)
     {
         OnErased(context, instance);
     }
 }
 void IContentGDPRHandler.Erased(EraseContentContext context)
 {
     foreach (var filter in Filters.OfType <IContentGDPRFilter>())
     {
         filter.Erased(context);
     }
     Erased(context);
 }
Ejemplo n.º 4
0
 protected override void Erasing(EraseContentContext 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.ErasurePropertyValuePairs));
             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.ErasurePropertyValuePairs);
             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
                 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.ErasurePropertyValuePairs);
                 }
                 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.ErasurePropertyValuePairs);
                         }
                     };
                 }
                 foreach (var partVersion in partVersions)
                 {
                     partVersionAction(partVersion);
                     fieldVersionAction(partVersion);
                 }
             }
         }
     }
 }
 protected override void Erased(EraseContentContext 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("ContentErased", context.ContentItem,
                                       () => new Dictionary <string, object> {
             { "Content", context.ContentItem },
             { "GDPRContentContext", context }
         });
     }
 }
Ejemplo n.º 6
0
 protected override void Erased(EraseContentContext context)
 {
     context.Outcome = GDPRProcessOutcome.Erased;
 }
Ejemplo n.º 7
0
 private void FieldsErasing(EraseContentContext context, GDPRPart part) {
     Processing(context, part, _contentGDPRManager.Erase);
 }
 protected virtual void Erased(EraseContentContext context, TPart instance)
 {
 }
 protected virtual void Erased(EraseContentContext context)
 {
 }