protected virtual FilterResult ExcludeMatches(IncludeEntry entry, string itemPath, ID itemId, ID templateId, string templateName) { FilterResult result = ExcludeMatchesPath(entry.Exclude, itemPath); if (!result.IsIncluded) { return(result); } result = ExcludeMatchesTemplateId(entry.Exclude, templateId); if (!result.IsIncluded) { return(result); } result = ExcludeMatchesTemplate(entry.Exclude, templateName); if (!result.IsIncluded) { return(result); } result = ExcludeMatchesId(entry.Exclude, itemId); return(result); }
/// <summary> /// Checks if a preset includes a given item /// </summary> public static bool Includes(this IncludeEntry entry, Item item) { // check for db match if (item.Database.Name != entry.Database) { return(false); } // check for path match if (!item.Paths.Path.StartsWith(entry.Path, StringComparison.OrdinalIgnoreCase)) { return(false); } // check excluded paths (*our* path exclusions are case-insensitive, whereas Sitecore's are case-sensitive - this can result in unexpected deletions) if (entry.Exclude.Any(x => x.Type == "path" && item.Paths.FullPath.StartsWith(x.Value, StringComparison.OrdinalIgnoreCase))) { return(false); } // check excludes if (entry.Exclude.Any(exclude => exclude.Matches(item))) { return(false); } // we passed all the checks - we're included by the current rule return(true); }
protected virtual PredicateResult ExcludeMatches(IncludeEntry entry, ISourceItem item) { PredicateResult result = ExcludeMatchesTemplate(entry.Exclude, item.TemplateName); if (!result.IsIncluded) { return(result); } result = ExcludeMatchesTemplateId(entry.Exclude, item.TemplateId); if (!result.IsIncluded) { return(result); } result = ExcludeMatchesPath(entry.Exclude, item.ItemPath); if (!result.IsIncluded) { return(result); } result = ExcludeMatchesId(entry.Exclude, item.Id); return(result); }
private string GetExcludeDescription(IncludeEntry entry) { if (entry.Exclude.Count == 0) { return(string.Empty); } return(string.Format(" (except {0})", string.Join(", ", entry.Exclude.Select(x => x.Type + ":" + x.Value)))); }
/// <summary> /// Checks if a preset includes a given serialized item /// </summary> protected FilterResult Includes(IncludeEntry entry, SyncItem item) { // check for db match if (item.DatabaseName != entry.Database) return new FilterResult(false); // check for path match if (!item.ItemPath.StartsWith(entry.Path, StringComparison.OrdinalIgnoreCase)) return new FilterResult(false); // check excludes return ExcludeMatches(entry, item.ItemPath, ID.Parse(item.ID), ID.Parse(item.TemplateID), item.TemplateName); }
/// <summary> /// Checks if a preset includes a given item /// </summary> /// <param name="entry">The entry.</param> /// <param name="item">The item.</param> /// <returns>Whether item is included</returns> protected virtual bool Includes(IncludeEntry entry, Item item) { // check for db match if (item.Database.Name != entry.Database) { return(false); } // check for path match if (!item.Paths.FullPath.StartsWith(entry.Path, StringComparison.OrdinalIgnoreCase)) { return(false); } // check excludes return(this.ExcludeMatches(entry, item)); }
/// <summary> /// Checks if a preset includes a given serialized item /// </summary> protected FilterResult Includes(IncludeEntry entry, SyncItem item) { // check for db match if (item.DatabaseName != entry.Database) { return(new FilterResult(false)); } // check for path match if (!item.ItemPath.StartsWith(entry.Path, StringComparison.OrdinalIgnoreCase)) { return(new FilterResult(false)); } // check excludes return(ExcludeMatches(entry, item.ItemPath, ID.Parse(item.ID), ID.Parse(item.TemplateID), item.TemplateName)); }
/// <summary> /// Checks if a preset includes a given set of criteria /// </summary> protected FilterResult Includes(IncludeEntry entry, string itemPath, ID itemId, ID templateId, string templateName, Database database) { // check for db match if (database.Name != entry.Database) { return(new FilterResult(false)); } // check for path match if (!itemPath.StartsWith(entry.Path, StringComparison.OrdinalIgnoreCase)) { return(new FilterResult(false)); } // check excludes return(ExcludeMatches(entry, itemPath, itemId, templateId, templateName)); }
/// <summary> /// Checks if a preset includes a given serialized item /// </summary> protected PredicateResult Includes(IncludeEntry entry, ISerializedReference item) { // check for db match if (item.DatabaseName != entry.Database) { return(new PredicateResult(false)); } // check for path match if (!item.ItemPath.StartsWith(entry.Path, StringComparison.OrdinalIgnoreCase)) { return(new PredicateResult(false)); } // check excludes return(ExcludeMatches(entry, item)); }
private static void ProcessPreset(IncludeEntry preset, IProgressStatus progress) { try { using (new SecurityDisabler()) { new SerializationLoader().LoadTree( new AdvancedLoadOptions(preset) { Progress = progress, ForceUpdate = false, DeleteOrphans = true }); } } catch (Exception ex) { if(Debugger.IsAttached) Debugger.Break(); progress.ReportException(ex); } }
private static IncludeEntry CreateIncludeEntry(XmlNode configuration) { var includeEntry = new IncludeEntry(); if (configuration.Attributes != null) { includeEntry.Database = configuration.Attributes["database"].Value; includeEntry.Path = configuration.Attributes["path"].Value; } foreach (XmlNode child in configuration.ChildNodes) { if (child.NodeType == XmlNodeType.Element && child.Name == "exclude") { includeEntry.Exclude.Add(CreateExcludeEntry(child)); } if (child.NodeType == XmlNodeType.Element && child.Name == "skip") { includeEntry.Skip.Add(CreateExcludeEntry(child)); } } return includeEntry; }
private static IncludeEntry CreateIncludeEntry(XmlNode configuration) { var includeEntry = new IncludeEntry(); if (configuration.Attributes != null) { includeEntry.Database = configuration.Attributes["database"].Value; includeEntry.Path = configuration.Attributes["path"].Value; } foreach (XmlNode child in configuration.ChildNodes) { if (child.NodeType == XmlNodeType.Element && child.Name == "exclude") { includeEntry.Exclude.Add(CreateExcludeEntry(child)); } if (child.NodeType == XmlNodeType.Element && child.Name == "skip") { includeEntry.Skip.Add(CreateExcludeEntry(child)); } } return(includeEntry); }
protected virtual PredicateResult ExcludeMatches(IncludeEntry entry, ISerializedReference reference) { PredicateResult result = ExcludeMatchesPath(entry.Exclude, reference.ItemPath); if (!result.IsIncluded) { return(result); } // many times the ISerializedReference may also have an item ref in it (e.g. be a serialized item) // in this case we can check additional criteria var item = reference as ISerializedItem; if (item == null) { return(result); } result = ExcludeMatchesTemplateId(entry.Exclude, ID.Parse(item.TemplateId)); if (!result.IsIncluded) { return(result); } result = ExcludeMatchesTemplate(entry.Exclude, item.TemplateName); if (!result.IsIncluded) { return(result); } result = ExcludeMatchesId(entry.Exclude, ID.Parse(item.Id)); return(result); }
private static void ProcessPreset(IncludeEntry preset, IProgressStatus progress) { try { using (new SecurityDisabler()) { new SerializationLoader().LoadTree( new AdvancedLoadOptions(preset) { Progress = progress, ForceUpdate = false, DeleteOrphans = true }); } } catch (Exception ex) { if (Debugger.IsAttached) { Debugger.Break(); } progress.ReportException(ex); } }
/// <summary> /// Checks if a preset excludes a given item /// </summary> /// <param name="entry">The entry.</param> /// <param name="item">The item.</param> /// <returns>Whether the item matches exclude rules</returns> protected virtual bool ExcludeMatches(IncludeEntry entry, Item item) { var result = this.ExcludeMatchesTemplate(entry.Exclude, item.TemplateName); if (!result) { return(false); } result = this.ExcludeMatchesTemplateId(entry.Exclude, item.TemplateID); if (!result) { return(false); } result = this.ExcludeMatchesPath(entry.Exclude, item.Paths.FullPath); if (!result) { return(false); } result = this.ExcludeMatchesId(entry.Exclude, item.ID); return(result); }
protected virtual FilterResult ExcludeMatches(IncludeEntry entry, string itemPath, ID itemId, ID templateId, string templateName) { FilterResult result = ExcludeMatchesPath(entry.Exclude, itemPath); if (!result.IsIncluded) return result; result = ExcludeMatchesTemplateId(entry.Exclude, templateId); if (!result.IsIncluded) return result; result = ExcludeMatchesTemplate(entry.Exclude, templateName); if (!result.IsIncluded) return result; result = ExcludeMatchesId(entry.Exclude, itemId); return result; }
/// <summary> /// Checks if a preset includes a given set of criteria /// </summary> protected FilterResult Includes(IncludeEntry entry, string itemPath, ID itemId, ID templateId, string templateName, Database database) { // check for db match if (database.Name != entry.Database) return new FilterResult(false); // check for path match if (!itemPath.StartsWith(entry.Path, StringComparison.OrdinalIgnoreCase)) return new FilterResult(false); // check excludes return ExcludeMatches(entry, itemPath, itemId, templateId, templateName); }
protected virtual PredicateResult ExcludeMatches(IncludeEntry entry, ISourceItem item) { PredicateResult result = ExcludeMatchesTemplate(entry.Exclude, item.TemplateName); if (!result.IsIncluded) return result; result = ExcludeMatchesTemplateId(entry.Exclude, item.TemplateId); if (!result.IsIncluded) return result; result = ExcludeMatchesPath(entry.Exclude, item.ItemPath); if (!result.IsIncluded) return result; result = ExcludeMatchesId(entry.Exclude, item.Id); return result; }
protected virtual PredicateResult ExcludeMatches(IncludeEntry entry, ISerializedReference reference) { PredicateResult result = ExcludeMatchesPath(entry.Exclude, reference.ItemPath); if (!result.IsIncluded) return result; // many times the ISerializedReference may also have an item ref in it (e.g. be a serialized item) // in this case we can check additional criteria var item = reference as ISerializedItem; if (item == null) return result; result = ExcludeMatchesTemplateId(entry.Exclude, ID.Parse(item.TemplateId)); if (!result.IsIncluded) return result; result = ExcludeMatchesTemplate(entry.Exclude, item.TemplateName); if (!result.IsIncluded) return result; result = ExcludeMatchesId(entry.Exclude, ID.Parse(item.Id)); return result; }
public void Deserialize(IncludeEntry entry) { var worker = new PresetWorker(entry); worker.Deserialize(GetLoadOptions()); }
/// <summary> /// Checks if a preset includes a given serialized item /// </summary> protected PredicateResult Includes(IncludeEntry entry, ISerializedReference item) { // check for db match if (item.DatabaseName != entry.Database) return new PredicateResult(false); // check for path match if (!item.ItemPath.StartsWith(entry.Path, StringComparison.OrdinalIgnoreCase)) return new PredicateResult(false); // check excludes return ExcludeMatches(entry, item); }
private string GetExcludeDescription(IncludeEntry entry) { if (entry.Exclude.Count == 0) return string.Empty; return string.Format(" (except {0})", string.Join(", ", entry.Exclude.Select(x => x.Type + ":" + x.Value))); }
public PresetWorker(IncludeEntry entry) { this.entry = entry; }
public AdvancedLoadOptions(IncludeEntry preset) { DeleteOrphans = false; Progress = new SitecoreLogProgressStatus(); Preset = preset; }
public AdvancedLoadOptions(IncludeEntry preset) { DeleteOrphans = false; Progress = new StringProgressStatus(); Preset = preset; }
public void Serialize(IncludeEntry entry) { var worker = new PresetWorker(entry); worker.Serialize(); }