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 bt...@apache.org on 2016/03/04 13:38:01 UTC
[04/20] james-project git commit: IMAP-370 Solve inheritance bugg on
request handling
IMAP-370 Solve inheritance bugg on request handling
Project: http://git-wip-us.apache.org/repos/asf/james-project/repo
Commit: http://git-wip-us.apache.org/repos/asf/james-project/commit/792a87a0
Tree: http://git-wip-us.apache.org/repos/asf/james-project/tree/792a87a0
Diff: http://git-wip-us.apache.org/repos/asf/james-project/diff/792a87a0
Branch: refs/heads/master
Commit: 792a87a04872842060cd9054a86bb6de8987ca19
Parents: b06992f
Author: Benoit Tellier <bt...@linagora.com>
Authored: Wed Feb 24 13:31:53 2016 +0700
Committer: Benoit Tellier <bt...@linagora.com>
Committed: Fri Mar 4 19:35:19 2016 +0700
----------------------------------------------------------------------
.../AbstractMessageRangeCommandParser.java | 45 ++++++++
.../imap/decode/parser/CopyCommandParser.java | 26 +----
.../imap/decode/parser/MoveCommandParser.java | 5 +-
.../request/AbstractMessageRangeRequest.java | 49 ++++++++
.../james/imap/message/request/CopyRequest.java | 35 +-----
.../james/imap/message/request/MoveRequest.java | 5 +-
.../AbstractMessageRangeProcessor.java | 114 +++++++++++++++++++
.../james/imap/processor/CopyProcessor.java | 93 ++-------------
.../imap/processor/DefaultProcessorChain.java | 5 +-
.../james/imap/processor/MoveProcessor.java | 23 ++--
10 files changed, 245 insertions(+), 155 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/james-project/blob/792a87a0/protocols/imap/src/main/java/org/apache/james/imap/decode/parser/AbstractMessageRangeCommandParser.java
----------------------------------------------------------------------
diff --git a/protocols/imap/src/main/java/org/apache/james/imap/decode/parser/AbstractMessageRangeCommandParser.java b/protocols/imap/src/main/java/org/apache/james/imap/decode/parser/AbstractMessageRangeCommandParser.java
new file mode 100644
index 0000000..0a2f81b
--- /dev/null
+++ b/protocols/imap/src/main/java/org/apache/james/imap/decode/parser/AbstractMessageRangeCommandParser.java
@@ -0,0 +1,45 @@
+/****************************************************************
+ * 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.decode.parser;
+
+import org.apache.james.imap.api.ImapCommand;
+import org.apache.james.imap.api.ImapMessage;
+import org.apache.james.imap.api.message.IdRange;
+import org.apache.james.imap.api.process.ImapSession;
+import org.apache.james.imap.decode.ImapRequestLineReader;
+import org.apache.james.imap.message.request.AbstractMessageRangeRequest;
+import org.apache.james.protocols.imap.DecodingException;
+
+public abstract class AbstractMessageRangeCommandParser extends AbstractUidCommandParser {
+
+ public AbstractMessageRangeCommandParser(ImapCommand command) {
+ super(command);
+ }
+
+ protected ImapMessage decode(ImapCommand command, ImapRequestLineReader request, String tag, boolean useUids, ImapSession session) throws DecodingException {
+ IdRange[] idSet = request.parseIdRange(session);
+ String mailboxName = request.mailbox();
+ request.eol();
+ return createRequest(command, tag, useUids, idSet, mailboxName);
+ }
+
+ abstract protected AbstractMessageRangeRequest createRequest(ImapCommand command, String tag, boolean useUids, IdRange[] idSet, String mailboxName);
+
+}
http://git-wip-us.apache.org/repos/asf/james-project/blob/792a87a0/protocols/imap/src/main/java/org/apache/james/imap/decode/parser/CopyCommandParser.java
----------------------------------------------------------------------
diff --git a/protocols/imap/src/main/java/org/apache/james/imap/decode/parser/CopyCommandParser.java b/protocols/imap/src/main/java/org/apache/james/imap/decode/parser/CopyCommandParser.java
index 4abc0b4..0487839 100644
--- a/protocols/imap/src/main/java/org/apache/james/imap/decode/parser/CopyCommandParser.java
+++ b/protocols/imap/src/main/java/org/apache/james/imap/decode/parser/CopyCommandParser.java
@@ -30,31 +30,15 @@ import org.apache.james.protocols.imap.DecodingException;
/**
* Parse COPY commands
*/
-public class CopyCommandParser extends AbstractUidCommandParser {
+public class CopyCommandParser extends AbstractMessageRangeCommandParser {
public CopyCommandParser() {
- this(ImapCommand.selectedStateCommand(ImapConstants.COPY_COMMAND_NAME));
+ super(ImapCommand.selectedStateCommand(ImapConstants.COPY_COMMAND_NAME));
}
- protected CopyCommandParser(ImapCommand command) {
- super(command);
+ @Override
+ protected CopyRequest createRequest(ImapCommand command, String tag, boolean useUids, IdRange[] idSet, String mailboxName) {
+ return new CopyRequest(command, idSet, mailboxName, useUids, tag);
}
- /**
- * @see
- * org.apache.james.imap.decode.parser.AbstractUidCommandParser#decode(org.apache.james.imap.api.ImapCommand,
- * org.apache.james.imap.decode.ImapRequestLineReader, java.lang.String,
- * boolean, org.apache.james.imap.api.process.ImapSession)
- */
- protected ImapMessage decode(ImapCommand command, ImapRequestLineReader request, String tag, boolean useUids, ImapSession session) throws DecodingException {
- IdRange[] idSet = request.parseIdRange(session);
- String mailboxName = request.mailbox();
- request.eol();
- return createRequest(command, tag, useUids, idSet, mailboxName);
- }
-
- protected CopyRequest createRequest(ImapCommand command, String tag,
- boolean useUids, IdRange[] idSet, String mailboxName) {
- return new CopyRequest(command, idSet, mailboxName, useUids, tag);
-}
}
http://git-wip-us.apache.org/repos/asf/james-project/blob/792a87a0/protocols/imap/src/main/java/org/apache/james/imap/decode/parser/MoveCommandParser.java
----------------------------------------------------------------------
diff --git a/protocols/imap/src/main/java/org/apache/james/imap/decode/parser/MoveCommandParser.java b/protocols/imap/src/main/java/org/apache/james/imap/decode/parser/MoveCommandParser.java
index 63b984f..a30dfdc 100644
--- a/protocols/imap/src/main/java/org/apache/james/imap/decode/parser/MoveCommandParser.java
+++ b/protocols/imap/src/main/java/org/apache/james/imap/decode/parser/MoveCommandParser.java
@@ -8,12 +8,13 @@ import org.apache.james.imap.message.request.MoveRequest;
/**
* Parse MOVE commands
*/
-public class MoveCommandParser extends CopyCommandParser {
+public class MoveCommandParser extends AbstractMessageRangeCommandParser {
public MoveCommandParser() {
super(ImapCommand.selectedStateCommand(ImapConstants.MOVE_COMMAND_NAME));
}
-
+
+ @Override
protected MoveRequest createRequest(ImapCommand command, String tag,
boolean useUids, IdRange[] idSet, String mailboxName) {
return new MoveRequest(command, idSet, mailboxName, useUids, tag);
http://git-wip-us.apache.org/repos/asf/james-project/blob/792a87a0/protocols/imap/src/main/java/org/apache/james/imap/message/request/AbstractMessageRangeRequest.java
----------------------------------------------------------------------
diff --git a/protocols/imap/src/main/java/org/apache/james/imap/message/request/AbstractMessageRangeRequest.java b/protocols/imap/src/main/java/org/apache/james/imap/message/request/AbstractMessageRangeRequest.java
new file mode 100644
index 0000000..f9672a0
--- /dev/null
+++ b/protocols/imap/src/main/java/org/apache/james/imap/message/request/AbstractMessageRangeRequest.java
@@ -0,0 +1,49 @@
+/****************************************************************
+ * 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.message.request;
+
+import org.apache.james.imap.api.ImapCommand;
+import org.apache.james.imap.api.message.IdRange;
+
+public abstract class AbstractMessageRangeRequest extends AbstractImapRequest {
+
+ private final IdRange[] idSet;
+ private final String mailboxName;
+ private final boolean useUids;
+
+ public AbstractMessageRangeRequest(ImapCommand command, IdRange[] idSet, String mailboxName, boolean useUids, String tag) {
+ super(tag, command);
+ this.idSet = idSet;
+ this.mailboxName = mailboxName;
+ this.useUids = useUids;
+ }
+
+ public final IdRange[] getIdSet() {
+ return idSet;
+ }
+
+ public final String getMailboxName() {
+ return mailboxName;
+ }
+
+ public final boolean isUseUids() {
+ return useUids;
+ }
+}
http://git-wip-us.apache.org/repos/asf/james-project/blob/792a87a0/protocols/imap/src/main/java/org/apache/james/imap/message/request/CopyRequest.java
----------------------------------------------------------------------
diff --git a/protocols/imap/src/main/java/org/apache/james/imap/message/request/CopyRequest.java b/protocols/imap/src/main/java/org/apache/james/imap/message/request/CopyRequest.java
index 77f9077..8408a24 100644
--- a/protocols/imap/src/main/java/org/apache/james/imap/message/request/CopyRequest.java
+++ b/protocols/imap/src/main/java/org/apache/james/imap/message/request/CopyRequest.java
@@ -25,40 +25,9 @@ import org.apache.james.imap.api.message.request.ImapRequest;
/**
* {@link ImapRequest} which request the copy of messages
*/
-public class CopyRequest extends AbstractImapRequest {
-
- private final IdRange[] idSet;
-
- private final String mailboxName;
-
- private final boolean useUids;
+public class CopyRequest extends AbstractMessageRangeRequest {
public CopyRequest(ImapCommand command, IdRange[] idSet, String mailboxName, boolean useUids, String tag) {
- super(tag, command);
- this.idSet = idSet;
- this.mailboxName = mailboxName;
- this.useUids = useUids;
- }
-
- /**
- * Return an Array of {@link IdRange} to copy
- *
- * @return range
- */
- public final IdRange[] getIdSet() {
- return idSet;
- }
-
- /**
- * Return the name of the mailbox
- *
- * @return mailbox
- */
- public final String getMailboxName() {
- return mailboxName;
- }
-
- public final boolean isUseUids() {
- return useUids;
+ super(command, idSet, mailboxName, useUids, tag);
}
}
http://git-wip-us.apache.org/repos/asf/james-project/blob/792a87a0/protocols/imap/src/main/java/org/apache/james/imap/message/request/MoveRequest.java
----------------------------------------------------------------------
diff --git a/protocols/imap/src/main/java/org/apache/james/imap/message/request/MoveRequest.java b/protocols/imap/src/main/java/org/apache/james/imap/message/request/MoveRequest.java
index 9015ea0..270a7ca 100644
--- a/protocols/imap/src/main/java/org/apache/james/imap/message/request/MoveRequest.java
+++ b/protocols/imap/src/main/java/org/apache/james/imap/message/request/MoveRequest.java
@@ -26,10 +26,9 @@ import org.apache.james.imap.api.message.request.ImapRequest;
/**
* {@link ImapRequest} which request the move of messages
*/
-public class MoveRequest extends CopyRequest {
+public class MoveRequest extends AbstractMessageRangeRequest {
- public MoveRequest(ImapCommand command, IdRange[] idSet,
- String mailboxName, boolean useUids, String tag) {
+ public MoveRequest(ImapCommand command, IdRange[] idSet, String mailboxName, boolean useUids, String tag) {
super(command, idSet, mailboxName, useUids, tag);
}
http://git-wip-us.apache.org/repos/asf/james-project/blob/792a87a0/protocols/imap/src/main/java/org/apache/james/imap/processor/AbstractMessageRangeProcessor.java
----------------------------------------------------------------------
diff --git a/protocols/imap/src/main/java/org/apache/james/imap/processor/AbstractMessageRangeProcessor.java b/protocols/imap/src/main/java/org/apache/james/imap/processor/AbstractMessageRangeProcessor.java
new file mode 100644
index 0000000..a900afa
--- /dev/null
+++ b/protocols/imap/src/main/java/org/apache/james/imap/processor/AbstractMessageRangeProcessor.java
@@ -0,0 +1,114 @@
+/****************************************************************
+ * 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.processor;
+
+import java.util.ArrayList;
+import java.util.List;
+
+import org.apache.james.imap.api.ImapCommand;
+import org.apache.james.imap.api.ImapSessionUtils;
+import org.apache.james.imap.api.display.HumanReadableText;
+import org.apache.james.imap.api.message.IdRange;
+import org.apache.james.imap.api.message.response.StatusResponse;
+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;
+import org.apache.james.imap.api.process.SelectedMailbox;
+import org.apache.james.imap.message.request.AbstractMessageRangeRequest;
+import org.apache.james.mailbox.MailboxManager;
+import org.apache.james.mailbox.MailboxSession;
+import org.apache.james.mailbox.MessageManager;
+import org.apache.james.mailbox.exception.MailboxException;
+import org.apache.james.mailbox.exception.MessageRangeException;
+import org.apache.james.mailbox.model.MailboxPath;
+import org.apache.james.mailbox.model.MessageRange;
+
+public abstract class AbstractMessageRangeProcessor<M extends AbstractMessageRangeRequest> extends AbstractMailboxProcessor<M> {
+
+ public AbstractMessageRangeProcessor(Class<M> acceptableClass, ImapProcessor next, MailboxManager mailboxManager, StatusResponseFactory factory) {
+ super(acceptableClass, next, mailboxManager, factory);
+ }
+
+ abstract protected List<MessageRange> process(final MailboxPath targetMailbox,
+ final SelectedMailbox currentMailbox,
+ final MailboxSession mailboxSession,
+ final MailboxManager mailboxManager,
+ MessageRange messageSet) throws MailboxException;
+
+ abstract protected String getOperationName();
+
+ @Override
+ protected void doProcess(M request, ImapSession session, String tag, ImapCommand command, Responder responder) {
+ final MailboxPath targetMailbox = buildFullPath(session, request.getMailboxName());
+ final IdRange[] idSet = request.getIdSet();
+ final boolean useUids = request.isUseUids();
+ final SelectedMailbox currentMailbox = session.getSelected();
+ try {
+ final MailboxSession mailboxSession = ImapSessionUtils.getMailboxSession(session);
+ final MailboxManager mailboxManager = getMailboxManager();
+ final boolean mailboxExists = mailboxManager.mailboxExists(targetMailbox, mailboxSession);
+
+ if (!mailboxExists) {
+ no(command, tag, responder, HumanReadableText.FAILURE_NO_SUCH_MAILBOX, StatusResponse.ResponseCode.tryCreate());
+ } else {
+
+ final MessageManager mailbox = mailboxManager.getMailbox(targetMailbox, mailboxSession);
+
+ List<IdRange> resultRanges = new ArrayList<IdRange>();
+ for (IdRange range : idSet) {
+ MessageRange messageSet = messageRange(currentMailbox, range, useUids);
+ if (messageSet != null) {
+ List<MessageRange> processedUids = process(
+ targetMailbox, currentMailbox, mailboxSession,
+ mailboxManager, messageSet);
+ for (MessageRange mr : processedUids) {
+ // Set recent flag on copied message as this SHOULD be
+ // done.
+ // See RFC 3501 6.4.7. COPY Command
+ // See IMAP-287
+ //
+ // Disable this as this is now done directly in the scope of the copy operation.
+ // See MAILBOX-85
+ //mailbox.setFlags(new Flags(Flags.Flag.RECENT), true, false, mr, mailboxSession);
+ resultRanges.add(new IdRange(mr.getUidFrom(), mr.getUidTo()));
+ }
+ }
+ }
+ IdRange[] resultUids = IdRange.mergeRanges(resultRanges).toArray(new IdRange[0]);
+
+ // get folder UIDVALIDITY
+ Long uidValidity = mailbox.getMetaData(false, mailboxSession, MessageManager.MetaData.FetchGroup.NO_UNSEEN).getUidValidity();
+
+ unsolicitedResponses(session, responder, useUids);
+ okComplete(command, tag, StatusResponse.ResponseCode.copyUid(uidValidity, idSet, resultUids), responder);
+ }
+ } catch (MessageRangeException e) {
+ if (session.getLog().isDebugEnabled()) {
+ session.getLog().debug(getOperationName() + " failed from mailbox " + currentMailbox.getPath() + " to " + targetMailbox + " for invalid sequence-set " + idSet.toString(), e);
+ }
+ taggedBad(command, tag, responder, HumanReadableText.INVALID_MESSAGESET);
+ } catch (MailboxException e) {
+ if (session.getLog().isInfoEnabled()) {
+ session.getLog().info(getOperationName() + " failed from mailbox " + currentMailbox.getPath() + " to " + targetMailbox + " for sequence-set " + idSet.toString(), e);
+ }
+ no(command, tag, responder, HumanReadableText.GENERIC_FAILURE_DURING_PROCESSING);
+ }
+ }
+}
http://git-wip-us.apache.org/repos/asf/james-project/blob/792a87a0/protocols/imap/src/main/java/org/apache/james/imap/processor/CopyProcessor.java
----------------------------------------------------------------------
diff --git a/protocols/imap/src/main/java/org/apache/james/imap/processor/CopyProcessor.java b/protocols/imap/src/main/java/org/apache/james/imap/processor/CopyProcessor.java
index 2e71d42..f55a356 100644
--- a/protocols/imap/src/main/java/org/apache/james/imap/processor/CopyProcessor.java
+++ b/protocols/imap/src/main/java/org/apache/james/imap/processor/CopyProcessor.java
@@ -19,107 +19,34 @@
package org.apache.james.imap.processor;
-import java.util.ArrayList;
import java.util.List;
-import org.apache.james.imap.api.ImapCommand;
-import org.apache.james.imap.api.ImapSessionUtils;
-import org.apache.james.imap.api.display.HumanReadableText;
-import org.apache.james.imap.api.message.IdRange;
-import org.apache.james.imap.api.message.response.StatusResponse.ResponseCode;
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;
import org.apache.james.imap.api.process.SelectedMailbox;
import org.apache.james.imap.message.request.CopyRequest;
import org.apache.james.mailbox.MailboxManager;
import org.apache.james.mailbox.MailboxSession;
-import org.apache.james.mailbox.MessageManager;
-import org.apache.james.mailbox.MessageManager.MetaData.FetchGroup;
import org.apache.james.mailbox.exception.MailboxException;
-import org.apache.james.mailbox.exception.MessageRangeException;
import org.apache.james.mailbox.model.MailboxPath;
import org.apache.james.mailbox.model.MessageRange;
-public class CopyProcessor extends AbstractMailboxProcessor<CopyRequest> {
+public class CopyProcessor extends AbstractMessageRangeProcessor<CopyRequest> {
public CopyProcessor(ImapProcessor next, MailboxManager mailboxManager, StatusResponseFactory factory) {
- this(CopyRequest.class, next, mailboxManager, factory);
- }
-
- protected CopyProcessor(Class<? extends CopyRequest> acceptableClass, ImapProcessor next, MailboxManager mailboxManager, StatusResponseFactory factory) {
super(CopyRequest.class, next, mailboxManager, factory);
}
- /**
- * @see
- * org.apache.james.imap.processor.AbstractMailboxProcessor#doProcess(org.apache.james.imap.api.message.request.ImapRequest,
- * org.apache.james.imap.api.process.ImapSession, java.lang.String,
- * org.apache.james.imap.api.ImapCommand,
- * org.apache.james.imap.api.process.ImapProcessor.Responder)
- */
- protected void doProcess(CopyRequest request, ImapSession session, String tag, ImapCommand command, Responder responder) {
- final MailboxPath targetMailbox = buildFullPath(session, request.getMailboxName());
- final IdRange[] idSet = request.getIdSet();
- final boolean useUids = request.isUseUids();
- final SelectedMailbox currentMailbox = session.getSelected();
- try {
- final MailboxSession mailboxSession = ImapSessionUtils.getMailboxSession(session);
- final MailboxManager mailboxManager = getMailboxManager();
- final boolean mailboxExists = mailboxManager.mailboxExists(targetMailbox, mailboxSession);
-
- if (!mailboxExists) {
- no(command, tag, responder, HumanReadableText.FAILURE_NO_SUCH_MAILBOX, ResponseCode.tryCreate());
- } else {
-
- final MessageManager mailbox = mailboxManager.getMailbox(targetMailbox, mailboxSession);
-
- List<IdRange> resultRanges = new ArrayList<IdRange>();
- for (IdRange range : idSet) {
- MessageRange messageSet = messageRange(currentMailbox, range, useUids);
- if (messageSet != null) {
- List<MessageRange> processedUids = process(
- targetMailbox, currentMailbox, mailboxSession,
- mailboxManager, messageSet);
- for (MessageRange mr : processedUids) {
- // Set recent flag on copied message as this SHOULD be
- // done.
- // See RFC 3501 6.4.7. COPY Command
- // See IMAP-287
- //
- // Disable this as this is now done directly in the scope of the copy operation.
- // See MAILBOX-85
- //mailbox.setFlags(new Flags(Flags.Flag.RECENT), true, false, mr, mailboxSession);
- resultRanges.add(new IdRange(mr.getUidFrom(), mr.getUidTo()));
- }
- }
- }
- IdRange[] resultUids = IdRange.mergeRanges(resultRanges).toArray(new IdRange[0]);
-
- // get folder UIDVALIDITY
- Long uidValidity = mailbox.getMetaData(false, mailboxSession, FetchGroup.NO_UNSEEN).getUidValidity();
-
- unsolicitedResponses(session, responder, useUids);
- okComplete(command, tag, ResponseCode.copyUid(uidValidity, idSet, resultUids), responder);
- }
- } catch (MessageRangeException e) {
- if (session.getLog().isDebugEnabled()) {
- session.getLog().debug("Copy failed from mailbox " + currentMailbox.getPath() + " to " + targetMailbox + " for invalid sequence-set " + idSet.toString(), e);
- }
- taggedBad(command, tag, responder, HumanReadableText.INVALID_MESSAGESET);
- } catch (MailboxException e) {
- if (session.getLog().isInfoEnabled()) {
- session.getLog().info("Copy failed from mailbox " + currentMailbox.getPath() + " to " + targetMailbox + " for sequence-set " + idSet.toString(), e);
- }
- no(command, tag, responder, HumanReadableText.GENERIC_FAILURE_DURING_PROCESSING);
- }
+ @Override
+ protected String getOperationName() {
+ return "Copy";
}
- protected List<MessageRange> process(MailboxPath targetMailbox,
- final SelectedMailbox currentMailbox,
- final MailboxSession mailboxSession,
- final MailboxManager mailboxManager, MessageRange messageSet)
- throws MailboxException {
+ @Override
+ protected List<MessageRange> process(MailboxPath targetMailbox,
+ SelectedMailbox currentMailbox,
+ MailboxSession mailboxSession,
+ MailboxManager mailboxManager, MessageRange messageSet) throws MailboxException {
return mailboxManager.copyMessages(messageSet, currentMailbox.getPath(), targetMailbox, mailboxSession);
-}
+ }
}
http://git-wip-us.apache.org/repos/asf/james-project/blob/792a87a0/protocols/imap/src/main/java/org/apache/james/imap/processor/DefaultProcessorChain.java
----------------------------------------------------------------------
diff --git a/protocols/imap/src/main/java/org/apache/james/imap/processor/DefaultProcessorChain.java b/protocols/imap/src/main/java/org/apache/james/imap/processor/DefaultProcessorChain.java
index b47afcf..a3d655d 100644
--- a/protocols/imap/src/main/java/org/apache/james/imap/processor/DefaultProcessorChain.java
+++ b/protocols/imap/src/main/java/org/apache/james/imap/processor/DefaultProcessorChain.java
@@ -57,9 +57,8 @@ public class DefaultProcessorChain {
final UnsubscribeProcessor unsubscribeProcessor = new UnsubscribeProcessor(closeProcessor, mailboxManager, subscriptionManager, statusResponseFactory);
final SubscribeProcessor subscribeProcessor = new SubscribeProcessor(unsubscribeProcessor, mailboxManager, subscriptionManager, statusResponseFactory);
final CopyProcessor copyProcessor = new CopyProcessor(subscribeProcessor, mailboxManager, statusResponseFactory);
- // TODO Active the MoveProcess when IMAP-370 is solved
-// final MoveProcessor moveProcessor = new MoveProcessor(copyProcessor, mailboxManager, statusResponseFactory);
- final AuthenticateProcessor authenticateProcessor = new AuthenticateProcessor(copyProcessor, mailboxManager, statusResponseFactory);
+ final MoveProcessor moveProcessor = new MoveProcessor(copyProcessor, mailboxManager, statusResponseFactory);
+ final AuthenticateProcessor authenticateProcessor = new AuthenticateProcessor(moveProcessor, mailboxManager, statusResponseFactory);
final ExpungeProcessor expungeProcessor = new ExpungeProcessor(authenticateProcessor, mailboxManager, statusResponseFactory);
final ExamineProcessor examineProcessor = new ExamineProcessor(expungeProcessor, mailboxManager, statusResponseFactory);
final AppendProcessor appendProcessor = new AppendProcessor(examineProcessor, mailboxManager, statusResponseFactory);
http://git-wip-us.apache.org/repos/asf/james-project/blob/792a87a0/protocols/imap/src/main/java/org/apache/james/imap/processor/MoveProcessor.java
----------------------------------------------------------------------
diff --git a/protocols/imap/src/main/java/org/apache/james/imap/processor/MoveProcessor.java b/protocols/imap/src/main/java/org/apache/james/imap/processor/MoveProcessor.java
index 2666cc2..ca8e612 100644
--- a/protocols/imap/src/main/java/org/apache/james/imap/processor/MoveProcessor.java
+++ b/protocols/imap/src/main/java/org/apache/james/imap/processor/MoveProcessor.java
@@ -1,6 +1,5 @@
package org.apache.james.imap.processor;
-import java.util.Arrays;
import java.util.Collections;
import java.util.List;
@@ -16,23 +15,27 @@ import org.apache.james.mailbox.exception.MailboxException;
import org.apache.james.mailbox.model.MailboxPath;
import org.apache.james.mailbox.model.MessageRange;
-public class MoveProcessor extends CopyProcessor implements CapabilityImplementingProcessor {
+public class MoveProcessor extends AbstractMessageRangeProcessor<MoveRequest> implements CapabilityImplementingProcessor {
- private static final List<String> CAPS = Collections.unmodifiableList(Arrays.asList(ImapConstants.MOVE_COMMAND_NAME));
+ private static final List<String> CAPS = Collections.unmodifiableList(Collections.singletonList(ImapConstants.MOVE_COMMAND_NAME));
- public MoveProcessor(ImapProcessor next, MailboxManager mailboxManager,
- StatusResponseFactory factory) {
+ public MoveProcessor(ImapProcessor next, MailboxManager mailboxManager, StatusResponseFactory factory) {
super(MoveRequest.class, next, mailboxManager, factory);
}
- protected List<MessageRange> process(MailboxPath targetMailbox,
- final SelectedMailbox currentMailbox,
- final MailboxSession mailboxSession,
- final MailboxManager mailboxManager, MessageRange messageSet)
- throws MailboxException {
+ @Override
+ protected List<MessageRange> process(MailboxPath targetMailbox,
+ SelectedMailbox currentMailbox,
+ MailboxSession mailboxSession,
+ MailboxManager mailboxManager, MessageRange messageSet) throws MailboxException {
return mailboxManager.moveMessages(messageSet, currentMailbox.getPath(), targetMailbox, mailboxSession);
}
+ @Override
+ protected String getOperationName() {
+ return "Move";
+ }
+
/**
* @see org.apache.james.imap.processor.CapabilityImplementingProcessor
* #getImplementedCapabilities(org.apache.james.imap.api.process.ImapSession)
---------------------------------------------------------------------
To unsubscribe, e-mail: server-dev-unsubscribe@james.apache.org
For additional commands, e-mail: server-dev-help@james.apache.org