[java-opensaml COMMIT] in /trunk/opensaml-storage-impl/src: main/java/org/opensaml/storage/impl/client/PopulateClient...

noreply at shibboleth.net noreply at shibboleth.net
Fri Aug 14 14:48:15 EDT 2015


Author: scantor
Date: Fri Aug 14 14:48:15 2015
New Revision: 4322

URL: http://svn.shibboleth.net/view/java-opensaml?rev=4322&view=rev
Log:
IDP-594 - Adjust load-prep action to signal when no load required.

Modified:
    trunk/opensaml-storage-impl/src/main/java/org/opensaml/storage/impl/client/PopulateClientStorageLoadContext.java
    trunk/opensaml-storage-impl/src/test/java/org/opensaml/storage/impl/client/PopulateClientStorageLoadContextTest.java

Modified: trunk/opensaml-storage-impl/src/main/java/org/opensaml/storage/impl/client/PopulateClientStorageLoadContext.java
URL: http://svn.shibboleth.net/view/java-opensaml/trunk/opensaml-storage-impl/src/main/java/org/opensaml/storage/impl/client/PopulateClientStorageLoadContext.java?rev=4322&r1=4321&r2=4322&view=diff
==============================================================================
--- trunk/opensaml-storage-impl/src/main/java/org/opensaml/storage/impl/client/PopulateClientStorageLoadContext.java	(original)
+++ trunk/opensaml-storage-impl/src/main/java/org/opensaml/storage/impl/client/PopulateClientStorageLoadContext.java	Fri Aug 14 14:48:15 2015
@@ -24,6 +24,7 @@
 import javax.annotation.Nonnull;
 
 import org.opensaml.profile.action.AbstractProfileAction;
+import org.opensaml.profile.action.ActionSupport;
 import org.opensaml.profile.context.ProfileRequestContext;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
@@ -32,6 +33,7 @@
 import com.google.common.collect.Collections2;
 
 import net.shibboleth.utilities.java.support.annotation.constraint.NonnullElements;
+import net.shibboleth.utilities.java.support.annotation.constraint.NotEmpty;
 import net.shibboleth.utilities.java.support.component.ComponentSupport;
 import net.shibboleth.utilities.java.support.logic.Constraint;
 
@@ -39,7 +41,11 @@
  * An action that creates and populates a {@link ClientStorageLoadContext} with any storage keys identified
  * as missing from the current session and in need of loading.
  * 
+ * <p>The action will signal the {@link #LOAD_NOT_NEEDED} event if it is unnecessary to proceed with the
+ * load operation.</p>
+ * 
  * @event {@link org.opensaml.profile.action.EventIds#PROCEED_EVENT_ID}
+ * @event {@link #LOAD_NOT_NEEDED}
  * @post <pre>ProfileRequestContext.getSubcontext(ClientStorageLoadContext.class) != null</pre>
  * 
  * @param <InboundMessageType>
@@ -48,6 +54,9 @@
 public class PopulateClientStorageLoadContext<InboundMessageType, OutboundMessageType>
         extends AbstractProfileAction<InboundMessageType, OutboundMessageType> {
 
+    /** Event signaling that no load step is necessary. */
+    @Nonnull @NotEmpty public static final String LOAD_NOT_NEEDED = "LoadNotNeeded";
+    
     /** Class logger. */
     @Nonnull private final Logger log = LoggerFactory.getLogger(PopulateClientStorageLoadContext.class);
 
@@ -76,11 +85,13 @@
             @Nonnull final ProfileRequestContext<InboundMessageType, OutboundMessageType> profileRequestContext) {
         
         if (!super.doPreExecute(profileRequestContext)) {
+            ActionSupport.buildEvent(profileRequestContext, LOAD_NOT_NEEDED);
             return false;
         }
         
         if (storageServices.isEmpty()) {
             log.debug("{} No ClientStorageServices supplied, nothing to do", getLogPrefix());
+            ActionSupport.buildEvent(profileRequestContext, LOAD_NOT_NEEDED);
             return false;
         }
         
@@ -92,7 +103,6 @@
             @Nonnull final ProfileRequestContext<InboundMessageType, OutboundMessageType> profileRequestContext) {
         
         final ClientStorageLoadContext loadCtx = new ClientStorageLoadContext();
-        profileRequestContext.addSubcontext(loadCtx, true);
         
         for (final ClientStorageService service : storageServices) {
             
@@ -100,6 +110,12 @@
                 loadCtx.getStorageKeys().add(service.getStorageName());
             }
         }
+        
+        if (loadCtx.getStorageKeys().isEmpty()) {
+            ActionSupport.buildEvent(profileRequestContext, LOAD_NOT_NEEDED);
+        } else {
+            profileRequestContext.addSubcontext(loadCtx, true);
+        }
     }
 
 }

Modified: trunk/opensaml-storage-impl/src/test/java/org/opensaml/storage/impl/client/PopulateClientStorageLoadContextTest.java
URL: http://svn.shibboleth.net/view/java-opensaml/trunk/opensaml-storage-impl/src/test/java/org/opensaml/storage/impl/client/PopulateClientStorageLoadContextTest.java?rev=4322&r1=4321&r2=4322&view=diff
==============================================================================
--- trunk/opensaml-storage-impl/src/test/java/org/opensaml/storage/impl/client/PopulateClientStorageLoadContextTest.java	(original)
+++ trunk/opensaml-storage-impl/src/test/java/org/opensaml/storage/impl/client/PopulateClientStorageLoadContextTest.java	Fri Aug 14 14:48:15 2015
@@ -67,7 +67,7 @@
         action.initialize();
         
         action.execute(prc);
-        ActionTestingSupport.assertProceedEvent(prc);
+        ActionTestingSupport.assertEvent(prc, PopulateClientStorageLoadContext.LOAD_NOT_NEEDED);

[... 18 lines stripped ...]


More information about the commits mailing list