james-server-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From nor...@apache.org
Subject svn commit: r960653 - in /james/imap/trunk: store/src/main/java/org/apache/james/imap/store/StoreMailboxManager.java torque/src/main/java/org/apache/james/mailboxmanager/torque/TorqueMailboxManager.java
Date Mon, 05 Jul 2010 18:07:06 GMT
Author: norman
Date: Mon Jul  5 18:07:06 2010
New Revision: 960653

URL: http://svn.apache.org/viewvc?rev=960653&view=rev
Log:
Don't allow to specify the delimiter, we use "." and not allow to override this. (IMAP-179)

Modified:
    james/imap/trunk/store/src/main/java/org/apache/james/imap/store/StoreMailboxManager.java
    james/imap/trunk/torque/src/main/java/org/apache/james/mailboxmanager/torque/TorqueMailboxManager.java

Modified: james/imap/trunk/store/src/main/java/org/apache/james/imap/store/StoreMailboxManager.java
URL: http://svn.apache.org/viewvc/james/imap/trunk/store/src/main/java/org/apache/james/imap/store/StoreMailboxManager.java?rev=960653&r1=960652&r2=960653&view=diff
==============================================================================
--- james/imap/trunk/store/src/main/java/org/apache/james/imap/store/StoreMailboxManager.java
(original)
+++ james/imap/trunk/store/src/main/java/org/apache/james/imap/store/StoreMailboxManager.java
Mon Jul  5 18:07:06 2010
@@ -69,19 +69,13 @@ public abstract class StoreMailboxManage
     private final DelegatingMailboxListener delegatingListener = new DelegatingMailboxListener();
     private final Authenticator authenticator;    
     private final Subscriber subscriber;    
-    private final char delimiter;
     protected final MailboxSessionMapperFactory<Id> mailboxSessionMapperFactory;
     private UidConsumer<Id> consumer;
     
-    public StoreMailboxManager(MailboxSessionMapperFactory<Id> mailboxSessionMapperFactory,
final Authenticator authenticator, final Subscriber subscriber, final UidConsumer<Id>
consumer) {
-        this(mailboxSessionMapperFactory, authenticator, subscriber, consumer, MailboxConstants.DEFAULT_DELIMITER);
-    }
-
     
-    public StoreMailboxManager(MailboxSessionMapperFactory<Id> mailboxSessionMapperFactory,
final Authenticator authenticator, final Subscriber subscriber, final UidConsumer<Id>
consumer, final char delimiter) {
+    public StoreMailboxManager(MailboxSessionMapperFactory<Id> mailboxSessionMapperFactory,
final Authenticator authenticator, final Subscriber subscriber, final UidConsumer<Id>
consumer) {
         this.authenticator = authenticator;
         this.subscriber = subscriber;
-        this.delimiter = delimiter;
         this.consumer = consumer;
         this.mailboxSessionMapperFactory = mailboxSessionMapperFactory;
     }
@@ -147,14 +141,14 @@ public abstract class StoreMailboxManage
         final int length = namespaceName.length();
         if (length == 0) {
             getLog().warn("Ignoring mailbox with empty name");
-        } else if (namespaceName.charAt(length - 1) == delimiter) {
+        } else if (namespaceName.charAt(length - 1) == MailboxConstants.DEFAULT_DELIMITER)
{
             createMailbox(namespaceName.substring(0, length - 1), mailboxSession);
         } else {
             synchronized (mutex) {
                 // Create root first
                 // If any creation fails then mailbox will not be created
                 // TODO: transaction
-                int index = namespaceName.indexOf(delimiter);
+                int index = namespaceName.indexOf(MailboxConstants.DEFAULT_DELIMITER);
                 int count = 0;
                 while (index >= 0) {
                     // Until explicit namespace support is added,
@@ -168,7 +162,7 @@ public abstract class StoreMailboxManage
                             doCreateMailbox(mailbox, mailboxSession);
                         }
                     }
-                    index = namespaceName.indexOf(delimiter, ++index);
+                    index = namespaceName.indexOf(MailboxConstants.DEFAULT_DELIMITER, ++index);
                 }
                 if (mailboxExists(namespaceName, mailboxSession)) {
                     throw new MailboxExistsException(namespaceName); 
@@ -236,7 +230,7 @@ public abstract class StoreMailboxManage
                     changeMailboxName(from, to, session);
 
                     // rename submailbox
-                    final List<Mailbox<Id>> subMailboxes = mapper.findMailboxWithNameLike(from
+ delimiter + "%");
+                    final List<Mailbox<Id>> subMailboxes = mapper.findMailboxWithNameLike(from
+ MailboxConstants.DEFAULT_DELIMITER + "%");
                     for (Mailbox<Id> sub:subMailboxes) {
                         final String subOriginalName = sub.getName();
                         final String subNewName = to + subOriginalName.substring(from.length());
@@ -303,7 +297,7 @@ public abstract class StoreMailboxManage
         }
 
         final String search = mailboxExpression.getCombinedName(
-                delimiter).replace(freeWildcard, SQL_WILDCARD_CHAR)
+                MailboxConstants.DEFAULT_DELIMITER).replace(freeWildcard, SQL_WILDCARD_CHAR)
                 .replace(localWildcard, SQL_WILDCARD_CHAR);
 
         final MailboxMapper<Id> mapper = mailboxSessionMapperFactory.getMailboxMapper(session);
@@ -313,7 +307,7 @@ public abstract class StoreMailboxManage
             final String name = mailbox.getName();
             if (name.startsWith(base)) {
                 final String match = name.substring(baseLength);
-                if (mailboxExpression.isExpressionMatch(match, delimiter)) {
+                if (mailboxExpression.isExpressionMatch(match, MailboxConstants.DEFAULT_DELIMITER))
{
                     final MailboxMetaData.Children inferiors; 
                     if (mapper.hasChildren(mailbox)) {
                         inferiors = MailboxMetaData.Children.HAS_CHILDREN;
@@ -362,7 +356,7 @@ public abstract class StoreMailboxManage
      * @return session
      */
     private SimpleMailboxSession createSession(String userName, String password, Log log)
{
-        return new SimpleMailboxSession(randomId(), userName, password, log, delimiter, new
ArrayList<Locale>());
+        return new SimpleMailboxSession(randomId(), userName, password, log, MailboxConstants.DEFAULT_DELIMITER,
new ArrayList<Locale>());
     }
 
     /**
@@ -379,10 +373,10 @@ public abstract class StoreMailboxManage
      * @see org.apache.james.imap.mailbox.MailboxManager#resolve(java.lang.String, java.lang.String)
      */
     public String resolve(final String userName, String mailboxPath) {
-        if (mailboxPath.length() > 0 && mailboxPath.charAt(0) != delimiter) {
-            mailboxPath = delimiter + mailboxPath;
+        if (mailboxPath.length() > 0 && mailboxPath.charAt(0) != MailboxConstants.DEFAULT_DELIMITER)
{
+            mailboxPath = MailboxConstants.DEFAULT_DELIMITER + mailboxPath;
         }
-        final String result = MailboxConstants.USER_NAMESPACE + delimiter + userName
+        final String result = MailboxConstants.USER_NAMESPACE + MailboxConstants.DEFAULT_DELIMITER
+ userName
         + mailboxPath;
         return result;
     }
@@ -455,8 +449,8 @@ public abstract class StoreMailboxManage
      * (non-Javadoc)
      * @see org.apache.james.imap.mailbox.MailboxManager#getDelimiter()
      */
-    public char getDelimiter() {
-        return delimiter;
+    public final char getDelimiter() {
+        return MailboxConstants.DEFAULT_DELIMITER;
     }
 
     /**

Modified: james/imap/trunk/torque/src/main/java/org/apache/james/mailboxmanager/torque/TorqueMailboxManager.java
URL: http://svn.apache.org/viewvc/james/imap/trunk/torque/src/main/java/org/apache/james/mailboxmanager/torque/TorqueMailboxManager.java?rev=960653&r1=960652&r2=960653&view=diff
==============================================================================
--- james/imap/trunk/torque/src/main/java/org/apache/james/mailboxmanager/torque/TorqueMailboxManager.java
(original)
+++ james/imap/trunk/torque/src/main/java/org/apache/james/mailboxmanager/torque/TorqueMailboxManager.java
Mon Jul  5 18:07:06 2010
@@ -36,6 +36,7 @@ import org.apache.commons.logging.impl.S
 import org.apache.james.imap.api.display.HumanReadableText;
 import org.apache.james.imap.mailbox.BadCredentialsException;
 import org.apache.james.imap.mailbox.Mailbox;
+import org.apache.james.imap.mailbox.MailboxConstants;
 import org.apache.james.imap.mailbox.MailboxException;
 import org.apache.james.imap.mailbox.MailboxExistsException;
 import org.apache.james.imap.mailbox.MailboxListener;
@@ -59,8 +60,6 @@ import org.apache.torque.util.CountHelpe
 import org.apache.torque.util.Criteria;
 
 public class TorqueMailboxManager implements MailboxManager {
-
-    public static final String USER_NAMESPACE_PREFIX = "#private";
     
     private static final char SQL_WILDCARD_CHAR = '%';
 
@@ -371,7 +370,7 @@ public class TorqueMailboxManager implem
         if (mailboxPath.charAt(0) != delimiter) {
             mailboxPath = delimiter + mailboxPath;
         }
-        final String result = USER_NAMESPACE_PREFIX + delimiter + userName
+        final String result = MailboxConstants.USER_NAMESPACE + delimiter + userName
                 + mailboxPath;
         return result;
     }
@@ -433,12 +432,4 @@ public class TorqueMailboxManager implem
         return delimiter;
     }
 
-    /*
-     * (non-Javadoc)
-     * @see org.apache.james.imap.mailbox.MailboxManager#getUserNameSpacePrefix()
-     */
-    public String getUserNameSpacePrefix() {
-        return USER_NAMESPACE_PREFIX;
-    }
-
 }



---------------------------------------------------------------------
To unsubscribe, e-mail: server-dev-unsubscribe@james.apache.org
For additional commands, e-mail: server-dev-help@james.apache.org


Mime
View raw message