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 rd...@apache.org on 2007/02/10 09:18:56 UTC
svn commit: r505653 [1/3] -
/james/server/sandbox/seda-imap/src/java/org/apache/james/imapserver/commands/
Author: rdonkin
Date: Sat Feb 10 00:18:54 2007
New Revision: 505653
URL: http://svn.apache.org/viewvc?view=rev&rev=505653
Log:
Moved message inner classes to top level.
Added:
james/server/sandbox/seda-imap/src/java/org/apache/james/imapserver/commands/AbstractImapCommandMessage.java
james/server/sandbox/seda-imap/src/java/org/apache/james/imapserver/commands/AppendCommandMessage.java
james/server/sandbox/seda-imap/src/java/org/apache/james/imapserver/commands/AuthenticateCommandMessage.java
james/server/sandbox/seda-imap/src/java/org/apache/james/imapserver/commands/BodyFetchElement.java
james/server/sandbox/seda-imap/src/java/org/apache/james/imapserver/commands/CapabilityCommandMessage.java
james/server/sandbox/seda-imap/src/java/org/apache/james/imapserver/commands/CapabilityReponseMessage.java
james/server/sandbox/seda-imap/src/java/org/apache/james/imapserver/commands/CloseCommandMessage.java
james/server/sandbox/seda-imap/src/java/org/apache/james/imapserver/commands/CompleteCommandMessage.java
james/server/sandbox/seda-imap/src/java/org/apache/james/imapserver/commands/CopyCommandMessage.java
james/server/sandbox/seda-imap/src/java/org/apache/james/imapserver/commands/CreateCommandMessage.java
james/server/sandbox/seda-imap/src/java/org/apache/james/imapserver/commands/DeleteCommandMessage.java
james/server/sandbox/seda-imap/src/java/org/apache/james/imapserver/commands/ExpungeCommandMessage.java
james/server/sandbox/seda-imap/src/java/org/apache/james/imapserver/commands/FetchCommandMessage.java
james/server/sandbox/seda-imap/src/java/org/apache/james/imapserver/commands/FetchRequest.java
james/server/sandbox/seda-imap/src/java/org/apache/james/imapserver/commands/FetchResponseMessage.java
james/server/sandbox/seda-imap/src/java/org/apache/james/imapserver/commands/ListCommandMessage.java
james/server/sandbox/seda-imap/src/java/org/apache/james/imapserver/commands/ListResponseMessage.java
james/server/sandbox/seda-imap/src/java/org/apache/james/imapserver/commands/LoginCommandMessage.java
james/server/sandbox/seda-imap/src/java/org/apache/james/imapserver/commands/LogoutResponseMessage.java
james/server/sandbox/seda-imap/src/java/org/apache/james/imapserver/commands/LsubListCommandMessage.java
james/server/sandbox/seda-imap/src/java/org/apache/james/imapserver/commands/RenameCommandMessage.java
james/server/sandbox/seda-imap/src/java/org/apache/james/imapserver/commands/SearchImapCommand.java
james/server/sandbox/seda-imap/src/java/org/apache/james/imapserver/commands/SearchResponseMessage.java
james/server/sandbox/seda-imap/src/java/org/apache/james/imapserver/commands/SelectCommandMessage.java
james/server/sandbox/seda-imap/src/java/org/apache/james/imapserver/commands/SelectResponseMessage.java
james/server/sandbox/seda-imap/src/java/org/apache/james/imapserver/commands/StatusCommandMessage.java
james/server/sandbox/seda-imap/src/java/org/apache/james/imapserver/commands/StatusDataItems.java
james/server/sandbox/seda-imap/src/java/org/apache/james/imapserver/commands/StatusResponseMessage.java
james/server/sandbox/seda-imap/src/java/org/apache/james/imapserver/commands/StoreCommandMessage.java
james/server/sandbox/seda-imap/src/java/org/apache/james/imapserver/commands/StoreDirective.java
james/server/sandbox/seda-imap/src/java/org/apache/james/imapserver/commands/StoreResponseMessage.java
james/server/sandbox/seda-imap/src/java/org/apache/james/imapserver/commands/SubscribeCommandMessage.java
james/server/sandbox/seda-imap/src/java/org/apache/james/imapserver/commands/UnsubscribeCommandMessage.java
Modified:
james/server/sandbox/seda-imap/src/java/org/apache/james/imapserver/commands/AppendCommand.java
james/server/sandbox/seda-imap/src/java/org/apache/james/imapserver/commands/AuthenticateCommand.java
james/server/sandbox/seda-imap/src/java/org/apache/james/imapserver/commands/CapabilityCommand.java
james/server/sandbox/seda-imap/src/java/org/apache/james/imapserver/commands/CloseCommand.java
james/server/sandbox/seda-imap/src/java/org/apache/james/imapserver/commands/CommandTemplate.java
james/server/sandbox/seda-imap/src/java/org/apache/james/imapserver/commands/CopyCommand.java
james/server/sandbox/seda-imap/src/java/org/apache/james/imapserver/commands/CreateCommand.java
james/server/sandbox/seda-imap/src/java/org/apache/james/imapserver/commands/DeleteCommand.java
james/server/sandbox/seda-imap/src/java/org/apache/james/imapserver/commands/ExpungeCommand.java
james/server/sandbox/seda-imap/src/java/org/apache/james/imapserver/commands/FetchCommand.java
james/server/sandbox/seda-imap/src/java/org/apache/james/imapserver/commands/ListCommand.java
james/server/sandbox/seda-imap/src/java/org/apache/james/imapserver/commands/LoginCommand.java
james/server/sandbox/seda-imap/src/java/org/apache/james/imapserver/commands/LogoutCommand.java
james/server/sandbox/seda-imap/src/java/org/apache/james/imapserver/commands/LsubCommand.java
james/server/sandbox/seda-imap/src/java/org/apache/james/imapserver/commands/RenameCommand.java
james/server/sandbox/seda-imap/src/java/org/apache/james/imapserver/commands/SearchCommand.java
james/server/sandbox/seda-imap/src/java/org/apache/james/imapserver/commands/SelectCommand.java
james/server/sandbox/seda-imap/src/java/org/apache/james/imapserver/commands/StatusCommand.java
james/server/sandbox/seda-imap/src/java/org/apache/james/imapserver/commands/StoreCommand.java
james/server/sandbox/seda-imap/src/java/org/apache/james/imapserver/commands/SubscribeCommand.java
james/server/sandbox/seda-imap/src/java/org/apache/james/imapserver/commands/UidEnabledCommand.java
james/server/sandbox/seda-imap/src/java/org/apache/james/imapserver/commands/UnsubscribeCommand.java
Added: james/server/sandbox/seda-imap/src/java/org/apache/james/imapserver/commands/AbstractImapCommandMessage.java
URL: http://svn.apache.org/viewvc/james/server/sandbox/seda-imap/src/java/org/apache/james/imapserver/commands/AbstractImapCommandMessage.java?view=auto&rev=505653
==============================================================================
--- james/server/sandbox/seda-imap/src/java/org/apache/james/imapserver/commands/AbstractImapCommandMessage.java (added)
+++ james/server/sandbox/seda-imap/src/java/org/apache/james/imapserver/commands/AbstractImapCommandMessage.java Sat Feb 10 00:18:54 2007
@@ -0,0 +1,81 @@
+/****************************************************************
+ * 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.imapserver.commands;
+
+import org.apache.avalon.framework.logger.AbstractLogEnabled;
+import org.apache.avalon.framework.logger.Logger;
+import org.apache.james.imapserver.AuthorizationException;
+import org.apache.james.imapserver.ImapSession;
+import org.apache.james.imapserver.ProtocolException;
+import org.apache.james.imapserver.store.MailboxException;
+
+abstract class AbstractImapCommandMessage extends AbstractLogEnabled implements ImapCommandMessage {
+ private final String tag;
+ private final ImapCommand command;
+
+ public AbstractImapCommandMessage(final String tag, final ImapCommand command) {
+ this.tag = tag;
+ this.command = command;
+ }
+ public ImapResponseMessage process(ImapSession session) {
+ ImapResponseMessage result;
+ final Logger logger = getLogger();
+ try {
+ result = doProcess(session);
+ }
+ catch ( MailboxException e ) {
+ if (logger != null) {
+ logger.debug("error processing command ", e);
+ }
+ result = new CommandFailedResponseMessage( command, e.getResponseCode(),
+ e.getMessage(), tag );
+ }
+ catch ( AuthorizationException e ) {
+ if (logger != null) {
+ logger.debug("error processing command ", e);
+ }
+ String msg = "Authorization error: Lacking permissions to perform requested operation.";
+ result = new CommandFailedResponseMessage( command, null,
+ msg, tag );
+ }
+ catch ( ProtocolException e ) {
+ if (logger != null) {
+ logger.debug("error processing command ", e);
+ }
+ String msg = e.getMessage() + " Command should be '" +
+ command.getExpectedMessage() + "'";
+ result = new ErrorResponseMessage( msg, tag );
+ }
+ return result;
+ }
+
+ final ImapResponseMessage doProcess(ImapSession session) throws MailboxException, AuthorizationException, ProtocolException {
+ ImapResponseMessage result;
+ if ( !command.validForState( session.getState() ) ) {
+ result =
+ new CommandFailedResponseMessage(command,
+ "Command not valid in this state", tag );
+ } else {
+ result = doProcess( session, tag, command );
+ }
+ return result;
+ }
+
+ protected abstract ImapResponseMessage doProcess(ImapSession session, String tag, ImapCommand command) throws MailboxException, AuthorizationException, ProtocolException;
+}
Modified: james/server/sandbox/seda-imap/src/java/org/apache/james/imapserver/commands/AppendCommand.java
URL: http://svn.apache.org/viewvc/james/server/sandbox/seda-imap/src/java/org/apache/james/imapserver/commands/AppendCommand.java?view=diff&rev=505653&r1=505652&r2=505653
==============================================================================
--- james/server/sandbox/seda-imap/src/java/org/apache/james/imapserver/commands/AppendCommand.java (original)
+++ james/server/sandbox/seda-imap/src/java/org/apache/james/imapserver/commands/AppendCommand.java Sat Feb 10 00:18:54 2007
@@ -29,11 +29,7 @@
import javax.mail.internet.MimeMessage;
import org.apache.james.imapserver.ImapRequestLineReader;
-import org.apache.james.imapserver.ImapSession;
import org.apache.james.imapserver.ProtocolException;
-import org.apache.james.imapserver.store.MailboxException;
-import org.apache.james.mailboxmanager.MailboxManagerException;
-import org.apache.james.mailboxmanager.mailbox.ImapMailboxSession;
/**
* Handles processeing for the APPEND imap command.
@@ -77,59 +73,6 @@
return ARGS;
}
- private static class AppendCommandMessage extends AbstractImapCommandMessage {
- private String mailboxName;
- private Flags flags;
- private Date datetime;
- private MimeMessage message;
-
- public AppendCommandMessage(ImapCommand command, String mailboxName, Flags flags,
- Date datetime, MimeMessage message, String tag) {
- super(tag, command);
- this.mailboxName = mailboxName;
- this.flags = flags;
- this.datetime = datetime;
- this.message = message;
- }
-
- public Date getDatetime() {
- return datetime;
- }
-
- public Flags getFlags() {
- return flags;
- }
-
- public String getMailboxName() {
- return mailboxName;
- }
-
- public MimeMessage getMessage() {
- return message;
- }
-
- public ImapResponseMessage doProcess( final ImapSession session, String tag, ImapCommand command ) throws MailboxException {
- ImapMailboxSession mailbox = null;
- try {
- mailboxName=session.buildFullName(mailboxName);
- mailbox = session.getMailboxManager().getImapMailboxSession(mailboxName);
- }
- catch ( MailboxManagerException mme ) {
- MailboxException me = new MailboxException(mme);
- me.setResponseCode( "TRYCREATE" );
- throw me;
- }
-
- try {
- mailbox.appendMessage( message, datetime ,0);
- } catch (MailboxManagerException e) {
- // TODO why not TRYCREATE?
- throw new MailboxException(e);
- }
- return new CommandCompleteResponseMessage(false, command, tag);
- }
- }
-
private class AppendCommandParser extends CommandParser
{
/**
Added: james/server/sandbox/seda-imap/src/java/org/apache/james/imapserver/commands/AppendCommandMessage.java
URL: http://svn.apache.org/viewvc/james/server/sandbox/seda-imap/src/java/org/apache/james/imapserver/commands/AppendCommandMessage.java?view=auto&rev=505653
==============================================================================
--- james/server/sandbox/seda-imap/src/java/org/apache/james/imapserver/commands/AppendCommandMessage.java (added)
+++ james/server/sandbox/seda-imap/src/java/org/apache/james/imapserver/commands/AppendCommandMessage.java Sat Feb 10 00:18:54 2007
@@ -0,0 +1,82 @@
+/****************************************************************
+ * 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.imapserver.commands;
+
+import java.util.Date;
+
+import javax.mail.Flags;
+import javax.mail.internet.MimeMessage;
+
+import org.apache.james.imapserver.ImapSession;
+import org.apache.james.imapserver.store.MailboxException;
+import org.apache.james.mailboxmanager.MailboxManagerException;
+import org.apache.james.mailboxmanager.mailbox.ImapMailboxSession;
+
+class AppendCommandMessage extends AbstractImapCommandMessage {
+ private String mailboxName;
+ private Flags flags;
+ private Date datetime;
+ private MimeMessage message;
+
+ public AppendCommandMessage(ImapCommand command, String mailboxName, Flags flags,
+ Date datetime, MimeMessage message, String tag) {
+ super(tag, command);
+ this.mailboxName = mailboxName;
+ this.flags = flags;
+ this.datetime = datetime;
+ this.message = message;
+ }
+
+ public Date getDatetime() {
+ return datetime;
+ }
+
+ public Flags getFlags() {
+ return flags;
+ }
+
+ public String getMailboxName() {
+ return mailboxName;
+ }
+
+ public MimeMessage getMessage() {
+ return message;
+ }
+
+ public ImapResponseMessage doProcess( final ImapSession session, String tag, ImapCommand command ) throws MailboxException {
+ ImapMailboxSession mailbox = null;
+ try {
+ mailboxName=session.buildFullName(mailboxName);
+ mailbox = session.getMailboxManager().getImapMailboxSession(mailboxName);
+ }
+ catch ( MailboxManagerException mme ) {
+ MailboxException me = new MailboxException(mme);
+ me.setResponseCode( "TRYCREATE" );
+ throw me;
+ }
+
+ try {
+ mailbox.appendMessage( message, datetime ,0);
+ } catch (MailboxManagerException e) {
+ // TODO why not TRYCREATE?
+ throw new MailboxException(e);
+ }
+ return new CommandCompleteResponseMessage(false, command, tag);
+ }
+}
Modified: james/server/sandbox/seda-imap/src/java/org/apache/james/imapserver/commands/AuthenticateCommand.java
URL: http://svn.apache.org/viewvc/james/server/sandbox/seda-imap/src/java/org/apache/james/imapserver/commands/AuthenticateCommand.java?view=diff&rev=505653&r1=505652&r2=505653
==============================================================================
--- james/server/sandbox/seda-imap/src/java/org/apache/james/imapserver/commands/AuthenticateCommand.java (original)
+++ james/server/sandbox/seda-imap/src/java/org/apache/james/imapserver/commands/AuthenticateCommand.java Sat Feb 10 00:18:54 2007
@@ -19,11 +19,8 @@
package org.apache.james.imapserver.commands;
-import org.apache.james.imapserver.AuthorizationException;
import org.apache.james.imapserver.ImapRequestLineReader;
-import org.apache.james.imapserver.ImapSession;
import org.apache.james.imapserver.ProtocolException;
-import org.apache.james.imapserver.store.MailboxException;
/**
* Handles processeing for the AUTHENTICATE imap command.
@@ -42,23 +39,6 @@
return result;
}
- private static class AuthenticateCommandMessage extends AbstractImapCommandMessage {
-
- private final String authType;
-
- public AuthenticateCommandMessage(final ImapCommand command, final String authType, final String tag) {
- super(tag, command);
- this.authType = authType;
- }
-
- protected ImapResponseMessage doProcess(ImapSession session, String tag, ImapCommand command) throws MailboxException, AuthorizationException, ProtocolException {
- final CommandFailedResponseMessage result = new CommandFailedResponseMessage(command,
- "Unsupported authentication mechanism '" + authType + "'", tag);
- return result;
- }
-
- }
-
/** @see ImapCommand#getName */
public String getName()
{
Added: james/server/sandbox/seda-imap/src/java/org/apache/james/imapserver/commands/AuthenticateCommandMessage.java
URL: http://svn.apache.org/viewvc/james/server/sandbox/seda-imap/src/java/org/apache/james/imapserver/commands/AuthenticateCommandMessage.java?view=auto&rev=505653
==============================================================================
--- james/server/sandbox/seda-imap/src/java/org/apache/james/imapserver/commands/AuthenticateCommandMessage.java (added)
+++ james/server/sandbox/seda-imap/src/java/org/apache/james/imapserver/commands/AuthenticateCommandMessage.java Sat Feb 10 00:18:54 2007
@@ -0,0 +1,41 @@
+/****************************************************************
+ * 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.imapserver.commands;
+
+import org.apache.james.imapserver.AuthorizationException;
+import org.apache.james.imapserver.ImapSession;
+import org.apache.james.imapserver.ProtocolException;
+import org.apache.james.imapserver.store.MailboxException;
+
+class AuthenticateCommandMessage extends AbstractImapCommandMessage {
+
+ private final String authType;
+
+ public AuthenticateCommandMessage(final ImapCommand command, final String authType, final String tag) {
+ super(tag, command);
+ this.authType = authType;
+ }
+
+ protected ImapResponseMessage doProcess(ImapSession session, String tag, ImapCommand command) throws MailboxException, AuthorizationException, ProtocolException {
+ final CommandFailedResponseMessage result = new CommandFailedResponseMessage(command,
+ "Unsupported authentication mechanism '" + authType + "'", tag);
+ return result;
+ }
+
+}
Added: james/server/sandbox/seda-imap/src/java/org/apache/james/imapserver/commands/BodyFetchElement.java
URL: http://svn.apache.org/viewvc/james/server/sandbox/seda-imap/src/java/org/apache/james/imapserver/commands/BodyFetchElement.java?view=auto&rev=505653
==============================================================================
--- james/server/sandbox/seda-imap/src/java/org/apache/james/imapserver/commands/BodyFetchElement.java (added)
+++ james/server/sandbox/seda-imap/src/java/org/apache/james/imapserver/commands/BodyFetchElement.java Sat Feb 10 00:18:54 2007
@@ -0,0 +1,40 @@
+/****************************************************************
+ * 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.imapserver.commands;
+
+class BodyFetchElement
+{
+ private String name;
+ private String sectionIdentifier;
+
+ public BodyFetchElement( String name, String sectionIdentifier)
+ {
+ this.name = name;
+ this.sectionIdentifier = sectionIdentifier;
+ }
+
+ public String getParameters()
+ {
+ return this.sectionIdentifier;
+ }
+
+ public String getResponseName() {
+ return this.name;
+ }
+}
Modified: james/server/sandbox/seda-imap/src/java/org/apache/james/imapserver/commands/CapabilityCommand.java
URL: http://svn.apache.org/viewvc/james/server/sandbox/seda-imap/src/java/org/apache/james/imapserver/commands/CapabilityCommand.java?view=diff&rev=505653&r1=505652&r2=505653
==============================================================================
--- james/server/sandbox/seda-imap/src/java/org/apache/james/imapserver/commands/CapabilityCommand.java (original)
+++ james/server/sandbox/seda-imap/src/java/org/apache/james/imapserver/commands/CapabilityCommand.java Sat Feb 10 00:18:54 2007
@@ -19,12 +19,8 @@
package org.apache.james.imapserver.commands;
-import org.apache.james.imapserver.AuthorizationException;
import org.apache.james.imapserver.ImapRequestLineReader;
-import org.apache.james.imapserver.ImapResponse;
-import org.apache.james.imapserver.ImapSession;
import org.apache.james.imapserver.ProtocolException;
-import org.apache.james.imapserver.store.MailboxException;
/**
* Handles processeing for the CAPABILITY imap command.
@@ -54,32 +50,6 @@
public String getArgSyntax()
{
return ARGS;
- }
-
- private static class CapabilityReponseMessage extends AbstractCommandResponseMessage {
-
- public CapabilityReponseMessage(ImapCommand command, String tag) {
- super(command, tag);
- }
-
- void doEncode(ImapResponse response, ImapSession session, ImapCommand command, String tag) throws MailboxException {
- response.untaggedResponse( CAPABILITY_RESPONSE );
- session.unsolicitedResponses( response, false);
- response.commandComplete( command , tag );
- }
-
- }
-
- private static class CapabilityCommandMessage extends AbstractImapCommandMessage {
-
- public CapabilityCommandMessage(final ImapCommand command, final String tag) {
- super(tag, command);
- }
-
- protected ImapResponseMessage doProcess(ImapSession session, String tag, ImapCommand command) throws MailboxException, AuthorizationException, ProtocolException {
- final CapabilityReponseMessage result = new CapabilityReponseMessage(command, tag);
- return result;
- }
}
}
Added: james/server/sandbox/seda-imap/src/java/org/apache/james/imapserver/commands/CapabilityCommandMessage.java
URL: http://svn.apache.org/viewvc/james/server/sandbox/seda-imap/src/java/org/apache/james/imapserver/commands/CapabilityCommandMessage.java?view=auto&rev=505653
==============================================================================
--- james/server/sandbox/seda-imap/src/java/org/apache/james/imapserver/commands/CapabilityCommandMessage.java (added)
+++ james/server/sandbox/seda-imap/src/java/org/apache/james/imapserver/commands/CapabilityCommandMessage.java Sat Feb 10 00:18:54 2007
@@ -0,0 +1,36 @@
+/****************************************************************
+ * 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.imapserver.commands;
+
+import org.apache.james.imapserver.AuthorizationException;
+import org.apache.james.imapserver.ImapSession;
+import org.apache.james.imapserver.ProtocolException;
+import org.apache.james.imapserver.store.MailboxException;
+
+class CapabilityCommandMessage extends AbstractImapCommandMessage {
+
+ public CapabilityCommandMessage(final ImapCommand command, final String tag) {
+ super(tag, command);
+ }
+
+ protected ImapResponseMessage doProcess(ImapSession session, String tag, ImapCommand command) throws MailboxException, AuthorizationException, ProtocolException {
+ final CapabilityReponseMessage result = new CapabilityReponseMessage(command, tag);
+ return result;
+ }
+}
Added: james/server/sandbox/seda-imap/src/java/org/apache/james/imapserver/commands/CapabilityReponseMessage.java
URL: http://svn.apache.org/viewvc/james/server/sandbox/seda-imap/src/java/org/apache/james/imapserver/commands/CapabilityReponseMessage.java?view=auto&rev=505653
==============================================================================
--- james/server/sandbox/seda-imap/src/java/org/apache/james/imapserver/commands/CapabilityReponseMessage.java (added)
+++ james/server/sandbox/seda-imap/src/java/org/apache/james/imapserver/commands/CapabilityReponseMessage.java Sat Feb 10 00:18:54 2007
@@ -0,0 +1,37 @@
+/****************************************************************
+ * 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.imapserver.commands;
+
+import org.apache.james.imapserver.ImapResponse;
+import org.apache.james.imapserver.ImapSession;
+import org.apache.james.imapserver.store.MailboxException;
+
+class CapabilityReponseMessage extends AbstractCommandResponseMessage {
+
+ public CapabilityReponseMessage(ImapCommand command, String tag) {
+ super(command, tag);
+ }
+
+ void doEncode(ImapResponse response, ImapSession session, ImapCommand command, String tag) throws MailboxException {
+ response.untaggedResponse( CapabilityCommand.CAPABILITY_RESPONSE );
+ session.unsolicitedResponses( response, false);
+ response.commandComplete( command , tag );
+ }
+
+}
Modified: james/server/sandbox/seda-imap/src/java/org/apache/james/imapserver/commands/CloseCommand.java
URL: http://svn.apache.org/viewvc/james/server/sandbox/seda-imap/src/java/org/apache/james/imapserver/commands/CloseCommand.java?view=diff&rev=505653&r1=505652&r2=505653
==============================================================================
--- james/server/sandbox/seda-imap/src/java/org/apache/james/imapserver/commands/CloseCommand.java (original)
+++ james/server/sandbox/seda-imap/src/java/org/apache/james/imapserver/commands/CloseCommand.java Sat Feb 10 00:18:54 2007
@@ -19,16 +19,11 @@
package org.apache.james.imapserver.commands;
-import org.apache.james.imapserver.AuthorizationException;
import org.apache.james.imapserver.ImapRequestLineReader;
import org.apache.james.imapserver.ImapResponse;
import org.apache.james.imapserver.ImapSession;
import org.apache.james.imapserver.ProtocolException;
import org.apache.james.imapserver.store.MailboxException;
-import org.apache.james.mailboxmanager.MailboxManagerException;
-import org.apache.james.mailboxmanager.MessageResult;
-import org.apache.james.mailboxmanager.impl.GeneralMessageSetImpl;
-import org.apache.james.mailboxmanager.mailbox.ImapMailboxSession;
/**
* Handles processeing for the CHECK imap command.
@@ -40,7 +35,7 @@
public static final String NAME = "CLOSE";
public static final String ARGS = null;
- private static class CloseResponseMessage extends AbstractCommandResponseMessage {
+ static class CloseResponseMessage extends AbstractCommandResponseMessage {
public CloseResponseMessage(ImapCommand command, String tag) {
super(command, tag);
}
@@ -52,27 +47,6 @@
// Don't send unsolicited responses on close.
session.unsolicitedResponses( response, false );
response.commandComplete( command , tag);
- }
- }
-
- private static class CloseCommandMessage extends AbstractImapCommandMessage {
-
- public CloseCommandMessage(final ImapCommand command, final String tag) {
- super(tag, command);
- }
-
- protected ImapResponseMessage doProcess(ImapSession session, String tag, ImapCommand command) throws MailboxException, AuthorizationException, ProtocolException {
- ImapMailboxSession mailbox = session.getSelected().getMailbox();
- if ( session.getSelected().getMailbox().isWriteable() ) {
- try {
- mailbox.expunge(GeneralMessageSetImpl.all(),MessageResult.NOTHING);
- } catch (MailboxManagerException e) {
- throw new MailboxException(e);
- }
- }
- session.deselect();
- final CloseResponseMessage result = new CloseResponseMessage(command, tag);
- return result;
}
}
Added: james/server/sandbox/seda-imap/src/java/org/apache/james/imapserver/commands/CloseCommandMessage.java
URL: http://svn.apache.org/viewvc/james/server/sandbox/seda-imap/src/java/org/apache/james/imapserver/commands/CloseCommandMessage.java?view=auto&rev=505653
==============================================================================
--- james/server/sandbox/seda-imap/src/java/org/apache/james/imapserver/commands/CloseCommandMessage.java (added)
+++ james/server/sandbox/seda-imap/src/java/org/apache/james/imapserver/commands/CloseCommandMessage.java Sat Feb 10 00:18:54 2007
@@ -0,0 +1,50 @@
+/****************************************************************
+ * 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.imapserver.commands;
+
+import org.apache.james.imapserver.AuthorizationException;
+import org.apache.james.imapserver.ImapSession;
+import org.apache.james.imapserver.ProtocolException;
+import org.apache.james.imapserver.commands.CloseCommand.CloseResponseMessage;
+import org.apache.james.imapserver.store.MailboxException;
+import org.apache.james.mailboxmanager.MailboxManagerException;
+import org.apache.james.mailboxmanager.MessageResult;
+import org.apache.james.mailboxmanager.impl.GeneralMessageSetImpl;
+import org.apache.james.mailboxmanager.mailbox.ImapMailboxSession;
+
+class CloseCommandMessage extends AbstractImapCommandMessage {
+
+ public CloseCommandMessage(final ImapCommand command, final String tag) {
+ super(tag, command);
+ }
+
+ protected ImapResponseMessage doProcess(ImapSession session, String tag, ImapCommand command) throws MailboxException, AuthorizationException, ProtocolException {
+ ImapMailboxSession mailbox = session.getSelected().getMailbox();
+ if ( session.getSelected().getMailbox().isWriteable() ) {
+ try {
+ mailbox.expunge(GeneralMessageSetImpl.all(),MessageResult.NOTHING);
+ } catch (MailboxManagerException e) {
+ throw new MailboxException(e);
+ }
+ }
+ session.deselect();
+ final CloseResponseMessage result = new CloseResponseMessage(command, tag);
+ return result;
+ }
+}
Modified: james/server/sandbox/seda-imap/src/java/org/apache/james/imapserver/commands/CommandTemplate.java
URL: http://svn.apache.org/viewvc/james/server/sandbox/seda-imap/src/java/org/apache/james/imapserver/commands/CommandTemplate.java?view=diff&rev=505653&r1=505652&r2=505653
==============================================================================
--- james/server/sandbox/seda-imap/src/java/org/apache/james/imapserver/commands/CommandTemplate.java (original)
+++ james/server/sandbox/seda-imap/src/java/org/apache/james/imapserver/commands/CommandTemplate.java Sat Feb 10 00:18:54 2007
@@ -90,19 +90,24 @@
* @param request <code>ImapRequestLineReader</code>, not null
* @return <code>ImapCommandMessage</code>, not null
*/
- public ImapCommandMessage parse( ImapRequestLineReader request, String tag ) {
- ImapCommandMessage message;
+ public final ImapCommandMessage parse( ImapRequestLineReader request, String tag ) {
+ ImapCommandMessage result;
try {
- message = decode(request, tag);
+ AbstractImapCommandMessage message = decode(request, tag);
+ final Logger logger = getLogger();
+ if (logger != null) {
+ message.enableLogging(logger);
+ }
+ result = message;
} catch ( ProtocolException e ) {
getLogger().debug("error processing command ", e);
String msg = e.getMessage() + " Command should be '" +
getExpectedMessage() + "'";
- message = new ErrorResponseMessage( msg, tag );
+ result = new ErrorResponseMessage( msg, tag );
}
- return message;
+ return result;
}
@@ -152,6 +157,10 @@
ImapSession session, String tag )
throws ProtocolException, MailboxException, AuthorizationException {
AbstractImapCommandMessage message = decode( request, tag );
+ final Logger logger = getLogger();
+ if (logger != null) {
+ message.enableLogging(logger);
+ }
ImapResponseMessage responseMessage = message.doProcess( session );
responseMessage.encode(response, session);
}
@@ -173,76 +182,5 @@
public CommandParser getParser()
{
return parser;
- }
-
- protected abstract static class AbstractImapCommandMessage extends AbstractLogEnabled implements ImapCommandMessage {
- private final String tag;
- private final ImapCommand command;
-
- public AbstractImapCommandMessage(final String tag, final ImapCommand command) {
- this.tag = tag;
- this.command = command;
- }
- public ImapResponseMessage process(ImapSession session) {
- ImapResponseMessage result;
- final Logger logger = getLogger();
- try {
- result = doProcess(session);
- }
- catch ( MailboxException e ) {
- if (logger != null) {
- logger.debug("error processing command ", e);
- }
- result = new CommandFailedResponseMessage( command, e.getResponseCode(),
- e.getMessage(), tag );
- }
- catch ( AuthorizationException e ) {
- if (logger != null) {
- logger.debug("error processing command ", e);
- }
- String msg = "Authorization error: Lacking permissions to perform requested operation.";
- result = new CommandFailedResponseMessage( command, null,
- msg, tag );
- }
- catch ( ProtocolException e ) {
- if (logger != null) {
- logger.debug("error processing command ", e);
- }
- String msg = e.getMessage() + " Command should be '" +
- command.getExpectedMessage() + "'";
- result = new ErrorResponseMessage( msg, tag );
- }
- return result;
- }
-
- final ImapResponseMessage doProcess(ImapSession session) throws MailboxException, AuthorizationException, ProtocolException {
- ImapResponseMessage result;
- if ( !command.validForState( session.getState() ) ) {
- result =
- new CommandFailedResponseMessage(command,
- "Command not valid in this state", tag );
- } else {
- result = doProcess( session, tag, command );
- }
- return result;
- }
-
- protected abstract ImapResponseMessage doProcess(ImapSession session, String tag, ImapCommand command) throws MailboxException, AuthorizationException, ProtocolException;
- }
-
- protected static class CompleteCommandMessage extends AbstractImapCommandMessage {
-
- private final boolean useUids;
-
- public CompleteCommandMessage(final ImapCommand command, final boolean useUids, final String tag) {
- super(tag, command);
- this.useUids = useUids;
- }
-
- protected ImapResponseMessage doProcess(ImapSession session, String tag, ImapCommand command) throws MailboxException, AuthorizationException, ProtocolException {
- final CommandCompleteResponseMessage result = new CommandCompleteResponseMessage(useUids, command, tag);
- return result;
- }
-
}
}
Added: james/server/sandbox/seda-imap/src/java/org/apache/james/imapserver/commands/CompleteCommandMessage.java
URL: http://svn.apache.org/viewvc/james/server/sandbox/seda-imap/src/java/org/apache/james/imapserver/commands/CompleteCommandMessage.java?view=auto&rev=505653
==============================================================================
--- james/server/sandbox/seda-imap/src/java/org/apache/james/imapserver/commands/CompleteCommandMessage.java (added)
+++ james/server/sandbox/seda-imap/src/java/org/apache/james/imapserver/commands/CompleteCommandMessage.java Sat Feb 10 00:18:54 2007
@@ -0,0 +1,40 @@
+/****************************************************************
+ * 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.imapserver.commands;
+
+import org.apache.james.imapserver.AuthorizationException;
+import org.apache.james.imapserver.ImapSession;
+import org.apache.james.imapserver.ProtocolException;
+import org.apache.james.imapserver.store.MailboxException;
+
+class CompleteCommandMessage extends AbstractImapCommandMessage {
+
+ private final boolean useUids;
+
+ public CompleteCommandMessage(final ImapCommand command, final boolean useUids, final String tag) {
+ super(tag, command);
+ this.useUids = useUids;
+ }
+
+ protected ImapResponseMessage doProcess(ImapSession session, String tag, ImapCommand command) throws MailboxException, AuthorizationException, ProtocolException {
+ final CommandCompleteResponseMessage result = new CommandCompleteResponseMessage(useUids, command, tag);
+ return result;
+ }
+
+}
Modified: james/server/sandbox/seda-imap/src/java/org/apache/james/imapserver/commands/CopyCommand.java
URL: http://svn.apache.org/viewvc/james/server/sandbox/seda-imap/src/java/org/apache/james/imapserver/commands/CopyCommand.java?view=diff&rev=505653&r1=505652&r2=505653
==============================================================================
--- james/server/sandbox/seda-imap/src/java/org/apache/james/imapserver/commands/CopyCommand.java (original)
+++ james/server/sandbox/seda-imap/src/java/org/apache/james/imapserver/commands/CopyCommand.java Sat Feb 10 00:18:54 2007
@@ -19,15 +19,8 @@
package org.apache.james.imapserver.commands;
-import org.apache.james.imapserver.AuthorizationException;
import org.apache.james.imapserver.ImapRequestLineReader;
-import org.apache.james.imapserver.ImapSession;
import org.apache.james.imapserver.ProtocolException;
-import org.apache.james.imapserver.store.MailboxException;
-import org.apache.james.mailboxmanager.GeneralMessageSet;
-import org.apache.james.mailboxmanager.MailboxManagerException;
-import org.apache.james.mailboxmanager.impl.GeneralMessageSetImpl;
-import org.apache.james.mailboxmanager.mailbox.ImapMailboxSession;
/**
* Handles processeing for the COPY imap command.
@@ -51,42 +44,6 @@
return ARGS;
}
- private static class CopyCommandMessage extends AbstractImapCommandMessage {
-
- private final IdRange[] idSet;
- private final String mailboxName;
- private final boolean useUids;
-
- public CopyCommandMessage(final ImapCommand command, final IdRange[] idSet, final String mailboxName,
- final boolean useUids, final String tag) {
- super(tag, command);
- this.idSet = idSet;
- this.mailboxName = mailboxName;
- this.useUids = useUids;
- }
-
- protected ImapResponseMessage doProcess(ImapSession session, String tag, ImapCommand command) throws MailboxException, AuthorizationException, ProtocolException {
- ImapMailboxSession currentMailbox = session.getSelected().getMailbox();
- try {
- String fullMailboxName = session.buildFullName(this.mailboxName);
- if (!session.getMailboxManager().existsMailbox(fullMailboxName)) {
- MailboxException e=new MailboxException("Mailbox does not exists");
- e.setResponseCode( "TRYCREATE" );
- throw e;
- }
- for (int i = 0; i < idSet.length; i++) {
- GeneralMessageSet messageSet=GeneralMessageSetImpl.range(idSet[i].getLowVal(),idSet[i].getHighVal(),useUids);
- session.getMailboxManager().copyMessages(currentMailbox,messageSet,fullMailboxName);
- }
- } catch (MailboxManagerException e) {
- throw new MailboxException(e);
- }
- final CommandCompleteResponseMessage result =
- new CommandCompleteResponseMessage(useUids, command, tag);
- return result;
- }
- }
-
protected AbstractImapCommandMessage decode(ImapRequestLineReader request, String tag) throws ProtocolException {
return decode(request, false, tag);
}
Added: james/server/sandbox/seda-imap/src/java/org/apache/james/imapserver/commands/CopyCommandMessage.java
URL: http://svn.apache.org/viewvc/james/server/sandbox/seda-imap/src/java/org/apache/james/imapserver/commands/CopyCommandMessage.java?view=auto&rev=505653
==============================================================================
--- james/server/sandbox/seda-imap/src/java/org/apache/james/imapserver/commands/CopyCommandMessage.java (added)
+++ james/server/sandbox/seda-imap/src/java/org/apache/james/imapserver/commands/CopyCommandMessage.java Sat Feb 10 00:18:54 2007
@@ -0,0 +1,64 @@
+/****************************************************************
+ * 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.imapserver.commands;
+
+import org.apache.james.imapserver.AuthorizationException;
+import org.apache.james.imapserver.ImapSession;
+import org.apache.james.imapserver.ProtocolException;
+import org.apache.james.imapserver.store.MailboxException;
+import org.apache.james.mailboxmanager.GeneralMessageSet;
+import org.apache.james.mailboxmanager.MailboxManagerException;
+import org.apache.james.mailboxmanager.impl.GeneralMessageSetImpl;
+import org.apache.james.mailboxmanager.mailbox.ImapMailboxSession;
+
+class CopyCommandMessage extends AbstractImapCommandMessage {
+
+ private final IdRange[] idSet;
+ private final String mailboxName;
+ private final boolean useUids;
+
+ public CopyCommandMessage(final ImapCommand command, final IdRange[] idSet, final String mailboxName,
+ final boolean useUids, final String tag) {
+ super(tag, command);
+ this.idSet = idSet;
+ this.mailboxName = mailboxName;
+ this.useUids = useUids;
+ }
+
+ protected ImapResponseMessage doProcess(ImapSession session, String tag, ImapCommand command) throws MailboxException, AuthorizationException, ProtocolException {
+ ImapMailboxSession currentMailbox = session.getSelected().getMailbox();
+ try {
+ String fullMailboxName = session.buildFullName(this.mailboxName);
+ if (!session.getMailboxManager().existsMailbox(fullMailboxName)) {
+ MailboxException e=new MailboxException("Mailbox does not exists");
+ e.setResponseCode( "TRYCREATE" );
+ throw e;
+ }
+ for (int i = 0; i < idSet.length; i++) {
+ GeneralMessageSet messageSet=GeneralMessageSetImpl.range(idSet[i].getLowVal(),idSet[i].getHighVal(),useUids);
+ session.getMailboxManager().copyMessages(currentMailbox,messageSet,fullMailboxName);
+ }
+ } catch (MailboxManagerException e) {
+ throw new MailboxException(e);
+ }
+ final CommandCompleteResponseMessage result =
+ new CommandCompleteResponseMessage(useUids, command, tag);
+ return result;
+ }
+}
Modified: james/server/sandbox/seda-imap/src/java/org/apache/james/imapserver/commands/CreateCommand.java
URL: http://svn.apache.org/viewvc/james/server/sandbox/seda-imap/src/java/org/apache/james/imapserver/commands/CreateCommand.java?view=diff&rev=505653&r1=505652&r2=505653
==============================================================================
--- james/server/sandbox/seda-imap/src/java/org/apache/james/imapserver/commands/CreateCommand.java (original)
+++ james/server/sandbox/seda-imap/src/java/org/apache/james/imapserver/commands/CreateCommand.java Sat Feb 10 00:18:54 2007
@@ -19,12 +19,8 @@
package org.apache.james.imapserver.commands;
-import org.apache.james.imapserver.AuthorizationException;
import org.apache.james.imapserver.ImapRequestLineReader;
-import org.apache.james.imapserver.ImapSession;
import org.apache.james.imapserver.ProtocolException;
-import org.apache.james.imapserver.store.MailboxException;
-import org.apache.james.mailboxmanager.MailboxManagerException;
/**
* Handles processeing for the CREATE imap command.
@@ -53,25 +49,6 @@
parser.endLine( request );
final CreateCommandMessage result = new CreateCommandMessage(this, mailboxName, tag);
return result;
- }
-
- private static class CreateCommandMessage extends AbstractImapCommandMessage {
- private final String mailboxName;
- public CreateCommandMessage(final ImapCommand command, final String mailboxName, final String tag) {
- super(tag, command);
- this.mailboxName = mailboxName;
- }
-
- protected ImapResponseMessage doProcess(ImapSession session, String tag, ImapCommand command) throws MailboxException, AuthorizationException, ProtocolException {
- try {
-
- final String fullMailboxName=session.buildFullName(this.mailboxName);
- session.getMailboxManager().createMailbox(fullMailboxName );
- } catch (MailboxManagerException e) {
- throw new MailboxException(e);
- }
- return new CommandCompleteResponseMessage(false, command, tag);
- }
}
}
Added: james/server/sandbox/seda-imap/src/java/org/apache/james/imapserver/commands/CreateCommandMessage.java
URL: http://svn.apache.org/viewvc/james/server/sandbox/seda-imap/src/java/org/apache/james/imapserver/commands/CreateCommandMessage.java?view=auto&rev=505653
==============================================================================
--- james/server/sandbox/seda-imap/src/java/org/apache/james/imapserver/commands/CreateCommandMessage.java (added)
+++ james/server/sandbox/seda-imap/src/java/org/apache/james/imapserver/commands/CreateCommandMessage.java Sat Feb 10 00:18:54 2007
@@ -0,0 +1,44 @@
+/****************************************************************
+ * 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.imapserver.commands;
+
+import org.apache.james.imapserver.AuthorizationException;
+import org.apache.james.imapserver.ImapSession;
+import org.apache.james.imapserver.ProtocolException;
+import org.apache.james.imapserver.store.MailboxException;
+import org.apache.james.mailboxmanager.MailboxManagerException;
+
+class CreateCommandMessage extends AbstractImapCommandMessage {
+ private final String mailboxName;
+ public CreateCommandMessage(final ImapCommand command, final String mailboxName, final String tag) {
+ super(tag, command);
+ this.mailboxName = mailboxName;
+ }
+
+ protected ImapResponseMessage doProcess(ImapSession session, String tag, ImapCommand command) throws MailboxException, AuthorizationException, ProtocolException {
+ try {
+
+ final String fullMailboxName=session.buildFullName(this.mailboxName);
+ session.getMailboxManager().createMailbox(fullMailboxName );
+ } catch (MailboxManagerException e) {
+ throw new MailboxException(e);
+ }
+ return new CommandCompleteResponseMessage(false, command, tag);
+ }
+}
Modified: james/server/sandbox/seda-imap/src/java/org/apache/james/imapserver/commands/DeleteCommand.java
URL: http://svn.apache.org/viewvc/james/server/sandbox/seda-imap/src/java/org/apache/james/imapserver/commands/DeleteCommand.java?view=diff&rev=505653&r1=505652&r2=505653
==============================================================================
--- james/server/sandbox/seda-imap/src/java/org/apache/james/imapserver/commands/DeleteCommand.java (original)
+++ james/server/sandbox/seda-imap/src/java/org/apache/james/imapserver/commands/DeleteCommand.java Sat Feb 10 00:18:54 2007
@@ -19,12 +19,8 @@
package org.apache.james.imapserver.commands;
-import org.apache.james.imapserver.AuthorizationException;
import org.apache.james.imapserver.ImapRequestLineReader;
-import org.apache.james.imapserver.ImapSession;
import org.apache.james.imapserver.ProtocolException;
-import org.apache.james.imapserver.store.MailboxException;
-import org.apache.james.mailboxmanager.MailboxManagerException;
/**
* Handles processeing for the DELETE imap command.
@@ -54,35 +50,6 @@
final DeleteCommandMessage result =
new DeleteCommandMessage( this, mailboxName, tag );
return result;
- }
-
- private static class DeleteCommandMessage extends AbstractImapCommandMessage {
- private final String mailboxName;
- public DeleteCommandMessage(final ImapCommand command, final String mailboxName, final String tag) {
- super(tag, command);
- this.mailboxName = mailboxName;
- }
-
- protected ImapResponseMessage doProcess(ImapSession session, String tag, ImapCommand command) throws MailboxException, AuthorizationException, ProtocolException {
- try {
- final String fullMailboxName = session.buildFullName(this.mailboxName);
- if (session.getSelected() != null) {
- if (session.getSelected().getMailbox().getName().equals(
- fullMailboxName)) {
- session.deselect();
- }
- }
- session.getMailboxManager().deleteMailbox(fullMailboxName);
- } catch (MailboxManagerException e) {
- throw new MailboxException(e);
- }
-
- final CommandCompleteResponseMessage result =
- new CommandCompleteResponseMessage(false, command, tag);
- return result;
- }
-
-
}
}
Added: james/server/sandbox/seda-imap/src/java/org/apache/james/imapserver/commands/DeleteCommandMessage.java
URL: http://svn.apache.org/viewvc/james/server/sandbox/seda-imap/src/java/org/apache/james/imapserver/commands/DeleteCommandMessage.java?view=auto&rev=505653
==============================================================================
--- james/server/sandbox/seda-imap/src/java/org/apache/james/imapserver/commands/DeleteCommandMessage.java (added)
+++ james/server/sandbox/seda-imap/src/java/org/apache/james/imapserver/commands/DeleteCommandMessage.java Sat Feb 10 00:18:54 2007
@@ -0,0 +1,54 @@
+/****************************************************************
+ * 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.imapserver.commands;
+
+import org.apache.james.imapserver.AuthorizationException;
+import org.apache.james.imapserver.ImapSession;
+import org.apache.james.imapserver.ProtocolException;
+import org.apache.james.imapserver.store.MailboxException;
+import org.apache.james.mailboxmanager.MailboxManagerException;
+
+class DeleteCommandMessage extends AbstractImapCommandMessage {
+ private final String mailboxName;
+ public DeleteCommandMessage(final ImapCommand command, final String mailboxName, final String tag) {
+ super(tag, command);
+ this.mailboxName = mailboxName;
+ }
+
+ protected ImapResponseMessage doProcess(ImapSession session, String tag, ImapCommand command) throws MailboxException, AuthorizationException, ProtocolException {
+ try {
+ final String fullMailboxName = session.buildFullName(this.mailboxName);
+ if (session.getSelected() != null) {
+ if (session.getSelected().getMailbox().getName().equals(
+ fullMailboxName)) {
+ session.deselect();
+ }
+ }
+ session.getMailboxManager().deleteMailbox(fullMailboxName);
+ } catch (MailboxManagerException e) {
+ throw new MailboxException(e);
+ }
+
+ final CommandCompleteResponseMessage result =
+ new CommandCompleteResponseMessage(false, command, tag);
+ return result;
+ }
+
+
+}
Modified: james/server/sandbox/seda-imap/src/java/org/apache/james/imapserver/commands/ExpungeCommand.java
URL: http://svn.apache.org/viewvc/james/server/sandbox/seda-imap/src/java/org/apache/james/imapserver/commands/ExpungeCommand.java?view=diff&rev=505653&r1=505652&r2=505653
==============================================================================
--- james/server/sandbox/seda-imap/src/java/org/apache/james/imapserver/commands/ExpungeCommand.java (original)
+++ james/server/sandbox/seda-imap/src/java/org/apache/james/imapserver/commands/ExpungeCommand.java Sat Feb 10 00:18:54 2007
@@ -19,15 +19,8 @@
package org.apache.james.imapserver.commands;
-import org.apache.james.imapserver.AuthorizationException;
import org.apache.james.imapserver.ImapRequestLineReader;
-import org.apache.james.imapserver.ImapSession;
import org.apache.james.imapserver.ProtocolException;
-import org.apache.james.imapserver.store.MailboxException;
-import org.apache.james.mailboxmanager.MailboxManagerException;
-import org.apache.james.mailboxmanager.MessageResult;
-import org.apache.james.mailboxmanager.impl.GeneralMessageSetImpl;
-import org.apache.james.mailboxmanager.mailbox.ImapMailboxSession;
/**
* Handles processeing for the EXPUNGE imap command.
@@ -55,30 +48,6 @@
parser.endLine( request );
final ExpungeCommandMessage result = new ExpungeCommandMessage(this, tag);
return result;
- }
-
- private static class ExpungeCommandMessage extends AbstractImapCommandMessage {
-
- public ExpungeCommandMessage(final ImapCommand command, final String tag) {
- super(tag, command);
- }
-
- protected ImapResponseMessage doProcess(ImapSession session, String tag, ImapCommand command) throws MailboxException, AuthorizationException, ProtocolException {
- ImapResponseMessage result;
- ImapMailboxSession mailbox = session.getSelected().getMailbox();
- if (!mailbox.isWriteable()) {
- result = new CommandFailedResponseMessage(command, "Mailbox selected read only.", tag );
- } else {
- try {
- mailbox.expunge(GeneralMessageSetImpl.all(),MessageResult.NOTHING);
- result = new CommandCompleteResponseMessage(false, command, tag);
- } catch (MailboxManagerException e) {
- throw new MailboxException(e);
- }
- }
- return result;
- }
-
}
}
/*
Added: james/server/sandbox/seda-imap/src/java/org/apache/james/imapserver/commands/ExpungeCommandMessage.java
URL: http://svn.apache.org/viewvc/james/server/sandbox/seda-imap/src/java/org/apache/james/imapserver/commands/ExpungeCommandMessage.java?view=auto&rev=505653
==============================================================================
--- james/server/sandbox/seda-imap/src/java/org/apache/james/imapserver/commands/ExpungeCommandMessage.java (added)
+++ james/server/sandbox/seda-imap/src/java/org/apache/james/imapserver/commands/ExpungeCommandMessage.java Sat Feb 10 00:18:54 2007
@@ -0,0 +1,52 @@
+/****************************************************************
+ * 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.imapserver.commands;
+
+import org.apache.james.imapserver.AuthorizationException;
+import org.apache.james.imapserver.ImapSession;
+import org.apache.james.imapserver.ProtocolException;
+import org.apache.james.imapserver.store.MailboxException;
+import org.apache.james.mailboxmanager.MailboxManagerException;
+import org.apache.james.mailboxmanager.MessageResult;
+import org.apache.james.mailboxmanager.impl.GeneralMessageSetImpl;
+import org.apache.james.mailboxmanager.mailbox.ImapMailboxSession;
+
+class ExpungeCommandMessage extends AbstractImapCommandMessage {
+
+ public ExpungeCommandMessage(final ImapCommand command, final String tag) {
+ super(tag, command);
+ }
+
+ protected ImapResponseMessage doProcess(ImapSession session, String tag, ImapCommand command) throws MailboxException, AuthorizationException, ProtocolException {
+ ImapResponseMessage result;
+ ImapMailboxSession mailbox = session.getSelected().getMailbox();
+ if (!mailbox.isWriteable()) {
+ result = new CommandFailedResponseMessage(command, "Mailbox selected read only.", tag );
+ } else {
+ try {
+ mailbox.expunge(GeneralMessageSetImpl.all(),MessageResult.NOTHING);
+ result = new CommandCompleteResponseMessage(false, command, tag);
+ } catch (MailboxManagerException e) {
+ throw new MailboxException(e);
+ }
+ }
+ return result;
+ }
+
+}
Modified: james/server/sandbox/seda-imap/src/java/org/apache/james/imapserver/commands/FetchCommand.java
URL: http://svn.apache.org/viewvc/james/server/sandbox/seda-imap/src/java/org/apache/james/imapserver/commands/FetchCommand.java?view=diff&rev=505653&r1=505652&r2=505653
==============================================================================
--- james/server/sandbox/seda-imap/src/java/org/apache/james/imapserver/commands/FetchCommand.java (original)
+++ james/server/sandbox/seda-imap/src/java/org/apache/james/imapserver/commands/FetchCommand.java Sat Feb 10 00:18:54 2007
@@ -19,37 +19,11 @@
package org.apache.james.imapserver.commands;
-import java.io.ByteArrayOutputStream;
-import java.io.IOException;
-import java.util.ArrayList;
-import java.util.Collection;
-import java.util.Enumeration;
-import java.util.HashSet;
-import java.util.Iterator;
-import java.util.List;
-import java.util.Set;
-
-import javax.mail.Flags;
-import javax.mail.MessagingException;
-import javax.mail.internet.MimeMessage;
-import org.apache.james.core.MimeMessageWrapper;
-import org.apache.james.imapserver.AuthorizationException;
+
import org.apache.james.imapserver.ImapRequestLineReader;
-import org.apache.james.imapserver.ImapResponse;
-import org.apache.james.imapserver.ImapSession;
import org.apache.james.imapserver.ProtocolException;
-import org.apache.james.imapserver.store.MailboxException;
-import org.apache.james.imapserver.store.MessageFlags;
-import org.apache.james.imapserver.store.SimpleMessageAttributes;
-import org.apache.james.mailboxmanager.GeneralMessageSet;
-import org.apache.james.mailboxmanager.MailboxManagerException;
-import org.apache.james.mailboxmanager.MessageResult;
-import org.apache.james.mailboxmanager.impl.GeneralMessageSetImpl;
-import org.apache.james.mailboxmanager.mailbox.ImapMailboxSession;
-import org.apache.mailet.dates.RFC822DateFormat;
-import com.sun.mail.util.CRLFOutputStream;
/**
* Handles processeing for the FETCH imap command.
@@ -210,58 +184,6 @@
}
- private static class FetchRequest
- {
- boolean flags;
- boolean uid;
- boolean internalDate;
- boolean size;
- boolean envelope;
- boolean body;
- boolean bodyStructure;
-
- private boolean setSeen = false;
-
- private Set bodyElements = new HashSet();
-
- public Collection getBodyElements() {
- return bodyElements;
- }
-
- public boolean isSetSeen() {
- return setSeen;
- }
-
- public void add( BodyFetchElement element, boolean peek )
- {
- if (!peek) {
- setSeen = true;
- }
- bodyElements.add(element);
- }
- }
-
- private class BodyFetchElement
- {
- private String name;
- private String sectionIdentifier;
-
- public BodyFetchElement( String name, String sectionIdentifier)
- {
- this.name = name;
- this.sectionIdentifier = sectionIdentifier;
- }
-
- public String getParameters()
- {
- return this.sectionIdentifier;
- }
-
- public String getResponseName() {
- return this.name;
- }
- }
-
protected AbstractImapCommandMessage decode(ImapRequestLineReader request, String tag) throws ProtocolException {
final AbstractImapCommandMessage result = decode(request, false, tag);
return result;
@@ -274,339 +196,6 @@
final FetchCommandMessage result = new FetchCommandMessage(this, useUids, idSet, fetch, tag);
return result;
- }
-
- private static class FetchCommandMessage extends AbstractImapCommandMessage {
- private final boolean useUids;
- private final IdRange[] idSet;
- private final FetchRequest fetch;
-
- public FetchCommandMessage(final ImapCommand command, final boolean useUids, final IdRange[] idSet,
- final FetchRequest fetch, String tag) {
- super(tag, command);
- this.useUids = useUids;
- this.idSet = idSet;
- this.fetch = fetch;
- if (useUids) {
- fetch.uid = true;
- }
- }
-
-
- protected ImapResponseMessage doProcess(ImapSession session, String tag, ImapCommand command) throws MailboxException, AuthorizationException, ProtocolException {
-
- FetchResponseMessage result =
- new FetchResponseMessage(command, useUids, tag);
- // TODO only fetch needed results
- int resultToFetch = MessageResult.FLAGS | MessageResult.MIME_MESSAGE
- | MessageResult.INTERNAL_DATE | MessageResult.MSN
- | MessageResult.SIZE;
- ImapMailboxSession mailbox = session.getSelected().getMailbox();
- for (int i = 0; i < idSet.length; i++) {
- GeneralMessageSet messageSet=GeneralMessageSetImpl.range(idSet[i].getLowVal(),idSet[i].getHighVal(),useUids);
- MessageResult[] fetchResults;
- try {
- fetchResults = mailbox.getMessages(messageSet,resultToFetch);
- } catch (MailboxManagerException e) {
- throw new MailboxException(e);
- }
- for (int j = 0; j < fetchResults.length; j++) {
- String msgData = outputMessage( fetch, fetchResults[j], mailbox, useUids );
- // TODO: this is inefficient
- // TODO: stream output upon response
- result.addMessageData(fetchResults[j].getMsn(), msgData );
- }
- }
- return result;
- }
-
-
- private String outputMessage(FetchRequest fetch, MessageResult result,
- ImapMailboxSession mailbox, boolean useUids)
- throws MailboxException, ProtocolException {
- // Check if this fetch will cause the "SEEN" flag to be set on this
- // message
- // If so, update the flags, and ensure that a flags response is included
- // in the response.
- try {
- boolean ensureFlagsResponse = false;
- if (fetch.isSetSeen()
- && !result.getFlags().contains(Flags.Flag.SEEN)) {
- mailbox.setFlags(new Flags(Flags.Flag.SEEN), true, false,
- GeneralMessageSetImpl.oneUid(result.getUid()), null);
- result.getFlags().add(Flags.Flag.SEEN);
- ensureFlagsResponse = true;
- }
-
- StringBuffer response = new StringBuffer();
-
- // FLAGS response
- if (fetch.flags || ensureFlagsResponse) {
- response.append(" FLAGS ");
- response.append(MessageFlags.format(result.getFlags()));
- }
-
- // INTERNALDATE response
- if (fetch.internalDate) {
- response.append(" INTERNALDATE \"");
- // TODO format properly
- response.append(RFC822DateFormat.toString(result
- .getInternalDate())); // not right format
- response.append("\"");
-
- }
-
- // RFC822.SIZE response
- if (fetch.size) {
- response.append(" RFC822.SIZE ");
- response.append(result.getSize());
- }
-
- SimpleMessageAttributes attrs = new SimpleMessageAttributes(result
- .getMimeMessage(), getLogger());
-
- // ENVELOPE response
- if (fetch.envelope) {
- response.append(" ENVELOPE ");
- response.append(attrs.getEnvelope());
- }
-
- // BODY response
- if (fetch.body) {
- response.append(" BODY ");
- response.append(attrs.getBodyStructure(false));
- }
-
- // BODYSTRUCTURE response
- if (fetch.bodyStructure) {
- response.append(" BODYSTRUCTURE ");
- response.append(attrs.getBodyStructure(true));
- }
-
- // UID response
- if (fetch.uid) {
- response.append(" UID ");
- response.append(result.getUid());
- }
-
- // BODY part responses.
- Collection elements = fetch.getBodyElements();
- for (Iterator iterator = elements.iterator(); iterator.hasNext();) {
- BodyFetchElement fetchElement = (BodyFetchElement) iterator
- .next();
- response.append(SP);
- response.append(fetchElement.getResponseName());
- response.append(SP);
-
- // Various mechanisms for returning message body.
- String sectionSpecifier = fetchElement.getParameters();
-
- MimeMessage mimeMessage = result.getMimeMessage();
- try {
- handleBodyFetch(mimeMessage, sectionSpecifier, response);
- } catch (MessagingException e) {
- throw new MailboxException(e.getMessage(), e);
- }
- }
-
- if (response.length() > 0) {
- // Remove the leading " ".
- return response.substring(1);
- } else {
- return "";
- }
- } catch (MailboxManagerException mme) {
- throw new MailboxException(mme);
- } catch (MessagingException me) {
- throw new MailboxException(me);
- }
- }
-
-
-
-
- private void handleBodyFetch( MimeMessage mimeMessage,
- String sectionSpecifier,
- StringBuffer response )
- throws ProtocolException, MessagingException
- {
- if ( sectionSpecifier.length() == 0 ) {
- // TODO - need to use an InputStream from the response here.
- ByteArrayOutputStream bout = new ByteArrayOutputStream();
- try {
- mimeMessage.writeTo(new CRLFOutputStream(bout));
- }
- catch ( IOException e ) {
- throw new ProtocolException( "Error reading message source", e);
- }
- byte[] bytes = bout.toByteArray();
- addLiteral( bytes, response );
- // TODO JD maybe we've to add CRLF here
-
- }
- else if ( sectionSpecifier.equalsIgnoreCase( "HEADER" ) ) {
- Enumeration e = mimeMessage.getAllHeaderLines();
- addHeaders( e, response );
- }
- else if ( sectionSpecifier.startsWith( "HEADER.FIELDS.NOT " ) ) {
- String[] excludeNames = extractHeaderList( sectionSpecifier, "HEADER.FIELDS.NOT ".length() );
- Enumeration e = mimeMessage.getNonMatchingHeaderLines( excludeNames );
- addHeaders( e, response );
- }
- else if ( sectionSpecifier.startsWith( "HEADER.FIELDS " ) ) {
- String[] includeNames = extractHeaderList( sectionSpecifier, "HEADER.FIELDS ".length() );
- Enumeration e = mimeMessage.getMatchingHeaderLines( includeNames );
- addHeaders( e, response );
- }
- else if ( sectionSpecifier.equalsIgnoreCase( "MIME" ) ) {
- // TODO implement
- throw new ProtocolException( "MIME not yet implemented." );
- }
- else if ( sectionSpecifier.equalsIgnoreCase( "TEXT" ) ) {
- // TODO - need to use an InputStream from the response here.
- // TODO - this is a hack. To get just the body content, I'm using a null
- // input stream to take the headers. Need to have a way of ignoring headers.
- ByteArrayOutputStream headerOut = new ByteArrayOutputStream();
- ByteArrayOutputStream bodyOut = new ByteArrayOutputStream();
- try {
- // TODO James Trunk : Is this okay?
- MimeMessageWrapper mmw=new MimeMessageWrapper(mimeMessage);
-
- mmw.writeTo(headerOut, bodyOut );
- byte[] bytes = bodyOut.toByteArray();
-
- addLiteral( bytes, response );
-
- }
- catch ( IOException e ) {
- throw new ProtocolException( "Error reading message source", e);
- }
- }
- else {
- // Should be a part specifier followed by a section specifier.
- // See if there's a leading part specifier.
- // If so, get the number, get the part, and call this recursively.
- int dotPos = sectionSpecifier.indexOf( '.' );
- if ( dotPos == -1 ) {
- throw new ProtocolException( "Malformed fetch attribute: " + sectionSpecifier );
- }
- int partNumber = Integer.parseInt( sectionSpecifier.substring( 0, dotPos ) );
- String partSectionSpecifier = sectionSpecifier.substring( dotPos + 1 );
-
- // TODO - get the MimePart of the mimeMessage, and call this method
- // with the new partSectionSpecifier.
-// MimeMessage part;
-// handleBodyFetch( part, partSectionSpecifier, response );
- throw new ProtocolException( "Mime parts not yet implemented for fetch." );
- }
-
- }
-
- private void addLiteral( byte[] bytes, StringBuffer response )
- {
- response.append('{' );
- response.append( bytes.length ); // TODO JD addLiteral: why was it bytes.length +1 here?
- response.append( '}' );
- response.append( "\r\n" );
-
- for ( int i = 0; i < bytes.length; i++ ) {
- byte b = bytes[i];
- response.append((char)b);
- }
- }
-
- // TODO should do this at parse time.
- private String[] extractHeaderList( String headerList, int prefixLen )
- {
- // Remove the trailing and leading ')('
- String tmp = headerList.substring( prefixLen + 1, headerList.length() - 1 );
- String[] headerNames = split( tmp, " " );
- return headerNames;
- }
-
- private String[] split(String value, String delimiter) {
- ArrayList strings = new ArrayList();
- int startPos = 0;
- int delimPos;
- while ( (delimPos = value.indexOf(delimiter, startPos) ) != -1) {
- String sub = value.substring(startPos, delimPos);
- strings.add(sub);
- startPos = delimPos + 1;
- }
- String sub = value.substring(startPos);
- strings.add(sub);
-
- return (String[]) strings.toArray(new String[0]);
- }
-
- private void addHeaders( Enumeration e, StringBuffer response )
- {
- List lines = new ArrayList();
- int count = 0;
- while (e.hasMoreElements()) {
- String line = (String)e.nextElement();
- count += line.length() + 2;
- lines.add(line);
- }
- response.append( '{' );
- response.append( count + 2 );
- response.append( '}' );
- response.append("\r\n");
-
- Iterator lit = lines.iterator();
- while (lit.hasNext()) {
- String line = (String)lit.next();
- response.append( line );
- response.append( "\r\n" );
- }
- response.append("\r\n");
- }
- }
-
- private static class FetchResponseMessage extends AbstractCommandResponseMessage {
-
- private final boolean useUids;
-
- public FetchResponseMessage(final ImapCommand command, final boolean useUids,
- final String tag) {
- super(command, tag);
- this.useUids = useUids;
- }
-
- private List messages = new ArrayList();
-
- public void addMessageData(int number, String messageData) {
- final MessageData data = new MessageData(number, messageData);
- messages.add(data);
- }
-
- void doEncode(ImapResponse response, ImapSession session, ImapCommand command, String tag) throws MailboxException {
- for (final Iterator it=messages.iterator();it.hasNext();) {
- MessageData data = (MessageData) it.next();
- data.encode(response);
- }
- boolean omitExpunged = (!useUids);
- session.unsolicitedResponses( response, omitExpunged , useUids);
- response.commandComplete( command, tag );
-
- }
-
- private class MessageData {
- // TODO: this is not an efficient solution
- // TODO: would be better to lazy load and stream on output
- // TODO: this is just a transitional solution
- private final int number;
- private final String data;
- public MessageData(final int number, final String data) {
- super();
- this.number = number;
- this.data = data;
- }
-
- public void encode(ImapResponse response) {
- response.fetchResponse(number, data);
- }
- }
}
}
/*
---------------------------------------------------------------------
To unsubscribe, e-mail: server-dev-unsubscribe@james.apache.org
For additional commands, e-mail: server-dev-help@james.apache.org