You are viewing a plain text version of this content. The canonical link for it is here.
Posted to server-dev@james.apache.org by no...@apache.org on 2010/07/18 20:18:10 UTC
svn commit: r965270 [1/4] - in /james/imap/trunk: ./
api/src/main/java/org/apache/james/imap/api/
api/src/main/java/org/apache/james/imap/api/process/
deployment/src/test/java/org/apache/james/imap/functional/
jcr/src/main/java/org/apache/james/imap/jc...
Author: norman
Date: Sun Jul 18 18:18:08 2010
New Revision: 965270
URL: http://svn.apache.org/viewvc?rev=965270&view=rev
Log:
Introduce a MailboxPath to better handle the identification of a mailbox. This will allow us to have different namespaces later. The code is based on a patch of Tim Christian Mundt (thx). See IMAP-168
Added:
james/imap/trunk/api/src/main/java/org/apache/james/imap/api/MailboxPath.java
james/imap/trunk/api/src/main/java/org/apache/james/imap/api/MailboxPathHashMap.java
james/imap/trunk/store/src/main/java/org/apache/james/imap/store/StoreMailboxPath.java
Modified:
james/imap/trunk/api/src/main/java/org/apache/james/imap/api/process/SelectedMailbox.java
james/imap/trunk/deployment/src/test/java/org/apache/james/imap/functional/AbstractStressTest.java
james/imap/trunk/jcr/src/main/java/org/apache/james/imap/jcr/JCRMailboxManager.java
james/imap/trunk/jcr/src/main/java/org/apache/james/imap/jcr/JCRMailboxSessionMapperFactory.java
james/imap/trunk/jcr/src/main/java/org/apache/james/imap/jcr/mail/JCRMailboxMapper.java
james/imap/trunk/jcr/src/main/java/org/apache/james/imap/jcr/mail/model/JCRMailbox.java
james/imap/trunk/jcr/src/main/resources/org/apache/james/imap/jcr/imap.cnd
james/imap/trunk/jpa/src/main/java/org/apache/james/imap/jpa/JPAMailboxManager.java
james/imap/trunk/jpa/src/main/java/org/apache/james/imap/jpa/mail/JPAMailboxMapper.java
james/imap/trunk/jpa/src/main/java/org/apache/james/imap/jpa/mail/model/JPAMailbox.java
james/imap/trunk/mailbox/src/main/java/org/apache/james/imap/mailbox/MailboxConstants.java
james/imap/trunk/mailbox/src/main/java/org/apache/james/imap/mailbox/MailboxListener.java
james/imap/trunk/mailbox/src/main/java/org/apache/james/imap/mailbox/MailboxManager.java
james/imap/trunk/mailbox/src/main/java/org/apache/james/imap/mailbox/MailboxMetaData.java
james/imap/trunk/mailbox/src/main/java/org/apache/james/imap/mailbox/MailboxNotFoundException.java
james/imap/trunk/mailbox/src/main/java/org/apache/james/imap/mailbox/MailboxQuery.java
james/imap/trunk/mailbox/src/main/java/org/apache/james/imap/mailbox/StandardMailboxMetaDataComparator.java
james/imap/trunk/mailbox/src/main/java/org/apache/james/imap/mailbox/util/MailboxEventDispatcher.java
james/imap/trunk/mailbox/src/main/java/org/apache/james/imap/mailbox/util/SimpleMailboxMetaData.java
james/imap/trunk/mailbox/src/test/java/org/apache/james/imap/mailbox/MailboxExpressionTest.java
james/imap/trunk/mailbox/src/test/java/org/apache/james/imap/mailbox/util/MailboxEventDispatcherFlagsTest.java
james/imap/trunk/memory/src/main/java/org/apache/james/imap/inmemory/InMemoryMailboxManager.java
james/imap/trunk/memory/src/main/java/org/apache/james/imap/inmemory/mail/InMemoryMailboxMapper.java
james/imap/trunk/memory/src/main/java/org/apache/james/imap/inmemory/mail/model/InMemoryMailbox.java
james/imap/trunk/message/src/main/java/org/apache/james/imap/encode/ListingEncodingUtils.java
james/imap/trunk/message/src/main/java/org/apache/james/imap/message/response/AbstractListingResponse.java
james/imap/trunk/message/src/main/java/org/apache/james/imap/message/response/LSubResponse.java
james/imap/trunk/message/src/main/java/org/apache/james/imap/message/response/ListResponse.java
james/imap/trunk/message/src/test/java/org/apache/james/imap/encode/LSubResponseEncoderTest.java
james/imap/trunk/message/src/test/java/org/apache/james/imap/encode/ListingEncodingUtilsTest.java
james/imap/trunk/message/src/test/java/org/apache/james/imap/encode/SearchResponseEncoderTest.java
james/imap/trunk/pom.xml
james/imap/trunk/processor/src/main/java/org/apache/james/imap/processor/AbstractMailboxProcessor.java
james/imap/trunk/processor/src/main/java/org/apache/james/imap/processor/AbstractSelectionProcessor.java
james/imap/trunk/processor/src/main/java/org/apache/james/imap/processor/AppendProcessor.java
james/imap/trunk/processor/src/main/java/org/apache/james/imap/processor/CopyProcessor.java
james/imap/trunk/processor/src/main/java/org/apache/james/imap/processor/CreateProcessor.java
james/imap/trunk/processor/src/main/java/org/apache/james/imap/processor/DeleteProcessor.java
james/imap/trunk/processor/src/main/java/org/apache/james/imap/processor/LSubProcessor.java
james/imap/trunk/processor/src/main/java/org/apache/james/imap/processor/ListProcessor.java
james/imap/trunk/processor/src/main/java/org/apache/james/imap/processor/LoginProcessor.java
james/imap/trunk/processor/src/main/java/org/apache/james/imap/processor/RenameProcessor.java
james/imap/trunk/processor/src/main/java/org/apache/james/imap/processor/StatusProcessor.java
james/imap/trunk/processor/src/main/java/org/apache/james/imap/processor/base/MailboxEventAnalyser.java
james/imap/trunk/processor/src/main/java/org/apache/james/imap/processor/base/SelectedMailboxImpl.java
james/imap/trunk/processor/src/test/java/org/apache/james/imap/processor/LSubProcessorTest.java
james/imap/trunk/processor/src/test/java/org/apache/james/imap/processor/ListProcessorTest.java
james/imap/trunk/processor/src/test/java/org/apache/james/imap/processor/SearchProcessorTest.java
james/imap/trunk/processor/src/test/java/org/apache/james/imap/processor/base/FakeMailboxListenerAdded.java
james/imap/trunk/processor/src/test/java/org/apache/james/imap/processor/base/FakeMailboxListenerFlagsUpdate.java
james/imap/trunk/processor/src/test/java/org/apache/james/imap/processor/base/MailboxEventAnalyserTest.java
james/imap/trunk/seda/src/test/resources/org/apache/james/imap/scripts/ListNamespace.test
james/imap/trunk/store/src/main/java/org/apache/james/imap/store/DelegatingMailboxListener.java
james/imap/trunk/store/src/main/java/org/apache/james/imap/store/DelegatingMailboxManager.java
james/imap/trunk/store/src/main/java/org/apache/james/imap/store/StoreMailboxManager.java
james/imap/trunk/store/src/main/java/org/apache/james/imap/store/StoreMessageManager.java
james/imap/trunk/store/src/main/java/org/apache/james/imap/store/mail/MailboxMapper.java
james/imap/trunk/store/src/main/java/org/apache/james/imap/store/mail/model/Mailbox.java
james/imap/trunk/torque/src/main/java/org/apache/james/mailboxmanager/torque/TorqueMailbox.java
james/imap/trunk/torque/src/main/java/org/apache/james/mailboxmanager/torque/TorqueMailboxManager.java
james/imap/trunk/torque/src/main/java/org/apache/james/mailboxmanager/torque/UidChangeTracker.java
Added: james/imap/trunk/api/src/main/java/org/apache/james/imap/api/MailboxPath.java
URL: http://svn.apache.org/viewvc/james/imap/trunk/api/src/main/java/org/apache/james/imap/api/MailboxPath.java?rev=965270&view=auto
==============================================================================
--- james/imap/trunk/api/src/main/java/org/apache/james/imap/api/MailboxPath.java (added)
+++ james/imap/trunk/api/src/main/java/org/apache/james/imap/api/MailboxPath.java Sun Jul 18 18:18:08 2010
@@ -0,0 +1,160 @@
+/****************************************************************
+ * Licensed to the Apache Software Foundation (ASF) under one *
+ * or more contributor license agreements. See the NOTICE file *
+ * distributed with this work for additional information *
+ * regarding copyright ownership. The ASF licenses this file *
+ * to you 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. *
+ ****************************************************************/
+
+package org.apache.james.imap.api;
+
+import java.util.ArrayList;
+import java.util.List;
+
+/**
+ * The path to a mailbox.
+ */
+public class MailboxPath {
+
+ private String namespace;
+ private String user;
+ private String name;
+
+ public MailboxPath(String namespace, String user, String name) {
+ this.namespace = namespace;
+ this.user = user;
+ this.name = name;
+ }
+
+ public MailboxPath(MailboxPath mailboxPath) {
+ this.namespace = mailboxPath.getNamespace();
+ this.user = mailboxPath.getUser();
+ this.name = mailboxPath.getName();
+ }
+
+ public MailboxPath(MailboxPath mailboxPath, String name) {
+ this.namespace = mailboxPath.getNamespace();
+ this.user = mailboxPath.getUser();
+ this.name = name;
+ }
+
+ /**
+ * Get the namespace this mailbox is in
+ * @return The namespace
+ */
+ public String getNamespace() {
+ return namespace;
+ }
+
+ /**
+ * Set the namespace this mailbox is in
+ */
+ public void setNamespace(String namespace) {
+ this.namespace = namespace;
+ }
+
+ /**
+ * Get the name of the user who owns the mailbox.
+ * This can be null e.g. for shared mailboxes.
+ * @return The username
+ */
+ public String getUser() {
+ return user;
+ }
+
+ /**
+ * Set the name of the user who owns the mailbox.
+ */
+ public void setUser(String user) {
+ this.user = user;
+ }
+
+ /**
+ * Get the name of the mailbox. This is the pure name without
+ * user or namespace, so this is what a user would see in his client.
+ * @return The name string
+ */
+ public String getName() {
+ return name;
+ }
+
+ /**
+ * Set the name of the mailbox. This is the pure name without
+ * user or namespace, so this is what a user would see in his client.
+ */
+ public void setName(String name) {
+ this.name = name;
+ }
+
+ /**
+ * Return a list of MailboxPath representing the hierarchy levels
+ * of this MailboxPath. E.g. INBOX.main.sub would yield
+ * INBOX
+ * INBOX.main
+ * INBOX.main.sub
+ * @param delimiter
+ * @return
+ */
+ public List<MailboxPath> getHierarchyLevels(char delimiter) {
+ ArrayList<MailboxPath> levels = new ArrayList<MailboxPath>();
+ int index = name.indexOf(delimiter);
+ while (index >= 0) {
+ final String levelname = name.substring(0, index);
+ levels.add(new MailboxPath(namespace, user, levelname));
+ index = name.indexOf(delimiter, ++index);
+ }
+ levels.add(this);
+ return levels;
+ }
+
+ /*
+ * (non-Javadoc)
+ * @see java.lang.Object#toString()
+ */
+ @Override
+ public String toString() {
+ return namespace + ":" + user + ":" + name;
+ }
+
+ /*
+ * (non-Javadoc)
+ * @see java.lang.Object#equals(java.lang.Object)
+ */
+ @Override
+ public boolean equals(Object mailboxPath) {
+ if (!(mailboxPath instanceof MailboxPath))
+ return false;
+ MailboxPath mp = (MailboxPath) mailboxPath;
+ if (namespace == null) {
+ if (mp.getNamespace() != null)
+ return false;
+ }
+ else if (!namespace.equals(mp.getNamespace()))
+ return false;
+ if (user == null) {
+ if (mp.getUser() != null)
+ return false;
+ }
+ else if (!user.equals(mp.getUser()))
+ return false;
+ if (name == null) {
+ if (mp.getName() != null)
+ return false;
+ }
+ else if (!name.equals(mp.getName()))
+ return false;
+ return true;
+ }
+
+}
Added: james/imap/trunk/api/src/main/java/org/apache/james/imap/api/MailboxPathHashMap.java
URL: http://svn.apache.org/viewvc/james/imap/trunk/api/src/main/java/org/apache/james/imap/api/MailboxPathHashMap.java?rev=965270&view=auto
==============================================================================
--- james/imap/trunk/api/src/main/java/org/apache/james/imap/api/MailboxPathHashMap.java (added)
+++ james/imap/trunk/api/src/main/java/org/apache/james/imap/api/MailboxPathHashMap.java Sun Jul 18 18:18:08 2010
@@ -0,0 +1,49 @@
+package org.apache.james.imap.api;
+
+import java.util.HashMap;
+import java.util.Iterator;
+
+/**
+ * This special map uses MailboxPath objects as keys.
+ *
+ * @param <T> The type of objects to store.
+ */
+public class MailboxPathHashMap<T> extends HashMap<MailboxPath, T> {
+
+ private static final long serialVersionUID = -7424356447437920137L;
+
+ @Override
+ public T get(Object object) {
+ if (!(object instanceof MailboxPath))
+ throw new IllegalArgumentException("Instance of type MailboxPath expected as key.");
+ MailboxPath path = (MailboxPath) object;
+ Iterator<MailboxPath> iteraror = this.keySet().iterator();
+ while (iteraror.hasNext()) {
+ MailboxPath iterPath = iteraror.next();
+ if (iterPath.equals(path))
+ return super.get(iterPath);
+ }
+ return null;
+ }
+
+ @Override
+ public T put(MailboxPath mailboxPath, T object) {
+ MailboxPath previousKey = null;
+ T previousValue = null;
+ Iterator<MailboxPath> iteraror = this.keySet().iterator();
+ while (iteraror.hasNext()) {
+ MailboxPath iterPath = iteraror.next();
+ if (iterPath.equals(mailboxPath)) {
+ previousKey = iterPath;
+ previousValue = super.get(iterPath);
+ break;
+ }
+ }
+ if (previousKey == null)
+ super.put(mailboxPath, object);
+ else
+ super.put(previousKey, object);
+ return previousValue;
+ }
+
+}
Modified: james/imap/trunk/api/src/main/java/org/apache/james/imap/api/process/SelectedMailbox.java
URL: http://svn.apache.org/viewvc/james/imap/trunk/api/src/main/java/org/apache/james/imap/api/process/SelectedMailbox.java?rev=965270&r1=965269&r2=965270&view=diff
==============================================================================
--- james/imap/trunk/api/src/main/java/org/apache/james/imap/api/process/SelectedMailbox.java (original)
+++ james/imap/trunk/api/src/main/java/org/apache/james/imap/api/process/SelectedMailbox.java Sun Jul 18 18:18:08 2010
@@ -21,6 +21,8 @@ package org.apache.james.imap.api.proces
import java.util.Collection;
+import org.apache.james.imap.api.MailboxPath;
+
/**
* Interface which represent a selected Mailbox during the selected state
@@ -78,11 +80,11 @@ public interface SelectedMailbox {
public int recentCount();
/**
- * Return the name of the selected Mailbox
+ * Return the path of the selected Mailbox
*
- * @return mailboxName
+ * @return path
*/
- public String getName();
+ public MailboxPath getPath();
/**
* Is the given uid recent ?
Modified: james/imap/trunk/deployment/src/test/java/org/apache/james/imap/functional/AbstractStressTest.java
URL: http://svn.apache.org/viewvc/james/imap/trunk/deployment/src/test/java/org/apache/james/imap/functional/AbstractStressTest.java?rev=965270&r1=965269&r2=965270&view=diff
==============================================================================
--- james/imap/trunk/deployment/src/test/java/org/apache/james/imap/functional/AbstractStressTest.java (original)
+++ james/imap/trunk/deployment/src/test/java/org/apache/james/imap/functional/AbstractStressTest.java Sun Jul 18 18:18:08 2010
@@ -28,6 +28,7 @@ import java.util.concurrent.atomic.Atomi
import javax.mail.Flags;
import org.apache.commons.logging.impl.SimpleLog;
+import org.apache.james.imap.api.MailboxPath;
import org.apache.james.imap.mailbox.Mailbox;
import org.apache.james.imap.mailbox.MailboxConstants;
import org.apache.james.imap.mailbox.MailboxException;
@@ -50,7 +51,8 @@ public abstract class AbstractStressTest
MailboxSession session = getMailboxManager().createSystemSession("test", new SimpleLog("Test"));
getMailboxManager().startProcessingRequest(session);
- getMailboxManager().createMailbox(MailboxConstants.USER_NAMESPACE +".username.INBOX", session);
+ final MailboxPath path = new MailboxPath(MailboxConstants.USER_NAMESPACE, "username", "INBOX");
+ getMailboxManager().createMailbox(path, session);
getMailboxManager().endProcessingRequest(session);
getMailboxManager().logout(session, false);
final AtomicBoolean fail = new AtomicBoolean(false);
@@ -69,7 +71,7 @@ public abstract class AbstractStressTest
try {
getMailboxManager().startProcessingRequest(session);
- Mailbox m = getMailboxManager().getMailbox(MailboxConstants.USER_NAMESPACE +".username.INBOX", session);
+ Mailbox m = getMailboxManager().getMailbox(path, session);
System.out.println("Append message with uid=" + m.appendMessage(new ByteArrayInputStream("Subject: test\r\n\r\ntestmail".getBytes()), new Date(), session, false, new Flags()));
getMailboxManager().endProcessingRequest(session);
Modified: james/imap/trunk/jcr/src/main/java/org/apache/james/imap/jcr/JCRMailboxManager.java
URL: http://svn.apache.org/viewvc/james/imap/trunk/jcr/src/main/java/org/apache/james/imap/jcr/JCRMailboxManager.java?rev=965270&r1=965269&r2=965270&view=diff
==============================================================================
--- james/imap/trunk/jcr/src/main/java/org/apache/james/imap/jcr/JCRMailboxManager.java (original)
+++ james/imap/trunk/jcr/src/main/java/org/apache/james/imap/jcr/JCRMailboxManager.java Sun Jul 18 18:18:08 2010
@@ -20,6 +20,7 @@ package org.apache.james.imap.jcr;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
+import org.apache.james.imap.api.MailboxPath;
import org.apache.james.imap.jcr.mail.JCRMailboxMapper;
import org.apache.james.imap.jcr.mail.model.JCRMailbox;
import org.apache.james.imap.mailbox.MailboxException;
@@ -58,8 +59,8 @@ public class JCRMailboxManager extends S
}
@Override
- protected void doCreateMailbox(String namespaceName, MailboxSession session) throws MailboxException {
- final Mailbox<String> mailbox = new org.apache.james.imap.jcr.mail.model.JCRMailbox(namespaceName, randomUidValidity(), logger);
+ protected void doCreateMailbox(MailboxPath path, MailboxSession session) throws MailboxException {
+ final Mailbox<String> mailbox = new org.apache.james.imap.jcr.mail.model.JCRMailbox(path, randomUidValidity(), logger);
final JCRMailboxMapper mapper = (JCRMailboxMapper) mapperFactory.getMailboxMapper(session);
mapper.execute(new TransactionalMapper.Transaction() {
Modified: james/imap/trunk/jcr/src/main/java/org/apache/james/imap/jcr/JCRMailboxSessionMapperFactory.java
URL: http://svn.apache.org/viewvc/james/imap/trunk/jcr/src/main/java/org/apache/james/imap/jcr/JCRMailboxSessionMapperFactory.java?rev=965270&r1=965269&r2=965270&view=diff
==============================================================================
--- james/imap/trunk/jcr/src/main/java/org/apache/james/imap/jcr/JCRMailboxSessionMapperFactory.java (original)
+++ james/imap/trunk/jcr/src/main/java/org/apache/james/imap/jcr/JCRMailboxSessionMapperFactory.java Sun Jul 18 18:18:08 2010
@@ -24,7 +24,6 @@ import org.apache.james.imap.jcr.mail.JC
import org.apache.james.imap.jcr.mail.JCRMessageMapper;
import org.apache.james.imap.jcr.user.JCRSubscriptionMapper;
-import org.apache.james.imap.mailbox.MailboxConstants;
import org.apache.james.imap.mailbox.MailboxException;
import org.apache.james.imap.mailbox.MailboxSession;
import org.apache.james.imap.mailbox.SubscriptionException;
@@ -42,20 +41,18 @@ public class JCRMailboxSessionMapperFact
private final MailboxSessionJCRRepository repository;
private final Log logger;
- private final char delimiter;
private final NodeLocker locker;
private final static int DEFAULT_SCALING = 2;
private int scaling;
private int messageScaling;
public JCRMailboxSessionMapperFactory(final MailboxSessionJCRRepository repository, final NodeLocker locker) {
- this(repository, locker, MailboxConstants.DEFAULT_DELIMITER, DEFAULT_SCALING, JCRMessageMapper.MESSAGE_SCALE_DAY);
+ this(repository, locker, DEFAULT_SCALING, JCRMessageMapper.MESSAGE_SCALE_DAY);
}
- public JCRMailboxSessionMapperFactory(final MailboxSessionJCRRepository repository, final NodeLocker locker, final char delimiter, final int scaling, final int messageScaling) {
+ public JCRMailboxSessionMapperFactory(final MailboxSessionJCRRepository repository, final NodeLocker locker, final int scaling, final int messageScaling) {
this.repository = repository;
this.logger = LogFactory.getLog(JCRSubscriptionManager.class);
- this.delimiter = delimiter;
this.locker = locker;
this.scaling = scaling;
this.messageScaling = messageScaling;
@@ -63,7 +60,7 @@ public class JCRMailboxSessionMapperFact
@Override
public MailboxMapper<String> createMailboxMapper(MailboxSession session) throws MailboxException {
- JCRMailboxMapper mapper = new JCRMailboxMapper(repository, session, locker, scaling, logger, delimiter);
+ JCRMailboxMapper mapper = new JCRMailboxMapper(repository, session, locker, scaling, logger);
return mapper;
}
Modified: james/imap/trunk/jcr/src/main/java/org/apache/james/imap/jcr/mail/JCRMailboxMapper.java
URL: http://svn.apache.org/viewvc/james/imap/trunk/jcr/src/main/java/org/apache/james/imap/jcr/mail/JCRMailboxMapper.java?rev=965270&r1=965269&r2=965270&view=diff
==============================================================================
--- james/imap/trunk/jcr/src/main/java/org/apache/james/imap/jcr/mail/JCRMailboxMapper.java (original)
+++ james/imap/trunk/jcr/src/main/java/org/apache/james/imap/jcr/mail/JCRMailboxMapper.java Sun Jul 18 18:18:08 2010
@@ -33,12 +33,14 @@ import org.apache.commons.logging.Log;
import org.apache.jackrabbit.JcrConstants;
import org.apache.jackrabbit.commons.JcrUtils;
import org.apache.jackrabbit.util.Text;
+import org.apache.james.imap.api.MailboxPath;
import org.apache.james.imap.api.display.HumanReadableText;
import org.apache.james.imap.jcr.AbstractJCRScalingMapper;
import org.apache.james.imap.jcr.MailboxSessionJCRRepository;
import org.apache.james.imap.jcr.NodeLocker;
import org.apache.james.imap.jcr.NodeLocker.NodeLockedExecution;
import org.apache.james.imap.jcr.mail.model.JCRMailbox;
+import org.apache.james.imap.mailbox.MailboxConstants;
import org.apache.james.imap.mailbox.MailboxNotFoundException;
import org.apache.james.imap.mailbox.MailboxSession;
import org.apache.james.imap.mailbox.StorageException;
@@ -52,11 +54,8 @@ import org.apache.james.imap.store.mail.
*/
public class JCRMailboxMapper extends AbstractJCRScalingMapper implements MailboxMapper<String> {
- private char delimiter;
-
- public JCRMailboxMapper(final MailboxSessionJCRRepository repos, MailboxSession session, final NodeLocker locker, final int scaling, final Log logger, char delimiter) {
+ public JCRMailboxMapper(final MailboxSessionJCRRepository repos, MailboxSession session, final NodeLocker locker, final int scaling, final Log logger) {
super(repos, session, locker, scaling, logger);
- this.delimiter = delimiter;
}
/*
@@ -109,42 +108,55 @@ public class JCRMailboxMapper extends Ab
}
}
+
/*
* (non-Javadoc)
- *
- * @see
- * org.apache.james.imap.store.mail.MailboxMapper#findMailboxByName(java
- * .lang.String)
+ * @see org.apache.james.imap.store.mail.MailboxMapper#findMailboxByPath(org.apache.james.imap.api.MailboxPath)
*/
- public Mailbox<String> findMailboxByName(String name) throws StorageException, MailboxNotFoundException {
+ public Mailbox<String> findMailboxByPath(MailboxPath path) throws StorageException, MailboxNotFoundException {
try {
+ String name = Text.escapeIllegalXpathSearchChars(path.getName());
+ String user = path.getUser();
+ if (user == null ) {
+ user = "";
+ }
+ user = Text.escapeIllegalXpathSearchChars(user);
+ String namespace = Text.escapeIllegalXpathSearchChars(path.getNamespace());
+
QueryManager manager = getSession().getWorkspace().getQueryManager();
- String queryString = "/jcr:root/" + MAILBOXES_PATH + "//element(*,jamesMailbox:mailbox)[@" + JCRMailbox.NAME_PROPERTY + "='" + name + "']";
+
+ String queryString = "/jcr:root/" + MAILBOXES_PATH + "//element(*,jamesMailbox:mailbox)[@" + JCRMailbox.NAME_PROPERTY + "='" + name+ "' and @" + JCRMailbox.NAMESPACE_PROPERTY +"='" + namespace + "' and @" + JCRMailbox.USER_PROPERTY + "='" + user + "']";
QueryResult result = manager.createQuery(queryString, Query.XPATH).execute();
NodeIterator it = result.getNodes();
if (it.hasNext()) {
return new JCRMailbox(it.nextNode(), getLogger());
}
- throw new MailboxNotFoundException(name);
+ throw new MailboxNotFoundException(path);
} catch (PathNotFoundException e) {
- throw new MailboxNotFoundException(name);
+ throw new MailboxNotFoundException(path);
} catch (RepositoryException e) {
throw new StorageException(HumanReadableText.SEARCH_FAILED, e);
}
}
+
/*
* (non-Javadoc)
- *
- * @see
- * org.apache.james.imap.store.mail.MailboxMapper#findMailboxWithNameLike
- * (java.lang.String)
+ * @see org.apache.james.imap.store.mail.MailboxMapper#findMailboxWithPathLike(org.apache.james.imap.api.MailboxPath)
*/
- public List<Mailbox<String>> findMailboxWithNameLike(String name) throws StorageException {
+ public List<Mailbox<String>> findMailboxWithPathLike(MailboxPath path) throws StorageException {
List<Mailbox<String>> mailboxList = new ArrayList<Mailbox<String>>();
try {
+ String name = Text.escapeIllegalXpathSearchChars(path.getName());
+ String user = path.getUser();
+ if (user == null ) {
+ user = "";
+ }
+ user = Text.escapeIllegalXpathSearchChars(user);
+ String namespace = Text.escapeIllegalXpathSearchChars(path.getNamespace());
+
QueryManager manager = getSession().getWorkspace().getQueryManager();
- String queryString = "/jcr:root/" + MAILBOXES_PATH + "//element(*,jamesMailbox:mailbox)[jcr:like(@" + JCRMailbox.NAME_PROPERTY + ",'%" + name + "%')]";
+ String queryString = "/jcr:root/" + MAILBOXES_PATH + "//element(*,jamesMailbox:mailbox)[jcr:like(@" + JCRMailbox.NAME_PROPERTY + ",'%" + name + "%') and @" + JCRMailbox.NAMESPACE_PROPERTY +"='" + namespace + "' and @" + JCRMailbox.USER_PROPERTY + "='" + user + "']";
QueryResult result = manager.createQuery(queryString, Query.XPATH).execute();
NodeIterator it = result.getNodes();
while (it.hasNext()) {
@@ -188,13 +200,12 @@ public class JCRMailboxMapper extends Ab
locker.execute(new NodeLockedExecution<Void>() {
public Void execute(Node node) throws RepositoryException {
- final String name = jcrMailbox.getName();
- //split the name so we can construct a nice node tree
- final String nameParts[] = name.split("\\" + String.valueOf(delimiter), 3);
- node = JcrUtils.getOrAddNode(node, Text.escapeIllegalJcrChars(nameParts[0]), "nt:unstructured");
- node = createUserPathStructure(node, Text.escapeIllegalJcrChars(nameParts[1]));
- node = JcrUtils.getOrAddNode(node, Text.escapeIllegalJcrChars(nameParts[2]), "nt:unstructured");
+ node = JcrUtils.getOrAddNode(node, Text.escapeIllegalJcrChars(jcrMailbox.getNamespace()), "nt:unstructured");
+ if (jcrMailbox.getUser() != null) {
+ node = createUserPathStructure(node, Text.escapeIllegalJcrChars(jcrMailbox.getUser()));
+ }
+ node = JcrUtils.getOrAddNode(node, Text.escapeIllegalJcrChars(jcrMailbox.getName()), "nt:unstructured");
node.addMixin("jamesMailbox:mailbox");
@@ -230,11 +241,19 @@ public class JCRMailboxMapper extends Ab
public boolean hasChildren(Mailbox<String> mailbox)
throws StorageException, MailboxNotFoundException {
try {
+ String name = Text.escapeIllegalXpathSearchChars(mailbox.getName());
+ String user = mailbox.getUser();
+ if (user == null ) {
+ user = "";
+ }
+ user = Text.escapeIllegalXpathSearchChars(user);
+ String namespace = Text.escapeIllegalXpathSearchChars(mailbox.getNamespace());
+
QueryManager manager = getSession().getWorkspace()
.getQueryManager();
String queryString = "/jcr:root/" + MAILBOXES_PATH
+ "//element(*,jamesMailbox:mailbox)[jcr:like(@"
- + JCRMailbox.NAME_PROPERTY + ",'" + mailbox.getName() + delimiter + "%')]";
+ + JCRMailbox.NAME_PROPERTY + ",'" + name + MailboxConstants.DEFAULT_DELIMITER_STRING + "%') and @" + JCRMailbox.NAMESPACE_PROPERTY +"='" + namespace + "' and @" + JCRMailbox.USER_PROPERTY + "='" + user + "']";
QueryResult result = manager.createQuery(queryString, Query.XPATH)
.execute();
NodeIterator it = result.getNodes();
Modified: james/imap/trunk/jcr/src/main/java/org/apache/james/imap/jcr/mail/model/JCRMailbox.java
URL: http://svn.apache.org/viewvc/james/imap/trunk/jcr/src/main/java/org/apache/james/imap/jcr/mail/model/JCRMailbox.java?rev=965270&r1=965269&r2=965270&view=diff
==============================================================================
--- james/imap/trunk/jcr/src/main/java/org/apache/james/imap/jcr/mail/model/JCRMailbox.java (original)
+++ james/imap/trunk/jcr/src/main/java/org/apache/james/imap/jcr/mail/model/JCRMailbox.java Sun Jul 18 18:18:08 2010
@@ -24,6 +24,7 @@ import javax.jcr.RepositoryException;
import org.apache.commons.logging.Log;
import org.apache.jackrabbit.JcrConstants;
import org.apache.jackrabbit.util.Text;
+import org.apache.james.imap.api.MailboxPath;
import org.apache.james.imap.jcr.JCRImapConstants;
import org.apache.james.imap.jcr.Persistent;
import org.apache.james.imap.store.mail.model.Mailbox;
@@ -37,6 +38,8 @@ public class JCRMailbox implements Mailb
private static final String TAB = " ";
+ public final static String USER_PROPERTY = "jamesMailbox:mailboxUser";
+ public final static String NAMESPACE_PROPERTY = "jamesMailbox:mailboxNamespace";
public final static String NAME_PROPERTY = "jamesMailbox:mailboxName";
public final static String UIDVALIDITY_PROPERTY = "jamesMailbox:mailboxUidValidity";
public final static String LASTUID_PROPERTY = "jamesMailbox:mailboxLastUid";
@@ -46,16 +49,20 @@ public class JCRMailbox implements Mailb
private long lastUid = 0;
private final Log logger;
private Node node;
+
+
+ private String namespace;
+ private String user;
- public JCRMailbox(final String name, final long uidValidity, final long lastUid, Log logger) {
- this.name = name;
- this.uidValidity = uidValidity;
+ public JCRMailbox(final MailboxPath path, final long uidValidity, final long lastUid, Log logger) {
+ this(path, uidValidity, logger);
this.lastUid = lastUid;
- this.logger = logger;
}
- public JCRMailbox( final String name, final long uidValidity, Log logger) {
- this.name = name;
+ public JCRMailbox( final MailboxPath path, final long uidValidity, Log logger) {
+ this.name = path.getName();
+ this.namespace = path.getNamespace();
+ this.user = path.getUser();
this.uidValidity = uidValidity;
this.logger = logger;
}
@@ -177,7 +184,12 @@ public class JCRMailbox implements Mailb
node.setProperty(NAME_PROPERTY, getName());
node.setProperty(UIDVALIDITY_PROPERTY, getUidValidity());
node.setProperty(LASTUID_PROPERTY, getLastUid());
-
+ String user = getUser();
+ if (user == null) {
+ user = "";
+ }
+ node.setProperty(USER_PROPERTY, user);
+ node.setProperty(NAMESPACE_PROPERTY, getNamespace());
this.node = node;
}
@@ -229,4 +241,74 @@ public class JCRMailbox implements Mailb
return null;
}
+ /*
+ * (non-Javadoc)
+ * @see org.apache.james.imap.store.mail.model.Mailbox#getNamespace()
+ */
+ public String getNamespace() {
+ if (isPersistent()) {
+ try {
+ return node.getProperty(NAMESPACE_PROPERTY).getString();
+ } catch (RepositoryException e) {
+ logger.error("Unable to access property " + NAMESPACE_PROPERTY, e);
+ }
+ }
+ return namespace;
+ }
+
+ /*
+ * (non-Javadoc)
+ * @see org.apache.james.imap.store.mail.model.Mailbox#getUser()
+ */
+ public String getUser() {
+ if (isPersistent()) {
+ try {
+ String user = node.getProperty(USER_PROPERTY).getString();
+ if (user.trim().length() == 0) {
+ return null;
+ } else {
+ return user;
+ }
+ } catch (RepositoryException e) {
+ logger.error("Unable to access property " + USER_PROPERTY, e);
+ }
+ }
+ return user;
+ }
+
+ /*
+ * (non-Javadoc)
+ * @see org.apache.james.imap.store.mail.model.Mailbox#setNamespace(java.lang.String)
+ */
+ public void setNamespace(String namespace) {
+ if (isPersistent()) {
+ try {
+ node.setProperty(NAMESPACE_PROPERTY, namespace);
+ } catch (RepositoryException e) {
+ logger.error("Unable to access property " + NAMESPACE_PROPERTY, e);
+ }
+ } else {
+ this.namespace = namespace;
+ }
+ }
+
+ /*
+ * (non-Javadoc)
+ * @see org.apache.james.imap.store.mail.model.Mailbox#setuser(java.lang.String)
+ */
+ public void setuser(String user) {
+ if (isPersistent()) {
+ try {
+ if (user == null) {
+ user = "";
+ }
+ node.setProperty(USER_PROPERTY, user);
+ } catch (RepositoryException e) {
+ logger.error("Unable to access property " + NAME_PROPERTY, e);
+ }
+ } else {
+ this.user = user;
+ }
+ }
+
}
Modified: james/imap/trunk/jcr/src/main/resources/org/apache/james/imap/jcr/imap.cnd
URL: http://svn.apache.org/viewvc/james/imap/trunk/jcr/src/main/resources/org/apache/james/imap/jcr/imap.cnd?rev=965270&r1=965269&r2=965270&view=diff
==============================================================================
--- james/imap/trunk/jcr/src/main/resources/org/apache/james/imap/jcr/imap.cnd (original)
+++ james/imap/trunk/jcr/src/main/resources/org/apache/james/imap/jcr/imap.cnd Sun Jul 18 18:18:08 2010
@@ -60,4 +60,6 @@
- jamesMailbox:mailboxUidValidity (LONG)
- jamesMailbox:mailboxName (STRING)
- jamesMailbox:mailboxLastUid (LONG)
+ - jamesMailbox:mailboxNamespace (STRING)
+ - jamesMailbox:mailboxUser (STRING)
+ * (nt:unstructured) multiple
Modified: james/imap/trunk/jpa/src/main/java/org/apache/james/imap/jpa/JPAMailboxManager.java
URL: http://svn.apache.org/viewvc/james/imap/trunk/jpa/src/main/java/org/apache/james/imap/jpa/JPAMailboxManager.java?rev=965270&r1=965269&r2=965270&view=diff
==============================================================================
--- james/imap/trunk/jpa/src/main/java/org/apache/james/imap/jpa/JPAMailboxManager.java (original)
+++ james/imap/trunk/jpa/src/main/java/org/apache/james/imap/jpa/JPAMailboxManager.java Sun Jul 18 18:18:08 2010
@@ -18,6 +18,7 @@
****************************************************************/
package org.apache.james.imap.jpa;
+import org.apache.james.imap.api.MailboxPath;
import org.apache.james.imap.jpa.mail.model.JPAMailbox;
import org.apache.james.imap.mailbox.MailboxException;
import org.apache.james.imap.mailbox.MailboxSession;
@@ -39,8 +40,8 @@ public abstract class JPAMailboxManager
}
@Override
- protected void doCreateMailbox(String namespaceName, MailboxSession session) throws MailboxException {
- final Mailbox<Long> mailbox = new JPAMailbox(namespaceName, randomUidValidity());
+ protected void doCreateMailbox(MailboxPath path, MailboxSession session) throws MailboxException {
+ final Mailbox<Long> mailbox = new JPAMailbox(path, randomUidValidity());
final MailboxMapper<Long> mapper = mailboxSessionMapperFactory.getMailboxMapper(session);
mapper.execute(new TransactionalMapper.Transaction(){
Modified: james/imap/trunk/jpa/src/main/java/org/apache/james/imap/jpa/mail/JPAMailboxMapper.java
URL: http://svn.apache.org/viewvc/james/imap/trunk/jpa/src/main/java/org/apache/james/imap/jpa/mail/JPAMailboxMapper.java?rev=965270&r1=965269&r2=965270&view=diff
==============================================================================
--- james/imap/trunk/jpa/src/main/java/org/apache/james/imap/jpa/mail/JPAMailboxMapper.java (original)
+++ james/imap/trunk/jpa/src/main/java/org/apache/james/imap/jpa/mail/JPAMailboxMapper.java Sun Jul 18 18:18:08 2010
@@ -27,6 +27,7 @@ import javax.persistence.NoResultExcepti
import javax.persistence.PersistenceException;
import javax.persistence.RollbackException;
+import org.apache.james.imap.api.MailboxPath;
import org.apache.james.imap.api.display.HumanReadableText;
import org.apache.james.imap.jpa.JPATransactionalMapper;
import org.apache.james.imap.jpa.mail.model.JPAMailbox;
@@ -84,13 +85,17 @@ public class JPAMailboxMapper extends JP
}
/**
- * @see org.apache.james.imap.store.mail.MailboxMapper#findMailboxByName(java.lang.String)
+ * @see org.apache.james.imap.store.mail.MailboxMapper#findMailboxByPath(java.lang.String)
*/
- public Mailbox<Long> findMailboxByName(String name) throws StorageException, MailboxNotFoundException {
+ public Mailbox<Long> findMailboxByPath(MailboxPath mailboxPath) throws StorageException, MailboxNotFoundException {
try {
- return (JPAMailbox) getEntityManager().createNamedQuery("findMailboxByName").setParameter("nameParam", name).getSingleResult();
+ if (mailboxPath.getUser() == null) {
+ return (JPAMailbox) getEntityManager().createNamedQuery("findMailboxByName").setParameter("nameParam", mailboxPath.getName()).setParameter("namespaceParam", mailboxPath.getNamespace()).getSingleResult();
+ } else {
+ return (JPAMailbox) getEntityManager().createNamedQuery("findMailboxByNameWithUser").setParameter("nameParam", mailboxPath.getName()).setParameter("namespaceParam", mailboxPath.getNamespace()).setParameter("userParam", mailboxPath.getUser()).getSingleResult();
+ }
} catch (NoResultException e) {
- throw new MailboxNotFoundException(name);
+ throw new MailboxNotFoundException(mailboxPath);
} catch (PersistenceException e) {
throw new StorageException(HumanReadableText.SEARCH_FAILED, e);
@@ -109,13 +114,18 @@ public class JPAMailboxMapper extends JP
}
}
- /**
- * @see org.apache.james.imap.store.mail.MailboxMapper#findMailboxWithNameLike(java.lang.String)
+ /*
+ * (non-Javadoc)
+ * @see org.apache.james.imap.store.mail.MailboxMapper#findMailboxWithPathLike(org.apache.james.imap.api.MailboxPath)
*/
@SuppressWarnings("unchecked")
- public List<Mailbox<Long>> findMailboxWithNameLike(String name) throws StorageException {
+ public List<Mailbox<Long>> findMailboxWithPathLike(MailboxPath path) throws StorageException {
try {
- return getEntityManager().createNamedQuery("findMailboxWithNameLike").setParameter("nameParam", SQL_WILDCARD_CHAR + name + SQL_WILDCARD_CHAR).getResultList();
+ if (path.getUser() == null) {
+ return getEntityManager().createNamedQuery("findMailboxWithNameLike").setParameter("nameParam", SQL_WILDCARD_CHAR + path.getName() + SQL_WILDCARD_CHAR).setParameter("namespaceParam", path.getNamespace()).getResultList();
+ } else {
+ return getEntityManager().createNamedQuery("findMailboxWithNameLikeWithUser").setParameter("nameParam", SQL_WILDCARD_CHAR + path.getName() + SQL_WILDCARD_CHAR).setParameter("namespaceParam", path.getNamespace()).setParameter("userParam", path.getUser()).getResultList();
+ }
} catch (PersistenceException e) {
throw new StorageException(HumanReadableText.SEARCH_FAILED, e);
}
@@ -151,7 +161,12 @@ public class JPAMailboxMapper extends JP
public boolean hasChildren(Mailbox<Long> mailbox) throws StorageException,
MailboxNotFoundException {
final String name = mailbox.getName() + delimiter + SQL_WILDCARD_CHAR;
- final Long numberOfChildMailboxes = (Long) getEntityManager().createNamedQuery("countMailboxesWithNameLike").setParameter("nameParam", name).getSingleResult();
+ final Long numberOfChildMailboxes;
+ if (mailbox.getUser() == null) {
+ numberOfChildMailboxes = (Long) getEntityManager().createNamedQuery("countMailboxesWithNameLike").setParameter("nameParam", name).setParameter("namespaceParam", mailbox.getNamespace()).getSingleResult();
+ } else {
+ numberOfChildMailboxes = (Long) getEntityManager().createNamedQuery("countMailboxesWithNameLikeWithUser").setParameter("nameParam", name).setParameter("namespaceParam", mailbox.getNamespace()).setParameter("userParam", mailbox.getUser()).getSingleResult();
+ }
return numberOfChildMailboxes != null && numberOfChildMailboxes > 0;
}
}
Modified: james/imap/trunk/jpa/src/main/java/org/apache/james/imap/jpa/mail/model/JPAMailbox.java
URL: http://svn.apache.org/viewvc/james/imap/trunk/jpa/src/main/java/org/apache/james/imap/jpa/mail/model/JPAMailbox.java?rev=965270&r1=965269&r2=965270&view=diff
==============================================================================
--- james/imap/trunk/jpa/src/main/java/org/apache/james/imap/jpa/mail/model/JPAMailbox.java (original)
+++ james/imap/trunk/jpa/src/main/java/org/apache/james/imap/jpa/mail/model/JPAMailbox.java Sun Jul 18 18:18:08 2010
@@ -26,6 +26,7 @@ import javax.persistence.Id;
import javax.persistence.NamedQueries;
import javax.persistence.NamedQuery;
+import org.apache.james.imap.api.MailboxPath;
import org.apache.james.imap.store.mail.model.Mailbox;
@Entity(name="Mailbox")
@@ -33,13 +34,19 @@ import org.apache.james.imap.store.mail.
@NamedQuery(name="findMailboxById",
query="SELECT mailbox FROM Mailbox mailbox WHERE mailbox.mailboxId = :idParam"),
@NamedQuery(name="findMailboxByName",
- query="SELECT mailbox FROM Mailbox mailbox WHERE mailbox.name = :nameParam"),
+ query="SELECT mailbox FROM Mailbox mailbox WHERE mailbox.name = :nameParam and mailbox.user is NULL and mailbox.namespace= :namespaceParam"),
+ @NamedQuery(name="findMailboxByNameWithUser",
+ query="SELECT mailbox FROM Mailbox mailbox WHERE mailbox.name = :nameParam and mailbox.user= :userParam and mailbox.namespace= :namespaceParam"),
@NamedQuery(name="deleteAll",
query="DELETE FROM Mailbox mailbox"),
+ @NamedQuery(name="findMailboxWithNameLikeWithUser",
+ query="SELECT mailbox FROM Mailbox mailbox WHERE mailbox.name LIKE :nameParam and mailbox.user= :userParam and mailbox.namespace= :namespaceParam"),
@NamedQuery(name="findMailboxWithNameLike",
- query="SELECT mailbox FROM Mailbox mailbox WHERE mailbox.name LIKE :nameParam"),
+ query="SELECT mailbox FROM Mailbox mailbox WHERE mailbox.name LIKE :nameParam and mailbox.user is NULL and mailbox.namespace= :namespaceParam"),
+ @NamedQuery(name="countMailboxesWithNameLikeWithUser",
+ query="SELECT COUNT(mailbox) FROM Mailbox mailbox WHERE mailbox.name LIKE :nameParam and mailbox.user= :userParam and mailbox.namespace= :namespaceParam"),
@NamedQuery(name="countMailboxesWithNameLike",
- query="SELECT COUNT(mailbox) FROM Mailbox mailbox WHERE mailbox.name LIKE :nameParam")
+ query="SELECT COUNT(mailbox) FROM Mailbox mailbox WHERE mailbox.name LIKE :nameParam and mailbox.user is NULL and mailbox.namespace= :namespaceParam")
})
public class JPAMailbox implements Mailbox<Long> {
@@ -49,7 +56,7 @@ public class JPAMailbox implements Mailb
@Id @GeneratedValue private long mailboxId;
/** The value for the name field */
- @Basic(optional=false) @Column(unique = true) private String name;
+ @Basic(optional=false) @Column(nullable = false) private String name;
/** The value for the uidValidity field */
@Basic(optional=false) private long uidValidity;
@@ -58,6 +65,9 @@ public class JPAMailbox implements Mailb
/** The value for the lastUid field */
@Basic(optional=false) private long lastUid = 0;
+ @Basic(optional=false) @Column(nullable = true) private String user;
+ @Basic(optional=false) @Column(nullable = false) private String namespace;
+
/**
* JPA only
*/
@@ -66,9 +76,11 @@ public class JPAMailbox implements Mailb
super();
}
- public JPAMailbox(String name, int uidValidity) {
+ public JPAMailbox(MailboxPath path, int uidValidity) {
this();
- this.name= name;
+ this.name = path.getName();
+ this.user = path.getUser();
+ this.namespace = path.getNamespace();
this.uidValidity = uidValidity;
}
@@ -148,4 +160,36 @@ public class JPAMailbox implements Mailb
return false;
return true;
}
+
+ /*
+ * (non-Javadoc)
+ * @see org.apache.james.imap.store.mail.model.Mailbox#getNamespace()
+ */
+ public String getNamespace() {
+ return namespace;
+ }
+
+ /*
+ * (non-Javadoc)
+ * @see org.apache.james.imap.store.mail.model.Mailbox#getUser()
+ */
+ public String getUser() {
+ return user;
+ }
+
+ /*
+ * (non-Javadoc)
+ * @see org.apache.james.imap.store.mail.model.Mailbox#setNamespace(java.lang.String)
+ */
+ public void setNamespace(String namespace) {
+ this.namespace = namespace;
+ }
+
+ /*
+ * (non-Javadoc)
+ * @see org.apache.james.imap.store.mail.model.Mailbox#setuser(java.lang.String)
+ */
+ public void setuser(String user) {
+ this.user = user;
+ }
}
Modified: james/imap/trunk/mailbox/src/main/java/org/apache/james/imap/mailbox/MailboxConstants.java
URL: http://svn.apache.org/viewvc/james/imap/trunk/mailbox/src/main/java/org/apache/james/imap/mailbox/MailboxConstants.java?rev=965270&r1=965269&r2=965270&view=diff
==============================================================================
--- james/imap/trunk/mailbox/src/main/java/org/apache/james/imap/mailbox/MailboxConstants.java (original)
+++ james/imap/trunk/mailbox/src/main/java/org/apache/james/imap/mailbox/MailboxConstants.java Sun Jul 18 18:18:08 2010
@@ -35,4 +35,9 @@ public interface MailboxConstants {
*/
public static final char DEFAULT_DELIMITER = '.';
+ /**
+ * The default delimiter used to seperated parent/child folders
+ */
+ public static final String DEFAULT_DELIMITER_STRING = ".";
+
}
Modified: james/imap/trunk/mailbox/src/main/java/org/apache/james/imap/mailbox/MailboxListener.java
URL: http://svn.apache.org/viewvc/james/imap/trunk/mailbox/src/main/java/org/apache/james/imap/mailbox/MailboxListener.java?rev=965270&r1=965269&r2=965270&view=diff
==============================================================================
--- james/imap/trunk/mailbox/src/main/java/org/apache/james/imap/mailbox/MailboxListener.java (original)
+++ james/imap/trunk/mailbox/src/main/java/org/apache/james/imap/mailbox/MailboxListener.java Sun Jul 18 18:18:08 2010
@@ -23,6 +23,8 @@ import java.util.Iterator;
import javax.mail.Flags;
+import org.apache.james.imap.api.MailboxPath;
+
/**
* Listens to <code>Mailbox</code> events.
* Note that listeners may be removed asynchronously.
@@ -49,12 +51,12 @@ public interface MailboxListener {
/**
* A mailbox event.
*/
- public abstract class Event {
+ public class Event {
private final long sessionId;
- private final String name;
- public Event(final long sessionId, final String name) {
+ private final MailboxPath path;
+ public Event(final long sessionId, final MailboxPath path) {
this.sessionId = sessionId;
- this.name = name;
+ this.path = path;
}
/**
@@ -67,22 +69,22 @@ public interface MailboxListener {
}
/**
- * Return the name of the Mailbox this event belongs to.
+ * Return the path of the Mailbox this event belongs to.
*
- * @return name
+ * @return path
*/
- public String getMailboxName() {
- return name;
+ public MailboxPath getMailboxPath() {
+ return path;
}
}
/**
* Indicates that mailbox has been deleted.
*/
- public abstract class MailboxDeletionEvent extends Event {
+ public class MailboxDeletionEvent extends Event {
- public MailboxDeletionEvent(long sessionId, String name) {
- super(sessionId, name);
+ public MailboxDeletionEvent(long sessionId, MailboxPath path) {
+ super(sessionId, path);
}
}
@@ -91,15 +93,15 @@ public interface MailboxListener {
* Indicates that a mailbox has been renamed.
*/
public abstract class MailboxRenamed extends Event {
- public MailboxRenamed(long sessionId, String name) {
- super(sessionId, name);
+ public MailboxRenamed(long sessionId, MailboxPath path) {
+ super(sessionId, path);
}
/**
* Gets the new name for this mailbox.
*
* @return name, not null
*/
- public abstract String getNewName();
+ public abstract MailboxPath getNewPath();
}
/**
@@ -107,8 +109,8 @@ public interface MailboxListener {
*/
public abstract class MessageEvent extends Event {
- public MessageEvent(long sessionId, String name) {
- super(sessionId, name);
+ public MessageEvent(long sessionId, MailboxPath path) {
+ super(sessionId, path);
}
/**
@@ -121,8 +123,8 @@ public interface MailboxListener {
public abstract class Expunged extends MessageEvent {
- public Expunged(long sessionId, String name) {
- super(sessionId, name);
+ public Expunged(long sessionId, MailboxPath path) {
+ super(sessionId, path);
}
}
@@ -133,8 +135,8 @@ public interface MailboxListener {
*/
public abstract class FlagsUpdated extends MessageEvent {
- public FlagsUpdated(long sessionId, String name) {
- super(sessionId, name);
+ public FlagsUpdated(long sessionId, MailboxPath path) {
+ super(sessionId, path);
}
/**
@@ -157,8 +159,8 @@ public interface MailboxListener {
*/
public abstract class Added extends MessageEvent {
- public Added(long sessionId, String name) {
- super(sessionId, name);
+ public Added(long sessionId, MailboxPath path) {
+ super(sessionId, path);
}
}
Modified: james/imap/trunk/mailbox/src/main/java/org/apache/james/imap/mailbox/MailboxManager.java
URL: http://svn.apache.org/viewvc/james/imap/trunk/mailbox/src/main/java/org/apache/james/imap/mailbox/MailboxManager.java?rev=965270&r1=965269&r2=965270&view=diff
==============================================================================
--- james/imap/trunk/mailbox/src/main/java/org/apache/james/imap/mailbox/MailboxManager.java (original)
+++ james/imap/trunk/mailbox/src/main/java/org/apache/james/imap/mailbox/MailboxManager.java Sun Jul 18 18:18:08 2010
@@ -23,6 +23,7 @@ import java.util.Collection;
import java.util.List;
import org.apache.commons.logging.Log;
+import org.apache.james.imap.api.MailboxPath;
/**
@@ -41,7 +42,7 @@ import org.apache.commons.logging.Log;
* <p>
* Internally MailboxManager deals with named repositories that could have
* different implementations. E.g. JDBC connections to different hosts or
- * Maildir / Mbox like stores. This repositories are identified by its names and
+ * Maildir / Mbox like stores. These repositories are identified by their names and
* maybe are configured in config.xml. The names of the mailboxes have to be
* mapped to the corresponding repository name. For user mailboxes this could be
* done by a "User.getRepositoryName()" property. It is imaginable that
@@ -66,21 +67,11 @@ public interface MailboxManager {
* @return delimiter
*/
char getDelimiter();
-
- /**
- * <p>
- * Resolves a path for the given user.
- * </p>
- * TODO: Think about replacing this operation TODO: More elegant to pass in
- * the username TODO: Or switch to URLs
- */
- String resolve(String userName, String mailboxPath);
/**
* Gets an session suitable for IMAP.
*
- * @param mailboxName
- * the name of the mailbox, not null
+ * @param mailboxPath the Path of the mailbox, not null
* @param session the context for this call, not null
* @return <code>ImapMailboxSession</code>, not null
* @throws MailboxException
@@ -88,35 +79,34 @@ public interface MailboxManager {
* @throws MailboxNotFoundException
* when the given mailbox does not exist
*/
- Mailbox getMailbox(String mailboxName, MailboxSession session) throws MailboxException;
+ Mailbox getMailbox(MailboxPath mailboxPath, MailboxSession session) throws MailboxException;
/**
* Creates a new mailbox. Any intermediary mailboxes missing from the
* hierarchy should be created.
*
- * @param mailboxName
- * name, not null
+ * @param mailboxPath
* @param mailboxSession the context for this call, not null
* @throws MailboxException when creation fails
*/
- void createMailbox(String mailboxName, MailboxSession mailboxSession) throws MailboxException;
+ void createMailbox(MailboxPath mailboxPath, MailboxSession mailboxSession) throws MailboxException;
/**
* Delete the mailbox with the name
*
- * @param mailboxName
+ * @param mailboxPath
* @param session
* @throws MailboxException
*/
- void deleteMailbox(String mailboxName, MailboxSession session) throws MailboxException;
+ void deleteMailbox(MailboxPath mailboxPath, MailboxSession session) throws MailboxException;
/**
* Renames a mailbox.
*
* @param from
- * original name for the mailbox
+ * original mailbox
* @param to
- * new name for the mailbox
+ * new mailbox
* @param session the context for this call, not nul
* @throws MailboxException otherwise
* @throws MailboxExistsException
@@ -124,7 +114,7 @@ public interface MailboxManager {
* @throws MailboxNotFound
* when the <code>from</code> mailbox does not exist
*/
- void renameMailbox(String from, String to, MailboxSession session) throws MailboxException;
+ void renameMailbox(MailboxPath from, MailboxPath to, MailboxSession session) throws MailboxException;
/**
* this is done by the MailboxRepository because maybe this operation could
@@ -139,8 +129,7 @@ public interface MailboxManager {
* @param session
* <code>MailboxSession</code>, not null
*/
- void copyMessages(MessageRange set, String from, String to,
- MailboxSession session) throws MailboxException;
+ void copyMessages(MessageRange set, MailboxPath from, MailboxPath to, MailboxSession session) throws MailboxException;
/**
* Searches for mailboxes matching the given query.
@@ -157,7 +146,7 @@ public interface MailboxManager {
* @return true when the mailbox exists and is accessible for the given user, false otherwise
* @throws MailboxException
*/
- boolean mailboxExists(String mailboxName, MailboxSession session) throws MailboxException;
+ boolean mailboxExists(MailboxPath mailboxPath, MailboxSession session) throws MailboxException;
/**
* Creates a new system session.
@@ -245,12 +234,12 @@ public interface MailboxManager {
* Listeners should return true from {@link MailboxListener#isClosed()}
* when they are ready to be removed.
* </p>
- * @param mailboxName not null
+ * @param mailboxPath not null
* @param listener not null
* @param session not null
* @throws MailboxException
*/
- void addListener(String mailboxName, MailboxListener listener, MailboxSession session) throws MailboxException;
+ void addListener(MailboxPath mailboxPath, MailboxListener listener, MailboxSession session) throws MailboxException;
/**
* Start the processing of a request for the given MailboxSession. If the user is not logged in already then the MailboxSession will be null
Modified: james/imap/trunk/mailbox/src/main/java/org/apache/james/imap/mailbox/MailboxMetaData.java
URL: http://svn.apache.org/viewvc/james/imap/trunk/mailbox/src/main/java/org/apache/james/imap/mailbox/MailboxMetaData.java?rev=965270&r1=965269&r2=965270&view=diff
==============================================================================
--- james/imap/trunk/mailbox/src/main/java/org/apache/james/imap/mailbox/MailboxMetaData.java (original)
+++ james/imap/trunk/mailbox/src/main/java/org/apache/james/imap/mailbox/MailboxMetaData.java Sun Jul 18 18:18:08 2010
@@ -19,6 +19,8 @@
package org.apache.james.imap.mailbox;
+import org.apache.james.imap.api.MailboxPath;
+
/**
* Returned by the list method of MailboxRepository and others
@@ -70,7 +72,7 @@ public interface MailboxMetaData {
String getHierarchyDelimiter();
/**
- * @return full namespace-name
+ * @return full mailbox path
*/
- String getName();
+ MailboxPath getPath();
}
Modified: james/imap/trunk/mailbox/src/main/java/org/apache/james/imap/mailbox/MailboxNotFoundException.java
URL: http://svn.apache.org/viewvc/james/imap/trunk/mailbox/src/main/java/org/apache/james/imap/mailbox/MailboxNotFoundException.java?rev=965270&r1=965269&r2=965270&view=diff
==============================================================================
--- james/imap/trunk/mailbox/src/main/java/org/apache/james/imap/mailbox/MailboxNotFoundException.java (original)
+++ james/imap/trunk/mailbox/src/main/java/org/apache/james/imap/mailbox/MailboxNotFoundException.java Sun Jul 18 18:18:08 2010
@@ -19,6 +19,7 @@
package org.apache.james.imap.mailbox;
+import org.apache.james.imap.api.MailboxPath;
import org.apache.james.imap.api.display.HumanReadableText;
/**
@@ -59,6 +60,16 @@ public class MailboxNotFoundException ex
this.mailboxName = mailboxName;
this.id = 0;
}
+
+ /**
+ * @param mailboxPath
+ * name of the mailbox, not null
+ */
+ public MailboxNotFoundException(MailboxPath mailboxPath) {
+ super(HumanReadableText.MAILBOX_NOT_FOUND, message(mailboxPath.toString()));
+ this.mailboxName = mailboxPath.toString();
+ this.id = 0;
+ }
/**
* Gets the name of the mailbox which cannot be found.
Modified: james/imap/trunk/mailbox/src/main/java/org/apache/james/imap/mailbox/MailboxQuery.java
URL: http://svn.apache.org/viewvc/james/imap/trunk/mailbox/src/main/java/org/apache/james/imap/mailbox/MailboxQuery.java?rev=965270&r1=965269&r2=965270&view=diff
==============================================================================
--- james/imap/trunk/mailbox/src/main/java/org/apache/james/imap/mailbox/MailboxQuery.java (original)
+++ james/imap/trunk/mailbox/src/main/java/org/apache/james/imap/mailbox/MailboxQuery.java Sun Jul 18 18:18:08 2010
@@ -19,12 +19,14 @@
package org.apache.james.imap.mailbox;
+import org.apache.james.imap.api.MailboxPath;
+
/**
* Expresses select criteria for mailboxes.
*/
public class MailboxQuery {
- private final String base;
+ private final MailboxPath base;
private final String expression;
@@ -47,14 +49,12 @@ public class MailboxQuery {
* matches any sequence of characters up to the next hierarchy
* delimiter
*/
- public MailboxQuery(final String base, final String expression,
+ public MailboxQuery(final MailboxPath base, final String expression,
final char freeWildcard, final char localWildcard) {
super();
- if (base == null) {
- this.base = "";
- } else {
- this.base = base;
- }
+ this.base = base;
+ if (base.getName() == null)
+ this.base.setName("");
if (expression == null) {
this.expression = "";
} else {
@@ -66,11 +66,11 @@ public class MailboxQuery {
}
/**
- * Gets the base reference name for the search.
+ * Gets the base reference for the search.
*
* @return the base
*/
- public final String getBase() {
+ public final MailboxPath getBase() {
return base;
}
@@ -112,13 +112,13 @@ public class MailboxQuery {
* mailbox hierarchy delimiter
* @return true if the given name matches this expression, false otherwise
*/
- public final boolean isExpressionMatch(String name, char hierarchyDelimiter) {
+ public final boolean isExpressionMatch(String name) {
final boolean result;
if (isWild()) {
if (name == null) {
result = false;
} else {
- result = isWildcardMatch(name, 0, 0, hierarchyDelimiter);
+ result = isWildcardMatch(name, 0, 0);
}
} else {
result = expression.equals(name);
@@ -127,23 +127,20 @@ public class MailboxQuery {
}
private final boolean isWildcardMatch(final String name,
- final int nameIndex, final int expressionIndex,
- final char hierarchyDelimiter) {
+ final int nameIndex, final int expressionIndex) {
final boolean result;
if (expressionIndex < expressionLength) {
final char expressionNext = expression.charAt(expressionIndex);
if (expressionNext == freeWildcard) {
- result = isFreeWildcardMatch(name, nameIndex, expressionIndex,
- hierarchyDelimiter);
+ result = isFreeWildcardMatch(name, nameIndex, expressionIndex);
} else if (expressionNext == localWildcard) {
- result = isLocalWildcardMatch(name, nameIndex, expressionIndex,
- hierarchyDelimiter);
+ result = isLocalWildcardMatch(name, nameIndex, expressionIndex);
} else {
if (nameIndex < name.length()) {
final char nameNext = name.charAt(nameIndex);
if (nameNext == expressionNext) {
result = isWildcardMatch(name, nameIndex + 1,
- expressionIndex + 1, hierarchyDelimiter);
+ expressionIndex + 1);
} else {
result = false;
}
@@ -161,26 +158,23 @@ public class MailboxQuery {
}
private boolean isLocalWildcardMatch(final String name,
- final int nameIndex, final int expressionIndex,
- final char hierarchyDelimiter) {
+ final int nameIndex, final int expressionIndex) {
final boolean result;
if (expressionIndex < expressionLength) {
final char expressionNext = expression.charAt(expressionIndex);
if (expressionNext == localWildcard) {
result = isLocalWildcardMatch(name, nameIndex,
- expressionIndex + 1, hierarchyDelimiter);
+ expressionIndex + 1);
} else if (expressionNext == freeWildcard) {
- result = isFreeWildcardMatch(name, nameIndex,
- expressionIndex + 1, hierarchyDelimiter);
+ result = isFreeWildcardMatch(name, nameIndex, expressionIndex + 1);
} else {
boolean matchRest = false;
for (int i = nameIndex; i < name.length(); i++) {
final char tasteNextName = name.charAt(i);
if (expressionNext == tasteNextName) {
- matchRest = isLocalWildcardMatch(name, i + 1, expressionIndex + 1,
- hierarchyDelimiter);
+ matchRest = isLocalWildcardMatch(name, i + 1, expressionIndex + 1);
break;
- } else if (tasteNextName == hierarchyDelimiter) {
+ } else if (tasteNextName == MailboxConstants.DEFAULT_DELIMITER) {
matchRest = false;
break;
}
@@ -191,7 +185,7 @@ public class MailboxQuery {
boolean containsDelimiter = false;
for (int i = nameIndex; i < name.length(); i++) {
final char nextRemaining = name.charAt(i);
- if (nextRemaining == hierarchyDelimiter) {
+ if (nextRemaining == MailboxConstants.DEFAULT_DELIMITER) {
containsDelimiter = true;
break;
}
@@ -206,7 +200,7 @@ public class MailboxQuery {
}
private boolean isFreeWildcardMatch(final String name, final int nameIndex,
- final int expressionIndex, final char hierarchyDelimiter) {
+ final int expressionIndex) {
final boolean result;
int nextNormal = expressionIndex;
while (nextNormal < expressionLength
@@ -219,7 +213,7 @@ public class MailboxQuery {
for (int i = nameIndex; i < name.length(); i++) {
final char tasteNextName = name.charAt(i);
if (expressionNextNormal == tasteNextName) {
- if (isWildcardMatch(name, i, nextNormal, hierarchyDelimiter)) {
+ if (isWildcardMatch(name, i, nextNormal)) {
matchRest = true;
break;
}
@@ -234,39 +228,35 @@ public class MailboxQuery {
}
/**
- * Get combined name formed by adding expression to base using the given
+ * Get combined name formed by adding the expression to the base using the given
* hierarchy delimiter. Note that the wildcards are retained in the combined
* name.
*
- * @param hierarchyDelimiter
- * delimiter for mailbox hierarchy
- * @return {@link #getBase()} combined with {@link #getExpression()}, not
- * null
+ * @return {@link #getBase()} combined with {@link #getExpression()}, notnull
*/
- public String getCombinedName(char hierarchyDelimiter) {
+ public String getCombinedName() {
final String result;
- final int baseLength = base.length();
- if (base != null && baseLength > 0) {
- final int lastChar = baseLength - 1;
- if (base.charAt(lastChar) == hierarchyDelimiter) {
+ if (base != null && base.getName() != null && base.getName().length() > 0) {
+ final int baseLength = base.getName().length();
+ if (base.getName().charAt(baseLength - 1) == MailboxConstants.DEFAULT_DELIMITER) {
if (expression != null && expression.length() > 0) {
- if (expression.charAt(0) == hierarchyDelimiter) {
- result = base + expression.substring(1);
+ if (expression.charAt(0) == MailboxConstants.DEFAULT_DELIMITER) {
+ result = base.getName() + expression.substring(1);
} else {
- result = base + expression;
+ result = base.getName() + expression;
}
} else {
- result = base;
+ result = base.getName();
}
} else {
if (expression != null && expression.length() > 0) {
- if (expression.charAt(0) == hierarchyDelimiter) {
- result = base + expression;
+ if (expression.charAt(0) == MailboxConstants.DEFAULT_DELIMITER) {
+ result = base.getName() + expression;
} else {
- result = base + hierarchyDelimiter + expression;
+ result = base.getName() + MailboxConstants.DEFAULT_DELIMITER + expression;
}
} else {
- result = base;
+ result = base.getName();
}
}
} else {
@@ -282,26 +272,21 @@ public class MailboxQuery {
*/
public boolean isWild() {
return expression != null
- && (expression.indexOf(freeWildcard) >= 0 || expression
- .indexOf(localWildcard) >= 0);
+ && (expression.indexOf(freeWildcard) >= 0
+ || expression.indexOf(localWildcard) >= 0);
}
/**
- * Renders a string sutable for logging.
+ * Renders a string suitable for logging.
*
* @return a <code>String</code> representation of this object.
*/
public String toString() {
final String TAB = " ";
-
- String retValue = "";
-
- retValue = "MailboxExpression [ " + "base = " + this.base + TAB
+ return "MailboxExpression [ " + "base = " + this.base + TAB
+ "expression = " + this.expression + TAB + "freeWildcard = "
+ this.freeWildcard + TAB + "localWildcard = "
+ this.localWildcard + TAB + " ]";
-
- return retValue;
}
}
Modified: james/imap/trunk/mailbox/src/main/java/org/apache/james/imap/mailbox/StandardMailboxMetaDataComparator.java
URL: http://svn.apache.org/viewvc/james/imap/trunk/mailbox/src/main/java/org/apache/james/imap/mailbox/StandardMailboxMetaDataComparator.java?rev=965270&r1=965269&r2=965270&view=diff
==============================================================================
--- james/imap/trunk/mailbox/src/main/java/org/apache/james/imap/mailbox/StandardMailboxMetaDataComparator.java (original)
+++ james/imap/trunk/mailbox/src/main/java/org/apache/james/imap/mailbox/StandardMailboxMetaDataComparator.java Sun Jul 18 18:18:08 2010
@@ -33,9 +33,9 @@ public class StandardMailboxMetaDataComp
* @return {@link Comparator#compare(Object, Object)}
*/
public static int order(MailboxMetaData one, MailboxMetaData two) {
- final String nameTwo = two.getName();
+ final String nameTwo = two.getPath().getName();
final int result;
- final String nameOne = one.getName();
+ final String nameOne = one.getPath().getName();
if (INBOX.equals(nameOne)) {
result = INBOX.equals(nameTwo) ? 0 : -1;
} else if (INBOX.equals(nameTwo)) {
Modified: james/imap/trunk/mailbox/src/main/java/org/apache/james/imap/mailbox/util/MailboxEventDispatcher.java
URL: http://svn.apache.org/viewvc/james/imap/trunk/mailbox/src/main/java/org/apache/james/imap/mailbox/util/MailboxEventDispatcher.java?rev=965270&r1=965269&r2=965270&view=diff
==============================================================================
--- james/imap/trunk/mailbox/src/main/java/org/apache/james/imap/mailbox/util/MailboxEventDispatcher.java (original)
+++ james/imap/trunk/mailbox/src/main/java/org/apache/james/imap/mailbox/util/MailboxEventDispatcher.java Sun Jul 18 18:18:08 2010
@@ -29,6 +29,7 @@ import java.util.concurrent.CopyOnWriteA
import javax.mail.Flags;
import javax.mail.Flags.Flag;
+import org.apache.james.imap.api.MailboxPath;
import org.apache.james.imap.mailbox.MailboxListener;
public class MailboxEventDispatcher implements MailboxListener {
@@ -52,20 +53,20 @@ public class MailboxEventDispatcher impl
listeners.add(mailboxListener);
}
- public void added(long uid, long sessionId, String name) {
+ public void added(long uid, long sessionId, MailboxPath path) {
pruneClosed();
- final AddedImpl added = new AddedImpl(sessionId, name, uid);
+ final AddedImpl added = new AddedImpl(sessionId, path, uid);
event(added);
}
- public void expunged(final long uid, long sessionId, String name) {
- final ExpungedImpl expunged = new ExpungedImpl(sessionId, name, uid);
+ public void expunged(final long uid, long sessionId, MailboxPath path) {
+ final ExpungedImpl expunged = new ExpungedImpl(sessionId, path, uid);
event(expunged);
}
- public void flagsUpdated(final long uid, long sessionId, final String name,
+ public void flagsUpdated(final long uid, long sessionId, final MailboxPath path,
final Flags original, final Flags updated) {
- final FlagsUpdatedImpl flags = new FlagsUpdatedImpl(sessionId, name, uid,
+ final FlagsUpdatedImpl flags = new FlagsUpdatedImpl(sessionId, path, uid,
original, updated);
event(flags);
}
@@ -85,7 +86,7 @@ public class MailboxEventDispatcher impl
return listeners.size();
}
- public void mailboxRenamed(String from, String to, long sessionId) {
+ public void mailboxRenamed(MailboxPath from, MailboxPath to, long sessionId) {
event(new MailboxRenamedEventImpl(from, to, sessionId));
}
@@ -93,8 +94,8 @@ public class MailboxEventDispatcher impl
private final long subjectUid;
- public AddedImpl(final long sessionId, final String name, final long subjectUid) {
- super(sessionId, name);
+ public AddedImpl(final long sessionId, final MailboxPath path, final long subjectUid) {
+ super(sessionId, path);
this.subjectUid = subjectUid;
}
@@ -111,8 +112,8 @@ public class MailboxEventDispatcher impl
private final long subjectUid;
- public ExpungedImpl(final long sessionId, final String name, final long subjectUid) {
- super(sessionId, name);
+ public ExpungedImpl(final long sessionId, final MailboxPath path, final long subjectUid) {
+ super(sessionId, path);
this.subjectUid = subjectUid;
}
@@ -142,9 +143,9 @@ public class MailboxEventDispatcher impl
private final Flags newFlags;
- public FlagsUpdatedImpl(final long sessionId, final String name, final long subjectUid,
+ public FlagsUpdatedImpl(final long sessionId, final MailboxPath path, final long subjectUid,
final Flags original, final Flags updated) {
- this(sessionId, name, subjectUid, updated, isChanged(original, updated,
+ this(sessionId, path, subjectUid, updated, isChanged(original, updated,
Flags.Flag.ANSWERED), isChanged(original, updated,
Flags.Flag.DELETED), isChanged(original, updated,
Flags.Flag.DRAFT), isChanged(original, updated,
@@ -153,12 +154,12 @@ public class MailboxEventDispatcher impl
Flags.Flag.SEEN));
}
- public FlagsUpdatedImpl(final long sessionId, final String name, final long subjectUid,
+ public FlagsUpdatedImpl(final long sessionId, final MailboxPath path, final long subjectUid,
final Flags newFlags, boolean answeredUpdated,
boolean deletedUpdated, boolean draftUpdated,
boolean flaggedUpdated, boolean recentUpdated,
boolean seenUpdated) {
- super(sessionId, name);
+ super(sessionId, path);
this.subjectUid = subjectUid;
this.modifiedFlags = new boolean[NUMBER_OF_SYSTEM_FLAGS];
this.modifiedFlags[0] = answeredUpdated;
@@ -242,33 +243,33 @@ public class MailboxEventDispatcher impl
}
}
- public void mailboxDeleted(long sessionId, String name) {
+ public void mailboxDeleted(long sessionId, MailboxPath path) {
final MailboxDeletionEventImpl event = new MailboxDeletionEventImpl(
- sessionId, name);
+ sessionId, path);
event(event);
}
private static final class MailboxDeletionEventImpl extends
MailboxListener.MailboxDeletionEvent {
- public MailboxDeletionEventImpl(final long sessionId, String name) {
- super(sessionId, name);
+ public MailboxDeletionEventImpl(final long sessionId, MailboxPath path) {
+ super(sessionId, path);
}
}
private static final class MailboxRenamedEventImpl extends MailboxListener.MailboxRenamed {
- private final String newName;
+ private final MailboxPath newPath;
- public MailboxRenamedEventImpl(final String name, final String newName, final long sessionId) {
- super(sessionId, name);
- this.newName = newName;
+ public MailboxRenamedEventImpl(final MailboxPath path, final MailboxPath newPath, final long sessionId) {
+ super(sessionId, path);
+ this.newPath = newPath;
}
/*
* (non-Javadoc)
* @see org.apache.james.imap.mailbox.MailboxListener.MailboxRenamed#getNewName()
*/
- public String getNewName() {
- return newName;
+ public MailboxPath getNewPath() {
+ return newPath;
}
}
Modified: james/imap/trunk/mailbox/src/main/java/org/apache/james/imap/mailbox/util/SimpleMailboxMetaData.java
URL: http://svn.apache.org/viewvc/james/imap/trunk/mailbox/src/main/java/org/apache/james/imap/mailbox/util/SimpleMailboxMetaData.java?rev=965270&r1=965269&r2=965270&view=diff
==============================================================================
--- james/imap/trunk/mailbox/src/main/java/org/apache/james/imap/mailbox/util/SimpleMailboxMetaData.java (original)
+++ james/imap/trunk/mailbox/src/main/java/org/apache/james/imap/mailbox/util/SimpleMailboxMetaData.java Sun Jul 18 18:18:08 2010
@@ -19,16 +19,17 @@
package org.apache.james.imap.mailbox.util;
+import org.apache.james.imap.api.MailboxPath;
import org.apache.james.imap.mailbox.MailboxMetaData;
import org.apache.james.imap.mailbox.StandardMailboxMetaDataComparator;
public class SimpleMailboxMetaData implements MailboxMetaData, Comparable<MailboxMetaData> {
- public static MailboxMetaData createNoSelect(String name, String delimiter) {
- return new SimpleMailboxMetaData(name, delimiter, Children.CHILDREN_ALLOWED_BUT_UNKNOWN, Selectability.NOSELECT);
+ public static MailboxMetaData createNoSelect(MailboxPath path, String delimiter) {
+ return new SimpleMailboxMetaData(path, delimiter, Children.CHILDREN_ALLOWED_BUT_UNKNOWN, Selectability.NOSELECT);
}
- private final String name;
+ private final MailboxPath path;
private final String delimiter;
@@ -36,14 +37,14 @@ public class SimpleMailboxMetaData imple
private final Selectability selectability;
- public SimpleMailboxMetaData(String name, String delimiter) {
- this(name, delimiter, Children.CHILDREN_ALLOWED_BUT_UNKNOWN, Selectability.NONE);
+ public SimpleMailboxMetaData(MailboxPath path, String delimiter) {
+ this(path, delimiter, Children.CHILDREN_ALLOWED_BUT_UNKNOWN, Selectability.NONE);
}
- public SimpleMailboxMetaData(final String name, final String delimiter,
+ public SimpleMailboxMetaData(final MailboxPath path, final String delimiter,
final Children inferiors, final Selectability selectability) {
super();
- this.name = name;
+ this.path = path;
this.delimiter = delimiter;
this.inferiors = inferiors;
this.selectability = selectability;
@@ -75,10 +76,10 @@ public class SimpleMailboxMetaData imple
/*
* (non-Javadoc)
- * @see org.apache.james.imap.mailbox.MailboxMetaData#getName()
+ * @see org.apache.james.imap.mailbox.MailboxMetaData#getPath()
*/
- public String getName() {
- return name;
+ public MailboxPath getPath() {
+ return path;
}
/*
@@ -86,7 +87,7 @@ public class SimpleMailboxMetaData imple
* @see java.lang.Object#toString()
*/
public String toString() {
- return "ListResult: " + name;
+ return "ListResult: " + path;
}
/**
@@ -95,7 +96,7 @@ public class SimpleMailboxMetaData imple
public int hashCode() {
final int PRIME = 31;
int result = 1;
- result = PRIME * result + ((name == null) ? 0 : name.hashCode());
+ result = PRIME * result + ((path == null) ? 0 : path.hashCode());
return result;
}
@@ -110,10 +111,10 @@ public class SimpleMailboxMetaData imple
if (getClass() != obj.getClass())
return false;
final SimpleMailboxMetaData other = (SimpleMailboxMetaData) obj;
- if (name == null) {
- if (other.name != null)
+ if (path == null) {
+ if (other.path != null)
return false;
- } else if (!name.equals(other.name))
+ } else if (!path.equals(other.path))
return false;
return true;
}
---------------------------------------------------------------------
To unsubscribe, e-mail: server-dev-unsubscribe@james.apache.org
For additional commands, e-mail: server-dev-help@james.apache.org