private SharepointValidationResult GetValidationResult(Guid webId, Guid siteId, string contentClass, IDictionary <string, object> resultRow, ClientContext context) { SharepointSource sharepointSource = new SharepointSource(resultRow["Path"] as string, resultRow["Title"] as string, siteId, webId); SharepointValidationResult sharepointValidationResult = new SharepointValidationResult(); sharepointValidationResult.SharepointSource = sharepointSource; sharepointValidationResult.IsValid = true; if (contentClass == "STS_Site" && this.HasMultipleSitesUnderLocation(sharepointSource.SiteUrl, context)) { sharepointValidationResult.ValidationText = Strings.SpLocationHasMultipleSites(sharepointSource.SiteUrl); sharepointValidationResult.IsTopLevelSiteCollection = true; base.LogOneEntry(ExecutionLog.EventType.Warning, "Found top level site collection. {0}", new object[] { sharepointValidationResult.ValidationText }); } return(sharepointValidationResult); }
private SharepointValidationResult ValidateLocationByLoad(string location) { SharepointValidationResult validationResult = null; try { Uri uri = new Uri(location, UriKind.Absolute); if (this.spSiteContextUrl.IsBaseOf(uri)) { Utils.WrapSharePointCsomCall(uri, this.credentials, delegate(ClientContext context) { string siteUrl; string text; Guid siteId; Guid webId; SharepointValidator.CsomProvider.LoadWebInfo(context, out siteUrl, out text, out siteId, out webId); if (string.IsNullOrWhiteSpace(text)) { this.LogOneEntry(ExecutionLog.EventType.Error, "The site is invalid as it missing the title: {0}", new object[] { Strings.SpLocationValidationFailed(location) }); validationResult = SharepointValidator.CreateFailedResult(Strings.SpLocationValidationFailed(location)); return; } SharepointSource sharepointSource = new SharepointSource(siteUrl, text, siteId, webId); validationResult = new SharepointValidationResult { SharepointSource = sharepointSource, IsValid = true }; if (this.spSiteContextUrl.Equals(sharepointSource.SiteUrl)) { validationResult.IsTopLevelSiteCollection = true; validationResult.ValidationText = Strings.SpLocationHasMultipleSites(location); this.LogOneEntry(ExecutionLog.EventType.Warning, "Found top level site collection. {0}", new object[] { validationResult.ValidationText }); } }); } else { base.LogOneEntry(ExecutionLog.EventType.Error, "InvalidArgument: {0}, the url does not start with the tenant root url {1}", new object[] { Strings.SpLocationValidationFailed(location), this.spSiteContextUrl }); validationResult = SharepointValidator.CreateFailedResult(Strings.SpLocationValidationFailed(location)); } } catch (UriFormatException exception) { base.LogOneEntry(ExecutionLog.EventType.Error, exception, "InvalidArgument: {0}", new object[] { Strings.SpLocationValidationFailed(location) }); validationResult = SharepointValidator.CreateFailedResult(Strings.SpLocationValidationFailed(location)); } catch (SpCsomCallException ex) { if (!(ex.InnerException is WebException) && !(ex.InnerException is ClientRequestException)) { throw; } base.LogOneEntry(ExecutionLog.EventType.Error, ex, "InvalidArgument: {0}", new object[] { Strings.SpLocationValidationFailed(location) }); validationResult = SharepointValidator.CreateFailedResult(Strings.SpLocationValidationFailed(location)); } return(validationResult); }