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 ba...@apache.org on 2006/10/10 10:35:02 UTC

svn commit: r454662 [10/15] - in /james/server/sandbox/imap-integration: ./ 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/imapserver/store/ src...

Modified: 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=diff&rev=454662&r1=454661&r2=454662
==============================================================================
--- james/server/sandbox/imap-integration/src/java/org/apache/james/imapserver/store/SimpleMessageAttributes.java (original)
+++ james/server/sandbox/imap-integration/src/java/org/apache/james/imapserver/store/SimpleMessageAttributes.java Tue Oct 10 01:34:56 2006
@@ -1,641 +1,641 @@
-/****************************************************************
- * 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.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();
-    }
-}
+/****************************************************************
+ * 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.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();
+    }
+}

Propchange: james/server/sandbox/imap-integration/src/java/org/apache/james/imapserver/store/SimpleMessageAttributes.java
------------------------------------------------------------------------------
    svn:eol-style = native

Modified: 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=diff&rev=454662&r1=454661&r2=454662
==============================================================================
--- james/server/sandbox/imap-integration/src/java/org/apache/james/mailboxmanager/Constants.java (original)
+++ james/server/sandbox/imap-integration/src/java/org/apache/james/mailboxmanager/Constants.java Tue Oct 10 01:34:56 2006
@@ -1,9 +1,9 @@
 package org.apache.james.mailboxmanager;
 
 public interface Constants {
-	
-	public final long UID_INFINITY=-1;
-	
-	public final int MSN_INFINITY=-1;
+    
+    public final long UID_INFINITY=-1;
+    
+    public final int MSN_INFINITY=-1;
 
 }

Propchange: james/server/sandbox/imap-integration/src/java/org/apache/james/mailboxmanager/Constants.java
------------------------------------------------------------------------------
    svn:eol-style = native

Modified: 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=diff&rev=454662&r1=454661&r2=454662
==============================================================================
--- james/server/sandbox/imap-integration/src/java/org/apache/james/mailboxmanager/GeneralMessageSet.java (original)
+++ james/server/sandbox/imap-integration/src/java/org/apache/james/mailboxmanager/GeneralMessageSet.java Tue Oct 10 01:34:56 2006
@@ -9,27 +9,27 @@
  */
 
 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_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();
+    
+    int getType();
+    
+    long getUidFrom();
+    
+    long getUidTo();
+    
+    int getMsnFrom();
+    
+    int getMsnTo();
+    
+    String getKey();
+    
+    Message getMessage();
     
     boolean isValid();
 

Propchange: james/server/sandbox/imap-integration/src/java/org/apache/james/mailboxmanager/GeneralMessageSet.java
------------------------------------------------------------------------------
    svn:eol-style = native

Modified: 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=diff&rev=454662&r1=454661&r2=454662
==============================================================================
--- james/server/sandbox/imap-integration/src/java/org/apache/james/mailboxmanager/ListResult.java (original)
+++ james/server/sandbox/imap-integration/src/java/org/apache/james/mailboxmanager/ListResult.java Tue Oct 10 01:34:56 2006
@@ -5,19 +5,19 @@
  */
 
 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();
+    
+    /**
+     * \Noinferiors, \Noselect, \Marked, \Unmarked TODO this should be done in a different way..
+     * @return
+     */
+    String[] getAttributes();
+    
+    String getHierarchyDelimiter();
+    
+    /**
+     * @return full namespace-name
+     */
+    
+    String getName();
 
 }

Propchange: james/server/sandbox/imap-integration/src/java/org/apache/james/mailboxmanager/ListResult.java
------------------------------------------------------------------------------
    svn:eol-style = native

Modified: 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=diff&rev=454662&r1=454661&r2=454662
==============================================================================
--- james/server/sandbox/imap-integration/src/java/org/apache/james/mailboxmanager/MailboxListener.java (original)
+++ james/server/sandbox/imap-integration/src/java/org/apache/james/mailboxmanager/MailboxListener.java Tue Oct 10 01:34:56 2006
@@ -1,39 +1,39 @@
-/****************************************************************
- * 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.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
+/****************************************************************
+ * 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.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);
+    
+}

Propchange: james/server/sandbox/imap-integration/src/java/org/apache/james/mailboxmanager/MailboxListener.java
------------------------------------------------------------------------------
    svn:eol-style = native

Modified: 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=diff&rev=454662&r1=454661&r2=454662
==============================================================================
--- james/server/sandbox/imap-integration/src/java/org/apache/james/mailboxmanager/MailboxManagerException.java (original)
+++ james/server/sandbox/imap-integration/src/java/org/apache/james/mailboxmanager/MailboxManagerException.java Tue Oct 10 01:34:56 2006
@@ -1,46 +1,46 @@
-/****************************************************************
- * 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.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;
-    }
-}
+/****************************************************************
+ * 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.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;
+    }
+}

Propchange: james/server/sandbox/imap-integration/src/java/org/apache/james/mailboxmanager/MailboxManagerException.java
------------------------------------------------------------------------------
    svn:eol-style = native

Modified: 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=diff&rev=454662&r1=454661&r2=454662
==============================================================================
--- james/server/sandbox/imap-integration/src/java/org/apache/james/mailboxmanager/MessageResult.java (original)
+++ james/server/sandbox/imap-integration/src/java/org/apache/james/mailboxmanager/MessageResult.java Tue Oct 10 01:34:56 2006
@@ -39,78 +39,78 @@
 
 public interface MessageResult extends Comparable {
 
-	/**
-	 * For example: could have best performance when doing store and then
-	 * forget.
-	 */
-	public static final int NOTHING = 0x00;
+    /**
+     * 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;
+    /**
+     * 
+     */
+    public static final int MIME_MESSAGE = 0x01;
 
-	/**
-	 * return a complete mail object
-	 */
-	public static final int MAIL = 0x02;
+    /**
+     * return a complete mail object
+     */
+    public static final int MAIL = 0x02;
 
-	public static final int UID = 0x04;
+    public static final int UID = 0x04;
 
-	public static final int MSN = 0x08;
+    public static final int MSN = 0x08;
 
-	/**
-	 * return a string baded key (used by James)
-	 */
-	public static final int KEY = 0x10;
+    /**
+     * return a string baded key (used by James)
+     */
+    public static final int KEY = 0x10;
 
-	public static final int SIZE = 0x20;
+    public static final int SIZE = 0x20;
 
-	public static final int INTERNAL_DATE = 0x40;
+    public static final int INTERNAL_DATE = 0x40;
 
-	public static final int FLAGS = 0x80;
+    public static final int FLAGS = 0x80;
 
-	int getIncludedResults();
+    int getIncludedResults();
 
-	boolean contains(int result);
+    boolean contains(int result);
 
-	MimeMessage getMimeMessage();
+    MimeMessage getMimeMessage();
 
-	long getUid();
+    long getUid();
 
-	long getUidValidity();
+    long getUidValidity();
 
-	int getMsn();
+    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
-	 */
+    /**
+     * 
+     * <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();
+    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();
+    /**
+     * 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();
+    Mail getMail();
 
-	String getKey();
+    String getKey();
     
     int getSize();
 

Propchange: james/server/sandbox/imap-integration/src/java/org/apache/james/mailboxmanager/MessageResult.java
------------------------------------------------------------------------------
    svn:eol-style = native

Modified: 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=diff&rev=454662&r1=454661&r2=454662
==============================================================================
--- james/server/sandbox/imap-integration/src/java/org/apache/james/mailboxmanager/Namespace.java (original)
+++ james/server/sandbox/imap-integration/src/java/org/apache/james/mailboxmanager/Namespace.java Tue Oct 10 01:34:56 2006
@@ -5,8 +5,8 @@
  */
 
 public interface Namespace {
-	
-	String getName();
-	String getHierarchyDelimter();
+    
+    String getName();
+    String getHierarchyDelimter();
 
 }

Propchange: james/server/sandbox/imap-integration/src/java/org/apache/james/mailboxmanager/Namespace.java
------------------------------------------------------------------------------
    svn:eol-style = native

Modified: 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=diff&rev=454662&r1=454661&r2=454662
==============================================================================
--- james/server/sandbox/imap-integration/src/java/org/apache/james/mailboxmanager/Namespaces.java (original)
+++ james/server/sandbox/imap-integration/src/java/org/apache/james/mailboxmanager/Namespaces.java Tue Oct 10 01:34:56 2006
@@ -5,10 +5,10 @@
  */
 
 public interface Namespaces {
-	
-	Namespace getPersonalDefault();
-	Namespace[] getPersonal();
-	Namespace[] getShared();
-	Namespace[] getUser();
+    
+    Namespace getPersonalDefault();
+    Namespace[] getPersonal();
+    Namespace[] getShared();
+    Namespace[] getUser();
 
 }

Propchange: james/server/sandbox/imap-integration/src/java/org/apache/james/mailboxmanager/Namespaces.java
------------------------------------------------------------------------------
    svn:eol-style = native

Modified: 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=diff&rev=454662&r1=454661&r2=454662
==============================================================================
--- james/server/sandbox/imap-integration/src/java/org/apache/james/mailboxmanager/Purger.java (original)
+++ james/server/sandbox/imap-integration/src/java/org/apache/james/mailboxmanager/Purger.java Tue Oct 10 01:34:56 2006
@@ -14,80 +14,80 @@
 
 public interface Purger {
 
-	boolean isEnabled();
+    boolean isEnabled();
 
-	void setEnabled(boolean enabled);
+    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();
+    /**
+     * <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();
 
 }

Propchange: james/server/sandbox/imap-integration/src/java/org/apache/james/mailboxmanager/Purger.java
------------------------------------------------------------------------------
    svn:eol-style = native

Modified: 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=diff&rev=454662&r1=454661&r2=454662
==============================================================================
--- james/server/sandbox/imap-integration/src/java/org/apache/james/mailboxmanager/Quota.java (original)
+++ james/server/sandbox/imap-integration/src/java/org/apache/james/mailboxmanager/Quota.java Tue Oct 10 01:34:56 2006
@@ -23,201 +23,201 @@
  */
 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.
-	 */
+    /**
+     * <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();
+    void save();
 }

Propchange: james/server/sandbox/imap-integration/src/java/org/apache/james/mailboxmanager/Quota.java
------------------------------------------------------------------------------
    svn:eol-style = native

Modified: 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=diff&rev=454662&r1=454661&r2=454662
==============================================================================
--- james/server/sandbox/imap-integration/src/java/org/apache/james/mailboxmanager/acl/Acl.java (original)
+++ james/server/sandbox/imap-integration/src/java/org/apache/james/mailboxmanager/acl/Acl.java Tue Oct 10 01:34:56 2006
@@ -10,16 +10,16 @@
 
 public interface Acl {
 
-	/**
-	 * 
-	 * Rights to grant
-	 */
-	MailboxRights getPositiveRights();
+    /**
+     * 
+     * Rights to grant
+     */
+    MailboxRights getPositiveRights();
 
-	/**
-	 * 
-	 * Rights to be revoked. This rights cannot be granted anymore in anyway.
-	 */
-	MailboxRights getNegativeRights();
+    /**
+     * 
+     * Rights to be revoked. This rights cannot be granted anymore in anyway.
+     */
+    MailboxRights getNegativeRights();
 
 }

Propchange: james/server/sandbox/imap-integration/src/java/org/apache/james/mailboxmanager/acl/Acl.java
------------------------------------------------------------------------------
    svn:eol-style = native

Modified: 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=diff&rev=454662&r1=454661&r2=454662
==============================================================================
--- james/server/sandbox/imap-integration/src/java/org/apache/james/mailboxmanager/acl/AclManager.java (original)
+++ james/server/sandbox/imap-integration/src/java/org/apache/james/mailboxmanager/acl/AclManager.java Tue Oct 10 01:34:56 2006
@@ -1,33 +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);
+    
+    /**
+     * 
+     * @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);
 }



---------------------------------------------------------------------
To unsubscribe, e-mail: server-dev-unsubscribe@james.apache.org
For additional commands, e-mail: server-dev-help@james.apache.org