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 fe...@apache.org on 2011/04/04 16:59:14 UTC
svn commit: r1088657 [9/9] - in /james/server/trunk:
container-spring/src/main/java/org/apache/james/container/spring/bean/factory/mailrepositorystore/
core/src/main/java/org/apache/james/core/
data-api/src/main/java/org/apache/james/domainlist/api/ da...
Modified: james/server/trunk/jdbc/src/main/java/org/apache/james/user/jdbc/DefaultUsersJdbcRepository.java
URL: http://svn.apache.org/viewvc/james/server/trunk/jdbc/src/main/java/org/apache/james/user/jdbc/DefaultUsersJdbcRepository.java?rev=1088657&r1=1088656&r2=1088657&view=diff
==============================================================================
--- james/server/trunk/jdbc/src/main/java/org/apache/james/user/jdbc/DefaultUsersJdbcRepository.java (original)
+++ james/server/trunk/jdbc/src/main/java/org/apache/james/user/jdbc/DefaultUsersJdbcRepository.java Mon Apr 4 14:59:11 2011
@@ -17,8 +17,6 @@
* under the License. *
****************************************************************/
-
-
package org.apache.james.user.jdbc;
import org.apache.james.user.api.UsersRepositoryException;
@@ -29,29 +27,24 @@ import java.sql.PreparedStatement;
import java.sql.ResultSet;
import java.sql.SQLException;
-
-
/**
- * A Jdbc-backed UserRepository which handles User instances
- * of the <CODE>DefaultUser</CODE> class.
- * Although this repository can handle subclasses of DefaultUser,
- * like <CODE>DefaultJamesUser</CODE>, only properties from
- * the DefaultUser class are persisted.
+ * A Jdbc-backed UserRepository which handles User instances of the
+ * <code>DefaultUser</code> class.<br>
+ * Although this repository can handle subclasses of DefaultUser, like
+ * <code>DefaultJamesUser</code>, only properties from the DefaultUser class are
+ * persisted.
*
* TODO Please note that default configuration uses JamesUsersJdbcRepository
* instead of this class. So we could also delete this implementation.
*
*/
@Deprecated
-public class DefaultUsersJdbcRepository extends AbstractJdbcUsersRepository
-{
+public class DefaultUsersJdbcRepository extends AbstractJdbcUsersRepository {
-
/**
* @see org.apache.james.user.jdbc.AbstractJdbcUsersRepository#readUserFromResultSet(java.sql.ResultSet)
*/
- protected User readUserFromResultSet(ResultSet rsUsers) throws SQLException
- {
+ protected User readUserFromResultSet(ResultSet rsUsers) throws SQLException {
// Get the username, and build a DefaultUser with it.
String username = rsUsers.getString(1);
String passwordHash = rsUsers.getString(2);
@@ -61,33 +54,30 @@ public class DefaultUsersJdbcRepository
}
/**
- * @see org.apache.james.user.jdbc.AbstractJdbcUsersRepository#setUserForInsertStatement(org.apache.james.user.api.model.User, java.sql.PreparedStatement)
+ * @see org.apache.james.user.jdbc.AbstractJdbcUsersRepository#setUserForInsertStatement(org.apache.james.user.api.model.User,
+ * java.sql.PreparedStatement)
*/
- protected void setUserForInsertStatement(User user,
- PreparedStatement userInsert)
- throws SQLException
- {
- DefaultUser defUser = (DefaultUser)user;
+ protected void setUserForInsertStatement(User user, PreparedStatement userInsert) throws SQLException {
+ DefaultUser defUser = (DefaultUser) user;
userInsert.setString(1, defUser.getUserName());
userInsert.setString(2, defUser.getHashedPassword());
userInsert.setString(3, defUser.getHashAlgorithm());
}
/**
- * @see org.apache.james.user.jdbc.AbstractJdbcUsersRepository#setUserForUpdateStatement(org.apache.james.user.api.model.User, java.sql.PreparedStatement)
+ * @see org.apache.james.user.jdbc.AbstractJdbcUsersRepository#setUserForUpdateStatement(org.apache.james.user.api.model.User,
+ * java.sql.PreparedStatement)
*/
- protected void setUserForUpdateStatement(User user,
- PreparedStatement userUpdate)
- throws SQLException
- {
- DefaultUser defUser = (DefaultUser)user;
+ protected void setUserForUpdateStatement(User user, PreparedStatement userUpdate) throws SQLException {
+ DefaultUser defUser = (DefaultUser) user;
userUpdate.setString(1, defUser.getHashedPassword());
userUpdate.setString(2, defUser.getHashAlgorithm());
userUpdate.setString(3, defUser.getUserName());
}
-
+
/**
- * @see org.apache.james.user.api.UsersRepository#addUser(java.lang.String, java.lang.String)
+ * @see org.apache.james.user.api.UsersRepository#addUser(java.lang.String,
+ * java.lang.String)
*/
public void addUser(String username, String password) throws UsersRepositoryException {
if (contains(username) == true) {
@@ -99,6 +89,4 @@ public class DefaultUsersJdbcRepository
doAddUser(newbie);
}
-
}
-
Modified: james/server/trunk/jdbc/src/main/java/org/apache/james/user/jdbc/JamesUsersJdbcRepository.java
URL: http://svn.apache.org/viewvc/james/server/trunk/jdbc/src/main/java/org/apache/james/user/jdbc/JamesUsersJdbcRepository.java?rev=1088657&r1=1088656&r2=1088657&view=diff
==============================================================================
--- james/server/trunk/jdbc/src/main/java/org/apache/james/user/jdbc/JamesUsersJdbcRepository.java (original)
+++ james/server/trunk/jdbc/src/main/java/org/apache/james/user/jdbc/JamesUsersJdbcRepository.java Mon Apr 4 14:59:11 2011
@@ -17,8 +17,6 @@
* under the License. *
****************************************************************/
-
-
package org.apache.james.user.jdbc;
import org.apache.james.user.api.model.User;
@@ -31,8 +29,8 @@ import java.sql.ResultSet;
import java.sql.SQLException;
/**
- * A Jdbc-backed UserRepository which handles User instances of the <CODE>DefaultJamesUser</CODE>
- * class, or any superclass.
+ * A Jdbc-backed UserRepository which handles User instances of the
+ * <code>DefaultJamesUser</code> class, or any superclass.
*/
@Deprecated
public class JamesUsersJdbcRepository extends AbstractJdbcUsersRepository {
@@ -51,21 +49,17 @@ public class JamesUsersJdbcRepository ex
String alias = rsUsers.getString(7);
MailAddress forwardAddress = null;
- if ( forwardingDestination != null ) {
+ if (forwardingDestination != null) {
try {
forwardAddress = new MailAddress(forwardingDestination);
} catch (javax.mail.internet.ParseException pe) {
- StringBuffer exceptionBuffer = new StringBuffer(256).append(
- "Invalid mail address in database: ").append(
- forwardingDestination).append(", for user ").append(
- username).append(".");
+ StringBuffer exceptionBuffer = new StringBuffer(256).append("Invalid mail address in database: ").append(forwardingDestination).append(", for user ").append(username).append(".");
throw new RuntimeException(exceptionBuffer.toString());
}
}
// Build a DefaultJamesUser with these values, and add to the list.
- DefaultJamesUser user = new DefaultJamesUser(username, pwdHash,
- pwdAlgorithm);
+ DefaultJamesUser user = new DefaultJamesUser(username, pwdHash, pwdAlgorithm);
user.setForwarding(useForwarding);
user.setForwardingDestination(forwardAddress);
user.setAliasing(useAlias);
@@ -74,13 +68,11 @@ public class JamesUsersJdbcRepository ex
return user;
}
-
/**
* @see org.apache.james.user.jdbc.AbstractJdbcUsersRepository#setUserForInsertStatement(org.apache.james.user.api.model.User,
* java.sql.PreparedStatement)
*/
- protected void setUserForInsertStatement(User user,
- PreparedStatement userInsert) throws SQLException {
+ protected void setUserForInsertStatement(User user, PreparedStatement userInsert) throws SQLException {
setUserForStatement(user, userInsert, false);
}
@@ -88,15 +80,14 @@ public class JamesUsersJdbcRepository ex
* @see org.apache.james.user.jdbc.AbstractJdbcUsersRepository#setUserForUpdateStatement(org.apache.james.user.api.model.User,
* java.sql.PreparedStatement)
*/
- protected void setUserForUpdateStatement(User user,
- PreparedStatement userUpdate) throws SQLException {
+ protected void setUserForUpdateStatement(User user, PreparedStatement userUpdate) throws SQLException {
setUserForStatement(user, userUpdate, true);
}
/**
* Sets the data for the prepared statement to match the information in the
* user object.
- *
+ *
* @param user
* the user whose data is to be stored in the PreparedStatement.
* @param stmt
@@ -104,12 +95,11 @@ public class JamesUsersJdbcRepository ex
* @param userNameLast
* whether the user id is the last or the first column
*/
- private void setUserForStatement(User user, PreparedStatement stmt,
- boolean userNameLast) throws SQLException {
+ private void setUserForStatement(User user, PreparedStatement stmt, boolean userNameLast) throws SQLException {
// Determine column offsets to use, based on username column pos.
int nameIndex = 1;
int colOffset = 1;
- if ( userNameLast ) {
+ if (userNameLast) {
nameIndex = 7;
colOffset = 0;
}
@@ -117,17 +107,14 @@ public class JamesUsersJdbcRepository ex
// Can handle instances of DefaultJamesUser and DefaultUser.
DefaultJamesUser jamesUser;
if (user instanceof DefaultJamesUser) {
- jamesUser = (DefaultJamesUser)user;
+ jamesUser = (DefaultJamesUser) user;
} else if (user instanceof DefaultUser) {
- DefaultUser aUser = (DefaultUser)user;
- jamesUser = new DefaultJamesUser(aUser.getUserName(), aUser
- .getHashedPassword(), aUser.getHashAlgorithm());
- }
+ DefaultUser aUser = (DefaultUser) user;
+ jamesUser = new DefaultJamesUser(aUser.getUserName(), aUser.getHashedPassword(), aUser.getHashAlgorithm());
+ }
// Can't handle any other implementations.
else {
- throw new RuntimeException("An unknown implementation of User was "
- + "found. This implementation cannot be "
- + "persisted to a UsersJDBCRepsitory.");
+ throw new RuntimeException("An unknown implementation of User was " + "found. This implementation cannot be " + "persisted to a UsersJDBCRepsitory.");
}
// Get the user details to save.
@@ -138,15 +125,12 @@ public class JamesUsersJdbcRepository ex
MailAddress forwardAddress = jamesUser.getForwardingDestination();
String forwardDestination = null;
- if ( forwardAddress != null ) {
+ if (forwardAddress != null) {
forwardDestination = forwardAddress.toString();
}
stmt.setString(4 + colOffset, forwardDestination);
stmt.setInt(5 + colOffset, (jamesUser.getAliasing() ? 1 : 0));
stmt.setString(6 + colOffset, jamesUser.getAlias());
}
-
-
-
-
+
}
Modified: james/server/trunk/jdbc/src/main/java/org/apache/james/vut/jdbc/JDBCVirtualUserTable.java
URL: http://svn.apache.org/viewvc/james/server/trunk/jdbc/src/main/java/org/apache/james/vut/jdbc/JDBCVirtualUserTable.java?rev=1088657&r1=1088656&r2=1088657&view=diff
==============================================================================
--- james/server/trunk/jdbc/src/main/java/org/apache/james/vut/jdbc/JDBCVirtualUserTable.java (original)
+++ james/server/trunk/jdbc/src/main/java/org/apache/james/vut/jdbc/JDBCVirtualUserTable.java Mon Apr 4 14:59:11 2011
@@ -44,7 +44,8 @@ import org.apache.james.vut.lib.Abstract
import org.apache.james.vut.lib.VirtualUserTableUtil;
/**
- * Class responsible to implement the Virtual User Table in database with JDBC access.
+ * Class responsible to implement the Virtual User Table in database with JDBC
+ * access.
*
* @deprecated use JPAVirtualUserTable
*/
@@ -53,19 +54,20 @@ public class JDBCVirtualUserTable extend
private DataSource dataSource = null;
private String dataSourceName = null;
-
+
private String tableName = "VirtualUserTable";
/**
* Contains all of the sql strings for this component.
*/
private SqlResources sqlQueries;
-
+
/**
- * The name of the SQL configuration file to be used to configure this repository.
+ * The name of the SQL configuration file to be used to configure this
+ * repository.
*/
private String sqlFileName;
-
+
private FileSystem fileSystem;
/**
@@ -79,7 +81,7 @@ public class JDBCVirtualUserTable extend
@PostConstruct
public void init() throws Exception {
-
+
StringBuffer logBuffer = null;
if (getLogger().isDebugEnabled()) {
getLogger().debug(this.getClass().getName() + ".initialize()");
@@ -93,7 +95,7 @@ public class JDBCVirtualUserTable extend
// Initialise the sql strings.
InputStream sqlFile = null;
-
+
try {
sqlFile = fileSystem.getResource(sqlFileName);
} catch (Exception e) {
@@ -102,76 +104,63 @@ public class JDBCVirtualUserTable extend
}
if (getLogger().isDebugEnabled()) {
- logBuffer =
- new StringBuffer(128)
- .append("Reading SQL resources from file: ")
- .append(sqlFileName)
- .append(", section ")
- .append(this.getClass().getName())
- .append(".");
+ logBuffer = new StringBuffer(128).append("Reading SQL resources from file: ").append(sqlFileName).append(", section ").append(this.getClass().getName()).append(".");
getLogger().debug(logBuffer.toString());
}
// Build the statement parameters
- Map<String,String> sqlParameters = new HashMap<String,String>();
+ Map<String, String> sqlParameters = new HashMap<String, String>();
if (tableName != null) {
sqlParameters.put("table", tableName);
}
-
+
sqlQueries = new SqlResources();
- sqlQueries.init(sqlFile, this.getClass().getName(),
- conn, sqlParameters);
+ sqlQueries.init(sqlFile, this.getClass().getName(), conn, sqlParameters);
// Check if the required table exists. If not, create it.
DatabaseMetaData dbMetaData = conn.getMetaData();
-
- // Need to ask in the case that identifiers are stored, ask the DatabaseMetaInfo.
+
+ // Need to ask in the case that identifiers are stored, ask the
+ // DatabaseMetaInfo.
// Try UPPER, lower, and MixedCase, to see if the table is there.
if (!(theJDBCUtil.tableExists(dbMetaData, tableName))) {
-
+
// Users table doesn't exist - create it.
- createStatement =
- conn.prepareStatement(sqlQueries.getSqlString("createTable", true));
+ createStatement = conn.prepareStatement(sqlQueries.getSqlString("createTable", true));
createStatement.execute();
if (getLogger().isInfoEnabled()) {
- logBuffer =
- new StringBuffer(64)
- .append("JdbcVirtalUserTable: Created table '")
- .append(tableName)
- .append("'.");
+ logBuffer = new StringBuffer(64).append("JdbcVirtalUserTable: Created table '").append(tableName).append("'.");
getLogger().info(logBuffer.toString());
}
}
-
-
+
} finally {
theJDBCUtil.closeJDBCStatement(createStatement);
theJDBCUtil.closeJDBCConnection(conn);
}
}
-
- @Resource(name="filesystem")
+
+ @Resource(name = "filesystem")
public void setFileSystem(FileSystem fileSystem) {
this.fileSystem = fileSystem;
}
-
- @Resource(name="datasource")
+
+ @Resource(name = "datasource")
public void setDataSource(DataSource dataSource) {
this.dataSource = dataSource;
}
-
protected void doConfigure(HierarchicalConfiguration conf) throws ConfigurationException {
-
- String destination = conf.getString("[@destinationURL]",null);
-
+
+ String destination = conf.getString("[@destinationURL]", null);
+
if (destination == null) {
throw new ConfigurationException("destinationURL must configured");
}
-
+
// normalize the destination, to simplify processing.
- if ( ! destination.endsWith("/") ) {
+ if (!destination.endsWith("/")) {
destination += "/";
}
// Parse the DestinationURL for the name of the datasource,
@@ -179,86 +168,80 @@ public class JDBCVirtualUserTable extend
// Split on "/", starting after "db://"
List<String> urlParams = new ArrayList<String>();
int start = 5;
-
+
int end = destination.indexOf('/', start);
- while ( end > -1 ) {
+ while (end > -1) {
urlParams.add(destination.substring(start, end));
start = end + 1;
end = destination.indexOf('/', start);
}
-
+
// Build SqlParameters and get datasource name from URL parameters
if (urlParams.size() == 0) {
- StringBuffer exceptionBuffer =
- new StringBuffer(256)
- .append("Malformed destinationURL - Must be of the format '")
- .append("db://<data-source>'. Was passed ")
- .append(conf.getString("[@destinationURL]"));
+ StringBuffer exceptionBuffer = new StringBuffer(256).append("Malformed destinationURL - Must be of the format '").append("db://<data-source>'. Was passed ").append(conf.getString("[@destinationURL]"));
throw new ConfigurationException(exceptionBuffer.toString());
}
-
+
if (urlParams.size() >= 1) {
- dataSourceName = (String)urlParams.get(0);
+ dataSourceName = (String) urlParams.get(0);
}
-
+
if (urlParams.size() >= 2) {
- tableName = (String)urlParams.get(1);
+ tableName = (String) urlParams.get(1);
}
-
+
if (getLogger().isDebugEnabled()) {
- StringBuffer logBuffer =
- new StringBuffer(128)
- .append("Parsed URL: table = '")
- .append(tableName)
- .append("'");
+ StringBuffer logBuffer = new StringBuffer(128).append("Parsed URL: table = '").append(tableName).append("'");
getLogger().debug(logBuffer.toString());
}
-
+
sqlFileName = conf.getString("sqlFile");
-
+
}
/**
- * @throws VirtualUserTableException
- * @see org.apache.james.vut.lib.AbstractVirtualUserTable#addMappingInternal(String, String, String)
+ * @throws VirtualUserTableException
+ * @see org.apache.james.vut.lib.AbstractVirtualUserTable#addMappingInternal(String,
+ * String, String)
*/
protected void addMappingInternal(String user, String domain, String regex) throws VirtualUserTableException {
String newUser = getUserString(user);
String newDomain = getDomainString(domain);
- Collection<String> map = getUserDomainMappings(newUser,newDomain);
+ Collection<String> map = getUserDomainMappings(newUser, newDomain);
if (map != null && map.size() != 0) {
map.add(regex);
- updateMapping(newUser,newDomain,VirtualUserTableUtil.CollectionToMapping(map));
+ updateMapping(newUser, newDomain, VirtualUserTableUtil.CollectionToMapping(map));
}
-
- addRawMapping(newUser,newDomain,regex);
-
+
+ addRawMapping(newUser, newDomain, regex);
+
}
-
+
/**
- * @see org.apache.james.vut.lib.AbstractVirtualUserTable#mapAddressInternal(java.lang.String, java.lang.String)
+ * @see org.apache.james.vut.lib.AbstractVirtualUserTable#mapAddressInternal(java.lang.String,
+ * java.lang.String)
*/
- protected String mapAddressInternal(String user, String domain) throws VirtualUserTableException{
+ protected String mapAddressInternal(String user, String domain) throws VirtualUserTableException {
Connection conn = null;
PreparedStatement mappingStmt = null;
try {
conn = dataSource.getConnection();
mappingStmt = conn.prepareStatement(sqlQueries.getSqlString("selectMappings", true));
- ResultSet mappingRS = null;
- try {
- mappingStmt.setString(1, user);
- mappingStmt.setString(2, domain);
- mappingRS = mappingStmt.executeQuery();
- if (mappingRS.next()) {
- return mappingRS.getString(1);
- }
- } finally {
- theJDBCUtil.closeJDBCResultSet(mappingRS);
+ ResultSet mappingRS = null;
+ try {
+ mappingStmt.setString(1, user);
+ mappingStmt.setString(2, domain);
+ mappingRS = mappingStmt.executeQuery();
+ if (mappingRS.next()) {
+ return mappingRS.getString(1);
}
-
+ } finally {
+ theJDBCUtil.closeJDBCResultSet(mappingRS);
+ }
+
} catch (SQLException sqle) {
getLogger().error("Error accessing database", sqle);
throw new VirtualUserTableException("Error accessing database", sqle);
@@ -268,10 +251,11 @@ public class JDBCVirtualUserTable extend
}
return null;
}
-
+
/**
- * @throws VirtualUserTableException
- * @see org.apache.james.vut.lib.AbstractVirtualUserTable#mapAddress(java.lang.String, java.lang.String)
+ * @throws VirtualUserTableException
+ * @see org.apache.james.vut.lib.AbstractVirtualUserTable#mapAddress(java.lang.String,
+ * java.lang.String)
*/
protected Collection<String> getUserDomainMappingsInternal(String user, String domain) throws VirtualUserTableException {
Connection conn = null;
@@ -301,30 +285,31 @@ public class JDBCVirtualUserTable extend
}
/**
- * @throws VirtualUserTableException
+ * @throws VirtualUserTableException
* @see org.apache.james.vut.lib.AbstractVirtualUserTable#getAllMappingsInternal()
*/
- protected Map<String,Collection<String>> getAllMappingsInternal() throws VirtualUserTableException {
+ protected Map<String, Collection<String>> getAllMappingsInternal() throws VirtualUserTableException {
Connection conn = null;
PreparedStatement mappingStmt = null;
- Map<String,Collection<String>> mapping = new HashMap<String,Collection<String>>();
+ Map<String, Collection<String>> mapping = new HashMap<String, Collection<String>>();
try {
conn = dataSource.getConnection();
mappingStmt = conn.prepareStatement(sqlQueries.getSqlString("selectAllMappings", true));
ResultSet mappingRS = null;
try {
mappingRS = mappingStmt.executeQuery();
- while(mappingRS.next()) {
+ while (mappingRS.next()) {
String user = mappingRS.getString(1);
String domain = mappingRS.getString(2);
String map = mappingRS.getString(3);
mapping.put(user + "@" + domain, VirtualUserTableUtil.mappingToCollection(map));
}
- if (mapping.size() > 0 ) return mapping;
+ if (mapping.size() > 0)
+ return mapping;
} finally {
theJDBCUtil.closeJDBCResultSet(mappingRS);
}
-
+
} catch (SQLException sqle) {
getLogger().error("Error accessing database", sqle);
throw new VirtualUserTableException("Error accessing database", sqle);
@@ -334,31 +319,35 @@ public class JDBCVirtualUserTable extend
}
return null;
}
-
+
/**
- * @throws VirtualUserTableException
- * @see org.apache.james.vut.lib.AbstractVirtualUserTable#removeMappingInternal(String, String, String)
+ * @throws VirtualUserTableException
+ * @see org.apache.james.vut.lib.AbstractVirtualUserTable#removeMappingInternal(String,
+ * String, String)
*/
protected void removeMappingInternal(String user, String domain, String mapping) throws VirtualUserTableException {
String newUser = getUserString(user);
String newDomain = getDomainString(domain);
- Collection<String> map = getUserDomainMappings(newUser,newDomain);
+ Collection<String> map = getUserDomainMappings(newUser, newDomain);
if (map != null && map.size() > 1) {
map.remove(mapping);
- updateMapping(newUser,newDomain,VirtualUserTableUtil.CollectionToMapping(map));
+ updateMapping(newUser, newDomain, VirtualUserTableUtil.CollectionToMapping(map));
} else {
- removeRawMapping(newUser,newDomain,mapping);
+ removeRawMapping(newUser, newDomain, mapping);
}
}
- /**
+ /**
* Update the mapping for the given user and domain
*
- * @param user the user
- * @param domain the domain
- * @param mapping the mapping
+ * @param user
+ * the user
+ * @param domain
+ * the domain
+ * @param mapping
+ * the mapping
* @return true if update was successfully
- * @throws VirtualUserTableException
+ * @throws VirtualUserTableException
*/
private void updateMapping(String user, String domain, String mapping) throws VirtualUserTableException {
Connection conn = null;
@@ -366,16 +355,15 @@ public class JDBCVirtualUserTable extend
try {
conn = dataSource.getConnection();
- mappingStmt = conn.prepareStatement(sqlQueries.getSqlString(
- "updateMapping", true));
+ mappingStmt = conn.prepareStatement(sqlQueries.getSqlString("updateMapping", true));
ResultSet mappingRS = null;
try {
mappingStmt.setString(1, mapping);
mappingStmt.setString(2, user);
mappingStmt.setString(3, domain);
-
- if (mappingStmt.executeUpdate() < 1) {
+
+ if (mappingStmt.executeUpdate() < 1) {
throw new VirtualUserTableException("Mapping not found");
}
} finally {
@@ -390,16 +378,18 @@ public class JDBCVirtualUserTable extend
theJDBCUtil.closeJDBCConnection(conn);
}
}
-
-
+
/**
* Remove a mapping for the given user and domain
*
- * @param user the user
- * @param domain the domain
- * @param mapping the mapping
+ * @param user
+ * the user
+ * @param domain
+ * the domain
+ * @param mapping
+ * the mapping
* @return true if succesfully
- * @throws VirtualUserTableException
+ * @throws VirtualUserTableException
*/
private void removeRawMapping(String user, String domain, String mapping) throws VirtualUserTableException {
Connection conn = null;
@@ -407,19 +397,18 @@ public class JDBCVirtualUserTable extend
try {
conn = dataSource.getConnection();
- mappingStmt = conn.prepareStatement(sqlQueries.getSqlString(
- "deleteMapping", true));
+ mappingStmt = conn.prepareStatement(sqlQueries.getSqlString("deleteMapping", true));
ResultSet mappingRS = null;
try {
mappingStmt.setString(1, user);
mappingStmt.setString(2, domain);
mappingStmt.setString(3, mapping);
- if(mappingStmt.executeUpdate() < 1) {
+ if (mappingStmt.executeUpdate() < 1) {
throw new VirtualUserTableException("Mapping not found");
}
} finally {
- theJDBCUtil.closeJDBCResultSet(mappingRS);
+ theJDBCUtil.closeJDBCResultSet(mappingRS);
}
} catch (SQLException sqle) {
@@ -429,15 +418,18 @@ public class JDBCVirtualUserTable extend
theJDBCUtil.closeJDBCConnection(conn);
}
}
-
+
/**
* Add mapping for given user and domain
*
- * @param user the user
- * @param domain the domain
- * @param mapping the mapping
+ * @param user
+ * the user
+ * @param domain
+ * the domain
+ * @param mapping
+ * the mapping
* @return true if successfully
- * @throws VirtualUserTableException
+ * @throws VirtualUserTableException
*/
private void addRawMapping(String user, String domain, String mapping) throws VirtualUserTableException {
Connection conn = null;
@@ -445,16 +437,15 @@ public class JDBCVirtualUserTable extend
try {
conn = dataSource.getConnection();
- mappingStmt = conn.prepareStatement(sqlQueries.getSqlString(
- "addMapping", true));
+ mappingStmt = conn.prepareStatement(sqlQueries.getSqlString("addMapping", true));
ResultSet mappingRS = null;
try {
mappingStmt.setString(1, user);
mappingStmt.setString(2, domain);
mappingStmt.setString(3, mapping);
-
- if(mappingStmt.executeUpdate() < 1) {
+
+ if (mappingStmt.executeUpdate() < 1) {
throw new VirtualUserTableException("Mapping not found");
}
} finally {
@@ -469,16 +460,16 @@ public class JDBCVirtualUserTable extend
}
}
-
/**
* Return user String for the given argument
*
- * @param user the given user String
+ * @param user
+ * the given user String
* @return user the user String
*/
private String getUserString(String user) {
if (user != null) {
- if(user.equals(WILDCARD) || user.indexOf("@") < 0) {
+ if (user.equals(WILDCARD) || user.indexOf("@") < 0) {
return user;
} else {
throw new IllegalArgumentException("Invalid user: " + user);
@@ -487,17 +478,18 @@ public class JDBCVirtualUserTable extend
return WILDCARD;
}
}
-
+
/**
* Return domain String for the given argument
*
- * @param domain the given domain String
+ * @param domain
+ * the given domain String
* @return domainString the domain String
*/
private String getDomainString(String domain) {
- if(domain != null) {
+ if (domain != null) {
if (domain.equals(WILDCARD) || domain.indexOf("@") < 0) {
- return domain;
+ return domain;
} else {
throw new IllegalArgumentException("Invalid domain: " + domain);
}
@@ -505,5 +497,5 @@ public class JDBCVirtualUserTable extend
return WILDCARD;
}
}
-
+
}
---------------------------------------------------------------------
To unsubscribe, e-mail: server-dev-unsubscribe@james.apache.org
For additional commands, e-mail: server-dev-help@james.apache.org