public override TokenParser ProvisionObjects(Web web, ProvisioningTemplate template, TokenParser parser, ProvisioningTemplateApplyingInformation applyingInformation) { using (var scope = new PnPMonitoredScope(this.Name)) { var systemPropertyBagEntriesExclusions = new List <string>(new[] { "_", "vti_", "dlc_", "ecm_", "profileschemaversion", "DesignPreview" }); // Check if this is not a noscript site as we're not allowed to write to the web property bag is that one bool isNoScriptSite = web.IsNoScriptSite(); if (isNoScriptSite) { return(parser); } // To handle situations where the propertybag is not updated fully when applying a theme, // we need to create a new context and use that one. Reloading the propertybag does not solve this. var newContext = web.Context.Clone(web.Context.Url); web = newContext.Web; foreach (var propbagEntry in template.PropertyBagEntries) { bool propExists = web.PropertyBagContainsKey(propbagEntry.Key); if (propbagEntry.Overwrite) { var systemProp = systemPropertyBagEntriesExclusions.Any(k => propbagEntry.Key.StartsWith(k, StringComparison.OrdinalIgnoreCase)); if (!systemProp || (systemProp && applyingInformation.OverwriteSystemPropertyBagValues)) { scope.LogDebug(CoreResources.Provisioning_ObjectHandlers_PropertyBagEntries_Overwriting_existing_propertybag_entry__0__with_value__1_, propbagEntry.Key, propbagEntry.Value); web.SetPropertyBagValue(propbagEntry.Key, parser.ParseString(propbagEntry.Value)); if (propbagEntry.Indexed) { web.AddIndexedPropertyBagKey(propbagEntry.Key); } } } else { if (!propExists) { scope.LogDebug(CoreResources.Provisioning_ObjectHandlers_PropertyBagEntries_Creating_new_propertybag_entry__0__with_value__1__2_, propbagEntry.Key, propbagEntry.Value, propbagEntry.Indexed ? ",Indexed = true" : ""); web.SetPropertyBagValue(propbagEntry.Key, parser.ParseString(propbagEntry.Value)); if (propbagEntry.Indexed) { web.AddIndexedPropertyBagKey(propbagEntry.Key); } } } } } return(parser); }
public override void ProvisionObjects(Web web, ProvisioningTemplate template, ProvisioningTemplateApplyingInformation applyingInformation) { Log.Info(Constants.LOGGING_SOURCE_FRAMEWORK_PROVISIONING, CoreResources.Provisioning_ObjectHandlers_PropertyBagEntries); var systemPropertyBagEntriesExclusions = new List <string>(new [] { "_", "vti_", "dlc_", "ecm_", "profileschemaversion", "DesignPreview" }); // To handle situations where the propertybag is not updated fully when applying a theme, // we need to create a new context and use that one. Reloading the propertybag does not solve this. var newContext = web.Context.Clone(web.Context.Url); web = newContext.Web; foreach (var propbagEntry in template.PropertyBagEntries) { bool propExists = web.PropertyBagContainsKey(propbagEntry.Key); if (propbagEntry.Overwrite) { var systemProp = systemPropertyBagEntriesExclusions.Any(k => propbagEntry.Key.StartsWith(k, StringComparison.OrdinalIgnoreCase)); if (!systemProp || (systemProp && applyingInformation.OverwriteSystemPropertyBagValues)) { web.SetPropertyBagValue(propbagEntry.Key, propbagEntry.Value.ToParsedString()); if (propbagEntry.Indexed) { web.AddIndexedPropertyBagKey(propbagEntry.Key); } } } else { if (!propExists) { web.SetPropertyBagValue(propbagEntry.Key, propbagEntry.Value.ToParsedString()); if (propbagEntry.Indexed) { web.AddIndexedPropertyBagKey(propbagEntry.Key); } } } } }
public override TokenParser ProvisionObjects(Web web, ProvisioningTemplate template, TokenParser parser, ProvisioningTemplateApplyingInformation applyingInformation) { using (var scope = new PnPMonitoredScope(this.Name)) { // Check if this is not a noscript site as we're not allowed to write to the web property bag is that one bool isNoScriptSite = web.IsNoScriptSite(); if (isNoScriptSite) { return(parser); } web.SetPropertyBagValue("_PnP_ProvisioningTemplateId", template.Id != null ? template.Id : ""); web.AddIndexedPropertyBagKey("_PnP_ProvisioningTemplateId"); ProvisioningTemplateInfo info = new ProvisioningTemplateInfo(); info.TemplateId = template.Id != null ? template.Id : ""; info.TemplateVersion = template.Version; info.TemplateSitePolicy = template.SitePolicy; info.Result = true; info.ProvisioningTime = DateTime.Now; string jsonInfo = JsonConvert.SerializeObject(info); web.SetPropertyBagValue("_PnP_ProvisioningTemplateInfo", jsonInfo); } return(parser); }
public override TokenParser ProvisionObjects(Web web, ProvisioningTemplate template, TokenParser parser, ProvisioningTemplateApplyingInformation applyingInformation) { using (var scope = new PnPMonitoredScope(this.Name)) { // Check if this is not a noscript site as we're not allowed to write to the web property bag is that one bool isNoScriptSite = web.IsNoScriptSite(); if (isNoScriptSite) { return parser; } web.SetPropertyBagValue("_PnP_ProvisioningTemplateId", template.Id != null ? template.Id : ""); web.AddIndexedPropertyBagKey("_PnP_ProvisioningTemplateId"); ProvisioningTemplateInfo info = new ProvisioningTemplateInfo(); info.TemplateId = template.Id != null ? template.Id : ""; info.TemplateVersion = template.Version; info.TemplateSitePolicy = template.SitePolicy; info.Result = true; info.ProvisioningTime = DateTime.Now; string jsonInfo = JsonConvert.SerializeObject(info); web.SetPropertyBagValue("_PnP_ProvisioningTemplateInfo", jsonInfo); } return parser; }
/// <summary> /// Actual implementation of the apply templates /// </summary> /// <param name="web"></param> /// <param name="template"></param> internal void ApplyRemoteTemplate(Web web, ProvisioningTemplate template) { // Site Security new ObjectSiteSecurity().ProvisionObjects(web, template); // Features new ObjectFeatures().ProvisionObjects(web, template); // Site Fields new ObjectField().ProvisionObjects(web, template); // Content Types new ObjectContentType().ProvisionObjects(web, template); // Lists new ObjectListInstance().ProvisionObjects(web, template); // Files new ObjectFiles().ProvisionObjects(web, template); // Custom actions new ObjectCustomActions().ProvisionObjects(web, template); // Composite look new ObjectComposedLook().ProvisionObjects(web, template); // Property Bag Entries new ObjectPropertyBagEntry().ProvisionObjects(web, template); // Extensibility Provider CallOut the last thing we do. new ObjectExtensibilityProviders().ProvisionObjects(web, template); web.SetPropertyBagValue("_PnP_ProvisioningTemplateId", template.ID != null ? template.ID : ""); web.AddIndexedPropertyBagKey("_PnP_ProvisioningTemplateId"); ProvisioningTemplateInfo info = new ProvisioningTemplateInfo(); info.TemplateID = template.ID != null ? template.ID : ""; info.TemplateVersion = template.Version; info.TemplateSitePolicy = template.SitePolicy; info.Result = true; info.ProvisioningTime = DateTime.Now; var s = new JavaScriptSerializer(); string jsonInfo = s.Serialize(info); web.SetPropertyBagValue("_PnP_ProvisioningTemplateInfo", jsonInfo); }
public override void ProvisionObjects(Web web, ProvisioningTemplate template) { web.SetPropertyBagValue("_PnP_ProvisioningTemplateId", template.Id != null ? template.Id : ""); web.AddIndexedPropertyBagKey("_PnP_ProvisioningTemplateId"); ProvisioningTemplateInfo info = new ProvisioningTemplateInfo(); info.TemplateId = template.Id != null ? template.Id : ""; info.TemplateVersion = template.Version; info.TemplateSitePolicy = template.SitePolicy; info.Result = true; info.ProvisioningTime = DateTime.Now; string jsonInfo = JsonConvert.SerializeObject(info); web.SetPropertyBagValue("_PnP_ProvisioningTemplateInfo", jsonInfo); }
public override void ProvisionObjects(Web web, ProvisioningTemplate template) { Log.Info(Constants.LOGGING_SOURCE_FRAMEWORK_PROVISIONING, CoreResources.Provisioning_ObjectHandlers_PropertyBagEntries); foreach (var propbagEntry in template.PropertyBagEntries) { if (!web.PropertyBagContainsKey(propbagEntry.Key)) { web.SetPropertyBagValue(propbagEntry.Key, propbagEntry.Value.ToParsedString()); if (propbagEntry.Indexed) { web.AddIndexedPropertyBagKey(propbagEntry.Key); } } } }
/// <summary> /// Actual implementation of the apply templates /// </summary> /// <param name="web"></param> /// <param name="template"></param> internal void ApplyRemoteTemplate(Web web, ProvisioningTemplate template) { // Site Security new ObjectSiteSecurity().ProvisionObjects(web, template); // Features new ObjectFeatures().ProvisionObjects(web, template); // Site Fields new ObjectField().ProvisionObjects(web, template); // Content Types new ObjectContentType().ProvisionObjects(web, template); // Lists new ObjectListInstance().ProvisionObjects(web, template); // Files new ObjectFiles().ProvisionObjects(web, template); // Custom actions new ObjectCustomActions().ProvisionObjects(web, template); // Composite look (commented) //new ObjectComposedLook().ProvisionObjects(web, template); // Property Bag Entries new ObjectPropertyBagEntry().ProvisionObjects(web, template); // Extensibility Provider CallOut the last thing we do. new ObjectExtensibilityProviders().ProvisionObjects(web, template); web.SetPropertyBagValue("_PnP_ProvisioningTemplateId", template.ID != null ? template.ID : ""); web.AddIndexedPropertyBagKey("_PnP_ProvisioningTemplateId"); ProvisioningTemplateInfo info = new ProvisioningTemplateInfo(); info.TemplateID = template.ID != null ? template.ID : ""; info.TemplateVersion = template.Version; info.TemplateSitePolicy = template.SitePolicy; info.Result = true; info.ProvisioningTime = DateTime.Now; var s = new JavaScriptSerializer(); string jsonInfo = s.Serialize(info); web.SetPropertyBagValue("_PnP_ProvisioningTemplateInfo", jsonInfo); }
public override TokenParser ProvisionObjects(Web web, ProvisioningTemplate template, TokenParser parser, ProvisioningTemplateApplyingInformation applyingInformation) { using (var scope = new PnPMonitoredScope(this.Name)) { web.SetPropertyBagValue("_PnP_ProvisioningTemplateId", template.Id != null ? template.Id : ""); web.AddIndexedPropertyBagKey("_PnP_ProvisioningTemplateId"); ProvisioningTemplateInfo info = new ProvisioningTemplateInfo(); info.TemplateId = template.Id != null ? template.Id : ""; info.TemplateVersion = template.Version; info.TemplateSitePolicy = template.SitePolicy; info.Result = true; info.ProvisioningTime = DateTime.Now; string jsonInfo = JsonConvert.SerializeObject(info); web.SetPropertyBagValue("_PnP_ProvisioningTemplateInfo", jsonInfo); } return parser; }
public override TokenParser ProvisionObjects(Web web, ProvisioningTemplate template, TokenParser parser, ProvisioningTemplateApplyingInformation applyingInformation) { using (var scope = new PnPMonitoredScope(this.Name)) { web.SetPropertyBagValue("_PnP_ProvisioningTemplateId", template.Id != null ? template.Id : ""); web.AddIndexedPropertyBagKey("_PnP_ProvisioningTemplateId"); ProvisioningTemplateInfo info = new ProvisioningTemplateInfo(); info.TemplateId = template.Id != null ? template.Id : ""; info.TemplateVersion = template.Version; info.TemplateSitePolicy = template.SitePolicy; info.Result = true; info.ProvisioningTime = DateTime.Now; string jsonInfo = JsonConvert.SerializeObject(info); web.SetPropertyBagValue("_PnP_ProvisioningTemplateInfo", jsonInfo); } return(parser); }