jackrabbit-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ju...@apache.org
Subject svn commit: r1043545 - in /jackrabbit/branches/2.2: ./ jackrabbit-core/src/main/java/org/apache/jackrabbit/core/security/user/
Date Wed, 08 Dec 2010 17:44:36 GMT
Author: jukka
Date: Wed Dec  8 17:44:35 2010
New Revision: 1043545

URL: http://svn.apache.org/viewvc?rev=1043545&view=rev
Log:
2.2: Merged trunk revisions

Modified:
    jackrabbit/branches/2.2/   (props changed)
    jackrabbit/branches/2.2/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/security/user/UserImpl.java
    jackrabbit/branches/2.2/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/security/user/UserImporter.java
    jackrabbit/branches/2.2/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/security/user/UserManagerImpl.java
    jackrabbit/branches/2.2/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/security/user/XPathQueryBuilder.java
    jackrabbit/branches/2.2/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/security/user/XPathQueryEvaluator.java

Propchange: jackrabbit/branches/2.2/
------------------------------------------------------------------------------
--- svn:mergeinfo (original)
+++ svn:mergeinfo Wed Dec  8 17:44:35 2010
@@ -2,4 +2,4 @@
 /jackrabbit/sandbox/JCR-1456:774917-886178
 /jackrabbit/sandbox/JCR-2170:812417-816332
 /jackrabbit/sandbox/tripod-JCR-2209:795441-795863
-/jackrabbit/trunk:1038201,1038203,1038205,1038657,1039064,1039347,1039408,1039422-1039423,1039888,1039946,1040033,1040090,1040459,1040601,1040606,1040661,1040958,1041379,1041439,1041761,1042643,1042647,1042978-1042982
+/jackrabbit/trunk:1038201,1038203,1038205,1038657,1039064,1039347,1039408,1039422-1039423,1039888,1039946,1040033,1040090,1040459,1040601,1040606,1040661,1040958,1041379,1041439,1041761,1042643,1042647,1042978-1042982,1043084-1043086,1043088

Modified: jackrabbit/branches/2.2/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/security/user/UserImpl.java
URL: http://svn.apache.org/viewvc/jackrabbit/branches/2.2/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/security/user/UserImpl.java?rev=1043545&r1=1043544&r2=1043545&view=diff
==============================================================================
--- jackrabbit/branches/2.2/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/security/user/UserImpl.java
(original)
+++ jackrabbit/branches/2.2/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/security/user/UserImpl.java
Wed Dec  8 17:44:35 2010
@@ -61,7 +61,29 @@ public class UserImpl extends Authorizab
         }
     }
 
-    //------------------------------------------------< User >------------------
+    //-------------------------------------------------------< Authorizable >---
+    /**
+     * @see org.apache.jackrabbit.api.security.user.Authorizable#isGroup()
+     */
+    public boolean isGroup() {
+        return false;
+    }
+
+    /**
+     * @see org.apache.jackrabbit.api.security.user.Authorizable#getPrincipal()
+     */
+    public Principal getPrincipal() throws RepositoryException {
+        if (principal == null) {
+            if (isAdmin()) {
+                principal = new NodeBasedAdminPrincipal(getPrincipalName());
+            } else {
+                principal = new NodeBasedPrincipal(getPrincipalName());
+            }
+        }
+        return principal;
+    }
+
+    //---------------------------------------------------------------< User >---
     /**
      * @see User#isAdmin()
      */
@@ -88,26 +110,6 @@ public class UserImpl extends Authorizab
             throw new RepositoryException(e);
         }
     }
-    /**
-     * @see User#isGroup()
-     */
-    public boolean isGroup() {
-        return false;
-    }
-
-    /**
-     * @see User#getPrincipal()
-     */
-    public Principal getPrincipal() throws RepositoryException {
-        if (principal == null) {
-            if (isAdmin()) {
-                principal = new NodeBasedAdminPrincipal(getPrincipalName());
-            } else {
-                principal = new NodeBasedPrincipal(getPrincipalName());
-            }
-        }
-        return principal;
-    }
 
     /**
      * @see User#getImpersonation()

Modified: jackrabbit/branches/2.2/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/security/user/UserImporter.java
URL: http://svn.apache.org/viewvc/jackrabbit/branches/2.2/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/security/user/UserImporter.java?rev=1043545&r1=1043544&r2=1043545&view=diff
==============================================================================
--- jackrabbit/branches/2.2/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/security/user/UserImporter.java
(original)
+++ jackrabbit/branches/2.2/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/security/user/UserImporter.java
Wed Dec  8 17:44:35 2010
@@ -122,16 +122,15 @@ public class UserImporter implements Pro
 
     private static final Logger log = LoggerFactory.getLogger(UserImporter.class);
 
+    /**
+     * Parameter name for the import behavior configuration option.
+     */
     public static final String PARAM_IMPORT_BEHAVIOR = "importBehavior";
 
     private JackrabbitSession session;
 
     private NamePathResolver resolver;
 
-    private boolean isWorkspaceImport;
-
-    private int uuidBehavior;
-
     private ReferenceChangeTracker referenceTracker;
 
     private UserPerWorkspaceUserManager userManager;
@@ -148,8 +147,6 @@ public class UserImporter implements Pro
 
         this.session = session;
         this.resolver = resolver;
-        this.isWorkspaceImport = isWorkspaceImport;
-        this.uuidBehavior = uuidBehavior;
         this.referenceTracker = referenceTracker;
 
         if (initialized) {
@@ -299,10 +296,9 @@ public class UserImporter implements Pro
                 // since group-members are references to user/groups that potentially
                 // are to be imported later on -> postpone processing to the end.
                 // see -> processRefeferences
-                Value[] vs = protectedPropInfo.getValues(PropertyType.WEAKREFERENCE, resolver);
                 Membership membership = new Membership(a.getID());
-                for (int i = 0; i < vs.length; i++) {
-                    membership.addMember(new NodeId(vs[i].getString()));
+                for (Value v : protectedPropInfo.getValues(PropertyType.WEAKREFERENCE, resolver))
{
+                    membership.addMember(new NodeId(v.getString()));
                 }
                 referenceTracker.processedReference(membership);
                 return true;
@@ -551,10 +547,9 @@ public class UserImporter implements Pro
 
         if (UserConstants.NT_REP_MEMBERS.equals(childInfo.getNodeTypeName())) {
             for (PropInfo prop : propInfos) {
-                Value[] vs = prop.getValues(PropertyType.WEAKREFERENCE, resolver);
-                for (int i = 0; i < vs.length; i++) {
+                for (Value v : prop.getValues(PropertyType.WEAKREFERENCE, resolver)) {
                     String name = resolver.getJCRName(prop.getName());
-                    NodeId id = new NodeId(vs[i].getString());
+                    NodeId id = new NodeId(v.getString());
                     currentMembership.addMember(name, id);
                 }
             }

Modified: jackrabbit/branches/2.2/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/security/user/UserManagerImpl.java
URL: http://svn.apache.org/viewvc/jackrabbit/branches/2.2/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/security/user/UserManagerImpl.java?rev=1043545&r1=1043544&r2=1043545&view=diff
==============================================================================
--- jackrabbit/branches/2.2/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/security/user/UserManagerImpl.java
(original)
+++ jackrabbit/branches/2.2/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/security/user/UserManagerImpl.java
Wed Dec  8 17:44:35 2010
@@ -375,6 +375,18 @@ public class UserManagerImpl extends Pro
      */
     public MembershipCache getMembershipCache() {
         return membershipCache;
+    }  
+
+    /**
+     * Maximum number of properties on the group membership node structure under
+     * {@link UserConstants#N_MEMBERS} until additional intermediate nodes are inserted.
+     * If 0 (default), {@link UserConstants#P_MEMBERS} is used to record group
+     * memberships.
+     *
+     * @return
+     */
+    public int getGroupMembershipSplitSize() {
+        return groupMembershipSplitSize;
     }
 
     //--------------------------------------------------------< UserManager >---
@@ -487,6 +499,9 @@ public class UserManagerImpl extends Pro
         return new AuthorizableIterator(nodes);
     }
 
+    /**
+     * @see UserManager#findAuthorizables(Query)
+     */
     public Iterator<Authorizable> findAuthorizables(Query query) throws RepositoryException
{
         XPathQueryBuilder builder = new XPathQueryBuilder();
         query.build(builder);
@@ -633,18 +648,6 @@ public class UserManagerImpl extends Pro
         throw new UnsupportedRepositoryOperationException("Cannot change autosave behavior.");
     }
 
-    /**
-     * Maximum number of properties on the group membership node structure under
-     * {@link UserConstants#N_MEMBERS} until additional intermediate nodes are inserted.
-     * If 0 (default), {@link UserConstants#P_MEMBERS} is used to record group
-     * memberships.
-     *
-     * @return
-     */
-    public int getGroupMembershipSplitSize() {
-        return groupMembershipSplitSize;
-    }
-
     //--------------------------------------------------------------------------
     /**
      *

Modified: jackrabbit/branches/2.2/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/security/user/XPathQueryBuilder.java
URL: http://svn.apache.org/viewvc/jackrabbit/branches/2.2/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/security/user/XPathQueryBuilder.java?rev=1043545&r1=1043544&r2=1043545&view=diff
==============================================================================
--- jackrabbit/branches/2.2/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/security/user/XPathQueryBuilder.java
(original)
+++ jackrabbit/branches/2.2/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/security/user/XPathQueryBuilder.java
Wed Dec  8 17:44:35 2010
@@ -53,18 +53,24 @@ public class XPathQueryBuilder implement
             return op;
         }
     }
-    
+
     interface Condition {
         void accept(ConditionVisitor visitor) throws RepositoryException;
     }
 
     interface ConditionVisitor {
         void visit(NodeCondition nodeCondition) throws RepositoryException;
+
         void visit(PropertyCondition condition) throws RepositoryException;
+
         void visit(ContainsCondition condition);
+
         void visit(ImpersonationCondition condition);
+
         void visit(NotCondition condition) throws RepositoryException;
+
         void visit(AndCondition condition) throws RepositoryException;
+
         void visit(OrCondition condition) throws RepositoryException;
     }
 
@@ -89,7 +95,7 @@ public class XPathQueryBuilder implement
     public boolean isDeclaredMembersOnly() {
         return declaredMembersOnly;
     }
-    
+
     Condition getCondition() {
         return condition;
     }
@@ -113,7 +119,7 @@ public class XPathQueryBuilder implement
     long getMaxCount() {
         return maxCount;
     }
-    
+
     //------------------------------------------< QueryBuilder >---
 
     public void setSelector(Class<? extends Authorizable> selector) {
@@ -166,7 +172,7 @@ public class XPathQueryBuilder implement
         return new PropertyCondition(relPath, RelationOp.LT, value);
     }
 
-    public Condition le(String relPath, Value value){
+    public Condition le(String relPath, Value value) {
         return new PropertyCondition(relPath, RelationOp.LE, value);
     }
 

Modified: jackrabbit/branches/2.2/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/security/user/XPathQueryEvaluator.java
URL: http://svn.apache.org/viewvc/jackrabbit/branches/2.2/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/security/user/XPathQueryEvaluator.java?rev=1043545&r1=1043544&r2=1043545&view=diff
==============================================================================
--- jackrabbit/branches/2.2/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/security/user/XPathQueryEvaluator.java
(original)
+++ jackrabbit/branches/2.2/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/security/user/XPathQueryEvaluator.java
Wed Dec  8 17:44:35 2010
@@ -43,7 +43,7 @@ import java.util.Iterator;
 
 /**
  * This evaluator for {@link org.apache.jackrabbit.api.security.user.Query}s use XPath
- * and some minimal client side filtering.  
+ * and some minimal client side filtering.
  */
 public class XPathQueryEvaluator implements XPathQueryBuilder.ConditionVisitor {
     static final Logger log = LoggerFactory.getLogger(XPathQueryEvaluator.class);
@@ -61,8 +61,8 @@ public class XPathQueryEvaluator impleme
 
     public Iterator<Authorizable> eval() throws RepositoryException {
         xPath.append("//element(*,")
-             .append(getNtName(builder.getSelector()))
-             .append(')');
+                .append(getNtName(builder.getSelector()))
+                .append(')');
 
         Value bound = builder.getBound();
         long offset = builder.getOffset();
@@ -77,10 +77,9 @@ public class XPathQueryEvaluator impleme
         if (bound != null) {
             if (sortCol == null) {
                 log.warn("Ignoring bound {} since no sort order is specified");
-            }
-            else {
+            } else {
                 Condition boundCondition = builder.property(sortCol, getCollation(sortDir),
bound);
-                condition = condition == null 
+                condition = condition == null
                         ? boundCondition
                         : builder.and(condition, boundCondition);
             }
@@ -94,9 +93,9 @@ public class XPathQueryEvaluator impleme
 
         if (sortCol != null) {
             xPath.append(" order by ")
-                 .append(sortCol)
-                 .append(' ')
-                 .append(sortDir.getDirection());
+                    .append(sortCol)
+                    .append(' ')
+                    .append(sortDir.getDirection());
         }
 
         QueryManager queryManager = session.getWorkspace().getQueryManager();
@@ -117,8 +116,7 @@ public class XPathQueryEvaluator impleme
                 query.setOffset(offset);
             }
             return toAuthorizables(execute(query));
-        }
-        else {
+        } else {
             Iterator<Authorizable> result = filter(toAuthorizables(execute(query)),
builder.getGroupName(), builder.isDeclaredMembersOnly());
             for (int c = 0; c < offset && result.hasNext(); c++) {
                 result.next();
@@ -133,49 +131,47 @@ public class XPathQueryEvaluator impleme
         String repPrincipal = session.getJCRName(UserConstants.P_PRINCIPAL_NAME);
 
         xPath.append('(')
-             .append("jcr:like(")
-             .append(repPrincipal)
-             .append(",'")
-             .append(condition.getPattern())
-             .append("')")
-             .append(" or ")
-             .append("jcr:like(fn:name(.),'")
-             .append(escape(condition.getPattern()))
-             .append("')")
-             .append(')');
+                .append("jcr:like(")
+                .append(repPrincipal)
+                .append(",'")
+                .append(condition.getPattern())
+                .append("')")
+                .append(" or ")
+                .append("jcr:like(fn:name(.),'")
+                .append(escape(condition.getPattern()))
+                .append("')")
+                .append(')');
     }
 
     public void visit(XPathQueryBuilder.PropertyCondition condition) throws RepositoryException
{
         RelationOp relOp = condition.getOp();
         if (relOp == RelationOp.EX) {
             xPath.append(condition.getRelPath());
-        }
-        else if (relOp == RelationOp.LIKE) {
+        } else if (relOp == RelationOp.LIKE) {
             xPath.append("jcr:like(")
-                 .append(condition.getRelPath())
-                 .append(",'")
-                 .append(condition.getPattern())
-                 .append("')");
-        }
-        else {
+                    .append(condition.getRelPath())
+                    .append(",'")
+                    .append(condition.getPattern())
+                    .append("')");
+        } else {
             xPath.append(condition.getRelPath())
-                 .append(condition.getOp().getOp())
-                 .append(format(condition.getValue()));
+                    .append(condition.getOp().getOp())
+                    .append(format(condition.getValue()));
         }
     }
 
     public void visit(XPathQueryBuilder.ContainsCondition condition) {
         xPath.append("jcr:contains(")
-             .append(condition.getRelPath())
-             .append(",'")
-             .append(condition.getSearchExpr())
-             .append("')");
+                .append(condition.getRelPath())
+                .append(",'")
+                .append(condition.getSearchExpr())
+                .append("')");
     }
 
     public void visit(XPathQueryBuilder.ImpersonationCondition condition) {
         xPath.append("@rep:impersonators='")
-             .append(condition.getName())
-             .append('\'');
+                .append(condition.getName())
+                .append('\'');
     }
 
     public void visit(XPathQueryBuilder.NotCondition condition) throws RepositoryException
{
@@ -212,8 +208,9 @@ public class XPathQueryEvaluator impleme
 
     /**
      * Escape <code>string</code> for matching in jcr escaped node names
-     * @param string  string to escape
-     * @return  escaped string
+     *
+     * @param string string to escape
+     * @return escaped string
      */
     public static String escape(String string) {
         StringBuilder result = new StringBuilder();
@@ -225,12 +222,10 @@ public class XPathQueryEvaluator impleme
             if (j < 0) {
                 // jcr escape trail
                 result.append(Text.escapeIllegalJcrChars(string.substring(k)));
-            }
-            else if (j > 0 && string.charAt(j - 1) == '\\') {
+            } else if (j > 0 && string.charAt(j - 1) == '\\') {
                 // literal occurrence of % -> jcr escape
                 result.append(Text.escapeIllegalJcrChars(string.substring(k, j) + '%'));
-            }
-            else {
+            } else {
                 // wildcard occurrence of % -> jcr escape all but %
                 result.append(Text.escapeIllegalJcrChars(string.substring(k, j))).append('%');
             }
@@ -244,11 +239,9 @@ public class XPathQueryEvaluator impleme
     private String getNtName(Class<? extends Authorizable> selector) throws RepositoryException
{
         if (User.class.isAssignableFrom(selector)) {
             return session.getJCRName(UserConstants.NT_REP_USER);
-        }
-        else if (Group.class.isAssignableFrom(selector)) {
+        } else if (Group.class.isAssignableFrom(selector)) {
             return session.getJCRName(UserConstants.NT_REP_GROUP);
-        }
-        else {
+        } else {
             return session.getJCRName(UserConstants.NT_REP_AUTHORIZABLE);
         }
     }
@@ -313,8 +306,7 @@ public class XPathQueryEvaluator impleme
         Authorizable groupAuth = userManager.getAuthorizable(groupName);
         if (groupAuth == null || !groupAuth.isGroup()) {
             predicate = Predicates.FALSE();
-        }
-        else {
+        } else {
             final Group group = (Group) groupAuth;
             if (declaredMembersOnly) {
                 predicate = new Predicate<Authorizable>() {
@@ -329,8 +321,7 @@ public class XPathQueryEvaluator impleme
                     }
                 };
 
-            }
-            else {
+            } else {
                 predicate = new Predicate<Authorizable>() {
                     public boolean evaluate(Authorizable authorizable) {
                         try {



Mime
View raw message