sling-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From cziege...@apache.org
Subject svn commit: r1711079 - in /sling/trunk/bundles/resourceresolver/src/main/java/org/apache/sling/resourceresolver/impl: ./ providers/stateful/
Date Wed, 28 Oct 2015 17:37:28 GMT
Author: cziegeler
Date: Wed Oct 28 17:37:28 2015
New Revision: 1711079

URL: http://svn.apache.org/viewvc?rev=1711079&view=rev
Log:
SLING-5208 : Correctly handle LoginException from ResourceProviders

Added:
    sling/trunk/bundles/resourceresolver/src/main/java/org/apache/sling/resourceresolver/impl/providers/stateful/BasicResolveContext.java
      - copied, changed from r1711010, sling/trunk/bundles/resourceresolver/src/main/java/org/apache/sling/resourceresolver/impl/BasicResolveContext.java
Removed:
    sling/trunk/bundles/resourceresolver/src/main/java/org/apache/sling/resourceresolver/impl/BasicResolveContext.java
Modified:
    sling/trunk/bundles/resourceresolver/src/main/java/org/apache/sling/resourceresolver/impl/providers/stateful/AuthenticatedResourceProvider.java
    sling/trunk/bundles/resourceresolver/src/main/java/org/apache/sling/resourceresolver/impl/providers/stateful/ResourceProviderAuthenticator.java

Modified: sling/trunk/bundles/resourceresolver/src/main/java/org/apache/sling/resourceresolver/impl/providers/stateful/AuthenticatedResourceProvider.java
URL: http://svn.apache.org/viewvc/sling/trunk/bundles/resourceresolver/src/main/java/org/apache/sling/resourceresolver/impl/providers/stateful/AuthenticatedResourceProvider.java?rev=1711079&r1=1711078&r2=1711079&view=diff
==============================================================================
--- sling/trunk/bundles/resourceresolver/src/main/java/org/apache/sling/resourceresolver/impl/providers/stateful/AuthenticatedResourceProvider.java
(original)
+++ sling/trunk/bundles/resourceresolver/src/main/java/org/apache/sling/resourceresolver/impl/providers/stateful/AuthenticatedResourceProvider.java
Wed Oct 28 17:37:28 2015
@@ -34,7 +34,6 @@ import org.apache.sling.api.resource.Res
 import org.apache.sling.api.resource.query.Query;
 import org.apache.sling.api.resource.query.QueryInstructions;
 import org.apache.sling.api.resource.runtime.dto.AuthType;
-import org.apache.sling.resourceresolver.impl.BasicResolveContext;
 import org.apache.sling.resourceresolver.impl.providers.ResourceProviderInfo;
 import org.apache.sling.spi.resource.provider.JCRQueryProvider;
 import org.apache.sling.spi.resource.provider.QueryProvider;

Copied: sling/trunk/bundles/resourceresolver/src/main/java/org/apache/sling/resourceresolver/impl/providers/stateful/BasicResolveContext.java
(from r1711010, sling/trunk/bundles/resourceresolver/src/main/java/org/apache/sling/resourceresolver/impl/BasicResolveContext.java)
URL: http://svn.apache.org/viewvc/sling/trunk/bundles/resourceresolver/src/main/java/org/apache/sling/resourceresolver/impl/providers/stateful/BasicResolveContext.java?p2=sling/trunk/bundles/resourceresolver/src/main/java/org/apache/sling/resourceresolver/impl/providers/stateful/BasicResolveContext.java&p1=sling/trunk/bundles/resourceresolver/src/main/java/org/apache/sling/resourceresolver/impl/BasicResolveContext.java&r1=1711010&r2=1711079&rev=1711079&view=diff
==============================================================================
--- sling/trunk/bundles/resourceresolver/src/main/java/org/apache/sling/resourceresolver/impl/BasicResolveContext.java
(original)
+++ sling/trunk/bundles/resourceresolver/src/main/java/org/apache/sling/resourceresolver/impl/providers/stateful/BasicResolveContext.java
Wed Oct 28 17:37:28 2015
@@ -16,19 +16,16 @@
  * specific language governing permissions and limitations
  * under the License.
  */
-package org.apache.sling.resourceresolver.impl;
+package org.apache.sling.resourceresolver.impl.providers.stateful;
 
 import org.apache.sling.api.resource.LoginException;
 import org.apache.sling.api.resource.ResourceResolver;
 import org.apache.sling.api.resource.ResourceUtil;
 import org.apache.sling.resourceresolver.impl.providers.ResourceProviderHandler;
 import org.apache.sling.resourceresolver.impl.providers.ResourceProviderStorage;
-import org.apache.sling.resourceresolver.impl.providers.stateful.CombinedResourceProvider;
-import org.apache.sling.resourceresolver.impl.providers.stateful.StatefulResourceProvider;
 import org.apache.sling.spi.resource.provider.ResolverContext;
 import org.apache.sling.spi.resource.provider.ResourceProvider;
 
-// TODO - we should move this to the providers.stateful package
 public class BasicResolveContext<T> implements ResolverContext<T> {
 
     private final String parentPath;
@@ -41,7 +38,7 @@ public class BasicResolveContext<T> impl
 
     private volatile boolean parentLookupDone = false;
 
-    private volatile ResourceProvider parentProvider;
+    private volatile ResourceProvider<Object> parentProvider;
 
     private volatile ResolverContext<Object> parentResolveContext;
 

Modified: sling/trunk/bundles/resourceresolver/src/main/java/org/apache/sling/resourceresolver/impl/providers/stateful/ResourceProviderAuthenticator.java
URL: http://svn.apache.org/viewvc/sling/trunk/bundles/resourceresolver/src/main/java/org/apache/sling/resourceresolver/impl/providers/stateful/ResourceProviderAuthenticator.java?rev=1711079&r1=1711078&r2=1711079&view=diff
==============================================================================
--- sling/trunk/bundles/resourceresolver/src/main/java/org/apache/sling/resourceresolver/impl/providers/stateful/ResourceProviderAuthenticator.java
(original)
+++ sling/trunk/bundles/resourceresolver/src/main/java/org/apache/sling/resourceresolver/impl/providers/stateful/ResourceProviderAuthenticator.java
Wed Oct 28 17:37:28 2015
@@ -63,9 +63,26 @@ public class ResourceProviderAuthenticat
         this.securityTracker = securityTracker;
     }
 
-    public void authenticateAll(List<ResourceProviderHandler> handlers, CombinedResourceProvider
combinedProvider) throws LoginException {
-        for (ResourceProviderHandler h : handlers) {
-            authenticate(h, combinedProvider);
+    /**
+     * Authenticate all handlers
+     * @param handlers
+     * @param combinedProvider
+     * @throws LoginException
+     */
+    public void authenticateAll(final List<ResourceProviderHandler> handlers,
+                                final CombinedResourceProvider combinedProvider)
+    throws LoginException {
+        final List<StatefulResourceProvider> successfulHandlers = new ArrayList<StatefulResourceProvider>();
+        for (final ResourceProviderHandler h : handlers) {
+            try {
+                successfulHandlers.add(authenticate(h, combinedProvider));
+            } catch ( final LoginException le ) {
+                // logout from all successful handlers
+                for(final StatefulResourceProvider handler : successfulHandlers) {
+                    handler.logout();
+                }
+                throw le;
+            }
         }
     }
 



Mime
View raw message