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 [3/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...
Modified: james/imap/trunk/processor/src/main/java/org/apache/james/imap/processor/ListProcessor.java
URL: http://svn.apache.org/viewvc/james/imap/trunk/processor/src/main/java/org/apache/james/imap/processor/ListProcessor.java?rev=965270&r1=965269&r2=965270&view=diff
==============================================================================
--- james/imap/trunk/processor/src/main/java/org/apache/james/imap/processor/ListProcessor.java (original)
+++ james/imap/trunk/processor/src/main/java/org/apache/james/imap/processor/ListProcessor.java Sun Jul 18 18:18:08 2010
@@ -25,6 +25,7 @@ import java.util.List;
import org.apache.james.imap.api.ImapCommand;
import org.apache.james.imap.api.ImapConstants;
import org.apache.james.imap.api.ImapMessage;
+import org.apache.james.imap.api.MailboxPath;
import org.apache.james.imap.api.message.request.ImapRequest;
import org.apache.james.imap.api.message.response.ImapResponseMessage;
import org.apache.james.imap.api.message.response.StatusResponseFactory;
@@ -64,79 +65,91 @@ public class ListProcessor extends Abstr
protected ImapResponseMessage createResponse(boolean noInferior,
boolean noSelect, boolean marked, boolean unmarked,
- boolean hasChildren, boolean hasNoChildren, String hierarchyDelimiter, String mailboxName) {
+ boolean hasChildren, boolean hasNoChildren, String mailboxName) {
return new ListResponse(noInferior, noSelect, marked, unmarked,
- hasChildren, hasNoChildren, hierarchyDelimiter, mailboxName);
+ hasChildren, hasNoChildren, mailboxName);
}
- protected final void doProcess(final String baseReferenceName,
- final String mailboxPattern, final ImapSession session,
+ /**
+ * (from rfc3501)
+ * The LIST command returns a subset of names from the complete set
+ * of all names available to the client. Zero or more untagged LIST
+ * replies are returned, containing the name attributes, hierarchy
+ * delimiter, and name; see the description of the LIST reply for
+ * more detail.
+ * ...
+ * An empty ("" string) mailbox name argument is a special request to
+ * return the hierarchy delimiter and the root name of the name given
+ * in the reference. The value returned as the root MAY be the empty
+ * string if the reference is non-rooted or is an empty string.
+ *
+ * @param referenceName
+ * @param mailboxName
+ * @param session
+ * @param tag
+ * @param command
+ * @param responder
+ */
+ protected final void doProcess(final String referenceName,
+ final String mailboxName, final ImapSession session,
final String tag, ImapCommand command, final Responder responder) {
try {
- String referenceName = baseReferenceName;
- // Should the #user.userName section be removed from names returned?
- final boolean removeUserPrefix;
+ // Should the namespace section be returned or not?
+ final boolean isRelative;
final List<MailboxMetaData> results;
final String user = ImapSessionUtils.getUserName(session);
- final String personalNamespace = MailboxConstants.USER_NAMESPACE
- + ImapConstants.HIERARCHY_DELIMITER_CHAR + user;
- if (mailboxPattern.length() == 0) {
- // An empty mailboxPattern signifies a request for the hierarchy
- // delimiter
- // and root name of the referenceName argument
+ if (mailboxName.length() == 0) {
+ // An empty mailboxName signifies a request for the hierarchy
+ // delimiter and root name of the referenceName argument
String referenceRoot;
if (referenceName.startsWith(ImapConstants.NAMESPACE_PREFIX)) {
- // A qualified reference name - get the first element,
- // and don't remove the user prefix
- removeUserPrefix = false;
- int firstDelimiter = referenceName
- .indexOf(ImapConstants.HIERARCHY_DELIMITER_CHAR);
+ // A qualified reference name - get the root element
+ isRelative = false;
+ int firstDelimiter = referenceName.indexOf(ImapConstants.HIERARCHY_DELIMITER_CHAR);
if (firstDelimiter == -1) {
referenceRoot = referenceName;
- } else {
- referenceRoot = referenceName.substring(0,
- firstDelimiter);
}
- } else {
- // A relative reference name - need to remove user prefix
- // from
- // results.
+ else {
+ referenceRoot = referenceName.substring(0, firstDelimiter);
+ }
+ }
+ else {
+ // A relative reference name, return "" to indicate it is non-rooted
referenceRoot = "";
- removeUserPrefix = true;
-
+ isRelative = true;
}
-
// Get the mailbox for the reference name.
+ MailboxPath rootPath = new MailboxPath(referenceRoot, "", "");
results = new ArrayList<MailboxMetaData>(1);
- results.add(SimpleMailboxMetaData.createNoSelect(referenceRoot,
- ImapConstants.HIERARCHY_DELIMITER));
- } else {
-
- // If the mailboxPattern is fully qualified, ignore the
- // reference name.
- if (mailboxPattern.charAt(0) == ImapConstants.NAMESPACE_PREFIX_CHAR) {
- referenceName = "";
+ results.add(SimpleMailboxMetaData.createNoSelect(rootPath, ImapConstants.HIERARCHY_DELIMITER));
+ }
+ else {
+ // If the mailboxPattern is fully qualified, ignore the reference name.
+ String finalReferencename = referenceName;
+ if (mailboxName.charAt(0) == ImapConstants.NAMESPACE_PREFIX_CHAR) {
+ finalReferencename = "";
}
+ // Is the interpreted (combined) pattern relative?
+ isRelative = ((finalReferencename + mailboxName).charAt(0) != ImapConstants.NAMESPACE_PREFIX_CHAR);
- // If the search pattern is relative, need to remove user prefix
- // from results.
- removeUserPrefix = ((referenceName + mailboxPattern).charAt(0) != ImapConstants.NAMESPACE_PREFIX_CHAR);
-
- if (removeUserPrefix) {
- referenceName = personalNamespace + "." + referenceName;
+ MailboxPath basePath = null;
+ if (isRelative) {
+ basePath = new MailboxPath(MailboxConstants.USER_NAMESPACE, user, finalReferencename);
+ }
+ else {
+ basePath = buildFullPath(session, finalReferencename);
}
- results = doList(session, referenceName, mailboxPattern);
+ results = getMailboxManager().search(new MailboxQuery(basePath, mailboxName, '*', '%'),
+ ImapSessionUtils.getMailboxSession(session));
}
- final int prefixLength = personalNamespace.length();
-
for (final MailboxMetaData metaData: results) {
- processResult(responder, removeUserPrefix, prefixLength, metaData);
+ processResult(responder, isRelative, metaData);
}
okComplete(command, tag, responder);
@@ -145,12 +158,9 @@ public class ListProcessor extends Abstr
}
}
- void processResult(final Responder responder,
- final boolean removeUserPrefix, int prefixLength,
- final MailboxMetaData listResult) {
+ void processResult(final Responder responder, final boolean relative, final MailboxMetaData listResult) {
final String delimiter = listResult.getHierarchyDelimiter();
- final String mailboxName = mailboxName(removeUserPrefix, prefixLength,
- listResult);
+ final String mailboxName = mailboxName(relative, listResult.getPath());
final Children inferiors = listResult.inferiors();
final boolean noInferior = MailboxMetaData.Children.NO_INFERIORS.equals(inferiors);
@@ -171,30 +181,7 @@ public class ListProcessor extends Abstr
break;
}
responder.respond(createResponse(noInferior, noSelect, marked,
- unmarked, hasChildren, hasNoChildren, delimiter, mailboxName));
- }
-
- private String mailboxName(final boolean removeUserPrefix,
- int prefixLength, final MailboxMetaData listResult) {
- final String mailboxName;
- final String name = listResult.getName();
- if (removeUserPrefix) {
- if (name.length() <= prefixLength) {
- mailboxName = "";
- } else {
- mailboxName = name.substring(prefixLength + 1);
- }
- } else {
- mailboxName = name;
- }
- return mailboxName;
+ unmarked, hasChildren, hasNoChildren, mailboxName));
}
- protected final List<MailboxMetaData> doList(ImapSession session, String base,
- String pattern) throws MailboxException {
- final MailboxManager mailboxManager = getMailboxManager();
- final List<MailboxMetaData> results = mailboxManager.search(new MailboxQuery(
- base, pattern, '*', '%'), ImapSessionUtils.getMailboxSession(session));
- return results;
- }
}
Modified: james/imap/trunk/processor/src/main/java/org/apache/james/imap/processor/LoginProcessor.java
URL: http://svn.apache.org/viewvc/james/imap/trunk/processor/src/main/java/org/apache/james/imap/processor/LoginProcessor.java?rev=965270&r1=965269&r2=965270&view=diff
==============================================================================
--- james/imap/trunk/processor/src/main/java/org/apache/james/imap/processor/LoginProcessor.java (original)
+++ james/imap/trunk/processor/src/main/java/org/apache/james/imap/processor/LoginProcessor.java Sun Jul 18 18:18:08 2010
@@ -21,6 +21,7 @@ package org.apache.james.imap.processor;
import org.apache.james.imap.api.ImapCommand;
import org.apache.james.imap.api.ImapMessage;
+import org.apache.james.imap.api.MailboxPath;
import org.apache.james.imap.api.display.HumanReadableText;
import org.apache.james.imap.api.message.request.ImapRequest;
import org.apache.james.imap.api.message.response.StatusResponseFactory;
@@ -66,16 +67,15 @@ public class LoginProcessor extends Abst
try {
final MailboxSession mailboxSession = mailboxManager.login(userid, passwd, session.getLog());
session.authenticated();
- session.setAttribute(
- ImapSessionUtils.MAILBOX_SESSION_ATTRIBUTE_SESSION_KEY,
- mailboxSession);
- final String inboxName = buildFullName(session, INBOX);
- if (mailboxManager.mailboxExists(inboxName, mailboxSession)) {
+ session.setAttribute(ImapSessionUtils.MAILBOX_SESSION_ATTRIBUTE_SESSION_KEY,
+ mailboxSession);
+ final MailboxPath inboxPath = buildFullPath(session, INBOX);
+ if (mailboxManager.mailboxExists(inboxPath, mailboxSession)) {
session.getLog().debug("INBOX exists. No need to create it.");
} else {
try {
session.getLog().debug("INBOX does not exist. Creating it.");
- mailboxManager.createMailbox(inboxName, mailboxSession);
+ mailboxManager.createMailbox(inboxPath, mailboxSession);
} catch (MailboxExistsException e) {
session.getLog().debug("Mailbox created by concurrent call. Safe to ignore this exception.");
}
Modified: james/imap/trunk/processor/src/main/java/org/apache/james/imap/processor/RenameProcessor.java
URL: http://svn.apache.org/viewvc/james/imap/trunk/processor/src/main/java/org/apache/james/imap/processor/RenameProcessor.java?rev=965270&r1=965269&r2=965270&view=diff
==============================================================================
--- james/imap/trunk/processor/src/main/java/org/apache/james/imap/processor/RenameProcessor.java (original)
+++ james/imap/trunk/processor/src/main/java/org/apache/james/imap/processor/RenameProcessor.java Sun Jul 18 18:18:08 2010
@@ -21,6 +21,7 @@ package org.apache.james.imap.processor;
import org.apache.james.imap.api.ImapCommand;
import org.apache.james.imap.api.ImapMessage;
+import org.apache.james.imap.api.MailboxPath;
import org.apache.james.imap.api.display.HumanReadableText;
import org.apache.james.imap.api.message.request.ImapRequest;
import org.apache.james.imap.api.message.response.StatusResponseFactory;
@@ -48,23 +49,17 @@ public class RenameProcessor extends Abs
protected void doProcess(ImapRequest message, ImapSession session,
String tag, ImapCommand command, Responder responder) {
final RenameRequest request = (RenameRequest) message;
- final String existingName = request.getExistingName();
- final String newName = request.getNewName();
+ final MailboxPath existingPath = buildFullPath(session, request.getExistingName());
+ final MailboxPath newPath = buildFullPath(session, request.getNewName());
try {
-
- final String fullExistingName = buildFullName(session, existingName);
- final String fullNewName = buildFullName(session, newName);
final MailboxManager mailboxManager = getMailboxManager();
- mailboxManager.renameMailbox(fullExistingName, fullNewName, ImapSessionUtils.getMailboxSession(session));
+ mailboxManager.renameMailbox(existingPath, newPath, ImapSessionUtils.getMailboxSession(session));
okComplete(command, tag, responder);
unsolicitedResponses(session, responder, false);
-
} catch (MailboxExistsException e) {
- no(command, tag, responder,
- HumanReadableText.FAILURE_MAILBOX_EXISTS);
+ no(command, tag, responder, HumanReadableText.FAILURE_MAILBOX_EXISTS);
} catch (MailboxNotFoundException e) {
- no(command, tag, responder,
- HumanReadableText.FAILURE_NO_SUCH_MAILBOX);
+ no(command, tag, responder, HumanReadableText.FAILURE_NO_SUCH_MAILBOX);
} catch (MailboxException e) {
no(command, tag, responder, e, session);
}
Modified: james/imap/trunk/processor/src/main/java/org/apache/james/imap/processor/StatusProcessor.java
URL: http://svn.apache.org/viewvc/james/imap/trunk/processor/src/main/java/org/apache/james/imap/processor/StatusProcessor.java?rev=965270&r1=965269&r2=965270&view=diff
==============================================================================
--- james/imap/trunk/processor/src/main/java/org/apache/james/imap/processor/StatusProcessor.java (original)
+++ james/imap/trunk/processor/src/main/java/org/apache/james/imap/processor/StatusProcessor.java Sun Jul 18 18:18:08 2010
@@ -22,6 +22,7 @@ package org.apache.james.imap.processor;
import org.apache.commons.logging.Log;
import org.apache.james.imap.api.ImapCommand;
import org.apache.james.imap.api.ImapMessage;
+import org.apache.james.imap.api.MailboxPath;
import org.apache.james.imap.api.message.StatusDataItems;
import org.apache.james.imap.api.message.request.ImapRequest;
import org.apache.james.imap.api.message.response.StatusResponseFactory;
@@ -50,22 +51,19 @@ public class StatusProcessor extends Abs
protected void doProcess(ImapRequest message, ImapSession session,
String tag, ImapCommand command, Responder responder) {
final StatusRequest request = (StatusRequest) message;
- final String mailboxName = request.getMailboxName();
+ final MailboxPath mailboxPath = buildFullPath(session, request.getMailboxName());
final StatusDataItems statusDataItems = request.getStatusDataItems();
final Log logger = session.getLog();
- final MailboxSession mailboxSession = ImapSessionUtils
- .getMailboxSession(session);
+ final MailboxSession mailboxSession = ImapSessionUtils.getMailboxSession(session);
try {
- String fullMailboxName = buildFullName(session, mailboxName);
-
if (logger != null && logger.isDebugEnabled()) {
- logger.debug("Status called on mailbox named " + mailboxName
- + " (" + fullMailboxName + ")");
+ logger.debug("Status called on mailbox named " + mailboxPath
+ + " (" + mailboxPath + ")");
}
final MailboxManager mailboxManager = getMailboxManager();
- final Mailbox mailbox = mailboxManager.getMailbox(fullMailboxName, ImapSessionUtils.getMailboxSession(session));
+ final Mailbox mailbox = mailboxManager.getMailbox(mailboxPath, ImapSessionUtils.getMailboxSession(session));
final Mailbox.MetaData.FetchGroup fetchGroup;
if (statusDataItems.isUnseen()) {
fetchGroup = Mailbox.MetaData.FetchGroup.UNSEEN_COUNT;
@@ -81,7 +79,7 @@ public class StatusProcessor extends Abs
final Long unseen = unseen(statusDataItems, metaData);
final MailboxStatusResponse response = new MailboxStatusResponse(messages,
- recent, uidNext, uidValidity, unseen, mailboxName);
+ recent, uidNext, uidValidity, unseen, request.getMailboxName());
responder.respond(response);
unsolicitedResponses(session, responder, false);
okComplete(command, tag, responder);
Modified: james/imap/trunk/processor/src/main/java/org/apache/james/imap/processor/base/MailboxEventAnalyser.java
URL: http://svn.apache.org/viewvc/james/imap/trunk/processor/src/main/java/org/apache/james/imap/processor/base/MailboxEventAnalyser.java?rev=965270&r1=965269&r2=965270&view=diff
==============================================================================
--- james/imap/trunk/processor/src/main/java/org/apache/james/imap/processor/base/MailboxEventAnalyser.java (original)
+++ james/imap/trunk/processor/src/main/java/org/apache/james/imap/processor/base/MailboxEventAnalyser.java Sun Jul 18 18:18:08 2010
@@ -27,13 +27,13 @@ import java.util.TreeSet;
import javax.mail.Flags;
+import org.apache.james.imap.api.MailboxPath;
import org.apache.james.imap.mailbox.MailboxListener;
/**
* {@link MailboxListener} implementation which will listen for {@link Event} notifications and
- * analyze these. It will only act on {@link Event} notifications whiche are send for the registered
- * Mailbox name
- *
+ * analyze these. It will only act on {@link Event} notifications which are sent for the registered
+ * MailboxPath
*/
public class MailboxEventAnalyser implements MailboxListener {
@@ -45,16 +45,16 @@ public class MailboxEventAnalyser implem
private boolean isDeletedByOtherSession = false;
private boolean sizeChanged = false;
private boolean silentFlagChanges = false;
- private String mailboxName;
+ private MailboxPath mailboxPath;
private boolean closed = false;
- public MailboxEventAnalyser(final long sessionId, final String mailboxName) {
+ public MailboxEventAnalyser(final long sessionId, final MailboxPath mailboxPath) {
super();
this.sessionId = sessionId;
flagUpdateUids = new TreeSet<Long>();
expungedUids = new TreeSet<Long>();
uninterestingFlag = Flags.Flag.RECENT;
- this.mailboxName = mailboxName;
+ this.mailboxPath = mailboxPath;
}
/**
@@ -62,8 +62,8 @@ public class MailboxEventAnalyser implem
*
* @return name
*/
- public String getMailboxName() {
- return mailboxName;
+ public MailboxPath getMailboxPath() {
+ return mailboxPath;
}
/**
@@ -71,8 +71,8 @@ public class MailboxEventAnalyser implem
*
* @param mailboxName
*/
- public void setMailboxName(String mailboxName) {
- this.mailboxName = mailboxName;
+ public void setMailboxPath(MailboxPath mailboxPath) {
+ this.mailboxPath = mailboxPath;
}
/**
@@ -82,34 +82,34 @@ public class MailboxEventAnalyser implem
* @see org.apache.james.imap.mailbox.MailboxListener#event(org.apache.james.imap.mailbox.MailboxListener.Event)
*/
public void event(Event event) {
-
+
// Check if the event was for the mailbox we are observing
- if (event.getMailboxName().equals(mailboxName)) {
- final long eventSessionId = event.getSessionId();
- if (event instanceof MessageEvent) {
- final MessageEvent messageEvent = (MessageEvent) event;
- final long uid = messageEvent.getSubjectUid();
- if (messageEvent instanceof Added) {
- sizeChanged = true;
- } else if (messageEvent instanceof FlagsUpdated) {
- FlagsUpdated updated = (FlagsUpdated) messageEvent;
- if (interestingFlags(updated)
- && (sessionId != eventSessionId || !silentFlagChanges)) {
+ if (event.getMailboxPath().equals(mailboxPath)) {
+ final long eventSessionId = event.getSessionId();
+ if (event instanceof MessageEvent) {
+ final MessageEvent messageEvent = (MessageEvent) event;
+ final long uid = messageEvent.getSubjectUid();
+ if (messageEvent instanceof Added) {
+ sizeChanged = true;
+ } else if (messageEvent instanceof FlagsUpdated) {
+ FlagsUpdated updated = (FlagsUpdated) messageEvent;
+ if (interestingFlags(updated)
+ && (sessionId != eventSessionId || !silentFlagChanges)) {
+ final Long uidObject = new Long(uid);
+ flagUpdateUids.add(uidObject);
+ }
+ } else if (messageEvent instanceof Expunged) {
final Long uidObject = new Long(uid);
- flagUpdateUids.add(uidObject);
+ expungedUids.add(uidObject);
}
- } else if (messageEvent instanceof Expunged) {
- final Long uidObject = new Long(uid);
- expungedUids.add(uidObject);
- }
- } else if (event instanceof MailboxDeletionEvent) {
- if (eventSessionId != sessionId) {
- isDeletedByOtherSession = true;
+ } else if (event instanceof MailboxDeletionEvent) {
+ if (eventSessionId != sessionId) {
+ isDeletedByOtherSession = true;
+ }
+ } else if (event instanceof MailboxRenamed) {
+ final MailboxRenamed mailboxRenamed = (MailboxRenamed) event;
+ setMailboxPath(mailboxRenamed.getNewPath());
}
- } else if (event instanceof MailboxRenamed) {
- final MailboxRenamed mailboxRenamed = (MailboxRenamed) event;
- setMailboxName(mailboxRenamed.getNewName());
- }
}
}
Modified: james/imap/trunk/processor/src/main/java/org/apache/james/imap/processor/base/SelectedMailboxImpl.java
URL: http://svn.apache.org/viewvc/james/imap/trunk/processor/src/main/java/org/apache/james/imap/processor/base/SelectedMailboxImpl.java?rev=965270&r1=965269&r2=965270&view=diff
==============================================================================
--- james/imap/trunk/processor/src/main/java/org/apache/james/imap/processor/base/SelectedMailboxImpl.java (original)
+++ james/imap/trunk/processor/src/main/java/org/apache/james/imap/processor/base/SelectedMailboxImpl.java Sun Jul 18 18:18:08 2010
@@ -25,6 +25,7 @@ import java.util.List;
import java.util.Set;
import java.util.TreeSet;
+import org.apache.james.imap.api.MailboxPath;
import org.apache.james.imap.api.process.SelectedMailbox;
import org.apache.james.imap.mailbox.MailboxException;
import org.apache.james.imap.mailbox.MailboxManager;
@@ -45,16 +46,16 @@ public class SelectedMailboxImpl impleme
private boolean recentUidRemoved;
public SelectedMailboxImpl(final MailboxManager mailboxManager, final List<Long> uids,
- final MailboxSession mailboxSession, final String name) throws MailboxException {
+ final MailboxSession mailboxSession, final MailboxPath path) throws MailboxException {
recentUids = new TreeSet<Long>();
recentUidRemoved = false;
final long sessionId = mailboxSession.getSessionId();
- events = new MailboxEventAnalyser(sessionId, name);
+ events = new MailboxEventAnalyser(sessionId, path);
// Ignore events from our session
events.setSilentFlagChanges(true);
- mailboxManager.addListener(name, events, mailboxSession);
+ mailboxManager.addListener(path, events, mailboxSession);
converter = new UidToMsnConverter(uids);
- mailboxManager.addListener(name, converter, mailboxSession);
+ mailboxManager.addListener(path, converter, mailboxSession);
}
/**
@@ -138,12 +139,11 @@ public class SelectedMailboxImpl impleme
return recentUids.size();
}
- /*
- * (non-Javadoc)
- * @see org.apache.james.imap.api.process.SelectedMailbox#getName()
+ /* (non-Javadoc)
+ * @see org.apache.james.imap.api.process.SelectedMailbox#getPath()
*/
- public String getName() {
- return events.getMailboxName();
+ public MailboxPath getPath() {
+ return events.getMailboxPath();
}
private void checkExpungedRecents() {
Modified: james/imap/trunk/processor/src/test/java/org/apache/james/imap/processor/LSubProcessorTest.java
URL: http://svn.apache.org/viewvc/james/imap/trunk/processor/src/test/java/org/apache/james/imap/processor/LSubProcessorTest.java?rev=965270&r1=965269&r2=965270&view=diff
==============================================================================
--- james/imap/trunk/processor/src/test/java/org/apache/james/imap/processor/LSubProcessorTest.java (original)
+++ james/imap/trunk/processor/src/test/java/org/apache/james/imap/processor/LSubProcessorTest.java Sun Jul 18 18:18:08 2010
@@ -21,6 +21,8 @@ package org.apache.james.imap.processor;
import java.util.ArrayList;
import java.util.Collection;
+import java.util.List;
+import java.util.Locale;
import org.apache.james.imap.api.ImapCommand;
import org.apache.james.imap.api.ImapConstants;
@@ -114,8 +116,7 @@ public class LSubProcessorTest {
subscriptions.add(MAILBOX_C);
mockery.checking(new Expectations() {{
oneOf(responder).respond(with(
- equal(new LSubResponse("",
- ImapConstants.HIERARCHY_DELIMITER, true))));
+ equal(new LSubResponse("", true))));
}});
expectOk();
@@ -136,11 +137,9 @@ public class LSubProcessorTest {
mockery.checking(new Expectations() {{
oneOf(responder).respond(with(
- equal(new LSubResponse(CHILD_ONE,
- ImapConstants.HIERARCHY_DELIMITER, false))));
+ equal(new LSubResponse(CHILD_ONE, false))));
oneOf(responder).respond(with(
- equal(new LSubResponse(CHILD_TWO,
- ImapConstants.HIERARCHY_DELIMITER, false))));
+ equal(new LSubResponse(CHILD_TWO, false))));
}});
expectSubscriptions();
@@ -163,7 +162,7 @@ public class LSubProcessorTest {
mockery.checking(new Expectations() {{
oneOf(responder).respond(with(
- equal(new LSubResponse(PARENT, ImapConstants.HIERARCHY_DELIMITER, true))));
+ equal(new LSubResponse(PARENT, true))));
}});
expectSubscriptions();
@@ -187,8 +186,7 @@ public class LSubProcessorTest {
mockery.checking(new Expectations() {{
oneOf(responder).respond(with(
- equal(new LSubResponse(PARENT, ImapConstants.HIERARCHY_DELIMITER,
- false))));
+ equal(new LSubResponse(PARENT, false))));
}});
expectSubscriptions();
@@ -204,13 +202,11 @@ public class LSubProcessorTest {
public void testSelectAll() throws Exception {
mockery.checking(new Expectations() {{
oneOf(responder).respond(with(equal(
- new LSubResponse(MAILBOX_A, ImapConstants.HIERARCHY_DELIMITER, false))));
+ new LSubResponse(MAILBOX_A, false))));
oneOf(responder).respond(with(equal(
- new LSubResponse(MAILBOX_B,
- ImapConstants.HIERARCHY_DELIMITER, false))));
+ new LSubResponse(MAILBOX_B, false))));
oneOf(responder).respond(with(equal(
- new LSubResponse(MAILBOX_C,
- ImapConstants.HIERARCHY_DELIMITER, false))));
+ new LSubResponse(MAILBOX_C, false))));
}});
subscriptions.add(MAILBOX_A);
subscriptions.add(MAILBOX_B);
@@ -239,6 +235,33 @@ public class LSubProcessorTest {
mockery.checking(new Expectations() {{
oneOf(session).getAttribute(ImapSessionUtils.MAILBOX_SESSION_ATTRIBUTE_SESSION_KEY);
will(returnValue(mailboxSession));
+ oneOf(mailboxSession).getUser(); will(returnValue(new MailboxSession.User() {
+
+ /*
+ * (non-Javadoc)
+ * @see org.apache.james.imap.mailbox.MailboxSession.User#getLocalePreferences()
+ */
+ public List<Locale> getLocalePreferences() {
+ return new ArrayList<Locale>();
+ }
+
+ /*
+ * (non-Javadoc)
+ * @see org.apache.james.imap.mailbox.MailboxSession.User#getPassword()
+ */
+ public String getPassword() {
+ return "test";
+ }
+
+ /*
+ * (non-Javadoc)
+ * @see org.apache.james.imap.mailbox.MailboxSession.User#getUserName()
+ */
+ public String getUserName() {
+ return "test";
+ }
+
+ }));
oneOf(manager).subscriptions(with(same(mailboxSession)));will(returnValue(subscriptions));
}});
}
Modified: james/imap/trunk/processor/src/test/java/org/apache/james/imap/processor/ListProcessorTest.java
URL: http://svn.apache.org/viewvc/james/imap/trunk/processor/src/test/java/org/apache/james/imap/processor/ListProcessorTest.java?rev=965270&r1=965269&r2=965270&view=diff
==============================================================================
--- james/imap/trunk/processor/src/test/java/org/apache/james/imap/processor/ListProcessorTest.java (original)
+++ james/imap/trunk/processor/src/test/java/org/apache/james/imap/processor/ListProcessorTest.java Sun Jul 18 18:18:08 2010
@@ -20,6 +20,7 @@
package org.apache.james.imap.processor;
import org.apache.james.imap.api.ImapCommand;
+import org.apache.james.imap.api.MailboxPath;
import org.apache.james.imap.api.message.response.StatusResponseFactory;
import org.apache.james.imap.api.process.ImapProcessor;
import org.apache.james.imap.api.process.ImapSession;
@@ -53,6 +54,8 @@ public class ListProcessorTest {
StatusResponseFactory serverResponseFactory;
+ MailboxPath inboxPath = new MailboxPath("", "", "INBOX");
+
private Mockery mockery = new JUnit4Mockery();
@Before
@@ -76,71 +79,70 @@ public class ListProcessorTest {
boolean marked, boolean unmarked, boolean hasChildren,
boolean hasNoChildren, String hierarchyDelimiter, String mailboxName) {
return new ListResponse(noinferior, noselect, marked, unmarked,
- hasChildren, hasNoChildren, hierarchyDelimiter, mailboxName);
+ hasChildren, hasNoChildren, mailboxName);
}
void setUpResult(final MailboxMetaData.Children children, final MailboxMetaData.Selectability selectability,
- final String hierarchyDelimiter, final String name) {
+ final String hierarchyDelimiter, final MailboxPath path) {
mockery.checking(new Expectations() {{
oneOf(result).inferiors();will(returnValue(children));
oneOf(result).getSelectability();will(returnValue(selectability));
oneOf(result).getHierarchyDelimiter();will(returnValue(hierarchyDelimiter));
- oneOf(result).getName();will(returnValue(name));
+ oneOf(result).getPath();will(returnValue(path));
}});
}
@Test
public void testHasChildren() throws Exception {
- setUpResult(MailboxMetaData.Children.HAS_CHILDREN, MailboxMetaData.Selectability.NONE, ".", "#INBOX");
+ setUpResult(MailboxMetaData.Children.HAS_CHILDREN, MailboxMetaData.Selectability.NONE, ".", inboxPath);
mockery.checking(new Expectations() {{
- oneOf(responder).respond(with(equal(createResponse(false, false, false, false, true, false, ".", "#INBOX"))));
+ oneOf(responder).respond(with(equal(createResponse(false, false, false, false, true, false, ".", "INBOX"))));
}});
- processor.processResult(responder, false, 0, result);
+ processor.processResult(responder, false, result);
}
@Test
public void testHasNoChildren() throws Exception {
- setUpResult(MailboxMetaData.Children.HAS_NO_CHILDREN, MailboxMetaData.Selectability.NONE, ".", "#INBOX");
+ setUpResult(MailboxMetaData.Children.HAS_NO_CHILDREN, MailboxMetaData.Selectability.NONE, ".", inboxPath);
mockery.checking(new Expectations() {{
- oneOf(responder).respond(with(equal(createResponse(false, false, false, false, false, true, ".", "#INBOX"))));
+ oneOf(responder).respond(with(equal(createResponse(false, false, false, false, false, true, ".", "INBOX"))));
}});
- processor.processResult(responder, false, 0, result);
+ processor.processResult(responder, false, result);
}
@Test
public void testNoInferiors() throws Exception {
- setUpResult(MailboxMetaData.Children.NO_INFERIORS, MailboxMetaData.Selectability.NONE, ".", "#INBOX");
+ setUpResult(MailboxMetaData.Children.NO_INFERIORS, MailboxMetaData.Selectability.NONE, ".", inboxPath);
mockery.checking(new Expectations() {{
- oneOf(responder).respond(with(equal(createResponse(true, false, false, false, false, false, ".", "#INBOX"))));
+ oneOf(responder).respond(with(equal(createResponse(true, false, false, false, false, false, ".", "INBOX"))));
}});
- processor.processResult(responder, false, 0, result);
+ processor.processResult(responder, false, result);
}
@Test
public void testNoSelect() throws Exception {
- setUpResult(MailboxMetaData.Children.CHILDREN_ALLOWED_BUT_UNKNOWN, MailboxMetaData.Selectability.NOSELECT, ".", "#INBOX");
+ setUpResult(MailboxMetaData.Children.CHILDREN_ALLOWED_BUT_UNKNOWN, MailboxMetaData.Selectability.NOSELECT, ".", inboxPath);
mockery.checking(new Expectations() {{
- oneOf(responder).respond(with(equal(createResponse(false, true, false, false, false, false, ".", "#INBOX"))));
+ oneOf(responder).respond(with(equal(createResponse(false, true, false, false, false, false, ".", "INBOX"))));
}});
- processor.processResult(responder, false, 0, result);
+ processor.processResult(responder, false, result);
}
@Test
public void testUnMarked() throws Exception {
- setUpResult(MailboxMetaData.Children.CHILDREN_ALLOWED_BUT_UNKNOWN, MailboxMetaData.Selectability.UNMARKED, ".",
- "#INBOX");
+ setUpResult(MailboxMetaData.Children.CHILDREN_ALLOWED_BUT_UNKNOWN, MailboxMetaData.Selectability.UNMARKED, ".", inboxPath);
mockery.checking(new Expectations() {{
- oneOf(responder).respond(with(equal(createResponse(false, false, false, true, false, false, ".", "#INBOX"))));
+ oneOf(responder).respond(with(equal(createResponse(false, false, false, true, false, false, ".", "INBOX"))));
}});
- processor.processResult(responder, false, 0, result);
+ processor.processResult(responder, false, result);
}
@Test
public void testMarked() throws Exception {
- setUpResult(MailboxMetaData.Children.CHILDREN_ALLOWED_BUT_UNKNOWN, MailboxMetaData.Selectability.MARKED, ".", "#INBOX");
+ setUpResult(MailboxMetaData.Children.CHILDREN_ALLOWED_BUT_UNKNOWN, MailboxMetaData.Selectability.MARKED, ".", inboxPath);
mockery.checking(new Expectations() {{
- oneOf(responder).respond(with(equal(createResponse(false, false, true, false, false, false, ".", "#INBOX"))));
+ oneOf(responder).respond(with(equal(createResponse(false, false, true, false, false, false, ".", "INBOX"))));
}});
- processor.processResult(responder, false, 0, result);
+ processor.processResult(responder, false, result);
}
}
Modified: james/imap/trunk/processor/src/test/java/org/apache/james/imap/processor/SearchProcessorTest.java
URL: http://svn.apache.org/viewvc/james/imap/trunk/processor/src/test/java/org/apache/james/imap/processor/SearchProcessorTest.java?rev=965270&r1=965269&r2=965270&view=diff
==============================================================================
--- james/imap/trunk/processor/src/test/java/org/apache/james/imap/processor/SearchProcessorTest.java (original)
+++ james/imap/trunk/processor/src/test/java/org/apache/james/imap/processor/SearchProcessorTest.java Sun Jul 18 18:18:08 2010
@@ -27,6 +27,7 @@ import javax.mail.Flags.Flag;
import org.apache.james.imap.api.ImapCommand;
import org.apache.james.imap.api.ImapConstants;
+import org.apache.james.imap.api.MailboxPath;
import org.apache.james.imap.api.display.HumanReadableText;
import org.apache.james.imap.api.message.IdRange;
import org.apache.james.imap.api.message.request.DayMonthYear;
@@ -81,6 +82,8 @@ public class SearchProcessorTest {
private static final SearchQuery.NumericRange[] RANGES = {
new SearchQuery.NumericRange(1),
new SearchQuery.NumericRange(42, 1048) };
+
+ private static final MailboxPath mailboxPath = new MailboxPath("namespace", "user", "name");
SearchProcessor processor;
@@ -194,13 +197,12 @@ public class SearchProcessorTest {
private void expectsGetSelectedMailbox() throws Exception {
mockery.checking(new Expectations() {{
- atMost(1).of(mailboxManager).resolve(with(equal("user")), with(equal("name")));will(returnValue("user"));
- atMost(1).of(mailboxManager).getMailbox(with(equal("user")), with(same(mailboxSession)));will(returnValue(mailbox));
- atMost(1).of(mailboxManager).getMailbox(with(equal("MailboxName")), with(same(mailboxSession)));will(returnValue(mailbox));
+ atMost(1).of(mailboxManager).getMailbox(with(equal(mailboxPath)), with(same(mailboxSession)));will(returnValue(mailbox));
+ atMost(1).of(mailboxManager).getMailbox(with(equal(mailboxPath)), with(same(mailboxSession)));will(returnValue(mailbox));
allowing(session).getSelected();will(returnValue(selectedMailbox));
atMost(1).of(selectedMailbox).isRecentUidRemoved();will(returnValue(false));
atLeast(1).of(selectedMailbox).isSizeChanged();will(returnValue(false));
- atLeast(1).of(selectedMailbox).getName();will(returnValue("MailboxName"));
+ atLeast(1).of(selectedMailbox).getPath();will(returnValue(mailboxPath));
atMost(1).of(selectedMailbox).flagUpdateUids();will(returnValue(Collections.EMPTY_LIST));
atMost(1).of(selectedMailbox).resetEvents();
oneOf(selectedMailbox).getRecent();will(returnValue(new ArrayList<Long>()));
Modified: james/imap/trunk/processor/src/test/java/org/apache/james/imap/processor/base/FakeMailboxListenerAdded.java
URL: http://svn.apache.org/viewvc/james/imap/trunk/processor/src/test/java/org/apache/james/imap/processor/base/FakeMailboxListenerAdded.java?rev=965270&r1=965269&r2=965270&view=diff
==============================================================================
--- james/imap/trunk/processor/src/test/java/org/apache/james/imap/processor/base/FakeMailboxListenerAdded.java (original)
+++ james/imap/trunk/processor/src/test/java/org/apache/james/imap/processor/base/FakeMailboxListenerAdded.java Sun Jul 18 18:18:08 2010
@@ -19,6 +19,7 @@
package org.apache.james.imap.processor.base;
+import org.apache.james.imap.api.MailboxPath;
import org.apache.james.imap.mailbox.MailboxListener;
public class FakeMailboxListenerAdded extends MailboxListener.Added {
@@ -27,8 +28,8 @@ public class FakeMailboxListenerAdded ex
public long sessionId;
- public FakeMailboxListenerAdded(long subjectUid, long sessionId, String name) {
- super(sessionId, name);
+ public FakeMailboxListenerAdded(long subjectUid, long sessionId, MailboxPath path) {
+ super(sessionId, path);
this.subjectUid = subjectUid;
}
Modified: james/imap/trunk/processor/src/test/java/org/apache/james/imap/processor/base/FakeMailboxListenerFlagsUpdate.java
URL: http://svn.apache.org/viewvc/james/imap/trunk/processor/src/test/java/org/apache/james/imap/processor/base/FakeMailboxListenerFlagsUpdate.java?rev=965270&r1=965269&r2=965270&view=diff
==============================================================================
--- james/imap/trunk/processor/src/test/java/org/apache/james/imap/processor/base/FakeMailboxListenerFlagsUpdate.java (original)
+++ james/imap/trunk/processor/src/test/java/org/apache/james/imap/processor/base/FakeMailboxListenerFlagsUpdate.java Sun Jul 18 18:18:08 2010
@@ -26,6 +26,7 @@ import java.util.List;
import javax.mail.Flags;
import javax.mail.Flags.Flag;
+import org.apache.james.imap.api.MailboxPath;
import org.apache.james.imap.mailbox.MailboxListener.FlagsUpdated;
public class FakeMailboxListenerFlagsUpdate extends FlagsUpdated {
@@ -37,8 +38,8 @@ public class FakeMailboxListenerFlagsUpd
public Flags newFlags;
public FakeMailboxListenerFlagsUpdate(long subjectUid, Flags newFlags,
- long sessionId, String name) {
- super(sessionId, name);
+ long sessionId, MailboxPath path) {
+ super(sessionId, path);
this.subjectUid = subjectUid;
this.newFlags = newFlags;
}
Modified: james/imap/trunk/processor/src/test/java/org/apache/james/imap/processor/base/MailboxEventAnalyserTest.java
URL: http://svn.apache.org/viewvc/james/imap/trunk/processor/src/test/java/org/apache/james/imap/processor/base/MailboxEventAnalyserTest.java?rev=965270&r1=965269&r2=965270&view=diff
==============================================================================
--- james/imap/trunk/processor/src/test/java/org/apache/james/imap/processor/base/MailboxEventAnalyserTest.java (original)
+++ james/imap/trunk/processor/src/test/java/org/apache/james/imap/processor/base/MailboxEventAnalyserTest.java Sun Jul 18 18:18:08 2010
@@ -28,6 +28,7 @@ import java.util.Iterator;
import javax.mail.Flags;
+import org.apache.james.imap.api.MailboxPath;
import org.apache.james.imap.mailbox.MailboxListener;
import org.junit.Before;
import org.junit.Test;
@@ -37,15 +38,15 @@ public class MailboxEventAnalyserTest {
private static final long BASE_SESSION_ID = 99;
private MailboxEventAnalyser analyser;
- private String name = "Mailbox Name";
+ MailboxPath mailboxPath = new MailboxPath("namespace", "user", "name");
@Before
public void setUp() throws Exception {
- analyser = new MailboxEventAnalyser(BASE_SESSION_ID, name);
+ analyser = new MailboxEventAnalyser(BASE_SESSION_ID, mailboxPath);
}
@Test
public void testShouldBeNoSizeChangeOnOtherEvent() throws Exception {
- final MailboxListener.Event event = new MailboxListener.Event(0, name) {};
+ final MailboxListener.Event event = new MailboxListener.Event(0, mailboxPath) {};
analyser.event(event);
assertFalse(analyser.isSizeChanged());
@@ -53,13 +54,13 @@ public class MailboxEventAnalyserTest {
@Test
public void testShouldBeNoSizeChangeOnAdded() throws Exception {
- analyser.event(new FakeMailboxListenerAdded(78, 11, name));
+ analyser.event(new FakeMailboxListenerAdded(78, 11, mailboxPath));
assertTrue(analyser.isSizeChanged());
}
@Test
public void testShouldNoSizeChangeAfterReset() throws Exception {
- analyser.event(new FakeMailboxListenerAdded(99, 11, name));
+ analyser.event(new FakeMailboxListenerAdded(99, 11, mailboxPath));
analyser.reset();
assertFalse(analyser.isSizeChanged());
}
@@ -67,7 +68,7 @@ public class MailboxEventAnalyserTest {
@Test
public void testShouldNotSetUidWhenNoSystemFlagChange() throws Exception {
final FakeMailboxListenerFlagsUpdate update = new FakeMailboxListenerFlagsUpdate(
- 90, new Flags(), 11, name);
+ 90, new Flags(), 11, mailboxPath);
analyser.event(update);
assertNotNull(analyser.flagUpdateUids());
assertFalse(analyser.flagUpdateUids().iterator().hasNext());
@@ -77,7 +78,7 @@ public class MailboxEventAnalyserTest {
public void testShouldSetUidWhenSystemFlagChange() throws Exception {
final long uid = 900L;
final FakeMailboxListenerFlagsUpdate update = new FakeMailboxListenerFlagsUpdate(
- uid, new Flags(), 11, name);
+ uid, new Flags(), 11, mailboxPath);
update.flags.add(Flags.Flag.ANSWERED);
analyser.event(update);
final Iterator<Long> iterator = analyser.flagUpdateUids().iterator();
@@ -91,7 +92,7 @@ public class MailboxEventAnalyserTest {
public void testShouldClearFlagUidsUponReset() throws Exception {
final long uid = 900L;
final FakeMailboxListenerFlagsUpdate update = new FakeMailboxListenerFlagsUpdate(
- uid, new Flags(), 11, name);
+ uid, new Flags(), 11, mailboxPath);
update.flags.add(Flags.Flag.ANSWERED);
analyser.event(update);
analyser.reset();
@@ -104,7 +105,7 @@ public class MailboxEventAnalyserTest {
throws Exception {
final long uid = 900L;
final FakeMailboxListenerFlagsUpdate update = new FakeMailboxListenerFlagsUpdate(
- uid, new Flags(), 11, name);
+ uid, new Flags(), 11, mailboxPath);
update.flags.add(Flags.Flag.ANSWERED);
analyser.setSilentFlagChanges(true);
analyser.event(update);
@@ -119,7 +120,7 @@ public class MailboxEventAnalyserTest {
public void testShouldNotSetUidWhenSystemFlagChangeSameSessionInSilentMode()
throws Exception {
final FakeMailboxListenerFlagsUpdate update = new FakeMailboxListenerFlagsUpdate(
- 345, new Flags(), BASE_SESSION_ID, name);
+ 345, new Flags(), BASE_SESSION_ID, mailboxPath);
update.flags.add(Flags.Flag.ANSWERED);
analyser.setSilentFlagChanges(true);
analyser.event(update);
@@ -131,7 +132,7 @@ public class MailboxEventAnalyserTest {
@Test
public void testShouldNotSetUidWhenOnlyRecentFlagUpdated() throws Exception {
final FakeMailboxListenerFlagsUpdate update = new FakeMailboxListenerFlagsUpdate(
- 886, new Flags(), BASE_SESSION_ID ,name);
+ 886, new Flags(), BASE_SESSION_ID ,mailboxPath);
update.flags.add(Flags.Flag.RECENT);
analyser.event(update);
final Iterator<Long> iterator = analyser.flagUpdateUids().iterator();
Modified: james/imap/trunk/seda/src/test/resources/org/apache/james/imap/scripts/ListNamespace.test
URL: http://svn.apache.org/viewvc/james/imap/trunk/seda/src/test/resources/org/apache/james/imap/scripts/ListNamespace.test?rev=965270&r1=965269&r2=965270&view=diff
==============================================================================
--- james/imap/trunk/seda/src/test/resources/org/apache/james/imap/scripts/ListNamespace.test (original)
+++ james/imap/trunk/seda/src/test/resources/org/apache/james/imap/scripts/ListNamespace.test Sun Jul 18 18:18:08 2010
@@ -29,11 +29,11 @@ S: \* LIST \(\\Noselect\) \"\.\" \"\"
S: e1 OK LIST completed.
# Rooted in users namespace
-C: e2 LIST "#mail" ""
-S: \* LIST \(\\Noselect\) \"\.\" \"\#mail\"
+C: e2 LIST "#private" ""
+S: \* LIST \(\\Noselect\) \"\.\" \"\#private\"
S: e2 OK LIST completed.
-C: e3 LIST "#mail.someone" ""
-S: \* LIST \(\\Noselect\) \"\.\" \"\#mail\"
+C: e3 LIST "#private.someone" ""
+S: \* LIST \(\\Noselect\) \"\.\" \"\#private\"
S: e3 OK LIST completed.
# Rooted in shared namespace
Modified: james/imap/trunk/store/src/main/java/org/apache/james/imap/store/DelegatingMailboxListener.java
URL: http://svn.apache.org/viewvc/james/imap/trunk/store/src/main/java/org/apache/james/imap/store/DelegatingMailboxListener.java?rev=965270&r1=965269&r2=965270&view=diff
==============================================================================
--- james/imap/trunk/store/src/main/java/org/apache/james/imap/store/DelegatingMailboxListener.java (original)
+++ james/imap/trunk/store/src/main/java/org/apache/james/imap/store/DelegatingMailboxListener.java Sun Jul 18 18:18:08 2010
@@ -20,10 +20,10 @@
package org.apache.james.imap.store;
import java.util.ArrayList;
-import java.util.HashMap;
import java.util.List;
-import java.util.Map;
+import org.apache.james.imap.api.MailboxPath;
+import org.apache.james.imap.api.MailboxPathHashMap;
import org.apache.james.imap.mailbox.MailboxListener;
/**
@@ -32,13 +32,13 @@ import org.apache.james.imap.mailbox.Mai
*/
public class DelegatingMailboxListener implements MailboxListener{
- private Map<String,List<MailboxListener>> listeners = new HashMap<String, List<MailboxListener>>();
+ private MailboxPathHashMap<List<MailboxListener>> listeners = new MailboxPathHashMap<List<MailboxListener>>();
- public synchronized void addListener(String name, MailboxListener listener) {
- List<MailboxListener> mListeners = listeners.get(name);
+ public synchronized void addListener(MailboxPath path, MailboxListener listener) {
+ List<MailboxListener> mListeners = listeners.get(path);
if (mListeners == null) {
mListeners = new ArrayList<MailboxListener>();
- listeners.put(name, mListeners);
+ listeners.put(path, mListeners);
}
if (mListeners.contains(listener) == false) {
mListeners.add(listener);
@@ -51,7 +51,7 @@ public class DelegatingMailboxListener i
* @see org.apache.james.imap.mailbox.MailboxListener#event(org.apache.james.imap.mailbox.MailboxListener.Event)
*/
public void event(Event event) {
- List<MailboxListener> mListeners = listeners.get(event.getMailboxName());
+ List<MailboxListener> mListeners = listeners.get(event.getMailboxPath());
if (mListeners != null && mListeners.isEmpty() == false) {
for (int i = 0; i < mListeners.size(); i++) {
MailboxListener l = mListeners.get(i);
Modified: james/imap/trunk/store/src/main/java/org/apache/james/imap/store/DelegatingMailboxManager.java
URL: http://svn.apache.org/viewvc/james/imap/trunk/store/src/main/java/org/apache/james/imap/store/DelegatingMailboxManager.java?rev=965270&r1=965269&r2=965270&view=diff
==============================================================================
--- james/imap/trunk/store/src/main/java/org/apache/james/imap/store/DelegatingMailboxManager.java (original)
+++ james/imap/trunk/store/src/main/java/org/apache/james/imap/store/DelegatingMailboxManager.java Sun Jul 18 18:18:08 2010
@@ -37,7 +37,7 @@ import org.apache.james.imap.mailbox.Sub
* Abstract {@link MailboxManager} which delegates various stuff to the {@link Authenticator} and {@link Subscriber}
*
*/
-public abstract class DelegatingMailboxManager extends AbstractLogEnabled implements MailboxManager{
+public abstract class DelegatingMailboxManager extends AbstractLogEnabled implements MailboxManager {
private final Authenticator authenticator;
private final Subscriber subscriper;
@@ -93,19 +93,6 @@ public abstract class DelegatingMailboxM
return MailboxConstants.DEFAULT_DELIMITER;
}
- /*
- * (non-Javadoc)
- * @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) != MailboxConstants.DEFAULT_DELIMITER) {
- mailboxPath = MailboxConstants.DEFAULT_DELIMITER + mailboxPath;
- }
- final String result = MailboxConstants.USER_NAMESPACE + MailboxConstants.DEFAULT_DELIMITER + userName
- + mailboxPath;
- return result;
- }
-
/**
* Log in the user with the given userid and password
*
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=965270&r1=965269&r2=965270&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 Sun Jul 18 18:18:08 2010
@@ -24,6 +24,7 @@ import java.util.Collections;
import java.util.List;
import org.apache.commons.logging.Log;
+import org.apache.james.imap.api.MailboxPath;
import org.apache.james.imap.mailbox.MailboxConstants;
import org.apache.james.imap.mailbox.MailboxException;
import org.apache.james.imap.mailbox.MailboxExistsException;
@@ -68,6 +69,7 @@ public abstract class StoreMailboxManage
this.consumer = consumer;
this.mailboxSessionMapperFactory = mailboxSessionMapperFactory;
}
+
/**
* Create a {@link StoreMessageManager} for the given Mailbox
*
@@ -82,36 +84,35 @@ public abstract class StoreMailboxManage
* @param namespaceName
* @throws MailboxException
*/
- protected abstract void doCreateMailbox(String namespaceName, MailboxSession session) throws MailboxException;
-
+ protected abstract void doCreateMailbox(MailboxPath mailboxPath, MailboxSession session) throws MailboxException;
/*
* (non-Javadoc)
- * @see org.apache.james.imap.mailbox.MailboxManager#getMailbox(java.lang.String, org.apache.james.imap.mailbox.MailboxSession)
+ * @see org.apache.james.imap.mailbox.MailboxManager#getMailbox(org.apache.james.imap.api.MailboxPath, org.apache.james.imap.mailbox.MailboxSession)
*/
- public org.apache.james.imap.mailbox.Mailbox getMailbox(String mailboxName, MailboxSession session)
+ public org.apache.james.imap.mailbox.Mailbox getMailbox(MailboxPath mailboxPath, MailboxSession session)
throws MailboxException {
- return doGetMailbox(mailboxName, session);
+ return doGetMailbox(mailboxPath, session);
}
/**
- * Get the Mailbox for the given name. If non is found a MailboxException will get thrown
+ * Get the Mailbox for the given name. If none is found a MailboxException will get thrown
*
- * @param mailboxName the name of the mailbox to return
+ * @param mailboxPath the name of the mailbox to return
* @return mailbox the mailbox for the given name
* @throws MailboxException get thrown if no Mailbox could be found for the given name
*/
- private StoreMessageManager<Id> doGetMailbox(String mailboxName, MailboxSession session) throws MailboxException {
+ private StoreMessageManager<Id> doGetMailbox(MailboxPath mailboxPath, MailboxSession session) throws MailboxException {
synchronized (mutex) {
final MailboxMapper<Id> mapper = mailboxSessionMapperFactory.getMailboxMapper(session);
- Mailbox<Id> mailboxRow = mapper.findMailboxByName(mailboxName);
+ Mailbox<Id> mailboxRow = mapper.findMailboxByPath(mailboxPath);
if (mailboxRow == null) {
- getLog().info("Mailbox '" + mailboxName + "' not found.");
- throw new MailboxNotFoundException(mailboxName);
+ getLog().info("Mailbox '" + mailboxPath + "' not found.");
+ throw new MailboxNotFoundException(mailboxPath);
} else {
- getLog().debug("Loaded mailbox " + mailboxName);
+ getLog().debug("Loaded mailbox " + mailboxPath);
StoreMessageManager<Id> result = createMessageManager(dispatcher, consumer, mailboxRow, session);
result.addListener(delegatingListener);
@@ -122,53 +123,38 @@ public abstract class StoreMailboxManage
/*
* (non-Javadoc)
- * @see org.apache.james.imap.mailbox.MailboxManager#createMailbox(java.lang.String, org.apache.james.imap.mailbox.MailboxSession)
+ * @see org.apache.james.imap.mailbox.MailboxManager#createMailbox(org.apache.james.imap.api.MailboxPath, org.apache.james.imap.mailbox.MailboxSession)
*/
- public void createMailbox(String namespaceName, MailboxSession mailboxSession)
+ public void createMailbox(MailboxPath mailboxPath, MailboxSession mailboxSession)
throws MailboxException {
- getLog().debug("createMailbox " + namespaceName);
- final int length = namespaceName.length();
+ getLog().debug("createMailbox " + mailboxPath);
+ final int length = mailboxPath.getName().length();
if (length == 0) {
getLog().warn("Ignoring mailbox with empty name");
- } else if (namespaceName.charAt(length - 1) == MailboxConstants.DEFAULT_DELIMITER) {
- createMailbox(namespaceName.substring(0, length - 1), mailboxSession);
- } else {
+ }
+ else {
+ if (mailboxPath.getName().charAt(length - 1) == MailboxConstants.DEFAULT_DELIMITER)
+ mailboxPath.setName(mailboxPath.getName().substring(0, length - 1));
+ if (mailboxExists(mailboxPath, mailboxSession))
+ throw new MailboxExistsException(mailboxPath.toString());
synchronized (mutex) {
- // Create root first
- // If any creation fails then mailbox will not be created
+ // Create parents first
+ // If any creation fails then the mailbox will not be created
// TODO: transaction
- int index = namespaceName.indexOf(MailboxConstants.DEFAULT_DELIMITER);
- int count = 0;
- while (index >= 0) {
- // Until explicit namespace support is added,
- // this workaround prevents the namespaced elements being
- // created
- // TODO: add explicit support for namespaces
- if (index > 0 && count++ > 1) {
- final String mailbox = namespaceName
- .substring(0, index);
- if (!mailboxExists(mailbox, mailboxSession)) {
- doCreateMailbox(mailbox, mailboxSession);
- }
- }
- index = namespaceName.indexOf(MailboxConstants.DEFAULT_DELIMITER, ++index);
- }
- if (mailboxExists(namespaceName, mailboxSession)) {
- throw new MailboxExistsException(namespaceName);
- } else {
- doCreateMailbox(namespaceName, mailboxSession);
- }
+ for (MailboxPath mailbox : mailboxPath.getHierarchyLevels(MailboxConstants.DEFAULT_DELIMITER))
+ if (!mailboxExists(mailbox, mailboxSession))
+ doCreateMailbox(mailbox, mailboxSession);
}
}
}
/*
* (non-Javadoc)
- * @see org.apache.james.imap.mailbox.MailboxManager#deleteMailbox(java.lang.String, org.apache.james.imap.mailbox.MailboxSession)
+ * @see org.apache.james.imap.mailbox.MailboxManager#deleteMailbox(org.apache.james.imap.api.MailboxPath, org.apache.james.imap.mailbox.MailboxSession)
*/
- public void deleteMailbox(final String mailboxName, final MailboxSession session)
+ public void deleteMailbox(final MailboxPath mailboxPath, final MailboxSession session)
throws MailboxException {
- session.getLog().info("deleteMailbox " + mailboxName);
+ session.getLog().info("deleteMailbox " + mailboxPath);
synchronized (mutex) {
// TODO put this into a serilizable transaction
@@ -177,7 +163,7 @@ public abstract class StoreMailboxManage
mapper.execute(new TransactionalMapper.Transaction() {
public void run() throws MailboxException {
- Mailbox<Id> mailbox = mapper.findMailboxByName(mailboxName);
+ Mailbox<Id> mailbox = mapper.findMailboxByPath(mailboxPath);
if (mailbox == null) {
throw new MailboxNotFoundException("Mailbox not found");
}
@@ -186,21 +172,21 @@ public abstract class StoreMailboxManage
});
- dispatcher.mailboxDeleted(session.getSessionId(), mailboxName);
+ dispatcher.mailboxDeleted(session.getSessionId(), mailboxPath);
}
}
/*
* (non-Javadoc)
- * @see org.apache.james.imap.mailbox.MailboxManager#renameMailbox(java.lang.String, java.lang.String, org.apache.james.imap.mailbox.MailboxSession)
+ * @see org.apache.james.imap.mailbox.MailboxManager#renameMailbox(org.apache.james.imap.api.MailboxPath, org.apache.james.imap.api.MailboxPath, org.apache.james.imap.mailbox.MailboxSession)
*/
- public void renameMailbox(final String from, final String to, final MailboxSession session)
+ public void renameMailbox(final MailboxPath from, final MailboxPath to, final MailboxSession session)
throws MailboxException {
final Log log = getLog();
if (log.isDebugEnabled()) log.debug("renameMailbox " + from + " to " + to);
synchronized (mutex) {
if (mailboxExists(to, session)) {
- throw new MailboxExistsException(to);
+ throw new MailboxExistsException(to.toString());
}
final MailboxMapper<Id> mapper = mailboxSessionMapperFactory.getMailboxMapper(session);
@@ -208,25 +194,28 @@ public abstract class StoreMailboxManage
public void run() throws MailboxException {
// TODO put this into a serilizable transaction
- final Mailbox<Id> mailbox = mapper.findMailboxByName(from);
-
+ final Mailbox<Id> mailbox = mapper.findMailboxByPath(from);
if (mailbox == null) {
throw new MailboxNotFoundException(from);
}
- mailbox.setName(to);
+ mailbox.setNamespace(to.getNamespace());
+ mailbox.setuser(to.getUser());
+ mailbox.setName(to.getName());
mapper.save(mailbox);
changeMailboxName(from, to, session);
- // rename submailbox
- final List<Mailbox<Id>> subMailboxes = mapper.findMailboxWithNameLike(from + MailboxConstants.DEFAULT_DELIMITER + "%");
+ // rename submailboxes
+ MailboxPath children = new MailboxPath(MailboxConstants.USER_NAMESPACE, from.getUser(), from.getName() + MailboxConstants.DEFAULT_DELIMITER + "%");
+ final List<Mailbox<Id>> subMailboxes = mapper.findMailboxWithPathLike(children);
for (Mailbox<Id> sub:subMailboxes) {
final String subOriginalName = sub.getName();
- final String subNewName = to + subOriginalName.substring(from.length());
+ final String subNewName = to.getName() + subOriginalName.substring(from.getName().length());
sub.setName(subNewName);
mapper.save(sub);
- changeMailboxName(subOriginalName, subNewName, session);
+ changeMailboxName(new MailboxPath(children, subOriginalName),
+ new MailboxPath(children, subNewName), session);
if (log.isDebugEnabled()) log.debug("Rename mailbox sub-mailbox " + subOriginalName + " to "
+ subNewName);
@@ -243,20 +232,19 @@ public abstract class StoreMailboxManage
* @param from not null
* @param to not null
*/
- private void changeMailboxName(String from, String to, MailboxSession session) {
+ private void changeMailboxName(MailboxPath from, MailboxPath to, MailboxSession session) {
dispatcher.mailboxRenamed(from, to, session.getSessionId());
}
/*
* (non-Javadoc)
- * @see org.apache.james.imap.mailbox.MailboxManager#copyMessages(org.apache.james.imap.mailbox.MessageRange, java.lang.String, java.lang.String, org.apache.james.imap.mailbox.MailboxSession)
+ * @see org.apache.james.imap.mailbox.MailboxManager#copyMessages(org.apache.james.imap.mailbox.MessageRange, org.apache.james.imap.api.MailboxPath, org.apache.james.imap.api.MailboxPath, org.apache.james.imap.mailbox.MailboxSession)
*/
- public void copyMessages(MessageRange set, String from, String to,
- MailboxSession session) throws MailboxException {
+ public void copyMessages(MessageRange set, MailboxPath from, MailboxPath to, MailboxSession session)
+ throws MailboxException {
synchronized (mutex) {
-
- StoreMessageManager<Id> toMailbox = doGetMailbox(to, session);
- StoreMessageManager<Id> fromMailbox = doGetMailbox(from, session);
+ StoreMessageManager<Id> toMailbox = doGetMailbox(to, session);
+ StoreMessageManager<Id> fromMailbox = doGetMailbox(from, session);
fromMailbox.copyTo(set, toMailbox, session);
}
}
@@ -269,50 +257,50 @@ public abstract class StoreMailboxManage
throws MailboxException {
final char localWildcard = mailboxExpression.getLocalWildcard();
final char freeWildcard = mailboxExpression.getFreeWildcard();
- final String base = mailboxExpression.getBase();
+ final String baseName = mailboxExpression.getBase().getName();
final int baseLength;
- if (base == null) {
+ if (baseName == null) {
baseLength = 0;
} else {
- baseLength = base.length();
+ baseLength = baseName.length();
}
-
- final String search = mailboxExpression.getCombinedName(
- MailboxConstants.DEFAULT_DELIMITER).replace(freeWildcard, SQL_WILDCARD_CHAR)
- .replace(localWildcard, SQL_WILDCARD_CHAR);
+ final String combinedName = mailboxExpression.getCombinedName()
+ .replace(freeWildcard, SQL_WILDCARD_CHAR)
+ .replace(localWildcard, SQL_WILDCARD_CHAR);
+ final MailboxPath search = new MailboxPath(mailboxExpression.getBase(), combinedName);
final MailboxMapper<Id> mapper = mailboxSessionMapperFactory.getMailboxMapper(session);
- final List<Mailbox<Id>> mailboxes = mapper.findMailboxWithNameLike(search);
+ final List<Mailbox<Id>> mailboxes = mapper.findMailboxWithPathLike(search);
final List<MailboxMetaData> results = new ArrayList<MailboxMetaData>(mailboxes.size());
for (Mailbox<Id> mailbox: mailboxes) {
final String name = mailbox.getName();
- if (name.startsWith(base)) {
+ if (name.startsWith(baseName)) {
final String match = name.substring(baseLength);
- if (mailboxExpression.isExpressionMatch(match, MailboxConstants.DEFAULT_DELIMITER)) {
+ if (mailboxExpression.isExpressionMatch(match)) {
final MailboxMetaData.Children inferiors;
if (mapper.hasChildren(mailbox)) {
inferiors = MailboxMetaData.Children.HAS_CHILDREN;
} else {
inferiors = MailboxMetaData.Children.HAS_NO_CHILDREN;
}
- results.add(new SimpleMailboxMetaData(name, ".", inferiors, Selectability.NONE));
+ MailboxPath mailboxPath = new MailboxPath(mailbox.getNamespace(), mailbox.getUser(), name);
+ results.add(new SimpleMailboxMetaData(mailboxPath, MailboxConstants.DEFAULT_DELIMITER_STRING, inferiors, Selectability.NONE));
}
}
}
Collections.sort(results, new StandardMailboxMetaDataComparator());
return results;
-
}
/*
* (non-Javadoc)
- * @see org.apache.james.imap.mailbox.MailboxManager#mailboxExists(java.lang.String, org.apache.james.imap.mailbox.MailboxSession)
+ * @see org.apache.james.imap.mailbox.MailboxManager#mailboxExists(org.apache.james.imap.api.MailboxPath, org.apache.james.imap.mailbox.MailboxSession)
*/
- public boolean mailboxExists(String mailboxName, MailboxSession session) throws MailboxException {
+ public boolean mailboxExists(MailboxPath mailboxPath, MailboxSession session) throws MailboxException {
synchronized (mutex) {
try {
final MailboxMapper<Id> mapper = mailboxSessionMapperFactory.getMailboxMapper(session);
- mapper.findMailboxByName(mailboxName);
+ mapper.findMailboxByPath(mailboxPath);
return true;
}
catch (MailboxNotFoundException e) {
@@ -321,12 +309,13 @@ public abstract class StoreMailboxManage
}
}
+
/*
* (non-Javadoc)
- * @see org.apache.james.imap.mailbox.MailboxManager#addListener(java.lang.String, org.apache.james.imap.mailbox.MailboxListener, org.apache.james.imap.mailbox.MailboxSession)
+ * @see org.apache.james.imap.mailbox.MailboxManager#addListener(org.apache.james.imap.api.MailboxPath, org.apache.james.imap.mailbox.MailboxListener, org.apache.james.imap.mailbox.MailboxSession)
*/
- public void addListener(String mailboxName, MailboxListener listener, MailboxSession session) throws MailboxException {
- delegatingListener.addListener(mailboxName, listener);
+ public void addListener(MailboxPath path, MailboxListener listener, MailboxSession session) throws MailboxException {
+ delegatingListener.addListener(path, listener);
}
/**
Added: james/imap/trunk/store/src/main/java/org/apache/james/imap/store/StoreMailboxPath.java
URL: http://svn.apache.org/viewvc/james/imap/trunk/store/src/main/java/org/apache/james/imap/store/StoreMailboxPath.java?rev=965270&view=auto
==============================================================================
--- james/imap/trunk/store/src/main/java/org/apache/james/imap/store/StoreMailboxPath.java (added)
+++ james/imap/trunk/store/src/main/java/org/apache/james/imap/store/StoreMailboxPath.java Sun Jul 18 18:18:08 2010
@@ -0,0 +1,43 @@
+/****************************************************************
+ * 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.store;
+
+import org.apache.james.imap.api.MailboxPath;
+import org.apache.james.imap.store.mail.model.Mailbox;
+
+public class StoreMailboxPath<Id> extends MailboxPath {
+
+ public StoreMailboxPath(String namespace, String user, String name) {
+ super(namespace, user, name);
+ }
+
+ public StoreMailboxPath(MailboxPath mailboxPath) {
+ super(mailboxPath);
+ }
+
+ public StoreMailboxPath(MailboxPath mailboxPath, String name) {
+ super(mailboxPath, name);
+ }
+
+ public StoreMailboxPath(Mailbox<Id> mailbox) {
+ super(mailbox.getNamespace(), mailbox.getUser(), mailbox.getName());
+ }
+
+}
Modified: james/imap/trunk/store/src/main/java/org/apache/james/imap/store/StoreMessageManager.java
URL: http://svn.apache.org/viewvc/james/imap/trunk/store/src/main/java/org/apache/james/imap/store/StoreMessageManager.java?rev=965270&r1=965269&r2=965270&view=diff
==============================================================================
--- james/imap/trunk/store/src/main/java/org/apache/james/imap/store/StoreMessageManager.java (original)
+++ james/imap/trunk/store/src/main/java/org/apache/james/imap/store/StoreMessageManager.java Sun Jul 18 18:18:08 2010
@@ -273,7 +273,7 @@ public abstract class StoreMessageManage
}
});
- dispatcher.added(uid, mailboxSession.getSessionId(), getMailboxEntity().getName());
+ dispatcher.added(uid, mailboxSession.getSessionId(), new StoreMailboxPath<Id>(getMailboxEntity()));
return uid;
} catch (IOException e) {
e.printStackTrace();
@@ -475,7 +475,7 @@ public abstract class StoreMessageManage
Iterator<Long> uidIt = uids.iterator();
while(uidIt.hasNext()) {
- dispatcher.expunged(uidIt.next(), mailboxSession.getSessionId(), getMailboxEntity().getName());
+ dispatcher.expunged(uidIt.next(), mailboxSession.getSessionId(), new StoreMailboxPath<Id>(getMailboxEntity()));
}
return uids.iterator();
}
@@ -520,7 +520,7 @@ public abstract class StoreMessageManage
Iterator<Long> it = newFlagsByUid.keySet().iterator();
while (it.hasNext()) {
Long uid = it.next();
- dispatcher.flagsUpdated(uid, mailboxSession.getSessionId(), getMailboxEntity().getName(), originalFlagsByUid.get(uid), newFlagsByUid.get(uid));
+ dispatcher.flagsUpdated(uid, mailboxSession.getSessionId(), new StoreMailboxPath<Id>(getMailboxEntity()), originalFlagsByUid.get(uid), newFlagsByUid.get(uid));
}
return newFlagsByUid;
@@ -596,7 +596,7 @@ public abstract class StoreMessageManage
}
// Wait until commit before issuing events
for (MailboxMembership<Id> newMember:copiedRows) {
- dispatcher.added(newMember.getUid(), session.getSessionId(), getMailboxEntity().getName());
+ dispatcher.added(newMember.getUid(), session.getSessionId(), new StoreMailboxPath<Id>(getMailboxEntity()));
}
} catch (MessagingException e) {
throw new MailboxException(HumanReadableText.FAILURE_MAIL_PARSE, e);
Modified: james/imap/trunk/store/src/main/java/org/apache/james/imap/store/mail/MailboxMapper.java
URL: http://svn.apache.org/viewvc/james/imap/trunk/store/src/main/java/org/apache/james/imap/store/mail/MailboxMapper.java?rev=965270&r1=965269&r2=965270&view=diff
==============================================================================
--- james/imap/trunk/store/src/main/java/org/apache/james/imap/store/mail/MailboxMapper.java (original)
+++ james/imap/trunk/store/src/main/java/org/apache/james/imap/store/mail/MailboxMapper.java Sun Jul 18 18:18:08 2010
@@ -20,6 +20,7 @@ package org.apache.james.imap.store.mail
import java.util.List;
+import org.apache.james.imap.api.MailboxPath;
import org.apache.james.imap.mailbox.MailboxNotFoundException;
import org.apache.james.imap.mailbox.StorageException;
import org.apache.james.imap.store.mail.model.Mailbox;
@@ -63,7 +64,7 @@ public interface MailboxMapper<Id> exten
* @throws StorageException
* @throws MailboxNotFoundException
*/
- public abstract Mailbox<Id> findMailboxByName(String mailboxName)
+ public abstract Mailbox<Id> findMailboxByPath(MailboxPath mailboxName)
throws StorageException, MailboxNotFoundException;
/**
@@ -73,7 +74,7 @@ public interface MailboxMapper<Id> exten
* @return mailboxList
* @throws StorageException
*/
- public abstract List<Mailbox<Id>> findMailboxWithNameLike(String mailboxName)
+ public abstract List<Mailbox<Id>> findMailboxWithPathLike(MailboxPath mailboxPath)
throws StorageException;
/**
Modified: james/imap/trunk/store/src/main/java/org/apache/james/imap/store/mail/model/Mailbox.java
URL: http://svn.apache.org/viewvc/james/imap/trunk/store/src/main/java/org/apache/james/imap/store/mail/model/Mailbox.java?rev=965270&r1=965269&r2=965270&view=diff
==============================================================================
--- james/imap/trunk/store/src/main/java/org/apache/james/imap/store/mail/model/Mailbox.java (original)
+++ james/imap/trunk/store/src/main/java/org/apache/james/imap/store/mail/model/Mailbox.java Sun Jul 18 18:18:08 2010
@@ -41,6 +41,30 @@ public interface Mailbox<Id> {
public abstract Id getMailboxId();
/**
+ * Gets the current namespace for this mailbox.
+ * @return not null
+ */
+ public abstract String getNamespace();
+
+ /**
+ * Sets the current namespace for this mailbox.
+ * @param name not null
+ */
+ public abstract void setNamespace(String namespace);
+
+ /**
+ * Gets the current user for this mailbox.
+ * @return not null
+ */
+ public abstract String getUser();
+
+ /**
+ * Sets the current user for this mailbox.
+ * @param name not null
+ */
+ public abstract void setuser(String user);
+
+ /**
* Gets the current name for this mailbox.
* @return not null
*/
Modified: james/imap/trunk/torque/src/main/java/org/apache/james/mailboxmanager/torque/TorqueMailbox.java
URL: http://svn.apache.org/viewvc/james/imap/trunk/torque/src/main/java/org/apache/james/mailboxmanager/torque/TorqueMailbox.java?rev=965270&r1=965269&r2=965270&view=diff
==============================================================================
--- james/imap/trunk/torque/src/main/java/org/apache/james/mailboxmanager/torque/TorqueMailbox.java (original)
+++ james/imap/trunk/torque/src/main/java/org/apache/james/mailboxmanager/torque/TorqueMailbox.java Sun Jul 18 18:18:08 2010
@@ -44,9 +44,11 @@ import javax.mail.Flags;
import javax.mail.MessagingException;
import javax.mail.internet.MimeMessage;
+import org.apache.james.imap.api.MailboxPath;
import org.apache.james.imap.api.display.HumanReadableText;
import org.apache.james.imap.mailbox.LockException;
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.MailboxListener;
import org.apache.james.imap.mailbox.MailboxSession;
@@ -92,7 +94,7 @@ public class TorqueMailbox implements Ma
TorqueMailbox(final MailboxRow mailboxRow, final ReentrantReadWriteLock lock) {
this.searches = new MessageSearches();
this.mailboxRow = mailboxRow;
- this.tracker = new UidChangeTracker(mailboxRow.getLastUid(), mailboxRow.getName());
+ this.tracker = new UidChangeTracker(mailboxRow.getLastUid(), getMailboxPath(mailboxRow.getName()));
this.lock = lock;
}
@@ -805,10 +807,18 @@ public class TorqueMailbox implements Ma
}
public void reportRenamed(String from, MailboxRow mailboxRow) {
- tracker.reportRenamed(mailboxRow.getName());
+ tracker.reportRenamed(getMailboxPath(mailboxRow.getName()));
this.mailboxRow = mailboxRow;
}
+ public MailboxPath getMailboxPath(String name) {
+ String nameParts[] = name.split("\\" +MailboxConstants.DEFAULT_DELIMITER_STRING,3);
+ if (nameParts.length < 3) {
+ return new MailboxPath(nameParts[0], null, nameParts[1]);
+ }
+ return new MailboxPath(nameParts[0], nameParts[1], nameParts[2]);
+
+ }
/**
* @see org.apache.james.imap.mailbox.Mailbox#getMetaData(boolean, MailboxSession, org.apache.james.imap.mailbox.Mailbox.MetaData.FetchGroup)
*/
---------------------------------------------------------------------
To unsubscribe, e-mail: server-dev-unsubscribe@james.apache.org
For additional commands, e-mail: server-dev-help@james.apache.org