incubator-sling-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From jus...@apache.org
Subject svn commit: r950103 - /sling/trunk/bundles/jcr/resource/src/main/java/org/apache/sling/jcr/resource/internal/JcrResourceResolver.java
Date Tue, 01 Jun 2010 15:12:32 GMT
Author: justin
Date: Tue Jun  1 15:12:31 2010
New Revision: 950103

URL: http://svn.apache.org/viewvc?rev=950103&view=rev
Log:
SLING-1447 - if resolve is called with a request which specifies a workspace, future requests
to adaptTo(Session.class) will return a session to the request-specified workspace. also modifying
queryResources to query the request-specified workspace under those conditions

Modified:
    sling/trunk/bundles/jcr/resource/src/main/java/org/apache/sling/jcr/resource/internal/JcrResourceResolver.java

Modified: sling/trunk/bundles/jcr/resource/src/main/java/org/apache/sling/jcr/resource/internal/JcrResourceResolver.java
URL: http://svn.apache.org/viewvc/sling/trunk/bundles/jcr/resource/src/main/java/org/apache/sling/jcr/resource/internal/JcrResourceResolver.java?rev=950103&r1=950102&r2=950103&view=diff
==============================================================================
--- sling/trunk/bundles/jcr/resource/src/main/java/org/apache/sling/jcr/resource/internal/JcrResourceResolver.java
(original)
+++ sling/trunk/bundles/jcr/resource/src/main/java/org/apache/sling/jcr/resource/internal/JcrResourceResolver.java
Tue Jun  1 15:12:31 2010
@@ -104,6 +104,9 @@ public class JcrResourceResolver
     /** Closed marker. */
     private volatile boolean closed = false;
 
+    /** a resolver with the workspace which was specifically requested via a request attribute.
*/
+    private ResourceResolver requestBoundResolver;
+
     public JcrResourceResolver(final JcrResourceProviderEntry rootProvider,
                                final JcrResourceResolverFactoryImpl factory,
                                final boolean isAdmin,
@@ -179,6 +182,7 @@ public class JcrResourceResolver
             LOGGER.debug("Delegating resolving to resolver for workspace {}", workspaceName);
             try {
                 final ResourceResolver wsResolver = getResolverForWorkspace(workspaceName);
+                requestBoundResolver = wsResolver;
                 return wsResolver.resolve(request, absPath);
             } catch (LoginException e) {
                 // requested a resource in a workspace I don't have access to.
@@ -644,7 +648,7 @@ public class JcrResourceResolver
     throws SlingException {
         checkClosed();
         try {
-            QueryResult result = JcrResourceUtil.query(getSession(), query,
+            QueryResult result = JcrResourceUtil.query(adaptTo(Session.class), query,
                 language);
             final String[] colNames = result.getColumnNames();
             final RowIterator rows = result.getRows();
@@ -693,7 +697,11 @@ public class JcrResourceResolver
     public <AdapterType> AdapterType adaptTo(Class<AdapterType> type) {
         checkClosed();
         if (type == Session.class) {
-            return (AdapterType) getSession();
+            if (requestBoundResolver != null) {
+                return (AdapterType) requestBoundResolver.adaptTo(Session.class);
+            } else {
+                return (AdapterType) getSession();
+            }
         }
 
         // fall back to default behaviour



Mime
View raw message