james-server-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From btell...@apache.org
Subject [1/9] james-project git commit: JAMES-1617 SieveRepository no longer throws UserNotFoundException
Date Thu, 07 Apr 2016 03:10:11 GMT
Repository: james-project
Updated Branches:
  refs/heads/master d1d5712f9 -> 49b318080


JAMES-1617 SieveRepository no longer throws UserNotFoundException


Project: http://git-wip-us.apache.org/repos/asf/james-project/repo
Commit: http://git-wip-us.apache.org/repos/asf/james-project/commit/5f995abf
Tree: http://git-wip-us.apache.org/repos/asf/james-project/tree/5f995abf
Diff: http://git-wip-us.apache.org/repos/asf/james-project/diff/5f995abf

Branch: refs/heads/master
Commit: 5f995abf430c33d0f5dbe777d553fd8a0d68cab0
Parents: f657ad7
Author: Erwan Guyomarch <contact@erwan-guyomarch.fr>
Authored: Sat Jan 23 23:02:32 2016 +0100
Committer: Benoit Tellier <btellier@linagora.com>
Committed: Thu Apr 7 09:07:31 2016 +0700

----------------------------------------------------------------------
 .../james/managesieve/core/CoreProcessor.java   |  5 +-
 .../sieverepository/api/SieveRepository.java    | 30 +++++-----
 .../api/exception/UserNotFoundException.java    | 61 --------------------
 .../file/SieveDefaultRepository.java            | 27 +++++----
 .../file/SieveFileRepository.java               | 50 ++++++----------
 5 files changed, 46 insertions(+), 127 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/james-project/blob/5f995abf/protocols/managesieve/src/main/java/org/apache/james/managesieve/core/CoreProcessor.java
----------------------------------------------------------------------
diff --git a/protocols/managesieve/src/main/java/org/apache/james/managesieve/core/CoreProcessor.java
b/protocols/managesieve/src/main/java/org/apache/james/managesieve/core/CoreProcessor.java
index 46a216e..f2b8679 100644
--- a/protocols/managesieve/src/main/java/org/apache/james/managesieve/core/CoreProcessor.java
+++ b/protocols/managesieve/src/main/java/org/apache/james/managesieve/core/CoreProcessor.java
@@ -47,7 +47,6 @@ import org.apache.james.sieverepository.api.exception.QuotaExceededException;
 import org.apache.james.sieverepository.api.exception.ScriptNotFoundException;
 import org.apache.james.sieverepository.api.exception.SieveRepositoryException;
 import org.apache.james.sieverepository.api.exception.StorageException;
-import org.apache.james.sieverepository.api.exception.UserNotFoundException;
 import org.apache.james.user.api.UsersRepository;
 
 import java.io.IOException;
@@ -177,7 +176,7 @@ public class CoreProcessor implements CoreCommands {
         }, session);
     }
 
-    private String listScriptsInternals(Session session) throws AuthenticationRequiredException,
UserNotFoundException, StorageException {
+    private String listScriptsInternals(Session session) throws AuthenticationRequiredException,
StorageException {
         authenticationCheck(session);
         String list = Joiner.on("\r\n").join(
             Iterables.transform(sieveRepository.listScripts(session.getUser()), new Function<ScriptSummary,
String>() {
@@ -317,8 +316,6 @@ public class CoreProcessor implements CoreCommands {
             return "NO (NONEXISTENT) \"There is no script by that name\"";
         } catch (IsActiveException ex) {
             return "NO (ACTIVE) \"You may not delete an active script\"";
-        }  catch (UserNotFoundException e) {
-            return "NO : Invalid user " + session.getUser();
         } catch (StorageException e) {
             return "NO : Storage Exception : " + e.getMessage();
         } catch (SyntaxException e) {

http://git-wip-us.apache.org/repos/asf/james-project/blob/5f995abf/server/data/data-api/src/main/java/org/apache/james/sieverepository/api/SieveRepository.java
----------------------------------------------------------------------
diff --git a/server/data/data-api/src/main/java/org/apache/james/sieverepository/api/SieveRepository.java
b/server/data/data-api/src/main/java/org/apache/james/sieverepository/api/SieveRepository.java
index 1806077..8e0a999 100644
--- a/server/data/data-api/src/main/java/org/apache/james/sieverepository/api/SieveRepository.java
+++ b/server/data/data-api/src/main/java/org/apache/james/sieverepository/api/SieveRepository.java
@@ -29,7 +29,6 @@ import org.apache.james.sieverepository.api.exception.QuotaExceededException;
 import org.apache.james.sieverepository.api.exception.QuotaNotFoundException;
 import org.apache.james.sieverepository.api.exception.ScriptNotFoundException;
 import org.apache.james.sieverepository.api.exception.StorageException;
-import org.apache.james.sieverepository.api.exception.UserNotFoundException;
 import org.joda.time.DateTime;
 
 
@@ -38,7 +37,7 @@ import org.joda.time.DateTime;
  */
 public interface SieveRepository {
 
-    void haveSpace(String user, String name, long size) throws UserNotFoundException, QuotaExceededException,
StorageException;
+    void haveSpace(String user, String name, long size) throws QuotaExceededException, StorageException;
     
     /**
      * PutScript.
@@ -48,25 +47,24 @@ public interface SieveRepository {
      * @param user
      * @param name
      * @param content
-     * @throws UserNotFoundException
      * @throws StorageException
      * @throws QuotaExceededException
      */
-    void putScript(String user, String name, String content) throws UserNotFoundException,
StorageException, QuotaExceededException;
+    void putScript(String user, String name, String content) throws StorageException, QuotaExceededException;
     
-    List<ScriptSummary> listScripts(String user) throws UserNotFoundException, StorageException;
-    
-    InputStream getActive(String user) throws UserNotFoundException, ScriptNotFoundException,
StorageException;
+    List<ScriptSummary> listScripts(String user) throws StorageException;
+
+    DateTime getActivationDateForActiveScript(String user) throws StorageException, ScriptNotFoundException;
 
-    DateTime getActivationDateForActiveScript(String user) throws StorageException, UserNotFoundException,
ScriptNotFoundException;
+    InputStream getActive(String user) throws ScriptNotFoundException, StorageException;
     
-    void setActive(String user, String name) throws UserNotFoundException, ScriptNotFoundException,
StorageException;
+    void setActive(String user, String name) throws ScriptNotFoundException, StorageException;
     
-    InputStream getScript(String user, String name) throws UserNotFoundException, ScriptNotFoundException,
StorageException;
+    InputStream getScript(String user, String name) throws ScriptNotFoundException, StorageException;
     
-    void deleteScript(String user, String name) throws UserNotFoundException, ScriptNotFoundException,
IsActiveException, StorageException;
+    void deleteScript(String user, String name) throws ScriptNotFoundException, IsActiveException,
StorageException;
     
-    void renameScript(String user, String oldName, String newName) throws UserNotFoundException,
ScriptNotFoundException, DuplicateException, StorageException;
+    void renameScript(String user, String oldName, String newName) throws ScriptNotFoundException,
DuplicateException, StorageException;
 
     boolean hasQuota() throws StorageException;
     
@@ -76,12 +74,12 @@ public interface SieveRepository {
     
     void removeQuota() throws QuotaNotFoundException, StorageException;
     
-    boolean hasQuota(String user) throws UserNotFoundException, StorageException;
+    boolean hasQuota(String user) throws StorageException;
     
-    long getQuota(String user) throws UserNotFoundException, QuotaNotFoundException, StorageException;
+    long getQuota(String user) throws QuotaNotFoundException, StorageException;
     
-    void setQuota(String user, long quota) throws UserNotFoundException, StorageException;
+    void setQuota(String user, long quota) throws StorageException;
     
-    void removeQuota(String user) throws UserNotFoundException, QuotaNotFoundException, StorageException;
+    void removeQuota(String user) throws QuotaNotFoundException, StorageException;
 
 }

http://git-wip-us.apache.org/repos/asf/james-project/blob/5f995abf/server/data/data-api/src/main/java/org/apache/james/sieverepository/api/exception/UserNotFoundException.java
----------------------------------------------------------------------
diff --git a/server/data/data-api/src/main/java/org/apache/james/sieverepository/api/exception/UserNotFoundException.java
b/server/data/data-api/src/main/java/org/apache/james/sieverepository/api/exception/UserNotFoundException.java
deleted file mode 100644
index e5a1219..0000000
--- a/server/data/data-api/src/main/java/org/apache/james/sieverepository/api/exception/UserNotFoundException.java
+++ /dev/null
@@ -1,61 +0,0 @@
-/*
- *   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.sieverepository.api.exception;
-
-public class UserNotFoundException extends SieveRepositoryException {
-    /**
-     * Creates a new instance of UserNotFoundException.
-     *
-     */
-    public UserNotFoundException() {
-        super();
-    }
-
-    /**
-     * Creates a new instance of UserNotFoundException.
-     *
-     * @param message
-     * @param cause
-     */
-    public UserNotFoundException(String message, Throwable cause) {
-        super(message, cause);
-    }
-
-    /**
-     * Creates a new instance of UserNotFoundException.
-     *
-     * @param message
-     */
-    public UserNotFoundException(String message) {
-        super(message);
-    }
-
-    /**
-     * Creates a new instance of UserNotFoundException.
-     *
-     * @param cause
-     */
-    public UserNotFoundException(Throwable cause) {
-        super(cause);
-    }
-
-    private static final long serialVersionUID = -5075227645788455698L;
-}
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/james-project/blob/5f995abf/server/data/data-file/src/main/java/org/apache/james/sieverepository/file/SieveDefaultRepository.java
----------------------------------------------------------------------
diff --git a/server/data/data-file/src/main/java/org/apache/james/sieverepository/file/SieveDefaultRepository.java
b/server/data/data-file/src/main/java/org/apache/james/sieverepository/file/SieveDefaultRepository.java
index 469b8c3..dd865e2 100644
--- a/server/data/data-file/src/main/java/org/apache/james/sieverepository/file/SieveDefaultRepository.java
+++ b/server/data/data-file/src/main/java/org/apache/james/sieverepository/file/SieveDefaultRepository.java
@@ -37,7 +37,6 @@ import org.apache.james.sieverepository.api.exception.QuotaExceededException;
 import org.apache.james.sieverepository.api.exception.QuotaNotFoundException;
 import org.apache.james.sieverepository.api.exception.ScriptNotFoundException;
 import org.apache.james.sieverepository.api.exception.StorageException;
-import org.apache.james.sieverepository.api.exception.UserNotFoundException;
 import org.joda.time.DateTime;
 
 /**
@@ -56,22 +55,22 @@ public class SieveDefaultRepository implements SieveRepository {
     }
 
     @Override
-    public void haveSpace(String user, String name, long size) throws UserNotFoundException,
QuotaExceededException, StorageException {
+    public void haveSpace(String user, String name, long size) throws QuotaExceededException,
StorageException {
         throw apologizeForQuotas();
     }
 
     @Override
-    public void putScript(String user, String name, String content) throws UserNotFoundException,
StorageException, QuotaExceededException {
+    public void putScript(String user, String name, String content) throws StorageException,
QuotaExceededException {
         throw new StorageException("This implementation is deprecated and does not support
script put operation. You must directly position your scripts in the .sieve folder. Please
consider using a SieveFileRepository.");
     }
 
     @Override
-    public List<ScriptSummary> listScripts(String user) throws UserNotFoundException,
StorageException {
+    public List<ScriptSummary> listScripts(String user) throws StorageException {
         throw new StorageException("This implementation is deprecated and does not support
listScripts operation. Please consider using a SieveFileRepository.");
     }
 
     @Override
-    public InputStream getActive(String user) throws UserNotFoundException, ScriptNotFoundException,
StorageException {
+    public InputStream getActive(String user) throws ScriptNotFoundException, StorageException
{
         try {
             return new FileInputStream(retrieveUserFile(user));
         } catch (FileNotFoundException e) {
@@ -80,7 +79,7 @@ public class SieveDefaultRepository implements SieveRepository {
     }
 
     @Override
-    public DateTime getActivationDateForActiveScript(String user) throws StorageException,
UserNotFoundException, ScriptNotFoundException {
+    public DateTime getActivationDateForActiveScript(String user) throws StorageException,
ScriptNotFoundException {
         return new DateTime(retrieveUserFile(user).lastModified());
     }
 
@@ -99,22 +98,22 @@ public class SieveDefaultRepository implements SieveRepository {
     }
 
     @Override
-    public void setActive(String user, String name) throws UserNotFoundException, ScriptNotFoundException,
StorageException {
+    public void setActive(String user, String name) throws ScriptNotFoundException, StorageException
{
         throw new StorageException("This implementation is deprecated and does not support
script SetActive operation. Your uploaded script is by default the active script. Please consider
using a SieveFileRepository.");
     }
 
     @Override
-    public InputStream getScript(String user, String name) throws UserNotFoundException,
ScriptNotFoundException, StorageException {
+    public InputStream getScript(String user, String name) throws ScriptNotFoundException,
StorageException {
         return getActive(user);
     }
 
     @Override
-    public void deleteScript(String user, String name) throws UserNotFoundException, ScriptNotFoundException,
IsActiveException, StorageException {
+    public void deleteScript(String user, String name) throws ScriptNotFoundException, IsActiveException,
StorageException {
         throw new StorageException("This implementation is deprecated and does not support
delete script operation. Please consider using a SieveFileRepository.");
     }
 
     @Override
-    public void renameScript(String user, String oldName, String newName) throws UserNotFoundException,
ScriptNotFoundException, DuplicateException, StorageException {
+    public void renameScript(String user, String oldName, String newName) throws ScriptNotFoundException,
DuplicateException, StorageException {
         throw new StorageException("This implementation is deprecated and does not support
rename script operation. Please consider using a SieveFileRepository.");
     }
 
@@ -139,22 +138,22 @@ public class SieveDefaultRepository implements SieveRepository {
     }
 
     @Override
-    public boolean hasQuota(String user) throws UserNotFoundException, StorageException {
+    public boolean hasQuota(String user) throws StorageException {
         throw apologizeForQuotas();
     }
 
     @Override
-    public long getQuota(String user) throws UserNotFoundException, QuotaNotFoundException,
StorageException {
+    public long getQuota(String user) throws QuotaNotFoundException, StorageException {
         throw apologizeForQuotas();
     }
 
     @Override
-    public void setQuota(String user, long quota) throws UserNotFoundException, StorageException
{
+    public void setQuota(String user, long quota) throws StorageException {
         throw apologizeForQuotas();
     }
 
     @Override
-    public void removeQuota(String user) throws UserNotFoundException, QuotaNotFoundException,
StorageException {
+    public void removeQuota(String user) throws QuotaNotFoundException, StorageException
{
         throw apologizeForQuotas();
     }
 

http://git-wip-us.apache.org/repos/asf/james-project/blob/5f995abf/server/data/data-file/src/main/java/org/apache/james/sieverepository/file/SieveFileRepository.java
----------------------------------------------------------------------
diff --git a/server/data/data-file/src/main/java/org/apache/james/sieverepository/file/SieveFileRepository.java
b/server/data/data-file/src/main/java/org/apache/james/sieverepository/file/SieveFileRepository.java
index a0b9cc0..4628040 100644
--- a/server/data/data-file/src/main/java/org/apache/james/sieverepository/file/SieveFileRepository.java
+++ b/server/data/data-file/src/main/java/org/apache/james/sieverepository/file/SieveFileRepository.java
@@ -31,7 +31,6 @@ import org.apache.james.sieverepository.api.exception.QuotaExceededException;
 import org.apache.james.sieverepository.api.exception.QuotaNotFoundException;
 import org.apache.james.sieverepository.api.exception.ScriptNotFoundException;
 import org.apache.james.sieverepository.api.exception.StorageException;
-import org.apache.james.sieverepository.api.exception.UserNotFoundException;
 import org.joda.time.DateTime;
 
 import javax.inject.Inject;
@@ -157,8 +156,7 @@ public class SieveFileRepository implements SieveRepository {
     }
 
     @Override
-    public void deleteScript(String user, String name) throws UserNotFoundException,
-            ScriptNotFoundException, IsActiveException, StorageException {
+    public void deleteScript(String user, String name) throws ScriptNotFoundException, IsActiveException,
StorageException {
         synchronized (lock) {
             File file = getScriptFile(user, name);
             if (isActiveFile(user, file)) {
@@ -173,8 +171,7 @@ public class SieveFileRepository implements SieveRepository {
     }
 
     @Override
-    public InputStream getScript(String user, String name) throws UserNotFoundException,
-            ScriptNotFoundException, StorageException {
+    public InputStream getScript(String user, String name) throws ScriptNotFoundException,
StorageException {
         InputStream script;
         try {
             script = new FileInputStream(getScriptFile(user, name));
@@ -193,8 +190,7 @@ public class SieveFileRepository implements SieveRepository {
      * @see SieveRepository#haveSpace(java.lang.String, java.lang.String, long)
      */
     @Override
-    public void haveSpace(String user, String name, long size) throws UserNotFoundException,
-            QuotaExceededException, StorageException {
+    public void haveSpace(String user, String name, long size) throws QuotaExceededException,
StorageException {
         long usedSpace = 0;
         for (File file : getUserDirectory(user).listFiles()) {
             if (!(file.getName().equals(name) || SYSTEM_FILES.contains(file.getName())))
{
@@ -228,8 +224,7 @@ public class SieveFileRepository implements SieveRepository {
         }
     }
 
-    @Override
-    public List<ScriptSummary> listScripts(String user) throws UserNotFoundException,
StorageException {
+    public List<ScriptSummary> listScripts(String user) throws StorageException {
         File[] files = getUserDirectory(user).listFiles();
         List<ScriptSummary> summaries = new ArrayList<ScriptSummary>(files.length);
         File activeFile = null;
@@ -252,8 +247,7 @@ public class SieveFileRepository implements SieveRepository {
     }
 
     @Override
-    public void putScript(String user, String name, String content)
-            throws UserNotFoundException, StorageException, QuotaExceededException {
+    public void putScript(String user, String name, String content) throws StorageException,
QuotaExceededException {
         synchronized (lock) {
             File file = new File(getUserDirectory(user), name);
             haveSpace(user, name, content.length());
@@ -263,8 +257,7 @@ public class SieveFileRepository implements SieveRepository {
 
     @Override
     public void renameScript(String user, String oldName, String newName)
-            throws UserNotFoundException, ScriptNotFoundException,
-            DuplicateException, StorageException {
+            throws ScriptNotFoundException, DuplicateException, StorageException {
         synchronized (lock) {
             File oldFile = getScriptFile(user, oldName);
             File newFile = new File(getUserDirectory(user), newName);
@@ -284,8 +277,7 @@ public class SieveFileRepository implements SieveRepository {
     }
 
     @Override
-    public InputStream getActive(String user) throws UserNotFoundException,
-            ScriptNotFoundException, StorageException {
+    public InputStream getActive(String user) throws ScriptNotFoundException, StorageException
{
         InputStream script;
         try {
             script = new FileInputStream(getActiveFile(user));
@@ -296,13 +288,11 @@ public class SieveFileRepository implements SieveRepository {
     }
 
     @Override
-    public DateTime getActivationDateForActiveScript(String user) throws StorageException,
UserNotFoundException, ScriptNotFoundException {
+    public DateTime getActivationDateForActiveScript(String user) throws StorageException,
ScriptNotFoundException {
         return new DateTime(getActiveFile(user).lastModified());
     }
 
-    @Override
-    public void setActive(String user, String name) throws UserNotFoundException,
-            ScriptNotFoundException, StorageException {
+    public void setActive( String user, String name) throws ScriptNotFoundException, StorageException
{
         synchronized (lock) {
             // Turn off currently active script, if any
             File oldActive = null;
@@ -334,7 +324,7 @@ public class SieveFileRepository implements SieveRepository {
         }
     }
 
-    protected File getUserDirectory(String user) throws UserNotFoundException, StorageException
{
+    protected File getUserDirectory(String user) throws StorageException {
         File file = getUserDirectoryFile(user);
         if (!file.exists()) {
             ensureUser(user);
@@ -346,8 +336,7 @@ public class SieveFileRepository implements SieveRepository {
         return new File(getSieveRootDirectory(), user + '/');
     }
 
-    protected File getActiveFile(String user) throws UserNotFoundException,
-            ScriptNotFoundException, StorageException {
+    protected File getActiveFile(String user) throws ScriptNotFoundException, StorageException
{
         File dir = getUserDirectory(user);
         String content;
         try {
@@ -358,7 +347,7 @@ public class SieveFileRepository implements SieveRepository {
         return new File(dir, content);
     }
 
-    protected boolean isActiveFile(String user, File file) throws UserNotFoundException,
StorageException {
+    protected boolean isActiveFile(String user, File file) throws StorageException {
         try {
             return 0 == getActiveFile(user).compareTo(file);
         } catch (ScriptNotFoundException ex) {
@@ -388,8 +377,7 @@ public class SieveFileRepository implements SieveRepository {
         }
     }
 
-    protected File getScriptFile(String user, String name) throws UserNotFoundException,
-            ScriptNotFoundException, StorageException {
+    protected File getScriptFile(String user, String name) throws ScriptNotFoundException,
StorageException {
         File file = new File(getUserDirectory(user), name);
         if (!file.exists()) {
             throw new ScriptNotFoundException("User: " + user + "Script: " + name);
@@ -461,17 +449,17 @@ public class SieveFileRepository implements SieveRepository {
         toFile(file, content);
     }
 
-    protected File getQuotaFile(String user) throws UserNotFoundException, StorageException
{
+    protected File getQuotaFile(String user) throws StorageException {
         return new File(getUserDirectory(user), FILE_NAME_QUOTA);
     }
 
     @Override
-    public boolean hasQuota(String user) throws UserNotFoundException, StorageException {
+    public boolean hasQuota(String user) throws StorageException {
         return getQuotaFile(user).exists();
     }
 
     @Override
-    public long getQuota(String user) throws UserNotFoundException, QuotaNotFoundException,
StorageException {
+    public long getQuota(String user) throws QuotaNotFoundException, StorageException {
         Long quota = null;
         File file = getQuotaFile(user);
         if (file.exists()) {
@@ -496,8 +484,7 @@ public class SieveFileRepository implements SieveRepository {
     }
 
     @Override
-    public void removeQuota(String user) throws UserNotFoundException,
-            QuotaNotFoundException, StorageException {
+    public void removeQuota(String user) throws QuotaNotFoundException, StorageException
{
         synchronized (lock) {
             File file = getQuotaFile(user);
             if (!file.exists()) {
@@ -512,8 +499,7 @@ public class SieveFileRepository implements SieveRepository {
     }
 
     @Override
-    public void setQuota(String user, long quota) throws UserNotFoundException,
-            StorageException {
+    public void setQuota(String user, long quota) throws StorageException {
         synchronized (lock) {
             File file = getQuotaFile(user);
             String content = Long.toString(quota);


---------------------------------------------------------------------
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