jackrabbit-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ang...@apache.org
Subject svn commit: r1043088 - in /jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/security/user: XPathQueryBuilder.java XPathQueryEvaluator.java
Date Tue, 07 Dec 2010 15:11:58 GMT
Author: angela
Date: Tue Dec  7 15:11:57 2010
New Revision: 1043088

URL: http://svn.apache.org/viewvc?rev=1043088&view=rev
Log:
fix indention and spaces

Modified:
    jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/security/user/XPathQueryBuilder.java
    jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/security/user/XPathQueryEvaluator.java

Modified: jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/security/user/XPathQueryBuilder.java
URL: http://svn.apache.org/viewvc/jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/security/user/XPathQueryBuilder.java?rev=1043088&r1=1043087&r2=1043088&view=diff
==============================================================================
--- jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/security/user/XPathQueryBuilder.java
(original)
+++ jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/security/user/XPathQueryBuilder.java
Tue Dec  7 15:11:57 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/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/security/user/XPathQueryEvaluator.java
URL: http://svn.apache.org/viewvc/jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/security/user/XPathQueryEvaluator.java?rev=1043088&r1=1043087&r2=1043088&view=diff
==============================================================================
--- jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/security/user/XPathQueryEvaluator.java
(original)
+++ jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/security/user/XPathQueryEvaluator.java
Tue Dec  7 15:11:57 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