Пример #1
0
        protected override void InternalValidate()
        {
            if (TargetUrl != null)
            {
                TargetUrl = TargetUrl.Trim();
                siteUri   = new Uri(TargetUrl, UriKind.Absolute);
                if (!Uri.UriSchemeHttps.Equals(siteUri.Scheme, StringComparison.OrdinalIgnoreCase) && !Uri.UriSchemeHttp.Equals(siteUri.Scheme, StringComparison.OrdinalIgnoreCase))
                {
                    throw new ArgumentException("The specified target URL is not valid.");
                }
            }
            string serverRelUrlFromFullUrl = Utilities.GetServerRelUrlFromFullUrl(TargetUrl);
            string siteRoot = null;

            if (this.HostHeaderWebApplication == null)
            {
                webApp   = new SPWebApplicationPipeBind(TargetUrl).Read(false);
                siteRoot = Utilities.FindSiteRoot(webApp.Prefixes, serverRelUrlFromFullUrl);
                if ((siteRoot == null) || !siteRoot.Equals(serverRelUrlFromFullUrl, StringComparison.OrdinalIgnoreCase))
                {
                    throw new SPCmdletException("A managed path for the site could not be found.");
                }
            }
            else
            {
                webApp = this.HostHeaderWebApplication.Read();
                useHostHeaderAsSiteName = true;
                SPWebService service = SPFarm.Local.Services.GetValue <SPWebService>();
                if (service == null)
                {
                    throw new InvalidOperationException("A default web service could not be found.");
                }
                siteRoot = Utilities.FindSiteRoot(service.HostHeaderPrefixes, serverRelUrlFromFullUrl);
                if ((siteRoot == null) || !siteRoot.Equals(serverRelUrlFromFullUrl, StringComparison.OrdinalIgnoreCase))
                {
                    throw new SPCmdletException("A managed path for the site could not be found.");
                }
            }
            if (this.ContentDatabase != null)
            {
                this.contentDb = this.ContentDatabase.Read();
                if (null == this.contentDb)
                {
                    throw new SPException("The specified content database could not be found.");
                }
            }
            if (this.QuotaTemplate != null)
            {
                quotaTemplate = this.QuotaTemplate.Read().Name;
            }
            if (this.SiteSubscription != null)
            {
                this.siteSubscription = this.SiteSubscription.Read();
                if (this.siteSubscription == null)
                {
                    base.WriteError(new ArgumentException("The provided site subscription object is invalid."), ErrorCategory.InvalidArgument, this);
                    base.SkipProcessCurrentRecord();
                }
            }
        }