Author: jcompagner
Date: Wed Nov 10 16:03:26 2010
New Revision: 1033552

URL: http://svn.apache.org/viewvc?rev=1033552&view=rev
Log:
make lastmodified calls also work for mounted shared resources

Modified:
    
wicket/branches/wicket-1.4.x/wicket/src/main/java/org/apache/wicket/protocol/http/WicketFilter.java
    
wicket/branches/wicket-1.4.x/wicket/src/main/java/org/apache/wicket/request/target/coding/SharedResourceRequestTargetUrlCodingStrategy.java

Modified: 
wicket/branches/wicket-1.4.x/wicket/src/main/java/org/apache/wicket/protocol/http/WicketFilter.java
URL: 
http://svn.apache.org/viewvc/wicket/branches/wicket-1.4.x/wicket/src/main/java/org/apache/wicket/protocol/http/WicketFilter.java?rev=1033552&r1=1033551&r2=1033552&view=diff
==============================================================================
--- 
wicket/branches/wicket-1.4.x/wicket/src/main/java/org/apache/wicket/protocol/http/WicketFilter.java
 (original)
+++ 
wicket/branches/wicket-1.4.x/wicket/src/main/java/org/apache/wicket/protocol/http/WicketFilter.java
 Wed Nov 10 16:03:26 2010
@@ -50,6 +50,8 @@ import org.apache.wicket.protocol.http.p
 import org.apache.wicket.protocol.http.portlet.WicketFilterPortletContext;
 import org.apache.wicket.protocol.http.request.WebRequestCodingStrategy;
 import org.apache.wicket.request.RequestParameters;
+import org.apache.wicket.request.target.coding.IRequestTargetUrlCodingStrategy;
+import 
org.apache.wicket.request.target.coding.SharedResourceRequestTargetUrlCodingStrategy;
 import org.apache.wicket.session.ISessionStore;
 import org.apache.wicket.settings.IRequestCycleSettings;
 import org.apache.wicket.util.resource.IResourceStream;
@@ -1132,11 +1134,23 @@ public class WicketFilter implements Fil
         * @param servletRequest
         * @return The last modified time stamp
         */
-       long getLastModified(final HttpServletRequest servletRequest)
+       protected long getLastModified(final HttpServletRequest servletRequest)
        {
                final String pathInfo = getRelativePath(servletRequest);
+               if (Strings.isEmpty(pathInfo))
+                       return -1;
 
-               if 
(pathInfo.startsWith(WebRequestCodingStrategy.RESOURCES_PATH_PREFIX))
+               IRequestTargetUrlCodingStrategy sharedResourceMount = null;
+               boolean sharedResource = 
pathInfo.startsWith(WebRequestCodingStrategy.RESOURCES_PATH_PREFIX);
+               if (!sharedResource)
+               {
+                       sharedResourceMount = 
webApplication.getRequestCycleProcessor()
+                               .getRequestCodingStrategy()
+                               .urlCodingStrategyForPath(pathInfo);
+                       sharedResource = sharedResourceMount instanceof 
SharedResourceRequestTargetUrlCodingStrategy;
+               }
+
+               if (sharedResource)
                {
                        Resource resource = null;
                        WebRequestCycle requestCycle = null;
@@ -1151,7 +1165,15 @@ public class WicketFilter implements Fil
                                        Application.set(webApplication);
                                }
 
-                               final String resourceReferenceKey = 
WicketURLDecoder.PATH_INSTANCE.decode(pathInfo.substring(WebRequestCodingStrategy.RESOURCES_PATH_PREFIX.length()));
+                               final String resourceReferenceKey;
+                               if (sharedResourceMount != null)
+                               {
+                                       resourceReferenceKey = 
((SharedResourceRequestTargetUrlCodingStrategy)sharedResourceMount).getResourceKey();
+                               }
+                               else
+                               {
+                                       resourceReferenceKey = 
WicketURLDecoder.PATH_INSTANCE.decode(pathInfo.substring(WebRequestCodingStrategy.RESOURCES_PATH_PREFIX.length()));
+                               }
 
 
                                // Try to find shared resource
@@ -1181,6 +1203,10 @@ public class WicketFilter implements Fil
                                                .getProcessor()
                                                .getRequestCodingStrategy()
                                                .decode(request);
+                                       if (sharedResourceMount != null)
+                                       {
+                                               sharedResourceMount.decode(rp);
+                                       }
                                        // Set parameters from servlet request
                                        
resource.setParameters(rp.getParameters());
 

Modified: 
wicket/branches/wicket-1.4.x/wicket/src/main/java/org/apache/wicket/request/target/coding/SharedResourceRequestTargetUrlCodingStrategy.java
URL: 
http://svn.apache.org/viewvc/wicket/branches/wicket-1.4.x/wicket/src/main/java/org/apache/wicket/request/target/coding/SharedResourceRequestTargetUrlCodingStrategy.java?rev=1033552&r1=1033551&r2=1033552&view=diff
==============================================================================
--- 
wicket/branches/wicket-1.4.x/wicket/src/main/java/org/apache/wicket/request/target/coding/SharedResourceRequestTargetUrlCodingStrategy.java
 (original)
+++ 
wicket/branches/wicket-1.4.x/wicket/src/main/java/org/apache/wicket/request/target/coding/SharedResourceRequestTargetUrlCodingStrategy.java
 Wed Nov 10 16:03:26 2010
@@ -98,6 +98,14 @@ public class SharedResourceRequestTarget
        }
 
        /**
+        * @return the shared resource key for this mount
+        */
+       public String getResourceKey()
+       {
+               return resourceKey;
+       }
+
+       /**
         * @see java.lang.Object#toString()
         */
        @Override


Reply via email to