incubator-sling-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From jus...@apache.org
Subject svn commit: r1179422 - in /sling/trunk/bundles/servlets/post/src/main/java/org/apache/sling/servlets/post: AbstractPostOperation.java SlingPostConstants.java
Date Wed, 05 Oct 2011 20:29:13 GMT
Author: justin
Date: Wed Oct  5 20:29:13 2011
New Revision: 1179422

URL: http://svn.apache.org/viewvc?rev=1179422&view=rev
Log:
SLING-2227 - applying tweaked version of patch from Markus Joschko which stops a post operation
from saving the session if the request attribute skip-session-handling is true. package export
already bumped to 2.1.0 in a prior change.

Modified:
    sling/trunk/bundles/servlets/post/src/main/java/org/apache/sling/servlets/post/AbstractPostOperation.java
    sling/trunk/bundles/servlets/post/src/main/java/org/apache/sling/servlets/post/SlingPostConstants.java

Modified: sling/trunk/bundles/servlets/post/src/main/java/org/apache/sling/servlets/post/AbstractPostOperation.java
URL: http://svn.apache.org/viewvc/sling/trunk/bundles/servlets/post/src/main/java/org/apache/sling/servlets/post/AbstractPostOperation.java?rev=1179422&r1=1179421&r2=1179422&view=diff
==============================================================================
--- sling/trunk/bundles/servlets/post/src/main/java/org/apache/sling/servlets/post/AbstractPostOperation.java
(original)
+++ sling/trunk/bundles/servlets/post/src/main/java/org/apache/sling/servlets/post/AbstractPostOperation.java
Wed Oct  5 20:29:13 2011
@@ -124,7 +124,8 @@ public abstract class AbstractPostOperat
                         break;
                 }
             }
-            if (session.hasPendingChanges()) {
+
+            if (isSessionSaveRequired(session, request)) {
                 session.save();
             }
 
@@ -144,7 +145,7 @@ public abstract class AbstractPostOperat
 
         } finally {
             try {
-                if (session.hasPendingChanges()) {
+                if (isSessionSaveRequired(session, request)) {
                     session.refresh(false);
                 }
             } catch (RepositoryException e) {
@@ -188,6 +189,15 @@ public abstract class AbstractPostOperat
         return !getVersioningConfiguration(request).isAutoCheckin();
     }
 
+    protected boolean isSkipSessionHandling(SlingHttpServletRequest request) {
+        return Boolean.parseBoolean((String) request.getAttribute(SlingPostConstants.ATTR_SKIP_SESSION_HANDLING))
== true;
+    }
+
+    protected boolean isSessionSaveRequired(Session session, SlingHttpServletRequest request)
+            throws RepositoryException {
+        return !isSkipSessionHandling(request) && session.hasPendingChanges();
+    }
+
     /**
      * Remove the workspace name, if any, from the start of the path and validate that the
      * session's workspace name matches the path workspace name.

Modified: sling/trunk/bundles/servlets/post/src/main/java/org/apache/sling/servlets/post/SlingPostConstants.java
URL: http://svn.apache.org/viewvc/sling/trunk/bundles/servlets/post/src/main/java/org/apache/sling/servlets/post/SlingPostConstants.java?rev=1179422&r1=1179421&r2=1179422&view=diff
==============================================================================
--- sling/trunk/bundles/servlets/post/src/main/java/org/apache/sling/servlets/post/SlingPostConstants.java
(original)
+++ sling/trunk/bundles/servlets/post/src/main/java/org/apache/sling/servlets/post/SlingPostConstants.java
Wed Oct  5 20:29:13 2011
@@ -465,4 +465,12 @@ public interface SlingPostConstants {
      */
     public static final String RP_CHECKIN = RP_PREFIX + "checkin";
 
+    /**
+     * Name of the request attribute (not parameter) indicating that a post operation
+     * should not invoke session.save() upon completion.
+     * 
+     * @since 2.1.2
+     */
+    public static final String ATTR_SKIP_SESSION_HANDLING = "skip-session-handling";
+
 }



Mime
View raw message