jackrabbit-oak-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ang...@apache.org
Subject svn commit: r1463483 - in /jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/security/user: AuthorizableImpl.java AuthorizablePropertiesImpl.java UserManagerImpl.java
Date Tue, 02 Apr 2013 11:07:30 GMT
Author: angela
Date: Tue Apr  2 11:07:29 2013
New Revision: 1463483

URL: http://svn.apache.org/r1463483
Log:
OAK-690: adjust user management to reflect changes made to oak API

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

Modified: jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/security/user/AuthorizableImpl.java
URL: http://svn.apache.org/viewvc/jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/security/user/AuthorizableImpl.java?rev=1463483&r1=1463482&r2=1463483&view=diff
==============================================================================
--- jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/security/user/AuthorizableImpl.java
(original)
+++ jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/security/user/AuthorizableImpl.java
Tue Apr  2 11:07:29 2013
@@ -47,6 +47,7 @@ abstract class AuthorizableImpl implemen
     private static final Logger log = LoggerFactory.getLogger(AuthorizableImpl.class);
 
     private final String id;
+    private final Tree tree;
     private final String principalName;
     private final UserManagerImpl userManager;
 
@@ -58,6 +59,7 @@ abstract class AuthorizableImpl implemen
         checkValidTree(tree);
 
         this.id = id;
+        this.tree = tree;
         this.userManager = userManager;
 
         PropertyState pNameProp = tree.getProperty(REP_PRINCIPAL_NAME);
@@ -179,7 +181,11 @@ abstract class AuthorizableImpl implemen
     //--------------------------------------------------------------------------
     @Nonnull
     Tree getTree() {
-        return userManager.getAuthorizableTree(id);
+        if (tree.isConnected()) {
+            return tree;
+        } else {
+            throw new IllegalStateException("Authorizable " + id + ": underlying tree has
been disconnected.");
+        }
     }
 
     @Nonnull
@@ -218,11 +224,10 @@ abstract class AuthorizableImpl implemen
      * Retrieve authorizable properties for property related operations.
      *
      * @return The authorizable properties for this user/group.
-     * @throws RepositoryException If an error occurs.
      */
-    private AuthorizableProperties getAuthorizableProperties() throws RepositoryException
{
+    private AuthorizableProperties getAuthorizableProperties() {
         if (properties == null) {
-            properties = userManager.getAuthorizableProperties(id);
+            properties = new AuthorizablePropertiesImpl(this);
         }
         return properties;
     }

Modified: jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/security/user/AuthorizablePropertiesImpl.java
URL: http://svn.apache.org/viewvc/jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/security/user/AuthorizablePropertiesImpl.java?rev=1463483&r1=1463482&r2=1463483&view=diff
==============================================================================
--- jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/security/user/AuthorizablePropertiesImpl.java
(original)
+++ jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/security/user/AuthorizablePropertiesImpl.java
Tue Apr  2 11:07:29 2013
@@ -52,15 +52,10 @@ class AuthorizablePropertiesImpl impleme
 
     private static final Logger log = LoggerFactory.getLogger(AuthorizablePropertiesImpl.class);
 
-    private final UserManagerImpl userManager;
-    private final String id;
-    private final ReadOnlyNodeTypeManager nodeTypeManager;
-
-    AuthorizablePropertiesImpl(String id, UserManagerImpl userManager,
-                               ReadOnlyNodeTypeManager nodeTypeManager) {
-        this.userManager = userManager;
-        this.id = id;
-        this.nodeTypeManager = nodeTypeManager;
+    private final AuthorizableImpl authorizable;
+
+    AuthorizablePropertiesImpl(AuthorizableImpl authorizable) {
+        this.authorizable = authorizable;
     }
 
     //---------------------------------------------< AuthorizableProperties >---
@@ -106,7 +101,7 @@ class AuthorizablePropertiesImpl impleme
         Value[] values = null;
         PropertyState property = getAuthorizableProperty(tree, getLocation(tree, relPath),
true);
         if (property != null) {
-            NamePathMapper npMapper = userManager.getNamePathMapper();
+            NamePathMapper npMapper = authorizable.getUserManager().getNamePathMapper();
             if (property.isArray()) {
                 List<Value> vs = ValueFactoryImpl.createValues(property, npMapper);
                 values = vs.toArray(new Value[vs.size()]);
@@ -184,7 +179,7 @@ class AuthorizablePropertiesImpl impleme
     //------------------------------------------------------------< private >---
     @Nonnull
     private Tree getTree() {
-        return userManager.getAuthorizableTree(id);
+        return authorizable.getTree();
     }
 
     /**
@@ -243,6 +238,7 @@ class AuthorizablePropertiesImpl impleme
             log.debug("Unable to determine definition of authorizable property at " + propertyLocation.getPath());
             return null;
         }
+        ReadOnlyNodeTypeManager nodeTypeManager = authorizable.getUserManager().getNodeTypeManager();
         PropertyDefinition def = nodeTypeManager.getDefinition(parent, property, true);
         if (def.isProtected() || (authorizablePath.equals(parent.getPath())
                 && !def.getDeclaringNodeType().isNodeType(UserConstants.NT_REP_AUTHORIZABLE)))
{
@@ -253,8 +249,8 @@ class AuthorizablePropertiesImpl impleme
     }
 
     private void checkProtectedProperty(Tree parent, PropertyState property) throws RepositoryException
{
-        PropertyDefinition def =
-                nodeTypeManager.getDefinition(parent, property, false);
+        ReadOnlyNodeTypeManager nodeTypeManager = authorizable.getUserManager().getNodeTypeManager();
+        PropertyDefinition def = nodeTypeManager.getDefinition(parent, property, false);
         if (def.isProtected()) {
             throw new ConstraintViolationException(
                     "Attempt to set an protected property " + property.getName());

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=1463483&r1=1463482&r2=1463483&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 Apr  2 11:07:29 2013
@@ -71,6 +71,7 @@ public class UserManagerImpl implements 
     private final List<AuthorizableAction> authorizableActions;
 
     private UserQueryManager queryManager;
+    private ReadOnlyNodeTypeManager ntMgr;
 
     public UserManagerImpl(Root root, NamePathMapper namePathMapper, SecurityProvider securityProvider)
{
         this.root = root;
@@ -278,15 +279,6 @@ public class UserManagerImpl implements 
     }
 
     //--------------------------------------------------------------------------
-    @Nonnull
-    Tree getAuthorizableTree(String id) {
-        Tree tree = userProvider.getAuthorizable(id);
-        if (tree == null) {
-            throw new IllegalStateException("Authorizable not associated with an existing
tree (WAITING FOR OAK-343 TO BE FIXED)");
-        }
-        return tree;
-    }
-
     @CheckForNull
     Authorizable getAuthorizable(Tree tree) throws RepositoryException {
         if (tree == null) {
@@ -296,13 +288,16 @@ public class UserManagerImpl implements 
     }
 
     @Nonnull
-    AuthorizableProperties getAuthorizableProperties(String id) throws RepositoryException
{
-        return new AuthorizablePropertiesImpl(id, this, ReadOnlyNodeTypeManager.getInstance(root,
NamePathMapper.DEFAULT));
+    NamePathMapper getNamePathMapper() {
+        return namePathMapper;
     }
 
     @Nonnull
-    NamePathMapper getNamePathMapper() {
-        return namePathMapper;
+    ReadOnlyNodeTypeManager getNodeTypeManager() {
+        if (ntMgr == null) {
+            ntMgr = ReadOnlyNodeTypeManager.getInstance(root, NamePathMapper.DEFAULT);
+        }
+        return ntMgr;
     }
 
     @Nonnull



Mime
View raw message