jackrabbit-oak-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From mdue...@apache.org
Subject svn commit: r1513519 - in /jackrabbit/oak/trunk: oak-core/src/main/java/org/apache/jackrabbit/oak/security/user/UserManagerImpl.java oak-jcr/src/main/java/org/apache/jackrabbit/oak/jcr/SessionContext.java
Date Tue, 13 Aug 2013 14:53:02 GMT
Author: mduerig
Date: Tue Aug 13 14:53:01 2013
New Revision: 1513519

URL: http://svn.apache.org/r1513519
Log:
OAK-938 UserManager does not honour session refresh settings
Replace UserManager.checkLive by the precondition check provided by UserManagerOperation

Modified:
    jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/security/user/UserManagerImpl.java
    jackrabbit/oak/trunk/oak-jcr/src/main/java/org/apache/jackrabbit/oak/jcr/SessionContext.java

Modified: jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/security/user/UserManagerImpl.java
URL: http://svn.apache.org/viewvc/jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/security/user/UserManagerImpl.java?rev=1513519&r1=1513518&r2=1513519&view=diff
==============================================================================
--- jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/security/user/UserManagerImpl.java
(original)
+++ jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/security/user/UserManagerImpl.java
Tue Aug 13 14:53:01 2013
@@ -89,7 +89,6 @@ public class UserManagerImpl implements 
     //--------------------------------------------------------< UserManager >---
     @Override
     public Authorizable getAuthorizable(String id) throws RepositoryException {
-        checkIsLive();
         Authorizable authorizable = null;
         Tree tree = userProvider.getAuthorizable(id);
         if (tree != null) {
@@ -100,13 +99,11 @@ public class UserManagerImpl implements 
 
     @Override
     public Authorizable getAuthorizable(Principal principal) throws RepositoryException {
-        checkIsLive();
         return getAuthorizable(userProvider.getAuthorizableByPrincipal(principal));
     }
 
     @Override
     public Authorizable getAuthorizableByPath(String path) throws RepositoryException {
-        checkIsLive();
         String oakPath = namePathMapper.getOakPathKeepIndex(path);
         if (oakPath == null) {
             throw new RepositoryException("Invalid path " + path);
@@ -121,13 +118,11 @@ public class UserManagerImpl implements 
 
     @Override
     public Iterator<Authorizable> findAuthorizables(String relPath, String value, int
searchType) throws RepositoryException {
-        checkIsLive();
         return getQueryManager().findAuthorizables(relPath, value, AuthorizableType.getType(searchType));
     }
 
     @Override
     public Iterator<Authorizable> findAuthorizables(Query query) throws RepositoryException
{
-        checkIsLive();
         return getQueryManager().findAuthorizables(query);
     }
 
@@ -140,7 +135,6 @@ public class UserManagerImpl implements 
     @Override
     public User createUser(String userID, String password, Principal principal,
                            @Nullable String intermediatePath) throws RepositoryException
{
-        checkIsLive();
         checkValidID(userID);
         checkValidPrincipal(principal, false);
 
@@ -178,7 +172,6 @@ public class UserManagerImpl implements 
 
     @Override
     public Group createGroup(String groupID, Principal principal, @Nullable String intermediatePath)
throws RepositoryException {
-        checkIsLive();
         checkValidID(groupID);
         checkValidPrincipal(principal, true);
 
@@ -376,16 +369,6 @@ public class UserManagerImpl implements 
         userTree.setProperty(UserConstants.REP_PASSWORD, pwHash);
     }
 
-    private void checkIsLive() throws RepositoryException {
-        try {
-            // Note: Root#checkIsLive is not part of the public root interface.
-            // therefore execute the check using another method.
-            root.getBlobFactory();
-        } catch (IllegalStateException e) {
-            throw new RepositoryException("User manager is no longer alive.");
-        }
-    }
-
     private UserQueryManager getQueryManager() {
         if (queryManager == null) {
             queryManager = new UserQueryManager(this, namePathMapper, config, root);

Modified: jackrabbit/oak/trunk/oak-jcr/src/main/java/org/apache/jackrabbit/oak/jcr/SessionContext.java
URL: http://svn.apache.org/viewvc/jackrabbit/oak/trunk/oak-jcr/src/main/java/org/apache/jackrabbit/oak/jcr/SessionContext.java?rev=1513519&r1=1513518&r2=1513519&view=diff
==============================================================================
--- jackrabbit/oak/trunk/oak-jcr/src/main/java/org/apache/jackrabbit/oak/jcr/SessionContext.java
(original)
+++ jackrabbit/oak/trunk/oak-jcr/src/main/java/org/apache/jackrabbit/oak/jcr/SessionContext.java
Tue Aug 13 14:53:01 2013
@@ -194,6 +194,13 @@ public class SessionContext implements N
         return principalManager;
     }
 
+    private abstract class UserManagerOperation<T> extends SessionOperation<T>
{
+        @Override
+        public void checkPreconditions() throws RepositoryException {
+            delegate.checkAlive();
+        }
+    }
+
     @Nonnull
     public UserManager getUserManager() {
         // TODO Move to top level class (OAK-938), make UserManager from core the delegate
and pass root through argument of perform
@@ -202,7 +209,7 @@ public class SessionContext implements N
             userManager = new UserManager() {
                 @Override
                 public Authorizable getAuthorizable(final String id) throws RepositoryException
{
-                    return delegate.perform(new SessionOperation<Authorizable>() {
+                    return delegate.perform(new UserManagerOperation<Authorizable>()
{
                         @Override
                         public Authorizable perform() throws RepositoryException {
                             return uMgr.getAuthorizable(id);
@@ -212,7 +219,7 @@ public class SessionContext implements N
 
                 @Override
                 public Authorizable getAuthorizable(final Principal principal) throws RepositoryException
{
-                    return delegate.perform(new SessionOperation<Authorizable>() {
+                    return delegate.perform(new UserManagerOperation<Authorizable>()
{
                         @Override
                         public Authorizable perform() throws RepositoryException {
                             return uMgr.getAuthorizable(principal);
@@ -222,7 +229,7 @@ public class SessionContext implements N
 
                 @Override
                 public Authorizable getAuthorizableByPath(final String path) throws UnsupportedRepositoryOperationException,
RepositoryException {
-                    return delegate.perform(new SessionOperation<Authorizable>() {
+                    return delegate.perform(new UserManagerOperation<Authorizable>()
{
                         @Override
                         public Authorizable perform() throws RepositoryException {
                             return uMgr.getAuthorizableByPath(path);
@@ -232,7 +239,7 @@ public class SessionContext implements N
 
                 @Override
                 public Iterator<Authorizable> findAuthorizables(final String relPath,
final String value) throws RepositoryException {
-                    return delegate.perform(new SessionOperation<Iterator<Authorizable>>()
{
+                    return delegate.perform(new UserManagerOperation<Iterator<Authorizable>>()
{
                         @Override
                         public Iterator<Authorizable> perform() throws RepositoryException
{
                             return uMgr.findAuthorizables(relPath, value);
@@ -242,7 +249,7 @@ public class SessionContext implements N
 
                 @Override
                 public Iterator<Authorizable> findAuthorizables(final String relPath,
final String value, final int searchType) throws RepositoryException {
-                    return delegate.perform(new SessionOperation<Iterator<Authorizable>>()
{
+                    return delegate.perform(new UserManagerOperation<Iterator<Authorizable>>()
{
                         @Override
                         public Iterator<Authorizable> perform() throws RepositoryException
{
                             return uMgr.findAuthorizables(relPath, value, searchType);
@@ -252,7 +259,7 @@ public class SessionContext implements N
 
                 @Override
                 public Iterator<Authorizable> findAuthorizables(final Query query)
throws RepositoryException {
-                    return delegate.perform(new SessionOperation<Iterator<Authorizable>>()
{
+                    return delegate.perform(new UserManagerOperation<Iterator<Authorizable>>()
{
                         @Override
                         public Iterator<Authorizable> perform() throws RepositoryException
{
                             return uMgr.findAuthorizables(query);
@@ -262,7 +269,7 @@ public class SessionContext implements N
 
                 @Override
                 public User createUser(final String userID, final String password) throws
AuthorizableExistsException, RepositoryException {
-                    return delegate.perform(new SessionOperation<User>() {
+                    return delegate.perform(new UserManagerOperation<User>() {
                         @Override
                         public User perform() throws RepositoryException {
                             return uMgr.createUser(userID, password);
@@ -272,7 +279,7 @@ public class SessionContext implements N
 
                 @Override
                 public User createUser(final String userID, final String password, final
Principal principal, final String intermediatePath) throws AuthorizableExistsException, RepositoryException
{
-                    return delegate.perform(new SessionOperation<User>() {
+                    return delegate.perform(new UserManagerOperation<User>() {
                         @Override
                         public User perform() throws RepositoryException {
                             return uMgr.createUser(userID, password, principal, intermediatePath);
@@ -282,7 +289,7 @@ public class SessionContext implements N
 
                 @Override
                 public Group createGroup(final String groupID) throws AuthorizableExistsException,
RepositoryException {
-                    return delegate.perform(new SessionOperation<Group>() {
+                    return delegate.perform(new UserManagerOperation<Group>() {
                         @Override
                         public Group perform() throws RepositoryException {
                             return uMgr.createGroup(groupID);
@@ -292,7 +299,7 @@ public class SessionContext implements N
 
                 @Override
                 public Group createGroup(final Principal principal) throws AuthorizableExistsException,
RepositoryException {
-                    return delegate.perform(new SessionOperation<Group>() {
+                    return delegate.perform(new UserManagerOperation<Group>() {
                         @Override
                         public Group perform() throws RepositoryException {
                             return uMgr.createGroup(principal);
@@ -302,7 +309,7 @@ public class SessionContext implements N
 
                 @Override
                 public Group createGroup(final Principal principal, final String intermediatePath)
throws AuthorizableExistsException, RepositoryException {
-                    return delegate.perform(new SessionOperation<Group>() {
+                    return delegate.perform(new UserManagerOperation<Group>() {
                         @Override
                         public Group perform() throws RepositoryException {
                             return uMgr.createGroup(principal, intermediatePath);
@@ -312,7 +319,7 @@ public class SessionContext implements N
 
                 @Override
                 public Group createGroup(final String groupID, final Principal principal,
final String intermediatePath) throws AuthorizableExistsException, RepositoryException {
-                    return delegate.perform(new SessionOperation<Group>() {
+                    return delegate.perform(new UserManagerOperation<Group>() {
                         @Override
                         public Group perform() throws RepositoryException {
                             return uMgr.createGroup(groupID, principal, intermediatePath);
@@ -323,7 +330,7 @@ public class SessionContext implements N
                 @Override
                 public boolean isAutoSave() {
                     try {
-                        return delegate.perform(new SessionOperation<Boolean>() {
+                        return delegate.perform(new UserManagerOperation<Boolean>()
{
                             @Override
                             public Boolean perform() throws RepositoryException {
                                 return uMgr.isAutoSave();
@@ -337,7 +344,7 @@ public class SessionContext implements N
 
                 @Override
                 public void autoSave(final boolean enable) throws UnsupportedRepositoryOperationException,
RepositoryException {
-                    delegate.perform(new SessionOperation<Void>() {
+                    delegate.perform(new UserManagerOperation<Void>() {
                         @Override
                         public Void perform() throws RepositoryException {
                             uMgr.autoSave(enable);



Mime
View raw message