[exo-jcr-commits] exo-jcr SVN: r4692 - jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/core/query/lucene.
do-not-reply at jboss.org
do-not-reply at jboss.org
Wed Aug 3 04:00:54 EDT 2011
Author: nzamosenchuk
Date: 2011-08-03 04:00:53 -0400 (Wed, 03 Aug 2011)
New Revision: 4692
Modified:
jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/core/query/lucene/QueryResultImpl.java
Log:
EXOJCR-1389 : access granted check rewritten in a lazy manner.
Modified: jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/core/query/lucene/QueryResultImpl.java
===================================================================
--- jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/core/query/lucene/QueryResultImpl.java 2011-08-02 13:01:46 UTC (rev 4691)
+++ jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/core/query/lucene/QueryResultImpl.java 2011-08-03 08:00:53 UTC (rev 4692)
@@ -141,7 +141,7 @@
* The maximum size of this result if limit > 0
*/
private final long limit;
-
+
/**
* If <code>true</code>, it means we're using a System session.
*/
@@ -323,7 +323,7 @@
result = executeQuery(maxResultSize);
if (log.isDebugEnabled())
{
- log.debug("query executed in {} ms", new Long(System.currentTimeMillis() - time));
+ log.debug("query executed in {} ms", new Long(System.currentTimeMillis() - time));
}
// set selector names
selectorNames = result.getSelectorNames();
@@ -341,12 +341,12 @@
if (log.isDebugEnabled())
{
- time = System.currentTimeMillis();
+ time = System.currentTimeMillis();
}
collectScoreNodes(result, resultNodes, maxResultSize);
if (log.isDebugEnabled())
{
- log.debug("retrieved ScoreNodes in {} ms", new Long(System.currentTimeMillis() - time));
+ log.debug("retrieved ScoreNodes in {} ms", new Long(System.currentTimeMillis() - time));
}
// update numResults
@@ -400,7 +400,7 @@
break;
}
// check access
- if (isAccessGranted(sn))
+ if (!docOrder || isAccessGranted(sn))
{
collector.add(sn);
}
@@ -511,25 +511,16 @@
else
{
// attempt to get enough results
- try
+ long expectedPosition = position + skipNum;
+ while (position < expectedPosition)
{
- getResults(position + invalid + (int)skipNum);
- if (resultNodes.size() >= position + skipNum)
+ fetchNext();
+ if (next == null)
{
- // skip within already fetched results
- position += skipNum - 1;
- fetchNext();
- }
- else
- {
// not enough results after getResults()
throw new NoSuchElementException();
}
}
- catch (RepositoryException e)
- {
- throw new NoSuchElementException(e.getMessage());
- }
}
}
@@ -676,6 +667,25 @@
}
}
next = (ScoreNode[])resultNodes.get(nextPos);
+ try
+ {
+ if (!isAccessGranted(next))
+ {
+ next = null;
+ invalid++;
+ resultNodes.remove(nextPos);
+ if (log.isDebugEnabled())
+ {
+ log
+ .debug("The node is invalid since we don't have sufficient rights to access it, it will be removed from the results set");
+ }
+ }
+ }
+ catch (RepositoryException e)
+ {
+ log.error("Could not check access permission", e);
+ break;
+ }
}
position++;
}
More information about the exo-jcr-commits
mailing list