Author: chris.laprun(a)jboss.com
Date: 2010-08-05 08:51:22 -0400 (Thu, 05 Aug 2010)
New Revision: 3758
Modified:
components/pc/trunk/portlet/src/main/java/org/gatein/pc/portlet/impl/jsr168/api/ResourceResponseImpl.java
Log:
- Improved error message.
Modified:
components/pc/trunk/portlet/src/main/java/org/gatein/pc/portlet/impl/jsr168/api/ResourceResponseImpl.java
===================================================================
---
components/pc/trunk/portlet/src/main/java/org/gatein/pc/portlet/impl/jsr168/api/ResourceResponseImpl.java 2010-08-05
10:36:29 UTC (rev 3757)
+++
components/pc/trunk/portlet/src/main/java/org/gatein/pc/portlet/impl/jsr168/api/ResourceResponseImpl.java 2010-08-05
12:51:22 UTC (rev 3758)
@@ -33,6 +33,7 @@
import javax.portlet.PortletURL;
import javax.portlet.ResourceResponse;
+import javax.portlet.ResourceURL;
import java.util.ArrayList;
import java.util.List;
import java.util.Locale;
@@ -109,26 +110,23 @@
public PortletURL createActionURL()
{
- if (cacheability != CacheLevel.PAGE)
- {
- throw new IllegalStateException("Cannot create action URL because the
current cache level " + cacheability +
- " is not " + CacheLevel.PAGE);
- }
-
- //
+ checkCacheLevel();
return super.createActionURL();
}
public PortletURL createRenderURL()
{
+ checkCacheLevel();
+ return super.createRenderURL();
+ }
+
+ private void checkCacheLevel()
+ {
if (cacheability != CacheLevel.PAGE)
{
- throw new IllegalStateException("Cannot create render URL because the
current cache level " + cacheability +
- " is not " + CacheLevel.PAGE);
+ throw new IllegalStateException("A resource cannot create URLs if the cache
level hasn't been set to "
+ + ResourceURL.PAGE + " as mandated by JSR-286 PLT.13.7. Cache level was:
" + cacheability);
}
-
- //
- return super.createRenderURL();
}
protected ContentResponse createMarkupResponse(ResponseProperties properties,
Map<String, Object> attributeMap, String contentType, byte[] bytes, String chars,
CacheControl cacheControl)