[Nmailserver-commits] SF.net SVN: nmailserver: [177] NMail/trunk/NMail
Brought to you by:
dframpton-oss,
tmyroadctfig
|
From: <tmy...@us...> - 2007-03-13 05:07:35
|
Revision: 177
http://svn.sourceforge.net/nmailserver/?rev=177&view=rev
Author: tmyroadctfig
Date: 2007-03-12 22:07:34 -0700 (Mon, 12 Mar 2007)
Log Message:
-----------
Several changes to make things more NHibernate friendly. Also changed MySql local store data to work with unit tests.
Modified Paths:
--------------
NMail/trunk/NMail/DataTypes/ACLs/StoreFolderAcl.cs
NMail/trunk/NMail/DataTypes/LocalStore/ILocalStore.cs
NMail/trunk/NMail/DataTypes/LocalStore/ILocalStoreData.cs
NMail/trunk/NMail/DataTypes/LocalStore/LocalStoreUser.cs
NMail/trunk/NMail.Administration.Console/Command/AddUserCommand.cs
NMail/trunk/NMail.Administration.Console/Command/DeleteUserCommand.cs
NMail/trunk/NMail.Administration.Console/Command/ListUserAddressesCommand.cs
NMail/trunk/NMail.Administration.Console/Command/ListUsersCommand.cs
NMail/trunk/NMail.LocalStore/LocalStore.cs
NMail/trunk/NMail.LocalStoreData.MySql/MySqlLocalStore.sql
NMail/trunk/NMail.LocalStoreData.MySql/MySqlLocalStoreData.cs
NMail/trunk/NMail.LocalStoreData.MySql/NMail.LocalStoreData.MySql.csproj
NMail/trunk/NMail.LocalStoreData.MySql/Resources/NMail.LocalStoreData.MySql.hbm.xml
Modified: NMail/trunk/NMail/DataTypes/ACLs/StoreFolderAcl.cs
===================================================================
--- NMail/trunk/NMail/DataTypes/ACLs/StoreFolderAcl.cs 2007-03-13 05:05:16 UTC (rev 176)
+++ NMail/trunk/NMail/DataTypes/ACLs/StoreFolderAcl.cs 2007-03-13 05:07:34 UTC (rev 177)
@@ -27,6 +27,9 @@
/// </summary>
[Serializable]
public class StoreFolderAcl : GenericAcl<StoreFolderPrivilege> {
+
+ private StoreFolderAcl() { }
+
/// <summary>
/// Creates a new ACL for the given folder.
/// </summary>
@@ -35,6 +38,16 @@
this.folder = folder;
}
+ private int aclId;
+
+ /// <summary>
+ /// The Id of this store folder ACL.
+ /// </summary>
+ public int AclId {
+ get { return aclId; }
+ set { aclId = value; }
+ }
+
private StoreFolder folder;
/// <summary>
Modified: NMail/trunk/NMail/DataTypes/LocalStore/ILocalStore.cs
===================================================================
--- NMail/trunk/NMail/DataTypes/LocalStore/ILocalStore.cs 2007-03-13 05:05:16 UTC (rev 176)
+++ NMail/trunk/NMail/DataTypes/LocalStore/ILocalStore.cs 2007-03-13 05:07:34 UTC (rev 177)
@@ -396,33 +396,28 @@
/// </summary>
/// <param name="authToken">The authentication credentials.</param>
/// <returns>The list of users.</returns>
- LocalStoreUser[] GetUsers(IAuthenticationToken authToken);
+ IList<LocalStoreUser> GetUsers(IAuthenticationToken authToken);
/// <summary>
/// Creates a new user in the local store and creates an initial folder.
/// </summary>
/// <param name="authToken">The authentication credentials.</param>
- /// <param name="userName">The name of the new user.</param>
- /// <param name="warnQuota">The warning quota level.</param>
- /// <param name="hardQuota">The hard quota.</param>
- /// <returns>The result of the attemp to create a new user.</returns>
- LocalStoreUserResult CreateUser(IAuthenticationToken authToken, string userName, int? warnQuota, int? hardQuota);
+ /// <param name="user">The user to create.</param>
+ void CreateUser(IAuthenticationToken authToken, LocalStoreUser user);
/// <summary>
/// Removes a user from the local store.
/// </summary>
/// <param name="authToken">The authentication credentials.</param>
/// <param name="userId">The Id of the user to delete.</param>
- /// <returns>The result of the attempt to delete a user.</returns>
- LocalStoreUserResult DeleteUser(IAuthenticationToken authToken, int userId);
+ void DeleteUser(IAuthenticationToken authToken, int userId);
/// <summary>
/// Updates the any changes to the user into the local store.
/// </summary>
/// <param name="authToken">The authentication credentials.</param>
/// <param name="user">The user details to update.</param>
- /// <returns>The result of the attempt to update the user.</returns>
- LocalStoreUserResult UpdateUser(IAuthenticationToken authToken, LocalStoreUser user);
+ void UpdateUser(IAuthenticationToken authToken, LocalStoreUser user);
/// <summary>
/// Gets the list of email addresses that map to the given user.
@@ -430,7 +425,7 @@
/// <param name="authToken">The authentication credentials.</param>
/// <param name="userId">The Id of the user to look up the addresses for.</param>
/// <returns>The user's email addresses.</returns>
- EmailAddress[] GetUserAddresses(IAuthenticationToken authToken, int userId);
+ IList<EmailAddress> GetUserAddresses(IAuthenticationToken authToken, int userId);
/// <summary>
/// Gets a list of folder that belong to the user with the given user Id.
@@ -438,7 +433,7 @@
/// <param name="authToken">The authentication credentials.</param>
/// <param name="userId">The Id of the user to get the folder for.</param>
/// <returns>The list of folders or null if the user Id is invalid or unauthorized.</returns>
- StoreFolder[] GetUserFolders(IAuthenticationToken authToken, int userId);
+ IList<StoreFolder> GetUserFolders(IAuthenticationToken authToken, int userId);
#endregion
#region Group Management
@@ -654,7 +649,7 @@
/// <summary>
/// An unknown error occurred trying to perform the operation.
/// </summary>
- UnkownError = 7
+ UnknownError = 7
}
/// <summary>
Modified: NMail/trunk/NMail/DataTypes/LocalStore/ILocalStoreData.cs
===================================================================
--- NMail/trunk/NMail/DataTypes/LocalStore/ILocalStoreData.cs 2007-03-13 05:05:16 UTC (rev 176)
+++ NMail/trunk/NMail/DataTypes/LocalStore/ILocalStoreData.cs 2007-03-13 05:07:34 UTC (rev 177)
@@ -318,37 +318,42 @@
/// Gets the list of users that currently exist in the local store.
/// </summary>
/// <returns>The list of users.</returns>
- LocalStoreUser[] GetUsers();
+ IList<LocalStoreUser> GetUsers();
/// <summary>
/// Creates a new user in the local store and creates an initial folder.
/// </summary>
- /// <param name="userName">The name of the new user.</param>
- /// <param name="warnQuota">The warning quota level.</param>
- /// <param name="hardQuota">The hard quota.</param>
- /// <returns>The result of the attemp to create a new user.</returns>
- LocalStoreUserResult CreateUser(string userName, int? warnQuota, int? hardQuota);
+ /// <param name="user">The user to create.</param>
+ /// <exception cref="System.Data.DuplicateNameException">If a user with the same name already exists.</exception>
+ /// <exception cref="System.InvalidOperationException">Changes to the user are not permitted.</exception>
+ /// <exception cref="System.ArgumentException">The user is invalid.</exception>
+ void CreateUser(LocalStoreUser user);
/// <summary>
/// Removes a user from the local store.
/// </summary>
/// <param name="userId">The Id of the user to delete.</param>
- /// <returns>The result of the attempt to delete a user.</returns>
- LocalStoreUserResult DeleteUser(int userId);
+ /// <exception cref="System.Data.DuplicateNameException">If a user with the same name already exists.</exception>
+ /// <exception cref="System.InvalidOperationException">Changes to the user are not permitted.</exception>
+ /// <exception cref="System.ArgumentException">The user is invalid.</exception>
+ /// <exception cref="System.Data.ConstraintException">User still has folders.</exception>
+ void DeleteUser(int userId);
/// <summary>
/// Updates the any changes to the user into the local store.
/// </summary>
/// <param name="user">The user details to update.</param>
- /// <returns>The result of the attempt to update the user.</returns>
- LocalStoreUserResult UpdateUser(LocalStoreUser user);
+ /// <exception cref="System.Data.DuplicateNameException">If a user with the same name already exists.</exception>
+ /// <exception cref="System.InvalidOperationException">Changes to the user are not permitted.</exception>
+ /// <exception cref="System.ArgumentException">The user is invalid.</exception>
+ void UpdateUser(LocalStoreUser user);
/// <summary>
/// Gets a list of folder that belong to the user with the given user Id.
/// </summary>
/// <param name="userId">The Id of the user to get the folder for.</param>
/// <returns>The list of folders or null if the user Id is invalid.</returns>
- StoreFolder[] GetUserFolders(int userId);
+ IList<StoreFolder> GetUserFolders(int userId);
#endregion
#region Group Management
Modified: NMail/trunk/NMail/DataTypes/LocalStore/LocalStoreUser.cs
===================================================================
--- NMail/trunk/NMail/DataTypes/LocalStore/LocalStoreUser.cs 2007-03-13 05:05:16 UTC (rev 176)
+++ NMail/trunk/NMail/DataTypes/LocalStore/LocalStoreUser.cs 2007-03-13 05:07:34 UTC (rev 177)
@@ -27,6 +27,11 @@
/// </summary>
[Serializable]
public class LocalStoreUser {
+ /// <summary>
+ /// Creates a new local store user.
+ /// </summary>
+ public LocalStoreUser() { }
+
/// <summary>
/// Creates a new local store user with the given details.
/// </summary>
Modified: NMail/trunk/NMail.Administration.Console/Command/AddUserCommand.cs
===================================================================
--- NMail/trunk/NMail.Administration.Console/Command/AddUserCommand.cs 2007-03-13 05:05:16 UTC (rev 176)
+++ NMail/trunk/NMail.Administration.Console/Command/AddUserCommand.cs 2007-03-13 05:07:34 UTC (rev 177)
@@ -92,16 +92,24 @@
System.Console.WriteLine("Error parsing quota values.");
return;
}
+
}
- LocalStoreUserResult result = this.localStore.CreateUser(this.authToken, username, warnQuota, hardQuota);
+ LocalStoreUser user = new LocalStoreUser();
+ user.Username = username;
+ user.QuotaHardLimit = hardQuota;
+ user.QuotaWarnLimit = warnQuota;
- if (result == LocalStoreUserResult.AlreadyExists) {
+ try {
+ this.localStore.CreateUser(this.authToken, user);
+
+ user = this.localStore.GetUser(null, username);
+ System.Console.WriteLine("Added user \"{0}\", user Id {1}.", user.Username, user.UserId);
+
+ } catch (System.Data.DuplicateNameException) {
System.Console.WriteLine("User with the the same username already exists.");
- } else {
- LocalStoreUser user = this.localStore.GetUser(null, username);
- System.Console.WriteLine("Added user \"{0}\", user Id {1}.", user.Username, user.UserId);
}
+
System.Console.WriteLine();
}
Modified: NMail/trunk/NMail.Administration.Console/Command/DeleteUserCommand.cs
===================================================================
--- NMail/trunk/NMail.Administration.Console/Command/DeleteUserCommand.cs 2007-03-13 05:05:16 UTC (rev 176)
+++ NMail/trunk/NMail.Administration.Console/Command/DeleteUserCommand.cs 2007-03-13 05:07:34 UTC (rev 177)
@@ -82,13 +82,13 @@
return;
}
- LocalStoreUserResult result = this.localStore.DeleteUser(null, user.UserId);
+ try {
+ this.localStore.DeleteUser(null, user.UserId);
+ System.Console.WriteLine("User deleted.");
- if (result == LocalStoreUserResult.OkSuccessful) {
- System.Console.WriteLine("User deleted.");
- } else if (result == LocalStoreUserResult.UserStillHasFolders) {
+ } catch (System.Data.ConstraintException) {
System.Console.WriteLine("Cannot delete the user because they still own folders.");
- } else {
+ } catch {
System.Console.WriteLine("Unknown error deleting the user.");
}
Modified: NMail/trunk/NMail.Administration.Console/Command/ListUserAddressesCommand.cs
===================================================================
--- NMail/trunk/NMail.Administration.Console/Command/ListUserAddressesCommand.cs 2007-03-13 05:05:16 UTC (rev 176)
+++ NMail/trunk/NMail.Administration.Console/Command/ListUserAddressesCommand.cs 2007-03-13 05:07:34 UTC (rev 177)
@@ -63,7 +63,7 @@
return;
}
- EmailAddress[] addresses = this.localStore.GetUserAddresses(null, user.UserId);
+ IList<EmailAddress> addresses = this.localStore.GetUserAddresses(null, user.UserId);
System.Console.WriteLine();
System.Console.WriteLine(string.Format("{0,-50}", "Addresses"));
Modified: NMail/trunk/NMail.Administration.Console/Command/ListUsersCommand.cs
===================================================================
--- NMail/trunk/NMail.Administration.Console/Command/ListUsersCommand.cs 2007-03-13 05:05:16 UTC (rev 176)
+++ NMail/trunk/NMail.Administration.Console/Command/ListUsersCommand.cs 2007-03-13 05:07:34 UTC (rev 177)
@@ -54,7 +54,7 @@
}
public void Process(string[] commandTokens) {
- LocalStoreUser[] users = this.localStore.GetUsers(this.authToken);
+ IList<LocalStoreUser> users = this.localStore.GetUsers(this.authToken);
System.Console.WriteLine();
System.Console.WriteLine(string.Format("{0,-7} {1,-25} {2,-10} {3,-10}", "User Id", "Username", "Warn Quota", "Hard Quota"));
Modified: NMail/trunk/NMail.LocalStore/LocalStore.cs
===================================================================
--- NMail/trunk/NMail.LocalStore/LocalStore.cs 2007-03-13 05:05:16 UTC (rev 176)
+++ NMail/trunk/NMail.LocalStore/LocalStore.cs 2007-03-13 05:07:34 UTC (rev 177)
@@ -1012,23 +1012,23 @@
return LocalStoreData.GetUser(userId);
}
- public LocalStoreUser[] GetUsers(IAuthenticationToken authToken) {
+ public IList<LocalStoreUser> GetUsers(IAuthenticationToken authToken) {
return LocalStoreData.GetUsers();
}
- public LocalStoreUserResult CreateUser(IAuthenticationToken authToken, string userName, int? quota, int? warnQuota) {
- return LocalStoreData.CreateUser(userName, quota, warnQuota);
+ public void CreateUser(IAuthenticationToken authToken, LocalStoreUser user) {
+ LocalStoreData.CreateUser(user);
}
- public LocalStoreUserResult DeleteUser(IAuthenticationToken authToken, int userId) {
- return LocalStoreData.DeleteUser(userId);
+ public void DeleteUser(IAuthenticationToken authToken, int userId) {
+ LocalStoreData.DeleteUser(userId);
}
- public LocalStoreUserResult UpdateUser(IAuthenticationToken authToken, LocalStoreUser user) {
- return LocalStoreData.UpdateUser(user);
+ public void UpdateUser(IAuthenticationToken authToken, LocalStoreUser user) {
+ LocalStoreData.UpdateUser(user);
}
- public EmailAddress[] GetUserAddresses(IAuthenticationToken authToken, int userId) {
+ public IList<EmailAddress> GetUserAddresses(IAuthenticationToken authToken, int userId) {
List<EmailAddress> result = new List<EmailAddress>();
MailDomain[] mailDomains = LocalStoreData.GetMailDomains();
LocalStoreUser user = LocalStoreData.GetUser(userId);
@@ -1045,7 +1045,7 @@
}
}
- return result.ToArray();
+ return result;
}
/// <summary>
@@ -1054,7 +1054,7 @@
/// <param name="authToken">The authentication credentials.</param>
/// <param name="userId">The Id of the user to get the folder for.</param>
/// <returns>The list of folders or null if the user Id is invalid or unauthorized.</returns>
- public StoreFolder[] GetUserFolders(IAuthenticationToken authToken, int userId) {
+ public IList<StoreFolder> GetUserFolders(IAuthenticationToken authToken, int userId) {
return this.LocalStoreData.GetUserFolders(userId);
}
#endregion
Modified: NMail/trunk/NMail.LocalStoreData.MySql/MySqlLocalStore.sql
===================================================================
--- NMail/trunk/NMail.LocalStoreData.MySql/MySqlLocalStore.sql 2007-03-13 05:05:16 UTC (rev 176)
+++ NMail/trunk/NMail.LocalStoreData.MySql/MySqlLocalStore.sql 2007-03-13 05:07:34 UTC (rev 177)
@@ -458,12 +458,12 @@
QuotaHardLimit INT,
QuotaWarnLimit INT,
OUT UserId INT,
+ OUT UserFolderId INT,
OUT Result INT
)
BEGIN
DECLARE NamespaceId INT;
DECLARE InboxName VARCHAR(1000);
- DECLARE UserFolderId INT;
DECLARE UserInboxId INT;
DECLARE CreateResult INT;
Modified: NMail/trunk/NMail.LocalStoreData.MySql/MySqlLocalStoreData.cs
===================================================================
--- NMail/trunk/NMail.LocalStoreData.MySql/MySqlLocalStoreData.cs 2007-03-13 05:05:16 UTC (rev 176)
+++ NMail/trunk/NMail.LocalStoreData.MySql/MySqlLocalStoreData.cs 2007-03-13 05:07:34 UTC (rev 177)
@@ -19,6 +19,8 @@
using System.Collections;
using System.Collections.Generic;
using System.Data;
+using System.IO;
+using System.Reflection;
using System.Security.Cryptography;
using System.Text;
@@ -306,11 +308,11 @@
cmd.CommandText = "DeleteFolder";
cmd.Parameters.Add("?DeleteFolderId", folderId);
cmd.Parameters.Add("?Result", MySqlDbType.Int32);
- cmd.Parameters["Result"].Direction = ParameterDirection.Output;
+ cmd.Parameters["?Result"].Direction = ParameterDirection.Output;
cmd.ExecuteNonQuery();
- int result = (int) cmd.Parameters["Result"].Value;
+ int result = (int) cmd.Parameters["?Result"].Value;
return (LocalStoreFolderResult) result;
}
@@ -1010,7 +1012,7 @@
/// Gets the list of users that currently exist in the local store.
/// </summary>
/// <returns>The list of users.</returns>
- public LocalStoreUser[] GetUsers() {
+ public IList<LocalStoreUser> GetUsers() {
using (MySqlConnection cnn = MySqlHelper.GetConnection()) {
MySqlTransaction transaction = cnn.BeginTransaction();
@@ -1035,7 +1037,7 @@
}
transaction.Commit();
- return users.ToArray();
+ return users;
} catch (Exception ex) {
if (transaction != null) {
@@ -1052,28 +1054,34 @@
/// <summary>
/// Creates a new user in the local store and creates an initial folder.
/// </summary>
- /// <param name="userName">The name of the new user.</param>
- /// <param name="warnQuota">The warning quota level.</param>
- /// <param name="hardQuota">The hard quota.</param>
- /// <returns>The result of the attemp to create a new user.</returns>
- public LocalStoreUserResult CreateUser(string username, int? warnQuota, int? hardQuota) {
+ /// <param name="user">The new user.</param>
+ public void CreateUser(LocalStoreUser user) {
using (MySqlConnection cnn = MySqlHelper.GetConnection()) {
using (MySqlCommand cmd = cnn.CreateCommand()) {
cmd.CommandType = CommandType.StoredProcedure;
cmd.CommandText = "CreateUser";
- cmd.Parameters.Add("?Name", username);
- cmd.Parameters.Add("?QuotaHardLimit", hardQuota);
- cmd.Parameters.Add("?QuotaWarnLimit", warnQuota);
+ cmd.Parameters.Add("?Name", user.Username);
+ cmd.Parameters.Add("?QuotaHardLimit", user.QuotaHardLimit);
+ cmd.Parameters.Add("?QuotaWarnLimit", user.QuotaWarnLimit);
cmd.Parameters.Add("?UserId", MySqlDbType.Int32);
- cmd.Parameters.Add("?Result", MySqlDbType.Int32);
- cmd.Parameters["UserId"].Direction = ParameterDirection.Output;
- cmd.Parameters["Result"].Direction = ParameterDirection.Output;
+ cmd.Parameters.Add("?UserFolderId", MySqlDbType.Int32);
+ cmd.Parameters.Add("?Result", MySqlDbType.Int32);
+ cmd.Parameters["?UserId"].Direction = ParameterDirection.Output;
+ cmd.Parameters["?UserFolderId"].Direction = ParameterDirection.Output;
+ cmd.Parameters["?Result"].Direction = ParameterDirection.Output;
cmd.ExecuteNonQuery();
- int result = (int) cmd.Parameters["Result"].Value;
+ LocalStoreUserResult result = (LocalStoreUserResult)((int) cmd.Parameters["?Result"].Value);
+
+ if (result == LocalStoreUserResult.AlreadyExists) {
+ throw new DuplicateNameException("User with the same name already exists.");
+ } else if (result == LocalStoreUserResult.NotPermitted) {
+ throw new InvalidOperationException("Not permitted.");
+ }
- return (LocalStoreUserResult) result;
+ user.UserId = (int) cmd.Parameters["?UserId"].Value;
+ user.UserFolderId = (int) cmd.Parameters["?UserFolderId"].Value;
}
}
}
@@ -1085,20 +1093,28 @@
/// </summary>
/// <param name="userId">The Id of the user to delete.</param>
/// <returns>The result of the attempt to delete a user.</returns>
- public LocalStoreUserResult DeleteUser(int userId) {
+ public void DeleteUser(int userId) {
using (MySqlConnection cnn = MySqlHelper.GetConnection()) {
using (MySqlCommand cmd = cnn.CreateCommand()) {
cmd.CommandType = CommandType.StoredProcedure;
cmd.CommandText = "DeleteUser";
cmd.Parameters.Add("?DeleteUserId", userId);
cmd.Parameters.Add("?Result", MySqlDbType.Int32);
- cmd.Parameters["Result"].Direction = ParameterDirection.Output;
+ cmd.Parameters["?Result"].Direction = ParameterDirection.Output;
cmd.ExecuteNonQuery();
- int result = (int) cmd.Parameters["Result"].Value;
+ LocalStoreUserResult result = (LocalStoreUserResult) ((int) cmd.Parameters["?Result"].Value);
- return (LocalStoreUserResult) result;
+ if (result == LocalStoreUserResult.AlreadyExists) {
+ throw new DuplicateNameException("User with the same name already exists.");
+ } else if (result == LocalStoreUserResult.UserStillHasFolders) {
+ throw new ConstraintException("User still has folders.");
+ } else if (result == LocalStoreUserResult.NotPermitted) {
+ throw new InvalidOperationException("Not permitted.");
+ } else if (result == LocalStoreUserResult.NoSuchUser) {
+ throw new ArgumentException("No such user.");
+ }
}
}
}
@@ -1110,7 +1126,7 @@
/// </summary>
/// <param name="user">The user details to update.</param>
/// <returns>The result of the attempt to update the user.</returns>
- public LocalStoreUserResult UpdateUser(LocalStoreUser user) {
+ public void UpdateUser(LocalStoreUser user) {
using (MySqlConnection cnn = MySqlHelper.GetConnection()) {
using (MySqlCommand cmd = cnn.CreateCommand()) {
cmd.CommandType = CommandType.StoredProcedure;
@@ -1124,9 +1140,15 @@
cmd.ExecuteNonQuery();
- int result = (int) cmd.Parameters["Result"].Value;
+ LocalStoreUserResult result = (LocalStoreUserResult)((int) cmd.Parameters["Result"].Value);
- return (LocalStoreUserResult) result;
+ if (result == LocalStoreUserResult.AlreadyExists) {
+ throw new DuplicateNameException("User with the same name already exists.");
+ } else if (result == LocalStoreUserResult.NotPermitted) {
+ throw new InvalidOperationException("Not permitted.");
+ } else if (result == LocalStoreUserResult.NoSuchUser) {
+ throw new ArgumentException("No such user.");
+ }
}
}
}
@@ -1137,7 +1159,7 @@
/// </summary>
/// <param name="userId">The Id of the user to get the folder for.</param>
/// <returns>The list of folders or null if the user Id is invalid.</returns>
- public StoreFolder[] GetUserFolders(int userId) {
+ public IList<StoreFolder> GetUserFolders(int userId) {
using (MySqlConnection cnn = MySqlHelper.GetConnection()) {
using (MySqlCommand cmd = cnn.CreateCommand()) {
cmd.CommandType = CommandType.StoredProcedure;
@@ -1159,7 +1181,7 @@
folders.Add(new StoreFolder(nameSpace, name, folderId, parentId, userId, false));
}
- return folders.ToArray();
+ return folders;
}
}
}
@@ -1770,6 +1792,17 @@
public void ReinstallSchema() {
new NHibernate.Tool.hbm2ddl.SchemaExport(this.hibernateCfg).Create(false, true);
+
+ Stream stream = Assembly.GetExecutingAssembly().GetManifestResourceStream("NMail.LocalStoreData.MySql.MySqlLocalStore.sql");
+ TextReader reader = new StreamReader(stream);
+ string schemaSql = reader.ReadToEnd();
+
+ using (MySqlConnection cnn = MySqlHelper.GetConnection()) {
+ using (MySqlCommand cmd = cnn.CreateCommand()) {
+ cmd.CommandText = schemaSql;
+ cmd.ExecuteNonQuery();
+ }
+ }
}
}
}
Modified: NMail/trunk/NMail.LocalStoreData.MySql/NMail.LocalStoreData.MySql.csproj
===================================================================
--- NMail/trunk/NMail.LocalStoreData.MySql/NMail.LocalStoreData.MySql.csproj 2007-03-13 05:05:16 UTC (rev 176)
+++ NMail/trunk/NMail.LocalStoreData.MySql/NMail.LocalStoreData.MySql.csproj 2007-03-13 05:07:34 UTC (rev 177)
@@ -115,9 +115,9 @@
<SubType>Code</SubType>
</Compile>
<Compile Include="MySqlUserMap.cs" />
- <Content Include="MySqlLocalStore.sql">
+ <EmbeddedResource Include="MySqlLocalStore.sql">
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
- </Content>
+ </EmbeddedResource>
<Content Include="NMail.LocalStoreData.Mysql.build" />
<EmbeddedResource Include="Resources\hibernate-configuration.xml" />
<EmbeddedResource Include="Resources\NMail.LocalStoreData.MySql.hbm.xml" />
Modified: NMail/trunk/NMail.LocalStoreData.MySql/Resources/NMail.LocalStoreData.MySql.hbm.xml
===================================================================
--- NMail/trunk/NMail.LocalStoreData.MySql/Resources/NMail.LocalStoreData.MySql.hbm.xml 2007-03-13 05:05:16 UTC (rev 176)
+++ NMail/trunk/NMail.LocalStoreData.MySql/Resources/NMail.LocalStoreData.MySql.hbm.xml 2007-03-13 05:07:34 UTC (rev 177)
@@ -8,168 +8,9 @@
- ACLs (system)
-->
- <!--
- -
- - Folder
- -
- -->
- <class name="NMail.DataTypes.LocalStore.StoreFolder" table="Folder">
- <id name="FolderId" type="Int32" unsaved-value="0">
- <column name="FolderId" not-null="true"/>
- <generator class="native" />
- </id>
-
- <property name="FullFolderName" not-null="true"/>
-
- <property name="NameSpace" not-null="true" />
-
- <!-- TODO: lookup how best to implement this nullable type... -->
- <!-- <many-to-one name="ParentId" foreign-key="FolderId" /> -->
- <!--<property name="ParentId" type="Int32?" />-->
-
- <many-to-one name="OwnerUserId" class="NMail.DataTypes.LocalStore.LocalStoreUser" foreign-key="UserId"/>
-
- <list name="ChildrenIds" cascade="all">
- <key column="FolderId" />
- <index column="ChildIndex" type="Int32" />
- <one-to-many class="NMail.DataTypes.LocalStore.StoreFolder" />
- </list>
- </class>
-
<!--
-
- - Local Store User
- -
- -->
- <class name="NMail.DataTypes.LocalStore.LocalStoreUser" table="t_User">
- <id name="UserId" type="Int32" unsaved-value="0">
- <column name="UserId" not-null="true"/>
- <generator class="native" />
- </id>
-
- <property name="Username" not-null="true"/>
-
- <many-to-one name="UserFolderId" class="NMail.DataTypes.LocalStore.StoreFolder" foreign-key="FolderId" />
-
- <property name="QuotaHardLimit" />
-
- <property name="QuotaWarnLimit" />
- </class>
-
-
- <!--
- -
- - Local Store Group
- -
- -->
- <class name="NMail.DataTypes.LocalStore.LocalStoreGroup" table="t_Group">
- <id name="GroupId" type="Int32" unsaved-value="0">
- <column name="GroupId" not-null="true"/>
- <generator class="native" />
- </id>
-
- <property name="Name" not-null="true"/>
-
- <list name="SubGroupIds" table="GroupSubGroups">
- <key column="ParentGroupId" />
- <index column="ChildIndex" type="Int32" />
- <many-to-many column="GroupId" class="NMail.DataTypes.LocalStore.LocalStoreGroup" />
- </list>
-
- <list name="UserIds" table="GroupUsers">
- <key column="GroupId" />
- <index column="ChildIndex" type="Int32" />
- <many-to-many column="UserId" class="NMail.DataTypes.LocalStore.LocalStoreUser" />
- </list>
- </class>
-
-
- <!--
- -
- - Mail Domain
- -
- -->
- <class name="NMail.DataTypes.LocalStore.MailDomain" table="MailDomain">
- <id name="MailDomainId" type="Int32" unsaved-value="0">
- <column name="MailDomainId" not-null="true"/>
- <generator class="native" />
- </id>
-
- <property name="PrimaryHost" not-null="true" />
-
- <list name="GroupIds" table="MailDomainGroups">
- <key column="MailDomainId" />
- <index column="ChildIndex" type="Int32" />
- <many-to-many column="GroupId" class="NMail.DataTypes.LocalStore.LocalStoreGroup" />
- </list>
-
- <list name="UserIds" table="MailDomainUsers">
- <key column="MailDomainId" />
- <index column="ChildIndex" type="Int32" />
- <many-to-many column="UserId" class="NMail.DataTypes.LocalStore.LocalStoreUser" />
- </list>
-
- <list name="AdditionalHosts" table="MailDomainHosts">
- <key column="MailDomainId" />
- <index column="ChildIndex" type="Int32" />
- <element column="Host" unique="true" type="Serializable" />
- </list>
- </class>
-
-
- <!--
- -
- - Folder ACL
- -
- -->
- <class name="NMail.DataTypes.ACLs.StoreFolderAcl" table="StoreFolderAcl">
- <id name="AclId" type="Int32" unsaved-value="0">
- <column name="AclId" not-null="true"/>
- <generator class="native" />
- </id>
-
- <many-to-one name="Folder" cascade="all" class="NMail.DataTypes.LocalStore.StoreFolder" not-null="true"/>
-
- <map name="entries" access="field" table="StoreFolderAclEntries">
- <key column="IdentifierId" />
- <index column="Identifier" type="String" />
- <element column="StoreFolderPrivilege" type="Int32" />
- </map>
- </class>
-
-
- <!--
- -
- - Message
- -
- - ->
- <class name="NMail.DataTypes.Message" table="Message">
- <id name="MessageId" type="Int64" unsaved-value="0">
- <column name="MessageId" not-null="true"/>
- <generator class="native" />
- </id>
-
- <many-to-one name="FolderId" class="NMail.DataTypes.LocalStore.StoreFolder" foreign-key="FolderId" />
-
- <!- -
- FolderMessageId INT NOT NULL,
-
- MimeMessage BOOLEAN NOT NULL,
- Headers LONGBLOB NOT NULL,
- Preamble LONGBLOB,
- Postamble LONGBLOB,
- MessageFlags INT NOT NULL,
- Size INT NOT NULL,
- InternalDate DATETIME NOT NULL,
- PRIMARY KEY(MessageId),
- INDEX FolderId (FolderId),
- FOREIGN KEY (FolderId) REFERENCES Folder (FolderId) ON DELETE CASCADE - ->
- </class> -->
-
-
- <!--
- -
- Calendar
-
-->
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|