james-server-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From nor...@apache.org
Subject svn commit: r992965 - in /james/imap/trunk: mailbox/src/main/java/org/apache/james/imap/mailbox/ mailbox/src/main/java/org/apache/james/imap/mailbox/util/ torque/src/main/java/org/apache/james/mailboxmanager/torque/
Date Mon, 06 Sep 2010 08:05:52 GMT
Author: norman
Date: Mon Sep  6 08:05:52 2010
New Revision: 992965

URL: http://svn.apache.org/viewvc?rev=992965&view=rev
Log:
* Move LockException to torque module
* Remove UidRange and just use MessageRange because it serve the same purpose

Added:
    james/imap/trunk/torque/src/main/java/org/apache/james/mailboxmanager/torque/LockException.java
Removed:
    james/imap/trunk/mailbox/src/main/java/org/apache/james/imap/mailbox/LockException.java
    james/imap/trunk/mailbox/src/main/java/org/apache/james/imap/mailbox/util/UidRange.java
Modified:
    james/imap/trunk/mailbox/src/main/java/org/apache/james/imap/mailbox/MessageResult.java
    james/imap/trunk/mailbox/src/main/java/org/apache/james/imap/mailbox/util/MailboxEventDispatcher.java
    james/imap/trunk/mailbox/src/main/java/org/apache/james/imap/mailbox/util/MessageResultImpl.java
    james/imap/trunk/torque/src/main/java/org/apache/james/mailboxmanager/torque/TorqueMailbox.java
    james/imap/trunk/torque/src/main/java/org/apache/james/mailboxmanager/torque/UidChangeTracker.java

Modified: james/imap/trunk/mailbox/src/main/java/org/apache/james/imap/mailbox/MessageResult.java
URL: http://svn.apache.org/viewvc/james/imap/trunk/mailbox/src/main/java/org/apache/james/imap/mailbox/MessageResult.java?rev=992965&r1=992964&r2=992965&view=diff
==============================================================================
--- james/imap/trunk/mailbox/src/main/java/org/apache/james/imap/mailbox/MessageResult.java
(original)
+++ james/imap/trunk/mailbox/src/main/java/org/apache/james/imap/mailbox/MessageResult.java
Mon Sep  6 08:05:52 2010
@@ -138,10 +138,13 @@ public interface MessageResult extends C
 
     MimeDescriptor getMimeDescriptor() throws MailboxException;
 
+    /**
+     * Return the uid of the message which the MessageResult belongs to
+     * 
+     * @return uid
+     */
     long getUid();
 
-    long getUidValidity();
-
     /**
      * 
      * <p>
@@ -166,16 +169,14 @@ public interface MessageResult extends C
      */
     Flags getFlags() throws MailboxException;
 
-    long getSize();
-
     /**
-     * Gets headers for the message.
+     * Return the size in bytes
      * 
-     * @return <code>Header</code> <code>Iterator</code>, or null
if
-     *         {@link FetchGroup#HEADERS} was not fetched
+     * @return size
      */
-    Iterator<Header> headers() throws MailboxException;
+    long getSize();
 
+  
     /**
      * Iterates the message headers for the given part in a multipart message.
      * 

Modified: james/imap/trunk/mailbox/src/main/java/org/apache/james/imap/mailbox/util/MailboxEventDispatcher.java
URL: http://svn.apache.org/viewvc/james/imap/trunk/mailbox/src/main/java/org/apache/james/imap/mailbox/util/MailboxEventDispatcher.java?rev=992965&r1=992964&r2=992965&view=diff
==============================================================================
--- james/imap/trunk/mailbox/src/main/java/org/apache/james/imap/mailbox/util/MailboxEventDispatcher.java
(original)
+++ james/imap/trunk/mailbox/src/main/java/org/apache/james/imap/mailbox/util/MailboxEventDispatcher.java
Mon Sep  6 08:05:52 2010
@@ -264,9 +264,10 @@ public class MailboxEventDispatcher impl
             this.newPath = newPath;
         }
 
+
         /*
          * (non-Javadoc)
-         * @see org.apache.james.imap.mailbox.MailboxListener.MailboxRenamed#getNewName()
+         * @see org.apache.james.imap.mailbox.MailboxListener.MailboxRenamed#getNewPath()
          */
         public MailboxPath getNewPath() {
             return newPath;

Modified: james/imap/trunk/mailbox/src/main/java/org/apache/james/imap/mailbox/util/MessageResultImpl.java
URL: http://svn.apache.org/viewvc/james/imap/trunk/mailbox/src/main/java/org/apache/james/imap/mailbox/util/MessageResultImpl.java?rev=992965&r1=992964&r2=992965&view=diff
==============================================================================
--- james/imap/trunk/mailbox/src/main/java/org/apache/james/imap/mailbox/util/MessageResultImpl.java
(original)
+++ james/imap/trunk/mailbox/src/main/java/org/apache/james/imap/mailbox/util/MessageResultImpl.java
Mon Sep  6 08:05:52 2010
@@ -76,14 +76,6 @@ public class MessageResultImpl implement
         return uid;
     }
 
-    /*
-     * (non-Javadoc)
-     * @see org.apache.james.imap.mailbox.MessageResult#getUidValidity()
-     */
-    public long getUidValidity() {
-        // TODO implement or remove
-        return 0;
-    }
 
     /*
      * (non-Javadoc)

Added: james/imap/trunk/torque/src/main/java/org/apache/james/mailboxmanager/torque/LockException.java
URL: http://svn.apache.org/viewvc/james/imap/trunk/torque/src/main/java/org/apache/james/mailboxmanager/torque/LockException.java?rev=992965&view=auto
==============================================================================
--- james/imap/trunk/torque/src/main/java/org/apache/james/mailboxmanager/torque/LockException.java
(added)
+++ james/imap/trunk/torque/src/main/java/org/apache/james/mailboxmanager/torque/LockException.java
Mon Sep  6 08:05:52 2010
@@ -0,0 +1,56 @@
+/****************************************************************
+ * 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.torque;
+
+import java.util.concurrent.TimeUnit;
+import java.util.concurrent.locks.Lock;
+import org.apache.james.imap.api.display.HumanReadableText;
+import org.apache.james.imap.mailbox.MailboxException;
+
+/**
+ * Indicates that required locks cannot be acquired at this time.
+ */
+@Deprecated
+public class LockException extends MailboxException {
+
+    private static final long serialVersionUID = 698379731076300030L;
+
+    public LockException(HumanReadableText key, String message) {
+        super(key, message);
+    }
+
+    public LockException(HumanReadableText key) {
+        super(key);}
+
+    public LockException(HumanReadableText key, Exception cause) {
+        super(key, cause);
+    }
+
+    public static void tryLock(final Lock lock, final int timeoutInSeconds) throws LockException
{
+        try {
+            if (!lock.tryLock(timeoutInSeconds, TimeUnit.SECONDS)) {
+                throw new LockException(HumanReadableText.LOCK_FAILED);
+            }
+        } catch (InterruptedException e) {
+            throw new LockException(HumanReadableText.LOCK_FAILED, e);
+        }
+    }
+
+}

Modified: james/imap/trunk/torque/src/main/java/org/apache/james/mailboxmanager/torque/TorqueMailbox.java
URL: http://svn.apache.org/viewvc/james/imap/trunk/torque/src/main/java/org/apache/james/mailboxmanager/torque/TorqueMailbox.java?rev=992965&r1=992964&r2=992965&view=diff
==============================================================================
--- james/imap/trunk/torque/src/main/java/org/apache/james/mailboxmanager/torque/TorqueMailbox.java
(original)
+++ james/imap/trunk/torque/src/main/java/org/apache/james/mailboxmanager/torque/TorqueMailbox.java
Mon Sep  6 08:05:52 2010
@@ -47,7 +47,6 @@ import javax.mail.internet.MimeMessage;
 
 import org.apache.james.imap.api.MailboxPath;
 import org.apache.james.imap.api.display.HumanReadableText;
-import org.apache.james.imap.mailbox.LockException;
 import org.apache.james.imap.mailbox.MessageManager;
 import org.apache.james.imap.mailbox.MailboxConstants;
 import org.apache.james.imap.mailbox.MailboxException;
@@ -60,7 +59,6 @@ import org.apache.james.imap.mailbox.Mes
 import org.apache.james.imap.mailbox.SearchQuery.Criterion;
 import org.apache.james.imap.mailbox.SearchQuery.NumericRange;
 import org.apache.james.imap.mailbox.util.FetchGroupImpl;
-import org.apache.james.imap.mailbox.util.UidRange;
 import org.apache.james.imap.store.MailboxMetaData;
 import org.apache.james.imap.store.streaming.CRLFOutputStream;
 import org.apache.james.mailboxmanager.torque.om.MailboxRow;
@@ -333,12 +331,11 @@ public class TorqueMailbox implements Me
         lockForReading();
         try {
             checkAccess();
-            UidRange range = uidRangeForMessageSet(set);
             try {
                 Criteria c = criteriaForMessageSet(set);
                 c.add(MessageFlagsPeer.MAILBOX_ID, getMailboxRow()
                         .getMailboxId());
-                return getMessages(fetchGroup, range, c);
+                return getMessages(fetchGroup, set, c);
             } catch (TorqueException e) {
                 throw new MailboxException(HumanReadableText.SEARCH_FAILED, e);
             } catch (MessagingException e) {
@@ -350,7 +347,7 @@ public class TorqueMailbox implements Me
     }
 
     @SuppressWarnings("unchecked")
-    private TorqueResultIterator getMessages(FetchGroup result, UidRange range,
+    private TorqueResultIterator getMessages(FetchGroup result, MessageRange range,
             Criteria c) throws TorqueException, MessagingException,
             MailboxException {
         List<MessageRow> rows = MessageRowPeer.doSelectJoinMessageFlags(c);
@@ -371,15 +368,6 @@ public class TorqueMailbox implements Me
         return results;
     }
 
-    private static UidRange uidRangeForMessageSet(MessageRange set)
-    throws MailboxException {
-        if (set.getType().equals(MessageRange.Type.ALL)) {
-            return new UidRange(1, -1);
-        } else {
-            return new UidRange(set.getUidFrom(), set.getUidTo());
-        }
-    }
-
     public MessageResult fillMessageResult(MessageRow messageRow,
             FetchGroup result) throws TorqueException, MessagingException,
             MailboxException, MimeException {

Modified: james/imap/trunk/torque/src/main/java/org/apache/james/mailboxmanager/torque/UidChangeTracker.java
URL: http://svn.apache.org/viewvc/james/imap/trunk/torque/src/main/java/org/apache/james/mailboxmanager/torque/UidChangeTracker.java?rev=992965&r1=992964&r2=992965&view=diff
==============================================================================
--- james/imap/trunk/torque/src/main/java/org/apache/james/mailboxmanager/torque/UidChangeTracker.java
(original)
+++ james/imap/trunk/torque/src/main/java/org/apache/james/mailboxmanager/torque/UidChangeTracker.java
Mon Sep  6 08:05:52 2010
@@ -35,7 +35,7 @@ import org.apache.james.imap.mailbox.Mai
 import org.apache.james.imap.mailbox.MessageManager;
 import org.apache.james.imap.mailbox.MailboxListener;
 import org.apache.james.imap.mailbox.util.MailboxEventDispatcher;
-import org.apache.james.imap.mailbox.util.UidRange;
+import org.apache.james.imap.mailbox.MessageRange;
 
 /**
  * 
@@ -94,7 +94,7 @@ public class UidChangeTracker implements
         }
     }
 
-    public synchronized void found(UidRange range, final Map<Long, Flags> flagsByIndex)
{
+    public synchronized void found(MessageRange range, final Map<Long, Flags> flagsByIndex)
{
         final Set<Long> expectedSet = getSubSet(range);
         for (Map.Entry<Long, Flags> entry:flagsByIndex.entrySet()) {
             final Long uid = entry.getKey();
@@ -125,10 +125,10 @@ public class UidChangeTracker implements
         cache.put(uid, flags);
     }
 
-    private SortedSet<Long> getSubSet(UidRange range) {
-        final Long rangeStartLong = new Long(range.getFromUid());
-        if (range.getToUid() > 0) {
-            final long nextUidAfterRange = range.getToUid() + 1;
+    private SortedSet<Long> getSubSet(MessageRange range) {
+        final Long rangeStartLong = range.getUidFrom();
+        if (range.getUidTo() > 0) {
+            final long nextUidAfterRange = range.getUidTo() + 1;
             final Long nextUidAfterRangeLong = new Long(nextUidAfterRange);
             final SortedMap<Long, Flags> subMap = cache.subMap(rangeStartLong,
                     nextUidAfterRangeLong);



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


Mime
View raw message