portals-jetspeed-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From a..@apache.org
Subject svn commit: r377039 - /portals/jetspeed-2/trunk/components/portal/src/java/org/apache/jetspeed/profiler/impl/ProfilerValveImpl.java
Date Sat, 11 Feb 2006 20:10:59 GMT
Author: ate
Date: Sat Feb 11 12:10:57 2006
New Revision: 377039

URL: http://svn.apache.org/viewcvs?rev=377039&view=rev
Log:
Creating a PageActionAccess component and storing it in the session is now centralized and
done only by the ProfilerVavle, 
right after the page has been resolved.
See http://issues.apache.org/jira/browse/JS2-468.

Modified:
    portals/jetspeed-2/trunk/components/portal/src/java/org/apache/jetspeed/profiler/impl/ProfilerValveImpl.java

Modified: portals/jetspeed-2/trunk/components/portal/src/java/org/apache/jetspeed/profiler/impl/ProfilerValveImpl.java
URL: http://svn.apache.org/viewcvs/portals/jetspeed-2/trunk/components/portal/src/java/org/apache/jetspeed/profiler/impl/ProfilerValveImpl.java?rev=377039&r1=377038&r2=377039&view=diff
==============================================================================
--- portals/jetspeed-2/trunk/components/portal/src/java/org/apache/jetspeed/profiler/impl/ProfilerValveImpl.java
(original)
+++ portals/jetspeed-2/trunk/components/portal/src/java/org/apache/jetspeed/profiler/impl/ProfilerValveImpl.java
Sat Feb 11 12:10:57 2006
@@ -21,12 +21,14 @@
 import java.util.Map;
 
 import javax.security.auth.Subject;
-import javax.servlet.http.HttpServletRequest;
 import javax.servlet.http.HttpServletResponse;
 
 import org.apache.commons.logging.Log;
 import org.apache.commons.logging.LogFactory;
+import org.apache.jetspeed.PortalReservedParameters;
+import org.apache.jetspeed.decoration.PageActionAccess;
 import org.apache.jetspeed.om.page.ContentPageImpl;
+import org.apache.jetspeed.om.page.Page;
 import org.apache.jetspeed.page.PageManager;
 import org.apache.jetspeed.page.document.NodeNotFoundException;
 import org.apache.jetspeed.pipeline.PipelineException;
@@ -69,6 +71,11 @@
     public static final String PROFILED_PAGE_CONTEXT_ATTR_KEY = "org.apache.jetspeed.profiledPageContext";
 
     /**
+     * session key for storing map of PageActionAccess instances
+     */
+    private static final String PAGE_ACTION_ACCESS_MAP_SESSION_ATTR_KEY = "org.apache.jetspeed.profiler.pageActionAccessMap";
+    
+    /**
      * profiler - profiler component
      */
     private Profiler profiler;
@@ -206,6 +213,8 @@
                 // request
                 request.setPage(new ContentPageImpl(requestContext.getManagedPage()));
                 request.setProfileLocators(requestContext.getLocators());
+                
+                request.setAttribute(PortalReservedParameters.PAGE_EDIT_ACCESS_ATTRIBUTE,getPageActionAccess(request));
               
             }
 
             // continue
@@ -260,6 +269,50 @@
             log.error("Exception in request pipeline: " + e.getMessage(), e);
             throw new PipelineException(e.toString(), e);
         }
+    }
+
+    /**
+     * Returns the <code>PageActionAccess</code> for the current user request.
+     * @see PageActionAccess
+     * @param requestContext RequestContext of the current portal request.
+     * @return PageActionAccess for the current user request.
+     */
+    protected PageActionAccess getPageActionAccess(RequestContext requestContext)
+    { 
+        Page page = requestContext.getPage();
+        String key = page.getId();
+        boolean loggedOn = requestContext.getRequest().getUserPrincipal() != null;
+        boolean anonymous = !loggedOn;
+        PageActionAccess pageActionAccess = null;
+
+        Map sessionActions = null;
+        synchronized (this)
+        {
+            sessionActions = (Map) requestContext.getSessionAttribute(PAGE_ACTION_ACCESS_MAP_SESSION_ATTR_KEY);
+            if (sessionActions == null)
+            {
+                sessionActions = new HashMap();
+                requestContext.setSessionAttribute(PAGE_ACTION_ACCESS_MAP_SESSION_ATTR_KEY,
sessionActions);
+            }
+            else
+            {
+                pageActionAccess = (PageActionAccess) sessionActions.get(key);
+            }
+        }
+        synchronized (sessionActions)
+        {
+            if (pageActionAccess == null)
+            {
+                pageActionAccess = new PageActionAccess(anonymous, page);
+                sessionActions.put(key, pageActionAccess);
+            }
+            else
+            {
+                pageActionAccess.checkReset(anonymous, page);
+            }        
+        }
+        
+        return pageActionAccess;
     }
 
     public String toString()



---------------------------------------------------------------------
To unsubscribe, e-mail: jetspeed-dev-unsubscribe@portals.apache.org
For additional commands, e-mail: jetspeed-dev-help@portals.apache.org


Mime
View raw message