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 jo...@apache.org on 2006/10/09 19:15:42 UTC
svn commit: r454432 [5/14] - in /james/server/sandbox/imap-integration: ./
lib/ src/java/ src/java/org/apache/james/imapserver/
src/java/org/apache/james/imapserver/commands/
src/java/org/apache/james/imapserver/debug/
src/java/org/apache/james/imapser...
Added: james/server/sandbox/imap-integration/src/java/org/apache/james/imapserver/commands/SubscribeCommand.java
URL: http://svn.apache.org/viewvc/james/server/sandbox/imap-integration/src/java/org/apache/james/imapserver/commands/SubscribeCommand.java?view=auto&rev=454432
==============================================================================
--- james/server/sandbox/imap-integration/src/java/org/apache/james/imapserver/commands/SubscribeCommand.java (added)
+++ james/server/sandbox/imap-integration/src/java/org/apache/james/imapserver/commands/SubscribeCommand.java Mon Oct 9 10:15:30 2006
@@ -0,0 +1,68 @@
+/***********************************************************************
+ * Copyright (c) 2000-2004 The Apache Software Foundation. *
+ * All rights reserved. *
+ * ------------------------------------------------------------------- *
+ * Licensed 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.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;
+
+/**
+ * Handles processeing for the SUBSCRIBE imap command.
+ *
+ * @author Darrell DeBoer <da...@apache.org>
+ *
+ * @version $Revision: 109034 $
+ */
+class SubscribeCommand extends AuthenticatedStateCommand
+{
+ public static final String NAME = "SUBSCRIBE";
+ public static final String ARGS = "<mailbox>";
+
+ /** @see CommandTemplate#doProcess */
+ protected void doProcess( ImapRequestLineReader request,
+ ImapResponse response,
+ ImapSession session )
+ throws ProtocolException, MailboxException
+ {
+ String mailboxName = parser.mailbox( request );
+ parser.endLine( request );
+
+ try {
+ session.getMailboxManager().setSubscription(mailboxName,true);
+ } catch (MailboxManagerException e) {
+ throw new MailboxException(e);
+ }
+ session.unsolicitedResponses( response, false );
+ response.commandComplete( this );
+ }
+
+ /** @see ImapCommand#getName */
+ public String getName()
+ {
+ return NAME;
+ }
+
+ /** @see CommandTemplate#getArgSyntax */
+ public String getArgSyntax()
+ {
+ return ARGS;
+ }
+}
Added: james/server/sandbox/imap-integration/src/java/org/apache/james/imapserver/commands/UidCommand.java
URL: http://svn.apache.org/viewvc/james/server/sandbox/imap-integration/src/java/org/apache/james/imapserver/commands/UidCommand.java?view=auto&rev=454432
==============================================================================
--- james/server/sandbox/imap-integration/src/java/org/apache/james/imapserver/commands/UidCommand.java (added)
+++ james/server/sandbox/imap-integration/src/java/org/apache/james/imapserver/commands/UidCommand.java Mon Oct 9 10:15:30 2006
@@ -0,0 +1,72 @@
+/***********************************************************************
+ * Copyright (c) 2000-2004 The Apache Software Foundation. *
+ * All rights reserved. *
+ * ------------------------------------------------------------------- *
+ * Licensed 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.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 UID imap command.
+ *
+ * @author Darrell DeBoer <da...@apache.org>
+ *
+ * @version $Revision: 109034 $
+ */
+class UidCommand extends SelectedStateCommand
+{
+ public static final String NAME = "UID";
+ public static final String ARGS = "<fetch-command>|<store-command>|<copy-command>|<search-command>";
+
+ private ImapCommandFactory commandFactory;
+
+ /** @see CommandTemplate#doProcess */
+ protected void doProcess( ImapRequestLineReader request,
+ ImapResponse response,
+ ImapSession session )
+ throws ProtocolException, MailboxException
+ {
+ String commandName = parser.atom( request );
+ ImapCommand command = commandFactory.getCommand( commandName );
+ if ( command == null ||
+ ! (command instanceof UidEnabledCommand ) ) {
+ throw new ProtocolException("Invalid UID command: '" + commandName + "'" );
+ }
+
+ ((UidEnabledCommand)command).doProcess( request, response, session, true );
+ }
+
+ /** @see ImapCommand#getName */
+ public String getName()
+ {
+ return NAME;
+ }
+
+ /** @see CommandTemplate#getArgSyntax */
+ public String getArgSyntax()
+ {
+ return ARGS;
+ }
+
+ public void setCommandFactory( ImapCommandFactory imapCommandFactory )
+ {
+ this.commandFactory = imapCommandFactory;
+ }
+}
Added: james/server/sandbox/imap-integration/src/java/org/apache/james/imapserver/commands/UidEnabledCommand.java
URL: http://svn.apache.org/viewvc/james/server/sandbox/imap-integration/src/java/org/apache/james/imapserver/commands/UidEnabledCommand.java?view=auto&rev=454432
==============================================================================
--- james/server/sandbox/imap-integration/src/java/org/apache/james/imapserver/commands/UidEnabledCommand.java (added)
+++ james/server/sandbox/imap-integration/src/java/org/apache/james/imapserver/commands/UidEnabledCommand.java Mon Oct 9 10:15:30 2006
@@ -0,0 +1,39 @@
+/***********************************************************************
+ * Copyright (c) 2000-2004 The Apache Software Foundation. *
+ * All rights reserved. *
+ * ------------------------------------------------------------------- *
+ * Licensed 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.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;
+
+/**
+ *
+ * @author Darrell DeBoer <da...@apache.org>
+ *
+ * @version $Revision: 109034 $
+ */
+public interface UidEnabledCommand
+{
+ void doProcess( ImapRequestLineReader request,
+ ImapResponse response,
+ ImapSession session,
+ boolean useUids)
+ throws ProtocolException, MailboxException;
+}
Added: james/server/sandbox/imap-integration/src/java/org/apache/james/imapserver/commands/UnsubscribeCommand.java
URL: http://svn.apache.org/viewvc/james/server/sandbox/imap-integration/src/java/org/apache/james/imapserver/commands/UnsubscribeCommand.java?view=auto&rev=454432
==============================================================================
--- james/server/sandbox/imap-integration/src/java/org/apache/james/imapserver/commands/UnsubscribeCommand.java (added)
+++ james/server/sandbox/imap-integration/src/java/org/apache/james/imapserver/commands/UnsubscribeCommand.java Mon Oct 9 10:15:30 2006
@@ -0,0 +1,68 @@
+/***********************************************************************
+ * Copyright (c) 2000-2004 The Apache Software Foundation. *
+ * All rights reserved. *
+ * ------------------------------------------------------------------- *
+ * Licensed 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.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;
+
+/**
+ * Handles processeing for the UNSUBSCRIBE imap command.
+ *
+ * @author Darrell DeBoer <da...@apache.org>
+ *
+ * @version $Revision: 109034 $
+ */
+class UnsubscribeCommand extends AuthenticatedStateCommand
+{
+ public static final String NAME = "UNSUBSCRIBE";
+ public static final String ARGS = "<mailbox>";
+
+ /** @see CommandTemplate#doProcess */
+ protected void doProcess( ImapRequestLineReader request,
+ ImapResponse response,
+ ImapSession session )
+ throws ProtocolException, MailboxException
+ {
+ String mailboxName = parser.mailbox( request );
+ parser.endLine( request );
+
+ try {
+ session.getMailboxManager().setSubscription(mailboxName,false);
+ } catch (MailboxManagerException e) {
+ throw new MailboxException(e);
+ }
+ session.unsolicitedResponses( response , false );
+ response.commandComplete( this );
+ }
+
+ /** @see ImapCommand#getName */
+ public String getName()
+ {
+ return NAME;
+ }
+
+ /** @see CommandTemplate#getArgSyntax */
+ public String getArgSyntax()
+ {
+ return ARGS;
+ }
+}
Added: james/server/sandbox/imap-integration/src/java/org/apache/james/imapserver/debug/CopyInputStream.java
URL: http://svn.apache.org/viewvc/james/server/sandbox/imap-integration/src/java/org/apache/james/imapserver/debug/CopyInputStream.java?view=auto&rev=454432
==============================================================================
--- james/server/sandbox/imap-integration/src/java/org/apache/james/imapserver/debug/CopyInputStream.java (added)
+++ james/server/sandbox/imap-integration/src/java/org/apache/james/imapserver/debug/CopyInputStream.java Mon Oct 9 10:15:30 2006
@@ -0,0 +1,58 @@
+package org.apache.james.imapserver.debug;
+
+import java.io.IOException;
+import java.io.InputStream;
+import java.io.OutputStream;
+
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.impl.SimpleLog;
+/**
+ *
+ * @author Joachim Draeger <jd at joachim-draeger.de>
+ *
+ */
+public class CopyInputStream extends InputStream
+{
+
+ private InputStream is;
+
+ private OutputStream copy;
+
+ private Log log;
+
+ StringBuffer logString = new StringBuffer();
+
+ private boolean DEEP_DEBUG = false;
+
+ public CopyInputStream(InputStream is, OutputStream copy)
+ {
+ this.is = is;
+ this.copy = copy;
+ }
+
+ public int read() throws IOException {
+ int in = is.read();
+ copy.write(in);
+ if (DEEP_DEBUG) {
+ if (in == 10) {
+ getLog().debug(logString);
+ logString = new StringBuffer();
+ } else if (in != 13) {
+ logString.append((char) in);
+ }
+ }
+ return in;
+ }
+
+ protected Log getLog() {
+ if (log==null) {
+ log=new SimpleLog("CopyInputStream");
+ }
+ return log;
+ }
+
+ public void setLog(Log log) {
+ this.log=log;
+ }
+
+}
Added: james/server/sandbox/imap-integration/src/java/org/apache/james/imapserver/debug/SplitOutputStream.java
URL: http://svn.apache.org/viewvc/james/server/sandbox/imap-integration/src/java/org/apache/james/imapserver/debug/SplitOutputStream.java?view=auto&rev=454432
==============================================================================
--- james/server/sandbox/imap-integration/src/java/org/apache/james/imapserver/debug/SplitOutputStream.java (added)
+++ james/server/sandbox/imap-integration/src/java/org/apache/james/imapserver/debug/SplitOutputStream.java Mon Oct 9 10:15:30 2006
@@ -0,0 +1,64 @@
+package org.apache.james.imapserver.debug;
+
+import java.io.FilterOutputStream;
+import java.io.IOException;
+import java.io.OutputStream;
+
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.impl.SimpleLog;
+
+/**
+ *
+ * @author Joachim Draeger <jd at joachim-draeger.de>
+ *
+ */
+public class SplitOutputStream extends FilterOutputStream {
+
+ private OutputStream debugOutputStream;
+
+ StringBuffer logString = new StringBuffer();
+
+ private boolean DEEP_DEBUG = false;
+
+ private Log log;
+
+ public SplitOutputStream(OutputStream out, OutputStream debug) {
+ super(out);
+ debugOutputStream = debug;
+ }
+
+ public void flush() throws IOException {
+ super.flush();
+ if (debugOutputStream != null) {
+ debugOutputStream.flush();
+ }
+ }
+
+ public void write(int b) throws IOException {
+ super.write(b);
+ if (DEEP_DEBUG) {
+ if (b == 10) {
+ getLog().debug(logString);
+ logString = new StringBuffer();
+ } else if (b != 13) {
+ logString.append((char) b);
+ }
+ }
+ if (debugOutputStream != null) {
+ debugOutputStream.write(b);
+ debugOutputStream.flush();
+ }
+ }
+
+ public void setLog(Log log) {
+ this.log = log;
+ }
+
+ protected Log getLog() {
+ if (log == null) {
+ log = new SimpleLog("SplitOutputStream");
+ }
+ return log;
+ }
+
+}
Added: james/server/sandbox/imap-integration/src/java/org/apache/james/imapserver/store/ImapMessage.java
URL: http://svn.apache.org/viewvc/james/server/sandbox/imap-integration/src/java/org/apache/james/imapserver/store/ImapMessage.java?view=auto&rev=454432
==============================================================================
--- james/server/sandbox/imap-integration/src/java/org/apache/james/imapserver/store/ImapMessage.java (added)
+++ james/server/sandbox/imap-integration/src/java/org/apache/james/imapserver/store/ImapMessage.java Mon Oct 9 10:15:30 2006
@@ -0,0 +1,42 @@
+/***********************************************************************
+ * Copyright (c) 2000-2004 The Apache Software Foundation. *
+ * All rights reserved. *
+ * ------------------------------------------------------------------- *
+ * Licensed 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.store;
+
+import java.util.Date;
+
+import javax.mail.Flags;
+import javax.mail.internet.MimeMessage;
+
+/**
+ *
+ * @author Darrell DeBoer <da...@apache.org>
+ *
+ * @version $Revision: 109034 $
+ */
+public interface ImapMessage
+{
+ MimeMessage getMimeMessage();
+
+ Flags getFlags();
+
+ Date getInternalDate();
+
+ long getUid();
+
+ ImapMessageAttributes getAttributes() throws MailboxException;
+}
Added: james/server/sandbox/imap-integration/src/java/org/apache/james/imapserver/store/ImapMessageAttributes.java
URL: http://svn.apache.org/viewvc/james/server/sandbox/imap-integration/src/java/org/apache/james/imapserver/store/ImapMessageAttributes.java?view=auto&rev=454432
==============================================================================
--- james/server/sandbox/imap-integration/src/java/org/apache/james/imapserver/store/ImapMessageAttributes.java (added)
+++ james/server/sandbox/imap-integration/src/java/org/apache/james/imapserver/store/ImapMessageAttributes.java Mon Oct 9 10:15:30 2006
@@ -0,0 +1,80 @@
+/***********************************************************************
+ * Copyright (c) 2000-2004 The Apache Software Foundation. *
+ * All rights reserved. *
+ * ------------------------------------------------------------------- *
+ * Licensed 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.store;
+
+import java.util.Date;
+
+/**
+ * Interface for objects holding IMAP4rev1 Message Attributes. Message
+ * Attributes should be set when a message enters a mailbox. Implementations
+ * are encouraged to implement and store MessageAttributes apart from the
+ * underlying message. This allows the Mailbox to respond to questions about
+ * very large message without needing to access them directly.
+ * <p> Note that the message in a mailbox have the same order using either
+ * Message Sequence Numbers or UIDs.
+ *
+ * Reference: RFC 2060 - para 2.3
+ * @author <a href="mailto:charles@benett1.demon.co.uk">Charles Benett</a>
+ * @version 0.1 on 14 Dec 2000
+ */
+public interface ImapMessageAttributes {
+
+ /**
+ * Provides the date and time at which the message was received. In the
+ * case of delivery by SMTP, this SHOULD be the date and time of final
+ * delivery as defined for SMTP. In the case of messages copied from
+ * another mailbox, it shuld be the internalDate of the source message. In
+ * the case of messages Appended to the mailbox, example drafts, the
+ * internalDate is either specified in the Append command or is the
+ * current dat and time at the time of the Append.
+ *
+ * @return Date imap internal date
+ */
+ Date getInternalDate();
+
+ /**
+ * Returns IMAP formatted String representation of Date
+ */
+ String getInternalDateAsString();
+
+ /**
+ * Provides the sizeof the message in octets.
+ *
+ * @return int number of octets in message.
+ */
+ int getSize();
+
+ /**
+ * Provides the Envelope structure information for this message.
+ * This is a parsed representation of the rfc-822 envelope information.
+ * This is not to be confused with the SMTP envelope!
+ *
+ * @return String satisfying envelope syntax in rfc 2060.
+ */
+ String getEnvelope();
+
+ /**
+ * Provides the Body Structure information for this message.
+ * This is a parsed representtion of the MIME structure of the message.
+ *
+ * @return String satisfying body syntax in rfc 2060.
+ */
+ String getBodyStructure( boolean includeExtensions );
+}
+
+
Added: james/server/sandbox/imap-integration/src/java/org/apache/james/imapserver/store/JavaMailImapStore.xinfo
URL: http://svn.apache.org/viewvc/james/server/sandbox/imap-integration/src/java/org/apache/james/imapserver/store/JavaMailImapStore.xinfo?view=auto&rev=454432
==============================================================================
--- james/server/sandbox/imap-integration/src/java/org/apache/james/imapserver/store/JavaMailImapStore.xinfo (added)
+++ james/server/sandbox/imap-integration/src/java/org/apache/james/imapserver/store/JavaMailImapStore.xinfo Mon Oct 9 10:15:30 2006
@@ -0,0 +1,21 @@
+<?xml version="1.0"?>
+
+<blockinfo>
+
+ <!-- section to describe block -->
+ <block>
+ <version>1.0</version>
+ </block>
+
+ <!-- services that are offered by this block -->
+ <services>
+ <service name="org.apache.james.imapserver.store.ImapStore" version="1.0"/>
+ </services>
+
+ <dependencies>
+ <dependency>
+ <service name="org.apache.james.services.MailServer" version="1.0"/>
+ </dependency>
+ </dependencies>
+
+</blockinfo>
\ No newline at end of file
Added: james/server/sandbox/imap-integration/src/java/org/apache/james/imapserver/store/MailboxException.java
URL: http://svn.apache.org/viewvc/james/server/sandbox/imap-integration/src/java/org/apache/james/imapserver/store/MailboxException.java?view=auto&rev=454432
==============================================================================
--- james/server/sandbox/imap-integration/src/java/org/apache/james/imapserver/store/MailboxException.java (added)
+++ james/server/sandbox/imap-integration/src/java/org/apache/james/imapserver/store/MailboxException.java Mon Oct 9 10:15:30 2006
@@ -0,0 +1,125 @@
+/***********************************************************************
+ * Copyright (c) 2000-2004 The Apache Software Foundation. *
+ * All rights reserved. *
+ * ------------------------------------------------------------------- *
+ * Licensed 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.store;
+
+import javax.mail.MessagingException;
+
+import org.apache.james.mailboxmanager.MailboxManagerException;
+
+/**
+ * Thrown on an inappropriate attempt to reference a mailbox.
+ * Includes attempting to create a mailbox that already exists and attempting
+ * to open a mailbox that does not exist.
+ * If status is ALREADY_EXISTS_REMOTELY or IF_CREATED_REMOTE then field
+ * remoteServer should be set to the url of the remote server, formatted for
+ * Mailbox Referral.
+ *
+ * @author <a href="mailto:charles@benett1.demon.co.uk">Charles Benett</a>
+ * @version 0.1 on 14 Dec 2000
+ */
+public class MailboxException extends Exception
+{
+
+ public final static String ALREADY_EXISTS_LOCALLY
+ = "Already exists locally";
+ public final static String ALREADY_EXISTS_REMOTELY
+ = "Already exists remotely";
+ public final static String IF_CREATED_LOCAL
+ = "If created, mailbox would be local";
+ public final static String IF_CREATED_REMOTE
+ = "If created, mailbox would be remote";
+ public final static String NOT_LOCAL
+ = "Does not exist locally, no further information available";
+ public final static String LOCAL_BUT_DELETED
+ = "Was local but has been deleted.";
+
+ protected String status = null;
+ protected String remoteServer = null;
+
+ private String responseCode = null;
+
+ /**
+ * Construct a new <code>MailboxException</code> instance.
+ *
+ * @param message The detail message for this exception (mandatory).
+ */
+ public MailboxException( String message )
+ {
+ super( message );
+ }
+
+ /**
+ * Construct a new <code>MailBoxException</code> instance.
+ *
+ * @param message The detail message for this exception (mandatory).
+ * @param aStatus String constant indicating condition
+ */
+ public MailboxException( String message, String aStatus )
+ {
+ super( message );
+ this.status = aStatus;
+ }
+
+ /**
+ * Construct a new <code>MailBoxException</code> instance.
+ *
+ * @param message The detail message for this exception (mandatory).
+ * @param aStatus String constant indicating condition
+ * @param aServer String indicating another server where Mailbox should be.
+ */
+ public MailboxException( String message, String aStatus, String aServer )
+ {
+ super( message );
+ this.status = aStatus;
+ this.remoteServer = aServer;
+ }
+
+ public MailboxException(MailboxManagerException e) {
+ super(e);
+ }
+
+ public MailboxException(MessagingException e) {
+ super(e);
+ }
+
+ public String getStatus()
+ {
+ return status;
+ }
+
+ public String getRemoteServer()
+ {
+ return remoteServer;
+ }
+
+ public boolean isRemote()
+ {
+ return ( status.equals( ALREADY_EXISTS_REMOTELY )
+ || status.equals( IF_CREATED_REMOTE ) );
+ }
+
+ public String getResponseCode()
+ {
+ return responseCode;
+ }
+
+ public void setResponseCode( String responseCode )
+ {
+ this.responseCode = responseCode;
+ }
+}
Added: james/server/sandbox/imap-integration/src/java/org/apache/james/imapserver/store/MessageFlags.java
URL: http://svn.apache.org/viewvc/james/server/sandbox/imap-integration/src/java/org/apache/james/imapserver/store/MessageFlags.java?view=auto&rev=454432
==============================================================================
--- james/server/sandbox/imap-integration/src/java/org/apache/james/imapserver/store/MessageFlags.java (added)
+++ james/server/sandbox/imap-integration/src/java/org/apache/james/imapserver/store/MessageFlags.java Mon Oct 9 10:15:30 2006
@@ -0,0 +1,83 @@
+/***********************************************************************
+ * Copyright (c) 2000-2004 The Apache Software Foundation. *
+ * All rights reserved. *
+ * ------------------------------------------------------------------- *
+ * Licensed 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.store;
+
+import javax.mail.Flags;
+
+
+/**
+ * The set of flags associated with a message.
+ * TODO - why not use javax.mail.Flags instead of having our own.
+ *
+ * <p>Reference: RFC 2060 - para 2.3
+ * @author <a href="mailto:charles@benett1.demon.co.uk">Charles Benett</a>
+ * @version 0.1 on 14 Dec 2000
+ */
+public class MessageFlags
+{
+ public static final Flags ALL_FLAGS = new Flags();
+ static {
+ ALL_FLAGS.add(Flags.Flag.ANSWERED);
+ ALL_FLAGS.add(Flags.Flag.DELETED);
+ ALL_FLAGS.add(Flags.Flag.DRAFT);
+ ALL_FLAGS.add(Flags.Flag.FLAGGED);
+ ALL_FLAGS.add(Flags.Flag.RECENT);
+ ALL_FLAGS.add(Flags.Flag.SEEN);
+ }
+
+ public static final String ANSWERED = "\\ANSWERED";
+ public static final String DELETED = "\\DELETED";
+ public static final String DRAFT = "\\DRAFT";
+ public static final String FLAGGED = "\\FLAGGED";
+ public static final String SEEN = "\\SEEN";
+
+ /**
+ * Returns IMAP formatted String of MessageFlags for named user
+ */
+ public static String format(Flags flags)
+ {
+ StringBuffer buf = new StringBuffer();
+ buf.append( "(" );
+ if ( flags.contains(Flags.Flag.ANSWERED) ) {
+ buf.append( "\\Answered " );
+ }
+ if ( flags.contains(Flags.Flag.DELETED) ) {
+ buf.append( "\\Deleted " );
+ }
+ if ( flags.contains(Flags.Flag.DRAFT) ) {
+ buf.append( "\\Draft " );
+ }
+ if ( flags.contains(Flags.Flag.FLAGGED) ) {
+ buf.append( "\\Flagged " );
+ }
+ if ( flags.contains(Flags.Flag.RECENT) ) {
+ buf.append( "\\Recent " );
+ }
+ if ( flags.contains(Flags.Flag.SEEN) ) {
+ buf.append( "\\Seen " );
+ }
+ // Remove the trailing space, if necessary.
+ if ( buf.length() > 1 )
+ {
+ buf.setLength( buf.length() - 1 );
+ }
+ buf.append( ")" );
+ return buf.toString();
+ }
+}
+
Added: james/server/sandbox/imap-integration/src/java/org/apache/james/imapserver/store/SimpleImapMessage.java
URL: http://svn.apache.org/viewvc/james/server/sandbox/imap-integration/src/java/org/apache/james/imapserver/store/SimpleImapMessage.java?view=auto&rev=454432
==============================================================================
--- james/server/sandbox/imap-integration/src/java/org/apache/james/imapserver/store/SimpleImapMessage.java (added)
+++ james/server/sandbox/imap-integration/src/java/org/apache/james/imapserver/store/SimpleImapMessage.java Mon Oct 9 10:15:30 2006
@@ -0,0 +1,89 @@
+/***********************************************************************
+ * Copyright (c) 2000-2004 The Apache Software Foundation. *
+ * All rights reserved. *
+ * ------------------------------------------------------------------- *
+ * Licensed 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.store;
+
+import java.util.Date;
+
+import javax.mail.Flags;
+import javax.mail.MessagingException;
+import javax.mail.internet.MimeMessage;
+
+import org.apache.avalon.framework.logger.AbstractLogEnabled;
+
+/**
+ * A mail message with all of the extra stuff that IMAP requires.
+ * This is just a placeholder object, while I work out what's really required. A common
+ * way of handling *all* messages needs to be available for James (maybe MailImpl?)
+ * @author Darrell DeBoer <da...@apache.org>
+ *
+ * @version $Revision: 109034 $
+ */
+public class SimpleImapMessage
+ extends AbstractLogEnabled implements ImapMessage
+{
+ private MimeMessage mimeMessage;
+ private Flags flags;
+ private Date internalDate;
+ private long uid;
+ private SimpleMessageAttributes attributes;
+
+ public SimpleImapMessage(MimeMessage mimeMessage, Date internalDate, long uid)
+ throws MessagingException {
+ this(mimeMessage, mimeMessage.getFlags(), internalDate, uid);
+ }
+
+ SimpleImapMessage( MimeMessage mimeMessage, Flags flags,
+ Date internalDate, long uid )
+ {
+ this.mimeMessage = mimeMessage;
+ this.flags = flags;
+ this.internalDate = internalDate;
+ this.uid = uid;
+ }
+
+ public MimeMessage getMimeMessage() {
+ return mimeMessage;
+ }
+
+ public Flags getFlags() {
+ return flags;
+ }
+
+ public Date getInternalDate() {
+ return internalDate;
+ }
+
+ public long getUid() {
+ return uid;
+ }
+
+ public ImapMessageAttributes getAttributes() throws MailboxException
+ {
+ if ( attributes == null ) {
+ attributes = new SimpleMessageAttributes();
+ setupLogger( attributes );
+ try {
+ attributes.setAttributesFor( mimeMessage );
+ }
+ catch ( MessagingException e ) {
+ throw new MailboxException( "Could not parse mime message." );
+ }
+ }
+ return attributes;
+ }
+}
Added: james/server/sandbox/imap-integration/src/java/org/apache/james/imapserver/store/SimpleMessageAttributes.java
URL: http://svn.apache.org/viewvc/james/server/sandbox/imap-integration/src/java/org/apache/james/imapserver/store/SimpleMessageAttributes.java?view=auto&rev=454432
==============================================================================
--- james/server/sandbox/imap-integration/src/java/org/apache/james/imapserver/store/SimpleMessageAttributes.java (added)
+++ james/server/sandbox/imap-integration/src/java/org/apache/james/imapserver/store/SimpleMessageAttributes.java Mon Oct 9 10:15:30 2006
@@ -0,0 +1,639 @@
+/***********************************************************************
+ * Copyright (c) 2000-2004 The Apache Software Foundation. *
+ * All rights reserved. *
+ * ------------------------------------------------------------------- *
+ * Licensed 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.store;
+
+import java.util.ArrayList;
+import java.util.Date;
+import java.util.HashSet;
+import java.util.Iterator;
+import java.util.List;
+import java.util.Set;
+
+import javax.mail.BodyPart;
+import javax.mail.MessagingException;
+import javax.mail.internet.AddressException;
+import javax.mail.internet.InternetAddress;
+import javax.mail.internet.MimeMessage;
+import javax.mail.internet.MimeMultipart;
+import javax.mail.internet.MimePart;
+import javax.mail.internet.ParseException;
+
+import org.apache.avalon.framework.logger.AbstractLogEnabled;
+import org.apache.mailet.MailAddress;
+import org.apache.mailet.dates.RFC822DateFormat;
+
+/**
+ * Attributes of a Message in IMAP4rev1 style. Message
+ * Attributes should be set when a message enters a mailbox.
+ * <p> Note that the message in a mailbox have the same order using either
+ * Message Sequence Numbers or UIDs.
+ * <p> reinitialize() must be called on deserialization to reset Logger
+ *
+ * Reference: RFC 2060 - para 2.3
+ * @author <a href="mailto:sascha@kulawik.de">Sascha Kulawik</a>
+ * @author <a href="mailto:charles@benett1.demon.co.uk">Charles Benett</a>
+ * @version 0.2 on 04 Aug 2002
+ */
+public class SimpleMessageAttributes
+ extends AbstractLogEnabled
+ implements ImapMessageAttributes
+{
+
+ private final static String SP = " ";
+ private final static String NIL = "NIL";
+ private final static String Q = "\"";
+ private final static String LB = "(";
+ private final static String RB = ")";
+ private final static boolean DEBUG = false;
+ private final static String MULTIPART = "MULTIPART";
+ private final static String MESSAGE = "MESSAGE";
+
+ private int uid;
+ private int messageSequenceNumber;
+ private Date internalDate;
+ private String internalDateString;
+ private String bodyStructure;
+ private String envelope;
+ private int size;
+ private int lineCount;
+ public ImapMessageAttributes[] parts;
+ private List headers;
+
+ //rfc822 or MIME header fields
+ //arrays only if multiple values allowed under rfc822
+ private String subject;
+ private String[] from;
+ private String[] sender;
+ private String[] replyTo;
+ private String[] to;
+ private String[] cc;
+ private String[] bcc;
+ private String[] inReplyTo;
+ private String[] date;
+ private String[] messageID;
+ private String contentType;
+ private String primaryType; // parsed from contentType
+ private String secondaryType; // parsed from contentType
+ private Set parameters; // parsed from contentType
+ private String contentID;
+ private String contentDesc;
+ private String contentEncoding;
+
+ SimpleMessageAttributes() {
+ }
+
+ public SimpleMessageAttributes(MimeMessage mm) throws MessagingException {
+ setAttributesFor(mm);
+ }
+
+ void setAttributesFor(MimeMessage msg) throws MessagingException {
+ size = msg.getSize();
+ try {
+ internalDate = msg.getSentDate();
+ } catch (MessagingException me) {
+ }
+ if (internalDate == null) {
+ // TODO setAttributesFor: decide what to do when internalDate is null
+ internalDate=new Date();
+ }
+
+ internalDateString = RFC822DateFormat.toString(internalDate); // not right format
+ parseMimePart(msg);
+ envelope = null;
+ bodyStructure = null;
+ }
+
+ void setUID(int thisUID) {
+ uid = thisUID;
+ }
+
+ /**
+ * Parses key data items from a MimeMessage for seperate storage.
+ * TODO this is a mess, and should be completely revamped.
+ */
+ void parseMimePart(MimePart part) {
+ // Section 1 - Message Headers
+ if (part instanceof MimeMessage) {
+ try {
+ subject = ((MimeMessage)part).getSubject();
+ } catch (MessagingException me) {
+ if (DEBUG) getLogger().debug("Messaging Exception for getSubject: " + me);
+ }
+ }
+ try {
+ from = part.getHeader("From");
+ } catch (MessagingException me) {
+ if (DEBUG) getLogger().debug("Messaging Exception for getHeader(From): " + me);
+ }
+ try {
+ sender = part.getHeader("Sender");
+ } catch (MessagingException me) {
+ if (DEBUG) getLogger().debug("Messaging Exception for getHeader(Sender): " + me);
+ }
+ try {
+ replyTo = part.getHeader("Reply To");
+ } catch (MessagingException me) {
+ if (DEBUG) getLogger().debug("Messaging Exception for getHeader(Reply To): " + me);
+ }
+ try {
+ to = part.getHeader("To");
+ } catch (MessagingException me) {
+ if (DEBUG) getLogger().debug("Messaging Exception for getHeader(To): " + me);
+ }
+ try {
+ cc = part.getHeader("Cc");
+ } catch (MessagingException me) {
+ if (DEBUG) getLogger().debug("Messaging Exception for getHeader(To): " + me);
+ }
+ try {
+ bcc = part.getHeader("Bcc");
+ } catch (MessagingException me) {
+ if (DEBUG) getLogger().debug("Messaging Exception for getHeader(To): " + me);
+ }
+ try {
+ inReplyTo = part.getHeader("In Reply To");
+ } catch (MessagingException me) {
+ if (DEBUG) getLogger().debug("Messaging Exception for getHeader(In Reply To): " + me);
+ }
+ try {
+ date = part.getHeader("Date");
+ } catch (MessagingException me) {
+ if (DEBUG) getLogger().debug("Messaging Exception for getHeader(Date): " + me);
+ }
+ try {
+ messageID = part.getHeader("Message-ID");
+ } catch (MessagingException me) {
+ if (DEBUG) getLogger().debug("Messaging Exception for getHeader(messageID): " + me);
+ }
+ String contentTypeLine = null;
+ try {
+ contentTypeLine = part.getContentType();
+ } catch (MessagingException me) {
+ if (DEBUG) getLogger().debug("Messaging Exception for getContentType(): " + me);
+ }
+ if (contentTypeLine !=null ) {
+ decodeContentType(contentTypeLine);
+ }
+ try {
+ contentID = part.getContentID();
+ } catch (MessagingException me) {
+ if (DEBUG) getLogger().debug("Messaging Exception for getContentUD(): " + me);
+ }
+ try {
+ contentDesc = part.getDescription();
+ } catch (MessagingException me) {
+ if (DEBUG) getLogger().debug("Messaging Exception for getDescription(): " + me);
+ }
+ try {
+ contentEncoding = part.getEncoding();
+ // default value.
+ if ( contentEncoding == null ) {
+ contentEncoding = "7BIT";
+ }
+ } catch (MessagingException me) {
+ if (DEBUG) getLogger().debug("Messaging Exception for getEncoding(): " + me);
+ }
+ if (DEBUG) {
+ try {
+ String contentDisposition = part.getDisposition();
+ } catch (MessagingException me) {
+ getLogger().debug("Messaging Exception for getEncoding(): " + me);
+ }
+ }
+
+ try {
+ // TODO this doesn't work
+ lineCount = part.getLineCount();
+ } catch (MessagingException me) {
+ if (DEBUG) getLogger().debug("Messaging Exception for getLineCount(): " + me);
+ } catch (Exception e) {
+ if (DEBUG) getLogger().debug("Exception for getLineCount(): " + e);
+ }
+
+ // Recurse through any embedded parts
+ if (primaryType.equalsIgnoreCase(MULTIPART)) {
+ MimeMultipart container;
+ try {
+ container =(MimeMultipart) part.getContent();
+ int count = container.getCount();
+ parts = new SimpleMessageAttributes[count];
+ for (int i = 0; i < count ; i ++) {
+ BodyPart nextPart = container.getBodyPart(i);
+
+ if (nextPart instanceof MimePart) {
+ SimpleMessageAttributes partAttrs = new SimpleMessageAttributes();
+ setupLogger(partAttrs); // reset transient logger
+ partAttrs.parseMimePart((MimePart)nextPart);
+ parts[i] = partAttrs;
+
+ } else {
+ getLogger().info("Found a non-Mime bodyPart");
+ }
+ }
+ } catch (Exception e) {
+ getLogger().debug("Messaging Exception for getContent(): " + e);
+ e.printStackTrace();
+ }
+ } else if (primaryType.equalsIgnoreCase("message")) {
+ getLogger().info("This part contains an embedded message of subtype: " + secondaryType);
+ getLogger().info("Uses java class: " + part.getClass().getName());
+ if (secondaryType.equalsIgnoreCase("RFC822")) {
+ //try {
+
+ /*
+ MimeMessageWrapper message = new MimeMessageWrapper(part.getInputStream());
+ SimpleMessageAttributes msgAttrs = new SimpleMessageAttributes();
+ msgAttrs.setAttributesFor(message);
+
+ if (part instanceof MimeMessage) {
+ Comments out because I don't know what it should do here
+ MimeMessage msg1 = (MimeMessage) part;
+ MimeMessageWrapper message2 = new MimeMessageWrapper(msg1);
+ SimpleMessageAttributes msgAttrs2 = new SimpleMessageAttributes();
+ msgAttrs.setAttributesFor(message2);
+ }
+
+ parts = new SimpleMessageAttributes[1];
+ parts[0] = msgAttrs;
+ */
+ //} catch (Exception e) {
+ //getLogger().error("Error interpreting a message/rfc822: " + e);
+ //e.printStackTrace();
+ //}
+ } else {
+ getLogger().info("Unknown subtype of message encountered.");
+ System.out.println("Unknown subtype of message encountered.");
+ }
+ }
+ else {
+// System.out.println("parseMimePart: its just a plain message");
+ }
+ }
+
+ /**
+ * Builds IMAP envelope String from pre-parsed data.
+ */
+ String parseEnvelope() {
+ List response = new ArrayList();
+ response.add( LB + Q + internalDateString + Q + SP);
+ if (subject != null && (!subject.equals(""))) {
+ response.add( Q + subject + Q + SP );
+ } else {
+ response.add( NIL + SP );
+ }
+ if (from != null && from.length > 0) {
+ response.add(LB);
+ for (int i=0; i<from.length; i++) {
+ response.add(parseAddress( from[i]) );
+ }
+ response.add(RB);
+ } else {
+ response.add( NIL);
+ }
+ response.add(SP);
+ if (sender != null && sender.length >0) {
+ if (DEBUG) getLogger().debug("parsingEnvelope - sender[0] is: " + sender[0]);
+ //Check for Netscape feature - sender is local part only
+ if (sender[0].indexOf("@") == -1) {
+ response.add(LB + (String)response.get(3) + RB); //first From address
+ } else {
+ response.add(LB);
+ for (int i=0; i<sender.length; i++) {
+ response.add( parseAddress(sender[i]));
+ }
+ response.add(RB);
+ }
+ } else {
+ if (from != null && from.length > 0) {
+ response.add(LB + (String)response.get(3) + RB); //first From address
+ } else {
+ response.add( NIL);
+ }
+ }
+ response.add(SP);
+ if (replyTo != null && replyTo.length >0) {
+ if (replyTo[0].indexOf("@") == -1) {
+ response.add(LB + (String)response.get(3) + RB); //first From address
+ } else {
+ response.add(LB);
+ for (int i=0; i<replyTo.length; i++) {
+ response.add( parseAddress(replyTo[i]));
+ }
+ response.add(RB);
+ }
+ } else {
+ if (from != null && from.length > 0) {
+ response.add(LB + (String)response.get(3) + RB); //first From address
+ } else {
+ response.add( NIL);
+ }
+ }
+ response.add(SP);
+ if (to != null && to.length >0) {
+ response.add(LB);
+ for (int i=0; i<to.length; i++) {
+ response.add( parseAddress(to[i]));
+ }
+ response.add(RB);
+ } else {
+ response.add( NIL);
+ }
+ response.add(SP);
+ if (cc != null && cc.length >0) {
+ response.add(LB);
+ for (int i=0; i<cc.length; i++) {
+ response.add( parseAddress(cc[i]));
+ }
+ response.add(RB);
+ } else {
+ response.add( NIL);
+ }
+ response.add(SP);
+ if (bcc != null && bcc.length >0) {
+ response.add(LB);
+ for (int i=0; i<bcc.length; i++) {
+ response.add( parseAddress(bcc[i]));
+ }
+ response.add(RB);
+ } else {
+ response.add( NIL);
+ }
+ response.add(SP);
+ if (inReplyTo != null && inReplyTo.length>0) {
+ response.add( inReplyTo[0]);
+ } else {
+ response.add( NIL);
+ }
+ response.add(SP);
+ if (messageID != null && messageID.length>0) {
+ response.add(Q + messageID[0] + Q);
+ } else {
+ response.add( NIL);
+ }
+ response.add(RB);
+
+ StringBuffer buf = new StringBuffer(16 * response.size());
+ for (int j=0; j<response.size(); j++) {
+ buf.append((String)response.get(j));
+ }
+
+ return buf.toString();
+ }
+
+ /**
+ * Parses a String email address to an IMAP address string.
+ */
+ String parseAddress(String address) {
+ int comma = address.indexOf(",");
+ StringBuffer buf = new StringBuffer();
+ if (comma == -1) { //single address
+ buf.append(LB);
+ InternetAddress netAddr = null;
+ try {
+ netAddr = new InternetAddress(address);
+ } catch (AddressException ae) {
+ return null;
+ }
+ String personal = netAddr.getPersonal();
+ if (personal != null && (!personal.equals(""))) {
+ buf.append(Q + personal + Q);
+ } else {
+ buf.append( NIL);
+ }
+ buf.append( SP);
+ buf.append( NIL) ; // should add route-addr
+ buf.append( SP);
+ try {
+ MailAddress mailAddr = new MailAddress(netAddr);
+ buf.append(Q + mailAddr.getUser() + Q);
+ buf.append(SP);
+ buf.append(Q + mailAddr.getHost() + Q);
+ } catch (ParseException pe) {
+ buf.append( NIL + SP + NIL);
+ }
+ buf.append(RB);
+ } else {
+ buf.append(parseAddress(address.substring(0, comma)));
+ buf.append(SP);
+ buf.append(parseAddress(address.substring(comma + 1)));
+ }
+ return buf.toString();
+ }
+
+ /**
+ * Decode a content Type header line into types and parameters pairs
+ */
+ void decodeContentType(String rawLine) {
+ int slash = rawLine.indexOf("/");
+ if( slash == -1){
+ if (DEBUG) getLogger().debug("decoding ... no slash found");
+ return;
+ } else {
+ primaryType = rawLine.substring(0, slash).trim();
+ }
+ int semicolon = rawLine.indexOf(";");
+ if (semicolon == -1) {
+ if (DEBUG) getLogger().debug("decoding ... no semicolon found");
+ secondaryType = rawLine.substring(slash + 1).trim();
+ return;
+ }
+ // have parameters
+ parameters = new HashSet();
+ secondaryType = rawLine.substring(slash + 1, semicolon).trim();
+ int pos = semicolon;
+ int nextsemi = rawLine.indexOf(";", pos+1);
+ while (nextsemi != -1) {
+ if (DEBUG) getLogger().debug("decoding ... found another semicolon");
+ String param = rawLine.substring(pos + 1, nextsemi);
+ int esign = param.indexOf("=") ;
+ if (esign == -1) {
+ if (DEBUG) getLogger().debug("Whacky parameter found: " + param);
+ } else {
+ String name = param.substring(0, esign).trim();
+ String value = param.substring(esign + 1).trim();
+ parameters.add(name + SP + value);
+ if (DEBUG) getLogger().debug("Found parameter: " + name + SP + value);
+ }
+ pos = nextsemi;
+ nextsemi = rawLine.indexOf(";", pos +1);
+ }
+ String lastParam = rawLine.substring(pos + 1);
+ int esign = lastParam.indexOf("=") ;
+ if (esign == -1) {
+ if (DEBUG) getLogger().debug("Whacky parameter found: " + lastParam);
+ } else {
+ String name = lastParam.substring(0, esign).trim();
+ String value = lastParam.substring(esign + 1).trim();
+ parameters.add(Q + name + Q + SP + Q + value + Q);
+ if (DEBUG) getLogger().debug("Found parameter: " + name + SP + value);
+ }
+ }
+
+ String parseBodyFields() {
+ StringBuffer buf = new StringBuffer();
+ if (parameters == null || parameters.isEmpty()) {
+ buf.append(NIL);
+ } else {
+ buf.append(LB);
+ Iterator it = parameters.iterator();
+ while(it.hasNext()) {
+ buf.append((String)it.next());
+ }
+ buf.append(RB);
+ }
+ buf.append(SP);
+ if(contentID == null) {
+ buf.append(NIL);
+ } else {
+ buf.append(Q + contentID + Q);
+ }
+ buf.append(SP);
+ if(contentDesc == null) {
+ buf.append(NIL);
+ } else {
+ buf.append(Q + contentDesc + Q);
+ }
+ buf.append(SP);
+ if(contentEncoding == null) {
+ buf.append( NIL );
+ } else {
+ buf.append(Q + contentEncoding + Q);
+ }
+ buf.append(SP);
+ buf.append(size);
+ return buf.toString();
+ }
+
+ /**
+ * Produce the IMAP formatted String for the BodyStructure of a pre-parsed MimeMessage
+ * TODO handle extension elements - Content-disposition, Content-Language and other parameters.
+ */
+ String parseBodyStructure() {
+ try {
+ String fields = parseBodyFields();
+ StringBuffer buf = new StringBuffer();
+ buf.append(LB);
+ if (primaryType.equalsIgnoreCase("Text")) {
+ buf.append("\"TEXT\" \"" );
+ buf.append( secondaryType.toUpperCase() );
+ buf.append( "\" ");
+ buf.append( fields );
+ buf.append( " " );
+ buf.append( lineCount );
+
+ // is: * 1 FETCH (BODYSTRUCTURE ("Text" "plain" NIL NIL NIL NIL 4 -1))
+ // wants: * 1 FETCH (BODYSTRUCTURE ("text" "plain" NIL NIL NIL "8bit" 6 1 NIL NIL NIL))
+ // or: * 1 FETCH (BODYSTRUCTURE ("text" "plain" NIL NIL NIL "7bit" 28 1 NIL NIL NIL))
+
+ } else if (primaryType.equalsIgnoreCase(MESSAGE) && secondaryType.equalsIgnoreCase("rfc822")) {
+ buf.append("\"MESSAGE\" \"RFC822\" ");
+ buf.append(fields + SP);
+ setupLogger(parts[0]); // reset transient logger
+ buf.append(parts[0].getEnvelope() + SP);
+ buf.append(parts[0].getBodyStructure( false ) + SP);
+ buf.append(lineCount);
+ } else if (primaryType.equalsIgnoreCase(MULTIPART)) {
+ for (int i=0; i<parts.length; i++) {
+ setupLogger(parts[i]); // reset transient getLogger()
+ buf.append(parts[i].getBodyStructure( false ));
+ }
+ buf.append(SP + secondaryType);
+ }
+ buf.append(RB);
+ return buf.toString();
+ } catch (Exception e) {
+ getLogger().error("Exception while parsing BodyStrucuture: " + e);
+ e.printStackTrace();
+ throw new RuntimeException("Exception in parseBodyStructure");
+ }
+ }
+
+ /**
+ * Provides the current Message Sequence Number for this message. MSNs
+ * change when messages are expunged from the mailbox.
+ *
+ * @return int a positive non-zero integer
+ */
+ public int getMessageSequenceNumber() {
+ return messageSequenceNumber;
+ }
+
+ void setMessageSequenceNumber(int newMsn) {
+ messageSequenceNumber = newMsn;
+ }
+
+
+ /**
+ * Provides the unique identity value for this message. UIDs combined with
+ * a UIDValidity value form a unique reference for a message in a given
+ * mailbox. UIDs persist across sessions unless the UIDValidity value is
+ * incremented. UIDs are not copied if a message is copied to another
+ * mailbox.
+ *
+ * @return int a 32-bit value
+ */
+ public int getUID() {
+ return uid;
+ }
+
+ /**
+ * Provides the date and time at which the message was received. In the
+ * case of delivery by SMTP, this SHOULD be the date and time of final
+ * delivery as defined for SMTP. In the case of messages copied from
+ * another mailbox, it shuld be the internalDate of the source message. In
+ * the case of messages Appended to the mailbox, example drafts, the
+ * internalDate is either specified in the Append command or is the
+ * current dat and time at the time of the Append.
+ *
+ * @return Date imap internal date
+ */
+ public Date getInternalDate() {
+ return internalDate;
+ }
+
+ public String getInternalDateAsString() {
+ return internalDateString;
+ }
+
+ /**
+ * Provides the sizeof the message in octets.
+ *
+ * @return int number of octets in message.
+ */
+ public int getSize() {
+ return size;
+ }
+
+ /**
+ * Provides the Envelope structure information for this message. This is a parsed representation of the rfc-822 envelope information. This is not to be confused with the SMTP envelope!
+ *
+ * @return String satisfying envelope syntax in rfc 2060.
+ */
+ public String getEnvelope() {
+ return parseEnvelope();
+ }
+
+ /**
+ * Provides the Body Structure information for this message. This is a parsed representtion of the MIME structure of the message.
+ *
+ * @return String satisfying body syntax in rfc 2060.
+ */
+ public String getBodyStructure( boolean includeExtensions ) {
+ return parseBodyStructure();
+ }
+}
Added: james/server/sandbox/imap-integration/src/java/org/apache/james/mailboxmanager/Constants.java
URL: http://svn.apache.org/viewvc/james/server/sandbox/imap-integration/src/java/org/apache/james/mailboxmanager/Constants.java?view=auto&rev=454432
==============================================================================
--- james/server/sandbox/imap-integration/src/java/org/apache/james/mailboxmanager/Constants.java (added)
+++ james/server/sandbox/imap-integration/src/java/org/apache/james/mailboxmanager/Constants.java Mon Oct 9 10:15:30 2006
@@ -0,0 +1,9 @@
+package org.apache.james.mailboxmanager;
+
+public interface Constants {
+
+ public final long UID_INFINITY=-1;
+
+ public final int MSN_INFINITY=-1;
+
+}
Added: james/server/sandbox/imap-integration/src/java/org/apache/james/mailboxmanager/GeneralMessageSet.java
URL: http://svn.apache.org/viewvc/james/server/sandbox/imap-integration/src/java/org/apache/james/mailboxmanager/GeneralMessageSet.java?view=auto&rev=454432
==============================================================================
--- james/server/sandbox/imap-integration/src/java/org/apache/james/mailboxmanager/GeneralMessageSet.java (added)
+++ james/server/sandbox/imap-integration/src/java/org/apache/james/mailboxmanager/GeneralMessageSet.java Mon Oct 9 10:15:30 2006
@@ -0,0 +1,36 @@
+package org.apache.james.mailboxmanager;
+
+import javax.mail.Message;
+
+/**
+ * Used to define a range of messages by uid or msn, or a individual message by key or message object.<br />
+ * The type of the set should be defined by using an appropriate constructor.
+ *
+ */
+
+public interface GeneralMessageSet {
+
+ public static int TYPE_NONE=0;
+ public static int TYPE_MSN=1;
+ public static int TYPE_UID=2;
+ public static int TYPE_KEY=4;
+ public static int TYPE_MESSAGE=8;
+ public static int TYPE_ALL=16;
+
+ int getType();
+
+ long getUidFrom();
+
+ long getUidTo();
+
+ int getMsnFrom();
+
+ int getMsnTo();
+
+ String getKey();
+
+ Message getMessage();
+
+ boolean isValid();
+
+}
Added: james/server/sandbox/imap-integration/src/java/org/apache/james/mailboxmanager/ListResult.java
URL: http://svn.apache.org/viewvc/james/server/sandbox/imap-integration/src/java/org/apache/james/mailboxmanager/ListResult.java?view=auto&rev=454432
==============================================================================
--- james/server/sandbox/imap-integration/src/java/org/apache/james/mailboxmanager/ListResult.java (added)
+++ james/server/sandbox/imap-integration/src/java/org/apache/james/mailboxmanager/ListResult.java Mon Oct 9 10:15:30 2006
@@ -0,0 +1,23 @@
+package org.apache.james.mailboxmanager;
+
+/**
+ * Returned by the list method of MailboxRepository and others
+ */
+
+public interface ListResult {
+
+ /**
+ * \Noinferiors, \Noselect, \Marked, \Unmarked TODO this should be done in a different way..
+ * @return
+ */
+ String[] getAttributes();
+
+ String getHierarchyDelimiter();
+
+ /**
+ * @return full namespace-name
+ */
+
+ String getName();
+
+}
Added: james/server/sandbox/imap-integration/src/java/org/apache/james/mailboxmanager/MailboxListener.java
URL: http://svn.apache.org/viewvc/james/server/sandbox/imap-integration/src/java/org/apache/james/mailboxmanager/MailboxListener.java?view=auto&rev=454432
==============================================================================
--- james/server/sandbox/imap-integration/src/java/org/apache/james/mailboxmanager/MailboxListener.java (added)
+++ james/server/sandbox/imap-integration/src/java/org/apache/james/mailboxmanager/MailboxListener.java Mon Oct 9 10:15:30 2006
@@ -0,0 +1,37 @@
+/***********************************************************************
+ * Copyright (c) 2000-2004 The Apache Software Foundation. *
+ * All rights reserved. *
+ * ------------------------------------------------------------------- *
+ * Licensed 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.mailboxmanager;
+
+/**
+ * Receives Events from a ImapMailbox <br />
+ * TODO Maybe use only one receiving method with an MailboxEvent object
+ */
+
+public interface MailboxListener {
+
+ void expunged(MessageResult mr);
+
+ void added(MessageResult result);
+
+ void flagsUpdated(MessageResult result, MailboxListener silentListener);
+
+ void mailboxDeleted();
+
+ void mailboxRenamed(String origName, String newName);
+
+}
\ No newline at end of file
Added: james/server/sandbox/imap-integration/src/java/org/apache/james/mailboxmanager/MailboxManagerException.java
URL: http://svn.apache.org/viewvc/james/server/sandbox/imap-integration/src/java/org/apache/james/mailboxmanager/MailboxManagerException.java?view=auto&rev=454432
==============================================================================
--- james/server/sandbox/imap-integration/src/java/org/apache/james/mailboxmanager/MailboxManagerException.java (added)
+++ james/server/sandbox/imap-integration/src/java/org/apache/james/mailboxmanager/MailboxManagerException.java Mon Oct 9 10:15:30 2006
@@ -0,0 +1,44 @@
+/***********************************************************************
+ * Copyright (c) 2000-2004 The Apache Software Foundation. *
+ * All rights reserved. *
+ * ------------------------------------------------------------------- *
+ * Licensed 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.mailboxmanager;
+
+public class MailboxManagerException extends Exception {
+
+ private static final long serialVersionUID = -7034955921835169361L;
+
+ private Exception cause;
+
+ private String message;
+
+ public MailboxManagerException(Exception e) {
+ cause=e;
+ message="MailboxException caused by "+cause;
+ }
+
+ public MailboxManagerException(String string) {
+ message=string;
+ }
+
+ public Throwable getCause() {
+ return cause;
+ }
+
+ public String getMessage() {
+ return message;
+ }
+}
Added: james/server/sandbox/imap-integration/src/java/org/apache/james/mailboxmanager/MessageResult.java
URL: http://svn.apache.org/viewvc/james/server/sandbox/imap-integration/src/java/org/apache/james/mailboxmanager/MessageResult.java?view=auto&rev=454432
==============================================================================
--- james/server/sandbox/imap-integration/src/java/org/apache/james/mailboxmanager/MessageResult.java (added)
+++ james/server/sandbox/imap-integration/src/java/org/apache/james/mailboxmanager/MessageResult.java Mon Oct 9 10:15:30 2006
@@ -0,0 +1,117 @@
+package org.apache.james.mailboxmanager;
+
+import java.util.Date;
+
+import javax.mail.Flags;
+import javax.mail.internet.MimeMessage;
+
+import org.apache.mailet.Mail;
+
+/**
+ * <p>
+ * Used to get specific informations about a Message without dealing with a
+ * MimeMessage instance. Demanded information can be requested by binary
+ * combining the constants.
+ * </p>
+ *
+ * <p>
+ * I came to the Idea of the MessageResult because there are many possible
+ * combinations of different requests (uid, msn, MimeMessage, Flags).
+ * </p>
+ * <p>
+ * e.g. I want to have all uids, msns and flags of all messages. (a common IMAP
+ * operation) Javamail would do it that way:
+ * <ol>
+ * <li>get all Message objects (Message[])</li>
+ * <li>call Message.getMessageNumber() </li>
+ * <li>call Message.getFlags() </li>
+ * <li>call Folder.getUid(Message)</li>
+ * </ol>
+ * <p>
+ * This means creating a lazy-loading MimeMessage instance. </br> So why don't
+ * call getMessages(MessageResult.UID | MessageResult.MSN |
+ * MessageResult.FLAGS)? This would leave a lot of room for the implementation
+ * to optimize
+ * </p>
+ *
+ *
+ */
+
+public interface MessageResult extends Comparable {
+
+ /**
+ * For example: could have best performance when doing store and then
+ * forget.
+ */
+ public static final int NOTHING = 0x00;
+
+ /**
+ *
+ */
+ public static final int MIME_MESSAGE = 0x01;
+
+ /**
+ * return a complete mail object
+ */
+ public static final int MAIL = 0x02;
+
+ public static final int UID = 0x04;
+
+ public static final int MSN = 0x08;
+
+ /**
+ * return a string baded key (used by James)
+ */
+ public static final int KEY = 0x10;
+
+ public static final int SIZE = 0x20;
+
+ public static final int INTERNAL_DATE = 0x40;
+
+ public static final int FLAGS = 0x80;
+
+ int getIncludedResults();
+
+ boolean contains(int result);
+
+ MimeMessage getMimeMessage();
+
+ long getUid();
+
+ long getUidValidity();
+
+ int getMsn();
+
+ /**
+ *
+ * <p>
+ * IMAP defines this as the time when the message has arrived to the server
+ * (by smtp). Clients are also allowed to set the internalDate on apppend.
+ * </p>
+ * <p>
+ * Is this Mail.getLastUpdates() for James delivery? Should we use
+ * MimeMessage.getReceivedDate()?
+ * </p>
+ *
+ * @return
+ */
+
+ Date getInternalDate();
+
+ /**
+ * TODO optional, to be decided <br />
+ * maybe this is a good thing because IMAP often requests only the Flags and
+ * this way we don't need to create a lazy-loading MimeMessage instance just
+ * for the Flags.
+ *
+ * @return
+ */
+ Flags getFlags();
+
+ Mail getMail();
+
+ String getKey();
+
+ int getSize();
+
+}
Added: james/server/sandbox/imap-integration/src/java/org/apache/james/mailboxmanager/Namespace.java
URL: http://svn.apache.org/viewvc/james/server/sandbox/imap-integration/src/java/org/apache/james/mailboxmanager/Namespace.java?view=auto&rev=454432
==============================================================================
--- james/server/sandbox/imap-integration/src/java/org/apache/james/mailboxmanager/Namespace.java (added)
+++ james/server/sandbox/imap-integration/src/java/org/apache/james/mailboxmanager/Namespace.java Mon Oct 9 10:15:30 2006
@@ -0,0 +1,12 @@
+package org.apache.james.mailboxmanager;
+
+/**
+ * A namespace consists of the name and a hierarchy delimiter (e.g "." or "/")
+ */
+
+public interface Namespace {
+
+ String getName();
+ String getHierarchyDelimter();
+
+}
Added: james/server/sandbox/imap-integration/src/java/org/apache/james/mailboxmanager/Namespaces.java
URL: http://svn.apache.org/viewvc/james/server/sandbox/imap-integration/src/java/org/apache/james/mailboxmanager/Namespaces.java?view=auto&rev=454432
==============================================================================
--- james/server/sandbox/imap-integration/src/java/org/apache/james/mailboxmanager/Namespaces.java (added)
+++ james/server/sandbox/imap-integration/src/java/org/apache/james/mailboxmanager/Namespaces.java Mon Oct 9 10:15:30 2006
@@ -0,0 +1,14 @@
+package org.apache.james.mailboxmanager;
+
+/**
+ * Provides the existing namespaces
+ */
+
+public interface Namespaces {
+
+ Namespace getPersonalDefault();
+ Namespace[] getPersonal();
+ Namespace[] getShared();
+ Namespace[] getUser();
+
+}
Added: james/server/sandbox/imap-integration/src/java/org/apache/james/mailboxmanager/Purger.java
URL: http://svn.apache.org/viewvc/james/server/sandbox/imap-integration/src/java/org/apache/james/mailboxmanager/Purger.java?view=auto&rev=454432
==============================================================================
--- james/server/sandbox/imap-integration/src/java/org/apache/james/mailboxmanager/Purger.java (added)
+++ james/server/sandbox/imap-integration/src/java/org/apache/james/mailboxmanager/Purger.java Mon Oct 9 10:15:30 2006
@@ -0,0 +1,93 @@
+package org.apache.james.mailboxmanager;
+
+import javax.mail.Flags;
+
+/**
+ * bound to a quota object and will be called when quota has exceeded
+ *
+ * <h4>Milestone 7</h4>
+ *
+ * The first action of the Purger is expunging all \Deleted messages. If
+ * the quota limit is still exceeded it will start with the oldest message.
+ *
+ */
+
+public interface Purger {
+
+ boolean isEnabled();
+
+ void setEnabled(boolean enabled);
+
+ /**
+ * <p>
+ * If set, purged messages are moved to this destination. If moving fails
+ * for any reason, messages will not be purged.
+ * </p>
+ * <p>
+ * If not set (null) messages will be expunged from the mailbox at once
+ * </p>
+ *
+ * @return destination mailbox, null if messages will be expunged.
+ */
+
+ String getDestination();
+
+ /**
+ * @param destination
+ * destination mailbox, null if messages will be expunged.
+ */
+
+ void setDestination(String destination);
+
+ /**
+ * The minimal age in days of messages that are allowed to be purged.
+ *
+ * @return minimal age in days. 0 if all message could be purged
+ */
+
+ int getMinimalAge();
+
+ /**
+ *
+ * @param days minimal age in days. 0 if all message could be purged
+ */
+ void setMinimalAge(int days);
+
+ /**
+ * <p>Message that are considered for purging have to have one of this flags.</p>
+ * <p>A common example could be the \Seen Flag to only purge seen messages</p>
+ *
+ * @return flags to purge
+ */
+
+ Flags getDoPurgeFlags();
+
+ /**
+ * @param flags flags to purge
+ */
+
+ void setDoPurgeFlags(Flags flags);
+
+ /**
+ * <p>Messages that have one of this Flags will not be purged.</p>
+ * <p>A common example would be marking interesting/important messages a mailing list. This could be
+ * done with the \Flagged flag that is supported by various clients</p>
+ *
+ * @return flags not to purge, may be null
+ */
+ Flags getDontPurgeFlags();
+
+ /**
+ *
+ * @param flags flags not to purge, may be null
+ */
+
+ void setDontPurgeFlags(Flags flags);
+
+ /**
+ * Presists the changes. Implementations may decide to persist changes at once.
+ */
+
+ void save();
+
+}
Added: james/server/sandbox/imap-integration/src/java/org/apache/james/mailboxmanager/Quota.java
URL: http://svn.apache.org/viewvc/james/server/sandbox/imap-integration/src/java/org/apache/james/mailboxmanager/Quota.java?view=auto&rev=454432
==============================================================================
--- james/server/sandbox/imap-integration/src/java/org/apache/james/mailboxmanager/Quota.java (added)
+++ james/server/sandbox/imap-integration/src/java/org/apache/james/mailboxmanager/Quota.java Mon Oct 9 10:15:30 2006
@@ -0,0 +1,223 @@
+package org.apache.james.mailboxmanager;
+
+
+
+/**
+ * Quota for a list of mailboxes.
+ * <h4>Milestone 5</h4>
+ * <p>
+ * Quotas are not treated hierarchically but have to be set for each mailbox
+ * individually. When a mailbox is created or renamed, it has to inherit the
+ * quota of its parent folder. An instantiated Quota object has to be setup
+ * with the accessing user for further credential checks.
+ * </p>
+ * <p>
+ * Implementation of quota management could of course be done in a hierarchy
+ * way.
+ * </p>
+ *
+ * <p>
+ * I came to the conclusion that it makes no sense to have user specific quotas.
+ * <p>
+ *
+ */
+public interface Quota {
+
+ /**
+ * <p>
+ * The root mailbox for this quota. All mailboxes that are assigned to this
+ * quota must be childs of the root mailbox or the root mailbox itself. If
+ * the quota spans several namespaces (#news., #mail.,#shared.) root mailbox
+ * can be an empty string (""). That means it is bound to the namespace root.
+ * </p>
+ * <p>
+ * Users are limited to create quotas with a root mailbox they have the
+ * rights to manage quota for. Administrators should use a suitable root
+ * mailbox where ever possible for better clarity.
+ * </p>
+ * <p>
+ * When the root mailbox is deleted the assigned quotas will be deleted too.
+ * If the root mailbox gets moved to another parent quota is deleted too,
+ * because the moved mailboxes have to inherit the quota of its new parents.
+ * </p>
+ *
+ * @return root mailbox
+ */
+
+ String getRootMailbox();
+
+ /**
+ *
+ * @param rootMailbox
+ * the root mailbox
+ */
+ void setRootMailbox(String rootMailbox);
+
+ /**
+ * <p>Indicates that the user needs quota management rights to the parent mailbox of root
+ * mailbox to be able to manage this quota</p>
+ * <p>Example: A user should be able to setup and manage quotas in his own mailboxes. But he
+ * should not be able to modify/delete the quota setup by his admin. NeedsParentRights would be
+ * set true and the admin would need to have the quota management right for "#mail"</p>
+ * <p>If needsParentRights is false this could be understood like a self-control quota</p>
+ *
+ * @return true, if user needs quota management rights to parent folder to manage this quota
+ */
+
+ boolean getNeedsParentRights();
+
+ /**
+ *
+ * @param needsParentRights true, if user needs quota management rights to parent folder to manage this quota
+ */
+ void setNeedsParentRights(boolean needsParentRights);
+
+ /**
+ * <p>
+ * The name of this quota which could be free chosen. The name has to be
+ * unique for the root mailbox. Some implementation specific names may be
+ * reserved like "user_mailbox_quota" that is setup by the administrator for every
+ * user.
+ * </p>
+ * <p>
+ * From the imap view the name is a combination of root mailbox and name
+ * separated by a semi colon ";". For example user joe sets up a quota for
+ * his trash folder: "#mail.joe.trash;my_trash_quota"
+ * </p>
+ *
+ * @return the name
+ */
+
+ String getName();
+
+ /**
+ * List mailboxes that are assigned to this quota.
+ *
+ * @param base
+ * @param expression
+ * @return
+ */
+
+ ListResult[] list(String base, String expression);
+
+ /**
+ * Add a Mailbox to this quota. (This is not performed hierarchically) You
+ * can only add mailboxes that belong to the same repository.
+ *
+ * @param name
+ * mailbox name
+ * @param user
+ * to check credentials
+ * @throws IllegalArgumentException
+ * if the mailbox does not belong to this store TODO throw
+ * another exception
+ */
+
+ void addMailbox(String name);
+
+ /**
+ * Removes a Mailbox from this quota. (This is not performed hierarchically)
+ *
+ * @param name
+ * mailbox name
+ * @param user
+ * to check credentials
+ */
+
+ void removeMailbox(String name);
+
+ /**
+ * The total sum of messages in all mailboxes that belong to this quota
+ *
+ * @return message count
+ */
+
+ int getMessageCount();
+
+ /**
+ * The limit for getMessageCount()
+ *
+ * @return maximal message count or -1 if there is no limit
+ */
+
+ int getMessageCountLimit();
+
+ /**
+ *
+ * @param limit
+ * maximal message count or -1 if there is no limit
+ */
+ void setMessageCountLimit(int limit);
+
+ /**
+ * The total sum of storage usage in all mailboxes that belong to this quota
+ * in KiB (1024 bytes).
+ *
+ * @return storage usage
+ */
+
+ int getStorageUsage();
+
+ /**
+ * The limit for getStorageUsage()
+ *
+ * @return maximal storage usage or -1 if there is no limit
+ */
+ int getStorageUsageLimit();
+
+ /**
+ *
+ * @param limit
+ * maximal storage usage or -1 if there is no limit
+ */
+ void setStorageUsageLimit(int limit);
+
+ /**
+ * <p>
+ * The maximal allowed age (internal date) of messages in all mailboxes that
+ * belong to this quota in days.
+ * </p>
+ * <p>
+ * This will be interesting for mailing lists or news groups. Another
+ * possibility is to automaticly move old messages into an archive by the
+ * purger
+ * </p>
+ *
+ * @return maximal age in days or -1 if there is no limit
+ */
+ int getAgeLimit();
+
+ /**
+ *
+ * @param days
+ * maximal age in days or -1 if there is no limit
+ */
+
+ void setAgeLimit(int days);
+
+ /**
+ * <p>
+ * The purger that will come into action when the quota is exceeded in any
+ * way. Implementations may decide whether to trigger purging at once or at
+ * specific intervals or even manually.
+ * </p>
+ *
+ * @return the purger, null if there is no automatic purging
+ */
+
+ Purger getPurger();
+
+ /**
+ *
+ * @param purger
+ * the purger, null if there is no automatic purging
+ */
+ void setPurger(Purger purger);
+
+ /**
+ * Presists the changes. Implementations may decide to persist changes at
+ * once.
+ */
+
+ void save();
+}
Added: james/server/sandbox/imap-integration/src/java/org/apache/james/mailboxmanager/acl/Acl.java
URL: http://svn.apache.org/viewvc/james/server/sandbox/imap-integration/src/java/org/apache/james/mailboxmanager/acl/Acl.java?view=auto&rev=454432
==============================================================================
--- james/server/sandbox/imap-integration/src/java/org/apache/james/mailboxmanager/acl/Acl.java (added)
+++ james/server/sandbox/imap-integration/src/java/org/apache/james/mailboxmanager/acl/Acl.java Mon Oct 9 10:15:30 2006
@@ -0,0 +1,25 @@
+package org.apache.james.mailboxmanager.acl;
+
+
+/**
+ *
+ * order: allow/deny. An ACL will be attached to a mailbox with a belonging
+ * group or user. (extended by GroupAcl or UserAcl)
+ *
+ */
+
+public interface Acl {
+
+ /**
+ *
+ * Rights to grant
+ */
+ MailboxRights getPositiveRights();
+
+ /**
+ *
+ * Rights to be revoked. This rights cannot be granted anymore in anyway.
+ */
+ MailboxRights getNegativeRights();
+
+}
Added: james/server/sandbox/imap-integration/src/java/org/apache/james/mailboxmanager/acl/AclManager.java
URL: http://svn.apache.org/viewvc/james/server/sandbox/imap-integration/src/java/org/apache/james/mailboxmanager/acl/AclManager.java?view=auto&rev=454432
==============================================================================
--- james/server/sandbox/imap-integration/src/java/org/apache/james/mailboxmanager/acl/AclManager.java (added)
+++ james/server/sandbox/imap-integration/src/java/org/apache/james/mailboxmanager/acl/AclManager.java Mon Oct 9 10:15:30 2006
@@ -0,0 +1,33 @@
+package org.apache.james.mailboxmanager.acl;
+
+public interface AclManager {
+
+ /**
+ *
+ * @param mailboxName
+ * @param requestingUser to check credentials
+ * @return
+ */
+ GroupAcl[] getGroupAcls(String mailboxName);
+
+ /**
+ *
+ * @param mailboxName
+ * @param requestingUser to check credentials
+ * @return
+ */
+ UserAcl[] getUserAcls(String mailboxName);
+
+ /**
+ * If there are no rights granted/revoked corresponding acl will be removed
+ *
+ */
+ void setGroupAcls(String mailboxName, GroupAcl groupAclacl);
+
+
+ /**
+ * If there are no rights granted/revoked corresponding acl will be removed
+ *
+ */
+ void getUserAcls(String mailboxName, UserAcl userAcl);
+}
Added: james/server/sandbox/imap-integration/src/java/org/apache/james/mailboxmanager/acl/EffectiveRightsComputer.java
URL: http://svn.apache.org/viewvc/james/server/sandbox/imap-integration/src/java/org/apache/james/mailboxmanager/acl/EffectiveRightsComputer.java?view=auto&rev=454432
==============================================================================
--- james/server/sandbox/imap-integration/src/java/org/apache/james/mailboxmanager/acl/EffectiveRightsComputer.java (added)
+++ james/server/sandbox/imap-integration/src/java/org/apache/james/mailboxmanager/acl/EffectiveRightsComputer.java Mon Oct 9 10:15:30 2006
@@ -0,0 +1,32 @@
+package org.apache.james.mailboxmanager.acl;
+
+
+/**
+ *
+ * Used to compute the effective rights of a bunch of Acl objects bound to a
+ * mailbox. For a specific user there could be one user acl and multiple group
+ * acls that take effect. The proposed approach is allow/deny. This means first
+ * sum up all rights granted by group membership or user acl, then remove every
+ * right that is revoked.<br />
+ * Another approach could be that a right granted by a user acl cannot be
+ * revoked by a group acl.
+ *
+ */
+
+public interface EffectiveRightsComputer {
+
+ public void setUserAcl(UserAcl userAcl);
+
+ public void setGroupAcls(GroupAcl[] groupAcl);
+
+ /**
+ * used to filter the groups to retain only the ones the user is member of.<br 7>
+ * TODO just a draft...
+ *
+ * @param groups
+ */
+ public void retainGroups(String[] groupMemberships);
+
+ public MailboxRights computeEffective();
+
+}
---------------------------------------------------------------------
To unsubscribe, e-mail: server-dev-unsubscribe@james.apache.org
For additional commands, e-mail: server-dev-help@james.apache.org