public class SieveFileRepository extends Object implements org.apache.james.managesieve.api.SieveRepository
SieveFileRepository
manages sieve scripts stored on the file system.
The sieve root directory is a sub-directory of the application base directory named "sieve". Scripts are stored in sub-directories of the sieve root directory, each with the name of the associated user.
Constructor and Description |
---|
SieveFileRepository()
Creates a new instance of SieveFileRepository.
|
SieveFileRepository(FileSystem fileSystem)
Creates a new instance of SieveFileRepository.
|
Modifier and Type | Method and Description |
---|---|
void |
addUser(String user) |
void |
deleteScript(String user,
String name) |
String |
getActive(String user) |
protected File |
getActiveFile(String user) |
long |
getQuota() |
long |
getQuota(String user) |
protected File |
getQuotaFile() |
protected File |
getQuotaFile(String user) |
String |
getScript(String user,
String name) |
protected File |
getScriptFile(String user,
String name) |
protected File |
getSieveRootDirectory() |
protected File |
getUserDirectory(String user) |
protected File |
getUserDirectoryFile(String user) |
boolean |
hasQuota() |
boolean |
hasQuota(String user) |
boolean |
hasUser(String user) |
void |
haveSpace(String user,
String name,
long size)
The default quota, if any, is stored in file '.quota' in the sieve root directory.
|
protected boolean |
isActiveFile(String user,
File file) |
List<org.apache.james.managesieve.api.ScriptSummary> |
listScripts(String user) |
void |
putScript(String user,
String name,
String content) |
void |
removeQuota() |
void |
removeQuota(String user) |
void |
removeUser(String user) |
void |
renameScript(String user,
String oldName,
String newName) |
void |
setActive(String user,
String name) |
protected void |
setActiveFile(File activeFile,
boolean isActive) |
void |
setFileSystem(FileSystem fileSystem) |
void |
setQuota(long quota) |
void |
setQuota(String user,
long quota) |
protected static void |
toFile(File file,
String content) |
protected static String |
toString(File file,
String encoding)
Read a file with the specified encoding into a String
|
public SieveFileRepository()
public SieveFileRepository(FileSystem fileSystem)
fileSystem
- protected static String toString(File file, String encoding) throws FileNotFoundException
file
- encoding
- FileNotFoundException
protected static void toFile(File file, String content) throws org.apache.james.managesieve.api.StorageException
org.apache.james.managesieve.api.StorageException
public void setFileSystem(FileSystem fileSystem)
public void deleteScript(String user, String name) throws org.apache.james.managesieve.api.UserNotFoundException, org.apache.james.managesieve.api.ScriptNotFoundException, org.apache.james.managesieve.api.IsActiveException, org.apache.james.managesieve.api.StorageException
deleteScript
in interface org.apache.james.managesieve.api.SieveRepository
org.apache.james.managesieve.api.StorageException
org.apache.james.managesieve.api.UserNotFoundException
org.apache.james.managesieve.api.ScriptNotFoundException
org.apache.james.managesieve.api.IsActiveException
SieveRepository.deleteScript(java.lang.String, java.lang.String)
public String getScript(String user, String name) throws org.apache.james.managesieve.api.UserNotFoundException, org.apache.james.managesieve.api.ScriptNotFoundException
getScript
in interface org.apache.james.managesieve.api.SieveRepository
org.apache.james.managesieve.api.UserNotFoundException
org.apache.james.managesieve.api.ScriptNotFoundException
SieveRepository.getScript(java.lang.String, java.lang.String)
public void haveSpace(String user, String name, long size) throws org.apache.james.managesieve.api.UserNotFoundException, org.apache.james.managesieve.api.QuotaExceededException
The '.quota' file contains a single positive integer value representing the quota in octets.
haveSpace
in interface org.apache.james.managesieve.api.SieveRepository
org.apache.james.managesieve.api.UserNotFoundException
org.apache.james.managesieve.api.QuotaExceededException
SieveRepository.haveSpace(java.lang.String, java.lang.String, long)
public List<org.apache.james.managesieve.api.ScriptSummary> listScripts(String user) throws org.apache.james.managesieve.api.UserNotFoundException
listScripts
in interface org.apache.james.managesieve.api.SieveRepository
org.apache.james.managesieve.api.UserNotFoundException
SieveRepository.listScripts(java.lang.String)
public void putScript(String user, String name, String content) throws org.apache.james.managesieve.api.UserNotFoundException, org.apache.james.managesieve.api.StorageException, org.apache.james.managesieve.api.QuotaExceededException
putScript
in interface org.apache.james.managesieve.api.SieveRepository
org.apache.james.managesieve.api.UserNotFoundException
org.apache.james.managesieve.api.StorageException
org.apache.james.managesieve.api.QuotaExceededException
SieveRepository.putScript(java.lang.String, java.lang.String, java.lang.String)
public void renameScript(String user, String oldName, String newName) throws org.apache.james.managesieve.api.UserNotFoundException, org.apache.james.managesieve.api.ScriptNotFoundException, org.apache.james.managesieve.api.DuplicateException, org.apache.james.managesieve.api.StorageException
renameScript
in interface org.apache.james.managesieve.api.SieveRepository
org.apache.james.managesieve.api.StorageException
org.apache.james.managesieve.api.UserNotFoundException
org.apache.james.managesieve.api.ScriptNotFoundException
org.apache.james.managesieve.api.DuplicateException
SieveRepository.renameScript(java.lang.String, java.lang.String, java.lang.String)
public String getActive(String user) throws org.apache.james.managesieve.api.UserNotFoundException, org.apache.james.managesieve.api.ScriptNotFoundException
getActive
in interface org.apache.james.managesieve.api.SieveRepository
org.apache.james.managesieve.api.UserNotFoundException
org.apache.james.managesieve.api.ScriptNotFoundException
SieveRepository.getActive(java.lang.String)
public void setActive(String user, String name) throws org.apache.james.managesieve.api.UserNotFoundException, org.apache.james.managesieve.api.ScriptNotFoundException, org.apache.james.managesieve.api.StorageException
setActive
in interface org.apache.james.managesieve.api.SieveRepository
org.apache.james.managesieve.api.StorageException
org.apache.james.managesieve.api.UserNotFoundException
org.apache.james.managesieve.api.ScriptNotFoundException
SieveRepository.setActive(java.lang.String, java.lang.String)
protected File getSieveRootDirectory()
protected File getUserDirectory(String user) throws org.apache.james.managesieve.api.UserNotFoundException
org.apache.james.managesieve.api.UserNotFoundException
protected File getActiveFile(String user) throws org.apache.james.managesieve.api.UserNotFoundException, org.apache.james.managesieve.api.ScriptNotFoundException
org.apache.james.managesieve.api.UserNotFoundException
org.apache.james.managesieve.api.ScriptNotFoundException
protected boolean isActiveFile(String user, File file) throws org.apache.james.managesieve.api.UserNotFoundException
org.apache.james.managesieve.api.UserNotFoundException
protected void setActiveFile(File activeFile, boolean isActive) throws org.apache.james.managesieve.api.StorageException
org.apache.james.managesieve.api.StorageException
protected File getScriptFile(String user, String name) throws org.apache.james.managesieve.api.UserNotFoundException, org.apache.james.managesieve.api.ScriptNotFoundException
org.apache.james.managesieve.api.UserNotFoundException
org.apache.james.managesieve.api.ScriptNotFoundException
public boolean hasUser(String user)
hasUser
in interface org.apache.james.managesieve.api.SieveRepository
org.apache.james.managesieve.api.SieveRepository#hasUser()
public void addUser(String user) throws org.apache.james.managesieve.api.DuplicateUserException, org.apache.james.managesieve.api.StorageException
addUser
in interface org.apache.james.managesieve.api.SieveRepository
org.apache.james.managesieve.api.StorageException
org.apache.james.managesieve.api.DuplicateUserException
SieveRepository.addUser(java.lang.String)
public void removeUser(String user) throws org.apache.james.managesieve.api.UserNotFoundException, org.apache.james.managesieve.api.StorageException
removeUser
in interface org.apache.james.managesieve.api.SieveRepository
org.apache.james.managesieve.api.StorageException
org.apache.james.managesieve.api.UserNotFoundException
SieveRepository.removeUser(java.lang.String)
protected File getQuotaFile()
public boolean hasQuota()
hasQuota
in interface org.apache.james.managesieve.api.SieveRepository
SieveRepository.hasQuota()
public long getQuota() throws org.apache.james.managesieve.api.QuotaNotFoundException
getQuota
in interface org.apache.james.managesieve.api.SieveRepository
org.apache.james.managesieve.api.QuotaNotFoundException
SieveRepository.getQuota()
public void removeQuota() throws org.apache.james.managesieve.api.QuotaNotFoundException, org.apache.james.managesieve.api.StorageException
removeQuota
in interface org.apache.james.managesieve.api.SieveRepository
org.apache.james.managesieve.api.QuotaNotFoundException
org.apache.james.managesieve.api.StorageException
SieveRepository.removeQuota()
public void setQuota(long quota) throws org.apache.james.managesieve.api.StorageException
setQuota
in interface org.apache.james.managesieve.api.SieveRepository
org.apache.james.managesieve.api.StorageException
SieveRepository.setQuota(long)
protected File getQuotaFile(String user) throws org.apache.james.managesieve.api.UserNotFoundException
org.apache.james.managesieve.api.UserNotFoundException
public boolean hasQuota(String user) throws org.apache.james.managesieve.api.UserNotFoundException
hasQuota
in interface org.apache.james.managesieve.api.SieveRepository
org.apache.james.managesieve.api.UserNotFoundException
SieveRepository.hasQuota(java.lang.String)
public long getQuota(String user) throws org.apache.james.managesieve.api.UserNotFoundException, org.apache.james.managesieve.api.QuotaNotFoundException
getQuota
in interface org.apache.james.managesieve.api.SieveRepository
org.apache.james.managesieve.api.QuotaNotFoundException
org.apache.james.managesieve.api.UserNotFoundException
SieveRepository.getQuota(java.lang.String)
public void removeQuota(String user) throws org.apache.james.managesieve.api.UserNotFoundException, org.apache.james.managesieve.api.QuotaNotFoundException, org.apache.james.managesieve.api.StorageException
removeQuota
in interface org.apache.james.managesieve.api.SieveRepository
org.apache.james.managesieve.api.QuotaNotFoundException
org.apache.james.managesieve.api.StorageException
org.apache.james.managesieve.api.UserNotFoundException
SieveRepository.removeQuota(java.lang.String)
public void setQuota(String user, long quota) throws org.apache.james.managesieve.api.UserNotFoundException, org.apache.james.managesieve.api.StorageException
setQuota
in interface org.apache.james.managesieve.api.SieveRepository
org.apache.james.managesieve.api.StorageException
org.apache.james.managesieve.api.UserNotFoundException
SieveRepository.setQuota(java.lang.String, long)
Copyright © 2002-2012 The Apache Software Foundation. All Rights Reserved.