nmailserver-commits Mailing List for NMail (Page 5)
Brought to you by:
dframpton-oss,
tmyroadctfig
You can subscribe to this list here.
| 2006 |
Jan
|
Feb
|
Mar
|
Apr
|
May
(13) |
Jun
(14) |
Jul
(8) |
Aug
|
Sep
|
Oct
(8) |
Nov
(22) |
Dec
(9) |
|---|---|---|---|---|---|---|---|---|---|---|---|---|
| 2007 |
Jan
(21) |
Feb
(31) |
Mar
(24) |
Apr
(8) |
May
(23) |
Jun
(40) |
Jul
(14) |
Aug
(5) |
Sep
(7) |
Oct
(10) |
Nov
|
Dec
|
| 2008 |
Jan
|
Feb
|
Mar
|
Apr
|
May
|
Jun
(1) |
Jul
|
Aug
|
Sep
|
Oct
|
Nov
|
Dec
|
|
From: <tmy...@us...> - 2007-04-30 08:59:20
|
Revision: 187
http://svn.sourceforge.net/nmailserver/?rev=187&view=rev
Author: tmyroadctfig
Date: 2007-04-30 01:59:18 -0700 (Mon, 30 Apr 2007)
Log Message:
-----------
Further work on local store data. Restructure Message related classes. Fixed a major defect in MySql authentication. More work on unit tests.
Modified Paths:
--------------
NMail/trunk/NMail/Authentication/BasicAuthToken.cs
NMail/trunk/NMail/Authentication/IAuthenticationProvider.cs
NMail/trunk/NMail/DataTypes/ACLs/GenericAce.cs
NMail/trunk/NMail/DataTypes/ACLs/SystemPrivilege.cs
NMail/trunk/NMail/DataTypes/LocalStore/ILocalStore.cs
NMail/trunk/NMail/DataTypes/LocalStore/ILocalStoreData.cs
NMail/trunk/NMail/DataTypes/LocalStore/LocalStoreDelivery.cs
NMail/trunk/NMail/DataTypes/SmtpMessage.cs
NMail/trunk/NMail/DataTypes/Spool/SpoolEnvelope.cs
NMail/trunk/NMail/Helper/MessageHelper.cs
NMail/trunk/NMail/Helper/MimeHelper.cs
NMail/trunk/NMail/NMail.csproj
NMail/trunk/NMail.ImapService/State/AuthenticatedState.cs
NMail/trunk/NMail.ImapService/State/ExamineState.cs
NMail/trunk/NMail.ImapService/State/SelectedState.cs
NMail/trunk/NMail.LocalStore/DeliveryActions/ManageWhiteList.cs
NMail/trunk/NMail.LocalStore/LocalStore.cs
NMail/trunk/NMail.LocalStoreData.MySql/MySqlAuthProvider.cs
NMail/trunk/NMail.LocalStoreData.MySql/MySqlLocalStoreData.cs
NMail/trunk/NMail.LocalStoreData.NHibernate/InternalMessage.cs
NMail/trunk/NMail.LocalStoreData.NHibernate/Mappings/NMail.LocalStoreData.NHibernate.InternalMessage.hbm.xml
NMail/trunk/NMail.LocalStoreData.NHibernate/NHibernateAuthProvider.cs
NMail/trunk/NMail.LocalStoreData.NHibernate/NHibernateLocalStoreData.cs
NMail/trunk/NMail.LocalStoreData.NHibernate/NMail.LocalStoreData.NHibernate.csproj
NMail/trunk/NMail.MessageRouter/MessageRouter.cs
NMail/trunk/NMail.RemoteAccessService.Serializers/DataTypes/BodyStructureSerializer.cs
NMail/trunk/NMail.RemoteAccessService.Serializers/DataTypes/EnvelopeSerializer.cs
NMail/trunk/NMail.RemoteAccessService.Serializers/DataTypes/MessageHeadersSerializer.cs
NMail/trunk/NMail.Sendmail/Sendmail.cs
NMail/trunk/NMail.SmtpClient/SmtpClientConnection.cs
NMail/trunk/NMail.SmtpService/Command/DataCommand.cs
NMail/trunk/NMail.SpoolData.MySql/MySqlSpoolData.cs
NMail/trunk/NMail.UnitTests/DataTypes/MessageHeaderTests.cs
NMail/trunk/NMail.UnitTests/LocalStoreData/DeliverMessageTest1.cs
NMail/trunk/NMail.UnitTests/LocalStoreData/GetMessageIdTest1.cs
NMail/trunk/NMail.UnitTests/LocalStoreData/GetMessageIdsTest1.cs
NMail/trunk/NMail.UnitTests/LocalStoreData/GetMessageOffsetTest1.cs
NMail/trunk/NMail.UnitTests/LocalStoreData/GetNextMessageIdTest1.cs
NMail/trunk/NMail.UnitTests/LocalStoreData/GetSetMessageFlagsTest1.cs
NMail/trunk/NMail.UnitTests/NMail.UnitTests.csproj
NMail/trunk/NMail.UnitTests/Resources/ResourceHelper.cs
Added Paths:
-----------
NMail/trunk/NMail/DataTypes/Message/
NMail/trunk/NMail/DataTypes/Message/BodyStructure.cs
NMail/trunk/NMail/DataTypes/Message/Envelope.cs
NMail/trunk/NMail/DataTypes/Message/IMessageBodyPart.cs
NMail/trunk/NMail/DataTypes/Message/IMessagePart.cs
NMail/trunk/NMail/DataTypes/Message/IMultipartMessageBody.cs
NMail/trunk/NMail/DataTypes/Message/Message.cs
NMail/trunk/NMail/DataTypes/Message/MessageDataPart.cs
NMail/trunk/NMail/DataTypes/Message/MessageHeaders.cs
NMail/trunk/NMail/DataTypes/Message/MultipartMessageBody.cs
NMail/trunk/NMail/DataTypes/Message/SimpleMessageBody.cs
NMail/trunk/NMail.LocalStoreData.NHibernate/AuthenticationUser.cs
NMail/trunk/NMail.LocalStoreData.NHibernate/InternalSystemAce.cs
NMail/trunk/NMail.LocalStoreData.NHibernate/InternalUserObject.cs
NMail/trunk/NMail.LocalStoreData.NHibernate/Mappings/NMail.Authentication.BasicAuthToken.hbm.xml
NMail/trunk/NMail.LocalStoreData.NHibernate/Mappings/NMail.LocalStoreData.NHibernate.AuthenticationUser.hbm.xml
NMail/trunk/NMail.LocalStoreData.NHibernate/Mappings/NMail.LocalStoreData.NHibernate.InternalSystemAce.hbm.xml
NMail/trunk/NMail.LocalStoreData.NHibernate/Mappings/NMail.LocalStoreData.NHibernate.InternalUserObject.hbm.xml
NMail/trunk/NMail.UnitTests/LocalStoreData/DeliverMessageTest2.cs
NMail/trunk/NMail.UnitTests/LocalStoreData/GetMessageCountTest1.cs
NMail/trunk/NMail.UnitTests/LocalStoreData/GetMessageCountWithFlagsTest1.cs
NMail/trunk/NMail.UnitTests/LocalStoreData/GetMessageDateTest1.cs
NMail/trunk/NMail.UnitTests/LocalStoreData/GetMessageHeadersTest1.cs
NMail/trunk/NMail.UnitTests/LocalStoreData/GetMessageMimePartTest1.cs
NMail/trunk/NMail.UnitTests/LocalStoreData/GetMessageMimePartTest2.cs
NMail/trunk/NMail.UnitTests/LocalStoreData/GetMessageSizeTest1.cs
NMail/trunk/NMail.UnitTests/LocalStoreData/GetMessageTest1.cs
NMail/trunk/NMail.UnitTests/LocalStoreData/LoadSaveObjectTest1.cs
NMail/trunk/NMail.UnitTests/LocalStoreData/PurgeDeletedMessagesTest1.cs
NMail/trunk/NMail.UnitTests/Resources/Test2.eml
Removed Paths:
-------------
NMail/trunk/NMail/DataTypes/BodyStructure.cs
NMail/trunk/NMail/DataTypes/Envelope.cs
NMail/trunk/NMail/DataTypes/IMessageBodyPart.cs
NMail/trunk/NMail/DataTypes/IMessagePart.cs
NMail/trunk/NMail/DataTypes/Message.cs
NMail/trunk/NMail/DataTypes/MessageDataPart.cs
NMail/trunk/NMail/DataTypes/MessageHeaders.cs
NMail/trunk/NMail/DataTypes/MultipartBodyPart.cs
NMail/trunk/NMail/DataTypes/SimpleBodyPart.cs
Modified: NMail/trunk/NMail/Authentication/BasicAuthToken.cs
===================================================================
--- NMail/trunk/NMail/Authentication/BasicAuthToken.cs 2007-04-24 15:46:35 UTC (rev 186)
+++ NMail/trunk/NMail/Authentication/BasicAuthToken.cs 2007-04-30 08:59:18 UTC (rev 187)
@@ -24,6 +24,11 @@
[Serializable]
public class BasicAuthToken : IAuthenticationToken {
/// <summary>
+ /// Creates a new basic authentication token.
+ /// </summary>
+ public BasicAuthToken() { }
+
+ /// <summary>
/// Creates a new basic authentication token with the given username.
/// </summary>
/// <param name="username">The username associated with then authentication token.</param>
@@ -73,5 +78,56 @@
get { return tokenExpiry; }
}
#endregion
+
+ #region Comparison
+ /// <summary>
+ /// Checks if two tokens are equal.
+ /// </summary>
+ /// <param name="other">The token to compare.</param>
+ /// <returns>True if the token names match.</returns>
+ public override bool Equals(object other) {
+ return (other is BasicAuthToken) && this == (BasicAuthToken) other;
+ }
+
+ /// <summary>
+ /// Gets the unique hash code for this object.
+ /// </summary>
+ /// <returns>The hash code.</returns>
+ public override int GetHashCode() {
+ return base.GetHashCode();
+ }
+
+ /// <summary>
+ /// Checks if the given token is equal to this host.
+ /// </summary>
+ /// <param name="tokenA">Token A.</param>
+ /// <param name="tokenB">Token B.</param>
+ /// <returns>True if they are equal.</returns>
+ public static bool operator ==(BasicAuthToken tokenA, BasicAuthToken tokenB) {
+ if ((object) tokenA == null && (object) tokenB == null) {
+ return true;
+ }
+
+ if ((object) tokenA == null || (object) tokenB == null) {
+ return false;
+ }
+
+ return
+ (tokenA.username == tokenB.username) &&
+ (tokenA.tokenId == tokenB.tokenId) &&
+ (tokenA.tokenExpiry == tokenB.tokenExpiry) &&
+ (tokenA.credentialsExpiry == tokenB.credentialsExpiry);
+ }
+
+ /// <summary>
+ /// Checks if the given token is equal to this token.
+ /// </summary>
+ /// <param name="tokenA">Token A.</param>
+ /// <param name="tokenB">Token B.</param>
+ /// <returns>True if they are not equal.</returns>
+ public static bool operator !=(BasicAuthToken tokenA, BasicAuthToken tokenB) {
+ return !(tokenA == tokenB);
+ }
+ #endregion
}
}
Modified: NMail/trunk/NMail/Authentication/IAuthenticationProvider.cs
===================================================================
--- NMail/trunk/NMail/Authentication/IAuthenticationProvider.cs 2007-04-24 15:46:35 UTC (rev 186)
+++ NMail/trunk/NMail/Authentication/IAuthenticationProvider.cs 2007-04-30 08:59:18 UTC (rev 187)
@@ -46,20 +46,6 @@
IAuthenticationToken CreateAuthToken(string username);
/// <summary>
- /// Gets the date and time that the given token will expire.
- /// </summary>
- /// <param name="user">The token to check the expire time for.</param>
- /// <returns>The expiry time.</returns>
- DateTime GetTokenExpiry(IAuthenticationToken user);
-
- /// <summary>
- /// Checks if the given token has expired.
- /// </summary>
- /// <param name="user">The token to check the expire time for.</param>
- /// <returns>True if the token has expired.</returns>
- bool TokenExpired(IAuthenticationToken user);
-
- /// <summary>
/// Checks if the given authentication token is valid.
/// </summary>
/// <param name="user">The token to check.</param>
Modified: NMail/trunk/NMail/DataTypes/ACLs/GenericAce.cs
===================================================================
--- NMail/trunk/NMail/DataTypes/ACLs/GenericAce.cs 2007-04-24 15:46:35 UTC (rev 186)
+++ NMail/trunk/NMail/DataTypes/ACLs/GenericAce.cs 2007-04-30 08:59:18 UTC (rev 187)
@@ -25,7 +25,13 @@
/// </summary>
[Serializable]
public class GenericAce<PrivilegeType> {
+
/// <summary>
+ /// Creates a new empty ACE.
+ /// </summary>
+ public GenericAce() {}
+
+ /// <summary>
/// Creates a new access control entry.
/// </summary>
/// <param name="identifier">The identifier to associated the ACE with.</param>
Modified: NMail/trunk/NMail/DataTypes/ACLs/SystemPrivilege.cs
===================================================================
--- NMail/trunk/NMail/DataTypes/ACLs/SystemPrivilege.cs 2007-04-24 15:46:35 UTC (rev 186)
+++ NMail/trunk/NMail/DataTypes/ACLs/SystemPrivilege.cs 2007-04-30 08:59:18 UTC (rev 187)
@@ -7,7 +7,7 @@
/// The possible privileges a user or group can have on the NMail system.
/// </summary>
[FlagsAttribute]
- public enum SystemPrivilege : uint {
+ public enum SystemPrivilege : int {
/// <summary>
/// No rights are granted.
/// </summary>
Deleted: NMail/trunk/NMail/DataTypes/BodyStructure.cs
===================================================================
--- NMail/trunk/NMail/DataTypes/BodyStructure.cs 2007-04-24 15:46:35 UTC (rev 186)
+++ NMail/trunk/NMail/DataTypes/BodyStructure.cs 2007-04-30 08:59:18 UTC (rev 187)
@@ -1,134 +0,0 @@
-/*
- * Copyright 2004-2006 Luke Quinane
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- *
- */
-
-using System;
-using System.Collections.Generic;
-using System.Text;
-
-using NMail.Helper;
-
-namespace NMail.DataTypes {
- /// <summary>
- /// Represents a the structure of a message body.
- /// </summary>
- [Serializable]
- public class BodyStructure : List<BodyStructure> {
-
- public BodyStructure(IMessageBodyPart bodyPart) {
- this.headers = bodyPart.Headers;
-
- if (bodyPart.MultipartBody) {
- foreach (IMessageBodyPart part in bodyPart.MimeParts) {
- this.Add(new BodyStructure(part));
- }
- } else {
- // Count the number of lines in the message body
- string bodyData = bodyPart.BodyData.ToString();
- int index = bodyData.IndexOf(Message.Terminator);
- while (index != -1) {
- this.bodyLineCount++;
- index = bodyData.IndexOf(Message.Terminator, index + 1);
- }
-
- this.bodyCharacterCount = bodyData.Length;
- this.size = bodyPart.Size;
- }
- }
-
- public BodyStructure(MessageHeaders headers) {
- this.headers = headers;
- }
-
- private MessageHeaders headers;
-
- /// <summary>
- /// The message headers associated with this level of the body structure.
- /// </summary>
- public MessageHeaders Headers {
- get { return headers; }
- set { headers = value; }
- }
-
- private int bodyLineCount;
-
- /// <summary>
- /// The number of lines in the message body. Only valid for bodystructures
- /// without multiple parts.
- /// </summary>
- public int BodyLineCount {
- get { return bodyLineCount; }
- set { bodyLineCount = value; }
- }
-
- private int bodyCharacterCount;
-
- /// <summary>
- /// The number of characters in the body. Only valid for bodystructures
- /// witout multiple parts.
- /// </summary>
- public int BodyCharacterCount {
- get { return bodyCharacterCount; }
- set { bodyCharacterCount = value; }
- }
-
- private int size;
-
- /// <summary>
- /// The size of this part in bytes.
- /// </summary>
- public int Size {
- get { return size; }
- set { size = value; }
- }
-
- public override string ToString() {
- if (this.Count > 0) {
- StringBuilder data = new StringBuilder();
- data.Append("(");
-
- foreach (BodyStructure child in this) {
- data.Append(child.ToString());
- }
-
- data.Append("\"MIXED\")");
- return data.ToString();
-
- } else {
- MimeContentTransferEncoding encoding = MimeHelper.GetTransferEncoding(this.headers);
- MimeContentType contentType = MimeHelper.GetContentType(this.headers);
- string charset = MimeHelper.GetCharacterSet(this.headers);
-
- string encodingStr = encoding.ToString().ToUpper();
- if (encoding == MimeContentTransferEncoding.EightBit) {
- encodingStr = "8bit";
- } else if (encoding == MimeContentTransferEncoding.SevenBit) {
- encodingStr = "7bit";
- }
-
- return string.Format("(\"{0}\" \"{1}\" (\"charset\" \"{2}\") {3} {4} \"{5}\" {6} {7} NIL NIL NIL)",
- contentType.ToString().ToLower(),
- "plain",
- charset,
- "NIL", // body-fld-id
- "NIL", // body-fld-desc
- encodingStr,
- this.bodyCharacterCount,
- this.bodyLineCount);
- }
- }
- }
-}
Deleted: NMail/trunk/NMail/DataTypes/Envelope.cs
===================================================================
--- NMail/trunk/NMail/DataTypes/Envelope.cs 2007-04-24 15:46:35 UTC (rev 186)
+++ NMail/trunk/NMail/DataTypes/Envelope.cs 2007-04-30 08:59:18 UTC (rev 187)
@@ -1,364 +0,0 @@
-/*
- * Copyright 2004-2006 Luke Quinane
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- *
- */
-
-using System;
-using System.Collections.Generic;
-using System.Text;
-
-using NMail.Helper;
-
-namespace NMail.DataTypes {
- /// <summary>
- /// A message envelope. This includes the From, To, Cc, Bcc, Subject
- /// </summary>
- [Serializable]
- public class Envelope {
-
- protected Envelope() { }
-
- /// <summary>
- /// Creates a new envelope from the message headers.
- /// </summary>
- /// <param name="messageHeaders">The headers containing the envelope information.</param>
- public Envelope(MessageHeaders messageHeaders) {
- // These fields should never be null
- this.from = messageHeaders["From"];
- this.date = messageHeaders["Date"];
- this.subject = messageHeaders["Subject"];
-
- this.sender = messageHeaders["Sender"];
- if (this.sender == null || this.sender.Trim() == string.Empty) {
- this.sender = this.from;
- }
- this.replyTo = messageHeaders["Rely-To"];
- if (this.replyTo == null || this.replyTo.Trim() == string.Empty) {
- this.replyTo = this.from;
- }
-
- // These fields can be null
- this.messageId = messageHeaders["Message-Id"];
- if (this.messageId != null && this.messageId.Trim() == string.Empty) {
- this.messageId = null;
- }
- this.to = messageHeaders["To"];
- if (this.to != null && this.to.Trim() == string.Empty) {
- this.to = null;
- }
- this.inReplyTo = messageHeaders["In-Reply-To"];
- if (this.inReplyTo != null && this.inReplyTo.Trim() == string.Empty) {
- this.inReplyTo = null;
- }
- this.bcc = messageHeaders["Bcc"];
- if (this.bcc != null && this.inReplyTo.Trim() == string.Empty) {
- this.bcc = null;
- }
- this.cc = messageHeaders["Cc"];
- if (this.cc != null && this.cc.Trim() == string.Empty) {
- this.cc = null;
- }
- }
-
- /// <summary>
- /// Creates a new envelope with the minimum required fields.
- /// </summary>
- /// <param name="from">The sender of the message.</param>
- /// <param name="date">The date the message was sent.</param>
- /// <param name="subject">The message's subject.</param>
- public Envelope(string from, string date, string subject) {
- this.from = from;
- this.sender = from;
- this.replyTo = from;
-
- this.subject = subject;
- this.date = date;
- }
-
- #region Properties
-
- private string messageId;
-
- /// <summary>
- /// Extracted from the Message-Id header.
- /// </summary>
- public string MessageId {
- get {
- return this.messageId;
- }
- set {
- this.messageId = value;
- }
- }
-
- private string from;
-
- /// <summary>
- /// The value extracted from the From header field.
- /// </summary>
- public string From {
- get {
- return this.from;
- }
- set {
- this.from = value;
- }
- }
-
- private string sender;
-
- /// <summary>
- /// The value extracted from the Sender header field.
- /// </summary>
- public string Sender {
- get {
- return this.sender;
- }
- set {
- this.sender = value;
- }
- }
-
- private string to;
-
- /// <summary>
- /// The value extracted from the To header field.
- /// </summary>
- public string To {
- get {
- return this.to;
- }
- set {
- this.to = value;
- }
- }
-
-
- private string inReplyTo;
-
- /// <summary>
- /// The value extracted from the In-Reply-To header field.
- /// </summary>
- public string InReplyTo {
- get {
- return this.inReplyTo;
- }
- set {
- this.inReplyTo = value;
- }
- }
-
-
- private string replyTo;
-
- /// <summary>
- /// The value extracted from the Reply-To header field.
- /// </summary>
- public string ReplyTo {
- get {
- return this.replyTo;
- }
- set {
- this.replyTo = value;
- }
- }
-
-
- private string bcc;
-
- /// <summary>
- /// The value extracted from the Bcc header field.
- /// </summary>
- public string Bcc {
- get {
- return this.bcc;
- }
- set {
- this.bcc = value;
- }
- }
-
-
- private string cc;
-
- /// <summary>
- /// The value extracted from the Cc header field.
- /// </summary>
- public string Cc {
- get {
- return this.cc;
- }
- set {
- this.cc = value;
- }
- }
-
-
- private string subject;
-
- /// <summary>
- /// The value extracted from the Subject header field.
- /// </summary>
- public string Subject {
- get {
- return this.subject;
- }
- set {
- this.subject = value;
- }
- }
-
-
- private string date;
-
- /// <summary>
- /// The value extracted from the Date header field.
- /// </summary>
- public string Date {
- get {
- return this.date;
- }
- set {
- this.date = value;
- }
- }
- #endregion
-
- #region getEnvelopeImapAddress
- private string getEnvelopeImapAddress(string data) {
- // TODO: handle groups
-
- StringBuilder output = new StringBuilder();
- string[] addresses = StringTokenizer.GetQuotedTokens(data, ",".ToCharArray(), Int32.MaxValue, false);
-
- output.Append("(");
-
- foreach (string address in addresses) {
- string[] tokens = StringTokenizer.GetQuotedTokens(address, " ".ToCharArray(), Int32.MaxValue, true);
- string emailAddress = null;
- string personalName = null;
- string host = null;
- string mailbox = null;
-
- if (tokens.Length > 0) {
- if (tokens[0][0] != '<') {
- personalName = tokens[0];
-
- if (tokens.Length > 1) {
- emailAddress = tokens[1];
- }
- } else {
- // No personal name
- emailAddress = tokens[0];
- }
- }
-
- if (emailAddress != null) {
- try {
- EmailAddress tmpAddress = new EmailAddress(emailAddress, true);
- host = tmpAddress.Host.ToString();
- mailbox = tmpAddress.Mailbox.ToString();
- } catch {
- }
- }
-
- // Append the personal name and source route
- if (personalName != null) {
- output.Append("(\"");
- output.Append(personalName);
- output.Append("\" NIL ");
- } else {
- output.Append("(NIL NIL ");
- }
-
- // Append the mailbox
- if (mailbox != null) {
- output.Append("\"");
- output.Append(mailbox);
- output.Append("\" ");
- } else {
- output.Append("NIL ");
- }
-
- // Append the host
- if (host != null) {
- output.Append("\"");
- output.Append(host);
- output.Append("\")");
- } else {
- output.Append("NIL)");
- }
- }
-
- output.Append(")");
-
- return output.ToString();
- }
- #endregion
-
- #region ToImapEnvelopeString
- /// <summary>
- /// Converts this envelope into a string that can be used in an IMAP envelope
- /// response.
- /// </summary>
- /// <returns>The IMAP envelope string.</returns>
- public string ToImapEnvelopeString() {
- StringBuilder envelope = new StringBuilder();
-
- envelope.Append("ENVELOPE (\"");
- envelope.Append(this.date);
- envelope.Append("\" \"");
- envelope.Append(this.subject);
- envelope.Append("\" ");
-
- // From
- envelope.Append(getEnvelopeImapAddress(this.from));
- envelope.Append(" ");
-
- // Sender
- envelope.Append(getEnvelopeImapAddress(this.sender));
- envelope.Append(" ");
-
- // Reply-To
- envelope.Append(getEnvelopeImapAddress(this.replyTo));
- envelope.Append(" ");
-
- // To
- envelope.Append((this.to == null) ? "NIL" : getEnvelopeImapAddress(this.to));
- envelope.Append(" ");
-
- // Cc
- envelope.Append((this.cc == null) ? "NIL" : getEnvelopeImapAddress(this.cc));
- envelope.Append(" ");
-
- // Bcc
- envelope.Append((this.bcc == null) ? "NIL" : getEnvelopeImapAddress(this.bcc));
- envelope.Append(" ");
-
- // In-Reply-To
- envelope.Append("\"");
- envelope.Append((this.inReplyTo == null) ? "NIL" : this.inReplyTo);
- envelope.Append("\" ");
-
- // Message-Id
- envelope.Append("\"");
- envelope.Append((this.messageId == null) ? "NIL" : this.messageId);
- envelope.Append("\")");
-
- return envelope.ToString();
- }
- #endregion
- }
-}
Deleted: NMail/trunk/NMail/DataTypes/IMessageBodyPart.cs
===================================================================
--- NMail/trunk/NMail/DataTypes/IMessageBodyPart.cs 2007-04-24 15:46:35 UTC (rev 186)
+++ NMail/trunk/NMail/DataTypes/IMessageBodyPart.cs 2007-04-30 08:59:18 UTC (rev 187)
@@ -1,56 +0,0 @@
-/*
- * Copyright 2004-2006 Luke Quinane and Daniel Frampton
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- *
- */
-
-using System;
-using System.Collections.Generic;
-
-namespace NMail.DataTypes {
- /// <summary>
- /// A body part of a RFC 2822 message.
- /// </summary>
- public interface IMessageBodyPart : IMessagePart {
- /// <summary>
- /// Gets or sets the headers associated with this body part.
- /// </summary>
- MessageHeaders Headers { get; set; }
-
- /// <summary>
- /// The data for the body of this body part.
- /// </summary>
- ByteString BodyData { get; }
-
- /// <summary>
- /// Checks if the current body part is a multi-part body.
- /// </summary>
- bool MultipartBody { get; }
-
- /// <summary>
- /// Gets the mime parts of this message part, if any.
- /// </summary>
- IList<IMessageBodyPart> MimeParts { get; }
-
- /// <summary>
- /// Gets the preamble for the message body, if any.
- /// </summary>
- IMessagePart Preamble { get; }
-
- /// <summary>
- /// Gets the postamble for the message body, if any.
- /// </summary>
- IMessagePart Postamble { get; }
- }
-}
Deleted: NMail/trunk/NMail/DataTypes/IMessagePart.cs
===================================================================
--- NMail/trunk/NMail/DataTypes/IMessagePart.cs 2007-04-24 15:46:35 UTC (rev 186)
+++ NMail/trunk/NMail/DataTypes/IMessagePart.cs 2007-04-30 08:59:18 UTC (rev 187)
@@ -1,35 +0,0 @@
-/*
- * Copyright 2004-2006 Luke Quinane and Daniel Frampton
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- *
- */
-
-using System;
-
-namespace NMail.DataTypes {
- /// <summary>
- /// A part of a RFC 2822 message.
- /// </summary>
- public interface IMessagePart {
- /// <summary>
- /// The data as a single string.
- /// </summary>
- ByteString Data { get; }
-
- /// <summary>
- /// The size of the data in bytes.
- /// </summary>
- int Size { get; }
- }
-}
Modified: NMail/trunk/NMail/DataTypes/LocalStore/ILocalStore.cs
===================================================================
--- NMail/trunk/NMail/DataTypes/LocalStore/ILocalStore.cs 2007-04-24 15:46:35 UTC (rev 186)
+++ NMail/trunk/NMail/DataTypes/LocalStore/ILocalStore.cs 2007-04-30 08:59:18 UTC (rev 187)
@@ -22,6 +22,7 @@
using NMail.DataTypes;
using NMail.DataTypes.ACLs;
using NMail.DataTypes.Calendar;
+using NMail.DataTypes.Message;
namespace NMail.DataTypes.LocalStore {
/// <summary>
@@ -64,7 +65,7 @@
/// <param name="message">The message to deliver.</param>
/// <param name="folder">The folder to deliver the message into.</param>
/// <returns>The result of the delivery.</returns>
- DeliveryResult DeliverMessage(IAuthenticationToken authToken, Message message, StoreFolder folder);
+ DeliveryResult DeliverMessage(IAuthenticationToken authToken, Message.Message message, StoreFolder folder);
#endregion
#region Folder Retrieval and Manipulation
@@ -291,7 +292,7 @@
/// <param name="messageId">The Id of the message to get.</param>
/// <param name="folderId">The Id of the folder the message is in.</param>
/// <returns>The message or null if the message Id is invalid.</returns>
- Message GetMessage(IAuthenticationToken authToken, int messageId, int folderId);
+ Message.Message GetMessage(IAuthenticationToken authToken, int messageId, int folderId);
/// <summary>
/// Gets the body structure for a message.
Modified: NMail/trunk/NMail/DataTypes/LocalStore/ILocalStoreData.cs
===================================================================
--- NMail/trunk/NMail/DataTypes/LocalStore/ILocalStoreData.cs 2007-04-24 15:46:35 UTC (rev 186)
+++ NMail/trunk/NMail/DataTypes/LocalStore/ILocalStoreData.cs 2007-04-30 08:59:18 UTC (rev 187)
@@ -22,6 +22,7 @@
using NMail.DataTypes;
using NMail.DataTypes.ACLs;
using NMail.DataTypes.Calendar;
+using NMail.DataTypes.Message;
namespace NMail.DataTypes.LocalStore {
/// <summary>
@@ -47,7 +48,8 @@
/// </summary>
/// <param name="message">The message data.</param>
/// <param name="folder">The Id of the folder to deliver into.</param>
- void DeliverMessage(Message message, int folderId);
+ /// <exception cref="ArgumentException">The folder Id was invalid.</exception>
+ void DeliverMessage(Message.Message message, int folderId);
#endregion
#region Folder Retrieval and Manipulation
@@ -209,24 +211,24 @@
/// Gets the internal date for the message.
/// </summary>
/// <param name="messageId">The Id of the message to get the date for.</param>
- /// <param name="folder">The folder the message is in.</param>
- /// <returns>The message date.</returns>
- DateTime GetInternalDate(int messageId, StoreFolder folder);
+ /// <param name="folderId">The Id of the folder the message is in.</param>
+ /// <returns>The message date or null if non is found.</returns>
+ DateTime? GetInternalDate(int messageId, int folderId);
/// <summary>
/// Gets the size of the message.
/// </summary>
/// <param name="messageId">The Id of the message to get the size from.</param>
- /// <param name="folder">The folder the message is in.</param>
- /// <returns>The message size in bytes.</returns>
- int GetMessageSize(int messageId, StoreFolder folder);
+ /// <param name="folderId">The Id of the folder the message is in.</param>
+ /// <returns>The message size in bytes or null if non is found.</returns>
+ int? GetMessageSize(int messageId, int folderId);
/// <summary>
/// Gets the headers for the message.
/// </summary>
/// <param name="messageId">The Id of the message to get the headers for.</param>
/// <param name="folderId">The Id of the folder the message is in.</param>
- /// <returns>The message headers or null if none exist.</returns>
+ /// <returns>The message headers or null if none exists.</returns>
MessageHeaders GetMessageHeaders(int messageId, int folderId);
/// <summary>
@@ -244,7 +246,7 @@
/// <param name="messageId">The Id of the message to get.</param>
/// <param name="folderId">The Id of the folder the message is in.</param>
/// <returns>The message or null if the message Id is invalid.</returns>
- Message GetMessage(int messageId, int folderId);
+ Message.Message GetMessage(int messageId, int folderId);
#endregion
#region Message Counts
@@ -258,18 +260,18 @@
/// <summary>
/// Gets the number of messages with the specified flag set.
/// </summary>
- /// <param name="folder">The folder to count the flagged messages in.</param>
+ /// <param name="folderId">The Id of the folder to count the flagged messages in.</param>
/// <param name="flags">The flags to check for when counting.</param>
/// <returns>The number of messages.</returns>
- int GetMessageCountWithFlags(StoreFolder folder, StoreMessageFlags flags);
+ int GetMessageCountWithFlags(int folderId, StoreMessageFlags flags);
#endregion
/// <summary>
/// Permanently removes messages flagged as deleted.
/// </summary>
- /// <param name="folder">The folder to delete messages in.</param>
+ /// <param name="folderId">The Id of the folder to delete messages in.</param>
/// <returns>The list of message offsets for the deleted messages.</returns>
- int[] PurgeDeletedMessages(StoreFolder folder);
+ IList<int> PurgeDeletedMessages(int folderId);
#region Load and Save Object
/// <summary>
Modified: NMail/trunk/NMail/DataTypes/LocalStore/LocalStoreDelivery.cs
===================================================================
--- NMail/trunk/NMail/DataTypes/LocalStore/LocalStoreDelivery.cs 2007-04-24 15:46:35 UTC (rev 186)
+++ NMail/trunk/NMail/DataTypes/LocalStore/LocalStoreDelivery.cs 2007-04-30 08:59:18 UTC (rev 187)
@@ -39,7 +39,7 @@
this.additionalFolders = new ArrayList();
}
- public LocalStoreDelivery(Message message, Folder nominalTargetFolder) {
+ public LocalStoreDelivery(Message.Message message, Folder nominalTargetFolder) {
this.message = message;
this.folderDelimiter = NMailConfiguration.Current.LocalStore.FolderDelimiter;
@@ -88,12 +88,12 @@
}
}
- private Message message;
+ private Message.Message message;
/// <summary>
/// Gets the message associated with this instance.
/// </summary>
- public Message Message {
+ public Message.Message Message {
get {
return this.message;
}
Added: NMail/trunk/NMail/DataTypes/Message/BodyStructure.cs
===================================================================
--- NMail/trunk/NMail/DataTypes/Message/BodyStructure.cs (rev 0)
+++ NMail/trunk/NMail/DataTypes/Message/BodyStructure.cs 2007-04-30 08:59:18 UTC (rev 187)
@@ -0,0 +1,134 @@
+/*
+ * Copyright 2004-2006 Luke Quinane
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ */
+
+using System;
+using System.Collections.Generic;
+using System.Text;
+
+using NMail.Helper;
+
+namespace NMail.DataTypes.Message {
+ /// <summary>
+ /// Represents a the structure of a message body.
+ /// </summary>
+ [Serializable]
+ public class BodyStructure : List<BodyStructure> {
+
+ public BodyStructure(IMessageBodyPart bodyPart) {
+ this.headers = bodyPart.Headers;
+
+ if (bodyPart is IMultipartMessageBody) {
+ foreach (IMessageBodyPart part in ((IMultipartMessageBody) bodyPart).MimeParts) {
+ this.Add(new BodyStructure(part));
+ }
+ } else {
+ // Count the number of lines in the message body
+ string bodyData = bodyPart.BodyData.ToString();
+ int index = bodyData.IndexOf(Message.Terminator);
+ while (index != -1) {
+ this.bodyLineCount++;
+ index = bodyData.IndexOf(Message.Terminator, index + 1);
+ }
+
+ this.bodyCharacterCount = bodyData.Length;
+ this.size = bodyPart.Size;
+ }
+ }
+
+ public BodyStructure(MessageHeaders headers) {
+ this.headers = headers;
+ }
+
+ private MessageHeaders headers;
+
+ /// <summary>
+ /// The message headers associated with this level of the body structure.
+ /// </summary>
+ public MessageHeaders Headers {
+ get { return headers; }
+ set { headers = value; }
+ }
+
+ private int bodyLineCount;
+
+ /// <summary>
+ /// The number of lines in the message body. Only valid for bodystructures
+ /// without multiple parts.
+ /// </summary>
+ public int BodyLineCount {
+ get { return bodyLineCount; }
+ set { bodyLineCount = value; }
+ }
+
+ private int bodyCharacterCount;
+
+ /// <summary>
+ /// The number of characters in the body. Only valid for bodystructures
+ /// witout multiple parts.
+ /// </summary>
+ public int BodyCharacterCount {
+ get { return bodyCharacterCount; }
+ set { bodyCharacterCount = value; }
+ }
+
+ private int size;
+
+ /// <summary>
+ /// The size of this part in bytes.
+ /// </summary>
+ public int Size {
+ get { return size; }
+ set { size = value; }
+ }
+
+ public string ToImapString() {
+ if (this.Count > 0) {
+ StringBuilder data = new StringBuilder();
+ data.Append("(");
+
+ foreach (BodyStructure child in this) {
+ data.Append(child.ToString());
+ }
+
+ data.Append("\"MIXED\")");
+ return data.ToString();
+
+ } else {
+ MimeContentTransferEncoding encoding = MimeHelper.GetTransferEncoding(this.headers);
+ MimeContentType contentType = MimeHelper.GetContentType(this.headers);
+ string charset = MimeHelper.GetCharacterSet(this.headers);
+
+ string encodingStr = encoding.ToString().ToUpper();
+ if (encoding == MimeContentTransferEncoding.EightBit) {
+ encodingStr = "8bit";
+ } else if (encoding == MimeContentTransferEncoding.SevenBit) {
+ encodingStr = "7bit";
+ }
+
+ return string.Format("(\"{0}\" \"{1}\" (\"charset\" \"{2}\") {3} {4} \"{5}\" {6} {7} NIL NIL NIL)",
+ contentType.ToString().ToLower(),
+ "plain",
+ charset,
+ "NIL", // body-fld-id
+ "NIL", // body-fld-desc
+ encodingStr,
+ this.bodyCharacterCount,
+ this.bodyLineCount);
+ }
+ }
+ }
+}
Added: NMail/trunk/NMail/DataTypes/Message/Envelope.cs
===================================================================
--- NMail/trunk/NMail/DataTypes/Message/Envelope.cs (rev 0)
+++ NMail/trunk/NMail/DataTypes/Message/Envelope.cs 2007-04-30 08:59:18 UTC (rev 187)
@@ -0,0 +1,364 @@
+/*
+ * Copyright 2004-2006 Luke Quinane
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ */
+
+using System;
+using System.Collections.Generic;
+using System.Text;
+
+using NMail.Helper;
+
+namespace NMail.DataTypes.Message {
+ /// <summary>
+ /// A message envelope. This includes the From, To, Cc, Bcc, Subject
+ /// </summary>
+ [Serializable]
+ public class Envelope {
+
+ protected Envelope() { }
+
+ /// <summary>
+ /// Creates a new envelope from the message headers.
+ /// </summary>
+ /// <param name="messageHeaders">The headers containing the envelope information.</param>
+ public Envelope(MessageHeaders messageHeaders) {
+ // These fields should never be null
+ this.from = messageHeaders["From"];
+ this.date = messageHeaders["Date"];
+ this.subject = messageHeaders["Subject"];
+
+ this.sender = messageHeaders["Sender"];
+ if (this.sender == null || this.sender.Trim() == string.Empty) {
+ this.sender = this.from;
+ }
+ this.replyTo = messageHeaders["Rely-To"];
+ if (this.replyTo == null || this.replyTo.Trim() == string.Empty) {
+ this.replyTo = this.from;
+ }
+
+ // These fields can be null
+ this.messageId = messageHeaders["Message-Id"];
+ if (this.messageId != null && this.messageId.Trim() == string.Empty) {
+ this.messageId = null;
+ }
+ this.to = messageHeaders["To"];
+ if (this.to != null && this.to.Trim() == string.Empty) {
+ this.to = null;
+ }
+ this.inReplyTo = messageHeaders["In-Reply-To"];
+ if (this.inReplyTo != null && this.inReplyTo.Trim() == string.Empty) {
+ this.inReplyTo = null;
+ }
+ this.bcc = messageHeaders["Bcc"];
+ if (this.bcc != null && this.inReplyTo.Trim() == string.Empty) {
+ this.bcc = null;
+ }
+ this.cc = messageHeaders["Cc"];
+ if (this.cc != null && this.cc.Trim() == string.Empty) {
+ this.cc = null;
+ }
+ }
+
+ /// <summary>
+ /// Creates a new envelope with the minimum required fields.
+ /// </summary>
+ /// <param name="from">The sender of the message.</param>
+ /// <param name="date">The date the message was sent.</param>
+ /// <param name="subject">The message's subject.</param>
+ public Envelope(string from, string date, string subject) {
+ this.from = from;
+ this.sender = from;
+ this.replyTo = from;
+
+ this.subject = subject;
+ this.date = date;
+ }
+
+ #region Properties
+
+ private string messageId;
+
+ /// <summary>
+ /// Extracted from the Message-Id header.
+ /// </summary>
+ public string MessageId {
+ get {
+ return this.messageId;
+ }
+ set {
+ this.messageId = value;
+ }
+ }
+
+ private string from;
+
+ /// <summary>
+ /// The value extracted from the From header field.
+ /// </summary>
+ public string From {
+ get {
+ return this.from;
+ }
+ set {
+ this.from = value;
+ }
+ }
+
+ private string sender;
+
+ /// <summary>
+ /// The value extracted from the Sender header field.
+ /// </summary>
+ public string Sender {
+ get {
+ return this.sender;
+ }
+ set {
+ this.sender = value;
+ }
+ }
+
+ private string to;
+
+ /// <summary>
+ /// The value extracted from the To header field.
+ /// </summary>
+ public string To {
+ get {
+ return this.to;
+ }
+ set {
+ this.to = value;
+ }
+ }
+
+
+ private string inReplyTo;
+
+ /// <summary>
+ /// The value extracted from the In-Reply-To header field.
+ /// </summary>
+ public string InReplyTo {
+ get {
+ return this.inReplyTo;
+ }
+ set {
+ this.inReplyTo = value;
+ }
+ }
+
+
+ private string replyTo;
+
+ /// <summary>
+ /// The value extracted from the Reply-To header field.
+ /// </summary>
+ public string ReplyTo {
+ get {
+ return this.replyTo;
+ }
+ set {
+ this.replyTo = value;
+ }
+ }
+
+
+ private string bcc;
+
+ /// <summary>
+ /// The value extracted from the Bcc header field.
+ /// </summary>
+ public string Bcc {
+ get {
+ return this.bcc;
+ }
+ set {
+ this.bcc = value;
+ }
+ }
+
+
+ private string cc;
+
+ /// <summary>
+ /// The value extracted from the Cc header field.
+ /// </summary>
+ public string Cc {
+ get {
+ return this.cc;
+ }
+ set {
+ this.cc = value;
+ }
+ }
+
+
+ private string subject;
+
+ /// <summary>
+ /// The value extracted from the Subject header field.
+ /// </summary>
+ public string Subject {
+ get {
+ return this.subject;
+ }
+ set {
+ this.subject = value;
+ }
+ }
+
+
+ private string date;
+
+ /// <summary>
+ /// The value extracted from the Date header field.
+ /// </summary>
+ public string Date {
+ get {
+ return this.date;
+ }
+ set {
+ this.date = value;
+ }
+ }
+ #endregion
+
+ #region getEnvelopeImapAddress
+ private string getEnvelopeImapAddress(string data) {
+ // TODO: handle groups
+
+ StringBuilder output = new StringBuilder();
+ string[] addresses = StringTokenizer.GetQuotedTokens(data, ",".ToCharArray(), Int32.MaxValue, false);
+
+ output.Append("(");
+
+ foreach (string address in addresses) {
+ string[] tokens = StringTokenizer.GetQuotedTokens(address, " ".ToCharArray(), Int32.MaxValue, true);
+ string emailAddress = null;
+ string personalName = null;
+ string host = null;
+ string mailbox = null;
+
+ if (tokens.Length > 0) {
+ if (tokens[0][0] != '<') {
+ personalName = tokens[0];
+
+ if (tokens.Length > 1) {
+ emailAddress = tokens[1];
+ }
+ } else {
+ // No personal name
+ emailAddress = tokens[0];
+ }
+ }
+
+ if (emailAddress != null) {
+ try {
+ EmailAddress tmpAddress = new EmailAddress(emailAddress, true);
+ host = tmpAddress.Host.ToString();
+ mailbox = tmpAddress.Mailbox.ToString();
+ } catch {
+ }
+ }
+
+ // Append the personal name and source route
+ if (personalName != null) {
+ output.Append("(\"");
+ output.Append(personalName);
+ output.Append("\" NIL ");
+ } else {
+ output.Append("(NIL NIL ");
+ }
+
+ // Append the mailbox
+ if (mailbox != null) {
+ output.Append("\"");
+ output.Append(mailbox);
+ output.Append("\" ");
+ } else {
+ output.Append("NIL ");
+ }
+
+ // Append the host
+ if (host != null) {
+ output.Append("\"");
+ output.Append(host);
+ output.Append("\")");
+ } else {
+ output.Append("NIL)");
+ }
+ }
+
+ output.Append(")");
+
+ return output.ToString();
+ }
+ #endregion
+
+ #region ToImapEnvelopeString
+ /// <summary>
+ /// Converts this envelope into a string that can be used in an IMAP envelope
+ /// response.
+ /// </summary>
+ /// <returns>The IMAP envelope string.</returns>
+ public string ToImapEnvelopeString() {
+ StringBuilder envelope = new StringBuilder();
+
+ envelope.Append("ENVELOPE (\"");
+ envelope.Append(this.date);
+ envelope.Append("\" \"");
+ envelope.Append(this.subject);
+ envelope.Append("\" ");
+
+ // From
+ envelope.Append(getEnvelopeImapAddress(this.from));
+ envelope.Append(" ");
+
+ // Sender
+ envelope.Append(getEnvelopeImapAddress(this.sender));
+ envelope.Append(" ");
+
+ // Reply-To
+ envelope.Append(getEnvelopeImapAddress(this.replyTo));
+ envelope.Append(" ");
+
+ // To
+ envelope.Append((this.to == null) ? "NIL" : getEnvelopeImapAddress(this.to));
+ envelope.Append(" ");
+
+ // Cc
+ envelope.Append((this.cc == null) ? "NIL" : getEnvelopeImapAddress(this.cc));
+ envelope.Append(" ");
+
+ // Bcc
+ envelope.Append((this.bcc == null) ? "NIL" : getEnvelopeImapAddress(this.bcc));
+ envelope.Append(" ");
+
+ // In-Reply-To
+ envelope.Append("\"");
+ envelope.Append((this.inReplyTo == null) ? "NIL" : this.inReplyTo);
+ envelope.Append("\" ");
+
+ // Message-Id
+ envelope.Append("\"");
+ envelope.Append((this.messageId == null) ? "NIL" : this.messageId);
+ envelope.Append("\")");
+
+ return envelope.ToString();
+ }
+ #endregion
+ }
+}
Added: NMail/trunk/NMail/DataTypes/Message/IMessageBodyPart.cs
===================================================================
--- NMail/trunk/NMail/DataTypes/Message/IMessageBodyPart.cs (rev 0)
+++ NMail/trunk/NMail/DataTypes/Message/IMessageBodyPart.cs 2007-04-30 08:59:18 UTC (rev 187)
@@ -0,0 +1,36 @@
+/*
+ * Copyright 2004-2006 Luke Quinane and Daniel Frampton
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ */
+
+using System;
+using System.Collections.Generic;
+
+namespace NMail.DataTypes.Message {
+ /// <summary>
+ /// A body part of a RFC 2822 message.
+ /// </summary>
+ public interface IMessageBodyPart : IMessagePart {
+ /// <summary>
+ /// Gets or sets the headers associated with this body part.
+ /// </summary>
+ MessageHeaders Headers { get; set; }
+
+ /// <summary>
+ /// The data for the body of this body part.
+ /// </summary>
+ ByteString BodyData { get; }
+ }
+}
Added: NMail/trunk/NMail/DataTypes/Message/IMessagePart.cs
===================================================================
--- NMail/trunk/NMail/DataTypes/Message/IMessagePart.cs (rev 0)
+++ NMail/trunk/NMail/DataTypes/Message/IMessagePart.cs 2007-04-30 08:59:18 UTC (rev 187)
@@ -0,0 +1,35 @@
+/*
+ * Copyright 2004-2006 Luke Quinane and Daniel Frampton
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ */
+
+using System;
+
+namespace NMail.DataTypes.Message {
+ /// <summary>
+ /// A part of a RFC 2822 message.
+ /// </summary>
+ public interface IMessagePart {
+ /// <summary>
+ /// The data as a single string.
+ /// </summary>
+ ByteString Data { get; }
+
+ /// <summary>
+ /// The size of the data in bytes.
+ /// </summary>
+ int Size { get; }
+ }
+}
Added: NMail/trunk/NMail/DataTypes/Message/IMultipartMessageBody.cs
===================================================================
--- NMail/trunk/NMail/DataTypes/Message/IMultipartMessageBody.cs (rev 0)
+++ NMail/trunk/NMail/DataTypes/Message/IMultipartMessageBody.cs 2007-04-30 08:59:18 UTC (rev 187)
@@ -0,0 +1,44 @@
+/*
+ * Copyright 2004-2007 Luke Quinane
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ */
+
+using System;
+using System.Collections.Generic;
+using System.Text;
+
+namespace NMail.DataTypes.Message {
+ public interface IMultipartMessageBody : IMessageBodyPart {
+ /// <summary>
+ /// Gets the mime parts of this message part, if any.
+ /// </summary>
+ IList<IMessageBodyPart> MimeParts { get; }
+
+ /// <summary>
+ /// Gets the preamble for the message body, if any.
+ /// </summary>
+ IMessagePart Preamble { get; set; }
+
+ /// <summary>
+ /// Gets the postamble for the message body, if any.
+ /// </summary>
+ IMessagePart Postamble { get; set; }
+
+ /// <summary>
+ /// A string containing the mime boundary.
+ /// </summary>
+ string MimeBoundary { get; set; }
+ }
+}
Added: NMail/trunk/NMail/DataTypes/Message/Message.cs
===================================================================
--- NMail/trunk/NMail/DataTypes/Message/Message.cs (rev 0)
+++ NMail/trunk/NMail/DataTypes/Message/Message.cs 2007-04-30 08:59:18 UTC (rev 187)
@@ -0,0 +1,157 @@
+/*
+ * Copyright 2004-2006 Luke Quinane and Daniel Frampton
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ */
+
+using System;
+using System.Collections.Generic;
+using System.Collections.Specialized;
+using System.Text;
+using System.Text.RegularExpressions;
+
+using NMail.Helper;
+
+namespace NMail.DataTypes.Message {
+ /// <summary>
+ /// An RFC 2822 compliant message.
+ /// </summary>
+ [Serializable]
+ public class Message : IMessageBodyPart {
+ /// <summary>
+ /// Creates a new emtpy message.
+ /// </summary>
+ public Message() {
+ this.body = new SimpleMessageBody();
+ }
+
+ /// <summary>
+ /// Creates a message from the given data.
+ /// </summary>
+ /// <param name="data">The data to create the message from.</param>
+ public Message(ByteString data) {
+ this.body = MessageHelper.ParseMessage(data);
+ }
+
+ /// <summary>
+ /// Creates a message from the given data.
+ /// </summary>
+ /// <param name="dataString">The data to create the message from.</param>
+ public Message(string dataString) {
+ // TODO: check this encoding is ok
+ ByteString data = new ByteString(dataString, Encoding.ASCII);
+ this.body = MessageHelper.ParseMessage(data);
+ }
+
+ /// <summary>
+ /// Creates a new message from the given body data.
+ /// </summary>
+ /// <param name="bodyData">The data to use in the message.</param>
+ public Message(IMessageBodyPart bodyData) {
+ this.body = bodyData;
+ }
+
+ /// <summary>
+ /// Gets an envelope for this message.
+ /// </summary>
+ /// <returns>The envelope.</returns>
+ public Envelope GetEnvelope() {
+ return new Envelope(this.Headers);
+ }
+
+ /// <summary>
+ /// Converts the body to a multipart body.
+ /// </summary>
+ public void ConvertToMultipartBody() {
+ if (!(this.body is IMultipartMessageBody)) {
+ MessageDataPart preamble = null;
+ MessageDataPart postamble = null;
+ IMessageBodyPart[] parsedParts;
+
+ string mimeBoundary = MimeHelper.GetBoundary(this.body.Headers);
+
+ if (mimeBoundary != null) {
+ // Parse the MIME parts and pre/postambles
+ MimeHelper.ParseMime(
+ mimeBoundary,
+ this.body.BodyData,
+ out preamble,
+ out parsedParts,
+ out postamble);
+ } else {
+ parsedParts = new IMessageBodyPart[1];
+ parsedParts[0] = this.body;
+ }
+
+ this.body = new MultipartMessageBody(this.body.Headers, preamble, parsedParts, postamble);
+ }
+ }
+
+ private IMessageBodyPart body;
+
+ /// <summary>
+ /// The body data associated with this message
+ /// </summary>
+ public IMessageBodyPart Body {
+ get { return body; }
+ set { body = value; }
+ }
+
+ #region IMessageBodyPart
+ /// <summary>
+ /// Gets or sets the headers associated with this body part.
+ /// </summary>
+ public MessageHeaders Headers {
+ get {
+ return this.body.Headers;
+ }
+ set {
+ this.body.Headers = value;
+ }
+ }
+
+ /// <summary>
+ /// The data for the body of this body part.
+ /// </summary>
+ public ByteString BodyData {
+ get {
+ return this.body.BodyData;
+ }
+ }
+
+ /// <summary>
+ /// The data as a single string.
+ /// </summary>
+ public ByteString Data {
+ get {
+ return this.body.Data;
+ }
+ }
+
+ /// <summary>
+ /// The size of the data in bytes.
+ /// </summary>
+ public int Size {
+ get {
+ return this.body.Size;
+ }
+ }
+ #endregion
+
+ /// <summary>
+ /// The end of line terminator.
+ /// </summary>
+ public const string Terminator = "\r\n";
+ }
+}
Added: NMail/trunk/NMail/DataTypes/Message/MessageDataPart.cs
===================================================================
--- NMail/trunk/NMail/DataTypes/Message/MessageDataPart.cs (rev 0)
+++ NMail/trunk/NMail/DataTypes/Message/MessageDataPart.cs 2007-04-30 08:59:18 UTC (rev 187)
@@ -0,0 +1,88 @@
+/*
+ * Copyright 2004-2006 Luke Quinane and Daniel Frampton
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ */
+
+using System;
+
+namespace NMail.DataTypes.Message {
+ /// <summary>
+ /// Represents a block of message data.
+ /// </summary>
+ [Serializable]
+ public class MessageDataPart : IMessagePart {
+ /// <summary>
+ /// The data for this class.
+ /// </summary>
+ protected ByteString data;
+
+ /// <summary>
+ /// Creates a message data part from the given lines.
+ /// </summary>
+ /// <param name="data">The lines to create the data from.</param>
+ public MessageDataPart(ByteString data) {
+ this.data = data;
+
+ if (this.data == null) {
+ this.data = ByteString.Empty;
+ }
+ }
+
+ /// <summary>
+ /// Appends a line onto the end of the data.
+ /// </summary>
+ /// <param name="line">The line to append</param>
+ public void Append(string line) {
+ AppendEnd(line);
+ }
+
+ /// <summary>
+ /// Appends a line onto the start of the data.
+ /// </summary>
+ /// <param name="line">The line to append</param>
+ public void AppendStart(string line) {
+ this.data = this.data.Prepend(line);
+ }
+
+ /// <summary>
+ /// Appends a line onto the end of the data.
+ /// </summary>
+ /// <param name="line">The line to append</param>
+ public void AppendEnd(string line) {
+ this.data = this.data.Postfix(line);
+ }
+
+ /// <summary>
+ /// The size of the data in bytes.
+ /// </summary>
+ public virtual int Size {
+ get {
+ return this.data.Length;
+ }
+ }
+
+ /// <summary>
+ /// The data as a single string.
+ /// </summary>
+ public virtual ByteString Data {
+ get {
+ return this.data;
+ }
+ set {
+ this.data = value;
+ }
+ }
+ }
+}
Added: NMail/trunk/NMail/DataTypes/Message/MessageHeaders.cs
===================================================================
--- NMail/trunk/NMail/DataTypes/Message/MessageHeaders.cs (rev 0)
+++ NMail/trunk/NMail/DataTypes/Message/MessageHeaders.cs 2007-04-30 08:59:18 UTC (rev 187)
@@ -0,0 +1,232 @@
+/*
+ * Copyright 2004-2006 Luke Quinane and Daniel Frampton
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ */
+
+using System;
+using System.Collections;
+using System.Collections.Specialized;
+using System.Text;
+using System.Text.RegularExpressions;
+
+using NMail.Helper;
+
+namespace NMail.DataTypes.Message {
+ /// <summary>
+ /// A set of message headers for an email message.
+ /// </summary>
+ [Serializable]
+ public class MessageHeaders : IMessagePart {
+ /// <summary>
+ /// The raw headers for this set of message headers
+ /// </summary>
+ private ByteString rawHeaders;
+
+ /// <summary>
+ /// A hashtable of arraylists for each header
+ /// </summary>
+ private Hashtable parsedHeaders;
+
+ /// <summary>
+ /// Are the current set of message headers parsed.
+ /// </summary>
+ private bool parsed;
+
+ /// <summary>
+ /// Creates a new set of message headers from the set of lines.
+ /// </summary>
+ public MessageHeaders() : this(ByteString.Empty) {}
+
+ /// <summary>
+ /// Creates a new set of message headers from the set of lines.
+ /// </summary>
+ /// <param name="data">The lines to create the headers from.</param>
+ public MessageHeaders(ByteString data) {
+ this.Data = data;
+ }
+
+ /// <summary>
+ /// Gets the value of the first header associated with the given name.
+ /// </summary>
+ /// <param name="name">The name of the header to lookup, e.g "Subject".</param>
+ /// <returns>The returned header, e.g. "A subject".</returns>
+ public string GetSingleHeader(string name) {
+ if (!this.parsed) parseRawHeaders();
+
+ ArrayList headerList = (ArrayList) this.parsedHeaders[name];
+ return (headerList == null) ?
+ null :
+ (string) headerList[0];
+ }
+
+ /// <summary>
+ /// Gets the value for all headers associated with the given name.
+ /// </summary>
+ /// <param name="name">The name of the headers to lookup, e.g "Received".</param>
+ /// <returns>An array of corresponding headers.</returns>
+ public string[] GetHeaders(string name) {
+ if (!this.parsed) parseRawHeaders();
+
+ ArrayList headerList = (ArrayList) this.parsedHeaders[name];
+ return (headerList == null) ?
+ null :
+ (string[]) headerList.ToArray(typeof(string));
+ }
+
+ /// <summary>
+ /// Appends a header line onto the end of the message headers.
+ /// </summary>
+ /// <param name="headerLine">The valid complete line of header information.</param>
+ public void AppendEnd(string headerLine) {
+ // Parse the new header line
+ int indexOfColon = headerLine.IndexOf(':');
+ if (indexOfColon <= 0) {
+ throw new ArgumentException("Only valid headers can be appended.");
+ }
+ string headerName = headerLine.Substring(0, indexOfColon).T...
[truncated message content] |
|
From: <tmy...@us...> - 2007-04-24 15:46:37
|
Revision: 186
http://svn.sourceforge.net/nmailserver/?rev=186&view=rev
Author: tmyroadctfig
Date: 2007-04-24 08:46:35 -0700 (Tue, 24 Apr 2007)
Log Message:
-----------
Further work on local store data and unit tests.
Modified Paths:
--------------
NMail/trunk/NMail/DataTypes/LocalStore/ILocalStoreData.cs
NMail/trunk/NMail.LocalStore/LocalStore.cs
NMail/trunk/NMail.LocalStoreData.MySql/MySqlLocalStoreData.cs
NMail/trunk/NMail.LocalStoreData.NHibernate/InternalStoreFolder.cs
NMail/trunk/NMail.LocalStoreData.NHibernate/Mappings/NMail.LocalStoreData.NHibernate.InternalMessage.hbm.xml
NMail/trunk/NMail.LocalStoreData.NHibernate/NHibernateLocalStoreData.cs
NMail/trunk/NMail.UnitTests/NMail.UnitTests.csproj
Added Paths:
-----------
NMail/trunk/NMail.UnitTests/LocalStoreData/DeliverMessageTest1.cs
NMail/trunk/NMail.UnitTests/LocalStoreData/GetMessageIdTest1.cs
NMail/trunk/NMail.UnitTests/LocalStoreData/GetMessageIdsTest1.cs
NMail/trunk/NMail.UnitTests/LocalStoreData/GetMessageOffsetTest1.cs
NMail/trunk/NMail.UnitTests/LocalStoreData/GetNextMessageIdTest1.cs
NMail/trunk/NMail.UnitTests/LocalStoreData/GetSetMessageFlagsTest1.cs
Modified: NMail/trunk/NMail/DataTypes/LocalStore/ILocalStoreData.cs
===================================================================
--- NMail/trunk/NMail/DataTypes/LocalStore/ILocalStoreData.cs 2007-04-24 12:45:08 UTC (rev 185)
+++ NMail/trunk/NMail/DataTypes/LocalStore/ILocalStoreData.cs 2007-04-24 15:46:35 UTC (rev 186)
@@ -150,32 +150,32 @@
/// Gets the Id for the next message in the folder after the current Id.
/// </summary>
/// <param name="currentId">The Id to start looking from.</param>
- /// <param name="folder"></param>
+ /// <param name="folderId">The Id of the folder to get the next Id in.</param>
/// <returns>The Id of the next existing message or 0 if there is none.</returns>
- int GetNextMessageId(int messageId, StoreFolder folder);
+ int GetNextMessageId(int messageId, int folderId);
/// <summary>
/// Gets the Id for the next message to be added into the folder.
/// </summary>
- /// <param name="folder">The folder the message is in.</param>
+ /// <param name="folderId">The Id of the folder the message is in.</param>
/// <returns>The next message Id.</returns>
- int GetNextMessageId(StoreFolder folder);
+ int GetNextMessageId(int folderId);
/// <summary>
/// Gets the message Id (UID) corresponding to the given message offset.
/// </summary>
/// <param name="messageOffset">The offset of the message to lookup.</param>
- /// <param name="folder">The folder the message is in.</param>
+ /// <param name="folderId">The Id of the folder the message is in.</param>
/// <returns>The message Id or 0 if there is no such message.</returns>
- int GetMessageId(int messageOffset, StoreFolder folder);
+ int GetMessageId(int messageOffset, int folderId);
/// <summary>
/// Gets the message offset corresponding the to given message Id (UID).
/// </summary>
/// <param name="messageId">The Id of the message to lookup.</param>
- /// <param name="folder">The folder the message is in.</param>
+ /// <param name="folderId">The Id of the folder the message is in.</param>
/// <returns>The message offset or 0 if there is no such message.</returns>
- int GetMessageOffset(int messageId, StoreFolder folder);
+ int GetMessageOffset(int messageId, int folderId);
/// <summary>
/// Gets a list of message Ids for a given folder.
@@ -190,18 +190,18 @@
/// Gets the message flags for a message.
/// </summary>
/// <param name="messageId">The Id of the message to get the flags for.</param>
- /// <param name="folder">The folder the message is in.</param>
+ /// <param name="folderId">The Id of the folder the message is in.</param>
/// <returns>The message flags.</returns>
- StoreMessageFlags GetMessageFlags(int messageId, StoreFolder folder);
+ StoreMessageFlags? GetMessageFlags(int messageId, int folderId);
/// <summary>
/// Sets the message flags for a message.
/// </summary>
/// <remarks>This will replace any existing flags on the message.</remarks>
/// <param name="messageId">The Id of the message to set the flags for.</param>
- /// <param name="folder">The folder the message is in.</param>
+ /// <param name="folderId">The Id of the folder the message is in.</param>
/// <param name="flags">The flags to set.</param>
- void SetMessageFlags(int messageId, StoreFolder folder, StoreMessageFlags flags);
+ void SetMessageFlags(int messageId, int folderId, StoreMessageFlags flags);
#endregion
#region Message Retrieval
@@ -251,9 +251,9 @@
/// <summary>
/// Gets the number of messages in the given store folder.
/// </summary>
- /// <param name="folder">The folder to count the messages in.</param>
+ /// <param name="folderId">The Id of the folder to count the messages in.</param>
/// <returns>The message count.</returns>
- int GetMessageCount(StoreFolder folder);
+ int GetMessageCount(int folderId);
/// <summary>
/// Gets the number of messages with the specified flag set.
Modified: NMail/trunk/NMail.LocalStore/LocalStore.cs
===================================================================
--- NMail/trunk/NMail.LocalStore/LocalStore.cs 2007-04-24 12:45:08 UTC (rev 185)
+++ NMail/trunk/NMail.LocalStore/LocalStore.cs 2007-04-24 15:46:35 UTC (rev 186)
@@ -630,7 +630,7 @@
if (hasFolderPrivilege(authToken.Username, folder.FolderId, StoreFolderPrivilege.Read)) {
// Return the message Id
- return LocalStoreData.GetNextMessageId(currentId, folder);
+ return LocalStoreData.GetNextMessageId(currentId, folder.FolderId);
} else {
return 0;
@@ -649,7 +649,7 @@
if (hasFolderPrivilege(authToken.Username, folder.FolderId, StoreFolderPrivilege.Read)) {
// Return the message Id
- return LocalStoreData.GetNextMessageId(folder);
+ return LocalStoreData.GetNextMessageId(folder.FolderId);
} else {
return 0;
@@ -671,7 +671,7 @@
if (hasFolderPrivilege(authToken.Username, folder.FolderId, StoreFolderPrivilege.Read)) {
// Return the message Id
- return LocalStoreData.GetMessageId(messageOffset, folder);
+ return LocalStoreData.GetMessageId(messageOffset, folder.FolderId);
} else {
return 0;
@@ -693,7 +693,7 @@
if (hasFolderPrivilege(authToken.Username, folder.FolderId, StoreFolderPrivilege.Read)) {
// Return the message Id
- return LocalStoreData.GetMessageOffset(messageId, folder);
+ return LocalStoreData.GetMessageOffset(messageId, folder.FolderId);
} else {
return 0;
@@ -733,7 +733,7 @@
if (hasFolderPrivilege(authToken.Username, folder.FolderId, StoreFolderPrivilege.Read)) {
// Return the message flags
- return LocalStoreData.GetMessageFlags(messageId, folder);
+ return LocalStoreData.GetMessageFlags(messageId, folder.FolderId);
} else {
return null;
@@ -751,7 +751,12 @@
/// <param name="folder">The folder the message is in.</param>
/// <param name="flags">The flags to set.</param>
public void SetMessageFlags(IAuthenticationToken authToken, int messageId, StoreFolder folder, StoreMessageFlags flags) {
- StoreMessageFlags currentFlags = LocalStoreData.GetMessageFlags(messageId, folder);
+ StoreMessageFlags? tmpFlags = LocalStoreData.GetMessageFlags(messageId, folder.FolderId);
+ if (!tmpFlags.HasValue) {
+ throw new ArgumentException("Invalid message or folder Id.");
+ }
+
+ StoreMessageFlags currentFlags = tmpFlags.Value;
StoreMessageFlags changedFlags = (currentFlags ^ flags);
if ((changedFlags & StoreMessageFlags.Deleted) == StoreMessageFlags.Deleted) {
@@ -788,7 +793,7 @@
}
}
- LocalStoreData.SetMessageFlags(messageId, folder, flags);
+ LocalStoreData.SetMessageFlags(messageId, folder.FolderId, flags);
}
#endregion
#endregion
@@ -944,7 +949,7 @@
if (hasFolderPrivilege(authToken.Username, folder.FolderId, StoreFolderPrivilege.Read)) {
// Return the message count
- return LocalStoreData.GetMessageCount(folder);
+ return LocalStoreData.GetMessageCount(folder.FolderId);
} else {
return null;
Modified: NMail/trunk/NMail.LocalStoreData.MySql/MySqlLocalStoreData.cs
===================================================================
--- NMail/trunk/NMail.LocalStoreData.MySql/MySqlLocalStoreData.cs 2007-04-24 12:45:08 UTC (rev 185)
+++ NMail/trunk/NMail.LocalStoreData.MySql/MySqlLocalStoreData.cs 2007-04-24 15:46:35 UTC (rev 186)
@@ -491,11 +491,11 @@
#region Message Id and Offset
#region GetNextMessageId
- public int GetNextMessageId(int messageId, StoreFolder folder) {
+ public int GetNextMessageId(int messageId, int folderId) {
using (MySqlConnection cnn = MySqlHelper.GetConnection()) {
using (MySqlCommand cmd = cnn.CreateCommand()) {
cmd.CommandText = "SELECT FolderMessageId FROM Message WHERE FolderId = ?FolderId AND FolderMessageId > ?MessageId ORDER BY FolderMessageId LIMIT 1";
- cmd.Parameters.Add("?FolderId", folder.FolderId);
+ cmd.Parameters.Add("?FolderId", folderId);
cmd.Parameters.Add("?MessageId", messageId);
object o = cmd.ExecuteScalar();
@@ -504,11 +504,11 @@
}
}
- public int GetNextMessageId(StoreFolder folder) {
+ public int GetNextMessageId(int folderId) {
using (MySqlConnection cnn = MySqlHelper.GetConnection()) {
using (MySqlCommand cmd = cnn.CreateCommand()) {
cmd.CommandText = "SELECT NextMessageId FROM Folder WHERE FolderId = ?FolderId";
- cmd.Parameters.Add("?FolderId", folder.FolderId);
+ cmd.Parameters.Add("?FolderId", folderId);
object o = cmd.ExecuteScalar();
return (o == null) ? 0 : (int)o;
@@ -518,11 +518,11 @@
#endregion
#region GetMessageId
- public int GetMessageId(int messageOffset, StoreFolder folder) {
+ public int GetMessageId(int messageOffset, int folderId) {
using (MySqlConnection cnn = MySqlHelper.GetConnection()) {
using (MySqlCommand cmd = cnn.CreateCommand()) {
cmd.CommandText = "SELECT FolderMessageId FROM Message WHERE FolderId = ?FolderId ORDER BY FolderMessageId LIMIT 1 OFFSET ?Offset";
- cmd.Parameters.Add("?FolderId", folder.FolderId);
+ cmd.Parameters.Add("?FolderId", folderId);
cmd.Parameters.Add("?Offset", messageOffset - 1);
return (int)cmd.ExecuteScalar();
}
@@ -531,11 +531,11 @@
#endregion
#region GetMessageOffset
- public int GetMessageOffset(int messageId, StoreFolder folder) {
+ public int GetMessageOffset(int messageId, int folderId) {
using (MySqlConnection cnn = MySqlHelper.GetConnection()) {
using (MySqlCommand cmd = cnn.CreateCommand()) {
cmd.CommandText = "SELECT COUNT(*) FROM Message WHERE FolderId = ?FolderId AND FolderMessageId <= ?FolderMessageId";
- cmd.Parameters.Add("?FolderId", folder.FolderId);
+ cmd.Parameters.Add("?FolderId", folderId);
cmd.Parameters.Add("?FolderMessageId", messageId);
return Convert.ToInt32((long)cmd.ExecuteScalar());
}
@@ -569,32 +569,30 @@
#region Message Flags
#region GetMessageFlags
- public StoreMessageFlags GetMessageFlags(int messageId, StoreFolder folder) {
- StoreMessageFlags flags = StoreMessageFlags.None;
-
+ public StoreMessageFlags? GetMessageFlags(int messageId, int folderId) {
using (MySqlConnection cnn = MySqlHelper.GetConnection()) {
using (MySqlCommand cmd = cnn.CreateCommand()) {
cmd.CommandText = "SELECT MessageFlags FROM Message WHERE FolderId = ?FolderId AND FolderMessageId = ?FolderMessageId";
- cmd.Parameters.Add("?FolderId", folder.FolderId);
+ cmd.Parameters.Add("?FolderId", folderId);
cmd.Parameters.Add("?FolderMessageId", messageId);
object o = cmd.ExecuteScalar();
if (!Convert.IsDBNull(o)) {
- flags = (StoreMessageFlags) o;
+ return (StoreMessageFlags) o;
+ } else {
+ return null;
}
}
}
-
- return flags;
}
#endregion
#region SetMessageFlags
- public void SetMessageFlags(int messageId, StoreFolder folder, StoreMessageFlags flags) {
+ public void SetMessageFlags(int messageId, int folderId, StoreMessageFlags flags) {
using (MySqlConnection cnn = MySqlHelper.GetConnection()) {
using (MySqlCommand cmd = cnn.CreateCommand()) {
cmd.CommandText = "UPDATE Message SET MessageFlags = ?MessageFlags WHERE FolderId = ?FolderId AND FolderMessageId = ?FolderMessageId";
- cmd.Parameters.Add("?FolderId", folder.FolderId);
+ cmd.Parameters.Add("?FolderId", folderId);
cmd.Parameters.Add("?FolderMessageId", messageId);
cmd.Parameters.Add("?MessageFlags", (int) flags);
@@ -736,11 +734,11 @@
#region Message Counts
#region GetMessageCount
- public int GetMessageCount(StoreFolder folder) {
+ public int GetMessageCount(int folderId) {
using (MySqlConnection cnn = MySqlHelper.GetConnection()) {
using (MySqlCommand cmd = cnn.CreateCommand()) {
cmd.CommandText = "SELECT COUNT(*) as MessageCount FROM Message WHERE FolderId = ?FolderId";
- cmd.Parameters.Add("?FolderId", folder.FolderId);
+ cmd.Parameters.Add("?FolderId", folderId);
return Convert.ToInt32((Int64)cmd.ExecuteScalar());
}
}
@@ -783,7 +781,7 @@
int[] result = new int[folderMsgIds.Count];
for (int i = 0; i < folderMsgIds.Count; i++) {
- result[i] = GetMessageOffset((int) folderMsgIds[i], folder);
+ result[i] = GetMessageOffset((int) folderMsgIds[i], folder.FolderId);
cmd = cnn.CreateCommand();
cmd.Transaction = transaction;
Modified: NMail/trunk/NMail.LocalStoreData.NHibernate/InternalStoreFolder.cs
===================================================================
--- NMail/trunk/NMail.LocalStoreData.NHibernate/InternalStoreFolder.cs 2007-04-24 12:45:08 UTC (rev 185)
+++ NMail/trunk/NMail.LocalStoreData.NHibernate/InternalStoreFolder.cs 2007-04-24 15:46:35 UTC (rev 186)
@@ -41,7 +41,7 @@
this.ParentId = f.ParentId;
}
- private int nextMessageId;
+ private int nextMessageId = 1;
public int NextMessageId {
get { return nextMessageId; }
Modified: NMail/trunk/NMail.LocalStoreData.NHibernate/Mappings/NMail.LocalStoreData.NHibernate.InternalMessage.hbm.xml
===================================================================
--- NMail/trunk/NMail.LocalStoreData.NHibernate/Mappings/NMail.LocalStoreData.NHibernate.InternalMessage.hbm.xml 2007-04-24 12:45:08 UTC (rev 185)
+++ NMail/trunk/NMail.LocalStoreData.NHibernate/Mappings/NMail.LocalStoreData.NHibernate.InternalMessage.hbm.xml 2007-04-24 15:46:35 UTC (rev 186)
@@ -15,9 +15,9 @@
<property name="Headers" not-null="true"/>
- <property name="Preamble" not-null="true" type="Serializable"/>
+ <property name="Preamble" type="Serializable"/>
- <property name="Postamble" not-null="true" type="Serializable"/>
+ <property name="Postamble" type="Serializable"/>
<property name="MessageFlags" not-null="true"/>
Modified: NMail/trunk/NMail.LocalStoreData.NHibernate/NHibernateLocalStoreData.cs
===================================================================
--- NMail/trunk/NMail.LocalStoreData.NHibernate/NHibernateLocalStoreData.cs 2007-04-24 12:45:08 UTC (rev 185)
+++ NMail/trunk/NMail.LocalStoreData.NHibernate/NHibernateLocalStoreData.cs 2007-04-24 15:46:35 UTC (rev 186)
@@ -571,82 +571,96 @@
#region Message Id and Offset
#region GetNextMessageId
- public int GetNextMessageId(int messageId, StoreFolder folder) {
- //using (MySqlConnection cnn = MySqlHelper.GetConnection()) {
- // using (MySqlCommand cmd = cnn.CreateCommand()) {
- // cmd.CommandText = "SELECT FolderMessageId FROM Message WHERE FolderId = ?FolderId AND FolderMessageId > ?MessageId ORDER BY FolderMessageId LIMIT 1";
- // cmd.Parameters.Add("?FolderId", folder.FolderId);
- // cmd.Parameters.Add("?MessageId", messageId);
- // object o = cmd.ExecuteScalar();
+ /// <summary>
+ /// Gets the Id for the next message in the folder after the current Id.
+ /// </summary>
+ /// <param name="currentId">The Id to start looking from.</param>
+ /// <param name="folderId">The Id of the folder to get the next Id in.</param>
+ /// <returns>The Id of the next existing message or 0 if there is none.</returns>
+ public int GetNextMessageId(int messageId, int folderId) {
+ using (ISession session = this.hibernateFactory.OpenSession()) {
+ InternalMessage message = session.CreateCriteria(typeof(InternalMessage))
+ .Add(Expression.Eq("FolderId", folderId))
+ .Add(Expression.Gt("FolderMessageId", messageId))
+ .AddOrder(Order.Asc("FolderMessageId"))
+ .SetMaxResults(1)
+ .UniqueResult<InternalMessage>();
- // return (o == null) ? 0 : (int)o;
- // }
- //}
- throw new NotImplementedException();
+ return (message == null) ? 0 : message.FolderMessageId;
+ }
}
- public int GetNextMessageId(StoreFolder folder) {
- //using (MySqlConnection cnn = MySqlHelper.GetConnection()) {
- // using (MySqlCommand cmd = cnn.CreateCommand()) {
- // cmd.CommandText = "SELECT NextMessageId FROM Folder WHERE FolderId = ?FolderId";
- // cmd.Parameters.Add("?FolderId", folder.FolderId);
- // object o = cmd.ExecuteScalar();
-
- // return (o == null) ? 0 : (int)o;
- // }
- //}
- throw new NotImplementedException();
+ /// <summary>
+ /// Gets the Id for the next message to be added into the folder.
+ /// </summary>
+ /// <param name="folderId">The Id of the folder the message is in.</param>
+ /// <returns>The next message Id.</returns>
+ public int GetNextMessageId(int folderId) {
+ using (ISession session = this.hibernateFactory.OpenSession()) {
+ InternalStoreFolder folder = session.Get<InternalStoreFolder>(folderId);
+ return (folder == null) ? 0 : folder.NextMessageId;
+ }
}
#endregion
#region GetMessageId
- public int GetMessageId(int messageOffset, StoreFolder folder) {
- //using (MySqlConnection cnn = MySqlHelper.GetConnection()) {
- // using (MySqlCommand cmd = cnn.CreateCommand()) {
- // cmd.CommandText = "SELECT FolderMessageId FROM Message WHERE FolderId = ?FolderId ORDER BY FolderMessageId LIMIT 1 OFFSET ?Offset";
- // cmd.Parameters.Add("?FolderId", folder.FolderId);
- // cmd.Parameters.Add("?Offset", messageOffset - 1);
- // return (int)cmd.ExecuteScalar();
- // }
- //}
- throw new NotImplementedException();
+ /// <summary>
+ /// Gets the message Id (UID) corresponding to the given message offset.
+ /// </summary>
+ /// <param name="messageOffset">The offset of the message to lookup.</param>
+ /// <param name="folderId">The Id of the folder the message is in.</param>
+ /// <returns>The message Id or 0 if there is no such message.</returns>
+ public int GetMessageId(int messageOffset, int folderId) {
+ using (ISession session = this.hibernateFactory.OpenSession()) {
+ InternalMessage message = session.CreateCriteria(typeof(InternalMessage))
+ .Add(Expression.Eq("FolderId", folderId))
+ .AddOrder(Order.Asc("FolderMessageId"))
+ .SetFirstResult(messageOffset - 1)
+ .SetMaxResults(1)
+ .UniqueResult<InternalMessage>();
+
+ return (message == null) ? 0 : message.FolderMessageId;
+ }
}
#endregion
#region GetMessageOffset
- public int GetMessageOffset(int messageId, StoreFolder folder) {
- //using (MySqlConnection cnn = MySqlHelper.GetConnection()) {
- // using (MySqlCommand cmd = cnn.CreateCommand()) {
- // cmd.CommandText = "SELECT COUNT(*) FROM Message WHERE FolderId = ?FolderId AND FolderMessageId <= ?FolderMessageId";
- // cmd.Parameters.Add("?FolderId", folder.FolderId);
- // cmd.Parameters.Add("?FolderMessageId", messageId);
- // return Convert.ToInt32((long)cmd.ExecuteScalar());
- // }
- //}
- throw new NotImplementedException();
+ /// <summary>
+ /// Gets the message offset corresponding the to given message Id (UID).
+ /// </summary>
+ /// <param name="messageId">The Id of the message to lookup.</param>
+ /// <param name="folderId">The Id of the folder the message is in.</param>
+ /// <returns>The message offset or 0 if there is no such message.</returns>
+ public int GetMessageOffset(int messageId, int folderId) {
+ using (ISession session = this.hibernateFactory.OpenSession()) {
+ return session.CreateCriteria(typeof(InternalMessage))
+ .Add(Expression.Eq("FolderId", folderId))
+ .Add(Expression.Le("FolderMessageId", messageId))
+ .List<InternalMessage>().Count;
+ }
}
#endregion
#region GetMessageIds
+ /// <summary>
+ /// Gets a list of message Ids for a given folder.
+ /// </summary>
+ /// <param name="folderId">The Id of the folder the message is in.</param>
+ /// <returns>The list of messages in the folder.</returns>
public IList<int> GetMessageIds(int folderId) {
- //List<int> result = new List<int>();
+ List<int> result = new List<int>();
- //using (MySqlConnection cnn = MySqlHelper.GetConnection()) {
- // using (MySqlCommand cmd = cnn.CreateCommand()) {
- // cmd.CommandText = "SELECT FolderMessageId FROM Message WHERE FolderId = ?FolderId";
- // cmd.Parameters.Add("?FolderId", folderId);
+ using (ISession session = this.hibernateFactory.OpenSession()) {
+ IList<InternalMessage> messages = session.CreateCriteria(typeof(InternalMessage))
+ .Add(Expression.Eq("FolderId", folderId))
+ .List<InternalMessage>();
- // MySqlDataReader reader = cmd.ExecuteReader();
+ foreach (InternalMessage message in messages) {
+ result.Add(message.FolderMessageId);
+ }
+ }
- // while (reader.Read()) {
- // int id = (int) reader["FolderMessageId"];
- // result.Add(id);
- // }
- // }
- //}
-
- //return result;
- throw new NotImplementedException();
+ return result;
}
#endregion
#endregion
@@ -654,42 +668,53 @@
#region Message Flags
#region GetMessageFlags
- public StoreMessageFlags GetMessageFlags(int messageId, StoreFolder folder) {
- //StoreMessageFlags flags = StoreMessageFlags.None;
+ /// <summary>
+ /// Gets the message flags for a message.
+ /// </summary>
+ /// <param name="messageId">The Id of the message to get the flags for.</param>
+ /// <param name="folderId">The Id of the folder the message is in.</param>
+ /// <returns>The message flags.</returns>
+ public StoreMessageFlags? GetMessageFlags(int messageId, int folderId) {
+ using (ISession session = this.hibernateFactory.OpenSession()) {
+ InternalMessage message = session.CreateCriteria(typeof(InternalMessage))
+ .Add(Expression.Eq("FolderId", folderId))
+ .Add(Expression.Eq("FolderMessageId", messageId))
+ .UniqueResult<InternalMessage>();
- //using (MySqlConnection cnn = MySqlHelper.GetConnection()) {
- // using (MySqlCommand cmd = cnn.CreateCommand()) {
- // cmd.CommandText = "SELECT MessageFlags FROM Message WHERE FolderId = ?FolderId AND FolderMessageId = ?FolderMessageId";
- // cmd.Parameters.Add("?FolderId", folder.FolderId);
- // cmd.Parameters.Add("?FolderMessageId", messageId);
- // object o = cmd.ExecuteScalar();
-
- // if (!Convert.IsDBNull(o)) {
- // flags = (StoreMessageFlags) o;
- // }
- // }
- //}
-
- //return flags;
- throw new NotImplementedException();
+ return (message == null) ? null : (StoreMessageFlags?) message.MessageFlags;
+ }
}
#endregion
#region SetMessageFlags
- public void SetMessageFlags(int messageId, StoreFolder folder, StoreMessageFlags flags) {
- //using (MySqlConnection cnn = MySqlHelper.GetConnection()) {
- // using (MySqlCommand cmd = cnn.CreateCommand()) {
- // cmd.CommandText = "UPDATE Message SET MessageFlags = ?MessageFlags WHERE FolderId = ?FolderId AND FolderMessageId = ?FolderMessageId";
- // cmd.Parameters.Add("?FolderId", folder.FolderId);
- // cmd.Parameters.Add("?FolderMessageId", messageId);
- // cmd.Parameters.Add("?MessageFlags", (int) flags);
+ /// <summary>
+ /// Sets the message flags for a message.
+ /// </summary>
+ /// <remarks>This will replace any existing flags on the message.</remarks>
+ /// <param name="messageId">The Id of the message to set the flags for.</param>
+ /// <param name="folderId">The Id of the folder the message is in.</param>
+ /// <param name="flags">The flags to set.</param>
+ public void SetMessageFlags(int messageId, int folderId, StoreMessageFlags flags) {
+ using (ISession session = this.hibernateFactory.OpenSession()) {
+ using (ITransaction tx = session.BeginTransaction()) {
- // if (cmd.ExecuteNonQuery() != 1) {
- // throw new Exception("Error updating message flags.");
- // }
- // }
- //}
- throw new NotImplementedException();
+ InternalMessage message = session.CreateCriteria(typeof(InternalMessage))
+ .Add(Expression.Eq("FolderId", folderId))
+ .Add(Expression.Eq("FolderMessageId", messageId))
+ .UniqueResult<InternalMessage>();
+
+ if (message == null) {
+ throw new ArgumentException("Invalid message or folder Id.");
+ }
+
+ message.MessageFlags = flags;
+
+ session.Update(message);
+
+ tx.Commit();
+ session.Close();
+ }
+ }
}
#endregion
@@ -828,15 +853,17 @@
#region Message Counts
#region GetMessageCount
- public int GetMessageCount(StoreFolder folder) {
- //using (MySqlConnection cnn = MySqlHelper.GetConnection()) {
- // using (MySqlCommand cmd = cnn.CreateCommand()) {
- // cmd.CommandText = "SELECT COUNT(*) as MessageCount FROM Message WHERE FolderId = ?FolderId";
- // cmd.Parameters.Add("?FolderId", folder.FolderId);
- // return Convert.ToInt32((Int64)cmd.ExecuteScalar());
- // }
- //}
- throw new NotImplementedException();
+ /// <summary>
+ /// Gets the number of messages in the given store folder.
+ /// </summary>
+ /// <param name="folderId">The Id of the folder to count the messages in.</param>
+ /// <returns>The message count.</returns>
+ public int GetMessageCount(int folderId) {
+ using (ISession session = this.hibernateFactory.OpenSession()) {
+ return session.CreateCriteria(typeof(InternalMessage))
+ .Add(Expression.Eq("FolderId", folderId))
+ .List<InternalMessage>().Count;
+ }
}
#endregion
Added: NMail/trunk/NMail.UnitTests/LocalStoreData/DeliverMessageTest1.cs
===================================================================
--- NMail/trunk/NMail.UnitTests/LocalStoreData/DeliverMessageTest1.cs (rev 0)
+++ NMail/trunk/NMail.UnitTests/LocalStoreData/DeliverMessageTest1.cs 2007-04-24 15:46:35 UTC (rev 186)
@@ -0,0 +1,34 @@
+using System;
+using System.Collections.Generic;
+using System.Text;
+
+using NUnit.Framework;
+
+using NMail.Configuration;
+using NMail.DataTypes;
+using NMail.DataTypes.LocalStore;
+using NMail.UnitTests.Resources;
+
+namespace NMail.UnitTests.LocalStoreData {
+ /// <summary>
+ /// Tests delivering a message.
+ /// </summary>
+ [TestFixture]
+ public class DeliverMessageTest1 : BaseLocalStoreDataTest {
+
+ [Test]
+ public void TestGetStoreFolder() {
+ LocalStoreUser user1 = new LocalStoreUser();
+ user1.Username = "Test";
+ this.localStoreData.CreateUser(user1);
+
+ Assert.IsTrue(user1.UserId > 0, "Valid user Id.");
+ Assert.IsTrue(user1.UserFolderId > 0, "Valid user folder Id.");
+
+ Message m1 = ResourceHelper.GetMessage("Test1.eml");
+ this.localStoreData.DeliverMessage(m1, user1.UserFolderId);
+
+ Assert.IsTrue(this.localStoreData.GetMessageCount(user1.UserFolderId) > 0, "Folder has messages.");
+ }
+ }
+}
Added: NMail/trunk/NMail.UnitTests/LocalStoreData/GetMessageIdTest1.cs
===================================================================
--- NMail/trunk/NMail.UnitTests/LocalStoreData/GetMessageIdTest1.cs (rev 0)
+++ NMail/trunk/NMail.UnitTests/LocalStoreData/GetMessageIdTest1.cs 2007-04-24 15:46:35 UTC (rev 186)
@@ -0,0 +1,43 @@
+using System;
+using System.Collections.Generic;
+using System.Text;
+
+using NUnit.Framework;
+
+using NMail.Configuration;
+using NMail.DataTypes;
+using NMail.DataTypes.LocalStore;
+using NMail.UnitTests.Resources;
+
+namespace NMail.UnitTests.LocalStoreData {
+ /// <summary>
+ /// Tests getting the message Id.
+ /// </summary>
+ [TestFixture]
+ public class GetMessageIdTest1 : BaseLocalStoreDataTest {
+
+ [Test]
+ public void TestGetMessageId() {
+ LocalStoreUser user1 = new LocalStoreUser();
+ user1.Username = "Test1";
+ this.localStoreData.CreateUser(user1);
+ Assert.IsTrue(user1.UserId > 0, "Valid user Id.");
+ Assert.IsTrue(user1.UserFolderId > 0, "Valid user folder Id.");
+
+ LocalStoreUser user2 = new LocalStoreUser();
+ user2.Username = "Test2";
+ this.localStoreData.CreateUser(user2);
+ Assert.IsTrue(user2.UserId > 0, "Valid user Id.");
+ Assert.IsTrue(user2.UserFolderId > 0, "Valid user folder Id.");
+
+ Message m1 = ResourceHelper.GetMessage("Test1.eml");
+ this.localStoreData.DeliverMessage(m1, user1.UserFolderId);
+ this.localStoreData.DeliverMessage(m1, user2.UserFolderId);
+
+ Assert.IsTrue(this.localStoreData.GetMessageId(1, user1.UserFolderId) > 0, "Valid message Id.");
+
+ this.localStoreData.DeliverMessage(m1, user1.UserFolderId);
+ Assert.IsTrue(this.localStoreData.GetMessageId(2, user1.UserFolderId) > 0, "Valid message Id.");
+ }
+ }
+}
Added: NMail/trunk/NMail.UnitTests/LocalStoreData/GetMessageIdsTest1.cs
===================================================================
--- NMail/trunk/NMail.UnitTests/LocalStoreData/GetMessageIdsTest1.cs (rev 0)
+++ NMail/trunk/NMail.UnitTests/LocalStoreData/GetMessageIdsTest1.cs 2007-04-24 15:46:35 UTC (rev 186)
@@ -0,0 +1,46 @@
+using System;
+using System.Collections.Generic;
+using System.Text;
+
+using NUnit.Framework;
+
+using NMail.Configuration;
+using NMail.DataTypes;
+using NMail.DataTypes.LocalStore;
+using NMail.UnitTests.Resources;
+
+namespace NMail.UnitTests.LocalStoreData {
+ /// <summary>
+ /// Tests getting the message Ids.
+ /// </summary>
+ [TestFixture]
+ public class GetMessageIdsTest1 : BaseLocalStoreDataTest {
+
+ [Test]
+ public void TestGetMessageIds() {
+ LocalStoreUser user1 = new LocalStoreUser();
+ user1.Username = "Test1";
+ this.localStoreData.CreateUser(user1);
+ Assert.IsTrue(user1.UserId > 0, "Valid user Id.");
+ Assert.IsTrue(user1.UserFolderId > 0, "Valid user folder Id.");
+
+ LocalStoreUser user2 = new LocalStoreUser();
+ user2.Username = "Test2";
+ this.localStoreData.CreateUser(user2);
+ Assert.IsTrue(user2.UserId > 0, "Valid user Id.");
+ Assert.IsTrue(user2.UserFolderId > 0, "Valid user folder Id.");
+
+ Message m1 = ResourceHelper.GetMessage("Test1.eml");
+ this.localStoreData.DeliverMessage(m1, user1.UserFolderId);
+ this.localStoreData.DeliverMessage(m1, user2.UserFolderId);
+ this.localStoreData.DeliverMessage(m1, user1.UserFolderId);
+
+ IList<int> messageIds = this.localStoreData.GetMessageIds(user1.UserFolderId);
+
+ Assert.AreEqual(2, messageIds.Count, "Two messages.");
+
+ Assert.AreEqual(1, this.localStoreData.GetMessageOffset(messageIds[0], user1.UserFolderId), "Correct message offset 1.");
+ Assert.AreEqual(2, this.localStoreData.GetMessageOffset(messageIds[1], user1.UserFolderId), "Correct message offset 2.");
+ }
+ }
+}
Added: NMail/trunk/NMail.UnitTests/LocalStoreData/GetMessageOffsetTest1.cs
===================================================================
--- NMail/trunk/NMail.UnitTests/LocalStoreData/GetMessageOffsetTest1.cs (rev 0)
+++ NMail/trunk/NMail.UnitTests/LocalStoreData/GetMessageOffsetTest1.cs 2007-04-24 15:46:35 UTC (rev 186)
@@ -0,0 +1,48 @@
+using System;
+using System.Collections.Generic;
+using System.Text;
+
+using NUnit.Framework;
+
+using NMail.Configuration;
+using NMail.DataTypes;
+using NMail.DataTypes.LocalStore;
+using NMail.UnitTests.Resources;
+
+namespace NMail.UnitTests.LocalStoreData {
+ /// <summary>
+ /// Tests getting the message offset.
+ /// </summary>
+ [TestFixture]
+ public class GetMessageOffsetTest1 : BaseLocalStoreDataTest {
+
+ [Test]
+ public void TestGetMessageOffset() {
+ LocalStoreUser user1 = new LocalStoreUser();
+ user1.Username = "Test1";
+ this.localStoreData.CreateUser(user1);
+ Assert.IsTrue(user1.UserId > 0, "Valid user Id.");
+ Assert.IsTrue(user1.UserFolderId > 0, "Valid user folder Id.");
+
+ LocalStoreUser user2 = new LocalStoreUser();
+ user2.Username = "Test2";
+ this.localStoreData.CreateUser(user2);
+ Assert.IsTrue(user2.UserId > 0, "Valid user Id.");
+ Assert.IsTrue(user2.UserFolderId > 0, "Valid user folder Id.");
+
+ Message m1 = ResourceHelper.GetMessage("Test1.eml");
+ this.localStoreData.DeliverMessage(m1, user1.UserFolderId);
+ this.localStoreData.DeliverMessage(m1, user2.UserFolderId);
+ this.localStoreData.DeliverMessage(m1, user1.UserFolderId);
+
+ int m1Uid = this.localStoreData.GetMessageId(1, user1.UserFolderId);
+ int m2Uid = this.localStoreData.GetMessageId(2, user1.UserFolderId);
+
+ Assert.IsTrue(m1Uid > 0, "Valid message Id 1.");
+ Assert.IsTrue(m2Uid > 0, "Valid message Id 2.");
+
+ Assert.AreEqual(1, this.localStoreData.GetMessageOffset(m1Uid, user1.UserFolderId), "Correct message offset 1.");
+ Assert.AreEqual(2, this.localStoreData.GetMessageOffset(m2Uid, user1.UserFolderId), "Correct message offset 2.");
+ }
+ }
+}
Added: NMail/trunk/NMail.UnitTests/LocalStoreData/GetNextMessageIdTest1.cs
===================================================================
--- NMail/trunk/NMail.UnitTests/LocalStoreData/GetNextMessageIdTest1.cs (rev 0)
+++ NMail/trunk/NMail.UnitTests/LocalStoreData/GetNextMessageIdTest1.cs 2007-04-24 15:46:35 UTC (rev 186)
@@ -0,0 +1,38 @@
+using System;
+using System.Collections.Generic;
+using System.Text;
+
+using NUnit.Framework;
+
+using NMail.Configuration;
+using NMail.DataTypes;
+using NMail.DataTypes.LocalStore;
+using NMail.UnitTests.Resources;
+
+namespace NMail.UnitTests.LocalStoreData {
+ /// <summary>
+ /// Tests getting the next message Id.
+ /// </summary>
+ [TestFixture]
+ public class GetNextMessageIdTest1 : BaseLocalStoreDataTest {
+
+ [Test]
+ public void TestGetNextMessageId() {
+ LocalStoreUser user1 = new LocalStoreUser();
+ user1.Username = "Test";
+ this.localStoreData.CreateUser(user1);
+
+ Assert.IsTrue(user1.UserId > 0, "Valid user Id.");
+ Assert.IsTrue(user1.UserFolderId > 0, "Valid user folder Id.");
+
+ Assert.AreEqual(1, this.localStoreData.GetNextMessageId(user1.UserFolderId), "Next message Id is one.");
+
+ Message m1 = ResourceHelper.GetMessage("Test1.eml");
+ this.localStoreData.DeliverMessage(m1, user1.UserFolderId);
+
+ Assert.IsTrue(this.localStoreData.GetMessageCount(user1.UserFolderId) > 0, "Folder has messages.");
+
+ Assert.AreEqual(2, this.localStoreData.GetNextMessageId(user1.UserFolderId), "Next message Id is two.");
+ }
+ }
+}
Added: NMail/trunk/NMail.UnitTests/LocalStoreData/GetSetMessageFlagsTest1.cs
===================================================================
--- NMail/trunk/NMail.UnitTests/LocalStoreData/GetSetMessageFlagsTest1.cs (rev 0)
+++ NMail/trunk/NMail.UnitTests/LocalStoreData/GetSetMessageFlagsTest1.cs 2007-04-24 15:46:35 UTC (rev 186)
@@ -0,0 +1,54 @@
+using System;
+using System.Collections.Generic;
+using System.Text;
+
+using NUnit.Framework;
+
+using NMail.Configuration;
+using NMail.DataTypes;
+using NMail.DataTypes.LocalStore;
+using NMail.UnitTests.Resources;
+
+namespace NMail.UnitTests.LocalStoreData {
+ /// <summary>
+ /// Tests getting and setting the message flags.
+ /// </summary>
+ [TestFixture]
+ public class GetSetMessageFlagsTest1 : BaseLocalStoreDataTest {
+
+ [Test]
+ public void TestGetSetMessageFlags() {
+ LocalStoreUser user1 = new LocalStoreUser();
+ user1.Username = "Test1";
+ this.localStoreData.CreateUser(user1);
+ Assert.IsTrue(user1.UserId > 0, "Valid user Id.");
+ Assert.IsTrue(user1.UserFolderId > 0, "Valid user folder Id.");
+
+ LocalStoreUser user2 = new LocalStoreUser();
+ user2.Username = "Test2";
+ this.localStoreData.CreateUser(user2);
+ Assert.IsTrue(user2.UserId > 0, "Valid user Id.");
+ Assert.IsTrue(user2.UserFolderId > 0, "Valid user folder Id.");
+
+ Message m1 = ResourceHelper.GetMessage("Test1.eml");
+ this.localStoreData.DeliverMessage(m1, user1.UserFolderId);
+ this.localStoreData.DeliverMessage(m1, user2.UserFolderId);
+ this.localStoreData.DeliverMessage(m1, user1.UserFolderId);
+
+ int m1Uid = this.localStoreData.GetMessageId(1, user1.UserFolderId);
+ int m2Uid = this.localStoreData.GetMessageId(2, user1.UserFolderId);
+
+ Assert.IsTrue(m1Uid > 0, "Valid message Id 1.");
+ Assert.IsTrue(m2Uid > 0, "Valid message Id 2.");
+
+ Assert.AreEqual(StoreMessageFlags.Recent, this.localStoreData.GetMessageFlags(m1Uid, user1.UserFolderId), "Correct message flags 1.");
+ Assert.AreEqual(StoreMessageFlags.Recent, this.localStoreData.GetMessageFlags(m2Uid, user1.UserFolderId), "Correct message flags 2.");
+
+ this.localStoreData.SetMessageFlags(m1Uid, user1.UserFolderId, StoreMessageFlags.Answered);
+ this.localStoreData.SetMessageFlags(m2Uid, user1.UserFolderId, StoreMessageFlags.Draft | StoreMessageFlags.Flagged);
+
+ Assert.AreEqual(StoreMessageFlags.Answered, this.localStoreData.GetMessageFlags(m1Uid, user1.UserFolderId), "Correct message flags 3.");
+ Assert.AreEqual(StoreMessageFlags.Draft | StoreMessageFlags.Flagged, this.localStoreData.GetMessageFlags(m2Uid, user1.UserFolderId), "Correct message flags 4.");
+ }
+ }
+}
Modified: NMail/trunk/NMail.UnitTests/NMail.UnitTests.csproj
===================================================================
--- NMail/trunk/NMail.UnitTests/NMail.UnitTests.csproj 2007-04-24 12:45:08 UTC (rev 185)
+++ NMail/trunk/NMail.UnitTests/NMail.UnitTests.csproj 2007-04-24 15:46:35 UTC (rev 186)
@@ -52,6 +52,12 @@
<Compile Include="DataTypes\Helper\MimeHelperTests.cs" />
<Compile Include="DataTypes\Helper\StringTokenizerTests.cs" />
<Compile Include="LocalStoreData\BaseLocalStoreDataTest.cs" />
+ <Compile Include="LocalStoreData\GetSetMessageFlagsTest1.cs" />
+ <Compile Include="LocalStoreData\GetMessageIdsTest1.cs" />
+ <Compile Include="LocalStoreData\GetMessageOffsetTest1.cs" />
+ <Compile Include="LocalStoreData\GetMessageIdTest1.cs" />
+ <Compile Include="LocalStoreData\GetNextMessageIdTest1.cs" />
+ <Compile Include="LocalStoreData\DeliverMessageTest1.cs" />
<Compile Include="LocalStoreData\GetStoreFolderChildrenTest1.cs" />
<Compile Include="LocalStoreData\GetStoreFolderTest2.cs" />
<Compile Include="LocalStoreData\GetStoreFolderTest1.cs" />
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <tmy...@us...> - 2007-04-24 12:45:08
|
Revision: 185
http://svn.sourceforge.net/nmailserver/?rev=185&view=rev
Author: tmyroadctfig
Date: 2007-04-24 05:45:08 -0700 (Tue, 24 Apr 2007)
Log Message:
-----------
Further work on local store data and unit tests.
Modified Paths:
--------------
NMail/trunk/NMail/DataTypes/LocalStore/ILocalStoreData.cs
NMail/trunk/NMail.LocalStore/LocalStore.cs
NMail/trunk/NMail.LocalStoreData.MySql/MySqlLocalStoreData.cs
NMail/trunk/NMail.LocalStoreData.NHibernate/NHibernateLocalStoreData.cs
NMail/trunk/NMail.LocalStoreData.NHibernate/NMail.LocalStoreData.NHibernate.csproj
NMail/trunk/NMail.UnitTests/NMail.UnitTests.csproj
Added Paths:
-----------
NMail/trunk/NMail.LocalStoreData.NHibernate/InternalMessage.cs
NMail/trunk/NMail.LocalStoreData.NHibernate/InternalStoreFolder.cs
NMail/trunk/NMail.LocalStoreData.NHibernate/InternalStoreFolderAcl.cs
NMail/trunk/NMail.LocalStoreData.NHibernate/Mappings/NMail.LocalStoreData.NHibernate.InternalMessage.hbm.xml
NMail/trunk/NMail.LocalStoreData.NHibernate/Mappings/NMail.LocalStoreData.NHibernate.InternalStoreFolder.hbm.xml
NMail/trunk/NMail.LocalStoreData.NHibernate/Mappings/NMail.LocalStoreData.NHibernate.InternalStoreFolderAcl.hbm.xml
NMail/trunk/NMail.UnitTests/LocalStoreData/CreateGroupTest1.cs
NMail/trunk/NMail.UnitTests/LocalStoreData/CreateGroupTest2.cs
NMail/trunk/NMail.UnitTests/LocalStoreData/DeleteGroupTest1.cs
NMail/trunk/NMail.UnitTests/LocalStoreData/GetStoreFolderChildrenTest1.cs
NMail/trunk/NMail.UnitTests/LocalStoreData/GetStoreFolderTest1.cs
NMail/trunk/NMail.UnitTests/LocalStoreData/GetStoreFolderTest2.cs
NMail/trunk/NMail.UnitTests/LocalStoreData/RemoveStoreFolderAceTest1.cs
Removed Paths:
-------------
NMail/trunk/NMail.LocalStoreData.NHibernate/Mappings/NMail.DataTypes.ACLs.StoreFolderAcl.hbm.xml
NMail/trunk/NMail.LocalStoreData.NHibernate/Mappings/NMail.DataTypes.LocalStore.StoreFolder.hbm.xml
Modified: NMail/trunk/NMail/DataTypes/LocalStore/ILocalStoreData.cs
===================================================================
--- NMail/trunk/NMail/DataTypes/LocalStore/ILocalStoreData.cs 2007-04-19 12:09:29 UTC (rev 184)
+++ NMail/trunk/NMail/DataTypes/LocalStore/ILocalStoreData.cs 2007-04-24 12:45:08 UTC (rev 185)
@@ -46,8 +46,8 @@
/// Delivers the message into the given folder.
/// </summary>
/// <param name="message">The message data.</param>
- /// <param name="folder">The folder to deliver into.</param>
- void DeliverMessage(Message message, StoreFolder folder);
+ /// <param name="folder">The Id of the folder to deliver into.</param>
+ void DeliverMessage(Message message, int folderId);
#endregion
#region Folder Retrieval and Manipulation
Modified: NMail/trunk/NMail.LocalStore/LocalStore.cs
===================================================================
--- NMail/trunk/NMail.LocalStore/LocalStore.cs 2007-04-19 12:09:29 UTC (rev 184)
+++ NMail/trunk/NMail.LocalStore/LocalStore.cs 2007-04-24 12:45:08 UTC (rev 185)
@@ -204,7 +204,7 @@
/// <returns>The result of the delivery.</returns>
public DeliveryResult DeliverMessage(IAuthenticationToken authToken, Message message, StoreFolder folder) {
- LocalStoreData.DeliverMessage(message, folder);
+ LocalStoreData.DeliverMessage(message, folder.FolderId);
return new DeliveryResult(DeliveryResultType.Success, null);
// TODO: lookup a maildomain or a system wide delivery chain to process the message
Modified: NMail/trunk/NMail.LocalStoreData.MySql/MySqlLocalStoreData.cs
===================================================================
--- NMail/trunk/NMail.LocalStoreData.MySql/MySqlLocalStoreData.cs 2007-04-19 12:09:29 UTC (rev 184)
+++ NMail/trunk/NMail.LocalStoreData.MySql/MySqlLocalStoreData.cs 2007-04-24 12:45:08 UTC (rev 185)
@@ -63,14 +63,14 @@
// TODO: update quotas?
public void DeliverMessage(LocalStoreDelivery message) {
- DeliverMessage(message.Message, GetStoreFolder(message.TargetFolder));
+ DeliverMessage(message.Message, GetStoreFolder(message.TargetFolder).FolderId);
foreach (StoreFolder folder in message.AdditionalFolders) {
- DeliverMessage(message.Message, GetStoreFolder(folder));
+ DeliverMessage(message.Message, GetStoreFolder(folder).FolderId);
}
}
- public void DeliverMessage(Message message, StoreFolder folder) {
+ public void DeliverMessage(Message message, int folderId) {
using (MySqlConnection cnn = MySqlHelper.GetConnection()) {
MySqlTransaction transaction = null;
@@ -83,7 +83,7 @@
// Get the next folder message id
cmd.CommandText = "SELECT NextMessageId FROM Folder WHERE FolderId=?FolderId";
- cmd.Parameters.Add("?FolderId", folder.FolderId);
+ cmd.Parameters.Add("?FolderId", folderId);
int folderMessageId = (int)cmd.ExecuteScalar();
// Update the next message id
@@ -91,7 +91,7 @@
cmd.Transaction = transaction;
cmd.Connection = cnn;
cmd.CommandText = "UPDATE Folder SET NextMessageId=?NextMessageId WHERE FolderId=?FolderId";
- cmd.Parameters.Add("?FolderId", folder.FolderId);
+ cmd.Parameters.Add("?FolderId", folderId);
cmd.Parameters.Add("?NextMessageId", folderMessageId + 1);
int count = cmd.ExecuteNonQuery();
if (count == 1) {
@@ -101,7 +101,7 @@
cmd.Connection = cnn;
cmd.CommandText = "INSERT INTO Message (FolderId, FolderMessageId, MimeMessage, Headers, Preamble, Postamble, MessageFlags, Size, InternalDate) " +
"VALUES (?FolderId, ?FolderMessageId, ?MimeMessage, ?Headers, ?Preamble, ?Postamble, ?MessageFlags, ?Size, ?InternalDate)";
- cmd.Parameters.Add("?FolderId", folder.FolderId);
+ cmd.Parameters.Add("?FolderId", folderId);
cmd.Parameters.Add("?FolderMessageId", folderMessageId);
cmd.Parameters.Add("?MimeMessage", message.MultipartBody);
cmd.Parameters.Add("?Headers", message.Headers.Data.Bytes);
Added: NMail/trunk/NMail.LocalStoreData.NHibernate/InternalMessage.cs
===================================================================
--- NMail/trunk/NMail.LocalStoreData.NHibernate/InternalMessage.cs (rev 0)
+++ NMail/trunk/NMail.LocalStoreData.NHibernate/InternalMessage.cs 2007-04-24 12:45:08 UTC (rev 185)
@@ -0,0 +1,104 @@
+using System;
+using System.Collections.Generic;
+using System.Text;
+
+using NMail.DataTypes;
+using NMail.DataTypes.LocalStore;
+
+namespace NMail.LocalStoreData.NHibernate {
+
+ internal class InternalMessage {
+
+ internal InternalMessage() { }
+
+ internal InternalMessage(Message message) {
+ this.mimeMessage = message.MultipartBody;
+ this.headers = message.Headers;
+ this.preamble = message.Preamble;
+ this.postamble = message.Postamble;
+
+ if (this.mimeMessage) {
+ this.mimeParts = message.MimeParts;
+ } else {
+ this.simpleBody = message.BodyData;
+ }
+ }
+
+ private long messageId;
+
+ internal long MessageId {
+ get { return messageId; }
+ set { messageId = value; }
+ }
+
+ private int folderMessageId;
+
+ internal int FolderMessageId {
+ get { return folderMessageId; }
+ set { folderMessageId = value; }
+ }
+
+ private int folderId;
+
+ internal int FolderId {
+ get { return folderId; }
+ set { folderId = value; }
+ }
+
+ private bool mimeMessage;
+
+ internal bool MimeMessage {
+ get { return this.mimeMessage; }
+ set { this.mimeMessage = value; }
+ }
+
+ private MessageHeaders headers;
+
+ internal MessageHeaders Headers {
+ get { return headers; }
+ set { headers = value; }
+ }
+
+ private IMessagePart preamble;
+
+ internal IMessagePart Preamble {
+ get { return preamble; }
+ set { preamble = value; }
+ }
+
+ private IMessagePart postamble;
+
+ internal IMessagePart Postamble {
+ get { return postamble; }
+ set { postamble = value; }
+ }
+
+ private StoreMessageFlags messageFlags;
+
+ internal StoreMessageFlags MessageFlags {
+ get { return messageFlags; }
+ set { messageFlags = value; }
+ }
+
+ private DateTime internalDate;
+
+ internal DateTime InternalDate {
+ get { return internalDate; }
+ set { internalDate = value; }
+ }
+
+ private ByteString simpleBody;
+
+ internal ByteString SimpleBody {
+ get { return simpleBody; }
+ set { simpleBody = value; }
+ }
+
+ private IList<IMessageBodyPart> mimeParts;
+
+ internal IList<IMessageBodyPart> MimeParts {
+ get { return mimeParts; }
+ set { mimeParts = value; }
+ }
+ }
+}
Added: NMail/trunk/NMail.LocalStoreData.NHibernate/InternalStoreFolder.cs
===================================================================
--- NMail/trunk/NMail.LocalStoreData.NHibernate/InternalStoreFolder.cs (rev 0)
+++ NMail/trunk/NMail.LocalStoreData.NHibernate/InternalStoreFolder.cs 2007-04-24 12:45:08 UTC (rev 185)
@@ -0,0 +1,51 @@
+using System;
+using System.Collections.Generic;
+using System.Text;
+
+using NMail.DataTypes;
+using NMail.DataTypes.LocalStore;
+
+namespace NMail.LocalStoreData.NHibernate {
+ [Serializable]
+ internal class InternalStoreFolder : StoreFolder {
+
+ internal InternalStoreFolder() { }
+
+ /// <summary>
+ /// Creates a new store folder.
+ /// </summary>
+ /// <param name="newFolder">The folder name.</param>
+ internal InternalStoreFolder(string newFolder) : base(newFolder) { }
+
+ /// <summary>
+ /// Creates a new store folder.
+ /// </summary>
+ /// <param name="newNameSpace">The namespace the folder belongs to.</param>
+ /// <param name="newFolder">The folder name.</param>
+ internal InternalStoreFolder(string newNameSpace, string newFolder) : base(newNameSpace, newFolder) { }
+
+ /// <summary>
+ /// Creates a new store folder.
+ /// </summary>
+ /// <param name="parent">The parent folder.</param>
+ /// <param name="childName">The name of this folder.</param>
+ internal InternalStoreFolder(Folder parent, string childName) : base(parent, childName) { }
+
+ internal InternalStoreFolder(StoreFolder f) {
+ this.ChildIds = f.ChildIds;
+ this.FolderId = f.FolderId;
+ this.FullFolderName = f.FullFolderName;
+ this.HasChildren = f.HasChildren;
+ this.NameSpace = f.NameSpace;
+ this.OwnerUserId = f.OwnerUserId;
+ this.ParentId = f.ParentId;
+ }
+
+ private int nextMessageId;
+
+ public int NextMessageId {
+ get { return nextMessageId; }
+ set { nextMessageId = value; }
+ }
+ }
+}
Added: NMail/trunk/NMail.LocalStoreData.NHibernate/InternalStoreFolderAcl.cs
===================================================================
--- NMail/trunk/NMail.LocalStoreData.NHibernate/InternalStoreFolderAcl.cs (rev 0)
+++ NMail/trunk/NMail.LocalStoreData.NHibernate/InternalStoreFolderAcl.cs 2007-04-24 12:45:08 UTC (rev 185)
@@ -0,0 +1,59 @@
+using System;
+using System.Collections.Generic;
+using System.Text;
+
+using NMail.DataTypes.ACLs;
+using NMail.DataTypes.LocalStore;
+
+namespace NMail.LocalStoreData.NHibernate {
+
+ internal class InternalStoreFolderAcl : GenericAcl<StoreFolderPrivilege> {
+
+ internal InternalStoreFolderAcl() { }
+
+ internal InternalStoreFolderAcl(StoreFolder folder) : base() {
+ this.folder = new InternalStoreFolder(folder);
+ }
+
+ internal InternalStoreFolderAcl(StoreFolderAcl acl) : base() {
+ this.folder = new InternalStoreFolder(acl.Folder);
+ this.aclId = acl.AclId;
+ }
+
+ internal StoreFolderAcl CreateStoreFolderAcl() {
+ StoreFolderAcl result = new StoreFolderAcl(this.folder);
+ result.AclId = this.aclId;
+
+ IEnumerator<KeyValuePair<string, GenericAce<StoreFolderPrivilege>>> e = this.entries.GetEnumerator();
+ while (e.MoveNext()) {
+ result.SetAce(e.Current.Value);
+ }
+
+ return result;
+ }
+
+ private int aclId;
+
+ /// <summary>
+ /// The Id of this store folder ACL.
+ /// </summary>
+ public int AclId {
+ get { return aclId; }
+ set { aclId = value; }
+ }
+
+ private InternalStoreFolder folder;
+
+ /// <summary>
+ /// The folder associated with this ACL.
+ /// </summary>
+ public InternalStoreFolder Folder {
+ get {
+ return this.folder;
+ }
+ set {
+ this.folder = value;
+ }
+ }
+ }
+}
Deleted: NMail/trunk/NMail.LocalStoreData.NHibernate/Mappings/NMail.DataTypes.ACLs.StoreFolderAcl.hbm.xml
===================================================================
--- NMail/trunk/NMail.LocalStoreData.NHibernate/Mappings/NMail.DataTypes.ACLs.StoreFolderAcl.hbm.xml 2007-04-19 12:09:29 UTC (rev 184)
+++ NMail/trunk/NMail.LocalStoreData.NHibernate/Mappings/NMail.DataTypes.ACLs.StoreFolderAcl.hbm.xml 2007-04-24 12:45:08 UTC (rev 185)
@@ -1,19 +0,0 @@
-<?xml version="1.0" encoding="utf-8" ?>
-<hibernate-mapping xmlns="urn:nhibernate-mapping-2.2" namespace="NMail" assembly="NMail" default-lazy="false">
-
- <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="Serializable" />
- </map>
- </class>
-
-</hibernate-mapping>
\ No newline at end of file
Deleted: NMail/trunk/NMail.LocalStoreData.NHibernate/Mappings/NMail.DataTypes.LocalStore.StoreFolder.hbm.xml
===================================================================
--- NMail/trunk/NMail.LocalStoreData.NHibernate/Mappings/NMail.DataTypes.LocalStore.StoreFolder.hbm.xml 2007-04-19 12:09:29 UTC (rev 184)
+++ NMail/trunk/NMail.LocalStoreData.NHibernate/Mappings/NMail.DataTypes.LocalStore.StoreFolder.hbm.xml 2007-04-24 12:45:08 UTC (rev 185)
@@ -1,27 +0,0 @@
-<?xml version="1.0" encoding="utf-8" ?>
-<hibernate-mapping xmlns="urn:nhibernate-mapping-2.2" namespace="NMail" assembly="NMail" default-lazy="false">
-
- <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: ideally this would be a many-to-one relationship with StoreFolder -->
- <property name="ParentId" type="System.Int32" />
-
- <!-- TODO: ideally this would be a many-to-one relationship with LocalStoreUser -->
- <property name="OwnerUserId" not-null="true" />
-
- <list name="ChildIds" cascade="all" table="FolderChildren">
- <key column="FolderId" />
- <index column="ChildIndex" type="Int32" />
- <element column="ChildId" type="Int32" />
- </list>
- </class>
-
-</hibernate-mapping>
\ No newline at end of file
Added: NMail/trunk/NMail.LocalStoreData.NHibernate/Mappings/NMail.LocalStoreData.NHibernate.InternalMessage.hbm.xml
===================================================================
--- NMail/trunk/NMail.LocalStoreData.NHibernate/Mappings/NMail.LocalStoreData.NHibernate.InternalMessage.hbm.xml (rev 0)
+++ NMail/trunk/NMail.LocalStoreData.NHibernate/Mappings/NMail.LocalStoreData.NHibernate.InternalMessage.hbm.xml 2007-04-24 12:45:08 UTC (rev 185)
@@ -0,0 +1,35 @@
+<?xml version="1.0" encoding="utf-8" ?>
+<hibernate-mapping xmlns="urn:nhibernate-mapping-2.2" namespace="NMail.LocalStoreData.NHibernate" assembly="NMail.LocalStoreData.NHibernate" default-lazy="false">
+
+ <class name="NMail.LocalStoreData.NHibernate.InternalMessage" table="InternalMessage">
+ <id name="MessageId" type="Int64" unsaved-value="0">
+ <column name="MessageId" not-null="true"/>
+ <generator class="native" />
+ </id>
+
+ <property name="FolderMessageId" not-null="true"/>
+
+ <property name="FolderId" not-null="true"/>
+
+ <property name="MimeMessage" not-null="true"/>
+
+ <property name="Headers" not-null="true"/>
+
+ <property name="Preamble" not-null="true" type="Serializable"/>
+
+ <property name="Postamble" not-null="true" type="Serializable"/>
+
+ <property name="MessageFlags" not-null="true"/>
+
+ <property name="InternalDate" not-null="true"/>
+
+ <property name="SimpleBody" type="Serializable"/>
+
+ <list name="MimeParts" table="InternalMessageMimeParts" cascade="all">
+ <key column="MimePartId" />
+ <index column="PartNumber" type="Int32" />
+ <element column="Part" type="Serializable"/>
+ </list>
+ </class>
+
+</hibernate-mapping>
\ No newline at end of file
Added: NMail/trunk/NMail.LocalStoreData.NHibernate/Mappings/NMail.LocalStoreData.NHibernate.InternalStoreFolder.hbm.xml
===================================================================
--- NMail/trunk/NMail.LocalStoreData.NHibernate/Mappings/NMail.LocalStoreData.NHibernate.InternalStoreFolder.hbm.xml (rev 0)
+++ NMail/trunk/NMail.LocalStoreData.NHibernate/Mappings/NMail.LocalStoreData.NHibernate.InternalStoreFolder.hbm.xml 2007-04-24 12:45:08 UTC (rev 185)
@@ -0,0 +1,29 @@
+<?xml version="1.0" encoding="utf-8" ?>
+<hibernate-mapping xmlns="urn:nhibernate-mapping-2.2" namespace="NMail.LocalStoreData.NHibernate" assembly="NMail.LocalStoreData.NHibernate" default-lazy="false">
+
+ <class name="NMail.LocalStoreData.NHibernate.InternalStoreFolder" 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: ideally this would be a many-to-one relationship with StoreFolder -->
+ <property name="ParentId" type="System.Int32" />
+
+ <!-- TODO: ideally this would be a many-to-one relationship with LocalStoreUser -->
+ <property name="OwnerUserId" not-null="true" />
+
+ <list name="ChildIds" cascade="all" table="FolderChildren">
+ <key column="FolderId" />
+ <index column="ChildIndex" type="Int32" />
+ <element column="ChildId" type="Int32" />
+ </list>
+
+ <property name="NextMessageId" not-null="true"/>
+ </class>
+
+</hibernate-mapping>
\ No newline at end of file
Added: NMail/trunk/NMail.LocalStoreData.NHibernate/Mappings/NMail.LocalStoreData.NHibernate.InternalStoreFolderAcl.hbm.xml
===================================================================
--- NMail/trunk/NMail.LocalStoreData.NHibernate/Mappings/NMail.LocalStoreData.NHibernate.InternalStoreFolderAcl.hbm.xml (rev 0)
+++ NMail/trunk/NMail.LocalStoreData.NHibernate/Mappings/NMail.LocalStoreData.NHibernate.InternalStoreFolderAcl.hbm.xml 2007-04-24 12:45:08 UTC (rev 185)
@@ -0,0 +1,19 @@
+<?xml version="1.0" encoding="utf-8" ?>
+<hibernate-mapping xmlns="urn:nhibernate-mapping-2.2" namespace="NMail.LocalStoreData.NHibernate" assembly="NMail.LocalStoreData.NHibernate" default-lazy="false">
+
+ <class name="NMail.LocalStoreData.NHibernate.InternalStoreFolderAcl" 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.LocalStoreData.NHibernate.InternalStoreFolder" not-null="true"/>
+
+ <map name="entries" access="field" table="StoreFolderAclEntries">
+ <key column="IdentifierId" />
+ <index column="Identifier" type="String" />
+ <element column="StoreFolderPrivilege" type="Serializable" />
+ </map>
+ </class>
+
+</hibernate-mapping>
\ No newline at end of file
Modified: NMail/trunk/NMail.LocalStoreData.NHibernate/NHibernateLocalStoreData.cs
===================================================================
--- NMail/trunk/NMail.LocalStoreData.NHibernate/NHibernateLocalStoreData.cs 2007-04-19 12:09:29 UTC (rev 184)
+++ NMail/trunk/NMail.LocalStoreData.NHibernate/NHibernateLocalStoreData.cs 2007-04-24 12:45:08 UTC (rev 185)
@@ -55,120 +55,46 @@
#region ILocalStoreData Members
#region Message Delivery
-
- // TODO: update quotas?
+ /// <summary>
+ /// Delivers the message into the given folder.
+ /// </summary>
+ /// <param name="message">The details of the delivery.</param>
public void DeliverMessage(LocalStoreDelivery message) {
- DeliverMessage(message.Message, GetStoreFolder(message.TargetFolder));
+ DeliverMessage(message.Message, GetStoreFolder(message.TargetFolder).FolderId);
foreach (StoreFolder folder in message.AdditionalFolders) {
- DeliverMessage(message.Message, GetStoreFolder(folder));
+ DeliverMessage(message.Message, GetStoreFolder(folder).FolderId);
}
}
- public void DeliverMessage(Message message, StoreFolder folder) {
- //using (MySqlConnection cnn = MySqlHelper.GetConnection()) {
- // MySqlTransaction transaction = null;
+ /// <summary>
+ /// Delivers the message into the given folder.
+ /// </summary>
+ /// <param name="message">The message data.</param>
+ /// <param name="folder">The Id of the folder to deliver into.</param>
+ public void DeliverMessage(Message message, int folderId) {
+ using (ISession session = this.hibernateFactory.OpenSession()) {
+ using (ITransaction tx = session.BeginTransaction()) {
+ // Get the next folder message id
+ InternalStoreFolder folder = session.Load<InternalStoreFolder>(folderId);
+ int nextFolderMessageId = folder.NextMessageId;
- // try {
- // transaction = cnn.BeginTransaction();
+ // Update the next message id
+ folder.NextMessageId++;
+ session.Update(folder);
- // MySqlCommand cmd = cnn.CreateCommand();
- // cmd.Transaction = transaction;
- // cmd.Connection = cnn;
+ // Save the message details and data
+ InternalMessage internalMessage = new InternalMessage(message);
+ internalMessage.FolderId = folderId;
+ internalMessage.FolderMessageId = nextFolderMessageId;
+ internalMessage.InternalDate = DateTime.Now;
+ internalMessage.MessageFlags = StoreMessageFlags.Recent;
+ session.Save(internalMessage);
- // // Get the next folder message id
- // cmd.CommandText = "SELECT NextMessageId FROM Folder WHERE FolderId=?FolderId";
- // cmd.Parameters.Add("?FolderId", folder.FolderId);
- // int folderMessageId = (int)cmd.ExecuteScalar();
-
- // // Update the next message id
- // cmd = cnn.CreateCommand();
- // cmd.Transaction = transaction;
- // cmd.Connection = cnn;
- // cmd.CommandText = "UPDATE Folder SET NextMessageId=?NextMessageId WHERE FolderId=?FolderId";
- // cmd.Parameters.Add("?FolderId", folder.FolderId);
- // cmd.Parameters.Add("?NextMessageId", folderMessageId + 1);
- // int count = cmd.ExecuteNonQuery();
- // if (count == 1) {
- // // Insert the message body
- // cmd = cnn.CreateCommand();
- // cmd.Transaction = transaction;
- // cmd.Connection = cnn;
- // cmd.CommandText = "INSERT INTO Message (FolderId, FolderMessageId, MimeMessage, Headers, Preamble, Postamble, MessageFlags, Size, InternalDate) " +
- // "VALUES (?FolderId, ?FolderMessageId, ?MimeMessage, ?Headers, ?Preamble, ?Postamble, ?MessageFlags, ?Size, ?InternalDate)";
- // cmd.Parameters.Add("?FolderId", folder.FolderId);
- // cmd.Parameters.Add("?FolderMessageId", folderMessageId);
- // cmd.Parameters.Add("?MimeMessage", message.MultipartBody);
- // cmd.Parameters.Add("?Headers", message.Headers.Data.Bytes);
- // cmd.Parameters.Add("?Preamble", (message.Preamble != null) ? message.Preamble.Data.Bytes : null);
- // cmd.Parameters.Add("?Postamble", (message.Postamble != null) ? message.Postamble.Data.Bytes : null);
- // cmd.Parameters.Add("?MessageFlags", StoreMessageFlags.Recent);
- // cmd.Parameters.Add("?Size", message.Size);
- // cmd.Parameters.Add("?InternalDate", DateTime.Now);
- // count = cmd.ExecuteNonQuery();
-
- // if (count == 1) {
- // // Get the message Id
- // cmd = cnn.CreateCommand();
- // cmd.Transaction = transaction;
- // cmd.Connection = cnn;
- // cmd.CommandText = "SELECT LAST_INSERT_ID()";
- // long messageId = (long)cmd.ExecuteScalar(); ;
-
- // if (message.MultipartBody) {
- // // Insert each part of the message
- // for (int i = 0; i < message.MimeParts.Count; i++) {
- // // Insert the current part
- // cmd = cnn.CreateCommand();
- // cmd.Transaction = transaction;
- // cmd.Connection = cnn;
- // cmd.CommandText = "INSERT INTO MessageData (MessageId, Part, Data) " +
- // "VALUES (?MessageId, ?Part, ?Data)";
- // cmd.Parameters.Add("?MessageId", messageId);
- // cmd.Parameters.Add("?Part", i + 1); // Count from 1
- // cmd.Parameters.Add("?Data", message.MimeParts[i].Data.Bytes);
- // count = cmd.ExecuteNonQuery();
-
- // if (count != 1) {
- // // Insert failed, rollback
- // throw new System.Data.DataException("Error inserting message part.");
- // }
- // }
- // } else {
- // // Insert the body data
- // cmd = cnn.CreateCommand();
- // cmd.Transaction = transaction;
- // cmd.Connection = cnn;
-
- // cmd.CommandText = "INSERT INTO MessageData (MessageId, Part, Data) " +
- // "VALUES (?MessageId, 1, ?Data)";
- // cmd.Parameters.Add("?MessageId", messageId);
- // cmd.Parameters.Add("?Data", message.BodyData.Bytes);
- // count = cmd.ExecuteNonQuery();
-
- // if (count != 1) {
- // // Insert failed, rollback
- // throw new System.Data.DataException("Error inserting message body.");
- // }
- // }
- // } else {
- // throw new System.Data.DataException("Error inserting message details.");
- // }
- // } else {
- // throw new System.Data.DataException("Error updating next message id.");
- // }
-
- // transaction.Commit();
-
- // } catch (Exception e) {
- // if (transaction != null) {
- // transaction.Rollback();
- // }
-
- // throw e;
- // }
- //}
- throw new NotImplementedException();
+ tx.Commit();
+ session.Close();
+ }
+ }
}
#endregion
@@ -182,10 +108,10 @@
/// <returns>The store folder or null if the folder name is invalid.</returns>
public StoreFolder GetStoreFolder(Folder folder) {
using (ISession session = this.hibernateFactory.OpenSession()) {
- return session.CreateCriteria(typeof(StoreFolder))
+ return session.CreateCriteria(typeof(InternalStoreFolder))
.Add(Expression.Like("NameSpace", folder.NameSpace))
.Add(Expression.Like("FullFolderName", folder.FullFolderName))
- .UniqueResult<StoreFolder>();
+ .UniqueResult<InternalStoreFolder>();
}
}
@@ -196,7 +122,7 @@
/// <returns>The store folder or null if the folder Id is invalid.</returns>
public StoreFolder GetStoreFolder(int folderId) {
using (ISession session = this.hibernateFactory.OpenSession()) {
- return session.Load<StoreFolder>(folderId);
+ return session.Load<InternalStoreFolder>(folderId);
}
}
#endregion
@@ -241,9 +167,9 @@
// Validate parent details
if (newFolder.Parent != null) {
// Lookup the parent Id
- parentByName = session.CreateCriteria(typeof(StoreFolder))
+ parentByName = session.CreateCriteria(typeof(InternalStoreFolder))
.Add(Expression.Like("FullFolderName", newFolder.Parent.FullFolderName))
- .UniqueResult<StoreFolder>();
+ .UniqueResult<InternalStoreFolder>();
if (parentByName == null) {
throw new InvalidOperationException("Can't find a valid parent folder.");
@@ -268,21 +194,23 @@
}
// Check for any folders with the same name
- ICriteria criteria = session.CreateCriteria(typeof(StoreFolder))
+ ICriteria criteria = session.CreateCriteria(typeof(InternalStoreFolder))
.Add(Expression.Like("FullFolderName", newFolder.FullFolderName));
if (newFolder.ParentId.HasValue) {
criteria = criteria.Add(Expression.Eq("ParentId", newFolder.ParentId));
- }
+ }
- IList<StoreFolder> matching = criteria.List<StoreFolder>();
+ IList<InternalStoreFolder> matching = criteria.List<InternalStoreFolder>();
if (matching.Count > 0) {
throw new DuplicateNameException("Folder with the same name already exists.");
}
// Checks done, save!
- session.Save(newFolder);
+ InternalStoreFolder internalNewFolder = new InternalStoreFolder(newFolder);
+ session.Save(internalNewFolder);
+ newFolder.FolderId = internalNewFolder.FolderId;
// Add an ACL to the folder
GenericAce<StoreFolderPrivilege> ace = new GenericAce<StoreFolderPrivilege>(user.Username, StoreFolderPrivilege.Admin, AcePrivilegeType.Allow);
@@ -309,7 +237,7 @@
public void DeleteFolder(int folderId, bool deleteChildren) {
using (ISession session = this.hibernateFactory.OpenSession()) {
using (ITransaction tx = session.BeginTransaction()) {
- StoreFolder folder = session.Get<StoreFolder>(folderId);
+ InternalStoreFolder folder = session.Get<InternalStoreFolder>(folderId);
if (folder == null) {
throw new ArgumentException("Invalid folder Id.", "folderId");
@@ -321,14 +249,14 @@
DeleteChildrenWithoutUpdate(folder, session);
- DeleteStoreFolderAcl(folderId);
- DeleteSubscriptions(folderId);
+ DeleteStoreFolderAcl(folderId, session);
+ DeleteSubscriptions(folderId, session);
session.Delete(folder);
// Remove the folder from the parent's list of children if present
if (folder.ParentId != null) {
- StoreFolder parent = session.Load<StoreFolder>(folder.ParentId);
+ InternalStoreFolder parent = session.Load<InternalStoreFolder>(folder.ParentId);
parent.ChildIds.Remove(folderId);
session.Update(parent);
}
@@ -345,7 +273,7 @@
/// </summary>
/// <param name="folder">The folder to delete the children from.</param>
/// <param name="session">The session to use.</param>
- protected void DeleteChildrenWithoutUpdate(StoreFolder folder, ISession session) {
+ internal void DeleteChildrenWithoutUpdate(InternalStoreFolder folder, ISession session) {
// Ensure session has started a transaction
if (!session.Transaction.IsActive) {
throw new InvalidOperationException("A transaction is required for this operation.");
@@ -353,14 +281,14 @@
// Delete each child and sub-children
foreach (int childId in folder.ChildIds) {
- StoreFolder child = session.Load<StoreFolder>(childId);
+ InternalStoreFolder child = session.Load<InternalStoreFolder>(childId);
// Recurse down
DeleteChildrenWithoutUpdate(child, session);
// Delete the child at the current level
- DeleteStoreFolderAcl(childId);
- DeleteSubscriptions(childId);
+ DeleteStoreFolderAcl(childId, session);
+ DeleteSubscriptions(childId, session);
session.Delete(child);
}
}
@@ -388,42 +316,42 @@
public void MoveFolder(int folderId, int? parentId, string newFolderName) {
using (ISession session = this.hibernateFactory.OpenSession()) {
using (ITransaction tx = session.BeginTransaction()) {
- StoreFolder currentFolder = session.Load<StoreFolder>(folderId);
- StoreFolder newFolder;
- StoreFolder currentParent;
- StoreFolder newParentFolder = null;
+ InternalStoreFolder currentFolder = session.Load<InternalStoreFolder>(folderId);
+ InternalStoreFolder newFolder;
+ InternalStoreFolder currentParent;
+ InternalStoreFolder newParentFolder = null;
if (parentId.HasValue) {
- newParentFolder = session.Load<StoreFolder>(parentId.Value);
+ newParentFolder = session.Load<InternalStoreFolder>(parentId.Value);
}
if (currentFolder.ParentId.HasValue) {
- currentParent = session.Load<StoreFolder>(currentFolder.ParentId.Value);
+ currentParent = session.Load<InternalStoreFolder>(currentFolder.ParentId.Value);
}
// Setup the new folder
if (newParentFolder != null) {
- newFolder = new StoreFolder(newParentFolder, newFolderName);
+ newFolder = new InternalStoreFolder(newParentFolder, newFolderName);
// Check for any folders with the same name
- IList<StoreFolder> matching = session.CreateCriteria(typeof(StoreFolder))
+ IList<InternalStoreFolder> matching = session.CreateCriteria(typeof(InternalStoreFolder))
.Add(Expression.Like("FullFolderName", newFolder.FullFolderName))
.Add(Expression.Eq("ParentId", parentId))
- .List<StoreFolder>();
+ .List<InternalStoreFolder>();
if (matching.Count > 0) {
throw new DuplicateNameException("Folder with the same name already exists.");
}
} else {
- newFolder = new StoreFolder(currentFolder.NameSpace, newFolderName);
+ newFolder = new InternalStoreFolder(currentFolder.NameSpace, newFolderName);
}
newFolder.ParentId = parentId;
newFolder.OwnerUserId = currentFolder.OwnerUserId;
session.Save(newFolder);
- MoveStoreFolderAcl(folderId, newFolder.FolderId);
- MoveSubscriptions(folderId, newFolder.FolderId);
+ MoveStoreFolderAcl(folderId, newFolder.FolderId, session);
+ MoveSubscriptions(folderId, newFolder.FolderId, session);
// Adjust the details of the child folders and move them across
MoveChildren(newFolder, currentFolder, session);
@@ -440,7 +368,7 @@
/// <param name="newParent">The new parent folder.</param>
/// <param name="oldParent">The old parent folder.</param>
/// <param name="session">The session to use.</param>
- protected void MoveChildren(StoreFolder newParent, StoreFolder oldParent, ISession session) {
+ internal void MoveChildren(InternalStoreFolder newParent, InternalStoreFolder oldParent, ISession session) {
// Ensure session has started a transaction
if (!session.Transaction.IsActive) {
throw new InvalidOperationException("A transaction is required for this operation.");
@@ -448,16 +376,16 @@
// Update each child recursively
foreach (int childId in oldParent.ChildIds) {
- StoreFolder currentChild = session.Load<StoreFolder>(childId);
+ InternalStoreFolder currentChild = session.Load<InternalStoreFolder>(childId);
// Make a new child folder
- StoreFolder newChild = new StoreFolder(newParent, currentChild.FolderName);
+ InternalStoreFolder newChild = new InternalStoreFolder(newParent, currentChild.FolderName);
newChild.ParentId = newParent.FolderId;
newChild.OwnerUserId = currentChild.OwnerUserId;
session.Save(newChild);
- MoveStoreFolderAcl(childId, newChild.FolderId);
- MoveSubscriptions(childId, newChild.FolderId);
+ MoveStoreFolderAcl(childId, newChild.FolderId, session);
+ MoveSubscriptions(childId, newChild.FolderId, session);
// Add the to parent
newParent.ChildIds.Add(newChild.FolderId);
@@ -480,9 +408,9 @@
public IList<StoreFolder> GetChildren(int parentId) {
using (ISession session = this.hibernateFactory.OpenSession()) {
using (ITransaction tx = session.BeginTransaction()) {
- StoreFolder folder = session.Load<StoreFolder>(parentId);
+ InternalStoreFolder folder = session.Load<InternalStoreFolder>(parentId);
- IList<StoreFolder> result = session.CreateCriteria(typeof(StoreFolder))
+ IList<StoreFolder> result = session.CreateCriteria(typeof(InternalStoreFolder))
.Add(Expression.Eq("ParentId", parentId))
.List<StoreFolder>();
@@ -501,7 +429,7 @@
/// <returns>The list of folders.</returns>
public IList<StoreFolder> GetFolders() {
using (ISession session = this.hibernateFactory.OpenSession()) {
- return session.CreateCriteria(typeof(StoreFolder)).List<StoreFolder>();
+ return session.CreateCriteria(typeof(InternalStoreFolder)).List<StoreFolder>();
}
}
#endregion
@@ -513,20 +441,19 @@
/// Deletes all subscriptions from a folder.
/// </summary>
/// <param name="folderId">The Id of the folder to delete the subscriptions from.</param>
- protected void DeleteSubscriptions(int folderId) {
- using (ISession session = this.hibernateFactory.OpenSession()) {
- using (ITransaction tx = session.BeginTransaction()) {
- IList<FolderSubscription> current = session.CreateCriteria(typeof(FolderSubscription))
- .Add(Expression.Eq("FolderId", folderId))
- .List<FolderSubscription>();
+ /// <param name="session">The session to use.</param>
+ protected void DeleteSubscriptions(int folderId, ISession session) {
+ // Ensure session has started a transaction
+ if (!session.Transaction.IsActive) {
+ throw new InvalidOperationException("A transaction is required for this operation.");
+ }
- for (int i = 0; i < current.Count; i++) {
- session.Delete(current[i]);
- }
+ IList<FolderSubscription> current = session.CreateCriteria(typeof(FolderSubscription))
+ .Add(Expression.Eq("FolderId", folderId))
+ .List<FolderSubscription>();
- tx.Commit();
- session.Close();
- }
+ for (int i = 0; i < current.Count; i++) {
+ session.Delete(current[i]);
}
}
#endregion
@@ -537,21 +464,19 @@
/// </summary>
/// <param name="currentFolderId">The current folder Id.</param>
/// <param name="newFolderId">The new folder Id.</param>
- protected void MoveSubscriptions(int currentFolderId, int newFolderId) {
- using (ISession session = this.hibernateFactory.OpenSession()) {
- using (ITransaction tx = session.BeginTransaction()) {
- IList<FolderSubscription> current = session.CreateCriteria(typeof(FolderSubscription))
- .Add(Expression.Eq("FolderId", currentFolderId))
- .List<FolderSubscription>();
+ protected void MoveSubscriptions(int currentFolderId, int newFolderId, ISession session) {
+ // Ensure session has started a transaction
+ if (!session.Transaction.IsActive) {
+ throw new InvalidOperationException("A transaction is required for this operation.");
+ }
+
+ IList<FolderSubscription> current = session.CreateCriteria(typeof(FolderSubscription))
+ .Add(Expression.Eq("FolderId", currentFolderId))
+ .List<FolderSubscription>();
- for (int i = 0; i < current.Count; i++) {
- current[i].FolderId = newFolderId;
- session.Update(current[i]);
- }
-
- tx.Commit();
- session.Close();
- }
+ for (int i = 0; i < current.Count; i++) {
+ current[i].FolderId = newFolderId;
+ session.Update(current[i]);
}
}
#endregion
@@ -574,7 +499,7 @@
folderIds[i] = subscriptionList[i].FolderId;
}
- IList<StoreFolder> subscribed = session.CreateCriteria(typeof(StoreFolder))
+ IList<StoreFolder> subscribed = session.CreateCriteria(typeof(InternalStoreFolder))
.Add(Expression.In("FolderId", folderIds))
.List<StoreFolder>();
@@ -1110,8 +1035,6 @@
inboxFolder.OwnerUserId = user.UserId;
CreateFolder(inboxFolder, session);
- // TODO: ACLs
-
// Set the user's folder Id
user.UserFolderId = userFolder.FolderId;
session.Update(user);
@@ -1191,7 +1114,7 @@
/// <param name="session">The session to use.</param>
/// <returns>The list of folders or null if the user Id is invalid.</returns>
protected IList<StoreFolder> GetUserFolders(int userId, ISession session) {
- return session.CreateCriteria(typeof(StoreFolder))
+ return session.CreateCriteria(typeof(InternalStoreFolder))
.Add(Expression.Eq("OwnerUserId", userId))
.List<StoreFolder>();
}
@@ -1255,9 +1178,9 @@
}
// Check if any other user with the same name exists in the system
- IList<LocalStoreUser> existing = session.CreateCriteria(typeof(LocalStoreGroup))
+ IList<LocalStoreGroup> existing = session.CreateCriteria(typeof(LocalStoreGroup))
.Add(Expression.Like("Name", group.Name))
- .List<LocalStoreUser>();
+ .List<LocalStoreGroup>();
if (existing.Count > 0) {
throw new DuplicateNameException("Group with the same name already exists in the system.");
@@ -1327,27 +1250,26 @@
/// Completely deletes a store folder's ACL.
/// </summary>
/// <param name="folderId">The Id of the folder to delete the ACL for.</param>
- protected void DeleteStoreFolderAcl(int folderId) {
- using (ISession session = this.hibernateFactory.OpenSession()) {
- using (ITransaction tx = session.BeginTransaction()) {
- IList<StoreFolderAcl> current = session.CreateCriteria(typeof(StoreFolderAcl))
- .CreateCriteria("Folder")
- .Add(Expression.Eq("FolderId", folderId))
- .List<StoreFolderAcl>();
+ /// <param name="session">The session to use.</param>
+ protected void DeleteStoreFolderAcl(int folderId, ISession session) {
+ // Ensure session has started a transaction
+ if (!session.Transaction.IsActive) {
+ throw new InvalidOperationException("A transaction is required for this operation.");
+ }
- if (current.Count == 0) {
- // No such ACL
- throw new ArgumentException("Invalid folder Id.");
+ IList<InternalStoreFolderAcl> current = session.CreateCriteria(typeof(InternalStoreFolderAcl))
+ .CreateCriteria("Folder")
+ .Add(Expression.Eq("FolderId", folderId))
+ .List<InternalStoreFolderAcl>();
- } else {
- // Update the current ACL
- StoreFolderAcl acl = current[0];
- session.Delete(acl);
- }
+ if (current.Count == 0) {
+ // No such ACL
+ throw new ArgumentException("Invalid folder Id.");
- tx.Commit();
- session.Close();
- }
+ } else {
+ // Update the current ACL
+ InternalStoreFolderAcl acl = current[0];
+ session.Delete(acl);
}
}
#endregion
@@ -1358,28 +1280,26 @@
/// </summary>
/// <param name="currentFolderId">The Id of the current folder.</param>
/// <param name="newFolderId">The Id of the new folder.</param>
- protected void MoveStoreFolderAcl(int currentFolderId, int newFolderId) {
- using (ISession session = this.hibernateFactory.OpenSession()) {
- using (ITransaction tx = session.BeginTransaction()) {
- IList<StoreFolderAcl> current = session.CreateCriteria(typeof(StoreFolderAcl))
- .CreateCriteria("Folder")
- .Add(Expression.Eq("FolderId", currentFolderId))
- .List<StoreFolderAcl>();
+ protected void MoveStoreFolderAcl(int currentFolderId, int newFolderId, ISession session) {
+ // Ensure session has started a transaction
+ if (!session.Transaction.IsActive) {
+ throw new InvalidOperationException("A transaction is required for this operation.");
+ }
- if (current.Count == 0) {
- // No such ACL
- throw new ArgumentException("Invalid folder Id.");
+ IList<InternalStoreFolderAcl> current = session.CreateCriteria(typeof(InternalStoreFolderAcl))
+ .CreateCriteria("Folder")
+ .Add(Expression.Eq("FolderId", currentFolderId))
+ .List<InternalStoreFolderAcl>();
- } else {
- // Update the current ACL
- StoreFolderAcl acl = current[0];
- acl.Folder = session.Load<StoreFolder>(newFolderId);
- session.Update(acl);
- }
+ if (current.Count == 0) {
+ // No such ACL
+ throw new ArgumentException("Invalid folder Id.");
- tx.Commit();
- session.Close();
- }
+ } else {
+ // Update the current ACL
+ InternalStoreFolderAcl acl = current[0];
+ acl.Folder = session.Load<InternalStoreFolder>(newFolderId);
+ session.Update(acl);
}
}
#endregion
@@ -1408,22 +1328,22 @@
throw new InvalidOperationException("A transaction is required for this operation.");
}
- IList<StoreFolderAcl> current = session.CreateCriteria(typeof(StoreFolderAcl))
+ IList<InternalStoreFolderAcl> current = session.CreateCriteria(typeof(InternalStoreFolderAcl))
.CreateCriteria("Folder")
.Add(Expression.Eq("FolderId", folderId))
- .List<StoreFolderAcl>();
+ .List<InternalStoreFolderAcl>();
if (current.Count == 0) {
// Create a new ACL
- StoreFolder folder = session.Load<StoreFolder>(folderId);
- StoreFolderAcl acl = new StoreFolderAcl(folder);
+ InternalStoreFolder folder = session.Load<InternalStoreFolder>(folderId);
+ InternalStoreFolderAcl acl = new InternalStoreFolderAcl(folder);
acl[ace.Identifier] = ace;
- session.Save(acl);
+ session.SaveOrUpdateCopy(acl);
} else {
// Update the current ACL
- StoreFolderAcl acl = current[0];
+ InternalStoreFolderAcl acl = current[0];
acl[ace.Identifier] = ace;
session.Update(acl);
@@ -1440,10 +1360,10 @@
public void RemoveStoreFolderAce(int folderId, string identifier) {
using (ISession session = this.hibernateFactory.OpenSession()) {
using (ITransaction tx = session.BeginTransaction()) {
- IList<StoreFolderAcl> current = session.CreateCriteria(typeof(StoreFolderAcl))
+ IList<InternalStoreFolderAcl> current = session.CreateCriteria(typeof(InternalStoreFolderAcl))
.CreateCriteria("Folder")
.Add(Expression.Eq("FolderId", folderId))
- .List<StoreFolderAcl>();
+ .List<InternalStoreFolderAcl>();
if (current.Count == 0) {
// No such ACL
@@ -1451,7 +1371,7 @@
} else {
// Update the current ACL
- StoreFolderAcl acl = current[0];
+ InternalStoreFolderAcl acl = current[0];
acl.RemoveAce(identifier);
session.Update(acl);
@@ -1472,10 +1392,10 @@
/// <returns>The folder ACL.</returns>
public StoreFolderAcl GetStoreFolderAcl(int folderId) {
using (ISession session = this.hibernateFactory.OpenSession()) {
- IList<StoreFolderAcl> current = session.CreateCriteria(typeof(StoreFolderAcl))
+ IList<InternalStoreFolderAcl> current = session.CreateCriteria(typeof(InternalStoreFolderAcl))
.CreateCriteria("Folder")
.Add(Expression.Eq("FolderId", folderId))
- .List<StoreFolderAcl>();
+ .List<InternalStoreFolderAcl>();
if (current.Count == 0) {
// No such ACL
@@ -1483,7 +1403,7 @@
}
- return current[0];
+ return current[0].CreateStoreFolderAcl();
}
}
#endregion
Modified: NMail/trunk/NMail.LocalStoreData.NHibernate/NMail.LocalStoreData.NHibernate.csproj
===================================================================
--- NMail/trunk/NMail.LocalStoreData.NHibernate/NMail.LocalStoreData.NHibernate.csproj 2007-04-19 12:09:29 UTC (rev 184)
+++ NMail/trunk/NMail.LocalStoreData.NHibernate/NMail.LocalStoreData.NHibernate.csproj 2007-04-24 12:45:08 UTC (rev 185)
@@ -48,6 +48,8 @@
<ItemGroup>
<Compile Include="FolderSubscription.cs" />
<Compile Include="InternalMessage.cs" />
+ <Compile Include="InternalStoreFolder.cs" />
+ <Compile Include="InternalStoreFolderAcl.cs" />
<Compile Include="NHibernateAuthProvider.cs" />
<Compile Include="NHibernateLocalStoreData.cs" />
<Compile Include="NHibernateUserMap.cs" />
@@ -64,7 +66,7 @@
</ItemGroup>
<ItemGroup>
<EmbeddedResource Include="Mappings\NMail.DataTypes.LocalStore.LocalStoreUser.hbm.xml" />
- <EmbeddedResource Include="Mappings\NMail.DataTypes.LocalStore.StoreFolder.hbm.xml" />
+ <EmbeddedResource Include="Mappings\NMail.LocalStoreData.NHibernate.InternalStoreFolder.hbm.xml" />
</ItemGroup>
<ItemGroup>
<EmbeddedResource Include="Mappings\NMail.DataTypes.LocalStore.LocalStoreGroup.hbm.xml" />
@@ -82,11 +84,14 @@
<EmbeddedResource Include="Mappings\NMail.DataTypes.LocalStore.MailDomain.hbm.xml" />
</ItemGroup>
<ItemGroup>
- <EmbeddedResource Include="Mappings\NMail.DataTypes.ACLs.StoreFolderAcl.hbm.xml" />
+ <EmbeddedResource Include="Mappings\NMail.LocalStoreData.NHibernate.InternalStoreFolderAcl.hbm.xml" />
</ItemGroup>
<ItemGroup>
<EmbeddedResource Include="Mappings\NMail.LocalStoreData.NHibernate.FolderSubsciption.hbm.xml" />
</ItemGroup>
+ <ItemGroup>
+ <EmbeddedResource Include="Mappings\NMail.LocalStoreData.NHibernate.InternalMessage.hbm.xml" />
+ </ItemGroup>
<Import Project="$(MSBuildBinPath)\Microsoft.CSharp.targets" />
<!-- To modify your build process, add your task inside one of the targets below and uncomment it.
Other similar extension points exist, see Microsoft.Common.targets.
Added: NMail/trunk/NMail.UnitTests/LocalStoreData/CreateGroupTest1.cs
===================================================================
--- NMail/trunk/NMail.UnitTests/LocalStoreData/CreateGroupTest1.cs (rev 0)
+++ NMail/trunk/NMail.UnitTests/LocalStoreData/CreateGroupTest1.cs 2007-04-24 12:45:08 UTC (rev 185)
@@ -0,0 +1,27 @@
+using System;
+using System.Collections.Generic;
+using System.Text;
+
+using NUnit.Framework;
+
+using NMail.Configuration;
+using NMail.DataTypes.Calendar;
+using NMail.DataTypes.LocalStore;
+
+namespace NMail.UnitTests.LocalStoreData {
+ /// <summary>
+ /// Tests creating a group.
+ /// </summary>
+ [TestFixture]
+ public class CreateGroupTest1 : BaseLocalStoreDataTest {
+
+ [Test]
+ public void TestCreateGroup() {
+ LocalStoreGroup group = new LocalStoreGroup();
+ group.Name = "Test";
+ this.localStoreData.CreateGroup(group);
+
+ Assert.IsTrue(group.GroupId > 0, "Valid group Id.");
+ }
+ }
+}
Added: NMail/trunk/NMail.UnitTests/LocalStoreData/CreateGroupTest2.cs
===================================================================
--- NMail/trunk/NMail.UnitTests/LocalStoreData/CreateGroupTest2.cs (rev 0)
+++ NMail/trunk/NMail.UnitTests/LocalStoreData/CreateGroupTest2.cs 2007-04-24 12:45:08 UTC (rev 185)
@@ -0,0 +1,35 @@
+using System;
+using System.Collections.Generic;
+using System.Data;
+using System.Text;
+
+using NUnit.Framework;
+
+using NMail.Configuration;
+using NMail.DataTypes.Calendar;
+using NMail.DataTypes.LocalStore;
+
+namespace NMail.UnitTests.LocalStoreData {
+ /// <summary>
+ /// Tests creating a group.
+ /// </summary>
+ [TestFixture]
+ public class CreateGroupTest2 : BaseLocalStoreDataTest {
+
+ [ExpectedException(typeof(DuplicateNameException))]
+ [Test]
+ public void TestCreateGroup() {
+ LocalStoreGroup group1 = new LocalStoreGroup();
+ group1.Name = "Test";
+ this.localStoreData.CreateGroup(group1);
+
+ Assert.IsTrue(group1.GroupId > 0, "Valid group Id.");
+
+ LocalStoreGroup group2 = new LocalStoreGroup();
+ group2.Name = "Test";
+ this.localStoreData.CreateGroup(group2);
+
+ Assert.Fail("Allowed duplicate user names.");
+ }
+ }
+}
Added: NMail/trunk/NMail.UnitTests/LocalStoreData/DeleteGroupTest1.cs
===================================================================
--- NMail/trunk/NMail.UnitTests/LocalStoreData/DeleteGroupTest1.cs (rev 0)
+++ NMail/trunk/NMail.UnitTests/LocalStoreData/DeleteGroupTest1.cs 2007-04-24 12:45:08 UTC (rev 185)
@@ -0,0 +1,31 @@
+using System;
+using System.Collections.Generic;
+using System.Text;
+
+using NUnit.Framework;
+
+using NMail.Configuration;
+using NMail.DataTypes.Calendar;
+using NMail.DataTypes.LocalStore;
+
+namespace NMail.UnitTests.LocalStoreData {
+ /// <summary>
+ /// Tests deleting a group.
+ /// </summary>
+ [TestFixture]
+ public class DeleteGroupTest1 : BaseLocalStoreDataTest {
+
+ [Test]
+ public void TestDeleteGroup() {
+ LocalStoreGroup group = new LocalStoreGroup();
+ group.Name = "Test";
+ this.localStoreData.CreateGroup(group);
+
+ Assert.IsTrue(group.GroupId > 0, "Valid group Id.");
+
+ this.localStoreData.DeleteGroup(group.GroupId);
+
+ Assert.IsNull(this.localStoreData.GetGroup("Test"), "No group.");
+ }
+ }
+}
Added: NMail/trunk/NMail.UnitTests/LocalStoreData/GetStoreFolderChildrenTest1.cs
===================================================================
--- NMail/trunk/NMail.UnitTests/LocalStoreData/GetStoreFolderChildrenTest1.cs (rev 0)
+++ NMail/trunk/NMail.UnitTests/LocalStoreData/GetStoreFolderChildrenTest1.cs 2007-04-24 12:45:08 UTC (rev 185)
@@ -0,0 +1,32 @@
+using System;
+using System.Collections.Generic;
+using System.Text;
+
+using NUnit.Framework;
+
+using NMail.Configuration;
+using NMail.DataTypes.Calendar;
+using NMail.DataTypes.LocalStore;
+
+namespace NMail.UnitTests.LocalStoreData {
+ /// <summary>
+ /// Tests getting a store folder's children.
+ /// </summary>
+ [TestFixture]
+ public class GetStoreFolderChildrenTest1 : BaseLocalStoreDataTest {
+
+ [Test]
+ public void TestGetStoreFolderChildren() {
+ LocalStoreUser user1 = new LocalStoreUser();
+ user1.Username = "Test";
+ this.localStoreData.CreateUser(user1);
+
+ Assert.IsTrue(user1.UserId > 0, "Valid user Id.");
+ Assert.IsTrue(user1.UserFolderId > 0, "Valid user folder Id.");
+
+ IList<StoreFolder> children = this.localStoreData.GetChildren(user1.UserFolderId);
+
+ Assert.IsTrue(children.Count > 0, "Children exist.");
+ }
+ }
+}
Added: NMail/trunk/NMail.UnitTests/LocalStoreData/GetStoreFolderTest1.cs
===================================================================
--- NMail/trunk/NMail.UnitTests/LocalStoreData/GetStoreFolderTest1.cs (rev 0)
+++ NMail/trunk/NMail.UnitTests/LocalStoreData/GetStoreFolderTest1.cs 2007-04-24 12:45:08 UTC (rev 185)
@@ -0,0 +1,33 @@
+using System;
+using System.Collections.Generic;
+using System.Text;
+
+using NUnit.Framework;
+
+using NMail.Configuration;
+using NMail.DataTypes.Calendar;
+using NMail.DataTypes.LocalStore;
+
+namespace NMail.UnitTests.LocalStoreData {
+ /// <summary>
+ /// Tests getting a store folder.
+ /// </summary>
+ [TestFixture]
+ public class GetStoreFolderTest1 : BaseLocalStoreDataTest {
+
+ [Test]
+ public void TestGetStoreFolder() {
+ LocalStoreUser user1 = new LocalStoreUser();
+ user1.Username = "Test";
+ this.localStoreData.CreateUser(user1);
+
+ Assert.IsTrue(user1.UserId > 0, "Valid user Id.");
+ Assert.IsTrue(user1.UserFolderId > 0, "Valid user folder Id.");
+
+ StoreFolder f = this.localStoreData.GetStoreFolder(user1.UserFolderId);
+
+ Assert.IsTrue(f.FolderId > 0, "Valid folder Id.");
+ Assert.AreEqual(user1.UserId, f.OwnerUserId, "Valid owner user Id.");
+ }
+ }
+}
Added: NMail/trunk/NMail.UnitTests/LocalStoreData/GetStoreFolderTest2.cs
===================================================================
--- NMail/trunk/NMail.UnitTests/LocalStoreData/GetStoreFolderTest2.cs (rev 0)
+++ NMail/trunk/NMail.UnitTests/LocalStoreData/GetStoreFolderTest2.cs 2007-04-24 12:45:08 UTC (rev 185)
@@ -0,0 +1,39 @@
+using System;
+using System.Collections.Generic;
+using System.Text;
+
+using NUnit.Framework;
+
+using NMail.Configuration;
+using NMail.DataTypes;
+using NMail.DataTypes.Calendar;
+using NMail.DataTypes.LocalStore;
+
+namespace NMail.UnitTests.LocalStoreData {
+ /// <summary>
+ /// Tests getting a store folder.
+ /// </summary>
+ [TestFixture]
+ public class GetStoreFolderTest2 : BaseLocalStoreDataTest {
+
+ [Test]
+ public void TestGetStoreFolder() {
+ LocalStoreUser user1 = new LocalStoreUser();
+ user1.Username = "Test";
+ this.localStoreData.CreateUser(user1);
+
+ Assert.IsTrue(user1.UserId > 0, "Valid user Id.");
+ Assert.IsTrue(user1.UserFolderId > 0, "Valid user folder Id.");
+
+ StoreFolder f1 = this.localStoreData.GetStoreFolder(user1.UserFolderId);
+
+ Assert.IsTrue(f1.FolderId > 0, "Valid folder Id.");
+ Assert.AreEqual(user1.UserId, f1.OwnerUserId, "Valid owner user Id.");
+
+ StoreFolder f2 = this.localStoreData.GetStoreFolder(new Folder(f1.NameSpace, f1.FullFolderName));
+
+ Assert.IsTrue(f2.FolderId > 0, "Valid folder Id.");
+ Assert.AreEqual(user1.UserId, f2.OwnerUserId, "Valid owner user Id.");
+ }
+ }
+}
Added: NMail/trunk/NMail.UnitTests/LocalStoreData/RemoveStoreFolderAceTest1.cs
===================================================================
--- NMail/trunk/NMail.UnitTests/LocalStoreData/RemoveStoreFolderAceTest1.cs (rev 0)
+++ NMail/trunk/NMail.UnitTests/LocalStoreData/RemoveStoreFolderAceTest1.cs 2007-04-24 12:45:08 UTC (rev 185)
@@ -0,0 +1,55 @@
+using System;
+using System.Collections.Generic;
+using System.Text;
+
+using NUnit.Framework;
+
+using NMail.Configuration;
+using NMail.DataTypes.ACLs;
+using NMail.DataTypes.LocalStore;
+
+namespace NMail.UnitTests.LocalStoreData {
+ /// <summary>
+ /// Tests for removing a store folder ACE
+ /// </summary>
+ [TestFixture]
+ public class RemoveStoreFolderAceTest1 : BaseLocalStoreDataTest {
+
+ [Test]
+ public void TestSetAce() {
+ // Create a user
+ LocalStoreUser u1 = new LocalStoreUser();
+ u1.Username = "Test1";
+ this.localStoreData.CreateUser(u1);
+ Assert.IsTrue(u1.UserFolderId > 0, "Valid user folder Id.");
+ Assert.IsTrue(u1.UserId > 0, "Valid user Id.");
+
+ // Create a user
+ LocalStoreUser u2 = new LocalStoreUser();
+ u2.Username = "Test2";
+ this.localStoreData.CreateUser(u2);
+ Assert.IsTrue(u2.UserId > 0, "Valid user Id.");
+
+ // Check ACL
+ StoreFolderAcl acl1 = this.localStoreData.GetStoreFolderAcl(u1.UserFolderId);
+ Assert.IsNull(acl1[u2.Username], "No ACE for user 2.");
+
+ // Add ACE
+ GenericAce<StoreFolderPrivilege> ace1 = new GenericAce<StoreFolderPrivilege>(u2.Username, StoreFolderPrivilege.Admin, AcePrivilegeType.Allow);
+ this.localStoreData.SetStoreFolderAce(u1.UserFolderId, ace1);
+
+ // Check ACL
+ StoreFolderAcl acl2 = this.localStoreData.GetStoreFolderAcl(u1.UserFolderId);
+ Assert.IsNotNull(acl2[u2.Username], "Valid ACE for user 2.");
+ Assert.AreEqual(StoreFolderPrivilege.Admin, acl2[u2.Username].Privilege, "Correct ACE privilege.");
+ Assert.AreEqual(AcePrivilegeType.Allow, acl2[u2.Username].AceType, "Correct ACE type.");
+
+ // Remove ACE
+ this.localStoreData.RemoveStoreFolderAce(u1.UserFolderId, u2.Username);
+
+ // Check ACL
+ StoreFolderAcl acl3 = this.localStoreData.GetStoreFolderAcl(u1.UserFolderId);
+ Assert.IsNull(acl3[u2.Username], "No ACE for user 2.");
+ }
+ }
+}
Modified: NMail/trunk/NMail.UnitTests/NMail.UnitTests.csproj
===================================================================
--- NMail/trunk/NMail.UnitTests/NMail.UnitTests.csproj 2007-04-19 12:09:29 UTC (rev 184)
+++ NMail/trunk/NMail.UnitTests/NMail.UnitTests.csproj 2007-04-24 12:45:08 UTC (rev 185)
@@ -52,6 +52,13 @@
<Compile Include="DataTypes\Helper\MimeHelperTests.cs" />
<Compile Include="DataTypes\Helper\StringTokenizerTests.cs" />
<Compile Include="LocalStoreData\BaseLocalStoreDataTest.cs" />
+ <Compile Include="LocalStoreData\GetStoreFolderChildrenTest1.cs" />
+ <Compile Include="LocalStoreData\GetStoreFolderTest2.cs" />
+ <Compile Include="LocalStoreData\GetStoreFolderTest1.cs" />
+ <Compile Include="LocalStoreData\DeleteGroupTest1.cs" />
+ <Compile Include="LocalStoreData\CreateGroupTest2.cs" />
+ <Compile Include="LocalStoreData\CreateGroupTest1.cs" />
+ <Compile Include="LocalStoreData\RemoveStoreFolderAceTest1.cs" />
<Compile Include="LocalStoreData\SetStoreFolderAceTest1.cs" />
<Compile Include="LocalStoreData\DeleteMailDomainTest1.cs" />
<Compile Include="LocalStoreData\CreateMailDomainTest2.cs" />
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <tmy...@us...> - 2007-04-19 12:09:29
|
Revision: 184
http://svn.sourceforge.net/nmailserver/?rev=184&view=rev
Author: tmyroadctfig
Date: 2007-04-19 05:09:29 -0700 (Thu, 19 Apr 2007)
Log Message:
-----------
More work on unit tests and NHibernate local store data.
Modified Paths:
--------------
NMail/trunk/NMail/DataTypes/LocalStore/ILocalStoreData.cs
NMail/trunk/NMail.LocalStore/LocalStore.cs
NMail/trunk/NMail.LocalStoreData.MySql/MySqlLocalStoreData.cs
NMail/trunk/NMail.LocalStoreData.NHibernate/Mappings/NMail.DataTypes.ACLs.StoreFolderAcl.hbm.xml
NMail/trunk/NMail.LocalStoreData.NHibernate/NHibernateLocalStoreData.cs
NMail/trunk/NMail.UnitTests/NMail.UnitTests.csproj
Added Paths:
-----------
NMail/trunk/NMail.UnitTests/LocalStoreData/SetStoreFolderAceTest1.cs
Modified: NMail/trunk/NMail/DataTypes/LocalStore/ILocalStoreData.cs
===================================================================
--- NMail/trunk/NMail/DataTypes/LocalStore/ILocalStoreData.cs 2007-04-18 13:02:58 UTC (rev 183)
+++ NMail/trunk/NMail/DataTypes/LocalStore/ILocalStoreData.cs 2007-04-19 12:09:29 UTC (rev 184)
@@ -134,15 +134,15 @@
/// Subscribes to a folder.
/// </summary>
/// <param name="userId">The Id of the user to subscribe for.</param>
- /// <param name="folder">The folder to subscribe to.</param>
- void Subscribe(int userId, StoreFolder folder);
+ /// <param name="folder">The Id of the folder to subscribe to.</param>
+ void Subscribe(int userId, int folderId);
/// <summary>
/// Un-subscribes from a folder.
/// </summary>
/// <param name="userId">The Id of the user to unsubscribe for.</param>
- /// <param name="folder">The folder to unsubscribe from.</param>
- void UnSubscribe(int userId, StoreFolder folder);
+ /// <param name="folder">The Id of the folder to unsubscribe from.</param>
+ void UnSubscribe(int userId, int folderId);
#endregion
#region Message Id and Offset
Modified: NMail/trunk/NMail.LocalStore/LocalStore.cs
===================================================================
--- NMail/trunk/NMail.LocalStore/LocalStore.cs 2007-04-18 13:02:58 UTC (rev 183)
+++ NMail/trunk/NMail.LocalStore/LocalStore.cs 2007-04-19 12:09:29 UTC (rev 184)
@@ -592,7 +592,7 @@
// Subscribe to the folder
LocalStoreUser user = LocalStoreData.GetUser(authToken.Username);
- LocalStoreData.Subscribe(user.UserId, folder);
+ LocalStoreData.Subscribe(user.UserId, folder.FolderId);
return LocalStoreFolderResult.OkSuccessful;
} else {
@@ -610,7 +610,7 @@
public void UnSubscribe(IAuthenticationToken authToken, StoreFolder folder) {
// Un-subscribe from the folder
LocalStoreUser user = LocalStoreData.GetUser(authToken.Username);
- LocalStoreData.UnSubscribe(user.UserId, folder);
+ LocalStoreData.UnSubscribe(user.UserId, folder.FolderId);
}
#endregion
#endregion
Modified: NMail/trunk/NMail.LocalStoreData.MySql/MySqlLocalStoreData.cs
===================================================================
--- NMail/trunk/NMail.LocalStoreData.MySql/MySqlLocalStoreData.cs 2007-04-18 13:02:58 UTC (rev 183)
+++ NMail/trunk/NMail.LocalStoreData.MySql/MySqlLocalStoreData.cs 2007-04-19 12:09:29 UTC (rev 184)
@@ -453,12 +453,12 @@
}
}
- public void Subscribe(int userId, StoreFolder folder) {
+ public void Subscribe(int userId, int folderId) {
using (MySqlConnection cnn = MySqlHelper.GetConnection()) {
using (MySqlCommand cmd = cnn.CreateCommand()) {
- if (!folderSubscribed(userId, folder.FolderId)) {
+ if (!folderSubscribed(userId, folderId)) {
cmd.CommandText = "INSERT INTO Subscription (UserId, FolderId) VALUES(?UserId, ?FolderId)";
- cmd.Parameters.Add("?FolderId", folder.FolderId);
+ cmd.Parameters.Add("?FolderId", folderId);
cmd.Parameters.Add("?UserId", userId);
if (cmd.ExecuteNonQuery() != 1) {
@@ -471,12 +471,12 @@
#endregion
#region UnSubscribe
- public void UnSubscribe(int userId, StoreFolder folder) {
+ public void UnSubscribe(int userId, int folderId) {
using (MySqlConnection cnn = MySqlHelper.GetConnection()) {
using (MySqlCommand cmd = cnn.CreateCommand()) {
cmd.CommandText = "DELETE FROM Subscription WHERE UserId = ?UserId AND FolderId = ?FolderId";
cmd.Parameters.Add("?UserId", userId);
- cmd.Parameters.Add("?FolderId", folder.FolderId);
+ cmd.Parameters.Add("?FolderId", folderId);
if (cmd.ExecuteNonQuery() != 1) {
throw new System.Data.DataException("Error updating subscription.");
Modified: NMail/trunk/NMail.LocalStoreData.NHibernate/Mappings/NMail.DataTypes.ACLs.StoreFolderAcl.hbm.xml
===================================================================
--- NMail/trunk/NMail.LocalStoreData.NHibernate/Mappings/NMail.DataTypes.ACLs.StoreFolderAcl.hbm.xml 2007-04-18 13:02:58 UTC (rev 183)
+++ NMail/trunk/NMail.LocalStoreData.NHibernate/Mappings/NMail.DataTypes.ACLs.StoreFolderAcl.hbm.xml 2007-04-19 12:09:29 UTC (rev 184)
@@ -12,7 +12,7 @@
<map name="entries" access="field" table="StoreFolderAclEntries">
<key column="IdentifierId" />
<index column="Identifier" type="String" />
- <element column="StoreFolderPrivilege" type="Int32" />
+ <element column="StoreFolderPrivilege" type="Serializable" />
</map>
</class>
Modified: NMail/trunk/NMail.LocalStoreData.NHibernate/NHibernateLocalStoreData.cs
===================================================================
--- NMail/trunk/NMail.LocalStoreData.NHibernate/NHibernateLocalStoreData.cs 2007-04-18 13:02:58 UTC (rev 183)
+++ NMail/trunk/NMail.LocalStoreData.NHibernate/NHibernateLocalStoreData.cs 2007-04-19 12:09:29 UTC (rev 184)
@@ -284,6 +284,10 @@
// Checks done, save!
session.Save(newFolder);
+ // Add an ACL to the folder
+ GenericAce<StoreFolderPrivilege> ace = new GenericAce<StoreFolderPrivilege>(user.Username, StoreFolderPrivilege.Admin, AcePrivilegeType.Allow);
+ SetStoreFolderAce(newFolder.FolderId, ace, session);
+
// Add the new folder to the parent's children
if (parentByName != null) {
parentByName.ChildIds.Add(newFolder.FolderId);
@@ -317,8 +321,9 @@
DeleteChildrenWithoutUpdate(folder, session);
- // TODO: delete ACLs
- // TODO: delete folder subscriptions
+ DeleteStoreFolderAcl(folderId);
+ DeleteSubscriptions(folderId);
+
session.Delete(folder);
// Remove the folder from the parent's list of children if present
@@ -354,8 +359,8 @@
DeleteChildrenWithoutUpdate(child, session);
// Delete the child at the current level
- // TODO: remove child ACLs
- // TODO: delete folder subscriptions
+ DeleteStoreFolderAcl(childId);
+ DeleteSubscriptions(childId);
session.Delete(child);
}
}
@@ -415,9 +420,10 @@
}
newFolder.ParentId = parentId;
newFolder.OwnerUserId = currentFolder.OwnerUserId;
- // TODO: ACLs
session.Save(newFolder);
+ MoveStoreFolderAcl(folderId, newFolder.FolderId);
+ MoveSubscriptions(folderId, newFolder.FolderId);
// Adjust the details of the child folders and move them across
MoveChildren(newFolder, currentFolder, session);
@@ -448,9 +454,11 @@
StoreFolder newChild = new StoreFolder(newParent, currentChild.FolderName);
newChild.ParentId = newParent.FolderId;
newChild.OwnerUserId = currentChild.OwnerUserId;
- // TODO: child ACLs
session.Save(newChild);
+ MoveStoreFolderAcl(childId, newChild.FolderId);
+ MoveSubscriptions(childId, newChild.FolderId);
+
// Add the to parent
newParent.ChildIds.Add(newChild.FolderId);
@@ -500,6 +508,54 @@
#region Folder Subscription
+ #region Delete Subscriptions
+ /// <summary>
+ /// Deletes all subscriptions from a folder.
+ /// </summary>
+ /// <param name="folderId">The Id of the folder to delete the subscriptions from.</param>
+ protected void DeleteSubscriptions(int folderId) {
+ using (ISession session = this.hibernateFactory.OpenSession()) {
+ using (ITransaction tx = session.BeginTransaction()) {
+ IList<FolderSubscription> current = session.CreateCriteria(typeof(FolderSubscription))
+ .Add(Expression.Eq("FolderId", folderId))
+ .List<FolderSubscription>();
+
+ for (int i = 0; i < current.Count; i++) {
+ session.Delete(current[i]);
+ }
+
+ tx.Commit();
+ session.Close();
+ }
+ }
+ }
+ #endregion
+
+ #region Move Subscriptions
+ /// <summary>
+ /// Moves all subscriptions to a new folder.
+ /// </summary>
+ /// <param name="currentFolderId">The current folder Id.</param>
+ /// <param name="newFolderId">The new folder Id.</param>
+ protected void MoveSubscriptions(int currentFolderId, int newFolderId) {
+ using (ISession session = this.hibernateFactory.OpenSession()) {
+ using (ITransaction tx = session.BeginTransaction()) {
+ IList<FolderSubscription> current = session.CreateCriteria(typeof(FolderSubscription))
+ .Add(Expression.Eq("FolderId", currentFolderId))
+ .List<FolderSubscription>();
+
+ for (int i = 0; i < current.Count; i++) {
+ current[i].FolderId = newFolderId;
+ session.Update(current[i]);
+ }
+
+ tx.Commit();
+ session.Close();
+ }
+ }
+ }
+ #endregion
+
#region GetSubscribedFolders
/// <summary>
/// Gets a list of subscribed folders that match the query folder.
@@ -536,18 +592,18 @@
/// Subscribes to a folder.
/// </summary>
/// <param name="userId">The Id of the user to subscribe for.</param>
- /// <param name="folder">The folder to subscribe to.</param>
- public void Subscribe(int userId, StoreFolder folder) {
+ /// <param name="folder">The Id of the folder to subscribe to.</param>
+ public void Subscribe(int userId, int folderId) {
using (ISession session = this.hibernateFactory.OpenSession()) {
using (ITransaction tx = session.BeginTransaction()) {
IList<FolderSubscription> current = session.CreateCriteria(typeof(FolderSubscription))
.Add(Expression.Eq("UserId", userId))
- .Add(Expression.Eq("FolderId", folder.FolderId))
+ .Add(Expression.Eq("FolderId", folderId))
.List<FolderSubscription>();
if (current.Count == 0) {
FolderSubscription subscription = new FolderSubscription();
- subscription.FolderId = folder.FolderId;
+ subscription.FolderId = folderId;
subscription.UserId = userId;
session.Save(subscription);
@@ -565,13 +621,13 @@
/// Un-subscribes from a folder.
/// </summary>
/// <param name="userId">The Id of the user to unsubscribe for.</param>
- /// <param name="folder">The folder to unsubscribe from.</param>
- public void UnSubscribe(int userId, StoreFolder folder) {
+ /// <param name="folder">The Id of the folder to unsubscribe from.</param>
+ public void UnSubscribe(int userId, int folderId) {
using (ISession session = this.hibernateFactory.OpenSession()) {
using (ITransaction tx = session.BeginTransaction()) {
IList<FolderSubscription> current = session.CreateCriteria(typeof(FolderSubscription))
.Add(Expression.Eq("UserId", userId))
- .Add(Expression.Eq("FolderId", folder.FolderId))
+ .Add(Expression.Eq("FolderId", folderId))
.List<FolderSubscription>();
if (current.Count != 0) {
@@ -1266,14 +1322,12 @@
#region Folder ACLs
- #region Set StoreFolder ACE
+ #region Delete StoreFolder ACL
/// <summary>
- /// Sets the privileges on the folder. If no ACE exists for the associated
- /// identifier one is added.
+ /// Completely deletes a store folder's ACL.
/// </summary>
- /// <param name="folder">The Id of the folder to set the ACE on.</param>
- /// <param name="ace">The privileges and the identifier to put.</param>
- public void SetStoreFolderAce(int folderId, GenericAce<StoreFolderPrivilege> ace) {
+ /// <param name="folderId">The Id of the folder to delete the ACL for.</param>
+ protected void DeleteStoreFolderAcl(int folderId) {
using (ISession session = this.hibernateFactory.OpenSession()) {
using (ITransaction tx = session.BeginTransaction()) {
IList<StoreFolderAcl> current = session.CreateCriteria(typeof(StoreFolderAcl))
@@ -1282,18 +1336,44 @@
.List<StoreFolderAcl>();
if (current.Count == 0) {
- // Create a new ACL
- StoreFolder folder = session.Load<StoreFolder>(folderId);
- StoreFolderAcl acl = new StoreFolderAcl(folder);
- acl[ace.Identifier] = ace;
+ // No such ACL
+ throw new ArgumentException("Invalid folder Id.");
- session.Save(acl);
+ } else {
+ // Update the current ACL
+ StoreFolderAcl acl = current[0];
+ session.Delete(acl);
+ }
+ tx.Commit();
+ session.Close();
+ }
+ }
+ }
+ #endregion
+
+ #region Move StoreFolder ACL
+ /// <summary>
+ /// Moves an ACL to a new folder Id.
+ /// </summary>
+ /// <param name="currentFolderId">The Id of the current folder.</param>
+ /// <param name="newFolderId">The Id of the new folder.</param>
+ protected void MoveStoreFolderAcl(int currentFolderId, int newFolderId) {
+ using (ISession session = this.hibernateFactory.OpenSession()) {
+ using (ITransaction tx = session.BeginTransaction()) {
+ IList<StoreFolderAcl> current = session.CreateCriteria(typeof(StoreFolderAcl))
+ .CreateCriteria("Folder")
+ .Add(Expression.Eq("FolderId", currentFolderId))
+ .List<StoreFolderAcl>();
+
+ if (current.Count == 0) {
+ // No such ACL
+ throw new ArgumentException("Invalid folder Id.");
+
} else {
// Update the current ACL
StoreFolderAcl acl = current[0];
- acl[ace.Identifier] = ace;
-
+ acl.Folder = session.Load<StoreFolder>(newFolderId);
session.Update(acl);
}
@@ -1304,6 +1384,53 @@
}
#endregion
+ #region Set StoreFolder ACE
+ /// <summary>
+ /// Sets the privileges on the folder. If no ACE exists for the associated
+ /// identifier one is added.
+ /// </summary>
+ /// <param name="folder">The Id of the folder to set the ACE on.</param>
+ /// <param name="ace">The privileges and the identifier to put.</param>
+ public void SetStoreFolderAce(int folderId, GenericAce<StoreFolderPrivilege> ace) {
+ using (ISession session = this.hibernateFactory.OpenSession()) {
+ using (ITransaction tx = session.BeginTransaction()) {
+ SetStoreFolderAce(folderId, ace, session);
+
+ tx.Commit();
+ session.Close();
+ }
+ }
+ }
+
+ protected void SetStoreFolderAce(int folderId, GenericAce<StoreFolderPrivilege> ace, ISession session) {
+ // Ensure session has started a transaction
+ if (!session.Transaction.IsActive) {
+ throw new InvalidOperationException("A transaction is required for this operation.");
+ }
+
+ IList<StoreFolderAcl> current = session.CreateCriteria(typeof(StoreFolderAcl))
+ .CreateCriteria("Folder")
+ .Add(Expression.Eq("FolderId", folderId))
+ .List<StoreFolderAcl>();
+
+ if (current.Count == 0) {
+ // Create a new ACL
+ StoreFolder folder = session.Load<StoreFolder>(folderId);
+ StoreFolderAcl acl = new StoreFolderAcl(folder);
+ acl[ace.Identifier] = ace;
+
+ session.Save(acl);
+
+ } else {
+ // Update the current ACL
+ StoreFolderAcl acl = current[0];
+ acl[ace.Identifier] = ace;
+
+ session.Update(acl);
+ }
+ }
+ #endregion
+
#region Remove StoreFolder ACE
/// <summary>
/// Removes any ACE associated with the given user.
Added: NMail/trunk/NMail.UnitTests/LocalStoreData/SetStoreFolderAceTest1.cs
===================================================================
--- NMail/trunk/NMail.UnitTests/LocalStoreData/SetStoreFolderAceTest1.cs (rev 0)
+++ NMail/trunk/NMail.UnitTests/LocalStoreData/SetStoreFolderAceTest1.cs 2007-04-19 12:09:29 UTC (rev 184)
@@ -0,0 +1,48 @@
+using System;
+using System.Collections.Generic;
+using System.Text;
+
+using NUnit.Framework;
+
+using NMail.Configuration;
+using NMail.DataTypes.ACLs;
+using NMail.DataTypes.LocalStore;
+
+namespace NMail.UnitTests.LocalStoreData {
+ /// <summary>
+ /// Tests for setting a store folder ACE
+ /// </summary>
+ [TestFixture]
+ public class SetStoreFolderAceTest1 : BaseLocalStoreDataTest {
+
+ [Test]
+ public void TestSetAce() {
+ // Create a user
+ LocalStoreUser u1 = new LocalStoreUser();
+ u1.Username = "Test1";
+ this.localStoreData.CreateUser(u1);
+ Assert.IsTrue(u1.UserFolderId > 0, "Valid user folder Id.");
+ Assert.IsTrue(u1.UserId > 0, "Valid user Id.");
+
+ // Create a user
+ LocalStoreUser u2 = new LocalStoreUser();
+ u2.Username = "Test2";
+ this.localStoreData.CreateUser(u2);
+ Assert.IsTrue(u2.UserId > 0, "Valid user Id.");
+
+ // Check ACL
+ StoreFolderAcl acl1 = this.localStoreData.GetStoreFolderAcl(u1.UserFolderId);
+ Assert.IsNull(acl1[u2.Username], "No ACE for user 2.");
+
+ // Add ACE
+ GenericAce<StoreFolderPrivilege> ace1 = new GenericAce<StoreFolderPrivilege>(u2.Username, StoreFolderPrivilege.Admin, AcePrivilegeType.Allow);
+ this.localStoreData.SetStoreFolderAce(u1.UserFolderId, ace1);
+
+ // Check ACL
+ StoreFolderAcl acl2 = this.localStoreData.GetStoreFolderAcl(u1.UserFolderId);
+ Assert.IsNotNull(acl2[u2.Username], "Valid ACE for user 2.");
+ Assert.AreEqual(StoreFolderPrivilege.Admin, acl2[u2.Username].Privilege, "Correct ACE privilege.");
+ Assert.AreEqual(AcePrivilegeType.Allow, acl2[u2.Username].AceType, "Correct ACE type.");
+ }
+ }
+}
Modified: NMail/trunk/NMail.UnitTests/NMail.UnitTests.csproj
===================================================================
--- NMail/trunk/NMail.UnitTests/NMail.UnitTests.csproj 2007-04-18 13:02:58 UTC (rev 183)
+++ NMail/trunk/NMail.UnitTests/NMail.UnitTests.csproj 2007-04-19 12:09:29 UTC (rev 184)
@@ -52,6 +52,7 @@
<Compile Include="DataTypes\Helper\MimeHelperTests.cs" />
<Compile Include="DataTypes\Helper\StringTokenizerTests.cs" />
<Compile Include="LocalStoreData\BaseLocalStoreDataTest.cs" />
+ <Compile Include="LocalStoreData\SetStoreFolderAceTest1.cs" />
<Compile Include="LocalStoreData\DeleteMailDomainTest1.cs" />
<Compile Include="LocalStoreData\CreateMailDomainTest2.cs" />
<Compile Include="LocalStoreData\CreateMailDomainTest1.cs" />
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <tmy...@us...> - 2007-04-18 13:02:58
|
Revision: 183
http://svn.sourceforge.net/nmailserver/?rev=183&view=rev
Author: tmyroadctfig
Date: 2007-04-18 06:02:58 -0700 (Wed, 18 Apr 2007)
Log Message:
-----------
More work on NHibernate local store and unit tests.
Modified Paths:
--------------
NMail/trunk/NMail/DataTypes/Calendar/Calendar.cs
NMail/trunk/NMail/DataTypes/Calendar/EventEntry.cs
NMail/trunk/NMail/DataTypes/LocalStore/ILocalStore.cs
NMail/trunk/NMail/DataTypes/LocalStore/ILocalStoreData.cs
NMail/trunk/NMail.Administration.Console/Command/AddMailDomainCommand.cs
NMail/trunk/NMail.Administration.Console/Command/ListMailDomainsCommand.cs
NMail/trunk/NMail.LocalStore/LocalStore.cs
NMail/trunk/NMail.LocalStoreData.MySql/MySqlLocalStoreData.cs
NMail/trunk/NMail.LocalStoreData.NHibernate/NHibernateLocalStoreData.cs
NMail/trunk/NMail.LocalStoreData.NHibernate/NMail.LocalStoreData.NHibernate.csproj
NMail/trunk/NMail.Server.Console/NMail.config
NMail/trunk/NMail.UnitTests/LocalStoreData/CreateEventEntryTest1.cs
NMail/trunk/NMail.UnitTests/NMail.UnitTests.csproj
Added Paths:
-----------
NMail/trunk/NMail.LocalStoreData.NHibernate/FolderSubscription.cs
NMail/trunk/NMail.LocalStoreData.NHibernate/Mappings/NMail.LocalStoreData.NHibernate.FolderSubsciption.hbm.xml
NMail/trunk/NMail.UnitTests/LocalStoreData/CreateMailDomainTest1.cs
NMail/trunk/NMail.UnitTests/LocalStoreData/CreateMailDomainTest2.cs
NMail/trunk/NMail.UnitTests/LocalStoreData/DeleteMailDomainTest1.cs
NMail/trunk/NMail.UnitTests/LocalStoreData/MoveStoreFolderTest1.cs
NMail/trunk/NMail.UnitTests/LocalStoreData/MoveStoreFolderTest2.cs
NMail/trunk/NMail.UnitTests/LocalStoreData/MySqlLocalStoreTests.cs
Modified: NMail/trunk/NMail/DataTypes/Calendar/Calendar.cs
===================================================================
--- NMail/trunk/NMail/DataTypes/Calendar/Calendar.cs 2007-04-11 04:58:48 UTC (rev 182)
+++ NMail/trunk/NMail/DataTypes/Calendar/Calendar.cs 2007-04-18 13:02:58 UTC (rev 183)
@@ -1,11 +1,14 @@
using System;
using System.Collections.Generic;
+using System.Diagnostics;
using System.Text;
namespace NMail.DataTypes.Calendar {
/// <summary>
/// Represents a calendar in the system.
/// </summary>
+ [Serializable]
+ [DebuggerDisplay("Calendar: {Name} Id:{CalendarId}")]
public class Calendar {
private string name;
Modified: NMail/trunk/NMail/DataTypes/Calendar/EventEntry.cs
===================================================================
--- NMail/trunk/NMail/DataTypes/Calendar/EventEntry.cs 2007-04-11 04:58:48 UTC (rev 182)
+++ NMail/trunk/NMail/DataTypes/Calendar/EventEntry.cs 2007-04-18 13:02:58 UTC (rev 183)
@@ -17,9 +17,12 @@
using System;
using System.Collections.Generic;
+using System.Diagnostics;
using System.Text;
namespace NMail.DataTypes.Calendar {
+ [Serializable]
+ [DebuggerDisplay("EventEntry: {Summary} Id:{EntryId}")]
public class EventEntry : CalendarEntry {
// TODO: alarm list
// TODO: GeographicPosition
Modified: NMail/trunk/NMail/DataTypes/LocalStore/ILocalStore.cs
===================================================================
--- NMail/trunk/NMail/DataTypes/LocalStore/ILocalStore.cs 2007-04-11 04:58:48 UTC (rev 182)
+++ NMail/trunk/NMail/DataTypes/LocalStore/ILocalStore.cs 2007-04-18 13:02:58 UTC (rev 183)
@@ -463,31 +463,36 @@
/// </summary>
/// <param name="authToken">The authentication credentials.</param>
/// <returns>The list of groups.</returns>
- LocalStoreGroup[] GetGroups(IAuthenticationToken authToken);
+ IList<LocalStoreGroup> GetGroups(IAuthenticationToken authToken);
/// <summary>
/// Creates a new group in the local store.
/// </summary>
/// <param name="authToken">The authentication credentials.</param>
- /// <param name="name">The name of the new group.</param>
- /// <returns>The result of the attemp to create a new group.</returns>
- LocalStoreGroupResult CreateGroup(IAuthenticationToken authToken, string name);
+ /// <param name="group">The new group.</param>
+ /// <exception cref="System.Data.DuplicateNameException">If a group with the same name already exists.</exception>
+ /// <exception cref="System.InvalidOperationException">Changes to the group are not permitted.</exception>
+ /// <exception cref="System.ArgumentException">The group is invalid.</exception>
+ void CreateGroup(IAuthenticationToken authToken, LocalStoreGroup group);
/// <summary>
/// Removes a group from the local store.
/// </summary>
/// <param name="authToken">The authentication credentials.</param>
/// <param name="groupId">The Id of the group to delete.</param>
- /// <returns>The result of the attempt to delete a group.</returns>
- LocalStoreGroupResult DeleteGroup(IAuthenticationToken authToken, int groupId);
+ /// <exception cref="System.InvalidOperationException">Changes to the group are not permitted.</exception>
+ /// <exception cref="System.ArgumentException">The user is invalid.</exception>
+ void DeleteGroup(IAuthenticationToken authToken, int groupId);
/// <summary>
/// Updates the group.
/// </summary>
/// <param name="authToken">The authentication credentials.</param>
- /// <param name="group">The group to update.</param>
- /// <returns>The result of the attempt to update the group.</returns>
- LocalStoreGroupResult UpdateGroup(IAuthenticationToken authToken, LocalStoreGroup group);
+ /// <param name="group">The group to update.</param>
+ /// <exception cref="System.Data.DuplicateNameException">If a group with the same name already exists.</exception>
+ /// <exception cref="System.InvalidOperationException">Changes to the group are not permitted.</exception>
+ /// <exception cref="System.ArgumentException">The group is invalid.</exception>
+ void UpdateGroup(IAuthenticationToken authToken, LocalStoreGroup group);
#endregion
#region Mail Domain Management
@@ -496,31 +501,28 @@
/// </summary>
/// <param name="authToken">The authentication credentials.</param>
/// <returns>The mail domains.</returns>
- MailDomain[] GetMailDomains(IAuthenticationToken authToken);
+ IList<MailDomain> GetMailDomains(IAuthenticationToken authToken);
/// <summary>
/// Creates a new mail domain for the given host.
/// </summary>
/// <param name="authToken">The authentication credentials.</param>
- /// <param name="host">The primary host for the mail domain.</param>
- /// <returns>The result of the attempt to add the mail domain.</returns>
- LocalStoreMailDomainResult CreateMailDomain(IAuthenticationToken authToken, Host host);
+ /// <param name="mailDomain">The mail domain.</param>
+ void CreateMailDomain(IAuthenticationToken authToken, MailDomain mailDomain);
/// <summary>
/// Deletes a mail domain from the local store.
/// </summary>
/// <param name="authToken">The authentication credentials.</param>
/// <param name="mailDomainId">The Id of the mail domain to delete.</param>
- /// <returns>The result of the attempt to delete the domain.</returns>
- LocalStoreMailDomainResult DeleteMailDomain(IAuthenticationToken authToken, int mailDomainId);
+ void DeleteMailDomain(IAuthenticationToken authToken, int mailDomainId);
/// <summary>
/// Updates a mail domain.
/// </summary>
/// <param name="authToken">The authentication credentials.</param>
/// <param name="mailDomain">The mail domain to update.</param>
- /// <returns>The result of the attempt to update the mail domain.</returns>
- LocalStoreMailDomainResult UpdateMailDomain(IAuthenticationToken authToken, MailDomain mailDomain);
+ void UpdateMailDomain(IAuthenticationToken authToken, MailDomain mailDomain);
#endregion
#region System ACL
Modified: NMail/trunk/NMail/DataTypes/LocalStore/ILocalStoreData.cs
===================================================================
--- NMail/trunk/NMail/DataTypes/LocalStore/ILocalStoreData.cs 2007-04-11 04:58:48 UTC (rev 182)
+++ NMail/trunk/NMail/DataTypes/LocalStore/ILocalStoreData.cs 2007-04-18 13:02:58 UTC (rev 183)
@@ -126,23 +126,23 @@
/// <summary>
/// Gets a list of subscribed folders that match the query folder.
/// </summary>
- /// <param name="userName">The username to get the list of subscribed folders for.</param>
+ /// <param name="userId">The Id of the user to get the list of subscribed folders for.</param>
/// <returns>The list of folders.</returns>
- IList<StoreFolder> GetSubscribedFolders(string userName);
+ IList<StoreFolder> GetSubscribedFolders(int userId);
/// <summary>
/// Subscribes to a folder.
/// </summary>
- /// <param name="userName">The username to subscribe for.</param>
+ /// <param name="userId">The Id of the user to subscribe for.</param>
/// <param name="folder">The folder to subscribe to.</param>
- void Subscribe(string userName, StoreFolder folder);
+ void Subscribe(int userId, StoreFolder folder);
/// <summary>
/// Un-subscribes from a folder.
/// </summary>
- /// <param name="userName">The username to unsubscribe for.</param>
+ /// <param name="userId">The Id of the user to unsubscribe for.</param>
/// <param name="folder">The folder to unsubscribe from.</param>
- void UnSubscribe(string userName, StoreFolder folder);
+ void UnSubscribe(int userId, StoreFolder folder);
#endregion
#region Message Id and Offset
@@ -291,16 +291,16 @@
/// Sets the privileges on the folder. If no ACE exists for the associated
/// identifier one is added.
/// </summary>
- /// <param name="folder">The folder to set the ACE on.</param>
+ /// <param name="folder">The Id of the folder to set the ACE on.</param>
/// <param name="ace">The privileges and the identifier to put.</param>
- void SetStoreFolderAce(StoreFolder folder, GenericAce<StoreFolderPrivilege> ace);
+ void SetStoreFolderAce(int folderId, GenericAce<StoreFolderPrivilege> ace);
/// <summary>
/// Removes any ACE associated with the given user.
/// </summary>
- /// <param name="folder">The folder to remove the ACE from.</param>
+ /// <param name="folderId">The Id of the folder to remove the ACE from.</param>
/// <param name="identifier">The identifier to remove from the ACL.</param>
- void RemoveStoreFolderAce(StoreFolder folder, string identifier);
+ void RemoveStoreFolderAce(int folderId, string identifier);
/// <summary>
/// Gets the ACL for the given folder.
@@ -344,7 +344,6 @@
/// Removes a user from the local store.
/// </summary>
/// <param name="userId">The Id of the user to delete.</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>
/// <exception cref="System.Data.ConstraintException">User still has folders.</exception>
@@ -386,28 +385,33 @@
/// Gets the list of groups that currently exist in the local store.
/// </summary>
/// <returns>The list of groups.</returns>
- LocalStoreGroup[] GetGroups();
+ IList<LocalStoreGroup> GetGroups();
/// <summary>
- /// Creates a new group in the local store.
- /// </summary>
- /// <param name="name">The name of the new group.</param>
- /// <returns>The result of the attemp to create a new group.</returns>
- LocalStoreGroupResult CreateGroup(string name);
-
+ /// Creates a new group in the local store.
+ /// </summary>
+ /// <param name="group">The group to create.</param>
+ /// <exception cref="System.Data.DuplicateNameException">If a group with the same name already exists.</exception>
+ /// <exception cref="System.InvalidOperationException">Changes to the group are not permitted.</exception>
+ /// <exception cref="System.ArgumentException">The group is invalid.</exception>
+ void CreateGroup(LocalStoreGroup group);
+
/// <summary>
/// Removes a group from the local store.
/// </summary>
/// <param name="groupId">The Id of the group to delete.</param>
- /// <returns>The result of the attempt to delete a group.</returns>
- LocalStoreGroupResult DeleteGroup(int groupId);
+ /// <exception cref="System.InvalidOperationException">Changes to the group are not permitted.</exception>
+ /// <exception cref="System.ArgumentException">The user is invalid.</exception>
+ void DeleteGroup(int groupId);
/// <summary>
/// Updates the group.
- /// </summary>
- /// <param name="group">The updated group.</param>
- /// <returns>The result of the attempt to update the group.</returns>
- LocalStoreGroupResult UpdateGroup(LocalStoreGroup group);
+ /// </summary>
+ /// <param name="user">The group details to update.</param>
+ /// <exception cref="System.Data.DuplicateNameException">If a group with the same name already exists.</exception>
+ /// <exception cref="System.InvalidOperationException">Changes to the group are not permitted.</exception>
+ /// <exception cref="System.ArgumentException">The group is invalid.</exception>
+ void UpdateGroup(LocalStoreGroup group);
#endregion
#region Mail Domain Management
@@ -415,28 +419,25 @@
/// Gets all mail domains associated with this local store.
/// </summary>
/// <returns>The mail domains.</returns>
- MailDomain[] GetMailDomains();
+ IList<MailDomain> GetMailDomains();
/// <summary>
/// Creates a new mail domain for the given host.
- /// </summary>
- /// <param name="host">The primary host for the mail domain.</param>
- /// <returns>The result of the attempt to add the mail domain.</returns>
- LocalStoreMailDomainResult CreateMailDomain(Host host);
+ /// </summary>
+ /// <param name="mailDomain">The mail domain to create.</param>
+ void CreateMailDomain(MailDomain mailDomain);
/// <summary>
/// Deletes a mail domain from the local store.
/// </summary>
/// <param name="mailDomainId">The Id of the mail domain to delete.</param>
- /// <returns>The result of the attempt to delete the domain.</returns>
- LocalStoreMailDomainResult DeleteMailDomain(int mailDomainId);
+ void DeleteMailDomain(int mailDomainId);
/// <summary>
/// Updates a mail domain.
/// </summary>
/// <param name="mailDomain">The updated mail domain.</param>
- /// <returns>The result of the attempt to update the mail domain.</returns>
- LocalStoreMailDomainResult UpdateMailDomain(MailDomain mailDomain);
+ void UpdateMailDomain(MailDomain mailDomain);
#endregion
#region System ACL
Modified: NMail/trunk/NMail.Administration.Console/Command/AddMailDomainCommand.cs
===================================================================
--- NMail/trunk/NMail.Administration.Console/Command/AddMailDomainCommand.cs 2007-04-11 04:58:48 UTC (rev 182)
+++ NMail/trunk/NMail.Administration.Console/Command/AddMailDomainCommand.cs 2007-04-18 13:02:58 UTC (rev 183)
@@ -81,12 +81,16 @@
return;
}
- LocalStoreMailDomainResult result = this.localStore.CreateMailDomain(this.authToken, host);
+ try {
+ MailDomain md = new MailDomain();
+ md.PrimaryHost = host;
- if (result == LocalStoreMailDomainResult.OkSuccessful) {
+ this.localStore.CreateMailDomain(this.authToken, md);
+
System.Console.WriteLine("Added new mail domain.");
- } else {
- System.Console.WriteLine("Error adding mail domain.");
+
+ } catch (Exception ex) {
+ System.Console.WriteLine("Error adding mail domain: {0}.", ex.Message);
}
System.Console.WriteLine();
}
Modified: NMail/trunk/NMail.Administration.Console/Command/ListMailDomainsCommand.cs
===================================================================
--- NMail/trunk/NMail.Administration.Console/Command/ListMailDomainsCommand.cs 2007-04-11 04:58:48 UTC (rev 182)
+++ NMail/trunk/NMail.Administration.Console/Command/ListMailDomainsCommand.cs 2007-04-18 13:02:58 UTC (rev 183)
@@ -55,7 +55,7 @@
}
public void Process(string[] commandTokens) {
- MailDomain[] domains = this.localStore.GetMailDomains(this.authToken);
+ IList<MailDomain> domains = this.localStore.GetMailDomains(this.authToken);
System.Console.WriteLine();
Modified: NMail/trunk/NMail.LocalStore/LocalStore.cs
===================================================================
--- NMail/trunk/NMail.LocalStore/LocalStore.cs 2007-04-11 04:58:48 UTC (rev 182)
+++ NMail/trunk/NMail.LocalStore/LocalStore.cs 2007-04-18 13:02:58 UTC (rev 183)
@@ -231,7 +231,7 @@
#endregion
private MailDomain ResolveMailDomain(Host host) {
- MailDomain[] mailDomains = this.LocalStoreData.GetMailDomains();
+ IList<MailDomain> mailDomains = this.LocalStoreData.GetMailDomains();
// First check primary hosts
foreach (MailDomain mailDomain in mailDomains) {
@@ -373,7 +373,7 @@
// Create an ACL for the folder
GenericAce<StoreFolderPrivilege> ace = new GenericAce<StoreFolderPrivilege>(authToken.Username, StoreFolderPrivilegeHelper.AllPrivileges, AcePrivilegeType.Allow);
- LocalStoreData.SetStoreFolderAce(createdFolder, ace);
+ LocalStoreData.SetStoreFolderAce(createdFolder.FolderId, ace);
return LocalStoreFolderResult.OkSuccessful;
@@ -552,7 +552,8 @@
// Filter out unsubscribed folders from the list
IList<StoreFolder> result = new List<StoreFolder>();
- IList<StoreFolder> subscribedFolders = LocalStoreData.GetSubscribedFolders(authToken.Username);
+ LocalStoreUser user = LocalStoreData.GetUser(authToken.Username);
+ IList<StoreFolder> subscribedFolders = LocalStoreData.GetSubscribedFolders(user.UserId);
foreach (StoreFolder currentFolder in subscribedFolders) {
if (matchMode == MatchMode.Single) {
if (currentFolder == folder) {
@@ -590,7 +591,8 @@
if (hasFolderPrivilege(authToken.Username, folder.FolderId, StoreFolderPrivilege.Lookup)) {
// Subscribe to the folder
- LocalStoreData.Subscribe(authToken.Username, folder);
+ LocalStoreUser user = LocalStoreData.GetUser(authToken.Username);
+ LocalStoreData.Subscribe(user.UserId, folder);
return LocalStoreFolderResult.OkSuccessful;
} else {
@@ -607,7 +609,8 @@
/// <param name="folder">The folder to unsubscribe from.</param>
public void UnSubscribe(IAuthenticationToken authToken, StoreFolder folder) {
// Un-subscribe from the folder
- LocalStoreData.UnSubscribe(authToken.Username, folder);
+ LocalStoreUser user = LocalStoreData.GetUser(authToken.Username);
+ LocalStoreData.UnSubscribe(user.UserId, folder);
}
#endregion
#endregion
@@ -1034,7 +1037,7 @@
public IList<EmailAddress> GetUserAddresses(IAuthenticationToken authToken, int userId) {
List<EmailAddress> result = new List<EmailAddress>();
- MailDomain[] mailDomains = LocalStoreData.GetMailDomains();
+ IList<MailDomain> mailDomains = LocalStoreData.GetMailDomains();
LocalStoreUser user = LocalStoreData.GetUser(userId);
if (user != null) {
@@ -1091,7 +1094,7 @@
/// </summary>
/// <param name="authToken">The authentication credentials.</param>
/// <returns>The list of groups.</returns>
- public LocalStoreGroup[] GetGroups(IAuthenticationToken authToken) {
+ public IList<LocalStoreGroup> GetGroups(IAuthenticationToken authToken) {
return LocalStoreData.GetGroups();
}
@@ -1099,10 +1102,12 @@
/// Creates a new group in the local store.
/// </summary>
/// <param name="authToken">The authentication credentials.</param>
- /// <param name="name">The name of the new group.</param>
- /// <returns>The result of the attemp to create a new group.</returns>
- public LocalStoreGroupResult CreateGroup(IAuthenticationToken authToken, string name) {
- return LocalStoreData.CreateGroup(name);
+ /// <param name="group">The new group.</param>
+ /// <exception cref="System.Data.DuplicateNameException">If a group with the same name already exists.</exception>
+ /// <exception cref="System.InvalidOperationException">Changes to the group are not permitted.</exception>
+ /// <exception cref="System.ArgumentException">The group is invalid.</exception>
+ public void CreateGroup(IAuthenticationToken authToken, LocalStoreGroup group) {
+ LocalStoreData.CreateGroup(group);
}
/// <summary>
@@ -1110,9 +1115,10 @@
/// </summary>
/// <param name="authToken">The authentication credentials.</param>
/// <param name="groupId">The Id of the group to delete.</param>
- /// <returns>The result of the attempt to delete a group.</returns>
- public LocalStoreGroupResult DeleteGroup(IAuthenticationToken authToken, int groupId) {
- return LocalStoreData.DeleteGroup(groupId);
+ /// <exception cref="System.InvalidOperationException">Changes to the group are not permitted.</exception>
+ /// <exception cref="System.ArgumentException">The user is invalid.</exception>
+ public void DeleteGroup(IAuthenticationToken authToken, int groupId) {
+ LocalStoreData.DeleteGroup(groupId);
}
/// <summary>
@@ -1120,9 +1126,11 @@
/// </summary>
/// <param name="authToken">The authentication credentials.</param>
/// <param name="group">The group to update.</param>
- /// <returns>The result of the attempt to update the group.</returns>
- public LocalStoreGroupResult UpdateGroup(IAuthenticationToken authToken, LocalStoreGroup group) {
- return LocalStoreData.UpdateGroup(group);
+ /// <exception cref="System.Data.DuplicateNameException">If a group with the same name already exists.</exception>
+ /// <exception cref="System.InvalidOperationException">Changes to the group are not permitted.</exception>
+ /// <exception cref="System.ArgumentException">The group is invalid.</exception>
+ public void UpdateGroup(IAuthenticationToken authToken, LocalStoreGroup group) {
+ LocalStoreData.UpdateGroup(group);
}
#endregion
@@ -1133,7 +1141,7 @@
if (hasFolderPrivilege(authToken.Username, folder.FolderId, StoreFolderPrivilege.Admin)
|| hasSystemPrivilege(authToken.Username, SystemPrivilege.EditAllAcls)) {
// Set the ACE
- LocalStoreData.SetStoreFolderAce(folder, ace);
+ LocalStoreData.SetStoreFolderAce(folder.FolderId, ace);
}
}
@@ -1143,7 +1151,7 @@
if (hasFolderPrivilege(authToken.Username, folder.FolderId, StoreFolderPrivilege.Admin)
|| hasSystemPrivilege(authToken.Username, SystemPrivilege.EditAllAcls)) {
// Remove the ACE
- LocalStoreData.RemoveStoreFolderAce(folder, identifier);
+ LocalStoreData.RemoveStoreFolderAce(folder.FolderId, identifier);
}
}
@@ -1168,7 +1176,7 @@
/// </summary>
/// <param name="authToken">The authentication credentials.</param>
/// <returns>The mail domains.</returns>
- public MailDomain[] GetMailDomains(IAuthenticationToken authToken) {
+ public IList<MailDomain> GetMailDomains(IAuthenticationToken authToken) {
// TODO: check acls
return this.LocalStoreData.GetMailDomains();
@@ -1177,12 +1185,11 @@
/// Creates a new mail domain for the given host.
/// </summary>
/// <param name="authToken">The authentication credentials.</param>
- /// <param name="host">The primary host for the mail domain.</param>
- /// <returns>The result of the attempt to add the mail domain.</returns>
- public LocalStoreMailDomainResult CreateMailDomain(IAuthenticationToken authToken, Host host) {
+ /// <param name="mailDomain">The mail domain to create.</param>
+ public void CreateMailDomain(IAuthenticationToken authToken, MailDomain mailDomain) {
// TODO: check ACLs
- return this.LocalStoreData.CreateMailDomain(host);
+ this.LocalStoreData.CreateMailDomain(mailDomain);
}
/// <summary>
@@ -1190,11 +1197,10 @@
/// </summary>
/// <param name="authToken">The authentication credentials.</param>
/// <param name="mailDomainId">The Id of the mail domain to delete.</param>
- /// <returns>The result of the attempt to delete the domain.</returns>
- public LocalStoreMailDomainResult DeleteMailDomain(IAuthenticationToken authToken, int mailDomainId) {
+ public void DeleteMailDomain(IAuthenticationToken authToken, int mailDomainId) {
// TODO: check acls
- return this.LocalStoreData.DeleteMailDomain(mailDomainId);
+ this.LocalStoreData.DeleteMailDomain(mailDomainId);
}
/// <summary>
@@ -1202,11 +1208,10 @@
/// </summary>
/// <param name="authToken">The authentication credentials.</param>
/// <param name="mailDomain">The mail domain to update.</param>
- /// <returns>The result of the attempt to update the mail domain.</returns>
- public LocalStoreMailDomainResult UpdateMailDomain(IAuthenticationToken authToken, MailDomain mailDomain) {
+ public void UpdateMailDomain(IAuthenticationToken authToken, MailDomain mailDomain) {
// TODO: check acls
- return this.LocalStoreData.UpdateMailDomain(mailDomain);
+ this.LocalStoreData.UpdateMailDomain(mailDomain);
}
#endregion
Modified: NMail/trunk/NMail.LocalStoreData.MySql/MySqlLocalStoreData.cs
===================================================================
--- NMail/trunk/NMail.LocalStoreData.MySql/MySqlLocalStoreData.cs 2007-04-11 04:58:48 UTC (rev 182)
+++ NMail/trunk/NMail.LocalStoreData.MySql/MySqlLocalStoreData.cs 2007-04-18 13:02:58 UTC (rev 183)
@@ -412,11 +412,11 @@
#region Folder Subscription
#region GetSubscribedFolders
- public IList<StoreFolder> GetSubscribedFolders(string userName) {
+ public IList<StoreFolder> GetSubscribedFolders(int userId) {
using (MySqlConnection cnn = MySqlHelper.GetConnection()) {
using (MySqlCommand cmd = cnn.CreateCommand()) {
- cmd.CommandText = "SELECT s.FolderId AS FolderId FROM User u, Subscription s WHERE s.UserId = u.UserId AND u.UserName = ?UserName";
- cmd.Parameters.Add("?UserName", userName);
+ cmd.CommandText = "SELECT s.FolderId AS FolderId FROM User u, Subscription s WHERE s.UserId = ?UserId";
+ cmd.Parameters.Add("?UserId", userId);
using (MySqlDataReader reader = cmd.ExecuteReader()) {
List<int> subscribedIds = new List<int>();
@@ -453,13 +453,9 @@
}
}
- public void Subscribe(string userName, StoreFolder folder) {
+ public void Subscribe(int userId, StoreFolder folder) {
using (MySqlConnection cnn = MySqlHelper.GetConnection()) {
using (MySqlCommand cmd = cnn.CreateCommand()) {
- cmd.CommandText = "SELECT UserId FROM User WHERE UserName = ?UserName";
- cmd.Parameters.Add("?UserName", userName);
- int userId = (int) cmd.ExecuteScalar();
-
if (!folderSubscribed(userId, folder.FolderId)) {
cmd.CommandText = "INSERT INTO Subscription (UserId, FolderId) VALUES(?UserId, ?FolderId)";
cmd.Parameters.Add("?FolderId", folder.FolderId);
@@ -475,13 +471,9 @@
#endregion
#region UnSubscribe
- public void UnSubscribe(string userName, StoreFolder folder) {
+ public void UnSubscribe(int userId, StoreFolder folder) {
using (MySqlConnection cnn = MySqlHelper.GetConnection()) {
using (MySqlCommand cmd = cnn.CreateCommand()) {
- cmd.CommandText = "SELECT UserId FROM User WHERE Username = ?Username";
- cmd.Parameters.Add("?Username", userName);
- int userId = (int)cmd.ExecuteScalar();
-
cmd.CommandText = "DELETE FROM Subscription WHERE UserId = ?UserId AND FolderId = ?FolderId";
cmd.Parameters.Add("?UserId", userId);
cmd.Parameters.Add("?FolderId", folder.FolderId);
@@ -1281,7 +1273,7 @@
/// Gets the list of groups that currently exist in the local store.
/// </summary>
/// <returns>The list of groups.</returns>
- public LocalStoreGroup[] GetGroups() {
+ public IList<LocalStoreGroup> GetGroups() {
using (MySqlConnection cnn = MySqlHelper.GetConnection()) {
MySqlTransaction transaction = cnn.BeginTransaction();
@@ -1304,7 +1296,7 @@
}
transaction.Commit();
- return groups.ToArray();
+ return groups;
} catch (Exception ex) {
if (transaction != null) {
@@ -1323,12 +1315,12 @@
/// </summary>
/// <param name="name">The name of the new group.</param>
/// <returns>The result of the attemp to create a new group.</returns>
- public LocalStoreGroupResult CreateGroup(string name) {
+ public void CreateGroup(LocalStoreGroup group) {
using (MySqlConnection cnn = MySqlHelper.GetConnection()) {
using (MySqlCommand cmd = cnn.CreateCommand()) {
cmd.CommandType = CommandType.StoredProcedure;
cmd.CommandText = "CreateGroup";
- cmd.Parameters.Add("?Name", name);
+ cmd.Parameters.Add("?Name", group.Name);
cmd.Parameters.Add("?GroupId", MySqlDbType.Int32);
cmd.Parameters["GroupId"].Direction = ParameterDirection.Output;
cmd.Parameters.Add("?Result", MySqlDbType.Int32);
@@ -1336,9 +1328,13 @@
cmd.ExecuteNonQuery();
- int result = (int) cmd.Parameters["Result"].Value;
+ LocalStoreGroupResult result = (LocalStoreGroupResult)((int) cmd.Parameters["Result"].Value);
- return (LocalStoreGroupResult) result;
+ if (result == LocalStoreGroupResult.AlreadyExists) {
+ throw new DuplicateNameException();
+ } else if (result == LocalStoreGroupResult.NotPermitted) {
+ throw new InvalidOperationException();
+ }
}
}
}
@@ -1350,7 +1346,7 @@
/// </summary>
/// <param name="groupId">The Id of the group to delete.</param>
/// <returns>The result of the attempt to delete a group.</returns>
- public LocalStoreGroupResult DeleteGroup(int groupId) {
+ public void DeleteGroup(int groupId) {
using (MySqlConnection cnn = MySqlHelper.GetConnection()) {
using (MySqlCommand cmd = cnn.CreateCommand()) {
cmd.CommandType = CommandType.StoredProcedure;
@@ -1361,9 +1357,13 @@
cmd.ExecuteNonQuery();
- int result = (int) cmd.Parameters["Result"].Value;
+ LocalStoreGroupResult result = (LocalStoreGroupResult) ((int) cmd.Parameters["Result"].Value);
- return (LocalStoreGroupResult) result;
+ if (result == LocalStoreGroupResult.NoSuchGroup) {
+ throw new ArgumentException();
+ } else if (result == LocalStoreGroupResult.NotPermitted) {
+ throw new InvalidOperationException();
+ }
}
}
}
@@ -1375,7 +1375,7 @@
/// </summary>
/// <param name="group">The updated group.</param>
/// <returns>The result of the attempt to update the group.</returns>
- public LocalStoreGroupResult UpdateGroup(LocalStoreGroup group) {
+ public void UpdateGroup(LocalStoreGroup group) {
using (MySqlConnection cnn = MySqlHelper.GetConnection()) {
using (MySqlCommand cmd = cnn.CreateCommand()) {
cmd.CommandType = CommandType.StoredProcedure;
@@ -1388,9 +1388,15 @@
cmd.ExecuteNonQuery();
- int result = (int) cmd.Parameters["Result"].Value;
+ LocalStoreGroupResult result = (LocalStoreGroupResult) ((int) cmd.Parameters["Result"].Value);
- return (LocalStoreGroupResult) result;
+ if (result == LocalStoreGroupResult.AlreadyExists) {
+ throw new DuplicateNameException();
+ } else if (result == LocalStoreGroupResult.NoSuchGroup) {
+ throw new ArgumentException();
+ } else if (result == LocalStoreGroupResult.NotPermitted) {
+ throw new InvalidOperationException();
+ }
}
}
}
@@ -1399,16 +1405,16 @@
#region Folder ACLs
#region Set StoreFolder ACE
- public void SetStoreFolderAce(StoreFolder folder, GenericAce<StoreFolderPrivilege> ace) {
+ public void SetStoreFolderAce(int folderId, GenericAce<StoreFolderPrivilege> ace) {
using (MySqlConnection cnn = MySqlHelper.GetConnection()) {
- setStoreFolderAce(folder, ace, cnn, null);
+ setStoreFolderAce(folderId, ace, cnn, null);
}
}
- private void setStoreFolderAce(StoreFolder folder, GenericAce<StoreFolderPrivilege> ace, MySqlConnection cnn, MySqlTransaction transaction) {
+ private void setStoreFolderAce(int folderId, GenericAce<StoreFolderPrivilege> ace, MySqlConnection cnn, MySqlTransaction transaction) {
using (MySqlCommand cmd = cnn.CreateCommand()) {
cmd.CommandText = "REPLACE FolderAcl (FolderId, Identifier, Allow, Privilege) VALUES (?FolderId, ?Identifier, ?Allow, ?Privilege)";
- cmd.Parameters.Add("?FolderId", folder.FolderId);
+ cmd.Parameters.Add("?FolderId", folderId);
cmd.Parameters.Add("?Identifier", ace.Identifier);
cmd.Parameters.Add("?Privilege", Convert.ToUInt32(ace.Privilege));
cmd.Parameters.Add("?Allow", (ace.AceType == AcePrivilegeType.Allow));
@@ -1422,11 +1428,11 @@
#endregion
#region Remove StoreFolder ACE
- public void RemoveStoreFolderAce(StoreFolder folder, string identifier) {
+ public void RemoveStoreFolderAce(int folderId, string identifier) {
using (MySqlConnection cnn = MySqlHelper.GetConnection()) {
using (MySqlCommand cmd = cnn.CreateCommand()) {
cmd.CommandText = "DELETE FROM FolderAcl WHERE FolderId = ?FolderId AND Identifier = ?Identifier";
- cmd.Parameters.Add("?FolderId", folder.FolderId);
+ cmd.Parameters.Add("?FolderId", folderId);
cmd.Parameters.Add("?Identifier", identifier);
if (cmd.ExecuteNonQuery() != 1) {
@@ -1493,7 +1499,7 @@
/// Gets all mail domains associated with this local store.
/// </summary>
/// <returns>The mail domains.</returns>
- public MailDomain[] GetMailDomains() {
+ public IList<MailDomain> GetMailDomains() {
using (MySqlConnection cnn = MySqlHelper.GetConnection()) {
MySqlTransaction transaction = cnn.BeginTransaction();
@@ -1517,7 +1523,7 @@
}
transaction.Commit();
- return mailDomains.ToArray();
+ return mailDomains;
} catch (Exception ex) {
if (transaction != null) {
@@ -1536,11 +1542,9 @@
/// </summary>
/// <param name="host">The primary host for the mail domain.</param>
/// <returns>The result of the attempt to add the mail domain.</returns>
- public LocalStoreMailDomainResult CreateMailDomain(Host host) {
+ public void CreateMailDomain(MailDomain mailDomain) {
using (MySqlConnection cnn = MySqlHelper.GetConnection()) {
using (MySqlCommand cmd = cnn.CreateCommand()) {
- MailDomain mailDomain = new MailDomain(-1, host);
-
cmd.CommandType = CommandType.StoredProcedure;
cmd.CommandText = "AddMailDomain";
cmd.Parameters.Add("?PrimaryHost", mailDomain.PrimaryHost.ToString());
@@ -1552,9 +1556,13 @@
cmd.ExecuteNonQuery();
- int result = (int) cmd.Parameters["Result"].Value;
+ LocalStoreMailDomainResult result = (LocalStoreMailDomainResult) ((int) cmd.Parameters["Result"].Value);
- return (LocalStoreMailDomainResult) result;
+ if (result == LocalStoreMailDomainResult.AlreadyExists) {
+ throw new DuplicateNameException();
+ } else if (result == LocalStoreMailDomainResult.NotPermitted) {
+ throw new InvalidOperationException();
+ }
}
}
}
@@ -1566,7 +1574,7 @@
/// </summary>
/// <param name="mailDomainId">The Id of the mail domain to delete.</param>
/// <returns>The result of the attempt to delete the domain.</returns>
- public LocalStoreMailDomainResult DeleteMailDomain(int mailDomainId) {
+ public void DeleteMailDomain(int mailDomainId) {
using (MySqlConnection cnn = MySqlHelper.GetConnection()) {
using (MySqlCommand cmd = cnn.CreateCommand()) {
cmd.CommandType = CommandType.StoredProcedure;
@@ -1577,9 +1585,15 @@
cmd.ExecuteNonQuery();
- int result = (int) cmd.Parameters["Result"].Value;
+ LocalStoreMailDomainResult result = (LocalStoreMailDomainResult) ((int) cmd.Parameters["Result"].Value);
- return (LocalStoreMailDomainResult) result;
+ if (result == LocalStoreMailDomainResult.AlreadyExists) {
+ throw new DuplicateNameException();
+ } else if (result == LocalStoreMailDomainResult.NoSuchMailDomain) {
+ throw new ArgumentException();
+ } else if (result == LocalStoreMailDomainResult.NotPermitted) {
+ throw new InvalidOperationException();
+ }
}
}
}
@@ -1591,7 +1605,7 @@
/// </summary>
/// <param name="updatedMailDomain">The updated mail domain.</param>
/// <returns>The result of the attempt to update the mail domain.</returns>
- public LocalStoreMailDomainResult UpdateMailDomain(MailDomain updatedMailDomain) {
+ public void UpdateMailDomain(MailDomain updatedMailDomain) {
using (MySqlConnection cnn = MySqlHelper.GetConnection()) {
using (MySqlCommand cmd = cnn.CreateCommand()) {
cmd.CommandType = CommandType.StoredProcedure;
@@ -1604,9 +1618,15 @@
cmd.ExecuteNonQuery();
- int result = (int) cmd.Parameters["Result"].Value;
+ LocalStoreMailDomainResult result = (LocalStoreMailDomainResult) ((int) cmd.Parameters["Result"].Value);
- return (LocalStoreMailDomainResult) result;
+ if (result == LocalStoreMailDomainResult.AlreadyExists) {
+ throw new DuplicateNameException();
+ } else if (result == LocalStoreMailDomainResult.NoSuchMailDomain) {
+ throw new ArgumentException();
+ } else if (result == LocalStoreMailDomainResult.NotPermitted) {
+ throw new InvalidOperationException();
+ }
}
}
}
Added: NMail/trunk/NMail.LocalStoreData.NHibernate/FolderSubscription.cs
===================================================================
--- NMail/trunk/NMail.LocalStoreData.NHibernate/FolderSubscription.cs (rev 0)
+++ NMail/trunk/NMail.LocalStoreData.NHibernate/FolderSubscription.cs 2007-04-18 13:02:58 UTC (rev 183)
@@ -0,0 +1,41 @@
+using System;
+using System.Collections.Generic;
+using System.Text;
+
+namespace NMail.LocalStoreData.NHibernate {
+ /// <summary>
+ /// A simple class for storing folder subscriptions.
+ /// </summary>
+ internal class FolderSubscription {
+
+ private int subscriptionId;
+
+ /// <summary>
+ /// The Id of the folder subscription.
+ /// </summary>
+ public int SubscriptionId {
+ get { return subscriptionId; }
+ set { subscriptionId = value; }
+ }
+
+ private int userId;
+
+ /// <summary>
+ /// The user subscribing to a folder.
+ /// </summary>
+ public int UserId {
+ get { return userId; }
+ set { userId = value; }
+ }
+
+ private int folderId;
+
+ /// <summary>
+ /// The folder subscribed to.
+ /// </summary>
+ public int FolderId {
+ get { return folderId; }
+ set { folderId = value; }
+ }
+ }
+}
Added: NMail/trunk/NMail.LocalStoreData.NHibernate/Mappings/NMail.LocalStoreData.NHibernate.FolderSubsciption.hbm.xml
===================================================================
--- NMail/trunk/NMail.LocalStoreData.NHibernate/Mappings/NMail.LocalStoreData.NHibernate.FolderSubsciption.hbm.xml (rev 0)
+++ NMail/trunk/NMail.LocalStoreData.NHibernate/Mappings/NMail.LocalStoreData.NHibernate.FolderSubsciption.hbm.xml 2007-04-18 13:02:58 UTC (rev 183)
@@ -0,0 +1,17 @@
+<?xml version="1.0" encoding="utf-8" ?>
+<hibernate-mapping xmlns="urn:nhibernate-mapping-2.2" namespace="NMail.LocalStoreData.NHibernate" assembly="NMail.LocalStoreData.NHibernate" default-lazy="false">
+
+ <class name="NMail.LocalStoreData.NHibernate.FolderSubscription" table="FolderSubscription">
+ <id name="SubscriptionId" type="Int32" unsaved-value="0">
+ <column name="SubscriptionId" not-null="true"/>
+ <generator class="native" />
+ </id>
+
+ <!-- TODO: ideally this would be a many-to-one relationship with StoreFolder -->
+ <property name="FolderId" not-null="true" />
+
+ <!-- TODO: ideally this would be a many-to-one relationship with LocalStoreUser -->
+ <property name="UserId" not-null="true" />
+ </class>
+
+</hibernate-mapping>
\ No newline at end of file
Modified: NMail/trunk/NMail.LocalStoreData.NHibernate/NHibernateLocalStoreData.cs
===================================================================
--- NMail/trunk/NMail.LocalStoreData.NHibernate/NHibernateLocalStoreData.cs 2007-04-11 04:58:48 UTC (rev 182)
+++ NMail/trunk/NMail.LocalStoreData.NHibernate/NHibernateLocalStoreData.cs 2007-04-18 13:02:58 UTC (rev 183)
@@ -16,7 +16,6 @@
*/
using System;
-using System.Collections;
using System.Collections.Generic;
using System.Data;
using System.Security.Cryptography;
@@ -318,6 +317,8 @@
DeleteChildrenWithoutUpdate(folder, session);
+ // TODO: delete ACLs
+ // TODO: delete folder subscriptions
session.Delete(folder);
// Remove the folder from the parent's list of children if present
@@ -352,7 +353,9 @@
// Recurse down
DeleteChildrenWithoutUpdate(child, session);
- // Delete the child at the current leve
+ // Delete the child at the current level
+ // TODO: remove child ACLs
+ // TODO: delete folder subscriptions
session.Delete(child);
}
}
@@ -384,18 +387,29 @@
StoreFolder newFolder;
StoreFolder currentParent;
StoreFolder newParentFolder = null;
+
+ if (parentId.HasValue) {
+ newParentFolder = session.Load<StoreFolder>(parentId.Value);
+ }
if (currentFolder.ParentId.HasValue) {
currentParent = session.Load<StoreFolder>(currentFolder.ParentId.Value);
}
- if (parentId.HasValue) {
- newParentFolder = session.Load<StoreFolder>(parentId.Value);
- }
-
// Setup the new folder
if (newParentFolder != null) {
newFolder = new StoreFolder(newParentFolder, newFolderName);
+
+ // Check for any folders with the same name
+ IList<StoreFolder> matching = session.CreateCriteria(typeof(StoreFolder))
+ .Add(Expression.Like("FullFolderName", newFolder.FullFolderName))
+ .Add(Expression.Eq("ParentId", parentId))
+ .List<StoreFolder>();
+
+ if (matching.Count > 0) {
+ throw new DuplicateNameException("Folder with the same name already exists.");
+ }
+
} else {
newFolder = new StoreFolder(currentFolder.NameSpace, newFolderName);
}
@@ -487,88 +501,87 @@
#region Folder Subscription
#region GetSubscribedFolders
- public IList<StoreFolder> GetSubscribedFolders(string userName) {
- //using (MySqlConnection cnn = MySqlHelper.GetConnection()) {
- // using (MySqlCommand cmd = cnn.CreateCommand()) {
- // cmd.CommandText = "SELECT s.FolderId AS FolderId FROM User u, Subscription s WHERE s.UserId = u.UserId AND u.UserName = ?UserName";
- // cmd.Parameters.Add("?UserName", userName);
-
- // using (MySqlDataReader reader = cmd.ExecuteReader()) {
- // List<int> subscribedIds = new List<int>();
+ /// <summary>
+ /// Gets a list of subscribed folders that match the query folder.
+ /// </summary>
+ /// <param name="userId">The Id of the user to get the list of subscribed folders for.</param>
+ /// <returns>The list of folders.</returns>
+ public IList<StoreFolder> GetSubscribedFolders(int userId) {
+ using (ISession session = this.hibernateFactory.OpenSession()) {
+ using (ITransaction tx = session.BeginTransaction()) {
+ IList<FolderSubscription> subscriptionList = session.CreateCriteria(typeof(FolderSubscription))
+ .Add(Expression.Eq("UserId", userId))
+ .List<FolderSubscription>();
- // while (reader.Read()) {
- // int currentId = (int) reader["FolderId"];
+ int[] folderIds = new int[subscriptionList.Count];
+ for (int i = 0; i < subscriptionList.Count; i++) {
+ folderIds[i] = subscriptionList[i].FolderId;
+ }
- // subscribedIds.Add(currentId);
- // }
- // reader.Close();
+ IList<StoreFolder> subscribed = session.CreateCriteria(typeof(StoreFolder))
+ .Add(Expression.In("FolderId", folderIds))
+ .List<StoreFolder>();
- // List<StoreFolder> subscribedFolders = new List<StoreFolder>();
- // foreach (int currentId in subscribedIds) {
- // subscribedFolders.Add(GetStoreFolder(currentId));
- // }
- // return subscribedFolders.ToArray();
- // }
- // }
- //}
- throw new NotImplementedException();
+ tx.Commit();
+ session.Close();
+
+ return subscribed;
+ }
+ }
}
#endregion
#region Subscribe
- //private bool folderSubscribed(int userId, int folderId) {
- // using (MySqlConnection cnn = MySqlHelper.GetConnection()) {
- // using (MySqlCommand cmd = cnn.CreateCommand()) {
- // cmd.CommandText = "SELECT COUNT(*) FROM Subscription WHERE UserId = ?UserId AND FolderId = ?FolderId";
- // cmd.Parameters.Add("?UserId", userId);
- // cmd.Parameters.Add("?FolderId", folderId);
- // long count = (long) cmd.ExecuteScalar();
-
- // return (count > 0);
- // }
- // }
- //}
+ /// <summary>
+ /// Subscribes to a folder.
+ /// </summary>
+ /// <param name="userId">The Id of the user to subscribe for.</param>
+ /// <param name="folder">The folder to subscribe to.</param>
+ public void Subscribe(int userId, StoreFolder folder) {
+ using (ISession session = this.hibernateFactory.OpenSession()) {
+ using (ITransaction tx = session.BeginTransaction()) {
+ IList<FolderSubscription> current = session.CreateCriteria(typeof(FolderSubscription))
+ .Add(Expression.Eq("UserId", userId))
+ .Add(Expression.Eq("FolderId", folder.FolderId))
+ .List<FolderSubscription>();
- public void Subscribe(string userName, StoreFolder folder) {
- //using (MySqlConnection cnn = MySqlHelper.GetConnection()) {
- // using (MySqlCommand cmd = cnn.CreateCommand()) {
- // cmd.CommandText = "SELECT UserId FROM User WHERE UserName = ?UserName";
- // cmd.Parameters.Add("?UserName", userName);
- // int userId = (int) cmd.ExecuteScalar();
+ if (current.Count == 0) {
+ FolderSubscription subscription = new FolderSubscription();
+ subscription.FolderId = folder.FolderId;
+ subscription.UserId = userId;
- // if (!folderSubscribed(userId, folder.FolderId)) {
- // cmd.CommandText = "INSERT INTO Subscription (UserId, FolderId) VALUES(?UserId, ?FolderId)";
- // cmd.Parameters.Add("?FolderId", folder.FolderId);
- // cmd.Parameters.Add("?UserId", userId);
-
- // if (cmd.ExecuteNonQuery() != 1) {
- // throw new System.Data.DataException("Error updating subscription.");
- // }
- // }
- // }
- //}
- throw new NotImplementedException();
+ session.Save(subscription);
+ }
+
+ tx.Commit();
+ session.Close();
+ }
+ }
}
#endregion
#region UnSubscribe
- public void UnSubscribe(string userName, StoreFolder folder) {
- //using (MySqlConnection cnn = MySqlHelper.GetConnection()) {
- // using (MySqlCommand cmd = cnn.CreateCommand()) {
- // cmd.CommandText = "SELECT UserId FROM User WHERE Username = ?Username";
- // cmd.Parameters.Add("?Username", userName);
- // int userId = (int)cmd.ExecuteScalar();
+ /// <summary>
+ /// Un-subscribes from a folder.
+ /// </summary>
+ /// <param name="userId">The Id of the user to unsubscribe for.</param>
+ /// <param name="folder">The folder to unsubscribe from.</param>
+ public void UnSubscribe(int userId, StoreFolder folder) {
+ using (ISession session = this.hibernateFactory.OpenSession()) {
+ using (ITransaction tx = session.BeginTransaction()) {
+ IList<FolderSubscription> current = session.CreateCriteria(typeof(FolderSubscription))
+ .Add(Expression.Eq("UserId", userId))
+ .Add(Expression.Eq("FolderId", folder.FolderId))
+ .List<FolderSubscription>();
- // cmd.CommandText = "DELETE FROM Subscription WHERE UserId = ?UserId AND FolderId = ?FolderId";
- // cmd.Parameters.Add("?UserId", userId);
- // cmd.Parameters.Add("?FolderId", folder.FolderId);
+ if (current.Count != 0) {
+ session.Delete(current[0].SubscriptionId);
+ }
- // if (cmd.ExecuteNonQuery() != 1) {
- // throw new System.Data.DataException("Error updating subscription.");
- // }
- // }
- //}
- throw new NotImplementedException();
+ tx.Commit();
+ session.Close();
+ }
+ }
}
#endregion
@@ -1016,9 +1029,9 @@
}
// Check if any other user with the same name exists in the system
- IList existing = session.CreateCriteria(typeof(LocalStoreUser))
+ IList<LocalStoreUser> existing = session.CreateCriteria(typeof(LocalStoreUser))
.Add(Expression.Like("Username", user.Username))
- .List();
+ .List<LocalStoreUser>();
if (existing.Count > 0) {
throw new DuplicateNameException("User with the same name already exists in the system.");
@@ -1059,7 +1072,6 @@
/// 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>
public void DeleteUser(int userId) {
using (ISession session = this.hibernateFactory.OpenSession()) {
using (ITransaction tx = session.BeginTransaction()) {
@@ -1087,9 +1099,9 @@
using (ISession session = this.hibernateFactory.OpenSession()) {
using (ITransaction tx = session.BeginTransaction()) {
// Check if any other user with the same name exists in the system
- IList existing = session.CreateCriteria(typeof(LocalStoreUser))
+ IList<LocalStoreUser> existing = session.CreateCriteria(typeof(LocalStoreUser))
.Add(Expression.Like("Username", user.Username))
- .List();
+ .List<LocalStoreUser>();
if (existing.Count > 0) {
throw new DuplicateNameException("User with the same name already exists in the system.");
@@ -1138,109 +1150,25 @@
/// <param name="name">The name to look up.</param>
/// <returns>The matching group or null if non is found.</returns>
public LocalStoreGroup GetGroup(string name) {
- //using (MySqlConnection cnn = MySqlHelper.GetConnection()) {
- // return getGroup(name, cnn, null);
- //}
- throw new NotImplementedException();
+ using (ISession session = this.hibernateFactory.OpenSession()) {
+ return session.CreateCriteria(typeof(LocalStoreGroup))
+ .Add(Expression.Like("Name", name))
+ .UniqueResult<LocalStoreGroup>();
+ }
}
- //private LocalStoreGroup getGroup(string name, MySqlConnection cnn, MySqlTransaction transaction) {
- // using (MySqlCommand cmd = cnn.CreateCommand()) {
- // cmd.Transaction = transaction;
- // cmd.CommandType = CommandType.StoredProcedure;
- // cmd.CommandText = "GetGroupFromName";
- // cmd.Parameters.Add("?Name", name);
- // cmd.Parameters.Add("?GroupId", MySqlDbType.Int32);
- // cmd.Parameters["GroupId"].Direction = ParameterDirection.Output;
- // cmd.Parameters.Add("?Result", MySqlDbType.Int32);
- // cmd.Parameters["Result"].Direction = ParameterDirection.Output;
-
- // DataSet groupData = new DataSet();
- // MySqlDataAdapter da = new MySqlDataAdapter(cmd);
- // da.Fill(groupData);
-
- // int resultValue = (int) cmd.Parameters["Result"].Value;
- // LocalStoreUserResult result = (LocalStoreUserResult) resultValue;
-
- // // Check if the lookup succeeded
- // if (result != LocalStoreUserResult.OkSuccessful) {
- // return null;
- // }
-
- // int groupId = (int) cmd.Parameters["GroupId"].Value;
-
- // // Get the group's sub-group Ids
- // List<int> groupIds = new List<int>();
- // DataTable groupGroupTable = groupData.Tables[0];
- // foreach (DataRow row in groupGroupTable.Rows) {
- // groupIds.Add((int) row[0]);
- // }
-
- // // The the group's user Ids
- // List<int> userIds = new List<int>();
- // DataTable userGroupTable = groupData.Tables[1];
- // foreach (DataRow row in userGroupTable.Rows) {
- // userIds.Add((int) row[0]);
- // }
-
- // return new LocalStoreGroup(name, groupId, userIds.ToArray(), groupIds.ToArray());
- // }
- //}
-
/// <summary>
/// Gets the group for the given user Id.
/// </summary>
/// <param name="groupId">The Id of the group to look up.</param>
/// <returns>The matching group or null if non is found.</returns>
public LocalStoreGroup GetGroup(int groupId) {
- //using (MySqlConnection cnn = MySqlHelper.GetConnection()) {
- // return getGroup(groupId, cnn, null);
- //}
- throw new NotImplementedException();
+ using (ISession session = this.hibernateFactory.OpenSession()) {
+ return session.CreateCriteria(typeof(LocalStoreGroup))
+ .Add(Expression.Like("GroupId", groupId))
+ .UniqueResult<LocalStoreGroup>();
+ }
}
-
- //private LocalStoreGroup getGroup(int groupId, MySqlConnection cnn, MySqlTransaction transaction) {
- // using (MySqlCommand cmd = cnn.CreateCommand()) {
- // cmd.Transaction = transaction;
- // cmd.CommandType = CommandType.StoredProcedure;
- // cmd.CommandText = "GetGroupFromId";
- // cmd.Parameters.Add("?GroupId", groupId);
- // cmd.Parameters.Add("?Name", MySqlDbType.VarChar);
- // cmd.Parameters["Name"].Direction = ParameterDirection.Output;
- // cmd.Parameters.Add("?Result", MySqlDbType.Int32);
- // cmd.Parameters["Result"].Direction = ParameterDirection.Output;
-
- // DataSet groupData = new DataSet();
- // MySqlDataAdapter da = new MySqlDataAdapter(cmd);
- // da.Fill(groupData);
-
- // int resultValue = (int) cmd.Parameters["Result"].Value;
- // LocalStoreUserResult result = (LocalStoreUserResult) resultValue;
-
- // // Check if the lookup succeeded
- // if (result != LocalStoreUserResult.OkSuccessful) {
- // return null;
- // }
-
- // string name = (string) cmd.Parameters["Name"].Value;
-
- // // Get the group's sub-group Ids
- // List<int> groupIds = new List<int>();
- // DataTable groupGroupTable = groupData.Tables[0];
- // foreach (DataRow row in groupGroupTable.Rows) {
- // groupIds.Add((int) row[0]);
- // }
-
- // // The the group's user Ids
- // List<int> userIds = new List<int>();
- // DataTable userGroupTable = groupData.Tables[1];
- // foreach (DataRow row in userGroupTable.Rows) {
- // userIds.Add((int) row[0]);
- // }
-
- // return new LocalStoreGroup(name, groupId, userIds.ToArray(), groupIds.ToArray());
- // }
- //}
#endregion
#region GetGroups
@@ -1248,68 +1176,43 @@
/// Gets the list of groups that currently exist in the local store.
/// </summary>
/// <returns>The list of groups.</returns>
- public LocalStoreGroup[] GetGroups() {
- //using (MySqlConnection cnn = MySqlHelper.GetConnection()) {
- // MySqlTransaction transaction = cnn.BeginTransaction();
-
- // try {
- // MySqlCommand cmd = cnn.CreateCommand();
- // cmd.Transaction = transaction;
-
- // cmd.CommandType = CommandType.StoredProcedure;
- // cmd.CommandText = "GetGroupIds";
- // MySqlDataReader reader = cmd.ExecuteReader();
- // List<int> groupIds = new List<int>();
-
- // while (reader.NextResult()) {
- // int groupId = (int) reader["GroupId"];
- // }
-
- // List<LocalStoreGroup> groups = new List<LocalStoreGroup>();
- // foreach (int groupId in groupIds) {
- // groups.Add(getGroup(groupId, cnn, transaction));
- // }
-
- // transaction.Commit();
- // return groups.ToArray();
-
- // } catch (Exception ex) {
- // if (transaction != null) {
- // transaction.Rollback();
- // }
-
- // throw ex;
- // }
- //}
- throw new NotImplementedException();
+ public IList<LocalStoreGroup> GetGroups() {
+ using (ISession session = this.hibernateFactory.OpenSession()) {
+ return session.CreateCriteria(typeof(LocalStoreGroup)).List<LocalStoreGroup>();
+ }
}
#endregion
#region CreateGroup
/// <summary>
- /// Creates a new group in the local store.
- /// </summary>
- /// <param name="name">The name of the new group.</param>
- /// <returns>The result of the attemp to create a new group.</returns>
- public LocalStoreGroupResult CreateGroup(string name) {
- //using (MySqlConnection cnn = MySqlHelper.GetConnection()) {
- // using (MySqlCommand cmd = cnn.CreateCommand()) {
- // cmd.CommandType = CommandType.StoredProcedure;
- // cmd.CommandText = "CreateGroup";
- // cmd.Parameters.Add("?Name", name);
- // cmd.Parameters.Add("?GroupId", MySqlDbType.Int32);
- // cmd.Parameters["GroupId"].Direction = ParameterDirection.Output;
- // cmd.Parameters.Add("?Result", MySqlDbType.Int32);
- // cmd.Parameters["Result"].Direction = ParameterDirection.Output;
+ /// Creates a new group in the local store.
+ /// </summary>
+ /// <param name="group">The group to create.</param>
+ /// <exception cref="System.Data.DuplicateNameException">If a group with the same name already exists.</exception>
+ /// <exception cref="System.InvalidOperationException">Changes to the group are not permitted.</exception>
+ /// <exception cref="System.ArgumentException">The group is invalid.</exception>
+ public void CreateGroup(LocalStoreGroup group) {
+ using (ISession session = this.hibernateFactory.OpenSession()) {
+ using (ITransaction tx = session.BeginTransaction()) {
+ if (group.GroupId != 0) {
+ throw new InvalidOperationException("Can't save an existing group with this method.");
+ }
- // cmd.ExecuteNonQuery();
+ // Check if any other user with the same name exists in the system
+ IList<LocalStoreUser> existing = session.CreateCriteria(typeof(LocalStoreGroup))
+ .Add(Expression.Like("Name", group.Name))
+ .List<LocalStoreUser>();
- // int result = (int) cmd.Parameters["Result"].Value;
+ if (existing.Count > 0) {
+ throw new DuplicateNameException("Group with the same name already exists in the system.");
+ }
- // return (LocalStoreGroupResult) result;
- // }
- //}
- throw new NotImplementedException();
+ session.Save(group);
+
+ tx.Commit();
+ session.Close();
+ }
+ }
}
#endregion
@@ -1318,24 +1221,18 @@
/// Removes a group from the local store.
/// </summary>
/// <param name="groupId">The Id of the group to delete.</param>
- /// <returns>The result of the attempt to delete a group.</returns>
- public LocalStoreGroupResult DeleteGroup(int groupId) {
- //using (MySqlConnection cnn = MySqlHelper.GetConnection()) {
- // using (MySqlCommand cmd = cnn.CreateCommand()) {
- // cmd.CommandType = CommandType.StoredProcedure;
- // cmd.CommandText = "DeleteGroup";
- // cmd.Parameters.Add("?DeleteGroupId", groupId);
- // cmd.Parameters.Add("?Result", MySqlDbType.Int32);
- // cmd.Parameters["Result"].Direction = ParameterDirection.Output;
+ /// <exception cref="System.InvalidOperationException">Changes to the group are not permitted.</exception>
+ /// <exception cref="System.ArgumentException">The user is invalid.</exception>
+ public void DeleteGroup(int groupId) {
+ using (ISession session = this.hibernateFactory.OpenSession()) {
+ using (ITransaction tx = session.BeginTransaction()) {
+ LocalStoreGroup group = session.Load<LocalStoreGroup>(groupId);
+ session.Delete(group);
- // cmd.ExecuteNonQuery();
-
- // int result = (int) cmd.Parameters["Result"].Value;
-
- // return (LocalStoreGroupResult) result;
- // }
- //}
- throw new NotImplementedException();
+ tx.Commit();
+ }
+ session.Close();
+ }
}
#endregion
@@ -1345,163 +1242,136 @@
/// </summary>
/// <param name="group">The updated group.</param>
/// <returns>The result of the attempt to update the group.</returns>
- public LocalStoreGroupResult UpdateGroup(LocalStoreGroup gro...
[truncated message content] |
|
From: <tmy...@us...> - 2007-04-11 04:58:47
|
Revision: 182
http://svn.sourceforge.net/nmailserver/?rev=182&view=rev
Author: tmyroadctfig
Date: 2007-04-10 21:58:48 -0700 (Tue, 10 Apr 2007)
Log Message:
-----------
Further work on localstore data.
Modified Paths:
--------------
NMail/trunk/NMail/DataTypes/LocalStore/ILocalStore.cs
NMail/trunk/NMail/DataTypes/LocalStore/ILocalStoreData.cs
NMail/trunk/NMail.ImapService/State/AuthenticatedState.cs
NMail/trunk/NMail.LocalStore/LocalStore.cs
NMail/trunk/NMail.LocalStoreData.MySql/MySqlLocalStoreData.cs
NMail/trunk/NMail.LocalStoreData.NHibernate/NHibernateLocalStoreData.cs
Modified: NMail/trunk/NMail/DataTypes/LocalStore/ILocalStore.cs
===================================================================
--- NMail/trunk/NMail/DataTypes/LocalStore/ILocalStore.cs 2007-04-11 02:50:01 UTC (rev 181)
+++ NMail/trunk/NMail/DataTypes/LocalStore/ILocalStore.cs 2007-04-11 04:58:48 UTC (rev 182)
@@ -111,21 +111,26 @@
LocalStoreFolderResult DeleteFolder(IAuthenticationToken authToken, int folderId);
/// <summary>
- /// Renames an existing folder in the local store.
+ /// Moves an existing folder in the local store to another location.
/// </summary>
/// <remarks>
- /// It is a requirement of the local store that a renamed folder and all its sub-folder get a new
+ /// It is a requirement of the local store that a moved folder and all its sub-folder get a new
/// folder Id. Futher, this new Id number cannot have been used previously.
///
- /// Thus any existing folder Ids for the rename folder or its childed obtained before the rename may
- /// be altered and must be reaquired from the local store.
+ /// Thus any existing folder Ids for the moved folder or its children obtained before the move may
+ /// be invalid and must be reaquired from the local store.
/// </remarks>
/// <param name="authToken">The authentication credentials.</param>
- /// <param name="folder">The folder to rename.</param>
- /// <param name="newFolder">The new folder name.</param>
- /// <returns>The result of the rename attempt.</returns>
- LocalStoreFolderResult RenameFolder(IAuthenticationToken authToken, StoreFolder folder, string newFolder);
-
+ /// <param name="folderId">The Id of the folder to move.</param>
+ /// <param name="parentId">The Id of the new parent folder if any.</param>
+ /// <param name="newFolderName">
+ /// The new folder name. Note: this is <b>not</b> the full folder name or the qualified folder name.
+ /// </param>
+ /// <exception cref="System.Data.DuplicateNameException">If a folder with the same name already exists.</exception>
+ /// <exception cref="System.InvalidOperationException">Changes to the folder are not permitted.</exception>
+ /// <exception cref="System.ArgumentException">The folder Id or parent Id or folder name is invalid.</exception>
+ void MoveFolder(IAuthenticationToken authToken, int folderId, int? parentId, string newFolderName);
+
/// <summary>
/// Gets a list of folders that match the query folder.
/// </summary>
Modified: NMail/trunk/NMail/DataTypes/LocalStore/ILocalStoreData.cs
===================================================================
--- NMail/trunk/NMail/DataTypes/LocalStore/ILocalStoreData.cs 2007-04-11 02:50:01 UTC (rev 181)
+++ NMail/trunk/NMail/DataTypes/LocalStore/ILocalStoreData.cs 2007-04-11 04:58:48 UTC (rev 182)
@@ -89,19 +89,24 @@
void DeleteFolder(int folderId, bool deleteChildren);
/// <summary>
- /// Renames an existing folder in the local store.
+ /// Moves an existing folder in the local store to another location.
/// </summary>
/// <remarks>
- /// It is a requirement of the local store that a renamed folder and all its sub-folder get a new
+ /// It is a requirement of the local store that a moved folder and all its sub-folder get a new
/// folder Id. Futher, this new Id number cannot have been used previously.
///
- /// Thus any existing folder Ids for the rename folder or its childed obtained before the rename may
- /// be altered and must be reaquired from the local store.
+ /// Thus any existing folder Ids for the moved folder or its children obtained before the move may
+ /// be invalid and must be reaquired from the local store.
/// </remarks>
- /// <param name="folder">The folder to rename.</param>
- /// <param name="newFolder">The new folder name.</param>
- /// <returns>The result of the rename attempt.</returns>
- LocalStoreFolderResult RenameFolder(StoreFolder folder, string newFolder);
+ /// <param name="folderId">The Id of the folder to move.</param>
+ /// <param name="parentId">The Id of the new parent folder if any.</param>
+ /// <param name="newFolderName">
+ /// The new folder name. Note: this is <b>not</b> the full folder name or the qualified folder name.
+ /// </param>
+ /// <exception cref="System.Data.DuplicateNameException">If a folder with the same name already exists.</exception>
+ /// <exception cref="System.InvalidOperationException">Changes to the folder are not permitted.</exception>
+ /// <exception cref="System.ArgumentException">The folder Id or parent Id or folder name is invalid.</exception>
+ void MoveFolder(int folderId, int? parentId, string newFolderName);
/// <summary>
/// Gets a list of child folders for the given parent folder.
Modified: NMail/trunk/NMail.ImapService/State/AuthenticatedState.cs
===================================================================
--- NMail/trunk/NMail.ImapService/State/AuthenticatedState.cs 2007-04-11 02:50:01 UTC (rev 181)
+++ NMail/trunk/NMail.ImapService/State/AuthenticatedState.cs 2007-04-11 04:58:48 UTC (rev 182)
@@ -17,6 +17,7 @@
using System;
using System.Collections.Generic;
+using System.Data;
using System.Globalization;
using System.Text;
@@ -310,9 +311,19 @@
StoreFolder folder = LocalStore.GetStoreFolder(Session.AuthenticationToken, cmd.CurrentFolder);
if (folder != null) {
- LocalStoreFolderResult result = LocalStore.RenameFolder(Session.AuthenticationToken, folder, cmd.NewFolder);
+ try {
+ int? parentId = null;
+ Folder newFolder = new Folder(cmd.NewFolder);
- if (result == LocalStoreFolderResult.OkSuccessful) {
+ // Get the parent folder Id if any
+ if (newFolder.Parent != null) {
+ StoreFolder parent = LocalStore.GetStoreFolder(Session.AuthenticationToken, newFolder.Parent.FullyQualifiedName);
+ parentId = parent.FolderId;
+ }
+
+ // Move the folder
+ LocalStore.MoveFolder(Session.AuthenticationToken, folder.FolderId, parentId, newFolder.FolderName);
+
// Renaming INBOX creates a new empty INBOX.
if (LocalStore.GetStoreFolder(Session.AuthenticationToken, Folder.Inbox) == null) {
LocalStore.CreateFolder(Session.AuthenticationToken, Folder.Inbox);
@@ -320,16 +331,16 @@
QueueResponse(new SimpleResponse(cmd.Tag, ResponseType.Ok, "RENAME Completed."));
- } else if (result == LocalStoreFolderResult.AlreadyExists) {
+ } catch (DuplicateNameException) {
QueueResponse(new SimpleResponse(cmd.Tag, ResponseType.No, "RENAME: Folder:[" + cmd.NewFolder + "] already exists."));
- } else if (result == LocalStoreFolderResult.NonExistent) {
- QueueResponse(new SimpleResponse(cmd.Tag, ResponseType.No, "RENAME: No such folder:[" + cmd.CurrentFolder + "]"));
+ } catch (ArgumentException) {
+ QueueResponse(new SimpleResponse(cmd.Tag, ResponseType.No, "RENAME: Invalid parameters: Current name:[" + cmd.CurrentFolder + "] New name:[" + cmd.NewFolder + "]"));
- } else if (result == LocalStoreFolderResult.NotPermitted) {
+ } catch (InvalidOperationException) {
QueueResponse(new SimpleResponse(cmd.Tag, ResponseType.No, "RENAME: Insufficient privileges to delete folder:[" + cmd.CurrentFolder + "]."));
- } else {
+ } catch (Exception) {
QueueResponse(new SimpleResponse(cmd.Tag, ResponseType.No, "RENAME: Unknown error."));
}
} else {
Modified: NMail/trunk/NMail.LocalStore/LocalStore.cs
===================================================================
--- NMail/trunk/NMail.LocalStore/LocalStore.cs 2007-04-11 02:50:01 UTC (rev 181)
+++ NMail/trunk/NMail.LocalStore/LocalStore.cs 2007-04-11 04:58:48 UTC (rev 182)
@@ -427,37 +427,41 @@
return LocalStoreData.GetFolders();
}
- #region Rename Folder
+ #region Move Folder
/// <summary>
- /// Renames an existing folder in the local store.
+ /// Moves an existing folder in the local store to another location.
/// </summary>
/// <remarks>
- /// It is a requirement of the local store that a renamed folder and all its sub-folder get a new
+ /// It is a requirement of the local store that a moved folder and all its sub-folder get a new
/// folder Id. Futher, this new Id number cannot have been used previously.
///
- /// Thus any existing folder Ids for the rename folder or its childed obtained before the rename may
- /// be altered and must be reaquired from the local store.
+ /// Thus any existing folder Ids for the moved folder or its children obtained before the move may
+ /// be invalid and must be reaquired from the local store.
/// </remarks>
/// <param name="authToken">The authentication credentials.</param>
- /// <param name="folder">The folder to rename.</param>
- /// <param name="newFolder">The new folder name.</param>
- /// <returns>The result of the rename attempt.</returns>
- public LocalStoreFolderResult RenameFolder(IAuthenticationToken authToken, StoreFolder folder, string newFolderName) {
+ /// <param name="folderId">The Id of the folder to move.</param>
+ /// <param name="parentId">The Id of the new parent folder if any.</param>
+ /// <param name="newFolderName">
+ /// The new folder name. Note: this is <b>not</b> the full folder name or the qualified folder name.
+ /// </param>
+ /// <exception cref="System.Data.DuplicateNameException">If a folder with the same name already exists.</exception>
+ /// <exception cref="System.InvalidOperationException">Changes to the folder are not permitted.</exception>
+ /// <exception cref="System.ArgumentException">The folder Id or parent Id or folder name is invalid.</exception>
+ public void MoveFolder(IAuthenticationToken authToken, int folderId, int? parentId, string newFolderName) {
// Ensure the user has delete privileges on the original folder
- if (hasFolderPrivilege(authToken.Username, folder.FolderId, StoreFolderPrivilege.Delete)) {
+ if (hasFolderPrivilege(authToken.Username, folderId, StoreFolderPrivilege.Delete)) {
- Folder newFolder = new Folder(folder.NameSpace, newFolderName);
- StoreFolder parent = LocalStoreData.GetStoreFolder(newFolder.Parent);
-
// Ensure the user has create privileges on the new parent folder
- if (parent != null && hasFolderPrivilege(authToken.Username, parent.FolderId, StoreFolderPrivilege.CreateFolders)) {
- return LocalStoreData.RenameFolder(folder, newFolderName);
+ // TODO: implement move for top level folders
+ if (parentId.HasValue && hasFolderPrivilege(authToken.Username, parentId.Value, StoreFolderPrivilege.CreateFolders)) {
+ LocalStoreData.MoveFolder(folderId, parentId, newFolderName);
+
} else {
- return LocalStoreFolderResult.NotPermitted;
+ throw new InvalidOperationException("Not permitted to move this folder or invalid folder.");
}
} else {
- return LocalStoreFolderResult.NotPermitted;
+ throw new InvalidOperationException("Not permitted to move this folder or invalid folder.");
}
}
#endregion
Modified: NMail/trunk/NMail.LocalStoreData.MySql/MySqlLocalStoreData.cs
===================================================================
--- NMail/trunk/NMail.LocalStoreData.MySql/MySqlLocalStoreData.cs 2007-04-11 02:50:01 UTC (rev 181)
+++ NMail/trunk/NMail.LocalStoreData.MySql/MySqlLocalStoreData.cs 2007-04-11 04:58:48 UTC (rev 182)
@@ -330,51 +330,10 @@
}
#endregion
- #region RenameFolder
- public LocalStoreFolderResult RenameFolder(StoreFolder folder, string newFolderName) {
- /* Several cases:
- * a1.b1 -> a1.b2 => simply rename "a1.b1" to "a1.b2"
- * a1.b1 -> a2.b1 => rename "a1" to "a2" and "a1.b1" to "a2.b1"
- * a1.b1.c1 -> a1.b2.c1 => rename "a1.b1" to "a1.b2" and "a1.b1.c1" to "a1.b2.c1"
- * So simply rename the folder and any children.
- *
- * Also renaming "a1.b1" to "a2.b2" causes problems so renaming will be limited
- * to only allow changing the end folder in the hierarchy. For example:
- * a1.b1 -> a1.b2 is ok
- * a1 -> a2 is ok
- * a1.b1 to a2.b1 is not ok
- */
+ #region MoveFolder
+ public void MoveFolder(int folderId, int? parentId, string newFolderName) {
- // Check only the top level folder is being renamed
- char[] delim = { NMailConfiguration.Current.LocalStore.FolderDelimiter };
- string[] folderParts = folder.FullFolderName.Split(delim);
- string[] newParts = newFolderName.Split(delim);
-
- if (folderParts.Length != newParts.Length) {
- return LocalStoreFolderResult.NotPermitted;
- }
-
- for (int i = 0; i < folderParts.Length - 1; i++) {
- if (!folderParts[i].ToLower().Equals(newParts[i].ToLower())) {
- return LocalStoreFolderResult.NotPermitted;
- }
- }
-
- // Only the last part of the folder name has changed, proceed with the rename
- using (MySqlConnection cnn = MySqlHelper.GetConnection()) {
- MySqlTransaction transaction = cnn.BeginTransaction();
-
- // Check for a folder with the same name
- Folder newFolder = new Folder(folder.NameSpace, newFolderName);
- if (getStoreFolder(newFolder, cnn, transaction) != null) {
- transaction.Commit();
- return LocalStoreFolderResult.AlreadyExists;
- }
-
- throw new NotImplementedException();
- // TODO: rename the folder
- // TODO: recursively rename all children
- }
+ throw new NotImplementedException();
}
#endregion
Modified: NMail/trunk/NMail.LocalStoreData.NHibernate/NHibernateLocalStoreData.cs
===================================================================
--- NMail/trunk/NMail.LocalStoreData.NHibernate/NHibernateLocalStoreData.cs 2007-04-11 02:50:01 UTC (rev 181)
+++ NMail/trunk/NMail.LocalStoreData.NHibernate/NHibernateLocalStoreData.cs 2007-04-11 04:58:48 UTC (rev 182)
@@ -269,11 +269,15 @@
}
// Check for any folders with the same name
- IList<StoreFolder> matching = session.CreateCriteria(typeof(StoreFolder))
- .Add(Expression.Eq("ParentId", newFolder.ParentId))
- .Add(Expression.Like("FullFolderName", newFolder.FullFolderName))
- .List<StoreFolder>();
+ ICriteria criteria = session.CreateCriteria(typeof(StoreFolder))
+ .Add(Expression.Like("FullFolderName", newFolder.FullFolderName));
+ if (newFolder.ParentId.HasValue) {
+ criteria = criteria.Add(Expression.Eq("ParentId", newFolder.ParentId));
+ }
+
+ IList<StoreFolder> matching = criteria.List<StoreFolder>();
+
if (matching.Count > 0) {
throw new DuplicateNameException("Folder with the same name already exists.");
}
@@ -354,26 +358,94 @@
}
#endregion
- #region RenameFolder
- public void RenameFolder(int folderId, Folder newFolderName) {
+ #region MoveFolder
+ /// <summary>
+ /// Moves an existing folder in the local store to another location.
+ /// </summary>
+ /// <remarks>
+ /// It is a requirement of the local store that a moved folder and all its sub-folder get a new
+ /// folder Id. Futher, this new Id number cannot have been used previously.
+ ///
+ /// Thus any existing folder Ids for the moved folder or its children obtained before the move may
+ /// be invalid and must be reaquired from the local store.
+ /// </remarks>
+ /// <param name="folderId">The Id of the folder to move.</param>
+ /// <param name="parentId">The Id of the new parent folder if any.</param>
+ /// <param name="newFolderName">
+ /// The new folder name. Note: this is <b>not</b> the full folder name or the qualified folder name.
+ /// </param>
+ /// <exception cref="System.Data.DuplicateNameException">If a folder with the same name already exists.</exception>
+ /// <exception cref="System.InvalidOperationException">Changes to the folder are not permitted.</exception>
+ /// <exception cref="System.ArgumentException">The folder Id or parent Id or folder name is invalid.</exception>
+ public void MoveFolder(int folderId, int? parentId, string newFolderName) {
using (ISession session = this.hibernateFactory.OpenSession()) {
using (ITransaction tx = session.BeginTransaction()) {
- StoreFolder folder = session.Load<StoreFolder>(folderId);
+ StoreFolder currentFolder = session.Load<StoreFolder>(folderId);
+ StoreFolder newFolder;
+ StoreFolder currentParent;
+ StoreFolder newParentFolder = null;
- throw new NotImplementedException();
+ if (currentFolder.ParentId.HasValue) {
+ currentParent = session.Load<StoreFolder>(currentFolder.ParentId.Value);
+ }
- if (folder.ChildIds.Count > 0) {
- // TODO: rename children
+ if (parentId.HasValue) {
+ newParentFolder = session.Load<StoreFolder>(parentId.Value);
}
+ // Setup the new folder
+ if (newParentFolder != null) {
+ newFolder = new StoreFolder(newParentFolder, newFolderName);
+ } else {
+ newFolder = new StoreFolder(currentFolder.NameSpace, newFolderName);
+ }
+ newFolder.ParentId = parentId;
+ newFolder.OwnerUserId = currentFolder.OwnerUserId;
+ // TODO: ACLs
+
+ session.Save(newFolder);
+
+ // Adjust the details of the child folders and move them across
+ MoveChildren(newFolder, currentFolder, session);
+
tx.Commit();
session.Close();
}
}
}
- public LocalStoreFolderResult RenameFolder(StoreFolder f, string s) {
- throw new NotImplementedException();
+ /// <summary>
+ /// Moves all child folders recursively to the new folder.
+ /// </summary>
+ /// <param name="newParent">The new parent folder.</param>
+ /// <param name="oldParent">The old parent folder.</param>
+ /// <param name="session">The session to use.</param>
+ protected void MoveChildren(StoreFolder newParent, StoreFolder oldParent, ISession session) {
+ // Ensure session has started a transaction
+ if (!session.Transaction.IsActive) {
+ throw new InvalidOperationException("A transaction is required for this operation.");
+ }
+
+ // Update each child recursively
+ foreach (int childId in oldParent.ChildIds) {
+ StoreFolder currentChild = session.Load<StoreFolder>(childId);
+
+ // Make a new child folder
+ StoreFolder newChild = new StoreFolder(newParent, currentChild.FolderName);
+ newChild.ParentId = newParent.FolderId;
+ newChild.OwnerUserId = currentChild.OwnerUserId;
+ // TODO: child ACLs
+ session.Save(newChild);
+
+ // Add the to parent
+ newParent.ChildIds.Add(newChild.FolderId);
+
+ // Recurse
+ MoveChildren(newChild, currentChild, session);
+ }
+
+ // Store all child Ids to the database
+ session.Update(newParent);
}
#endregion
@@ -991,6 +1063,10 @@
public void DeleteUser(int userId) {
using (ISession session = this.hibernateFactory.OpenSession()) {
using (ITransaction tx = session.BeginTransaction()) {
+ if (GetUserFolders(userId, session).Count > 0) {
+ throw new ConstraintException("Can't delete a user that still owns folders.");
+ }
+
LocalStoreUser user = session.Load<LocalStoreUser>(userId);
session.Delete(user);
@@ -1036,11 +1112,21 @@
/// <returns>The list of folders or null if the user Id is invalid.</returns>
public IList<StoreFolder> GetUserFolders(int userId) {
using (ISession session = this.hibernateFactory.OpenSession()) {
- return session.CreateCriteria(typeof(StoreFolder))
- .Add(Expression.Eq("OwnerUserId", userId))
- .List<StoreFolder>();
+ return GetUserFolders(userId, session);
}
}
+
+ /// <summary>
+ /// Gets a list of folders 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>
+ /// <param name="session">The session to use.</param>
+ /// <returns>The list of folders or null if the user Id is invalid.</returns>
+ protected IList<StoreFolder> GetUserFolders(int userId, ISession session) {
+ return session.CreateCriteria(typeof(StoreFolder))
+ .Add(Expression.Eq("OwnerUserId", userId))
+ .List<StoreFolder>();
+ }
#endregion
#endregion
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <tmy...@us...> - 2007-04-11 02:50:00
|
Revision: 181
http://svn.sourceforge.net/nmailserver/?rev=181&view=rev
Author: tmyroadctfig
Date: 2007-04-10 19:50:01 -0700 (Tue, 10 Apr 2007)
Log Message:
-----------
Added some debugger information.
Modified Paths:
--------------
NMail/trunk/NMail/DataTypes/Folder.cs
NMail/trunk/NMail/DataTypes/LocalStore/LocalStoreGroup.cs
NMail/trunk/NMail/DataTypes/LocalStore/LocalStoreUser.cs
NMail/trunk/NMail/DataTypes/LocalStore/StoreFolder.cs
Modified: NMail/trunk/NMail/DataTypes/Folder.cs
===================================================================
--- NMail/trunk/NMail/DataTypes/Folder.cs 2007-04-11 02:49:28 UTC (rev 180)
+++ NMail/trunk/NMail/DataTypes/Folder.cs 2007-04-11 02:50:01 UTC (rev 181)
@@ -16,6 +16,7 @@
*/
using System;
+using System.Diagnostics;
using NMail.Configuration;
@@ -24,6 +25,7 @@
/// Represents a folder in the local store.
/// </summary>
[Serializable]
+ [DebuggerDisplay("Folder: '{FullyQualifiedName}'")]
public class Folder {
#region Constructors
/// <summary>
Modified: NMail/trunk/NMail/DataTypes/LocalStore/LocalStoreGroup.cs
===================================================================
--- NMail/trunk/NMail/DataTypes/LocalStore/LocalStoreGroup.cs 2007-04-11 02:49:28 UTC (rev 180)
+++ NMail/trunk/NMail/DataTypes/LocalStore/LocalStoreGroup.cs 2007-04-11 02:50:01 UTC (rev 181)
@@ -17,6 +17,7 @@
using System;
using System.Collections.Generic;
+using System.Diagnostics;
using System.Text;
using NMail.DataTypes;
@@ -26,6 +27,7 @@
/// Represents a group in the local store.
/// </summary>
[Serializable]
+ [DebuggerDisplay("Group: '{Name}' Id:{GroupId}")]
public class LocalStoreGroup {
/// <summary>
/// Creates a new local store group.
Modified: NMail/trunk/NMail/DataTypes/LocalStore/LocalStoreUser.cs
===================================================================
--- NMail/trunk/NMail/DataTypes/LocalStore/LocalStoreUser.cs 2007-04-11 02:49:28 UTC (rev 180)
+++ NMail/trunk/NMail/DataTypes/LocalStore/LocalStoreUser.cs 2007-04-11 02:50:01 UTC (rev 181)
@@ -17,6 +17,7 @@
using System;
using System.Collections.Generic;
+using System.Diagnostics;
using System.Text;
using NMail.DataTypes;
@@ -26,6 +27,7 @@
/// Represents a user in the local store.
/// </summary>
[Serializable]
+ [DebuggerDisplay("User: '{Username}' Id:{UserId}")]
public class LocalStoreUser {
/// <summary>
/// Creates a new local store user.
Modified: NMail/trunk/NMail/DataTypes/LocalStore/StoreFolder.cs
===================================================================
--- NMail/trunk/NMail/DataTypes/LocalStore/StoreFolder.cs 2007-04-11 02:49:28 UTC (rev 180)
+++ NMail/trunk/NMail/DataTypes/LocalStore/StoreFolder.cs 2007-04-11 02:50:01 UTC (rev 181)
@@ -17,6 +17,7 @@
using System;
using System.Collections.Generic;
+using System.Diagnostics;
using NMail.Configuration;
using NMail.DataTypes;
@@ -26,6 +27,7 @@
/// A folder that has been obtained from the local store.
/// </summary>
[Serializable]
+ [DebuggerDisplay("StoreFolder: '{FullyQualifiedName}' Id:{FolderId}")]
public class StoreFolder : Folder {
/// <summary>
/// Creates a new store folder.
@@ -104,7 +106,7 @@
}
}
- private IList<int> childIds;
+ private IList<int> childIds = new List<int>();
/// <summary>
/// A list of child folder Ids.
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <tmy...@us...> - 2007-04-11 02:49:29
|
Revision: 180
http://svn.sourceforge.net/nmailserver/?rev=180&view=rev
Author: tmyroadctfig
Date: 2007-04-10 19:49:28 -0700 (Tue, 10 Apr 2007)
Log Message:
-----------
More work on NHibernate localstore data.
Modified Paths:
--------------
NMail/trunk/NMail.LocalStoreData.NHibernate/NHibernateLocalStoreData.cs
NMail/trunk/NMail.UnitTests/LocalStoreData/DeleteUserTest1.cs
Modified: NMail/trunk/NMail.LocalStoreData.NHibernate/NHibernateLocalStoreData.cs
===================================================================
--- NMail/trunk/NMail.LocalStoreData.NHibernate/NHibernateLocalStoreData.cs 2007-03-24 10:01:32 UTC (rev 179)
+++ NMail/trunk/NMail.LocalStoreData.NHibernate/NHibernateLocalStoreData.cs 2007-04-11 02:49:28 UTC (rev 180)
@@ -225,7 +225,10 @@
}
protected void CreateFolder(StoreFolder newFolder, ISession session) {
- // TODO: ensure session has started a transaction...
+ // Ensure session has started a transaction
+ if (!session.Transaction.IsActive) {
+ throw new InvalidOperationException("A transaction is required for this operation.");
+ }
// Validate owner user Id
LocalStoreUser user = session.Get<LocalStoreUser>(newFolder.OwnerUserId);
@@ -309,6 +312,8 @@
throw new InvalidOperationException("Folder still has children.");
}
+ DeleteChildrenWithoutUpdate(folder, session);
+
session.Delete(folder);
// Remove the folder from the parent's list of children if present
@@ -323,6 +328,30 @@
}
}
}
+
+ /// <summary>
+ /// Recursively delete's child folders without updating the parent folders
+ /// child Id list.
+ /// </summary>
+ /// <param name="folder">The folder to delete the children from.</param>
+ /// <param name="session">The session to use.</param>
+ protected void DeleteChildrenWithoutUpdate(StoreFolder folder, ISession session) {
+ // Ensure session has started a transaction
+ if (!session.Transaction.IsActive) {
+ throw new InvalidOperationException("A transaction is required for this operation.");
+ }
+
+ // Delete each child and sub-children
+ foreach (int childId in folder.ChildIds) {
+ StoreFolder child = session.Load<StoreFolder>(childId);
+
+ // Recurse down
+ DeleteChildrenWithoutUpdate(child, session);
+
+ // Delete the child at the current leve
+ session.Delete(child);
+ }
+ }
#endregion
#region RenameFolder
@@ -930,7 +959,7 @@
userFolder.NameSpace = DefaultNameSpace;
userFolder.FullFolderName = user.Username;
userFolder.OwnerUserId = user.UserId;
- CreateFolder(userFolder);
+ CreateFolder(userFolder, session);
// Create the user's folder
StoreFolder inboxFolder = new StoreFolder();
@@ -938,7 +967,7 @@
inboxFolder.FullFolderName = string.Format("{0}{1}{2}", user.Username, userFolder.Delimiter, Folder.Inbox);
inboxFolder.ParentId = userFolder.FolderId;
inboxFolder.OwnerUserId = user.UserId;
- CreateFolder(inboxFolder);
+ CreateFolder(inboxFolder, session);
// TODO: ACLs
Modified: NMail/trunk/NMail.UnitTests/LocalStoreData/DeleteUserTest1.cs
===================================================================
--- NMail/trunk/NMail.UnitTests/LocalStoreData/DeleteUserTest1.cs 2007-03-24 10:01:32 UTC (rev 179)
+++ NMail/trunk/NMail.UnitTests/LocalStoreData/DeleteUserTest1.cs 2007-04-11 02:49:28 UTC (rev 180)
@@ -32,7 +32,7 @@
foreach (StoreFolder folder in userFolders) {
try {
this.localStoreData.DeleteFolder(folder.FolderId, true);
- } catch (Exception ex) {
+ } catch (Exception) {
// Ignore, may be trying to delete a deleted sub-folder
}
}
@@ -41,7 +41,7 @@
IList<LocalStoreUser> users = this.localStoreData.GetUsers();
- Assert.AreEqual(0, users.Count, "Users.count == 0");
+ Assert.AreEqual(1, users.Count, "Users.count == 1");
}
}
}
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <tmy...@us...> - 2007-03-24 10:15:54
|
Revision: 178
http://svn.sourceforge.net/nmailserver/?rev=178&view=rev
Author: tmyroadctfig
Date: 2007-03-24 02:59:33 -0700 (Sat, 24 Mar 2007)
Log Message:
-----------
Work on NHibernate local store data. Changes to make interfaces more NHibernate friendly.
Modified Paths:
--------------
NMail/trunk/NMail/DataTypes/LocalStore/ILocalStore.cs
NMail/trunk/NMail/DataTypes/LocalStore/ILocalStoreData.cs
NMail/trunk/NMail/DataTypes/LocalStore/StoreFolder.cs
NMail/trunk/NMail.ImapService/State/AuthenticatedState.cs
NMail/trunk/NMail.LocalStore/LocalStore.cs
NMail/trunk/NMail.LocalStoreData.MySql/MySqlLocalStoreData.cs
NMail/trunk/NMail.LocalStoreData.NHibernate/Mappings/NMail.DataTypes.LocalStore.LocalStoreUser.hbm.xml
NMail/trunk/NMail.LocalStoreData.NHibernate/Mappings/NMail.DataTypes.LocalStore.StoreFolder.hbm.xml
NMail/trunk/NMail.LocalStoreData.NHibernate/NHibernateLocalStoreData.cs
NMail/trunk/NMail.LocalStoreData.NHibernate/hibernate-configuration.xml
NMail/trunk/NMail.RemoteAccessService.Serializers/DataTypes/LocalStore/StoreFolderSerializer.cs
NMail/trunk/NMail.Server.Console/NMail.Server.Console.csproj
Modified: NMail/trunk/NMail/DataTypes/LocalStore/ILocalStore.cs
===================================================================
--- NMail/trunk/NMail/DataTypes/LocalStore/ILocalStore.cs 2007-03-13 05:07:34 UTC (rev 177)
+++ NMail/trunk/NMail/DataTypes/LocalStore/ILocalStore.cs 2007-03-24 09:59:33 UTC (rev 178)
@@ -132,7 +132,7 @@
/// <param name="authToken">The authentication credentials.</param>
/// <param name="queryFolder">The query folder used in the lookup.</param>
/// <returns>The list of matching folders.</returns>
- StoreFolder[] GetMatching(IAuthenticationToken authToken, string queryFolder);
+ IList<StoreFolder> GetMatching(IAuthenticationToken authToken, string queryFolder);
/// <summary>
/// Gets a list of child folders for the given parent folder.
@@ -140,14 +140,14 @@
/// <param name="authToken">The authentication credentials.</param>
/// <param name="parent">The parent to get the children from.</param>
/// <returns>The list of folders.</returns>
- StoreFolder[] GetChildren(IAuthenticationToken authToken, StoreFolder parent);
+ IList<StoreFolder> GetChildren(IAuthenticationToken authToken, StoreFolder parent);
/// <summary>
/// Gets a list of all folders
/// </summary>
/// <param name="authToken">The authentication credentials.</param>
/// <returns>The list of folders.</returns>
- StoreFolder[] GetFolders(IAuthenticationToken authToken);
+ IList<StoreFolder> GetFolders(IAuthenticationToken authToken);
#endregion
#region Folder Subscription
@@ -157,7 +157,7 @@
/// <param name="authToken">The authentication credentials.</param>
/// <param name="queryFolder">The query folder used in the lookup.</param>
/// <returns>The list of folders.</returns>
- StoreFolder[] GetSubscribed(IAuthenticationToken authToken, string queryFolder);
+ IList<StoreFolder> GetSubscribed(IAuthenticationToken authToken, string queryFolder);
/// <summary>
/// Subscribes to a folder.
Modified: NMail/trunk/NMail/DataTypes/LocalStore/ILocalStoreData.cs
===================================================================
--- NMail/trunk/NMail/DataTypes/LocalStore/ILocalStoreData.cs 2007-03-13 05:07:34 UTC (rev 177)
+++ NMail/trunk/NMail/DataTypes/LocalStore/ILocalStoreData.cs 2007-03-24 09:59:33 UTC (rev 178)
@@ -72,15 +72,21 @@
/// It is a requirement of the local store that each new folder get an incremented Id number.
/// </remarks>
/// <param name="newFolder">The folder to create.</param>
- /// <returns>The result of the attempt to create the folder.</returns>
- LocalStoreFolderResult CreateFolder(int userId, StoreFolder parent, Folder newFolder);
+ /// <exception cref="System.Data.DuplicateNameException">If a folder with the same name already exists.</exception>
+ /// <exception cref="System.InvalidOperationException">Changes to the folder are not permitted.</exception>
+ /// <exception cref="System.ArgumentException">The folder is invalid.</exception>
+ void CreateFolder(StoreFolder newFolder);
/// <summary>
/// Deletes an existing folder.
/// </summary>
/// <param name="folderId">The Id of the folder to delete.</param>
- /// <returns>The result of the delete attempt.</returns>
- LocalStoreFolderResult DeleteFolder(int folderId);
+ /// <exception cref="System.InvalidOperationException">
+ /// Deleting the folder are not permitted or children are present but
+ /// 'deleteChildren' is false.
+ /// </exception>
+ /// <exception cref="System.ArgumentException">The folder is invalid.</exception>
+ void DeleteFolder(int folderId, bool deleteChildren);
/// <summary>
/// Renames an existing folder in the local store.
@@ -100,15 +106,15 @@
/// <summary>
/// Gets a list of child folders for the given parent folder.
/// </summary>
- /// <param name="parent">The parent to get the children from.</param>
+ /// <param name="parentId">The Id of the parent to get the children from.</param>
/// <returns>The list of folders.</returns>
- StoreFolder[] GetChildren(StoreFolder parent);
+ IList<StoreFolder> GetChildren(int parentId);
/// <summary>
/// Gets a list of all folders
/// </summary>
/// <returns>The list of folders.</returns>
- StoreFolder[] GetFolders();
+ IList<StoreFolder> GetFolders();
#endregion
#region Folder Subscription
@@ -117,7 +123,7 @@
/// </summary>
/// <param name="userName">The username to get the list of subscribed folders for.</param>
/// <returns>The list of folders.</returns>
- StoreFolder[] GetSubscribedFolders(string userName);
+ IList<StoreFolder> GetSubscribedFolders(string userName);
/// <summary>
/// Subscribes to a folder.
Modified: NMail/trunk/NMail/DataTypes/LocalStore/StoreFolder.cs
===================================================================
--- NMail/trunk/NMail/DataTypes/LocalStore/StoreFolder.cs 2007-03-13 05:07:34 UTC (rev 177)
+++ NMail/trunk/NMail/DataTypes/LocalStore/StoreFolder.cs 2007-03-24 09:59:33 UTC (rev 178)
@@ -36,33 +36,22 @@
/// Creates a new store folder.
/// </summary>
/// <param name="newFolder">The folder name.</param>
- /// <param name="folderId">The folder Id.</param>
- /// <param name="parentId">The Id of this folder's parent or null if non.</param>
- /// <param name="ownerUserId">The user that owns this folder.</param>
- /// <param name="hasChildren">A flag indicating if this folder has subfolder.s</param>
- public StoreFolder(string newFolder, int folderId, int? parentId, int ownerUserId, bool hasChildren) : base(newFolder) {
- this.folderId = folderId;
- this.parentId = parentId;
- this.ownerUserId = ownerUserId;
- this.hasChildren = hasChildren;
- }
+ public StoreFolder(string newFolder) : base(newFolder) { }
/// <summary>
/// Creates a new store folder.
/// </summary>
/// <param name="newNameSpace">The namespace the folder belongs to.</param>
/// <param name="newFolder">The folder name.</param>
- /// <param name="folderId">The folder Id.</param>
- /// <param name="parentId">The Id of this folder's parent or null if non.</param>
- /// <param name="ownerUserId">The user that owns this folder.</param>
- /// <param name="hasChildren">A flag indicating if this folder has subfolder.s</param>
- public StoreFolder(string newNameSpace, string newFolder, int folderId, int? parentId, int ownerUserId, bool hasChildren) : base(newNameSpace, newFolder) {
- this.folderId = folderId;
- this.parentId = parentId;
- this.ownerUserId = ownerUserId;
- this.hasChildren = hasChildren;
- }
+ public StoreFolder(string newNameSpace, string newFolder) : base(newNameSpace, newFolder) { }
+ /// <summary>
+ /// Creates a new store folder.
+ /// </summary>
+ /// <param name="parent">The parent folder.</param>
+ /// <param name="childName">The name of this folder.</param>
+ public StoreFolder(Folder parent, string childName) : base(parent, childName) { }
+
private int folderId;
/// <summary>
@@ -80,7 +69,7 @@
private int? parentId;
/// <summary>
- /// The Id of this folder's parent or null if non.
+ /// The Id of this folder's parent or null if none.
/// </summary>
public int? ParentId {
get {
@@ -115,11 +104,14 @@
}
}
- private IList<int> childrenIds;
+ private IList<int> childIds;
- public IList<int> ChildrenIds {
- get { return childrenIds; }
- set { childrenIds = value; }
+ /// <summary>
+ /// A list of child folder Ids.
+ /// </summary>
+ public IList<int> ChildIds {
+ get { return childIds; }
+ set { childIds = value; }
}
}
}
Modified: NMail/trunk/NMail.ImapService/State/AuthenticatedState.cs
===================================================================
--- NMail/trunk/NMail.ImapService/State/AuthenticatedState.cs 2007-03-13 05:07:34 UTC (rev 177)
+++ NMail/trunk/NMail.ImapService/State/AuthenticatedState.cs 2007-03-24 09:59:33 UTC (rev 178)
@@ -54,7 +54,7 @@
try {
if (cmd.Folder.EndsWith("*")) {
// Get a list of folders that match the search string
- StoreFolder[] matches =
+ IList<StoreFolder> matches =
LocalStore.GetMatching(Session.AuthenticationToken, cmd.Folder);
// Output each matching folder to the client
@@ -85,7 +85,7 @@
if (folder.HasChildren) {
// Get a list of child folders
- StoreFolder[] children =
+ IList<StoreFolder> children =
LocalStore.GetChildren(Session.AuthenticationToken, folder);
// Output each matching folder to the client
@@ -116,7 +116,7 @@
// TODO: wildcards
// Get a list of subscribed folders
- StoreFolder[] subscribed =
+ IList<StoreFolder> subscribed =
LocalStore.GetSubscribed(Session.AuthenticationToken, cmd.Folder);
// Output each matching folder to the client
Modified: NMail/trunk/NMail.LocalStore/LocalStore.cs
===================================================================
--- NMail/trunk/NMail.LocalStore/LocalStore.cs 2007-03-13 05:07:34 UTC (rev 177)
+++ NMail/trunk/NMail.LocalStore/LocalStore.cs 2007-03-24 09:59:33 UTC (rev 178)
@@ -364,14 +364,13 @@
}
// Create the mailbox
- LocalStoreFolderResult result = LocalStoreData.CreateFolder(user.UserId, parent, resolvedFolder);
- if (result != LocalStoreFolderResult.OkSuccessful) {
- return result;
- }
+ StoreFolder createdFolder = new StoreFolder();
+ createdFolder.ParentId = parent.ParentId;
+ createdFolder.NameSpace = resolvedFolder.NameSpace;
+ createdFolder.FullFolderName = resolvedFolder.FullFolderName;
+ createdFolder.OwnerUserId = user.UserId;
+ LocalStoreData.CreateFolder(createdFolder);
- // Get the folder
- StoreFolder createdFolder = LocalStoreData.GetStoreFolder(resolvedFolder);
-
// Create an ACL for the folder
GenericAce<StoreFolderPrivilege> ace = new GenericAce<StoreFolderPrivilege>(authToken.Username, StoreFolderPrivilegeHelper.AllPrivileges, AcePrivilegeType.Allow);
LocalStoreData.SetStoreFolderAce(createdFolder, ace);
@@ -408,7 +407,8 @@
if (hasFolderPrivilege(authToken.Username, folderId, StoreFolderPrivilege.Delete)) {
// Delete the folder
- return LocalStoreData.DeleteFolder(folderId);
+ throw new NotImplementedException("Need to adjust localstore iface before implementing...");
+ //return LocalStoreData.DeleteFolder(folderId);
} else {
return LocalStoreFolderResult.NotPermitted;
@@ -421,7 +421,7 @@
/// </summary>
/// <param name="authToken">The authentication credentials.</param>
/// <returns>The list of folders.</returns>
- public StoreFolder[] GetFolders(IAuthenticationToken authToken) {
+ public IList<StoreFolder> GetFolders(IAuthenticationToken authToken) {
// TODO: check for admin ACLs
return LocalStoreData.GetFolders();
@@ -469,12 +469,12 @@
/// <param name="authToken">The authentication credentials.</param>
/// <param name="queryFolder">The query folder used in the lookup.</param>
/// <returns>The list of matching folders.</returns>
- public StoreFolder[] GetMatching(IAuthenticationToken authToken, string queryFolder) {
+ public IList<StoreFolder> GetMatching(IAuthenticationToken authToken, string queryFolder) {
// TODO: handle wildcards in the middle of mailbox names, e.g "A*" matches "Ab" and "Ac.d"
// TODO: filter out any folders that the user can't see due to ACLs
StoreFolder resolvedFolder = GetStoreFolder(authToken, queryFolder);
- ArrayList result = new ArrayList();
+ List<StoreFolder> result = new List<StoreFolder>();
if (resolvedFolder != GetNominalStoreFolder(authToken)) {
result.Add(resolvedFolder);
}
@@ -483,7 +483,7 @@
GetDescendants(authToken, resolvedFolder, result);
// Return the list of matching folders
- return (StoreFolder[]) result.ToArray(typeof(StoreFolder));
+ return result;
}
/// <summary>
@@ -492,9 +492,9 @@
/// <param name="authToken">The authentication credentials.</param>
/// <param name="parent">The parent to get the children from.</param>
/// <returns>The list of folders.</returns>
- private void GetDescendants(IAuthenticationToken authToken, StoreFolder parent, ArrayList result) {
+ private void GetDescendants(IAuthenticationToken authToken, StoreFolder parent, IList<StoreFolder> result) {
// Get a list of folders for this parent
- StoreFolder[] children = GetChildren(authToken, parent);
+ IList<StoreFolder> children = GetChildren(authToken, parent);
foreach (StoreFolder child in children) {
// Add the current child and get any descendants
@@ -513,17 +513,17 @@
/// <param name="authToken">The authentication credentials</param>
/// <param name="parent">The parent to get the children from.</param>
/// <returns>The list of folders.</returns>
- public StoreFolder[] GetChildren(IAuthenticationToken authToken, StoreFolder parent) {
+ public IList<StoreFolder> GetChildren(IAuthenticationToken authToken, StoreFolder parent) {
// Ensure the user has rights to list the folders
if (parent != null
&& hasFolderPrivilege(authToken.Username, parent.FolderId, StoreFolderPrivilege.Lookup)) {
// Return the children
- return LocalStoreData.GetChildren(parent);
+ return LocalStoreData.GetChildren(parent.FolderId);
} else {
- return new StoreFolder[0];
+ return new List<StoreFolder>();
}
}
#endregion
@@ -537,7 +537,7 @@
/// <param name="authToken">The authentication credentials.</param>
/// <param name="queryFolder">The query folder used in the lookup.</param>
/// <returns>The list of folders.</returns>
- public StoreFolder[] GetSubscribed(IAuthenticationToken authToken, string queryFolder) {
+ public IList<StoreFolder> GetSubscribed(IAuthenticationToken authToken, string queryFolder) {
// TODO: handle wildcards in the middle of mailbox names, e.g "A*" matches "Ab" and "Ac.d"
Folder folder = GetStoreFolder(authToken, queryFolder);
MatchMode matchMode = MatchMode.Single;
@@ -547,8 +547,8 @@
matchMode = MatchMode.Children;
// Filter out unsubscribed folders from the list
- ArrayList result = new ArrayList();
- StoreFolder[] subscribedFolders = LocalStoreData.GetSubscribedFolders(authToken.Username);
+ IList<StoreFolder> result = new List<StoreFolder>();
+ IList<StoreFolder> subscribedFolders = LocalStoreData.GetSubscribedFolders(authToken.Username);
foreach (StoreFolder currentFolder in subscribedFolders) {
if (matchMode == MatchMode.Single) {
if (currentFolder == folder) {
@@ -567,7 +567,7 @@
}
// Return the list of matching folders
- return (StoreFolder[]) result.ToArray(typeof(StoreFolder));
+ return result;
}
private enum MatchMode { Children, Descendants, Single };
Modified: NMail/trunk/NMail.LocalStoreData.MySql/MySqlLocalStoreData.cs
===================================================================
--- NMail/trunk/NMail.LocalStoreData.MySql/MySqlLocalStoreData.cs 2007-03-13 05:07:34 UTC (rev 177)
+++ NMail/trunk/NMail.LocalStoreData.MySql/MySqlLocalStoreData.cs 2007-03-24 09:59:33 UTC (rev 178)
@@ -248,12 +248,13 @@
int ownerUserId = (int) cmd.Parameters["OwnerUserId"].Value;
// Return the folder object
- return new StoreFolder(nameSpace,
- name,
- folderId,
- parentId,
- ownerUserId,
- (children != 0));
+ StoreFolder folder = new StoreFolder(nameSpace, name);
+ folder.FolderId = folderId;
+ folder.ParentId = parentId;
+ folder.OwnerUserId = ownerUserId;
+ folder.HasChildren = (children != 0);
+
+ return folder;
}
}
}
@@ -268,17 +269,15 @@
/// </remarks>
/// <param name="newFolder">The folder to create.</param>
/// <returns>The result of the attempt to create the folder.</returns>
- public LocalStoreFolderResult CreateFolder(int userId, StoreFolder parent, Folder newFolder) {
+ public void CreateFolder(StoreFolder newFolder) {
using (MySqlConnection cnn = MySqlHelper.GetConnection()) {
using (MySqlCommand cmd = cnn.CreateCommand()) {
- int? parentFolderId = (parent == null) ? null : (int?) parent.FolderId;
-
cmd.CommandType = CommandType.StoredProcedure;
cmd.CommandText = "CreateFolder";
- cmd.Parameters.Add("?ParentId", parentFolderId);
+ cmd.Parameters.Add("?ParentId", newFolder.ParentId);
cmd.Parameters.Add("?NamespaceId", 1);
cmd.Parameters.Add("?Name", newFolder.FullFolderName);
- cmd.Parameters.Add("?UserId", userId);
+ cmd.Parameters.Add("?UserId", newFolder.OwnerUserId);
cmd.Parameters.Add("?FolderId", MySqlDbType.Int32);
cmd.Parameters.Add("?Result", MySqlDbType.Int32);
cmd.Parameters["FolderId"].Direction = ParameterDirection.Output;
@@ -286,9 +285,11 @@
cmd.ExecuteNonQuery();
- int result = (int) cmd.Parameters["Result"].Value;
+ LocalStoreFolderResult result = (LocalStoreFolderResult)((int) cmd.Parameters["Result"].Value);
- return (LocalStoreFolderResult) result;
+ if (result == LocalStoreFolderResult.AlreadyExists) {
+ throw new DuplicateNameException("Folder with the same name already exists.");
+ }
}
}
}
@@ -300,9 +301,14 @@
/// </summary>
/// <param name="authToken">The authentication credentials.</param>
/// <param name="folderId">The Id of the folder to delete.</param>
+ /// <param name="deleteChildren">True if the folders children should be deleted as well.</param>
/// <returns>The result of the delete attempt.</returns>
- public LocalStoreFolderResult DeleteFolder(int folderId) {
+ public void DeleteFolder(int folderId, bool deleteChildren) {
using (MySqlConnection cnn = MySqlHelper.GetConnection()) {
+ if (deleteChildren) {
+ throw new NotImplementedException();
+ }
+
using (MySqlCommand cmd = cnn.CreateCommand()) {
cmd.CommandType = CommandType.StoredProcedure;
cmd.CommandText = "DeleteFolder";
@@ -312,9 +318,13 @@
cmd.ExecuteNonQuery();
- int result = (int) cmd.Parameters["?Result"].Value;
+ LocalStoreFolderResult result = (LocalStoreFolderResult)((int) cmd.Parameters["?Result"].Value);
- return (LocalStoreFolderResult) result;
+ if (result == LocalStoreFolderResult.HasChildren) {
+ throw new ConstraintException("Folder still has sub-folders.");
+ } else if (result == LocalStoreFolderResult.NonExistent) {
+ throw new ArgumentException("No such folder.");
+ }
}
}
}
@@ -369,12 +379,12 @@
#endregion
#region GetChildren
- public StoreFolder[] GetChildren(StoreFolder parent) {
+ public IList<StoreFolder> GetChildren(int parentId) {
using (MySqlConnection cnn = MySqlHelper.GetConnection()) {
using (MySqlCommand cmd = cnn.CreateCommand()) {
cmd.CommandType = CommandType.StoredProcedure;
cmd.CommandText = "GetFolderChildIds";
- cmd.Parameters.Add("?FolderId", parent.FolderId);
+ cmd.Parameters.Add("?FolderId", parentId);
using (MySqlDataReader reader = cmd.ExecuteReader()) {
List<int> childIds = new List<int>();
@@ -396,7 +406,7 @@
}
}
- return children.ToArray();
+ return children;
}
}
}
@@ -407,7 +417,7 @@
/// Gets a list of all folders
/// </summary>
/// <returns>The list of folders.</returns>
- public StoreFolder[] GetFolders() {
+ public IList<StoreFolder> GetFolders() {
using (MySqlConnection cnn = MySqlHelper.GetConnection()) {
using (MySqlCommand cmd = cnn.CreateCommand()) {
cmd.CommandType = CommandType.StoredProcedure;
@@ -426,7 +436,12 @@
int ownerUserId = (int) reader["OwnerUserId"];
// TODO: Get HasChildren from the reader
- folders.Add(new StoreFolder(nameSpace, name, folderId, parentId, ownerUserId, false));
+
+ StoreFolder folder = new StoreFolder(nameSpace, name);
+ folder.FolderId = folderId;
+ folder.ParentId = parentId;
+ folder.OwnerUserId = ownerUserId;
+ folders.Add(folder);
}
return folders.ToArray();
@@ -438,7 +453,7 @@
#region Folder Subscription
#region GetSubscribedFolders
- public StoreFolder[] GetSubscribedFolders(string userName) {
+ public IList<StoreFolder> GetSubscribedFolders(string userName) {
using (MySqlConnection cnn = MySqlHelper.GetConnection()) {
using (MySqlCommand cmd = cnn.CreateCommand()) {
cmd.CommandText = "SELECT s.FolderId AS FolderId FROM User u, Subscription s WHERE s.UserId = u.UserId AND u.UserName = ?UserName";
@@ -1178,7 +1193,11 @@
: (int?) reader["ParentFolderId"];
// TODO: Get HasChildren from the reader
- folders.Add(new StoreFolder(nameSpace, name, folderId, parentId, userId, false));
+ StoreFolder folder = new StoreFolder(nameSpace, name);
+ folder.FolderId = folderId;
+ folder.ParentId = parentId;
+ folder.OwnerUserId = userId;
+ folders.Add(folder);
}
return folders;
Modified: NMail/trunk/NMail.LocalStoreData.NHibernate/Mappings/NMail.DataTypes.LocalStore.LocalStoreUser.hbm.xml
===================================================================
--- NMail/trunk/NMail.LocalStoreData.NHibernate/Mappings/NMail.DataTypes.LocalStore.LocalStoreUser.hbm.xml 2007-03-13 05:07:34 UTC (rev 177)
+++ NMail/trunk/NMail.LocalStoreData.NHibernate/Mappings/NMail.DataTypes.LocalStore.LocalStoreUser.hbm.xml 2007-03-24 09:59:33 UTC (rev 178)
@@ -9,7 +9,8 @@
<property name="Username" not-null="true"/>
- <many-to-one name="UserFolderId" class="NMail.DataTypes.LocalStore.StoreFolder" foreign-key="FolderId" />
+ <!-- TODO: ideally this would be a many-to-one relationship with StoreFolder -->
+ <property name="UserFolderId" />
<property name="QuotaHardLimit" />
Modified: NMail/trunk/NMail.LocalStoreData.NHibernate/Mappings/NMail.DataTypes.LocalStore.StoreFolder.hbm.xml
===================================================================
--- NMail/trunk/NMail.LocalStoreData.NHibernate/Mappings/NMail.DataTypes.LocalStore.StoreFolder.hbm.xml 2007-03-13 05:07:34 UTC (rev 177)
+++ NMail/trunk/NMail.LocalStoreData.NHibernate/Mappings/NMail.DataTypes.LocalStore.StoreFolder.hbm.xml 2007-03-24 09:59:33 UTC (rev 178)
@@ -11,16 +11,16 @@
<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?" />-->
+ <!-- TODO: ideally this would be a many-to-one relationship with StoreFolder -->
+ <property name="ParentId" type="System.Int32" />
- <many-to-one name="OwnerUserId" class="NMail.DataTypes.LocalStore.LocalStoreUser" foreign-key="UserId"/>
+ <!-- TODO: ideally this would be a many-to-one relationship with LocalStoreUser -->
+ <property name="OwnerUserId" not-null="true" />
- <list name="ChildrenIds" cascade="all">
+ <list name="ChildIds" cascade="all" table="FolderChildren">
<key column="FolderId" />
<index column="ChildIndex" type="Int32" />
- <one-to-many class="NMail.DataTypes.LocalStore.StoreFolder" />
+ <element column="ChildId" type="Int32" />
</list>
</class>
Modified: NMail/trunk/NMail.LocalStoreData.NHibernate/NHibernateLocalStoreData.cs
===================================================================
--- NMail/trunk/NMail.LocalStoreData.NHibernate/NHibernateLocalStoreData.cs 2007-03-13 05:07:34 UTC (rev 177)
+++ NMail/trunk/NMail.LocalStoreData.NHibernate/NHibernateLocalStoreData.cs 2007-03-24 09:59:33 UTC (rev 178)
@@ -47,7 +47,7 @@
public NHibernateLocalStoreData() {
this.hibernateCfg = new global::NHibernate.Cfg.Configuration();
- this.hibernateCfg.Configure(System.Reflection.Assembly.GetExecutingAssembly(), "NMail.LocalStoreData.MySql.Resources.hibernate-configuration.xml");
+ this.hibernateCfg.Configure(System.Reflection.Assembly.GetExecutingAssembly(), "NMail.LocalStoreData.NHibernate.hibernate-configuration.xml");
this.hibernateCfg.AddAssembly("NMail.LocalStoreData.NHibernate");
this.hibernateFactory = this.hibernateCfg.BuildSessionFactory();
@@ -176,229 +176,199 @@
#region Folder Retrieval and Manipulation
#region GetStoreFolder
+ /// <summary>
+ /// Gets the store folder from the given folder name.
+ /// </summary>
+ /// <param name="folder">The folder to lookup.</param>
+ /// <returns>The store folder or null if the folder name is invalid.</returns>
+ public StoreFolder GetStoreFolder(Folder folder) {
+ using (ISession session = this.hibernateFactory.OpenSession()) {
+ return session.CreateCriteria(typeof(StoreFolder))
+ .Add(Expression.Like("NameSpace", folder.NameSpace))
+ .Add(Expression.Like("FullFolderName", folder.FullFolderName))
+ .UniqueResult<StoreFolder>();
+ }
+ }
- //private StoreFolder getStoreFolder(Folder folder, MySqlConnection cnn, MySqlTransaction transaction) {
- // using (MySqlCommand cmd = cnn.CreateCommand()) {
- // cmd.Transaction = transaction;
- // cmd.CommandType = CommandType.StoredProcedure;
- // cmd.CommandText = "GetFolderId";
- // cmd.Parameters.Add("?FolderId", MySqlDbType.Int32);
- // cmd.Parameters.Add("?Name", folder.FullFolderName);
- // cmd.Parameters.Add("?NameSpace", folder.NameSpace);
- // cmd.Parameters["FolderId"].Direction = ParameterDirection.Output;
+ /// <summary>
+ /// Gets the store folder from the given folder Id.
+ /// </summary>
+ /// <param name="folderId">The Id of the folder to lookup.</param>
+ /// <returns>The store folder or null if the folder Id is invalid.</returns>
+ public StoreFolder GetStoreFolder(int folderId) {
+ using (ISession session = this.hibernateFactory.OpenSession()) {
+ return session.Load<StoreFolder>(folderId);
+ }
+ }
+ #endregion
- // int count = cmd.ExecuteNonQuery();
+ #region CreateFolder
+ /// <summary>
+ /// Creates a new folder.
+ /// </summary>
+ /// <remarks>
+ /// It is a requirement of the local store that each new folder get an incremented Id number.
+ /// </remarks>
+ /// <param name="newFolder">The folder to create.</param>
+ /// <exception cref="System.Data.DuplicateNameException">If a folder with the same name already exists.</exception>
+ /// <exception cref="System.InvalidOperationException">Changes to the folder are not permitted.</exception>
+ /// <exception cref="System.ArgumentException">The folder is invalid.</exception>
+ public void CreateFolder(StoreFolder newFolder) {
+ using (ISession session = this.hibernateFactory.OpenSession()) {
+ using (ITransaction tx = session.BeginTransaction()) {
+ CreateFolder(newFolder, session);
- // object o = cmd.Parameters["FolderId"].Value;
- // int? folderId = (o == DBNull.Value) ? null : (int?) o;
+ tx.Commit();
+ session.Close();
+ }
+ }
+ }
- // if (folderId.HasValue) {
- // return GetStoreFolder(folderId.Value);
- // } else {
- // return null;
- // }
- // }
- //}
+ protected void CreateFolder(StoreFolder newFolder, ISession session) {
+ // TODO: ensure session has started a transaction...
+
+ // Validate owner user Id
+ LocalStoreUser user = session.Get<LocalStoreUser>(newFolder.OwnerUserId);
- public StoreFolder GetStoreFolder(Folder folder) {
- //using (MySqlConnection cnn = MySqlHelper.GetConnection()) {
- // return getStoreFolder(folder, cnn, null);
- //}
- throw new NotImplementedException();
- }
-
- public StoreFolder GetStoreFolder(int folderId) {
- //using (MySqlConnection cnn = MySqlHelper.GetConnection()) {
- // using (MySqlCommand cmd = cnn.CreateCommand()) {
- // cmd.CommandType = CommandType.StoredProcedure;
- // cmd.CommandText = "GetFolder";
- // cmd.Parameters.Add("?FolderId", folderId);
- // cmd.Parameters.Add("?ParentId", MySqlDbType.Int32);
- // cmd.Parameters.Add("?Name", MySqlDbType.VarChar);
- // cmd.Parameters.Add("?NameSpace", MySqlDbType.VarChar);
- // cmd.Parameters.Add("?Children", MySqlDbType.Int32);
- // cmd.Parameters.Add("?Result", MySqlDbType.Int32);
- // cmd.Parameters["ParentId"].Direction = ParameterDirection.Output;
- // cmd.Parameters["Name"].Direction = ParameterDirection.Output;
- // cmd.Parameters["NameSpace"].Direction = ParameterDirection.Output;
- // cmd.Parameters["Children"].Direction = ParameterDirection.Output;
- // cmd.Parameters["Result"].Direction = ParameterDirection.Output;
+ if (user == null) {
+ throw new ArgumentException("Invalid user Id.", "UserId");
+ }
- // cmd.ExecuteNonQuery();
+ StoreFolder parentByName = null;
- // int resultValue = (int) cmd.Parameters["Result"].Value;
- // LocalStoreFolderResult result = (LocalStoreFolderResult) resultValue;
+ // Validate parent details
+ if (newFolder.Parent != null) {
+ // Lookup the parent Id
+ parentByName = session.CreateCriteria(typeof(StoreFolder))
+ .Add(Expression.Like("FullFolderName", newFolder.Parent.FullFolderName))
+ .UniqueResult<StoreFolder>();
- // // Check if the lookup succeeded
- // if (result != LocalStoreFolderResult.OkSuccessful) {
- // return null;
- // }
+ if (parentByName == null) {
+ throw new InvalidOperationException("Can't find a valid parent folder.");
+ }
- // // Parse out all the returned values
- // string name = (string) cmd.Parameters["Name"].Value;
- // string nameSpace = (string) cmd.Parameters["NameSpace"].Value;
- // int children = (int) cmd.Parameters["Children"].Value;
- // int? parentId = (cmd.Parameters["ParentId"].Value == DBNull.Value)
- // ? null
- // : (int?) cmd.Parameters["ParentId"].Value;
+ if (newFolder.ParentId == null) {
+ // Link the child with the parent by Id
+ newFolder.ParentId = parentByName.FolderId;
- // // Return the folder object
- // return new StoreFolder(nameSpace,
- // name,
- // folderId,
- // parentId,
- // (children != 0));
- // }
- //}
- throw new NotImplementedException();
- }
- #endregion
+ } else {
+ // Check the parent name matches the parent Id
+ if (newFolder.ParentId != parentByName.FolderId) {
+ throw new ArgumentException("Parent Id doesn't match parent name.", "ParentId");
+ }
+ }
- #region CreateFolder
- /// <summary>
- /// Creates a new folder.
- /// </summary>
- /// <remarks>
- /// It is a requirement of the local store that each new folder get an incremented Id number.
- /// </remarks>
- /// <param name="newFolder">The folder to create.</param>
- /// <returns>The result of the attempt to create the folder.</returns>
- public LocalStoreFolderResult CreateFolder(int userId, StoreFolder parent, Folder newFolder) {
- //using (MySqlConnection cnn = MySqlHelper.GetConnection()) {
- // using (MySqlCommand cmd = cnn.CreateCommand()) {
- // int? parentFolderId = (parent == null) ? null : (int?) parent.FolderId;
+ } else if (newFolder.ParentId != null) {
+ throw new InvalidOperationException("Parent Id specified but folder is at the top level.");
- // cmd.CommandType = CommandType.StoredProcedure;
- // cmd.CommandText = "CreateFolder";
- // cmd.Parameters.Add("?ParentId", parentFolderId);
- // cmd.Parameters.Add("?NamespaceId", 1);
- // cmd.Parameters.Add("?Name", newFolder.FullFolderName);
- // cmd.Parameters.Add("?UserId", userId);
- // cmd.Parameters.Add("?FolderId", MySqlDbType.Int32);
- // cmd.Parameters.Add("?Result", MySqlDbType.Int32);
- // cmd.Parameters["FolderId"].Direction = ParameterDirection.Output;
- // cmd.Parameters["Result"].Direction = ParameterDirection.Output;
-
- // cmd.ExecuteNonQuery();
+ } else {
+ // Folder has no parent or parent Id, no action required
+ }
- // int result = (int) cmd.Parameters["Result"].Value;
+ // Check for any folders with the same name
+ IList<StoreFolder> matching = session.CreateCriteria(typeof(StoreFolder))
+ .Add(Expression.Eq("ParentId", newFolder.ParentId))
+ .Add(Expression.Like("FullFolderName", newFolder.FullFolderName))
+ .List<StoreFolder>();
- // return (LocalStoreFolderResult) result;
- // }
- //}
- throw new NotImplementedException();
+ if (matching.Count > 0) {
+ throw new DuplicateNameException("Folder with the same name already exists.");
+ }
+
+ // Checks done, save!
+ session.Save(newFolder);
+
+ // Add the new folder to the parent's children
+ if (parentByName != null) {
+ parentByName.ChildIds.Add(newFolder.FolderId);
+ session.Update(parentByName);
+ }
}
#endregion
#region DeleteFolder
/// <summary>
- /// Deletes an existing folder.
- /// </summary>
- /// <param name="authToken">The authentication credentials.</param>
- /// <param name="folderId">The Id of the folder to delete.</param>
- /// <returns>The result of the delete attempt.</returns>
- public LocalStoreFolderResult DeleteFolder(int folderId) {
- //using (MySqlConnection cnn = MySqlHelper.GetConnection()) {
- // using (MySqlCommand cmd = cnn.CreateCommand()) {
- // cmd.CommandType = CommandType.StoredProcedure;
- // cmd.CommandText = "DeleteFolder";
- // cmd.Parameters.Add("?DeleteFolderId", folderId);
- // cmd.Parameters.Add("?Result", MySqlDbType.Int32);
- // cmd.Parameters["Result"].Direction = ParameterDirection.Output;
+ /// Deletes an existing folder.
+ /// </summary>
+ /// <param name="folderId">The Id of the folder to delete.</param>
+ /// <exception cref="System.InvalidOperationException">
+ /// Deleting the folder are not permitted or children are present but
+ /// 'deleteChildren' is false.
+ /// </exception>
+ /// <exception cref="System.ArgumentException">The folder is invalid.</exception>
+ public void DeleteFolder(int folderId, bool deleteChildren) {
+ using (ISession session = this.hibernateFactory.OpenSession()) {
+ using (ITransaction tx = session.BeginTransaction()) {
+ StoreFolder folder = session.Get<StoreFolder>(folderId);
- // cmd.ExecuteNonQuery();
+ if (folder == null) {
+ throw new ArgumentException("Invalid folder Id.", "folderId");
+ }
- // int result = (int) cmd.Parameters["Result"].Value;
+ if (!deleteChildren && folder.ChildIds.Count > 0) {
+ throw new InvalidOperationException("Folder still has children.");
+ }
- // return (LocalStoreFolderResult) result;
- // }
- //}
- throw new NotImplementedException();
+ session.Delete(folder);
+
+ // Remove the folder from the parent's list of children if present
+ if (folder.ParentId != null) {
+ StoreFolder parent = session.Load<StoreFolder>(folder.ParentId);
+ parent.ChildIds.Remove(folderId);
+ session.Update(parent);
+ }
+
+ tx.Commit();
+ session.Close();
+ }
+ }
}
#endregion
#region RenameFolder
- public LocalStoreFolderResult RenameFolder(StoreFolder folder, string newFolderName) {
- ///* Several cases:
- // * a1.b1 -> a1.b2 => simply rename "a1.b1" to "a1.b2"
- // * a1.b1 -> a2.b1 => rename "a1" to "a2" and "a1.b1" to "a2.b1"
- // * a1.b1.c1 -> a1.b2.c1 => rename "a1.b1" to "a1.b2" and "a1.b1.c1" to "a1.b2.c1"
- // * So simply rename the folder and any children.
- // *
- // * Also renaming "a1.b1" to "a2.b2" causes problems so renaming will be limited
- // * to only allow changing the end folder in the hierarchy. For example:
- // * a1.b1 -> a1.b2 is ok
- // * a1 -> a2 is ok
- // * a1.b1 to a2.b1 is not ok
- // */
+ public void RenameFolder(int folderId, Folder newFolderName) {
+ using (ISession session = this.hibernateFactory.OpenSession()) {
+ using (ITransaction tx = session.BeginTransaction()) {
+ StoreFolder folder = session.Load<StoreFolder>(folderId);
- //// Check only the top level folder is being renamed
- //char[] delim = { NMailConfiguration.Current.LocalStore.FolderDelimiter };
- //string[] folderParts = folder.FullFolderName.Split(delim);
- //string[] newParts = newFolderName.Split(delim);
+ throw new NotImplementedException();
- //if (folderParts.Length != newParts.Length) {
- // return LocalStoreFolderResult.NotPermitted;
- //}
+ if (folder.ChildIds.Count > 0) {
+ // TODO: rename children
+ }
- //for (int i = 0; i < folderParts.Length - 1; i++) {
- // if (!folderParts[i].ToLower().Equals(newParts[i].ToLower())) {
- // return LocalStoreFolderResult.NotPermitted;
- // }
- //}
+ tx.Commit();
+ session.Close();
+ }
+ }
+ }
- //// Only the last part of the folder name has changed, proceed with the rename
- //using (MySqlConnection cnn = MySqlHelper.GetConnection()) {
- // MySqlTransaction transaction = cnn.BeginTransaction();
-
- // // Check for a folder with the same name
- // Folder newFolder = new Folder(folder.NameSpace, newFolderName);
- // if (getStoreFolder(newFolder, cnn, transaction) != null) {
- // transaction.Commit();
- // return LocalStoreFolderResult.AlreadyExists;
- // }
-
- // throw new NotImplementedException();
- // // TODO: rename the folder
- // // TODO: recursively rename all children
- //}
+ public LocalStoreFolderResult RenameFolder(StoreFolder f, string s) {
throw new NotImplementedException();
}
#endregion
- #region GetChildren
- public StoreFolder[] GetChildren(StoreFolder parent) {
- //using (MySqlConnection cnn = MySqlHelper.GetConnection()) {
- // using (MySqlCommand cmd = cnn.CreateCommand()) {
- // cmd.CommandType = CommandType.StoredProcedure;
- // cmd.CommandText = "GetFolderChildIds";
- // cmd.Parameters.Add("?FolderId", parent.FolderId);
+ #region Get Children
+ /// <summary>
+ /// Gets a list of child folders for the given parent folder.
+ /// </summary>
+ /// <param name="parentId">The Id of the parent to get the children from.</param>
+ /// <returns>The list of folders.</returns>
+ public IList<StoreFolder> GetChildren(int parentId) {
+ using (ISession session = this.hibernateFactory.OpenSession()) {
+ using (ITransaction tx = session.BeginTransaction()) {
+ StoreFolder folder = session.Load<StoreFolder>(parentId);
- // using (MySqlDataReader reader = cmd.ExecuteReader()) {
- // List<int> childIds = new List<int>();
-
- // while (reader.Read()) {
- // int childFolderId = (int)reader["FolderId"];
- // childIds.Add(childFolderId);
- // }
-
- // reader.Close();
+ IList<StoreFolder> result = session.CreateCriteria(typeof(StoreFolder))
+ .Add(Expression.Eq("ParentId", parentId))
+ .List<StoreFolder>();
- // List<StoreFolder> children = new List<StoreFolder>();
+ tx.Commit();
+ session.Close();
- // foreach (int childFolderId in childIds) {
- // StoreFolder folder = GetStoreFolder(childFolderId);
-
- // if (folder != null) {
- // children.Add(folder);
- // }
- // }
-
- // return children.ToArray();
- // }
- // }
- //}
- throw new NotImplementedException();
+ return result;
+ }
+ }
}
#endregion
@@ -406,38 +376,17 @@
/// Gets a list of all folders
/// </summary>
/// <returns>The list of folders.</returns>
- public StoreFolder[] GetFolders() {
- //using (MySqlConnection cnn = MySqlHelper.GetConnection()) {
- // using (MySqlCommand cmd = cnn.CreateCommand()) {
- // cmd.CommandType = CommandType.StoredProcedure;
- // cmd.CommandText = "GetFolders";
-
- // List<StoreFolder> folders = new List<StoreFolder>();
- // MySqlDataReader reader = cmd.ExecuteReader();
-
- // while (reader.Read()) {
- // int folderId = (int) reader["FolderId"];
- // string nameSpace = (string) reader["NameSpace"];
- // string name = (string) reader["Name"];
- // int? parentId = (reader["ParentFolderId"] == DBNull.Value)
- // ? null
- // : (int?) reader["ParentFolderId"];
-
- // // TODO: Get HasChildren from the reader
- // folders.Add(new StoreFolder(nameSpace, name, folderId, parentId, false));
- // }
-
- // return folders.ToArray();
- // }
- //}
- throw new NotImplementedException();
+ public IList<StoreFolder> GetFolders() {
+ using (ISession session = this.hibernateFactory.OpenSession()) {
+ return session.CreateCriteria(typeof(StoreFolder)).List<StoreFolder>();
+ }
}
#endregion
#region Folder Subscription
#region GetSubscribedFolders
- public StoreFolder[] GetSubscribedFolders(string userName) {
+ public IList<StoreFolder> GetSubscribedFolders(string userName) {
//using (MySqlConnection cnn = MySqlHelper.GetConnection()) {
// using (MySqlCommand cmd = cnn.CreateCommand()) {
// cmd.CommandText = "SELECT s.FolderId AS FolderId FROM User u, Subscription s WHERE s.UserId = u.UserId AND u.UserName = ?UserName";
@@ -981,18 +930,22 @@
userFolder.NameSpace = DefaultNameSpace;
userFolder.FullFolderName = user.Username;
userFolder.OwnerUserId = user.UserId;
+ CreateFolder(userFolder);
- session.Save(userFolder);
-
// Create the user's folder
StoreFolder inboxFolder = new StoreFolder();
inboxFolder.NameSpace = DefaultNameSpace;
inboxFolder.FullFolderName = string.Format("{0}{1}{2}", user.Username, userFolder.Delimiter, Folder.Inbox);
inboxFolder.ParentId = userFolder.FolderId;
inboxFolder.OwnerUserId = user.UserId;
+ CreateFolder(inboxFolder);
- session.Save(inboxFolder);
-
+ // TODO: ACLs
+
+ // Set the user's folder Id
+ user.UserFolderId = userFolder.FolderId;
+ session.Update(user);
+
tx.Commit();
session.Close();
}
@@ -1682,6 +1635,10 @@
public void ReinstallSchema() {
new global::NHibernate.Tool.hbm2ddl.SchemaExport(this.hibernateCfg).Create(false, true);
+
+ LocalStoreUser administrator = new LocalStoreUser();
+ administrator.Username = "Administrator"; // TODO: get from a global admin name or something
+ CreateUser(administrator);
}
#endregion
Modified: NMail/trunk/NMail.LocalStoreData.NHibernate/hibernate-configuration.xml
===================================================================
--- NMail/trunk/NMail.LocalStoreData.NHibernate/hibernate-configuration.xml 2007-03-13 05:07:34 UTC (rev 177)
+++ NMail/trunk/NMail.LocalStoreData.NHibernate/hibernate-configuration.xml 2007-03-24 09:59:33 UTC (rev 178)
@@ -2,8 +2,9 @@
<hibernate-configuration xmlns="urn:nhibernate-configuration-2.2">
<session-factory>
<property name="connection.provider">NHibernate.Connection.DriverConnectionProvider</property>
- <property name="connection.driver_class">NHibernate.Driver.MySqlDataDriver</property>
- <property name="connection.connection_string">Database=NMailLocalStore;Uid=NMail;Password=moo</property>
- <property name="dialect">NHibernate.Dialect.MySQLDialect</property>
+ <property name="connection.driver_class">NHibernate.Driver.SqlClientDriver</property>
+ <property name="connection.connection_string">Data Source=127.0.0.1;Initial Catalog=NMailLocalStore;Integrated Security=True</property>
+ <property name="dialect">NHibernate.Dialect.MsSql2005Dialect</property>
+ <property name="hibernate.query.substitutions">true 1, false 0</property>
</session-factory>
</hibernate-configuration>
Modified: NMail/trunk/NMail.RemoteAccessService.Serializers/DataTypes/LocalStore/StoreFolderSerializer.cs
===================================================================
--- NMail/trunk/NMail.RemoteAccessService.Serializers/DataTypes/LocalStore/StoreFolderSerializer.cs 2007-03-13 05:07:34 UTC (rev 177)
+++ NMail/trunk/NMail.RemoteAccessService.Serializers/DataTypes/LocalStore/StoreFolderSerializer.cs 2007-03-24 09:59:33 UTC (rev 178)
@@ -70,10 +70,6 @@
public int OwnerUserId {
get { return ownerUserId; }
set { ownerUserId = value; }
- }
-
- public StoreFolder GetStoreFolder() {
- return new StoreFolder(this.nameSpace, this.name, this.folderId, this.parentId, this.ownerUserId, this.hasChildren);
}
}
}
Modified: NMail/trunk/NMail.Server.Console/NMail.Server.Console.csproj
===================================================================
--- NMail/trunk/NMail.Server.Console/NMail.Server.Console.csproj 2007-03-13 05:07:34 UTC (rev 177)
+++ NMail/trunk/NMail.Server.Console/NMail.Server.Console.csproj 2007-03-24 09:59:33 UTC (rev 178)
@@ -117,6 +117,10 @@
<Project>{90B33C2B-F945-478A-BBA0-4F66EF78B870}</Project>
<Package>{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}</Package>
</ProjectReference>
+ <ProjectReference Include="..\NMail.LocalStoreData.NHibernate\NMail.LocalStoreData.NHibernate.csproj">
+ <Project>{72F7E307-F0A9-4750-9ED5-5A1F97725A11}</Project>
+ <Name>NMail.LocalStoreData.NHibernate</Name>
+ </ProjectReference>
<ProjectReference Include="..\NMail.LocalStore\NMail.LocalStore.csproj">
<Name>NMail.LocalStore</Name>
<Project>{488A8890-EEE1-4ACC-9B35-3DDBE8E70D1D}</Project>
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <tmy...@us...> - 2007-03-24 10:15:53
|
Revision: 179
http://svn.sourceforge.net/nmailserver/?rev=179&view=rev
Author: tmyroadctfig
Date: 2007-03-24 03:01:32 -0700 (Sat, 24 Mar 2007)
Log Message:
-----------
Work on unit tests.
Modified Paths:
--------------
NMail/trunk/NMail.UnitTests/LocalStoreData/CreateCalendarTest1.cs
NMail/trunk/NMail.UnitTests/LocalStoreData/CreateCalendarTest2.cs
NMail/trunk/NMail.UnitTests/LocalStoreData/CreateEventEntryTest1.cs
NMail/trunk/NMail.UnitTests/LocalStoreData/CreateUserTest1.cs
NMail/trunk/NMail.UnitTests/LocalStoreData/CreateUserTest2.cs
NMail/trunk/NMail.UnitTests/LocalStoreData/DeleteUserTest1.cs
NMail/trunk/NMail.UnitTests/LocalStoreData/DeleteUserTest2.cs
NMail/trunk/NMail.UnitTests/NMail.UnitTests.csproj
Added Paths:
-----------
NMail/trunk/NMail.UnitTests/LocalStoreData/CreateStoreFolderTest1.cs
NMail/trunk/NMail.UnitTests/LocalStoreData/CreateStoreFolderTest2.cs
Removed Paths:
-------------
NMail/trunk/NMail.UnitTests/LocalStoreData/MySqlLocalStoreTests.cs
Modified: NMail/trunk/NMail.UnitTests/LocalStoreData/CreateCalendarTest1.cs
===================================================================
--- NMail/trunk/NMail.UnitTests/LocalStoreData/CreateCalendarTest1.cs 2007-03-24 09:59:33 UTC (rev 178)
+++ NMail/trunk/NMail.UnitTests/LocalStoreData/CreateCalendarTest1.cs 2007-03-24 10:01:32 UTC (rev 179)
@@ -7,7 +7,6 @@
using NMail.Configuration;
using NMail.DataTypes.Calendar;
using NMail.DataTypes.LocalStore;
-using NMail.LocalStoreData.MySql;
namespace NMail.UnitTests.LocalStoreData {
/// <summary>
Modified: NMail/trunk/NMail.UnitTests/LocalStoreData/CreateCalendarTest2.cs
===================================================================
--- NMail/trunk/NMail.UnitTests/LocalStoreData/CreateCalendarTest2.cs 2007-03-24 09:59:33 UTC (rev 178)
+++ NMail/trunk/NMail.UnitTests/LocalStoreData/CreateCalendarTest2.cs 2007-03-24 10:01:32 UTC (rev 179)
@@ -7,7 +7,6 @@
using NMail.Configuration;
using NMail.DataTypes.Calendar;
using NMail.DataTypes.LocalStore;
-using NMail.LocalStoreData.MySql;
namespace NMail.UnitTests.LocalStoreData {
/// <summary>
Modified: NMail/trunk/NMail.UnitTests/LocalStoreData/CreateEventEntryTest1.cs
===================================================================
--- NMail/trunk/NMail.UnitTests/LocalStoreData/CreateEventEntryTest1.cs 2007-03-24 09:59:33 UTC (rev 178)
+++ NMail/trunk/NMail.UnitTests/LocalStoreData/CreateEventEntryTest1.cs 2007-03-24 10:01:32 UTC (rev 179)
@@ -7,7 +7,6 @@
using NMail.Configuration;
using NMail.DataTypes.Calendar;
using NMail.DataTypes.LocalStore;
-using NMail.LocalStoreData.MySql;
namespace NMail.UnitTests.LocalStoreData {
/// <summary>
Added: NMail/trunk/NMail.UnitTests/LocalStoreData/CreateStoreFolderTest1.cs
===================================================================
--- NMail/trunk/NMail.UnitTests/LocalStoreData/CreateStoreFolderTest1.cs (rev 0)
+++ NMail/trunk/NMail.UnitTests/LocalStoreData/CreateStoreFolderTest1.cs 2007-03-24 10:01:32 UTC (rev 179)
@@ -0,0 +1,30 @@
+using System;
+using System.Collections.Generic;
+using System.Text;
+
+using NUnit.Framework;
+
+using NMail.Configuration;
+using NMail.DataTypes.Calendar;
+using NMail.DataTypes.LocalStore;
+
+namespace NMail.UnitTests.LocalStoreData {
+ /// <summary>
+ /// Tests creating a folder.
+ /// </summary>
+ [TestFixture]
+ public class CreateStoreFolderTest1 : BaseLocalStoreDataTest {
+
+ [Test]
+ public void TestCreateFolder() {
+ StoreFolder s1 = new StoreFolder();
+ s1.NameSpace = "Local";
+ s1.FullFolderName = "TestFolder";
+ s1.OwnerUserId = 1;
+
+ localStoreData.CreateFolder(s1);
+
+ Assert.IsTrue(s1.FolderId > 0, "Valid folder Id.");
+ }
+ }
+}
Added: NMail/trunk/NMail.UnitTests/LocalStoreData/CreateStoreFolderTest2.cs
===================================================================
--- NMail/trunk/NMail.UnitTests/LocalStoreData/CreateStoreFolderTest2.cs (rev 0)
+++ NMail/trunk/NMail.UnitTests/LocalStoreData/CreateStoreFolderTest2.cs 2007-03-24 10:01:32 UTC (rev 179)
@@ -0,0 +1,38 @@
+using System;
+using System.Collections.Generic;
+using System.Text;
+
+using NUnit.Framework;
+
+using NMail.Configuration;
+using NMail.DataTypes.Calendar;
+using NMail.DataTypes.LocalStore;
+
+namespace NMail.UnitTests.LocalStoreData {
+ /// <summary>
+ /// Tests creating a folder.
+ /// </summary>
+ [TestFixture]
+ public class CreateStoreFolderTest2 : BaseLocalStoreDataTest {
+
+ [Test]
+ [ExpectedException(typeof(System.Data.DuplicateNameException))]
+ public void TestCreateFolder() {
+ StoreFolder s1 = new StoreFolder();
+ s1.NameSpace = "Local";
+ s1.FullFolderName = "TestFolder";
+ s1.OwnerUserId = 1;
+
+ localStoreData.CreateFolder(s1);
+
+ Assert.IsTrue(s1.FolderId > 0, "Valid folder Id.");
+
+ StoreFolder s2 = new StoreFolder();
+ s2.NameSpace = "Local";
+ s2.FullFolderName = "TestFolder";
+ s2.OwnerUserId = 1;
+
+ localStoreData.CreateFolder(s2);
+ }
+ }
+}
Modified: NMail/trunk/NMail.UnitTests/LocalStoreData/CreateUserTest1.cs
===================================================================
--- NMail/trunk/NMail.UnitTests/LocalStoreData/CreateUserTest1.cs 2007-03-24 09:59:33 UTC (rev 178)
+++ NMail/trunk/NMail.UnitTests/LocalStoreData/CreateUserTest1.cs 2007-03-24 10:01:32 UTC (rev 179)
@@ -7,7 +7,6 @@
using NMail.Configuration;
using NMail.DataTypes.Calendar;
using NMail.DataTypes.LocalStore;
-using NMail.LocalStoreData.MySql;
namespace NMail.UnitTests.LocalStoreData {
/// <summary>
Modified: NMail/trunk/NMail.UnitTests/LocalStoreData/CreateUserTest2.cs
===================================================================
--- NMail/trunk/NMail.UnitTests/LocalStoreData/CreateUserTest2.cs 2007-03-24 09:59:33 UTC (rev 178)
+++ NMail/trunk/NMail.UnitTests/LocalStoreData/CreateUserTest2.cs 2007-03-24 10:01:32 UTC (rev 179)
@@ -7,7 +7,6 @@
using NMail.Configuration;
using NMail.DataTypes.Calendar;
using NMail.DataTypes.LocalStore;
-using NMail.LocalStoreData.MySql;
namespace NMail.UnitTests.LocalStoreData {
/// <summary>
Modified: NMail/trunk/NMail.UnitTests/LocalStoreData/DeleteUserTest1.cs
===================================================================
--- NMail/trunk/NMail.UnitTests/LocalStoreData/DeleteUserTest1.cs 2007-03-24 09:59:33 UTC (rev 178)
+++ NMail/trunk/NMail.UnitTests/LocalStoreData/DeleteUserTest1.cs 2007-03-24 10:01:32 UTC (rev 179)
@@ -7,7 +7,6 @@
using NMail.Configuration;
using NMail.DataTypes.Calendar;
using NMail.DataTypes.LocalStore;
-using NMail.LocalStoreData.MySql;
namespace NMail.UnitTests.LocalStoreData {
/// <summary>
@@ -31,7 +30,11 @@
Assert.IsTrue(userFolders.Count > 0, "User has folders.");
foreach (StoreFolder folder in userFolders) {
- this.localStoreData.DeleteFolder(folder.FolderId);
+ try {
+ this.localStoreData.DeleteFolder(folder.FolderId, true);
+ } catch (Exception ex) {
+ // Ignore, may be trying to delete a deleted sub-folder
+ }
}
this.localStoreData.DeleteUser(user1.UserId);
Modified: NMail/trunk/NMail.UnitTests/LocalStoreData/DeleteUserTest2.cs
===================================================================
--- NMail/trunk/NMail.UnitTests/LocalStoreData/DeleteUserTest2.cs 2007-03-24 09:59:33 UTC (rev 178)
+++ NMail/trunk/NMail.UnitTests/LocalStoreData/DeleteUserTest2.cs 2007-03-24 10:01:32 UTC (rev 179)
@@ -7,7 +7,6 @@
using NMail.Configuration;
using NMail.DataTypes.Calendar;
using NMail.DataTypes.LocalStore;
-using NMail.LocalStoreData.MySql;
namespace NMail.UnitTests.LocalStoreData {
/// <summary>
Deleted: NMail/trunk/NMail.UnitTests/LocalStoreData/MySqlLocalStoreTests.cs
===================================================================
--- NMail/trunk/NMail.UnitTests/LocalStoreData/MySqlLocalStoreTests.cs 2007-03-24 09:59:33 UTC (rev 178)
+++ NMail/trunk/NMail.UnitTests/LocalStoreData/MySqlLocalStoreTests.cs 2007-03-24 10:01:32 UTC (rev 179)
@@ -1,88 +0,0 @@
-using System;
-using System.Collections.Generic;
-using System.Text;
-
-using NUnit.Framework;
-
-using NMail.Authentication;
-using NMail.Configuration;
-using NMail.DataTypes;
-using NMail.DataTypes.LocalStore;
-
-namespace NMail.LocalStoreData.MySql {
- /// <summary>
- /// Tests for the MySql localstore.
- /// </summary>
- [TestFixture]
- public class MySqlLocalStoreTests {
-
- ILocalStoreData localStoreData;
-
- [TestFixtureSetUp]
- public void Setup() {
- localStoreData = NMailConfiguration.Current.LocalStoreData;
- }
-
- public const string TestUsername = "testusername";
-
- public const string TestFolder = "testfolder";
-
- //[Test]
- //public void TestCreateUser() {
- // LocalStoreUser user = new LocalStoreUser();
- // user.Username = TestUsername;
- // LocalStoreUserResult result = localStoreData.CreateUser(user);
- // Assert.AreEqual(LocalStoreUserResult.OkSuccessful, result, "User created successfully.");
-
- // LocalStoreUser user = localStoreData.GetUser(TestUsername);
- // Assert.IsNotNull(user, "Valid user.");
- // Assert.IsTrue(user.UserId > 0, "Valid user Id");
- // Assert.IsTrue(user.UserFolderId > 0, "Valid user folder Id");
- //}
-
- [Test]
- public void CreateFolder() {
- LocalStoreUser user = localStoreData.GetUser(TestUsername);
- Assert.IsNotNull(user, "Valid user.");
-
- // Get the user's initial folder
- StoreFolder nominal = localStoreData.GetStoreFolder(user.UserFolderId);
- Assert.IsNotNull(nominal, "Nominal folder not null.");
-
- // Make a sub-folder under it
- Folder newFolder = new Folder(nominal, TestFolder);
- LocalStoreFolderResult result = localStoreData.CreateFolder(user.UserId, nominal, newFolder);
- Assert.AreEqual(LocalStoreFolderResult.OkSuccessful, result, "Created folder successfully.");
- }
-
- //[Test]
- //public void TestDeleteUser() {
- // // Make an initial delete attempt (which should fail)
- // int userId = localStoreData.GetUser(TestUsername).UserId;
- // LocalStoreUserResult result = localStoreData.DeleteUser(userId);
- // Assert.AreEqual(LocalStoreUserResult.UserStillHasFolders, result, "User deleted fails with still has folders.");
-
- // // Delete all the user's folders
- // Queue<StoreFolder> folders = new Queue<StoreFolder>(localStoreData.GetUserFolders(userId));
-
- // while (folders.Count > 0) {
- // StoreFolder folder = folders.Dequeue();
- // LocalStoreFolderResult folderResult = localStoreData.DeleteFolder(folder.FolderId);
-
- // if (folderResult == LocalStoreFolderResult.OkSuccessful) {
- // continue;
-
- // } else if (folderResult != LocalStoreFolderResult.HasChildren) {
- // throw new InvalidOperationException(string.Format("Error deleting user's folder. Id: {0}", folder.FolderId));
-
- // } else {
- // folders.Enqueue(folder);
- // }
- // }
-
- // // Attempt to delete the user again
- // result = localStoreData.DeleteUser(userId);
- // Assert.AreEqual(LocalStoreUserResult.OkSuccessful, result, "User deleted successfully.");
- //}
- }
-}
Modified: NMail/trunk/NMail.UnitTests/NMail.UnitTests.csproj
===================================================================
--- NMail/trunk/NMail.UnitTests/NMail.UnitTests.csproj 2007-03-24 09:59:33 UTC (rev 178)
+++ NMail/trunk/NMail.UnitTests/NMail.UnitTests.csproj 2007-03-24 10:01:32 UTC (rev 179)
@@ -52,6 +52,8 @@
<Compile Include="DataTypes\Helper\MimeHelperTests.cs" />
<Compile Include="DataTypes\Helper\StringTokenizerTests.cs" />
<Compile Include="LocalStoreData\BaseLocalStoreDataTest.cs" />
+ <Compile Include="LocalStoreData\CreateStoreFolderTest2.cs" />
+ <Compile Include="LocalStoreData\CreateStoreFolderTest1.cs" />
<Compile Include="LocalStoreData\DeleteUserTest2.cs" />
<Compile Include="LocalStoreData\DeleteUserTest1.cs" />
<Compile Include="LocalStoreData\CreateEventEntryTest1.cs" />
@@ -59,7 +61,6 @@
<Compile Include="LocalStoreData\CreateCalendarTest1.cs" />
<Compile Include="LocalStoreData\CreateUserTest2.cs" />
<Compile Include="LocalStoreData\CreateUserTest1.cs" />
- <Compile Include="LocalStoreData\MySqlLocalStoreTests.cs" />
<Compile Include="Properties\AssemblyInfo.cs" />
<Compile Include="Resources\ResourceHelper.cs" />
<Compile Include="SmtpService\SmtpServiceTests.cs" />
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
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.
|
|
From: <tmy...@us...> - 2007-03-13 05:05:16
|
Revision: 176
http://svn.sourceforge.net/nmailserver/?rev=176&view=rev
Author: tmyroadctfig
Date: 2007-03-12 22:05:16 -0700 (Mon, 12 Mar 2007)
Log Message:
-----------
Work on NHibernate local store data mappings.
Modified Paths:
--------------
NMail/trunk/NMail.LocalStoreData.NHibernate/NHibernateLocalStoreData.cs
NMail/trunk/NMail.LocalStoreData.NHibernate/NMail.LocalStoreData.NHibernate.csproj
Added Paths:
-----------
NMail/trunk/NMail.LocalStoreData.NHibernate/Mappings/
NMail/trunk/NMail.LocalStoreData.NHibernate/Mappings/NMail.DataTypes.ACLs.StoreFolderAcl.hbm.xml
NMail/trunk/NMail.LocalStoreData.NHibernate/Mappings/NMail.DataTypes.Calendar.Attendee.hbm.xml
NMail/trunk/NMail.LocalStoreData.NHibernate/Mappings/NMail.DataTypes.Calendar.Calendar.hbm.xml
NMail/trunk/NMail.LocalStoreData.NHibernate/Mappings/NMail.DataTypes.Calendar.CalendarEntry.hbm.xml
NMail/trunk/NMail.LocalStoreData.NHibernate/Mappings/NMail.DataTypes.LocalStore.LocalStoreGroup.hbm.xml
NMail/trunk/NMail.LocalStoreData.NHibernate/Mappings/NMail.DataTypes.LocalStore.LocalStoreUser.hbm.xml
NMail/trunk/NMail.LocalStoreData.NHibernate/Mappings/NMail.DataTypes.LocalStore.MailDomain.hbm.xml
NMail/trunk/NMail.LocalStoreData.NHibernate/Mappings/NMail.DataTypes.LocalStore.StoreFolder.hbm.xml
Removed Paths:
-------------
NMail/trunk/NMail.LocalStoreData.NHibernate/NMail.LocalStoreData.NHibernate.Auth.hbm.xml
NMail/trunk/NMail.LocalStoreData.NHibernate/NMail.LocalStoreData.NHibernate.UserMap.hbm.xml
NMail/trunk/NMail.LocalStoreData.NHibernate/NMail.LocalStoreData.NHibernate.hbm.xml
Added: NMail/trunk/NMail.LocalStoreData.NHibernate/Mappings/NMail.DataTypes.ACLs.StoreFolderAcl.hbm.xml
===================================================================
--- NMail/trunk/NMail.LocalStoreData.NHibernate/Mappings/NMail.DataTypes.ACLs.StoreFolderAcl.hbm.xml (rev 0)
+++ NMail/trunk/NMail.LocalStoreData.NHibernate/Mappings/NMail.DataTypes.ACLs.StoreFolderAcl.hbm.xml 2007-03-13 05:05:16 UTC (rev 176)
@@ -0,0 +1,19 @@
+<?xml version="1.0" encoding="utf-8" ?>
+<hibernate-mapping xmlns="urn:nhibernate-mapping-2.2" namespace="NMail" assembly="NMail" default-lazy="false">
+
+ <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>
+
+</hibernate-mapping>
\ No newline at end of file
Added: NMail/trunk/NMail.LocalStoreData.NHibernate/Mappings/NMail.DataTypes.Calendar.Attendee.hbm.xml
===================================================================
--- NMail/trunk/NMail.LocalStoreData.NHibernate/Mappings/NMail.DataTypes.Calendar.Attendee.hbm.xml (rev 0)
+++ NMail/trunk/NMail.LocalStoreData.NHibernate/Mappings/NMail.DataTypes.Calendar.Attendee.hbm.xml 2007-03-13 05:05:16 UTC (rev 176)
@@ -0,0 +1,17 @@
+<?xml version="1.0" encoding="utf-8" ?>
+<hibernate-mapping xmlns="urn:nhibernate-mapping-2.2" namespace="NMail" assembly="NMail" default-lazy="false">
+
+ <class name="NMail.DataTypes.Calendar.Attendee" table="Attendee">
+ <id type="Int32">
+ <column name="AttendeeId" not-null="true"/>
+ <generator class="native" />
+ </id>
+
+ <property name="Address" not-null="true"/>
+
+ <many-to-one name="CalendarEntry"
+ class="NMail.DataTypes.Calendar.CalendarEntry"
+ column="CalendarEntryId" />
+ </class>
+
+</hibernate-mapping>
\ No newline at end of file
Added: NMail/trunk/NMail.LocalStoreData.NHibernate/Mappings/NMail.DataTypes.Calendar.Calendar.hbm.xml
===================================================================
--- NMail/trunk/NMail.LocalStoreData.NHibernate/Mappings/NMail.DataTypes.Calendar.Calendar.hbm.xml (rev 0)
+++ NMail/trunk/NMail.LocalStoreData.NHibernate/Mappings/NMail.DataTypes.Calendar.Calendar.hbm.xml 2007-03-13 05:05:16 UTC (rev 176)
@@ -0,0 +1,25 @@
+<?xml version="1.0" encoding="utf-8" ?>
+<hibernate-mapping xmlns="urn:nhibernate-mapping-2.2" namespace="NMail" assembly="NMail" default-lazy="false">
+
+ <class name="NMail.DataTypes.Calendar.Calendar" table="Calendar">
+ <id name="CalendarId" type="Int32" unsaved-value="0">
+ <column name="CalendarId" not-null="true"/>
+ <generator class="native" />
+ </id>
+
+ <property name="Name" not-null="true"/>
+
+ <!-- TODO: make this a many to one relationship with folder -->
+ <property name="ParentFolderId" />
+
+ <!-- TODO: make this a many to one relationship with user -->
+ <property name="OwnerUserId" />
+
+ <list name="Entries" cascade="all">
+ <key column="CalendarEntryId" />
+ <index column="CategoryEntryIndex" type="Int32" />
+ <one-to-many class="NMail.DataTypes.Calendar.CalendarEntry" />
+ </list>
+ </class>
+
+</hibernate-mapping>
\ No newline at end of file
Added: NMail/trunk/NMail.LocalStoreData.NHibernate/Mappings/NMail.DataTypes.Calendar.CalendarEntry.hbm.xml
===================================================================
--- NMail/trunk/NMail.LocalStoreData.NHibernate/Mappings/NMail.DataTypes.Calendar.CalendarEntry.hbm.xml (rev 0)
+++ NMail/trunk/NMail.LocalStoreData.NHibernate/Mappings/NMail.DataTypes.Calendar.CalendarEntry.hbm.xml 2007-03-13 05:05:16 UTC (rev 176)
@@ -0,0 +1,84 @@
+<?xml version="1.0" encoding="utf-8" ?>
+<hibernate-mapping xmlns="urn:nhibernate-mapping-2.2" namespace="NMail" assembly="NMail" default-lazy="false">
+
+ <class name="NMail.DataTypes.Calendar.CalendarEntry" table="CalendarEntry">
+ <id name="EntryId" type="Int32" unsaved-value="0">
+ <column name="CalendarEntryId" not-null="true"/>
+ <generator class="native" />
+ </id>
+
+
+ <!--
+ - Descriptive Properties
+ -->
+ <property name="Classification" not-null="true" />
+
+ <list name="Categories" table="CalendarEventCategories" cascade="all">
+ <key column="CalendarEntryId" />
+ <index column="CategoryIndex" type="Int32" />
+ <element column="Category" type="String" />
+ </list>
+
+ <property name="Description" />
+
+ <!--<property name="Status" />-->
+
+ <property name="Summary" />
+
+
+ <!--
+ - Date/Time Properties
+ -->
+ <property name="StartTime" not-null="true" />
+
+
+ <!--
+ - Relationship Component Properties
+ -->
+ <list name="Attendees" cascade="all">
+ <key column="CalendarEntryId" />
+ <index column="AttendeeIndex" />
+ <one-to-many class="NMail.DataTypes.Calendar.Attendee" />
+ </list>
+
+ <property name="Organiser" type="String" />
+
+ <!-- TODO: make this a many to one relationship with user -->
+ <property name="OwnerUserId" />
+
+ <many-to-one name="Calendar"
+ class="NMail.DataTypes.Calendar.Calendar"
+ column="CalendarId" />
+
+
+ <!--
+ - Recurrence Component Properties
+ -->
+
+ <!-- one to many <property name="Recurrence" /> -->
+
+ <property name="RecurrenceId" />
+
+
+ <!--
+ - Change Management Component Properties
+ -->
+ <property name="Created" />
+
+ <property name="TimeStamp" />
+
+ <property name="LastModified" />
+
+ <property name="Sequence" />
+
+ <!--
+ -
+ - Calendar Event
+ -
+ -->
+ <joined-subclass name="NMail.DataTypes.Calendar.EventEntry" table="EventEntry">
+ <key column="CalendarEntryId"/>
+ </joined-subclass>
+ </class>
+
+</hibernate-mapping>
\ No newline at end of file
Added: NMail/trunk/NMail.LocalStoreData.NHibernate/Mappings/NMail.DataTypes.LocalStore.LocalStoreGroup.hbm.xml
===================================================================
--- NMail/trunk/NMail.LocalStoreData.NHibernate/Mappings/NMail.DataTypes.LocalStore.LocalStoreGroup.hbm.xml (rev 0)
+++ NMail/trunk/NMail.LocalStoreData.NHibernate/Mappings/NMail.DataTypes.LocalStore.LocalStoreGroup.hbm.xml 2007-03-13 05:05:16 UTC (rev 176)
@@ -0,0 +1,25 @@
+<?xml version="1.0" encoding="utf-8" ?>
+<hibernate-mapping xmlns="urn:nhibernate-mapping-2.2" namespace="NMail" assembly="NMail" default-lazy="false">
+
+ <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>
+
+</hibernate-mapping>
\ No newline at end of file
Added: NMail/trunk/NMail.LocalStoreData.NHibernate/Mappings/NMail.DataTypes.LocalStore.LocalStoreUser.hbm.xml
===================================================================
--- NMail/trunk/NMail.LocalStoreData.NHibernate/Mappings/NMail.DataTypes.LocalStore.LocalStoreUser.hbm.xml (rev 0)
+++ NMail/trunk/NMail.LocalStoreData.NHibernate/Mappings/NMail.DataTypes.LocalStore.LocalStoreUser.hbm.xml 2007-03-13 05:05:16 UTC (rev 176)
@@ -0,0 +1,19 @@
+<?xml version="1.0" encoding="utf-8" ?>
+<hibernate-mapping xmlns="urn:nhibernate-mapping-2.2" namespace="NMail" assembly="NMail" default-lazy="false">
+
+ <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>
+
+</hibernate-mapping>
\ No newline at end of file
Added: NMail/trunk/NMail.LocalStoreData.NHibernate/Mappings/NMail.DataTypes.LocalStore.MailDomain.hbm.xml
===================================================================
--- NMail/trunk/NMail.LocalStoreData.NHibernate/Mappings/NMail.DataTypes.LocalStore.MailDomain.hbm.xml (rev 0)
+++ NMail/trunk/NMail.LocalStoreData.NHibernate/Mappings/NMail.DataTypes.LocalStore.MailDomain.hbm.xml 2007-03-13 05:05:16 UTC (rev 176)
@@ -0,0 +1,31 @@
+<?xml version="1.0" encoding="utf-8" ?>
+<hibernate-mapping xmlns="urn:nhibernate-mapping-2.2" namespace="NMail" assembly="NMail" default-lazy="false">
+
+ <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>
+
+</hibernate-mapping>
\ No newline at end of file
Added: NMail/trunk/NMail.LocalStoreData.NHibernate/Mappings/NMail.DataTypes.LocalStore.StoreFolder.hbm.xml
===================================================================
--- NMail/trunk/NMail.LocalStoreData.NHibernate/Mappings/NMail.DataTypes.LocalStore.StoreFolder.hbm.xml (rev 0)
+++ NMail/trunk/NMail.LocalStoreData.NHibernate/Mappings/NMail.DataTypes.LocalStore.StoreFolder.hbm.xml 2007-03-13 05:05:16 UTC (rev 176)
@@ -0,0 +1,27 @@
+<?xml version="1.0" encoding="utf-8" ?>
+<hibernate-mapping xmlns="urn:nhibernate-mapping-2.2" namespace="NMail" assembly="NMail" default-lazy="false">
+
+ <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>
+
+</hibernate-mapping>
\ No newline at end of file
Modified: NMail/trunk/NMail.LocalStoreData.NHibernate/NHibernateLocalStoreData.cs
===================================================================
--- NMail/trunk/NMail.LocalStoreData.NHibernate/NHibernateLocalStoreData.cs 2007-03-13 05:04:17 UTC (rev 175)
+++ NMail/trunk/NMail.LocalStoreData.NHibernate/NHibernateLocalStoreData.cs 2007-03-13 05:05:16 UTC (rev 176)
@@ -919,113 +919,23 @@
/// <param name="username">The username to look up.</param>
/// <returns>The matching user or null if non is found.</returns>
public LocalStoreUser GetUser(string name) {
- //using (MySqlConnection cnn = MySqlHelper.GetConnection()) {
- // return getUser(name, cnn, null);
- //}
- throw new NotImplementedException();
+ using (ISession session = this.hibernateFactory.OpenSession()) {
+ return session.CreateCriteria(typeof(LocalStoreUser))
+ .Add(Expression.Like("Username", name))
+ .UniqueResult<LocalStoreUser>();
+ }
}
- //private LocalStoreUser getUser(string name, MySqlConnection cnn, MySqlTransaction transaction) {
- // using (MySqlCommand cmd = cnn.CreateCommand()) {
- // cmd.Transaction = transaction;
- // cmd.CommandType = CommandType.StoredProcedure;
- // cmd.CommandText = "GetUserFromName";
- // cmd.Parameters.Add("?Name", name);
- // cmd.Parameters.Add("?UserId", MySqlDbType.Int32);
- // cmd.Parameters.Add("?QuotaHardLimit", MySqlDbType.Int32);
- // cmd.Parameters.Add("?QuotaWarnLimit", MySqlDbType.Int32);
- // cmd.Parameters.Add("?UserFolderId", MySqlDbType.Int32);
- // cmd.Parameters.Add("?Result", MySqlDbType.Int32);
- // cmd.Parameters["UserId"].Direction = ParameterDirection.Output;
- // cmd.Parameters["QuotaHardLimit"].Direction = ParameterDirection.Output;
- // cmd.Parameters["QuotaWarnLimit"].Direction = ParameterDirection.Output;
- // cmd.Parameters["UserFolderId"].Direction = ParameterDirection.Output;
- // cmd.Parameters["Result"].Direction = ParameterDirection.Output;
-
- // cmd.ExecuteNonQuery();
-
- // int resultValue = (int) cmd.Parameters["Result"].Value;
- // LocalStoreUserResult result = (LocalStoreUserResult) resultValue;
-
- // // Check if the lookup succeeded
- // if (result != LocalStoreUserResult.OkSuccessful) {
- // return null;
- // }
-
- // // Parse out all the returned values
- // int userId = (int) cmd.Parameters["UserId"].Value;
- // object quotaHardLimit = cmd.Parameters["QuotaHardLimit"].Value;
- // object quotaWarnLimit = cmd.Parameters["QuotaWarnLimit"].Value;
- // int userFolderId = (int) cmd.Parameters["UserFolderId"].Value;
-
- // int? quotaHardLimitVal = (quotaHardLimit == DBNull.Value) ? null : (int?) quotaHardLimit;
- // int? quotaWarnLimitVal = (quotaWarnLimit == DBNull.Value) ? null : (int?) quotaWarnLimit;
-
- // // Return the user object
- // return new LocalStoreUser(name,
- // userId,
- // userFolderId,
- // quotaWarnLimitVal,
- // quotaHardLimitVal);
- // }
- //}
-
/// <summary>
/// Gets the user for the given user Id.
/// </summary>
/// <param name="userId">The Id of the user to look up.</param>
/// <returns>The matching user or null if non is found.</returns>
public LocalStoreUser GetUser(int userId) {
- //using (MySqlConnection cnn = MySqlHelper.GetConnection()) {
- // return getUser(userId, cnn, null);
- //}
- throw new NotImplementedException();
+ using (ISession session = this.hibernateFactory.OpenSession()) {
+ return session.Load<LocalStoreUser>(userId);
+ }
}
-
- //public LocalStoreUser getUser(int userId, MySqlConnection cnn, MySqlTransaction transaction) {
- // using (MySqlCommand cmd = cnn.CreateCommand()) {
- // cmd.Transaction = transaction;
- // cmd.CommandType = CommandType.StoredProcedure;
- // cmd.CommandText = "GetUserFromId";
- // cmd.Parameters.Add("?UserId", userId);
- // cmd.Parameters.Add("?Name", MySqlDbType.VarChar);
- // cmd.Parameters.Add("?QuotaHardLimit", MySqlDbType.Int32);
- // cmd.Parameters.Add("?QuotaWarnLimit", MySqlDbType.Int32);
- // cmd.Parameters.Add("?UserFolderId", MySqlDbType.Int32);
- // cmd.Parameters.Add("?Result", MySqlDbType.Int32);
- // cmd.Parameters["Name"].Direction = ParameterDirection.Output;
- // cmd.Parameters["QuotaHardLimit"].Direction = ParameterDirection.Output;
- // cmd.Parameters["QuotaWarnLimit"].Direction = ParameterDirection.Output;
- // cmd.Parameters["UserFolderId"].Direction = ParameterDirection.Output;
- // cmd.Parameters["Result"].Direction = ParameterDirection.Output;
-
- // cmd.ExecuteNonQuery();
-
- // int resultValue = (int) cmd.Parameters["Result"].Value;
- // LocalStoreUserResult result = (LocalStoreUserResult) resultValue;
-
- // // Check if the lookup succeeded
- // if (result != LocalStoreUserResult.OkSuccessful) {
- // return null;
- // }
-
- // // Parse out all the returned values
- // string name = (string) cmd.Parameters["Name"].Value;
- // object quotaHardLimit = cmd.Parameters["QuotaHardLimit"].Value;
- // object quotaWarnLimit = cmd.Parameters["QuotaWarnLimit"].Value;
- // int userFolderId = (int) cmd.Parameters["UserFolderId"].Value;
-
- // int? quotaHardLimitVal = (quotaHardLimit == DBNull.Value) ? null : (int?) quotaHardLimit;
- // int? quotaWarnLimitVal = (quotaWarnLimit == DBNull.Value) ? null : (int?) quotaWarnLimit;
-
- // // Return the user object
- // return new LocalStoreUser(name,
- // userId,
- // userFolderId,
- // quotaWarnLimitVal,
- // quotaHardLimitVal);
- // }
- //}
#endregion
#region Get Users
@@ -1033,74 +943,60 @@
/// Gets the list of users that currently exist in the local store.
/// </summary>
/// <returns>The list of users.</returns>
- public LocalStoreUser[] GetUsers() {
- //using (MySqlConnection cnn = MySqlHelper.GetConnection()) {
- // MySqlTransaction transaction = cnn.BeginTransaction();
+ public IList<LocalStoreUser> GetUsers() {
+ using (ISession session = this.hibernateFactory.OpenSession()) {
+ return session.CreateCriteria(typeof(LocalStoreUser)).List<LocalStoreUser>();
+ }
+ }
+ #endregion
- // try {
- // MySqlCommand cmd = cnn.CreateCommand();
- // cmd.Transaction = transaction;
+ #region Create User
+ /// <summary>
+ /// Creates a new user in the local store and creates an initial folder.
+ /// </summary>
+ /// <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>
+ public void CreateUser(LocalStoreUser user) {
+ using (ISession session = this.hibernateFactory.OpenSession()) {
+ using (ITransaction tx = session.BeginTransaction()) {
+ if (user.UserId != 0) {
+ throw new InvalidOperationException("Can't save an existing user with this method.");
+ }
- // cmd.CommandType = CommandType.StoredProcedure;
- // cmd.CommandText = "GetUserIds";
- // MySqlDataReader reader = cmd.ExecuteReader();
- // List<int> userIds = new List<int>();
+ // Check if any other user with the same name exists in the system
+ IList existing = session.CreateCriteria(typeof(LocalStoreUser))
+ .Add(Expression.Like("Username", user.Username))
+ .List();
- // while (reader.Read()) {
- // int userId = (int) reader["UserId"];
- // userIds.Add(userId);
- // }
- // reader.Close();
+ if (existing.Count > 0) {
+ throw new DuplicateNameException("User with the same name already exists in the system.");
+ }
- // List<LocalStoreUser> users = new List<LocalStoreUser>();
- // foreach (int userId in userIds) {
- // users.Add(getUser(userId, cnn, transaction));
- // }
+ session.Save(user);
- // transaction.Commit();
- // return users.ToArray();
+ // Create the user's folder
+ StoreFolder userFolder = new StoreFolder();
+ userFolder.NameSpace = DefaultNameSpace;
+ userFolder.FullFolderName = user.Username;
+ userFolder.OwnerUserId = user.UserId;
- // } catch (Exception ex) {
- // if (transaction != null) {
- // transaction.Rollback();
- // }
+ session.Save(userFolder);
- // throw ex;
- // }
- //}
- throw new NotImplementedException();
- }
- #endregion
+ // Create the user's folder
+ StoreFolder inboxFolder = new StoreFolder();
+ inboxFolder.NameSpace = DefaultNameSpace;
+ inboxFolder.FullFolderName = string.Format("{0}{1}{2}", user.Username, userFolder.Delimiter, Folder.Inbox);
+ inboxFolder.ParentId = userFolder.FolderId;
+ inboxFolder.OwnerUserId = user.UserId;
- #region Create User
- /// <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) {
- //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("?UserId", MySqlDbType.Int32);
- // cmd.Parameters.Add("?Result", MySqlDbType.Int32);
- // cmd.Parameters["UserId"].Direction = ParameterDirection.Output;
- // cmd.Parameters["Result"].Direction = ParameterDirection.Output;
-
- // cmd.ExecuteNonQuery();
-
- // int result = (int) cmd.Parameters["Result"].Value;
-
- // return (LocalStoreUserResult) result;
- // }
- //}
- throw new NotImplementedException();
+ session.Save(inboxFolder);
+
+ tx.Commit();
+ session.Close();
+ }
+ }
}
#endregion
@@ -1110,23 +1006,16 @@
/// </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) {
- //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;
+ public void DeleteUser(int userId) {
+ using (ISession session = this.hibernateFactory.OpenSession()) {
+ using (ITransaction tx = session.BeginTransaction()) {
+ LocalStoreUser user = session.Load<LocalStoreUser>(userId);
+ session.Delete(user);
- // cmd.ExecuteNonQuery();
-
- // int result = (int) cmd.Parameters["Result"].Value;
-
- // return (LocalStoreUserResult) result;
- // }
- //}
- throw new NotImplementedException();
+ tx.Commit();
+ }
+ session.Close();
+ }
}
#endregion
@@ -1136,62 +1025,42 @@
/// </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) {
- //using (MySqlConnection cnn = MySqlHelper.GetConnection()) {
- // using (MySqlCommand cmd = cnn.CreateCommand()) {
- // cmd.CommandType = CommandType.StoredProcedure;
- // cmd.CommandText = "UpdateUser";
- // cmd.Parameters.Add("?UserId", user.UserId);
- // cmd.Parameters.Add("?Name", user.Username);
- // cmd.Parameters.Add("?QuotaHardLimit", user.QuotaHardLimit);
- // cmd.Parameters.Add("?QuotaWarnLimit", user.QuotaWarnLimit);
- // cmd.Parameters.Add("?Result", MySqlDbType.Int32);
- // cmd.Parameters["Result"].Direction = ParameterDirection.Output;
+ public void UpdateUser(LocalStoreUser user) {
+ using (ISession session = this.hibernateFactory.OpenSession()) {
+ using (ITransaction tx = session.BeginTransaction()) {
+ // Check if any other user with the same name exists in the system
+ IList existing = session.CreateCriteria(typeof(LocalStoreUser))
+ .Add(Expression.Like("Username", user.Username))
+ .List();
- // cmd.ExecuteNonQuery();
+ if (existing.Count > 0) {
+ throw new DuplicateNameException("User with the same name already exists in the system.");
+ }
- // int result = (int) cmd.Parameters["Result"].Value;
+ session.Update(user);
- // return (LocalStoreUserResult) result;
- // }
- //}
- throw new NotImplementedException();
+ tx.Commit();
+ session.Close();
+ }
+ }
}
#endregion
+ #region Get User Folders
/// <summary>
/// Gets a list of folders 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>
- public StoreFolder[] GetUserFolders(int userId) {
- //using (MySqlConnection cnn = MySqlHelper.GetConnection()) {
- // using (MySqlCommand cmd = cnn.CreateCommand()) {
- // cmd.CommandType = CommandType.StoredProcedure;
- // cmd.CommandText = "GetUserFolders";
- // cmd.Parameters.Add("?UserId", userId);
-
- // List<StoreFolder> folders = new List<StoreFolder>();
- // MySqlDataReader reader = cmd.ExecuteReader();
-
- // while (reader.Read()) {
- // int folderId = (int) reader["FolderId"];
- // string nameSpace = (string) reader["NameSpace"];
- // string name = (string) reader["Name"];
- // int? parentId = (reader["ParentFolderId"] == DBNull.Value)
- // ? null
- // : (int?) reader["ParentFolderId"];
-
- // // TODO: Get HasChildren from the reader
- // folders.Add(new StoreFolder(nameSpace, name, folderId, parentId, false));
- // }
-
- // return folders.ToArray();
- // }
- //}
- throw new NotImplementedException();
+ public IList<StoreFolder> GetUserFolders(int userId) {
+ using (ISession session = this.hibernateFactory.OpenSession()) {
+ return session.CreateCriteria(typeof(StoreFolder))
+ .Add(Expression.Eq("OwnerUserId", userId))
+ .List<StoreFolder>();
+ }
}
#endregion
+ #endregion
#region Group Management
#region GetGroup
@@ -1810,10 +1679,15 @@
session.Delete("from CalendarEntry as calE where calE.EntryId = ?", entryId, NHibernateUtil.Int64);
}
}
- #endregion
public void ReinstallSchema() {
new global::NHibernate.Tool.hbm2ddl.SchemaExport(this.hibernateCfg).Create(false, true);
}
+ #endregion
+
+ /// <summary>
+ /// The default namespace.
+ /// </summary>
+ public const string DefaultNameSpace = "Local";
}
}
Deleted: NMail/trunk/NMail.LocalStoreData.NHibernate/NMail.LocalStoreData.NHibernate.Auth.hbm.xml
===================================================================
--- NMail/trunk/NMail.LocalStoreData.NHibernate/NMail.LocalStoreData.NHibernate.Auth.hbm.xml 2007-03-13 05:04:17 UTC (rev 175)
+++ NMail/trunk/NMail.LocalStoreData.NHibernate/NMail.LocalStoreData.NHibernate.Auth.hbm.xml 2007-03-13 05:05:16 UTC (rev 176)
@@ -1,131 +0,0 @@
-<?xml version="1.0" encoding="utf-8" ?>
-<hibernate-mapping xmlns="urn:nhibernate-mapping-2.2" namespace="NMail" assembly="NMail" default-lazy="false">
- <!--
- -
- - Calendar
- -
- -->
- <class name="NMail.DataTypes.Calendar.Calendar" table="Calendar">
- <id name="CalendarId" type="Int32" unsaved-value="0">
- <column name="CalendarId" not-null="true"/>
- <generator class="native" />
- </id>
-
- <property name="Name" not-null="true"/>
-
- <!-- TODO: make this a many to one relationship with folder -->
- <property name="ParentFolderId" />
-
- <!-- TODO: make this a many to one relationship with user -->
- <property name="OwnerUserId" />
-
- <list name="Entries" cascade="all">
- <key column="CalendarEntryId" />
- <index column="CategoryEntryIndex" type="Int32" />
- <one-to-many class="NMail.DataTypes.Calendar.CalendarEntry" />
- </list>
- </class>
-
- <!--
- -
- - Calendar Entry
- -
- -->
- <class name="NMail.DataTypes.Calendar.CalendarEntry" table="CalendarEntry">
- <id name="EntryId" type="Int32" unsaved-value="0">
- <column name="CalendarEntryId" not-null="true"/>
- <generator class="native" />
- </id>
-
-
- <!--
- - Descriptive Properties
- -->
- <property name="Classification" not-null="true" />
-
- <list name="Categories" table="CalendarEventCategories" cascade="all">
- <key column="CalendarEntryId" />
- <index column="CategoryIndex" type="Int32" />
- <element column="Category" type="String" />
- </list>
-
- <property name="Description" />
-
- <!--<property name="Status" />-->
-
- <property name="Summary" />
-
-
- <!--
- - Date/Time Properties
- -->
- <property name="StartTime" not-null="true" />
-
-
- <!--
- - Relationship Component Properties
- -->
- <list name="Attendees" cascade="all">
- <key column="CalendarEntryId" />
- <index column="AttendeeIndex" />
- <one-to-many class="NMail.DataTypes.Calendar.Attendee" />
- </list>
-
- <property name="Organiser" type="String" />
-
- <!-- TODO: make this a many to one relationship with user -->
- <property name="OwnerUserId" />
-
- <many-to-one name="Calendar"
- class="NMail.DataTypes.Calendar.Calendar"
- column="CalendarId" />
-
-
- <!--
- - Recurrence Component Properties
- -->
-
- <!-- one to many <property name="Recurrence" /> -->
-
- <property name="RecurrenceId" />
-
-
- <!--
- - Change Management Component Properties
- -->
- <property name="Created" />
-
- <property name="TimeStamp" />
-
- <property name="LastModified" />
-
- <property name="Sequence" />
-
- <!--
- -
- - Calendar Event
- -
- -->
- <joined-subclass name="NMail.DataTypes.Calendar.EventEntry" table="EventEntry">
- <key column="CalendarEntryId"/>
- </joined-subclass>
- </class>
-
- <!--
- -
- - Attendee
- -
- -->
- <class name="NMail.DataTypes.Calendar.Attendee" table="Attendee">
- <id type="Int32">
- <column name="AttendeeId" not-null="true"/>
- <generator class="native" />
- </id>
-
- <property name="Address" not-null="true"/>
-
- <many-to-one name="CalendarEntry"
- class="NMail.DataTypes.Calendar.CalendarEntry"
- column="CalendarEntryId" />
- </class>
-</hibernate-mapping>
\ No newline at end of file
Deleted: NMail/trunk/NMail.LocalStoreData.NHibernate/NMail.LocalStoreData.NHibernate.UserMap.hbm.xml
===================================================================
--- NMail/trunk/NMail.LocalStoreData.NHibernate/NMail.LocalStoreData.NHibernate.UserMap.hbm.xml 2007-03-13 05:04:17 UTC (rev 175)
+++ NMail/trunk/NMail.LocalStoreData.NHibernate/NMail.LocalStoreData.NHibernate.UserMap.hbm.xml 2007-03-13 05:05:16 UTC (rev 176)
@@ -1,131 +0,0 @@
-<?xml version="1.0" encoding="utf-8" ?>
-<hibernate-mapping xmlns="urn:nhibernate-mapping-2.2" namespace="NMail" assembly="NMail" default-lazy="false">
- <!--
- -
- - Calendar
- -
- -->
- <class name="NMail.DataTypes.Calendar.Calendar" table="Calendar">
- <id name="CalendarId" type="Int32" unsaved-value="0">
- <column name="CalendarId" not-null="true"/>
- <generator class="native" />
- </id>
-
- <property name="Name" not-null="true"/>
-
- <!-- TODO: make this a many to one relationship with folder -->
- <property name="ParentFolderId" />
-
- <!-- TODO: make this a many to one relationship with user -->
- <property name="OwnerUserId" />
-
- <list name="Entries" cascade="all">
- <key column="CalendarEntryId" />
- <index column="CategoryEntryIndex" type="Int32" />
- <one-to-many class="NMail.DataTypes.Calendar.CalendarEntry" />
- </list>
- </class>
-
- <!--
- -
- - Calendar Entry
- -
- -->
- <class name="NMail.DataTypes.Calendar.CalendarEntry" table="CalendarEntry">
- <id name="EntryId" type="Int32" unsaved-value="0">
- <column name="CalendarEntryId" not-null="true"/>
- <generator class="native" />
- </id>
-
-
- <!--
- - Descriptive Properties
- -->
- <property name="Classification" not-null="true" />
-
- <list name="Categories" table="CalendarEventCategories" cascade="all">
- <key column="CalendarEntryId" />
- <index column="CategoryIndex" type="Int32" />
- <element column="Category" type="String" />
- </list>
-
- <property name="Description" />
-
- <!--<property name="Status" />-->
-
- <property name="Summary" />
-
-
- <!--
- - Date/Time Properties
- -->
- <property name="StartTime" not-null="true" />
-
-
- <!--
- - Relationship Component Properties
- -->
- <list name="Attendees" cascade="all">
- <key column="CalendarEntryId" />
- <index column="AttendeeIndex" />
- <one-to-many class="NMail.DataTypes.Calendar.Attendee" />
- </list>
-
- <property name="Organiser" type="String" />
-
- <!-- TODO: make this a many to one relationship with user -->
- <property name="OwnerUserId" />
-
- <many-to-one name="Calendar"
- class="NMail.DataTypes.Calendar.Calendar"
- column="CalendarId" />
-
-
- <!--
- - Recurrence Component Properties
- -->
-
- <!-- one to many <property name="Recurrence" /> -->
-
- <property name="RecurrenceId" />
-
-
- <!--
- - Change Management Component Properties
- -->
- <property name="Created" />
-
- <property name="TimeStamp" />
-
- <property name="LastModified" />
-
- <property name="Sequence" />
-
- <!--
- -
- - Calendar Event
- -
- -->
- <joined-subclass name="NMail.DataTypes.Calendar.EventEntry" table="EventEntry">
- <key column="CalendarEntryId"/>
- </joined-subclass>
- </class>
-
- <!--
- -
- - Attendee
- -
- -->
- <class name="NMail.DataTypes.Calendar.Attendee" table="Attendee">
- <id type="Int32">
- <column name="AttendeeId" not-null="true"/>
- <generator class="native" />
- </id>
-
- <property name="Address" not-null="true"/>
-
- <many-to-one name="CalendarEntry"
- class="NMail.DataTypes.Calendar.CalendarEntry"
- column="CalendarEntryId" />
- </class>
-</hibernate-mapping>
\ No newline at end of file
Modified: NMail/trunk/NMail.LocalStoreData.NHibernate/NMail.LocalStoreData.NHibernate.csproj
===================================================================
--- NMail/trunk/NMail.LocalStoreData.NHibernate/NMail.LocalStoreData.NHibernate.csproj 2007-03-13 05:04:17 UTC (rev 175)
+++ NMail/trunk/NMail.LocalStoreData.NHibernate/NMail.LocalStoreData.NHibernate.csproj 2007-03-13 05:05:16 UTC (rev 176)
@@ -52,23 +52,36 @@
<Compile Include="Properties\AssemblyInfo.cs" />
</ItemGroup>
<ItemGroup>
- <EmbeddedResource Include="NMail.LocalStoreData.NHibernate.hbm.xml" />
+ <EmbeddedResource Include="hibernate-configuration.xml" />
</ItemGroup>
<ItemGroup>
- <EmbeddedResource Include="hibernate-configuration.xml" />
+ <ProjectReference Include="..\NMail\NMail.csproj">
+ <Project>{5A5A5012-B157-49B1-A35F-67EC9680112A}</Project>
+ <Name>NMail</Name>
+ </ProjectReference>
</ItemGroup>
<ItemGroup>
- <EmbeddedResource Include="NMail.LocalStoreData.NHibernate.Auth.hbm.xml" />
+ <EmbeddedResource Include="Mappings\NMail.DataTypes.LocalStore.LocalStoreUser.hbm.xml" />
+ <EmbeddedResource Include="Mappings\NMail.DataTypes.LocalStore.StoreFolder.hbm.xml" />
</ItemGroup>
<ItemGroup>
- <EmbeddedResource Include="NMail.LocalStoreData.NHibernate.UserMap.hbm.xml" />
+ <EmbeddedResource Include="Mappings\NMail.DataTypes.LocalStore.LocalStoreGroup.hbm.xml" />
</ItemGroup>
<ItemGroup>
- <ProjectReference Include="..\NMail\NMail.csproj">
- <Project>{5A5A5012-B157-49B1-A35F-67EC9680112A}</Project>
- <Name>NMail</Name>
- </ProjectReference>
+ <EmbeddedResource Include="Mappings\NMail.DataTypes.Calendar.Calendar.hbm.xml" />
</ItemGroup>
+ <ItemGroup>
+ <EmbeddedResource Include="Mappings\NMail.DataTypes.Calendar.CalendarEntry.hbm.xml" />
+ </ItemGroup>
+ <ItemGroup>
+ <EmbeddedResource Include="Mappings\NMail.DataTypes.Calendar.Attendee.hbm.xml" />
+ </ItemGroup>
+ <ItemGroup>
+ <EmbeddedResource Include="Mappings\NMail.DataTypes.LocalStore.MailDomain.hbm.xml" />
+ </ItemGroup>
+ <ItemGroup>
+ <EmbeddedResource Include="Mappings\NMail.DataTypes.ACLs.StoreFolderAcl.hbm.xml" />
+ </ItemGroup>
<Import Project="$(MSBuildBinPath)\Microsoft.CSharp.targets" />
<!-- To modify your build process, add your task inside one of the targets below and uncomment it.
Other similar extension points exist, see Microsoft.Common.targets.
Deleted: NMail/trunk/NMail.LocalStoreData.NHibernate/NMail.LocalStoreData.NHibernate.hbm.xml
===================================================================
--- NMail/trunk/NMail.LocalStoreData.NHibernate/NMail.LocalStoreData.NHibernate.hbm.xml 2007-03-13 05:04:17 UTC (rev 175)
+++ NMail/trunk/NMail.LocalStoreData.NHibernate/NMail.LocalStoreData.NHibernate.hbm.xml 2007-03-13 05:05:16 UTC (rev 176)
@@ -1,170 +0,0 @@
-<?xml version="1.0" encoding="utf-8" ?>
-<hibernate-mapping xmlns="urn:nhibernate-mapping-2.2" namespace="NMail" assembly="NMail" default-lazy="false">
- <!--
-
- TODO:
- - Message (parts)
- - Objects
- - Users
- - Groups
- - Folder
- - ACLs (folder & system)
- - Mail domain
-
- -->
-
- <!--
- -
- - 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="Name" not-null="true"/>
-
- <property name="NameSpace" not-null="true" />
-
- <many-to-one name="ParentId" foreign-key="FolderId" />
-
- <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>
-
- <!--
- -
- - Calendar
- -
- -->
- <class name="NMail.DataTypes.Calendar.Calendar" table="Calendar">
- <id name="CalendarId" type="Int32" unsaved-value="0">
- <column name="CalendarId" not-null="true"/>
- <generator class="native" />
- </id>
-
- <property name="Name" not-null="true"/>
-
- <!-- TODO: make this a many to one relationship with folder -->
- <property name="ParentFolderId" />
-
- <!-- TODO: make this a many to one relationship with user -->
- <property name="OwnerUserId" />
-
- <list name="Entries" cascade="all">
- <key column="CalendarEntryId" />
- <index column="CategoryEntryIndex" type="Int32" />
- <one-to-many class="NMail.DataTypes.Calendar.CalendarEntry" />
- </list>
- </class>
-
- <!--
- -
- - Calendar Entry
- -
- -->
- <class name="NMail.DataTypes.Calendar.CalendarEntry" table="CalendarEntry">
- <id name="EntryId" type="Int32" unsaved-value="0">
- <column name="CalendarEntryId" not-null="true"/>
- <generator class="native" />
- </id>
-
-
- <!--
- - Descriptive Properties
- -->
- <property name="Classification" not-null="true" />
-
- <list name="Categories" table="CalendarEventCategories" cascade="all">
- <key column="CalendarEntryId" />
- <index column="CategoryIndex" type="Int32" />
- <element column="Category" type="String" />
- </list>
-
- <property name="Description" />
-
- <!--<property name="Status" />-->
-
- <property name="Summary" />
-
-
- <!--
- - Date/Time Properties
- -->
- <property name="StartTime" not-null="true" />
-
-
- <!--
- - Relationship Component Properties
- -->
- <list name="Attendees" cascade="all">
- <key column="CalendarEntryId" />
- <index column="AttendeeIndex" />
- <one-to-many class="NMail.DataTypes.Calendar.Attendee" />
- </list>
-
- <property name="Organiser" type="String" />
-
- <!-- TODO: make this a many to one relationship with user -->
- <property name="OwnerUserId" />
-
- <many-to-one name="Calendar"
- class="NMail.DataTypes.Calendar.Calendar"
- column="CalendarId" />
-
-
- <!--
- - Recurrence Component Properties
- -->
-
- <!-- one to many <property name="Recurrence" /> -->
-
- <property name="RecurrenceId" />
-
-
- <!--
- - Change Management Component Properties
- -->
- <property name="Created" />
-
- <property name="TimeStamp" />
-
- <property name="LastModified" />
-
- <property name="Sequence" />
-
- <!--
- -
- - Calendar Event
- -
- -->
- <joined-subclass name="NMail.DataTypes.Calendar.EventEntry" table="EventEntry">
- <key column="CalendarEntryId"/>
- </joined-subclass>
- </class>
-
- <!--
- -
- - Attendee
- -
- -->
- <class name="NMail.DataTypes.Calendar.Attendee" table="Attendee">
- <id type="Int32">
- <column name="AttendeeId" not-null="true"/>
- <generator class="native" />
- </id>
-
- <property name="Address" not-null="true"/>
-
- <many-to-one name="CalendarEntry"
- class="NMail.DataTypes.Calendar.CalendarEntry"
- column="CalendarEntryId" />
- </class>
-</hibernate-mapping>
\ No newline at end of file
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <tmy...@us...> - 2007-03-13 05:04:18
|
Revision: 175
http://svn.sourceforge.net/nmailserver/?rev=175&view=rev
Author: tmyroadctfig
Date: 2007-03-12 22:04:17 -0700 (Mon, 12 Mar 2007)
Log Message:
-----------
Added some local store data unit tests.
Modified Paths:
--------------
NMail/trunk/NMail.UnitTests/LocalStoreData/CreateUserTest1.cs
NMail/trunk/NMail.UnitTests/LocalStoreData/MySqlLocalStoreTests.cs
NMail/trunk/NMail.UnitTests/NMail.UnitTests.csproj
Added Paths:
-----------
NMail/trunk/NMail.UnitTests/LocalStoreData/CreateCalendarTest1.cs
NMail/trunk/NMail.UnitTests/LocalStoreData/CreateCalendarTest2.cs
NMail/trunk/NMail.UnitTests/LocalStoreData/CreateEventEntryTest1.cs
NMail/trunk/NMail.UnitTests/LocalStoreData/CreateUserTest2.cs
NMail/trunk/NMail.UnitTests/LocalStoreData/DeleteUserTest1.cs
NMail/trunk/NMail.UnitTests/LocalStoreData/DeleteUserTest2.cs
Removed Paths:
-------------
NMail/trunk/NMail.UnitTests/LocalStoreData/CalendarTests.cs
Deleted: NMail/trunk/NMail.UnitTests/LocalStoreData/CalendarTests.cs
===================================================================
--- NMail/trunk/NMail.UnitTests/LocalStoreData/CalendarTests.cs 2007-03-11 15:17:37 UTC (rev 174)
+++ NMail/trunk/NMail.UnitTests/LocalStoreData/CalendarTests.cs 2007-03-13 05:04:17 UTC (rev 175)
@@ -1,82 +0,0 @@
-using System;
-using System.Collections.Generic;
-using System.Text;
-
-using NUnit.Framework;
-
-using NMail.Configuration;
-using NMail.DataTypes.Calendar;
-using NMail.DataTypes.LocalStore;
-using NMail.LocalStoreData.MySql;
-
-namespace NMail.UnitTests.LocalStoreData {
- /// <summary>
- /// Calendar tests for the local store data.
- /// </summary>
- [TestFixture]
- public class CalendarTests : BaseLocalStoreDataTest {
-
- public void CreateCalendar(string name, int ownerId, int parentId) {
- Calendar c1 = new Calendar();
- c1.Name = name;
- c1.OwnerUserId = ownerId;
- c1.ParentFolderId = parentId;
-
- localStoreData.SaveCalandar(c1);
- }
-
- public void DeleteCalendar(int calendarId) {
- localStoreData.DeleteCalandar(calendarId);
- }
-
- [Test]
- public void TestCreateCalendar() {
- CreateCalendar("Test", 1, 1);
-
- // Clean up
- Calendar c = localStoreData.GetCalandar("Test", 1);
- DeleteCalendar(c.CalendarId);
- }
-
- [Test]
- public void TestCreateCalendarDuplicate() {
- CreateCalendar("Test", 1, 1);
-
- try {
- CreateCalendar("Test", 1, 1);
-
- Assert.Fail("Allowed duplicate calendar names.");
-
- } catch (ArgumentException ex) {
- // Ignore
- }
-
- // Clean up
- Calendar c = localStoreData.GetCalandar("Test", 1);
- localStoreData.DeleteCalandar(c.CalendarId);
- }
-
- [Test]
- public void TestCreateEventEntry() {
- CreateCalendar("Test", 1, 1);
-
- Calendar c1 = localStoreData.GetCalandar("Test", 1);
-
- DateTime startTime = DateTime.Now;
- EventEntry e1 = new EventEntry();
- e1.Calendar = c1;
- e1.Categories.Add("Sample category.");
- e1.Classification = NMail.DataTypes.Classification.Private;
- e1.StartTime = startTime;
-
- localStoreData.SaveCalendarEntry(e1);
-
- IList<CalendarEntry> entries = localStoreData.GetCalendarEntries(startTime, DateTime.Now, c1.CalendarId);
-
- Assert.AreEqual(1, entries.Count, "Entries.count == 1");
- Assert.AreEqual(e1.EntryId, entries[0].EntryId, "e1.EntryId == entries[0].EntryId");
-
- DeleteCalendar(c1.CalendarId);
- }
- }
-}
Added: NMail/trunk/NMail.UnitTests/LocalStoreData/CreateCalendarTest1.cs
===================================================================
--- NMail/trunk/NMail.UnitTests/LocalStoreData/CreateCalendarTest1.cs (rev 0)
+++ NMail/trunk/NMail.UnitTests/LocalStoreData/CreateCalendarTest1.cs 2007-03-13 05:04:17 UTC (rev 175)
@@ -0,0 +1,31 @@
+using System;
+using System.Collections.Generic;
+using System.Text;
+
+using NUnit.Framework;
+
+using NMail.Configuration;
+using NMail.DataTypes.Calendar;
+using NMail.DataTypes.LocalStore;
+using NMail.LocalStoreData.MySql;
+
+namespace NMail.UnitTests.LocalStoreData {
+ /// <summary>
+ /// Calendar tests for the local store data.
+ /// </summary>
+ [TestFixture]
+ public class CreateCalendarTest1 : BaseLocalStoreDataTest {
+
+ [Test]
+ public void TestCreateCalendar() {
+ Calendar c1 = new Calendar();
+ c1.Name = "Test";
+ c1.OwnerUserId = 1;
+ c1.ParentFolderId = 1;
+
+ localStoreData.SaveCalandar(c1);
+
+ Assert.IsTrue(c1.CalendarId > 0, "Valid calendar Id.");
+ }
+ }
+}
Added: NMail/trunk/NMail.UnitTests/LocalStoreData/CreateCalendarTest2.cs
===================================================================
--- NMail/trunk/NMail.UnitTests/LocalStoreData/CreateCalendarTest2.cs (rev 0)
+++ NMail/trunk/NMail.UnitTests/LocalStoreData/CreateCalendarTest2.cs 2007-03-13 05:04:17 UTC (rev 175)
@@ -0,0 +1,41 @@
+using System;
+using System.Collections.Generic;
+using System.Text;
+
+using NUnit.Framework;
+
+using NMail.Configuration;
+using NMail.DataTypes.Calendar;
+using NMail.DataTypes.LocalStore;
+using NMail.LocalStoreData.MySql;
+
+namespace NMail.UnitTests.LocalStoreData {
+ /// <summary>
+ /// Calendar tests for the local store data.
+ /// </summary>
+ [TestFixture]
+ public class CreateCalendarTest2 : BaseLocalStoreDataTest {
+
+ [Test]
+ [ExpectedException(typeof(System.Data.DuplicateNameException))]
+ public void TestCreateCalendarDuplicate() {
+ Calendar c1 = new Calendar();
+ c1.Name = "Test";
+ c1.OwnerUserId = 1;
+ c1.ParentFolderId = 1;
+
+ localStoreData.SaveCalandar(c1);
+
+ Assert.IsTrue(c1.CalendarId > 0, "Valid calendar Id.");
+
+ Calendar c2 = new Calendar();
+ c2.Name = "Test";
+ c2.OwnerUserId = 1;
+ c2.ParentFolderId = 1;
+
+ localStoreData.SaveCalandar(c2);
+
+ Assert.Fail("Allowed duplicate calendar names.");
+ }
+ }
+}
Added: NMail/trunk/NMail.UnitTests/LocalStoreData/CreateEventEntryTest1.cs
===================================================================
--- NMail/trunk/NMail.UnitTests/LocalStoreData/CreateEventEntryTest1.cs (rev 0)
+++ NMail/trunk/NMail.UnitTests/LocalStoreData/CreateEventEntryTest1.cs 2007-03-13 05:04:17 UTC (rev 175)
@@ -0,0 +1,48 @@
+using System;
+using System.Collections.Generic;
+using System.Text;
+
+using NUnit.Framework;
+
+using NMail.Configuration;
+using NMail.DataTypes.Calendar;
+using NMail.DataTypes.LocalStore;
+using NMail.LocalStoreData.MySql;
+
+namespace NMail.UnitTests.LocalStoreData {
+ /// <summary>
+ /// Calendar tests for the local store data.
+ /// </summary>
+ [TestFixture]
+ public class CreateEventEntryTest1 : BaseLocalStoreDataTest {
+
+ [Test]
+ public void TestCreateEventEntry() {
+ Calendar c1 = new Calendar();
+ c1.Name = "Test";
+ c1.OwnerUserId = 1;
+ c1.ParentFolderId = 1;
+
+ localStoreData.SaveCalandar(c1);
+
+ Assert.IsTrue(c1.CalendarId > 0, "Valid calendar Id.");
+
+ Calendar c2 = localStoreData.GetCalandar("Test", c1.CalendarId);
+
+ DateTime startTime = DateTime.Now;
+ EventEntry e1 = new EventEntry();
+ e1.Calendar = c2;
+ e1.OwnerUserId = c2.OwnerUserId;
+ e1.Categories.Add("Sample category.");
+ e1.Classification = NMail.DataTypes.Classification.Private;
+ e1.StartTime = startTime;
+
+ localStoreData.SaveCalendarEntry(e1);
+
+ IList<CalendarEntry> entries = localStoreData.GetCalendarEntries(startTime, DateTime.Now, c2.CalendarId);
+
+ Assert.AreEqual(1, entries.Count, "Entries.count == 1");
+ Assert.AreEqual(e1.EntryId, entries[0].EntryId, "e1.EntryId == entries[0].EntryId");
+ }
+ }
+}
Modified: NMail/trunk/NMail.UnitTests/LocalStoreData/CreateUserTest1.cs
===================================================================
--- NMail/trunk/NMail.UnitTests/LocalStoreData/CreateUserTest1.cs 2007-03-11 15:17:37 UTC (rev 174)
+++ NMail/trunk/NMail.UnitTests/LocalStoreData/CreateUserTest1.cs 2007-03-13 05:04:17 UTC (rev 175)
@@ -18,7 +18,12 @@
[Test]
public void TestCreateUser() {
- //this.localStoreData.CreateUser();
+ LocalStoreUser user = new LocalStoreUser();
+ user.Username = "Test";
+ this.localStoreData.CreateUser(user);
+
+ Assert.IsTrue(user.UserId > 0, "Valid user Id.");
+ Assert.IsTrue(user.UserFolderId > 0, "Valid user folder Id.");
}
}
}
Added: NMail/trunk/NMail.UnitTests/LocalStoreData/CreateUserTest2.cs
===================================================================
--- NMail/trunk/NMail.UnitTests/LocalStoreData/CreateUserTest2.cs (rev 0)
+++ NMail/trunk/NMail.UnitTests/LocalStoreData/CreateUserTest2.cs 2007-03-13 05:04:17 UTC (rev 175)
@@ -0,0 +1,36 @@
+using System;
+using System.Collections.Generic;
+using System.Text;
+
+using NUnit.Framework;
+
+using NMail.Configuration;
+using NMail.DataTypes.Calendar;
+using NMail.DataTypes.LocalStore;
+using NMail.LocalStoreData.MySql;
+
+namespace NMail.UnitTests.LocalStoreData {
+ /// <summary>
+ /// Tests creating a duplicate user.
+ /// </summary>
+ [TestFixture]
+ public class CreateUserTest2 : BaseLocalStoreDataTest {
+
+ [Test]
+ [ExpectedException(typeof(System.Data.DuplicateNameException))]
+ public void TestCreateDuplicateUser() {
+ LocalStoreUser user1 = new LocalStoreUser();
+ user1.Username = "Test";
+ this.localStoreData.CreateUser(user1);
+
+ Assert.IsTrue(user1.UserId > 0, "Valid user Id.");
+ Assert.IsTrue(user1.UserFolderId > 0, "Valid user folder Id.");
+
+ LocalStoreUser user2 = new LocalStoreUser();
+ user2.Username = "Test";
+ this.localStoreData.CreateUser(user2);
+
+ Assert.Fail("Allowed duplicate user names.");
+ }
+ }
+}
Added: NMail/trunk/NMail.UnitTests/LocalStoreData/DeleteUserTest1.cs
===================================================================
--- NMail/trunk/NMail.UnitTests/LocalStoreData/DeleteUserTest1.cs (rev 0)
+++ NMail/trunk/NMail.UnitTests/LocalStoreData/DeleteUserTest1.cs 2007-03-13 05:04:17 UTC (rev 175)
@@ -0,0 +1,44 @@
+using System;
+using System.Collections.Generic;
+using System.Text;
+
+using NUnit.Framework;
+
+using NMail.Configuration;
+using NMail.DataTypes.Calendar;
+using NMail.DataTypes.LocalStore;
+using NMail.LocalStoreData.MySql;
+
+namespace NMail.UnitTests.LocalStoreData {
+ /// <summary>
+ /// Tests deleting a user.
+ /// </summary>
+ [TestFixture]
+ public class DeleteUserTest1 : BaseLocalStoreDataTest {
+
+ [Test]
+ public void TestDeleteUser() {
+ LocalStoreUser user1 = new LocalStoreUser();
+ user1.Username = "Test";
+ this.localStoreData.CreateUser(user1);
+
+ Assert.IsTrue(user1.UserId > 0, "Valid user Id.");
+ Assert.IsTrue(user1.UserFolderId > 0, "Valid user folder Id.");
+
+ IList<StoreFolder> userFolders = this.localStoreData.GetUserFolders(user1.UserId);
+
+ Assert.IsNotNull(userFolders, "User folders list not null.");
+ Assert.IsTrue(userFolders.Count > 0, "User has folders.");
+
+ foreach (StoreFolder folder in userFolders) {
+ this.localStoreData.DeleteFolder(folder.FolderId);
+ }
+
+ this.localStoreData.DeleteUser(user1.UserId);
+
+ IList<LocalStoreUser> users = this.localStoreData.GetUsers();
+
+ Assert.AreEqual(0, users.Count, "Users.count == 0");
+ }
+ }
+}
Added: NMail/trunk/NMail.UnitTests/LocalStoreData/DeleteUserTest2.cs
===================================================================
--- NMail/trunk/NMail.UnitTests/LocalStoreData/DeleteUserTest2.cs (rev 0)
+++ NMail/trunk/NMail.UnitTests/LocalStoreData/DeleteUserTest2.cs 2007-03-13 05:04:17 UTC (rev 175)
@@ -0,0 +1,39 @@
+using System;
+using System.Collections.Generic;
+using System.Text;
+
+using NUnit.Framework;
+
+using NMail.Configuration;
+using NMail.DataTypes.Calendar;
+using NMail.DataTypes.LocalStore;
+using NMail.LocalStoreData.MySql;
+
+namespace NMail.UnitTests.LocalStoreData {
+ /// <summary>
+ /// Tests deleting a user.
+ /// </summary>
+ [TestFixture]
+ public class DeleteUserTest2 : BaseLocalStoreDataTest {
+
+ [Test]
+ [ExpectedException(typeof(System.Data.ConstraintException))]
+ public void TestDeleteUser() {
+ LocalStoreUser user1 = new LocalStoreUser();
+ user1.Username = "Test";
+ this.localStoreData.CreateUser(user1);
+
+ Assert.IsTrue(user1.UserId > 0, "Valid user Id.");
+ Assert.IsTrue(user1.UserFolderId > 0, "Valid user folder Id.");
+
+ IList<StoreFolder> userFolders = this.localStoreData.GetUserFolders(user1.UserId);
+
+ Assert.IsNotNull(userFolders, "User folders list not null.");
+ Assert.IsTrue(userFolders.Count > 0, "User has folders.");
+
+ this.localStoreData.DeleteUser(user1.UserId);
+
+ Assert.Fail("Failed to throw an exception when user has folders.");
+ }
+ }
+}
Modified: NMail/trunk/NMail.UnitTests/LocalStoreData/MySqlLocalStoreTests.cs
===================================================================
--- NMail/trunk/NMail.UnitTests/LocalStoreData/MySqlLocalStoreTests.cs 2007-03-11 15:17:37 UTC (rev 174)
+++ NMail/trunk/NMail.UnitTests/LocalStoreData/MySqlLocalStoreTests.cs 2007-03-13 05:04:17 UTC (rev 175)
@@ -27,16 +27,18 @@
public const string TestFolder = "testfolder";
- [Test]
- public void TestCreateUser() {
- LocalStoreUserResult result = localStoreData.CreateUser(TestUsername, null, null);
- Assert.AreEqual(LocalStoreUserResult.OkSuccessful, result, "User created successfully.");
+ //[Test]
+ //public void TestCreateUser() {
+ // LocalStoreUser user = new LocalStoreUser();
+ // user.Username = TestUsername;
+ // LocalStoreUserResult result = localStoreData.CreateUser(user);
+ // Assert.AreEqual(LocalStoreUserResult.OkSuccessful, result, "User created successfully.");
- LocalStoreUser user = localStoreData.GetUser(TestUsername);
- Assert.IsNotNull(user, "Valid user.");
- Assert.IsTrue(user.UserId > 0, "Valid user Id");
- Assert.IsTrue(user.UserFolderId > 0, "Valid user folder Id");
- }
+ // LocalStoreUser user = localStoreData.GetUser(TestUsername);
+ // Assert.IsNotNull(user, "Valid user.");
+ // Assert.IsTrue(user.UserId > 0, "Valid user Id");
+ // Assert.IsTrue(user.UserFolderId > 0, "Valid user folder Id");
+ //}
[Test]
public void CreateFolder() {
@@ -53,34 +55,34 @@
Assert.AreEqual(LocalStoreFolderResult.OkSuccessful, result, "Created folder successfully.");
}
- [Test]
- public void TestDeleteUser() {
- // Make an initial delete attempt (which should fail)
- int userId = localStoreData.GetUser(TestUsername).UserId;
- LocalStoreUserResult result = localStoreData.DeleteUser(userId);
- Assert.AreEqual(LocalStoreUserResult.UserStillHasFolders, result, "User deleted fails with still has folders.");
+ //[Test]
+ //public void TestDeleteUser() {
+ // // Make an initial delete attempt (which should fail)
+ // int userId = localStoreData.GetUser(TestUsername).UserId;
+ // LocalStoreUserResult result = localStoreData.DeleteUser(userId);
+ // Assert.AreEqual(LocalStoreUserResult.UserStillHasFolders, result, "User deleted fails with still has folders.");
- // Delete all the user's folders
- Queue<StoreFolder> folders = new Queue<StoreFolder>(localStoreData.GetUserFolders(userId));
+ // // Delete all the user's folders
+ // Queue<StoreFolder> folders = new Queue<StoreFolder>(localStoreData.GetUserFolders(userId));
- while (folders.Count > 0) {
- StoreFolder folder = folders.Dequeue();
- LocalStoreFolderResult folderResult = localStoreData.DeleteFolder(folder.FolderId);
+ // while (folders.Count > 0) {
+ // StoreFolder folder = folders.Dequeue();
+ // LocalStoreFolderResult folderResult = localStoreData.DeleteFolder(folder.FolderId);
- if (folderResult == LocalStoreFolderResult.OkSuccessful) {
- continue;
+ // if (folderResult == LocalStoreFolderResult.OkSuccessful) {
+ // continue;
- } else if (folderResult != LocalStoreFolderResult.HasChildren) {
- throw new InvalidOperationException(string.Format("Error deleting user's folder. Id: {0}", folder.FolderId));
+ // } else if (folderResult != LocalStoreFolderResult.HasChildren) {
+ // throw new InvalidOperationException(string.Format("Error deleting user's folder. Id: {0}", folder.FolderId));
- } else {
- folders.Enqueue(folder);
- }
- }
+ // } else {
+ // folders.Enqueue(folder);
+ // }
+ // }
- // Attempt to delete the user again
- result = localStoreData.DeleteUser(userId);
- Assert.AreEqual(LocalStoreUserResult.OkSuccessful, result, "User deleted successfully.");
- }
+ // // Attempt to delete the user again
+ // result = localStoreData.DeleteUser(userId);
+ // Assert.AreEqual(LocalStoreUserResult.OkSuccessful, result, "User deleted successfully.");
+ //}
}
}
Modified: NMail/trunk/NMail.UnitTests/NMail.UnitTests.csproj
===================================================================
--- NMail/trunk/NMail.UnitTests/NMail.UnitTests.csproj 2007-03-11 15:17:37 UTC (rev 174)
+++ NMail/trunk/NMail.UnitTests/NMail.UnitTests.csproj 2007-03-13 05:04:17 UTC (rev 175)
@@ -52,7 +52,12 @@
<Compile Include="DataTypes\Helper\MimeHelperTests.cs" />
<Compile Include="DataTypes\Helper\StringTokenizerTests.cs" />
<Compile Include="LocalStoreData\BaseLocalStoreDataTest.cs" />
- <Compile Include="LocalStoreData\CalendarTests.cs" />
+ <Compile Include="LocalStoreData\DeleteUserTest2.cs" />
+ <Compile Include="LocalStoreData\DeleteUserTest1.cs" />
+ <Compile Include="LocalStoreData\CreateEventEntryTest1.cs" />
+ <Compile Include="LocalStoreData\CreateCalendarTest2.cs" />
+ <Compile Include="LocalStoreData\CreateCalendarTest1.cs" />
+ <Compile Include="LocalStoreData\CreateUserTest2.cs" />
<Compile Include="LocalStoreData\CreateUserTest1.cs" />
<Compile Include="LocalStoreData\MySqlLocalStoreTests.cs" />
<Compile Include="Properties\AssemblyInfo.cs" />
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <tmy...@us...> - 2007-03-11 15:17:37
|
Revision: 174
http://svn.sourceforge.net/nmailserver/?rev=174&view=rev
Author: tmyroadctfig
Date: 2007-03-11 08:17:37 -0700 (Sun, 11 Mar 2007)
Log Message:
-----------
Added folder unit tests.
Modified Paths:
--------------
NMail/trunk/NMail.UnitTests/NMail.UnitTests.csproj
Added Paths:
-----------
NMail/trunk/NMail.UnitTests/DataTypes/FolderTests.cs
NMail/trunk/NMail.UnitTests/LocalStoreData/CreateUserTest1.cs
Added: NMail/trunk/NMail.UnitTests/DataTypes/FolderTests.cs
===================================================================
--- NMail/trunk/NMail.UnitTests/DataTypes/FolderTests.cs (rev 0)
+++ NMail/trunk/NMail.UnitTests/DataTypes/FolderTests.cs 2007-03-11 15:17:37 UTC (rev 174)
@@ -0,0 +1,59 @@
+/*
+ * Copyright 2004-2006 Luke Quinane and Daniel Frampton
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ */
+
+using System;
+
+using NUnit.Framework;
+
+using NMail.DataTypes;
+
+namespace NMail.UnitTests.DataTypes {
+ /// <summary>
+ /// Unit tests for the Folder class.
+ /// </summary>
+ [TestFixture]
+ public class FolderTests {
+ /// <summary>
+ /// Checks if valid folder names are accepted.
+ /// </summary>
+ [Test]
+ public void CheckValidFolderNames() {
+ Folder f1 = new Folder("#Namespace.Folder");
+ Folder f2 = new Folder("#N.F.S");
+ Folder f3 = new Folder("#N.F.%");
+ Folder f4 = new Folder("#N.F.*");
+ }
+
+ [Test]
+ [ExpectedException(typeof(ArgumentException))]
+ public void InvalidFolderTest1() {
+ Folder f1 = new Folder("#Namespace");
+ }
+
+ [Test]
+ [ExpectedException(typeof(ArgumentException))]
+ public void InvalidFolderTest2() {
+ Folder f1 = new Folder("#Na#mespace.Folder");
+ }
+
+ [Test]
+ public void InboxTest1() {
+ Folder f1 = new Folder("#Ns.INBOX");
+ Assert.AreEqual(Folder.Inbox, f1.FolderName);
+ }
+ }
+}
Added: NMail/trunk/NMail.UnitTests/LocalStoreData/CreateUserTest1.cs
===================================================================
--- NMail/trunk/NMail.UnitTests/LocalStoreData/CreateUserTest1.cs (rev 0)
+++ NMail/trunk/NMail.UnitTests/LocalStoreData/CreateUserTest1.cs 2007-03-11 15:17:37 UTC (rev 174)
@@ -0,0 +1,24 @@
+using System;
+using System.Collections.Generic;
+using System.Text;
+
+using NUnit.Framework;
+
+using NMail.Configuration;
+using NMail.DataTypes.Calendar;
+using NMail.DataTypes.LocalStore;
+using NMail.LocalStoreData.MySql;
+
+namespace NMail.UnitTests.LocalStoreData {
+ /// <summary>
+ /// Tests creating a user.
+ /// </summary>
+ [TestFixture]
+ public class CreateUserTest1 : BaseLocalStoreDataTest {
+
+ [Test]
+ public void TestCreateUser() {
+ //this.localStoreData.CreateUser();
+ }
+ }
+}
Modified: NMail/trunk/NMail.UnitTests/NMail.UnitTests.csproj
===================================================================
--- NMail/trunk/NMail.UnitTests/NMail.UnitTests.csproj 2007-03-08 09:51:12 UTC (rev 173)
+++ NMail/trunk/NMail.UnitTests/NMail.UnitTests.csproj 2007-03-11 15:17:37 UTC (rev 174)
@@ -45,13 +45,15 @@
<ItemGroup>
<Compile Include="DataTypes\DomainTests.cs" />
<Compile Include="DataTypes\EmailAddressTests.cs" />
+ <Compile Include="DataTypes\FolderTests.cs" />
<Compile Include="DataTypes\HostTests.cs" />
<Compile Include="DataTypes\MessageHeaderTests.cs" />
<Compile Include="DNSCacheTests.cs" />
- <Compile Include="Helper\MimeHelperTests.cs" />
- <Compile Include="Helper\StringTokenizerTests.cs" />
+ <Compile Include="DataTypes\Helper\MimeHelperTests.cs" />
+ <Compile Include="DataTypes\Helper\StringTokenizerTests.cs" />
<Compile Include="LocalStoreData\BaseLocalStoreDataTest.cs" />
<Compile Include="LocalStoreData\CalendarTests.cs" />
+ <Compile Include="LocalStoreData\CreateUserTest1.cs" />
<Compile Include="LocalStoreData\MySqlLocalStoreTests.cs" />
<Compile Include="Properties\AssemblyInfo.cs" />
<Compile Include="Resources\ResourceHelper.cs" />
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <tmy...@us...> - 2007-03-08 09:51:11
|
Revision: 173
http://svn.sourceforge.net/nmailserver/?rev=173&view=rev
Author: tmyroadctfig
Date: 2007-03-08 01:51:12 -0800 (Thu, 08 Mar 2007)
Log Message:
-----------
Work on NHibernate local store data implementation.
Modified Paths:
--------------
NMail/trunk/NMail.LocalStoreData.MySql/Resources/NMail.LocalStoreData.MySql.hbm.xml
NMail/trunk/NMail.LocalStoreData.MySql/Resources/hibernate-configuration.xml
NMail/trunk/NMail.LocalStoreData.NHibernate/NMail.LocalStoreData.NHibernate.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-08 09:46:39 UTC (rev 172)
+++ NMail/trunk/NMail.LocalStoreData.MySql/Resources/NMail.LocalStoreData.MySql.hbm.xml 2007-03-08 09:51:12 UTC (rev 173)
@@ -1,7 +1,175 @@
<?xml version="1.0" encoding="utf-8" ?>
<hibernate-mapping xmlns="urn:nhibernate-mapping-2.2" namespace="NMail" assembly="NMail" default-lazy="false">
<!--
+
+ TODO:
+ - Message (parts)
+ - Objects
+ - 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
-
-->
@@ -12,7 +180,7 @@
</id>
<property name="Name" not-null="true"/>
-
+
<!-- TODO: make this a many to one relationship with folder -->
<property name="ParentFolderId" />
@@ -36,8 +204,8 @@
<column name="CalendarEntryId" not-null="true"/>
<generator class="native" />
</id>
-
-
+
+
<!--
- Descriptive Properties
-->
@@ -48,20 +216,20 @@
<index column="CategoryIndex" type="Int32" />
<element column="Category" type="String" />
</list>
-
+
<property name="Description" />
-
+
<!--<property name="Status" />-->
-
+
<property name="Summary" />
-
-
+
+
<!--
- Date/Time Properties
-->
<property name="StartTime" not-null="true" />
-
+
<!--
- Relationship Component Properties
-->
@@ -80,21 +248,21 @@
class="NMail.DataTypes.Calendar.Calendar"
column="CalendarId" />
-
+
<!--
- Recurrence Component Properties
-->
<!-- one to many <property name="Recurrence" /> -->
-
+
<property name="RecurrenceId" />
-
+
<!--
- Change Management Component Properties
-->
<property name="Created" />
-
+
<property name="TimeStamp" />
<property name="LastModified" />
Modified: NMail/trunk/NMail.LocalStoreData.MySql/Resources/hibernate-configuration.xml
===================================================================
--- NMail/trunk/NMail.LocalStoreData.MySql/Resources/hibernate-configuration.xml 2007-03-08 09:46:39 UTC (rev 172)
+++ NMail/trunk/NMail.LocalStoreData.MySql/Resources/hibernate-configuration.xml 2007-03-08 09:51:12 UTC (rev 173)
@@ -2,8 +2,9 @@
<hibernate-configuration xmlns="urn:nhibernate-configuration-2.2">
<session-factory>
<property name="connection.provider">NHibernate.Connection.DriverConnectionProvider</property>
- <property name="connection.driver_class">NHibernate.Driver.MySqlDataDriver</property>
- <property name="connection.connection_string">Database=NMailLocalStore;Uid=NMail;Password=moo</property>
- <property name="dialect">NHibernate.Dialect.MySQLDialect</property>
+ <property name="connection.driver_class">NHibernate.Driver.SqlClientDriver</property>
+ <property name="connection.connection_string">Data Source=127.0.0.1;Initial Catalog=NMailLocalStore;Integrated Security=True</property>
+ <property name="dialect">NHibernate.Dialect.MsSql2005Dialect</property>
+ <property name="hibernate.query.substitutions">true 1, false 0</property>
</session-factory>
</hibernate-configuration>
Modified: NMail/trunk/NMail.LocalStoreData.NHibernate/NMail.LocalStoreData.NHibernate.hbm.xml
===================================================================
--- NMail/trunk/NMail.LocalStoreData.NHibernate/NMail.LocalStoreData.NHibernate.hbm.xml 2007-03-08 09:46:39 UTC (rev 172)
+++ NMail/trunk/NMail.LocalStoreData.NHibernate/NMail.LocalStoreData.NHibernate.hbm.xml 2007-03-08 09:51:12 UTC (rev 173)
@@ -12,6 +12,32 @@
- Mail domain
-->
+
+ <!--
+ -
+ - 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="Name" not-null="true"/>
+
+ <property name="NameSpace" not-null="true" />
+
+ <many-to-one name="ParentId" foreign-key="FolderId" />
+
+ <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>
<!--
-
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <tmy...@us...> - 2007-03-08 09:46:41
|
Revision: 172
http://svn.sourceforge.net/nmailserver/?rev=172&view=rev
Author: tmyroadctfig
Date: 2007-03-08 01:46:39 -0800 (Thu, 08 Mar 2007)
Log Message:
-----------
Refactored folder.
Modified Paths:
--------------
NMail/trunk/NMail/DataTypes/Folder.cs
Modified: NMail/trunk/NMail/DataTypes/Folder.cs
===================================================================
--- NMail/trunk/NMail/DataTypes/Folder.cs 2007-03-08 09:45:38 UTC (rev 171)
+++ NMail/trunk/NMail/DataTypes/Folder.cs 2007-03-08 09:46:39 UTC (rev 172)
@@ -27,36 +27,27 @@
public class Folder {
#region Constructors
/// <summary>
+ /// Creates a new folder.
+ /// </summary>
+ public Folder() { }
+
+ /// <summary>
/// Creates a new folder from the given string.
/// </summary>
/// <param name="newFolder">The folder as a string.</param>
public Folder(string newFolder) {
- // TODO: validation / encoding of unicode strings
- this.delimiter = NMailConfiguration.Current.LocalStore.FolderDelimiter;
- this.folder = newFolder.Trim();
-
- removeWildCards();
-
- // Fully qualified folder, need to process out the namespace
- if (this.folder.StartsWith("#")) {
- // Remove the #
- this.folder = this.folder.Remove(0, 1);
-
- if (this.folder.IndexOf(this.delimiter) > 0) {
- // Split the folder and namespace out
- this.nameSpace = this.folder.Substring(0, this.folder.IndexOf(this.delimiter));
- this.folder = this.folder.Remove(0, this.nameSpace.Length + 1);
- } else {
- // Only a namespace given
- throw new ArgumentException("Only a namespace present.");
- }
+ if (newFolder.IndexOf(this.delimiter) > 0) {
+ // Split the folder and namespace out
+ this.nameSpace = newFolder.Substring(0, newFolder.IndexOf(this.delimiter));
+ this.folder = newFolder.Remove(0, this.nameSpace.Length + 1);
} else {
- throw new ArgumentException("No namespace present.");
+ // Only a namespace given
+ throw new ArgumentException("Only a namespace present.");
}
- removeTrailingDelimiters();
- fixFolderName();
+ this.folder = FixAndValidateFolderName(this.folder, this.delimiter);
+ this.nameSpace = FixAndValidateNameSpace(this.nameSpace, this.delimiter);
}
/// <summary>
@@ -65,20 +56,8 @@
/// <param name="newNameSpace">The namespace.</param>
/// <param name="newFolder">The folder as a string.</param>
public Folder(string newNameSpace, string newFolder) {
- // TODO: validation / encoding of unicode strings
-
- this.delimiter = NMailConfiguration.Current.LocalStore.FolderDelimiter;
- this.folder = newFolder.Trim();
- this.nameSpace = newNameSpace.Trim();
-
- // Remove the # if present
- if (this.nameSpace.StartsWith("#")) {
- this.nameSpace = this.nameSpace.Remove(0, 1);
- }
-
- removeWildCards();
- removeTrailingDelimiters();
- fixFolderName();
+ this.folder = FixAndValidateFolderName(newFolder, this.delimiter);
+ this.nameSpace = FixAndValidateFolderName(newNameSpace, this.delimiter);
}
/// <summary>
@@ -91,36 +70,70 @@
this.nameSpace = parent.nameSpace;
this.folder = parent.folder + this.delimiter + childName.Trim();
- removeWildCards();
- removeTrailingDelimiters();
- fixFolderName();
+ this.folder = FixAndValidateFolderName(this.folder, this.delimiter);
+ this.nameSpace = FixAndValidateNameSpace(this.nameSpace, this.delimiter);
}
+ #endregion
- private void removeWildCards() {
+ #region Fix And Validate Folder Name
+ /// <summary>
+ /// Fixes and validates the given folder name.
+ /// </summary>
+ /// <param name="folder">The name to fix and validate.</param>
+ /// <param name="delimiter">The delimiter to use.</param>
+ /// <returns>The fixed folder name.</returns>
+ protected static string FixAndValidateFolderName(string folder, char delimiter) {
+ // TODO: validation / encoding of unicode strings
+
// Remove any wildcards
- if (this.folder.EndsWith("*") || this.folder.EndsWith("%")) {
- this.folder = this.folder.Substring(0, this.folder.Length - 1);
+ if (folder.EndsWith("*") || folder.EndsWith("%")) {
+ folder = folder.Substring(0, folder.Length - 1);
}
- }
- private void removeTrailingDelimiters() {
// Remove a trailing delimiter if present
- if (this.folder.EndsWith(string.Empty + delimiter)) {
- this.folder = this.folder.Remove(this.folder.Length - 1, 1);
+ if (folder.EndsWith(string.Empty + delimiter)) {
+ folder = folder.Remove(folder.Length - 1, 1);
}
- }
- private void fixFolderName() {
// Convert any "INBOX" or "" to "Inbox"
- if (this.folder.ToUpper().StartsWith("INBOX")) {
- this.folder = "Inbox" + this.folder.Substring(5, this.folder.Length - 5);
+ if (folder.ToUpper().StartsWith("INBOX")) {
+ folder = "Inbox" + folder.Substring(5, folder.Length - 5);
}
- if (this.folder.Length == 0) {
- this.folder = "Inbox";
+ if (folder.Length == 0) {
+ folder = "Inbox";
}
+
+ return folder;
}
#endregion
+ #region Fix And Validate Name Space
+ /// <summary>
+ /// Fixes and validates the given namespace.
+ /// </summary>
+ /// <param name="nameSpace">The namespace to fix and validate.</param>
+ /// <param name="delimiter">The delimiter to use.</param>
+ /// <returns>The fixed namespace.</returns>
+ protected static string FixAndValidateNameSpace(string nameSpace, char delimiter) {
+ string result = nameSpace.Trim();
+
+ // Remove the leading # if present
+ if (result.StartsWith("#")) {
+ result = result.Remove(0, 1);
+ }
+
+ if (result.IndexOf('#') != -1) {
+ throw new ArgumentException("Invalid character '#' in namespace.");
+ }
+
+ if (result.IndexOf(delimiter) != -1) {
+ throw new ArgumentException("Delimiter present in namespace.");
+ }
+
+ return result;
+ }
+ #endregion
+
#region Folder Hierarchy
/// <summary>
/// Checks if the given folder is an ancestor of the current folder.
@@ -221,7 +234,9 @@
get {
return this.folder;
}
-
+ set {
+ this.folder = FixAndValidateFolderName(value, this.delimiter);
+ }
}
private string nameSpace;
@@ -233,6 +248,9 @@
get {
return this.nameSpace;
}
+ set {
+ this.nameSpace = FixAndValidateNameSpace(value, this.delimiter);
+ }
}
/// <summary>
@@ -244,7 +262,7 @@
}
}
- private char delimiter;
+ private char delimiter = NMailConfiguration.Current.LocalStore.FolderDelimiter;
/// <summary>
/// The delimiter for subfolders in above or below this folder.
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <tmy...@us...> - 2007-03-08 09:45:41
|
Revision: 171
http://svn.sourceforge.net/nmailserver/?rev=171&view=rev
Author: tmyroadctfig
Date: 2007-03-08 01:45:38 -0800 (Thu, 08 Mar 2007)
Log Message:
-----------
Added owner to StoreFolder.
Modified Paths:
--------------
NMail/trunk/NMail/DataTypes/LocalStore/StoreFolder.cs
NMail/trunk/NMail.LocalStoreData.MySql/MySqlLocalStore.sql
NMail/trunk/NMail.LocalStoreData.MySql/MySqlLocalStoreData.cs
NMail/trunk/NMail.RemoteAccessService.Serializers/DataTypes/LocalStore/StoreFolderSerializer.cs
Modified: NMail/trunk/NMail/DataTypes/LocalStore/StoreFolder.cs
===================================================================
--- NMail/trunk/NMail/DataTypes/LocalStore/StoreFolder.cs 2007-03-08 09:43:35 UTC (rev 170)
+++ NMail/trunk/NMail/DataTypes/LocalStore/StoreFolder.cs 2007-03-08 09:45:38 UTC (rev 171)
@@ -16,6 +16,7 @@
*/
using System;
+using System.Collections.Generic;
using NMail.Configuration;
using NMail.DataTypes;
@@ -25,17 +26,24 @@
/// A folder that has been obtained from the local store.
/// </summary>
[Serializable]
- public class StoreFolder : Folder {
+ public class StoreFolder : Folder {
/// <summary>
/// Creates a new store folder.
/// </summary>
+ public StoreFolder() : base() { }
+
+ /// <summary>
+ /// Creates a new store folder.
+ /// </summary>
/// <param name="newFolder">The folder name.</param>
/// <param name="folderId">The folder Id.</param>
/// <param name="parentId">The Id of this folder's parent or null if non.</param>
+ /// <param name="ownerUserId">The user that owns this folder.</param>
/// <param name="hasChildren">A flag indicating if this folder has subfolder.s</param>
- public StoreFolder(string newFolder, int folderId, int? parentId, bool hasChildren) : base(newFolder) {
+ public StoreFolder(string newFolder, int folderId, int? parentId, int ownerUserId, bool hasChildren) : base(newFolder) {
this.folderId = folderId;
this.parentId = parentId;
+ this.ownerUserId = ownerUserId;
this.hasChildren = hasChildren;
}
@@ -46,10 +54,12 @@
/// <param name="newFolder">The folder name.</param>
/// <param name="folderId">The folder Id.</param>
/// <param name="parentId">The Id of this folder's parent or null if non.</param>
+ /// <param name="ownerUserId">The user that owns this folder.</param>
/// <param name="hasChildren">A flag indicating if this folder has subfolder.s</param>
- public StoreFolder(string newNameSpace, string newFolder, int folderId, int? parentId, bool hasChildren) : base(newNameSpace, newFolder) {
+ public StoreFolder(string newNameSpace, string newFolder, int folderId, int? parentId, int ownerUserId, bool hasChildren) : base(newNameSpace, newFolder) {
this.folderId = folderId;
this.parentId = parentId;
+ this.ownerUserId = ownerUserId;
this.hasChildren = hasChildren;
}
@@ -80,6 +90,16 @@
this.parentId = value;
}
}
+
+ private int ownerUserId;
+
+ /// <summary>
+ /// The user that owns this folder.
+ /// </summary>
+ public int OwnerUserId {
+ get { return ownerUserId; }
+ set { ownerUserId = value; }
+ }
private bool hasChildren;
@@ -94,5 +114,12 @@
this.hasChildren = value;
}
}
+
+ private IList<int> childrenIds;
+
+ public IList<int> ChildrenIds {
+ get { return childrenIds; }
+ set { childrenIds = value; }
+ }
}
}
Modified: NMail/trunk/NMail.LocalStoreData.MySql/MySqlLocalStore.sql
===================================================================
--- NMail/trunk/NMail.LocalStoreData.MySql/MySqlLocalStore.sql 2007-03-08 09:43:35 UTC (rev 170)
+++ NMail/trunk/NMail.LocalStoreData.MySql/MySqlLocalStore.sql 2007-03-08 09:45:38 UTC (rev 171)
@@ -275,7 +275,7 @@
BEGIN
SELECT
- f.FolderId, f.Name, f.ParentFolderId, n.Name AS NameSpace
+ f.FolderId, f.Name, f.ParentFolderId, f.OwnerUserId, n.Name AS NameSpace
FROM
Folder f, Namespace n
WHERE
Modified: NMail/trunk/NMail.LocalStoreData.MySql/MySqlLocalStoreData.cs
===================================================================
--- NMail/trunk/NMail.LocalStoreData.MySql/MySqlLocalStoreData.cs 2007-03-08 09:43:35 UTC (rev 170)
+++ NMail/trunk/NMail.LocalStoreData.MySql/MySqlLocalStoreData.cs 2007-03-08 09:45:38 UTC (rev 171)
@@ -214,11 +214,13 @@
cmd.CommandText = "GetFolder";
cmd.Parameters.Add("?FolderId", folderId);
cmd.Parameters.Add("?ParentId", MySqlDbType.Int32);
+ cmd.Parameters.Add("?OwnerUserId", MySqlDbType.Int32);
cmd.Parameters.Add("?Name", MySqlDbType.VarChar);
cmd.Parameters.Add("?NameSpace", MySqlDbType.VarChar);
cmd.Parameters.Add("?Children", MySqlDbType.Int32);
cmd.Parameters.Add("?Result", MySqlDbType.Int32);
cmd.Parameters["ParentId"].Direction = ParameterDirection.Output;
+ cmd.Parameters["OwnerUserId"].Direction = ParameterDirection.Output;
cmd.Parameters["Name"].Direction = ParameterDirection.Output;
cmd.Parameters["NameSpace"].Direction = ParameterDirection.Output;
cmd.Parameters["Children"].Direction = ParameterDirection.Output;
@@ -241,12 +243,14 @@
int? parentId = (cmd.Parameters["ParentId"].Value == DBNull.Value)
? null
: (int?) cmd.Parameters["ParentId"].Value;
+ int ownerUserId = (int) cmd.Parameters["OwnerUserId"].Value;
// Return the folder object
return new StoreFolder(nameSpace,
name,
folderId,
parentId,
+ ownerUserId,
(children != 0));
}
}
@@ -417,9 +421,10 @@
int? parentId = (reader["ParentFolderId"] == DBNull.Value)
? null
: (int?) reader["ParentFolderId"];
+ int ownerUserId = (int) reader["OwnerUserId"];
// TODO: Get HasChildren from the reader
- folders.Add(new StoreFolder(nameSpace, name, folderId, parentId, false));
+ folders.Add(new StoreFolder(nameSpace, name, folderId, parentId, ownerUserId, false));
}
return folders.ToArray();
@@ -1151,7 +1156,7 @@
: (int?) reader["ParentFolderId"];
// TODO: Get HasChildren from the reader
- folders.Add(new StoreFolder(nameSpace, name, folderId, parentId, false));
+ folders.Add(new StoreFolder(nameSpace, name, folderId, parentId, userId, false));
}
return folders.ToArray();
Modified: NMail/trunk/NMail.RemoteAccessService.Serializers/DataTypes/LocalStore/StoreFolderSerializer.cs
===================================================================
--- NMail/trunk/NMail.RemoteAccessService.Serializers/DataTypes/LocalStore/StoreFolderSerializer.cs 2007-03-08 09:43:35 UTC (rev 170)
+++ NMail/trunk/NMail.RemoteAccessService.Serializers/DataTypes/LocalStore/StoreFolderSerializer.cs 2007-03-08 09:45:38 UTC (rev 171)
@@ -22,6 +22,7 @@
this.nameSpace = storeFolder.NameSpace;
this.hasChildren = storeFolder.HasChildren;
this.parentId = storeFolder.ParentId;
+ this.ownerUserId = storeFolder.OwnerUserId;
}
private int folderId;
@@ -63,9 +64,16 @@
get { return parentId;}
set { parentId = value;}
}
+
+ private int ownerUserId;
+
+ public int OwnerUserId {
+ get { return ownerUserId; }
+ set { ownerUserId = value; }
+ }
public StoreFolder GetStoreFolder() {
- return new StoreFolder(this.nameSpace, this.name, this.folderId, this.parentId, this.hasChildren);
+ return new StoreFolder(this.nameSpace, this.name, this.folderId, this.parentId, this.ownerUserId, this.hasChildren);
}
}
}
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <tmy...@us...> - 2007-03-08 09:43:35
|
Revision: 170
http://svn.sourceforge.net/nmailserver/?rev=170&view=rev
Author: tmyroadctfig
Date: 2007-03-08 01:43:35 -0800 (Thu, 08 Mar 2007)
Log Message:
-----------
Changed some classes to use generic interfaces instead of concrete types. Added a default constructor to LocalStoreGroup.
Modified Paths:
--------------
NMail/trunk/NMail/DataTypes/ACLs/GenericAcl.cs
NMail/trunk/NMail/DataTypes/IMessageBodyPart.cs
NMail/trunk/NMail/DataTypes/Imap/FetchDataList.cs
NMail/trunk/NMail/DataTypes/LocalStore/LocalStoreGroup.cs
NMail/trunk/NMail/DataTypes/LocalStore/MailDomain.cs
NMail/trunk/NMail/DataTypes/Message.cs
NMail/trunk/NMail/DataTypes/MultipartBodyPart.cs
NMail/trunk/NMail/DataTypes/SimpleBodyPart.cs
Modified: NMail/trunk/NMail/DataTypes/ACLs/GenericAcl.cs
===================================================================
--- NMail/trunk/NMail/DataTypes/ACLs/GenericAcl.cs 2007-03-04 10:11:20 UTC (rev 169)
+++ NMail/trunk/NMail/DataTypes/ACLs/GenericAcl.cs 2007-03-08 09:43:35 UTC (rev 170)
@@ -29,7 +29,7 @@
/// <summary>
/// A map of identifiers to access control entries.
/// </summary>
- protected Dictionary<string, GenericAce<PrivilegeType>> entries = new Dictionary<string, GenericAce<PrivilegeType>>(StringComparer.InvariantCultureIgnoreCase);
+ protected IDictionary<string, GenericAce<PrivilegeType>> entries = new Dictionary<string, GenericAce<PrivilegeType>>(StringComparer.InvariantCultureIgnoreCase);
/// <summary>
/// Creates a new ACL.
Modified: NMail/trunk/NMail/DataTypes/IMessageBodyPart.cs
===================================================================
--- NMail/trunk/NMail/DataTypes/IMessageBodyPart.cs 2007-03-04 10:11:20 UTC (rev 169)
+++ NMail/trunk/NMail/DataTypes/IMessageBodyPart.cs 2007-03-08 09:43:35 UTC (rev 170)
@@ -41,7 +41,7 @@
/// <summary>
/// Gets the mime parts of this message part, if any.
/// </summary>
- List<IMessageBodyPart> MimeParts { get; }
+ IList<IMessageBodyPart> MimeParts { get; }
/// <summary>
/// Gets the preamble for the message body, if any.
Modified: NMail/trunk/NMail/DataTypes/Imap/FetchDataList.cs
===================================================================
--- NMail/trunk/NMail/DataTypes/Imap/FetchDataList.cs 2007-03-04 10:11:20 UTC (rev 169)
+++ NMail/trunk/NMail/DataTypes/Imap/FetchDataList.cs 2007-03-08 09:43:35 UTC (rev 170)
@@ -29,7 +29,7 @@
/// <summary>
/// Internal storage for the data list.
/// </summary>
- private List<FetchDataItem> fetchDataList = new List<FetchDataItem>();
+ private IList<FetchDataItem> fetchDataList = new List<FetchDataItem>();
/// <summary>
/// Creates a new list from the given string.
@@ -89,7 +89,7 @@
/// <summary>
/// Returns the list of data items to retieve.
/// </summary>
- public List<FetchDataItem> DataListItems {
+ public IList<FetchDataItem> DataListItems {
get {
return this.fetchDataList;
}
Modified: NMail/trunk/NMail/DataTypes/LocalStore/LocalStoreGroup.cs
===================================================================
--- NMail/trunk/NMail/DataTypes/LocalStore/LocalStoreGroup.cs 2007-03-04 10:11:20 UTC (rev 169)
+++ NMail/trunk/NMail/DataTypes/LocalStore/LocalStoreGroup.cs 2007-03-08 09:43:35 UTC (rev 170)
@@ -28,6 +28,11 @@
[Serializable]
public class LocalStoreGroup {
/// <summary>
+ /// Creates a new local store group.
+ /// </summary>
+ public LocalStoreGroup() { }
+
+ /// <summary>
/// Creates a new local store group with the given details.
/// </summary>
/// <param name="name">The group name for this instance.</param>
@@ -37,8 +42,10 @@
public LocalStoreGroup(string name, int groupId, int[] userIds, int[] groupIds) {
this.name = name;
this.groupId = groupId;
- this.userIds.AddRange(userIds);
- this.groupIds.AddRange(groupIds);
+
+ // These casts should always be valid in the constructor
+ ((List<int>) this.userIds).AddRange(userIds);
+ ((List<int>) this.groupIds).AddRange(groupIds);
}
private string name;
@@ -69,26 +76,32 @@
}
}
- private List<int> groupIds = new List<int>();
+ private IList<int> groupIds = new List<int>();
/// <summary>
/// The group Ids under this group.
/// </summary>
- public List<int> SubGroupIds {
+ public IList<int> SubGroupIds {
get {
return this.groupIds;
}
+ set {
+ this.groupIds = value;
+ }
}
- private List<int> userIds = new List<int>();
+ private IList<int> userIds = new List<int>();
/// <summary>
/// The user Ids under this group.
/// </summary>
- public List<int> UserIds {
+ public IList<int> UserIds {
get {
return this.userIds;
}
+ set {
+ this.userIds = value;
+ }
}
}
}
Modified: NMail/trunk/NMail/DataTypes/LocalStore/MailDomain.cs
===================================================================
--- NMail/trunk/NMail/DataTypes/LocalStore/MailDomain.cs 2007-03-04 10:11:20 UTC (rev 169)
+++ NMail/trunk/NMail/DataTypes/LocalStore/MailDomain.cs 2007-03-08 09:43:35 UTC (rev 170)
@@ -30,6 +30,16 @@
/// </summary>
[Serializable]
public class MailDomain {
+ /// <summary>
+ /// Creates a new mail domain.
+ /// </summary>
+ public MailDomain() { }
+
+ /// <summary>
+ /// Creates a new mail domain with the given Id and host.
+ /// </summary>
+ /// <param name="mailDomainId">The mail domain's Id.</param>
+ /// <param name="primaryHost">The primary host.</param>
public MailDomain(int mailDomainId, Host primaryHost) {
this.mailDomainId = mailDomainId;
this.primaryHost = primaryHost;
@@ -63,78 +73,87 @@
}
}
- private List<int> mailDomainUserIds = new List<int>();
+ private IList<int> mailDomainUserIds = new List<int>();
/// <summary>
/// A list of Ids for users that are members of this mail domain.
/// </summary>
- public List<int> UserIds {
+ public IList<int> UserIds {
get {
return this.mailDomainUserIds;
}
+ set {
+ this.mailDomainUserIds = value;
+ }
}
- private List<int> mailDomainGroupIds = new List<int>();
+ private IList<int> mailDomainGroupIds = new List<int>();
/// <summary>
/// A list of Ids for groups that are members of this mail domain.
/// </summary>
- public List<int> GroupIds {
+ public IList<int> GroupIds {
get {
return this.mailDomainGroupIds;
}
+ set {
+ this.mailDomainGroupIds = value;
+ }
}
- private List<WildcardHost> additionalHosts = new List<WildcardHost>();
+ private IList<WildcardHost> additionalHosts = new List<WildcardHost>();
/// <summary>
/// Other hosts that this domain accepts mail for.
/// </summary>
- public List<WildcardHost> AdditionalHosts {
+ public IList<WildcardHost> AdditionalHosts {
get {
return this.additionalHosts;
}
+ set {
+ this.additionalHosts = value;
+ }
}
- private List<ILocalStoreUserMap> mailboxMappings = new List<ILocalStoreUserMap>();
+ private IList<ILocalStoreUserMap> mailboxMappings = new List<ILocalStoreUserMap>();
/// <summary>
/// Gets the mailbox mappings for this domain.
/// </summary>
- public List<ILocalStoreUserMap> MailboxMappings {
+ public IList<ILocalStoreUserMap> MailboxMappings {
get {
return this.mailboxMappings;
}
}
- private List<ILocalStoreDeliveryAction> allowedActions = new List<ILocalStoreDeliveryAction>();
+ private IList<ILocalStoreDeliveryAction> allowedActions = new List<ILocalStoreDeliveryAction>();
/// <summary>
/// The actions that user's of this domain are allowed to use.
/// </summary>
- public List<ILocalStoreDeliveryAction> AllowedActions {
+ public IList<ILocalStoreDeliveryAction> AllowedActions {
get {
return this.allowedActions;
}
}
- private List<ILocalStoreRecipientValidator> allowedValidators = new List<ILocalStoreRecipientValidator>();
+ private IList<ILocalStoreRecipientValidator> allowedValidators = new List<ILocalStoreRecipientValidator>();
/// <summary>
/// The validators that user's of this domain are allowed to use.
/// </summary>
- public List<ILocalStoreRecipientValidator> AllowedValidators {
+ public IList<ILocalStoreRecipientValidator> AllowedValidators {
get {
return this.allowedValidators;
}
}
- private List<ILocalStoreDeliveryAction> defaultActions = new List<ILocalStoreDeliveryAction>();
+ private IList<ILocalStoreDeliveryAction> defaultActions = new List<ILocalStoreDeliveryAction>();
/// <summary>
/// The default set of actions to apply to incoming messages.
/// </summary>
- public List<ILocalStoreDeliveryAction> DefaultActions {
+ public IList<ILocalStoreDeliveryAction> DefaultActions {
get {
return this.defaultActions;
}
Modified: NMail/trunk/NMail/DataTypes/Message.cs
===================================================================
--- NMail/trunk/NMail/DataTypes/Message.cs 2007-03-04 10:11:20 UTC (rev 169)
+++ NMail/trunk/NMail/DataTypes/Message.cs 2007-03-08 09:43:35 UTC (rev 170)
@@ -113,7 +113,7 @@
/// <summary>
/// Gets the mime parts of this message part, if any.
/// </summary>
- public List<IMessageBodyPart> MimeParts {
+ public IList<IMessageBodyPart> MimeParts {
get {
if (!this.parsed) parseMime();
return this.data.MimeParts;
Modified: NMail/trunk/NMail/DataTypes/MultipartBodyPart.cs
===================================================================
--- NMail/trunk/NMail/DataTypes/MultipartBodyPart.cs 2007-03-04 10:11:20 UTC (rev 169)
+++ NMail/trunk/NMail/DataTypes/MultipartBodyPart.cs 2007-03-08 09:43:35 UTC (rev 170)
@@ -97,7 +97,7 @@
/// <summary>
/// Gets the mime parts for this body.
/// </summary>
- public List<IMessageBodyPart> MimeParts {
+ public IList<IMessageBodyPart> MimeParts {
get {
return this.mimeParts;
}
Modified: NMail/trunk/NMail/DataTypes/SimpleBodyPart.cs
===================================================================
--- NMail/trunk/NMail/DataTypes/SimpleBodyPart.cs 2007-03-04 10:11:20 UTC (rev 169)
+++ NMail/trunk/NMail/DataTypes/SimpleBodyPart.cs 2007-03-08 09:43:35 UTC (rev 170)
@@ -111,7 +111,7 @@
/// <summary>
/// Gets the mime parts of this message part. Always returns null.
/// </summary>
- public List<IMessageBodyPart> MimeParts {
+ public IList<IMessageBodyPart> MimeParts {
get {
return null;
}
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <tmy...@us...> - 2007-03-04 10:11:19
|
Revision: 169
http://svn.sourceforge.net/nmailserver/?rev=169&view=rev
Author: tmyroadctfig
Date: 2007-03-04 02:11:20 -0800 (Sun, 04 Mar 2007)
Log Message:
-----------
Removed dev branch.
Removed Paths:
-------------
NMail/branches/luke-dev/
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <tmy...@us...> - 2007-03-04 10:06:32
|
Revision: 168
http://svn.sourceforge.net/nmailserver/?rev=168&view=rev
Author: tmyroadctfig
Date: 2007-03-04 02:06:31 -0800 (Sun, 04 Mar 2007)
Log Message:
-----------
Changed namespace.
Modified Paths:
--------------
NMail/trunk/NMail.UnitTests/DNSCacheTests.cs
Modified: NMail/trunk/NMail.UnitTests/DNSCacheTests.cs
===================================================================
--- NMail/trunk/NMail.UnitTests/DNSCacheTests.cs 2007-03-04 10:03:29 UTC (rev 167)
+++ NMail/trunk/NMail.UnitTests/DNSCacheTests.cs 2007-03-04 10:06:31 UTC (rev 168)
@@ -25,7 +25,7 @@
using NDns.Message.Records;
using NDns.Configuration;
-namespace NDns.Tests {
+namespace NDns.UnitTests {
/// <summary>
/// Unit tests for the DNS cache.
/// </summary>
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <tmy...@us...> - 2007-03-04 10:03:28
|
Revision: 167
http://svn.sourceforge.net/nmailserver/?rev=167&view=rev
Author: tmyroadctfig
Date: 2007-03-04 02:03:29 -0800 (Sun, 04 Mar 2007)
Log Message:
-----------
Updated assembly information.
Modified Paths:
--------------
NMail/trunk/NDns/AssemblyInfo.cs
NMail/trunk/NMail/AssemblyInfo.cs
NMail/trunk/NMail.Administration.Console/Properties/AssemblyInfo.cs
NMail/trunk/NMail.DnsClient/AssemblyInfo.cs
NMail/trunk/NMail.ImapService/AssemblyInfo.cs
NMail/trunk/NMail.LocalStore/AssemblyInfo.cs
NMail/trunk/NMail.LocalStoreData.MySql/AssemblyInfo.cs
NMail/trunk/NMail.LocalStoreData.NHibernate/Properties/AssemblyInfo.cs
NMail/trunk/NMail.MessageRouter/AssemblyInfo.cs
NMail/trunk/NMail.RemoteAccessService.Serializers/Properties/AssemblyInfo.cs
NMail/trunk/NMail.Sendmail/AssemblyInfo.cs
NMail/trunk/NMail.Server.Console/AssemblyInfo.cs
NMail/trunk/NMail.Server.Service/AssemblyInfo.cs
NMail/trunk/NMail.SetupWizard/Properties/AssemblyInfo.cs
NMail/trunk/NMail.SmtpClient/AssemblyInfo.cs
NMail/trunk/NMail.SmtpService/AssemblyInfo.cs
NMail/trunk/NMail.SpoolData.MySql/AssemblyInfo.cs
NMail/trunk/NMail.SpoolData.NHibernate/Properties/AssemblyInfo.cs
NMail/trunk/NMail.SpoolFilter/AssemblyInfo.cs
NMail/trunk/NMail.SpoolService/AssemblyInfo.cs
NMail/trunk/NMail.UnitTests/Properties/AssemblyInfo.cs
Modified: NMail/trunk/NDns/AssemblyInfo.cs
===================================================================
--- NMail/trunk/NDns/AssemblyInfo.cs 2007-03-04 08:42:03 UTC (rev 166)
+++ NMail/trunk/NDns/AssemblyInfo.cs 2007-03-04 10:03:29 UTC (rev 167)
@@ -18,58 +18,17 @@
using System.Reflection;
using System.Runtime.CompilerServices;
-//
-// General Information about an assembly is controlled through the following
-// set of attributes. Change these attribute values to modify the information
-// associated with an assembly.
-//
+// General details
[assembly: AssemblyTitle("NDns")]
-[assembly: AssemblyDescription("A Dns library for NMail.")]
-[assembly: AssemblyConfiguration("")]
-[assembly: AssemblyCompany("")]
-[assembly: AssemblyProduct("")]
-[assembly: AssemblyCopyright("Luke Quinane 2004")]
-[assembly: AssemblyTrademark("")]
-[assembly: AssemblyCulture("")]
-
-//
-// Version information for an assembly consists of the following four values:
-//
-// Major Version
-// Minor Version
-// Build Number
-// Revision
-//
-// You can specify all the values or you can default the Revision and Build Numbers
-// by using the '*' as shown below:
-
[assembly: AssemblyVersion("1.0.*")]
-//
-// In order to sign your assembly you must specify a key to use. Refer to the
-// Microsoft .NET Framework documentation for more information on assembly signing.
-//
-// Use the attributes below to control which key is used for signing.
-//
-// Notes:
-// (*) If no key is specified, the assembly is not signed.
-// (*) KeyName refers to a key that has been installed in the Crypto Service
-// Provider (CSP) on your machine. KeyFile refers to a file which contains
-// a key.
-// (*) If the KeyFile and the KeyName values are both specified, the
-// following processing occurs:
-// (1) If the KeyName can be found in the CSP, that key is used.
-// (2) If the KeyName does not exist and the KeyFile does exist, the key
-// in the KeyFile is installed into the CSP and used.
-// (*) In order to create a KeyFile, you can use the sn.exe (Strong Name) utility.
-// When specifying the KeyFile, the location of the KeyFile should be
-// relative to the project output directory which is
-// %Project Directory%\obj\<configuration>. For example, if your KeyFile is
-// located in the project directory, you would specify the AssemblyKeyFile
-// attribute as [assembly: AssemblyKeyFile("..\\..\\mykey.snk")]
-// (*) Delay Signing is an advanced option - see the Microsoft .NET Framework
-// documentation for more information on this.
-//
-[assembly: AssemblyDelaySign(false)]
-[assembly: AssemblyKeyFile("")]
-[assembly: AssemblyKeyName("")]
+[assembly: AssemblyDescription("A Dns library for NMail.")]
+[assembly: AssemblyCompany("http://NMailServer.SourceForge.net")]
+[assembly: AssemblyProduct("NMail")]
+[assembly: AssemblyCopyright("Copyright \xA9 2004 Luke Quinane")]
+
+#if DEBUG
+[assembly: AssemblyConfiguration("Debug")]
+#else
+[assembly: AssemblyConfiguration("Release")]
+#endif
Modified: NMail/trunk/NMail/AssemblyInfo.cs
===================================================================
--- NMail/trunk/NMail/AssemblyInfo.cs 2007-03-04 08:42:03 UTC (rev 166)
+++ NMail/trunk/NMail/AssemblyInfo.cs 2007-03-04 10:03:29 UTC (rev 167)
@@ -18,58 +18,17 @@
using System.Reflection;
using System.Runtime.CompilerServices;
-//
-// General Information about an assembly is controlled through the following
-// set of attributes. Change these attribute values to modify the information
-// associated with an assembly.
-//
+// General details
[assembly: AssemblyTitle("NMail core library.")]
+[assembly: AssemblyVersion("1.1.*")]
+
[assembly: AssemblyDescription("Provides a core library for NMail.")]
-[assembly: AssemblyConfiguration("")]
-[assembly: AssemblyCompany("")]
-[assembly: AssemblyProduct("")]
-[assembly: AssemblyCopyright("Luke Quinane and Daniel Frampton")]
-[assembly: AssemblyTrademark("")]
-[assembly: AssemblyCulture("")]
+[assembly: AssemblyCompany("http://NMailServer.SourceForge.net")]
+[assembly: AssemblyProduct("NMail")]
+[assembly: AssemblyCopyright("Copyright \xA9 2004-2007 Luke Quinane and Daniel Frampton")]
-//
-// Version information for an assembly consists of the following four values:
-//
-// Major Version
-// Minor Version
-// Build Number
-// Revision
-//
-// You can specify all the values or you can default the Revision and Build Numbers
-// by using the '*' as shown below:
-
-[assembly: AssemblyVersion("1.0.*")]
-
-//
-// In order to sign your assembly you must specify a key to use. Refer to the
-// Microsoft .NET Framework documentation for more information on assembly signing.
-//
-// Use the attributes below to control which key is used for signing.
-//
-// Notes:
-// (*) If no key is specified, the assembly is not signed.
-// (*) KeyName refers to a key that has been installed in the Crypto Service
-// Provider (CSP) on your machine. KeyFile refers to a file which contains
-// a key.
-// (*) If the KeyFile and the KeyName values are both specified, the
-// following processing occurs:
-// (1) If the KeyName can be found in the CSP, that key is used.
-// (2) If the KeyName does not exist and the KeyFile does exist, the key
-// in the KeyFile is installed into the CSP and used.
-// (*) In order to create a KeyFile, you can use the sn.exe (Strong Name) utility.
-// When specifying the KeyFile, the location of the KeyFile should be
-// relative to the project output directory which is
-// %Project Directory%\obj\<configuration>. For example, if your KeyFile is
-// located in the project directory, you would specify the AssemblyKeyFile
-// attribute as [assembly: AssemblyKeyFile("..\\..\\mykey.snk")]
-// (*) Delay Signing is an advanced option - see the Microsoft .NET Framework
-// documentation for more information on this.
-//
-[assembly: AssemblyDelaySign(false)]
-[assembly: AssemblyKeyFile("")]
-[assembly: AssemblyKeyName("")]
+#if DEBUG
+[assembly: AssemblyConfiguration("Debug")]
+#else
+[assembly: AssemblyConfiguration("Release")]
+#endif
Modified: NMail/trunk/NMail.Administration.Console/Properties/AssemblyInfo.cs
===================================================================
--- NMail/trunk/NMail.Administration.Console/Properties/AssemblyInfo.cs 2007-03-04 08:42:03 UTC (rev 166)
+++ NMail/trunk/NMail.Administration.Console/Properties/AssemblyInfo.cs 2007-03-04 10:03:29 UTC (rev 167)
@@ -17,34 +17,18 @@
using System.Reflection;
using System.Runtime.CompilerServices;
-using System.Runtime.InteropServices;
-// General Information about an assembly is controlled through the following
-// set of attributes. Change these attribute values to modify the information
-// associated with an assembly.
+// General details
[assembly: AssemblyTitle("NMail.Administration.Console")]
-[assembly: AssemblyDescription("")]
-[assembly: AssemblyConfiguration("")]
-[assembly: AssemblyCompany("")]
-[assembly: AssemblyProduct("NMail.Administration.Console")]
-[assembly: AssemblyCopyright("Copyright © 2006")]
-[assembly: AssemblyTrademark("")]
-[assembly: AssemblyCulture("")]
+[assembly: AssemblyVersion("1.1.*")]
-// Setting ComVisible to false makes the types in this assembly not visible
-// to COM components. If you need to access a type in this assembly from
-// COM, set the ComVisible attribute to true on that type.
-[assembly: ComVisible(false)]
+[assembly: AssemblyDescription("A console based administration utility for NMail.")]
+[assembly: AssemblyCompany("http://NMailServer.SourceForge.net")]
+[assembly: AssemblyProduct("NMail Administration Console")]
+[assembly: AssemblyCopyright("Copyright © 2004-2006 Luke Quinane and Daniel Frampton")]
-// The following GUID is for the ID of the typelib if this project is exposed to COM
-[assembly: Guid("edfbf1ab-7454-465e-beae-7fbc4275e83a")]
-
-// Version information for an assembly consists of the following four values:
-//
-// Major Version
-// Minor Version
-// Build Number
-// Revision
-//
-[assembly: AssemblyVersion("1.0.0.0")]
-[assembly: AssemblyFileVersion("1.0.0.0")]
+#if DEBUG
+[assembly: AssemblyConfiguration("Debug")]
+#else
+[assembly: AssemblyConfiguration("Release")]
+#endif
Modified: NMail/trunk/NMail.DnsClient/AssemblyInfo.cs
===================================================================
--- NMail/trunk/NMail.DnsClient/AssemblyInfo.cs 2007-03-04 08:42:03 UTC (rev 166)
+++ NMail/trunk/NMail.DnsClient/AssemblyInfo.cs 2007-03-04 10:03:29 UTC (rev 167)
@@ -18,58 +18,17 @@
using System.Reflection;
using System.Runtime.CompilerServices;
-//
-// General Information about an assembly is controlled through the following
-// set of attributes. Change these attribute values to modify the information
-// associated with an assembly.
-//
-[assembly: AssemblyTitle("")]
-[assembly: AssemblyDescription("")]
-[assembly: AssemblyConfiguration("")]
-[assembly: AssemblyCompany("")]
-[assembly: AssemblyProduct("")]
-[assembly: AssemblyCopyright("")]
-[assembly: AssemblyTrademark("")]
-[assembly: AssemblyCulture("")]
+// General details
+[assembly: AssemblyTitle("NMail DNS client provider.")]
+[assembly: AssemblyVersion("1.1.*")]
-//
-// Version information for an assembly consists of the following four values:
-//
-// Major Version
-// Minor Version
-// Build Number
-// Revision
-//
-// You can specify all the values or you can default the Revision and Build Numbers
-// by using the '*' as shown below:
+[assembly: AssemblyDescription("Provides a DNS client implementation for NMail.")]
+[assembly: AssemblyCompany("http://NMailServer.SourceForge.net")]
+[assembly: AssemblyProduct("NMail")]
+[assembly: AssemblyCopyright("Copyright \xA9 2004-2006 Luke Quinane and Daniel Frampton")]
-[assembly: AssemblyVersion("1.0.*")]
-
-//
-// In order to sign your assembly you must specify a key to use. Refer to the
-// Microsoft .NET Framework documentation for more information on assembly signing.
-//
-// Use the attributes below to control which key is used for signing.
-//
-// Notes:
-// (*) If no key is specified, the assembly is not signed.
-// (*) KeyName refers to a key that has been installed in the Crypto Service
-// Provider (CSP) on your machine. KeyFile refers to a file which contains
-// a key.
-// (*) If the KeyFile and the KeyName values are both specified, the
-// following processing occurs:
-// (1) If the KeyName can be found in the CSP, that key is used.
-// (2) If the KeyName does not exist and the KeyFile does exist, the key
-// in the KeyFile is installed into the CSP and used.
-// (*) In order to create a KeyFile, you can use the sn.exe (Strong Name) utility.
-// When specifying the KeyFile, the location of the KeyFile should be
-// relative to the project output directory which is
-// %Project Directory%\obj\<configuration>. For example, if your KeyFile is
-// located in the project directory, you would specify the AssemblyKeyFile
-// attribute as [assembly: AssemblyKeyFile("..\\..\\mykey.snk")]
-// (*) Delay Signing is an advanced option - see the Microsoft .NET Framework
-// documentation for more information on this.
-//
-[assembly: AssemblyDelaySign(false)]
-[assembly: AssemblyKeyFile("")]
-[assembly: AssemblyKeyName("")]
+#if DEBUG
+[assembly: AssemblyConfiguration("Debug")]
+#else
+[assembly: AssemblyConfiguration("Release")]
+#endif
Modified: NMail/trunk/NMail.ImapService/AssemblyInfo.cs
===================================================================
--- NMail/trunk/NMail.ImapService/AssemblyInfo.cs 2007-03-04 08:42:03 UTC (rev 166)
+++ NMail/trunk/NMail.ImapService/AssemblyInfo.cs 2007-03-04 10:03:29 UTC (rev 167)
@@ -18,58 +18,17 @@
using System.Reflection;
using System.Runtime.CompilerServices;
-//
-// General Information about an assembly is controlled through the following
-// set of attributes. Change these attribute values to modify the information
-// associated with an assembly.
-//
-[assembly: AssemblyTitle("NMail IMAP Service.")]
+// General details
+[assembly: AssemblyTitle("NMail IMAP service.")]
+[assembly: AssemblyVersion("1.1.*")]
+
[assembly: AssemblyDescription("Provides an IMAP server implementation for NMail.")]
-[assembly: AssemblyConfiguration("")]
-[assembly: AssemblyCompany("")]
-[assembly: AssemblyProduct("")]
-[assembly: AssemblyCopyright("Luke Quinane and Daniel Frampton")]
-[assembly: AssemblyTrademark("")]
-[assembly: AssemblyCulture("")]
+[assembly: AssemblyCompany("http://NMailServer.SourceForge.net")]
+[assembly: AssemblyProduct("NMail")]
+[assembly: AssemblyCopyright("Copyright \xA9 2004-2007 Luke Quinane and Daniel Frampton")]
-//
-// Version information for an assembly consists of the following four values:
-//
-// Major Version
-// Minor Version
-// Build Number
-// Revision
-//
-// You can specify all the values or you can default the Revision and Build Numbers
-// by using the '*' as shown below:
-
-[assembly: AssemblyVersion("1.0.*")]
-
-//
-// In order to sign your assembly you must specify a key to use. Refer to the
-// Microsoft .NET Framework documentation for more information on assembly signing.
-//
-// Use the attributes below to control which key is used for signing.
-//
-// Notes:
-// (*) If no key is specified, the assembly is not signed.
-// (*) KeyName refers to a key that has been installed in the Crypto Service
-// Provider (CSP) on your machine. KeyFile refers to a file which contains
-// a key.
-// (*) If the KeyFile and the KeyName values are both specified, the
-// following processing occurs:
-// (1) If the KeyName can be found in the CSP, that key is used.
-// (2) If the KeyName does not exist and the KeyFile does exist, the key
-// in the KeyFile is installed into the CSP and used.
-// (*) In order to create a KeyFile, you can use the sn.exe (Strong Name) utility.
-// When specifying the KeyFile, the location of the KeyFile should be
-// relative to the project output directory which is
-// %Project Directory%\obj\<configuration>. For example, if your KeyFile is
-// located in the project directory, you would specify the AssemblyKeyFile
-// attribute as [assembly: AssemblyKeyFile("..\\..\\mykey.snk")]
-// (*) Delay Signing is an advanced option - see the Microsoft .NET Framework
-// documentation for more information on this.
-//
-[assembly: AssemblyDelaySign(false)]
-[assembly: AssemblyKeyFile("")]
-[assembly: AssemblyKeyName("")]
+#if DEBUG
+[assembly: AssemblyConfiguration("Debug")]
+#else
+[assembly: AssemblyConfiguration("Release")]
+#endif
Modified: NMail/trunk/NMail.LocalStore/AssemblyInfo.cs
===================================================================
--- NMail/trunk/NMail.LocalStore/AssemblyInfo.cs 2007-03-04 08:42:03 UTC (rev 166)
+++ NMail/trunk/NMail.LocalStore/AssemblyInfo.cs 2007-03-04 10:03:29 UTC (rev 167)
@@ -18,58 +18,17 @@
using System.Reflection;
using System.Runtime.CompilerServices;
-//
-// General Information about an assembly is controlled through the following
-// set of attributes. Change these attribute values to modify the information
-// associated with an assembly.
-//
-[assembly: AssemblyTitle("")]
-[assembly: AssemblyDescription("")]
-[assembly: AssemblyConfiguration("")]
-[assembly: AssemblyCompany("")]
-[assembly: AssemblyProduct("")]
-[assembly: AssemblyCopyright("")]
-[assembly: AssemblyTrademark("")]
-[assembly: AssemblyCulture("")]
+// General details
+[assembly: AssemblyTitle("NMail Local Store library.")]
+[assembly: AssemblyVersion("1.1.*")]
-//
-// Version information for an assembly consists of the following four values:
-//
-// Major Version
-// Minor Version
-// Build Number
-// Revision
-//
-// You can specify all the values or you can default the Revision and Build Numbers
-// by using the '*' as shown below:
+[assembly: AssemblyDescription("Provides a local store implmentation for NMail.")]
+[assembly: AssemblyCompany("http://NMailServer.SourceForge.net")]
+[assembly: AssemblyProduct("NMail")]
+[assembly: AssemblyCopyright("Copyright \xA9 2004-2007 Luke Quinane and Daniel Frampton")]
-[assembly: AssemblyVersion("1.0.*")]
-
-//
-// In order to sign your assembly you must specify a key to use. Refer to the
-// Microsoft .NET Framework documentation for more information on assembly signing.
-//
-// Use the attributes below to control which key is used for signing.
-//
-// Notes:
-// (*) If no key is specified, the assembly is not signed.
-// (*) KeyName refers to a key that has been installed in the Crypto Service
-// Provider (CSP) on your machine. KeyFile refers to a file which contains
-// a key.
-// (*) If the KeyFile and the KeyName values are both specified, the
-// following processing occurs:
-// (1) If the KeyName can be found in the CSP, that key is used.
-// (2) If the KeyName does not exist and the KeyFile does exist, the key
-// in the KeyFile is installed into the CSP and used.
-// (*) In order to create a KeyFile, you can use the sn.exe (Strong Name) utility.
-// When specifying the KeyFile, the location of the KeyFile should be
-// relative to the project output directory which is
-// %Project Directory%\obj\<configuration>. For example, if your KeyFile is
-// located in the project directory, you would specify the AssemblyKeyFile
-// attribute as [assembly: AssemblyKeyFile("..\\..\\mykey.snk")]
-// (*) Delay Signing is an advanced option - see the Microsoft .NET Framework
-// documentation for more information on this.
-//
-[assembly: AssemblyDelaySign(false)]
-[assembly: AssemblyKeyFile("")]
-[assembly: AssemblyKeyName("")]
+#if DEBUG
+[assembly: AssemblyConfiguration("Debug")]
+#else
+[assembly: AssemblyConfiguration("Release")]
+#endif
Modified: NMail/trunk/NMail.LocalStoreData.MySql/AssemblyInfo.cs
===================================================================
--- NMail/trunk/NMail.LocalStoreData.MySql/AssemblyInfo.cs 2007-03-04 08:42:03 UTC (rev 166)
+++ NMail/trunk/NMail.LocalStoreData.MySql/AssemblyInfo.cs 2007-03-04 10:03:29 UTC (rev 167)
@@ -18,58 +18,17 @@
using System.Reflection;
using System.Runtime.CompilerServices;
-//
-// General Information about an assembly is controlled through the following
-// set of attributes. Change these attribute values to modify the information
-// associated with an assembly.
-//
-[assembly: AssemblyTitle("")]
-[assembly: AssemblyDescription("")]
-[assembly: AssemblyConfiguration("")]
-[assembly: AssemblyCompany("")]
-[assembly: AssemblyProduct("")]
-[assembly: AssemblyCopyright("")]
-[assembly: AssemblyTrademark("")]
-[assembly: AssemblyCulture("")]
+// General details
+[assembly: AssemblyTitle("NMail MySql Local Store Data.")]
+[assembly: AssemblyVersion("1.1.*")]
-//
-// Version information for an assembly consists of the following four values:
-//
-// Major Version
-// Minor Version
-// Build Number
-// Revision
-//
-// You can specify all the values or you can default the Revision and Build Numbers
-// by using the '*' as shown below:
+[assembly: AssemblyDescription("Provides an MySql based local store data implementation for NMail.")]
+[assembly: AssemblyCompany("http://NMailServer.SourceForge.net")]
+[assembly: AssemblyProduct("NMail")]
+[assembly: AssemblyCopyright("Copyright \xA9 2004-2007 Luke Quinane and Daniel Frampton")]
-[assembly: AssemblyVersion("1.0.*")]
-
-//
-// In order to sign your assembly you must specify a key to use. Refer to the
-// Microsoft .NET Framework documentation for more information on assembly signing.
-//
-// Use the attributes below to control which key is used for signing.
-//
-// Notes:
-// (*) If no key is specified, the assembly is not signed.
-// (*) KeyName refers to a key that has been installed in the Crypto Service
-// Provider (CSP) on your machine. KeyFile refers to a file which contains
-// a key.
-// (*) If the KeyFile and the KeyName values are both specified, the
-// following processing occurs:
-// (1) If the KeyName can be found in the CSP, that key is used.
-// (2) If the KeyName does not exist and the KeyFile does exist, the key
-// in the KeyFile is installed into the CSP and used.
-// (*) In order to create a KeyFile, you can use the sn.exe (Strong Name) utility.
-// When specifying the KeyFile, the location of the KeyFile should be
-// relative to the project output directory which is
-// %Project Directory%\obj\<configuration>. For example, if your KeyFile is
-// located in the project directory, you would specify the AssemblyKeyFile
-// attribute as [assembly: AssemblyKeyFile("..\\..\\mykey.snk")]
-// (*) Delay Signing is an advanced option - see the Microsoft .NET Framework
-// documentation for more information on this.
-//
-[assembly: AssemblyDelaySign(false)]
-[assembly: AssemblyKeyFile("")]
-[assembly: AssemblyKeyName("")]
+#if DEBUG
+[assembly: AssemblyConfiguration("Debug")]
+#else
+[assembly: AssemblyConfiguration("Release")]
+#endif
\ No newline at end of file
Modified: NMail/trunk/NMail.LocalStoreData.NHibernate/Properties/AssemblyInfo.cs
===================================================================
--- NMail/trunk/NMail.LocalStoreData.NHibernate/Properties/AssemblyInfo.cs 2007-03-04 08:42:03 UTC (rev 166)
+++ NMail/trunk/NMail.LocalStoreData.NHibernate/Properties/AssemblyInfo.cs 2007-03-04 10:03:29 UTC (rev 167)
@@ -1,35 +1,34 @@
-using System.Reflection;
+/*
+ * Copyright 2004-2006 Luke Quinane and Daniel Frampton
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ */
+
+using System.Reflection;
using System.Runtime.CompilerServices;
-using System.Runtime.InteropServices;
-// General Information about an assembly is controlled through the following
-// set of attributes. Change these attribute values to modify the information
-// associated with an assembly.
-[assembly: AssemblyTitle("NMail.LocalStoreData.NHibernate")]
-[assembly: AssemblyDescription("")]
-[assembly: AssemblyConfiguration("")]
-[assembly: AssemblyCompany("")]
-[assembly: AssemblyProduct("NMail.LocalStoreData.NHibernate")]
-[assembly: AssemblyCopyright("Copyright © 2007")]
-[assembly: AssemblyTrademark("")]
-[assembly: AssemblyCulture("")]
+// General details
+[assembly: AssemblyTitle("NMail NHibernate Local Store Data.")]
+[assembly: AssemblyVersion("1.1.*")]
-// Setting ComVisible to false makes the types in this assembly not visible
-// to COM components. If you need to access a type in this assembly from
-// COM, set the ComVisible attribute to true on that type.
-[assembly: ComVisible(false)]
+[assembly: AssemblyDescription("Provides an NHibernate based local store data implementation for NMail.")]
+[assembly: AssemblyCompany("http://NMailServer.SourceForge.net")]
+[assembly: AssemblyProduct("NMail")]
+[assembly: AssemblyCopyright("Copyright © 2007 Luke Quinane")]
-// The following GUID is for the ID of the typelib if this project is exposed to COM
-[assembly: Guid("4f310b23-2c73-4abe-8f6e-eb092078282c")]
-
-// Version information for an assembly consists of the following four values:
-//
-// Major Version
-// Minor Version
-// Build Number
-// Revision
-//
-// You can specify all the values or you can default the Revision and Build Numbers
-// by using the '*' as shown below:
-[assembly: AssemblyVersion("1.0.0.0")]
-[assembly: AssemblyFileVersion("1.0.0.0")]
+#if DEBUG
+[assembly: AssemblyConfiguration("Debug")]
+#else
+[assembly: AssemblyConfiguration("Release")]
+#endif
\ No newline at end of file
Modified: NMail/trunk/NMail.MessageRouter/AssemblyInfo.cs
===================================================================
--- NMail/trunk/NMail.MessageRouter/AssemblyInfo.cs 2007-03-04 08:42:03 UTC (rev 166)
+++ NMail/trunk/NMail.MessageRouter/AssemblyInfo.cs 2007-03-04 10:03:29 UTC (rev 167)
@@ -18,58 +18,18 @@
using System.Reflection;
using System.Runtime.CompilerServices;
-//
-// General Information about an assembly is controlled through the following
-// set of attributes. Change these attribute values to modify the information
-// associated with an assembly.
-//
-[assembly: AssemblyTitle("NMail message router.")]
-[assembly: AssemblyDescription("Provides a message router implementation for NMail.")]
-[assembly: AssemblyConfiguration("")]
-[assembly: AssemblyCompany("")]
-[assembly: AssemblyProduct("")]
-[assembly: AssemblyCopyright("Luke Quinane and Daniel Frampton")]
-[assembly: AssemblyTrademark("")]
-[assembly: AssemblyCulture("")]
-//
-// Version information for an assembly consists of the following four values:
-//
-// Major Version
-// Minor Version
-// Build Number
-// Revision
-//
-// You can specify all the values or you can default the Revision and Build Numbers
-// by using the '*' as shown below:
+// General details
+[assembly: AssemblyTitle("NMail Message Router.")]
+[assembly: AssemblyVersion("1.1.*")]
-[assembly: AssemblyVersion("1.0.*")]
+[assembly: AssemblyDescription("Provides a message router implementation for NMail.")]
+[assembly: AssemblyCompany("http://NMailServer.SourceForge.net")]
+[assembly: AssemblyProduct("NMail")]
+[assembly: AssemblyCopyright("Copyright \xA9 2004-2007 Luke Quinane and Daniel Frampton")]
-//
-// In order to sign your assembly you must specify a key to use. Refer to the
-// Microsoft .NET Framework documentation for more information on assembly signing.
-//
-// Use the attributes below to control which key is used for signing.
-//
-// Notes:
-// (*) If no key is specified, the assembly is not signed.
-// (*) KeyName refers to a key that has been installed in the Crypto Service
-// Provider (CSP) on your machine. KeyFile refers to a file which contains
-// a key.
-// (*) If the KeyFile and the KeyName values are both specified, the
-// following processing occurs:
-// (1) If the KeyName can be found in the CSP, that key is used.
-// (2) If the KeyName does not exist and the KeyFile does exist, the key
-// in the KeyFile is installed into the CSP and used.
-// (*) In order to create a KeyFile, you can use the sn.exe (Strong Name) utility.
-// When specifying the KeyFile, the location of the KeyFile should be
-// relative to the project output directory which is
-// %Project Directory%\obj\<configuration>. For example, if your KeyFile is
-// located in the project directory, you would specify the AssemblyKeyFile
-// attribute as [assembly: AssemblyKeyFile("..\\..\\mykey.snk")]
-// (*) Delay Signing is an advanced option - see the Microsoft .NET Framework
-// documentation for more information on this.
-//
-[assembly: AssemblyDelaySign(false)]
-[assembly: AssemblyKeyFile("")]
-[assembly: AssemblyKeyName("")]
+#if DEBUG
+[assembly: AssemblyConfiguration("Debug")]
+#else
+[assembly: AssemblyConfiguration("Release")]
+#endif
Modified: NMail/trunk/NMail.RemoteAccessService.Serializers/Properties/AssemblyInfo.cs
===================================================================
--- NMail/trunk/NMail.RemoteAccessService.Serializers/Properties/AssemblyInfo.cs 2007-03-04 08:42:03 UTC (rev 166)
+++ NMail/trunk/NMail.RemoteAccessService.Serializers/Properties/AssemblyInfo.cs 2007-03-04 10:03:29 UTC (rev 167)
@@ -1,35 +1,35 @@
-using System.Reflection;
+/*
+ * Copyright 2004-2007 Luke Quinane and Daniel Frampton
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ */
+
+using System.Reflection;
using System.Runtime.CompilerServices;
-using System.Runtime.InteropServices;
-// General Information about an assembly is controlled through the following
-// set of attributes. Change these attribute values to modify the information
-// associated with an assembly.
-[assembly: AssemblyTitle("NMail.RemoteAccessServiceSerializers")]
-[assembly: AssemblyDescription("")]
-[assembly: AssemblyConfiguration("")]
-[assembly: AssemblyCompany("")]
-[assembly: AssemblyProduct("NMail.RemoteAccessServiceSerializers")]
-[assembly: AssemblyCopyright("Copyright © 2006")]
-[assembly: AssemblyTrademark("")]
-[assembly: AssemblyCulture("")]
-// Setting ComVisible to false makes the types in this assembly not visible
-// to COM components. If you need to access a type in this assembly from
-// COM, set the ComVisible attribute to true on that type.
-[assembly: ComVisible(false)]
+// General details
+[assembly: AssemblyTitle("NMail Remote Access Serializers.")]
+[assembly: AssemblyVersion("1.1.*")]
-// The following GUID is for the ID of the typelib if this project is exposed to COM
-[assembly: Guid("993fe48c-1f11-4884-b320-fdb2e300c663")]
+[assembly: AssemblyDescription("Provides a XML serializers for NMail's remote access interface.")]
+[assembly: AssemblyCompany("http://NMailServer.SourceForge.net")]
+[assembly: AssemblyProduct("NMail")]
+[assembly: AssemblyCopyright("Copyright © 2006-2007 Luke Quinane")]
-// Version information for an assembly consists of the following four values:
-//
-// Major Version
-// Minor Version
-// Build Number
-// Revision
-//
-// You can specify all the values or you can default the Revision and Build Numbers
-// by using the '*' as shown below:
-[assembly: AssemblyVersion("1.0.0.0")]
-[assembly: AssemblyFileVersion("1.0.0.0")]
+#if DEBUG
+[assembly: AssemblyConfiguration("Debug")]
+#else
+[assembly: AssemblyConfiguration("Release")]
+#endif
Modified: NMail/trunk/NMail.Sendmail/AssemblyInfo.cs
===================================================================
--- NMail/trunk/NMail.Sendmail/AssemblyInfo.cs 2007-03-04 08:42:03 UTC (rev 166)
+++ NMail/trunk/NMail.Sendmail/AssemblyInfo.cs 2007-03-04 10:03:29 UTC (rev 167)
@@ -18,58 +18,17 @@
using System.Reflection;
using System.Runtime.CompilerServices;
-//
-// General Information about an assembly is controlled through the following
-// set of attributes. Change these attribute values to modify the information
-// associated with an assembly.
-//
+// General details
[assembly: AssemblyTitle("NMail sendmail style interface.")]
+[assembly: AssemblyVersion("1.1.*")]
+
[assembly: AssemblyDescription("Provides a 'sendmail' style command line interface.")]
-[assembly: AssemblyConfiguration("")]
-[assembly: AssemblyCompany("")]
-[assembly: AssemblyProduct("")]
-[assembly: AssemblyCopyright("Luke Quinane and Daniel Frampton")]
-[assembly: AssemblyTrademark("")]
-[assembly: AssemblyCulture("")]
+[assembly: AssemblyCompany("http://NMailServer.SourceForge.net")]
+[assembly: AssemblyProduct("NMail")]
+[assembly: AssemblyCopyright("Copyright \xA9 2004-2007 Luke Quinane and Daniel Frampton")]
-//
-// Version information for an assembly consists of the following four values:
-//
-// Major Version
-// Minor Version
-// Build Number
-// Revision
-//
-// You can specify all the values or you can default the Revision and Build Numbers
-// by using the '*' as shown below:
-
-[assembly: AssemblyVersion("1.0.*")]
-
-//
-// In order to sign your assembly you must specify a key to use. Refer to the
-// Microsoft .NET Framework documentation for more information on assembly signing.
-//
-// Use the attributes below to control which key is used for signing.
-//
-// Notes:
-// (*) If no key is specified, the assembly is not signed.
-// (*) KeyName refers to a key that has been installed in the Crypto Service
-// Provider (CSP) on your machine. KeyFile refers to a file which contains
-// a key.
-// (*) If the KeyFile and the KeyName values are both specified, the
-// following processing occurs:
-// (1) If the KeyName can be found in the CSP, that key is used.
-// (2) If the KeyName does not exist and the KeyFile does exist, the key
-// in the KeyFile is installed into the CSP and used.
-// (*) In order to create a KeyFile, you can use the sn.exe (Strong Name) utility.
-// When specifying the KeyFile, the location of the KeyFile should be
-// relative to the project output directory which is
-// %Project Directory%\obj\<configuration>. For example, if your KeyFile is
-// located in the project directory, you would specify the AssemblyKeyFile
-// attribute as [assembly: AssemblyKeyFile("..\\..\\mykey.snk")]
-// (*) Delay Signing is an advanced option - see the Microsoft .NET Framework
-// documentation for more information on this.
-//
-[assembly: AssemblyDelaySign(false)]
-[assembly: AssemblyKeyFile("")]
-[assembly: AssemblyKeyName("")]
+#if DEBUG
+[assembly: AssemblyConfiguration("Debug")]
+#else
+[assembly: AssemblyConfiguration("Release")]
+#endif
Modified: NMail/trunk/NMail.Server.Console/AssemblyInfo.cs
===================================================================
--- NMail/trunk/NMail.Server.Console/AssemblyInfo.cs 2007-03-04 08:42:03 UTC (rev 166)
+++ NMail/trunk/NMail.Server.Console/AssemblyInfo.cs 2007-03-04 10:03:29 UTC (rev 167)
@@ -18,58 +18,17 @@
using System.Reflection;
using System.Runtime.CompilerServices;
-//
-// General Information about an assembly is controlled through the following
-// set of attributes. Change these attribute values to modify the information
-// associated with an assembly.
-//
-[assembly: AssemblyTitle("")]
-[assembly: AssemblyDescription("")]
-[assembly: AssemblyConfiguration("")]
-[assembly: AssemblyCompany("")]
-[assembly: AssemblyProduct("")]
-[assembly: AssemblyCopyright("")]
-[assembly: AssemblyTrademark("")]
-[assembly: AssemblyCulture("")]
+// General details
+[assembly: AssemblyTitle("NMail Console Server.")]
+[assembly: AssemblyVersion("1.1.*")]
-//
-// Version information for an assembly consists of the following four values:
-//
-// Major Version
-// Minor Version
-// Build Number
-// Revision
-//
-// You can specify all the values or you can default the Revision and Build Numbers
-// by using the '*' as shown below:
+[assembly: AssemblyDescription("Provides a console based server for NMail.")]
+[assembly: AssemblyCompany("http://NMailServer.SourceForge.net")]
+[assembly: AssemblyProduct("NMail")]
+[assembly: AssemblyCopyright("Copyright \xA9 2004-2007 Luke Quinane and Daniel Frampton")]
-[assembly: AssemblyVersion("1.0.*")]
-
-//
-// In order to sign your assembly you must specify a key to use. Refer to the
-// Microsoft .NET Framework documentation for more information on assembly signing.
-//
-// Use the attributes below to control which key is used for signing.
-//
-// Notes:
-// (*) If no key is specified, the assembly is not signed.
-// (*) KeyName refers to a key that has been installed in the Crypto Service
-// Provider (CSP) on your machine. KeyFile refers to a file which contains
-// a key.
-// (*) If the KeyFile and the KeyName values are both specified, the
-// following processing occurs:
-// (1) If the KeyName can be found in the CSP, that key is used.
-// (2) If the KeyName does not exist and the KeyFile does exist, the key
-// in the KeyFile is installed into the CSP and used.
-// (*) In order to create a KeyFile, you can use the sn.exe (Strong Name) utility.
-// When specifying the KeyFile, the location of the KeyFile should be
-// relative to the project output directory which is
-// %Project Directory%\obj\<configuration>. For example, if your KeyFile is
-// located in the project directory, you would specify the AssemblyKeyFile
-// attribute as [assembly: AssemblyKeyFile("..\\..\\mykey.snk")]
-// (*) Delay Signing is an advanced option - see the Microsoft .NET Framework
-// documentation for more information on this.
-//
-[assembly: AssemblyDelaySign(false)]
-[assembly: AssemblyKeyFile("")]
-[assembly: AssemblyKeyName("")]
+#if DEBUG
+[assembly: AssemblyConfiguration("Debug")]
+#else
+[assembly: AssemblyConfiguration("Release")]
+#endif
Modified: NMail/trunk/NMail.Server.Service/AssemblyInfo.cs
===================================================================
--- NMail/trunk/NMail.Server.Service/AssemblyInfo.cs 2007-03-04 08:42:03 UTC (rev 166)
+++ NMail/trunk/NMail.Server.Service/AssemblyInfo.cs 2007-03-04 10:03:29 UTC (rev 167)
@@ -18,58 +18,17 @@
using System.Reflection;
using System.Runtime.CompilerServices;
-//
-// General Information about an assembly is controlled through the following
-// set of attributes. Change these attribute values to modify the information
-// associated with an assembly.
-//
-[assembly: AssemblyTitle("")]
-[assembly: AssemblyDescription("")]
-[assembly: AssemblyConfiguration("")]
-[assembly: AssemblyCompany("")]
-[assembly: AssemblyProduct("")]
-[assembly: AssemblyCopyright("")]
-[assembly: AssemblyTrademark("")]
-[assembly: AssemblyCulture("")]
+// General details
+[assembly: AssemblyTitle("NMail Server Service.")]
+[assembly: AssemblyVersion("1.1.*")]
-//
-// Version information for an assembly consists of the following four values:
-//
-// Major Version
-// Minor Version
-// Build Number
-// Revision
-//
-// You can specify all the values or you can default the Revision and Build Numbers
-// by using the '*' as shown below:
+[assembly: AssemblyDescription("Provides a Windows based service to host the NMail server.")]
+[assembly: AssemblyCompany("http://NMailServer.SourceForge.net")]
+[assembly: AssemblyProduct("NMail")]
+[assembly: AssemblyCopyright("Copyright \xA9 2004-2007 Luke Quinane and Daniel Frampton")]
-[assembly: AssemblyVersion("1.0.*")]
-
-//
-// In order to sign your assembly you must specify a key to use. Refer to the
-// Microsoft .NET Framework documentation for more information on assembly signing.
-//
-// Use the attributes below to control which key is used for signing.
-//
-// Notes:
-// (*) If no key is specified, the assembly is not signed.
-// (*) KeyName refers to a key that has been installed in the Crypto Service
-// Provider (CSP) on your machine. KeyFile refers to a file which contains
-// a key.
-// (*) If the KeyFile and the KeyName values are both specified, the
-// following processing occurs:
-// (1) If the KeyName can be found in the CSP, that key is used.
-// (2) If the KeyName does not exist and the KeyFile does exist, the key
-// in the KeyFile is installed into the CSP and used.
-// (*) In order to create a KeyFile, you can use the sn.exe (Strong Name) utility.
-// When specifying the KeyFile, the location of the KeyFile should be
-// relative to the project output directory which is
-// %Project Directory%\obj\<configuration>. For example, if your KeyFile is
-// located in the project directory, you would specify the AssemblyKeyFile
-// attribute as [assembly: AssemblyKeyFile("..\\..\\mykey.snk")]
-// (*) Delay Signing is an advanced option - see the Microsoft .NET Framework
-// documentation for more information on this.
-//
-[assembly: AssemblyDelaySign(false)]
-[assembly: AssemblyKeyFile("")]
-[assembly: AssemblyKeyName("")]
+#if DEBUG
+[assembly: AssemblyConfiguration("Debug")]
+#else
+[assembly: AssemblyConfiguration("Release")]
+#endif
Modified: NMail/trunk/NMail.SetupWizard/Properties/AssemblyInfo.cs
===================================================================
--- NMail/trunk/NMail.SetupWizard/Properties/AssemblyInfo.cs 2007-03-04 08:42:03 UTC (rev 166)
+++ NMail/trunk/NMail.SetupWizard/Properties/AssemblyInfo.cs 2007-03-04 10:03:29 UTC (rev 167)
@@ -19,32 +19,17 @@
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
-// General Information about an assembly is controlled through the following
-// set of attributes. Change these attribute values to modify the information
-// associated with an assembly.
-[assembly: AssemblyTitle("NMail.SetupWizard")]
+// General details
+[assembly: AssemblyTitle("NMail Setup Wizard.")]
+[assembly: AssemblyVersion("1.1.*")]
+
[assembly: AssemblyDescription("A wizard for setting up NMail installations.")]
-[assembly: AssemblyConfiguration("")]
-[assembly: AssemblyCompany("")]
-[assembly: AssemblyProduct("NMail.SetupWizard")]
-[assembly: AssemblyCopyright("Copyright © 2006")]
-[assembly: AssemblyTrademark("")]
-[assembly: AssemblyCulture("")]
+[assembly: AssemblyCompany("http://NMailServer.SourceForge.net")]
+[assembly: AssemblyProduct("NMail")]
+[assembly: AssemblyCopyright("Copyright © 2004-2007 Luke Quinane and Daniel Frampton")]
-// Setting ComVisible to false makes the types in this assembly not visible
-// to COM components. If you need to access a type in this assembly from
-// COM, set the ComVisible attribute to true on that type.
-[assembly: ComVisible(false)]
-
-// The following GUID is for the ID of the typelib if this project is exposed to COM
-[assembly: Guid("a8ab4221-e627-4364-a6e3-f53a368c2b4d")]
-
-// Version information for an assembly consists of the following four values:
-//
-// Major Version
-// Minor Version
-// Build Number
-// Revision
-//
-[assembly: AssemblyVersion("1.0.0.0")]
-[assembly: AssemblyFileVersion("1.0.0.0")]
+#if DEBUG
+[assembly: AssemblyConfiguration("Debug")]
+#else
+[assembly: AssemblyConfiguration("Release")]
+#endif
Modified: NMail/trunk/NMail.SmtpClient/AssemblyInfo.cs
===================================================================
--- NMail/trunk/NMail.SmtpClient/AssemblyInfo.cs 2007-03-04 08:42:03 UTC (rev 166)
+++ NMail/trunk/NMail.SmtpClient/AssemblyInfo.cs 2007-03-04 10:03:29 UTC (rev 167)
@@ -18,58 +18,18 @@
using System.Reflection;
using System.Runtime.CompilerServices;
-//
-// General Information about an assembly is controlled through the following
-// set of attributes. Change these attribute values to modify the information
-// associated with an assembly.
-//
+
+// General details
[assembly: AssemblyTitle("NMail SMTP client.")]
+[assembly: AssemblyVersion("1.1.*")]
+
[assembly: AssemblyDescription("Provides a SMTP client implementation for NMail.")]
-[assembly: AssemblyConfiguration("")]
-[assembly: AssemblyCompany("")]
-[assembly: AssemblyProduct("")]
-[assembly: AssemblyCopyright("Luke Quinane and Daniel Frampton")]
-[assembly: AssemblyTrademark("")]
-[assembly: AssemblyCulture("")]
+[assembly: AssemblyCompany("http://NMailServer.SourceForge.net")]
+[assembly: AssemblyProduct("NMail")]
+[assembly: AssemblyCopyright("Copyright \xA9 2004-2007 Luke Quinane and Daniel Frampton")]
-//
-// Version information for an assembly consists of the following four values:
-//
-// Major Version
-// Minor Version
-// Build Number
-// Revision
-//
-// You can specify all the values or you can default the Revision and Build Numbers
-// by using the '*' as shown below:
-
-[assembly: AssemblyVersion("1.0.*")]
-
-//
-// In order to sign your assembly you must specify a key to use. Refer to the
-// Microsoft .NET Framework documentation for more information on assembly signing.
-//
-// Use the attributes below to control which key is used for signing.
-//
-// Notes:
-// (*) If no key is specified, the assembly is not signed.
-// (*) KeyName refers to a key that has been installed in the Crypto Service
-// Provider (CSP) on your machine. KeyFile refers to a file which contains
-// a key.
-// (*) If the KeyFile and the KeyName values are both specified, the
-// following processing occurs:
-// (1) If the KeyName can be found in the CSP, that key is used.
-// (2) If the KeyName does not exist and the KeyFile does exist, the key
-// in the KeyFile is installed into the CSP and used.
-// (*) In order to create a KeyFile, you can use the sn.exe (Strong Name) utility.
-// When specifying the KeyFile, the location of the KeyFile should be
-// relative to the project output directory which is
-// %Project Directory%\obj\<configuration>. For example, if your KeyFile is
-// located in the project directory, you would specify the AssemblyKeyFile
-// attribute as [assembly: AssemblyKeyFile("..\\..\\mykey.snk")]
-// (*) Delay Signing is an advanced option - see the Microsoft .NET Framework
-// documentation for more information on this.
-//
-[assembly: AssemblyDelaySign(false)]
-[assembly: AssemblyKeyFile("")]
-[assembly: AssemblyKeyName("")]
+#if DEBUG
+[assembly: AssemblyConfiguration("Debug")]
+#else
+[assembly: AssemblyConfiguration("Release")]
+#endif
Modified: NMail/trunk/NMail.SmtpService/AssemblyInfo.cs
===================================================================
--- NMail/trunk/NMail.SmtpService/AssemblyInfo.cs 2007-03-04 08:42:03 UTC (rev 166)
+++ NMail/trunk/NMail.SmtpService/AssemblyInfo.cs 2007-03-04 10:03:29 UTC (rev 167)
@@ -18,58 +18,17 @@
using System.Reflection;
using System.Runtime.CompilerServices;
-//
-// General Information about an assembly is controlled through the following
-// set of attributes. Change these attribute values to modify the information
-// associated with an assembly.
-//
+// General details
[assembly: AssemblyTitle("NMail SMTP service.")]
+[assembly: AssemblyVersion("1.1.*")]
+
[assembly: AssemblyDescription("Provides a SMTP server implementation for NMail.")]
-[assembly: AssemblyConfiguration("")]
-[assembly: AssemblyCompany("")]
-[assembly: AssemblyProduct("")]
-[assembly: AssemblyCopyright("Luke Quinane and Daniel Frampton")]
-[assembly: AssemblyTrademark("")]
-[assembly: AssemblyCulture("")]
+[assembly: AssemblyCompany("http://NMailServer.SourceForge.net")]
+[assembly: AssemblyProduct("NMail")]
+[assembly: AssemblyCopyright("Copyright \xA9 2004-2007 Luke Quinane and Daniel Frampton")]
-//
-// Version information for an assembly consists of the following four values:
-//
-// Major Version
-// Minor Version
-// Build Number
-// Revision
-//
-// You can specify all the values or you can default the Revision and Build Numbers
-// by using the '*' as shown below:
-
-[assembly: AssemblyVersion("1.0.*")]
-
-//
-// In order to sign your assembly you must specify a key to use. Refer to the
-// Microsoft .NET Framework documentation for more information on assembly signing.
-//
-// Use the attributes below to control which key is used for signing.
-//
-// Notes:
-// (*) If no key is specified, the assembly is not signed.
-// (*) KeyName refers to a key that has been installed in the Crypto Service
-// Provider (CSP) on your machine. KeyFile refers to a file which contains
-// a key.
-// (*) If the KeyFile and the KeyName values are both specified, the
-// following processing occurs:
-// (1) If the KeyName can be found in the CSP, that key is used.
-// (2) If the KeyName does not exist and the KeyFile does exist, the key
-// in the KeyFile is installed into the CSP and used.
-// (*) In order to create a KeyFile, you can use the sn.exe (Strong Name) utility.
-// When specifying the KeyFile, the location of the KeyFile should be
-// relative to the project output directory which is
-// %Project Directory%\obj\<configuration>. For example, if your KeyFile is
-// located in the project directory, you would specify the AssemblyKeyFile
-// attribute as [assembly: AssemblyKeyFile("..\\..\\mykey.snk")]
-// (*) Delay Signing is an advanced option - see the Microsoft .NET Framework
-// documentation for more information on this.
-//
-[assembly: AssemblyDelaySign(false)]
-[assembly: AssemblyKeyFile("")]
-[assembly: AssemblyKeyName("")]
+#if DEBUG
+[assembly: AssemblyConfiguration("Debug")]
+#else
+[assembly: AssemblyConfiguration("Release")]
+#endif
Modified: NMail/trunk/NMail.SpoolData.MySql/AssemblyInfo.cs
===================================================================
--- NMail/trunk/NMail.SpoolData.MySql/AssemblyInfo.cs 2007-03-04 08:42:03 UTC (rev 166)
+++ NMail/trunk/NMail.SpoolData.MySql/AssemblyInfo.cs 2007-03-04 10:03:29 UTC (rev 167)
@@ -18,58 +18,17 @@
using System.Reflection;
using System.Runtime.CompilerServices;
-//
-// General Information about an assembly is controlled through the following
-// set of attributes. Change these attribute values to modify the information
-// associated with an assembly.
-//
-[assembly: AssemblyTitle("")]
-[assembly: AssemblyDescription("")]
-[assembly: AssemblyConfiguration("")]
-[assembly: AssemblyCompany("")]
-[assembly: AssemblyProduct("")]
-[assembly: AssemblyCopyright("")]
-[assembly: AssemblyTrademark("")]
-[assembly: AssemblyCulture("")]
+// General details
+[assembly: AssemblyTitle("NMail MySql Spool Data.")]
+[assembly: AssemblyVersion("1.1.*")]
-//
-// Version information for an assembly consists of the following four values:
-//
-// Major Version
-// Minor Version
-// Build Number
-// Revision
-//
-// You can specify all the values or you can default the Revision and Build Numbers
-// by using the '*' as shown below:
+[assembly: AssemblyDescription("Provides a MySql based spool data implementation for NMail.")]
+[assembly: AssemblyCompany("http://NMailServer.SourceForge.net")]
+[assembly: AssemblyProduct("NMail")]
+[assembly: AssemblyCopyright("Copyright \xA9 2004-2007 Luke Quinane and Daniel Frampton")]
-[assembly: AssemblyVersion("1.0.*")]
-
-//
-// In order to sign your assembly you must specify a key to use. Refer to the
-// Microsoft .NET Framework documentation for more information on assembly signing.
-//
-// Use the attributes below to control which key is used for signing.
-//
-// Notes:
-// (*) If no key is specified, the assembly is not signed.
-// (*) KeyName refers to a key that has been installed in the Crypto Service
-// Provider (CSP) on your machine. KeyFile refers to a file which contains
-// a key.
-// (*) If the KeyFile and the KeyName values are both specified, the
-// following processing occurs:
-// (1) If the KeyName can be found in the CSP, that key is used.
-// (2) If the KeyName does not exist and the KeyFile does exist, the key
-// in the KeyFile is installed into the CSP and used.
-// (*) In order to create a KeyFile, you can use the sn.exe (Strong Name) utility.
-// When specifying the KeyFile, the location of the KeyFile should be
-// relative to the project output directory which is
-// %Project Directory%\obj\<configuration>. For example, if your KeyFile is
-// located in the project directory, you would specify the AssemblyKeyFile
-// attribute as [assembly: AssemblyKeyFile("..\\..\\mykey.snk")]
-// (*) Delay Signing is an advanced option - see the Microsoft .NET Framework
-// documentation for more information on this.
-//
-[assembly: AssemblyDelaySign(false)]
-[assembly: AssemblyKeyFile("")]
-[assembly: AssemblyKeyName("")]
+#if DEBUG
+[assembly: AssemblyConfiguration("Debug")]
+#else
+[assembly: AssemblyConfiguration("Release")]
+#endif
Modified: NMail/trunk/NMail.SpoolData.NHibernate/Properties/AssemblyInfo.cs
===================================================================
--- NMail/trunk/NMail.SpoolData.NHibernate/Properties/AssemblyInfo.cs 2007-03-04 08:42:03 UTC (rev 166)
+++ NMail/trunk/NMail.SpoolData.NHibernate/Properties/AssemblyInfo.cs 2007-03-04 10:03:29 UTC (rev 167)
@@ -1,35 +1,34 @@
-using System.Reflection;
+/*
+ * Copyright 2004-2007 Luke Quinane
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ */
+
+using System.Reflection;
using System.Runtime.CompilerServices;
-using System.Runtime.InteropServices;
-// General Information about an assembly is controlled through the following
-// set of attributes. Change these attribute values to modify the information
-// associated with an assembly.
-[assembly: AssemblyTitle("NMail.SpoolData.NHibernate")]
-[assembly: AssemblyDescription("")]
-[assembly: AssemblyConfiguration("")]
-[assembly: AssemblyCompany("")]
-[assembly: AssemblyProduct("NMail.SpoolData.NHibernate")]
-[assembly: AssemblyCopyright("Copyright © 2007")]
-[assembly: AssemblyTrademark("")]
-[assembly: AssemblyCulture("")]
+// General details
+[assembly: AssemblyTitle("NMail NHibernate Spool Data.")]
+[assembly: AssemblyVersion("1.1.*")]
-// Setting ComVisible to false makes the types in this assembly not visible
-// to COM components. If you need to access a type in this assembly from
-// COM, set the ComVisible attribute to true on that type.
-[assembly: ComVisible(false)]
+[assembly: AssemblyDescription("Provides a NHibernate based spool data implementation for NMail.")]
+[assembly: AssemblyCompany("http://NMailServer.SourceForge.net")]
+[assembly: AssemblyProduct("NMail")]
+[assembly: AssemblyCopyright("Copyright © 2007 Luke Quinane")]
-// The following GUID is for the ID of the typelib if this project is exposed to COM
-[assembly: Guid("5bd9b2cc-5edd-4939-8e20-3a93b57209d0")]
-
-// Version information for an assembly consists of the following four values:
-//
-// Major Version
-// Minor Version
-// Build Number
-// Revision
-//
-// You can specify all the values or you can default the Revision and Build Numbers
-// by using the '*' as shown below:
-[assembly: AssemblyVersion("1.0.0.0")]
-[assembly: AssemblyFileVersion("1.0.0.0")]
+#if DEBUG
+[assembly: AssemblyConfiguration("Debug")]
+#else
+[assembly: AssemblyConfiguration("Release")]
+#endif
Modified: NMail/trunk/NMail.SpoolFilter/AssemblyInfo.cs
===================================================================
--- NMail/trunk/NMail.SpoolFilter/AssemblyInfo.cs 2007-03-04 08:42:03 UTC (rev 166)
+++ NMail/trunk/NMail.SpoolFilter/AssemblyInfo.cs 2007-03-04 10:03:29 UTC (rev 167)
@@ -18,58 +18,17 @@
using System.Reflection;
using System.Runtime.CompilerServices;
-//
-// General Information about an assembly is controlled through the following
-// set of attributes. Change these attribute values to modify the information
-// associated with an assembly.
-//
-[assembly: AssemblyTitle("")]
-[assembly: AssemblyDescription("")]
-[assembly: AssemblyConfiguration("")]
-[assembly: AssemblyCompany("")]
-[assembly: AssemblyProduct("")]
-[assembly: AssemblyCopyright("")]
-[assembly: AssemblyTrademark("")]
-[assembly: AssemblyCulture("")]
+// General details
+[assembly: AssemblyTitle("NMail Spool Filter Service.")]
+[assembly: AssemblyVersion("1.1.*")]
-//
-// Version information for an assembly consists of the following four values:
-//
-// Major Version
-// Minor Version
-// Build Number
-// Revision
-//
-// You can specify all the values or you can default the Revision and Build Numbers
-// by using the '*' as shown below:
+[assembly: AssemblyDescription("Provides a spool filter service implementation for NMail.")]
+[assembly: AssemblyCompany("http://NMailServer.SourceForge.net")]
+[assembly: AssemblyProduct("NMail")]
+[assembly: AssemblyCopyright("Copyright \xA9 2004-2007 Luke Quinane and Daniel Frampton")]
-[assembly: AssemblyVersion("1.0.*")]
-
-//
-// In order to sign your assembly you must specify a key to use. Refer to the
-// Microsoft .NET Framework documentation for more information on assembly signing.
-//
-// Use the attributes below to control which key is used for signing.
-//
-// Notes:
-// (*) If no key is specified, the assembly is not signed.
-// (*) KeyName refers to a key that has been installed in the Crypto Service
-// Provider (CSP) on your machine. KeyFile refers to a file which contains
-// a key.
-// (*) If the KeyFile and the KeyName values are both specified, the
-// following processing occurs:
-// (1) If the KeyName can be found in the CSP, that key is used.
-// (2) If the KeyName does not exist and the KeyFile does exist, the key
-// in the KeyFile is installed into the CSP and used.
-// (*) In order to create a KeyFile, you can use the sn.exe (Strong Name) utility.
-// When specifying the KeyFile, the location of the KeyFile should be
-// relative to the project output directory which is
-// %Project Directory%\obj\<configuration>. For example, if your KeyFile is
-// located in the project directory, you would specify the AssemblyKeyFile
-// attribute as [assembly: AssemblyKeyFile("..\\..\\mykey.snk")]
-// (*) Delay Signing is an advanced option - see the Microsoft .NET Framework
-// documentation for more information on this.
-//
-[assembly: AssemblyDelaySign(false)]
-[assembly: AssemblyKeyFile("")]
-[assembly: AssemblyKeyName("")]
+#if DEBUG
+[assembly: AssemblyConfiguration("Debug")]
+#else
+[assembly: AssemblyConfiguration("Release")]
+#endif
Modified: NMail/trunk/NMail.SpoolService/AssemblyInfo.cs
===================================================================
--- NMail/trunk/NMail.SpoolService/AssemblyInfo.cs 2007-03-04 08:42:03 UTC (rev 166)
+++ NMail/trunk/NMail.SpoolService/AssemblyInfo.cs 2007-03-04 10:03:29 UTC (rev 167)
@@ -18,58 +18,18 @@
using System.Reflection;
using System.Runtime.CompilerServices;
-//
-// General Information about an assembly is controlled through the following
-// set of attributes. Change these attribute values to modify the information
-// associated with an assembly.
-//
-[assembly: AssemblyTitle("NMail SMTP spool service.")]
-[assembly: AssemblyDescription("Provides an implem...
[truncated message content] |
|
From: <tmy...@us...> - 2007-03-04 08:42:05
|
Revision: 166
http://svn.sourceforge.net/nmailserver/?rev=166&view=rev
Author: tmyroadctfig
Date: 2007-03-04 00:42:03 -0800 (Sun, 04 Mar 2007)
Log Message:
-----------
Fixed defect in the RSET command (BUG 1673354).
Modified Paths:
--------------
NMail/trunk/NMail.SmtpService/Command/ResetCommand.cs
Modified: NMail/trunk/NMail.SmtpService/Command/ResetCommand.cs
===================================================================
--- NMail/trunk/NMail.SmtpService/Command/ResetCommand.cs 2007-03-04 08:36:21 UTC (rev 165)
+++ NMail/trunk/NMail.SmtpService/Command/ResetCommand.cs 2007-03-04 08:42:03 UTC (rev 166)
@@ -17,6 +17,7 @@
using System;
using System.Collections.Generic;
+using System.Net;
using System.Text;
using NMail.DataTypes;
@@ -54,6 +55,8 @@
}
session.Message = new SmtpMessage();
+ session.Message.ReportedHost = session.ReportedHost;
+ session.Message.SourceAddress = session.ClientAddress;
session.Connection.Ok();
} else {
throw new ApplicationException("Invalid command syntax");
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <tmy...@us...> - 2007-03-04 08:36:28
|
Revision: 165
http://svn.sourceforge.net/nmailserver/?rev=165&view=rev
Author: tmyroadctfig
Date: 2007-03-04 00:36:21 -0800 (Sun, 04 Mar 2007)
Log Message:
-----------
Work on unit tests. Completed work on NHibernate spool data.
Modified Paths:
--------------
NMail/trunk/NMail/DataTypes/LocalStore/LocalStoreDelivery.cs
NMail/trunk/NMail/DataTypes/SmtpMessage.cs
NMail/trunk/NMail/DataTypes/SmtpMessageRecipient.cs
NMail/trunk/NMail.LocalStore/DeliveryActions/ManageWhiteList.cs
NMail/trunk/NMail.MessageRouter/MessageRouter.cs
NMail/trunk/NMail.Sendmail/Sendmail.cs
NMail/trunk/NMail.SmtpClient/SmtpClient.cs
NMail/trunk/NMail.SmtpService/Command/DataCommand.cs
NMail/trunk/NMail.SpoolData.MySql/MySqlSpoolData.cs
NMail/trunk/NMail.SpoolData.NHibernate/NHibernateSpoolData.cs
NMail/trunk/NMail.SpoolData.NHibernate/NMail.SpoolData.NHibernate.hbm.xml
NMail/trunk/NMail.UnitTests/LocalStoreData/CalendarTests.cs
NMail/trunk/NMail.UnitTests/NMail.UnitTests.csproj
NMail/trunk/NMail.UnitTests/SpoolData/FilterTest1.cs
NMail/trunk/NMail.UnitTests/SpoolData/FilterTest2.cs
NMail/trunk/NMail.UnitTests/SpoolData/FilterTest3.cs
NMail/trunk/NMail.UnitTests/SpoolData/GetMsgToFilterTest1.cs
NMail/trunk/NMail.UnitTests/SpoolData/InitTest1.cs
NMail/trunk/NMail.UnitTests/SpoolData/NextDeliveryTest1.cs
NMail/trunk/NMail.UnitTests/SpoolData/SpoolMessageTest1.cs
NMail/trunk/NMail.sln
Added Paths:
-----------
NMail/trunk/NMail.UnitTests/LocalStoreData/BaseLocalStoreDataTest.cs
NMail/trunk/NMail.UnitTests/SpoolData/BeginDeliveryTest1.cs
NMail/trunk/NMail.UnitTests/SpoolData/BeginDeliveryTest2.cs
NMail/trunk/NMail.UnitTests/SpoolData/BeginDeliveryTest3.cs
NMail/trunk/NMail.UnitTests/SpoolData/CompleteDeliveryTest1.cs
Modified: NMail/trunk/NMail/DataTypes/LocalStore/LocalStoreDelivery.cs
===================================================================
--- NMail/trunk/NMail/DataTypes/LocalStore/LocalStoreDelivery.cs 2007-03-04 05:32:53 UTC (rev 164)
+++ NMail/trunk/NMail/DataTypes/LocalStore/LocalStoreDelivery.cs 2007-03-04 08:36:21 UTC (rev 165)
@@ -31,7 +31,7 @@
public LocalStoreDelivery(SmtpMessageRecipient recipient, Folder nominalTargetFolder) {
this.recipient = recipient.Address;
this.sender = recipient.Message.Sender;
- this.message = recipient.Message.Data;
+ this.message = recipient.Message.Message;
this.folderDelimiter = NMailConfiguration.Current.LocalStore.FolderDelimiter;
Modified: NMail/trunk/NMail/DataTypes/SmtpMessage.cs
===================================================================
--- NMail/trunk/NMail/DataTypes/SmtpMessage.cs 2007-03-04 05:32:53 UTC (rev 164)
+++ NMail/trunk/NMail/DataTypes/SmtpMessage.cs 2007-03-04 08:36:21 UTC (rev 165)
@@ -69,7 +69,7 @@
private bool inProgress;
/// <summary>
- /// True if the message is in progress.
+ /// True if the message is in progress of being filtered.
/// </summary>
public bool InProgress {
get { return inProgress; }
@@ -96,21 +96,29 @@
set { envelope = value; }
}
- private Message data;
+ private Message message;
/// <summary>
/// Gets or sets the data (headers and body content) of the message.
/// </summary>
- public Message Data {
+ public Message Message {
get {
- return this.data;
+ return this.message;
}
set {
- this.data = value;
- this.envelope = this.data.GetEnvelope();
+ this.message = value;
+ this.envelope = this.message.GetEnvelope();
}
}
+ /// <summary>
+ /// The size of the message in bytes.
+ /// </summary>
+ public int MessageSize {
+ get { return this.message.Size; }
+ private set { } // Hack: for NHibernate
+ }
+
private EmailAddress sender;
/// <summary>
Modified: NMail/trunk/NMail/DataTypes/SmtpMessageRecipient.cs
===================================================================
--- NMail/trunk/NMail/DataTypes/SmtpMessageRecipient.cs 2007-03-04 05:32:53 UTC (rev 164)
+++ NMail/trunk/NMail/DataTypes/SmtpMessageRecipient.cs 2007-03-04 08:36:21 UTC (rev 165)
@@ -185,5 +185,13 @@
public static bool operator != (SmtpMessageRecipient recipientA, SmtpMessageRecipient recipientB) {
return !(recipientA == recipientB);
}
+
+ /// <summary>
+ /// This recipient as a string.
+ /// </summary>
+ /// <returns>The string.</returns>
+ public override string ToString() {
+ return this.Address.ToString();
+ }
}
}
Modified: NMail/trunk/NMail.LocalStore/DeliveryActions/ManageWhiteList.cs
===================================================================
--- NMail/trunk/NMail.LocalStore/DeliveryActions/ManageWhiteList.cs 2007-03-04 05:32:53 UTC (rev 164)
+++ NMail/trunk/NMail.LocalStore/DeliveryActions/ManageWhiteList.cs 2007-03-04 08:36:21 UTC (rev 165)
@@ -185,7 +185,7 @@
SmtpMessage result = new SmtpMessage();
result.AddRecipient(sender);
result.Sender = recipient;
- result.Data = new Message(messageText);
+ result.Message = new Message(messageText);
result.ReportedHost = new Host(System.Net.IPAddress.Loopback);
result.SourceAddress = System.Net.IPAddress.Loopback;
return result;
Modified: NMail/trunk/NMail.MessageRouter/MessageRouter.cs
===================================================================
--- NMail/trunk/NMail.MessageRouter/MessageRouter.cs 2007-03-04 05:32:53 UTC (rev 164)
+++ NMail/trunk/NMail.MessageRouter/MessageRouter.cs 2007-03-04 08:36:21 UTC (rev 165)
@@ -224,7 +224,7 @@
SmtpMessage result = new SmtpMessage();
result.ReportedHost = Config.Current.VisibleHost;
result.SourceAddress = IPAddress.Loopback;
- result.Data = templateMessage;
+ result.Message = templateMessage;
result.Sender = new EmailAddress(new Mailbox(null, true), Config.Current.VisibleHost);
result.AddRecipient(sender);
Modified: NMail/trunk/NMail.Sendmail/Sendmail.cs
===================================================================
--- NMail/trunk/NMail.Sendmail/Sendmail.cs 2007-03-04 05:32:53 UTC (rev 164)
+++ NMail/trunk/NMail.Sendmail/Sendmail.cs 2007-03-04 08:36:21 UTC (rev 165)
@@ -51,7 +51,7 @@
// Make the SMTP message
SmtpMessage smtpMessage = new SmtpMessage();
- smtpMessage.Data = message;
+ smtpMessage.Message = message;
// Get the sender
if (options.Sender == null) {
Modified: NMail/trunk/NMail.SmtpClient/SmtpClient.cs
===================================================================
--- NMail/trunk/NMail.SmtpClient/SmtpClient.cs 2007-03-04 05:32:53 UTC (rev 164)
+++ NMail/trunk/NMail.SmtpClient/SmtpClient.cs 2007-03-04 08:36:21 UTC (rev 165)
@@ -226,7 +226,7 @@
// Can we send this message?
if (!HasExtension(ESmtpExtensionCode.EightBitMime)) {
- if (currentMessage.Data.Data.Encoding != Encoding.ASCII) {
+ if (currentMessage.Message.Data.Encoding != Encoding.ASCII) {
// We don't know how to 8BitMime --> 7Bit
DeliveryResult result = new DeliveryResult(DeliveryResultType.PermanentError,
"Remote server only supports 7BIT and message body is 8BITMIME.");
@@ -237,7 +237,7 @@
} else {
// Is the body 8 bit mime or 7 bit
mailFromParameters.Add("BODY",
- (currentMessage.Data.Data.Encoding == Encoding.ASCII)
+ (currentMessage.Message.Data.Encoding == Encoding.ASCII)
? "7BIT"
: "8BITMIME");
}
@@ -245,7 +245,7 @@
// Size Extension specific stuff
if (HasExtension(ESmtpExtensionCode.Size)) {
// Is our message under the limit?
- if (currentMessage.Data.Size > sizeLimit) {
+ if (currentMessage.Message.Size > sizeLimit) {
// Message is too large
DeliveryResult result = new DeliveryResult(DeliveryResultType.PermanentError,
"Message is larger than server message size limit.");
@@ -255,7 +255,7 @@
}
// Add the mail from size header
- mailFromParameters.Add("SIZE", this.currentMessage.Data.Size.ToString());
+ mailFromParameters.Add("SIZE", this.currentMessage.Message.Size.ToString());
}
try {
@@ -386,9 +386,9 @@
/// </summary>
private bool SimpleSendData() {
try {
- this.connection.DataContents(this.currentMessage.Data);
+ this.connection.DataContents(this.currentMessage.Message);
- int blocks = this.currentMessage.Data.Size / 1024;
+ int blocks = this.currentMessage.Message.Size / 1024;
blocks = (blocks > 0) ? blocks : 1;
this.response = this.connection.GetResponse(TimeSpan.FromSeconds(this.config.TimeoutDataBlock.TotalSeconds * blocks));
Modified: NMail/trunk/NMail.SmtpService/Command/DataCommand.cs
===================================================================
--- NMail/trunk/NMail.SmtpService/Command/DataCommand.cs 2007-03-04 05:32:53 UTC (rev 164)
+++ NMail/trunk/NMail.SmtpService/Command/DataCommand.cs 2007-03-04 08:36:21 UTC (rev 165)
@@ -94,8 +94,8 @@
}
// Parse the message headers
- session.Message.Data = new Message(messageData.ToByteString());
- MessageHeaders headers = session.Message.Data.Headers;
+ session.Message.Message = new Message(messageData.ToByteString());
+ MessageHeaders headers = session.Message.Message.Headers;
// Check the headers for signs of an endless SMTP loop
if (headers.GetHeaders("Recieved") == null
Modified: NMail/trunk/NMail.SpoolData.MySql/MySqlSpoolData.cs
===================================================================
--- NMail/trunk/NMail.SpoolData.MySql/MySqlSpoolData.cs 2007-03-04 05:32:53 UTC (rev 164)
+++ NMail/trunk/NMail.SpoolData.MySql/MySqlSpoolData.cs 2007-03-04 08:36:21 UTC (rev 165)
@@ -108,7 +108,7 @@
cmd.Transaction = transaction;
cmd.CommandText = "SELECT MessageId FROM MessageRecipient WHERE MessageRecipientId = ?MessageRecipientId";
cmd.Parameters.Add("?MessageRecipientId", messageRecipientId);
- int messageId = (int)cmd.ExecuteScalar();
+ Guid messageId = new Guid((byte[])cmd.ExecuteScalar());
// Either delivered successfully or permenant failure, delete the recipient
cmd = cnn.CreateCommand();
@@ -121,7 +121,7 @@
cmd = cnn.CreateCommand();
cmd.Transaction = transaction;
cmd.CommandText = "SELECT COUNT(*) FROM MessageRecipient WHERE MessageId = ?MessageId";
- cmd.Parameters.Add("?MessageId", messageId);
+ cmd.Parameters.Add("?MessageId", messageId.ToByteArray());
long count = (long)cmd.ExecuteScalar();
if (count == 0) {
@@ -129,7 +129,7 @@
cmd = cnn.CreateCommand();
cmd.Transaction = transaction;
cmd.CommandText = "DELETE FROM Message WHERE MessageId = ?MessageId";
- cmd.Parameters.Add("?MessageId", messageId);
+ cmd.Parameters.Add("?MessageId", messageId.ToByteArray());
if (cmd.ExecuteNonQuery() != 1) {
transaction.Rollback();
@@ -237,7 +237,7 @@
result.Sender = new EmailAddress((string)reader["Sender"], true);
result.ReportedHost = new Host((string)reader["ReportedHost"]);
result.SourceAddress = IPAddress.Parse((string)reader["SourceAddress"]);
- result.Data = (Message)SerializationHelper.Deserialize((byte[])reader["MessageData"]);
+ result.Message = (Message)SerializationHelper.Deserialize((byte[])reader["MessageData"]);
reader.Close();
cmd = cnn.CreateCommand();
@@ -294,8 +294,8 @@
// Insert the sender details and message data
cmd.CommandText = "INSERT INTO Message (MessageId, MessageData, MessageEnvelope, ReportedHost, SourceAddress, Sender, InProgress, Filtered) VALUES (?MessageId, ?MessageData, ?MessageEnvelope, ?ReportedHost, ?SourceAddress, ?Sender, ?InProgress, ?Filtered);";
cmd.Parameters.Add("?MessageId", message.MessageId.ToByteArray());
- cmd.Parameters.Add("?MessageData", SerializationHelper.Serialize(message.Data));
- cmd.Parameters.Add("?MessageEnvelope", SerializationHelper.Serialize(message.Data.GetEnvelope()));
+ cmd.Parameters.Add("?MessageData", SerializationHelper.Serialize(message.Message));
+ cmd.Parameters.Add("?MessageEnvelope", SerializationHelper.Serialize(message.Message.GetEnvelope()));
cmd.Parameters.Add("?ReportedHost", message.ReportedHost.ToString());
cmd.Parameters.Add("?SourceAddress", message.SourceAddress.ToString());
cmd.Parameters.Add("?Sender", message.Sender.ToString());
@@ -349,7 +349,7 @@
cmd.Parameters.Add("?CurrentTime", DateTime.Now);
object hostname = cmd.ExecuteScalar();
- if (hostname is DBNull) {
+ if (hostname == null || hostname is DBNull ) {
// No messages ready for delivery
transaction.Commit();
log.Debug("No hosts ready to deliver.");
@@ -381,23 +381,26 @@
for (int i = 0; i < messageIds.Length; i++) {
cmd = cnn.CreateCommand();
cmd.Transaction = transaction;
- cmd.CommandText = "SELECT MessageId, ReportedHost, SourceAddress, Sender, MessageData FROM Message WHERE MessageId = ?MessageId";
+ cmd.CommandText = "SELECT MessageId, Filtered, ReportedHost, SourceAddress, Sender, MessageData FROM Message WHERE MessageId = ?MessageId";
cmd.Parameters.Add("?MessageId", messageIds[i].ToByteArray());
reader = cmd.ExecuteReader();
if (reader.Read()) {
SmtpMessage currentMessage = new SmtpMessage();
+ currentMessage.MessageId = new Guid((byte[]) reader["MessageId"]);
currentMessage.ReportedHost = new Host((string)reader["ReportedHost"]);
currentMessage.SourceAddress = IPAddress.Parse((string)reader["SourceAddress"]);
currentMessage.Sender = new EmailAddress((string)reader["Sender"], true);
- currentMessage.Data = (Message)SerializationHelper.Deserialize((byte[])reader["MessageData"]);
+ currentMessage.Message = (Message)SerializationHelper.Deserialize((byte[])reader["MessageData"]);
+ currentMessage.Filtered = ((sbyte) reader["Filtered"] == 1) ? true : false;
reader.Close();
// Read in all the recipients details
cmd = cnn.CreateCommand();
cmd.Transaction = transaction;
- cmd.CommandText = "SELECT MessageRecipientId, Recipient, DeliveryAttempts, NextDeliveryAttempt FROM MessageRecipient WHERE MessageId = ?MessageId AND InProgress = false";
- cmd.Parameters.Add("?MessageId", messageIds[i]);
+ cmd.CommandText = "SELECT MessageRecipientId, Recipient, DeliveryAttempts, NextDeliveryAttempt FROM MessageRecipient WHERE MessageId = ?MessageId AND InProgress = false AND Host = ?Host";
+ cmd.Parameters.Add("?MessageId", messageIds[i].ToByteArray());
+ cmd.Parameters.Add("?Host", host.Name);
reader = cmd.ExecuteReader();
ArrayList recipientIdList = new ArrayList();
@@ -405,6 +408,7 @@
SmtpMessageRecipient messageRecipient = new SmtpMessageRecipient(currentMessage, new EmailAddress((string)reader["Recipient"]));
messageRecipient.DeliveryAttempts = (int)reader["DeliveryAttempts"];
messageRecipient.NextDeliveryAttempt = reader.GetDateTime(3);
+ messageRecipient.InProgress = true;
currentMessage.Recipients.Add(messageRecipient);
int messageRecipeintId = (int)reader["MessageRecipientId"];
Modified: NMail/trunk/NMail.SpoolData.NHibernate/NHibernateSpoolData.cs
===================================================================
--- NMail/trunk/NMail.SpoolData.NHibernate/NHibernateSpoolData.cs 2007-03-04 05:32:53 UTC (rev 164)
+++ NMail/trunk/NMail.SpoolData.NHibernate/NHibernateSpoolData.cs 2007-03-04 08:36:21 UTC (rev 165)
@@ -47,7 +47,7 @@
this.hibernateCfg.AddAssembly("NMail.SpoolData.NHibernate");
this.hibernateFactory = this.hibernateCfg.BuildSessionFactory();
- }
+ }
#region ISpoolData Members
/// <summary>
@@ -129,6 +129,7 @@
}
#endregion
+ #region Begin Delivery Batch
/// <summary>
/// Gets the next batch of messages for delivery subject to constraints.
/// </summary>
@@ -139,12 +140,12 @@
using (ISession session = this.hibernateFactory.OpenSession()) {
using (ITransaction tx = session.BeginTransaction()) {
// Get a host that has recipients ready for delivery
- IQuery query = session.CreateQuery("select mr1.Host from NMail.DataTypes.SmtpMessageRecipient as mr1 where mr1.NextDeliveryAttempt <= ?CurrentTime and mr1.InProgress = false and mr.Message.Filtered = true and mr1.Host not in (select mr2.Host from NMail.DataTypes.MessageRecipient as mr2 where mr2.InProgress = true) order by mr1.NextDeliveryAttempt asc")
+ IQuery query = session.CreateQuery("select mr1.Host from NMail.DataTypes.SmtpMessageRecipient as mr1 where mr1.NextDeliveryAttempt <= :CurrentTime and mr1.InProgress = false and mr1.Message.Filtered = true and mr1.Host not in (select mr2.Host from NMail.DataTypes.SmtpMessageRecipient as mr2 where mr2.InProgress = true) order by mr1.NextDeliveryAttempt asc")
.SetMaxResults(1)
- .SetParameter(0, DateTime.Now);
+ .SetDateTime("CurrentTime", DateTime.Now);
Host host = query.UniqueResult<Host>();
-
+
if (host == null) {
// No messages ready for delivery
tx.Commit();
@@ -154,97 +155,64 @@
DeliveryBatch batch = new DeliveryBatch(host);
int currentSize = 0;
- List<Guid> messageIdList = new List<Guid>();
+ List<Guid> messageIds = new List<Guid>();
- //// Get a list of message sizes & use to build a list of messages to deliver
- //query = session.CreateQuery("select mr1.MessageId, LENGTH(m.MessageData) AS Size from MessageRecipient mr1 where mr1.InProgress = false and mr1.Message.Filtered = true and mr1.Host = ?Host order by mr1.NextDeliveryAttempt asc")
- // .SetMaxResults(messageLimit)
- // .SetParameter(0, host);
+ // Get a list of message sizes & use to build a list of messages to deliver
+ query = session.CreateQuery("select mr1.Message.MessageId, mr1.Message.MessageSize from SmtpMessageRecipient mr1 where mr1.InProgress = false and mr1.Message.Filtered = true and mr1.Host = :Host order by mr1.NextDeliveryAttempt asc")
+ .SetMaxResults(messageLimit)
+ .SetParameter("Host", host);
+ IList idSizeList = query.List();
- //query.
+ for (int i = 0; i < idSizeList.Count; i++) {
+ object[] current = (object[]) idSizeList[i];
- //MySqlDataReader reader = cmd.ExecuteReader();
- //while (reader.Read()) {
- // messageIdList.Add(reader.GetInt32(0));
- // currentSize += reader.GetInt32(1);
+ messageIds.Add((Guid) current[0]);
+ currentSize += (int) current[1];
- // if (currentSize > sizeLimit)
- // break;
- //}
- //reader.Close();
+ if (currentSize > sizeLimit) {
+ break;
+ }
+ }
+ // Read in the details for each message
+ for (int i = 0; i < messageIds.Count; i++) {
+ // Load the message
+ SmtpMessage currentMessage = session.Load<SmtpMessage>(messageIds[i]);
+ // Filter out any recipients that a not going to our destination host
+ List<SmtpMessageRecipient> removeList = new List<SmtpMessageRecipient>();
+ for (int j = 0; j < currentMessage.Recipients.Count; j++) {
+ if (currentMessage.Recipients[j].Host != host) {
+ removeList.Add(currentMessage.Recipients[j]);
+ }
+ }
+ // Don't update the DB when these recipients are removed
+ session.Evict(currentMessage);
+ foreach (SmtpMessageRecipient recipient in removeList) {
+ currentMessage.Recipients.Remove(recipient);
+ }
+ // Set all the recipient's InProgress flags
+ foreach (SmtpMessageRecipient recipient in currentMessage.Recipients) {
+ recipient.InProgress = true;
+ session.Update(recipient);
+ }
+ batch.AddMessage(currentMessage);
+ }
- // // Read in the details for each message
- // int[] messageIds = (int[]) messageIdList.ToArray(typeof(int));
- // for (int i = 0; i < messageIds.Length; i++) {
- // cmd = cnn.CreateCommand();
- // cmd.Transaction = transaction;
- // cmd.CommandText = "SELECT MessageGuid, ReportedHost, SourceAddress, Sender, MessageData FROM Message WHERE MessageId = ?MessageId";
- // cmd.Parameters.Add("?MessageId", messageIds[i]);
- // reader = cmd.ExecuteReader();
-
- // if (reader.Read()) {
- // SmtpMessage currentMessage = new SmtpMessage();
- // currentMessage.MessageId = new Guid((byte[]) reader["MessageGuid"]);
- // currentMessage.ReportedHost = new Host((string) reader["ReportedHost"]);
- // currentMessage.SourceAddress = IPAddress.Parse((string) reader["SourceAddress"]);
- // currentMessage.Sender = new EmailAddress((string) reader["Sender"], true);
- // currentMessage.Data = (Message) SerializationHelper.Deserialize((byte[]) reader["MessageData"]);
- // reader.Close();
-
- // // Read in all the recipients details
- // cmd = cnn.CreateCommand();
- // cmd.Transaction = transaction;
- // cmd.CommandText = "SELECT MessageRecipientId, Recipient, DeliveryAttempts, NextDeliveryAttempt FROM MessageRecipient WHERE MessageId = ?MessageId AND InProgress = false";
- // cmd.Parameters.Add("?MessageId", messageIds[i]);
- // reader = cmd.ExecuteReader();
-
- // ArrayList recipientIdList = new ArrayList();
- // while (reader.Read()) {
- // SmtpMessageRecipient messageRecipient = new SmtpMessageRecipient(currentMessage, (string) reader["Recipient"]);
- // messageRecipient.DeliveryAttempts = (int) reader["DeliveryAttempts"];
- // messageRecipient.NextDeliveryAttempt = reader.GetDateTime(3);
- // currentMessage.AddRecipient(messageRecipient);
-
- // int messageRecipeintId = (int) reader["MessageRecipientId"];
- // recipientIdList.Add(messageRecipeintId);
- // }
- // reader.Close();
-
- // // Set all the recipient's InProgress flags
- // int[] recipientIds = (int[]) recipientIdList.ToArray(typeof(int));
- // for (int j = 0; j < recipientIds.Length; j++) {
- // cmd.CommandText = "UPDATE MessageRecipient SET InProgress = true WHERE MessageRecipientId = ?MessageRecipientId";
- // cmd.Parameters.Add("?MessageRecipientId", recipientIds[j]);
- // cmd.Transaction = transaction;
-
- // if (cmd.ExecuteNonQuery() != 1) {
- // throw new Exception("Error updating in-progress flag.");
- // }
- // }
-
- // batch.AddMessage(currentMessage);
- // }
-
- // if (!reader.IsClosed) {
- // reader.Close();
- // }
- // }
- // transaction.Commit();
- // log.Debug("Delivery batch created, " + batch.GetMessages().Length + " messages.");
- // return batch;
+ tx.Commit();
+ log.Debug("Delivery batch created, " + batch.GetMessages().Length + " messages.");
+ return batch;
}
}
-
- return null;
}
+ #endregion
+ #region Complete Delivery Attempt
/// <summary>
/// Either removes a recipient from a spool message or increments the number of
/// failed delivery attempts for the recipient. Also schedules the next delivery
@@ -266,10 +234,11 @@
} else {
// Either delivered successfully or permenant failure, delete the recipient
- SmtpMessage message = recipient.Message;
- message.Recipients.Remove(recipient);
+ SmtpMessage message = session.Load<SmtpMessage>(recipient.Message.MessageId);
+ SmtpMessageRecipient dbRecipient = session.Load<SmtpMessageRecipient>(recipient.RecipientId);
+ message.Recipients.Remove(dbRecipient);
session.Update(message);
- session.Delete(recipient);
+ session.Delete(dbRecipient);
// Check if any recipients remain
if (message.Recipients.Count == 0) {
@@ -296,6 +265,7 @@
CompleteDeliveryAttempt(recipient, result);
}
}
+ #endregion
#region Get Next Delivery Attempt
/// <summary>
@@ -378,7 +348,7 @@
recipient.NextDeliveryAttempt = deliveryTime;
}
- session.Update(message);
+ session.Update(message);
tx.Commit();
Modified: NMail/trunk/NMail.SpoolData.NHibernate/NMail.SpoolData.NHibernate.hbm.xml
===================================================================
--- NMail/trunk/NMail.SpoolData.NHibernate/NMail.SpoolData.NHibernate.hbm.xml 2007-03-04 05:32:53 UTC (rev 164)
+++ NMail/trunk/NMail.SpoolData.NHibernate/NMail.SpoolData.NHibernate.hbm.xml 2007-03-04 08:36:21 UTC (rev 165)
@@ -21,9 +21,9 @@
<property name="Filtered" not-null="true" />
- <property name="Data" type="Serializable" />
+ <property name="Message" type="Serializable" />
- <property name="Data.Size" type="Int32" />
+ <property name="MessageSize" type="Int32" />
<property name="Envelope" not-null="true" />
Added: NMail/trunk/NMail.UnitTests/LocalStoreData/BaseLocalStoreDataTest.cs
===================================================================
--- NMail/trunk/NMail.UnitTests/LocalStoreData/BaseLocalStoreDataTest.cs (rev 0)
+++ NMail/trunk/NMail.UnitTests/LocalStoreData/BaseLocalStoreDataTest.cs 2007-03-04 08:36:21 UTC (rev 165)
@@ -0,0 +1,27 @@
+using System;
+using System.Collections.Generic;
+using System.Text;
+
+using NUnit.Framework;
+
+using NMail.DataTypes.LocalStore;
+
+namespace NMail.UnitTests.LocalStoreData {
+ /// <summary>
+ /// A base class for local store data tests.
+ /// </summary>
+ public abstract class BaseLocalStoreDataTest {
+
+ protected ILocalStoreData localStoreData = NMail.Configuration.NMailConfiguration.Current.LocalStoreData;
+
+ [TestFixtureSetUp]
+ public void Setup() {
+ localStoreData.ReinstallSchema();
+ }
+
+ [TestFixtureTearDown]
+ public void TearDown() {
+ localStoreData.ReinstallSchema();
+ }
+ }
+}
Modified: NMail/trunk/NMail.UnitTests/LocalStoreData/CalendarTests.cs
===================================================================
--- NMail/trunk/NMail.UnitTests/LocalStoreData/CalendarTests.cs 2007-03-04 05:32:53 UTC (rev 164)
+++ NMail/trunk/NMail.UnitTests/LocalStoreData/CalendarTests.cs 2007-03-04 08:36:21 UTC (rev 165)
@@ -14,22 +14,8 @@
/// Calendar tests for the local store data.
/// </summary>
[TestFixture]
- public class CalendarTests {
+ public class CalendarTests : BaseLocalStoreDataTest {
- ILocalStoreData localStoreData;
-
- [TestFixtureSetUp]
- public void Setup() {
- localStoreData = NMailConfiguration.Current.LocalStoreData;
-
- localStoreData.ReinstallSchema();
- }
-
- [TestFixtureTearDown]
- public void TearDown() {
- localStoreData.ReinstallSchema();
- }
-
public void CreateCalendar(string name, int ownerId, int parentId) {
Calendar c1 = new Calendar();
c1.Name = name;
Modified: NMail/trunk/NMail.UnitTests/NMail.UnitTests.csproj
===================================================================
--- NMail/trunk/NMail.UnitTests/NMail.UnitTests.csproj 2007-03-04 05:32:53 UTC (rev 164)
+++ NMail/trunk/NMail.UnitTests/NMail.UnitTests.csproj 2007-03-04 08:36:21 UTC (rev 165)
@@ -50,12 +50,17 @@
<Compile Include="DNSCacheTests.cs" />
<Compile Include="Helper\MimeHelperTests.cs" />
<Compile Include="Helper\StringTokenizerTests.cs" />
+ <Compile Include="LocalStoreData\BaseLocalStoreDataTest.cs" />
<Compile Include="LocalStoreData\CalendarTests.cs" />
<Compile Include="LocalStoreData\MySqlLocalStoreTests.cs" />
<Compile Include="Properties\AssemblyInfo.cs" />
<Compile Include="Resources\ResourceHelper.cs" />
<Compile Include="SmtpService\SmtpServiceTests.cs" />
<Compile Include="SpoolData\BaseSpoolDataTest.cs" />
+ <Compile Include="SpoolData\BeginDeliveryTest1.cs" />
+ <Compile Include="SpoolData\BeginDeliveryTest2.cs" />
+ <Compile Include="SpoolData\BeginDeliveryTest3.cs" />
+ <Compile Include="SpoolData\CompleteDeliveryTest1.cs" />
<Compile Include="SpoolData\NextDeliveryTest1.cs" />
<Compile Include="SpoolData\FilterTest3.cs" />
<Compile Include="SpoolData\FilterTest2.cs" />
Added: NMail/trunk/NMail.UnitTests/SpoolData/BeginDeliveryTest1.cs
===================================================================
--- NMail/trunk/NMail.UnitTests/SpoolData/BeginDeliveryTest1.cs (rev 0)
+++ NMail/trunk/NMail.UnitTests/SpoolData/BeginDeliveryTest1.cs 2007-03-04 08:36:21 UTC (rev 165)
@@ -0,0 +1,57 @@
+using System;
+using System.Collections.Generic;
+using System.Net;
+using System.Text;
+
+using NUnit.Framework;
+
+using NMail.DataTypes;
+using NMail.DataTypes.Spool;
+using NMail.UnitTests.Resources;
+
+namespace NMail.UnitTests.SpoolData {
+ /// <summary>
+ /// Tests beginning a delivery batch.
+ /// </summary>
+ [TestFixture]
+ public class BeginDeliveryTest1 : BaseSpoolDataTest {
+ [Test]
+ public void Test1() {
+ DeliveryBatch batch = this.spoolData.BeginDeliveryBatch(1, 10000);
+ Assert.IsNull(batch, "Delivery batch null when no messages in spool.");
+
+ // Spool
+ SmtpMessage m1 = new SmtpMessage();
+ m1.Message = ResourceHelper.GetMessage("Test1.eml");
+ m1.Recipients.Add(new SmtpMessageRecipient(m1, new EmailAddress("rec...@re...")));
+ m1.ReportedHost = new Host("localhost");
+ m1.Sender = new EmailAddress("se...@se...");
+ m1.SourceAddress = IPAddress.Loopback;
+ this.spoolData.SpoolMessage(m1);
+
+ // Filter
+ SmtpMessage m2 = this.spoolData.GetMessageToFilter();
+ Assert.AreEqual(true, m2.InProgress, "InProgress == true");
+ Assert.AreEqual(m1.MessageId, m2.MessageId, "Message Ids match");
+ Assert.AreEqual(1, m2.Recipients.Count, "Recipient count correct.");
+ this.spoolData.SetFilterStatus(m2, true);
+
+ batch = this.spoolData.BeginDeliveryBatch(1, 10000);
+
+ Assert.AreEqual(m1.Recipients[0].Host, batch.Destination, "Correct destination host.");
+
+ SmtpMessage[] messages = batch.GetMessages();
+ Assert.AreEqual(1, messages.Length, "Correct number of messages.");
+ Assert.AreEqual(true, messages[0].Filtered, "Message is filtered.");
+ Assert.AreEqual(false, messages[0].InProgress, "Message is not in progress.");
+ Assert.AreEqual(m1.MessageId, messages[0].MessageId, "Correct message Id.");
+ Assert.AreEqual(m1.ReportedHost, messages[0].ReportedHost, "Correct reported host.");
+ Assert.AreEqual(m1.Sender, messages[0].Sender, "Correct reported sender.");
+ Assert.AreEqual(m1.SourceAddress, messages[0].SourceAddress, "Correct reported source address.");
+ Assert.AreEqual(1, messages[0].Recipients.Count, "Correct number of recipients.");
+ Assert.AreEqual(m1.Recipients[0].Address, messages[0].Recipients[0].Address, "Correct recipient address.");
+ Assert.AreEqual(true, messages[0].Recipients[0].InProgress, "Recipient is in progress.");
+ Assert.AreEqual(0, messages[0].Recipients[0].DeliveryAttempts, "Recipient delivery attempts == 0.");
+ }
+ }
+}
Added: NMail/trunk/NMail.UnitTests/SpoolData/BeginDeliveryTest2.cs
===================================================================
--- NMail/trunk/NMail.UnitTests/SpoolData/BeginDeliveryTest2.cs (rev 0)
+++ NMail/trunk/NMail.UnitTests/SpoolData/BeginDeliveryTest2.cs 2007-03-04 08:36:21 UTC (rev 165)
@@ -0,0 +1,71 @@
+using System;
+using System.Collections.Generic;
+using System.Net;
+using System.Text;
+
+using NUnit.Framework;
+
+using NMail.DataTypes;
+using NMail.DataTypes.Spool;
+using NMail.UnitTests.Resources;
+
+namespace NMail.UnitTests.SpoolData {
+ /// <summary>
+ /// Tests beginning a delivery batch.
+ /// </summary>
+ [TestFixture]
+ public class BeginDeliveryTest2 : BaseSpoolDataTest {
+ [Test]
+ public void Test1() {
+ // Spool
+ SmtpMessage m1 = new SmtpMessage();
+ m1.Message = ResourceHelper.GetMessage("Test1.eml");
+ m1.Recipients.Add(new SmtpMessageRecipient(m1, new EmailAddress("rec...@re...")));
+ m1.Recipients.Add(new SmtpMessageRecipient(m1, new EmailAddress("rec...@re...")));
+ m1.ReportedHost = new Host("localhost");
+ m1.Sender = new EmailAddress("se...@se...");
+ m1.SourceAddress = IPAddress.Loopback;
+ this.spoolData.SpoolMessage(m1);
+
+ // Filter
+ SmtpMessage m2 = this.spoolData.GetMessageToFilter();
+ Assert.AreEqual(true, m2.InProgress, "InProgress == true");
+ Assert.AreEqual(m1.MessageId, m2.MessageId, "Message Ids match");
+ Assert.AreEqual(2, m2.Recipients.Count, "Recipient count correct.");
+ this.spoolData.SetFilterStatus(m2, true);
+
+ DeliveryBatch batch1 = this.spoolData.BeginDeliveryBatch(1, 10000);
+
+ SmtpMessage[] messages1 = batch1.GetMessages();
+ Assert.AreEqual(1, messages1.Length, "Correct number of messages.");
+ Assert.AreEqual(true, messages1[0].Filtered, "Message is filtered.");
+ Assert.AreEqual(false, messages1[0].InProgress, "Message is not in progress.");
+ Assert.AreEqual(m1.MessageId, messages1[0].MessageId, "Correct message Id.");
+ Assert.AreEqual(m1.ReportedHost, messages1[0].ReportedHost, "Correct reported host.");
+ Assert.AreEqual(m1.Sender, messages1[0].Sender, "Correct reported sender.");
+ Assert.AreEqual(m1.SourceAddress, messages1[0].SourceAddress, "Correct reported source address.");
+ Assert.AreEqual(1, messages1[0].Recipients.Count, "Correct number of recipients.");
+ Assert.AreEqual(true, messages1[0].Recipients[0].InProgress, "Recipient is in progress.");
+ Assert.AreEqual(0, messages1[0].Recipients[0].DeliveryAttempts, "Recipient delivery attempts == 0.");
+
+ DeliveryBatch batch2 = this.spoolData.BeginDeliveryBatch(1, 10000);
+
+ SmtpMessage[] messages2 = batch2.GetMessages();
+ Assert.AreEqual(1, messages2.Length, "Correct number of messages.");
+ Assert.AreEqual(true, messages2[0].Filtered, "Message is filtered.");
+ Assert.AreEqual(false, messages2[0].InProgress, "Message is not in progress.");
+ Assert.AreEqual(m1.MessageId, messages2[0].MessageId, "Correct message Id.");
+ Assert.AreEqual(m1.ReportedHost, messages2[0].ReportedHost, "Correct reported host.");
+ Assert.AreEqual(m1.Sender, messages2[0].Sender, "Correct reported sender.");
+ Assert.AreEqual(m1.SourceAddress, messages2[0].SourceAddress, "Correct reported source address.");
+ Assert.AreEqual(1, messages2[0].Recipients.Count, "Correct number of recipients.");
+ Assert.AreEqual(true, messages2[0].Recipients[0].InProgress, "Recipient is in progress.");
+ Assert.AreEqual(0, messages2[0].Recipients[0].DeliveryAttempts, "Recipient delivery attempts == 0.");
+
+ Assert.IsTrue(messages1[0].Recipients[0].Address != messages2[0].Recipients[0].Address, "Recipients are different.");
+
+ DeliveryBatch batch3 = this.spoolData.BeginDeliveryBatch(1, 10000);
+ Assert.IsNull(batch3, "Batch3 is null");
+ }
+ }
+}
Added: NMail/trunk/NMail.UnitTests/SpoolData/BeginDeliveryTest3.cs
===================================================================
--- NMail/trunk/NMail.UnitTests/SpoolData/BeginDeliveryTest3.cs (rev 0)
+++ NMail/trunk/NMail.UnitTests/SpoolData/BeginDeliveryTest3.cs 2007-03-04 08:36:21 UTC (rev 165)
@@ -0,0 +1,63 @@
+using System;
+using System.Collections.Generic;
+using System.Net;
+using System.Text;
+
+using NUnit.Framework;
+
+using NMail.DataTypes;
+using NMail.DataTypes.Spool;
+using NMail.UnitTests.Resources;
+
+namespace NMail.UnitTests.SpoolData {
+ /// <summary>
+ /// Tests beginning a delivery batch.
+ /// </summary>
+ [TestFixture]
+ public class BeginDeliveryTest3 : BaseSpoolDataTest {
+ [Test]
+ public void Test1() {
+ // Spool
+ SmtpMessage m1 = new SmtpMessage();
+ m1.Message = ResourceHelper.GetMessage("Test1.eml");
+ m1.Recipients.Add(new SmtpMessageRecipient(m1, new EmailAddress("rec...@re...")));
+ m1.ReportedHost = new Host("localhost");
+ m1.Sender = new EmailAddress("se...@se...");
+ m1.SourceAddress = IPAddress.Loopback;
+ this.spoolData.SpoolMessage(m1);
+
+ // Filter
+ SmtpMessage m2 = this.spoolData.GetMessageToFilter();
+ Assert.AreEqual(true, m2.InProgress, "InProgress == true");
+ Assert.AreEqual(m1.MessageId, m2.MessageId, "Message Ids match");
+ Assert.AreEqual(1, m2.Recipients.Count, "Recipient count correct.");
+ this.spoolData.SetFilterStatus(m2, true);
+
+ // Spool
+ SmtpMessage m3 = new SmtpMessage();
+ m3.Message = ResourceHelper.GetMessage("Test1.eml");
+ m3.Recipients.Add(new SmtpMessageRecipient(m3, new EmailAddress("rec...@re...")));
+ m3.ReportedHost = new Host("localhost");
+ m3.Sender = new EmailAddress("se...@se...");
+ m3.SourceAddress = IPAddress.Loopback;
+ this.spoolData.SpoolMessage(m3);
+
+ // Filter
+ SmtpMessage m4 = this.spoolData.GetMessageToFilter();
+ Assert.AreEqual(true, m4.InProgress, "InProgress == true");
+ Assert.AreEqual(m3.MessageId, m4.MessageId, "Message Ids match");
+ Assert.AreEqual(1, m4.Recipients.Count, "Recipient count correct.");
+ this.spoolData.SetFilterStatus(m4, true);
+
+ DeliveryBatch batch1 = this.spoolData.BeginDeliveryBatch(2, 10000);
+
+ SmtpMessage[] messages1 = batch1.GetMessages();
+ Assert.AreEqual(2, messages1.Length, "Correct number of messages.");
+ Assert.AreEqual(1, messages1[0].Recipients.Count, "M1 Correct number of recipients.");
+ Assert.AreEqual(1, messages1[1].Recipients.Count, "M2 Correct number of recipients.");
+
+ DeliveryBatch batch2 = this.spoolData.BeginDeliveryBatch(1, 10000);
+ Assert.IsNull(batch2, "Batch2 is null");
+ }
+ }
+}
Added: NMail/trunk/NMail.UnitTests/SpoolData/CompleteDeliveryTest1.cs
===================================================================
--- NMail/trunk/NMail.UnitTests/SpoolData/CompleteDeliveryTest1.cs (rev 0)
+++ NMail/trunk/NMail.UnitTests/SpoolData/CompleteDeliveryTest1.cs 2007-03-04 08:36:21 UTC (rev 165)
@@ -0,0 +1,47 @@
+using System;
+using System.Collections.Generic;
+using System.Net;
+using System.Text;
+
+using NUnit.Framework;
+
+using NMail.DataTypes;
+using NMail.DataTypes.Spool;
+using NMail.UnitTests.Resources;
+
+namespace NMail.UnitTests.SpoolData {
+ /// <summary>
+ /// Tests completing a delivery batch.
+ /// </summary>
+ [TestFixture]
+ public class CompleteDeliveryTest1 : BaseSpoolDataTest {
+ [Test]
+ public void Test1() {
+ // Spool
+ SmtpMessage m1 = new SmtpMessage();
+ m1.Message = ResourceHelper.GetMessage("Test1.eml");
+ m1.Recipients.Add(new SmtpMessageRecipient(m1, new EmailAddress("rec...@re...")));
+ m1.ReportedHost = new Host("localhost");
+ m1.Sender = new EmailAddress("se...@se...");
+ m1.SourceAddress = IPAddress.Loopback;
+ this.spoolData.SpoolMessage(m1);
+
+ // Filter
+ SmtpMessage m2 = this.spoolData.GetMessageToFilter();
+ Assert.AreEqual(true, m2.InProgress, "InProgress == true");
+ Assert.AreEqual(m1.MessageId, m2.MessageId, "Message Ids match");
+ Assert.AreEqual(1, m2.Recipients.Count, "Recipient count correct.");
+ this.spoolData.SetFilterStatus(m2, true);
+
+ DeliveryBatch batch = this.spoolData.BeginDeliveryBatch(1, 10000);
+
+ Assert.AreEqual(m1.Recipients[0].Host, batch.Destination, "Correct destination host.");
+
+ this.spoolData.CompleteDeliveryAttempt(batch.GetMessages()[0], new DeliveryResult(DeliveryResultType.Success, string.Empty));
+
+ batch = this.spoolData.BeginDeliveryBatch(1, 10000);
+
+ Assert.IsNull(batch, "Batch is null");
+ }
+ }
+}
Modified: NMail/trunk/NMail.UnitTests/SpoolData/FilterTest1.cs
===================================================================
--- NMail/trunk/NMail.UnitTests/SpoolData/FilterTest1.cs 2007-03-04 05:32:53 UTC (rev 164)
+++ NMail/trunk/NMail.UnitTests/SpoolData/FilterTest1.cs 2007-03-04 08:36:21 UTC (rev 165)
@@ -18,7 +18,7 @@
[Test]
public void Test1() {
SmtpMessage m1 = new SmtpMessage();
- m1.Data = ResourceHelper.GetMessage("Test1.eml");
+ m1.Message = ResourceHelper.GetMessage("Test1.eml");
m1.Recipients.Add(new SmtpMessageRecipient(m1, new EmailAddress("rec...@re...")));
m1.Recipients.Add(new SmtpMessageRecipient(m1, new EmailAddress("rec...@re...")));
m1.ReportedHost = new Host("localhost");
Modified: NMail/trunk/NMail.UnitTests/SpoolData/FilterTest2.cs
===================================================================
--- NMail/trunk/NMail.UnitTests/SpoolData/FilterTest2.cs 2007-03-04 05:32:53 UTC (rev 164)
+++ NMail/trunk/NMail.UnitTests/SpoolData/FilterTest2.cs 2007-03-04 08:36:21 UTC (rev 165)
@@ -18,7 +18,7 @@
[Test]
public void Test1() {
SmtpMessage m1 = new SmtpMessage();
- m1.Data = ResourceHelper.GetMessage("Test1.eml");
+ m1.Message = ResourceHelper.GetMessage("Test1.eml");
m1.Recipients.Add(new SmtpMessageRecipient(m1, new EmailAddress("rec...@re...")));
m1.Recipients.Add(new SmtpMessageRecipient(m1, new EmailAddress("rec...@re...")));
m1.ReportedHost = new Host("localhost");
Modified: NMail/trunk/NMail.UnitTests/SpoolData/FilterTest3.cs
===================================================================
--- NMail/trunk/NMail.UnitTests/SpoolData/FilterTest3.cs 2007-03-04 05:32:53 UTC (rev 164)
+++ NMail/trunk/NMail.UnitTests/SpoolData/FilterTest3.cs 2007-03-04 08:36:21 UTC (rev 165)
@@ -18,7 +18,7 @@
[Test]
public void Test1() {
SmtpMessage m1 = new SmtpMessage();
- m1.Data = ResourceHelper.GetMessage("Test1.eml");
+ m1.Message = ResourceHelper.GetMessage("Test1.eml");
m1.Recipients.Add(new SmtpMessageRecipient(m1, new EmailAddress("rec...@re...")));
m1.Recipients.Add(new SmtpMessageRecipient(m1, new EmailAddress("rec...@re...")));
m1.ReportedHost = new Host("localhost");
Modified: NMail/trunk/NMail.UnitTests/SpoolData/GetMsgToFilterTest1.cs
===================================================================
--- NMail/trunk/NMail.UnitTests/SpoolData/GetMsgToFilterTest1.cs 2007-03-04 05:32:53 UTC (rev 164)
+++ NMail/trunk/NMail.UnitTests/SpoolData/GetMsgToFilterTest1.cs 2007-03-04 08:36:21 UTC (rev 165)
@@ -23,7 +23,7 @@
Assert.IsNull(m1, "No message to filter returns null.");
SmtpMessage m2 = new SmtpMessage();
- m2.Data = ResourceHelper.GetMessage("Test1.eml");
+ m2.Message = ResourceHelper.GetMessage("Test1.eml");
m2.Recipients.Add(new SmtpMessageRecipient(m2, new EmailAddress("rec...@re...")));
m2.ReportedHost = new Host("localhost");
m2.Sender = new EmailAddress("se...@se...");
Modified: NMail/trunk/NMail.UnitTests/SpoolData/InitTest1.cs
===================================================================
--- NMail/trunk/NMail.UnitTests/SpoolData/InitTest1.cs 2007-03-04 05:32:53 UTC (rev 164)
+++ NMail/trunk/NMail.UnitTests/SpoolData/InitTest1.cs 2007-03-04 08:36:21 UTC (rev 165)
@@ -18,7 +18,7 @@
[Test]
public void Test1() {
SmtpMessage message = new SmtpMessage();
- message.Data = ResourceHelper.GetMessage("Test1.eml");
+ message.Message = ResourceHelper.GetMessage("Test1.eml");
message.Recipients.Add(new SmtpMessageRecipient(message, new EmailAddress("rec...@re...")));
message.ReportedHost = new Host("localhost");
message.Sender = new EmailAddress("se...@se...");
Modified: NMail/trunk/NMail.UnitTests/SpoolData/NextDeliveryTest1.cs
===================================================================
--- NMail/trunk/NMail.UnitTests/SpoolData/NextDeliveryTest1.cs 2007-03-04 05:32:53 UTC (rev 164)
+++ NMail/trunk/NMail.UnitTests/SpoolData/NextDeliveryTest1.cs 2007-03-04 08:36:21 UTC (rev 165)
@@ -22,7 +22,7 @@
Assert.AreEqual(DateTime.MaxValue, nextAttempt, "Next delivery attempt == max when no messages.");
SmtpMessage m1 = new SmtpMessage();
- m1.Data = ResourceHelper.GetMessage("Test1.eml");
+ m1.Message = ResourceHelper.GetMessage("Test1.eml");
m1.Recipients.Add(new SmtpMessageRecipient(m1, new EmailAddress("rec...@re...")));
m1.Recipients.Add(new SmtpMessageRecipient(m1, new EmailAddress("rec...@re...")));
m1.ReportedHost = new Host("localhost");
Modified: NMail/trunk/NMail.UnitTests/SpoolData/SpoolMessageTest1.cs
===================================================================
--- NMail/trunk/NMail.UnitTests/SpoolData/SpoolMessageTest1.cs 2007-03-04 05:32:53 UTC (rev 164)
+++ NMail/trunk/NMail.UnitTests/SpoolData/SpoolMessageTest1.cs 2007-03-04 08:36:21 UTC (rev 165)
@@ -19,7 +19,7 @@
[Test]
public void Test1() {
SmtpMessage message = new SmtpMessage();
- message.Data = ResourceHelper.GetMessage("Test1.eml");
+ message.Message = ResourceHelper.GetMessage("Test1.eml");
message.Recipients.Add(new SmtpMessageRecipient(message, new EmailAddress("rec...@re...")));
message.ReportedHost = new Host("localhost");
message.Sender = new EmailAddress("se...@se...");
@@ -30,7 +30,7 @@
IList<SpoolEnvelope> spooledEnvelopes = this.spoolData.GetSpooledEnvelopes();
Assert.AreEqual(1, spooledEnvelopes.Count, "Spool envelope count == 1");
- Assert.AreEqual(message.Data.GetEnvelope().From, spooledEnvelopes[0].From, "\"From\"'s match");
+ Assert.AreEqual(message.Message.GetEnvelope().From, spooledEnvelopes[0].From, "\"From\"'s match");
Assert.AreEqual(message.MessageId, spooledEnvelopes[0].SpoolMessageId, "Message Id match");
Assert.AreEqual(false, spooledEnvelopes[0].InProgress, "InProgress == false");
Assert.AreEqual(false, spooledEnvelopes[0].Filtered, "Filtered == false");
Modified: NMail/trunk/NMail.sln
===================================================================
--- NMail/trunk/NMail.sln 2007-03-04 05:32:53 UTC (rev 164)
+++ NMail/trunk/NMail.sln 2007-03-04 08:36:21 UTC (rev 165)
@@ -48,8 +48,6 @@
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "nunit-gui.exe_VS2005", "..\..\..\NUnit-src\GuiRunner\nunit-gui-exe\nunit-gui.exe_VS2005.csproj", "{AAB186A4-FA3D-404D-AD78-7EB5BB861655}"
EndProject
-Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "NHibernate-2.0", "..\..\..\..\..\..\Program Files\NHibernate\src\src\NHibernate\NHibernate-2.0.csproj", "{5909BFE7-93CF-4E5F-BE22-6293368AF01D}"
-EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "NMail.LocalStoreData.NHibernate", "NMail.LocalStoreData.NHibernate\NMail.LocalStoreData.NHibernate.csproj", "{72F7E307-F0A9-4750-9ED5-5A1F97725A11}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "NMail.SpoolData.MySql", "NMail.SpoolData.MySql\NMail.SpoolData.MySql.csproj", "{68D6D57F-02CC-419F-8D69-3B479A1BFBED}"
@@ -254,14 +252,6 @@
{AAB186A4-FA3D-404D-AD78-7EB5BB861655}.Release|Any CPU.Build.0 = Release2005|Any CPU
{AAB186A4-FA3D-404D-AD78-7EB5BB861655}.Release2005|Any CPU.ActiveCfg = Release2005|Any CPU
{AAB186A4-FA3D-404D-AD78-7EB5BB861655}.Release2005|Any CPU.Build.0 = Release2005|Any CPU
- {5909BFE7-93CF-4E5F-BE22-6293368AF01D}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
- {5909BFE7-93CF-4E5F-BE22-6293368AF01D}.Debug|Any CPU.Build.0 = Debug|Any CPU
- {5909BFE7-93CF-4E5F-BE22-6293368AF01D}.Debug2005|Any CPU.ActiveCfg = Debug|Any CPU
- {5909BFE7-93CF-4E5F-BE22-6293368AF01D}.Debug2005|Any CPU.Build.0 = Debug|Any CPU
- {5909BFE7-93CF-4E5F-BE22-6293368AF01D}.Release|Any CPU.ActiveCfg = Release|Any CPU
- {5909BFE7-93CF-4E5F-BE22-6293368AF01D}.Release|Any CPU.Build.0 = Release|Any CPU
- {5909BFE7-93CF-4E5F-BE22-6293368AF01D}.Release2005|Any CPU.ActiveCfg = Release|Any CPU
- {5909BFE7-93CF-4E5F-BE22-6293368AF01D}.Release2005|Any CPU.Build.0 = Release|Any CPU
{72F7E307-F0A9-4750-9ED5-5A1F97725A11}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{72F7E307-F0A9-4750-9ED5-5A1F97725A11}.Debug|Any CPU.Build.0 = Debug|Any CPU
{72F7E307-F0A9-4750-9ED5-5A1F97725A11}.Debug2005|Any CPU.ActiveCfg = Debug|Any CPU
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <tmy...@us...> - 2007-03-04 05:32:55
|
Revision: 164
http://svn.sourceforge.net/nmailserver/?rev=164&view=rev
Author: tmyroadctfig
Date: 2007-03-03 21:32:53 -0800 (Sat, 03 Mar 2007)
Log Message:
-----------
Moved stuff around.
Modified Paths:
--------------
NMail/trunk/NMail.UnitTests/NMail.UnitTests.csproj
Added Paths:
-----------
NMail/trunk/NMail.UnitTests/LocalStoreData/CalendarTests.cs
NMail/trunk/NMail.UnitTests/LocalStoreData/MySqlLocalStoreTests.cs
NMail/trunk/NMail.UnitTests/SmtpService/SmtpServiceTests.cs
Removed Paths:
-------------
NMail/trunk/NMail.UnitTests/LocalStoreData/MySql/
NMail/trunk/NMail.UnitTests/SmtpServiceTests.cs
Added: NMail/trunk/NMail.UnitTests/LocalStoreData/CalendarTests.cs
===================================================================
--- NMail/trunk/NMail.UnitTests/LocalStoreData/CalendarTests.cs (rev 0)
+++ NMail/trunk/NMail.UnitTests/LocalStoreData/CalendarTests.cs 2007-03-04 05:32:53 UTC (rev 164)
@@ -0,0 +1,96 @@
+using System;
+using System.Collections.Generic;
+using System.Text;
+
+using NUnit.Framework;
+
+using NMail.Configuration;
+using NMail.DataTypes.Calendar;
+using NMail.DataTypes.LocalStore;
+using NMail.LocalStoreData.MySql;
+
+namespace NMail.UnitTests.LocalStoreData {
+ /// <summary>
+ /// Calendar tests for the local store data.
+ /// </summary>
+ [TestFixture]
+ public class CalendarTests {
+
+ ILocalStoreData localStoreData;
+
+ [TestFixtureSetUp]
+ public void Setup() {
+ localStoreData = NMailConfiguration.Current.LocalStoreData;
+
+ localStoreData.ReinstallSchema();
+ }
+
+ [TestFixtureTearDown]
+ public void TearDown() {
+ localStoreData.ReinstallSchema();
+ }
+
+ public void CreateCalendar(string name, int ownerId, int parentId) {
+ Calendar c1 = new Calendar();
+ c1.Name = name;
+ c1.OwnerUserId = ownerId;
+ c1.ParentFolderId = parentId;
+
+ localStoreData.SaveCalandar(c1);
+ }
+
+ public void DeleteCalendar(int calendarId) {
+ localStoreData.DeleteCalandar(calendarId);
+ }
+
+ [Test]
+ public void TestCreateCalendar() {
+ CreateCalendar("Test", 1, 1);
+
+ // Clean up
+ Calendar c = localStoreData.GetCalandar("Test", 1);
+ DeleteCalendar(c.CalendarId);
+ }
+
+ [Test]
+ public void TestCreateCalendarDuplicate() {
+ CreateCalendar("Test", 1, 1);
+
+ try {
+ CreateCalendar("Test", 1, 1);
+
+ Assert.Fail("Allowed duplicate calendar names.");
+
+ } catch (ArgumentException ex) {
+ // Ignore
+ }
+
+ // Clean up
+ Calendar c = localStoreData.GetCalandar("Test", 1);
+ localStoreData.DeleteCalandar(c.CalendarId);
+ }
+
+ [Test]
+ public void TestCreateEventEntry() {
+ CreateCalendar("Test", 1, 1);
+
+ Calendar c1 = localStoreData.GetCalandar("Test", 1);
+
+ DateTime startTime = DateTime.Now;
+ EventEntry e1 = new EventEntry();
+ e1.Calendar = c1;
+ e1.Categories.Add("Sample category.");
+ e1.Classification = NMail.DataTypes.Classification.Private;
+ e1.StartTime = startTime;
+
+ localStoreData.SaveCalendarEntry(e1);
+
+ IList<CalendarEntry> entries = localStoreData.GetCalendarEntries(startTime, DateTime.Now, c1.CalendarId);
+
+ Assert.AreEqual(1, entries.Count, "Entries.count == 1");
+ Assert.AreEqual(e1.EntryId, entries[0].EntryId, "e1.EntryId == entries[0].EntryId");
+
+ DeleteCalendar(c1.CalendarId);
+ }
+ }
+}
Copied: NMail/trunk/NMail.UnitTests/LocalStoreData/MySqlLocalStoreTests.cs (from rev 148, NMail/trunk/NMail.UnitTests/LocalStoreData/MySql/MySqlLocalStoreTests.cs)
===================================================================
--- NMail/trunk/NMail.UnitTests/LocalStoreData/MySqlLocalStoreTests.cs (rev 0)
+++ NMail/trunk/NMail.UnitTests/LocalStoreData/MySqlLocalStoreTests.cs 2007-03-04 05:32:53 UTC (rev 164)
@@ -0,0 +1,86 @@
+using System;
+using System.Collections.Generic;
+using System.Text;
+
+using NUnit.Framework;
+
+using NMail.Authentication;
+using NMail.Configuration;
+using NMail.DataTypes;
+using NMail.DataTypes.LocalStore;
+
+namespace NMail.LocalStoreData.MySql {
+ /// <summary>
+ /// Tests for the MySql localstore.
+ /// </summary>
+ [TestFixture]
+ public class MySqlLocalStoreTests {
+
+ ILocalStoreData localStoreData;
+
+ [TestFixtureSetUp]
+ public void Setup() {
+ localStoreData = NMailConfiguration.Current.LocalStoreData;
+ }
+
+ public const string TestUsername = "testusername";
+
+ public const string TestFolder = "testfolder";
+
+ [Test]
+ public void TestCreateUser() {
+ LocalStoreUserResult result = localStoreData.CreateUser(TestUsername, null, null);
+ Assert.AreEqual(LocalStoreUserResult.OkSuccessful, result, "User created successfully.");
+
+ LocalStoreUser user = localStoreData.GetUser(TestUsername);
+ Assert.IsNotNull(user, "Valid user.");
+ Assert.IsTrue(user.UserId > 0, "Valid user Id");
+ Assert.IsTrue(user.UserFolderId > 0, "Valid user folder Id");
+ }
+
+ [Test]
+ public void CreateFolder() {
+ LocalStoreUser user = localStoreData.GetUser(TestUsername);
+ Assert.IsNotNull(user, "Valid user.");
+
+ // Get the user's initial folder
+ StoreFolder nominal = localStoreData.GetStoreFolder(user.UserFolderId);
+ Assert.IsNotNull(nominal, "Nominal folder not null.");
+
+ // Make a sub-folder under it
+ Folder newFolder = new Folder(nominal, TestFolder);
+ LocalStoreFolderResult result = localStoreData.CreateFolder(user.UserId, nominal, newFolder);
+ Assert.AreEqual(LocalStoreFolderResult.OkSuccessful, result, "Created folder successfully.");
+ }
+
+ [Test]
+ public void TestDeleteUser() {
+ // Make an initial delete attempt (which should fail)
+ int userId = localStoreData.GetUser(TestUsername).UserId;
+ LocalStoreUserResult result = localStoreData.DeleteUser(userId);
+ Assert.AreEqual(LocalStoreUserResult.UserStillHasFolders, result, "User deleted fails with still has folders.");
+
+ // Delete all the user's folders
+ Queue<StoreFolder> folders = new Queue<StoreFolder>(localStoreData.GetUserFolders(userId));
+
+ while (folders.Count > 0) {
+ StoreFolder folder = folders.Dequeue();
+ LocalStoreFolderResult folderResult = localStoreData.DeleteFolder(folder.FolderId);
+
+ if (folderResult == LocalStoreFolderResult.OkSuccessful) {
+ continue;
+
+ } else if (folderResult != LocalStoreFolderResult.HasChildren) {
+ throw new InvalidOperationException(string.Format("Error deleting user's folder. Id: {0}", folder.FolderId));
+
+ } else {
+ folders.Enqueue(folder);
+ }
+ }
+
+ // Attempt to delete the user again
+ result = localStoreData.DeleteUser(userId);
+ Assert.AreEqual(LocalStoreUserResult.OkSuccessful, result, "User deleted successfully.");
+ }
+ }
+}
Modified: NMail/trunk/NMail.UnitTests/NMail.UnitTests.csproj
===================================================================
--- NMail/trunk/NMail.UnitTests/NMail.UnitTests.csproj 2007-03-04 05:29:38 UTC (rev 163)
+++ NMail/trunk/NMail.UnitTests/NMail.UnitTests.csproj 2007-03-04 05:32:53 UTC (rev 164)
@@ -50,11 +50,11 @@
<Compile Include="DNSCacheTests.cs" />
<Compile Include="Helper\MimeHelperTests.cs" />
<Compile Include="Helper\StringTokenizerTests.cs" />
- <Compile Include="LocalStoreData\MySql\CalendarTests.cs" />
- <Compile Include="LocalStoreData\MySql\MySqlLocalStoreTests.cs" />
+ <Compile Include="LocalStoreData\CalendarTests.cs" />
+ <Compile Include="LocalStoreData\MySqlLocalStoreTests.cs" />
<Compile Include="Properties\AssemblyInfo.cs" />
<Compile Include="Resources\ResourceHelper.cs" />
- <Compile Include="SmtpServiceTests.cs" />
+ <Compile Include="SmtpService\SmtpServiceTests.cs" />
<Compile Include="SpoolData\BaseSpoolDataTest.cs" />
<Compile Include="SpoolData\NextDeliveryTest1.cs" />
<Compile Include="SpoolData\FilterTest3.cs" />
Copied: NMail/trunk/NMail.UnitTests/SmtpService/SmtpServiceTests.cs (from rev 148, NMail/trunk/NMail.UnitTests/SmtpServiceTests.cs)
===================================================================
--- NMail/trunk/NMail.UnitTests/SmtpService/SmtpServiceTests.cs (rev 0)
+++ NMail/trunk/NMail.UnitTests/SmtpService/SmtpServiceTests.cs 2007-03-04 05:32:53 UTC (rev 164)
@@ -0,0 +1,97 @@
+/*
+ * Copyright 2004-2006 Luke Quinane, Daniel Frampton and Jared Hodges.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ */
+
+using System;
+using System.Net;
+using System.Net.Sockets;
+
+using NUnit.Framework;
+using log4net;
+
+using NMail.DataTypes;
+using NMail.IO;
+
+namespace NMail.UnitTests.SmtpService {
+ /// <summary>
+ /// Preforms tests on the Smtp Service.
+ /// </summary>
+ [TestFixture]
+ public class SmtpServiceTests {
+ private static ILog log = LogManager.GetLogger(typeof(SmtpServiceTests));
+ private TcpTextConnection connection;
+
+ /// <summary>
+ /// Opens a connection to the server.
+ /// </summary>
+ private void Open() {
+ this.connection = new TcpTextConnection(log);
+ try {
+ this.connection.Open(new Host(IPAddress.Loopback), 25);
+ } catch (System.Net.Sockets.SocketException e) {
+ Assert.Fail(e.Message +
+ "\n(These tests are not standalone - you may need to manually start the SMTP Service.)");
+ }
+
+ // Should get a 220 response
+ string welcome = this.connection.ReadLine();
+ Assert.IsTrue(welcome.StartsWith("220 "), "Welcome starts with '220 '");
+ }
+
+ /// <summary>
+ /// Closes the connection to the server
+ /// </summary>
+ private void Close() {
+ this.connection.WriteLine("QUIT");
+ this.connection.Close();
+ }
+
+ /// <summary>
+ /// Tests that the server sends a "220" welcome message.
+ /// </summary>
+ [Test]
+ public void WelcomeTest() {
+ Open();
+ Close();
+ }
+
+ /// <summary>
+ /// Checks that the server sends a "250 " response to a NOOP command.
+ /// </summary>
+ [Test]
+ public void NoopTest() {
+ Open();
+ this.connection.WriteLine("noop");
+ string response = this.connection.ReadLine();
+ Assert.IsTrue(response.StartsWith("250 "), "NOOP response starts with '250 '");
+ Close();
+ }
+
+ /// <summary>
+ /// Checks that the server sends a "250 " response to HELO command followed by
+ /// a host name.
+ /// </summary>
+ [Test]
+ public void HeloTest() {
+ Open();
+ this.connection.WriteLine("helo test.domain");
+ string response = this.connection.ReadLine();
+ Assert.IsTrue(response.StartsWith("250 "), "HELO response starts with '250 '");
+ Host h1 = new Host(response.Split(' ')[1]);
+ Close();
+ }
+ }
+}
Deleted: NMail/trunk/NMail.UnitTests/SmtpServiceTests.cs
===================================================================
--- NMail/trunk/NMail.UnitTests/SmtpServiceTests.cs 2007-03-04 05:29:38 UTC (rev 163)
+++ NMail/trunk/NMail.UnitTests/SmtpServiceTests.cs 2007-03-04 05:32:53 UTC (rev 164)
@@ -1,97 +0,0 @@
-/*
- * Copyright 2004-2006 Luke Quinane, Daniel Frampton and Jared Hodges.
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- *
- */
-
-using System;
-using System.Net;
-using System.Net.Sockets;
-
-using NUnit.Framework;
-using log4net;
-
-using NMail.DataTypes;
-using NMail.IO;
-
-namespace NMail.Tests.UnitTests {
- /// <summary>
- /// Preforms tests on the Smtp Service.
- /// </summary>
- [TestFixture]
- public class SmtpServiceTests {
- private static ILog log = LogManager.GetLogger(typeof(SmtpServiceTests));
- private TcpTextConnection connection;
-
- /// <summary>
- /// Opens a connection to the server.
- /// </summary>
- private void Open() {
- this.connection = new TcpTextConnection(log);
- try {
- this.connection.Open(new Host(IPAddress.Loopback), 25);
- } catch (System.Net.Sockets.SocketException e) {
- Assert.Fail(e.Message +
- "\n(These tests are not standalone - you may need to manually start the SMTP Service.)");
- }
-
- // Should get a 220 response
- string welcome = this.connection.ReadLine();
- Assert.IsTrue(welcome.StartsWith("220 "), "Welcome starts with '220 '");
- }
-
- /// <summary>
- /// Closes the connection to the server
- /// </summary>
- private void Close() {
- this.connection.WriteLine("QUIT");
- this.connection.Close();
- }
-
- /// <summary>
- /// Tests that the server sends a "220" welcome message.
- /// </summary>
- [Test]
- public void WelcomeTest() {
- Open();
- Close();
- }
-
- /// <summary>
- /// Checks that the server sends a "250 " response to a NOOP command.
- /// </summary>
- [Test]
- public void NoopTest() {
- Open();
- this.connection.WriteLine("noop");
- string response = this.connection.ReadLine();
- Assert.IsTrue(response.StartsWith("250 "), "NOOP response starts with '250 '");
- Close();
- }
-
- /// <summary>
- /// Checks that the server sends a "250 " response to HELO command followed by
- /// a host name.
- /// </summary>
- [Test]
- public void HeloTest() {
- Open();
- this.connection.WriteLine("helo test.domain");
- string response = this.connection.ReadLine();
- Assert.IsTrue(response.StartsWith("250 "), "HELO response starts with '250 '");
- Host h1 = new Host(response.Split(' ')[1]);
- Close();
- }
- }
-}
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <tmy...@us...> - 2007-03-04 05:29:37
|
Revision: 163
http://svn.sourceforge.net/nmailserver/?rev=163&view=rev
Author: tmyroadctfig
Date: 2007-03-03 21:29:38 -0800 (Sat, 03 Mar 2007)
Log Message:
-----------
Added some NHibernate calendar stuff.
Added Paths:
-----------
NMail/trunk/NMail.LocalStoreData.MySql/Properties/
NMail/trunk/NMail.LocalStoreData.MySql/Resources/
NMail/trunk/NMail.LocalStoreData.MySql/Resources/NMail.LocalStoreData.MySql.hbm.xml
NMail/trunk/NMail.LocalStoreData.MySql/Resources/hibernate-configuration.xml
Added: NMail/trunk/NMail.LocalStoreData.MySql/Resources/NMail.LocalStoreData.MySql.hbm.xml
===================================================================
--- NMail/trunk/NMail.LocalStoreData.MySql/Resources/NMail.LocalStoreData.MySql.hbm.xml (rev 0)
+++ NMail/trunk/NMail.LocalStoreData.MySql/Resources/NMail.LocalStoreData.MySql.hbm.xml 2007-03-04 05:29:38 UTC (rev 163)
@@ -0,0 +1,131 @@
+<?xml version="1.0" encoding="utf-8" ?>
+<hibernate-mapping xmlns="urn:nhibernate-mapping-2.2" namespace="NMail" assembly="NMail" default-lazy="false">
+ <!--
+ -
+ - Calendar
+ -
+ -->
+ <class name="NMail.DataTypes.Calendar.Calendar" table="Calendar">
+ <id name="CalendarId" type="Int32" unsaved-value="0">
+ <column name="CalendarId" not-null="true"/>
+ <generator class="native" />
+ </id>
+
+ <property name="Name" not-null="true"/>
+
+ <!-- TODO: make this a many to one relationship with folder -->
+ <property name="ParentFolderId" />
+
+ <!-- TODO: make this a many to one relationship with user -->
+ <property name="OwnerUserId" />
+
+ <list name="Entries" cascade="all">
+ <key column="CalendarEntryId" />
+ <index column="CategoryEntryIndex" type="Int32" />
+ <one-to-many class="NMail.DataTypes.Calendar.CalendarEntry" />
+ </list>
+ </class>
+
+ <!--
+ -
+ - Calendar Entry
+ -
+ -->
+ <class name="NMail.DataTypes.Calendar.CalendarEntry" table="CalendarEntry">
+ <id name="EntryId" type="Int32" unsaved-value="0">
+ <column name="CalendarEntryId" not-null="true"/>
+ <generator class="native" />
+ </id>
+
+
+ <!--
+ - Descriptive Properties
+ -->
+ <property name="Classification" not-null="true" />
+
+ <list name="Categories" table="CalendarEventCategories" cascade="all">
+ <key column="CalendarEntryId" />
+ <index column="CategoryIndex" type="Int32" />
+ <element column="Category" type="String" />
+ </list>
+
+ <property name="Description" />
+
+ <!--<property name="Status" />-->
+
+ <property name="Summary" />
+
+
+ <!--
+ - Date/Time Properties
+ -->
+ <property name="StartTime" not-null="true" />
+
+
+ <!--
+ - Relationship Component Properties
+ -->
+ <list name="Attendees" cascade="all">
+ <key column="CalendarEntryId" />
+ <index column="AttendeeIndex" />
+ <one-to-many class="NMail.DataTypes.Calendar.Attendee" />
+ </list>
+
+ <property name="Organiser" type="String" />
+
+ <!-- TODO: make this a many to one relationship with user -->
+ <property name="OwnerUserId" />
+
+ <many-to-one name="Calendar"
+ class="NMail.DataTypes.Calendar.Calendar"
+ column="CalendarId" />
+
+
+ <!--
+ - Recurrence Component Properties
+ -->
+
+ <!-- one to many <property name="Recurrence" /> -->
+
+ <property name="RecurrenceId" />
+
+
+ <!--
+ - Change Management Component Properties
+ -->
+ <property name="Created" />
+
+ <property name="TimeStamp" />
+
+ <property name="LastModified" />
+
+ <property name="Sequence" />
+
+ <!--
+ -
+ - Calendar Event
+ -
+ -->
+ <joined-subclass name="NMail.DataTypes.Calendar.EventEntry" table="EventEntry">
+ <key column="CalendarEntryId"/>
+ </joined-subclass>
+ </class>
+
+ <!--
+ -
+ - Attendee
+ -
+ -->
+ <class name="NMail.DataTypes.Calendar.Attendee" table="Attendee">
+ <id type="Int32">
+ <column name="AttendeeId" not-null="true"/>
+ <generator class="native" />
+ </id>
+
+ <property name="Address" not-null="true"/>
+
+ <many-to-one name="CalendarEntry"
+ class="NMail.DataTypes.Calendar.CalendarEntry"
+ column="CalendarEntryId" />
+ </class>
+</hibernate-mapping>
\ No newline at end of file
Added: NMail/trunk/NMail.LocalStoreData.MySql/Resources/hibernate-configuration.xml
===================================================================
--- NMail/trunk/NMail.LocalStoreData.MySql/Resources/hibernate-configuration.xml (rev 0)
+++ NMail/trunk/NMail.LocalStoreData.MySql/Resources/hibernate-configuration.xml 2007-03-04 05:29:38 UTC (rev 163)
@@ -0,0 +1,9 @@
+<?xml version="1.0" encoding="utf-8" ?>
+<hibernate-configuration xmlns="urn:nhibernate-configuration-2.2">
+ <session-factory>
+ <property name="connection.provider">NHibernate.Connection.DriverConnectionProvider</property>
+ <property name="connection.driver_class">NHibernate.Driver.MySqlDataDriver</property>
+ <property name="connection.connection_string">Database=NMailLocalStore;Uid=NMail;Password=moo</property>
+ <property name="dialect">NHibernate.Dialect.MySQLDialect</property>
+ </session-factory>
+</hibernate-configuration>
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|