Author: dimuthul
Date: Mon Jan  7 23:53:41 2008
New Revision: 11979

Log:

Fixing multiple user role problem.



Removed:
   trunk/commons/usermanager/modules/core/src/test/resources/org/
Modified:
   
trunk/commons/usermanager/modules/core/src/main/java/org/wso2/usermanager/UserManagerException.java
   
trunk/commons/usermanager/modules/core/src/main/java/org/wso2/usermanager/readwrite/DefaultDatabaseUtil.java
   
trunk/commons/usermanager/modules/core/src/main/java/org/wso2/usermanager/readwrite/DefaultUserStoreAdmin.java
   
trunk/commons/usermanager/modules/core/src/main/java/org/wso2/usermanager/readwrite/create_db.sql
   
trunk/commons/usermanager/modules/core/src/main/java/org/wso2/usermanager/resources.properties
   
trunk/commons/usermanager/modules/core/src/main/resources/org/wso2/usermanager/resources.properties
   
trunk/commons/usermanager/modules/core/src/test/java/org/wso2/usermanager/readwrite/DefaultRealmTest.java

Modified: 
trunk/commons/usermanager/modules/core/src/main/java/org/wso2/usermanager/UserManagerException.java
==============================================================================
--- 
trunk/commons/usermanager/modules/core/src/main/java/org/wso2/usermanager/UserManagerException.java
 (original)
+++ 
trunk/commons/usermanager/modules/core/src/main/java/org/wso2/usermanager/UserManagerException.java
 Mon Jan  7 23:53:41 2008
@@ -42,6 +42,6 @@
     }
 
     public UserManagerException(String key, Throwable e) {
-        this(key, null, e);
+        this(key, new Object[]{e.getMessage()}, e);
     }
 }

Modified: 
trunk/commons/usermanager/modules/core/src/main/java/org/wso2/usermanager/readwrite/DefaultDatabaseUtil.java
==============================================================================
--- 
trunk/commons/usermanager/modules/core/src/main/java/org/wso2/usermanager/readwrite/DefaultDatabaseUtil.java
        (original)
+++ 
trunk/commons/usermanager/modules/core/src/main/java/org/wso2/usermanager/readwrite/DefaultDatabaseUtil.java
        Mon Jan  7 23:53:41 2008
@@ -59,11 +59,12 @@
             + " PRIMARY KEY (ID))";
     
     public static  String userRolesTable = "CREATE TABLE UM_USER_ROLES (ID 
VARCHAR(255),"
-        + "ROLE_ID VARCHAR(255),"
-        + "USER_ID VARCHAR(255),"
-        + "FOREIGN KEY (ROLE_ID) REFERENCES UM_ROLES(ID) ON DELETE CASCADE,"
-        + "FOREIGN KEY (USER_ID) REFERENCES UM_USERS(ID) ON DELETE CASCADE,"
-        + "PRIMARY KEY (ID))";
+        + " ROLE_ID VARCHAR(255) NOT NULL,"
+        + " USER_ID VARCHAR(255) NOT NULL,"
+        + " FOREIGN KEY (ROLE_ID) REFERENCES UM_ROLES(ID) ON DELETE CASCADE,"
+        + " FOREIGN KEY (USER_ID) REFERENCES UM_USERS(ID) ON DELETE CASCADE,"
+        + " UNIQUE (USER_ID, ROLE_ID),"
+        + " PRIMARY KEY (ID))";
 
     public static void createDatabase(Connection conn) throws SQLException, 
UserManagerException {
       

Modified: 
trunk/commons/usermanager/modules/core/src/main/java/org/wso2/usermanager/readwrite/DefaultUserStoreAdmin.java
==============================================================================
--- 
trunk/commons/usermanager/modules/core/src/main/java/org/wso2/usermanager/readwrite/DefaultUserStoreAdmin.java
      (original)
+++ 
trunk/commons/usermanager/modules/core/src/main/java/org/wso2/usermanager/readwrite/DefaultUserStoreAdmin.java
      Mon Jan  7 23:53:41 2008
@@ -399,7 +399,7 @@
             addUserToRoleStmt.close();
         } catch (SQLException e) {
             log.debug(e);
-            throw new UserManagerException("errorModifyingUserStore", e);
+            throw new UserManagerException("errorAddingUserToRole", e);
         } finally {
             try {
                 if (dbConnection != null) {

Modified: 
trunk/commons/usermanager/modules/core/src/main/java/org/wso2/usermanager/readwrite/create_db.sql
==============================================================================
--- 
trunk/commons/usermanager/modules/core/src/main/java/org/wso2/usermanager/readwrite/create_db.sql
   (original)
+++ 
trunk/commons/usermanager/modules/core/src/main/java/org/wso2/usermanager/readwrite/create_db.sql
   Mon Jan  7 23:53:41 2008
@@ -5,4 +5,4 @@
 CREATE TABLE UM_PERMISSIONS (ID VARCHAR(255), RESOURCE_ID VARCHAR(255) NOT 
NULL, ACTION VARCHAR(255) NOT NULL, PRIMARY KEY (ID));
 CREATE TABLE UM_ROLE_PERMISSIONS (ID VARCHAR(255), PERMISSION_ID VARCHAR(255) 
NOT NULL, ROLE_ID VARCHAR(255) NOT NULL, IS_ALLOWED SMALLINT NOT NULL, UNIQUE 
(PERMISSION_ID, ROLE_ID), FOREIGN KEY (PERMISSION_ID) REFERENCES 
UM_PERMISSIONS(ID) ON DELETE  CASCADE, FOREIGN KEY (ROLE_ID) REFERENCES 
UM_ROLES(ID) ON DELETE CASCADE, PRIMARY KEY (ID));
 CREATE TABLE UM_USER_PERMISSIONS (ID VARCHAR(255), PERMISSION_ID VARCHAR(255) 
NOT NULL, USER_ID VARCHAR(255) NOT NULL, IS_ALLOWED SMALLINT NOT NULL, UNIQUE 
(PERMISSION_ID, USER_ID), FOREIGN KEY (PERMISSION_ID) REFERENCES 
UM_PERMISSIONS(ID) ON DELETE CASCADE, FOREIGN KEY (USER_ID) REFERENCES 
UM_USERS(ID) ON DELETE CASCADE, PRIMARY KEY (ID));
-CREATE TABLE UM_USER_ROLES (ID VARCHAR(255), ROLE_ID VARCHAR(255), USER_ID 
VARCHAR(255), FOREIGN KEY (ROLE_ID) REFERENCES UM_ROLES(ID) ON DELETE CASCADE, 
FOREIGN KEY (USER_ID) REFERENCES UM_USERS(ID) ON DELETE CASCADE, PRIMARY KEY 
(ID));
\ No newline at end of file
+CREATE TABLE UM_USER_ROLES (ID VARCHAR(255), ROLE_ID VARCHAR(255) NOT NULL, 
USER_ID VARCHAR(255) NOT NULL, UNIQUE (USER_ID, ROLE_ID), FOREIGN KEY (ROLE_ID) 
REFERENCES UM_ROLES(ID) ON DELETE CASCADE, FOREIGN KEY (USER_ID) REFERENCES 
UM_USERS(ID) ON DELETE CASCADE, PRIMARY KEY (ID));
\ No newline at end of file

Modified: 
trunk/commons/usermanager/modules/core/src/main/java/org/wso2/usermanager/resources.properties
==============================================================================
--- 
trunk/commons/usermanager/modules/core/src/main/java/org/wso2/usermanager/resources.properties
      (original)
+++ 
trunk/commons/usermanager/modules/core/src/main/java/org/wso2/usermanager/resources.properties
      Mon Jan  7 23:53:41 2008
@@ -1,3 +1,6 @@
+#This is not the correct resouce.properties. This is here because
+#maven tests fail otherwise.
+errorAddingUserToRole = ErrorAddingUserToRole 
 credentialTypeNotSupport = Credential not Supported
 duplicateUser = User name already exists. Please select another user name!
 exceptionOnConnectionOpen = Error occuered while connecting to Userstore

Modified: 
trunk/commons/usermanager/modules/core/src/main/resources/org/wso2/usermanager/resources.properties
==============================================================================
--- 
trunk/commons/usermanager/modules/core/src/main/resources/org/wso2/usermanager/resources.properties
 (original)
+++ 
trunk/commons/usermanager/modules/core/src/main/resources/org/wso2/usermanager/resources.properties
 Mon Jan  7 23:53:41 2008
@@ -1,3 +1,4 @@
+errorAddingUserToRole = Error adding user to role. {0}
 duplicateUser = User name already exists. Please select another user name!
 exceptionOnConnectionOpen = Error occuered while connecting to Userstore
 sqlFileNotFound = SQL file not found for Default Realm

Modified: 
trunk/commons/usermanager/modules/core/src/test/java/org/wso2/usermanager/readwrite/DefaultRealmTest.java
==============================================================================
--- 
trunk/commons/usermanager/modules/core/src/test/java/org/wso2/usermanager/readwrite/DefaultRealmTest.java
   (original)
+++ 
trunk/commons/usermanager/modules/core/src/test/java/org/wso2/usermanager/readwrite/DefaultRealmTest.java
   Mon Jan  7 23:53:41 2008
@@ -185,7 +185,7 @@
         admin.addRole("normal");
         admin.addRole("hora");
         admin.addUserToRole("dimuthu", "normal");
-        admin.addUserToRole("vajira", "admin");
+        
     }
 
     public void authorizationStuff() throws Exception {

_______________________________________________
Commons-dev mailing list
[email protected]
http://wso2.org/cgi-bin/mailman/listinfo/commons-dev

Reply via email to