Update of
/var/cvs/contributions/CMSContainer/cmsc/portal/src/java/com/finalist/pluto/portalImpl/aggregation
In directory
james.mmbase.org:/tmp/cvs-serv22296/cmsc/portal/src/java/com/finalist/pluto/portalImpl/aggregation
Modified Files:
ScreenFragment.java PortletFragment.java
Log Message:
CMSC-1290 Problems with caching in the editors
See also:
http://cvs.mmbase.org/viewcvs/contributions/CMSContainer/cmsc/portal/src/java/com/finalist/pluto/portalImpl/aggregation
See also: http://www.mmbase.org/jira/browse/CMSC-1290
Index: ScreenFragment.java
===================================================================
RCS file:
/var/cvs/contributions/CMSContainer/cmsc/portal/src/java/com/finalist/pluto/portalImpl/aggregation/ScreenFragment.java,v
retrieving revision 1.13
retrieving revision 1.14
diff -u -b -r1.13 -r1.14
--- ScreenFragment.java 25 Jul 2008 16:08:10 -0000 1.13
+++ ScreenFragment.java 11 Feb 2009 23:12:25 -0000 1.14
@@ -13,6 +13,8 @@
import com.finalist.cmsc.beans.om.Layout;
import com.finalist.cmsc.beans.om.Page;
import com.finalist.cmsc.portalImpl.PortalConstants;
+import com.finalist.cmsc.services.security.LoginSession;
+import com.finalist.cmsc.services.sitemanagement.SiteManagement;
/**
* @author Wouter Heijke
@@ -65,12 +67,27 @@
}
}
-
- long expires = System.currentTimeMillis();
+ LoginSession ls = SiteManagement.getLoginSession(request);
+ if (!ls.isAuthenticated()) {
if (expirationCache > -1) {
- expires += expirationCache * 1000; // seconds to milliseconds
- }
+ response.setHeader("Cache-Control", "maxage=" + expirationCache);
+ if (expirationCache > 30) {
+ /*
+ If a response includes both an Expires header and a max-age
+ directive, the max-age directive overrides the Expires header,
even
+ if the Expires header is more restrictive. This rule allows an
+ origin server to provide, for a given response, a longer
expiration
+ time to an HTTP/1.1 (or later) cache than to an HTTP/1.0 cache.
This
+ might be useful if certain HTTP/1.0 caches improperly calculate
ages
+ or expiration times, perhaps due to desynchronized clocks.
+ */
+ long now = System.currentTimeMillis();
+ response.setDateHeader("Date", now);
+ long expires = now + (expirationCache * 1000); // seconds to
milliseconds
response.setDateHeader("Expires", expires);
+ }
+ }
+ }
if (page != null) {
if (layout != null) {
Index: PortletFragment.java
===================================================================
RCS file:
/var/cvs/contributions/CMSContainer/cmsc/portal/src/java/com/finalist/pluto/portalImpl/aggregation/PortletFragment.java,v
retrieving revision 1.14
retrieving revision 1.15
diff -u -b -r1.14 -r1.15
--- PortletFragment.java 25 Jul 2008 16:08:10 -0000 1.14
+++ PortletFragment.java 11 Feb 2009 23:12:25 -0000 1.15
@@ -86,6 +86,10 @@
PortletEntityImpl portletEntity = new PortletEntityImpl();
portletEntity.setId(getId());
portletEntity.setDefinitionId(definition.getDefinition());
+ PortletDefinition portletDefinition =
portletEntity.getPortletDefinition();
+ if (portletDefinition == null) {
+ throw new IllegalArgumentException("Missing definition " +
definition.getDefinition() + " in portlet.xml");
+ }
// for now set CMSC portlet params in the preferences of the portlet
// entiy
@@ -126,8 +130,7 @@
ps.add(PortalConstants.CMSC_PORTLET_VIEW_TEMPLATE,
view.getResource());
}
-
- String expiractionFromDefinition =
portletEntity.getPortletDefinition().getExpirationCache();
+ String expiractionFromDefinition =
portletDefinition.getExpirationCache();
/* Portlet spec 1.0 PLT.18.1 Expiration Cache
* For a portlet that has not defined expiration cache in the deployment
descriptor,
* if the expiration cache property is set it must be ignored by the
portlet-container.
@@ -140,7 +143,7 @@
expirationCache = Integer.valueOf(expiractionFromDefinition);
}
catch(NumberFormatException nfe) {
- log.error("Cache expiration in xml is not a number for " +
portletEntity.getPortletDefinition().getName());
+ log.error("Cache expiration in xml is not a number for " +
portletDefinition.getName());
}
if (definition.getExpirationcache() > -1) {
@@ -177,9 +180,11 @@
}
catch (PortletException e) {
log.fatal("process portlet raised an exception", e);
+ response.sendError(HttpServletResponse.SC_INTERNAL_SERVER_ERROR,
e.getMessage());
}
catch (PortletContainerException e) {
log.fatal("portlet container raised an exception", e);
+ response.sendError(HttpServletResponse.SC_INTERNAL_SERVER_ERROR,
e.getMessage());
}
cleanRequest(request);
}
_______________________________________________
Cvs mailing list
[email protected]
http://lists.mmbase.org/mailman/listinfo/cvs