public static WebCreationParameters Create(string name, NewWebParameters parameters) { if (name == null) { throw new ArgumentNullException("name"); } if (parameters == null) { throw new ArgumentNullException("parameters"); } var created = new WebCreationParameters { Name = name, Title = parameters.Title, Description = parameters.Description, Template = parameters.Template, Language = parameters.Language, Locale = parameters.Locale, CollationLocale = parameters.CollationLocale, }; if (parameters.UniquePermissions.IsPresent) { created.UniquePermissions = parameters.UniquePermissions; } if (parameters.Anonymous.IsPresent) { created.Anonymous = parameters.Anonymous; } if (parameters.Presence.IsPresent) { created.Presence = parameters.Presence; } return(created); }
protected override XmlElement RawAddWeb(WebInfo web, WebCreationParameters parameters) { var name = web.Name; if (string.IsNullOrEmpty(name)) { name = parameters.Title; } var title = web.Title; if (string.IsNullOrEmpty(title)) { title = name; } Log.Verbose("Adding the web {0} to /{1}.", name, web.Path); var result = GetService <Sites>(web.Path).CreateWeb( name, title, parameters.Description, parameters.Template, parameters.Language, parameters.Language > 0, parameters.Locale, parameters.Locale > 0, parameters.CollationLocale, parameters.CollationLocale > 0, parameters.UniquePermissions.GetValueOrDefault(), parameters.UniquePermissions.HasValue, parameters.Anonymous.GetValueOrDefault(), parameters.Anonymous.HasValue, parameters.Presence.GetValueOrDefault(), parameters.Presence.HasValue); return(QueryWeb(PathUtility.JoinPath(web.Path, parameters.Name))); }
protected override XmlElement RawAddWeb(WebInfo web, WebCreationParameters parameters) { var target = GetWebXml(web); if (HasWebXml(target, parameters.Name)) { throw new ApplicationException("Web with the same name found."); } if (HasWebFolderXml(target, parameters.Name)) { throw new ApplicationException("WebFolder with the same name found."); } if (HasListXml(target, parameters.Name)) { throw new ApplicationException("List with the same name found."); } var source = target.OwnerDocument.CreateElement("Web"); source.SetAttribute("ID", Guid.NewGuid().ToString("D")); source.SetAttribute("Name", parameters.Name); source.SetAttribute("Title", parameters.Title); if (string.IsNullOrEmpty(parameters.Description)) { source.SetAttribute("Description", parameters.Description); } source.SetAttribute("Template", parameters.Template); if (parameters.Language > 0) { source.SetAttribute("Language", parameters.Language.ToStringI()); } if (parameters.Locale > 0) { source.SetAttribute("Locale", parameters.Locale.ToStringI()); } if (parameters.CollationLocale > 0) { source.SetAttribute("CollationLocale", parameters.CollationLocale.ToStringI()); } if (parameters.UniquePermissions.HasValue) { source.SetAttribute("UniquePermissions", parameters.UniquePermissions.Value.ToStringI()); } if (parameters.Anonymous.HasValue) { source.SetAttribute("Anonymous", parameters.Anonymous.Value.ToStringI()); } if (parameters.Presence.HasValue) { source.SetAttribute("Presence", parameters.Presence.Value.ToStringI()); } source.SetAttribute("Created", DateForNow); target.AppendChild(source); SaveSite(target); return(source); }
public WebInfo AddWeb(WebInfo web, WebCreationParameters parameters) { if (web == null) { throw new ArgumentNullException("web"); } if (parameters == null) { throw new ArgumentNullException("parameters"); } parameters.Check(); var newWeb = AddWebDirectly(web, parameters); if (web.Webs != null) { web.Webs = web.Webs.Concat(new[] { newWeb }).ToList(); } return(newWeb); }
public WebInfo AddWeb(WebCreationParameters parameters) { return Connector.GetModifying().AddWeb(this, parameters); }
protected abstract WebInfo AddWebDirectly(WebInfo web, WebCreationParameters parameters);
public WebInfo AddWeb(WebInfo web, WebCreationParameters parameters) { if (web == null) throw new ArgumentNullException("web"); if (parameters == null) throw new ArgumentNullException("parameters"); parameters.Check(); var newWeb = AddWebDirectly(web, parameters); if (web.Webs != null) web.Webs = web.Webs.Concat(new[] { newWeb }).ToList(); return newWeb; }
public WebInfo AddWeb(WebCreationParameters parameters) { return(Connector.GetModifying().AddWeb(this, parameters)); }
// Item creation protected override void NewItem(string path, string itemTypeName, object newItemValue) { EnsureLog(); path = PathUtility.NormalizePath(path); if (ShouldProcess(path, "New Item")) { string name; var parent = PathUtility.GetParentPath(path, out name); var target = GetObject(parent); // The type of the parameters object returned by the NewItemDynamicParameters // method decides the type of the object that is going to be created. Info added; var webParameters = DynamicParameters as NewWebParameters; if (webParameters != null) { var web = target as WebInfo; if (web == null) { throw new ApplicationException("Parent cannot contain a web."); } added = web.AddWeb(WebCreationParameters.Create(name, webParameters)); } else { var listParameters = DynamicParameters as NewListParameters; if (listParameters != null) { var listContainer = target as ListContainerInfo; if (listContainer == null) { throw new ApplicationException("Parent cannot contain a list."); } added = listContainer.AddList( ListCreationParameters.Create(name, listParameters)); } else { var itemContainer = target as ItemContainerInfo; if (itemContainer == null) { throw new ApplicationException("Parent cannot contain an item."); } var folderParameters = DynamicParameters as NewFolderParameters; if (folderParameters != null) { added = itemContainer.AddFolder(name); } else { var fileParameters = DynamicParameters as NewFileParameters; if (fileParameters != null) { var contentContainer = target as ContentContainerInfo; if (contentContainer == null) { throw new ApplicationException( "Parent cannot contain a file."); } newItemValue = newItemValue.GetBaseObject(); using (var content = GetContent(newItemValue, fileParameters)) added = contentContainer.AddFile(name, content); } else { var itemParameters = (NewItemParameters)DynamicParameters; added = itemContainer.AddItem(name); } } } } WriteItemObject(added); } }
protected abstract XmlElement RawAddWeb(WebInfo web, WebCreationParameters parameters);
protected override WebInfo AddWebDirectly(WebInfo web, WebCreationParameters parameters) { var path = PathUtility.JoinPath(web.Path, parameters.Name); return(CreateWebInfo(path, RawAddWeb(web, parameters))); }
protected override XmlElement RawAddWeb(WebInfo web, WebCreationParameters parameters) { var target = GetWebXml(web); if (HasWebXml(target, parameters.Name)) throw new ApplicationException("Web with the same name found."); if (HasWebFolderXml(target, parameters.Name)) throw new ApplicationException("WebFolder with the same name found."); if (HasListXml(target, parameters.Name)) throw new ApplicationException("List with the same name found."); var source = target.OwnerDocument.CreateElement("Web"); source.SetAttribute("ID", Guid.NewGuid().ToString("D")); source.SetAttribute("Name", parameters.Name); source.SetAttribute("Title", parameters.Title); if (string.IsNullOrEmpty(parameters.Description)) source.SetAttribute("Description", parameters.Description); source.SetAttribute("Template", parameters.Template); if (parameters.Language > 0) source.SetAttribute("Language", parameters.Language.ToStringI()); if (parameters.Locale > 0) source.SetAttribute("Locale", parameters.Locale.ToStringI()); if (parameters.CollationLocale > 0) source.SetAttribute("CollationLocale", parameters.CollationLocale.ToStringI()); if (parameters.UniquePermissions.HasValue) source.SetAttribute("UniquePermissions", parameters.UniquePermissions.Value.ToStringI()); if (parameters.Anonymous.HasValue) source.SetAttribute("Anonymous", parameters.Anonymous.Value.ToStringI()); if (parameters.Presence.HasValue) source.SetAttribute("Presence", parameters.Presence.Value.ToStringI()); source.SetAttribute("Created", DateForNow); target.AppendChild(source); SaveSite(target); return source; }
protected override WebInfo AddWebDirectly(WebInfo web, WebCreationParameters parameters) { var path = PathUtility.JoinPath(web.Path, parameters.Name); return CreateWebInfo(path, RawAddWeb(web, parameters)); }
public static WebCreationParameters Create(string name, NewWebParameters parameters) { if (name == null) throw new ArgumentNullException("name"); if (parameters == null) throw new ArgumentNullException("parameters"); var created = new WebCreationParameters { Name = name, Title = parameters.Title, Description = parameters.Description, Template = parameters.Template, Language = parameters.Language, Locale = parameters.Locale, CollationLocale = parameters.CollationLocale, }; if (parameters.UniquePermissions.IsPresent) created.UniquePermissions = parameters.UniquePermissions; if (parameters.Anonymous.IsPresent) created.Anonymous = parameters.Anonymous; if (parameters.Presence.IsPresent) created.Presence = parameters.Presence; return created; }