[Carbon-dev] svn commit r41438 - in trunk/carbon/org.wso2.carbon.registry.core/src: main/java/org/wso2/carbon/registry/app main/java/org/wso2/carbon/registry/core main/java/org/wso2/carbon/registry/core/jdbc main/java/org/wso2/carbon/registry/core/jdbc/utils main/java/org/wso2/carbon/registry/core/service main/java/org/wso2/carbon/registry/core/session test/java/org/wso2/carbon/registry/core/test/jdbc
dimuthu at wso2.com
dimuthu at wso2.com
Sat Jul 18 09:17:20 PDT 2009
Author: dimuthu
Date: Sat Jul 18 09:17:20 2009
New Revision: 41438
URL: http://wso2.org/svn/browse/wso2?view=rev&revision=41438
Log:
Removing ChrootRegistry and putting the functionlity inside the UserRegistry itself (chroot base can be given as a constructor argument).
Updating RegistryService to get a registry with a given chroot
Removing the unused SessionRealm
Added:
trunk/carbon/org.wso2.carbon.registry.core/src/main/java/org/wso2/carbon/registry/core/session/ChrootWrapper.java
Removed:
trunk/carbon/org.wso2.carbon.registry.core/src/main/java/org/wso2/carbon/registry/core/ChrootRegistry.java
trunk/carbon/org.wso2.carbon.registry.core/src/main/java/org/wso2/carbon/registry/core/session/SessionRealm.java
Modified:
trunk/carbon/org.wso2.carbon.registry.core/src/main/java/org/wso2/carbon/registry/app/RemoteRegistryService.java
trunk/carbon/org.wso2.carbon.registry.core/src/main/java/org/wso2/carbon/registry/core/jdbc/EmbeddedRegistry.java
trunk/carbon/org.wso2.carbon.registry.core/src/main/java/org/wso2/carbon/registry/core/jdbc/EmbeddedRegistryService.java
trunk/carbon/org.wso2.carbon.registry.core/src/main/java/org/wso2/carbon/registry/core/jdbc/utils/Transaction.java
trunk/carbon/org.wso2.carbon.registry.core/src/main/java/org/wso2/carbon/registry/core/service/RegistryService.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/test/java/org/wso2/carbon/registry/core/test/jdbc/ChrootJDBCTest.java
Modified: trunk/carbon/org.wso2.carbon.registry.core/src/main/java/org/wso2/carbon/registry/app/RemoteRegistryService.java
URL: http://wso2.org/svn/browse/wso2/trunk/carbon/org.wso2.carbon.registry.core/src/main/java/org/wso2/carbon/registry/app/RemoteRegistryService.java?rev=41438&r1=41437&r2=41438&view=diff
==============================================================================
--- trunk/carbon/org.wso2.carbon.registry.core/src/main/java/org/wso2/carbon/registry/app/RemoteRegistryService.java (original)
+++ trunk/carbon/org.wso2.carbon.registry.core/src/main/java/org/wso2/carbon/registry/app/RemoteRegistryService.java Sat Jul 18 09:17:20 2009
@@ -28,32 +28,31 @@
private static final Log log = LogFactory.getLog(RemoteRegistryService.class);
private Registry registry;
private UserRealm userRealm;
+ private String chroot;
private String url;
public RemoteRegistryService (String url, String username,
String password, UserRealm userRealm, String chroot) throws RegistryException {
try {
- RemoteRegistry remote = new RemoteRegistry(url, username, password);
+ registry = new RemoteRegistry(url, username, password);
//Hack to authenticate the user with the remote registry as remote regitry
//doesn't provide a way to log in
- remote.get("/");
+ registry.get("/");
//If chroot option is provided, create a ChrootRegistry
- if (chroot != null) {
- registry = new ChrootRegistry(remote,chroot);
- } else {
- registry = remote;
- }
this.url = url;
this.userRealm = userRealm;
+ this.chroot = chroot;
+
+ Registry systemRegistry = getSystemRegistry();
RegistryUtils.addRootCollectionAuthorization(userRealm);
- RegistryUtils.addSystemCollection(registry);
- RegistryUtils.addMountCollection(registry);
- RegistryUtils.addUserProfileCollection(registry, RegistryConstants.PROFILES_PATH);
- RegistryUtils.addServiceStoreCollection(registry, RegistryConstants.GOVERNANCE_SERVICE_PATH);
+ RegistryUtils.addSystemCollection(systemRegistry);
+ RegistryUtils.addMountCollection(systemRegistry);
+ RegistryUtils.addUserProfileCollection(systemRegistry, RegistryConstants.PROFILES_PATH);
+ RegistryUtils.addServiceStoreCollection(systemRegistry, RegistryConstants.GOVERNANCE_SERVICE_PATH);
} catch (MalformedURLException e) {
log.fatal("Registry URL is malformed, Registry configuration must be invalid",e);
@@ -65,7 +64,7 @@
}
public UserRegistry getUserRegistry() throws RegistryException {
- return new UserRegistry(RegistryConstants.ANONYMOUS_USER, 0, registry, userRealm);
+ return new UserRegistry(RegistryConstants.ANONYMOUS_USER, 0, registry, userRealm, chroot);
}
public UserRegistry getSystemRegistry() throws RegistryException {
@@ -78,9 +77,14 @@
}
public UserRegistry getSystemRegistry(int tenantId) throws RegistryException {
+ return getSystemRegistry(tenantId, chroot);
+ }
+
+
+ public UserRegistry getSystemRegistry(int tenantId, String chroot) throws RegistryException {
RegistryConfiguration regConfig = RegistryCoreServiceComponent.getRegistryConfig();
String username = regConfig.getValue(RegistryConfiguration.SYSTEM_USER_NAME);
- return new UserRegistry(username, tenantId, registry, userRealm);
+ return new UserRegistry(username, tenantId, registry, userRealm, concatChroot(this.chroot, chroot));
}
public UserRegistry getUserRegistry(String username, String password) throws RegistryException {
@@ -89,10 +93,15 @@
public UserRegistry getUserRegistry(String username, String password, int tenantId)
throws RegistryException {
+ return getUserRegistry(username, password, tenantId, null);
+ }
+
+ public UserRegistry getUserRegistry(String username, String password, int tenantId, String chroot)
+ throws RegistryException {
try {
RemoteRegistry userRemote = new RemoteRegistry(url, username, password);
- return new UserRegistry(username, tenantId, userRemote, userRealm);
+ return new UserRegistry(username, tenantId, userRemote, userRealm, concatChroot(this.chroot, chroot));
} catch (MalformedURLException e) {
log.fatal("Registry URL is malformed, Registry configuration must be invalid",e);
@@ -113,6 +122,17 @@
}
public UserRegistry getUserRegistry(String userName, int tenantId) throws RegistryException {
- return new UserRegistry(userName, tenantId, registry, userRealm);
+ return getUserRegistry(userName, tenantId, null);
+ }
+
+ public UserRegistry getUserRegistry(String userName, int tenantId, String chroot) throws RegistryException {
+ return new UserRegistry(userName, tenantId, registry, userRealm, concatChroot(this.chroot, chroot));
+ }
+
+ private String concatChroot(String chroot1, String chroot2) {
+ if (!chroot1.endsWith("/")) {
+ chroot1 = chroot1 + "/";
+ }
+ return chroot1 + chroot2;
}
}
Deleted: trunk/carbon/org.wso2.carbon.registry.core/src/main/java/org/wso2/carbon/registry/core/ChrootRegistry.java
URL: http://wso2.org/svn/browse/wso2/None?pathrev=41437
Modified: trunk/carbon/org.wso2.carbon.registry.core/src/main/java/org/wso2/carbon/registry/core/jdbc/EmbeddedRegistry.java
URL: http://wso2.org/svn/browse/wso2/trunk/carbon/org.wso2.carbon.registry.core/src/main/java/org/wso2/carbon/registry/core/jdbc/EmbeddedRegistry.java?rev=41438&r1=41437&r2=41438&view=diff
==============================================================================
--- trunk/carbon/org.wso2.carbon.registry.core/src/main/java/org/wso2/carbon/registry/core/jdbc/EmbeddedRegistry.java (original)
+++ trunk/carbon/org.wso2.carbon.registry.core/src/main/java/org/wso2/carbon/registry/core/jdbc/EmbeddedRegistry.java Sat Jul 18 09:17:20 2009
@@ -526,10 +526,11 @@
}
if (Transaction.isRollbacked()) {
- log.debug("The transaction is already rollbacked, you can not commit a transaction already rollbacked, " +
- "nested depath: " + Transaction.getNestedDepth() + ".");
+ String msg = "The transaction is already rollbacked, you can not commit a transaction already rollbacked, " +
+ "nested depath: " + Transaction.getNestedDepth() + ".";
+ log.debug(msg);
Transaction.decNestedDepth();
- return;
+ throw new RegistryException(msg);
}
Connection conn = Transaction.getConnection();
Modified: trunk/carbon/org.wso2.carbon.registry.core/src/main/java/org/wso2/carbon/registry/core/jdbc/EmbeddedRegistryService.java
URL: http://wso2.org/svn/browse/wso2/trunk/carbon/org.wso2.carbon.registry.core/src/main/java/org/wso2/carbon/registry/core/jdbc/EmbeddedRegistryService.java?rev=41438&r1=41437&r2=41438&view=diff
==============================================================================
--- trunk/carbon/org.wso2.carbon.registry.core/src/main/java/org/wso2/carbon/registry/core/jdbc/EmbeddedRegistryService.java (original)
+++ trunk/carbon/org.wso2.carbon.registry.core/src/main/java/org/wso2/carbon/registry/core/jdbc/EmbeddedRegistryService.java Sat Jul 18 09:17:20 2009
@@ -186,7 +186,7 @@
RegistryConstants.ANONYMOUS_PASSWORD,
0,
embeddedRegistry,
- defaultRealm);
+ defaultRealm, null);
}
/**
@@ -205,7 +205,6 @@
return getSystemRegistry(tenantId);
}
-
/**
* Returns a registry to be used for system operations. Human users should not be allowed
* log in using this registry.
@@ -216,6 +215,20 @@
*/
public UserRegistry getSystemRegistry(int tenantId) throws RegistryException {
+ return getSystemRegistry(tenantId, null);
+ }
+
+ /**
+ * Returns a registry to be used for system operations. Human users should not be allowed
+ * log in using this registry.
+ *
+ * @param tenantId tanent id of the user tenant.
+ * @param chroot to return a chrooted registry
+ * @return User registry for system user.
+ * @throws RegistryException
+ */
+ public UserRegistry getSystemRegistry(int tenantId, String chroot) throws RegistryException {
+
RegistryConfiguration regConfig = RegistryCoreServiceComponent.getRegistryConfig();
String username = regConfig.getValue(RegistryConfiguration.SYSTEM_USER_NAME);
@@ -223,7 +236,7 @@
username,
tenantId,
embeddedRegistry,
- defaultRealm);
+ defaultRealm, chroot);
return userRegistry;
}
@@ -261,8 +274,26 @@
* @throws RegistryException
*/
public UserRegistry getUserRegistry(String userName, String password, int tenantId) throws RegistryException {
+ return getUserRegistry(userName, password, tenantId, null);
+ }
+
+ /**
+ * Creates UserRegistry instances for normal users. Applications should use this method to
+ * create UserRegistry instances, unless there is a specific need documented in other methods.
+ * User name and the password will be authenticated by the EmbeddedRegistry before creating
+ * the requested UserRegistry instance.
+ *
+ * @param userName User name of the user.
+ * @param password Password of the user.
+ * @param tenantId Tenant id of the user tanent.
+ * @param chroot to return a chrooted registry
+ * @return UserRegistry instance for the given user.
+ * @throws RegistryException
+ */
+ public UserRegistry getUserRegistry(String userName, String password,
+ int tenantId, String chroot) throws RegistryException {
UserRegistry userRegistry = new UserRegistry(userName, password, tenantId,
- embeddedRegistry, defaultRealm);
+ embeddedRegistry, defaultRealm, chroot);
return userRegistry;
}
@@ -296,8 +327,24 @@
* @throws RegistryException
*/
public UserRegistry getUserRegistry(String userName, int tenantId) throws RegistryException {
+ return getUserRegistry(userName, tenantId, null);
+ }
+
+
+ /**
+ * Creates a UserRegistry instance for the given user. This method will NOT authenticate the
+ * user before creating the UserRegistry instance. It assumes that the user is authenticated
+ * outside the EmbeddedRegistry.
+ *
+ * @param userName User name of the user.
+ * @param tenantId Tenant id of the user tanent.
+ * @param chroot to return a chrooted registry
+ * @return UserRegistry instance for the given user.
+ * @throws RegistryException
+ */
+ public UserRegistry getUserRegistry(String userName, int tenantId, String chroot) throws RegistryException {
UserRegistry userRegistry = new UserRegistry(userName, tenantId,
- embeddedRegistry, defaultRealm);
+ embeddedRegistry, defaultRealm, chroot);
return userRegistry;
}
Modified: trunk/carbon/org.wso2.carbon.registry.core/src/main/java/org/wso2/carbon/registry/core/jdbc/utils/Transaction.java
URL: http://wso2.org/svn/browse/wso2/trunk/carbon/org.wso2.carbon.registry.core/src/main/java/org/wso2/carbon/registry/core/jdbc/utils/Transaction.java?rev=41438&r1=41437&r2=41438&view=diff
==============================================================================
--- trunk/carbon/org.wso2.carbon.registry.core/src/main/java/org/wso2/carbon/registry/core/jdbc/utils/Transaction.java (original)
+++ trunk/carbon/org.wso2.carbon.registry.core/src/main/java/org/wso2/carbon/registry/core/jdbc/utils/Transaction.java Sat Jul 18 09:17:20 2009
@@ -109,7 +109,7 @@
return tRollbacked.get();
}
- public static void setRollbacked(boolean started) {
- tRollbacked.set(started);
+ public static void setRollbacked(boolean rollbacked) {
+ tRollbacked.set(rollbacked);
}
}
Modified: trunk/carbon/org.wso2.carbon.registry.core/src/main/java/org/wso2/carbon/registry/core/service/RegistryService.java
URL: http://wso2.org/svn/browse/wso2/trunk/carbon/org.wso2.carbon.registry.core/src/main/java/org/wso2/carbon/registry/core/service/RegistryService.java?rev=41438&r1=41437&r2=41438&view=diff
==============================================================================
--- trunk/carbon/org.wso2.carbon.registry.core/src/main/java/org/wso2/carbon/registry/core/service/RegistryService.java (original)
+++ trunk/carbon/org.wso2.carbon.registry.core/src/main/java/org/wso2/carbon/registry/core/service/RegistryService.java Sat Jul 18 09:17:20 2009
@@ -50,6 +50,17 @@
UserRegistry getSystemRegistry(int tenantId) throws RegistryException;
/**
+ * Returns a registry to be used for system operations. Human users should not be allowed
+ * log in using this registry.
+ *
+ * @param tenantId the tenant id of the system.
+ * @param chroot to return a chrooted registry
+ * @return User registry for system user.
+ * @throws RegistryException
+ */
+ UserRegistry getSystemRegistry(int tenantId, String chroot) throws RegistryException;
+
+ /**
* Creates UserRegistry instances for normal users. Applications should use this method to
* create UserRegistry instances, unless there is a specific need documented in other methods.
* User name and the password will be authenticated by the EmbeddedRegistry before creating
@@ -63,6 +74,17 @@
UserRegistry getUserRegistry(String userName, String password) throws RegistryException;
/**
+ * Creates a Registry instance for the given user. This method will NOT authenticate the
+ * user before creating the UserRegistry instance. It assumes that the user is authenticated
+ * outside the EmbeddedRegistry.
+ *
+ * @param userName User name of the user.
+ * @return UserRegistry instance for the given user.
+ * @throws RegistryException
+ */
+ UserRegistry getUserRegistry(String userName) throws RegistryException;
+
+ /**
* Creates UserRegistry instances for normal users. Applications should use this method to
* create UserRegistry instances, unless there is a specific need documented in other methods.
* User name and the password will be authenticated by the EmbeddedRegistry before creating
@@ -77,15 +99,20 @@
UserRegistry getUserRegistry(String userName, String password, int tenantId) throws RegistryException;
/**
- * Creates a Registry instance for the given user. This method will NOT authenticate the
- * user before creating the UserRegistry instance. It assumes that the user is authenticated
- * outside the EmbeddedRegistry.
+ * Creates UserRegistry instances for normal users. Applications should use this method to
+ * create UserRegistry instances, unless there is a specific need documented in other methods.
+ * User name and the password will be authenticated by the EmbeddedRegistry before creating
+ * the requested UserRegistry instance.
*
* @param userName User name of the user.
+ * @param password Password of the user.
+ * @param tenantId tenant id of the user tenant.
+ * @param chroot to return a chrooted registry
* @return UserRegistry instance for the given user.
* @throws RegistryException
*/
- UserRegistry getUserRegistry(String userName) throws RegistryException;
+ UserRegistry getUserRegistry(String userName, String password,
+ int tenantId, String chroot) throws RegistryException;
/**
@@ -99,4 +126,17 @@
* @throws RegistryException
*/
UserRegistry getUserRegistry(String userName, int tenantId) throws RegistryException;
+
+ /**
+ * Creates a Registry instance for the given user with tenant id. This method will NOT authenticate the
+ * user before creating the Registry instance. It assumes that the user is authenticated
+ * outside the registry service.
+ *
+ * @param userName User name of the user.
+ * @param tenantId tenant id of the user tenant.
+ * @param chroot to return a chrooted registry
+ * @return UserRegistry instance for the given user.
+ * @throws RegistryException
+ */
+ UserRegistry getUserRegistry(String userName, int tenantId, String chroot) throws RegistryException;
}
Added: trunk/carbon/org.wso2.carbon.registry.core/src/main/java/org/wso2/carbon/registry/core/session/ChrootWrapper.java
URL: http://wso2.org/svn/browse/wso2/trunk/carbon/org.wso2.carbon.registry.core/src/main/java/org/wso2/carbon/registry/core/session/ChrootWrapper.java?pathrev=41438
==============================================================================
--- (empty file)
+++ trunk/carbon/org.wso2.carbon.registry.core/src/main/java/org/wso2/carbon/registry/core/session/ChrootWrapper.java Sat Jul 18 09:17:20 2009
@@ -0,0 +1,276 @@
+/*
+ * Copyright (c) 2005-2008, WSO2 Inc. (http://www.wso2.org) All Rights Reserved.
+ *
+ * WSO2 Inc. licenses this file to you under the Apache License,
+ * Version 2.0 (the "License"); you may not use this file except
+ * in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ *
+ */
+package org.wso2.carbon.registry.core.session;
+
+import org.wso2.carbon.registry.core.*;
+import org.wso2.carbon.registry.core.exceptions.RegistryException;
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+
+import java.util.List;
+import java.util.ArrayList;
+
+public class ChrootWrapper {
+
+ public static final Log log = LogFactory.getLog(UserRegistry.class);
+ // The URL prefix to use for all accesses - must end with a slash
+ protected String basePrefix = null;
+
+ public ChrootWrapper(String basePrefix) {
+ if (basePrefix != null) {
+ if (!basePrefix.endsWith("/")) {
+ basePrefix += "/";
+ }
+ this.basePrefix = basePrefix;
+ }
+ }
+
+ public String getBasePrefix() {
+ return basePrefix;
+ }
+
+ /**
+ * Get an absolute path for the given path argument, taking into
+ * account both initial double-slashes (indicating an absolute path)
+ * and any basePrefix that has been established.
+ *
+ * This is the converse of getOutPath().
+ *
+ * @param path a relative path
+ * @return an absolute path into the "real" registry.
+ */
+ public String getInPath(String path) {
+ // No worries if there's no base prefix
+ if (basePrefix == null || basePrefix.length() == 0 || path == null) {
+ return path;
+ }
+ if (log.isTraceEnabled()) {
+ log.trace("Deriving the absolute path, " +
+ "chroot-base: " + basePrefix + ", " +
+ "path: " + path + ".");
+ }
+
+ if (path.startsWith("//")) {
+ // This is an absolute path, so just strip the doubled slash
+ return path.substring(1);
+ }
+
+ // Relative path, so prepend basePrefix appropriately
+ if (path.startsWith("/")) {
+ return basePrefix + path.substring(1);
+ }
+
+ return basePrefix + path;
+ }
+
+ /**
+ * Take an absolute path in the "real" registry and convert it to a relative
+ * path suitable for this particular RemoteRegistry (which may be rooted at a
+ * particular place).
+ *
+ * This is the converse of getInPath().
+ *
+ * @param absolutePath a full path from the root of the registry, starting with "/"
+ * @return a relative path which generates the correct absolute path
+ */
+ public String getOutPath(String absolutePath) {
+ // No worries if there's no base prefix
+ if (basePrefix == null || basePrefix.length() == 0 || absolutePath == null) {
+ return absolutePath;
+ }
+ if (log.isTraceEnabled()) {
+ log.trace("Derivig the relative path, " +
+ "chroot-base: " + basePrefix + ", " +
+ "path: " + absolutePath + ".");
+ }
+
+ if (absolutePath.startsWith(basePrefix)) {
+ return absolutePath.substring(basePrefix.length() - 1);
+ }
+
+ // Somewhere else, so make sure there are dual slashes at the beginning
+ return "/" + absolutePath;
+ }
+
+ /**
+ * returns a set of outpaths
+ * @param absolutePaths
+ * @return relative paths
+ */
+ public String[] getOutPaths(String[] absolutePaths) {
+ if (basePrefix == null || basePrefix.length() == 0 ||
+ absolutePaths == null || absolutePaths.length == 0) {
+ return absolutePaths;
+ }
+ for (int i = 0; i < absolutePaths.length; i ++) {
+ String absolutePath = absolutePaths[i];
+ absolutePaths[i] = getOutPath(absolutePath);
+ }
+ return absolutePaths;
+ }
+
+ /**
+ * The resource needed to be modified in case of out resource
+ * @param resource
+ * @return
+ */
+ public Resource getOutResource(Resource resource) throws RegistryException {
+ // No worries if there's no base prefix
+ if (basePrefix == null || basePrefix.length() == 0) {
+ return resource;
+ }
+ String absolutePath = resource.getPath();
+ if (log.isTraceEnabled()) {
+ log.trace("Derivig the relative resource, " +
+ "chroot-base: " + basePrefix + ", " +
+ "resource-absolute-path: " + absolutePath + ".");
+ }
+ if (resource instanceof CollectionImpl) {
+ fixCollection((CollectionImpl)resource);
+ }
+ // fixing the path attribute of the resource
+ if (absolutePath != null) {
+ String relativePath = getOutPath(absolutePath);
+ ((ResourceImpl)resource).setPath(relativePath);
+ }
+ fixMountPoints(resource);
+ return resource;
+ }
+
+ /**
+ * When returning collection (with pagination) it need to unset the collection content
+ * @param collection
+ * @return
+ * @throws RegistryException
+ */
+ public Collection getOutCollection(Collection collection) throws RegistryException {
+ if (basePrefix == null || basePrefix.length() == 0) {
+ return collection;
+ }
+ collection.setContent(null);
+ return collection;
+ }
+
+ /**
+ * return the associations array with relative paths
+ * @param associations
+ * @return
+ */
+ public Association[] getOutAssociations(Association[] associations) {
+ if (basePrefix == null || basePrefix.length() == 0) {
+ return associations;
+ }
+ for ( Association association : associations) {
+ if (association != null) {
+ association.setSourcePath(getOutPath(association.getSourcePath()));
+ association.setDestinationPath(getOutPath(association.getDestinationPath()));
+ }
+ }
+ return associations;
+ }
+
+ /**
+ * return the tagged resouce path wth relative paths
+ * @param taggedResourcePaths
+ * @return
+ */
+ public TaggedResourcePath[] getOutTaggedResourcePaths(TaggedResourcePath[] taggedResourcePaths) {
+ if (basePrefix == null || basePrefix.length() == 0) {
+ return taggedResourcePaths;
+ }
+ for (TaggedResourcePath trp : taggedResourcePaths) {
+ String path = trp.getResourcePath();
+ trp.setResourcePath(getOutPath(path));
+ }
+ return taggedResourcePaths;
+ }
+
+ /**
+ * return the comments with relative paths set
+ * @param comments
+ * @return
+ */
+ public Comment[] getOutComments(Comment[] comments) {
+ if (basePrefix == null || basePrefix.length() == 0) {
+ return comments;
+ }
+ for (Comment comment : comments) {
+ comment.setPath(getOutPath(comment.getPath()));
+ comment.setResourcePath(getOutPath(comment.getResourcePath()));
+ comment.setCommentPath(getOutPath(comment.getCommentPath()));
+ }
+ return comments;
+ }
+
+ /**
+ * Filter search results
+ * @param collection unfiltered search results
+ * @return filtered search results
+ */
+ public Collection filterSearchResult(Collection collection) throws RegistryException {
+ if (basePrefix == null || basePrefix.length() == 0) {
+ return collection;
+ }
+ String[] results = collection.getChildren();
+ if (results == null || results.length == 0) {
+ return collection;
+ }
+ List<String> filteredResult = new ArrayList<String>();
+ for (int i = 0; i < results.length; i ++) {
+ if (results[i].startsWith(basePrefix)) {
+ if (results[i] instanceof String) {
+ filteredResult.add(results[i]);
+ }
+ }
+ }
+ String[] filteredResultArr = filteredResult.toArray(new String[filteredResult.size()]);
+ collection.setContent(filteredResultArr);
+ return collection;
+ }
+
+ private void fixCollection(CollectionImpl collection) throws RegistryException {
+ Object content = collection.getContent();
+ if (content instanceof String[]) {
+ String [] paths = (String[])content;
+ for (int i = 0; i < paths.length; i++) {
+ paths[i] = getOutPath(paths[i]);
+ }
+ } else if (content instanceof Resource[]) {
+ Resource [] resources = (Resource[])content;
+ for (Resource resource : resources) {
+ ((ResourceImpl)resource).setPath(getOutPath(resource.getPath()));
+ if (resource instanceof Comment) {
+ Comment comment = (Comment)resource;
+ comment.setResourcePath(getOutPath(comment.getResourcePath()));
+ }
+ }
+ }
+ }
+
+ private void fixMountPoints(Resource resource) {
+ String mountPoint = resource.getProperty("registry.mountpoint");
+ if (mountPoint != null) {
+ resource.setProperty("registry.mountpoint", getOutPath(mountPoint));
+ }
+ String targetPoint = resource.getProperty("registry.targetpoint");
+ if (targetPoint != null) {
+ resource.setProperty("registry.targetpoint", getOutPath(targetPoint));
+ }
+ }
+}
Deleted: trunk/carbon/org.wso2.carbon.registry.core/src/main/java/org/wso2/carbon/registry/core/session/SessionRealm.java
URL: http://wso2.org/svn/browse/wso2/None?pathrev=41437
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=41438&r1=41437&r2=41438&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 Sat Jul 18 09:17:20 2009
@@ -47,6 +47,8 @@
* user details, it does not perform any authorization. Underlying registry or other entities
* in the thread of invocation should perform authorizations as needed using the realm given by
* this class.
+ * In addition to associating user with the registry, this will be used to get a chrooted registry,
+ * as the new constructors accept chroot as the last parameter.
*/
public class UserRegistry implements Registry {
@@ -76,15 +78,23 @@
private Registry coreRegistry;
/**
- * Database connection is stored in this variable, if there is an open transaction. UserRegistry should provide
- * the connection object for uncommited transactions by setting it as a thread local variable. This is required as
- * there is no garauntee that the same thread will serve all method calls of a single
- * transaction (e.g. in servlets).
+ * functionality related to chrooting
*/
- private Connection connection;
+ private ChrootWrapper chrootWrapper;
+ /**
+ * Create a user reigstry with authorizing a user
+ * @param userName the username of the user accessing
+ * @param password the password credentials
+ * @param tenantId the tenant the user belong to
+ * @param coreRegistry either RemoteRegistry or the EmbeddedRegistry
+ * @param defaultRealm the realm provided by user manager
+ * @param chroot the base prefix if the registry needed to chrooted, if provided null
+ * non-chroot registry will be constructed.
+ * @throws RegistryException
+ */
public UserRegistry (String userName, String password, int tenantId,
- Registry coreRegistry, UserRealm defaultRealm)
+ Registry coreRegistry, UserRealm defaultRealm, String chroot)
throws RegistryException {
try {
@@ -109,26 +119,35 @@
throw new RegistryException(msg, e);
}
- init(userName, tenantId, coreRegistry, defaultRealm);
+ init(userName, tenantId, coreRegistry, defaultRealm, chroot);
}
-
+ /**
+ * Creates a user registry without authorizing the user
+ * @param userName the username of the user accessing
+ * @param tenantId the tenant the user belong to
+ * @param coreRegistry either RemoteRegistry or the EmbeddedRegistry
+ * @param defaultRealm the realm provided by user manager
+ * @param chroot the base prefix if the registry needed to chrooted, if provided null
+ * non-chroot registry will be constructed.
+ * @throws RegistryException
+ */
public UserRegistry (
String userName, int tenantId, Registry coreRegistry,
- UserRealm defaultRealm) throws RegistryException {
+ UserRealm defaultRealm, String chroot) throws RegistryException {
- init(userName, tenantId, coreRegistry, defaultRealm);
+ init(userName, tenantId, coreRegistry, defaultRealm, chroot);
}
private void init(
String userName, int tenantId, Registry registry,
- UserRealm defaultRealm) throws RegistryException {
+ UserRealm defaultRealm, String chroot) throws RegistryException {
this.userName = userName;
this.tenantId = tenantId;
this.coreRegistry = registry;
this.userRealm = defaultRealm;
- this.connection = null;
+ this.chrootWrapper = new ChrootWrapper(chroot);
addSystemCollections();
}
@@ -154,7 +173,7 @@
}
else {
systemRegistry = new UserRegistry(systemUsername, this.tenantId,
- this.coreRegistry, this.userRealm);
+ this.coreRegistry, this.userRealm, chrootWrapper.getBasePrefix());
}
// check if root is added. if not add it.
@@ -265,7 +284,6 @@
try {
setSessionInformation();
coreRegistry.beginTransaction();
- connection = Transaction.getConnection();
} finally {
clearSessionInformation();
}
@@ -278,7 +296,6 @@
try {
setSessionInformation();
coreRegistry.rollbackTransaction();
- connection = Transaction.getConnection();
} finally {
clearSessionInformation();
}
@@ -291,7 +308,6 @@
try {
setSessionInformation();
coreRegistry.commitTransaction();
- connection = Transaction.getConnection();
} finally {
clearSessionInformation();
}
@@ -332,10 +348,16 @@
"path: " + path + ".");
}
try {
+ // setting session information + chrooting the incomming paths
setSessionInformation();
+ path = chrootWrapper.getInPath(path);
+
ResourceImpl resource = (ResourceImpl) coreRegistry.get(path);
resource.setUserName(userName);
resource.setUserRealm(userRealm);
+
+ // unsetting the chrooted paths in returning values
+ resource = (ResourceImpl)chrootWrapper.getOutResource(resource);
return resource;
} finally {
@@ -349,10 +371,16 @@
"path: " + path + ".");
}
try {
+ // setting session information + chrooting the incomming paths
setSessionInformation();
+ path = chrootWrapper.getInPath(path);
+
ResourceImpl resource = (ResourceImpl) coreRegistry.getMetaData(path);
resource.setUserName(userName);
resource.setUserRealm(userRealm);
+
+ // unsetting the chrooted paths in returning values
+ resource = (ResourceImpl)chrootWrapper.getOutResource(resource);
return resource;
} finally {
@@ -368,7 +396,10 @@
"page size: " + pageSize + ".");
}
try {
+ // setting session information + chrooting the incomming paths
setSessionInformation();
+ path = chrootWrapper.getInPath(path);
+
Collection collection = coreRegistry.get(path, start, pageSize);
// collection implementation extends from the resource implementation.
@@ -376,6 +407,8 @@
resourceImpl.setUserName(userName);
resourceImpl.setUserRealm(userRealm);
+ // unsetting the chrooted paths in returning values
+ collection = chrootWrapper.getOutCollection(collection);
return collection;
} finally {
@@ -389,8 +422,12 @@
"path: " + path + ".");
}
try {
+ // setting session information + chrooting the incomming paths
setSessionInformation();
+ path = chrootWrapper.getInPath(path);
+
return coreRegistry.resourceExists(path);
+
} finally {
clearSessionInformation();
}
@@ -409,7 +446,10 @@
return suggestedPath;
}
try {
+ // setting session information + chrooting the incomming paths
setSessionInformation();
+ suggestedPath = chrootWrapper.getInPath(suggestedPath);
+
return coreRegistry.put(suggestedPath, resource);
} finally {
clearSessionInformation();
@@ -429,7 +469,10 @@
return;
}
try {
+ // setting session information + chrooting the incomming paths
setSessionInformation();
+ path = chrootWrapper.getInPath(path);
+
coreRegistry.delete(path);
} finally {
clearSessionInformation();
@@ -450,8 +493,15 @@
return suggestedPath;
}
try {
+ // setting session information + chrooting the incomming paths
setSessionInformation();
- return coreRegistry.importResource(suggestedPath, sourceURL, metadata);
+ suggestedPath = chrootWrapper.getInPath(suggestedPath);
+
+ String returnedPath = coreRegistry.importResource(suggestedPath, sourceURL, metadata);
+
+ // unsetting the chrooted paths in returning values
+ returnedPath = chrootWrapper.getOutPath(returnedPath);
+ return returnedPath;
} finally {
clearSessionInformation();
}
@@ -471,8 +521,19 @@
return currentPath;
}
try {
+ // setting session information + chrooting the incomming paths
setSessionInformation();
- return coreRegistry.rename(currentPath, newPath);
+ if (newPath.startsWith(RegistryConstants.ROOT_PATH)) {
+ // this is not an absolute path, so needded to be transformed
+ newPath = chrootWrapper.getInPath(newPath);
+ }
+ currentPath = chrootWrapper.getInPath(currentPath);
+
+ String renamedPath = coreRegistry.rename(currentPath, newPath);
+
+ // unsetting the chrooted paths in returning values
+ renamedPath = chrootWrapper.getOutPath(renamedPath);
+ return renamedPath;
} finally {
clearSessionInformation();
}
@@ -492,8 +553,16 @@
return currentPath;
}
try {
+ // setting session information + chrooting the incomming paths
setSessionInformation();
- return coreRegistry.move(currentPath, newPath);
+ currentPath = chrootWrapper.getInPath(currentPath);
+ newPath = chrootWrapper.getInPath(newPath);
+
+ String movedPath = coreRegistry.move(currentPath, newPath);
+
+ // unsetting the chrooted paths in returning values
+ movedPath = chrootWrapper.getOutPath(movedPath);
+ return movedPath;
} finally {
clearSessionInformation();
}
@@ -513,8 +582,16 @@
return sourcePath;
}
try {
+ // setting session information + chrooting the incomming paths
setSessionInformation();
- return coreRegistry.copy(sourcePath, targetPath);
+ sourcePath = chrootWrapper.getInPath(sourcePath);
+ targetPath = chrootWrapper.getInPath(targetPath);
+
+ String copiedPath = coreRegistry.copy(sourcePath, targetPath);
+
+ // unsetting the chrooted paths in returning values
+ copiedPath = chrootWrapper.getOutPath(copiedPath);
+ return copiedPath;
} finally {
clearSessionInformation();
}
@@ -533,7 +610,10 @@
return;
}
try {
+ // setting session information + chrooting the incomming paths
setSessionInformation();
+ path = chrootWrapper.getInPath(path);
+
coreRegistry.createVersion(path);
} finally {
clearSessionInformation();
@@ -546,8 +626,15 @@
"path: " + path + ".");
}
try {
+ // setting session information + chrooting the incomming paths
setSessionInformation();
- return coreRegistry.getVersions(path);
+ path = chrootWrapper.getInPath(path);
+
+ String[] versionPaths = coreRegistry.getVersions(path);
+
+ // unsetting the chrooted paths in returning values
+ versionPaths = chrootWrapper.getOutPaths(versionPaths);
+ return versionPaths;
} finally {
clearSessionInformation();
}
@@ -566,7 +653,10 @@
return;
}
try {
+ // setting session information + chrooting the incomming paths
setSessionInformation();
+ versionPath = chrootWrapper.getInPath(versionPath);
+
coreRegistry.restoreVersion(versionPath);
} finally {
clearSessionInformation();
@@ -592,20 +682,24 @@
return;
}
try {
+ // setting session information + chrooting the incomming paths
setSessionInformation();
+ sourcePath = chrootWrapper.getInPath(sourcePath);
+ targetPath = chrootWrapper.getInPath(targetPath);
+
coreRegistry.addAssociation(sourcePath, targetPath, associationType);
} finally {
clearSessionInformation();
}
}
- public void removeAssociation(String sourcePath, String associationPaths,
+ public void removeAssociation(String sourcePath, String associationPath,
String associationType)
throws RegistryException {
if (log.isTraceEnabled()) {
log.trace("Preparing operation remove association, " +
"source: " + sourcePath + ", " +
- "paths: " + associationPaths + ", " +
+ "path: " + associationPath + ", " +
"type: " + associationType + ".");
}
// If this node is operating in read-only mode, do not delete the associations
@@ -616,8 +710,12 @@
return;
}
try {
+ // setting session information + chrooting the incomming paths
setSessionInformation();
- coreRegistry.removeAssociation(sourcePath, associationPaths, associationType);
+ sourcePath = chrootWrapper.getInPath(sourcePath);
+ associationPath = chrootWrapper.getInPath(associationPath);
+
+ coreRegistry.removeAssociation(sourcePath, associationPath, associationType);
} finally {
clearSessionInformation();
}
@@ -629,8 +727,15 @@
"path: " + resourcePath + ".");
}
try {
+ // setting session information + chrooting the incomming paths
setSessionInformation();
- return coreRegistry.getAllAssociations(resourcePath);
+ resourcePath = chrootWrapper.getInPath(resourcePath);
+
+ Association[] associations = coreRegistry.getAllAssociations(resourcePath);
+
+ // unsetting the chrooted paths in returning values
+ associations = chrootWrapper.getOutAssociations(associations);
+ return associations;
} finally {
clearSessionInformation();
}
@@ -644,8 +749,15 @@
"association type: " + associationType + ".");
}
try {
+ // setting session information + chrooting the incomming paths
setSessionInformation();
- return coreRegistry.getAssociations(resourcePath, associationType);
+ resourcePath = chrootWrapper.getInPath(resourcePath);
+
+ Association[] associations = coreRegistry.getAssociations(resourcePath, associationType);
+
+ // unsetting the chrooted paths in returning values
+ associations = chrootWrapper.getOutAssociations(associations);
+ return associations;
} finally {
clearSessionInformation();
}
@@ -666,7 +778,10 @@
return;
}
try {
+ // setting session information + chrooting the incomming paths
setSessionInformation();
+ resourcePath = chrootWrapper.getInPath(resourcePath);
+
coreRegistry.applyTag(resourcePath, tag);
} finally {
clearSessionInformation();
@@ -679,8 +794,13 @@
"tag: " + tag + ".");
}
try {
+ // setting session information + chrooting the incomming paths
setSessionInformation();
- return coreRegistry.getResourcePathsWithTag(tag);
+ TaggedResourcePath[] taggedResourcePaths = coreRegistry.getResourcePathsWithTag(tag);
+
+ // unsetting the chrooted paths in returning values
+ taggedResourcePaths = chrootWrapper.getOutTaggedResourcePaths(taggedResourcePaths);
+ return taggedResourcePaths;
} finally {
clearSessionInformation();
}
@@ -692,7 +812,10 @@
"path: " + resourcePath + ".");
}
try {
+ // setting session information + chrooting the incomming paths
setSessionInformation();
+ resourcePath = chrootWrapper.getInPath(resourcePath);
+
return coreRegistry.getTags(resourcePath);
} finally {
clearSessionInformation();
@@ -713,7 +836,10 @@
return;
}
try {
+ // setting session information + chrooting the incomming paths
setSessionInformation();
+ path = chrootWrapper.getInPath(path);
+
coreRegistry.removeTag(path, tag);
} finally {
clearSessionInformation();
@@ -733,7 +859,10 @@
return resourcePath;
}
try {
+ // setting session information + chrooting the incomming paths
setSessionInformation();
+ resourcePath = chrootWrapper.getInPath(resourcePath);
+
return coreRegistry.addComment(resourcePath, comment);
} finally {
clearSessionInformation();
@@ -753,7 +882,10 @@
return;
}
try {
+ // setting session information + chrooting the incomming paths
setSessionInformation();
+ commentPath = chrootWrapper.getInPath(commentPath);
+
coreRegistry.editComment(commentPath, text);
} finally {
clearSessionInformation();
@@ -766,8 +898,15 @@
"path: " + resourcePath + ".");
}
try {
+ // setting session information + chrooting the incomming paths
setSessionInformation();
- return coreRegistry.getComments(resourcePath);
+ resourcePath = chrootWrapper.getInPath(resourcePath);
+
+ Comment[] returnedComments = coreRegistry.getComments(resourcePath);
+
+ // unsetting the chrooted paths in returning values
+ returnedComments = chrootWrapper.getOutComments(returnedComments);
+ return returnedComments;
} finally {
clearSessionInformation();
}
@@ -787,7 +926,10 @@
return;
}
try {
+ // setting session information + chrooting the incomming paths
setSessionInformation();
+ resourcePath = chrootWrapper.getInPath(resourcePath);
+
coreRegistry.rateResource(resourcePath, rating);
} finally {
clearSessionInformation();
@@ -800,7 +942,10 @@
"path: " + resourcePath + ".");
}
try {
+ // setting session information + chrooting the incomming paths
setSessionInformation();
+ resourcePath = chrootWrapper.getInPath(resourcePath);
+
return coreRegistry.getAverageRating(resourcePath);
} finally {
clearSessionInformation();
@@ -814,7 +959,10 @@
"user name: " + userName + ".");
}
try {
+ // setting session information + chrooting the incomming paths
setSessionInformation();
+ path = chrootWrapper.getInPath(path);
+
return coreRegistry.getRating(path, userName);
} finally {
clearSessionInformation();
@@ -840,13 +988,19 @@
log.trace(msg);
}
try {
+ // setting session information + chrooting the incomming paths
setSessionInformation();
+ path = chrootWrapper.getInPath(path);
+
Collection collection = coreRegistry.executeQuery(path, parameters);
ResourceImpl resourceImpl = (ResourceImpl) collection;
resourceImpl.setUserName(userName);
resourceImpl.setUserRealm(userRealm);
+ // unsetting the chrooted paths in returning values
+ collection = chrootWrapper.filterSearchResult(collection);
+ collection = (Collection)chrootWrapper.getOutResource(collection);
return collection;
} finally {
@@ -872,7 +1026,10 @@
"recent first: " + recentFirst + ".");
}
try {
+ // setting session information + chrooting the incomming paths
setSessionInformation();
+ resourcePath = chrootWrapper.getInPath(resourcePath);
+
return coreRegistry.getLogs(resourcePath, action, userName, from, to, recentFirst);
} finally {
clearSessionInformation();
@@ -896,7 +1053,10 @@
"recent first: " + recentFirst + ".");
}
try {
+ // setting session information + chrooting the incomming paths
setSessionInformation();
+ resourcePath = chrootWrapper.getInPath(resourcePath);
+
return coreRegistry.getLogCollection(resourcePath, action, userName, from, to, recentFirst);
} finally {
clearSessionInformation();
@@ -908,6 +1068,7 @@
log.trace("Preparing operation get available actions.");
}
try {
+ // setting session information + chrooting the incomming paths
setSessionInformation();
return coreRegistry.getAvailableAspects();
} finally {
@@ -930,7 +1091,10 @@
return;
}
try {
+ // setting session information + chrooting the incomming paths
setSessionInformation();
+ resourcePath = chrootWrapper.getInPath(resourcePath);
+
coreRegistry.associateAspect(resourcePath, aspect);
} finally {
clearSessionInformation();
@@ -945,7 +1109,10 @@
"action: " + action + ".");
}
try {
+ // setting session information + chrooting the incomming paths
setSessionInformation();
+ resourcePath = chrootWrapper.getInPath(resourcePath);
+
coreRegistry.invokeAspect(resourcePath, aspectName, action);
} finally {
clearSessionInformation();
@@ -959,7 +1126,10 @@
"aspect name: " + aspectName + ".");
}
try {
+ // setting session information + chrooting the incomming paths
setSessionInformation();
+ resourcePath = chrootWrapper.getInPath(resourcePath);
+
return coreRegistry.getAspectActions(resourcePath, aspectName);
} finally {
clearSessionInformation();
@@ -972,13 +1142,18 @@
"keywords: " + keywords + ".");
}
try {
+ // setting session information + chrooting the incomming paths
setSessionInformation();
+
Collection collection = coreRegistry.searchContent(keywords);
ResourceImpl resourceImpl = (ResourceImpl) collection;
resourceImpl.setUserName(userName);
resourceImpl.setUserRealm(userRealm);
+ // unsetting the chrooted paths in returning values
+ collection = chrootWrapper.filterSearchResult(collection);
+ collection = (Collection)chrootWrapper.getOutResource(collection);
return collection;
} finally {
@@ -1000,7 +1175,11 @@
return;
}
try {
+ // setting session information + chrooting the incomming paths
setSessionInformation();
+ path = chrootWrapper.getInPath(path);
+ target = chrootWrapper.getInPath(target);
+
coreRegistry.createLink(path, target);
} finally {
clearSessionInformation();
@@ -1023,7 +1202,10 @@
return;
}
try {
+ // setting session information + chrooting the incomming paths
setSessionInformation();
+ path = chrootWrapper.getInPath(path);
+
coreRegistry.createLink(path, target, targetSubPath);
} finally {
clearSessionInformation();
@@ -1043,7 +1225,10 @@
return;
}
try {
+ // setting session information + chrooting the incomming paths
setSessionInformation();
+ path = chrootWrapper.getInPath(path);
+
coreRegistry.removeLink(path);
} finally {
clearSessionInformation();
@@ -1064,7 +1249,10 @@
return;
}
try {
+ // setting session information + chrooting the incomming paths
setSessionInformation();
+ path = chrootWrapper.getInPath(path);
+
coreRegistry.restore(path, reader);
} finally {
clearSessionInformation();
@@ -1077,7 +1265,10 @@
"path: " + path + ".");
}
try {
+ // setting session information + chrooting the incomming paths
setSessionInformation();
+ path = chrootWrapper.getInPath(path);
+
coreRegistry.dump(path, writer);
} finally {
clearSessionInformation();
@@ -1091,7 +1282,10 @@
}
String eventingServiceURL = null;
try {
+ // setting session information + chrooting the incomming paths
setSessionInformation();
+ path = chrootWrapper.getInPath(path);
+
eventingServiceURL = coreRegistry.getEventingServiceURL(path);
} finally {
clearSessionInformation();
@@ -1103,7 +1297,7 @@
if (log.isTraceEnabled()) {
log.trace("Preparing operation set eventing service url, " +
"path: " + path + ", " +
- "eventing service url: " );
+ "eventing service url: " + eventingServiceURL + "." );
}
// If this node is operating in read-only mode, do not set eventing service url
if (CarbonUtils.isRegistryReadOnly()) {
@@ -1113,7 +1307,10 @@
return;
}
try {
+ // setting session information + chrooting the incomming paths
setSessionInformation();
+ path = chrootWrapper.getInPath(path);
+
coreRegistry.setEventingServiceURL(path, eventingServiceURL);
} finally {
clearSessionInformation();
@@ -1122,10 +1319,11 @@
public void setSessionInformation() {
-// if (connection != null) {
-// Transaction.setConnection(connection);
-// }
-
+ if (log.isTraceEnabled()) {
+ log.trace("Setting the session for registry operation, " +
+ "username: " + userName + ", " +
+ "tenantId: " + tenantId + "." );
+ }
CurrentSession.setUser(userName);
CurrentSession.setRealm(userRealm);
CurrentSession.setTenantId(tenantId);
@@ -1133,11 +1331,11 @@
public void clearSessionInformation() {
-// if (Transaction.isStarted()) {
-// Transaction.setStarted(false);
-// Transaction.setConnection(null);
-// }
-
+ if (log.isTraceEnabled()) {
+ log.trace("Clearing the session for registry operation, " +
+ "username: " + CurrentSession.getUser() + ", " +
+ "tenantId: " + CurrentSession.getTenantId() + "." );
+ }
CurrentSession.removeUser();
CurrentSession.removeRealm();
CurrentSession.removeTenantId();
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=41438&r1=41437&r2=41438&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 Sat Jul 18 09:17:20 2009
@@ -15,9 +15,10 @@
*/
package org.wso2.carbon.registry.core.test.jdbc;
-import org.wso2.carbon.registry.core.ChrootRegistry;
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.exceptions.RegistryException;
/**
* Execute all the JDBC registry tests with a non-standard root.
@@ -27,9 +28,11 @@
public void setUp() {
super.setUp();
- if (!(registry instanceof ChrootRegistry)) {
- originalRegistry = registry;
- registry = new ChrootRegistry(originalRegistry, "/basePrefix");
+ try {
+ originalRegistry = embeddedRegistry.getUserRegistry(RegistryConstants.ADMIN_USER);
+ registry = embeddedRegistry.getUserRegistry(RegistryConstants.ADMIN_USER, 0, "/basePrefix");
+ } catch (RegistryException e) {
+ fail("Failed to initialize the registry. Caused by: " + e.getMessage());
}
}
More information about the Carbon-dev
mailing list