private void VerifyProfileField(IHostV30 host, string profileFieldName) { var profileProperties = ProfileBase.Properties; var profileProperty = profileProperties[profileFieldName]; if (profileProperty == null) { host.LogEntry(this.Information.Name + " requires a '" + profileFieldName + "' profile field defined in the current Profile Provider.", LogEntryType.Error, null, "SystemWebMembershipProxyProvider"); throw new InvalidConfigurationException(this.Information.Name + " requires a '" + profileFieldName + "' profile field defined in the current Profile Provider."); } if (profileProperty.PropertyType != typeof(string)) { host.LogEntry(this.Information.Name + " requires that the '" + profileFieldName + "' profile field is configured with type=\"String\".", LogEntryType.Error, null, "SystemWebMembershipProxyProvider"); throw new InvalidConfigurationException(this.Information.Name + " requires that the '" + profileFieldName + "' profile field is configured with type=\"String\"."); } if (profileProperty.IsReadOnly) { host.LogEntry(this.Information.Name + " requires that the '" + profileFieldName + "' profile field is configured with readOnly=\"false\".", LogEntryType.Error, null, "SystemWebMembershipProxyProvider"); throw new InvalidConfigurationException(this.Information.Name + " requires that the '" + profileFieldName + "' profile field is configured with readOnly=\"false\"."); } //if (!(bool)profileProperty.Attributes["AllowAnonymous"]) // throw new InvalidConfigurationException(this.Information.Name + " requires that the '" + profileFieldName + "' profile field is configured with allowAnonymous=\"true\"."); }
/// <summary> /// Initializes the Storage Provider. /// </summary> /// <param name="host">The Host of the Component.</param> /// <param name="config">The Configuration data, if any.</param> /// <exception cref="ArgumentNullException">If <b>host</b> or <b>config</b> are <c>null</c>.</exception> /// <exception cref="InvalidConfigurationException">If <b>config</b> is not valid or is incorrect.</exception> public void Init(IHostV30 host, string config) { if(host == null) throw new ArgumentNullException("host"); if(config == null) throw new ArgumentNullException("config"); this.host = host; if(config.Length == 0) { // Try to load v2 provider configuration config = TryLoadV2Configuration(); } if(config == null || config.Length == 0) { // Try to load Settings Storage Provider configuration config = TryLoadSettingsStorageProviderConfiguration(); } if(config == null) config = ""; ValidateConnectionString(config); connString = config; CreateOrUpdateDatabaseIfNecessary(); }
/// <summary> /// Initializes the Storage Provider. /// </summary> /// <param name="host">The Host of the Component.</param> /// <param name="config">The Configuration data, if any.</param> /// <remarks>If the configuration string is not valid, the methoud should throw a <see cref="InvalidConfigurationException"/>.</remarks> public void Init(IHostV30 host, string config) { _host = host; _config = config ?? string.Empty; var configEntries = _config.Split(new[] { "\n" }, StringSplitOptions.RemoveEmptyEntries); if (configEntries.Length != 3) { throw new InvalidConfigurationException("Configuration is missing required parameters"); } _baseUrl = configEntries[0]; if (_baseUrl.EndsWith("/")) { _baseUrl = _baseUrl.Substring(0, _baseUrl.Length - 1); } _username = configEntries[1]; _password = configEntries[2]; var settings = new XsltSettings { EnableScript = true, EnableDocumentFunction = true }; _xslTransform = new XslCompiledTransform(true); using (var reader = XmlReader.Create(Assembly.GetExecutingAssembly().GetManifestResourceStream("ScrewTurn.Wiki.Plugins.PluginPack.Resources.UnfuddleTickets.xsl"))) { _xslTransform.Load(reader, settings, new XmlUrlResolver()); } }
/// <summary> /// Initializes the Storage Provider /// </summary> /// <param name="host"></param> /// <param name="config">configuration data, if any</param> public void Init(IHostV30 host, string config) { if (host == null) { throw new ArgumentNullException(nameof(host)); } if (config == null) { throw new ArgumentNullException(nameof(config)); } var membershipProvider = Membership.Provider; if (membershipProvider.RequiresQuestionAndAnswer) { host.LogEntry(this.Information.Name + " does not support the RequiresQuestionAndAnswer option on the current Membership Provider.", LogEntryType.Error, null, "SystemWebMembershipProxyProvider"); throw new InvalidConfigurationException(this.Information.Name + " does not support the RequiresQuestionAndAnswer option on the current Membership Provider."); } // For UserInfo VerifyProfileField(host, "DisplayName"); // For User Profile VerifyProfileField(host, "Culture"); VerifyProfileField(host, "Timezone"); // For Email Notifications VerifyProfileField(host, "PageChanges"); VerifyProfileField(host, "DiscussionMessages"); VerifyProfileField(host, "NamespacePageChanges"); VerifyProfileField(host, "NamespaceDiscussionMessages"); }
/// <summary> /// Initializes the Provider. /// </summary> /// <param name="host">The Host of the Provider.</param> /// <param name="config">The Configuration data, if any.</param> /// <exception cref="ArgumentNullException">If <b>host</b> or <b>config</b> are <c>null</c>.</exception> /// <exception cref="InvalidConfigurationException">If <b>config</b> is not valid or is incorrect.</exception> public void Init(IHostV30 host, string config) { if (host == null) { throw new ArgumentNullException("host"); } if (config == null) { throw new ArgumentNullException("config"); } this.host = host; if (!LocalProvidersTools.CheckWritePermissions(host.GetSettingValue(SettingName.PublicDirectory))) { throw new InvalidConfigurationException("Cannot write into the public directory - check permissions"); } if (!File.Exists(GetFullPath(UsersFile))) { File.Create(GetFullPath(UsersFile)).Close(); } if (!File.Exists(GetFullPath(UsersDataFile))) { File.Create(GetFullPath(UsersDataFile)).Close(); } if (!File.Exists(GetFullPath(GroupsFile))) { File.Create(GetFullPath(GroupsFile)).Close(); } VerifyAndPerformUpgrade(); }
/// <summary> /// Initializes the Storage Provider. /// </summary> /// <param name="host">The Host of the Component.</param> /// <param name="config">The Configuration data, if any.</param> /// <exception cref="ArgumentNullException">If <paramref name="host"/> or <paramref name="config"/> are <c>null</c>.</exception> /// <exception cref="InvalidConfigurationException">If <paramref name="config"/> is not valid or is incorrect.</exception> public void Init(IHostV30 host, string config) { m_Host = host; m_Random = new Random(); InitConfig(config); }
/// <summary> /// Initializes the Storage Provider. /// </summary> /// <param name="host">The Host of the Component.</param> /// <param name="config">The Configuration data, if any.</param> /// <exception cref="ArgumentNullException">If <b>host</b> or <b>config</b> are <c>null</c>.</exception> /// <exception cref="InvalidConfigurationException">If <b>config</b> is not valid or is incorrect.</exception> public void Init(IHostV30 host, string config) { if (host == null) { throw new ArgumentNullException("host"); } if (config == null) { throw new ArgumentNullException("config"); } _host = host; int s = int.Parse(host.GetSettingValue(SettingName.CacheSize)); // Initialize pseudo cache _pseudoCache = new Dictionary <string, string>(10); // Initialize page content cache _pageContentCache = new Dictionary <PageInfo, PageContent>(s); _pageCacheUsage = new Dictionary <PageInfo, int>(s); // Initialize formatted page content cache _formattedContentCache = new Dictionary <PageInfo, string>(s); _sessions = new List <EditingSession>(50); _redirections = new Dictionary <string, string>(50); }
/// <summary> /// Initializes the Storage Provider. /// </summary> /// <param name="host">The Host of the Component.</param> /// <param name="config">The Configuration data, if any.</param> /// <remarks>If the configuration string is not valid, the methoud should throw a <see cref="InvalidConfigurationException"/>.</remarks> public void Init(IHostV30 host, string config) { this.host = host; this.config = config != null ? config : ""; defaultLanguage = host.GetSettingValue(SettingName.DefaultLanguage); displayWarning = config.ToLowerInvariant().Equals("display warning"); }
public void Init(IHostV30 host, string config) { if (config != null && config.Contains("log")) { _enableLogging = true; } _host = host; }
public void Init(IHostV30 host, string config) { if (config != null && config.Contains("log")) { _enableLogging = true; } _host = host; }
/// <summary> /// Initializes the Storage Provider. /// </summary> /// <param name="host">The Host of the Component.</param> /// <param name="config">The Configuration data, if any.</param> /// <remarks>If the configuration string is not valid, the methoud should throw a <see cref="InvalidConfigurationException"/>.</remarks> public void Init(IHostV30 host, string config) { this._host = host; this._config = config != null ? config : ""; if (this._config.ToLowerInvariant() == "nolog") { _enableLogging = false; } }
protected IHostV30 MockHost() { IHostV30 host = mocks.DynamicMock <IHostV30>(); Expect.Call(host.GetSettingValue(SettingName.CacheSize)).Return("20").Repeat.Any(); Expect.Call(host.GetSettingValue(SettingName.EditingSessionTimeout)).Return("1").Repeat.Any(); mocks.Replay(host); return(host); }
/// <summary> /// Initializes the Storage Provider. /// </summary> /// <param name="host">The Host of the Component.</param> /// <param name="config">The Configuration data, if any.</param> /// <exception cref="ArgumentNullException">If <paramref name="host"/> or <paramref name="config"/> are <c>null</c>.</exception> /// <exception cref="InvalidConfigurationException">If <paramref name="config"/> is not valid or is incorrect.</exception> public void Init(IHostV30 host, string config) { if (host == null) { throw new ArgumentNullException("host"); } _host = host; DirectoryInfo dirInfo = System.IO.Directory.CreateDirectory(GetFullPath("Index")); _directory = FSDirectory.Open(dirInfo); }
/// <summary> /// Initializes the Storage Provider. /// </summary> /// <param name="host">The Host of the Component.</param> /// <param name="config">The Configuration data, if any.</param> /// <exception cref="ArgumentNullException">If <paramref name="host"/> or <paramref name="config"/> are <c>null</c>.</exception> /// <exception cref="InvalidConfigurationException">If <paramref name="config"/> is not valid or is incorrect.</exception> public void Init(IHostV30 host, string config) { _host = host; if (config != null) { string[] configEntries = config.Split(new string[] { "\n" }, StringSplitOptions.RemoveEmptyEntries); for (int i = 0; i < configEntries.Length; i++) { string[] configEntryDetails = configEntries[i].Split(new string[] { "=" }, 2, StringSplitOptions.None); switch (configEntryDetails[0].ToLowerInvariant()) { case "logoptions": if (configEntryDetails[1] == "nolog") { _enableLogging = false; } else { LogWarning(@"Unknown value in ""logOptions"" configuration string: " + configEntries[i] + "Supported values are: nolog."); } break; default: LogWarning("Unknown value in configuration string: " + configEntries[i]); break; } } } IFilesStorageProviderV30 filesStorageProvider = GetDefaultFilesStorageProvider(); if (!DirectoryExists(filesStorageProvider, defaultDirectoryName)) { filesStorageProvider.CreateDirectory("/", defaultDirectoryName.Trim('/')); } if (!FileExists(filesStorageProvider, defaultDirectoryName, cssFileName)) { filesStorageProvider.StoreFile(defaultDirectoryName + cssFileName, Assembly.GetExecutingAssembly().GetManifestResourceStream("ScrewTurn.Wiki.Plugins.RatingManagerPlugin.Resources.jquery.rating.css"), true); } if (!FileExists(filesStorageProvider, defaultDirectoryName, jsFileName)) { filesStorageProvider.StoreFile(defaultDirectoryName + jsFileName, Assembly.GetExecutingAssembly().GetManifestResourceStream("ScrewTurn.Wiki.Plugins.RatingManagerPlugin.Resources.jquery.rating.pack.js"), true); } if (!FileExists(filesStorageProvider, defaultDirectoryName, starImageFileName)) { filesStorageProvider.StoreFile(defaultDirectoryName + starImageFileName, Assembly.GetExecutingAssembly().GetManifestResourceStream("ScrewTurn.Wiki.Plugins.RatingManagerPlugin.Resources.star.gif"), true); } }
protected IHostV30 MockHost() { if (!Directory.Exists(testDir)) { Directory.CreateDirectory(testDir); } IHostV30 host = mocks.DynamicMock <IHostV30>(); Expect.Call(host.GetSettingValue(SettingName.PublicDirectory)).Return(testDir).Repeat.AtLeastOnce(); mocks.Replay(host); return(host); }
public void Init_Upgrade() { string testDir = Path.Combine(Environment.GetEnvironmentVariable("TEMP"), Guid.NewGuid().ToString()); Directory.CreateDirectory(testDir); MockRepository mocks = new MockRepository(); IHostV30 host = mocks.DynamicMock <IHostV30>(); Expect.Call(host.GetSettingValue(SettingName.PublicDirectory)).Return(testDir).Repeat.AtLeastOnce(); Expect.Call(host.GetSettingValue(SettingName.AdministratorsGroup)).Return("Administrators").Repeat.Once(); Expect.Call(host.GetSettingValue(SettingName.UsersGroup)).Return("Users").Repeat.Once(); Expect.Call(host.UpgradeSecurityFlagsToGroupsAcl(null, null)).IgnoreArguments().Repeat.Times(1).Return(true); mocks.Replay(host); string file = Path.Combine(host.GetSettingValue(SettingName.PublicDirectory), "Users.cs"); File.WriteAllText(file, "user|PASSHASH|[email protected]|Inactive|2008/10/31 15:15:15|USER\r\nsuperuser|SUPERPASSHASH|[email protected]|Active|2008/10/31 15:15:16|ADMIN"); UsersStorageProvider prov = new UsersStorageProvider(); prov.Init(host, ""); UserInfo[] users = prov.GetUsers(); Assert.AreEqual(2, users.Length, "Wrong user count"); Assert.AreEqual("superuser", users[0].Username, "Wrong username"); Assert.AreEqual("*****@*****.**", users[0].Email, "Wrong email"); Assert.IsTrue(users[0].Active, "User should be active"); Assert.AreEqual("2008/10/31 15:15:16", users[0].DateTime.ToString("yyyy'/'MM'/'dd' 'HH':'mm':'ss"), "Wrong date/time"); Assert.AreEqual(1, users[0].Groups.Length, "Wrong user count"); Assert.AreEqual("Administrators", users[0].Groups[0], "Wrong group"); Assert.AreEqual("user", users[1].Username, "Wrong username"); Assert.AreEqual("*****@*****.**", users[1].Email, "Wrong email"); Assert.IsFalse(users[1].Active, "User should be inactive"); Assert.AreEqual("2008/10/31 15:15:15", users[1].DateTime.ToString("yyyy'/'MM'/'dd' 'HH':'mm':'ss"), "Wrong date/time"); Assert.AreEqual(1, users[1].Groups.Length, "Wrong user count"); Assert.AreEqual("Users", users[1].Groups[0], "Wrong group"); mocks.Verify(host); Directory.Delete(testDir, true); }
protected IHostV30 MockHost() { if (!Directory.Exists(testDir)) { Directory.CreateDirectory(testDir); } IHostV30 host = mocks.DynamicMock <IHostV30>(); Expect.Call(host.GetSettingValue(SettingName.PublicDirectory)).Return(testDir).Repeat.AtLeastOnce(); Expect.Call(host.PrepareContentForIndexing(null, null)).IgnoreArguments().Do((ToStringDelegate) delegate(PageInfo p, string input) { return(input); }).Repeat.Any(); Expect.Call(host.PrepareTitleForIndexing(null, null)).IgnoreArguments().Do((ToStringDelegate) delegate(PageInfo p, string input) { return(input); }).Repeat.Any(); mocks.Replay(host); return(host); }
public void Init(IHostV30 host, string config) { _host = host; if (Configure(config)) { _host.UserAccountActivity += Host_UserAccountActivity; _notificationSender.Configure(_host, _settings); _logger.Info(String.Format("Waiting list is enabled after {0} attendees with a hard limit of {1}.", _configuration.MaximumAttendees, _configuration.HardLimit), "SYSTEM"); } else { _logger.Error("The auto registration plugin will be disabled.", "SYSTEM"); } }
public void Init(IHostV30 host, string config) { _host = host; if (Configure(config)) { _host.UserAccountActivity += Host_UserAccountActivity; _notificationSender.Configure(_host, _settings); _logger.Info(String.Format("Waiting list is enabled after {0} attendees with a hard limit of {1}.", _configuration.MaximumAttendees, _configuration.HardLimit), "SYSTEM"); } else { _logger.Error("The auto registration plugin will be disabled.", "SYSTEM"); } }
protected IHostV30 MockHost() { if (!Directory.Exists(testDir)) { Directory.CreateDirectory(testDir); } //Console.WriteLine("Temp dir: " + testDir); IHostV30 host = mocks.DynamicMock <IHostV30>(); Expect.Call(host.GetSettingValue(SettingName.PublicDirectory)).Return(testDir).Repeat.AtLeastOnce(); Expect.Call(host.GetSettingValue(SettingName.LoggingLevel)).Return("3").Repeat.Any(); Expect.Call(host.GetSettingValue(SettingName.MaxLogSize)).Return(MaxLogSize.ToString()).Repeat.Any(); Expect.Call(host.GetSettingValue(SettingName.MaxRecentChanges)).Return(MaxRecentChanges.ToString()).Repeat.Any(); mocks.Replay(host); return(host); }
/// <summary> /// Initializes the Storage Provider. /// </summary> /// <param name="host">The Host of the Component.</param> /// <param name="config">The Configuration data, if any.</param> /// <exception cref="ArgumentNullException">If <b>host</b> or <b>config</b> are <c>null</c>.</exception> /// <exception cref="InvalidConfigurationException">If <b>config</b> is not valid or is incorrect.</exception> public void Init(IHostV30 host, string config) { if (host == null) { throw new ArgumentNullException("host"); } if (config == null) { throw new ArgumentNullException("config"); } this.host = host; if (config.Length == 0) { // Try to load v2 provider configuration config = TryLoadV2Configuration(); } if (config == null || config.Length == 0) { // Try to load Settings Storage Provider configuration config = TryLoadSettingsStorageProviderConfiguration(); } if (config == null) { config = ""; } ValidateConnectionString(config); connString = config; CreateOrUpdateDatabaseIfNecessary(); }
public void Init(IHostV30 host, string config) { throw new NotImplementedException(); }
/// <summary> /// Gets the data directory. /// </summary> /// <param name="host">The host object.</param> /// <returns>The data directory.</returns> protected string GetDataDirectory(IHostV30 host) { return(host.GetSettingValue(SettingName.PublicDirectory)); }
public void Init(IHostV30 host, string config) { throw new NotImplementedException(); }
public void Init(IHostV30 host, string config) { this.host = host; // Initialize ACL Manager and Storer this.aclManager = new StandardAclManager(); aclStorer = new AclStorer(aclManager, GetFullPath(AclFile)); aclStorer.LoadData(); }
/// <summary> /// Gets the data directory. /// </summary> /// <param name="host">The host object.</param> /// <returns>The data directory.</returns> protected string GetDataDirectory(IHostV30 host) { return host.GetSettingValue(SettingName.PublicDirectory); }
public void Init_Upgrade( ) { FixtureTearDown( ); SqlConnection cn = new SqlConnection(ConnString); cn.Open( ); SqlCommand cmd = cn.CreateCommand( ); cmd.CommandText = "create database [ScrewTurnWikiTest];"; cmd.ExecuteNonQuery( ); cn.Close( ); cn = new SqlConnection(ConnString + InitialCatalog); cn.Open( ); cmd = cn.CreateCommand( ); cmd.CommandText = @"CREATE TABLE [PagesProviderVersion] ( [Version] varchar(12) PRIMARY KEY ); INSERT INTO [PagesProviderVersion] ([Version]) VALUES ('Irrelevant'); create table [Page] ( [Name] nvarchar(128) primary key, [Status] char not null default ('N'), -- (P)ublic, N(ormal), (L)ocked [CreationDateTime] datetime not null ); create table [PageContent] ( [Page] nvarchar(128) references [Page]([Name]) on update cascade on delete cascade, [Revision] int not null default ((-1)), -- -1 for Current Revision [Title] nvarchar(256) not null, [DateTime] datetime not null, [Username] nvarchar(64) not null, [Content] ntext not null, [Comment] nvarchar(128) not null, primary key ([Page], [Revision]) ); create table [Category] ( [Name] nvarchar(128) primary key ); create table [CategoryBinding] ( [Category] nvarchar(128) references [Category]([Name]) on update cascade on delete cascade, [Page] nvarchar(128) references [Page]([Name]) on update cascade on delete cascade, primary key ([Category], [Page]) ); create table [Message] ( [ID] int primary key identity, [Page] nvarchar(128) references [Page]([Name]) on update cascade on delete cascade, [Parent] int not null, -- -1 for no parent [Username] nvarchar(64) not null, [DateTime] datetime not null, [Subject] nvarchar(128) not null, [Body] ntext not null ); create table [Snippet] ( [Name] nvarchar(128) primary key, [Content] ntext not null ); create table [NavigationPath] ( [Name] nvarchar(128) not null primary key ); create table [NavigationPathBinding] ( [NavigationPath] nvarchar(128) not null references [NavigationPath]([Name]) on delete cascade, [Page] nvarchar(128) not null references [Page]([Name]) on update cascade on delete cascade, [Number] int not null, primary key ([NavigationPath], [Page], [Number]) ); insert into [Page] ([Name], [Status], [CreationDateTime]) values ('Page1', 'N', '2008/12/31 12:12:12'); insert into [Page] ([Name], [Status], [CreationDateTime]) values ('Page2', 'L', '2008/12/31 12:12:12'); insert into [Page] ([Name], [Status], [CreationDateTime]) values ('Page.WithDot', 'P', '2008/12/31 12:12:12'); insert into [PageContent] ([Page], [Revision], [Title], [DateTime], [Username], [Content], [Comment]) values ('Page1', -1, 'Page1 Title', '2008/12/31 14:14:14', 'SYSTEM', 'Test Content 1', 'Comment 1'); insert into [PageContent] ([Page], [Revision], [Title], [DateTime], [Username], [Content], [Comment]) values ('Page1', 0, 'Page1 Title 0', '2008/12/31 12:12:12', 'SYSTEM', 'Test Content 0', ''); insert into [PageContent] ([Page], [Revision], [Title], [DateTime], [Username], [Content], [Comment]) values ('Page2', -1, 'Page2 Title', '2008/12/31 14:14:14', 'SYSTEM', 'Test Content 2', 'Comment 2'); insert into [PageContent] ([Page], [Revision], [Title], [DateTime], [Username], [Content], [Comment]) values ('Page.WithDot', -1, 'Page.WithDot Title', '2008/12/31 14:14:14', 'SYSTEM', 'Test Content 3', 'Comment 3'); insert into [Category] ([Name]) values ('Cat1'); insert into [Category] ([Name]) values ('Cat2'); insert into [Category] ([Name]) values ('Cat.WithDot'); insert into [CategoryBinding] ([Category], [Page]) values ('Cat1', 'Page1'); insert into [CategoryBinding] ([Category], [Page]) values ('Cat2', 'Page1'); insert into [CategoryBinding] ([Category], [Page]) values ('Cat1', 'Page2'); insert into [CategoryBinding] ([Category], [Page]) values ('Cat2', 'Page.WithDot'); insert into [CategoryBinding] ([Category], [Page]) values ('Cat.WithDot', 'Page.WithDot'); insert into [Message] ([Page], [Parent], [Username], [DateTime], [Subject], [Body]) values ('Page1', -1, 'SYSTEM', '2008/12/31 16:16:16', 'Test 1', 'Body 1'); insert into [Message] ([Page], [Parent], [Username], [DateTime], [Subject], [Body]) values ('Page1', 0, 'SYSTEM', '2008/12/31 16:16:16', 'Test 1.1', 'Body 1.1'); insert into [Message] ([Page], [Parent], [Username], [DateTime], [Subject], [Body]) values ('Page.WithDot', -1, 'SYSTEM', '2008/12/31 16:16:16', 'Test dot', 'Body dot'); insert into [Snippet] ([Name], [Content]) values ('Snip', 'Content'); insert into [NavigationPath] ([Name]) values ('Path'); insert into [NavigationPathBinding] ([NavigationPath], [Page], [Number]) values ('Path', 'Page1', 1); insert into [NavigationPathBinding] ([NavigationPath], [Page], [Number]) values ('Path', 'Page2', 2); insert into [NavigationPathBinding] ([NavigationPath], [Page], [Number]) values ('Path', 'Page.WithDot', 3);"; bool done = false; try { cmd.ExecuteNonQuery( ); done = true; } catch (SqlException sqlex) { Console.WriteLine(sqlex); } finally { cn.Close( ); } if (!done) { throw new Exception("Could not generate v2 test database"); } MockRepository mocks = new MockRepository( ); IHostV30 host = mocks.DynamicMock <IHostV30>( ); Expect.Call(host.UpgradePageStatusToAcl(null, 'L')).IgnoreArguments( ).Repeat.Twice( ).Return(true); mocks.Replay(host); SqlServerPagesStorageProvider prov = new SqlServerPagesStorageProvider( ); prov.Init(host, ConnString + InitialCatalog); Snippet[] snippets = prov.GetSnippets( ); Assert.AreEqual(1, snippets.Length, "Wrong snippet count"); Assert.AreEqual("Snip", snippets[0].Name, "Wrong snippet name"); Assert.AreEqual("Content", snippets[0].Content, "Wrong snippet content"); PageInfo[] pages = prov.GetPages(null); Assert.AreEqual(3, pages.Length, "Wrong page count"); Assert.AreEqual("Page_WithDot", pages[0].FullName, "Wrong page name"); Assert.AreEqual("Page1", pages[1].FullName, "Wrong page name"); Assert.AreEqual("Page2", pages[2].FullName, "Wrong page name"); Assert.AreEqual("Test Content 3", prov.GetContent(pages[0]).Content, "Wrong content"); Assert.AreEqual("Test Content 1", prov.GetContent(pages[1]).Content, "Wrong content"); Assert.AreEqual("Test Content 0", prov.GetBackupContent(pages[1], 0).Content, "Wrong backup content"); Assert.AreEqual("Test Content 2", prov.GetContent(pages[2]).Content, "Wrong content"); Message[] messages = prov.GetMessages(pages[0]); Assert.AreEqual(1, messages.Length, "Wrong message count"); Assert.AreEqual("Test dot", messages[0].Subject, "Wrong message subject"); CategoryInfo[] categories = prov.GetCategories(null); Assert.AreEqual(3, categories.Length, "Wrong category count"); Assert.AreEqual("Cat_WithDot", categories[0].FullName, "Wrong category name"); Assert.AreEqual(1, categories[0].Pages.Length, "Wrong page count"); Assert.AreEqual("Page_WithDot", categories[0].Pages[0], "Wrong page"); Assert.AreEqual("Cat1", categories[1].FullName, "Wrong category name"); Assert.AreEqual("Page1", categories[1].Pages[0], "Wrong page"); Assert.AreEqual("Page2", categories[1].Pages[1], "Wrong page"); Assert.AreEqual("Cat2", categories[2].FullName, "Wrong category name"); Assert.AreEqual("Page_WithDot", categories[2].Pages[0], "Wrong page"); Assert.AreEqual("Page1", categories[2].Pages[1], "Wrong page"); NavigationPath[] paths = prov.GetNavigationPaths(null); Assert.AreEqual(1, paths.Length, "Wrong navigation path count"); Assert.AreEqual("Path", paths[0].FullName, "Wrong navigation path name"); Assert.AreEqual("Page1", paths[0].Pages[0], "Wrong page"); Assert.AreEqual("Page2", paths[0].Pages[1], "Wrong page"); Assert.AreEqual("Page_WithDot", paths[0].Pages[2], "Wrong page"); mocks.Verify(host); }
public void Init(IHostV30 host, string config) { this.host = host; // if no css in config, default to hardcoded defaults if (String.IsNullOrEmpty(config)) { host.SetProviderConfiguration(this, defaultCss); config = defaultCss; } this.cssFromConfig = config; }
/// <summary> /// Initializes the Storage Provider. /// </summary> /// <param name="host">The Host of the Component.</param> /// <param name="config">The Configuration data, if any.</param> /// <remarks>If the configuration string is not valid, the methoud should throw a <see cref="InvalidConfigurationException"/>.</remarks> public void Init(IHostV30 host, string config) { _defaultLanguage = host.GetSettingValue(SettingName.DefaultLanguage); _displayWarning = config.ToLowerInvariant( ).Equals("display warning"); }
public void Configure(IHostV30 host, ISettings settings) { _host = host; _settings = settings; }
/// <summary> /// Initializes the Storage Provider. /// </summary> /// <param name="host">The Host of the Component.</param> /// <param name="config">The Configuration data, if any.</param> /// <remarks>If the configuration string is not valid, the methoud should throw a <see cref="InvalidConfigurationException"/>.</remarks> public new void Init(IHostV30 host, string config) { base.Init(host, config); aclManager = new OracleAclManager(StoreEntry, DeleteEntries, RenameAclResource, RetrieveAllAclEntries, RetrieveAclEntriesForResource, RetrieveAclEntriesForSubject); }
/// <summary> /// Initializes the Provider. /// </summary> /// <param name="host">The Host of the Provider.</param> /// <param name="config">The Configuration data, if any.</param> /// <exception cref="ArgumentNullException">If <b>host</b> or <b>config</b> are <c>null</c>.</exception> /// <exception cref="InvalidConfigurationException">If <b>config</b> is not valid or is incorrect.</exception> public void Init(IHostV30 host, string config) { if(host == null) throw new ArgumentNullException("host"); if(config == null) throw new ArgumentNullException("config"); this.host = host; if(!LocalProvidersTools.CheckWritePermissions(GetDataDirectory(host))) { throw new InvalidConfigurationException("Cannot write into the public directory - check permissions"); } if(!File.Exists(GetFullPath(UsersFile))) { File.Create(GetFullPath(UsersFile)).Close(); } if(!File.Exists(GetFullPath(UsersDataFile))) { File.Create(GetFullPath(UsersDataFile)).Close(); } if(!File.Exists(GetFullPath(GroupsFile))) { File.Create(GetFullPath(GroupsFile)).Close(); } VerifyAndPerformUpgrade(); }
public void Configure(IHostV30 host, ISettings settings) { _host = host; _settings = settings; }
/// <summary> /// Initializes the Storage Provider. /// </summary> /// <param name="host">The Host of the Component.</param> /// <param name="config">The Configuration data, if any.</param> /// <remarks>If the configuration string is not valid, the methoud should throw a <see cref="InvalidConfigurationException"/>.</remarks> public void Init(IHostV30 host, string config) { this._host = host; this._config = config != null ? config : ""; if(this._config.ToLowerInvariant() == "nolog") _enableLogging = false; }
/// <summary> /// Initializes the Storage Provider. /// </summary> /// <param name="host">The Host of the Component.</param> /// <param name="config">The Configuration data, if any.</param> /// <exception cref="ArgumentNullException">If <paramref name="host"/> or <paramref name="config"/> are <c>null</c>.</exception> /// <exception cref="InvalidConfigurationException">If <paramref name="config"/> is not valid or is incorrect.</exception> public void Init(IHostV30 host, string config) { if(host == null) throw new ArgumentNullException("host"); if(config == null) throw new ArgumentNullException("config"); if(AlreadyRun) return; // 1. Delete PluginPack.dll // 2. Download all other DLLs string root = "http://www.screwturn.eu/Version/PluginPack/"; string[] dllNames = new string[] { "DownloadCounterPlugin.dll", "FootnotesPlugin.dll", "MultilanguageContentPlugin.dll", "RssFeedDisplayPlugin.dll", "UnfuddleTicketsPlugin.dll" }; string[] providerNames = new string[] { "ScrewTurn.Wiki.Plugins.PluginPack.DownloadCounter", "ScrewTurn.Wiki.Plugins.PluginPack.Footnotes", "ScrewTurn.Wiki.Plugins.PluginPack.MultilanguageContentPlugin", "ScrewTurn.Wiki.Plugins.PluginPack.RssFeedDisplay", "ScrewTurn.Wiki.Plugins.PluginPack.UnfuddleTickets", }; Dictionary<string, byte[]> assemblies = new Dictionary<string, byte[]>(dllNames.Length); try { foreach(string dll in dllNames) { host.LogEntry("Downloading " + dll, LogEntryType.General, null, this); HttpWebRequest req = (HttpWebRequest)HttpWebRequest.Create(root + dll); req.AllowAutoRedirect = true; HttpWebResponse resp = (HttpWebResponse)req.GetResponse(); if(resp.StatusCode == HttpStatusCode.OK) { BinaryReader reader = new BinaryReader(resp.GetResponseStream()); byte[] content = reader.ReadBytes((int)resp.ContentLength); reader.Close(); assemblies.Add(dll, content); } else { throw new InvalidOperationException("Response status code for " + dll + ":" + resp.StatusCode.ToString()); } } foreach(string dll in dllNames) { host.GetSettingsStorageProvider().StorePluginAssembly(dll, assemblies[dll]); } foreach(string dll in dllNames) { LoadProvider(dll); } host.GetSettingsStorageProvider().DeletePluginAssembly("PluginPack.dll"); AlreadyRun = true; } catch(Exception ex) { host.LogEntry("Error occurred during automatic DLL updating with Updater Plugin\n" + ex.ToString(), LogEntryType.Error, null, this); } }
public void SetUp() { _mocks = new MockRepository(); _mockedHost = _mocks.DynamicMock<IHostV30>(); _blockQuote = new BlockQuote(); _blockQuote.Init(_mockedHost, string.Empty); }
/// <summary> /// Initializes the Provider. /// </summary> /// <param name="host">The Host of the Provider.</param> /// <param name="config">The Configuration data, if any.</param> /// <exception cref="ArgumentNullException">If <b>host</b> or <b>config</b> are <c>null</c>.</exception> /// <exception cref="InvalidConfigurationException">If <b>config</b> is not valid or is incorrect.</exception> public void Init(IHostV30 host, string config) { if(host == null) throw new ArgumentNullException("host"); if(config == null) throw new ArgumentNullException("config"); this.host = host; if(!LocalProvidersTools.CheckWritePermissions(host.GetSettingValue(SettingName.PublicDirectory))) { throw new InvalidConfigurationException("Cannot write into the public directory - check permissions"); } if(!Directory.Exists(Path.Combine(host.GetSettingValue(SettingName.PublicDirectory), PagesDirectory))) { Directory.CreateDirectory(Path.Combine(host.GetSettingValue(SettingName.PublicDirectory), PagesDirectory)); } if(!Directory.Exists(Path.Combine(host.GetSettingValue(SettingName.PublicDirectory), MessagesDirectory))) { Directory.CreateDirectory(Path.Combine(host.GetSettingValue(SettingName.PublicDirectory), MessagesDirectory)); } if(!Directory.Exists(Path.Combine(host.GetSettingValue(SettingName.PublicDirectory), SnippetsDirectory))) { Directory.CreateDirectory(Path.Combine(host.GetSettingValue(SettingName.PublicDirectory), SnippetsDirectory)); } if(!Directory.Exists(Path.Combine(host.GetSettingValue(SettingName.PublicDirectory), ContentTemplatesDirectory))) { Directory.CreateDirectory(Path.Combine(host.GetSettingValue(SettingName.PublicDirectory), ContentTemplatesDirectory)); } if(!Directory.Exists(Path.Combine(host.GetSettingValue(SettingName.PublicDirectory), DraftsDirectory))) { Directory.CreateDirectory(Path.Combine(host.GetSettingValue(SettingName.PublicDirectory), DraftsDirectory)); } bool upgradeNeeded = false; if(!File.Exists(GetFullPath(NamespacesFile))) { File.Create(GetFullPath(NamespacesFile)).Close(); } upgradeNeeded = VerifyIfPagesFileNeedsAnUpgrade(); if(!File.Exists(GetFullPath(PagesFile))) { File.Create(GetFullPath(PagesFile)).Close(); } else if(upgradeNeeded) { VerifyAndPerformUpgradeForPages(); } if(!File.Exists(GetFullPath(CategoriesFile))) { File.Create(GetFullPath(CategoriesFile)).Close(); } else if(upgradeNeeded) { VerifyAndPerformUpgradeForCategories(); } if(!File.Exists(GetFullPath(NavigationPathsFile))) { File.Create(GetFullPath(NavigationPathsFile)).Close(); } else if(upgradeNeeded) { VerifyAndPerformUpgradeForNavigationPaths(); } // Prepare search index index = new StandardIndex(); index.SetBuildDocumentDelegate(BuildDocumentHandler); indexStorer = new IndexStorer(GetFullPath(IndexDocumentsFile), GetFullPath(IndexWordsFile), GetFullPath(IndexMappingsFile), index); indexStorer.LoadIndex(); if(indexStorer.DataCorrupted) { host.LogEntry("Search Engine Index is corrupted and needs to be rebuilt\r\n" + indexStorer.ReasonForDataCorruption.ToString(), LogEntryType.Warning, null, this); } }
public void Init(IHostV30 host, string config) { // Nothing to do. }
public void SetUp(IHostV30 host, string config) { directory = new RAMDirectory(); }
/// <summary> /// Initializes the Storage Provider. /// </summary> /// <param name="host">The Host of the Component.</param> /// <param name="config">The Configuration data, if any.</param> /// <remarks>If the configuration string is not valid, the methoud should throw a <see cref="InvalidConfigurationException"/>.</remarks> public void Init(IHostV30 host, string config) { this.host = host; this.config = config != null ? config : ""; defaultLanguage = host.GetSettingValue(SettingName.DefaultLanguage); displayWarning = config.ToLowerInvariant().Equals("display warning"); }
/// <summary> /// Initializes the Storage Provider. /// </summary> /// <param name="host">The Host of the Component.</param> /// <param name="config">The Configuration data, if any.</param> /// <exception cref="ArgumentNullException">If <paramref name="host"/> or <paramref name="config"/> are <c>null</c>.</exception> /// <exception cref="InvalidConfigurationException">If <paramref name="config"/> is not valid or is incorrect.</exception> public void Init(IHostV30 host, string config) { m_Host = host; m_Random = new Random(); InitConfig(config); }
/// <summary> /// Initializes the Storage Provider. /// </summary> /// <param name="host">The Host of the Component.</param> /// <param name="config">The Configuration data, if any.</param> /// <exception cref="ArgumentNullException">If <b>host</b> or <b>config</b> are <c>null</c>.</exception> /// <exception cref="InvalidConfigurationException">If <b>config</b> is not valid or is incorrect.</exception> public void Init(IHostV30 host, string config) { if(host == null) throw new ArgumentNullException("host"); if(config == null) throw new ArgumentNullException("config"); _host = host; int s = int.Parse(host.GetSettingValue(SettingName.CacheSize)); // Initialize pseudo cache _pseudoCache = new Dictionary<string, string>(10); // Initialize page content cache _pageContentCache = new Dictionary<PageInfo, PageContent>(s); _pageCacheUsage = new Dictionary<PageInfo, int>(s); // Initialize formatted page content cache _formattedContentCache = new Dictionary<PageInfo, string>(s); _sessions = new List<EditingSession>(50); _redirections = new Dictionary<string, string>(50); }
public void Init(IHostV30 host, string config) { _host = host; _config = config ?? ""; if (_config.ToLowerInvariant() == "nolog") _enableLogging = false; }
/// <summary> /// Initializes the Storage Provider. /// </summary> /// <param name="host">The Host of the Component.</param> /// <param name="config">The Configuration data, if any.</param> /// <remarks>If the configuration string is not valid, the methoud should throw a <see cref="InvalidConfigurationException"/>.</remarks> public void Init(IHostV30 host, string config) { _host = host; _config = config ?? string.Empty; var configEntries = _config.Split(new[] { "\n" }, StringSplitOptions.RemoveEmptyEntries); if(configEntries.Length != 3) throw new InvalidConfigurationException("Configuration is missing required parameters"); _baseUrl = configEntries[0]; if(_baseUrl.EndsWith("/")) _baseUrl = _baseUrl.Substring(0, _baseUrl.Length - 1); _username = configEntries[1]; _password = configEntries[2]; var settings = new XsltSettings { EnableScript = true, EnableDocumentFunction = true }; _xslTransform = new XslCompiledTransform(true); using(var reader = XmlReader.Create(Assembly.GetExecutingAssembly().GetManifestResourceStream("ScrewTurn.Wiki.Plugins.PluginPack.Resources.UnfuddleTickets.xsl"))) { _xslTransform.Load(reader, settings, new XmlUrlResolver()); } }
/// <summary> /// Initializes the Storage Provider. /// </summary> /// <param name="host">The Host of the Component.</param> /// <param name="config">The Configuration data, if any.</param> /// <exception cref="ArgumentNullException">If <paramref name="host"/> or <paramref name="config"/> are <c>null</c>.</exception> /// <exception cref="InvalidConfigurationException">If <paramref name="config"/> is not valid or is incorrect.</exception> public void Init(IHostV30 host, string config) { if(host == null) throw new ArgumentNullException("host"); if(config == null) throw new ArgumentNullException("config"); this.host = host; if(!LocalProvidersTools.CheckWritePermissions(GetDataDirectory(host))) { throw new InvalidConfigurationException("Cannot write into the public directory - check permissions"); } // Create directories, if needed if(!Directory.Exists(GetFullPath(UploadDirectory))) { Directory.CreateDirectory(GetFullPath(UploadDirectory)); } if(!Directory.Exists(GetFullPath(AttachmentsDirectory))) { Directory.CreateDirectory(GetFullPath(AttachmentsDirectory)); } if(!File.Exists(GetFullPath(FileDownloadsFile))) { File.Create(GetFullPath(FileDownloadsFile)).Close(); } if(!File.Exists(GetFullPath(AttachmentDownloadsFile))) { File.Create(GetFullPath(AttachmentDownloadsFile)).Close(); } }
/// <summary> /// Initializes the Storage Provider. /// </summary> /// <param name="host">The Host of the Component.</param> /// <param name="config">The Configuration data, if any.</param> /// <exception cref="ArgumentNullException">If <paramref name="host"/> or <paramref name="config"/> are <c>null</c>.</exception> /// <exception cref="InvalidConfigurationException">If <paramref name="config"/> is not valid or is incorrect.</exception> public void Init(IHostV30 host, string config) { this.host = host; this.config = config != null ? config : ""; }
/// <summary> /// Initializes the Storage Provider. /// </summary> /// <param name="host">The Host of the Component.</param> /// <param name="config">The Configuration data, if any.</param> /// <exception cref="ArgumentNullException">If <paramref name="host"/> or <paramref name="config"/> are <c>null</c>.</exception> /// <exception cref="InvalidConfigurationException">If <paramref name="config"/> is not valid or is incorrect.</exception> public void Init(IHostV30 host, string config) { if (host == null) { throw new ArgumentNullException("host"); } if (config == null) { throw new ArgumentNullException("config"); } if (AlreadyRun) { return; } // 1. Delete PluginPack.dll // 2. Download all other DLLs string root = "http://www.screwturn.eu/Version/PluginPack/"; string[] dllNames = new string[] { "DownloadCounterPlugin.dll", "FootnotesPlugin.dll", "MultilanguageContentPlugin.dll", "RssFeedDisplayPlugin.dll", "UnfuddleTicketsPlugin.dll" }; string[] providerNames = new string[] { "ScrewTurn.Wiki.Plugins.PluginPack.DownloadCounter", "ScrewTurn.Wiki.Plugins.PluginPack.Footnotes", "ScrewTurn.Wiki.Plugins.PluginPack.MultilanguageContentPlugin", "ScrewTurn.Wiki.Plugins.PluginPack.RssFeedDisplay", "ScrewTurn.Wiki.Plugins.PluginPack.UnfuddleTickets", }; Dictionary <string, byte[]> assemblies = new Dictionary <string, byte[]>(dllNames.Length); try { foreach (string dll in dllNames) { host.LogEntry("Downloading " + dll, LogEntryType.General, null, this); HttpWebRequest req = (HttpWebRequest)HttpWebRequest.Create(root + dll); req.AllowAutoRedirect = true; HttpWebResponse resp = (HttpWebResponse)req.GetResponse(); if (resp.StatusCode == HttpStatusCode.OK) { BinaryReader reader = new BinaryReader(resp.GetResponseStream()); byte[] content = reader.ReadBytes((int)resp.ContentLength); reader.Close(); assemblies.Add(dll, content); } else { throw new InvalidOperationException("Response status code for " + dll + ":" + resp.StatusCode.ToString()); } } foreach (string dll in dllNames) { host.GetSettingsStorageProvider().StorePluginAssembly(dll, assemblies[dll]); } foreach (string dll in dllNames) { LoadProvider(dll); } host.GetSettingsStorageProvider().DeletePluginAssembly("PluginPack.dll"); AlreadyRun = true; } catch (Exception ex) { host.LogEntry("Error occurred during automatic DLL updating with Updater Plugin\n" + ex.ToString(), LogEntryType.Error, null, this); } }
public void Init_Upgrade( ) { FixtureTearDown( ); SqlConnection cn = new SqlConnection(ConnString); cn.Open( ); SqlCommand cmd = cn.CreateCommand( ); cmd.CommandText = "create database [ScrewTurnWikiTest];"; cmd.ExecuteNonQuery( ); cn.Close( ); cn = new SqlConnection(ConnString + InitialCatalog); cn.Open( ); cmd = cn.CreateCommand( ); cmd.CommandText = @"CREATE TABLE [UsersProviderVersion] ( [Version] varchar(12) PRIMARY KEY ); INSERT INTO [UsersProviderVersion] ([Version]) VALUES ('Irrelevant'); CREATE TABLE [User] ( [Username] nvarchar(128) PRIMARY KEY, [PasswordHash] varchar(128) NOT NULL, [Email] varchar(128) NOT NULL, [DateTime] datetime NOT NULL, [Active] bit NOT NULL DEFAULT ((0)), [Admin] bit NOT NULL DEFAULT ((0)) ); INSERT INTO [User] ([Username], [PasswordHash], [Email], [DateTime], [Active], [Admin]) values ('user', 'hash', '*****@*****.**', '2008/12/27 12:12:12', 'true', 'false'); INSERT INTO [User] ([Username], [PasswordHash], [Email], [DateTime], [Active], [Admin]) values ('user2', 'hash2', '*****@*****.**', '2008/12/27 12:12:13', 'false', 'true');"; bool done = false; try { cmd.ExecuteNonQuery( ); done = true; } catch (SqlException sqlex) { Console.WriteLine(sqlex.ToString( )); } finally { cn.Close( ); } if (!done) { throw new Exception("Could not create v2 test database"); } MockRepository mocks = new MockRepository( ); IHostV30 host = mocks.DynamicMock <IHostV30>( ); Expect.Call(host.GetSettingValue(SettingName.AdministratorsGroup)).Return("Administrators").Repeat.Once( ); Expect.Call(host.GetSettingValue(SettingName.UsersGroup)).Return("Users").Repeat.Once( ); Expect.Call(host.UpgradeSecurityFlagsToGroupsAcl(null, null)).IgnoreArguments( ).Repeat.Times(1).Return(true); mocks.Replay(host); IUsersStorageProviderV30 prov = new SqlServerUsersStorageProvider( ); prov.Init(host, ConnString + InitialCatalog); mocks.Verify(host); UserInfo[] users = prov.GetUsers( ); Assert.AreEqual(2, users.Length, "Wrong user count"); Assert.AreEqual("user", users[0].Username, "Wrong username"); Assert.IsNull(users[0].DisplayName, "Display name should be null"); Assert.AreEqual("*****@*****.**", users[0].Email, "Wrong email"); Assert.AreEqual("2008/12/27 12:12:12", users[0].DateTime.ToString("yyyy'/'MM'/'dd' 'HH':'mm':'ss"), "Wrong date/time"); Assert.IsTrue(users[0].Active, "User should be active"); Assert.AreEqual(1, users[0].Groups.Length, "Wrong group count"); Assert.AreEqual("Users", users[0].Groups[0], "Wrong group"); Assert.AreEqual("user2", users[1].Username, "Wrong username"); Assert.IsNull(users[1].DisplayName, "Display name should be null"); Assert.AreEqual("*****@*****.**", users[1].Email, "Wrong email"); Assert.AreEqual("2008/12/27 12:12:13", users[1].DateTime.ToString("yyyy'/'MM'/'dd' 'HH':'mm':'ss"), "Wrong date/time"); Assert.IsFalse(users[1].Active, "User should be inactive"); Assert.AreEqual(1, users[1].Groups.Length, "Wrong group count"); Assert.AreEqual("Administrators", users[1].Groups[0], "Wrong group"); }
public void Init_Upgrade() { string testDir = Path.Combine(Environment.GetEnvironmentVariable("TEMP"), Guid.NewGuid().ToString()); Directory.CreateDirectory(testDir); MockRepository mocks = new MockRepository(); IHostV30 host = mocks.DynamicMock <IHostV30>(); Expect.Call(host.GetSettingValue(SettingName.PublicDirectory)).Return(testDir).Repeat.AtLeastOnce(); Expect.Call(host.UpgradePageStatusToAcl(null, 'L')).IgnoreArguments().Repeat.Twice().Return(true); mocks.Replay(host); string file = Path.Combine(host.GetSettingValue(SettingName.PublicDirectory), "Pages.cs"); string categoriesFile = Path.Combine(host.GetSettingValue(SettingName.PublicDirectory), "Categories.cs"); string navPathsFile = Path.Combine(host.GetSettingValue(SettingName.PublicDirectory), "NavigationPaths.cs"); string directory = Path.Combine(host.GetSettingValue(SettingName.PublicDirectory), "Pages"); string messagesDirectory = Path.Combine(host.GetSettingValue(SettingName.PublicDirectory), "Messages"); Directory.CreateDirectory(directory); Directory.CreateDirectory(messagesDirectory); // Structure (Keywords and Description are new in v3) // Page Title // Username|DateTime[|Comment] --- Comment is optional // ##PAGE## // Content... File.WriteAllText(Path.Combine(directory, "Page1.cs"), "Title1\r\nSYSTEM|2008/10/30 20:20:20|Comment\r\n##PAGE##\r\nContent..."); File.WriteAllText(Path.Combine(directory, "Page2.cs"), "Title2\r\nSYSTEM|2008/10/30 20:20:20\r\n##PAGE\r\nContent. [[Page.3]] [Page.3|Link to update]."); File.WriteAllText(Path.Combine(directory, "Page.3.cs"), "Title3\r\nSYSTEM|2008/10/30 20:20:20|Comment\r\n##PAGE\r\nContent..."); // ID|Username|Subject|DateTime|ParentID|Body File.WriteAllText(Path.Combine(messagesDirectory, "Page.3.cs"), "0|User|Hello|2008/10/30 21:21:21|-1|Blah\r\n"); // Structure // [Namespace.]PageName|PageFile|Status|DateTime File.WriteAllText(file, "Page1|Page1.cs|NORMAL|2008/10/30 20:20:20\r\nPage2|Page2.cs|PUBLIC\r\nPage.3|Page.3.cs|LOCKED"); File.WriteAllText(categoriesFile, "Cat1|Page.3\r\nCat.2|Page1|Page2\r\n"); File.WriteAllText(navPathsFile, "Path1|Page1|Page.3\r\nPath2|Page2\r\n"); PagesStorageProvider prov = new PagesStorageProvider(); prov.Init(host, ""); PageInfo[] pages = prov.GetPages(null); Assert.AreEqual(3, pages.Length, "Wrong page count"); Assert.AreEqual("Page1", pages[0].FullName, "Wrong name"); Assert.AreEqual("Page2", pages[1].FullName, "Wrong name"); Assert.AreEqual("Page_3", pages[2].FullName, "Wrong name"); //Assert.IsFalse(prov.GetContent(pages[1]).Content.Contains("Page.3"), "Content should not contain 'Page.3'"); //Assert.IsTrue(prov.GetContent(pages[1]).Content.Contains("Page_3"), "Content should contain 'Page_3'"); Message[] messages = prov.GetMessages(pages[2]); Assert.AreEqual(1, messages.Length, "Wrong message count"); Assert.AreEqual("Hello", messages[0].Subject, "Wrong subject"); CategoryInfo[] categories = prov.GetCategories(null); Assert.AreEqual(2, categories.Length, "Wrong category count"); Assert.AreEqual("Cat1", categories[0].FullName, "Wrong name"); Assert.AreEqual(1, categories[0].Pages.Length, "Wrong page count"); Assert.AreEqual("Page_3", categories[0].Pages[0], "Wrong page"); Assert.AreEqual("Cat_2", categories[1].FullName, "Wrong name"); Assert.AreEqual(2, categories[1].Pages.Length, "Wrong page count"); Assert.AreEqual("Page1", categories[1].Pages[0], "Wrong page"); Assert.AreEqual("Page2", categories[1].Pages[1], "Wrong page"); NavigationPath[] navPaths = prov.GetNavigationPaths(null); Assert.AreEqual(2, navPaths.Length, "Wrong nav path count"); Assert.AreEqual("Path1", navPaths[0].FullName, "Wrong name"); Assert.AreEqual(2, navPaths[0].Pages.Length, "Wrong page count"); Assert.AreEqual("Page1", navPaths[0].Pages[0], "Wrong page"); Assert.AreEqual("Page_3", navPaths[0].Pages[1], "Wrong page"); Assert.AreEqual(1, navPaths[1].Pages.Length, "Wrong page count"); Assert.AreEqual("Page2", navPaths[1].Pages[0], "Wrong page"); mocks.Verify(host); // Simulate another startup - upgrade not needed anymore mocks.BackToRecord(host); Expect.Call(host.GetSettingValue(SettingName.PublicDirectory)).Return(testDir).Repeat.AtLeastOnce(); Expect.Call(host.UpgradePageStatusToAcl(null, 'L')).IgnoreArguments().Repeat.Times(0).Return(false); mocks.Replay(host); prov = new PagesStorageProvider(); prov.Init(host, ""); mocks.Verify(host); Directory.Delete(testDir, true); }
/// <summary> /// Initializes the Storage Provider. /// </summary> /// <param name="host">The Host of the Component.</param> /// <param name="config">The Configuration data, if any.</param> /// <exception cref="ArgumentNullException">If <paramref name="host"/> or <paramref name="config"/> are <c>null</c>.</exception> /// <exception cref="InvalidConfigurationException">If <paramref name="config"/> is not valid or is incorrect.</exception> public void Init(IHostV30 host, string config) { _host = host; if(config != null) { string[] configEntries = config.Split(new string[] { "\n" }, StringSplitOptions.RemoveEmptyEntries); for(int i = 0; i < configEntries.Length; i++) { string[] configEntryDetails = configEntries[i].Split(new string[] { "=" }, 2, StringSplitOptions.None); switch(configEntryDetails[0].ToLowerInvariant()) { case "logoptions": if(configEntryDetails[1] == "nolog") { _enableLogging = false; } else { LogWarning(@"Unknown value in ""logOptions"" configuration string: " + configEntries[i] + "Supported values are: nolog."); } break; default: LogWarning("Unknown value in configuration string: " + configEntries[i]); break; } } } IFilesStorageProviderV30 filesStorageProvider = GetDefaultFilesStorageProvider(); if(!DirectoryExists(filesStorageProvider, defaultDirectoryName)) { filesStorageProvider.CreateDirectory("/", defaultDirectoryName.Trim('/')); } if(!FileExists(filesStorageProvider, defaultDirectoryName, cssFileName)) { filesStorageProvider.StoreFile(defaultDirectoryName + cssFileName, Assembly.GetExecutingAssembly().GetManifestResourceStream("ScrewTurn.Wiki.Plugins.RatingManagerPlugin.Resources.jquery.rating.css"), true); } if(!FileExists(filesStorageProvider, defaultDirectoryName, jsFileName)) { filesStorageProvider.StoreFile(defaultDirectoryName + jsFileName, Assembly.GetExecutingAssembly().GetManifestResourceStream("ScrewTurn.Wiki.Plugins.RatingManagerPlugin.Resources.jquery.rating.pack.js"), true); } if(!FileExists(filesStorageProvider, defaultDirectoryName, starImageFileName)) { filesStorageProvider.StoreFile(defaultDirectoryName + starImageFileName, Assembly.GetExecutingAssembly().GetManifestResourceStream("ScrewTurn.Wiki.Plugins.RatingManagerPlugin.Resources.star.gif"), true); } }
/// <summary> /// Sets up the Storage Provider. /// </summary> /// <param name="host">The Host of the Component.</param> /// <param name="config">The Configuration data, if any.</param> /// <remarks>If the configuration string is not valid, the methoud should throw a <see cref="InvalidConfigurationException"/>.</remarks> public void SetUp(IHostV30 host, string config) { }
/// <summary> /// Initializes the Storage Provider. /// </summary> /// <param name="host">The Host of the Component.</param> /// <param name="config">The Configuration data, if any.</param> /// <remarks>If the configuration string is not valid, the methoud should throw a <see cref="InvalidConfigurationException"/>.</remarks> public new void Init(IHostV30 host, string config) { base.Init(host, config); index = new SqlIndex(new IndexConnector(GetWordFetcher, GetSize, GetCount, ClearIndex, DeleteDataForDocument, SaveDataForDocument, TryFindWord)); }
/// <summary> /// Initializes the Storage Provider. /// </summary> /// <param name="host">The Host of the Component.</param> /// <param name="config">The Configuration data, if any.</param> /// <exception cref="ArgumentNullException">If <b>host</b> or <b>config</b> are <c>null</c>.</exception> /// <exception cref="InvalidConfigurationException">If <b>config</b> is not valid or is incorrect.</exception> public void Init(IHostV30 host, string config) { if(host == null) throw new ArgumentNullException("host"); if(config == null) throw new ArgumentNullException("config"); this.host = host; if(!LocalProvidersTools.CheckWritePermissions(host.GetSettingValue(SettingName.PublicDirectory))) { throw new InvalidConfigurationException("Cannot write into the public directory - check permissions"); } // Create all needed pluginAssemblies if(!File.Exists(GetFullPath(LogFile))) { File.Create(GetFullPath(LogFile)).Close(); } if(!File.Exists(GetFullPath(ConfigFile))) { File.Create(GetFullPath(ConfigFile)).Close(); isFirstStart = true; } if(!File.Exists(GetFullPath(RecentChangesFile))) { File.Create(GetFullPath(RecentChangesFile)).Close(); } if(!File.Exists(GetFullPath(HtmlHeadFile))) { File.Create(GetFullPath(HtmlHeadFile)).Close(); } if(!File.Exists(GetFullPath(HeaderFile))) { File.Create(GetFullPath(HeaderFile)).Close(); } if(!File.Exists(GetFullPath(SidebarFile))) { File.Create(GetFullPath(SidebarFile)).Close(); } if(!File.Exists(GetFullPath(FooterFile))) { File.Create(GetFullPath(FooterFile)).Close(); } if(!File.Exists(GetFullPath(PageHeaderFile))) { File.Create(GetFullPath(PageHeaderFile)).Close(); } if(!File.Exists(GetFullPath(PageFooterFile))) { File.Create(GetFullPath(PageFooterFile)).Close(); } if(!File.Exists(GetFullPath(AccountActivationMessageFile))) { File.Create(GetFullPath(AccountActivationMessageFile)).Close(); } if(!File.Exists(GetFullPath(PasswordResetProcedureMessageFile))) { File.Create(GetFullPath(PasswordResetProcedureMessageFile)).Close(); } if(!File.Exists(GetFullPath(EditNoticeFile))) { File.Create(GetFullPath(EditNoticeFile)).Close(); } if(!File.Exists(GetFullPath(LoginNoticeFile))) { File.Create(GetFullPath(LoginNoticeFile)).Close(); } if(!File.Exists(GetFullPath(AccessDeniedNoticeFile))) { File.Create(GetFullPath(AccessDeniedNoticeFile)).Close(); } if(!File.Exists(GetFullPath(RegisterNoticeFile))) { File.Create(GetFullPath(RegisterNoticeFile)).Close(); } if(!File.Exists(GetFullPath(PageChangeMessageFile))) { File.Create(GetFullPath(PageChangeMessageFile)).Close(); } if(!File.Exists(GetFullPath(DiscussionChangeMessageFile))) { File.Create(GetFullPath(DiscussionChangeMessageFile)).Close(); } if(!File.Exists(GetFullPath(ApproveDraftMessageFile))) { File.Create(GetFullPath(ApproveDraftMessageFile)).Close(); } if(!Directory.Exists(GetFullPath(PluginsDirectory))) { Directory.CreateDirectory(GetFullPath(PluginsDirectory)); } if(!Directory.Exists(GetFullPathForPlugin(PluginsConfigDirectory))) { Directory.CreateDirectory(GetFullPathForPlugin(PluginsConfigDirectory)); } if(!File.Exists(GetFullPathForPlugin(PluginsStatusFile))) { File.Create(GetFullPathForPlugin(PluginsStatusFile)).Close(); } if(!File.Exists(GetFullPath(LinksFile))) { File.Create(GetFullPath(LinksFile)).Close(); } LoadConfig(); // Initialize ACL Manager and Storer aclManager = new StandardAclManager(); aclStorer = new AclStorer(aclManager, GetFullPath(AclFile)); aclStorer.LoadData(); }
/// <summary> /// Initializes the Storage Provider. /// </summary> /// <param name="host">The Host of the Component.</param> /// <param name="config">The Configuration data, if any.</param> /// <exception cref="ArgumentNullException">If <paramref name="host"/> or <paramref name="config"/> are <c>null</c>.</exception> /// <exception cref="InvalidConfigurationException">If <paramref name="config"/> is not valid or is incorrect.</exception> public void Init(IHostV30 host, string config) { this.host = host; this.config = config != null ? config : ""; }