[Carbon-dev] svn commit r43596 - in trunk/carbon: org.wso2.carbon.registry.core/src/main/java/org/wso2/carbon/registry/core/jdbc org.wso2.carbon.registry.core/src/main/java/org/wso2/carbon/registry/core/jdbc/realm org.wso2.carbon.registry.core/src/main/java/org/wso2/carbon/registry/core/session org.wso2.carbon.registry.core/src/main/java/org/wso2/carbon/registry/core/utils org.wso2.carbon.registry.core/src/test/java/org/wso2/carbon/registry/core/test/jdbc org.wso2.carbon.registry.core/src/test/java/org/wso2/carbon/registry/core/test/multitenant org.wso2.carbon.registry.core/src/test/java/org/wso2/carbon/registry/core/test/secure org.wso2.carbon.user.core/src/main/java/org/wso2/carbon/user/core/common org.wso2.carbon.user.core/src/main/java/org/wso2/carbon/user/core/config org.wso2.carbon.user.core/src/main/java/org/wso2/carbon/user/core/service org.wso2.carbon.user.core/src/main/java/org/wso2/carbon/user/core/tenant

dimuthu at wso2.com dimuthu at wso2.com
Mon Aug 17 22:49:16 PDT 2009


Author: dimuthu
Date: Mon Aug 17 22:49:15 2009
New Revision: 43596
URL: http://wso2.org/svn/browse/wso2?view=rev&revision=43596

Log:
improved test cases for the tenant.


Modified:
   trunk/carbon/org.wso2.carbon.registry.core/src/main/java/org/wso2/carbon/registry/core/jdbc/InMemoryEmbeddedRegistryService.java
   trunk/carbon/org.wso2.carbon.registry.core/src/main/java/org/wso2/carbon/registry/core/jdbc/realm/InMemoryRealmService.java
   trunk/carbon/org.wso2.carbon.registry.core/src/main/java/org/wso2/carbon/registry/core/session/UserRegistry.java
   trunk/carbon/org.wso2.carbon.registry.core/src/main/java/org/wso2/carbon/registry/core/utils/RegistryUtils.java
   trunk/carbon/org.wso2.carbon.registry.core/src/test/java/org/wso2/carbon/registry/core/test/jdbc/ChrootJDBCTest.java
   trunk/carbon/org.wso2.carbon.registry.core/src/test/java/org/wso2/carbon/registry/core/test/jdbc/CommentsTest.java
   trunk/carbon/org.wso2.carbon.registry.core/src/test/java/org/wso2/carbon/registry/core/test/jdbc/CopyTest.java
   trunk/carbon/org.wso2.carbon.registry.core/src/test/java/org/wso2/carbon/registry/core/test/jdbc/DumpTest.java
   trunk/carbon/org.wso2.carbon.registry.core/src/test/java/org/wso2/carbon/registry/core/test/jdbc/FileRestoreTest.java
   trunk/carbon/org.wso2.carbon.registry.core/src/test/java/org/wso2/carbon/registry/core/test/jdbc/MoveTest.java
   trunk/carbon/org.wso2.carbon.registry.core/src/test/java/org/wso2/carbon/registry/core/test/jdbc/PaginationTest.java
   trunk/carbon/org.wso2.carbon.registry.core/src/test/java/org/wso2/carbon/registry/core/test/jdbc/PathCacheTest.java
   trunk/carbon/org.wso2.carbon.registry.core/src/test/java/org/wso2/carbon/registry/core/test/jdbc/PathsTest.java
   trunk/carbon/org.wso2.carbon.registry.core/src/test/java/org/wso2/carbon/registry/core/test/jdbc/PropertiesTest.java
   trunk/carbon/org.wso2.carbon.registry.core/src/test/java/org/wso2/carbon/registry/core/test/jdbc/QueryTest.java
   trunk/carbon/org.wso2.carbon.registry.core/src/test/java/org/wso2/carbon/registry/core/test/jdbc/RenameTest.java
   trunk/carbon/org.wso2.carbon.registry.core/src/test/java/org/wso2/carbon/registry/core/test/jdbc/ResourcesTest.java
   trunk/carbon/org.wso2.carbon.registry.core/src/test/java/org/wso2/carbon/registry/core/test/jdbc/SimpleLifecycleTest.java
   trunk/carbon/org.wso2.carbon.registry.core/src/test/java/org/wso2/carbon/registry/core/test/jdbc/StaticConfigurationFalseTest.java
   trunk/carbon/org.wso2.carbon.registry.core/src/test/java/org/wso2/carbon/registry/core/test/jdbc/StaticConfigurationTrueTest.java
   trunk/carbon/org.wso2.carbon.registry.core/src/test/java/org/wso2/carbon/registry/core/test/jdbc/SystemRegistryInHandlerTest.java
   trunk/carbon/org.wso2.carbon.registry.core/src/test/java/org/wso2/carbon/registry/core/test/jdbc/TagsTest.java
   trunk/carbon/org.wso2.carbon.registry.core/src/test/java/org/wso2/carbon/registry/core/test/jdbc/TransactionsTest.java
   trunk/carbon/org.wso2.carbon.registry.core/src/test/java/org/wso2/carbon/registry/core/test/jdbc/VersionHandlingTest.java
   trunk/carbon/org.wso2.carbon.registry.core/src/test/java/org/wso2/carbon/registry/core/test/multitenant/MultiTenantTest.java
   trunk/carbon/org.wso2.carbon.registry.core/src/test/java/org/wso2/carbon/registry/core/test/secure/CommentsTest.java
   trunk/carbon/org.wso2.carbon.registry.core/src/test/java/org/wso2/carbon/registry/core/test/secure/SecureRegistryTest.java
   trunk/carbon/org.wso2.carbon.user.core/src/main/java/org/wso2/carbon/user/core/common/DefaultRealmService.java
   trunk/carbon/org.wso2.carbon.user.core/src/main/java/org/wso2/carbon/user/core/config/RealmConfiguration.java
   trunk/carbon/org.wso2.carbon.user.core/src/main/java/org/wso2/carbon/user/core/service/RealmService.java
   trunk/carbon/org.wso2.carbon.user.core/src/main/java/org/wso2/carbon/user/core/tenant/Tenant.java
   trunk/carbon/org.wso2.carbon.user.core/src/main/java/org/wso2/carbon/user/core/tenant/TenantConstants.java
   trunk/carbon/org.wso2.carbon.user.core/src/main/java/org/wso2/carbon/user/core/tenant/TenantManager.java

Modified: trunk/carbon/org.wso2.carbon.registry.core/src/main/java/org/wso2/carbon/registry/core/jdbc/InMemoryEmbeddedRegistryService.java
URL: http://wso2.org/svn/browse/wso2/trunk/carbon/org.wso2.carbon.registry.core/src/main/java/org/wso2/carbon/registry/core/jdbc/InMemoryEmbeddedRegistryService.java?rev=43596&r1=43595&r2=43596&view=diff
==============================================================================
--- trunk/carbon/org.wso2.carbon.registry.core/src/main/java/org/wso2/carbon/registry/core/jdbc/InMemoryEmbeddedRegistryService.java	(original)
+++ trunk/carbon/org.wso2.carbon.registry.core/src/main/java/org/wso2/carbon/registry/core/jdbc/InMemoryEmbeddedRegistryService.java	Mon Aug 17 22:49:15 2009
@@ -37,7 +37,11 @@
         super.configure(realmService);
     }
 
-    public RealmConfiguration getRealmConfiguration() {
+    public RealmConfiguration getBootstrapRealmConfiguration() {
         return realmService.getBootstrapRealmConfiguration();
     }
+
+    public RealmService getRealmServie() {
+        return realmService;
+    }
 }

Modified: trunk/carbon/org.wso2.carbon.registry.core/src/main/java/org/wso2/carbon/registry/core/jdbc/realm/InMemoryRealmService.java
URL: http://wso2.org/svn/browse/wso2/trunk/carbon/org.wso2.carbon.registry.core/src/main/java/org/wso2/carbon/registry/core/jdbc/realm/InMemoryRealmService.java?rev=43596&r1=43595&r2=43596&view=diff
==============================================================================
--- trunk/carbon/org.wso2.carbon.registry.core/src/main/java/org/wso2/carbon/registry/core/jdbc/realm/InMemoryRealmService.java	(original)
+++ trunk/carbon/org.wso2.carbon.registry.core/src/main/java/org/wso2/carbon/registry/core/jdbc/realm/InMemoryRealmService.java	Mon Aug 17 22:49:15 2009
@@ -20,6 +20,7 @@
 
 import org.wso2.carbon.user.core.service.RealmService;
 import org.wso2.carbon.user.core.UserRealm;
+import org.wso2.carbon.user.core.UserStoreException;
 import org.wso2.carbon.user.core.tenant.TenantManager;
 import org.wso2.carbon.user.core.common.DefaultRealm;
 import org.wso2.carbon.user.core.config.RealmConfiguration;
@@ -42,8 +43,9 @@
     RealmConfiguration bootstrapRealmConfig = null;
     UserRealm bootstrapRealm = null;
     private static final Log log = LogFactory.getLog(InMemoryRealmService.class);
+    TenantManager tenantManager;
 
-    public InMemoryRealmService() throws RegistryException{
+    public InMemoryRealmService() throws RegistryException {
         setup();
         bootstrapRealm = new DefaultRealm();
         try {
@@ -54,10 +56,12 @@
         }
     }
 
-    public UserRealm getUserRealm(RealmConfiguration tenantRealmConfig) throws Exception {
+    public UserRealm getUserRealm(RealmConfiguration tenantRealmConfig) throws UserStoreException {
         int tenantId = tenantRealmConfig.getTenantId();
         UserRealm userRealm = userRealmMap.get(new Integer(tenantId));
-        if (userRealm == null) {
+        if (userRealm == null ||
+                !userRealm.getRealmConfiguration().getPersistedTimestamp().equals(
+                tenantRealmConfig.getPersistedTimestamp())) {
             userRealm = new DefaultRealm();
             userRealm.init(tenantRealmConfig, null, null, tenantId); // will use the default data
             userRealmMap.put(new Integer(tenantId), userRealm);
@@ -103,9 +107,10 @@
             log.error(msg, e);
             throw new RegistryException(msg, e);
         }
+        this.tenantManager = new TenantManager(ds);
     }
     
-    public UserRealm getBootstrapRealm() throws Exception {
+    public UserRealm getBootstrapRealm() throws UserStoreException {
         return bootstrapRealm;
     }
 
@@ -122,6 +127,6 @@
         return dir.delete();
     }
      public TenantManager getTenantManager() {
-         return null;
+         return tenantManager;
      }
 }

Modified: trunk/carbon/org.wso2.carbon.registry.core/src/main/java/org/wso2/carbon/registry/core/session/UserRegistry.java
URL: http://wso2.org/svn/browse/wso2/trunk/carbon/org.wso2.carbon.registry.core/src/main/java/org/wso2/carbon/registry/core/session/UserRegistry.java?rev=43596&r1=43595&r2=43596&view=diff
==============================================================================
--- trunk/carbon/org.wso2.carbon.registry.core/src/main/java/org/wso2/carbon/registry/core/session/UserRegistry.java	(original)
+++ trunk/carbon/org.wso2.carbon.registry.core/src/main/java/org/wso2/carbon/registry/core/session/UserRegistry.java	Mon Aug 17 22:49:15 2009
@@ -171,7 +171,7 @@
             // if we are login as system user, we always use bootstrap realm to do the work.
             // getting the bootstrap realm from the realm service.
             try {
-                this.userRealm = realmService.getBootstrapRealm();
+                this.userRealm = new RegistryRealm(realmService.getBootstrapRealm());
             }
             catch (Exception e) {
                 String msg = "Failed in getting the bootstrap realm for the tenantId: " + tenantId + ".";
@@ -245,7 +245,7 @@
         RegistryUtils.addServiceStoreCollection(this, registryContext.getServicepath());
         // adding /system/user-core/user-mgt.xml, if it doesn't already exist a copy of
         // bootstrap configuration is created
-        RegistryUtils.addRealmConfiguration(this, this.userRealm);
+        RegistryUtils.addDefaultRealmConfiguration(this, this.userRealm);
         // adding service configurations
         RegistryUtils.addServiceConfigResources(this);
     }

Modified: trunk/carbon/org.wso2.carbon.registry.core/src/main/java/org/wso2/carbon/registry/core/utils/RegistryUtils.java
URL: http://wso2.org/svn/browse/wso2/trunk/carbon/org.wso2.carbon.registry.core/src/main/java/org/wso2/carbon/registry/core/utils/RegistryUtils.java?rev=43596&r1=43595&r2=43596&view=diff
==============================================================================
--- trunk/carbon/org.wso2.carbon.registry.core/src/main/java/org/wso2/carbon/registry/core/utils/RegistryUtils.java	(original)
+++ trunk/carbon/org.wso2.carbon.registry.core/src/main/java/org/wso2/carbon/registry/core/utils/RegistryUtils.java	Mon Aug 17 22:49:15 2009
@@ -594,14 +594,20 @@
         return methods;
     }
 
-
-    public static void addRealmConfiguration(Registry registry, UserRealm bootstrapRealm) throws RegistryException {
+    /**
+     * Add the bootstrap realm configuration as the default configuration for the system registry
+     * @param tenantSystemRegistry
+     * @param bootstrapRealm
+     * @throws RegistryException
+     */
+    public static void addDefaultRealmConfiguration(Registry tenantSystemRegistry,
+                                                    UserRealm bootstrapRealm) throws RegistryException {
 
         if(log.isTraceEnabled()) {
             log.trace("Checking the existance of '" + RegistryConstants.REALM_CONFIGURATION_PATH +
                     "' resource of the Registry.");
         }
-        if (!registry.resourceExists(RegistryConstants.REALM_CONFIGURATION_PATH)) {
+        if (!tenantSystemRegistry.resourceExists(RegistryConstants.REALM_CONFIGURATION_PATH)) {
             if(log.isTraceEnabled()) {
                 log.trace("Creating the '" + RegistryConstants.REALM_CONFIGURATION_PATH + "'resource of the Registry.");
             }
@@ -613,16 +619,33 @@
                 log.error(msg);
                 throw new RegistryException(msg, e);
             }
-            OMElement realmConfig = RealmConfigXMLProcessor.serialize(bootstrapRelamConfig);
-            Resource realmConfigResource = registry.newResource();
-            realmConfigResource.setContent(realmConfig.toString());
-            String realmConfigurationDescription = "The user-core configuration for the registry.";
-            realmConfigResource.setDescription(realmConfigurationDescription);
-            registry.put(RegistryConstants.REALM_CONFIGURATION_PATH, realmConfigResource);
-            realmConfigResource.discard();
+            persistRealmConfiguration(tenantSystemRegistry, bootstrapRelamConfig);
         }
     }
 
+    /**
+     * Persist the user-mgt.xml in the registry
+     * @param tenantSystemRegistry
+     * @param realmConfig
+     * @throws RegistryException
+     */
+    public static void persistRealmConfiguration(Registry tenantSystemRegistry,
+                                                 RealmConfiguration realmConfig) throws RegistryException {
+        OMElement realmConfigEle = RealmConfigXMLProcessor.serialize(realmConfig);
+        Resource realmConfigResource = tenantSystemRegistry.newResource();
+        realmConfigResource.setContent(realmConfigEle.toString());
+        String realmConfigurationDescription = "The user-core configuration for the registry.";
+        realmConfigResource.setDescription(realmConfigurationDescription);
+        tenantSystemRegistry.put(RegistryConstants.REALM_CONFIGURATION_PATH, realmConfigResource);
+        realmConfigResource.discard();
+    }
+
+    /**
+     * Get the realm configuration from the system registry specific to the tenant
+     * @param tenantSystemRegistry
+     * @return
+     * @throws RegistryException
+     */
     public static RealmConfiguration getRealmConfiguration(UserRegistry tenantSystemRegistry) throws RegistryException {
         // read the realmconfiguration from the registry
         Resource realmConfigResource = tenantSystemRegistry.get(RegistryConstants.REALM_CONFIGURATION_PATH);
@@ -648,6 +671,7 @@
 
         RealmConfiguration tenantRealmConfig = new RealmConfigXMLProcessor().
                     buildRealmConfiguration(realmElement);
+        tenantRealmConfig.setPersistedTimestamp(realmConfigResource.getLastModified());
         return tenantRealmConfig;
     }
 

Modified: trunk/carbon/org.wso2.carbon.registry.core/src/test/java/org/wso2/carbon/registry/core/test/jdbc/ChrootJDBCTest.java
URL: http://wso2.org/svn/browse/wso2/trunk/carbon/org.wso2.carbon.registry.core/src/test/java/org/wso2/carbon/registry/core/test/jdbc/ChrootJDBCTest.java?rev=43596&r1=43595&r2=43596&view=diff
==============================================================================
--- trunk/carbon/org.wso2.carbon.registry.core/src/test/java/org/wso2/carbon/registry/core/test/jdbc/ChrootJDBCTest.java	(original)
+++ trunk/carbon/org.wso2.carbon.registry.core/src/test/java/org/wso2/carbon/registry/core/test/jdbc/ChrootJDBCTest.java	Mon Aug 17 22:49:15 2009
@@ -19,7 +19,6 @@
 import org.wso2.carbon.registry.core.Resource;
 import org.wso2.carbon.registry.core.exceptions.RegistryException;
 import org.wso2.carbon.user.core.config.RealmConfiguration;
-import org.wso2.carbon.user.core.UserStoreException;
 
 /**
  * Execute all the JDBC registry tests with a non-standard root.
@@ -30,7 +29,7 @@
     public void setUp() {
         super.setUp();
         try {
-            RealmConfiguration realmConfig = embeddedRegistryService.getRealmConfiguration();
+            RealmConfiguration realmConfig = embeddedRegistryService.getBootstrapRealmConfiguration();
             originalRegistry = embeddedRegistryService.getUserRegistry(realmConfig.getAdminUserName());
             registry = embeddedRegistryService.getUserRegistry(realmConfig.getAdminUserName(), 0, "/basePrefix");
             systemRegistry = embeddedRegistryService.getSystemRegistry(0, "/basePrefix");

Modified: trunk/carbon/org.wso2.carbon.registry.core/src/test/java/org/wso2/carbon/registry/core/test/jdbc/CommentsTest.java
URL: http://wso2.org/svn/browse/wso2/trunk/carbon/org.wso2.carbon.registry.core/src/test/java/org/wso2/carbon/registry/core/test/jdbc/CommentsTest.java?rev=43596&r1=43595&r2=43596&view=diff
==============================================================================
--- trunk/carbon/org.wso2.carbon.registry.core/src/test/java/org/wso2/carbon/registry/core/test/jdbc/CommentsTest.java	(original)
+++ trunk/carbon/org.wso2.carbon.registry.core/src/test/java/org/wso2/carbon/registry/core/test/jdbc/CommentsTest.java	Mon Aug 17 22:49:15 2009
@@ -21,7 +21,6 @@
 import org.wso2.carbon.registry.core.jdbc.InMemoryEmbeddedRegistryService;
 import org.wso2.carbon.registry.core.*;
 import org.wso2.carbon.registry.core.test.utils.BaseTestCase;
-import org.wso2.carbon.user.core.UserStoreException;
 import org.wso2.carbon.user.core.config.RealmConfiguration;
 
 import java.util.Map;
@@ -43,7 +42,7 @@
             embeddedRegistryService = new InMemoryEmbeddedRegistryService();
             // get the realm config to retrieve admin username, password
 
-            RealmConfiguration realmConfig = embeddedRegistryService.getRealmConfiguration();
+            RealmConfiguration realmConfig = embeddedRegistryService.getBootstrapRealmConfiguration();
             registry = embeddedRegistryService.getUserRegistry(
                 realmConfig.getAdminUserName(), realmConfig.getAdminPassword());
             systemRegistry = embeddedRegistryService.getSystemRegistry();

Modified: trunk/carbon/org.wso2.carbon.registry.core/src/test/java/org/wso2/carbon/registry/core/test/jdbc/CopyTest.java
URL: http://wso2.org/svn/browse/wso2/trunk/carbon/org.wso2.carbon.registry.core/src/test/java/org/wso2/carbon/registry/core/test/jdbc/CopyTest.java?rev=43596&r1=43595&r2=43596&view=diff
==============================================================================
--- trunk/carbon/org.wso2.carbon.registry.core/src/test/java/org/wso2/carbon/registry/core/test/jdbc/CopyTest.java	(original)
+++ trunk/carbon/org.wso2.carbon.registry.core/src/test/java/org/wso2/carbon/registry/core/test/jdbc/CopyTest.java	Mon Aug 17 22:49:15 2009
@@ -18,12 +18,10 @@
 
 import org.wso2.carbon.registry.core.exceptions.RegistryException;
 
-import org.wso2.carbon.registry.core.jdbc.EmbeddedRegistryService;
 import org.wso2.carbon.registry.core.jdbc.InMemoryEmbeddedRegistryService;
 import org.wso2.carbon.registry.core.*;
 import org.wso2.carbon.registry.core.test.utils.BaseTestCase;
 import org.wso2.carbon.user.core.config.RealmConfiguration;
-import org.wso2.carbon.user.core.UserStoreException;
 
 public class CopyTest extends BaseTestCase {
 
@@ -39,7 +37,7 @@
         try {
             embeddedRegistryService = new InMemoryEmbeddedRegistryService();
             // get the realm config to retrieve admin username, password
-            RealmConfiguration realmConfig = embeddedRegistryService.getRealmConfiguration();
+            RealmConfiguration realmConfig = embeddedRegistryService.getBootstrapRealmConfiguration();
             registry = embeddedRegistryService.getUserRegistry(
                 realmConfig.getAdminUserName(), realmConfig.getAdminPassword());
         } catch (RegistryException e) {

Modified: trunk/carbon/org.wso2.carbon.registry.core/src/test/java/org/wso2/carbon/registry/core/test/jdbc/DumpTest.java
URL: http://wso2.org/svn/browse/wso2/trunk/carbon/org.wso2.carbon.registry.core/src/test/java/org/wso2/carbon/registry/core/test/jdbc/DumpTest.java?rev=43596&r1=43595&r2=43596&view=diff
==============================================================================
--- trunk/carbon/org.wso2.carbon.registry.core/src/test/java/org/wso2/carbon/registry/core/test/jdbc/DumpTest.java	(original)
+++ trunk/carbon/org.wso2.carbon.registry.core/src/test/java/org/wso2/carbon/registry/core/test/jdbc/DumpTest.java	Mon Aug 17 22:49:15 2009
@@ -16,14 +16,12 @@
 
 package org.wso2.carbon.registry.core.test.jdbc;
 
-import org.wso2.carbon.registry.core.jdbc.EmbeddedRegistryService;
 import org.wso2.carbon.registry.core.jdbc.InMemoryEmbeddedRegistryService;
 
 import org.wso2.carbon.registry.core.*;
 import org.wso2.carbon.registry.core.test.utils.BaseTestCase;
 import org.wso2.carbon.registry.core.exceptions.RegistryException;
 import org.wso2.carbon.user.core.config.RealmConfiguration;
-import org.wso2.carbon.user.core.UserStoreException;
 
 import java.io.StringWriter;
 import java.io.Reader;
@@ -46,7 +44,7 @@
         try {
             embeddedRegistryService = new InMemoryEmbeddedRegistryService();
             // get the realm config to retrieve admin username, password
-            RealmConfiguration realmConfig = embeddedRegistryService.getRealmConfiguration();
+            RealmConfiguration realmConfig = embeddedRegistryService.getBootstrapRealmConfiguration();
             registry = embeddedRegistryService.getUserRegistry(
                 realmConfig.getAdminUserName(), realmConfig.getAdminPassword());
         } catch (RegistryException e) {

Modified: trunk/carbon/org.wso2.carbon.registry.core/src/test/java/org/wso2/carbon/registry/core/test/jdbc/FileRestoreTest.java
URL: http://wso2.org/svn/browse/wso2/trunk/carbon/org.wso2.carbon.registry.core/src/test/java/org/wso2/carbon/registry/core/test/jdbc/FileRestoreTest.java?rev=43596&r1=43595&r2=43596&view=diff
==============================================================================
--- trunk/carbon/org.wso2.carbon.registry.core/src/test/java/org/wso2/carbon/registry/core/test/jdbc/FileRestoreTest.java	(original)
+++ trunk/carbon/org.wso2.carbon.registry.core/src/test/java/org/wso2/carbon/registry/core/test/jdbc/FileRestoreTest.java	Mon Aug 17 22:49:15 2009
@@ -19,16 +19,13 @@
 package org.wso2.carbon.registry.core.test.jdbc;
 
 import org.wso2.carbon.registry.core.test.utils.BaseTestCase;
-import org.wso2.carbon.registry.core.jdbc.EmbeddedRegistryService;
 import org.wso2.carbon.registry.core.jdbc.InMemoryEmbeddedRegistryService;
 
 import org.wso2.carbon.registry.core.Registry;
-import org.wso2.carbon.registry.core.RegistryConstants;
 import org.wso2.carbon.registry.core.Resource;
 import org.wso2.carbon.registry.core.Comment;
 import org.wso2.carbon.registry.core.exceptions.RegistryException;
 import org.wso2.carbon.user.core.config.RealmConfiguration;
-import org.wso2.carbon.user.core.UserStoreException;
 import org.apache.axiom.om.OMElement;
 import org.apache.axiom.om.impl.builder.StAXOMBuilder;
 
@@ -52,7 +49,7 @@
         try {
             embeddedRegistryService = new InMemoryEmbeddedRegistryService();
             // get the realm config to retrieve admin username, password
-            RealmConfiguration realmConfig = embeddedRegistryService.getRealmConfiguration();
+            RealmConfiguration realmConfig = embeddedRegistryService.getBootstrapRealmConfiguration();
             registry = embeddedRegistryService.getUserRegistry(
                 realmConfig.getAdminUserName(), realmConfig.getAdminPassword());
         } catch (RegistryException e) {

Modified: trunk/carbon/org.wso2.carbon.registry.core/src/test/java/org/wso2/carbon/registry/core/test/jdbc/MoveTest.java
URL: http://wso2.org/svn/browse/wso2/trunk/carbon/org.wso2.carbon.registry.core/src/test/java/org/wso2/carbon/registry/core/test/jdbc/MoveTest.java?rev=43596&r1=43595&r2=43596&view=diff
==============================================================================
--- trunk/carbon/org.wso2.carbon.registry.core/src/test/java/org/wso2/carbon/registry/core/test/jdbc/MoveTest.java	(original)
+++ trunk/carbon/org.wso2.carbon.registry.core/src/test/java/org/wso2/carbon/registry/core/test/jdbc/MoveTest.java	Mon Aug 17 22:49:15 2009
@@ -18,13 +18,11 @@
 
 import org.wso2.carbon.registry.core.exceptions.RegistryException;
 
-import org.wso2.carbon.registry.core.jdbc.EmbeddedRegistryService;
 import org.wso2.carbon.registry.core.jdbc.InMemoryEmbeddedRegistryService;
 import org.wso2.carbon.registry.core.Collection;
 import org.wso2.carbon.registry.core.*;
 import org.wso2.carbon.registry.core.test.utils.BaseTestCase;
 import org.wso2.carbon.user.core.config.RealmConfiguration;
-import org.wso2.carbon.user.core.UserStoreException;
 
 public class MoveTest extends BaseTestCase {
 
@@ -40,7 +38,7 @@
         try {
             embeddedRegistryService = new InMemoryEmbeddedRegistryService();
             // get the realm config to retrieve admin username, password
-            RealmConfiguration realmConfig = embeddedRegistryService.getRealmConfiguration();
+            RealmConfiguration realmConfig = embeddedRegistryService.getBootstrapRealmConfiguration();
             registry = embeddedRegistryService.getUserRegistry(
                 realmConfig.getAdminUserName(), realmConfig.getAdminPassword());
         } catch (RegistryException e) {

Modified: trunk/carbon/org.wso2.carbon.registry.core/src/test/java/org/wso2/carbon/registry/core/test/jdbc/PaginationTest.java
URL: http://wso2.org/svn/browse/wso2/trunk/carbon/org.wso2.carbon.registry.core/src/test/java/org/wso2/carbon/registry/core/test/jdbc/PaginationTest.java?rev=43596&r1=43595&r2=43596&view=diff
==============================================================================
--- trunk/carbon/org.wso2.carbon.registry.core/src/test/java/org/wso2/carbon/registry/core/test/jdbc/PaginationTest.java	(original)
+++ trunk/carbon/org.wso2.carbon.registry.core/src/test/java/org/wso2/carbon/registry/core/test/jdbc/PaginationTest.java	Mon Aug 17 22:49:15 2009
@@ -18,15 +18,12 @@
 
 import org.wso2.carbon.registry.core.exceptions.RegistryException;
 
-import org.wso2.carbon.registry.core.jdbc.EmbeddedRegistryService;
 import org.wso2.carbon.registry.core.jdbc.InMemoryEmbeddedRegistryService;
 import org.wso2.carbon.registry.core.Collection;
 import org.wso2.carbon.registry.core.Registry;
-import org.wso2.carbon.registry.core.RegistryConstants;
 import org.wso2.carbon.registry.core.Resource;
 import org.wso2.carbon.registry.core.test.utils.BaseTestCase;
 import org.wso2.carbon.user.core.config.RealmConfiguration;
-import org.wso2.carbon.user.core.UserStoreException;
 
 public class PaginationTest extends BaseTestCase {
 
@@ -42,7 +39,7 @@
         try {
             embeddedRegistryService = new InMemoryEmbeddedRegistryService();
             // get the realm config to retrieve admin username, password
-            RealmConfiguration realmConfig = embeddedRegistryService.getRealmConfiguration();
+            RealmConfiguration realmConfig = embeddedRegistryService.getBootstrapRealmConfiguration();
             registry = embeddedRegistryService.getUserRegistry(
                 realmConfig.getAdminUserName(), realmConfig.getAdminPassword());
         } catch (RegistryException e) {

Modified: trunk/carbon/org.wso2.carbon.registry.core/src/test/java/org/wso2/carbon/registry/core/test/jdbc/PathCacheTest.java
URL: http://wso2.org/svn/browse/wso2/trunk/carbon/org.wso2.carbon.registry.core/src/test/java/org/wso2/carbon/registry/core/test/jdbc/PathCacheTest.java?rev=43596&r1=43595&r2=43596&view=diff
==============================================================================
--- trunk/carbon/org.wso2.carbon.registry.core/src/test/java/org/wso2/carbon/registry/core/test/jdbc/PathCacheTest.java	(original)
+++ trunk/carbon/org.wso2.carbon.registry.core/src/test/java/org/wso2/carbon/registry/core/test/jdbc/PathCacheTest.java	Mon Aug 17 22:49:15 2009
@@ -18,15 +18,12 @@
 
 import org.wso2.carbon.registry.core.exceptions.RegistryException;
 
-import org.wso2.carbon.registry.core.jdbc.EmbeddedRegistryService;
 import org.wso2.carbon.registry.core.jdbc.InMemoryEmbeddedRegistryService;
 import org.wso2.carbon.registry.core.jdbc.dao.PathCache;
 import org.wso2.carbon.registry.core.Registry;
-import org.wso2.carbon.registry.core.RegistryConstants;
 import org.wso2.carbon.registry.core.Resource;
 import org.wso2.carbon.registry.core.test.utils.BaseTestCase;
 import org.wso2.carbon.user.core.config.RealmConfiguration;
-import org.wso2.carbon.user.core.UserStoreException;
 
 public class PathCacheTest extends BaseTestCase {
 
@@ -42,7 +39,7 @@
         try {
             embeddedRegistryService = new InMemoryEmbeddedRegistryService();
             // get the realm config to retrieve admin username, password
-            RealmConfiguration realmConfig = embeddedRegistryService.getRealmConfiguration();
+            RealmConfiguration realmConfig = embeddedRegistryService.getBootstrapRealmConfiguration();
             registry = embeddedRegistryService.getUserRegistry(
                 realmConfig.getAdminUserName(), realmConfig.getAdminPassword());
         } catch (RegistryException e) {

Modified: trunk/carbon/org.wso2.carbon.registry.core/src/test/java/org/wso2/carbon/registry/core/test/jdbc/PathsTest.java
URL: http://wso2.org/svn/browse/wso2/trunk/carbon/org.wso2.carbon.registry.core/src/test/java/org/wso2/carbon/registry/core/test/jdbc/PathsTest.java?rev=43596&r1=43595&r2=43596&view=diff
==============================================================================
--- trunk/carbon/org.wso2.carbon.registry.core/src/test/java/org/wso2/carbon/registry/core/test/jdbc/PathsTest.java	(original)
+++ trunk/carbon/org.wso2.carbon.registry.core/src/test/java/org/wso2/carbon/registry/core/test/jdbc/PathsTest.java	Mon Aug 17 22:49:15 2009
@@ -18,15 +18,12 @@
 
 import org.wso2.carbon.registry.core.exceptions.RegistryException;
 
-import org.wso2.carbon.registry.core.jdbc.EmbeddedRegistryService;
 import org.wso2.carbon.registry.core.jdbc.InMemoryEmbeddedRegistryService;
 import org.wso2.carbon.registry.core.Collection;
 import org.wso2.carbon.registry.core.Registry;
-import org.wso2.carbon.registry.core.RegistryConstants;
 import org.wso2.carbon.registry.core.Resource;
 import org.wso2.carbon.registry.core.test.utils.BaseTestCase;
 import org.wso2.carbon.user.core.config.RealmConfiguration;
-import org.wso2.carbon.user.core.UserStoreException;
 
 public class PathsTest extends BaseTestCase {
 
@@ -42,7 +39,7 @@
         try {
             embeddedRegistryService = new InMemoryEmbeddedRegistryService();
             // get the realm config to retrieve admin username, password
-            RealmConfiguration realmConfig = embeddedRegistryService.getRealmConfiguration();
+            RealmConfiguration realmConfig = embeddedRegistryService.getBootstrapRealmConfiguration();
             registry = embeddedRegistryService.getUserRegistry(
                 realmConfig.getAdminUserName(), realmConfig.getAdminPassword());
         } catch (RegistryException e) {

Modified: trunk/carbon/org.wso2.carbon.registry.core/src/test/java/org/wso2/carbon/registry/core/test/jdbc/PropertiesTest.java
URL: http://wso2.org/svn/browse/wso2/trunk/carbon/org.wso2.carbon.registry.core/src/test/java/org/wso2/carbon/registry/core/test/jdbc/PropertiesTest.java?rev=43596&r1=43595&r2=43596&view=diff
==============================================================================
--- trunk/carbon/org.wso2.carbon.registry.core/src/test/java/org/wso2/carbon/registry/core/test/jdbc/PropertiesTest.java	(original)
+++ trunk/carbon/org.wso2.carbon.registry.core/src/test/java/org/wso2/carbon/registry/core/test/jdbc/PropertiesTest.java	Mon Aug 17 22:49:15 2009
@@ -23,7 +23,6 @@
 
 import org.wso2.carbon.registry.core.jdbc.InMemoryEmbeddedRegistryService;
 import org.wso2.carbon.user.core.config.RealmConfiguration;
-import org.wso2.carbon.user.core.UserStoreException;
 
 import java.util.List;
 
@@ -41,7 +40,7 @@
         try {
             embeddedRegistryService = new InMemoryEmbeddedRegistryService();
             // get the realm config to retrieve admin username, password
-            RealmConfiguration realmConfig = embeddedRegistryService.getRealmConfiguration();
+            RealmConfiguration realmConfig = embeddedRegistryService.getBootstrapRealmConfiguration();
             registry = embeddedRegistryService.getUserRegistry(
                 realmConfig.getAdminUserName(), realmConfig.getAdminPassword());
         } catch (RegistryException e) {

Modified: trunk/carbon/org.wso2.carbon.registry.core/src/test/java/org/wso2/carbon/registry/core/test/jdbc/QueryTest.java
URL: http://wso2.org/svn/browse/wso2/trunk/carbon/org.wso2.carbon.registry.core/src/test/java/org/wso2/carbon/registry/core/test/jdbc/QueryTest.java?rev=43596&r1=43595&r2=43596&view=diff
==============================================================================
--- trunk/carbon/org.wso2.carbon.registry.core/src/test/java/org/wso2/carbon/registry/core/test/jdbc/QueryTest.java	(original)
+++ trunk/carbon/org.wso2.carbon.registry.core/src/test/java/org/wso2/carbon/registry/core/test/jdbc/QueryTest.java	Mon Aug 17 22:49:15 2009
@@ -16,7 +16,6 @@
 
 package org.wso2.carbon.registry.core.test.jdbc;
 
-import org.wso2.carbon.registry.core.jdbc.EmbeddedRegistryService;
 import org.wso2.carbon.registry.core.jdbc.InMemoryEmbeddedRegistryService;
 
 import org.wso2.carbon.registry.core.*;
@@ -24,7 +23,6 @@
 import org.wso2.carbon.registry.core.test.utils.BaseTestCase;
 import org.wso2.carbon.registry.core.exceptions.RegistryException;
 import org.wso2.carbon.user.core.config.RealmConfiguration;
-import org.wso2.carbon.user.core.UserStoreException;
 
 import java.util.*;
 
@@ -44,7 +42,7 @@
         try {
             embeddedRegistryService = new InMemoryEmbeddedRegistryService();
             // get the realm config to retrieve admin username, password
-            RealmConfiguration realmConfig = embeddedRegistryService.getRealmConfiguration();
+            RealmConfiguration realmConfig = embeddedRegistryService.getBootstrapRealmConfiguration();
             registry = embeddedRegistryService.getUserRegistry(
                 realmConfig.getAdminUserName(), realmConfig.getAdminPassword());
             systemRegistry = embeddedRegistryService.getSystemRegistry();  

Modified: trunk/carbon/org.wso2.carbon.registry.core/src/test/java/org/wso2/carbon/registry/core/test/jdbc/RenameTest.java
URL: http://wso2.org/svn/browse/wso2/trunk/carbon/org.wso2.carbon.registry.core/src/test/java/org/wso2/carbon/registry/core/test/jdbc/RenameTest.java?rev=43596&r1=43595&r2=43596&view=diff
==============================================================================
--- trunk/carbon/org.wso2.carbon.registry.core/src/test/java/org/wso2/carbon/registry/core/test/jdbc/RenameTest.java	(original)
+++ trunk/carbon/org.wso2.carbon.registry.core/src/test/java/org/wso2/carbon/registry/core/test/jdbc/RenameTest.java	Mon Aug 17 22:49:15 2009
@@ -18,14 +18,11 @@
 
 import org.wso2.carbon.registry.core.Registry;
 import org.wso2.carbon.registry.core.exceptions.RegistryException;
-import org.wso2.carbon.registry.core.RegistryConstants;
 import org.wso2.carbon.registry.core.Resource;
 import org.wso2.carbon.registry.core.test.utils.BaseTestCase;
 
-import org.wso2.carbon.registry.core.jdbc.EmbeddedRegistryService;
 import org.wso2.carbon.registry.core.jdbc.InMemoryEmbeddedRegistryService;
 import org.wso2.carbon.user.core.config.RealmConfiguration;
-import org.wso2.carbon.user.core.UserStoreException;
 
 public class RenameTest extends BaseTestCase {
 
@@ -41,7 +38,7 @@
         try {
             embeddedRegistryService = new InMemoryEmbeddedRegistryService();
             // get the realm config to retrieve admin username, password
-            RealmConfiguration realmConfig = embeddedRegistryService.getRealmConfiguration();
+            RealmConfiguration realmConfig = embeddedRegistryService.getBootstrapRealmConfiguration();
             registry = embeddedRegistryService.getUserRegistry(
                 realmConfig.getAdminUserName(), realmConfig.getAdminPassword());
         } catch (RegistryException e) {

Modified: trunk/carbon/org.wso2.carbon.registry.core/src/test/java/org/wso2/carbon/registry/core/test/jdbc/ResourcesTest.java
URL: http://wso2.org/svn/browse/wso2/trunk/carbon/org.wso2.carbon.registry.core/src/test/java/org/wso2/carbon/registry/core/test/jdbc/ResourcesTest.java?rev=43596&r1=43595&r2=43596&view=diff
==============================================================================
--- trunk/carbon/org.wso2.carbon.registry.core/src/test/java/org/wso2/carbon/registry/core/test/jdbc/ResourcesTest.java	(original)
+++ trunk/carbon/org.wso2.carbon.registry.core/src/test/java/org/wso2/carbon/registry/core/test/jdbc/ResourcesTest.java	Mon Aug 17 22:49:15 2009
@@ -17,15 +17,12 @@
 package org.wso2.carbon.registry.core.test.jdbc;
 
 import org.wso2.carbon.registry.core.Registry;
-import org.wso2.carbon.registry.core.RegistryConstants;
 import org.wso2.carbon.registry.core.Resource;
 import org.wso2.carbon.registry.core.test.utils.BaseTestCase;
 import org.wso2.carbon.registry.core.exceptions.RegistryException;
 
-import org.wso2.carbon.registry.core.jdbc.EmbeddedRegistryService;
 import org.wso2.carbon.registry.core.jdbc.InMemoryEmbeddedRegistryService;
 import org.wso2.carbon.user.core.config.RealmConfiguration;
-import org.wso2.carbon.user.core.UserStoreException;
 
 public class ResourcesTest extends BaseTestCase {
 
@@ -41,7 +38,7 @@
         try {
             embeddedRegistryService = new InMemoryEmbeddedRegistryService();
             // get the realm config to retrieve admin username, password
-            RealmConfiguration realmConfig = embeddedRegistryService.getRealmConfiguration();
+            RealmConfiguration realmConfig = embeddedRegistryService.getBootstrapRealmConfiguration();
             registry = embeddedRegistryService.getUserRegistry(
                 realmConfig.getAdminUserName(), realmConfig.getAdminPassword());
         } catch (RegistryException e) {

Modified: trunk/carbon/org.wso2.carbon.registry.core/src/test/java/org/wso2/carbon/registry/core/test/jdbc/SimpleLifecycleTest.java
URL: http://wso2.org/svn/browse/wso2/trunk/carbon/org.wso2.carbon.registry.core/src/test/java/org/wso2/carbon/registry/core/test/jdbc/SimpleLifecycleTest.java?rev=43596&r1=43595&r2=43596&view=diff
==============================================================================
--- trunk/carbon/org.wso2.carbon.registry.core/src/test/java/org/wso2/carbon/registry/core/test/jdbc/SimpleLifecycleTest.java	(original)
+++ trunk/carbon/org.wso2.carbon.registry.core/src/test/java/org/wso2/carbon/registry/core/test/jdbc/SimpleLifecycleTest.java	Mon Aug 17 22:49:15 2009
@@ -24,7 +24,6 @@
 import org.wso2.carbon.registry.core.Resource;
 import org.wso2.carbon.registry.core.test.utils.BaseTestCase;
 import org.wso2.carbon.user.core.config.RealmConfiguration;
-import org.wso2.carbon.user.core.UserStoreException;
 
 public class SimpleLifecycleTest extends BaseTestCase {
     // todo: aspect
@@ -84,7 +83,7 @@
         try {
             embeddedRegistryService = new InMemoryEmbeddedRegistryService();
             // get the realm config to retrieve admin username, password
-            RealmConfiguration realmConfig = embeddedRegistryService.getRealmConfiguration();
+            RealmConfiguration realmConfig = embeddedRegistryService.getBootstrapRealmConfiguration();
             registry = embeddedRegistryService.getUserRegistry(
                 realmConfig.getAdminUserName(), realmConfig.getAdminPassword());
         } catch (RegistryException e) {

Modified: trunk/carbon/org.wso2.carbon.registry.core/src/test/java/org/wso2/carbon/registry/core/test/jdbc/StaticConfigurationFalseTest.java
URL: http://wso2.org/svn/browse/wso2/trunk/carbon/org.wso2.carbon.registry.core/src/test/java/org/wso2/carbon/registry/core/test/jdbc/StaticConfigurationFalseTest.java?rev=43596&r1=43595&r2=43596&view=diff
==============================================================================
--- trunk/carbon/org.wso2.carbon.registry.core/src/test/java/org/wso2/carbon/registry/core/test/jdbc/StaticConfigurationFalseTest.java	(original)
+++ trunk/carbon/org.wso2.carbon.registry.core/src/test/java/org/wso2/carbon/registry/core/test/jdbc/StaticConfigurationFalseTest.java	Mon Aug 17 22:49:15 2009
@@ -16,7 +16,6 @@
 
 package org.wso2.carbon.registry.core.test.jdbc;
 
-import org.wso2.carbon.registry.core.jdbc.EmbeddedRegistryService;
 import org.wso2.carbon.registry.core.jdbc.InMemoryEmbeddedRegistryService;
 
 import org.wso2.carbon.registry.core.*;
@@ -24,7 +23,6 @@
 import org.wso2.carbon.registry.core.config.StaticConfiguration;
 import org.wso2.carbon.registry.core.exceptions.RegistryException;
 import org.wso2.carbon.user.core.config.RealmConfiguration;
-import org.wso2.carbon.user.core.UserStoreException;
 
 public class StaticConfigurationFalseTest extends BaseTestCase {
 
@@ -40,7 +38,7 @@
         try {
             embeddedRegistryService = new InMemoryEmbeddedRegistryService();
             // get the realm config to retrieve admin username, password
-            RealmConfiguration realmConfig = embeddedRegistryService.getRealmConfiguration();
+            RealmConfiguration realmConfig = embeddedRegistryService.getBootstrapRealmConfiguration();
             registry = embeddedRegistryService.getUserRegistry(
                 realmConfig.getAdminUserName(), realmConfig.getAdminPassword());
         } catch (RegistryException e) {

Modified: trunk/carbon/org.wso2.carbon.registry.core/src/test/java/org/wso2/carbon/registry/core/test/jdbc/StaticConfigurationTrueTest.java
URL: http://wso2.org/svn/browse/wso2/trunk/carbon/org.wso2.carbon.registry.core/src/test/java/org/wso2/carbon/registry/core/test/jdbc/StaticConfigurationTrueTest.java?rev=43596&r1=43595&r2=43596&view=diff
==============================================================================
--- trunk/carbon/org.wso2.carbon.registry.core/src/test/java/org/wso2/carbon/registry/core/test/jdbc/StaticConfigurationTrueTest.java	(original)
+++ trunk/carbon/org.wso2.carbon.registry.core/src/test/java/org/wso2/carbon/registry/core/test/jdbc/StaticConfigurationTrueTest.java	Mon Aug 17 22:49:15 2009
@@ -16,7 +16,6 @@
 
 package org.wso2.carbon.registry.core.test.jdbc;
 
-import org.wso2.carbon.registry.core.jdbc.EmbeddedRegistryService;
 import org.wso2.carbon.registry.core.jdbc.InMemoryEmbeddedRegistryService;
 
 import org.wso2.carbon.registry.core.*;
@@ -24,7 +23,6 @@
 import org.wso2.carbon.registry.core.config.StaticConfiguration;
 import org.wso2.carbon.registry.core.exceptions.RegistryException;
 import org.wso2.carbon.user.core.config.RealmConfiguration;
-import org.wso2.carbon.user.core.UserStoreException;
 
 public class StaticConfigurationTrueTest extends BaseTestCase {
 
@@ -45,7 +43,7 @@
         try {
             embeddedRegistryService = new InMemoryEmbeddedRegistryService();
             // get the realm config to retrieve admin username, password
-            RealmConfiguration realmConfig = embeddedRegistryService.getRealmConfiguration();
+            RealmConfiguration realmConfig = embeddedRegistryService.getBootstrapRealmConfiguration();
             registry = embeddedRegistryService.getUserRegistry(
                 realmConfig.getAdminUserName(), realmConfig.getAdminPassword());
         } catch (RegistryException e) {

Modified: trunk/carbon/org.wso2.carbon.registry.core/src/test/java/org/wso2/carbon/registry/core/test/jdbc/SystemRegistryInHandlerTest.java
URL: http://wso2.org/svn/browse/wso2/trunk/carbon/org.wso2.carbon.registry.core/src/test/java/org/wso2/carbon/registry/core/test/jdbc/SystemRegistryInHandlerTest.java?rev=43596&r1=43595&r2=43596&view=diff
==============================================================================
--- trunk/carbon/org.wso2.carbon.registry.core/src/test/java/org/wso2/carbon/registry/core/test/jdbc/SystemRegistryInHandlerTest.java	(original)
+++ trunk/carbon/org.wso2.carbon.registry.core/src/test/java/org/wso2/carbon/registry/core/test/jdbc/SystemRegistryInHandlerTest.java	Mon Aug 17 22:49:15 2009
@@ -21,12 +21,10 @@
 import org.wso2.carbon.registry.core.test.utils.BaseTestCase;
 import org.wso2.carbon.registry.core.Registry;
 import org.wso2.carbon.registry.core.Resource;
-import org.wso2.carbon.registry.core.RegistryConstants;
 import org.wso2.carbon.registry.core.config.RegistryContext;
 import org.wso2.carbon.registry.core.session.CurrentSession;
 import org.wso2.carbon.registry.core.exceptions.RegistryException;
 
-import org.wso2.carbon.registry.core.jdbc.EmbeddedRegistryService;
 import org.wso2.carbon.registry.core.jdbc.InMemoryEmbeddedRegistryService;
 import org.wso2.carbon.registry.core.jdbc.Repository;
 import org.wso2.carbon.registry.core.jdbc.handlers.Handler;
@@ -35,7 +33,6 @@
 import org.wso2.carbon.registry.core.jdbc.handlers.filters.URLMatcher;
 import org.wso2.carbon.registry.core.jdbc.handlers.filters.Filter;
 import org.wso2.carbon.user.core.config.RealmConfiguration;
-import org.wso2.carbon.user.core.UserStoreException;
 
 public class SystemRegistryInHandlerTest  extends BaseTestCase {
 
@@ -58,7 +55,7 @@
     public void testNestedRegistryOperations() throws RegistryException {
 
         // get the realm config to retrieve admin username, password
-        realmConfig = embeddedRegistryService.getRealmConfiguration();
+        realmConfig = embeddedRegistryService.getBootstrapRealmConfiguration();
         Registry adminRegistry = embeddedRegistryService.getUserRegistry(
             realmConfig.getAdminUserName(), realmConfig.getAdminPassword());
         RegistryContext registryContext = adminRegistry.getRegistryContext();

Modified: trunk/carbon/org.wso2.carbon.registry.core/src/test/java/org/wso2/carbon/registry/core/test/jdbc/TagsTest.java
URL: http://wso2.org/svn/browse/wso2/trunk/carbon/org.wso2.carbon.registry.core/src/test/java/org/wso2/carbon/registry/core/test/jdbc/TagsTest.java?rev=43596&r1=43595&r2=43596&view=diff
==============================================================================
--- trunk/carbon/org.wso2.carbon.registry.core/src/test/java/org/wso2/carbon/registry/core/test/jdbc/TagsTest.java	(original)
+++ trunk/carbon/org.wso2.carbon.registry.core/src/test/java/org/wso2/carbon/registry/core/test/jdbc/TagsTest.java	Mon Aug 17 22:49:15 2009
@@ -23,13 +23,11 @@
 import org.wso2.carbon.registry.core.Tag;
 import org.wso2.carbon.registry.core.TaggedResourcePath;
 import org.wso2.carbon.registry.core.exceptions.RegistryException;
-import org.wso2.carbon.registry.core.jdbc.EmbeddedRegistryService;
 import org.wso2.carbon.registry.core.jdbc.InMemoryEmbeddedRegistryService;
 
 import org.wso2.carbon.registry.core.session.UserRegistry;
 import org.wso2.carbon.registry.core.test.utils.BaseTestCase;
 import org.wso2.carbon.user.core.UserRealm;
-import org.wso2.carbon.user.core.UserStoreException;
 import org.wso2.carbon.user.core.UserStoreManager;
 import org.wso2.carbon.user.core.config.RealmConfiguration;
 
@@ -50,7 +48,7 @@
         try {
             embeddedRegistryService = new InMemoryEmbeddedRegistryService();
             // get the realm config to retrieve admin username, password
-            RealmConfiguration realmConfig = embeddedRegistryService.getRealmConfiguration();
+            RealmConfiguration realmConfig = embeddedRegistryService.getBootstrapRealmConfiguration();
             registry = embeddedRegistryService.getUserRegistry(
                 realmConfig.getAdminUserName(), realmConfig.getAdminPassword());
         } catch (RegistryException e) {
@@ -116,7 +114,7 @@
 
         // embeddedRegistryService = new InMemoryEmbeddedRegistryService();
         // get the realm config to retrieve admin username, password
-        RealmConfiguration realmConfig = embeddedRegistryService.getRealmConfiguration();
+        RealmConfiguration realmConfig = embeddedRegistryService.getBootstrapRealmConfiguration();
         
         UserRegistry adminRegistry = embeddedRegistryService.
                 getUserRegistry(realmConfig.getAdminUserName(), realmConfig.getAdminPassword());

Modified: trunk/carbon/org.wso2.carbon.registry.core/src/test/java/org/wso2/carbon/registry/core/test/jdbc/TransactionsTest.java
URL: http://wso2.org/svn/browse/wso2/trunk/carbon/org.wso2.carbon.registry.core/src/test/java/org/wso2/carbon/registry/core/test/jdbc/TransactionsTest.java?rev=43596&r1=43595&r2=43596&view=diff
==============================================================================
--- trunk/carbon/org.wso2.carbon.registry.core/src/test/java/org/wso2/carbon/registry/core/test/jdbc/TransactionsTest.java	(original)
+++ trunk/carbon/org.wso2.carbon.registry.core/src/test/java/org/wso2/carbon/registry/core/test/jdbc/TransactionsTest.java	Mon Aug 17 22:49:15 2009
@@ -18,12 +18,10 @@
 
 import org.wso2.carbon.registry.core.exceptions.RegistryException;
 
-import org.wso2.carbon.registry.core.jdbc.EmbeddedRegistryService;
 import org.wso2.carbon.registry.core.jdbc.InMemoryEmbeddedRegistryService;
 import org.wso2.carbon.registry.core.*;
 import org.wso2.carbon.registry.core.test.utils.BaseTestCase;
 import org.wso2.carbon.user.core.config.RealmConfiguration;
-import org.wso2.carbon.user.core.UserStoreException;
 
 public class TransactionsTest extends BaseTestCase {
 
@@ -38,7 +36,7 @@
         }
         try {
             embeddedRegistryService = new InMemoryEmbeddedRegistryService();
-            RealmConfiguration realmConfig = embeddedRegistryService.getRealmConfiguration();
+            RealmConfiguration realmConfig = embeddedRegistryService.getBootstrapRealmConfiguration();
             registry = embeddedRegistryService.getUserRegistry(
                 realmConfig.getAdminUserName(), realmConfig.getAdminPassword());
         } catch (RegistryException e) {

Modified: trunk/carbon/org.wso2.carbon.registry.core/src/test/java/org/wso2/carbon/registry/core/test/jdbc/VersionHandlingTest.java
URL: http://wso2.org/svn/browse/wso2/trunk/carbon/org.wso2.carbon.registry.core/src/test/java/org/wso2/carbon/registry/core/test/jdbc/VersionHandlingTest.java?rev=43596&r1=43595&r2=43596&view=diff
==============================================================================
--- trunk/carbon/org.wso2.carbon.registry.core/src/test/java/org/wso2/carbon/registry/core/test/jdbc/VersionHandlingTest.java	(original)
+++ trunk/carbon/org.wso2.carbon.registry.core/src/test/java/org/wso2/carbon/registry/core/test/jdbc/VersionHandlingTest.java	Mon Aug 17 22:49:15 2009
@@ -19,15 +19,12 @@
 import org.wso2.carbon.registry.core.Resource;
 import org.wso2.carbon.registry.core.exceptions.RegistryException;
 
-import org.wso2.carbon.registry.core.jdbc.EmbeddedRegistryService;
 import org.wso2.carbon.registry.core.jdbc.InMemoryEmbeddedRegistryService;
 import org.wso2.carbon.registry.core.utils.RegistryUtils;
 import org.wso2.carbon.registry.core.Collection;
 import org.wso2.carbon.registry.core.Registry;
-import org.wso2.carbon.registry.core.*;
 import org.wso2.carbon.registry.core.test.utils.BaseTestCase;
 import org.wso2.carbon.user.core.config.RealmConfiguration;
-import org.wso2.carbon.user.core.UserStoreException;
 
 public class VersionHandlingTest extends BaseTestCase {
 
@@ -43,7 +40,7 @@
         try {
             embeddedRegistryService = new InMemoryEmbeddedRegistryService();
             // get the realm config to retrieve admin username, password
-            RealmConfiguration realmConfig = embeddedRegistryService.getRealmConfiguration();
+            RealmConfiguration realmConfig = embeddedRegistryService.getBootstrapRealmConfiguration();
             registry = embeddedRegistryService.getUserRegistry(
                 realmConfig.getAdminUserName(), realmConfig.getAdminPassword());
         } catch (RegistryException e) {

Modified: trunk/carbon/org.wso2.carbon.registry.core/src/test/java/org/wso2/carbon/registry/core/test/multitenant/MultiTenantTest.java
URL: http://wso2.org/svn/browse/wso2/trunk/carbon/org.wso2.carbon.registry.core/src/test/java/org/wso2/carbon/registry/core/test/multitenant/MultiTenantTest.java?rev=43596&r1=43595&r2=43596&view=diff
==============================================================================
--- trunk/carbon/org.wso2.carbon.registry.core/src/test/java/org/wso2/carbon/registry/core/test/multitenant/MultiTenantTest.java	(original)
+++ trunk/carbon/org.wso2.carbon.registry.core/src/test/java/org/wso2/carbon/registry/core/test/multitenant/MultiTenantTest.java	Mon Aug 17 22:49:15 2009
@@ -22,6 +22,7 @@
 import org.wso2.carbon.registry.core.Registry;
 import org.wso2.carbon.registry.core.Resource;
 import org.wso2.carbon.registry.core.ActionConstants;
+import org.wso2.carbon.registry.core.utils.RegistryUtils;
 import org.wso2.carbon.registry.core.session.UserRegistry;
 import org.wso2.carbon.registry.core.exceptions.RegistryException;
 import org.wso2.carbon.registry.core.exceptions.ResourceNotFoundException;
@@ -31,6 +32,9 @@
 import org.wso2.carbon.user.core.UserStoreException;
 import org.wso2.carbon.user.core.UserStoreManager;
 import org.wso2.carbon.user.core.AuthorizationManager;
+import org.wso2.carbon.user.core.tenant.TenantManager;
+import org.wso2.carbon.user.core.tenant.Tenant;
+import org.wso2.carbon.user.core.service.RealmService;
 import org.apache.commons.lang.ArrayUtils;
 
 import java.util.Properties;
@@ -56,7 +60,7 @@
      * @throws RegistryException
      */
     public void testVirtualRoots() throws RegistryException {
-        RealmConfiguration realmConfig = embeddedRegistryService.getRealmConfiguration();
+        RealmConfiguration realmConfig = embeddedRegistryService.getBootstrapRealmConfiguration();
         UserRegistry registry1 = embeddedRegistryService.getUserRegistry(realmConfig.getAdminUserName(), 0);
         Resource r = registry1.newResource();
         registry1.put("/test", r);
@@ -99,7 +103,7 @@
      * @throws RegistryException
      */
     public void testUserStores() throws RegistryException {
-        RealmConfiguration realmConfig = embeddedRegistryService.getRealmConfiguration();
+        RealmConfiguration realmConfig = embeddedRegistryService.getBootstrapRealmConfiguration();
         // first we will fill the user store for tenant 0
         UserRegistry registry1 = embeddedRegistryService.getUserRegistry(realmConfig.getAdminUserName(), 0);
 
@@ -287,4 +291,102 @@
             throw new RegistryException("Error in checking authorizations.");
         }
     }
+
+    /**
+     * Test each registry has different has different user stores
+     * @throws RegistryException
+     */
+    public void testCustomRealmConfiguration() throws RegistryException {
+        // first we will fill the user store for tenant 0
+        UserRegistry systemRegistry1 = embeddedRegistryService.getSystemRegistry(1);
+
+        // update the realm configuration for the tenant 1 registry
+        RealmConfiguration realmConfig1 = RegistryUtils.getRealmConfiguration(systemRegistry1);
+        realmConfig1.setAdminUserName("su1");
+        realmConfig1.setAdminPassword("su1xyz");
+        RegistryUtils.persistRealmConfiguration(systemRegistry1, realmConfig1);
+
+        boolean noException;
+        try {
+            UserRegistry adminRegistry1 = embeddedRegistryService.getUserRegistry("su1", "su1xyz", 1);
+            noException = true;
+        } catch (RegistryException e) {
+            noException = false;
+            e.printStackTrace();
+        }
+        assertTrue("No exception in authorizing in tenant 1", noException);
+
+        boolean throwsException;
+        try {
+            UserRegistry adminRegistry1 = embeddedRegistryService.getUserRegistry("su1", "su1xyz", 2);
+            throwsException = false;
+        } catch (RegistryException e) {
+            throwsException = true;
+        }
+        assertTrue("Exception should be thrown in authorizing in tenant 2", throwsException);
+    }
+
+
+    /**
+     * Test adding tenants
+     * @throws RegistryException
+     */
+    public void testAddTenant() throws RegistryException, UserStoreException {
+        RealmService realmService = embeddedRegistryService.getRealmServie();
+        TenantManager tenantManager = realmService.getTenantManager();
+
+        Tenant tenant = new Tenant();
+        tenant.setCompany("wso2");
+        tenant.setDescription("WSO2 inc.");
+        tenant.setDomain("wso2.org");
+
+        int tenantId = tenantManager.addTenant(tenant);
+        Tenant tenant2 = tenantManager.getTenant(tenantId);
+
+        // checking if the everyting is stored.
+        assertEquals("tenant company should be equal.", tenant.getCompany(), tenant2.getCompany());
+        assertEquals("tenant description should be equal.", tenant.getDescription(), tenant2.getDescription());
+        assertEquals("tenant domain should be equal.", tenant.getDomain(), tenant2.getDomain());
+
+        Tenant tenant3 = new Tenant();
+        tenant3.setCompany("ABC");
+        tenant3.setDescription("ABC inc..");
+        tenant3.setDomain("abc.org");
+        tenantManager.addTenant(tenant3);
+
+        Tenant[] tenants = tenantManager.getAllTenants();
+
+        // check the get all tenants
+        assertEquals("tenants length should be 2", tenants.length,  2);
+        assertTrue("tenants should contain wso2.org", (tenants[0].getDomain() + tenants[1].getDomain()).contains("wso2.org"));
+        assertTrue("tenants should contain abc.org" , (tenants[0].getDomain() + tenants[1].getDomain()).contains("abc.org"));
+
+        // if the domain exists
+        assertTrue("wso2.org should exist", tenantManager.getTenantId("wso2.org") > 0);
+        assertTrue("pqr.org should not exists", tenantManager.getTenantId("pqr.org") < 0);
+
+        int tenantId4 = tenantManager.getTenantId("wso2.org");
+        assertEquals("tenant domain should be wso2.org", "wso2.org", tenantManager.getDomain(tenantId4));
+
+        // check the update
+        Tenant tenant4 = tenantManager.getTenant(tenantId4);
+        tenant4.setCompany("WSO2/lk Inc.");
+        tenant4.setDescription("WSO2 Lanka private limited");
+        tenant4.setDomain("WSO2.com");
+        tenantManager.updateTenant(tenant4);
+
+        // checking the updated values
+        Tenant tenant5 = tenantManager.getTenant(tenantId4);          
+        assertEquals("tenant company should be equal.", tenant5.getCompany(), "WSO2/lk Inc.");
+        assertEquals("tenant description should be equal.", tenant5.getDescription(), "WSO2 Lanka private limited");
+        assertEquals("tenant domain should be equal.", tenant5.getDomain(), "WSO2.com");
+
+        Tenant[] tenants2 = tenantManager.getAllTenants();
+        // check the updted values get all tenants
+        assertEquals("tenants length should be 2", tenants.length,  2);
+        assertTrue("tenants should contain WSO2.com", (tenants2[0].getDomain() + tenants2[1].getDomain()).contains("WSO2.com"));
+        assertTrue("tenants should contain abc.org" , (tenants2[0].getDomain() + tenants2[1].getDomain()).contains("abc.org"));
+
+        
+    }
 }

Modified: trunk/carbon/org.wso2.carbon.registry.core/src/test/java/org/wso2/carbon/registry/core/test/secure/CommentsTest.java
URL: http://wso2.org/svn/browse/wso2/trunk/carbon/org.wso2.carbon.registry.core/src/test/java/org/wso2/carbon/registry/core/test/secure/CommentsTest.java?rev=43596&r1=43595&r2=43596&view=diff
==============================================================================
--- trunk/carbon/org.wso2.carbon.registry.core/src/test/java/org/wso2/carbon/registry/core/test/secure/CommentsTest.java	(original)
+++ trunk/carbon/org.wso2.carbon.registry.core/src/test/java/org/wso2/carbon/registry/core/test/secure/CommentsTest.java	Mon Aug 17 22:49:15 2009
@@ -19,14 +19,11 @@
 import org.wso2.carbon.registry.core.exceptions.RegistryException;
 import org.wso2.carbon.registry.core.session.UserRegistry;
 import org.wso2.carbon.registry.core.jdbc.InMemoryEmbeddedRegistryService;
-import org.wso2.carbon.registry.core.jdbc.EmbeddedRegistryService;
 import org.wso2.carbon.registry.core.ActionConstants;
 import org.wso2.carbon.registry.core.Comment;
-import org.wso2.carbon.registry.core.RegistryConstants;
 import org.wso2.carbon.registry.core.ResourceImpl;
 import org.wso2.carbon.registry.core.test.utils.BaseTestCase;
 import org.wso2.carbon.user.core.UserRealm;
-import org.wso2.carbon.user.core.UserStoreException;
 import org.wso2.carbon.user.core.config.RealmConfiguration;
 
 public class CommentsTest extends BaseTestCase {
@@ -48,7 +45,7 @@
 
         //embeddedRegistryService = new InMemoryEmbeddedRegistryService();
         // get the realm config to retrieve admin username, password
-            RealmConfiguration realmConfig = embeddedRegistryService.getRealmConfiguration();
+            RealmConfiguration realmConfig = embeddedRegistryService.getBootstrapRealmConfiguration();
         UserRegistry adminReg = embeddedRegistryService.getUserRegistry(
                 realmConfig.getAdminUserName(), realmConfig.getAdminPassword());
 

Modified: trunk/carbon/org.wso2.carbon.registry.core/src/test/java/org/wso2/carbon/registry/core/test/secure/SecureRegistryTest.java
URL: http://wso2.org/svn/browse/wso2/trunk/carbon/org.wso2.carbon.registry.core/src/test/java/org/wso2/carbon/registry/core/test/secure/SecureRegistryTest.java?rev=43596&r1=43595&r2=43596&view=diff
==============================================================================
--- trunk/carbon/org.wso2.carbon.registry.core/src/test/java/org/wso2/carbon/registry/core/test/secure/SecureRegistryTest.java	(original)
+++ trunk/carbon/org.wso2.carbon.registry.core/src/test/java/org/wso2/carbon/registry/core/test/secure/SecureRegistryTest.java	Mon Aug 17 22:49:15 2009
@@ -17,12 +17,10 @@
 package org.wso2.carbon.registry.core.test.secure;
 
 import org.wso2.carbon.registry.core.exceptions.RegistryException;
-import org.wso2.carbon.registry.core.jdbc.EmbeddedRegistryService;
 import org.wso2.carbon.registry.core.session.UserRegistry;
 import org.wso2.carbon.registry.core.jdbc.InMemoryEmbeddedRegistryService;
 import org.wso2.carbon.registry.core.secure.AuthorizationFailedException;
 import org.wso2.carbon.registry.core.ActionConstants;
-import org.wso2.carbon.registry.core.RegistryConstants;
 import org.wso2.carbon.registry.core.Resource;
 import org.wso2.carbon.registry.core.test.utils.BaseTestCase;
 import org.wso2.carbon.user.core.UserRealm;
@@ -49,7 +47,7 @@
     public void testUserBasedAuthorization() throws RegistryException {
 
         // get the realm config to retrieve admin username, password
-        RealmConfiguration realmConfig = embeddedRegistryService.getRealmConfiguration();
+        RealmConfiguration realmConfig = embeddedRegistryService.getBootstrapRealmConfiguration();
         UserRegistry adminRegistry = embeddedRegistryService.getUserRegistry(
                 realmConfig.getAdminUserName(), realmConfig.getAdminPassword());
         
@@ -99,7 +97,7 @@
 
         //embeddedRegistryService = new InMemoryEmbeddedRegistryService();
         // get the realm config to retrieve admin username, password
-        RealmConfiguration realmConfig = embeddedRegistryService.getRealmConfiguration();
+        RealmConfiguration realmConfig = embeddedRegistryService.getBootstrapRealmConfiguration();
         UserRegistry adminRegistry = embeddedRegistryService.getUserRegistry(
                 realmConfig.getAdminUserName(), realmConfig.getAdminPassword());
         UserRealm adminRealm = adminRegistry.getUserRealm();

Modified: trunk/carbon/org.wso2.carbon.user.core/src/main/java/org/wso2/carbon/user/core/common/DefaultRealmService.java
URL: http://wso2.org/svn/browse/wso2/trunk/carbon/org.wso2.carbon.user.core/src/main/java/org/wso2/carbon/user/core/common/DefaultRealmService.java?rev=43596&r1=43595&r2=43596&view=diff
==============================================================================
--- trunk/carbon/org.wso2.carbon.user.core/src/main/java/org/wso2/carbon/user/core/common/DefaultRealmService.java	(original)
+++ trunk/carbon/org.wso2.carbon.user.core/src/main/java/org/wso2/carbon/user/core/common/DefaultRealmService.java	Mon Aug 17 22:49:15 2009
@@ -21,14 +21,17 @@
 import org.wso2.carbon.user.core.UserRealm;
 import org.wso2.carbon.user.core.UserCoreConstants;
 import org.wso2.carbon.user.core.AuthorizationManager;
+import org.wso2.carbon.user.core.UserStoreException;
 import org.wso2.carbon.user.core.jdbc.JDBCRealmConstants;
 import org.wso2.carbon.user.core.tenant.TenantManager;
 import org.wso2.carbon.user.core.service.RealmService;
 import org.wso2.carbon.user.core.model.SystemPermissions;
 import org.wso2.carbon.user.core.profile.builder.ProfileConfigurationBuilder;
+import org.wso2.carbon.user.core.profile.builder.ProfileBuilderException;
 import org.wso2.carbon.user.core.profile.ProfileConfiguration;
 import org.wso2.carbon.user.core.profile.dao.ProfileConfigDAO;
 import org.wso2.carbon.user.core.claim.builder.ClaimBuilder;
+import org.wso2.carbon.user.core.claim.builder.ClaimBuilderException;
 import org.wso2.carbon.user.core.claim.ClaimMapping;
 import org.wso2.carbon.user.core.claim.dao.ClaimDAO;
 import org.wso2.carbon.user.core.config.RealmConfiguration;
@@ -39,6 +42,8 @@
 import org.apache.axiom.om.OMElement;
 import org.apache.axiom.om.impl.builder.StAXOMBuilder;
 import org.apache.commons.dbcp.BasicDataSource;
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
 
 import javax.sql.DataSource;
 import javax.xml.namespace.QName;
@@ -57,6 +62,7 @@
     OMElement parentElement;
     TenantManager tenantManager;
     UserRealm bootstrapRealm;
+    private static final Log log = LogFactory.getLog(DefaultRealmService.class);
 
     public DefaultRealmService(BundleContext bc) throws Exception {
 
@@ -79,10 +85,12 @@
         bc.registerService(UserRealm.class.getName(), bootstrapRealm, dictionary);
     }
 
-    public UserRealm getUserRealm(RealmConfiguration tenantRealmConfig) throws Exception {
+    public UserRealm getUserRealm(RealmConfiguration tenantRealmConfig) throws UserStoreException {
         int tenantId = tenantRealmConfig.getTenantId();
         UserRealm userRealm = userRealmMap.get(new Integer(tenantId));
-        if (userRealm == null) {
+        if (userRealm == null ||
+                !userRealm.getRealmConfiguration().getPersistedTimestamp().equals(
+                tenantRealmConfig.getPersistedTimestamp())) {
             userRealm = initializeRealm(bc, tenantRealmConfig, dataSource, tenantId);
             addUIPermissiontoAdminRoleAndUser(userRealm, parentElement, tenantRealmConfig);
             userRealmMap.put(new Integer(tenantId), userRealm);
@@ -91,7 +99,7 @@
     }
 
     public UserRealm initializeRealm(BundleContext bc, RealmConfiguration realmConfig,
-            DataSource dataSource, int tenantId) throws Exception {
+            DataSource dataSource, int tenantId) throws UserStoreException {
 
         ClaimBuilder.setBundleContext(bc);
         ProfileConfigurationBuilder.setBundleContext(bc);
@@ -106,17 +114,41 @@
         ProfileConfigurationBuilder profileBilder = new ProfileConfigurationBuilder(tenantId);
 
         if (count == 0) {
-            claimMappings = claimBuilder.buildClaimMappingsFromConfigFile();
+            try {
+                claimMappings = claimBuilder.buildClaimMappingsFromConfigFile();
+            } catch (ClaimBuilderException e) {
+                String msg = "Error in building claims.";
+                log.error(msg);
+                throw new UserStoreException(msg, e);
+            }
             claimDAO.addCliamMappings(claimMappings.values().toArray(
                     new ClaimMapping[claimMappings.size()]));
-            profileConfigs = profileBilder.buildProfileConfigurationFromConfigFile();
+            try {
+                profileConfigs = profileBilder.buildProfileConfigurationFromConfigFile();
+            } catch (ProfileBuilderException e) {
+                String msg = "Error in building the profile.";
+                log.error(msg);
+                throw new UserStoreException(msg, e);
+            }
             profileDAO.addProfileConfig(profileConfigs.values().toArray(
                     new ProfileConfiguration[profileConfigs.size()]));
         } else {
-            claimMappings = claimBuilder.buildClaimMappingsFromDatabase(dataSource,
-                    UserCoreConstants.INTERNAL_USERSTORE);
-            profileConfigs = profileBilder.buildProfileConfigurationFromDatabase(dataSource,
-                    UserCoreConstants.INTERNAL_USERSTORE);
+            try {
+                claimMappings = claimBuilder.buildClaimMappingsFromDatabase(dataSource,
+                        UserCoreConstants.INTERNAL_USERSTORE);
+            } catch (ClaimBuilderException e) {
+                String msg = "Error in building claims.";
+                log.error(msg);
+                throw new UserStoreException(msg, e);
+            }
+            try {
+                profileConfigs = profileBilder.buildProfileConfigurationFromDatabase(dataSource,
+                        UserCoreConstants.INTERNAL_USERSTORE);
+            } catch (ProfileBuilderException e) {
+                String msg = "Error in building the profile.";
+                log.error(msg);
+                throw new UserStoreException(msg, e);
+            }
         }
 
         userRealm.init(realmConfig, claimMappings, profileConfigs, tenantId);
@@ -125,7 +157,7 @@
     }
 
     public void addUIPermissiontoAdminRoleAndUser(UserRealm realm, OMElement parentElement,
-            RealmConfiguration realmConfig) throws Exception {
+            RealmConfiguration realmConfig) throws UserStoreException {
 
         String adminRole = realmConfig.getAdminRoleName();
         String userName = realmConfig.getAdminUserName();
@@ -136,7 +168,7 @@
         OMElement sysPermissions = parentElement
                 .getFirstChildWithName(new QName("SystemPermission"));
         if (sysPermissions == null) {
-            throw new Exception("System cannot startup without system permissions.");
+            throw new UserStoreException("System cannot startup without system permissions.");
         }
 
         AuthorizationManager auAdmin = realm.getAuthorizationManager();
@@ -222,7 +254,7 @@
         return bootstrapRealmConfig;
     }
 
-    public UserRealm getBootstrapRealm() throws Exception {
+    public UserRealm getBootstrapRealm() throws UserStoreException {
         return bootstrapRealm;
     }
 

Modified: trunk/carbon/org.wso2.carbon.user.core/src/main/java/org/wso2/carbon/user/core/config/RealmConfiguration.java
URL: http://wso2.org/svn/browse/wso2/trunk/carbon/org.wso2.carbon.user.core/src/main/java/org/wso2/carbon/user/core/config/RealmConfiguration.java?rev=43596&r1=43595&r2=43596&view=diff
==============================================================================
--- trunk/carbon/org.wso2.carbon.user.core/src/main/java/org/wso2/carbon/user/core/config/RealmConfiguration.java	(original)
+++ trunk/carbon/org.wso2.carbon.user.core/src/main/java/org/wso2/carbon/user/core/config/RealmConfiguration.java	Mon Aug 17 22:49:15 2009
@@ -2,6 +2,7 @@
 
 import java.util.HashMap;
 import java.util.Map;
+import java.util.Date;
 
 /**
  * The object representing the realm configuration.
@@ -22,6 +23,7 @@
     private Map<String, String> realmProperties = new HashMap<String, String>();
     boolean isReadOnly = true;
     private int tenantId;
+    private Date persistedTimestamp;
 
     public RealmConfiguration() {
         tenantId = 0;
@@ -170,4 +172,13 @@
     public void setTenantId(int tenantId) {
         this.tenantId = tenantId;
     }
+
+    public Date getPersistedTimestamp() {
+        return persistedTimestamp;
+    }
+
+    public void setPersistedTimestamp(Date persistedTimestamp) {
+        this.persistedTimestamp = persistedTimestamp;
+    }
+
 }

Modified: trunk/carbon/org.wso2.carbon.user.core/src/main/java/org/wso2/carbon/user/core/service/RealmService.java
URL: http://wso2.org/svn/browse/wso2/trunk/carbon/org.wso2.carbon.user.core/src/main/java/org/wso2/carbon/user/core/service/RealmService.java?rev=43596&r1=43595&r2=43596&view=diff
==============================================================================
--- trunk/carbon/org.wso2.carbon.user.core/src/main/java/org/wso2/carbon/user/core/service/RealmService.java	(original)
+++ trunk/carbon/org.wso2.carbon.user.core/src/main/java/org/wso2/carbon/user/core/service/RealmService.java	Mon Aug 17 22:49:15 2009
@@ -19,15 +19,35 @@
 package org.wso2.carbon.user.core.service;
 
 import org.wso2.carbon.user.core.UserRealm;
+import org.wso2.carbon.user.core.UserStoreException;
 import org.wso2.carbon.user.core.tenant.TenantManager;
 import org.wso2.carbon.user.core.config.RealmConfiguration;
 
 public interface RealmService {
-    public UserRealm getUserRealm(RealmConfiguration tenantRealmConfig) throws Exception;
+    /**
+     * Get a user realm from a given configuration
+     * @param tenantRealmConfig
+     * @return UserRealm
+     * @throws UserStoreException
+     */
+    public UserRealm getUserRealm(RealmConfiguration tenantRealmConfig) throws UserStoreException;
 
+    /**
+     * Get the boot strap realm configuration, this is always build from conf/user-mgt.xml
+     * @return tge realm configuration
+     */
     public RealmConfiguration getBootstrapRealmConfiguration();
 
-    public UserRealm getBootstrapRealm() throws Exception;
+    /**
+     * Get the bootstrap realm 
+     * @return
+     * @throws UserStoreException
+     */
+    public UserRealm getBootstrapRealm() throws UserStoreException;
 
+    /**
+     * Get tenant manager
+     * @return TenantManager
+     */
     public TenantManager getTenantManager();
 }

Modified: trunk/carbon/org.wso2.carbon.user.core/src/main/java/org/wso2/carbon/user/core/tenant/Tenant.java
URL: http://wso2.org/svn/browse/wso2/trunk/carbon/org.wso2.carbon.user.core/src/main/java/org/wso2/carbon/user/core/tenant/Tenant.java?rev=43596&r1=43595&r2=43596&view=diff
==============================================================================
--- trunk/carbon/org.wso2.carbon.user.core/src/main/java/org/wso2/carbon/user/core/tenant/Tenant.java	(original)
+++ trunk/carbon/org.wso2.carbon.user.core/src/main/java/org/wso2/carbon/user/core/tenant/Tenant.java	Mon Aug 17 22:49:15 2009
@@ -19,10 +19,19 @@
 package org.wso2.carbon.user.core.tenant;
 
 public class Tenant {
+    private int id;
     private String domain;
     private String company;
     private String description;
 
+    public int getId() {
+        return id;
+    }
+
+    public void setId(int id) {
+        this.id = id;
+    }
+
     public String getDomain() {
         return domain;
     }

Modified: trunk/carbon/org.wso2.carbon.user.core/src/main/java/org/wso2/carbon/user/core/tenant/TenantConstants.java
URL: http://wso2.org/svn/browse/wso2/trunk/carbon/org.wso2.carbon.user.core/src/main/java/org/wso2/carbon/user/core/tenant/TenantConstants.java?rev=43596&r1=43595&r2=43596&view=diff
==============================================================================
--- trunk/carbon/org.wso2.carbon.user.core/src/main/java/org/wso2/carbon/user/core/tenant/TenantConstants.java	(original)
+++ trunk/carbon/org.wso2.carbon.user.core/src/main/java/org/wso2/carbon/user/core/tenant/TenantConstants.java	Mon Aug 17 22:49:15 2009
@@ -21,8 +21,11 @@
 public class TenantConstants {
     public static String ADD_TENANT_SQL = "INSERT INTO UM_TENANT(UM_DOMAIN_NAME, UM_COMPANY, UM_DESCRIPTION) " +
                 "VALUES(?,?,?)";
+    public static String UPDATE_TENANT_SQL = "UPDATE UM_TENANT SET UM_DOMAIN_NAME=?, UM_COMPANY=?, UM_DESCRIPTION=? " +
+                "WHERE UM_ID=?";
     public static String GET_TENANT_SQL = "SELECT UM_ID, UM_DOMAIN_NAME, UM_COMPANY, UM_DESCRIPTION " +
                 "FROM UM_TENANT WHERE UM_ID=?";
+    public static String GET_ALL_TENANTS_SQL = "SELECT UM_ID, UM_DOMAIN_NAME, UM_COMPANY, UM_DESCRIPTION FROM UM_TENANT";
     public static String GET_DOMAIN_SQL = "SELECT UM_DOMAIN_NAME FROM UM_TENANT WHERE UM_ID=?";
     public static String GET_TENANT_ID_SQL = "SELECT UM_ID FROM UM_TENANT WHERE UM_DOMAIN_NAME=?";
 }

Modified: trunk/carbon/org.wso2.carbon.user.core/src/main/java/org/wso2/carbon/user/core/tenant/TenantManager.java
URL: http://wso2.org/svn/browse/wso2/trunk/carbon/org.wso2.carbon.user.core/src/main/java/org/wso2/carbon/user/core/tenant/TenantManager.java?rev=43596&r1=43595&r2=43596&view=diff
==============================================================================
--- trunk/carbon/org.wso2.carbon.user.core/src/main/java/org/wso2/carbon/user/core/tenant/TenantManager.java	(original)
+++ trunk/carbon/org.wso2.carbon.user.core/src/main/java/org/wso2/carbon/user/core/tenant/TenantManager.java	Mon Aug 17 22:49:15 2009
@@ -28,6 +28,8 @@
 import java.sql.SQLException;
 import java.sql.PreparedStatement;
 import java.sql.ResultSet;
+import java.util.List;
+import java.util.ArrayList;
 
 public class TenantManager {
     DataSource dataSource;
@@ -38,7 +40,7 @@
     }
 
     public int addTenant(Tenant tenant) throws UserStoreException {
-        Connection dbConnection;
+        Connection dbConnection = null;
         PreparedStatement prepStmt = null;
         ResultSet result = null;
         int id = 0;
@@ -53,7 +55,7 @@
             prepStmt.executeUpdate();
 
             result = prepStmt.getGeneratedKeys();
-            if(result.next()) {
+            if (result.next()) {
                 id = result.getInt(1);
             }
             dbConnection.commit();
@@ -67,6 +69,7 @@
             try {
                 if (result != null) {result.close();}
                 if (prepStmt != null) {prepStmt.close();}
+                if (dbConnection != null) {dbConnection.close();}
             }
             catch (SQLException ex)  {
                 String msg = "Error in closing the connection for result and prepared statement. " + ex.getMessage();
@@ -77,12 +80,47 @@
         return id;
     }
 
+
+    public void updateTenant(Tenant tenant) throws UserStoreException {
+        Connection dbConnection = null;
+        PreparedStatement prepStmt = null;
+        try {
+            dbConnection = getDBConnection();
+            String sqlStmt = TenantConstants.UPDATE_TENANT_SQL;
+            prepStmt = dbConnection.prepareStatement(sqlStmt);
+            prepStmt.setString(1, tenant.getDomain());
+            prepStmt.setString(2, tenant.getCompany());
+            prepStmt.setString(3, tenant.getDescription());
+            prepStmt.setInt(4, tenant.getId());
+
+            prepStmt.executeUpdate();
+
+            dbConnection.commit();
+        } catch (SQLException e) {
+            String msg = "Error in adding tenant with " +
+                    "tenant domain: " + tenant.getDomain() + ".";
+            log.error(msg);
+            throw new UserStoreException(e);
+        }
+        finally {
+            try {
+                if (prepStmt != null) {prepStmt.close();}
+                if (dbConnection != null) {dbConnection.close();}
+            }
+            catch (SQLException ex)  {
+                String msg = "Error in closing the connection for result and prepared statement. " + ex.getMessage();
+                log.error(msg,ex);
+                throw new UserStoreException(msg,ex);
+            }
+        }
+    }
+
     public Tenant getTenant(int tenantId) throws UserStoreException {
-        Connection dbConnection;
+        Connection dbConnection = null;
         PreparedStatement prepStmt = null;
         ResultSet result = null;
         Tenant tenant = null;
-        int id = 0;
+        int id;
         try {
             dbConnection = getDBConnection();
             String sqlStmt = TenantConstants.GET_TENANT_SQL;
@@ -91,13 +129,14 @@
 
             result = prepStmt.executeQuery();
 
-            if(result.next()) {
+            if (result.next()) {
                 id = result.getInt("UM_ID");
                 String domain = result.getString("UM_DOMAIN_NAME");
                 String company = result.getString("UM_COMPANY");
                 String description = result.getString("UM_DESCRIPTION");
 
                 tenant = new Tenant();
+                tenant.setId(id);
                 tenant.setDomain(domain);
                 tenant.setCompany(company);
                 tenant.setDescription(description);
@@ -113,6 +152,7 @@
             try {
                 if (result != null) {result.close();}
                 if (prepStmt != null) {prepStmt.close();}
+                if (dbConnection != null) {dbConnection.close();}
             }
             catch (SQLException ex)  {
                 String msg = "Error in closing the connection for result and prepared statement. " + ex.getMessage();
@@ -123,12 +163,57 @@
         return tenant;
     }
 
+    public Tenant[] getAllTenants() throws UserStoreException {
+        Connection dbConnection = null;
+        PreparedStatement prepStmt = null;
+        ResultSet result = null;
+        List<Tenant> tenantList = new ArrayList<Tenant>();
+        try {
+            dbConnection = getDBConnection();
+            String sqlStmt = TenantConstants.GET_ALL_TENANTS_SQL;
+            prepStmt = dbConnection.prepareStatement(sqlStmt);
+
+            result = prepStmt.executeQuery();
+
+            while (result.next()) {
+                int id = result.getInt("UM_ID");
+                String domain = result.getString("UM_DOMAIN_NAME");
+                String company = result.getString("UM_COMPANY");
+                String description = result.getString("UM_DESCRIPTION");
+
+                Tenant tenant = new Tenant();
+                tenant.setId(id);
+                tenant.setDomain(domain);
+                tenant.setCompany(company);
+                tenant.setDescription(description);
+                tenantList.add(tenant);
+            }
+            dbConnection.commit();
+        } catch (SQLException e) {
+            String msg = "Error in getting the tenants.";
+            log.error(msg);
+            throw new UserStoreException(e);
+        }
+        finally {
+            try {
+                if (result != null) {result.close();}
+                if (prepStmt != null) {prepStmt.close();}
+                if (dbConnection != null) {dbConnection.close();}
+            }
+            catch (SQLException ex)  {
+                String msg = "Error in closing the connection for result and prepared statement. " + ex.getMessage();
+                log.error(msg,ex);
+                throw new UserStoreException(msg,ex);
+            }
+        }
+        return tenantList.toArray(new Tenant[tenantList.size()]);
+    }
+
     public String getDomain(int tenantId) throws UserStoreException {
-        Connection dbConnection;
+        Connection dbConnection = null;
         PreparedStatement prepStmt = null;
         ResultSet result = null;
         String domain = null;
-        int id = 0;
         try {
             dbConnection = getDBConnection();
             String sqlStmt = TenantConstants.GET_DOMAIN_SQL;
@@ -137,7 +222,7 @@
 
             result = prepStmt.executeQuery();
 
-            if(result.next()) {
+            if (result.next()) {
                 domain = result.getString("UM_DOMAIN_NAME");
             }
             dbConnection.commit();
@@ -151,6 +236,7 @@
             try {
                 if (result != null) {result.close();}
                 if (prepStmt != null) {prepStmt.close();}
+                if (dbConnection != null) {dbConnection.close();}
             }
             catch (SQLException ex)  {
                 String msg = "Error in closing the connection for result and prepared statement. " + ex.getMessage();
@@ -162,10 +248,10 @@
     }
 
     public int getTenantId(String domain) throws UserStoreException {
-        Connection dbConnection;
+        Connection dbConnection = null;
         PreparedStatement prepStmt = null;
         ResultSet result = null;
-        int id = 0;
+        int id = -1;
         try {
             dbConnection = getDBConnection();
             String sqlStmt = TenantConstants.GET_TENANT_ID_SQL;
@@ -174,7 +260,7 @@
 
             result = prepStmt.executeQuery();
 
-            if(result.next()) {
+            if (result.next()) {
                 id = result.getInt("UM_ID");
             }
             dbConnection.commit();
@@ -188,6 +274,7 @@
             try {
                 if (result != null) {result.close();}
                 if (prepStmt != null) {prepStmt.close();}
+                if (dbConnection != null) {dbConnection.close();}
             }
             catch (SQLException ex)  {
                 String msg = "Error in closing the connection for result and prepared statement. " + ex.getMessage();



More information about the Carbon-dev mailing list