JBoss Portal SVN: r10153 - in modules/portlet/trunk/portlet/src/main/java/org/jboss/portal/portlet: invocation/response and 1 other directory.
by portal-commits@lists.jboss.org
Author: julien(a)jboss.com
Date: 2008-02-28 07:34:12 -0500 (Thu, 28 Feb 2008)
New Revision: 10153
Modified:
modules/portlet/trunk/portlet/src/main/java/org/jboss/portal/portlet/impl/jsr168/api/MimeResponseImpl.java
modules/portlet/trunk/portlet/src/main/java/org/jboss/portal/portlet/invocation/response/ResponseProperties.java
Log:
added a clear() methods on ResponseProperties that clears the 3 nested objects.
Modified: modules/portlet/trunk/portlet/src/main/java/org/jboss/portal/portlet/impl/jsr168/api/MimeResponseImpl.java
===================================================================
--- modules/portlet/trunk/portlet/src/main/java/org/jboss/portal/portlet/impl/jsr168/api/MimeResponseImpl.java 2008-02-28 12:28:42 UTC (rev 10152)
+++ modules/portlet/trunk/portlet/src/main/java/org/jboss/portal/portlet/impl/jsr168/api/MimeResponseImpl.java 2008-02-28 12:34:12 UTC (rev 10153)
@@ -210,9 +210,7 @@
resetBuffer();
// And properties
- getProperties().getTransportHeaders().clear();
- getProperties().getMarkupHeaders().clear();
- getProperties().getCookies().clear();
+ getProperties().clear();
}
public boolean isCommitted()
Modified: modules/portlet/trunk/portlet/src/main/java/org/jboss/portal/portlet/invocation/response/ResponseProperties.java
===================================================================
--- modules/portlet/trunk/portlet/src/main/java/org/jboss/portal/portlet/invocation/response/ResponseProperties.java 2008-02-28 12:28:42 UTC (rev 10152)
+++ modules/portlet/trunk/portlet/src/main/java/org/jboss/portal/portlet/invocation/response/ResponseProperties.java 2008-02-28 12:34:12 UTC (rev 10153)
@@ -77,4 +77,11 @@
markupHeaders.append(appended.markupHeaders);
cookies.addAll(appended.cookies);
}
+
+ public void clear()
+ {
+ transportHeaders.clear();
+ markupHeaders.clear();
+ cookies.clear();
+ }
}
\ No newline at end of file
16 years, 8 months
JBoss Portal SVN: r10152 - in modules/portlet/trunk: portlet/src/main/java/org/jboss/portal/portlet/impl/jsr168/api and 5 other directories.
by portal-commits@lists.jboss.org
Author: julien(a)jboss.com
Date: 2008-02-28 07:28:42 -0500 (Thu, 28 Feb 2008)
New Revision: 10152
Added:
modules/portlet/trunk/portlet/src/main/java/org/jboss/portal/portlet/invocation/response/ContentResponse.java
Modified:
modules/portlet/trunk/portlet/src/main/java/org/jboss/portal/portlet/aspects/portlet/ConsumerCacheInterceptor.java
modules/portlet/trunk/portlet/src/main/java/org/jboss/portal/portlet/impl/jsr168/api/MimeResponseImpl.java
modules/portlet/trunk/portlet/src/main/java/org/jboss/portal/portlet/impl/jsr168/api/RenderResponseImpl.java
modules/portlet/trunk/portlet/src/main/java/org/jboss/portal/portlet/impl/jsr168/api/ResourceResponseImpl.java
modules/portlet/trunk/portlet/src/main/java/org/jboss/portal/portlet/invocation/response/FragmentResponse.java
modules/portlet/trunk/portlet/src/main/java/org/jboss/portal/portlet/invocation/response/cache/ContentRef.java
modules/portlet/trunk/portlet/src/main/java/org/jboss/portal/portlet/invocation/response/cache/SoftContentRef.java
modules/portlet/trunk/portlet/src/main/java/org/jboss/portal/portlet/invocation/response/cache/StrongContentRef.java
modules/portlet/trunk/test/src/main/java/org/jboss/portal/portlet/test/controller/ControllerResponseRendererFactory.java
modules/portlet/trunk/test/src/main/java/org/jboss/portal/portlet/test/controller/FragmentRenderer.java
modules/portlet/trunk/test/src/main/java/org/jboss/portal/portlet/test/controller/PageRenderer.java
modules/portlet/trunk/test/src/main/java/org/jboss/portal/portlet/test/controller/ResourceRenderer.java
modules/portlet/trunk/test/src/main/java/org/jboss/portal/portlet/test/controller/SimpleFragmentRenderer.java
modules/portlet/trunk/test/src/main/java/org/jboss/portal/portlet/test/jsp/ControllerFilter.java
modules/portlet/trunk/test/src/main/java/org/jboss/portal/portlet/test/jsp/taglib/HeadersTag.java
modules/portlet/trunk/test/src/main/java/org/jboss/portal/portlet/test/jsp/taglib/PortletMarkupTag.java
modules/portlet/trunk/test/src/main/java/org/jboss/portal/portlet/test/jsp/taglib/PortletTag.java
Log:
introduced ContentResponse super class of FragmentResponse that is used by resource response
Modified: modules/portlet/trunk/portlet/src/main/java/org/jboss/portal/portlet/aspects/portlet/ConsumerCacheInterceptor.java
===================================================================
--- modules/portlet/trunk/portlet/src/main/java/org/jboss/portal/portlet/aspects/portlet/ConsumerCacheInterceptor.java 2008-02-28 11:57:23 UTC (rev 10151)
+++ modules/portlet/trunk/portlet/src/main/java/org/jboss/portal/portlet/aspects/portlet/ConsumerCacheInterceptor.java 2008-02-28 12:28:42 UTC (rev 10152)
@@ -27,9 +27,9 @@
import org.jboss.portal.portlet.invocation.RenderInvocation;
import org.jboss.portal.portlet.invocation.response.cache.ContentRef;
import org.jboss.portal.portlet.invocation.response.cache.StrongContentRef;
-import org.jboss.portal.portlet.invocation.response.FragmentResponse;
import org.jboss.portal.portlet.invocation.response.PortletInvocationResponse;
import org.jboss.portal.portlet.invocation.response.RevalidateMarkupResponse;
+import org.jboss.portal.portlet.invocation.response.ContentResponse;
import org.jboss.portal.portlet.StateString;
import org.jboss.portal.portlet.ParametersStateString;
import org.jboss.portal.portlet.cache.CacheControl;
@@ -144,7 +144,7 @@
}
}
- FragmentResponse fragment = cachedEntry != null ? cachedEntry.contentRef.getContent() : null;
+ ContentResponse fragment = cachedEntry != null ? cachedEntry.contentRef.getContent() : null;
// If no valid fragment we must invoke
if (fragment == null || cachedEntry.expirationTimeMillis < System.currentTimeMillis())
@@ -160,9 +160,9 @@
// Try to cache any fragment result
CacheControl control = null;
- if (response instanceof FragmentResponse)
+ if (response instanceof ContentResponse)
{
- fragment = (FragmentResponse)response;
+ fragment = (ContentResponse)response;
control = fragment.getCacheControl();
}
else if (response instanceof RevalidateMarkupResponse)
@@ -261,7 +261,7 @@
ParameterMap publicNavigationalState,
WindowState windowState,
Mode mode,
- FragmentResponse content,
+ ContentResponse content,
long expirationTimeMillis,
String validationToken)
{
Modified: modules/portlet/trunk/portlet/src/main/java/org/jboss/portal/portlet/impl/jsr168/api/MimeResponseImpl.java
===================================================================
--- modules/portlet/trunk/portlet/src/main/java/org/jboss/portal/portlet/impl/jsr168/api/MimeResponseImpl.java 2008-02-28 11:57:23 UTC (rev 10151)
+++ modules/portlet/trunk/portlet/src/main/java/org/jboss/portal/portlet/impl/jsr168/api/MimeResponseImpl.java 2008-02-28 12:28:42 UTC (rev 10152)
@@ -23,14 +23,14 @@
package org.jboss.portal.portlet.impl.jsr168.api;
import org.jboss.portal.portlet.invocation.PortletInvocation;
-import org.jboss.portal.portlet.invocation.response.FragmentResponse;
import org.jboss.portal.portlet.invocation.response.PortletInvocationResponse;
import org.jboss.portal.portlet.invocation.response.RevalidateMarkupResponse;
+import org.jboss.portal.portlet.invocation.response.ContentResponse;
+import org.jboss.portal.portlet.invocation.response.ResponseProperties;
import org.jboss.portal.portlet.info.PortletInfo;
import org.jboss.portal.portlet.info.CacheInfo;
import org.jboss.portal.portlet.cache.CacheScope;
import org.jboss.portal.portlet.impl.jsr168.ContentBuffer;
-import org.jboss.portal.Mode;
import javax.portlet.MimeResponse;
import javax.portlet.PortletURL;
@@ -40,7 +40,7 @@
import java.io.IOException;
import java.io.OutputStream;
import java.util.Locale;
-import java.util.Set;
+import java.util.Map;
/**
* @author <a href="mailto:julien@jboss.org">Julien Viet</a>
@@ -58,14 +58,9 @@
/** . */
private boolean contentTypeSet;
- /** The title if any. */
- protected String responseTitle;
-
/** . */
private ContentBuffer responseContent;
- /** . */
- protected Set<Mode> responseNextModes;
public MimeResponseImpl(PortletInvocation invocation, PortletRequestImpl preq)
{
@@ -84,10 +79,17 @@
this.bufferSize = 0;
this.contentTypeSet = false;
this.responseContent = new ContentBuffer();
- this.responseTitle = null;
- this.responseNextModes = null;
}
+ protected abstract ContentResponse createMarkupResponse(
+ ResponseProperties properties,
+ Map<String, Object> attributeMap,
+ String contentType,
+ byte[] bytes,
+ String chars,
+ org.jboss.portal.portlet.cache.CacheControl cacheControl
+ );
+
public PortletInvocationResponse getResponse()
{
org.jboss.portal.portlet.cache.CacheControl cc;
@@ -112,15 +114,13 @@
}
else
{
- return new FragmentResponse(
+ return createMarkupResponse(
getProperties(false),
preq.attributes.getAttributeMap(),
responseContent.getContentType(),
responseContent.getBytes(),
responseContent.getChars(),
- responseTitle,
- cc,
- responseNextModes != null ? responseNextModes : preq.supportedModes);
+ cc);
}
}
Modified: modules/portlet/trunk/portlet/src/main/java/org/jboss/portal/portlet/impl/jsr168/api/RenderResponseImpl.java
===================================================================
--- modules/portlet/trunk/portlet/src/main/java/org/jboss/portal/portlet/impl/jsr168/api/RenderResponseImpl.java 2008-02-28 11:57:23 UTC (rev 10151)
+++ modules/portlet/trunk/portlet/src/main/java/org/jboss/portal/portlet/impl/jsr168/api/RenderResponseImpl.java 2008-02-28 12:28:42 UTC (rev 10152)
@@ -23,11 +23,13 @@
package org.jboss.portal.portlet.impl.jsr168.api;
import org.jboss.portal.portlet.invocation.RenderInvocation;
-import org.jboss.portal.portlet.invocation.response.PortletInvocationResponse;
import org.jboss.portal.portlet.invocation.response.FragmentResponse;
+import org.jboss.portal.portlet.invocation.response.ContentResponse;
+import org.jboss.portal.portlet.invocation.response.ResponseProperties;
import org.jboss.portal.portlet.info.PortletInfo;
import org.jboss.portal.portlet.info.CapabilitiesInfo;
import org.jboss.portal.portlet.info.ModeInfo;
+import org.jboss.portal.portlet.cache.CacheControl;
import org.jboss.portal.Mode;
import org.jboss.portal.common.util.MediaType;
@@ -37,6 +39,7 @@
import java.util.Collection;
import java.util.Set;
import java.util.LinkedHashSet;
+import java.util.Map;
/**
* @author <a href="mailto:julien@jboss.org">Julien Viet</a>
@@ -45,9 +48,19 @@
public class RenderResponseImpl extends MimeResponseImpl implements RenderResponse
{
+ /** . */
+ protected Set<Mode> responseNextModes;
+
+ /** The title if any. */
+ protected String responseTitle;
+
public RenderResponseImpl(RenderInvocation invocation, PortletRequestImpl preq)
{
super(invocation, preq);
+
+ //
+ this.responseNextModes = null;
+ this.responseTitle = null;
}
public void setTitle(String title)
@@ -142,4 +155,17 @@
throw ex;
}
}
+
+ protected ContentResponse createMarkupResponse(ResponseProperties properties, Map<String, Object> attributeMap, String contentType, byte[] bytes, String chars, CacheControl cacheControl)
+ {
+ return new FragmentResponse(
+ properties,
+ attributeMap,
+ contentType,
+ bytes,
+ chars,
+ responseTitle,
+ cacheControl,
+ responseNextModes != null ? responseNextModes : preq.supportedModes);
+ }
}
Modified: modules/portlet/trunk/portlet/src/main/java/org/jboss/portal/portlet/impl/jsr168/api/ResourceResponseImpl.java
===================================================================
--- modules/portlet/trunk/portlet/src/main/java/org/jboss/portal/portlet/impl/jsr168/api/ResourceResponseImpl.java 2008-02-28 11:57:23 UTC (rev 10151)
+++ modules/portlet/trunk/portlet/src/main/java/org/jboss/portal/portlet/impl/jsr168/api/ResourceResponseImpl.java 2008-02-28 12:28:42 UTC (rev 10152)
@@ -23,11 +23,15 @@
package org.jboss.portal.portlet.impl.jsr168.api;
import org.jboss.portal.portlet.invocation.ResourceInvocation;
+import org.jboss.portal.portlet.invocation.response.ContentResponse;
+import org.jboss.portal.portlet.invocation.response.ResponseProperties;
import org.jboss.portal.portlet.cache.CacheLevel;
+import org.jboss.portal.portlet.cache.CacheControl;
import javax.portlet.ResourceResponse;
import javax.portlet.PortletURL;
import java.util.Locale;
+import java.util.Map;
/**
* @author <a href="mailto:julien@jboss.org">Julien Viet</a>
@@ -85,4 +89,15 @@
//
return super.createRenderURL();
}
+
+ protected ContentResponse createMarkupResponse(ResponseProperties properties, Map<String, Object> attributeMap, String contentType, byte[] bytes, String chars, CacheControl cacheControl)
+ {
+ return new ContentResponse(
+ properties,
+ attributeMap,
+ contentType,
+ bytes,
+ chars,
+ cacheControl);
+ }
}
Added: modules/portlet/trunk/portlet/src/main/java/org/jboss/portal/portlet/invocation/response/ContentResponse.java
===================================================================
--- modules/portlet/trunk/portlet/src/main/java/org/jboss/portal/portlet/invocation/response/ContentResponse.java (rev 0)
+++ modules/portlet/trunk/portlet/src/main/java/org/jboss/portal/portlet/invocation/response/ContentResponse.java 2008-02-28 12:28:42 UTC (rev 10152)
@@ -0,0 +1,168 @@
+/******************************************************************************
+ * JBoss, a division of Red Hat *
+ * Copyright 2006, Red Hat Middleware, LLC, and individual *
+ * contributors as indicated by the @authors tag. See the *
+ * copyright.txt in the distribution for a full listing of *
+ * individual contributors. *
+ * *
+ * This is free software; you can redistribute it and/or modify it *
+ * under the terms of the GNU Lesser General Public License as *
+ * published by the Free Software Foundation; either version 2.1 of *
+ * the License, or (at your option) any later version. *
+ * *
+ * This software is distributed in the hope that it will be useful, *
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of *
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU *
+ * Lesser General Public License for more details. *
+ * *
+ * You should have received a copy of the GNU Lesser General Public *
+ * License along with this software; if not, write to the Free *
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA *
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org. *
+ ******************************************************************************/
+package org.jboss.portal.portlet.invocation.response;
+
+import org.jboss.portal.portlet.cache.CacheControl;
+import org.jboss.portal.Mode;
+
+import java.util.Set;
+import java.util.Map;
+
+/**
+ * Data produced.
+ *
+ * @author <a href="mailto:julien@jboss.org">Julien Viet</a>
+ * @version $Revision: 5602 $
+ */
+public class ContentResponse extends PortletInvocationResponse
+{
+
+ /** . */
+ public static final int TYPE_EMPTY = 0;
+
+ /** . */
+ public static final int TYPE_CHARS = 1;
+
+ /** . */
+ public static final int TYPE_BYTES = 2;
+
+ /** . */
+ private final ResponseProperties properties;
+
+ /** . */
+ private final Map<String, Object> attributes;
+
+ /** The result content type if any. */
+ private String contentType;
+
+ /** . */
+ private final byte[] bytes;
+
+ /** . */
+ private final String chars;
+
+ /** . */
+ private final CacheControl cacheControl;
+
+ public ContentResponse(
+ ResponseProperties properties,
+ Map<String, Object> attributes,
+ String contentType,
+ byte[] bytes,
+ String chars,
+ CacheControl cacheControl)
+ {
+ this.properties = properties;
+ this.attributes = attributes;
+ this.contentType = contentType;
+ this.bytes = bytes;
+ this.chars = chars;
+ this.cacheControl = cacheControl;
+ }
+
+ public ResponseProperties getProperties()
+ {
+ return properties;
+ }
+
+ public CacheControl getCacheControl()
+ {
+ return cacheControl;
+ }
+
+ public Map<String, Object> getAttributes()
+ {
+ return attributes;
+ }
+
+ public int getType()
+ {
+ if (bytes == null)
+ {
+ if (chars == null)
+ {
+ return TYPE_EMPTY;
+ }
+ else
+ {
+ return TYPE_CHARS;
+ }
+ }
+ else
+ {
+ return TYPE_BYTES;
+ }
+ }
+
+ /**
+ * Return the content as a string.
+ *
+ * @return the content
+ */
+ public String getContent()
+ {
+ switch (getType())
+ {
+ case TYPE_CHARS:
+ return getChars();
+ case TYPE_BYTES:
+ return new String(bytes);
+ case TYPE_EMPTY:
+ return "";
+ default:
+ throw new AssertionError();
+ }
+ }
+
+ /**
+ * Return the bytes of the content held by the fragment.
+ *
+ * @return the bytes
+ * @throws IllegalArgumentException if the type is not bytes
+ */
+ public byte[] getBytes() throws IllegalArgumentException
+ {
+ return bytes;
+ }
+
+ /**
+ * Return the chars of the content held by the fragment.
+ *
+ * @return the chars
+ * @throws IllegalArgumentException if the type is not chars
+ */
+ public String getChars() throws IllegalArgumentException
+ {
+ return chars;
+ }
+
+ /**
+ * Return the content type of the generated fragment.
+ *
+ * @return the content type
+ */
+ public String getContentType()
+ {
+ return contentType;
+ }
+}
\ No newline at end of file
Modified: modules/portlet/trunk/portlet/src/main/java/org/jboss/portal/portlet/invocation/response/FragmentResponse.java
===================================================================
--- modules/portlet/trunk/portlet/src/main/java/org/jboss/portal/portlet/invocation/response/FragmentResponse.java 2008-02-28 11:57:23 UTC (rev 10151)
+++ modules/portlet/trunk/portlet/src/main/java/org/jboss/portal/portlet/invocation/response/FragmentResponse.java 2008-02-28 12:28:42 UTC (rev 10152)
@@ -34,40 +34,13 @@
* @author <a href="mailto:julien@jboss.org">Julien Viet</a>
* @version $Revision: 5602 $
*/
-public class FragmentResponse extends PortletInvocationResponse
+public class FragmentResponse extends ContentResponse
{
- /** . */
- public static final int TYPE_EMPTY = 0;
-
- /** . */
- public static final int TYPE_CHARS = 1;
-
- /** . */
- public static final int TYPE_BYTES = 2;
-
- /** . */
- private final ResponseProperties properties;
-
- /** . */
- private final Map<String, Object> attributes;
-
- /** The result content type if any. */
- private String contentType;
-
- /** . */
- private final byte[] bytes;
-
- /** . */
- private final String chars;
-
/** The title if any. */
private final String title;
- /** . */
- private final CacheControl cacheControl;
-
- /** . */
+ /** The next modes. */
private final Set<Mode> nextModes;
public FragmentResponse(
@@ -80,93 +53,14 @@
CacheControl cacheControl,
Set<Mode> nextModes)
{
- this.properties = properties;
- this.attributes = attributes;
- this.contentType = contentType;
- this.bytes = bytes;
- this.chars = chars;
+ super(properties, attributes, contentType, bytes, chars, cacheControl);
+
+ //
this.title = title;
- this.cacheControl = cacheControl;
this.nextModes = nextModes;
}
- public ResponseProperties getProperties()
- {
- return properties;
- }
-
- public CacheControl getCacheControl()
- {
- return cacheControl;
- }
-
- public Map<String, Object> getAttributes()
- {
- return attributes;
- }
-
- public int getType()
- {
- if (bytes == null)
- {
- if (chars == null)
- {
- return TYPE_EMPTY;
- }
- else
- {
- return TYPE_CHARS;
- }
- }
- else
- {
- return TYPE_BYTES;
- }
- }
-
/**
- * Return the content as a string.
- *
- * @return the content
- */
- public String getContent()
- {
- switch (getType())
- {
- case TYPE_CHARS:
- return getChars();
- case TYPE_BYTES:
- return new String(bytes);
- case TYPE_EMPTY:
- return "";
- default:
- throw new AssertionError();
- }
- }
-
- /**
- * Return the bytes of the content held by the fragment.
- *
- * @return the bytes
- * @throws IllegalArgumentException if the type is not bytes
- */
- public byte[] getBytes() throws IllegalArgumentException
- {
- return bytes;
- }
-
- /**
- * Return the chars of the content held by the fragment.
- *
- * @return the chars
- * @throws IllegalArgumentException if the type is not chars
- */
- public String getChars() throws IllegalArgumentException
- {
- return chars;
- }
-
- /**
* Return the fragment title.
*
* @return the title.
@@ -177,15 +71,10 @@
}
/**
- * Return the content type of the generated fragment.
+ * Returns the next modes.
*
- * @return the content type
+ * @return the next modes
*/
- public String getContentType()
- {
- return contentType;
- }
-
public Set<Mode> getNextModes()
{
return nextModes;
Modified: modules/portlet/trunk/portlet/src/main/java/org/jboss/portal/portlet/invocation/response/cache/ContentRef.java
===================================================================
--- modules/portlet/trunk/portlet/src/main/java/org/jboss/portal/portlet/invocation/response/cache/ContentRef.java 2008-02-28 11:57:23 UTC (rev 10151)
+++ modules/portlet/trunk/portlet/src/main/java/org/jboss/portal/portlet/invocation/response/cache/ContentRef.java 2008-02-28 12:28:42 UTC (rev 10152)
@@ -22,7 +22,7 @@
******************************************************************************/
package org.jboss.portal.portlet.invocation.response.cache;
-import org.jboss.portal.portlet.invocation.response.FragmentResponse;
+import org.jboss.portal.portlet.invocation.response.ContentResponse;
import java.io.Serializable;
@@ -40,5 +40,5 @@
*
* @return the content
*/
- public abstract FragmentResponse getContent();
+ public abstract ContentResponse getContent();
}
Modified: modules/portlet/trunk/portlet/src/main/java/org/jboss/portal/portlet/invocation/response/cache/SoftContentRef.java
===================================================================
--- modules/portlet/trunk/portlet/src/main/java/org/jboss/portal/portlet/invocation/response/cache/SoftContentRef.java 2008-02-28 11:57:23 UTC (rev 10151)
+++ modules/portlet/trunk/portlet/src/main/java/org/jboss/portal/portlet/invocation/response/cache/SoftContentRef.java 2008-02-28 12:28:42 UTC (rev 10152)
@@ -22,7 +22,7 @@
******************************************************************************/
package org.jboss.portal.portlet.invocation.response.cache;
-import org.jboss.portal.portlet.invocation.response.FragmentResponse;
+import org.jboss.portal.portlet.invocation.response.ContentResponse;
import java.lang.ref.WeakReference;
@@ -39,22 +39,22 @@
private static final long serialVersionUID = -8166044526732362286L;
/** The content. */
- private transient WeakReference<FragmentResponse> content;
+ private transient WeakReference<ContentResponse> content;
/**
* @param content the content
* @throws IllegalArgumentException if the content is null
*/
- public SoftContentRef(FragmentResponse content) throws IllegalArgumentException
+ public SoftContentRef(ContentResponse content) throws IllegalArgumentException
{
if (content == null)
{
throw new IllegalArgumentException("Content must not be null");
}
- this.content = new WeakReference<FragmentResponse>(content);
+ this.content = new WeakReference<ContentResponse>(content);
}
- public FragmentResponse getContent()
+ public ContentResponse getContent()
{
return content.get();
}
Modified: modules/portlet/trunk/portlet/src/main/java/org/jboss/portal/portlet/invocation/response/cache/StrongContentRef.java
===================================================================
--- modules/portlet/trunk/portlet/src/main/java/org/jboss/portal/portlet/invocation/response/cache/StrongContentRef.java 2008-02-28 11:57:23 UTC (rev 10151)
+++ modules/portlet/trunk/portlet/src/main/java/org/jboss/portal/portlet/invocation/response/cache/StrongContentRef.java 2008-02-28 12:28:42 UTC (rev 10152)
@@ -22,7 +22,7 @@
******************************************************************************/
package org.jboss.portal.portlet.invocation.response.cache;
-import org.jboss.portal.portlet.invocation.response.FragmentResponse;
+import org.jboss.portal.portlet.invocation.response.ContentResponse;
/**
* Use strong references.
@@ -37,13 +37,13 @@
private static final long serialVersionUID = -8194245397756941208L;
/** The content. */
- private transient FragmentResponse content;
+ private transient ContentResponse content;
/**
* @param content the content
* @throws IllegalArgumentException if the content is null
*/
- public StrongContentRef(FragmentResponse content) throws IllegalArgumentException
+ public StrongContentRef(ContentResponse content) throws IllegalArgumentException
{
if (content == null)
{
@@ -52,7 +52,7 @@
this.content = content;
}
- public FragmentResponse getContent()
+ public ContentResponse getContent()
{
return content;
}
Modified: modules/portlet/trunk/test/src/main/java/org/jboss/portal/portlet/test/controller/ControllerResponseRendererFactory.java
===================================================================
--- modules/portlet/trunk/test/src/main/java/org/jboss/portal/portlet/test/controller/ControllerResponseRendererFactory.java 2008-02-28 11:57:23 UTC (rev 10151)
+++ modules/portlet/trunk/test/src/main/java/org/jboss/portal/portlet/test/controller/ControllerResponseRendererFactory.java 2008-02-28 12:28:42 UTC (rev 10152)
@@ -30,10 +30,10 @@
import org.jboss.portal.portlet.controller.state.PageNavigationalState;
import org.jboss.portal.portlet.controller.state.StateControllerContext;
import org.jboss.portal.portlet.invocation.response.ErrorResponse;
-import org.jboss.portal.portlet.invocation.response.FragmentResponse;
import org.jboss.portal.portlet.invocation.response.HTTPRedirectionResponse;
import org.jboss.portal.portlet.invocation.response.PortletInvocationResponse;
import org.jboss.portal.portlet.invocation.response.ResponseProperties;
+import org.jboss.portal.portlet.invocation.response.ContentResponse;
/**
* @author <a href="mailto:julien@jboss.org">Julien Viet</a>
@@ -84,9 +84,9 @@
ResourceResponse resourceResponse = (ResourceResponse)response;
//
- if (resourceResponse.getResponse() instanceof FragmentResponse)
+ if (resourceResponse.getResponse() instanceof ContentResponse)
{
- return new ResourceRenderer((FragmentResponse)resourceResponse.getResponse(), sendNoContentResponseOnEmptyResource);
+ return new ResourceRenderer((ContentResponse)resourceResponse.getResponse(), sendNoContentResponseOnEmptyResource);
}
else
{
Modified: modules/portlet/trunk/test/src/main/java/org/jboss/portal/portlet/test/controller/FragmentRenderer.java
===================================================================
--- modules/portlet/trunk/test/src/main/java/org/jboss/portal/portlet/test/controller/FragmentRenderer.java 2008-02-28 11:57:23 UTC (rev 10151)
+++ modules/portlet/trunk/test/src/main/java/org/jboss/portal/portlet/test/controller/FragmentRenderer.java 2008-02-28 12:28:42 UTC (rev 10152)
@@ -24,7 +24,7 @@
package org.jboss.portal.portlet.test.controller;
import org.jboss.portal.portlet.invocation.response.ErrorResponse;
-import org.jboss.portal.portlet.invocation.response.FragmentResponse;
+import org.jboss.portal.portlet.invocation.response.ContentResponse;
/**
* @author <a href="mailto:chris.laprun@jboss.com">Chris Laprun</a>
@@ -32,7 +32,7 @@
*/
public interface FragmentRenderer
{
- String renderPortlet(FragmentResponse fragment);
+ String renderPortlet(ContentResponse fragment);
String renderError(ErrorResponse error);
}
Modified: modules/portlet/trunk/test/src/main/java/org/jboss/portal/portlet/test/controller/PageRenderer.java
===================================================================
--- modules/portlet/trunk/test/src/main/java/org/jboss/portal/portlet/test/controller/PageRenderer.java 2008-02-28 11:57:23 UTC (rev 10151)
+++ modules/portlet/trunk/test/src/main/java/org/jboss/portal/portlet/test/controller/PageRenderer.java 2008-02-28 12:28:42 UTC (rev 10152)
@@ -39,9 +39,9 @@
import org.jboss.portal.portlet.impl.spi.AbstractWindowContext;
import org.jboss.portal.portlet.invocation.RenderInvocation;
import org.jboss.portal.portlet.invocation.response.ErrorResponse;
-import org.jboss.portal.portlet.invocation.response.FragmentResponse;
import org.jboss.portal.portlet.invocation.response.PortletInvocationResponse;
import org.jboss.portal.portlet.invocation.response.ResponseProperties;
+import org.jboss.portal.portlet.invocation.response.ContentResponse;
import org.jboss.portal.portlet.controller.state.WindowNavigationalState;
import org.jboss.portal.portlet.controller.state.PageNavigationalState;
import org.w3c.dom.Element;
@@ -62,7 +62,7 @@
{
protected FragmentRenderer fragmentRenderer = new SimpleFragmentRenderer();
- protected List<FragmentResponse> fragments;
+ protected List<ContentResponse> fragments;
protected List<ErrorResponse> errors;
protected PageNavigationalState pageNavigationalState;
@@ -110,7 +110,7 @@
writer.print("<body>");
- for (FragmentResponse fragment : fragments)
+ for (ContentResponse fragment : fragments)
{
writer.print(fragmentRenderer.renderPortlet(fragment));
@@ -136,7 +136,7 @@
Collection<Portlet> portlets = context.getPortlets();
int capacity = portlets.size();
- fragments = new ArrayList<FragmentResponse>(capacity);
+ fragments = new ArrayList<ContentResponse>(capacity);
errors = new ArrayList<ErrorResponse>(capacity);
for (Portlet portlet : portlets)
@@ -175,9 +175,9 @@
{
PortletInvocationResponse response = context.render(render);
- if (response instanceof FragmentResponse)
+ if (response instanceof ContentResponse)
{
- FragmentResponse fragment = (FragmentResponse)response;
+ ContentResponse fragment = (ContentResponse)response;
//
fragments.add(fragment);
Modified: modules/portlet/trunk/test/src/main/java/org/jboss/portal/portlet/test/controller/ResourceRenderer.java
===================================================================
--- modules/portlet/trunk/test/src/main/java/org/jboss/portal/portlet/test/controller/ResourceRenderer.java 2008-02-28 11:57:23 UTC (rev 10151)
+++ modules/portlet/trunk/test/src/main/java/org/jboss/portal/portlet/test/controller/ResourceRenderer.java 2008-02-28 12:28:42 UTC (rev 10152)
@@ -24,7 +24,7 @@
package org.jboss.portal.portlet.test.controller;
import org.jboss.portal.common.io.IOTools;
-import org.jboss.portal.portlet.invocation.response.FragmentResponse;
+import org.jboss.portal.portlet.invocation.response.ContentResponse;
import javax.servlet.ServletOutputStream;
import javax.servlet.http.HttpServletResponse;
@@ -39,12 +39,12 @@
{
/** . */
- private FragmentResponse fragment;
+ private ContentResponse fragment;
/** . */
private boolean sendNoContentResponseOnEmptyResource;
- public ResourceRenderer(FragmentResponse response, boolean sendNoContentResponseOnEmptyResource)
+ public ResourceRenderer(ContentResponse response, boolean sendNoContentResponseOnEmptyResource)
{
super(response.getProperties());
@@ -55,7 +55,7 @@
protected void renderContent(HttpServletResponse resp) throws IOException
{
- if (fragment.getType() == FragmentResponse.TYPE_EMPTY)
+ if (fragment.getType() == ContentResponse.TYPE_EMPTY)
{
if (sendNoContentResponseOnEmptyResource)
{
@@ -90,7 +90,7 @@
}
//
- if (fragment.getType() == FragmentResponse.TYPE_BYTES)
+ if (fragment.getType() == ContentResponse.TYPE_BYTES)
{
ServletOutputStream out = null;
try
Modified: modules/portlet/trunk/test/src/main/java/org/jboss/portal/portlet/test/controller/SimpleFragmentRenderer.java
===================================================================
--- modules/portlet/trunk/test/src/main/java/org/jboss/portal/portlet/test/controller/SimpleFragmentRenderer.java 2008-02-28 11:57:23 UTC (rev 10151)
+++ modules/portlet/trunk/test/src/main/java/org/jboss/portal/portlet/test/controller/SimpleFragmentRenderer.java 2008-02-28 12:28:42 UTC (rev 10152)
@@ -24,7 +24,7 @@
package org.jboss.portal.portlet.test.controller;
import org.jboss.portal.portlet.invocation.response.ErrorResponse;
-import org.jboss.portal.portlet.invocation.response.FragmentResponse;
+import org.jboss.portal.portlet.invocation.response.ContentResponse;
import java.io.UnsupportedEncodingException;
@@ -34,15 +34,15 @@
*/
public class SimpleFragmentRenderer implements FragmentRenderer
{
- public String renderPortlet(FragmentResponse fragment)
+ public String renderPortlet(ContentResponse fragment)
{
- if (fragment.getType() != FragmentResponse.TYPE_EMPTY)
+ if (fragment.getType() != ContentResponse.TYPE_EMPTY)
{
String frag;
//
- if (fragment.getType() == FragmentResponse.TYPE_BYTES)
+ if (fragment.getType() == ContentResponse.TYPE_BYTES)
{
try
{
Modified: modules/portlet/trunk/test/src/main/java/org/jboss/portal/portlet/test/jsp/ControllerFilter.java
===================================================================
--- modules/portlet/trunk/test/src/main/java/org/jboss/portal/portlet/test/jsp/ControllerFilter.java 2008-02-28 11:57:23 UTC (rev 10151)
+++ modules/portlet/trunk/test/src/main/java/org/jboss/portal/portlet/test/jsp/ControllerFilter.java 2008-02-28 12:28:42 UTC (rev 10152)
@@ -28,8 +28,8 @@
import org.jboss.portal.portlet.PortletInvokerException;
import org.jboss.portal.portlet.URLFormat;
import org.jboss.portal.portlet.invocation.response.PortletInvocationResponse;
-import org.jboss.portal.portlet.invocation.response.FragmentResponse;
import org.jboss.portal.portlet.invocation.response.ErrorResponse;
+import org.jboss.portal.portlet.invocation.response.ContentResponse;
import org.jboss.portal.portlet.controller.PortletController;
import org.jboss.portal.portlet.controller.request.PortletActionRequest;
import org.jboss.portal.portlet.controller.impl.request.ControllerRequestFactory;
@@ -161,31 +161,31 @@
PortletInvocationResponse pir = resourceResponse.getResponse();
//
- if (pir instanceof FragmentResponse)
+ if (pir instanceof ContentResponse)
{
- FragmentResponse fragment = (FragmentResponse)pir;
+ ContentResponse contentResponse = (ContentResponse)pir;
//
- if (fragment.getType() == FragmentResponse.TYPE_EMPTY)
+ if (contentResponse.getType() == ContentResponse.TYPE_EMPTY)
{
resp.setStatus(HttpServletResponse.SC_NO_CONTENT);
}
else
{
- String contentType = fragment.getContentType();
+ String contentType = contentResponse.getContentType();
if (contentType != null)
{
resp.setContentType(contentType);
}
//
- if (fragment.getType() == FragmentResponse.TYPE_BYTES)
+ if (contentResponse.getType() == ContentResponse.TYPE_BYTES)
{
ServletOutputStream out = null;
try
{
out = resp.getOutputStream();
- out.write(fragment.getBytes());
+ out.write(contentResponse.getBytes());
}
finally
{
@@ -198,7 +198,7 @@
try
{
writer = resp.getWriter();
- writer.write(fragment.getChars());
+ writer.write(contentResponse.getChars());
}
finally
{
Modified: modules/portlet/trunk/test/src/main/java/org/jboss/portal/portlet/test/jsp/taglib/HeadersTag.java
===================================================================
--- modules/portlet/trunk/test/src/main/java/org/jboss/portal/portlet/test/jsp/taglib/HeadersTag.java 2008-02-28 11:57:23 UTC (rev 10151)
+++ modules/portlet/trunk/test/src/main/java/org/jboss/portal/portlet/test/jsp/taglib/HeadersTag.java 2008-02-28 12:28:42 UTC (rev 10152)
@@ -26,8 +26,8 @@
import org.jboss.portal.portlet.test.jsp.WindowResult;
import org.jboss.portal.portlet.test.jsp.PortalPrepareResponse;
import org.jboss.portal.portlet.invocation.response.PortletInvocationResponse;
-import org.jboss.portal.portlet.invocation.response.FragmentResponse;
import org.jboss.portal.portlet.invocation.response.ResponseProperties;
+import org.jboss.portal.portlet.invocation.response.ContentResponse;
import org.jboss.portal.common.util.MultiValuedPropertyMap;
import org.jboss.portal.common.xml.XMLTools;
import org.w3c.dom.Element;
@@ -69,9 +69,9 @@
PortletInvocationResponse response = result.getResponse();
//
- if (response instanceof FragmentResponse)
+ if (response instanceof ContentResponse)
{
- FragmentResponse fragmentResponse = (FragmentResponse)response;
+ ContentResponse fragmentResponse = (ContentResponse)response;
//
ResponseProperties properties = fragmentResponse.getProperties();
Modified: modules/portlet/trunk/test/src/main/java/org/jboss/portal/portlet/test/jsp/taglib/PortletMarkupTag.java
===================================================================
--- modules/portlet/trunk/test/src/main/java/org/jboss/portal/portlet/test/jsp/taglib/PortletMarkupTag.java 2008-02-28 11:57:23 UTC (rev 10151)
+++ modules/portlet/trunk/test/src/main/java/org/jboss/portal/portlet/test/jsp/taglib/PortletMarkupTag.java 2008-02-28 12:28:42 UTC (rev 10152)
@@ -24,7 +24,7 @@
import org.jboss.portal.portlet.test.jsp.PortalRenderResponse;
import org.jboss.portal.portlet.invocation.response.PortletInvocationResponse;
-import org.jboss.portal.portlet.invocation.response.FragmentResponse;
+import org.jboss.portal.portlet.invocation.response.ContentResponse;
import org.jboss.portal.portlet.controller.state.WindowNavigationalState;
import org.jboss.portal.WindowState;
@@ -49,9 +49,9 @@
if (portletResp != null)
{
- if (portletResp instanceof FragmentResponse)
+ if (portletResp instanceof ContentResponse)
{
- FragmentResponse fragment = (FragmentResponse)portletResp;
+ ContentResponse fragment = (ContentResponse)portletResp;
WindowNavigationalState windowNS = null;
if (renderResponse.getPageNavigationalState() != null)
{
@@ -59,16 +59,16 @@
}
if (windowNS == null || !windowNS.getWindowState().equals(WindowState.MINIMIZED))
{
- if (fragment.getType() != FragmentResponse.TYPE_EMPTY)
+ if (fragment.getType() != ContentResponse.TYPE_EMPTY)
{
String frag;
- if (fragment.getType() == FragmentResponse.TYPE_BYTES)
+ if (fragment.getType() == ContentResponse.TYPE_BYTES)
{
frag = fragment.getBytes().toString();
}
else
{
- frag = fragment.getChars().toString();
+ frag = fragment.getChars();
}
out.write(frag);
Modified: modules/portlet/trunk/test/src/main/java/org/jboss/portal/portlet/test/jsp/taglib/PortletTag.java
===================================================================
--- modules/portlet/trunk/test/src/main/java/org/jboss/portal/portlet/test/jsp/taglib/PortletTag.java 2008-02-28 11:57:23 UTC (rev 10151)
+++ modules/portlet/trunk/test/src/main/java/org/jboss/portal/portlet/test/jsp/taglib/PortletTag.java 2008-02-28 12:28:42 UTC (rev 10152)
@@ -28,9 +28,9 @@
import org.jboss.portal.portlet.test.jsp.WindowDef;
import org.jboss.portal.portlet.test.jsp.WindowResult;
import org.jboss.portal.portlet.invocation.response.PortletInvocationResponse;
-import org.jboss.portal.portlet.invocation.response.FragmentResponse;
import org.jboss.portal.portlet.invocation.response.ErrorResponse;
import org.jboss.portal.portlet.invocation.response.UnavailableResponse;
+import org.jboss.portal.portlet.invocation.response.ContentResponse;
import org.jboss.portal.Mode;
import org.jboss.portal.WindowState;
import org.jboss.portal.common.util.Tools;
@@ -278,7 +278,7 @@
PortletInvocationResponse portletResponse = result.getResponse();
//
- if (portletResponse instanceof FragmentResponse)
+ if (portletResponse instanceof ContentResponse)
{
this.result = result;
//
16 years, 8 months
JBoss Portal SVN: r10151 - in modules/portlet/trunk: portlet/src/main/java/org/jboss/portal/portlet/impl/jsr168/api and 4 other directories.
by portal-commits@lists.jboss.org
Author: julien(a)jboss.com
Date: 2008-02-28 06:57:23 -0500 (Thu, 28 Feb 2008)
New Revision: 10151
Modified:
modules/portlet/trunk/portlet/src/main/java/org/jboss/portal/portlet/impl/jsr168/ContentBuffer.java
modules/portlet/trunk/portlet/src/main/java/org/jboss/portal/portlet/impl/jsr168/api/MimeResponseImpl.java
modules/portlet/trunk/portlet/src/main/java/org/jboss/portal/portlet/invocation/response/FragmentResponse.java
modules/portlet/trunk/portlet/src/test/java/org/jboss/portal/test/portlet/ContentBufferTestCase.java
modules/portlet/trunk/test/src/main/java/org/jboss/portal/portlet/test/controller/ResourceRenderer.java
modules/portlet/trunk/test/src/main/java/org/jboss/portal/portlet/test/controller/SimpleFragmentRenderer.java
modules/portlet/trunk/test/src/main/java/org/jboss/portal/portlet/test/jsp/ControllerFilter.java
Log:
refactor to remove the dependency of FragmentResponse over ContentBuffer
Modified: modules/portlet/trunk/portlet/src/main/java/org/jboss/portal/portlet/impl/jsr168/ContentBuffer.java
===================================================================
--- modules/portlet/trunk/portlet/src/main/java/org/jboss/portal/portlet/impl/jsr168/ContentBuffer.java 2008-02-28 10:15:38 UTC (rev 10150)
+++ modules/portlet/trunk/portlet/src/main/java/org/jboss/portal/portlet/impl/jsr168/ContentBuffer.java 2008-02-28 11:57:23 UTC (rev 10151)
@@ -38,15 +38,6 @@
public class ContentBuffer
{
- /** . */
- public static final int TYPE_EMPTY = 0;
-
- /** . */
- public static final int TYPE_CHARS = 1;
-
- /** . */
- public static final int TYPE_BYTES = 2;
-
/** The output as a bytes if any. */
private ClosableOutputStream bytes;
@@ -71,70 +62,38 @@
this.commited = false;
}
- public int getType()
- {
- if (bytes == null)
- {
- if (chars == null)
- {
- return TYPE_EMPTY;
- }
- else
- {
- return TYPE_CHARS;
- }
- }
- else
- {
- return TYPE_BYTES;
- }
- }
-
/**
- * Return the content as a string.
+ * Return the bytes of the content held by the fragment or null.
*
- * @return the content
- */
- public String getContent()
- {
- switch (getType())
- {
- case TYPE_CHARS:
- return getChars().toString();
- case TYPE_BYTES:
- return getBytes().toString();
- }
- return "";
- }
-
- /**
- * Return the bytes of the content held by the fragment.
- *
* @return the bytes
- * @throws IllegalArgumentException if the type is not bytes
*/
- public ByteArrayOutputStream getBytes() throws IllegalArgumentException
+ public byte[] getBytes()
{
if (bytes == null)
{
- throw new IllegalStateException("Bytes not used");
+ return null;
}
- return (ByteArrayOutputStream)bytes.out;
+ else
+ {
+ return ((ByteArrayOutputStream)bytes.out).toByteArray();
+ }
}
/**
- * Return the chars of the content held by the fragment.
+ * Return the chars of the content held by the fragment or null.
*
* @return the chars
- * @throws IllegalArgumentException if the type is not chars
*/
- public StringWriter getChars() throws IllegalArgumentException
+ public String getChars()
{
if (chars == null)
{
- throw new IllegalStateException("Chars not used");
+ return null;
}
- return (StringWriter)chars.writer;
+ else
+ {
+ return chars.writer.toString();
+ }
}
/**
Modified: modules/portlet/trunk/portlet/src/main/java/org/jboss/portal/portlet/impl/jsr168/api/MimeResponseImpl.java
===================================================================
--- modules/portlet/trunk/portlet/src/main/java/org/jboss/portal/portlet/impl/jsr168/api/MimeResponseImpl.java 2008-02-28 10:15:38 UTC (rev 10150)
+++ modules/portlet/trunk/portlet/src/main/java/org/jboss/portal/portlet/impl/jsr168/api/MimeResponseImpl.java 2008-02-28 11:57:23 UTC (rev 10151)
@@ -115,7 +115,9 @@
return new FragmentResponse(
getProperties(false),
preq.attributes.getAttributeMap(),
- responseContent,
+ responseContent.getContentType(),
+ responseContent.getBytes(),
+ responseContent.getChars(),
responseTitle,
cc,
responseNextModes != null ? responseNextModes : preq.supportedModes);
Modified: modules/portlet/trunk/portlet/src/main/java/org/jboss/portal/portlet/invocation/response/FragmentResponse.java
===================================================================
--- modules/portlet/trunk/portlet/src/main/java/org/jboss/portal/portlet/invocation/response/FragmentResponse.java 2008-02-28 10:15:38 UTC (rev 10150)
+++ modules/portlet/trunk/portlet/src/main/java/org/jboss/portal/portlet/invocation/response/FragmentResponse.java 2008-02-28 11:57:23 UTC (rev 10151)
@@ -23,13 +23,8 @@
package org.jboss.portal.portlet.invocation.response;
import org.jboss.portal.portlet.cache.CacheControl;
-import org.jboss.portal.portlet.impl.jsr168.ContentBuffer;
import org.jboss.portal.Mode;
-import java.io.ByteArrayOutputStream;
-import java.io.OutputStream;
-import java.io.PrintWriter;
-import java.io.StringWriter;
import java.util.Set;
import java.util.Map;
@@ -43,13 +38,13 @@
{
/** . */
- public static final int TYPE_EMPTY = ContentBuffer.TYPE_EMPTY;
+ public static final int TYPE_EMPTY = 0;
/** . */
- public static final int TYPE_CHARS = ContentBuffer.TYPE_CHARS;
+ public static final int TYPE_CHARS = 1;
/** . */
- public static final int TYPE_BYTES = ContentBuffer.TYPE_BYTES;
+ public static final int TYPE_BYTES = 2;
/** . */
private final ResponseProperties properties;
@@ -57,9 +52,15 @@
/** . */
private final Map<String, Object> attributes;
+ /** The result content type if any. */
+ private String contentType;
+
/** . */
- private final ContentBuffer buffer;
+ private final byte[] bytes;
+ /** . */
+ private final String chars;
+
/** The title if any. */
private final String title;
@@ -69,11 +70,21 @@
/** . */
private final Set<Mode> nextModes;
- public FragmentResponse(ResponseProperties properties, Map<String, Object> attributes, ContentBuffer buffer, String title, CacheControl cacheControl, Set<Mode> nextModes)
+ public FragmentResponse(
+ ResponseProperties properties,
+ Map<String, Object> attributes,
+ String contentType,
+ byte[] bytes,
+ String chars,
+ String title,
+ CacheControl cacheControl,
+ Set<Mode> nextModes)
{
this.properties = properties;
this.attributes = attributes;
- this.buffer = buffer;
+ this.contentType = contentType;
+ this.bytes = bytes;
+ this.chars = chars;
this.title = title;
this.cacheControl = cacheControl;
this.nextModes = nextModes;
@@ -96,18 +107,52 @@
public int getType()
{
- return buffer.getType();
+ if (bytes == null)
+ {
+ if (chars == null)
+ {
+ return TYPE_EMPTY;
+ }
+ else
+ {
+ return TYPE_CHARS;
+ }
+ }
+ else
+ {
+ return TYPE_BYTES;
+ }
}
/**
+ * Return the content as a string.
+ *
+ * @return the content
+ */
+ public String getContent()
+ {
+ switch (getType())
+ {
+ case TYPE_CHARS:
+ return getChars();
+ case TYPE_BYTES:
+ return new String(bytes);
+ case TYPE_EMPTY:
+ return "";
+ default:
+ throw new AssertionError();
+ }
+ }
+
+ /**
* Return the bytes of the content held by the fragment.
*
* @return the bytes
* @throws IllegalArgumentException if the type is not bytes
*/
- public ByteArrayOutputStream getBytes() throws IllegalArgumentException
+ public byte[] getBytes() throws IllegalArgumentException
{
- return buffer.getBytes();
+ return bytes;
}
/**
@@ -116,9 +161,9 @@
* @return the chars
* @throws IllegalArgumentException if the type is not chars
*/
- public StringWriter getChars() throws IllegalArgumentException
+ public String getChars() throws IllegalArgumentException
{
- return buffer.getChars();
+ return chars;
}
/**
@@ -138,34 +183,9 @@
*/
public String getContentType()
{
- return buffer.getContentType();
+ return contentType;
}
- /**
- * Returns the writer.
- *
- * @return the writer
- * @throws IllegalStateException if the output stream is already used or if no content type is defined
- */
- public PrintWriter getWriter() throws IllegalStateException
- {
- return buffer.getWriter();
- }
-
- /**
- * @return the output stream
- * @throws IllegalStateException if the window writer is already used or if no content type is defined
- */
- public OutputStream getOutputStream() throws IllegalStateException
- {
- return buffer.getOutputStream();
- }
-
- public ContentBuffer getBuffer()
- {
- return buffer;
- }
-
public Set<Mode> getNextModes()
{
return nextModes;
Modified: modules/portlet/trunk/portlet/src/test/java/org/jboss/portal/test/portlet/ContentBufferTestCase.java
===================================================================
--- modules/portlet/trunk/portlet/src/test/java/org/jboss/portal/test/portlet/ContentBufferTestCase.java 2008-02-28 10:15:38 UTC (rev 10150)
+++ modules/portlet/trunk/portlet/src/test/java/org/jboss/portal/test/portlet/ContentBufferTestCase.java 2008-02-28 11:57:23 UTC (rev 10151)
@@ -25,6 +25,7 @@
import org.jboss.unit.api.pojo.annotations.Test;
import org.jboss.portal.portlet.impl.jsr168.ContentBuffer;
import static org.jboss.unit.api.Assert.*;
+import static org.jboss.unit.api.Assert.assertEquals;
import java.io.PrintWriter;
import java.io.OutputStream;
@@ -46,7 +47,7 @@
PrintWriter writer = buffer.getWriter();
writer.print("foo");
buffer.reset();
- assertChars("", buffer.getChars().getBuffer());
+ assertEquals("", buffer.getChars());
}
@Test
@@ -57,7 +58,7 @@
OutputStream out = buffer.getOutputStream();
out.write("foo".getBytes("UTF8"));
buffer.reset();
- assertEquals(new byte[0], buffer.getBytes().toByteArray());
+ assertEquals(new byte[0], buffer.getBytes());
}
@Test
@@ -96,7 +97,7 @@
assertNotNull(writer);
writer.print("foo");
writer.close();
- assertChars("foo", buffer.getChars().getBuffer());
+ assertEquals("foo", buffer.getChars());
}
@Test
@@ -110,7 +111,7 @@
buffer.commit();
writer.print("bar");
writer.close();
- assertChars("foobar", buffer.getChars().getBuffer());
+ assertEquals("foobar", buffer.getChars());
}
@Test
@@ -123,7 +124,7 @@
assertNotNull(out);
out.write("foo".getBytes("UTF8"));
out.close();
- assertEquals("foo".getBytes("UTF8"), buffer.getBytes().toByteArray());
+ assertEquals("foo".getBytes("UTF8"), buffer.getBytes());
}
@Test
@@ -137,7 +138,7 @@
assertNotNull(out);
out.write("bar".getBytes("UTF8"));
out.close();
- assertEquals("foobar".getBytes("UTF8"), buffer.getBytes().toByteArray());
+ assertEquals("foobar".getBytes("UTF8"), buffer.getBytes());
}
@Test
@@ -183,14 +184,4 @@
out.close();
assertTrue(buffer.isCommited());
}
-
- private void assertChars(String s, StringBuffer sb)
- {
- int length = s.length();
- assertEquals(length, sb.length());
- char[] chars = new char[length];
- sb.getChars(0, length, chars, 0);
- assertEquals(s, new String(chars));
- }
-
}
Modified: modules/portlet/trunk/test/src/main/java/org/jboss/portal/portlet/test/controller/ResourceRenderer.java
===================================================================
--- modules/portlet/trunk/test/src/main/java/org/jboss/portal/portlet/test/controller/ResourceRenderer.java 2008-02-28 10:15:38 UTC (rev 10150)
+++ modules/portlet/trunk/test/src/main/java/org/jboss/portal/portlet/test/controller/ResourceRenderer.java 2008-02-28 11:57:23 UTC (rev 10151)
@@ -96,7 +96,7 @@
try
{
out = resp.getOutputStream();
- out.write(fragment.getBytes().toByteArray());
+ out.write(fragment.getBytes());
}
finally
{
@@ -109,7 +109,7 @@
try
{
writer = resp.getWriter();
- writer.write(fragment.getChars().toString());
+ writer.write(fragment.getChars());
}
finally
{
Modified: modules/portlet/trunk/test/src/main/java/org/jboss/portal/portlet/test/controller/SimpleFragmentRenderer.java
===================================================================
--- modules/portlet/trunk/test/src/main/java/org/jboss/portal/portlet/test/controller/SimpleFragmentRenderer.java 2008-02-28 10:15:38 UTC (rev 10150)
+++ modules/portlet/trunk/test/src/main/java/org/jboss/portal/portlet/test/controller/SimpleFragmentRenderer.java 2008-02-28 11:57:23 UTC (rev 10151)
@@ -26,6 +26,8 @@
import org.jboss.portal.portlet.invocation.response.ErrorResponse;
import org.jboss.portal.portlet.invocation.response.FragmentResponse;
+import java.io.UnsupportedEncodingException;
+
/**
* @author <a href="mailto:chris.laprun@jboss.com">Chris Laprun</a>
* @version $Revision: 9748 $
@@ -42,11 +44,18 @@
//
if (fragment.getType() == FragmentResponse.TYPE_BYTES)
{
- frag = fragment.getBytes().toString();
+ try
+ {
+ frag = new String(fragment.getBytes(), "UTF-8");
+ }
+ catch (UnsupportedEncodingException e)
+ {
+ throw new Error(e);
+ }
}
else
{
- frag = fragment.getChars().toString();
+ frag = fragment.getChars();
}
StringBuilder builder = new StringBuilder(frag.length() + 50);
Modified: modules/portlet/trunk/test/src/main/java/org/jboss/portal/portlet/test/jsp/ControllerFilter.java
===================================================================
--- modules/portlet/trunk/test/src/main/java/org/jboss/portal/portlet/test/jsp/ControllerFilter.java 2008-02-28 10:15:38 UTC (rev 10150)
+++ modules/portlet/trunk/test/src/main/java/org/jboss/portal/portlet/test/jsp/ControllerFilter.java 2008-02-28 11:57:23 UTC (rev 10151)
@@ -185,7 +185,7 @@
try
{
out = resp.getOutputStream();
- out.write(fragment.getBytes().toByteArray());
+ out.write(fragment.getBytes());
}
finally
{
@@ -198,7 +198,7 @@
try
{
writer = resp.getWriter();
- writer.write(fragment.getChars().toString());
+ writer.write(fragment.getChars());
}
finally
{
16 years, 8 months
JBoss Portal SVN: r10150 - in branches/presentation: core-presentation/src/main/org/jboss/portal/core/presentation/server and 6 other directories.
by portal-commits@lists.jboss.org
Author: sohil.shah(a)jboss.com
Date: 2008-02-28 05:15:38 -0500 (Thu, 28 Feb 2008)
New Revision: 10150
Added:
branches/presentation/presentation/src/main/org/jboss/portal/presentation/test/portal/
branches/presentation/presentation/src/main/org/jboss/portal/presentation/test/portal/MockContext.java
branches/presentation/presentation/src/main/org/jboss/portal/presentation/test/portal/MockInstance.java
branches/presentation/presentation/src/main/org/jboss/portal/presentation/test/portal/MockPage.java
branches/presentation/presentation/src/main/org/jboss/portal/presentation/test/portal/MockPortal.java
branches/presentation/presentation/src/main/org/jboss/portal/presentation/test/portal/MockPortalObject.java
branches/presentation/presentation/src/main/org/jboss/portal/presentation/test/portal/MockPortalServer.java
branches/presentation/presentation/src/main/org/jboss/portal/presentation/test/portal/MockPortlet.java
branches/presentation/presentation/src/main/org/jboss/portal/presentation/test/portal/MockWindow.java
branches/presentation/presentation/src/main/org/jboss/portal/presentation/test/portal/plugin/
branches/presentation/presentation/src/main/org/jboss/portal/presentation/test/portal/plugin/MainProcessor.java
branches/presentation/presentation/src/main/org/jboss/portal/presentation/test/portal/plugin/PresentationServerImpl.java
branches/presentation/presentation/src/main/org/jboss/portal/presentation/test/portal/plugin/StructuralObjectImpl.java
branches/presentation/presentation/src/main/org/jboss/portal/presentation/test/portal/plugin/StructuralStateContextImpl.java
branches/presentation/presentation/src/main/org/jboss/portal/presentation/test/portal/plugin/StructuralStateImpl.java
Modified:
branches/presentation/core-presentation/build.xml
branches/presentation/core-presentation/src/main/org/jboss/portal/core/presentation/server/MainProcessor.java
branches/presentation/core-presentation/src/resources/presentation-sar/META-INF/jboss-service.xml
branches/presentation/presentation/build.xml
branches/presentation/presentation/src/main/org/jboss/portal/presentation/test/ajax/JBossUnitSandBox.java
Log:
testsuite - Integrating PF with a Mock Portal Server to be used in the test suite
Modified: branches/presentation/core-presentation/build.xml
===================================================================
--- branches/presentation/core-presentation/build.xml 2008-02-28 01:18:35 UTC (rev 10149)
+++ branches/presentation/core-presentation/build.xml 2008-02-28 10:15:38 UTC (rev 10150)
@@ -168,6 +168,8 @@
<copy file="${gwt.gwt.root}/lib/gwt-user.jar" todir="${build.resources}/presentation-sar/lib" overwrite="true"/>
<copy file="${build.lib}/portal-core-presentation-lib.jar" todir="${build.resources}/presentation-sar/lib" overwrite="true"/>
<copy file="${jboss.portal-presentation.lib}/portal-presentation-lib.jar" todir="${build.resources}/presentation-sar/lib" overwrite="true"/>
+ <!-- TODO: remove me -->
+ <copy file="${jboss.portal-presentation.lib}/portal-presentation-test-lib.jar" todir="${build.resources}/presentation-sar/lib" overwrite="true"/>
<copy todir="${build.resources}/presentation-sar">
<fileset dir="${jboss.portal-presentation.lib}" includes="presentation.war"/>
</copy>
Modified: branches/presentation/core-presentation/src/main/org/jboss/portal/core/presentation/server/MainProcessor.java
===================================================================
--- branches/presentation/core-presentation/src/main/org/jboss/portal/core/presentation/server/MainProcessor.java 2008-02-28 01:18:35 UTC (rev 10149)
+++ branches/presentation/core-presentation/src/main/org/jboss/portal/core/presentation/server/MainProcessor.java 2008-02-28 10:15:38 UTC (rev 10150)
@@ -188,7 +188,7 @@
decoder.decode(getActivation.getQueryParameters(), formParameters);
- // We assume that for now
+ //TODO: We assume that for now
UIWindow uiWindow = (UIWindow)presentationContext.getUIContext().getObject(id);
//
Modified: branches/presentation/core-presentation/src/resources/presentation-sar/META-INF/jboss-service.xml
===================================================================
--- branches/presentation/core-presentation/src/resources/presentation-sar/META-INF/jboss-service.xml 2008-02-28 01:18:35 UTC (rev 10149)
+++ branches/presentation/core-presentation/src/resources/presentation-sar/META-INF/jboss-service.xml 2008-02-28 10:15:38 UTC (rev 10150)
@@ -23,7 +23,6 @@
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~-->
<server>
-
<mbean
code="org.jboss.portal.presentation.client.controller.UIController"
name="portal:service=Controller,type=Presentation"
@@ -59,7 +58,27 @@
<depends
optional-attribute-name="Controller"
proxy-type="attribute">portal:service=Controller,type=Ajax/Presentation</depends>
+ </mbean>
+ <mbean
+ code="org.jboss.portal.core.presentation.model.StructuralStateContextImpl"
+ name="portal:container=ModelLoader"
+ xmbean-dd=""
+ xmbean-code="org.jboss.portal.jems.as.system.JBossServiceModelMBean">
+ <xmbean/>
+ <depends optional-attribute-name="PortalObjectContainer" proxy-type="attribute">portal:container=PortalObject</depends>
+ <depends>portal:container=PortalObject</depends>
+ <depends>portal:service=PageService</depends>
+ <depends>portal:commandFactory=DefaultPortal</depends>
+ <depends>portal:urlFactory=Delegating</depends>
+ <depends>portal:service=InterceptorStackFactory,type=Command</depends>
+ <depends>portal:container=Instance</depends>
+ <depends>portal:service=PortalAuthorizationManagerFactory</depends>
+ <depends>portal:service=CustomizationManager</depends>
+ <depends>portal:service=ContentProviderRegistry</depends>
+ <depends>portal:service=ResponseHandler,type=Selector</depends>
+ <depends>portal:service=ControlPolicy,type=Page</depends>
</mbean>
+ <!--
<mbean
code="org.jboss.portal.core.presentation.server.PresentationServerImpl"
name="portal:service=PresentationServer"
@@ -81,6 +100,8 @@
<depends>portal:service=ResponseHandler,type=Selector</depends>
<depends>portal:service=ControlPolicy,type=Page</depends>
</mbean>
+ -->
+ <!--
<mbean
code="org.jboss.portal.core.presentation.server.MainProcessor"
name="portal:service=Processor"
@@ -99,24 +120,20 @@
<depends optional-attribute-name="PortalObjectContainer" proxy-type="attribute">portal:container=PortalObject</depends>
<depends optional-attribute-name="CustomizationManager" proxy-type="attribute">portal:service=CustomizationManager</depends>
</mbean>
+ -->
<mbean
- code="org.jboss.portal.core.presentation.model.StructuralStateContextImpl"
- name="portal:container=ModelLoader"
+ code="org.jboss.portal.presentation.test.portal.plugin.PresentationServerImpl"
+ name="portal:service=PresentationServer"
xmbean-dd=""
xmbean-code="org.jboss.portal.jems.as.system.JBossServiceModelMBean">
<xmbean/>
- <depends optional-attribute-name="PortalObjectContainer" proxy-type="attribute">portal:container=PortalObject</depends>
- <depends>portal:container=PortalObject</depends>
- <depends>portal:service=PageService</depends>
- <depends>portal:commandFactory=DefaultPortal</depends>
- <depends>portal:urlFactory=Delegating</depends>
- <depends>portal:service=InterceptorStackFactory,type=Command</depends>
- <depends>portal:container=Instance</depends>
- <depends>portal:service=PortalAuthorizationManagerFactory</depends>
- <depends>portal:service=CustomizationManager</depends>
- <depends>portal:service=ContentProviderRegistry</depends>
- <depends>portal:service=ResponseHandler,type=Selector</depends>
- <depends>portal:service=ControlPolicy,type=Page</depends>
+ <depends optional-attribute-name="Processor" proxy-type="attribute">portal:service=Processor</depends>
</mbean>
-
+ <mbean
+ code="org.jboss.portal.presentation.test.portal.plugin.MainProcessor"
+ name="portal:service=Processor"
+ xmbean-dd=""
+ xmbean-code="org.jboss.portal.jems.as.system.JBossServiceModelMBean">
+ <xmbean/>
+ </mbean>
</server>
Modified: branches/presentation/presentation/build.xml
===================================================================
--- branches/presentation/presentation/build.xml 2008-02-28 01:18:35 UTC (rev 10149)
+++ branches/presentation/presentation/build.xml 2008-02-28 10:15:38 UTC (rev 10150)
@@ -243,8 +243,7 @@
<arg line="-out ${build.resources}/presentation.war/"/>
<arg line="org.jboss.portal.uiserver.ajax.PartialRefresh"/>
</java>
- -->
-
+ -->
<path id="full.gwt.classpath">
<path refid="gwt.gwt.classpath"/>
<path refid="mygwt.mygwt.classpath"/>
@@ -257,7 +256,9 @@
</classpath>
<arg line="-out ${build.lib}/ajax/"/>
<arg line="org.jboss.portal.presentation.ajax.Portal"/>
- </java>
+ </java>
+
+
<jar jarfile="${build.lib}/presentation.war">
<fileset dir="${build.resources}/presentation-war"></fileset>
<fileset dir="${build.lib}/ajax/org.jboss.portal.presentation.ajax.Portal"></fileset>
@@ -327,11 +328,17 @@
</target>
<target name="test-jbossunit" depends="init">
- <taskdef name="jboss-unit" classname="org.jboss.unit.tooling.ant.JBossUnitTask" classpathref="library.classpath"/>
+ <path id="jboss-unit.classpath">
+ <pathelement location="/home/soshah/.m2/repository/org/jboss/unit/jboss-unit/1.2.0-SNAPSHOT/jboss-unit-1.2.0-SNAPSHOT.jar"/>
+ <pathelement location="/home/soshah/.m2/repository/org/jboss/unit/jboss-unit-tooling-ant/1.2.0-SNAPSHOT/jboss-unit-tooling-ant-1.2.0-SNAPSHOT.jar"/>
+ <pathelement location="/home/soshah/.m2/repository/org/jboss/unit/jboss-unit-tooling-core/1.2.0-SNAPSHOT/jboss-unit-tooling-core-1.2.0-SNAPSHOT.jar"/>
+ <pathelement location="${build.lib}/portal-presentation-test-lib.jar"/>
+ </path>
+ <taskdef name="jboss-unit" classname="org.jboss.unit.tooling.ant.JBossUnitTask" classpathref="jboss-unit.classpath"/>
<jboss-unit>
<tests config="src/resources/jboss-unit/config/jboss-unit.xml"/>
<classpath>
- <path refid="library.classpath"/>
+ <path refid="jboss-unit.classpath"/>
</classpath>
</jboss-unit>
</target>
Modified: branches/presentation/presentation/src/main/org/jboss/portal/presentation/test/ajax/JBossUnitSandBox.java
===================================================================
--- branches/presentation/presentation/src/main/org/jboss/portal/presentation/test/ajax/JBossUnitSandBox.java 2008-02-28 01:18:35 UTC (rev 10149)
+++ branches/presentation/presentation/src/main/org/jboss/portal/presentation/test/ajax/JBossUnitSandBox.java 2008-02-28 10:15:38 UTC (rev 10150)
@@ -23,7 +23,9 @@
package org.jboss.portal.presentation.test.ajax;
import org.jboss.unit.api.pojo.annotations.Test;
+import static org.jboss.unit.api.Assert.*;
+
/**
* @author <a href="mailto:sshah@redhat.com">Sohil Shah</a>
*
@@ -33,6 +35,6 @@
@Test
public void test()
{
- System.out.println("Simple JBossUnit Test in the PresentationFramework successfully executed....");
+ fail("Simple JBossUnit Test in the PresentationFramework successfully executed....");
}
}
Added: branches/presentation/presentation/src/main/org/jboss/portal/presentation/test/portal/MockContext.java
===================================================================
--- branches/presentation/presentation/src/main/org/jboss/portal/presentation/test/portal/MockContext.java (rev 0)
+++ branches/presentation/presentation/src/main/org/jboss/portal/presentation/test/portal/MockContext.java 2008-02-28 10:15:38 UTC (rev 10150)
@@ -0,0 +1,55 @@
+/******************************************************************************
+ * JBoss, a division of Red Hat *
+ * Copyright 2006, Red Hat Middleware, LLC, and individual *
+ * contributors as indicated by the @authors tag. See the *
+ * copyright.txt in the distribution for a full listing of *
+ * individual contributors. *
+ * *
+ * This is free software; you can redistribute it and/or modify it *
+ * under the terms of the GNU Lesser General Public License as *
+ * published by the Free Software Foundation; either version 2.1 of *
+ * the License, or (at your option) any later version. *
+ * *
+ * This software is distributed in the hope that it will be useful, *
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of *
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU *
+ * Lesser General Public License for more details. *
+ * *
+ * You should have received a copy of the GNU Lesser General Public *
+ * License along with this software; if not, write to the Free *
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA *
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org. *
+ ******************************************************************************/
+package org.jboss.portal.presentation.test.portal;
+
+import java.util.List;
+
+/**
+ * @author <a href="mailto:sshah@redhat.com">Sohil Shah</a>
+ *
+ */
+public class MockContext extends MockPortalObject
+{
+ /**
+ *
+ */
+ private List portals = null;
+
+ /**
+ *
+ * @param id
+ */
+ public MockContext(String id, List portals)
+ {
+ super(id);
+ this.portals = portals;
+ }
+
+ /**
+ *
+ */
+ public List getChildren()
+ {
+ return this.portals;
+ }
+}
Added: branches/presentation/presentation/src/main/org/jboss/portal/presentation/test/portal/MockInstance.java
===================================================================
--- branches/presentation/presentation/src/main/org/jboss/portal/presentation/test/portal/MockInstance.java (rev 0)
+++ branches/presentation/presentation/src/main/org/jboss/portal/presentation/test/portal/MockInstance.java 2008-02-28 10:15:38 UTC (rev 10150)
@@ -0,0 +1,44 @@
+/******************************************************************************
+ * JBoss, a division of Red Hat *
+ * Copyright 2006, Red Hat Middleware, LLC, and individual *
+ * contributors as indicated by the @authors tag. See the *
+ * copyright.txt in the distribution for a full listing of *
+ * individual contributors. *
+ * *
+ * This is free software; you can redistribute it and/or modify it *
+ * under the terms of the GNU Lesser General Public License as *
+ * published by the Free Software Foundation; either version 2.1 of *
+ * the License, or (at your option) any later version. *
+ * *
+ * This software is distributed in the hope that it will be useful, *
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of *
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU *
+ * Lesser General Public License for more details. *
+ * *
+ * You should have received a copy of the GNU Lesser General Public *
+ * License along with this software; if not, write to the Free *
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA *
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org. *
+ ******************************************************************************/
+package org.jboss.portal.presentation.test.portal;
+
+import org.jboss.portal.portlet.PortletInvokerException;
+import org.jboss.portal.portlet.invocation.PortletInvocation;
+import org.jboss.portal.portlet.invocation.response.PortletInvocationResponse;
+
+/**
+ * @author <a href="mailto:sshah@redhat.com">Sohil Shah</a>
+ *
+ */
+public class MockInstance
+{
+ /**
+ * Invoke the instance
+ *
+ * @param invocation the invocation
+ */
+ public PortletInvocationResponse invoke(PortletInvocation invocation) throws PortletInvokerException
+ {
+ return null;
+ }
+}
Added: branches/presentation/presentation/src/main/org/jboss/portal/presentation/test/portal/MockPage.java
===================================================================
--- branches/presentation/presentation/src/main/org/jboss/portal/presentation/test/portal/MockPage.java (rev 0)
+++ branches/presentation/presentation/src/main/org/jboss/portal/presentation/test/portal/MockPage.java 2008-02-28 10:15:38 UTC (rev 10150)
@@ -0,0 +1,74 @@
+/******************************************************************************
+ * JBoss, a division of Red Hat *
+ * Copyright 2006, Red Hat Middleware, LLC, and individual *
+ * contributors as indicated by the @authors tag. See the *
+ * copyright.txt in the distribution for a full listing of *
+ * individual contributors. *
+ * *
+ * This is free software; you can redistribute it and/or modify it *
+ * under the terms of the GNU Lesser General Public License as *
+ * published by the Free Software Foundation; either version 2.1 of *
+ * the License, or (at your option) any later version. *
+ * *
+ * This software is distributed in the hope that it will be useful, *
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of *
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU *
+ * Lesser General Public License for more details. *
+ * *
+ * You should have received a copy of the GNU Lesser General Public *
+ * License along with this software; if not, write to the Free *
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA *
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org. *
+ ******************************************************************************/
+package org.jboss.portal.presentation.test.portal;
+
+import java.util.List;
+
+/**
+ * @author <a href="mailto:sshah@redhat.com">Sohil Shah</a>
+ *
+ */
+public class MockPage extends MockPortalObject
+{
+ /**
+ *
+ */
+ private List windows = null;
+
+ /**
+ *
+ * @param id
+ * @param windows
+ */
+ public MockPage(String id, List windows)
+ {
+ super(id);
+ this.windows = windows;
+ }
+
+ /**
+ *
+ * @return
+ */
+ public List getWindows()
+ {
+ return windows;
+ }
+
+ /**
+ *
+ * @param windows
+ */
+ public void setWindows(List windows)
+ {
+ this.windows = windows;
+ }
+
+ /**
+ *
+ */
+ public List getChildren()
+ {
+ return this.windows;
+ }
+}
Added: branches/presentation/presentation/src/main/org/jboss/portal/presentation/test/portal/MockPortal.java
===================================================================
--- branches/presentation/presentation/src/main/org/jboss/portal/presentation/test/portal/MockPortal.java (rev 0)
+++ branches/presentation/presentation/src/main/org/jboss/portal/presentation/test/portal/MockPortal.java 2008-02-28 10:15:38 UTC (rev 10150)
@@ -0,0 +1,55 @@
+/******************************************************************************
+ * JBoss, a division of Red Hat *
+ * Copyright 2006, Red Hat Middleware, LLC, and individual *
+ * contributors as indicated by the @authors tag. See the *
+ * copyright.txt in the distribution for a full listing of *
+ * individual contributors. *
+ * *
+ * This is free software; you can redistribute it and/or modify it *
+ * under the terms of the GNU Lesser General Public License as *
+ * published by the Free Software Foundation; either version 2.1 of *
+ * the License, or (at your option) any later version. *
+ * *
+ * This software is distributed in the hope that it will be useful, *
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of *
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU *
+ * Lesser General Public License for more details. *
+ * *
+ * You should have received a copy of the GNU Lesser General Public *
+ * License along with this software; if not, write to the Free *
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA *
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org. *
+ ******************************************************************************/
+package org.jboss.portal.presentation.test.portal;
+
+import java.util.List;
+
+/**
+ * @author <a href="mailto:sshah@redhat.com">Sohil Shah</a>
+ *
+ */
+public class MockPortal extends MockPortalObject
+{
+ /**
+ *
+ */
+ private List pages = null;
+
+ /**
+ *
+ * @param id
+ */
+ public MockPortal(String id, List pages)
+ {
+ super(id);
+ this.pages = pages;
+ }
+
+ /**
+ *
+ */
+ public List getChildren()
+ {
+ return this.pages;
+ }
+}
Added: branches/presentation/presentation/src/main/org/jboss/portal/presentation/test/portal/MockPortalObject.java
===================================================================
--- branches/presentation/presentation/src/main/org/jboss/portal/presentation/test/portal/MockPortalObject.java (rev 0)
+++ branches/presentation/presentation/src/main/org/jboss/portal/presentation/test/portal/MockPortalObject.java 2008-02-28 10:15:38 UTC (rev 10150)
@@ -0,0 +1,60 @@
+/******************************************************************************
+ * JBoss, a division of Red Hat *
+ * Copyright 2006, Red Hat Middleware, LLC, and individual *
+ * contributors as indicated by the @authors tag. See the *
+ * copyright.txt in the distribution for a full listing of *
+ * individual contributors. *
+ * *
+ * This is free software; you can redistribute it and/or modify it *
+ * under the terms of the GNU Lesser General Public License as *
+ * published by the Free Software Foundation; either version 2.1 of *
+ * the License, or (at your option) any later version. *
+ * *
+ * This software is distributed in the hope that it will be useful, *
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of *
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU *
+ * Lesser General Public License for more details. *
+ * *
+ * You should have received a copy of the GNU Lesser General Public *
+ * License along with this software; if not, write to the Free *
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA *
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org. *
+ ******************************************************************************/
+package org.jboss.portal.presentation.test.portal;
+
+import java.util.List;
+
+/**
+ * @author <a href="mailto:sshah@redhat.com">Sohil Shah</a>
+ *
+ */
+public abstract class MockPortalObject
+{
+ /**
+ *
+ */
+ protected String id = null;
+
+ /**
+ *
+ * @param id
+ */
+ public MockPortalObject(String id)
+ {
+ this.id = id;
+ }
+
+ /**
+ *
+ * @return
+ */
+ public String getId()
+ {
+ return this.id;
+ }
+
+ /**
+ *
+ */
+ public abstract List getChildren();
+}
Added: branches/presentation/presentation/src/main/org/jboss/portal/presentation/test/portal/MockPortalServer.java
===================================================================
--- branches/presentation/presentation/src/main/org/jboss/portal/presentation/test/portal/MockPortalServer.java (rev 0)
+++ branches/presentation/presentation/src/main/org/jboss/portal/presentation/test/portal/MockPortalServer.java 2008-02-28 10:15:38 UTC (rev 10150)
@@ -0,0 +1,136 @@
+/******************************************************************************
+ * JBoss, a division of Red Hat *
+ * Copyright 2006, Red Hat Middleware, LLC, and individual *
+ * contributors as indicated by the @authors tag. See the *
+ * copyright.txt in the distribution for a full listing of *
+ * individual contributors. *
+ * *
+ * This is free software; you can redistribute it and/or modify it *
+ * under the terms of the GNU Lesser General Public License as *
+ * published by the Free Software Foundation; either version 2.1 of *
+ * the License, or (at your option) any later version. *
+ * *
+ * This software is distributed in the hope that it will be useful, *
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of *
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU *
+ * Lesser General Public License for more details. *
+ * *
+ * You should have received a copy of the GNU Lesser General Public *
+ * License along with this software; if not, write to the Free *
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA *
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org. *
+ ******************************************************************************/
+package org.jboss.portal.presentation.test.portal;
+
+import java.util.Map;
+import java.util.List;
+import java.util.HashMap;
+import java.util.ArrayList;
+
+/**
+ * @author <a href="mailto:sshah@redhat.com">Sohil Shah</a>
+ *
+ */
+public class MockPortalServer
+{
+ /**
+ *
+ */
+ private static MockPortalServer singleton = null;
+
+ /**
+ *
+ */
+ private Map instances = null;
+
+ /**
+ *
+ *
+ */
+ private MockPortalServer()
+ {
+ //load up the MockPortal instances
+ this.instances = new HashMap();
+
+ //Create 3 MockPortlets
+ MockPortlet portlet1 = new MockPortlet("<div><b>Portlet 1:</b><br/></div>");
+ MockPortlet portlet2 = new MockPortlet("<div><b>Portlet 2:</b><br/></div>");
+ MockPortlet portlet3 = new MockPortlet("<div><b>Portlet 3:</b><br/></div>");
+
+ MockWindow window1 = new MockWindow("default/default/window1",portlet1);
+ MockWindow window2 = new MockWindow("default/default/window2",portlet2);
+ MockWindow window3 = new MockWindow("default/default/window3",portlet3);
+
+ List windows = new ArrayList();
+ windows.add(window1);
+ windows.add(window2);
+ windows.add(window3);
+
+ MockPage page1 = new MockPage("default/default", windows);
+
+ List pages = new ArrayList();
+ pages.add(page1);
+
+ MockPortal mockPortal = new MockPortal("default", pages);
+
+ List portals = new ArrayList();
+ portals.add(mockPortal);
+
+ MockContext mockContext = new MockContext("/", portals);
+
+ this.instances.put("/", mockContext);
+ this.instances.put("default", mockPortal);
+ this.instances.put("default/default", page1);
+ this.instances.put("default/default/window1", window1);
+ this.instances.put("default/default/window2", window2);
+ this.instances.put("default/default/window3", window3);
+ }
+
+ /**
+ *
+ * @return
+ */
+ public static MockPortalServer getInstance()
+ {
+ if(MockPortalServer.singleton == null)
+ {
+ MockPortalServer.singleton = new MockPortalServer();
+ }
+ return MockPortalServer.singleton;
+ }
+
+ /**
+ *
+ * @param id
+ * @return
+ */
+ public MockPortalObject getPortalObject(String id)
+ {
+ MockPortalObject portalObject = null;
+
+ if(!id.equals("/") && id.startsWith("/"))
+ {
+ id = id.substring(1);
+ }
+
+ portalObject = (MockPortalObject)this.instances.get(id);
+
+ return portalObject;
+ }
+
+ /**
+ *
+ * @param id
+ */
+ public void invoke(String id, Map queryParameters)
+ {
+ String[] action = (String[])queryParameters.get("action");
+
+ MockWindow window = (MockWindow)this.getPortalObject(id);
+
+ if(action != null && action[0].equals("2"))
+ {
+ window.getPortlet().processAction();
+ }
+ }
+}
Added: branches/presentation/presentation/src/main/org/jboss/portal/presentation/test/portal/MockPortlet.java
===================================================================
--- branches/presentation/presentation/src/main/org/jboss/portal/presentation/test/portal/MockPortlet.java (rev 0)
+++ branches/presentation/presentation/src/main/org/jboss/portal/presentation/test/portal/MockPortlet.java 2008-02-28 10:15:38 UTC (rev 10150)
@@ -0,0 +1,77 @@
+/******************************************************************************
+ * JBoss, a division of Red Hat *
+ * Copyright 2006, Red Hat Middleware, LLC, and individual *
+ * contributors as indicated by the @authors tag. See the *
+ * copyright.txt in the distribution for a full listing of *
+ * individual contributors. *
+ * *
+ * This is free software; you can redistribute it and/or modify it *
+ * under the terms of the GNU Lesser General Public License as *
+ * published by the Free Software Foundation; either version 2.1 of *
+ * the License, or (at your option) any later version. *
+ * *
+ * This software is distributed in the hope that it will be useful, *
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of *
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU *
+ * Lesser General Public License for more details. *
+ * *
+ * You should have received a copy of the GNU Lesser General Public *
+ * License along with this software; if not, write to the Free *
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA *
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org. *
+ ******************************************************************************/
+package org.jboss.portal.presentation.test.portal;
+
+/**
+ * @author <a href="mailto:sshah@redhat.com">Sohil Shah</a>
+ *
+ */
+public class MockPortlet
+{
+ /**
+ *
+ */
+ private String content = null;
+ private boolean actionActivated = false;
+
+ /**
+ *
+ *
+ */
+ public MockPortlet(String content)
+ {
+ this.content = content;
+ }
+
+ /**
+ *
+ *
+ */
+ public void processAction()
+ {
+ this.content += "<div><p>Action called:</p><br/><a href=\"default/default/window1?action=1\">View Window1</a><br/><a href=\"default/default/window2?action=1\">View Window2</a><br/><a href=\"default/default/window3?action=1\">View Window3</a><br/></div>";
+ this.actionActivated = true;
+ }
+
+ /**
+ *
+ *
+ */
+ public void doView()
+ {
+ if(!actionActivated)
+ {
+ this.content += "<div><p>View called:</p><br/><a href=\"default/default/window1?action=2\">Action Window1</a><br/><a href=\"default/default/window2?action=2\">Action Window2</a><br/><a href=\"default/default/window3?action=2\">Action Window3</a><br/></div>";
+ }
+ actionActivated = false;
+ }
+
+ /**
+ *
+ * @return
+ */
+ public String getContent()
+ {
+ return this.content;
+ }
+}
Added: branches/presentation/presentation/src/main/org/jboss/portal/presentation/test/portal/MockWindow.java
===================================================================
--- branches/presentation/presentation/src/main/org/jboss/portal/presentation/test/portal/MockWindow.java (rev 0)
+++ branches/presentation/presentation/src/main/org/jboss/portal/presentation/test/portal/MockWindow.java 2008-02-28 10:15:38 UTC (rev 10150)
@@ -0,0 +1,84 @@
+/******************************************************************************
+ * JBoss, a division of Red Hat *
+ * Copyright 2006, Red Hat Middleware, LLC, and individual *
+ * contributors as indicated by the @authors tag. See the *
+ * copyright.txt in the distribution for a full listing of *
+ * individual contributors. *
+ * *
+ * This is free software; you can redistribute it and/or modify it *
+ * under the terms of the GNU Lesser General Public License as *
+ * published by the Free Software Foundation; either version 2.1 of *
+ * the License, or (at your option) any later version. *
+ * *
+ * This software is distributed in the hope that it will be useful, *
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of *
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU *
+ * Lesser General Public License for more details. *
+ * *
+ * You should have received a copy of the GNU Lesser General Public *
+ * License along with this software; if not, write to the Free *
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA *
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org. *
+ ******************************************************************************/
+package org.jboss.portal.presentation.test.portal;
+
+import java.util.List;
+
+/**
+ * @author <a href="mailto:sshah@redhat.com">Sohil Shah</a>
+ *
+ */
+public class MockWindow extends MockPortalObject
+{
+ /**
+ *
+ */
+ private MockPortlet portlet = null;
+
+ /**
+ *
+ * @param id
+ * @param portlet
+ */
+ public MockWindow(String id, MockPortlet portlet)
+ {
+ super(id);
+ this.portlet = portlet;
+ }
+
+ /**
+ *
+ * @return
+ */
+ public MockPortlet getPortlet()
+ {
+ return portlet;
+ }
+
+ /**
+ *
+ * @param portlet
+ */
+ public void setPortlet(MockPortlet portlet)
+ {
+ this.portlet = portlet;
+ }
+
+ /**
+ *
+ */
+ public List getChildren()
+ {
+ return null;
+ }
+
+ /**
+ *
+ * @return
+ */
+ public String getMarkup()
+ {
+ this.portlet.doView();
+ return this.portlet.getContent();
+ }
+}
Added: branches/presentation/presentation/src/main/org/jboss/portal/presentation/test/portal/plugin/MainProcessor.java
===================================================================
--- branches/presentation/presentation/src/main/org/jboss/portal/presentation/test/portal/plugin/MainProcessor.java (rev 0)
+++ branches/presentation/presentation/src/main/org/jboss/portal/presentation/test/portal/plugin/MainProcessor.java 2008-02-28 10:15:38 UTC (rev 10150)
@@ -0,0 +1,122 @@
+/******************************************************************************
+ * JBoss, a division of Red Hat *
+ * Copyright 2006, Red Hat Middleware, LLC, and individual *
+ * contributors as indicated by the @authors tag. See the *
+ * copyright.txt in the distribution for a full listing of *
+ * individual contributors. *
+ * *
+ * This is free software; you can redistribute it and/or modify it *
+ * under the terms of the GNU Lesser General Public License as *
+ * published by the Free Software Foundation; either version 2.1 of *
+ * the License, or (at your option) any later version. *
+ * *
+ * This software is distributed in the hope that it will be useful, *
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of *
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU *
+ * Lesser General Public License for more details. *
+ * *
+ * You should have received a copy of the GNU Lesser General Public *
+ * License along with this software; if not, write to the Free *
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA *
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org. *
+ ******************************************************************************/
+package org.jboss.portal.presentation.test.portal.plugin;
+
+import org.apache.log4j.Logger;
+
+import org.jboss.portal.portlet.StateString;
+import org.jboss.portal.portlet.impl.PortletRequestDecoder;
+
+import org.jboss.portal.web.Body;
+
+import org.jboss.portal.server.ServerException;
+
+import org.jboss.portal.presentation.server.Processor;
+import org.jboss.portal.presentation.server.ProcessorRequest;
+import org.jboss.portal.presentation.server.ProcessorResponse;
+
+import org.jboss.portal.presentation.client.PresentationContext;
+
+import org.jboss.portal.presentation.model.StateType;
+import org.jboss.portal.presentation.model.UIWindow;
+
+import org.jboss.portal.presentation.protocol.LinkActivation;
+import org.jboss.portal.presentation.protocol.PostActivation;
+import org.jboss.portal.presentation.protocol.ServerAction;
+import org.jboss.portal.presentation.protocol.ServerResponse;
+import org.jboss.portal.presentation.protocol.ShowUIObjectResponse;
+import org.jboss.portal.presentation.protocol.ViewUIObjectAction;
+
+import org.jboss.portal.presentation.test.portal.MockPortalServer;
+
+
+import java.util.Map;
+
+/**
+ * @author <a href="mailto:sshah@redhat.com">Sohil Shah</a>
+ *
+ */
+public class MainProcessor implements Processor
+{
+
+ /** . */
+ private static Logger log = Logger.getLogger(MainProcessor.class);
+
+ /**
+ *
+ */
+ public ProcessorResponse process(PresentationContext presentationContext, ProcessorRequest request) throws ServerException
+ {
+ try
+ {
+
+ ServerAction serverAction = request.getAction();
+
+ ServerResponse response = null;
+
+ if(serverAction instanceof ViewUIObjectAction)
+ {
+ ViewUIObjectAction viewAction = (ViewUIObjectAction)serverAction;
+ response = new ShowUIObjectResponse(viewAction.getTargetId());
+ }
+ else if (serverAction instanceof LinkActivation)
+ {
+ LinkActivation getActivation = (LinkActivation)serverAction;
+ String id = getActivation.getTargetId();
+ PortletRequestDecoder decoder = new PortletRequestDecoder();
+
+ // Get form parameters if any
+ Map formParameters = null;
+ if (serverAction instanceof PostActivation)
+ {
+ PostActivation post = (PostActivation)serverAction;
+ Body body = post.getBody();
+ if (body instanceof Body.Form)
+ {
+ formParameters = ((Body.Form)body).getParameters();
+ }
+ }
+
+ decoder.decode(getActivation.getQueryParameters(), formParameters);
+ StateString contentState = decoder.getNavigationalState();
+
+ //TODO: We assume that for now
+ UIWindow uiWindow = (UIWindow)presentationContext.getUIContext().getObject(id);
+
+
+ //Make an invocation on the Mock Portal Server
+ MockPortalServer.getInstance().invoke(id, getActivation.getQueryParameters());
+
+ // It means we went through a successful action or it is a render
+ uiWindow.setProperty(StateType.NAVIGATIONAL, "content", contentState);
+ response = new ShowUIObjectResponse(uiWindow.getParent().getId());
+ }
+
+ return new ProcessorResponse(response);
+ }
+ catch(Exception e)
+ {
+ throw new ServerException(e);
+ }
+ }
+}
Added: branches/presentation/presentation/src/main/org/jboss/portal/presentation/test/portal/plugin/PresentationServerImpl.java
===================================================================
--- branches/presentation/presentation/src/main/org/jboss/portal/presentation/test/portal/plugin/PresentationServerImpl.java (rev 0)
+++ branches/presentation/presentation/src/main/org/jboss/portal/presentation/test/portal/plugin/PresentationServerImpl.java 2008-02-28 10:15:38 UTC (rev 10150)
@@ -0,0 +1,122 @@
+/******************************************************************************
+ * JBoss, a division of Red Hat *
+ * Copyright 2006, Red Hat Middleware, LLC, and individual *
+ * contributors as indicated by the @authors tag. See the *
+ * copyright.txt in the distribution for a full listing of *
+ * individual contributors. *
+ * *
+ * This is free software; you can redistribute it and/or modify it *
+ * under the terms of the GNU Lesser General Public License as *
+ * published by the Free Software Foundation; either version 2.1 of *
+ * the License, or (at your option) any later version. *
+ * *
+ * This software is distributed in the hope that it will be useful, *
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of *
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU *
+ * Lesser General Public License for more details. *
+ * *
+ * You should have received a copy of the GNU Lesser General Public *
+ * License along with this software; if not, write to the Free *
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA *
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org. *
+ ******************************************************************************/
+package org.jboss.portal.presentation.test.portal.plugin;
+
+import org.jboss.portal.presentation.client.PresentationContext;
+import org.jboss.portal.presentation.server.Processor;
+import org.jboss.portal.presentation.server.PresentationServer;
+import org.jboss.portal.presentation.model.UIWindow;
+import org.jboss.portal.presentation.model.content.WindowContent;
+import org.jboss.portal.presentation.model.state.structural.StructuralStateContext;
+
+import org.jboss.portal.presentation.test.portal.MockPortalServer;
+import org.jboss.portal.presentation.test.portal.MockWindow;
+
+/**
+ * @author <a href="mailto:sshah@redhat.com">Sohil Shah</a>
+ *
+ */
+public class PresentationServerImpl implements PresentationServer
+{
+
+ /**
+ *
+ */
+ private Processor processor;
+
+ /**
+ *
+ */
+ private StructuralStateContext structuralStateContext;
+
+
+ /**
+ *
+ *
+ */
+ public PresentationServerImpl()
+ {
+
+ }
+
+ /**
+ *
+ *
+ */
+ public void start()
+ {
+ this.structuralStateContext = new StructuralStateContextImpl();
+ }
+
+ /**
+ *
+ *
+ */
+ public void stop()
+ {
+
+ }
+
+ /**
+ *
+ */
+ public StructuralStateContext getStructuralStateManager()
+ {
+ return structuralStateContext;
+ }
+
+ /**
+ *
+ * @param structuralStateContext
+ */
+ public void setModelLoader(StructuralStateContext structuralStateContext)
+ {
+ this.structuralStateContext = structuralStateContext;
+ }
+
+ /**
+ *
+ */
+ public Processor getProcessor()
+ {
+ return this.processor;
+ }
+
+ /**
+ *
+ * @param processor
+ */
+ public void setProcessor(Processor processor)
+ {
+ this.processor = processor;
+ }
+
+ /**
+ *
+ */
+ public WindowContent render(PresentationContext context, UIWindow uiwindow) throws Exception
+ {
+ MockWindow window = (MockWindow)MockPortalServer.getInstance().getPortalObject(uiwindow.getId());
+ return new WindowContent(-1, "Blah:", window.getMarkup());
+ }
+}
Added: branches/presentation/presentation/src/main/org/jboss/portal/presentation/test/portal/plugin/StructuralObjectImpl.java
===================================================================
--- branches/presentation/presentation/src/main/org/jboss/portal/presentation/test/portal/plugin/StructuralObjectImpl.java (rev 0)
+++ branches/presentation/presentation/src/main/org/jboss/portal/presentation/test/portal/plugin/StructuralObjectImpl.java 2008-02-28 10:15:38 UTC (rev 10150)
@@ -0,0 +1,63 @@
+/******************************************************************************
+ * JBoss, a division of Red Hat *
+ * Copyright 2006, Red Hat Middleware, LLC, and individual *
+ * contributors as indicated by the @authors tag. See the *
+ * copyright.txt in the distribution for a full listing of *
+ * individual contributors. *
+ * *
+ * This is free software; you can redistribute it and/or modify it *
+ * under the terms of the GNU Lesser General Public License as *
+ * published by the Free Software Foundation; either version 2.1 of *
+ * the License, or (at your option) any later version. *
+ * *
+ * This software is distributed in the hope that it will be useful, *
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of *
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU *
+ * Lesser General Public License for more details. *
+ * *
+ * You should have received a copy of the GNU Lesser General Public *
+ * License along with this software; if not, write to the Free *
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA *
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org. *
+ ******************************************************************************/
+package org.jboss.portal.presentation.test.portal.plugin;
+
+import org.jboss.portal.presentation.model.state.structural.StructuralObject;
+import org.jboss.portal.presentation.model.state.structural.StructuralState;
+
+import org.jboss.portal.presentation.test.portal.MockPortalObject;
+
+/**
+ * @author <a href="mailto:julien@jboss.org">Julien Viet</a>
+ * @version $Revision: 630 $
+ */
+public class StructuralObjectImpl implements StructuralObject
+{
+
+ /** . */
+ private final String id;
+
+ /** . */
+ private final StructuralStateImpl state;
+
+ public StructuralObjectImpl(MockPortalObject portalObject)
+ {
+ this.id = portalObject.getId();
+ this.state = new StructuralStateImpl(portalObject);
+ }
+
+ public String getId()
+ {
+ return id;
+ }
+
+ public StructuralState getState()
+ {
+ return state;
+ }
+
+ public boolean compareTo(StructuralObject other)
+ {
+ return true;
+ }
+}
Added: branches/presentation/presentation/src/main/org/jboss/portal/presentation/test/portal/plugin/StructuralStateContextImpl.java
===================================================================
--- branches/presentation/presentation/src/main/org/jboss/portal/presentation/test/portal/plugin/StructuralStateContextImpl.java (rev 0)
+++ branches/presentation/presentation/src/main/org/jboss/portal/presentation/test/portal/plugin/StructuralStateContextImpl.java 2008-02-28 10:15:38 UTC (rev 10150)
@@ -0,0 +1,168 @@
+/******************************************************************************
+ * JBoss, a division of Red Hat *
+ * Copyright 2006, Red Hat Middleware, LLC, and individual *
+ * contributors as indicated by the @authors tag. See the *
+ * copyright.txt in the distribution for a full listing of *
+ * individual contributors. *
+ * *
+ * This is free software; you can redistribute it and/or modify it *
+ * under the terms of the GNU Lesser General Public License as *
+ * published by the Free Software Foundation; either version 2.1 of *
+ * the License, or (at your option) any later version. *
+ * *
+ * This software is distributed in the hope that it will be useful, *
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of *
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU *
+ * Lesser General Public License for more details. *
+ * *
+ * You should have received a copy of the GNU Lesser General Public *
+ * License along with this software; if not, write to the Free *
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA *
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org. *
+ ******************************************************************************/
+package org.jboss.portal.presentation.test.portal.plugin;
+
+
+import org.jboss.portal.presentation.model.state.StateException;
+import org.jboss.portal.presentation.model.state.structural.AbstractStructuralStateContext;
+import org.jboss.portal.presentation.model.state.structural.StructuralObject;
+import org.jboss.portal.common.NotYetImplemented;
+
+import org.jboss.portal.presentation.test.portal.MockPortalServer;
+import org.jboss.portal.presentation.test.portal.MockPortalObject;
+
+import java.util.Collection;
+import java.util.List;
+import java.util.ArrayList;
+
+/**
+ * @author <a href="mailto:sshah@redhat.com">Sohil Shah</a>
+ *
+ */
+public class StructuralStateContextImpl extends AbstractStructuralStateContext
+{
+ /**
+ *
+ */
+ public String getRootId()
+ {
+ return "/";
+ }
+
+ /**
+ * The implementation only validate that an object is present.
+ */
+ public void validate(StructuralObject object) throws IllegalArgumentException, StateException
+ {
+
+ }
+
+ /**
+ *
+ */
+ public StructuralObject.Refresh refresh(StructuralObject object) throws IllegalArgumentException, StateException
+ {
+ throw new NotYetImplemented();
+ }
+
+ /**
+ *
+ */
+ public StructuralObject load(String objectId) throws IllegalArgumentException
+ {
+ StructuralObject cour = null;
+
+ MockPortalObject portalObject = MockPortalServer.getInstance().getPortalObject(objectId);
+ if(portalObject != null)
+ {
+ cour = new StructuralObjectImpl(portalObject);
+ }
+
+ return cour;
+ }
+
+ /**
+ *
+ */
+ public Collection<StructuralObject> loadChildren(StructuralObject parent)
+ {
+ Collection<StructuralObject> children = null;
+
+ MockPortalObject parentPortalObject = MockPortalServer.getInstance().getPortalObject(parent.getId());
+ List cour = parentPortalObject.getChildren();
+
+ if(cour != null)
+ {
+ children = new ArrayList<StructuralObject>();
+ for(int i=0; i<cour.size(); i++)
+ {
+ MockPortalObject child = (MockPortalObject)cour.get(i);
+ children.add(new StructuralObjectImpl(child));
+ }
+ }
+
+ return children;
+ }
+
+ /**
+ *
+ */
+ public StructuralObject loadParent(StructuralObject child)
+ {
+ StructuralObject parent = null;
+
+ String id = child.getId();
+ int lastIndex = id.lastIndexOf('/');
+ String parentId = id.substring(0, lastIndex);
+
+ MockPortalObject parentObject = MockPortalServer.getInstance().getPortalObject(parentId);
+ if(parentObject != null)
+ {
+ parent = new StructuralObjectImpl(parentObject);
+ }
+
+ return parent;
+ }
+
+ /**
+ *
+ * @param left
+ * @param right
+ * @return
+ */
+ public boolean equals(StructuralObject left, StructuralObject right)
+ {
+ if (left == null)
+ {
+ return right == null;
+ }
+ else
+ {
+ if (right == null)
+ {
+ return false;
+ }
+ StructuralObjectImpl lefti = (StructuralObjectImpl)left;
+ StructuralObjectImpl righti = (StructuralObjectImpl)right;
+ return lefti.getId().equals(righti.getId());
+ }
+ }
+
+ /**
+ *
+ *
+ */
+ public void start()
+ {
+
+ }
+
+ /**
+ *
+ *
+ */
+ public void stop()
+ {
+
+ }
+}
Added: branches/presentation/presentation/src/main/org/jboss/portal/presentation/test/portal/plugin/StructuralStateImpl.java
===================================================================
--- branches/presentation/presentation/src/main/org/jboss/portal/presentation/test/portal/plugin/StructuralStateImpl.java (rev 0)
+++ branches/presentation/presentation/src/main/org/jboss/portal/presentation/test/portal/plugin/StructuralStateImpl.java 2008-02-28 10:15:38 UTC (rev 10150)
@@ -0,0 +1,105 @@
+/******************************************************************************
+ * JBoss, a division of Red Hat *
+ * Copyright 2006, Red Hat Middleware, LLC, and individual *
+ * contributors as indicated by the @authors tag. See the *
+ * copyright.txt in the distribution for a full listing of *
+ * individual contributors. *
+ * *
+ * This is free software; you can redistribute it and/or modify it *
+ * under the terms of the GNU Lesser General Public License as *
+ * published by the Free Software Foundation; either version 2.1 of *
+ * the License, or (at your option) any later version. *
+ * *
+ * This software is distributed in the hope that it will be useful, *
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of *
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU *
+ * Lesser General Public License for more details. *
+ * *
+ * You should have received a copy of the GNU Lesser General Public *
+ * License along with this software; if not, write to the Free *
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA *
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org. *
+ ******************************************************************************/
+package org.jboss.portal.presentation.test.portal.plugin;
+
+import org.jboss.portal.presentation.model.state.structural.StructuralState;
+import org.jboss.portal.presentation.model.UIObject;
+import org.jboss.portal.presentation.model.UIContext;
+import org.jboss.portal.presentation.model.UIPortal;
+import org.jboss.portal.presentation.model.UIPage;
+import org.jboss.portal.presentation.model.UIWindow;
+
+import org.jboss.portal.presentation.test.portal.MockPortalObject;
+import org.jboss.portal.presentation.test.portal.MockContext;
+import org.jboss.portal.presentation.test.portal.MockPortal;
+import org.jboss.portal.presentation.test.portal.MockPage;
+import org.jboss.portal.presentation.test.portal.MockWindow;
+
+import java.util.Map;
+
+/**
+ * @author <a href="mailto:julien@jboss.org">Julien Viet</a>
+ * @version $Revision: 630 $
+ */
+public class StructuralStateImpl implements StructuralState
+{
+
+ /** . */
+ private Class<? extends UIObject> type;
+
+ /** . */
+ private String name;
+
+ /** . */
+ private Map<String, String> properties;
+
+ StructuralStateImpl(MockPortalObject portalObject)
+ {
+ type = this.getType(portalObject);
+ this.name = portalObject.getId();
+ }
+
+ public Class<? extends UIObject> getType()
+ {
+ return type;
+ }
+
+ public String getName()
+ {
+ return name;
+ }
+
+ public Map<String, String> getProperties()
+ {
+ return properties;
+ }
+
+ /**
+ *
+ * @param portalObject
+ * @return
+ */
+ private Class<? extends UIObject> getType(MockPortalObject portalObject)
+ {
+ Class<? extends UIObject> type = null;
+
+ if(portalObject instanceof MockContext)
+ {
+ type = UIContext.class;
+ }
+ else if(portalObject instanceof MockPortal)
+ {
+ type = UIPortal.class;
+ }
+ else if(portalObject instanceof MockPage)
+ {
+ type = UIPage.class;
+ }
+ else if(portalObject instanceof MockWindow)
+ {
+ type = UIWindow.class;
+ }
+
+ return type;
+ }
+}
16 years, 8 months
JBoss Portal SVN: r10149 - in modules/portlet/trunk/portlet/src/main/java/org/jboss/portal/portlet: impl/jsr168 and 2 other directories.
by portal-commits@lists.jboss.org
Author: julien(a)jboss.com
Date: 2008-02-27 20:18:35 -0500 (Wed, 27 Feb 2008)
New Revision: 10149
Modified:
modules/portlet/trunk/portlet/src/main/java/org/jboss/portal/portlet/cache/CacheControl.java
modules/portlet/trunk/portlet/src/main/java/org/jboss/portal/portlet/impl/jsr168/ContentBuffer.java
modules/portlet/trunk/portlet/src/main/java/org/jboss/portal/portlet/impl/jsr168/api/CacheControlImpl.java
modules/portlet/trunk/portlet/src/main/java/org/jboss/portal/portlet/impl/jsr168/api/MimeResponseImpl.java
modules/portlet/trunk/portlet/src/main/java/org/jboss/portal/portlet/impl/jsr168/api/RenderResponseImpl.java
modules/portlet/trunk/portlet/src/main/java/org/jboss/portal/portlet/invocation/response/FragmentResponse.java
Log:
make FragmentResponse and CacheControl immutables
Modified: modules/portlet/trunk/portlet/src/main/java/org/jboss/portal/portlet/cache/CacheControl.java
===================================================================
--- modules/portlet/trunk/portlet/src/main/java/org/jboss/portal/portlet/cache/CacheControl.java 2008-02-28 00:25:00 UTC (rev 10148)
+++ modules/portlet/trunk/portlet/src/main/java/org/jboss/portal/portlet/cache/CacheControl.java 2008-02-28 01:18:35 UTC (rev 10149)
@@ -30,13 +30,13 @@
{
/** Number of seconds this result remains valid, a value of -1 indicates that it never expires. */
- private int expirationSecs;
+ private final int expirationSecs;
/** The cache scope for this fragment. */
- private CacheScope cacheScope;
+ private final CacheScope cacheScope;
/** The validation token. */
- private String validationToken;
+ private final String validationToken;
public CacheControl(int expirationSecs, CacheScope cacheScope, String validationToken)
{
@@ -50,49 +50,13 @@
return expirationSecs;
}
- public void setExpirationSecs(int expirationSecs)
- {
- this.expirationSecs = expirationSecs;
- }
-
public CacheScope getCacheScope()
{
return cacheScope;
}
- public void setCacheScope(CacheScope cacheScope)
- {
- this.cacheScope = cacheScope;
- }
-
public String getValidationToken()
{
return validationToken;
}
-
- public void setValidationToken(String validationToken)
- {
- this.validationToken = validationToken;
- }
-
- public CacheControl unmodifiable()
- {
- return new CacheControl(expirationSecs, cacheScope, validationToken)
- {
- public void setCacheScope(CacheScope cacheScope)
- {
- throw new UnsupportedOperationException("Not modifiable");
- }
-
- public void setValidationToken(String token)
- {
- throw new UnsupportedOperationException("Not modifiable");
- }
-
- public void setExpirationSecs(int expirationSecs)
- {
- throw new UnsupportedOperationException("Not modifiable");
- }
- };
- }
}
Modified: modules/portlet/trunk/portlet/src/main/java/org/jboss/portal/portlet/impl/jsr168/ContentBuffer.java
===================================================================
--- modules/portlet/trunk/portlet/src/main/java/org/jboss/portal/portlet/impl/jsr168/ContentBuffer.java 2008-02-28 00:25:00 UTC (rev 10148)
+++ modules/portlet/trunk/portlet/src/main/java/org/jboss/portal/portlet/impl/jsr168/ContentBuffer.java 2008-02-28 01:18:35 UTC (rev 10149)
@@ -227,10 +227,6 @@
*/
public void commit() throws IllegalStateException
{
-// if (contentType == null)
-// {
-// throw new IllegalStateException("No content type defined");
-// }
commited = true;
}
Modified: modules/portlet/trunk/portlet/src/main/java/org/jboss/portal/portlet/impl/jsr168/api/CacheControlImpl.java
===================================================================
--- modules/portlet/trunk/portlet/src/main/java/org/jboss/portal/portlet/impl/jsr168/api/CacheControlImpl.java 2008-02-28 00:25:00 UTC (rev 10148)
+++ modules/portlet/trunk/portlet/src/main/java/org/jboss/portal/portlet/impl/jsr168/api/CacheControlImpl.java 2008-02-28 01:18:35 UTC (rev 10149)
@@ -34,44 +34,53 @@
{
/** . */
- private org.jboss.portal.portlet.cache.CacheControl delegate;
+ private boolean useCachedContent;
/** . */
- private boolean useCachedContent;
+ private int expirationSecs;
- public CacheControlImpl(org.jboss.portal.portlet.cache.CacheControl delegate)
+ /** . */
+ private CacheScope cacheScope;
+
+ /** . */
+ private String validationToken;
+
+ public CacheControlImpl(int expirationSecs, CacheScope cacheScope)
{
- this.delegate = delegate;
+ this.useCachedContent = false;
+ this.expirationSecs = expirationSecs;
+ this.cacheScope = cacheScope;
+ this.validationToken = null;
}
public int getExpirationTime()
{
- return delegate.getExpirationSecs();
+ return expirationSecs;
}
public void setExpirationTime(int expirationTime)
{
- delegate.setExpirationSecs(expirationTime);
+ this.expirationSecs = expirationTime;
}
public boolean isPublicScope()
{
- return delegate.getCacheScope() == CacheScope.PUBLIC;
+ return cacheScope == CacheScope.PUBLIC;
}
public void setPublicScope(boolean publicScope)
{
- delegate.setCacheScope(publicScope ? CacheScope.PUBLIC : CacheScope.PRIVATE);
+ cacheScope = publicScope ? CacheScope.PUBLIC : CacheScope.PRIVATE;
}
public String getETag()
{
- return delegate.getValidationToken();
+ return validationToken;
}
public void setETag(String etag)
{
- delegate.setValidationToken(etag);
+ this.validationToken = etag;
}
public boolean useCachedContent()
Modified: modules/portlet/trunk/portlet/src/main/java/org/jboss/portal/portlet/impl/jsr168/api/MimeResponseImpl.java
===================================================================
--- modules/portlet/trunk/portlet/src/main/java/org/jboss/portal/portlet/impl/jsr168/api/MimeResponseImpl.java 2008-02-28 00:25:00 UTC (rev 10148)
+++ modules/portlet/trunk/portlet/src/main/java/org/jboss/portal/portlet/impl/jsr168/api/MimeResponseImpl.java 2008-02-28 01:18:35 UTC (rev 10149)
@@ -29,6 +29,8 @@
import org.jboss.portal.portlet.info.PortletInfo;
import org.jboss.portal.portlet.info.CacheInfo;
import org.jboss.portal.portlet.cache.CacheScope;
+import org.jboss.portal.portlet.impl.jsr168.ContentBuffer;
+import org.jboss.portal.Mode;
import javax.portlet.MimeResponse;
import javax.portlet.PortletURL;
@@ -38,6 +40,7 @@
import java.io.IOException;
import java.io.OutputStream;
import java.util.Locale;
+import java.util.Set;
/**
* @author <a href="mailto:julien@jboss.org">Julien Viet</a>
@@ -46,9 +49,6 @@
public abstract class MimeResponseImpl extends PortletResponseImpl implements MimeResponse
{
- /** The fragment result. */
- protected FragmentResponse fragment;
-
/** Not really used but we need it to memorize what the client set optionally. */
protected int bufferSize;
@@ -58,82 +58,104 @@
/** . */
private boolean contentTypeSet;
+ /** The title if any. */
+ protected String responseTitle;
+
+ /** . */
+ private ContentBuffer responseContent;
+
+ /** . */
+ protected Set<Mode> responseNextModes;
+
public MimeResponseImpl(PortletInvocation invocation, PortletRequestImpl preq)
{
super(invocation, preq);
- //
- FragmentResponse fragment = new FragmentResponse();
-
// Configure expiration value
PortletInfo info = preq.container.getInfo();
CacheInfo cacheInfo = info.getCache();
-
org.jboss.portal.portlet.cache.CacheControl cc = new org.jboss.portal.portlet.cache.CacheControl(
cacheInfo.getExpirationSecs(),
CacheScope.PRIVATE,
null
);
- //
- fragment.setCacheControl(cc);
-
// 0 means no buffering - we say no buffering
this.bufferSize = 0;
- this.fragment = fragment;
this.contentTypeSet = false;
+ this.responseContent = new ContentBuffer();
+ this.responseTitle = null;
+ this.responseNextModes = null;
}
public PortletInvocationResponse getResponse()
{
- if (cacheControl != null && cacheControl.useCachedContent())
+ org.jboss.portal.portlet.cache.CacheControl cc;
+ if (cacheControl != null)
{
- return new RevalidateMarkupResponse(fragment.getCacheControl());
+ cc = new org.jboss.portal.portlet.cache.CacheControl(
+ cacheControl.getExpirationTime(),
+ cacheControl.isPublicScope() ? CacheScope.PUBLIC : CacheScope.PRIVATE,
+ cacheControl.getETag());
}
else
{
- fragment.setProperties(getProperties(false));
- fragment.setAttributes(preq.attributes.getAttributeMap());
+ PortletInfo info = preq.container.getInfo();
+ CacheInfo cacheInfo = info.getCache();
+ cc = new org.jboss.portal.portlet.cache.CacheControl(cacheInfo.getExpirationSecs(), CacheScope.PRIVATE, null);
+ }
- //
- return fragment;
+ //
+ if (cacheControl != null && cacheControl.useCachedContent())
+ {
+ return new RevalidateMarkupResponse(cc);
}
+ else
+ {
+ return new FragmentResponse(
+ getProperties(false),
+ preq.attributes.getAttributeMap(),
+ responseContent,
+ responseTitle,
+ cc,
+ responseNextModes != null ? responseNextModes : preq.supportedModes);
+ }
}
public String getContentType()
{
- return contentTypeSet ? fragment.getContentType() : null;
+ return contentTypeSet ? responseContent.getContentType() : null;
}
public void setContentType(String contentType)
{
- if (fragment.getContentType() == null)
+ if (responseContent.getContentType() == null)
{
- fragment.setContentType(contentType);
+ responseContent.setContentType(contentType);
contentTypeSet = true;
}
}
public PrintWriter getWriter() throws IOException
{
- if (fragment.getContentType() == null)
+ if (responseContent.getContentType() == null)
{
- fragment.setContentType(preq.getResponseContentType());
+ responseContent.setContentType(preq.getResponseContentType());
}
//
- return fragment.getWriter();
+ return responseContent.getWriter();
}
public OutputStream getPortletOutputStream() throws IOException
{
- if (fragment.getContentType() == null)
+ if (responseContent.getContentType() == null)
{
- fragment.setContentType(preq.getResponseContentType());
+ responseContent.setContentType(preq.getResponseContentType());
}
//
- return fragment.getOutputStream();
+ return responseContent.getOutputStream();
}
public PortletURL createRenderURL()
@@ -171,13 +193,13 @@
public void flushBuffer() throws IOException
{
- fragment.getBuffer().commit();
+ responseContent.commit();
}
public void resetBuffer()
{
// Clear the buffer
- fragment.resetBuffer();
+ responseContent.reset();
}
public void reset()
@@ -193,7 +215,7 @@
public boolean isCommitted()
{
- return fragment.getBuffer().isCommited();
+ return responseContent.isCommited();
}
public ResourceURL createResourceURL()
@@ -210,7 +232,7 @@
try
{
int expirationSecs = Integer.parseInt(value);
- fragment.getCacheControl().setExpirationSecs(expirationSecs);
+ getCacheControl().setExpirationTime(expirationSecs);
}
catch (NumberFormatException e)
{
@@ -224,7 +246,7 @@
{
if (value != null)
{
- fragment.getCacheControl().setValidationToken(value);
+ getCacheControl().setETag(value);
}
}
else if (MimeResponse.USE_CACHED_CONTENT.equals(key))
@@ -244,7 +266,9 @@
{
if (cacheControl == null)
{
- cacheControl = new CacheControlImpl(fragment.getCacheControl());
+ PortletInfo info = preq.container.getInfo();
+ CacheInfo cacheInfo = info.getCache();
+ cacheControl = new CacheControlImpl(cacheInfo.getExpirationSecs(), CacheScope.PRIVATE);
}
return cacheControl;
}
Modified: modules/portlet/trunk/portlet/src/main/java/org/jboss/portal/portlet/impl/jsr168/api/RenderResponseImpl.java
===================================================================
--- modules/portlet/trunk/portlet/src/main/java/org/jboss/portal/portlet/impl/jsr168/api/RenderResponseImpl.java 2008-02-28 00:25:00 UTC (rev 10148)
+++ modules/portlet/trunk/portlet/src/main/java/org/jboss/portal/portlet/impl/jsr168/api/RenderResponseImpl.java 2008-02-28 01:18:35 UTC (rev 10149)
@@ -50,25 +50,22 @@
super(invocation, preq);
}
- /** . */
- private Set<Mode> nextModes;
-
- public void setTitle(String s)
+ public void setTitle(String title)
{
- fragment.setTitle(s);
+ this.responseTitle = title;
}
public void setNextPossiblePortletModes(Collection<PortletMode> portletModes)
{
if (portletModes != null && portletModes.size() > 0)
{
- if (this.nextModes == null)
+ if (responseNextModes == null)
{
- nextModes = new LinkedHashSet<Mode>(portletModes.size());
+ responseNextModes = new LinkedHashSet<Mode>(portletModes.size());
}
else
{
- nextModes.clear();
+ responseNextModes.clear();
}
//
@@ -81,7 +78,7 @@
//
if (preq.supportedModes.contains(mode))
{
- nextModes.add(mode);
+ responseNextModes.add(mode);
}
}
else
@@ -145,16 +142,4 @@
throw ex;
}
}
-
- public PortletInvocationResponse getResponse()
- {
- PortletInvocationResponse response = super.getResponse();
- if (response instanceof FragmentResponse)
- {
- FragmentResponse fragment = (FragmentResponse)response;
- fragment.setNextModes(nextModes != null ? nextModes : preq.supportedModes);
- }
- return response;
- }
-
}
Modified: modules/portlet/trunk/portlet/src/main/java/org/jboss/portal/portlet/invocation/response/FragmentResponse.java
===================================================================
--- modules/portlet/trunk/portlet/src/main/java/org/jboss/portal/portlet/invocation/response/FragmentResponse.java 2008-02-28 00:25:00 UTC (rev 10148)
+++ modules/portlet/trunk/portlet/src/main/java/org/jboss/portal/portlet/invocation/response/FragmentResponse.java 2008-02-28 01:18:35 UTC (rev 10149)
@@ -52,31 +52,31 @@
public static final int TYPE_BYTES = ContentBuffer.TYPE_BYTES;
/** . */
- private ResponseProperties properties;
+ private final ResponseProperties properties;
/** . */
- private Map<String, Object> attributes;
+ private final Map<String, Object> attributes;
/** . */
- private ContentBuffer buffer;
+ private final ContentBuffer buffer;
/** The title if any. */
- private String title;
+ private final String title;
/** . */
- private CacheControl cacheControl;
+ private final CacheControl cacheControl;
/** . */
- private Set<Mode> nextModes;
+ private final Set<Mode> nextModes;
- public FragmentResponse()
+ public FragmentResponse(ResponseProperties properties, Map<String, Object> attributes, ContentBuffer buffer, String title, CacheControl cacheControl, Set<Mode> nextModes)
{
- this.buffer = new ContentBuffer();
- this.title = null;
- this.cacheControl = null;
- this.properties = null;
- this.nextModes = null;
- this.attributes = null;
+ this.properties = properties;
+ this.attributes = attributes;
+ this.buffer = buffer;
+ this.title = title;
+ this.cacheControl = cacheControl;
+ this.nextModes = nextModes;
}
public ResponseProperties getProperties()
@@ -84,31 +84,16 @@
return properties;
}
- public void setProperties(ResponseProperties properties)
- {
- this.properties = properties;
- }
-
public CacheControl getCacheControl()
{
return cacheControl;
}
- public void setCacheControl(CacheControl cacheControl)
- {
- this.cacheControl = cacheControl;
- }
-
public Map<String, Object> getAttributes()
{
return attributes;
}
- public void setAttributes(Map<String, Object> attributes)
- {
- this.attributes = attributes;
- }
-
public int getType()
{
return buffer.getType();
@@ -147,16 +132,6 @@
}
/**
- * Set the fragment title.
- *
- * @param title the new title
- */
- public void setTitle(String title)
- {
- this.title = title;
- }
-
- /**
* Return the content type of the generated fragment.
*
* @return the content type
@@ -167,16 +142,6 @@
}
/**
- * Set the fragment of the content type.
- *
- * @param contentType the content type
- */
- public void setContentType(String contentType)
- {
- buffer.setContentType(contentType);
- }
-
- /**
* Returns the writer.
*
* @return the writer
@@ -196,11 +161,6 @@
return buffer.getOutputStream();
}
- public void resetBuffer()
- {
- buffer.reset();
- }
-
public ContentBuffer getBuffer()
{
return buffer;
@@ -210,9 +170,4 @@
{
return nextModes;
}
-
- public void setNextModes(Set<Mode> nextModes)
- {
- this.nextModes = nextModes;
- }
}
16 years, 8 months
JBoss Portal SVN: r10148 - in modules/portlet/trunk/portlet/src: test/java/org/jboss/portal/test/portlet and 1 other directories.
by portal-commits@lists.jboss.org
Author: julien(a)jboss.com
Date: 2008-02-27 19:25:00 -0500 (Wed, 27 Feb 2008)
New Revision: 10148
Removed:
modules/portlet/trunk/portlet/src/main/java/org/jboss/portal/portlet/Properties.java
modules/portlet/trunk/portlet/src/test/java/org/jboss/portal/test/portlet/PropertiesTestCase.java
Modified:
modules/portlet/trunk/portlet/src/test/resources/local-jboss-unit.xml
Log:
remove obsolete Properties class
Deleted: modules/portlet/trunk/portlet/src/main/java/org/jboss/portal/portlet/Properties.java
===================================================================
--- modules/portlet/trunk/portlet/src/main/java/org/jboss/portal/portlet/Properties.java 2008-02-28 00:18:59 UTC (rev 10147)
+++ modules/portlet/trunk/portlet/src/main/java/org/jboss/portal/portlet/Properties.java 2008-02-28 00:25:00 UTC (rev 10148)
@@ -1,173 +0,0 @@
-/******************************************************************************
- * JBoss, a division of Red Hat *
- * Copyright 2006, Red Hat Middleware, LLC, and individual *
- * contributors as indicated by the @authors tag. See the *
- * copyright.txt in the distribution for a full listing of *
- * individual contributors. *
- * *
- * This is free software; you can redistribute it and/or modify it *
- * under the terms of the GNU Lesser General Public License as *
- * published by the Free Software Foundation; either version 2.1 of *
- * the License, or (at your option) any later version. *
- * *
- * This software is distributed in the hope that it will be useful, *
- * but WITHOUT ANY WARRANTY; without even the implied warranty of *
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU *
- * Lesser General Public License for more details. *
- * *
- * You should have received a copy of the GNU Lesser General Public *
- * License along with this software; if not, write to the Free *
- * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA *
- * 02110-1301 USA, or see the FSF site: http://www.fsf.org. *
- ******************************************************************************/
-package org.jboss.portal.portlet;
-
-import java.util.ArrayList;
-import java.util.Collections;
-import java.util.HashMap;
-import java.util.List;
-import java.util.Map;
-import java.util.Set;
-
-/**
- * A set of multi valued properties produced by a response.
- *
- * @author <a href="mailto:julien@jboss.org">Julien Viet</a>
- * @version $Revision: 5448 $
- */
-public class Properties
-{
-
- private Map<String, ArrayList<String>> content;
-
- public Properties()
- {
- }
-
- /**
- * @param name the property name
- * @param value the property value
- * @throws IllegalArgumentException if name or value is null
- */
- public void addProperty(String name, String value)
- {
- if (name == null)
- {
- throw new IllegalArgumentException("Name cannot be null");
- }
- if (value == null)
- {
- throw new IllegalArgumentException("Value cannot be null");
- }
- if (content == null)
- {
- content = new HashMap<String, ArrayList<String>>();
- }
-
- //
- ArrayList<String> values = content.get(name);
- if (values == null)
- {
- values = new ArrayList<String>();
- content.put(name, values);
- }
-
- //
- values.add(value);
- }
-
- /**
- * @param name the property name
- * @param value the property value
- * @throws IllegalArgumentException if name or value is null
- */
- public void setProperty(String name, String value)
- {
- if (name == null)
- {
- throw new IllegalArgumentException("Name cannot be null");
- }
- if (value == null)
- {
- throw new IllegalArgumentException("Value cannot be null");
- }
- if (content == null)
- {
- content = new HashMap<String, ArrayList<String>>();
- }
-
- //
- ArrayList<String> values = content.get(name);
- if (values == null)
- {
- values = new ArrayList<String>();
- content.put(name, values);
- }
- else
- {
- values.clear();
- }
-
- //
- values.add(value);
- }
-
- /** Clear the properties. */
- public void clear()
- {
- if (content != null)
- {
- content.clear();
- }
- }
-
- public String getProperty(String name)
- {
- if (name == null)
- {
- throw new IllegalArgumentException("Name cannot be null");
- }
- if (content == null)
- {
- return null;
- }
-
- //
- ArrayList<String> values = content.get(name);
- if (values == null)
- {
- return null;
- }
- else
- {
- return values.get(0);
- }
- }
-
- /**
- * @param name the property name
- * @return the list of properties for the specified name or null if it does not exist
- * @throws IllegalArgumentException if name is null
- */
- public List<String> getProperties(String name)
- {
- if (name == null)
- {
- throw new IllegalArgumentException("Name cannot be null");
- }
- if (content == null)
- {
- return null;
- }
- return content.get(name);
- }
-
- public Set<String> getPropertyNames()
- {
- if (content == null)
- {
- return Collections.emptySet();
- }
- return content.keySet();
- }
-}
Deleted: modules/portlet/trunk/portlet/src/test/java/org/jboss/portal/test/portlet/PropertiesTestCase.java
===================================================================
--- modules/portlet/trunk/portlet/src/test/java/org/jboss/portal/test/portlet/PropertiesTestCase.java 2008-02-28 00:18:59 UTC (rev 10147)
+++ modules/portlet/trunk/portlet/src/test/java/org/jboss/portal/test/portlet/PropertiesTestCase.java 2008-02-28 00:25:00 UTC (rev 10148)
@@ -1,119 +0,0 @@
-/******************************************************************************
- * JBoss, a division of Red Hat *
- * Copyright 2006, Red Hat Middleware, LLC, and individual *
- * contributors as indicated by the @authors tag. See the *
- * copyright.txt in the distribution for a full listing of *
- * individual contributors. *
- * *
- * This is free software; you can redistribute it and/or modify it *
- * under the terms of the GNU Lesser General Public License as *
- * published by the Free Software Foundation; either version 2.1 of *
- * the License, or (at your option) any later version. *
- * *
- * This software is distributed in the hope that it will be useful, *
- * but WITHOUT ANY WARRANTY; without even the implied warranty of *
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU *
- * Lesser General Public License for more details. *
- * *
- * You should have received a copy of the GNU Lesser General Public *
- * License along with this software; if not, write to the Free *
- * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA *
- * 02110-1301 USA, or see the FSF site: http://www.fsf.org. *
- ******************************************************************************/
-package org.jboss.portal.test.portlet;
-
-import org.jboss.portal.common.util.Tools;
-import org.jboss.portal.portlet.Properties;
-import org.jboss.unit.api.pojo.annotations.Test;
-
-import static org.jboss.unit.api.Assert.*;
-
-/**
- * @author <a href="mailto:julien@jboss.org">Julien Viet</a>
- * @version $Revision: 5448 $
- */
-public class PropertiesTestCase
-{
-
- public PropertiesTestCase()
- {
- }
-
- @Test
- public void testA()
- {
- Properties props = new Properties();
- props.setProperty("name1", "value1");
-
- props.addProperty("name2", "value2");
-
- props.setProperty("name3", "value3-1");
- props.addProperty("name3", "value3-2");
-
- props.addProperty("name4", "value4-1");
- props.addProperty("name4", "value4-2");
-
- props.setProperty("name5", "value5-1");
- props.setProperty("name5", "value5-2");
-
- props.addProperty("name6", "value6-1");
- props.setProperty("name6", "value6-2");
-
- assertEquals("value1", props.getProperty("name1"));
- assertEquals(1, props.getProperties("name1").size());
- assertEquals("value1", props.getProperties("name1").get(0));
-
- assertEquals("value2", props.getProperty("name2"));
- assertEquals(1, props.getProperties("name2").size());
- assertEquals("value2", props.getProperties("name2").get(0));
-
- assertEquals("value3-1", props.getProperty("name3"));
- assertEquals(2, props.getProperties("name3").size());
- assertEquals("value3-1", props.getProperties("name3").get(0));
- assertEquals("value3-2", props.getProperties("name3").get(1));
-
- assertEquals("value4-1", props.getProperty("name4"));
- assertEquals(2, props.getProperties("name4").size());
- assertEquals("value4-1", props.getProperties("name4").get(0));
- assertEquals("value4-2", props.getProperties("name4").get(1));
-
- assertEquals(1, props.getProperties("name5").size());
- assertEquals("value5-2", props.getProperties("name5").get(0));
-
- assertEquals("value6-2", props.getProperty("name6"));
- assertEquals(1, props.getProperties("name6").size());
- assertEquals("value6-2", props.getProperties("name6").get(0));
-
- assertEquals(null, props.getProperties("not here"));
- assertNull(props.getProperty("not here"));
- assertEquals(Tools.toSet(new Object[]{"name1", "name2", "name3", "name4", "name5", "name6"}), props.getPropertyNames());
-
- try
- {
- props.setProperty(null, "not null");
- fail("Expected IllegalArgumentException");
- }
- catch (IllegalArgumentException e)
- {
- }
-
- try
- {
- props.setProperty("not null", null);
- fail("Expected IllegalArgumentException");
- }
- catch (IllegalArgumentException e)
- {
- }
-
- try
- {
- props.setProperty(null, null);
- fail("Expected IllegalArgumentException");
- }
- catch (IllegalArgumentException e)
- {
- }
- }
-
-}
Modified: modules/portlet/trunk/portlet/src/test/resources/local-jboss-unit.xml
===================================================================
--- modules/portlet/trunk/portlet/src/test/resources/local-jboss-unit.xml 2008-02-28 00:18:59 UTC (rev 10147)
+++ modules/portlet/trunk/portlet/src/test/resources/local-jboss-unit.xml 2008-02-28 00:25:00 UTC (rev 10148)
@@ -29,9 +29,6 @@
<class name="org.jboss.portal.test.portlet.ParametersTestCase"/>
</test>
<test>
- <class name="org.jboss.portal.test.portlet.PropertiesTestCase"/>
- </test>
- <test>
<class name="org.jboss.portal.test.portlet.ContentBufferTestCase"/>
</test>
<test>
16 years, 8 months
JBoss Portal SVN: r10147 - modules/portlet/trunk/controller/src/main/java/org/jboss/portal/portlet/controller/impl/request.
by portal-commits@lists.jboss.org
Author: julien(a)jboss.com
Date: 2008-02-27 19:18:59 -0500 (Wed, 27 Feb 2008)
New Revision: 10147
Modified:
modules/portlet/trunk/controller/src/main/java/org/jboss/portal/portlet/controller/impl/request/ControllerRequestParameterNames.java
Log:
minor upate to controller request parameter names
Modified: modules/portlet/trunk/controller/src/main/java/org/jboss/portal/portlet/controller/impl/request/ControllerRequestParameterNames.java
===================================================================
--- modules/portlet/trunk/controller/src/main/java/org/jboss/portal/portlet/controller/impl/request/ControllerRequestParameterNames.java 2008-02-28 00:17:07 UTC (rev 10146)
+++ modules/portlet/trunk/controller/src/main/java/org/jboss/portal/portlet/controller/impl/request/ControllerRequestParameterNames.java 2008-02-28 00:18:59 UTC (rev 10147)
@@ -32,31 +32,44 @@
* The life cycle type of the invocation. The values accepted are <code>ACTION_LIFECYCLE</code>,
* <code>RENDER_LIFECYCLE</code> and <code>RESOURCE_LIFECYCLE</code>.
*/
- public static final String LIFECYCLE_PHASE = "lifecycle";
+ public static final String LIFECYCLE_PHASE = "phase";
+
/** The window id. */
public static final String WINDOW_ID = "windowid";
+
/** The portlet mode. */
public static final String MODE = "mode";
+
/** The window state. */
public static final String WINDOW_STATE = "windowstate";
+
/** The portlet navigational state for any type of lifecycle. */
public static final String NAVIGATIONAL_STATE = "navigationalstate";
+
/** The portlet resource state for lifecycle of type <code>RENDER_LIFECYCLE</code>. */
public static final String RESOURCE_STATE = "resourcestate";
+
/** The portlet interaction state for lifecycle of type <code>ACTION_LIFECYCLE</code>. */
public static final String INTERACTION_STATE = "interactionstate";
+
/** The page state for any kind of lifecycle. */
- public static final String PAGE_NAVIGATIONAL_STATE = "pageNavigationalState";
+ public static final String PAGE_NAVIGATIONAL_STATE = "pagenavigationalstate";
+
/** The public navigational state changes of a portlet for lifecycle of type <code>RENDER_LIFECYCLE</code>. */
public static final String PUBLIC_NAVIGATIONAL_STATE_CHANGES = "publicnavigationalstatechanges";
+
/** The resource id for lifecycle of type <code>RESOURCE_LIFECYCLE</code>. */
public static final String RESOURCE_ID = "resourceid";
- /** The resource cacheability for lifecycle of type <code>RENDER_LIFECYCLE</code>. */
+
+ /** The resource cacheability for lifecycle of type <code>RESOURCE_LIFECYCLE</code>. */
public static final String RESOURCE_CACHEABILITY = "resourcecacheability";
+
/** Denotes an action lifecycle operation. */
public static final String ACTION_PHASE = "action";
+
/** Denotes a render lifecycle operation. */
public static final String RENDER_PHASE = "render";
+
/** Denotes a resource lifecycle operation. */
public static final String RESOURCE_PHASE = "resource";
}
16 years, 8 months
JBoss Portal SVN: r10146 - in modules/portlet/trunk: controller/src/main/java/org/jboss/portal/portlet/controller/impl/request and 11 other directories.
by portal-commits@lists.jboss.org
Author: julien(a)jboss.com
Date: 2008-02-27 19:17:07 -0500 (Wed, 27 Feb 2008)
New Revision: 10146
Modified:
modules/portlet/trunk/controller/src/main/java/org/jboss/portal/portlet/controller/PortletControllerContext.java
modules/portlet/trunk/controller/src/main/java/org/jboss/portal/portlet/controller/PortletRequestHandler.java
modules/portlet/trunk/controller/src/main/java/org/jboss/portal/portlet/controller/PortletResourceRequestHandler.java
modules/portlet/trunk/controller/src/main/java/org/jboss/portal/portlet/controller/impl/request/ControllerRequestFactory.java
modules/portlet/trunk/controller/src/main/java/org/jboss/portal/portlet/controller/impl/request/ControllerRequestParameterMapFactory.java
modules/portlet/trunk/controller/src/main/java/org/jboss/portal/portlet/controller/impl/request/ControllerRequestParameterNames.java
modules/portlet/trunk/controller/src/main/java/org/jboss/portal/portlet/controller/impl/state/StateControllerContextImpl.java
modules/portlet/trunk/controller/src/main/java/org/jboss/portal/portlet/controller/request/ControllerRequest.java
modules/portlet/trunk/controller/src/main/java/org/jboss/portal/portlet/controller/request/PortletActionRequest.java
modules/portlet/trunk/controller/src/main/java/org/jboss/portal/portlet/controller/request/PortletEventRequest.java
modules/portlet/trunk/controller/src/main/java/org/jboss/portal/portlet/controller/request/PortletRenderRequest.java
modules/portlet/trunk/controller/src/main/java/org/jboss/portal/portlet/controller/request/PortletRequest.java
modules/portlet/trunk/controller/src/main/java/org/jboss/portal/portlet/controller/request/PortletResourceRequest.java
modules/portlet/trunk/controller/src/main/java/org/jboss/portal/portlet/controller/response/PageUpdateResponse.java
modules/portlet/trunk/controller/src/main/java/org/jboss/portal/portlet/controller/state/PageNavigationalStateSerialization.java
modules/portlet/trunk/controller/src/main/java/org/jboss/portal/portlet/controller/state/StateControllerContext.java
modules/portlet/trunk/controller/src/test/java/org/jboss/portal/portlet/controller/PortletControllerContextSupport.java
modules/portlet/trunk/controller/src/test/java/org/jboss/portal/portlet/controller/PortletControllerTestCase.java
modules/portlet/trunk/test/src/main/java/org/jboss/portal/portlet/test/PortalServlet.java
modules/portlet/trunk/test/src/main/java/org/jboss/portal/portlet/test/controller/AbstractPortletControllerContext.java
modules/portlet/trunk/test/src/main/java/org/jboss/portal/portlet/test/controller/ControllerResponseRendererFactory.java
modules/portlet/trunk/test/src/main/java/org/jboss/portal/portlet/test/controller/PageRenderer.java
modules/portlet/trunk/test/src/main/java/org/jboss/portal/portlet/test/controller/PortletURLRenderer.java
modules/portlet/trunk/test/src/main/java/org/jboss/portal/portlet/test/controller/TestPortletInvocationContext.java
modules/portlet/trunk/test/src/main/java/org/jboss/portal/portlet/test/jsp/ControllerFilter.java
modules/portlet/trunk/test/src/main/java/org/jboss/portal/portlet/test/jsp/PortalRenderResponse.java
modules/portlet/trunk/test/src/main/java/org/jboss/portal/portlet/test/jsp/taglib/PortletMarkupTag.java
modules/portlet/trunk/test/src/main/java/org/jboss/portal/portlet/test/jsp/taglib/PortletURLTag.java
modules/portlet/trunk/test/src/main/java/org/jboss/portal/portlet/test/tck/TCKRendererContext.java
modules/portlet/trunk/test/src/main/java/org/jboss/portal/portlet/test/tck/TCKServlet.java
modules/portlet/trunk/test/src/main/java/org/jboss/portal/portlet/test/tck/TCKStateControllerContext.java
modules/portlet/trunk/test/src/test/java/org/jboss/portal/portlet/controller/StateControllerContextTestCase.java
Log:
rename pageState to pageNavigationalState because this is what it really is
Modified: modules/portlet/trunk/controller/src/main/java/org/jboss/portal/portlet/controller/PortletControllerContext.java
===================================================================
--- modules/portlet/trunk/controller/src/main/java/org/jboss/portal/portlet/controller/PortletControllerContext.java 2008-02-28 00:05:49 UTC (rev 10145)
+++ modules/portlet/trunk/controller/src/main/java/org/jboss/portal/portlet/controller/PortletControllerContext.java 2008-02-28 00:17:07 UTC (rev 10146)
@@ -60,10 +60,10 @@
* Create a portlet invocation context for the specified window id.
*
* @param windowId the window id
- * @param pageState
+ * @param pageNavigationalState
* @return
*/
- PortletInvocationContext createPortletInvocationContext(String windowId, PageNavigationalState pageState);
+ PortletInvocationContext createPortletInvocationContext(String windowId, PageNavigationalState pageNavigationalState);
PortletInvocationResponse invoke( ActionInvocation actionInvocation) throws PortletInvokerException;
Modified: modules/portlet/trunk/controller/src/main/java/org/jboss/portal/portlet/controller/PortletRequestHandler.java
===================================================================
--- modules/portlet/trunk/controller/src/main/java/org/jboss/portal/portlet/controller/PortletRequestHandler.java 2008-02-28 00:05:49 UTC (rev 10145)
+++ modules/portlet/trunk/controller/src/main/java/org/jboss/portal/portlet/controller/PortletRequestHandler.java 2008-02-28 00:17:07 UTC (rev 10146)
@@ -74,14 +74,14 @@
// The page navigational state we will operate on during the request
// Either we have nothing in the request so we create a new one
// Or we have one but we copy it as we should not modify the input state provided
- PageNavigationalState pageState = portletRequest.getPageState();
- if (pageState == null)
+ PageNavigationalState pageNavigationalState = portletRequest.getPageNavigationalState();
+ if (pageNavigationalState == null)
{
- pageState = stateContext.createPageState(true);
+ pageNavigationalState = stateContext.createPageNavigationalState(true);
}
else
{
- pageState = stateContext.clonePageState(pageState, true);
+ pageNavigationalState = stateContext.clonePageNavigationalState(pageNavigationalState, true);
}
//
@@ -92,7 +92,7 @@
{
// Update portlet NS
UpdateNavigationalStateResponse updateResponse = (UpdateNavigationalStateResponse)response;
- updateNavigationalState(context, portletRequest.getWindowId(), updateResponse, pageState);
+ updateNavigationalState(context, portletRequest.getWindowId(), updateResponse, pageNavigationalState);
//
ResponseProperties update = updateResponse.getProperties();
@@ -222,7 +222,7 @@
}
//
- PortletInvocationResponse eventResponse = deliverEvent(context, toConsumeEvent, pageState, requestProperties.getCookies());
+ PortletInvocationResponse eventResponse = deliverEvent(context, toConsumeEvent, pageNavigationalState, requestProperties.getCookies());
// Now it is consumed we add it to the history
session.consumedEventHistory.addFirst(toConsumeEvent);
@@ -233,7 +233,7 @@
UpdateNavigationalStateResponse eventStateResponse = (UpdateNavigationalStateResponse)eventResponse;
// Update ns
- updateNavigationalState(context, toConsumeEvent.getWindowId(), eventStateResponse, pageState);
+ updateNavigationalState(context, toConsumeEvent.getWindowId(), eventStateResponse, pageNavigationalState);
// Add events to source event queue
for (UpdateNavigationalStateResponse.Event portletEvent : eventStateResponse.getEvents())
@@ -263,7 +263,7 @@
}
//
- return new PageUpdateResponse(updateResponse, requestProperties, pageState, eventDistributionStatus);
+ return new PageUpdateResponse(updateResponse, requestProperties, pageNavigationalState, eventDistributionStatus);
}
else
{
@@ -292,7 +292,7 @@
PortletActionRequest portletActionRequest = (PortletActionRequest)portletRequest;
//
- PageNavigationalState pageState = portletActionRequest.getPageState();
+ PageNavigationalState pageNavigationalState = portletActionRequest.getPageNavigationalState();
//
Mode mode = portletActionRequest.getWindowNavigationalState().getMode();
@@ -310,12 +310,12 @@
//
ParameterMap publicNS = null;
- if (pageState != null)
+ if (pageNavigationalState != null)
{
- publicNS = pageState.getPublicNavigationalState(portletRequest.getWindowId());
+ publicNS = pageNavigationalState.getPublicNavigationalState(portletRequest.getWindowId());
}
- PortletInvocationContext portletInvocationContext = context.createPortletInvocationContext(portletRequest.getWindowId(), pageState);
+ PortletInvocationContext portletInvocationContext = context.createPortletInvocationContext(portletRequest.getWindowId(), pageNavigationalState);
ActionInvocation actionInvocation = new ActionInvocation(portletInvocationContext);
//
@@ -332,10 +332,10 @@
}
private PortletInvocationResponse deliverEvent(PortletControllerContext context, Event event,
- PageNavigationalState pageState, List<Cookie> requestCookies)
+ PageNavigationalState pageNavigationalState, List<Cookie> requestCookies)
throws PortletInvokerException
{
- WindowNavigationalState windowNS = pageState.getWindowNavigationalState(event.getWindowId());
+ WindowNavigationalState windowNS = pageNavigationalState.getWindowNavigationalState(event.getWindowId());
//
if (windowNS == null)
@@ -344,10 +344,10 @@
}
//
- ParameterMap publicNS = pageState.getPublicNavigationalState(event.getWindowId());
+ ParameterMap publicNS = pageNavigationalState.getPublicNavigationalState(event.getWindowId());
//
- PortletInvocationContext portletInvocationContext = context.createPortletInvocationContext(event.getWindowId(), pageState);
+ PortletInvocationContext portletInvocationContext = context.createPortletInvocationContext(event.getWindowId(), pageNavigationalState);
EventInvocation eventInvocation = new EventInvocation(portletInvocationContext);
//
@@ -366,10 +366,10 @@
PortletControllerContext context,
String windowId,
UpdateNavigationalStateResponse update,
- PageNavigationalState pageState)
+ PageNavigationalState pageNavigationalState)
throws PortletInvokerException
{
- WindowNavigationalState windowNS = pageState.getWindowNavigationalState(windowId);
+ WindowNavigationalState windowNS = pageNavigationalState.getWindowNavigationalState(windowId);
//
if (windowNS == null)
@@ -394,13 +394,13 @@
portletNS = update.getNavigationalState();
}
windowNS = new WindowNavigationalState(portletNS, mode, windowState);
- pageState.setWindowNavigationalState(windowId, windowNS);
+ pageNavigationalState.setWindowNavigationalState(windowId, windowNS);
// Now update shared state scoped at page
Map<String, String[]> publicNS = update.getPublicNavigationalStateUpdates();
if (publicNS != null)
{
- pageState.setPublicNavigationalState(windowId, publicNS);
+ pageNavigationalState.setPublicNavigationalState(windowId, publicNS);
}
}
}
Modified: modules/portlet/trunk/controller/src/main/java/org/jboss/portal/portlet/controller/PortletResourceRequestHandler.java
===================================================================
--- modules/portlet/trunk/controller/src/main/java/org/jboss/portal/portlet/controller/PortletResourceRequestHandler.java 2008-02-28 00:05:49 UTC (rev 10145)
+++ modules/portlet/trunk/controller/src/main/java/org/jboss/portal/portlet/controller/PortletResourceRequestHandler.java 2008-02-28 00:17:07 UTC (rev 10146)
@@ -60,7 +60,7 @@
//
Mode mode = null;
WindowState windowState = null;
- PageNavigationalState pageState = null;
+ PageNavigationalState pageNavigationalState = null;
ParameterMap publicNS = null;
StateString portletNS = null;
CacheLevel cacheability;
@@ -79,13 +79,13 @@
if (scope instanceof PortletResourceRequest.PageScope)
{
PortletResourceRequest.PageScope pageScope = (PortletResourceRequest.PageScope)scope;
- pageState = pageScope.getPageState();
+ pageNavigationalState = pageScope.getPageNavigationalState();
cacheability = CacheLevel.PAGE;
//
- if (pageState != null)
+ if (pageNavigationalState != null)
{
- publicNS = pageState.getPublicNavigationalState(portletResourceRequest.getWindowId());
+ publicNS = pageNavigationalState.getPublicNavigationalState(portletResourceRequest.getWindowId());
}
}
else
@@ -109,7 +109,7 @@
}
//
- PortletInvocationContext portletInvocationContext = context.createPortletInvocationContext(portletResourceRequest.getWindowId(), pageState);
+ PortletInvocationContext portletInvocationContext = context.createPortletInvocationContext(portletResourceRequest.getWindowId(), pageNavigationalState);
ResourceInvocation resourceInvocation = new ResourceInvocation(portletInvocationContext);
//
Modified: modules/portlet/trunk/controller/src/main/java/org/jboss/portal/portlet/controller/impl/request/ControllerRequestFactory.java
===================================================================
--- modules/portlet/trunk/controller/src/main/java/org/jboss/portal/portlet/controller/impl/request/ControllerRequestFactory.java 2008-02-28 00:05:49 UTC (rev 10145)
+++ modules/portlet/trunk/controller/src/main/java/org/jboss/portal/portlet/controller/impl/request/ControllerRequestFactory.java 2008-02-28 00:17:07 UTC (rev 10146)
@@ -63,12 +63,12 @@
// The nav state provided with the request
// Unmarshall portal navigational state if it is provided
- PageNavigationalState pageState = null;
- String context = req.getParameter(ControllerRequestParameterNames.PAGE_STATE);
+ PageNavigationalState pageNavigationalState = null;
+ String context = req.getParameter(ControllerRequestParameterNames.PAGE_NAVIGATIONAL_STATE);
if (context != null)
{
byte[] bytes = Base64.decode(context, true);
- pageState = IOTools.unserialize(serialization, SerializationFilter.COMPRESSOR, bytes);
+ pageNavigationalState = IOTools.unserialize(serialization, SerializationFilter.COMPRESSOR, bytes);
}
// Get the window id
@@ -127,7 +127,7 @@
scope = new PortletResourceRequest.PortletScope(windowNavigationalState);
break;
case PAGE:
- scope = new PortletResourceRequest.PageScope(windowNavigationalState, pageState);
+ scope = new PortletResourceRequest.PageScope(windowNavigationalState, pageNavigationalState);
break;
default:
throw new AssertionError();
@@ -160,7 +160,7 @@
interactionState,
formParameters,
windowNavigationalState,
- pageState);
+ pageNavigationalState);
}
else
{
@@ -172,7 +172,7 @@
windowId,
windowNavigationalState,
publicNavigationalStateChanges,
- pageState);
+ pageNavigationalState);
}
}
}
Modified: modules/portlet/trunk/controller/src/main/java/org/jboss/portal/portlet/controller/impl/request/ControllerRequestParameterMapFactory.java
===================================================================
--- modules/portlet/trunk/controller/src/main/java/org/jboss/portal/portlet/controller/impl/request/ControllerRequestParameterMapFactory.java 2008-02-28 00:05:49 UTC (rev 10145)
+++ modules/portlet/trunk/controller/src/main/java/org/jboss/portal/portlet/controller/impl/request/ControllerRequestParameterMapFactory.java 2008-02-28 00:17:07 UTC (rev 10146)
@@ -82,11 +82,11 @@
//
- String pageState = null;
+ String pageNavigationalState = null;
if (pageNS != null)
{
byte[] bytes = IOTools.serialize(serialization, SerializationFilter.COMPRESSOR, pageNS);
- pageState = Base64.encodeBytes(bytes, true);
+ pageNavigationalState = Base64.encodeBytes(bytes, true);
}
//
@@ -106,9 +106,9 @@
}
//
- if (pageState != null)
+ if (pageNavigationalState != null)
{
- parameters.put(ControllerRequestParameterNames.PAGE_STATE, pageState);
+ parameters.put(ControllerRequestParameterNames.PAGE_NAVIGATIONAL_STATE, pageNavigationalState);
}
//
@@ -183,9 +183,9 @@
parameters.put(ControllerRequestParameterNames.WINDOW_STATE, resourceURL.getWindowState().toString());
}
- if (cacheability == CacheLevel.PAGE && pageState != null)
+ if (cacheability == CacheLevel.PAGE && pageNavigationalState != null)
{
- parameters.put(ControllerRequestParameterNames.PAGE_STATE, pageState);
+ parameters.put(ControllerRequestParameterNames.PAGE_NAVIGATIONAL_STATE, pageNavigationalState);
}
}
}
Modified: modules/portlet/trunk/controller/src/main/java/org/jboss/portal/portlet/controller/impl/request/ControllerRequestParameterNames.java
===================================================================
--- modules/portlet/trunk/controller/src/main/java/org/jboss/portal/portlet/controller/impl/request/ControllerRequestParameterNames.java 2008-02-28 00:05:49 UTC (rev 10145)
+++ modules/portlet/trunk/controller/src/main/java/org/jboss/portal/portlet/controller/impl/request/ControllerRequestParameterNames.java 2008-02-28 00:17:07 UTC (rev 10146)
@@ -46,7 +46,7 @@
/** The portlet interaction state for lifecycle of type <code>ACTION_LIFECYCLE</code>. */
public static final String INTERACTION_STATE = "interactionstate";
/** The page state for any kind of lifecycle. */
- public static final String PAGE_STATE = "pagestate";
+ public static final String PAGE_NAVIGATIONAL_STATE = "pageNavigationalState";
/** The public navigational state changes of a portlet for lifecycle of type <code>RENDER_LIFECYCLE</code>. */
public static final String PUBLIC_NAVIGATIONAL_STATE_CHANGES = "publicnavigationalstatechanges";
/** The resource id for lifecycle of type <code>RESOURCE_LIFECYCLE</code>. */
Modified: modules/portlet/trunk/controller/src/main/java/org/jboss/portal/portlet/controller/impl/state/StateControllerContextImpl.java
===================================================================
--- modules/portlet/trunk/controller/src/main/java/org/jboss/portal/portlet/controller/impl/state/StateControllerContextImpl.java 2008-02-28 00:05:49 UTC (rev 10145)
+++ modules/portlet/trunk/controller/src/main/java/org/jboss/portal/portlet/controller/impl/state/StateControllerContextImpl.java 2008-02-28 00:17:07 UTC (rev 10146)
@@ -48,12 +48,12 @@
this.portletControllerContext = portletControllerContext;
}
- public PageNavigationalState clonePageState(PageNavigationalState pageState, boolean modifiable)
+ public PageNavigationalState clonePageNavigationalState(PageNavigationalState pageNavigationalState, boolean modifiable)
{
- return new PageNavigationalStateImpl((PageNavigationalStateImpl)pageState, modifiable);
+ return new PageNavigationalStateImpl((PageNavigationalStateImpl)pageNavigationalState, modifiable);
}
- public PageNavigationalState createPageState(boolean modifiable)
+ public PageNavigationalState createPageNavigationalState(boolean modifiable)
{
return new PageNavigationalStateImpl(this, modifiable);
}
Modified: modules/portlet/trunk/controller/src/main/java/org/jboss/portal/portlet/controller/request/ControllerRequest.java
===================================================================
--- modules/portlet/trunk/controller/src/main/java/org/jboss/portal/portlet/controller/request/ControllerRequest.java 2008-02-28 00:05:49 UTC (rev 10145)
+++ modules/portlet/trunk/controller/src/main/java/org/jboss/portal/portlet/controller/request/ControllerRequest.java 2008-02-28 00:17:07 UTC (rev 10146)
@@ -36,11 +36,11 @@
}
/**
- * Returns the page state or null if that kind of request cannot have one.
+ * Returns the page navigational state or null if that kind of request cannot have one.
*
* @return the page state
*/
- public PageNavigationalState getPageState()
+ public PageNavigationalState getPageNavigationalState()
{
return null;
}
Modified: modules/portlet/trunk/controller/src/main/java/org/jboss/portal/portlet/controller/request/PortletActionRequest.java
===================================================================
--- modules/portlet/trunk/controller/src/main/java/org/jboss/portal/portlet/controller/request/PortletActionRequest.java 2008-02-28 00:05:49 UTC (rev 10145)
+++ modules/portlet/trunk/controller/src/main/java/org/jboss/portal/portlet/controller/request/PortletActionRequest.java 2008-02-28 00:17:07 UTC (rev 10146)
@@ -45,9 +45,9 @@
StateString interactionState,
ParameterMap bodyParameters,
WindowNavigationalState windowNavigationalState,
- PageNavigationalState pageState)
+ PageNavigationalState pageNavigationalState)
{
- super(windowId, windowNavigationalState, pageState);
+ super(windowId, windowNavigationalState, pageNavigationalState);
//
this.interactionState = interactionState;
Modified: modules/portlet/trunk/controller/src/main/java/org/jboss/portal/portlet/controller/request/PortletEventRequest.java
===================================================================
--- modules/portlet/trunk/controller/src/main/java/org/jboss/portal/portlet/controller/request/PortletEventRequest.java 2008-02-28 00:05:49 UTC (rev 10145)
+++ modules/portlet/trunk/controller/src/main/java/org/jboss/portal/portlet/controller/request/PortletEventRequest.java 2008-02-28 00:17:07 UTC (rev 10146)
@@ -47,11 +47,11 @@
public PortletEventRequest(
String windowId,
WindowNavigationalState windowNavigationalState,
- PageNavigationalState pageState,
+ PageNavigationalState pageNavigationalState,
QName name,
Serializable payload)
{
- super(windowId, windowNavigationalState, pageState);
+ super(windowId, windowNavigationalState, pageNavigationalState);
//
this.name = name;
Modified: modules/portlet/trunk/controller/src/main/java/org/jboss/portal/portlet/controller/request/PortletRenderRequest.java
===================================================================
--- modules/portlet/trunk/controller/src/main/java/org/jboss/portal/portlet/controller/request/PortletRenderRequest.java 2008-02-28 00:05:49 UTC (rev 10145)
+++ modules/portlet/trunk/controller/src/main/java/org/jboss/portal/portlet/controller/request/PortletRenderRequest.java 2008-02-28 00:17:07 UTC (rev 10146)
@@ -42,9 +42,9 @@
String windowId,
WindowNavigationalState windowNavigationalState,
Map<String, String[]> publicNavigationalStateChanges,
- PageNavigationalState pageState)
+ PageNavigationalState pageNavigationalState)
{
- super(windowId, windowNavigationalState, pageState);
+ super(windowId, windowNavigationalState, pageNavigationalState);
//
this.publicNavigationalStateChanges = publicNavigationalStateChanges;
Modified: modules/portlet/trunk/controller/src/main/java/org/jboss/portal/portlet/controller/request/PortletRequest.java
===================================================================
--- modules/portlet/trunk/controller/src/main/java/org/jboss/portal/portlet/controller/request/PortletRequest.java 2008-02-28 00:05:49 UTC (rev 10145)
+++ modules/portlet/trunk/controller/src/main/java/org/jboss/portal/portlet/controller/request/PortletRequest.java 2008-02-28 00:17:07 UTC (rev 10146)
@@ -22,7 +22,6 @@
******************************************************************************/
package org.jboss.portal.portlet.controller.request;
-import org.jboss.portal.portlet.controller.PortletControllerContext;
import org.jboss.portal.portlet.controller.state.PageNavigationalState;
import org.jboss.portal.portlet.controller.state.WindowNavigationalState;
@@ -34,7 +33,7 @@
{
/** . */
- private final PageNavigationalState pageState;
+ private final PageNavigationalState pageNavigationalState;
/** . */
private final WindowNavigationalState windowNavigationalState;
@@ -42,18 +41,18 @@
PortletRequest(
String windowId,
WindowNavigationalState windowNavigationalState,
- PageNavigationalState pageState)
+ PageNavigationalState pageNavigationalState)
{
super(windowId);
//
this.windowNavigationalState = windowNavigationalState;
- this.pageState = pageState;
+ this.pageNavigationalState = pageNavigationalState;
}
- public PageNavigationalState getPageState()
+ public PageNavigationalState getPageNavigationalState()
{
- return pageState;
+ return pageNavigationalState;
}
public WindowNavigationalState getWindowNavigationalState()
Modified: modules/portlet/trunk/controller/src/main/java/org/jboss/portal/portlet/controller/request/PortletResourceRequest.java
===================================================================
--- modules/portlet/trunk/controller/src/main/java/org/jboss/portal/portlet/controller/request/PortletResourceRequest.java 2008-02-28 00:05:49 UTC (rev 10145)
+++ modules/portlet/trunk/controller/src/main/java/org/jboss/portal/portlet/controller/request/PortletResourceRequest.java 2008-02-28 00:17:07 UTC (rev 10146)
@@ -28,9 +28,6 @@
import org.jboss.portal.portlet.controller.state.PageNavigationalState;
import org.jboss.portal.portlet.cache.CacheLevel;
-import java.util.HashMap;
-import java.util.Map;
-
/**
* @author <a href="mailto:julien@jboss.org">Julien Viet</a>
* @version $Revision: 630 $
@@ -132,19 +129,19 @@
{
/** . */
- private final PageNavigationalState pageState;
+ private final PageNavigationalState pageNavigationalState;
- public PageScope(WindowNavigationalState windowNavigationalState, PageNavigationalState pageState)
+ public PageScope(WindowNavigationalState windowNavigationalState, PageNavigationalState pageNavigationalState)
{
super(windowNavigationalState);
//
- this.pageState = pageState;
+ this.pageNavigationalState = pageNavigationalState;
}
- public PageNavigationalState getPageState()
+ public PageNavigationalState getPageNavigationalState()
{
- return pageState;
+ return pageNavigationalState;
}
public CacheLevel getCacheability()
Modified: modules/portlet/trunk/controller/src/main/java/org/jboss/portal/portlet/controller/response/PageUpdateResponse.java
===================================================================
--- modules/portlet/trunk/controller/src/main/java/org/jboss/portal/portlet/controller/response/PageUpdateResponse.java 2008-02-28 00:05:49 UTC (rev 10145)
+++ modules/portlet/trunk/controller/src/main/java/org/jboss/portal/portlet/controller/response/PageUpdateResponse.java 2008-02-28 00:17:07 UTC (rev 10146)
@@ -37,19 +37,19 @@
private ResponseProperties properties;
/** . */
- private PageNavigationalState pageState;
+ private PageNavigationalState pageNavigationalState;
public PageUpdateResponse(
UpdateNavigationalStateResponse update,
ResponseProperties properties,
- PageNavigationalState pageState,
+ PageNavigationalState pageNavigationalState,
int eventCycleStatus)
{
super(update, eventCycleStatus);
//
this.properties = properties;
- this.pageState = pageState;
+ this.pageNavigationalState = pageNavigationalState;
}
public ResponseProperties getProperties()
@@ -57,8 +57,8 @@
return properties;
}
- public PageNavigationalState getPageState()
+ public PageNavigationalState getPageNavigationalState()
{
- return pageState;
+ return pageNavigationalState;
}
}
Modified: modules/portlet/trunk/controller/src/main/java/org/jboss/portal/portlet/controller/state/PageNavigationalStateSerialization.java
===================================================================
--- modules/portlet/trunk/controller/src/main/java/org/jboss/portal/portlet/controller/state/PageNavigationalStateSerialization.java 2008-02-28 00:05:49 UTC (rev 10145)
+++ modules/portlet/trunk/controller/src/main/java/org/jboss/portal/portlet/controller/state/PageNavigationalStateSerialization.java 2008-02-28 00:17:07 UTC (rev 10146)
@@ -87,16 +87,16 @@
this.context = context;
}
- public void serialize(PageNavigationalState pageState, OutputStream out) throws IOException, IllegalArgumentException
+ public void serialize(PageNavigationalState pageNavigationalState, OutputStream out) throws IOException, IllegalArgumentException
{
DataOutputStream data = out instanceof DataOutputStream ? (DataOutputStream)out : new DataOutputStream(out);
//
- data.writeInt(pageState.getWindowIds().size());
- for (String windowId : pageState.getWindowIds())
+ data.writeInt(pageNavigationalState.getWindowIds().size());
+ for (String windowId : pageNavigationalState.getWindowIds())
{
data.writeUTF(windowId);
- WindowNavigationalState windowNS = pageState.getWindowNavigationalState(windowId);
+ WindowNavigationalState windowNS = pageNavigationalState.getWindowNavigationalState(windowId);
byte header = 0;
int decision = 0;
if (windowNS.getPortletNavigationalState() != null)
@@ -146,13 +146,13 @@
}
//
- Set<QName> publicNames = pageState.getPublicNames();
+ Set<QName> publicNames = pageNavigationalState.getPublicNames();
data.writeInt(publicNames.size());
- for (QName name : pageState.getPublicNames())
+ for (QName name : pageNavigationalState.getPublicNames())
{
data.writeUTF(name.getNamespaceURI());
data.writeUTF(name.getLocalPart());
- String[] values = pageState.getPublicNavigationalState(name);
+ String[] values = pageNavigationalState.getPublicNavigationalState(name);
int length = values.length;
data.writeInt(length);
for (String value : values)
@@ -171,7 +171,7 @@
DataInputStream data = in instanceof DataInputStream ? (DataInputStream)in : new DataInputStream(in);
//
- PageNavigationalState pageNS = context.createPageState(true);
+ PageNavigationalState pageNS = context.createPageNavigationalState(true);
//
int size = data.readInt();
Modified: modules/portlet/trunk/controller/src/main/java/org/jboss/portal/portlet/controller/state/StateControllerContext.java
===================================================================
--- modules/portlet/trunk/controller/src/main/java/org/jboss/portal/portlet/controller/state/StateControllerContext.java 2008-02-28 00:05:49 UTC (rev 10145)
+++ modules/portlet/trunk/controller/src/main/java/org/jboss/portal/portlet/controller/state/StateControllerContext.java 2008-02-28 00:17:07 UTC (rev 10146)
@@ -34,11 +34,10 @@
/**
* Clone an existing page state object.
*
- * @param pageState the page state to clone
- * @param modifiable set the modifiable status
- * @return the page state clone
+ * @param pageNavigationalState
+ *@param modifiable set the modifiable status @return the page state clone
*/
- PageNavigationalState clonePageState(PageNavigationalState pageState, boolean modifiable);
+ PageNavigationalState clonePageNavigationalState(PageNavigationalState pageNavigationalState, boolean modifiable);
/**
* Create a new page state object.
@@ -46,6 +45,6 @@
* @param modifiable set the modifiable status
* @return the new page state
*/
- PageNavigationalState createPageState(boolean modifiable);
+ PageNavigationalState createPageNavigationalState(boolean modifiable);
}
Modified: modules/portlet/trunk/controller/src/test/java/org/jboss/portal/portlet/controller/PortletControllerContextSupport.java
===================================================================
--- modules/portlet/trunk/controller/src/test/java/org/jboss/portal/portlet/controller/PortletControllerContextSupport.java 2008-02-28 00:05:49 UTC (rev 10145)
+++ modules/portlet/trunk/controller/src/test/java/org/jboss/portal/portlet/controller/PortletControllerContextSupport.java 2008-02-28 00:17:07 UTC (rev 10146)
@@ -77,7 +77,7 @@
}
//
- public PortletInvocationContext createPortletInvocationContext(String windowId, PageNavigationalState pageState)
+ public PortletInvocationContext createPortletInvocationContext(String windowId, PageNavigationalState pageNavigationalState)
{
if (windowId == null)
{
@@ -85,7 +85,7 @@
}
//
- return new PortletInvocationContextSupport(windowId, pageState);
+ return new PortletInvocationContextSupport(windowId, pageNavigationalState);
}
private PortletInvocationResponse invoke(PortletInvocation invocation) throws PortletInvokerException
Modified: modules/portlet/trunk/controller/src/test/java/org/jboss/portal/portlet/controller/PortletControllerTestCase.java
===================================================================
--- modules/portlet/trunk/controller/src/test/java/org/jboss/portal/portlet/controller/PortletControllerTestCase.java 2008-02-28 00:05:49 UTC (rev 10145)
+++ modules/portlet/trunk/controller/src/test/java/org/jboss/portal/portlet/controller/PortletControllerTestCase.java 2008-02-28 00:17:07 UTC (rev 10146)
@@ -93,14 +93,14 @@
new OpaqueStateString(""),
new ParameterMap(),
new WindowNavigationalState(),
- context.getStateControllerContext().createPageState(false)
+ context.getStateControllerContext().createPageNavigationalState(false)
);
ControllerResponse response = controller.process(context, request);
PageUpdateResponse pageUpdate = assertInstanceOf(response, PageUpdateResponse.class);
- PageNavigationalState pageNS = assertNotNull(pageUpdate.getPageState());
+ PageNavigationalState pageNS = assertNotNull(pageUpdate.getPageNavigationalState());
assertEquals(Tools.toSet("foo"), pageNS.getWindowIds());
@@ -127,7 +127,7 @@
new OpaqueStateString(""),
new ParameterMap(),
new WindowNavigationalState(),
- context.getStateControllerContext().createPageState(false)
+ context.getStateControllerContext().createPageNavigationalState(false)
);
try
@@ -165,7 +165,7 @@
new OpaqueStateString(""),
new ParameterMap(),
new WindowNavigationalState(),
- context.getStateControllerContext().createPageState(false)
+ context.getStateControllerContext().createPageNavigationalState(false)
);
//
@@ -260,7 +260,7 @@
new OpaqueStateString(""),
new ParameterMap(),
new WindowNavigationalState(),
- context.getStateControllerContext().createPageState(false)
+ context.getStateControllerContext().createPageNavigationalState(false)
);
EventProducerActionHandler eventProducerActionHandler = new EventProducerActionHandler(srcName);
@@ -301,7 +301,7 @@
new OpaqueStateString(""),
new ParameterMap(),
new WindowNavigationalState(),
- context.getStateControllerContext().createPageState(false)
+ context.getStateControllerContext().createPageNavigationalState(false)
);
//
@@ -339,7 +339,7 @@
new OpaqueStateString(""),
new ParameterMap(),
new WindowNavigationalState(),
- context.getStateControllerContext().createPageState(false)
+ context.getStateControllerContext().createPageNavigationalState(false)
);
//
Modified: modules/portlet/trunk/test/src/main/java/org/jboss/portal/portlet/test/PortalServlet.java
===================================================================
--- modules/portlet/trunk/test/src/main/java/org/jboss/portal/portlet/test/PortalServlet.java 2008-02-28 00:05:49 UTC (rev 10145)
+++ modules/portlet/trunk/test/src/main/java/org/jboss/portal/portlet/test/PortalServlet.java 2008-02-28 00:17:07 UTC (rev 10146)
@@ -95,7 +95,7 @@
true,
true,
context.getStateControllerContext(),
- request.getPageState());
+ request.getPageNavigationalState());
//
Renderer renderer = rendererFactory.getRenderer(response);
@@ -106,7 +106,7 @@
else
{
- PageRenderer renderer = new PageRenderer(new ResponseProperties(), context.getStateControllerContext().createPageState(false));
+ PageRenderer renderer = new PageRenderer(new ResponseProperties(), context.getStateControllerContext().createPageNavigationalState(false));
//
renderer.render(new RendererContextImpl(context));
Modified: modules/portlet/trunk/test/src/main/java/org/jboss/portal/portlet/test/controller/AbstractPortletControllerContext.java
===================================================================
--- modules/portlet/trunk/test/src/main/java/org/jboss/portal/portlet/test/controller/AbstractPortletControllerContext.java 2008-02-28 00:05:49 UTC (rev 10145)
+++ modules/portlet/trunk/test/src/main/java/org/jboss/portal/portlet/test/controller/AbstractPortletControllerContext.java 2008-02-28 00:17:07 UTC (rev 10146)
@@ -184,8 +184,8 @@
return invoke((PortletInvocation)resourceInvocation);
}
- public PortletInvocationContext createPortletInvocationContext(String windowId, PageNavigationalState pageState)
+ public PortletInvocationContext createPortletInvocationContext(String windowId, PageNavigationalState pageNavigationalState)
{
- return new TestPortletInvocationContext(getPageNavigationalStateSerialization(), req, resp, windowId, pageState, MARKUP_INFO);
+ return new TestPortletInvocationContext(getPageNavigationalStateSerialization(), req, resp, windowId, pageNavigationalState, MARKUP_INFO);
}
}
\ No newline at end of file
Modified: modules/portlet/trunk/test/src/main/java/org/jboss/portal/portlet/test/controller/ControllerResponseRendererFactory.java
===================================================================
--- modules/portlet/trunk/test/src/main/java/org/jboss/portal/portlet/test/controller/ControllerResponseRendererFactory.java 2008-02-28 00:05:49 UTC (rev 10145)
+++ modules/portlet/trunk/test/src/main/java/org/jboss/portal/portlet/test/controller/ControllerResponseRendererFactory.java 2008-02-28 00:17:07 UTC (rev 10146)
@@ -49,7 +49,7 @@
private boolean sendErrorOnProcessActionError;
/** The page navigational state if there is one in the request. */
- private PageNavigationalState requestPageState;
+ private PageNavigationalState requestPageNavigationalState;
/** . */
private StateControllerContext stateControllerContext;
@@ -58,12 +58,12 @@
boolean sendNoContentResponseOnEmptyResource,
boolean sendErrorOnProcessActionError,
StateControllerContext stateControllerContext,
- PageNavigationalState requestPageState)
+ PageNavigationalState requestPageNavigationalState)
{
this.sendNoContentResponseOnEmptyResource = sendNoContentResponseOnEmptyResource;
this.sendErrorOnProcessActionError = sendErrorOnProcessActionError;
this.stateControllerContext = stateControllerContext;
- this.requestPageState = requestPageState;
+ this.requestPageNavigationalState = requestPageNavigationalState;
}
public Renderer getRenderer(ControllerResponse response)
@@ -73,7 +73,7 @@
PageUpdateResponse pageUpdate = (PageUpdateResponse)response;
//
- return new PageRenderer(pageUpdate.getProperties(), pageUpdate.getPageState());
+ return new PageRenderer(pageUpdate.getProperties(), pageUpdate.getPageNavigationalState());
}
else if (response instanceof PortletResponse)
{
@@ -112,7 +112,7 @@
}
else
{
- return new PageRenderer(new ResponseProperties(), requestPageState != null ? requestPageState : stateControllerContext.createPageState(false));
+ return new PageRenderer(new ResponseProperties(), requestPageNavigationalState != null ? requestPageNavigationalState : stateControllerContext.createPageNavigationalState(false));
}
}
Modified: modules/portlet/trunk/test/src/main/java/org/jboss/portal/portlet/test/controller/PageRenderer.java
===================================================================
--- modules/portlet/trunk/test/src/main/java/org/jboss/portal/portlet/test/controller/PageRenderer.java 2008-02-28 00:05:49 UTC (rev 10145)
+++ modules/portlet/trunk/test/src/main/java/org/jboss/portal/portlet/test/controller/PageRenderer.java 2008-02-28 00:17:07 UTC (rev 10146)
@@ -64,14 +64,14 @@
protected FragmentRenderer fragmentRenderer = new SimpleFragmentRenderer();
protected List<FragmentResponse> fragments;
protected List<ErrorResponse> errors;
- protected PageNavigationalState pageState;
+ protected PageNavigationalState pageNavigationalState;
- public PageRenderer(ResponseProperties properties, PageNavigationalState pageState)
+ public PageRenderer(ResponseProperties properties, PageNavigationalState pageNavigationalState)
{
super(properties);
//
- this.pageState = pageState;
+ this.pageNavigationalState = pageNavigationalState;
}
public void setFragmentRenderer(FragmentRenderer fragmentRenderer)
@@ -141,7 +141,7 @@
for (Portlet portlet : portlets)
{
- WindowNavigationalState windowNS = pageState.getWindowNavigationalState(portlet.getContext().getId());
+ WindowNavigationalState windowNS = pageNavigationalState.getWindowNavigationalState(portlet.getContext().getId());
//
Mode mode = Mode.VIEW;
@@ -166,9 +166,9 @@
}
//
- ParameterMap publicNS = pageState.getPublicNavigationalState(portlet.getContext().getId());
+ ParameterMap publicNS = pageNavigationalState.getPublicNavigationalState(portlet.getContext().getId());
- RenderInvocation render = createRenderInvocation(context, properties, pageState, portlet, windowNS, mode, windowState, portletNS, publicNS);
+ RenderInvocation render = createRenderInvocation(context, properties, pageNavigationalState, portlet, windowNS, mode, windowState, portletNS, publicNS);
//
try
Modified: modules/portlet/trunk/test/src/main/java/org/jboss/portal/portlet/test/controller/PortletURLRenderer.java
===================================================================
--- modules/portlet/trunk/test/src/main/java/org/jboss/portal/portlet/test/controller/PortletURLRenderer.java 2008-02-28 00:05:49 UTC (rev 10145)
+++ modules/portlet/trunk/test/src/main/java/org/jboss/portal/portlet/test/controller/PortletURLRenderer.java 2008-02-28 00:17:07 UTC (rev 10146)
@@ -112,18 +112,18 @@
public String renderURL(URLFormat format)
{
- String pageState = null;
+ String pageNavigationalState = null;
if (pageNS != null)
{
byte[] bytes = IOTools.serialize(serialization, SerializationFilter.COMPRESSOR, pageNS);
- pageState = Base64.encodeBytes(bytes, true);
+ pageNavigationalState = Base64.encodeBytes(bytes, true);
}
//
Map<String, String> parameters;
- if (pageState != null)
+ if (pageNavigationalState != null)
{
- parameters = Collections.singletonMap(ControllerRequestParameterNames.PAGE_STATE, pageState);
+ parameters = Collections.singletonMap(ControllerRequestParameterNames.PAGE_NAVIGATIONAL_STATE, pageNavigationalState);
}
else
{
Modified: modules/portlet/trunk/test/src/main/java/org/jboss/portal/portlet/test/controller/TestPortletInvocationContext.java
===================================================================
--- modules/portlet/trunk/test/src/main/java/org/jboss/portal/portlet/test/controller/TestPortletInvocationContext.java 2008-02-28 00:05:49 UTC (rev 10145)
+++ modules/portlet/trunk/test/src/main/java/org/jboss/portal/portlet/test/controller/TestPortletInvocationContext.java 2008-02-28 00:17:07 UTC (rev 10146)
@@ -61,7 +61,7 @@
HttpServletRequest clientRequest,
HttpServletResponse clientResponse,
String windowId,
- PageNavigationalState pageState,
+ PageNavigationalState pageNavigationalState,
MarkupInfo markupInfo)
{
super(markupInfo);
@@ -70,7 +70,7 @@
this.clientRequest = clientRequest;
this.clientResponse = clientResponse;
this.windowId = windowId;
- this.urlRenderer = new PortletURLRenderer(pageState, clientRequest, clientResponse, serialization);
+ this.urlRenderer = new PortletURLRenderer(pageNavigationalState, clientRequest, clientResponse, serialization);
//
addResolver(PortletInvocation.PRINCIPAL_SCOPE, new PrincipalAttributeResolver(clientRequest));
Modified: modules/portlet/trunk/test/src/main/java/org/jboss/portal/portlet/test/jsp/ControllerFilter.java
===================================================================
--- modules/portlet/trunk/test/src/main/java/org/jboss/portal/portlet/test/jsp/ControllerFilter.java 2008-02-28 00:05:49 UTC (rev 10145)
+++ modules/portlet/trunk/test/src/main/java/org/jboss/portal/portlet/test/jsp/ControllerFilter.java 2008-02-28 00:17:07 UTC (rev 10146)
@@ -109,7 +109,7 @@
// Process only portlet type
// The request decoded if not null
- PageNavigationalState pageState = null;
+ PageNavigationalState pageNavigationalState = null;
if (URLParameterConstants.PORTLET_TYPE.equals(type))
{
WebRequest wr = new WebRequest(req);
@@ -136,7 +136,7 @@
{
//
PortletURLRenderer renderer = new PortletURLRenderer(
- pageUpdate.getPageState(),
+ pageUpdate.getPageNavigationalState(),
context.getClientRequest(),
context.getClientResponse(),
context.getPageNavigationalStateSerialization());
@@ -152,7 +152,7 @@
}
else
{
- pageState = pageUpdate.getPageState();
+ pageNavigationalState = pageUpdate.getPageNavigationalState();
}
}
else if (controllerResponse instanceof ResourceResponse)
@@ -250,17 +250,17 @@
PageNavigationalStateSerialization serialization = new PageNavigationalStateSerialization(context.getStateControllerContext());
// The nav state provided with the request
// Unmarshall portal navigational state if it is provided
- pageState = null;
- String blah = req.getParameter(ControllerRequestParameterNames.PAGE_STATE);
+ pageNavigationalState = null;
+ String blah = req.getParameter(ControllerRequestParameterNames.PAGE_NAVIGATIONAL_STATE);
if (blah != null)
{
byte[] bytes = Base64.decode(blah, true);
- pageState = IOTools.unserialize(serialization, SerializationFilter.COMPRESSOR, bytes);
+ pageNavigationalState = IOTools.unserialize(serialization, SerializationFilter.COMPRESSOR, bytes);
}
}
//
- PortalRenderResponse renderResponse = new PortalRenderResponse(req, resp, context, pageState, prepareResponse);
+ PortalRenderResponse renderResponse = new PortalRenderResponse(req, resp, context, pageNavigationalState, prepareResponse);
//
chain.doFilter(req, renderResponse);
Modified: modules/portlet/trunk/test/src/main/java/org/jboss/portal/portlet/test/jsp/PortalRenderResponse.java
===================================================================
--- modules/portlet/trunk/test/src/main/java/org/jboss/portal/portlet/test/jsp/PortalRenderResponse.java 2008-02-28 00:05:49 UTC (rev 10145)
+++ modules/portlet/trunk/test/src/main/java/org/jboss/portal/portlet/test/jsp/PortalRenderResponse.java 2008-02-28 00:17:07 UTC (rev 10146)
@@ -57,7 +57,7 @@
{
/** . */
- private PageNavigationalState pageState;
+ private PageNavigationalState pageNavigationalState;
/** . */
private PagePortletControllerContext portletControllerContext;
@@ -69,7 +69,7 @@
HttpServletRequest request,
HttpServletResponse response,
PagePortletControllerContext portletControllerContext,
- PageNavigationalState pageState,
+ PageNavigationalState pageNavigationalState,
PortalPrepareResponse prepareResponse) throws PortletInvokerException
{
super(request, response);
@@ -78,17 +78,17 @@
Set<QName> pageParameterNames = prepareResponse.getPageParameterNames();
if (pageParameterNames.size() > 0)
{
- if (pageState == null)
+ if (pageNavigationalState == null)
{
- pageState = portletControllerContext.getStateControllerContext().createPageState(true);
+ pageNavigationalState = portletControllerContext.getStateControllerContext().createPageNavigationalState(true);
}
for (QName parameterName : pageParameterNames)
{
PageParameterDef parameterDef = prepareResponse.getPageParameterDef(parameterName);
- boolean update = parameterDef.isFrozen() ? true : pageState.getPublicNavigationalState(parameterName) == null;
+ boolean update = parameterDef.isFrozen() ? true : pageNavigationalState.getPublicNavigationalState(parameterName) == null;
if (update)
{
- pageState.setPublicNavigationalState(parameterName, new String[]{parameterDef.getValue()});
+ pageNavigationalState.setPublicNavigationalState(parameterName, new String[]{parameterDef.getValue()});
}
}
}
@@ -96,7 +96,7 @@
//
this.portletControllerContext = portletControllerContext;
this.windowResults = new HashMap<String, WindowResult>();
- this.pageState = pageState;
+ this.pageNavigationalState = pageNavigationalState;
//
render(prepareResponse);
@@ -107,9 +107,9 @@
*
* @return the page state
*/
- public PageNavigationalState getPageState()
+ public PageNavigationalState getPageNavigationalState()
{
- return pageState;
+ return pageNavigationalState;
}
public Set<String> getWindowIds()
@@ -130,16 +130,16 @@
private PortletInvocationResponse render(Portlet portlet, String windowId) throws PortletInvokerException
{
WindowNavigationalState windowNS = null;
- if (pageState != null)
+ if (pageNavigationalState != null)
{
- windowNS = pageState.getWindowNavigationalState(windowId);
+ windowNS = pageNavigationalState.getWindowNavigationalState(windowId);
}
//
ParameterMap publicNS = null;
- if (pageState != null)
+ if (pageNavigationalState != null)
{
- publicNS = pageState.getPublicNavigationalState(windowId);
+ publicNS = pageNavigationalState.getPublicNavigationalState(windowId);
}
//
@@ -165,7 +165,7 @@
}
//
- PortletInvocationContext renderContext = portletControllerContext.createPortletInvocationContext(windowId, pageState);
+ PortletInvocationContext renderContext = portletControllerContext.createPortletInvocationContext(windowId, pageNavigationalState);
RenderInvocation render = new RenderInvocation(renderContext);
render.setClientContext(new AbstractClientContext(portletControllerContext.getClientRequest()));
render.setServerContext(new AbstractServerContext(portletControllerContext.getClientRequest(), portletControllerContext.getClientResponse()));
@@ -229,11 +229,11 @@
public String getMaximizedWindowId()
{
- if (pageState != null)
+ if (pageNavigationalState != null)
{
- for (String windowId : pageState.getWindowIds())
+ for (String windowId : pageNavigationalState.getWindowIds())
{
- WindowNavigationalState windowNS = pageState.getWindowNavigationalState(windowId);
+ WindowNavigationalState windowNS = pageNavigationalState.getWindowNavigationalState(windowId);
if (WindowState.MAXIMIZED.equals(windowNS.getWindowState()))
{
return windowId;
Modified: modules/portlet/trunk/test/src/main/java/org/jboss/portal/portlet/test/jsp/taglib/PortletMarkupTag.java
===================================================================
--- modules/portlet/trunk/test/src/main/java/org/jboss/portal/portlet/test/jsp/taglib/PortletMarkupTag.java 2008-02-28 00:05:49 UTC (rev 10145)
+++ modules/portlet/trunk/test/src/main/java/org/jboss/portal/portlet/test/jsp/taglib/PortletMarkupTag.java 2008-02-28 00:17:07 UTC (rev 10146)
@@ -53,9 +53,9 @@
{
FragmentResponse fragment = (FragmentResponse)portletResp;
WindowNavigationalState windowNS = null;
- if (renderResponse.getPageState() != null)
+ if (renderResponse.getPageNavigationalState() != null)
{
- windowNS = renderResponse.getPageState().getWindowNavigationalState(portletTag.result.getWindowDef().getWindowId());
+ windowNS = renderResponse.getPageNavigationalState().getWindowNavigationalState(portletTag.result.getWindowDef().getWindowId());
}
if (windowNS == null || !windowNS.getWindowState().equals(WindowState.MINIMIZED))
{
Modified: modules/portlet/trunk/test/src/main/java/org/jboss/portal/portlet/test/jsp/taglib/PortletURLTag.java
===================================================================
--- modules/portlet/trunk/test/src/main/java/org/jboss/portal/portlet/test/jsp/taglib/PortletURLTag.java 2008-02-28 00:05:49 UTC (rev 10145)
+++ modules/portlet/trunk/test/src/main/java/org/jboss/portal/portlet/test/jsp/taglib/PortletURLTag.java 2008-02-28 00:17:07 UTC (rev 10146)
@@ -94,7 +94,7 @@
}
PortletURLRenderer renderer = new PortletURLRenderer(
- renderResponse.getPageState(),
+ renderResponse.getPageNavigationalState(),
context.getClientRequest(),
context.getClientResponse(),
context.getPageNavigationalStateSerialization());
Modified: modules/portlet/trunk/test/src/main/java/org/jboss/portal/portlet/test/tck/TCKRendererContext.java
===================================================================
--- modules/portlet/trunk/test/src/main/java/org/jboss/portal/portlet/test/tck/TCKRendererContext.java 2008-02-28 00:05:49 UTC (rev 10145)
+++ modules/portlet/trunk/test/src/main/java/org/jboss/portal/portlet/test/tck/TCKRendererContext.java 2008-02-28 00:17:07 UTC (rev 10146)
@@ -42,7 +42,7 @@
public TCKRendererContext(
TCKPortletControllerContext portletControllerContext,
- TCKPageNavigationalState pageState) throws PortletInvokerException
+ TCKPageNavigationalState tckPageNavigationalState) throws PortletInvokerException
{
super(portletControllerContext);
@@ -50,9 +50,9 @@
Collection<Portlet> involvedPortlets = new ArrayList<Portlet>();
// Page state could be null for some requests
- if (pageState != null)
+ if (tckPageNavigationalState != null)
{
- for (String involvedPortletId : pageState.getInvolvedPortlets())
+ for (String involvedPortletId : tckPageNavigationalState.getInvolvedPortlets())
{
try
{
Modified: modules/portlet/trunk/test/src/main/java/org/jboss/portal/portlet/test/tck/TCKServlet.java
===================================================================
--- modules/portlet/trunk/test/src/main/java/org/jboss/portal/portlet/test/tck/TCKServlet.java 2008-02-28 00:05:49 UTC (rev 10145)
+++ modules/portlet/trunk/test/src/main/java/org/jboss/portal/portlet/test/tck/TCKServlet.java 2008-02-28 00:17:07 UTC (rev 10146)
@@ -95,7 +95,7 @@
ControllerRequest request = factory.createRequest(wr);
// We must have one!!!
- TCKPageNavigationalState tckPageState = (TCKPageNavigationalState)request.getPageState();
+ TCKPageNavigationalState tckPageNavigationalState = (TCKPageNavigationalState)request.getPageNavigationalState();
//
ControllerResponse response = controller.process(context, request);
@@ -105,13 +105,13 @@
false,
false,
context.getStateControllerContext(),
- request.getPageState());
+ request.getPageNavigationalState());
//
Renderer renderer = rendererFactory.getRenderer(response);
//
- renderer.render(new TCKRendererContext(context, tckPageState));
+ renderer.render(new TCKRendererContext(context, tckPageNavigationalState));
}
else
{
@@ -140,13 +140,13 @@
throw new IllegalStateException("Portlets requested by TCK were not found");
}
- TCKPageNavigationalState tckPageState = new TCKPageNavigationalState(context.getStateControllerContext().createPageState(false), involvedPortlets);
+ TCKPageNavigationalState tckPageNavigationalState = new TCKPageNavigationalState(context.getStateControllerContext().createPageNavigationalState(false), involvedPortlets);
//
- PageRenderer renderer = new PageRenderer(new ResponseProperties(), tckPageState);
+ PageRenderer renderer = new PageRenderer(new ResponseProperties(), tckPageNavigationalState);
//
- renderer.render(new TCKRendererContext(context, tckPageState));
+ renderer.render(new TCKRendererContext(context, tckPageNavigationalState));
}
}
}
Modified: modules/portlet/trunk/test/src/main/java/org/jboss/portal/portlet/test/tck/TCKStateControllerContext.java
===================================================================
--- modules/portlet/trunk/test/src/main/java/org/jboss/portal/portlet/test/tck/TCKStateControllerContext.java 2008-02-28 00:05:49 UTC (rev 10145)
+++ modules/portlet/trunk/test/src/main/java/org/jboss/portal/portlet/test/tck/TCKStateControllerContext.java 2008-02-28 00:17:07 UTC (rev 10146)
@@ -41,18 +41,18 @@
this.defaultStateControllerContext = defaultStateControllerContext;
}
- public PageNavigationalState clonePageState(PageNavigationalState pageState, boolean modifiable)
+ public PageNavigationalState clonePageNavigationalState(PageNavigationalState pageNavigationalState, boolean modifiable)
{
- TCKPageNavigationalState tckPageState = (TCKPageNavigationalState)pageState;
+ TCKPageNavigationalState tckPageNavigationalState = (TCKPageNavigationalState)pageNavigationalState;
//
return new TCKPageNavigationalState(
- defaultStateControllerContext.clonePageState(tckPageState.defaultState, modifiable),
- new HashSet<String>(tckPageState.involvedPortlets));
+ defaultStateControllerContext.clonePageNavigationalState(tckPageNavigationalState.defaultState, modifiable),
+ new HashSet<String>(tckPageNavigationalState.involvedPortlets));
}
- public PageNavigationalState createPageState(boolean modifiable)
+ public PageNavigationalState createPageNavigationalState(boolean modifiable)
{
- return new TCKPageNavigationalState(defaultStateControllerContext.createPageState(modifiable), new HashSet<String>());
+ return new TCKPageNavigationalState(defaultStateControllerContext.createPageNavigationalState(modifiable), new HashSet<String>());
}
}
Modified: modules/portlet/trunk/test/src/test/java/org/jboss/portal/portlet/controller/StateControllerContextTestCase.java
===================================================================
--- modules/portlet/trunk/test/src/test/java/org/jboss/portal/portlet/controller/StateControllerContextTestCase.java 2008-02-28 00:05:49 UTC (rev 10145)
+++ modules/portlet/trunk/test/src/test/java/org/jboss/portal/portlet/controller/StateControllerContextTestCase.java 2008-02-28 00:17:07 UTC (rev 10146)
@@ -63,7 +63,7 @@
@Test
public void testMarshalling1()
{
- PageNavigationalState pageNS = cc.createPageState(true);
+ PageNavigationalState pageNS = cc.createPageNavigationalState(true);
assertMarshallable(pageNS);
}
@@ -90,7 +90,7 @@
private void test(StateString portletNavigationalState, Mode mode, WindowState windowState)
{
- PageNavigationalState pageNS = cc.createPageState(true);
+ PageNavigationalState pageNS = cc.createPageNavigationalState(true);
pageNS.setWindowNavigationalState("foo", new WindowNavigationalState(portletNavigationalState, mode, windowState));
assertMarshallable(pageNS);
}
@@ -127,7 +127,7 @@
throw new NotYetImplemented();
}
- public PortletInvocationContext createPortletInvocationContext(String windowId, PageNavigationalState pageState)
+ public PortletInvocationContext createPortletInvocationContext(String windowId, PageNavigationalState pageNavigationalState)
{
throw new NotYetImplemented();
}
16 years, 8 months
JBoss Portal SVN: r10145 - in modules/portlet/trunk/controller/src/main/java/org/jboss/portal/portlet/controller: impl/request and 1 other directories.
by portal-commits@lists.jboss.org
Author: julien(a)jboss.com
Date: 2008-02-27 19:05:49 -0500 (Wed, 27 Feb 2008)
New Revision: 10145
Removed:
modules/portlet/trunk/controller/src/main/java/org/jboss/portal/portlet/controller/request/FullScopedCacheablePortletResourceRequest.java
modules/portlet/trunk/controller/src/main/java/org/jboss/portal/portlet/controller/request/PageScopedFullPortletResourceRequest.java
modules/portlet/trunk/controller/src/main/java/org/jboss/portal/portlet/controller/request/PortletScopedPortletResourceRequest.java
Modified:
modules/portlet/trunk/controller/src/main/java/org/jboss/portal/portlet/controller/PortletResourceRequestHandler.java
modules/portlet/trunk/controller/src/main/java/org/jboss/portal/portlet/controller/impl/request/ControllerRequestFactory.java
modules/portlet/trunk/controller/src/main/java/org/jboss/portal/portlet/controller/request/PortletResourceRequest.java
Log:
refactor the inheritence logic of the PortletResourceRequest : use a Scope delegate object instead of having the scope behavior in PortletResourceRequest subclasses
Modified: modules/portlet/trunk/controller/src/main/java/org/jboss/portal/portlet/controller/PortletResourceRequestHandler.java
===================================================================
--- modules/portlet/trunk/controller/src/main/java/org/jboss/portal/portlet/controller/PortletResourceRequestHandler.java 2008-02-27 23:49:05 UTC (rev 10144)
+++ modules/portlet/trunk/controller/src/main/java/org/jboss/portal/portlet/controller/PortletResourceRequestHandler.java 2008-02-28 00:05:49 UTC (rev 10145)
@@ -32,9 +32,7 @@
import org.jboss.portal.portlet.cache.CacheLevel;
import org.jboss.portal.portlet.invocation.ResourceInvocation;
import org.jboss.portal.portlet.invocation.response.PortletInvocationResponse;
-import org.jboss.portal.portlet.controller.request.PageScopedFullPortletResourceRequest;
import org.jboss.portal.portlet.controller.request.PortletResourceRequest;
-import org.jboss.portal.portlet.controller.request.PortletScopedPortletResourceRequest;
import org.jboss.portal.portlet.controller.response.ControllerResponse;
import org.jboss.portal.portlet.controller.response.ResourceResponse;
import org.jboss.portal.portlet.controller.state.PageNavigationalState;
@@ -67,19 +65,21 @@
StateString portletNS = null;
CacheLevel cacheability;
+ PortletResourceRequest.Scope scope = portletResourceRequest.getScope();
+
//
- if (portletResourceRequest instanceof PortletScopedPortletResourceRequest)
+ if (scope instanceof PortletResourceRequest.PortletScope)
{
- PortletScopedPortletResourceRequest portletScopedRequest = (PortletScopedPortletResourceRequest)portletResourceRequest;
- mode = portletScopedRequest.getWindowNavigationalState().getMode();
- windowState = portletScopedRequest.getWindowNavigationalState().getWindowState();
- portletNS = portletScopedRequest.getWindowNavigationalState().getPortletNavigationalState();
+ PortletResourceRequest.PortletScope portletScope = (PortletResourceRequest.PortletScope)scope;
+ mode = portletScope.getWindowNavigationalState().getMode();
+ windowState = portletScope.getWindowNavigationalState().getWindowState();
+ portletNS = portletScope.getWindowNavigationalState().getPortletNavigationalState();
//
- if (portletResourceRequest instanceof PageScopedFullPortletResourceRequest)
+ if (scope instanceof PortletResourceRequest.PageScope)
{
- PageScopedFullPortletResourceRequest pageScopedRequest = (PageScopedFullPortletResourceRequest)portletResourceRequest;
- pageState = pageScopedRequest.getPageState();
+ PortletResourceRequest.PageScope pageScope = (PortletResourceRequest.PageScope)scope;
+ pageState = pageScope.getPageState();
cacheability = CacheLevel.PAGE;
//
Modified: modules/portlet/trunk/controller/src/main/java/org/jboss/portal/portlet/controller/impl/request/ControllerRequestFactory.java
===================================================================
--- modules/portlet/trunk/controller/src/main/java/org/jboss/portal/portlet/controller/impl/request/ControllerRequestFactory.java 2008-02-27 23:49:05 UTC (rev 10144)
+++ modules/portlet/trunk/controller/src/main/java/org/jboss/portal/portlet/controller/impl/request/ControllerRequestFactory.java 2008-02-28 00:05:49 UTC (rev 10145)
@@ -25,11 +25,9 @@
import org.jboss.portal.portlet.controller.state.PageNavigationalState;
import org.jboss.portal.portlet.controller.state.WindowNavigationalState;
import org.jboss.portal.portlet.controller.request.ControllerRequest;
-import org.jboss.portal.portlet.controller.request.FullScopedCacheablePortletResourceRequest;
-import org.jboss.portal.portlet.controller.request.PortletScopedPortletResourceRequest;
-import org.jboss.portal.portlet.controller.request.PageScopedFullPortletResourceRequest;
import org.jboss.portal.portlet.controller.request.PortletActionRequest;
import org.jboss.portal.portlet.controller.request.PortletRenderRequest;
+import org.jboss.portal.portlet.controller.request.PortletResourceRequest;
import org.jboss.portal.portlet.StateString;
import org.jboss.portal.portlet.ParametersStateString;
import org.jboss.portal.portlet.cache.CacheLevel;
@@ -119,32 +117,29 @@
CacheLevel resourceCacheLevel = CacheLevel.valueOf(req.getParameter(ControllerRequestParameterNames.RESOURCE_CACHEABILITY));
//
+ PortletResourceRequest.Scope scope;
switch (resourceCacheLevel)
{
case FULL:
- return new FullScopedCacheablePortletResourceRequest(
- windowId,
- resourceId,
- resourceState,
- formParameters);
+ scope = new PortletResourceRequest.FullScope();
+ break;
case PORTLET:
- return new PortletScopedPortletResourceRequest(
- windowId,
- resourceId,
- resourceState,
- formParameters,
- windowNavigationalState);
+ scope = new PortletResourceRequest.PortletScope(windowNavigationalState);
+ break;
case PAGE:
- return new PageScopedFullPortletResourceRequest(
- windowId,
- resourceId,
- resourceState,
- formParameters,
- pageState,
- windowNavigationalState);
+ scope = new PortletResourceRequest.PageScope(windowNavigationalState, pageState);
+ break;
default:
throw new AssertionError();
}
+
+ //
+ return new PortletResourceRequest(
+ windowId,
+ resourceId,
+ resourceState,
+ formParameters,
+ scope);
}
else
{
Deleted: modules/portlet/trunk/controller/src/main/java/org/jboss/portal/portlet/controller/request/FullScopedCacheablePortletResourceRequest.java
===================================================================
--- modules/portlet/trunk/controller/src/main/java/org/jboss/portal/portlet/controller/request/FullScopedCacheablePortletResourceRequest.java 2008-02-27 23:49:05 UTC (rev 10144)
+++ modules/portlet/trunk/controller/src/main/java/org/jboss/portal/portlet/controller/request/FullScopedCacheablePortletResourceRequest.java 2008-02-28 00:05:49 UTC (rev 10145)
@@ -1,43 +0,0 @@
-/******************************************************************************
- * JBoss, a division of Red Hat *
- * Copyright 2008, Red Hat Middleware, LLC, and individual *
- * contributors as indicated by the @authors tag. See the *
- * copyright.txt in the distribution for a full listing of *
- * individual contributors. *
- * *
- * This is free software; you can redistribute it and/or modify it *
- * under the terms of the GNU Lesser General Public License as *
- * published by the Free Software Foundation; either version 2.1 of *
- * the License, or (at your option) any later version. *
- * *
- * This software is distributed in the hope that it will be useful, *
- * but WITHOUT ANY WARRANTY; without even the implied warranty of *
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU *
- * Lesser General Public License for more details. *
- * *
- * You should have received a copy of the GNU Lesser General Public *
- * License along with this software; if not, write to the Free *
- * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA *
- * 02110-1301 USA, or see the FSF site: http://www.fsf.org. *
- ******************************************************************************/
-package org.jboss.portal.portlet.controller.request;
-
-import org.jboss.portal.common.util.ParameterMap;
-import org.jboss.portal.portlet.StateString;
-
-/**
- * @author <a href="mailto:julien@jboss.org">Julien Viet</a>
- * @version $Revision: 630 $
- */
-public class FullScopedCacheablePortletResourceRequest extends PortletResourceRequest
-{
-
- public FullScopedCacheablePortletResourceRequest(
- String windowId,
- String resourceId,
- StateString resourceState,
- ParameterMap bodyParameters)
- {
- super(windowId, resourceId, resourceState, bodyParameters);
- }
-}
Deleted: modules/portlet/trunk/controller/src/main/java/org/jboss/portal/portlet/controller/request/PageScopedFullPortletResourceRequest.java
===================================================================
--- modules/portlet/trunk/controller/src/main/java/org/jboss/portal/portlet/controller/request/PageScopedFullPortletResourceRequest.java 2008-02-27 23:49:05 UTC (rev 10144)
+++ modules/portlet/trunk/controller/src/main/java/org/jboss/portal/portlet/controller/request/PageScopedFullPortletResourceRequest.java 2008-02-28 00:05:49 UTC (rev 10145)
@@ -1,59 +0,0 @@
-/******************************************************************************
- * JBoss, a division of Red Hat *
- * Copyright 2008, Red Hat Middleware, LLC, and individual *
- * contributors as indicated by the @authors tag. See the *
- * copyright.txt in the distribution for a full listing of *
- * individual contributors. *
- * *
- * This is free software; you can redistribute it and/or modify it *
- * under the terms of the GNU Lesser General Public License as *
- * published by the Free Software Foundation; either version 2.1 of *
- * the License, or (at your option) any later version. *
- * *
- * This software is distributed in the hope that it will be useful, *
- * but WITHOUT ANY WARRANTY; without even the implied warranty of *
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU *
- * Lesser General Public License for more details. *
- * *
- * You should have received a copy of the GNU Lesser General Public *
- * License along with this software; if not, write to the Free *
- * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA *
- * 02110-1301 USA, or see the FSF site: http://www.fsf.org. *
- ******************************************************************************/
-package org.jboss.portal.portlet.controller.request;
-
-import org.jboss.portal.common.util.ParameterMap;
-import org.jboss.portal.portlet.StateString;
-import org.jboss.portal.portlet.controller.PortletControllerContext;
-import org.jboss.portal.portlet.controller.state.PageNavigationalState;
-import org.jboss.portal.portlet.controller.state.WindowNavigationalState;
-
-/**
- * @author <a href="mailto:julien@jboss.org">Julien Viet</a>
- * @version $Revision: 630 $
- */
-public class PageScopedFullPortletResourceRequest extends PortletScopedPortletResourceRequest
-{
-
- /** . */
- private final PageNavigationalState pageState;
-
- public PageScopedFullPortletResourceRequest(
- String windowId,
- String resourceId,
- StateString resourceState,
- ParameterMap bodyParameters,
- PageNavigationalState pageState,
- WindowNavigationalState windowNavigationalState)
- {
- super(windowId, resourceId, resourceState, bodyParameters, windowNavigationalState);
-
- //
- this.pageState = pageState;
- }
-
- public PageNavigationalState getPageState()
- {
- return pageState;
- }
-}
Modified: modules/portlet/trunk/controller/src/main/java/org/jboss/portal/portlet/controller/request/PortletResourceRequest.java
===================================================================
--- modules/portlet/trunk/controller/src/main/java/org/jboss/portal/portlet/controller/request/PortletResourceRequest.java 2008-02-27 23:49:05 UTC (rev 10144)
+++ modules/portlet/trunk/controller/src/main/java/org/jboss/portal/portlet/controller/request/PortletResourceRequest.java 2008-02-28 00:05:49 UTC (rev 10145)
@@ -24,6 +24,8 @@
import org.jboss.portal.common.util.ParameterMap;
import org.jboss.portal.portlet.StateString;
+import org.jboss.portal.portlet.controller.state.WindowNavigationalState;
+import org.jboss.portal.portlet.controller.state.PageNavigationalState;
import org.jboss.portal.portlet.cache.CacheLevel;
import java.util.HashMap;
@@ -37,16 +39,6 @@
{
/** . */
- private static final Map<Class, CacheLevel> cacheability = new HashMap<Class, CacheLevel>();
-
- static
- {
- cacheability.put(FullScopedCacheablePortletResourceRequest.class, CacheLevel.FULL);
- cacheability.put(PortletScopedPortletResourceRequest.class, CacheLevel.PORTLET);
- cacheability.put(PageScopedFullPortletResourceRequest.class, CacheLevel.PAGE);
- }
-
- /** . */
private final String resourceId;
/** . */
@@ -55,12 +47,15 @@
/** . */
private final ParameterMap bodyParameters;
- PortletResourceRequest(
+ /** . */
+ private final Scope scope;
+
+ public PortletResourceRequest(
String windowId,
String resourceId,
StateString resourceState,
- ParameterMap bodyParameters
- )
+ ParameterMap bodyParameters,
+ Scope scope)
{
super(windowId);
@@ -68,13 +63,19 @@
this.resourceId = resourceId;
this.resourceState = resourceState;
this.bodyParameters = bodyParameters;
+ this.scope = scope;
}
- public CacheLevel getCacheabilityType()
+ public Scope getScope()
{
- return cacheability.get(getClass());
+ return scope;
}
+ public CacheLevel getCacheability()
+ {
+ return scope.getCacheability();
+ }
+
public String getResourceId()
{
return resourceId;
@@ -89,4 +90,66 @@
{
return bodyParameters;
}
+
+ public abstract static class Scope
+ {
+
+ public abstract CacheLevel getCacheability();
+
+ }
+
+ public static class FullScope extends Scope
+ {
+ public CacheLevel getCacheability()
+ {
+ return CacheLevel.FULL;
+ }
+ }
+
+ public static class PortletScope extends FullScope
+ {
+
+ /** . */
+ private final WindowNavigationalState windowNavigationalState;
+
+ public PortletScope(WindowNavigationalState windowNavigationalState)
+ {
+ this.windowNavigationalState = windowNavigationalState;
+ }
+
+ public WindowNavigationalState getWindowNavigationalState()
+ {
+ return windowNavigationalState;
+ }
+
+ public CacheLevel getCacheability()
+ {
+ return CacheLevel.PORTLET;
+ }
+ }
+
+ public static class PageScope extends PortletScope
+ {
+
+ /** . */
+ private final PageNavigationalState pageState;
+
+ public PageScope(WindowNavigationalState windowNavigationalState, PageNavigationalState pageState)
+ {
+ super(windowNavigationalState);
+
+ //
+ this.pageState = pageState;
+ }
+
+ public PageNavigationalState getPageState()
+ {
+ return pageState;
+ }
+
+ public CacheLevel getCacheability()
+ {
+ return CacheLevel.PAGE;
+ }
+ }
}
Deleted: modules/portlet/trunk/controller/src/main/java/org/jboss/portal/portlet/controller/request/PortletScopedPortletResourceRequest.java
===================================================================
--- modules/portlet/trunk/controller/src/main/java/org/jboss/portal/portlet/controller/request/PortletScopedPortletResourceRequest.java 2008-02-27 23:49:05 UTC (rev 10144)
+++ modules/portlet/trunk/controller/src/main/java/org/jboss/portal/portlet/controller/request/PortletScopedPortletResourceRequest.java 2008-02-28 00:05:49 UTC (rev 10145)
@@ -1,57 +0,0 @@
-/******************************************************************************
- * JBoss, a division of Red Hat *
- * Copyright 2008, Red Hat Middleware, LLC, and individual *
- * contributors as indicated by the @authors tag. See the *
- * copyright.txt in the distribution for a full listing of *
- * individual contributors. *
- * *
- * This is free software; you can redistribute it and/or modify it *
- * under the terms of the GNU Lesser General Public License as *
- * published by the Free Software Foundation; either version 2.1 of *
- * the License, or (at your option) any later version. *
- * *
- * This software is distributed in the hope that it will be useful, *
- * but WITHOUT ANY WARRANTY; without even the implied warranty of *
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU *
- * Lesser General Public License for more details. *
- * *
- * You should have received a copy of the GNU Lesser General Public *
- * License along with this software; if not, write to the Free *
- * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA *
- * 02110-1301 USA, or see the FSF site: http://www.fsf.org. *
- ******************************************************************************/
-package org.jboss.portal.portlet.controller.request;
-
-import org.jboss.portal.common.util.ParameterMap;
-import org.jboss.portal.portlet.StateString;
-import org.jboss.portal.portlet.controller.PortletControllerContext;
-import org.jboss.portal.portlet.controller.state.WindowNavigationalState;
-
-/**
- * @author <a href="mailto:julien@jboss.org">Julien Viet</a>
- * @version $Revision: 630 $
- */
-public class PortletScopedPortletResourceRequest extends FullScopedCacheablePortletResourceRequest
-{
-
- /** . */
- private final WindowNavigationalState windowNavigationalState;
-
- public PortletScopedPortletResourceRequest(
- String windowId,
- String resourceId,
- StateString resourceState,
- ParameterMap bodyParameters,
- WindowNavigationalState windowNavigationalState)
- {
- super(windowId, resourceId, resourceState, bodyParameters);
-
- //
- this.windowNavigationalState = windowNavigationalState;
- }
-
- public WindowNavigationalState getWindowNavigationalState()
- {
- return windowNavigationalState;
- }
-}
16 years, 8 months
JBoss Portal SVN: r10144 - in modules/portlet/trunk: test/src/main/java/org/jboss/portal/portlet/test/controller and 1 other directories.
by portal-commits@lists.jboss.org
Author: julien(a)jboss.com
Date: 2008-02-27 18:49:05 -0500 (Wed, 27 Feb 2008)
New Revision: 10144
Modified:
modules/portlet/trunk/controller/src/main/java/org/jboss/portal/portlet/controller/response/PortletResponse.java
modules/portlet/trunk/controller/src/main/java/org/jboss/portal/portlet/controller/response/ResourceResponse.java
modules/portlet/trunk/test/src/main/java/org/jboss/portal/portlet/test/controller/ControllerResponseRendererFactory.java
modules/portlet/trunk/test/src/main/java/org/jboss/portal/portlet/test/jsp/ControllerFilter.java
Log:
encapsulate public fields
Modified: modules/portlet/trunk/controller/src/main/java/org/jboss/portal/portlet/controller/response/PortletResponse.java
===================================================================
--- modules/portlet/trunk/controller/src/main/java/org/jboss/portal/portlet/controller/response/PortletResponse.java 2008-02-27 23:33:14 UTC (rev 10143)
+++ modules/portlet/trunk/controller/src/main/java/org/jboss/portal/portlet/controller/response/PortletResponse.java 2008-02-27 23:49:05 UTC (rev 10144)
@@ -44,7 +44,7 @@
public static final int CONSUMED_EVENT_FLOODED = 3;
/** . */
- public final PortletInvocationResponse response;
+ private final PortletInvocationResponse response;
/** . */
private final int eventDistributionStatus;
@@ -59,4 +59,9 @@
{
return eventDistributionStatus;
}
+
+ public PortletInvocationResponse getResponse()
+ {
+ return response;
+ }
}
Modified: modules/portlet/trunk/controller/src/main/java/org/jboss/portal/portlet/controller/response/ResourceResponse.java
===================================================================
--- modules/portlet/trunk/controller/src/main/java/org/jboss/portal/portlet/controller/response/ResourceResponse.java 2008-02-27 23:33:14 UTC (rev 10143)
+++ modules/portlet/trunk/controller/src/main/java/org/jboss/portal/portlet/controller/response/ResourceResponse.java 2008-02-27 23:49:05 UTC (rev 10144)
@@ -33,10 +33,15 @@
{
/** . */
- public PortletInvocationResponse response;
+ private final PortletInvocationResponse response;
public ResourceResponse(PortletInvocationResponse response)
{
this.response = response;
}
+
+ public PortletInvocationResponse getResponse()
+ {
+ return response;
+ }
}
\ No newline at end of file
Modified: modules/portlet/trunk/test/src/main/java/org/jboss/portal/portlet/test/controller/ControllerResponseRendererFactory.java
===================================================================
--- modules/portlet/trunk/test/src/main/java/org/jboss/portal/portlet/test/controller/ControllerResponseRendererFactory.java 2008-02-27 23:33:14 UTC (rev 10143)
+++ modules/portlet/trunk/test/src/main/java/org/jboss/portal/portlet/test/controller/ControllerResponseRendererFactory.java 2008-02-27 23:49:05 UTC (rev 10144)
@@ -77,20 +77,20 @@
}
else if (response instanceof PortletResponse)
{
- return getRenderer(((PortletResponse)response).response);
+ return getRenderer(((PortletResponse)response).getResponse());
}
else if (response instanceof ResourceResponse)
{
ResourceResponse resourceResponse = (ResourceResponse)response;
//
- if (resourceResponse.response instanceof FragmentResponse)
+ if (resourceResponse.getResponse() instanceof FragmentResponse)
{
- return new ResourceRenderer((FragmentResponse)resourceResponse.response, sendNoContentResponseOnEmptyResource);
+ return new ResourceRenderer((FragmentResponse)resourceResponse.getResponse(), sendNoContentResponseOnEmptyResource);
}
else
{
- return getRenderer(((PortletResponse)response).response);
+ return getRenderer(((PortletResponse)response).getResponse());
}
}
Modified: modules/portlet/trunk/test/src/main/java/org/jboss/portal/portlet/test/jsp/ControllerFilter.java
===================================================================
--- modules/portlet/trunk/test/src/main/java/org/jboss/portal/portlet/test/jsp/ControllerFilter.java 2008-02-27 23:33:14 UTC (rev 10143)
+++ modules/portlet/trunk/test/src/main/java/org/jboss/portal/portlet/test/jsp/ControllerFilter.java 2008-02-27 23:49:05 UTC (rev 10144)
@@ -158,7 +158,7 @@
else if (controllerResponse instanceof ResourceResponse)
{
ResourceResponse resourceResponse = (ResourceResponse)controllerResponse;
- PortletInvocationResponse pir = resourceResponse.response;
+ PortletInvocationResponse pir = resourceResponse.getResponse();
//
if (pir instanceof FragmentResponse)
@@ -218,7 +218,7 @@
else if (controllerResponse instanceof PortletResponse)
{
PortletResponse portletResponse = (PortletResponse)controllerResponse;
- PortletInvocationResponse pir = portletResponse.response;
+ PortletInvocationResponse pir = portletResponse.getResponse();
//
if (pir instanceof ErrorResponse)
16 years, 8 months