This is an automated email from the ASF dual-hosted git repository. btellier pushed a commit to branch master in repository https://gitbox.apache.org/repos/asf/james-project.git
commit df7294c9183da716ed54e7160751344934b6dc36 Author: Benoit Tellier <btell...@linagora.com> AuthorDate: Tue Apr 9 16:01:55 2019 +0700 JAMES-2731 ReadOnlyException should rely on MailboxPath::asString getFullName ommits the user part and thus makes debugging harder --- .../james/mailbox/exception/ReadOnlyException.java | 18 ++---------------- .../james/mailbox/store/StoreMessageManager.java | 14 +++++++------- .../transport/mailets/delivery/SimpleMailStore.java | 2 +- 3 files changed, 10 insertions(+), 24 deletions(-) diff --git a/mailbox/api/src/main/java/org/apache/james/mailbox/exception/ReadOnlyException.java b/mailbox/api/src/main/java/org/apache/james/mailbox/exception/ReadOnlyException.java index eb9ba00..debbfdb 100644 --- a/mailbox/api/src/main/java/org/apache/james/mailbox/exception/ReadOnlyException.java +++ b/mailbox/api/src/main/java/org/apache/james/mailbox/exception/ReadOnlyException.java @@ -23,26 +23,12 @@ import org.apache.james.mailbox.model.MailboxPath; /** * {@link MailboxException} which should get thrown if someone tries to modify a READ-ONLY Mailbox - * - * */ public class ReadOnlyException extends MailboxException { - - - /** - * - */ private static final long serialVersionUID = 5016914557908202113L; - - - public ReadOnlyException(MailboxPath path, char delimiter) { - super(path.getFullName(delimiter)); - } - - - public ReadOnlyException(MailboxPath path, char delimiter, Exception e) { - super(path.getFullName(delimiter), e); + public ReadOnlyException(MailboxPath path) { + super(path.asString()); } } diff --git a/mailbox/store/src/main/java/org/apache/james/mailbox/store/StoreMessageManager.java b/mailbox/store/src/main/java/org/apache/james/mailbox/store/StoreMessageManager.java index 9a1f078..40318dc 100644 --- a/mailbox/store/src/main/java/org/apache/james/mailbox/store/StoreMessageManager.java +++ b/mailbox/store/src/main/java/org/apache/james/mailbox/store/StoreMessageManager.java @@ -265,7 +265,7 @@ public class StoreMessageManager implements MessageManager { @Override public Iterator<MessageUid> expunge(MessageRange set, MailboxSession mailboxSession) throws MailboxException { if (!isWriteable(mailboxSession)) { - throw new ReadOnlyException(getMailboxPath(), mailboxSession.getPathDelimiter()); + throw new ReadOnlyException(getMailboxPath()); } List<MessageUid> uids = retrieveMessagesMarkedForDeletion(set, mailboxSession); @@ -329,7 +329,7 @@ public class StoreMessageManager implements MessageManager { File file = null; if (!isWriteable(mailboxSession)) { - throw new ReadOnlyException(getMailboxPath(), mailboxSession.getPathDelimiter()); + throw new ReadOnlyException(getMailboxPath()); } try { @@ -610,7 +610,7 @@ public class StoreMessageManager implements MessageManager { public Map<MessageUid, Flags> setFlags(final Flags flags, final FlagsUpdateMode flagsUpdateMode, final MessageRange set, MailboxSession mailboxSession) throws MailboxException { if (!isWriteable(mailboxSession)) { - throw new ReadOnlyException(getMailboxPath(), mailboxSession.getPathDelimiter()); + throw new ReadOnlyException(getMailboxPath()); } trimFlags(flags, mailboxSession); @@ -644,7 +644,7 @@ public class StoreMessageManager implements MessageManager { */ public List<MessageRange> copyTo(final MessageRange set, final StoreMessageManager toMailbox, final MailboxSession session) throws MailboxException { if (!toMailbox.isWriteable(session)) { - throw new ReadOnlyException(toMailbox.getMailboxPath(), session.getPathDelimiter()); + throw new ReadOnlyException(toMailbox.getMailboxPath()); } return locker.executeWithLock(session, toMailbox.getMailboxPath(), () -> { @@ -663,10 +663,10 @@ public class StoreMessageManager implements MessageManager { */ public List<MessageRange> moveTo(final MessageRange set, final StoreMessageManager toMailbox, final MailboxSession session) throws MailboxException { if (!isWriteable(session)) { - throw new ReadOnlyException(getMailboxPath(), session.getPathDelimiter()); + throw new ReadOnlyException(getMailboxPath()); } if (!toMailbox.isWriteable(session)) { - throw new ReadOnlyException(toMailbox.getMailboxPath(), session.getPathDelimiter()); + throw new ReadOnlyException(toMailbox.getMailboxPath()); } //TODO lock the from mailbox too, in a non-deadlocking manner - how? @@ -707,7 +707,7 @@ public class StoreMessageManager implements MessageManager { protected List<MessageUid> recent(final boolean reset, MailboxSession mailboxSession) throws MailboxException { if (reset) { if (!isWriteable(mailboxSession)) { - throw new ReadOnlyException(getMailboxPath(), mailboxSession.getPathDelimiter()); + throw new ReadOnlyException(getMailboxPath()); } } final MessageMapper messageMapper = mapperFactory.getMessageMapper(mailboxSession); diff --git a/server/mailet/mailets/src/main/java/org/apache/james/transport/mailets/delivery/SimpleMailStore.java b/server/mailet/mailets/src/main/java/org/apache/james/transport/mailets/delivery/SimpleMailStore.java index 15b2c09..12c62ff 100644 --- a/server/mailet/mailets/src/main/java/org/apache/james/transport/mailets/delivery/SimpleMailStore.java +++ b/server/mailet/mailets/src/main/java/org/apache/james/transport/mailets/delivery/SimpleMailStore.java @@ -112,7 +112,7 @@ public class SimpleMailStore implements MailStore { return usersRepository.getUser(recipient); } catch (UsersRepositoryException e) { LOGGER.warn("Unable to retrieve username for {}", recipient.asPrettyString(), e); - return recipient.toString(); + return recipient.asString(); } } } --------------------------------------------------------------------- To unsubscribe, e-mail: server-dev-unsubscr...@james.apache.org For additional commands, e-mail: server-dev-h...@james.apache.org