private ISsrsObjectRewriter BuildReplacementRule(ReplacementRuleDef def) { var filter = PathFilter.ParseGlob(def.Filter) ?? PathFilter.MatchAll; switch (def.Target) { case "DataSet.DataSourceReference": return(new SsrsDataSetDataSourceReferenceRewriter(filter, def.Replacement)); default: throw new FormatException($"Unrecognised replacement target: {def.Target}"); } }
public IJob CreateJob() { if (String.IsNullOrWhiteSpace(SsrsUriString)) { throw new InvalidArgumentsException("No SSRS URI specified."); } if (!Uri.TryCreate(SsrsUriString, UriKind.Absolute, out _)) { throw new InvalidArgumentsException($"Not a valid absolute URI: {SsrsUriString}"); } var source = GetObjectSource(); if (!source.HasManifest && Site != null) { throw new InvalidArgumentsException("--site was specified but no manifest was found."); } if (!new SsrsObjectTypesParser().ValidateTypes(ObjectFilter.TypeFilter, out var invalidTypes)) { throw new InvalidArgumentsException($"Invalid object types: {invalidTypes}"); } var filter = new SsrsObjectFilter { ObjectTypes = new SsrsObjectTypesParser().GetTypeFilter(ObjectFilter.TypeFilter), Path = new PathFilterExpression( PathFilter.ParseGlob(ObjectFilter.IncludePaths) ?? PathFilter.MatchAll, PathFilter.ParseGlob(ObjectFilter.ExcludePaths) ), Site = Site }; var ssrsUri = new Uri(SsrsUriString, UriKind.Absolute); var service = ReportingServiceClientFactory.CreateFromShorthandUri(ssrsUri); var job = new ImportJob(service, source, filter) { Overwrite = Overwrite, BackupTarget = GetBackupTarget() }; foreach (var rule in RewriteRules) { var rewriter = new RewriteRuleParser().Parse(rule); job.Rewriters.Add(rewriter); } return(job); }
public IJob CreateJob() { var source = GetObjectSource(); if (!source.HasManifest && Site != null) { throw new InvalidArgumentsException("--site was specified but no manifest was found."); } if (!new SsrsObjectTypesParser().ValidateTypes(ObjectFilter.TypeFilter, out var invalidTypes)) { throw new InvalidArgumentsException($"Invalid object types: {invalidTypes}"); } var filter = new SsrsObjectFilter { ObjectTypes = new SsrsObjectTypesParser().GetTypeFilter(ObjectFilter.TypeFilter), Path = new PathFilterExpression( PathFilter.ParseGlob(ObjectFilter.IncludePaths) ?? PathFilter.MatchAll, PathFilter.ParseGlob(ObjectFilter.ExcludePaths) ), Site = Site }; return(new InspectJob(source, filter)); }
public void InvalidWildcardDoesNotParse(string pattern) { Assert.Throws <FormatException>(() => PathFilter.ParseGlob(pattern)); }
public void GetPrefixSegments(string pattern, string[] expectedPrefix) { var glob = PathFilter.ParseGlob(pattern); Assert.That(glob.PrefixSegments, Is.EqualTo(expectedPrefix)); }
public void DoesNotMatch(string pattern, string path) { var glob = PathFilter.ParseGlob(pattern); Assert.That(glob.Matches(path), Is.False); }
public void Matches(string pattern, string path) { var glob = PathFilter.ParseGlob(pattern); Assert.That(glob.Matches(path)); }
public void LeadingSlashIsAlwaysMatched(string pattern, string path) { var glob = PathFilter.ParseGlob(pattern); Assert.That(glob.Matches(path)); }