Beispiel #1
0
        /// <summary>
        /// Creates a new instance of the ModelNode adding site model provided.
        /// If RequireSelfProcessing set as 'true', then site model is going to be processed and pushed by SPMeta2 API.
        /// Use action to get access to the "site model node" and construct model tree.
        /// </summary>
        /// <param name="siteDefinition"></param>
        /// <param name="action"></param>
        /// <returns></returns>
        public static ModelNode NewSiteModel(SiteDefinition siteDefinition, Action<ModelNode> action)
        {
            var newModelNode = new ModelNode { Value = siteDefinition ?? new SiteDefinition { RequireSelfProcessing = false } };

            if (action != null)
                action(newModelNode);

            return newModelNode;
        }
Beispiel #2
0
        protected SPSite GetExistingSite(SPWebApplication webApp, SiteDefinition definition)
        {
            var siteCollectionUrl = SPUrlUtility.CombineUrl(definition.PrefixName, definition.Url);

            if (siteCollectionUrl.StartsWith("/"))
                siteCollectionUrl = siteCollectionUrl.Substring(1, siteCollectionUrl.Length - 1);

            if (webApp.Sites.Names.Contains(siteCollectionUrl))
                return webApp.Sites[siteCollectionUrl];

            return null;
        }
Beispiel #3
0
        private void DeploySiteModel(object modelHost, Microsoft.SharePoint.Client.Site site, SiteDefinition siteModel)
        {
            InvokeOnModelEvent(this, new ModelEventArgs
            {
                CurrentModelNode = null,
                Model = null,
                EventType = ModelEventType.OnProvisioning,
                Object = site,
                ObjectType = typeof(Site),
                ObjectDefinition = siteModel,
                ModelHost = modelHost
            });

            InvokeOnModelEvent(this, new ModelEventArgs
            {
                CurrentModelNode = null,
                Model = null,
                EventType = ModelEventType.OnProvisioned,
                Object = site,
                ObjectType = typeof(Site),
                ObjectDefinition = siteModel,
                ModelHost = modelHost
            });
        }
        private void DeploySite(WebApplicationModelHost webAppModelHost, Microsoft.SharePoint.Administration.SPWebApplication webApp, SiteDefinition siteModel)
        {
            var existingSite = GetExistingSite(webApp, siteModel);

            InvokeOnModelEvent(this, new ModelEventArgs
            {
                CurrentModelNode = null,
                Model = null,
                EventType = ModelEventType.OnProvisioning,
                Object = existingSite,
                ObjectType = typeof(SPSite),
                ObjectDefinition = siteModel,
                ModelHost = webAppModelHost
            });

            // while crating new site collection, a fall back for the secondlogin to mainowner
            // SecondaryContact setup is also checked on null and ignored is empty
            // https://github.com/SubPointSolutions/spmeta2/issues/835

            if (existingSite == null)
            {
                TraceService.Information((int)LogEventId.ModelProvisionProcessingNewObject, "Processing new site");

                var siteCollectionUrl = SPUrlUtility.CombineUrl(siteModel.PrefixName, siteModel.Url);
                siteCollectionUrl = siteCollectionUrl.TrimEnd('/');

                SPSite newSite = null;

                if (string.IsNullOrEmpty(siteModel.DatabaseName))
                {
                    newSite = webApp.Sites.Add(siteCollectionUrl,
                        siteModel.Name,
                        siteModel.Description ?? string.Empty,
                        siteModel.LCID,
                        siteModel.SiteTemplate,

                        siteModel.OwnerLogin,
                        siteModel.OwnerName,
                        siteModel.OwnerEmail,

                        siteModel.SecondaryContactLogin,
                        siteModel.SecondaryContactName,
                        siteModel.SecondaryContactEmail);
                }
                else
                {
                    // TODO, should be reimplemented later to handle more complicatd content DB provision
                    var dbServerName = webApp.ContentDatabases[0].Server;

                    newSite = webApp.Sites.Add(siteCollectionUrl,
                        siteModel.Name,
                        siteModel.Description,
                        siteModel.LCID,
                        siteModel.SiteTemplate,

                        siteModel.OwnerLogin,
                        siteModel.OwnerName,
                        siteModel.OwnerEmail,

                        siteModel.SecondaryContactLogin,
                        siteModel.SecondaryContactName,
                        siteModel.SecondaryContactEmail,

                        dbServerName,
                        siteModel.DatabaseName,

                        null,
                        null);
                }

                // weird issue with second admin, needs to be setup manually
                if (!string.IsNullOrEmpty(siteModel.SecondaryContactLogin))
                {
                    newSite.SecondaryContact = newSite.RootWeb.EnsureUser(siteModel.SecondaryContactLogin);
                }

                existingSite = GetExistingSite(webApp, siteModel);
            }
            else
            {
                TraceService.Information((int)LogEventId.ModelProvisionProcessingExistingObject, "Processing existing XXX");
            }

            InvokeOnModelEvent(this, new ModelEventArgs
            {
                CurrentModelNode = null,
                Model = null,
                EventType = ModelEventType.OnProvisioned,
                Object = existingSite,
                ObjectType = typeof(SPSite),
                ObjectDefinition = siteModel,
                ModelHost = webAppModelHost
            });
        }
Beispiel #5
0
 /// <summary>
 /// Creates a new instance of the ModelNode adding site model provided.
 /// If RequireSelfProcessing set as 'true', then site model is going to be processed and pushed by SPMeta2 API.
 /// </summary>
 /// <param name="siteDefinition"></param>
 /// <returns></returns>
 public static ModelNode NewSiteModel(SiteDefinition siteDefinition)
 {
     return NewSiteModel(siteDefinition, null);
 }
Beispiel #6
0
        /// <summary>
        /// Creates a new instance of the ModelNode adding "empty site model".
        /// Site model is not going to be pushes by SPMeta2 API, it just required to be there for model tree processing.
        /// Use action to get access to the "site model node" and construct model tree.
        /// </summary>
        /// <param name="action"></param>
        /// <returns></returns>
        public static ModelNode NewSiteModel(Action<ModelNode> action)
        {
            var definition = new SiteDefinition { RequireSelfProcessing = false };

            return NewSiteModel(definition, action);
        }
Beispiel #7
0
        private void DeploySite(WebApplicationModelHost webAppModelHost, Microsoft.SharePoint.Administration.SPWebApplication webApp, SiteDefinition siteModel)
        {
            var existingSite = GetExistingSite(webApp, siteModel);

            InvokeOnModelEvent(this, new ModelEventArgs
            {
                CurrentModelNode = null,
                Model = null,
                EventType = ModelEventType.OnProvisioning,
                Object = existingSite,
                ObjectType = typeof(SPSite),
                ObjectDefinition = siteModel,
                ModelHost = webAppModelHost
            });

            if (existingSite == null)
            {
                TraceService.Information((int)LogEventId.ModelProvisionProcessingNewObject, "Processing new site");

                var siteCollectionUrl = SPUrlUtility.CombineUrl(siteModel.PrefixName, siteModel.Url);

                if (string.IsNullOrEmpty(siteModel.DatabaseName))
                {
                    var newSite = webApp.Sites.Add(siteCollectionUrl,
                        siteModel.Name,
                        siteModel.Description,
                        siteModel.LCID,
                        siteModel.SiteTemplate,

                        siteModel.OwnerLogin,
                        siteModel.OwnerName,
                        siteModel.OwnerEmail,

                        siteModel.SecondaryContactLogin,
                        siteModel.SecondaryContactName,
                        siteModel.SecondaryContactEmail);

                    // weird issue with second admin, needs to be setup manually
                    newSite.SecondaryContact = newSite.RootWeb.EnsureUser(siteModel.SecondaryContactLogin);
                }
                else
                {
                    // TODO, should be reimplemented later.
                    var dbServerName = webApp.ContentDatabases[0].Server;

                    var newSite = webApp.Sites.Add(siteCollectionUrl,
                        siteModel.Name,
                        siteModel.Description,
                        siteModel.LCID,
                        siteModel.SiteTemplate,

                        siteModel.OwnerLogin,
                        siteModel.OwnerName,
                        siteModel.OwnerEmail,

                        siteModel.SecondaryContactLogin,
                        siteModel.SecondaryContactName,
                        siteModel.SecondaryContactEmail,

                        dbServerName,
                        siteModel.DatabaseName,
                        null,
                        null);

                    // weird issue with second admin, needs to be setup manually
                    newSite.SecondaryContact = newSite.RootWeb.EnsureUser(siteModel.SecondaryContactLogin);
                }

                existingSite = GetExistingSite(webApp, siteModel);
            }
            else
            {
                TraceService.Information((int)LogEventId.ModelProvisionProcessingExistingObject, "Processing existing XXX");
            }

            InvokeOnModelEvent(this, new ModelEventArgs
            {
                CurrentModelNode = null,
                Model = null,
                EventType = ModelEventType.OnProvisioned,
                Object = existingSite,
                ObjectType = typeof(SPSite),
                ObjectDefinition = siteModel,
                ModelHost = webAppModelHost
            });


        }
 public static ModelNode AddHostSite(this ModelNode model, SiteDefinition definition, Action<ModelNode> action)
 {
     return model.AddDefinitionNodeWithOptions(definition, action, ModelNodeOptions.New().NoSelfProcessing());
 }
 public static ModelNode AddHostSite(this ModelNode model, SiteDefinition definition)
 {
     return AddHostSite(model, definition, null);
 }
Beispiel #10
0
 public static ModelNode AddSite(this ModelNode model, SiteDefinition definition, Action<ModelNode> action)
 {
     return model.AddDefinitionNode(definition, action);
 }