JBoss Portal SVN: r9600 - in modules/portlet/trunk: portlet/src/main/java/org/jboss/portal/portlet/impl/spi and 9 other directories.
by portal-commits@lists.jboss.org
Author: julien(a)jboss.com
Date: 2008-01-24 16:33:17 -0500 (Thu, 24 Jan 2008)
New Revision: 9600
Added:
modules/portlet/trunk/portlet/src/main/java/org/jboss/portal/portlet/invocation/response/ResponseProperties.java
modules/portlet/trunk/portlet/src/test/java/org/jboss/portal/test/portlet/jsr286/ext/portletresponses/
modules/portlet/trunk/portlet/src/test/java/org/jboss/portal/test/portlet/jsr286/ext/portletresponses/WriteCookiesTestCase.java
modules/portlet/trunk/test/src/test/resources/jsr286/ext/portletresponses-war/
modules/portlet/trunk/test/src/test/resources/jsr286/ext/portletresponses-war/WEB-INF/
modules/portlet/trunk/test/src/test/resources/jsr286/ext/portletresponses-war/WEB-INF/portlet.xml
modules/portlet/trunk/test/src/test/resources/jsr286/ext/portletresponses-war/WEB-INF/web.xml
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/PortletResponseImpl.java
modules/portlet/trunk/portlet/src/main/java/org/jboss/portal/portlet/impl/jsr168/api/StateAwareResponseImpl.java
modules/portlet/trunk/portlet/src/main/java/org/jboss/portal/portlet/impl/spi/AbstractClientContext.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/UpdateNavigationalStateResponse.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/PortletController.java
modules/portlet/trunk/test/src/main/java/org/jboss/portal/portlet/test/PortletControllerContextImpl.java
modules/portlet/trunk/test/src/test/build.xml
modules/portlet/trunk/test/src/test/resources/test/remote-jboss-unit.xml
Log:
- implemented response cookies handling
- added test cases for response cookies
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-01-24 21:27:57 UTC (rev 9599)
+++ modules/portlet/trunk/portlet/src/main/java/org/jboss/portal/portlet/impl/jsr168/api/MimeResponseImpl.java 2008-01-24 21:33:17 UTC (rev 9600)
@@ -63,6 +63,9 @@
public PortletInvocationResponse getResponse()
{
+ result.setProperties(getProperties(false));
+
+ //
return result;
}
Modified: modules/portlet/trunk/portlet/src/main/java/org/jboss/portal/portlet/impl/jsr168/api/PortletResponseImpl.java
===================================================================
--- modules/portlet/trunk/portlet/src/main/java/org/jboss/portal/portlet/impl/jsr168/api/PortletResponseImpl.java 2008-01-24 21:27:57 UTC (rev 9599)
+++ modules/portlet/trunk/portlet/src/main/java/org/jboss/portal/portlet/impl/jsr168/api/PortletResponseImpl.java 2008-01-24 21:33:17 UTC (rev 9600)
@@ -24,16 +24,16 @@
import org.jboss.portal.portlet.invocation.PortletInvocation;
import org.jboss.portal.portlet.invocation.response.PortletInvocationResponse;
+import org.jboss.portal.portlet.invocation.response.ResponseProperties;
import org.jboss.portal.portlet.impl.jsr168.PortletUtils;
-import org.jboss.portal.common.invocation.AttributeResolver;
-import org.jboss.portal.common.NotYetImplemented;
import org.w3c.dom.Element;
import org.w3c.dom.DOMException;
+import org.w3c.dom.Document;
import javax.portlet.PortletResponse;
import javax.servlet.http.Cookie;
-import java.util.Collection;
-import java.util.ArrayList;
+import javax.xml.parsers.DocumentBuilderFactory;
+import javax.xml.parsers.ParserConfigurationException;
/**
* @author <a href="mailto:julien@jboss.org">Julien Viet</a>
@@ -49,8 +49,14 @@
protected final PortletRequestImpl preq;
/** The namespace. */
- protected String namespace;
+ private String namespace;
+ /** . */
+ private Document doc;
+
+ /** . */
+ private ResponseProperties properties;
+
protected PortletResponseImpl(PortletInvocation invocation, PortletRequestImpl preq)
{
this.invocation = invocation;
@@ -80,23 +86,7 @@
}
//
- AttributeResolver resolver = invocation.getContext().getAttributeResolver(PortletInvocation.RESPONSE_PROPERTIES_SCOPE);
- Object prop = resolver.getAttribute(key);
- if (prop == null)
- {
- resolver.setAttribute(key, prop);
- }
- else if (prop instanceof Collection)
- {
- ((Collection<String>)prop).add(value);
- }
- else
- {
- Collection<String> c = new ArrayList<String>();
- c.add((String)prop);
- c.add(value);
- resolver.setAttribute(key, c);
- }
+ getProperties().getTransportHeaders().addProperty(key, value);
}
public void setProperty(String key, String value) throws IllegalArgumentException
@@ -111,9 +101,38 @@
}
//
- invocation.setAttribute(PortletInvocation.RESPONSE_PROPERTIES_SCOPE, key, value);
+ getProperties().getTransportHeaders().setProperty(key, value);
}
+ public void addProperty(Cookie cookie)
+ {
+ getProperties().getCookies().add(cookie);
+ }
+
+ public void addProperty(String key, Element element)
+ {
+ getProperties().getMarkupHeaders().addProperty(key, element);
+ }
+
+ public Element createElement(String tagName) throws DOMException
+ {
+ if (doc == null)
+ {
+ try
+ {
+ DocumentBuilderFactory factory = DocumentBuilderFactory.newInstance();
+ doc = factory.newDocumentBuilder().newDocument();
+ }
+ catch (ParserConfigurationException e)
+ {
+ throw new IllegalStateException("Could not create a document builder factory", e);
+ }
+ }
+
+ //
+ return doc.createElement(tagName);
+ }
+
public String getNamespace()
{
if (namespace == null)
@@ -124,20 +143,17 @@
return namespace;
}
- public void addProperty(Cookie cookie)
+ protected final ResponseProperties getProperties()
{
- throw new NotYetImplemented();
+ return getProperties(true);
}
- public void addProperty(String s, Element element)
+ protected final ResponseProperties getProperties(boolean create)
{
- throw new NotYetImplemented();
+ if (properties == null && create)
+ {
+ properties = new ResponseProperties();
+ }
+ return properties;
}
-
- public Element createElement(String s) throws DOMException
- {
-
-
- throw new NotYetImplemented();
- }
}
Modified: modules/portlet/trunk/portlet/src/main/java/org/jboss/portal/portlet/impl/jsr168/api/StateAwareResponseImpl.java
===================================================================
--- modules/portlet/trunk/portlet/src/main/java/org/jboss/portal/portlet/impl/jsr168/api/StateAwareResponseImpl.java 2008-01-24 21:27:57 UTC (rev 9599)
+++ modules/portlet/trunk/portlet/src/main/java/org/jboss/portal/portlet/impl/jsr168/api/StateAwareResponseImpl.java 2008-01-24 21:33:17 UTC (rev 9600)
@@ -400,6 +400,9 @@
UpdateNavigationalStateResponse response = new UpdateNavigationalStateResponse();
//
+ response.setProperties(getProperties(false));
+
+ //
response.setMode(mode);
response.setWindowState(windowState);
response.setPublicNavigationalStateUpdates(navigationalState.getPublicMapSnapshot());
Modified: modules/portlet/trunk/portlet/src/main/java/org/jboss/portal/portlet/impl/spi/AbstractClientContext.java
===================================================================
--- modules/portlet/trunk/portlet/src/main/java/org/jboss/portal/portlet/impl/spi/AbstractClientContext.java 2008-01-24 21:27:57 UTC (rev 9599)
+++ modules/portlet/trunk/portlet/src/main/java/org/jboss/portal/portlet/impl/spi/AbstractClientContext.java 2008-01-24 21:33:17 UTC (rev 9600)
@@ -43,6 +43,9 @@
{
/** . */
+ private static final List<Cookie> NO_COOKIES = Collections.emptyList();
+
+ /** . */
private final String method;
/** . */
@@ -53,6 +56,11 @@
public AbstractClientContext(HttpServletRequest request)
{
+ this(request, NO_COOKIES);
+ }
+
+ public AbstractClientContext(HttpServletRequest request, List<Cookie> additionalCookies)
+ {
Map<String, List<String>> headers = new HashMap<String, List<String>>();
for (Enumeration e = request.getHeaderNames();e.hasMoreElements();)
{
@@ -80,7 +88,9 @@
headers.put(headerName, headerValues);
}
}
- List<Cookie> cookies = null;
+
+ //
+ List<Cookie> cookies;
Cookie[] tmp = request.getCookies();
if (tmp == null || tmp.length == 0)
{
@@ -88,9 +98,20 @@
}
else
{
- cookies = Arrays.asList(tmp);
+ cookies = new ArrayList<Cookie>(tmp.length);
+ for (Cookie cookie : tmp)
+ {
+ Cookie copy = (Cookie)cookie.clone();
+ cookies.add(copy);
+ }
}
+ for (Cookie cookie : additionalCookies)
+ {
+ Cookie copy = (Cookie)cookie.clone();
+ cookies.add(copy);
+ }
+
//
this.headers = headers;
this.method = request.getMethod();
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-01-24 21:27:57 UTC (rev 9599)
+++ modules/portlet/trunk/portlet/src/main/java/org/jboss/portal/portlet/invocation/response/FragmentResponse.java 2008-01-24 21:33:17 UTC (rev 9600)
@@ -35,7 +35,7 @@
* @author <a href="mailto:julien@jboss.org">Julien Viet</a>
* @version $Revision: 5602 $
*/
-public class FragmentResponse extends StateResponse
+public class FragmentResponse extends PortletInvocationResponse
{
/** . */
@@ -47,8 +47,8 @@
/** . */
public static final int TYPE_BYTES = 2;
- /** Any content that should appear in the header. */
- private String header;
+ /** . */
+ private ResponseProperties properties;
/** The output as a bytes if any. */
private ClosableOutputStream bytes;
@@ -70,23 +70,23 @@
public FragmentResponse()
{
- this.header = null;
this.bytes = null;
this.chars = null;
this.writer = null;
this.contentType = null;
this.title = null;
this.expirationSecs = 0;
+ this.properties = null;
}
- public String getHeader()
+ public ResponseProperties getProperties()
{
- return header;
+ return properties;
}
- public void setHeader(String header)
+ public void setProperties(ResponseProperties properties)
{
- this.header = header;
+ this.properties = properties;
}
public int getType()
Added: 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 (rev 0)
+++ modules/portlet/trunk/portlet/src/main/java/org/jboss/portal/portlet/invocation/response/ResponseProperties.java 2008-01-24 21:33:17 UTC (rev 9600)
@@ -0,0 +1,117 @@
+/******************************************************************************
+ * 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.common.util.MultiValuedPropertyMap;
+import org.w3c.dom.Element;
+
+import javax.servlet.http.Cookie;
+import java.util.ArrayList;
+import java.util.Collections;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+import java.util.Set;
+
+/**
+ * @author <a href="mailto:julien@jboss.org">Julien Viet</a>
+ * @version $Revision: 5448 $
+ */
+public class ResponseProperties
+{
+
+ /** . */
+ private MultiValuedPropertyMap<String> transportHeaders;
+
+ /** . */
+ private MultiValuedPropertyMap<Element> markupHeaders;
+
+ /** . */
+ private List<Cookie> cookies;
+
+ public ResponseProperties()
+ {
+ }
+
+ public MultiValuedPropertyMap<String> getTransportHeaders()
+ {
+ return getTransportHeaders(true);
+ }
+
+ public MultiValuedPropertyMap<String> getTransportHeaders(boolean create)
+ {
+ if (transportHeaders == null && create)
+ {
+ transportHeaders = new MultiValuedPropertyMap<String>();
+ }
+ return transportHeaders;
+ }
+
+ public MultiValuedPropertyMap<Element> getMarkupHeaders()
+ {
+ return getMarkupHeaders(true);
+ }
+
+ public MultiValuedPropertyMap<Element> getMarkupHeaders(boolean create)
+ {
+ if (markupHeaders == null && create)
+ {
+ markupHeaders = new MultiValuedPropertyMap<Element>();
+ }
+ return markupHeaders;
+ }
+
+ public List<Cookie> getCookies()
+ {
+ return getCookies(true);
+ }
+
+ public List<Cookie> getCookies(boolean create)
+ {
+ if (cookies == null && create)
+ {
+ cookies = new ArrayList<Cookie>();
+ }
+ return cookies;
+ }
+
+ public void append(ResponseProperties appended)
+ {
+ if (appended == null)
+ {
+ throw new IllegalArgumentException();
+ }
+ if (appended.transportHeaders != null)
+ {
+ getTransportHeaders().append(appended.transportHeaders);
+ }
+ if (appended.markupHeaders != null)
+ {
+ getMarkupHeaders().append(appended.markupHeaders);
+ }
+ if (appended.cookies != null)
+ {
+ getCookies().addAll(appended.cookies);
+ }
+ }
+}
\ No newline at end of file
Modified: modules/portlet/trunk/portlet/src/main/java/org/jboss/portal/portlet/invocation/response/UpdateNavigationalStateResponse.java
===================================================================
--- modules/portlet/trunk/portlet/src/main/java/org/jboss/portal/portlet/invocation/response/UpdateNavigationalStateResponse.java 2008-01-24 21:27:57 UTC (rev 9599)
+++ modules/portlet/trunk/portlet/src/main/java/org/jboss/portal/portlet/invocation/response/UpdateNavigationalStateResponse.java 2008-01-24 21:33:17 UTC (rev 9600)
@@ -38,6 +38,9 @@
public class UpdateNavigationalStateResponse extends StateResponse
{
+ /** . */
+ private ResponseProperties properties;
+
/** The navigational state returned. */
protected StateString navigationalState;
@@ -61,6 +64,16 @@
publicNavigationalStateUpdates = null;
}
+ public ResponseProperties getProperties()
+ {
+ return properties;
+ }
+
+ public void setProperties(ResponseProperties properties)
+ {
+ this.properties = properties;
+ }
+
public Mode getMode()
{
return mode;
Added: modules/portlet/trunk/portlet/src/test/java/org/jboss/portal/test/portlet/jsr286/ext/portletresponses/WriteCookiesTestCase.java
===================================================================
--- modules/portlet/trunk/portlet/src/test/java/org/jboss/portal/test/portlet/jsr286/ext/portletresponses/WriteCookiesTestCase.java (rev 0)
+++ modules/portlet/trunk/portlet/src/test/java/org/jboss/portal/test/portlet/jsr286/ext/portletresponses/WriteCookiesTestCase.java 2008-01-24 21:33:17 UTC (rev 9600)
@@ -0,0 +1,187 @@
+/******************************************************************************
+ * 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.jsr286.ext.portletresponses;
+
+import org.jboss.portal.unit.PortletTestCase;
+import org.jboss.portal.unit.PortletTestContext;
+import org.jboss.portal.unit.annotations.TestCase;
+import org.jboss.portal.unit.actions.PortletRenderTestAction;
+import org.jboss.portal.unit.actions.PortletActionTestAction;
+import org.jboss.portal.unit.actions.PortletEventTestAction;
+import org.jboss.portal.test.portlet.framework.UTP1;
+import org.jboss.unit.driver.DriverResponse;
+import org.jboss.unit.driver.response.EndTestResponse;
+import org.jboss.unit.remote.driver.handler.http.response.InvokeGetResponse;
+import static org.jboss.unit.api.Assert.*;
+
+import javax.portlet.Portlet;
+import javax.portlet.RenderRequest;
+import javax.portlet.RenderResponse;
+import javax.portlet.PortletException;
+import javax.portlet.ActionRequest;
+import javax.portlet.ActionResponse;
+import javax.portlet.EventRequest;
+import javax.portlet.EventResponse;
+import javax.servlet.http.Cookie;
+import java.io.IOException;
+import java.util.Map;
+
+/**
+ * @author <a href="mailto:julien@jboss.org">Julien Viet</a>
+ * @version $Revision: 630 $
+ */
+@TestCase
+public class WriteCookiesTestCase
+{
+ public WriteCookiesTestCase(PortletTestCase seq)
+ {
+ seq.bindAction(0, UTP1.RENDER_JOIN_POINT, new PortletRenderTestAction()
+ {
+ protected DriverResponse run(Portlet portlet, RenderRequest request, RenderResponse response, PortletTestContext context) throws PortletException, IOException
+ {
+ Map<String, String> cookieMap = createCookieMap(request);
+ assertNull(cookieMap.get("render_cookie"));
+
+ //
+ Cookie cookie = new Cookie("render_cookie", "render_cookie_value");
+ response.addProperty(cookie);
+
+ //
+ return new InvokeGetResponse(response.createActionURL().toString());
+ }
+ });
+ seq.bindAction(1, UTP1.ACTION_JOIN_POINT, new PortletActionTestAction()
+ {
+ protected void run(Portlet portlet, ActionRequest request, ActionResponse response, PortletTestContext context) throws PortletException, IOException
+ {
+ Map<String, String> cookieMap = createCookieMap(request);
+ assertEquals("render_cookie_value", cookieMap.get("render_cookie"));
+ assertNull(cookieMap.get("action_cookie"));
+
+ //
+ Cookie cookie = new Cookie("action_cookie", "action_cookie_value");
+ response.addProperty(cookie);
+
+ //
+ response.setEvent("Event", null);
+ }
+ });
+ seq.bindAction(1, UTP1.EVENT_JOIN_POINT, new PortletEventTestAction()
+ {
+ protected void run(Portlet portlet, EventRequest request, EventResponse response, PortletTestContext context) throws PortletException, IOException
+ {
+ Map<String, String> cookieMap = createCookieMap(request);
+ assertEquals("render_cookie_value", cookieMap.get("render_cookie"));
+ assertEquals("action_cookie_value", cookieMap.get("action_cookie"));
+ }
+ });
+ seq.bindAction(1, UTP1.RENDER_JOIN_POINT, new PortletRenderTestAction()
+ {
+ protected DriverResponse run(Portlet portlet, RenderRequest request, RenderResponse response, PortletTestContext context) throws PortletException, IOException
+ {
+ Map<String, String> cookieMap = createCookieMap(request);
+ assertEquals("render_cookie_value", cookieMap.get("render_cookie"));
+ assertEquals("action_cookie_value", cookieMap.get("action_cookie"));
+
+ //
+ return new InvokeGetResponse(response.createActionURL().toString());
+ }
+ });
+ seq.bindAction(2, UTP1.ACTION_JOIN_POINT, new PortletActionTestAction()
+ {
+ protected void run(Portlet portlet, ActionRequest request, ActionResponse response, PortletTestContext context) throws PortletException, IOException
+ {
+ Map<String, String> cookieMap = createCookieMap(request);
+ assertEquals("render_cookie_value", cookieMap.get("render_cookie"));
+ assertEquals("action_cookie_value", cookieMap.get("action_cookie"));
+
+ //
+ response.setEvent("Event", null);
+ }
+ });
+ seq.bindAction(2, UTP1.EVENT_JOIN_POINT, new PortletEventTestAction()
+ {
+ protected void run(Portlet portlet, EventRequest request, EventResponse response, PortletTestContext context) throws PortletException, IOException
+ {
+ Map<String, String> cookieMap = createCookieMap(request);
+ assertEquals("render_cookie_value", cookieMap.get("render_cookie"));
+ assertEquals("action_cookie_value", cookieMap.get("action_cookie"));
+ assertNull(cookieMap.get("event_cookie"));
+
+ //
+ //
+ Cookie cookie = new Cookie("event_cookie", "event_cookie_value");
+ response.addProperty(cookie);
+ }
+ });
+ seq.bindAction(2, UTP1.RENDER_JOIN_POINT, new PortletRenderTestAction()
+ {
+ protected DriverResponse run(Portlet portlet, RenderRequest request, RenderResponse response, PortletTestContext context) throws PortletException, IOException
+ {
+ Map<String, String> cookieMap = createCookieMap(request);
+ assertEquals("render_cookie_value", cookieMap.get("render_cookie"));
+ assertEquals("action_cookie_value", cookieMap.get("action_cookie"));
+ assertEquals("event_cookie_value", cookieMap.get("event_cookie"));
+
+ //
+ return new InvokeGetResponse(response.createActionURL().toString());
+ }
+ });
+ seq.bindAction(3, UTP1.ACTION_JOIN_POINT, new PortletActionTestAction()
+ {
+ protected void run(Portlet portlet, ActionRequest request, ActionResponse response, PortletTestContext context) throws PortletException, IOException
+ {
+ Map<String, String> cookieMap = createCookieMap(request);
+ assertEquals("render_cookie_value", cookieMap.get("render_cookie"));
+ assertEquals("action_cookie_value", cookieMap.get("action_cookie"));
+ assertEquals("event_cookie_value", cookieMap.get("event_cookie"));
+
+ //
+ response.setEvent("Event", null);
+ }
+ });
+ seq.bindAction(3, UTP1.EVENT_JOIN_POINT, new PortletEventTestAction()
+ {
+ protected void run(Portlet portlet, EventRequest request, EventResponse response, PortletTestContext context) throws PortletException, IOException
+ {
+ Map<String, String> cookieMap = createCookieMap(request);
+ assertEquals("render_cookie_value", cookieMap.get("render_cookie"));
+ assertEquals("action_cookie_value", cookieMap.get("action_cookie"));
+ assertEquals("event_cookie_value", cookieMap.get("event_cookie"));
+ }
+ });
+ seq.bindAction(3, UTP1.RENDER_JOIN_POINT, new PortletRenderTestAction()
+ {
+ protected DriverResponse run(Portlet portlet, RenderRequest request, RenderResponse response, PortletTestContext context) throws PortletException, IOException
+ {
+ Map<String, String> cookieMap = createCookieMap(request);
+ assertEquals("render_cookie_value", cookieMap.get("render_cookie"));
+ assertEquals("action_cookie_value", cookieMap.get("action_cookie"));
+ assertEquals("event_cookie_value", cookieMap.get("event_cookie"));
+
+ //
+ return new EndTestResponse();
+ }
+ });
+ }
+}
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-01-24 21:27:57 UTC (rev 9599)
+++ modules/portlet/trunk/test/src/main/java/org/jboss/portal/portlet/test/PortalServlet.java 2008-01-24 21:33:17 UTC (rev 9600)
@@ -67,6 +67,6 @@
PortletController controller = new PortletController();
//
- controller.process(context, context.getRequest());
+ controller.process(context.getRequest());
}
}
Modified: modules/portlet/trunk/test/src/main/java/org/jboss/portal/portlet/test/PortletController.java
===================================================================
--- modules/portlet/trunk/test/src/main/java/org/jboss/portal/portlet/test/PortletController.java 2008-01-24 21:27:57 UTC (rev 9599)
+++ modules/portlet/trunk/test/src/main/java/org/jboss/portal/portlet/test/PortletController.java 2008-01-24 21:33:17 UTC (rev 9600)
@@ -44,6 +44,7 @@
import org.jboss.portal.portlet.invocation.response.ErrorResponse;
import org.jboss.portal.portlet.invocation.response.StateResponse;
import org.jboss.portal.portlet.invocation.response.FragmentResponse;
+import org.jboss.portal.portlet.invocation.response.ResponseProperties;
import org.jboss.portal.portlet.invocation.ActionInvocation;
import org.jboss.portal.portlet.invocation.RenderInvocation;
import org.jboss.portal.portlet.invocation.EventInvocation;
@@ -52,13 +53,17 @@
import org.jboss.portal.common.util.ParameterMap;
import org.jboss.portal.common.util.MarkupInfo;
import org.jboss.portal.common.util.MediaType;
+import org.jboss.portal.common.util.MultiValuedPropertyMap;
import org.jboss.portal.common.io.IOTools;
+import org.jboss.portal.common.xml.XMLTools;
import org.jboss.portal.Mode;
import org.jboss.portal.WindowState;
import org.apache.log4j.Logger;
+import org.w3c.dom.Element;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
+import javax.servlet.http.Cookie;
import javax.servlet.ServletOutputStream;
import javax.xml.namespace.QName;
import java.io.UnsupportedEncodingException;
@@ -101,8 +106,9 @@
this.portalContext = portalContext;
}
- private PortletInvocationResponse handle(PortletControllerContext context, ContainerRequest containerRequest) throws PortletInvokerException, IOException
+ private PortletInvocationResponse invoke(ContainerRequest containerRequest) throws PortletInvokerException, IOException
{
+ PortletControllerContext context = containerRequest.controllerContext;
Portlet portlet = context.getPortlet(containerRequest.portletId);
HttpServletRequest req = context.getClientRequest();
HttpServletResponse resp = context.getClientResponse();
@@ -287,7 +293,8 @@
PortletControllerContext context,
Portlet portlet,
StateResponse.Event event,
- PageNavigationalState pageNS)
+ PageNavigationalState pageNS,
+ List<Cookie> requestCookies)
{
HttpServletRequest req = context.getClientRequest();
HttpServletResponse resp = context.getClientResponse();
@@ -317,7 +324,7 @@
EventInvocation eventInvocation = new EventInvocation(actionContext);
//
- eventInvocation.setClientContext(new AbstractClientContext(req));
+ eventInvocation.setClientContext(new AbstractClientContext(req, requestCookies));
eventInvocation.setServerContext(new AbstractServerContext(req, resp));
eventInvocation.setInstanceContext(instanceContext);
eventInvocation.setUserContext(new AbstractUserContext(req));
@@ -340,21 +347,21 @@
}
}
- public void process(PortletControllerContext context, ControllerRequest controllerRequest) throws PortletInvokerException, IOException
+ public void process(ControllerRequest controllerRequest) throws PortletInvokerException, IOException
{
- if (controllerRequest == null)
+ if (controllerRequest instanceof ViewRequest)
{
- render(context, new PageNavigationalState());
+ render(controllerRequest.controllerContext, new ResponseProperties(), new PageNavigationalState());
}
else if (controllerRequest instanceof ContainerRequest)
{
- process(context, (ContainerRequest)controllerRequest);
+ process((ContainerRequest)controllerRequest);
}
}
- public void process(PortletControllerContext context, ContainerRequest containerRequest) throws PortletInvokerException, IOException
+ public void process(ContainerRequest containerRequest) throws PortletInvokerException, IOException
{
- HttpServletRequest req = context.getClientRequest();
+ PortletControllerContext context = containerRequest.controllerContext;
HttpServletResponse resp = context.getClientResponse();
//
@@ -363,9 +370,12 @@
PortletRequest portletRequest = (PortletRequest)containerRequest;
//
- PortletInvocationResponse response = handle(context, containerRequest);
+ PortletInvocationResponse response = invoke(containerRequest);
//
+ ResponseProperties requestProperties = new ResponseProperties();
+
+ //
if (response instanceof ErrorResponse)
{
ErrorResponse error = (ErrorResponse)response;
@@ -387,14 +397,23 @@
{
StateResponse stateResponse = (StateResponse)response;
+
// Update portlet NS
if (response instanceof UpdateNavigationalStateResponse)
{
+ UpdateNavigationalStateResponse updateResponse = (UpdateNavigationalStateResponse)response;
updateNavigationalState(
context,
containerRequest.portletId,
- (UpdateNavigationalStateResponse)response,
+ updateResponse,
portletRequest.pageState);
+
+ //
+ ResponseProperties update = updateResponse.getProperties();
+ if (update != null)
+ {
+ requestProperties.append(updateResponse.getProperties());
+ }
}
// Create event list and feed it with the events that may have been produced
@@ -425,7 +444,12 @@
//
for (Portlet consumer : consumers)
{
- PortletInvocationResponse eventResponse = deliverEvent(context, consumer, event, portletRequest.pageState);
+ PortletInvocationResponse eventResponse = deliverEvent(
+ context,
+ consumer,
+ event,
+ portletRequest.pageState,
+ requestProperties.getCookies());
//
if (eventResponse instanceof UpdateNavigationalStateResponse)
@@ -437,6 +461,13 @@
// Add events if any
queue.addAll(update.getEvents());
+
+ //
+ ResponseProperties updateProperties = update.getProperties();
+ if (updateProperties != null)
+ {
+ requestProperties.append(update.getProperties());
+ }
}
else if (eventResponse instanceof ErrorResponse)
{
@@ -498,11 +529,11 @@
*/
//
- render(context, portletRequest.pageState);
+ render(context, requestProperties, portletRequest.pageState);
}
else if (containerRequest instanceof PortletResourceRequest)
{
- PortletInvocationResponse response = handle(context, containerRequest);
+ PortletInvocationResponse response = invoke(containerRequest);
//
if (response instanceof FragmentResponse)
@@ -557,24 +588,33 @@
}
}
- private void render(PortletControllerContext context, PageNavigationalState pageNS) throws IOException
+ /**
+ *
+ * @param context
+ * @param pageProperties properties that needs to be rendered on this page
+ * @param pageNS
+ * @throws IOException
+ */
+ private void render(
+ PortletControllerContext context,
+ ResponseProperties pageProperties,
+ PageNavigationalState pageNS) throws IOException
{
HttpServletRequest req = context.getClientRequest();
HttpServletResponse resp = context.getClientResponse();
- //
- resp.setContentType("text/html");
- PrintWriter writer = resp.getWriter();
- writer.print("<html><body>");
+ List<FragmentResponse> fragments = new ArrayList<FragmentResponse>();
+ // What we collect during the different renders
+ // we don't reuse the render properties argument since we want to avoid that
+ // a portlet rendition affects another rendition of a portlet on the same page
+ ResponseProperties renderProperties = new ResponseProperties();
+
//
try
{
for (Portlet portlet : context.getPortlets())
{
- writer.print("<div><div>" + portlet.getContext() + "</div>");
-
- //
WindowNavigationalState windowNS = pageNS.getWindowNavigationalState(portlet.getContext().getId());
//
@@ -613,7 +653,7 @@
RenderInvocation render = new RenderInvocation(renderContext);
//
- render.setClientContext(new AbstractClientContext(req));
+ render.setClientContext(new AbstractClientContext(req, pageProperties.getCookies()));
render.setServerContext(new AbstractServerContext(req, resp));
render.setInstanceContext(instanceContext);
render.setUserContext(new AbstractUserContext(req));
@@ -625,23 +665,97 @@
//
try
{
- context.invoke(render);
+ PortletInvocationResponse response = context.invoke(render);
+
+ if (response instanceof FragmentResponse)
+ {
+ FragmentResponse fragment = (FragmentResponse)response;
+
+ //
+ fragments.add(fragment);
+
+ //
+ ResponseProperties fragmentProperties = fragment.getProperties();
+ if (fragmentProperties != null)
+ {
+ renderProperties.append(fragmentProperties);
+ }
+ }
+
}
catch (PortletInvokerException e)
{
e.printStackTrace();
}
-
- writer.print("</div>");
}
}
catch (PortletInvokerException e)
{
+ // todo
e.printStackTrace();
}
+ // Now we combine the render properties with the page properties
+ pageProperties.append(renderProperties);
+
+ // Render the headers
+ MultiValuedPropertyMap<String> transportHeaders = pageProperties.getTransportHeaders(false);
+ if (transportHeaders != null)
+ {
+ for (String headerName : transportHeaders.getPropertyNames())
+ {
+ for (String headerValue : transportHeaders.getPropertyValues(headerName))
+ {
+ resp.addHeader(headerName, headerValue);
+ }
+ }
+ }
+
+ // Render the cookies
+ List<Cookie> cookies = pageProperties.getCookies(false);
+ if (cookies != null)
+ {
+ for (Cookie cookie : cookies)
+ {
+ resp.addCookie(cookie);
+ }
+ }
+
+ //
+ resp.setContentType("text/html");
+ PrintWriter writer = resp.getWriter();
+ writer.print("<html>");
+
+ // Render the head contributions
+ writer.print("<head>");
+ MultiValuedPropertyMap<Element> markupHeaders = pageProperties.getMarkupHeaders(false);
+ if (markupHeaders != null)
+ {
+ for (Element headerValue : markupHeaders.getPropertyValues("javax.portlet.markup.head.element"))
+ {
+ try
+ {
+ String serializedElement = XMLTools.toString(headerValue);
+ writer.print(serializedElement);
+ }
+ catch (Exception e)
+ {
+ // todo
+ e.printStackTrace();
+ }
+ }
+ }
+ writer.print("</head>");
+
+
+ writer.print("<body>");
+ for (FragmentResponse fragment : fragments)
+ {
+ writer.print("<div>");
+ // Do something with fragment
+ writer.print("</div>");
+ }
writer.print("</body></html>");
-
}
private void updateNavigationalState(
@@ -711,15 +825,34 @@
static class ControllerRequest
{
+
+ /** . */
+ final PortletControllerContext controllerContext;
+
+ ControllerRequest(PortletControllerContext controllerContext)
+ {
+ this.controllerContext = controllerContext;
+ }
}
+ static class ViewRequest extends ControllerRequest
+ {
+ ViewRequest(PortletControllerContext controllerContext)
+ {
+ super(controllerContext);
+ }
+ }
+
static class ContainerRequest extends ControllerRequest
{
/** . */
final String portletId;
- ContainerRequest(String portletId)
+ ContainerRequest(PortletControllerContext controllerContext, String portletId)
{
+ super(controllerContext);
+
+ //
this.portletId = portletId;
}
}
@@ -739,9 +872,15 @@
/** . */
final WindowState windowState;
- PortletRequest(String portletId, Mode mode, WindowState windowState, StateString navigationalState, PageNavigationalState pageState)
+ PortletRequest(
+ PortletControllerContext controllerContext,
+ String portletId,
+ Mode mode,
+ WindowState windowState,
+ StateString navigationalState,
+ PageNavigationalState pageState)
{
- super(portletId);
+ super(controllerContext, portletId);
//
this.mode = mode;
@@ -751,7 +890,6 @@
}
}
-
static abstract class PortletResourceRequest extends ContainerRequest
{
@@ -775,13 +913,14 @@
final ParameterMap bodyParameters;
PortletResourceRequest(
+ PortletControllerContext controllerContext,
String portletId,
String resourceId,
StateString resourceState,
ParameterMap bodyParameters
)
{
- super(portletId);
+ super(controllerContext, portletId);
//
this.resourceId = resourceId;
@@ -797,9 +936,14 @@
static class FullScopedCacheablePortletResourceRequest extends PortletResourceRequest
{
- FullScopedCacheablePortletResourceRequest(String portletId, String resourceId, StateString resourceState, ParameterMap bodyParameters)
+ FullScopedCacheablePortletResourceRequest(
+ PortletControllerContext controllerContext,
+ String portletId,
+ String resourceId,
+ StateString resourceState,
+ ParameterMap bodyParameters)
{
- super(portletId, resourceId, resourceState, bodyParameters);
+ super(controllerContext, portletId, resourceId, resourceState, bodyParameters);
}
}
@@ -816,6 +960,7 @@
final WindowState windowState;
PortletScopedPortletResourceRequest(
+ PortletControllerContext controllerContext,
String portletId,
String resourceId,
StateString resourceState,
@@ -824,7 +969,7 @@
Mode mode,
WindowState windowState)
{
- super(portletId, resourceId, resourceState, bodyParameters);
+ super(controllerContext, portletId, resourceId, resourceState, bodyParameters);
//
this.mode = mode;
@@ -840,6 +985,7 @@
private final PageNavigationalState pageState;
PageScopedFullPortletResourceRequest(
+ PortletControllerContext controllerContext,
String portletId,
String resourceId,
StateString resourceState,
@@ -849,7 +995,7 @@
Mode mode,
WindowState windowState)
{
- super(portletId, resourceId, resourceState, bodyParameters, navigationalState, mode, windowState);
+ super(controllerContext, portletId, resourceId, resourceState, bodyParameters, navigationalState, mode, windowState);
//
this.pageState = pageState;
@@ -866,6 +1012,7 @@
final ParameterMap bodyParameters;
public PortletActionRequest(
+ PortletControllerContext controllerContext,
String portletId,
StateString interactionState,
ParameterMap bodyParameters,
@@ -874,7 +1021,7 @@
WindowState windowState,
PageNavigationalState pageState)
{
- super(portletId, mode, windowState, navigationalState, pageState);
+ super(controllerContext, portletId, mode, windowState, navigationalState, pageState);
//
this.interactionState = interactionState;
@@ -889,6 +1036,7 @@
final Map<String, String[]> publicNavigationalStateChanges;
public PortletRenderRequest(
+ PortletControllerContext controllerContext,
String portletId,
StateString navigationalState,
Map<String, String[]> publicNavigationalStateChanges,
@@ -896,7 +1044,7 @@
WindowState windowState,
PageNavigationalState pageState)
{
- super(portletId, mode, windowState, navigationalState, pageState);
+ super(controllerContext, portletId, mode, windowState, navigationalState, pageState);
//
this.publicNavigationalStateChanges = publicNavigationalStateChanges;
Modified: modules/portlet/trunk/test/src/main/java/org/jboss/portal/portlet/test/PortletControllerContextImpl.java
===================================================================
--- modules/portlet/trunk/test/src/main/java/org/jboss/portal/portlet/test/PortletControllerContextImpl.java 2008-01-24 21:27:57 UTC (rev 9599)
+++ modules/portlet/trunk/test/src/main/java/org/jboss/portal/portlet/test/PortletControllerContextImpl.java 2008-01-24 21:33:17 UTC (rev 9600)
@@ -153,6 +153,7 @@
{
case FULL:
request = new PortletController.FullScopedCacheablePortletResourceRequest(
+ this,
targetId,
resourceId,
resourceState,
@@ -160,6 +161,7 @@
break;
case PORTLET:
request = new PortletController.PortletScopedPortletResourceRequest(
+ this,
targetId,
resourceId,
resourceState,
@@ -170,6 +172,7 @@
break;
case PAGE:
request = new PortletController.PageScopedFullPortletResourceRequest(
+ this,
targetId,
resourceId,
resourceState,
@@ -196,6 +199,7 @@
//
request = new PortletController.PortletActionRequest(
+ this,
targetId,
interactionState,
formParameters,
@@ -210,6 +214,7 @@
//
request = new PortletController.PortletRenderRequest(
+ this,
targetId,
navigationalState,
publicNavigationalStateChanges,
@@ -219,6 +224,10 @@
}
}
}
+ else
+ {
+ request = new PortletController.ViewRequest(this);
+ }
//
this.request = request;
Modified: modules/portlet/trunk/test/src/test/build.xml
===================================================================
--- modules/portlet/trunk/test/src/test/build.xml 2008-01-24 21:27:57 UTC (rev 9599)
+++ modules/portlet/trunk/test/src/test/build.xml 2008-01-24 21:33:17 UTC (rev 9600)
@@ -242,6 +242,7 @@
<package-jsr286-api-test test="event"/>
<package-jsr286-ext-test test="portletrequests"/>
+ <package-jsr286-ext-test test="portletresponses"/>
<jar jarfile="${test.temp.lib}/portlet-test-lib.jar">
<fileset dir="${target}/test-classes"/>
Added: modules/portlet/trunk/test/src/test/resources/jsr286/ext/portletresponses-war/WEB-INF/portlet.xml
===================================================================
--- modules/portlet/trunk/test/src/test/resources/jsr286/ext/portletresponses-war/WEB-INF/portlet.xml (rev 0)
+++ modules/portlet/trunk/test/src/test/resources/jsr286/ext/portletresponses-war/WEB-INF/portlet.xml 2008-01-24 21:33:17 UTC (rev 9600)
@@ -0,0 +1,48 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ ~ 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. ~
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~-->
+
+<portlet-app xmlns="http://java.sun.com/xml/ns/portlet/portlet-app_2_0.xsd"
+ xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xsi:schemaLocation="http://java.sun.com/xml/ns/portlet/portlet-app_2_0.xsd http://java.sun.com/xml/ns/portlet/portlet-app_2_0.xsd"
+ version="2.0">
+
+ <portlet>
+ <portlet-name>UniversalTestPortletA</portlet-name>
+ <portlet-class>org.jboss.portal.test.portlet.framework.UTP1</portlet-class>
+ <supports>
+ <mime-type>text/html</mime-type>
+ </supports>
+ <supported-processing-event>
+ <name>Event</name>
+ </supported-processing-event>
+ <supported-publishing-event>
+ <name>Event</name>
+ </supported-publishing-event>
+ </portlet>
+
+ <event-definition>
+ <name>Event</name>
+ </event-definition>
+
+</portlet-app>
Added: modules/portlet/trunk/test/src/test/resources/jsr286/ext/portletresponses-war/WEB-INF/web.xml
===================================================================
--- modules/portlet/trunk/test/src/test/resources/jsr286/ext/portletresponses-war/WEB-INF/web.xml (rev 0)
+++ modules/portlet/trunk/test/src/test/resources/jsr286/ext/portletresponses-war/WEB-INF/web.xml 2008-01-24 21:33:17 UTC (rev 9600)
@@ -0,0 +1,32 @@
+<?xml version="1.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. ~
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~-->
+
+<!DOCTYPE web-app PUBLIC
+ "-//Sun Microsystems, Inc.//DTD Web Application 2.3//EN"
+ "http://java.sun.com/dtd/web-app_2_3.dtd">
+<web-app>
+ <listener>
+ <listener-class>org.jboss.portal.unit.PortletTestSuite</listener-class>
+ </listener>
+</web-app>
Modified: modules/portlet/trunk/test/src/test/resources/test/remote-jboss-unit.xml
===================================================================
--- modules/portlet/trunk/test/src/test/resources/test/remote-jboss-unit.xml 2008-01-24 21:27:57 UTC (rev 9599)
+++ modules/portlet/trunk/test/src/test/resources/test/remote-jboss-unit.xml 2008-01-24 21:33:17 UTC (rev 9600)
@@ -189,6 +189,10 @@
<class name="org.jboss.unit.remote.driver.RemoteTestDriverClient"/>
<property name="archiveId" value="test-jsr286-ext-portletrequests.war"/>
</generic>
+ <generic>
+ <class name="org.jboss.unit.remote.driver.RemoteTestDriverClient"/>
+ <property name="archiveId" value="test-jsr286-ext-portletresponses.war"/>
+ </generic>
<!--Misc Tests-->
<!--
18 years, 3 months
JBoss Portal SVN: r9599 - in modules/common/trunk/common/src: test/java/org/jboss/portal/test/common/util and 1 other directory.
by portal-commits@lists.jboss.org
Author: julien(a)jboss.com
Date: 2008-01-24 16:27:57 -0500 (Thu, 24 Jan 2008)
New Revision: 9599
Modified:
modules/common/trunk/common/src/main/java/org/jboss/portal/common/util/MultiValuedPropertyMap.java
modules/common/trunk/common/src/test/java/org/jboss/portal/test/common/util/MultiValuedPropertyMapTestCase.java
Log:
bug fixes in MultiValuedPrropertyMap with test cases
Modified: modules/common/trunk/common/src/main/java/org/jboss/portal/common/util/MultiValuedPropertyMap.java
===================================================================
--- modules/common/trunk/common/src/main/java/org/jboss/portal/common/util/MultiValuedPropertyMap.java 2008-01-24 19:32:08 UTC (rev 9598)
+++ modules/common/trunk/common/src/main/java/org/jboss/portal/common/util/MultiValuedPropertyMap.java 2008-01-24 21:27:57 UTC (rev 9599)
@@ -200,22 +200,31 @@
}
//
- for (Map.Entry<String, LinkedList<T>> entry : appended.content.entrySet())
+ if (appended.content != null)
{
- String name = entry.getKey();
+ for (Map.Entry<String, LinkedList<T>> entry : appended.content.entrySet())
+ {
+ String name = entry.getKey();
- //
- LinkedList<T> values = content.get(name);
+ //
+ if (content == null)
+ {
+ content = new HashMap<String, LinkedList<T>>(appended.content.size());
+ }
- //
- if (values != null)
- {
- values.addAll(entry.getValue());
+ //
+ LinkedList<T> values = content.get(name);
+
+ //
+ if (values != null)
+ {
+ values.addAll(entry.getValue());
+ }
+ else
+ {
+ content.put(name, new LinkedList<T>(entry.getValue()));
+ }
}
- else
- {
- content.put(name, new LinkedList<T>(entry.getValue()));
- }
}
}
}
Modified: modules/common/trunk/common/src/test/java/org/jboss/portal/test/common/util/MultiValuedPropertyMapTestCase.java
===================================================================
--- modules/common/trunk/common/src/test/java/org/jboss/portal/test/common/util/MultiValuedPropertyMapTestCase.java 2008-01-24 19:32:08 UTC (rev 9598)
+++ modules/common/trunk/common/src/test/java/org/jboss/portal/test/common/util/MultiValuedPropertyMapTestCase.java 2008-01-24 21:27:57 UTC (rev 9599)
@@ -119,9 +119,35 @@
}
}
- public void testAppend()
+ public void testAppend1()
{
MultiValuedPropertyMap<String> props = new MultiValuedPropertyMap<String>();
+ MultiValuedPropertyMap<String> appended = new MultiValuedPropertyMap<String>();
+ appended.setProperty("foo", "bar");
+ props.append(appended);
+
+ //
+ assertEquals(Tools.toSet("foo"), props.getPropertyNames());
+ assertEquals(Tools.toList("bar"), props.getPropertyValues("foo"));
+ }
+
+ public void testAppend2()
+ {
+ MultiValuedPropertyMap<String> props = new MultiValuedPropertyMap<String>();
+ props.setProperty("foo", "bar");
+
+ //
+ MultiValuedPropertyMap<String> appended = new MultiValuedPropertyMap<String>();
+ props.append(appended);
+
+ //
+ assertEquals(Tools.toSet("foo"), props.getPropertyNames());
+ assertEquals(Tools.toList("bar"), props.getPropertyValues("foo"));
+ }
+
+ public void testAppend3()
+ {
+ MultiValuedPropertyMap<String> props = new MultiValuedPropertyMap<String>();
props.setProperty("foo", "foo1");
props.setProperty("bar", "bar1");
props.addProperty("bar", "bar2");
18 years, 3 months
JBoss Portal SVN: r9596 - in modules/common/trunk/common/src: test/java/org/jboss/portal/test/common/util and 1 other directory.
by portal-commits@lists.jboss.org
Author: julien(a)jboss.com
Date: 2008-01-24 09:25:15 -0500 (Thu, 24 Jan 2008)
New Revision: 9596
Added:
modules/common/trunk/common/src/main/java/org/jboss/portal/common/util/MultiValuedPropertyMap.java
modules/common/trunk/common/src/test/java/org/jboss/portal/test/common/util/MultiValuedPropertyMapTestCase.java
Log:
added MultiValuedPropertyMap class (migration from Portlet module) + its test case
Added: modules/common/trunk/common/src/main/java/org/jboss/portal/common/util/MultiValuedPropertyMap.java
===================================================================
--- modules/common/trunk/common/src/main/java/org/jboss/portal/common/util/MultiValuedPropertyMap.java (rev 0)
+++ modules/common/trunk/common/src/main/java/org/jboss/portal/common/util/MultiValuedPropertyMap.java 2008-01-24 14:25:15 UTC (rev 9596)
@@ -0,0 +1,221 @@
+/******************************************************************************
+ * 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.common.util;
+
+import java.util.Map;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Set;
+import java.util.Collections;
+import java.util.LinkedList;
+
+/**
+ * A map of multi valued properties
+ *
+ * @author <a href="mailto:julien@jboss.org">Julien Viet</a>
+ * @version $Revision: 630 $
+ */
+public class MultiValuedPropertyMap<T>
+{
+
+ /** . */
+ private Map<String, LinkedList<T>> content;
+
+ /**
+ * @param name the property name
+ * @param value the property value
+ * @throws IllegalArgumentException if name or value is null
+ */
+ public void addProperty(String name, T 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, LinkedList<T>>();
+ }
+
+ //
+ LinkedList<T> values = content.get(name);
+ if (values == null)
+ {
+ values = new LinkedList<T>();
+ 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, T 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, LinkedList<T>>();
+ }
+
+ //
+ LinkedList<T> values = content.get(name);
+ if (values == null)
+ {
+ values = new LinkedList<T>();
+ content.put(name, values);
+ }
+ else
+ {
+ values.clear();
+ }
+
+ //
+ values.add(value);
+ }
+
+ /**
+ * Clear the properties.
+ */
+ public void clear()
+ {
+ if (content != null)
+ {
+ content.clear();
+ }
+ }
+
+ /**
+ * Returns the first property value or null if it cannot be found.
+ *
+ * @param name the property name
+ * @return the property value
+ * @throws IllegalArgumentException if the name argument is null
+ */
+ public T getPropertyValue(String name) throws IllegalArgumentException
+ {
+ if (name == null)
+ {
+ throw new IllegalArgumentException("Name cannot be null");
+ }
+ if (content == null)
+ {
+ return null;
+ }
+
+ //
+ LinkedList<T> values = content.get(name);
+ if (values == null)
+ {
+ return null;
+ }
+ else
+ {
+ return values.get(0);
+ }
+ }
+
+ /**
+ * Returns the list of values for a specified property.
+ *
+ * @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 argument is null
+ */
+ public List<T> getPropertyValues(String name)
+ {
+ if (name == null)
+ {
+ throw new IllegalArgumentException("Name cannot be null");
+ }
+ if (content == null)
+ {
+ return null;
+ }
+ return content.get(name);
+ }
+
+ /**
+ * Returns the set of property names.
+ *
+ * @return the set of property names
+ */
+ public Set<String> getPropertyNames()
+ {
+ if (content == null)
+ {
+ return Collections.emptySet();
+ }
+ return content.keySet();
+ }
+
+ /**
+ * Append the multi valued property map to this one. Entries from the provided map that do not exist
+ * in the current map are created, entries that exist in both maps are concatenated in the existing map
+ * with the values of the existing map being before the values of the provided map.
+ *
+ * @param appended the property map to append
+ * @throws IllegalArgumentException if the provided map is null
+ */
+ public void append(MultiValuedPropertyMap<T> appended) throws IllegalArgumentException
+ {
+ if (appended == null)
+ {
+ throw new IllegalArgumentException();
+ }
+
+ //
+ for (Map.Entry<String, LinkedList<T>> entry : appended.content.entrySet())
+ {
+ String name = entry.getKey();
+
+ //
+ LinkedList<T> values = content.get(name);
+
+ //
+ if (values != null)
+ {
+ values.addAll(entry.getValue());
+ }
+ else
+ {
+ content.put(name, new LinkedList<T>(entry.getValue()));
+ }
+ }
+ }
+}
Added: modules/common/trunk/common/src/test/java/org/jboss/portal/test/common/util/MultiValuedPropertyMapTestCase.java
===================================================================
--- modules/common/trunk/common/src/test/java/org/jboss/portal/test/common/util/MultiValuedPropertyMapTestCase.java (rev 0)
+++ modules/common/trunk/common/src/test/java/org/jboss/portal/test/common/util/MultiValuedPropertyMapTestCase.java 2008-01-24 14:25:15 UTC (rev 9596)
@@ -0,0 +1,155 @@
+/******************************************************************************
+ * 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.common.util;
+
+import junit.framework.TestCase;
+import org.jboss.portal.common.util.MultiValuedPropertyMap;
+import org.jboss.portal.common.util.Tools;
+
+/**
+ * @author <a href="mailto:julien@jboss.org">Julien Viet</a>
+ * @version $Revision: 630 $
+ */
+public class MultiValuedPropertyMapTestCase extends TestCase
+{
+
+ public MultiValuedPropertyMapTestCase()
+ {
+ }
+
+ public MultiValuedPropertyMapTestCase(String name)
+ {
+ super(name);
+ }
+
+ public void testA()
+ {
+ MultiValuedPropertyMap<String> props = new MultiValuedPropertyMap<String>();
+
+ 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.getPropertyValue("name1"));
+ assertEquals(1, props.getPropertyValues("name1").size());
+ assertEquals("value1", props.getPropertyValues("name1").get(0));
+
+ assertEquals("value2", props.getPropertyValue("name2"));
+ assertEquals(1, props.getPropertyValues("name2").size());
+ assertEquals("value2", props.getPropertyValues("name2").get(0));
+
+ assertEquals("value3-1", props.getPropertyValue("name3"));
+ assertEquals(2, props.getPropertyValues("name3").size());
+ assertEquals("value3-1", props.getPropertyValues("name3").get(0));
+ assertEquals("value3-2", props.getPropertyValues("name3").get(1));
+
+ assertEquals("value4-1", props.getPropertyValue("name4"));
+ assertEquals(2, props.getPropertyValues("name4").size());
+ assertEquals("value4-1", props.getPropertyValues("name4").get(0));
+ assertEquals("value4-2", props.getPropertyValues("name4").get(1));
+
+ assertEquals(1, props.getPropertyValues("name5").size());
+ assertEquals("value5-2", props.getPropertyValues("name5").get(0));
+
+ assertEquals("value6-2", props.getPropertyValue("name6"));
+ assertEquals(1, props.getPropertyValues("name6").size());
+ assertEquals("value6-2", props.getPropertyValues("name6").get(0));
+
+ assertEquals(null, props.getPropertyValues("not here"));
+ assertNull(props.getPropertyValue("not here"));
+ assertEquals(Tools.toSet("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)
+ {
+ }
+ }
+
+ public void testAppend()
+ {
+ MultiValuedPropertyMap<String> props = new MultiValuedPropertyMap<String>();
+ props.setProperty("foo", "foo1");
+ props.setProperty("bar", "bar1");
+ props.addProperty("bar", "bar2");
+ props.setProperty("juu", "juu1");
+ props.setProperty("daa", "daa1");
+ props.addProperty("daa", "daa2");
+
+ //
+ MultiValuedPropertyMap<String> appended = new MultiValuedPropertyMap<String>();
+ appended.setProperty("juu", "juu2");
+ appended.addProperty("juu", "juu3");
+ appended.setProperty("daa", "daa3");
+ appended.setProperty("zoo", "zoo1");
+ appended.setProperty("tee", "tee1");
+ appended.addProperty("tee", "tee2");
+
+
+ //
+ props.append(appended);
+
+ //
+ assertEquals(Tools.toSet("foo","bar","juu","daa","zoo","tee"), props.getPropertyNames());
+ assertEquals(Tools.toList("foo1"), props.getPropertyValues("foo"));
+ assertEquals(Tools.toList("bar1", "bar2"), props.getPropertyValues("bar"));
+ assertEquals(Tools.toList("juu1", "juu2","juu3"), props.getPropertyValues("juu"));
+ assertEquals(Tools.toList("daa1", "daa2","daa3"), props.getPropertyValues("daa"));
+ assertEquals(Tools.toList("zoo1"), props.getPropertyValues("zoo"));
+ assertEquals(Tools.toList("tee1","tee2"), props.getPropertyValues("tee"));
+ }
+
+}
18 years, 3 months
JBoss Portal SVN: r9595 - branches/JBoss_Portal_Branch_2_6/core/src/main/org/jboss/portal/core/model/instance/metadata.
by portal-commits@lists.jboss.org
Author: thomas.heute(a)jboss.com
Date: 2008-01-24 03:39:03 -0500 (Thu, 24 Jan 2008)
New Revision: 9595
Modified:
branches/JBoss_Portal_Branch_2_6/core/src/main/org/jboss/portal/core/model/instance/metadata/InstanceMetaData.java
Log:
pwa can be null
Modified: branches/JBoss_Portal_Branch_2_6/core/src/main/org/jboss/portal/core/model/instance/metadata/InstanceMetaData.java
===================================================================
--- branches/JBoss_Portal_Branch_2_6/core/src/main/org/jboss/portal/core/model/instance/metadata/InstanceMetaData.java 2008-01-24 04:51:25 UTC (rev 9594)
+++ branches/JBoss_Portal_Branch_2_6/core/src/main/org/jboss/portal/core/model/instance/metadata/InstanceMetaData.java 2008-01-24 08:39:03 UTC (rev 9595)
@@ -184,7 +184,7 @@
}
// Set display name
- if (localizedStringMD.getValues().isEmpty())
+ if (localizedStringMD.getValues().isEmpty() && (pwa != null))
{
ResourceBundleManager bundleMgr = MetaDataResourceBundleFactory.createResourceBundleManager(pwa.getClassLoader(), supportedLocales, resourceBundle);
LocalizedString localizedString = bundleMgr.getLocalizedValue("org.jboss.portal.instance.name." + instanceName, instanceName);
18 years, 3 months
JBoss Portal SVN: r9594 - in branches/presentation/presentation/src/main/org/jboss/portal/presentation: client and 3 other directories.
by portal-commits@lists.jboss.org
Author: sohil.shah(a)jboss.com
Date: 2008-01-23 23:51:25 -0500 (Wed, 23 Jan 2008)
New Revision: 9594
Added:
branches/presentation/presentation/src/main/org/jboss/portal/presentation/impl/SessionConstants.java
branches/presentation/presentation/src/main/org/jboss/portal/presentation/impl/model/AjaxModelListener.java
Modified:
branches/presentation/presentation/src/main/org/jboss/portal/presentation/ajax/client/model/AjaxUIContext.java
branches/presentation/presentation/src/main/org/jboss/portal/presentation/ajax/client/model/AjaxUIObject.java
branches/presentation/presentation/src/main/org/jboss/portal/presentation/client/PresentationContext.java
branches/presentation/presentation/src/main/org/jboss/portal/presentation/client/controller/AjaxUIController.java
branches/presentation/presentation/src/main/org/jboss/portal/presentation/client/controller/UIController.java
branches/presentation/presentation/src/main/org/jboss/portal/presentation/impl/PresentationContextImpl.java
Log:
Ajax User Agent - first pass at the server side component of the agent based on ModelListener approach
Modified: branches/presentation/presentation/src/main/org/jboss/portal/presentation/ajax/client/model/AjaxUIContext.java
===================================================================
--- branches/presentation/presentation/src/main/org/jboss/portal/presentation/ajax/client/model/AjaxUIContext.java 2008-01-23 23:43:05 UTC (rev 9593)
+++ branches/presentation/presentation/src/main/org/jboss/portal/presentation/ajax/client/model/AjaxUIContext.java 2008-01-24 04:51:25 UTC (rev 9594)
@@ -45,10 +45,11 @@
{
AjaxUIObject object = null;
+ //Perform a direct quick lookup
if(this.objectTree.containsKey(id))
{
object = (AjaxUIObject)this.objectTree.get(id);
- }
+ }
return object;
}
Modified: branches/presentation/presentation/src/main/org/jboss/portal/presentation/ajax/client/model/AjaxUIObject.java
===================================================================
--- branches/presentation/presentation/src/main/org/jboss/portal/presentation/ajax/client/model/AjaxUIObject.java 2008-01-23 23:43:05 UTC (rev 9593)
+++ branches/presentation/presentation/src/main/org/jboss/portal/presentation/ajax/client/model/AjaxUIObject.java 2008-01-24 04:51:25 UTC (rev 9594)
@@ -23,6 +23,7 @@
package org.jboss.portal.presentation.ajax.client.model;
import java.util.List;
+import java.util.ArrayList;
import com.google.gwt.user.client.rpc.IsSerializable;
@@ -108,6 +109,10 @@
*/
public List getChildren()
{
+ if(this.children == null)
+ {
+ this.children = new ArrayList();
+ }
return this.children;
}
@@ -116,7 +121,7 @@
* @param name
* @return
*/
- public AjaxUIObject getChild(String name)
+ public AjaxUIObject getChild(String id)
{
AjaxUIObject child = null;
@@ -125,7 +130,7 @@
for(int i=0; i<this.children.size(); i++)
{
AjaxUIObject cour = (AjaxUIObject)this.children.get(i);
- if(cour.getName().equals(name))
+ if(cour.id.equals(id))
{
child = cour;
break;
@@ -135,6 +140,40 @@
return child;
}
+
+ /**
+ *
+ * @param children
+ */
+ public void setChildren(List children)
+ {
+ this.children = children;
+ }
+
+ /**
+ *
+ * @param child
+ */
+ /*public void addChild(AjaxUIObject child)
+ {
+ AjaxUIObject find = null;
+ for(int i=0; i<this.getChildren().size(); i++)
+ {
+ AjaxUIObject cour = (AjaxUIObject)this.getChildren().get(i);
+ if(cour.id.equals(child.id))
+ {
+ find = cour;
+ }
+ }
+
+ if(find != null)
+ {
+ this.getChildren().remove(find);
+ }
+
+ this.getChildren().add(child);
+ }*/
+
public AjaxUIContext getContext()
{
@@ -146,15 +185,6 @@
this.context = context;
}
- /**
- *
- * @param children
- */
- public void setChildren(List children)
- {
- this.children = children;
- }
-
public void setId(String id)
{
this.id = id;
@@ -168,5 +198,5 @@
public void setStatus(int status)
{
this.status = status;
- }
+ }
}
Modified: branches/presentation/presentation/src/main/org/jboss/portal/presentation/client/PresentationContext.java
===================================================================
--- branches/presentation/presentation/src/main/org/jboss/portal/presentation/client/PresentationContext.java 2008-01-23 23:43:05 UTC (rev 9593)
+++ branches/presentation/presentation/src/main/org/jboss/portal/presentation/client/PresentationContext.java 2008-01-24 04:51:25 UTC (rev 9594)
@@ -23,6 +23,7 @@
package org.jboss.portal.presentation.client;
import org.jboss.portal.presentation.protocol.ServerAction;
+import org.jboss.portal.presentation.ajax.client.model.AjaxUIContext;
import org.jboss.portal.presentation.model.UIContext;
import org.jboss.portal.server.ServerInvocation;
import org.jboss.portal.web.ServletContextDispatcher;
@@ -51,6 +52,13 @@
* @return the ui context
*/
UIContext getUIContext();
+
+ /**
+ * Provide the root UI context for the server side cache of the Ajax User Agent
+ *
+ * @return
+ */
+ public AjaxUIContext getAjaxUIContext();
/**
* Returns the servlet context dispatcher.
Modified: branches/presentation/presentation/src/main/org/jboss/portal/presentation/client/controller/AjaxUIController.java
===================================================================
--- branches/presentation/presentation/src/main/org/jboss/portal/presentation/client/controller/AjaxUIController.java 2008-01-23 23:43:05 UTC (rev 9593)
+++ branches/presentation/presentation/src/main/org/jboss/portal/presentation/client/controller/AjaxUIController.java 2008-01-24 04:51:25 UTC (rev 9594)
@@ -28,8 +28,6 @@
import org.jboss.portal.presentation.model.UIPage;
import org.jboss.portal.presentation.model.UIWindow;
import org.jboss.portal.presentation.model.content.WindowContent;
-import org.jboss.portal.presentation.protocol.GetActivation;
-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;
@@ -37,17 +35,15 @@
import org.jboss.portal.presentation.server.PresentationServer;
import org.jboss.portal.presentation.server.ProcessorRequest;
import org.jboss.portal.presentation.server.ProcessorResponse;
+import org.jboss.portal.presentation.ajax.client.model.AjaxUIContext;
+import org.jboss.portal.presentation.ajax.client.model.AjaxUIPage;
+import org.jboss.portal.presentation.ajax.client.model.AjaxUIWindow;
import org.jboss.portal.server.RequestController;
import org.jboss.portal.server.ServerException;
import org.jboss.portal.server.ServerInvocation;
-import org.jboss.portal.server.ServerInvocationContext;
-import org.jboss.portal.server.impl.ServerInvocationContextImpl;
-import org.jboss.portal.web.WebRequest;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
-import java.util.List;
-import java.util.ArrayList;
import java.util.Collection;
/**
@@ -84,9 +80,9 @@
/**
* TODO: decouple the implementation via factory pattern
- */
- PresentationContext presentationContext = new PresentationContextImpl(this.presentationServer,
- invocation);
+ */
+ PresentationContext presentationContext = presentationContext = new PresentationContextImpl(this.presentationServer,
+ invocation);
request.setAttribute("requestContext", presentationContext);
/**
@@ -139,55 +135,74 @@
private void render(ServerInvocation invocation,PresentationContext presentationContext, String targetId)
{
UIObject uiObject = presentationContext.getUIContext().getObject(targetId);
-
+
//Display the page to the client
if(uiObject instanceof UIPage)
{
UIPage page = (UIPage)uiObject;
+ AjaxUIContext ajaxUiContext = presentationContext.getAjaxUIContext();
- org.jboss.portal.presentation.ajax.client.model.AjaxUIPage clientPage = new org.jboss.portal.presentation.ajax.client.model.AjaxUIPage();
- clientPage.setId(page.getId());
- //TODO: set proper status
- //TODO: set proper parent reference
+ //Process the Page to be displayed
+ AjaxUIPage clientPage = (AjaxUIPage)ajaxUiContext.getObject(page.getId());
+ boolean pageJustCreated = false;
+ if(clientPage == null)
+ {
+ clientPage = new org.jboss.portal.presentation.ajax.client.model.AjaxUIPage();
+ clientPage.setId(page.getId());
+ ajaxUiContext.addObject(clientPage);
+ pageJustCreated = true;
+ }
- Collection<? extends UIObject> windows = page.getChildren();
- List clientWindows = new ArrayList();
+ //Process the Windows belonging to this Page
+ Collection<? extends UIObject> windows = page.getChildren();
for(UIObject cour : windows)
{
if(cour instanceof UIWindow)
{
- UIWindow window = (UIWindow)cour;
- try
+ UIWindow window = (UIWindow)cour;
+
+ //Make sure this window properly belongs to the AjaxUIContext object tree
+ AjaxUIWindow clientWindow = (AjaxUIWindow)clientPage.getChild(window.getId());
+ if(clientWindow == null)
{
- WindowContent windowContent = this.presentationServer.render(presentationContext, window);
-
- org.jboss.portal.presentation.ajax.client.model.AjaxUIWindow clientWindow = new org.jboss.portal.presentation.ajax.client.model.AjaxUIWindow();
-
- clientWindow.setId(window.getId());
- clientWindow.setParent(clientPage);
- //TODO: Set proper status
-
- clientWindow.setContent(windowContent.getMarkup());
- if(window.getMode() != null)
- {
- clientWindow.setMode(window.getMode().toString());
+ clientWindow = new org.jboss.portal.presentation.ajax.client.model.AjaxUIWindow();
+ clientWindow.setId(window.getId());
+ clientPage.getChildren().add(clientWindow);
+ ajaxUiContext.addObject(clientWindow);
+ }
+
+ //Render this window only if this Page is being rendered for the first time in this
+ //User Session or if the navigation state of this window has changed during this interaction
+ //TODO: also add cache expiration as one of the conditions for this action
+ if(pageJustCreated || clientWindow.getStatus() == AjaxUIWindow.STATUS_STALE)
+ {
+ try
+ {
+ WindowContent windowContent = this.presentationServer.render(presentationContext, window);
+
+ clientWindow.setId(window.getId());
+ clientWindow.setParent(clientPage);
+
+ clientWindow.setContent(windowContent.getMarkup());
+ if(window.getMode() != null)
+ {
+ clientWindow.setMode(window.getMode().toString());
+ }
+ if(window.getWindowState() != null)
+ {
+ clientWindow.setState(window.getWindowState().toString());
+ }
+
+ //Restore the Status of the Window
+ clientWindow.setStatus(AjaxUIWindow.STATUS_VALID);
}
- if(window.getWindowState() != null)
+ catch (Exception e)
{
- clientWindow.setState(window.getWindowState().toString());
- }
-
- clientWindows.add(clientWindow);
+ e.printStackTrace();
+ }
}
- catch (Exception e)
- {
- e.printStackTrace();
- }
}
- }
-
- clientPage.setChildren(clientWindows);
-
+ }
invocation.getServerContext().getClientRequest().setAttribute("uiObject", clientPage);
}
}
@@ -243,86 +258,7 @@
{
action = new ViewUIObjectAction("/default/default");
}
-
-
- return action;
- /*ServerInvocationContext invocationContext = invocation.getServerContext();
- String requestPath = invocation.getServerContext().getPortalRequestPath();
-
- //
- if (requestPath.startsWith("/invoke/"))
- {
- UIObject target = presentationContext.getUIContext();
-
- //
- int from = "/invoke/".length();
- while (true)
- {
- int pos = requestPath.indexOf('/', from);
- if (pos == -1)
- {
- String name = requestPath.substring(from);
- target = target.getChild(name);
- break;
- }
- else
- {
- String name = requestPath.substring(from, pos);
- target = target.getChild(name);
- }
- if (target == null)
- {
- break;
- }
- from = pos + 1;
- }
-
- // I know but it will go away later when we remove dependency on server module
- WebRequest webReq = ((ServerInvocationContextImpl)invocation.getContext()).getWebRequest();
-
- //
- if (target != null)
- {
- if ("GET".equals(webReq.getMethod()))
- {
- return new GetActivation(target.getId(), webReq.getQueryParameterMap());
- }
- else if ("POST".equals(webReq.getMethod()))
- {
- return new PostActivation(target.getId(), webReq.getQueryParameterMap(), webReq.getBody());
- }
- }
- }
-
-
- if(targetPortalObject instanceof UIPage)
- {
- serverAction = new ViewUIObjectAction(targetPortalObject.getId());
- }
- else if(targetPortalObject instanceof UIWindow)
- {
- if(request.getMethod().equals("GET"))
- {
- GetActivation get = new GetActivation();
- get.setUrl(request.getRequestURL().toString());
- get.setContentType(invocationContext.getMediaType());
- get.setQueryParameters(invocationContext.getQueryParameterMap());
- get.setPortal(targetPortal);
- get.setTarget(targetPortalObject);
- serverAction = get;
- }
- else if(request.getMethod().equals("POST"))
- {
- PostActivation post = new PostActivation();
- post.setUrl(request.getRequestURL().toString());
- post.setContentType(invocationContext.getMediaType());
- post.setQueryParameters(invocationContext.getQueryParameterMap());
- post.setBodyParameters(invocationContext.getBodyParameterMap());
- post.setPortal(targetPortal);
- post.setTarget(targetPortalObject);
- serverAction = post;
- }
- }*/
- }
+ return action;
+ }
}
Modified: branches/presentation/presentation/src/main/org/jboss/portal/presentation/client/controller/UIController.java
===================================================================
--- branches/presentation/presentation/src/main/org/jboss/portal/presentation/client/controller/UIController.java 2008-01-23 23:43:05 UTC (rev 9593)
+++ branches/presentation/presentation/src/main/org/jboss/portal/presentation/client/controller/UIController.java 2008-01-24 04:51:25 UTC (rev 9594)
@@ -40,14 +40,12 @@
import org.jboss.portal.server.RequestController;
import org.jboss.portal.server.ServerException;
import org.jboss.portal.server.ServerInvocation;
-import org.jboss.portal.server.ServerInvocationContext;
import org.jboss.portal.server.impl.ServerInvocationContextImpl;
import org.jboss.portal.web.WebRequest;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.PrintWriter;
-import java.util.List;
import java.util.Collection;
import java.util.Map;
@@ -179,7 +177,6 @@
*/
private ServerAction getServerAction(PresentationContext presentationContext, ServerInvocation invocation)
{
- ServerInvocationContext invocationContext = invocation.getServerContext();
String requestPath = invocation.getServerContext().getPortalRequestPath();
WebRequest webReq = ((ServerInvocationContextImpl)invocation.getContext()).getWebRequest();
Map queryParameters = webReq.getQueryParameterMap();
@@ -228,101 +225,8 @@
//Just use ViewUIObject command for now until URL interpretation/mapping
//to ServiceAction is implemented
- return new ViewUIObjectAction("/default/default");
-
- /*if(targetPortalObject instanceof UIPage)
- {
- serverAction = new ViewUIObjectAction(targetPortalObject.getId());
- }
- else if(targetPortalObject instanceof UIWindow)
- {
- if(request.getMethod().equals("GET"))
- {
- GetActivation get = new GetActivation();
- get.setUrl(request.getRequestURL().toString());
- get.setContentType(invocationContext.getMediaType());
- get.setQueryParameters(invocationContext.getQueryParameterMap());
- get.setPortal(targetPortal);
- get.setTarget(targetPortalObject);
- serverAction = get;
- }
- else if(request.getMethod().equals("POST"))
- {
- PostActivation post = new PostActivation();
- post.setUrl(request.getRequestURL().toString());
- post.setContentType(invocationContext.getMediaType());
- post.setQueryParameters(invocationContext.getQueryParameterMap());
- post.setBodyParameters(invocationContext.getBodyParameterMap());
- post.setPortal(targetPortal);
- post.setTarget(targetPortalObject);
- serverAction = post;
- }
- }*/
- }
-
- /**
- *
- * @param portalRequestPath
- * @return
- */
- /*private UIPortal getTargetPortal(RequestContext requestContext,String portalRequestPath)
- {
- UIPortal targetPortal = null;
-
- //Parse the portalRequestPath and find the targetted Portal
- StringTokenizer st = new StringTokenizer(portalRequestPath, "/");
- StringBuffer buffer = new StringBuffer("/");
- while(st.hasMoreTokens())
- {
- String token = st.nextToken();
- buffer.append(token);
- String id = buffer.toString();
- ObjectState objectState = this.presentationServer.getStructuralStateManager().load(id);
- if(objectState != null && objectState.getType() == UIPortal.class)
- {
- targetPortal = (UIPortal)requestContext.getUIContext().getObject(id);
- break;
- }
- buffer.append("/");
- }
-
- return targetPortal;
- }*/
-
- /**
- *
- * @param portalRequestPath
- * @return
- */
- /*private UIObject getTargetPortalObject(RequestContext requestContext,String portalRequestPath)
- {
- UIObject targetPortalObject = null;
-
- //Parse the portalRequestPath and find the targetted Portal Object (Page or Window)
- StringTokenizer st = new StringTokenizer(portalRequestPath, "/");
- StringBuffer buffer = new StringBuffer("/");
- while(st.hasMoreTokens())
- {
- String token = st.nextToken();
- buffer.append(token);
- String id = buffer.toString();
- ObjectState objectState = this.presentationServer.getStructuralStateManager().load(id);
- if(objectState != null)
- {
- if(objectState.getType() == UIPage.class)
- {
- targetPortalObject = (UIPage)requestContext.getUIContext().getObject(id);
- }
- else if(objectState.getType() == UIWindow.class)
- {
- targetPortalObject = (UIWindow)requestContext.getUIContext().getObject(id);
- }
- }
- buffer.append("/");
- }
-
- return targetPortalObject;
- }*/
+ return new ViewUIObjectAction("/default/default");
+ }
//-----------------------------------------------------------------------------------------------------------------------------------------------------------
/**
* TODO: this should be used only in classic UI case...eventually when Controller is abstracted, this will be moved to
Modified: branches/presentation/presentation/src/main/org/jboss/portal/presentation/impl/PresentationContextImpl.java
===================================================================
--- branches/presentation/presentation/src/main/org/jboss/portal/presentation/impl/PresentationContextImpl.java 2008-01-23 23:43:05 UTC (rev 9593)
+++ branches/presentation/presentation/src/main/org/jboss/portal/presentation/impl/PresentationContextImpl.java 2008-01-24 04:51:25 UTC (rev 9594)
@@ -22,9 +22,11 @@
******************************************************************************/
package org.jboss.portal.presentation.impl;
+import org.jboss.portal.presentation.ajax.client.model.AjaxUIContext;
import org.jboss.portal.presentation.client.PresentationContext;
import org.jboss.portal.presentation.impl.model.container.UIObjectContainer;
import org.jboss.portal.presentation.impl.model.state.navigational.NavigationalStateContextImpl;
+import org.jboss.portal.presentation.impl.model.AjaxModelListener;
import org.jboss.portal.presentation.model.UIContext;
import org.jboss.portal.presentation.model.UIObject;
import org.jboss.portal.presentation.model.state.navigational.NavigationalStateContext;
@@ -41,6 +43,7 @@
import org.jboss.portal.web.ServletContextDispatcher;
import org.jboss.portal.web.impl.DefaultServletContainerFactory;
+import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpSession;
/**
@@ -56,40 +59,67 @@
/** . */
private PresentationServer presentationServer = null;
- /** . */
- private UIObjectContainer container;
-
+ /**
+ *
+ * @param presentationServer
+ * @param invocation
+ */
public PresentationContextImpl(PresentationServer presentationServer, ServerInvocation invocation)
{
this.invocation = invocation;
this.presentationServer = presentationServer;
}
+ /**
+ *
+ */
public UIContext getUIContext()
{
- if (container == null)
- {
- HttpSession session = this.invocation.getServerContext().getClientRequest().getSession();
+ HttpSession session = this.invocation.getServerContext().getClientRequest().getSession();
+
+ //Process the UIObjectContainer for this session
+ UIObjectContainer uiObjectContainer = (UIObjectContainer)session.getAttribute(SessionConstants.serverModel);
+ if (uiObjectContainer == null)
+ {
+ NavigationalStateContext nsc = new NavigationalStateContextImpl();
//
- NavigationalStateContext nsc = (NavigationalStateContext)session.getAttribute("nsc");
- if (nsc == null)
- {
- nsc = new NavigationalStateContextImpl();
- session.setAttribute("nsc", nsc);
- }
-
- //
- container = new UIObjectContainer(presentationServer.getStructuralStateManager(), nsc);
+ uiObjectContainer = new UIObjectContainer(presentationServer.getStructuralStateManager(), nsc);
+
+ session.setAttribute(SessionConstants.serverModel, uiObjectContainer);
}
//
- return container.getRoot();
+ return uiObjectContainer.getRoot();
}
/**
*
+ * @param request
+ * @return
*/
+ public AjaxUIContext getAjaxUIContext()
+ {
+ AjaxUIContext uiContext = null;
+
+ HttpServletRequest request = this.invocation.getServerContext().getClientRequest();
+ uiContext = (AjaxUIContext)request.getSession().getAttribute(SessionConstants.ajaxModel);
+ if(uiContext == null)
+ {
+ uiContext = new AjaxUIContext();
+ request.getSession().setAttribute(SessionConstants.ajaxModel, uiContext);
+
+ //Register a ModelListener to perform partial model updates based on receiving events due to
+ //Model State changes
+ this.getUIContext().addModelListener(new AjaxModelListener(this.getAjaxUIContext()));
+ }
+
+ return uiContext;
+ }
+
+ /**
+ *
+ */
public ServletContextDispatcher getDispatcher()
{
ServletContainer container = DefaultServletContainerFactory.getInstance().getServletContainer();
@@ -141,6 +171,11 @@
}
}
+ /**
+ *
+ * @param object
+ * @param buffer
+ */
private static void createPath(UIObject object, StringBuffer buffer)
{
UIObject parent = object.getParent();
Added: branches/presentation/presentation/src/main/org/jboss/portal/presentation/impl/SessionConstants.java
===================================================================
--- branches/presentation/presentation/src/main/org/jboss/portal/presentation/impl/SessionConstants.java (rev 0)
+++ branches/presentation/presentation/src/main/org/jboss/portal/presentation/impl/SessionConstants.java 2008-01-24 04:51:25 UTC (rev 9594)
@@ -0,0 +1,40 @@
+/******************************************************************************
+ * 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.impl;
+
+/**
+ * @author <a href="mailto:sshah@redhat.com">Sohil Shah</a>
+ *
+ */
+public interface SessionConstants
+{
+ /**
+ * Represents the session key for storing the server side UI model
+ */
+ public final String serverModel = "serverModel";
+
+ /**
+ * Represents the session key for storing the client side UI model for the Ajax User Agent
+ */
+ public final String ajaxModel = "ajaxModel";
+}
Added: branches/presentation/presentation/src/main/org/jboss/portal/presentation/impl/model/AjaxModelListener.java
===================================================================
--- branches/presentation/presentation/src/main/org/jboss/portal/presentation/impl/model/AjaxModelListener.java (rev 0)
+++ branches/presentation/presentation/src/main/org/jboss/portal/presentation/impl/model/AjaxModelListener.java 2008-01-24 04:51:25 UTC (rev 9594)
@@ -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.impl.model;
+
+import org.jboss.portal.presentation.ajax.client.model.AjaxUIContext;
+import org.jboss.portal.presentation.ajax.client.model.AjaxUIObject;
+import org.jboss.portal.presentation.model.ModelEvent;
+import org.jboss.portal.presentation.model.ModelListener;
+import org.jboss.portal.presentation.model.event.state.StateChangeEvent;
+import org.jboss.portal.presentation.model.event.state.StateChange;
+import org.jboss.portal.presentation.model.event.state.StateModification;
+import org.jboss.portal.presentation.model.event.state.navigational.NavigationalStateModification;
+import org.jboss.portal.presentation.model.event.state.structural.StructuralStateModification;
+
+/**
+ * @author <a href="mailto:sshah@redhat.com">Sohil Shah</a>
+ *
+ */
+public class AjaxModelListener implements ModelListener
+{
+ private AjaxUIContext ajaxUiContext = null;
+
+ /**
+ *
+ * @param uiContext
+ */
+ public AjaxModelListener(AjaxUIContext ajaxUiContext)
+ {
+ this.ajaxUiContext = ajaxUiContext;
+ }
+
+ /**
+ *
+ */
+ public void onEvent(ModelEvent event)
+ {
+ if(event instanceof StateChangeEvent)
+ {
+ StateChangeEvent stateChangeEvent = (StateChangeEvent)event;
+ StateChange stateChange = stateChangeEvent.getChange();
+ StateModification modification = stateChange.getModification();
+ if(modification instanceof NavigationalStateModification)
+ {
+ NavigationalStateModification navMod = (NavigationalStateModification)modification;
+ if(this.ajaxUiContext != null)
+ {
+ AjaxUIObject ajaxUiObject = this.ajaxUiContext.getObject(stateChange.getTargetId());
+ if(ajaxUiObject != null)
+ {
+ ajaxUiObject.setStatus(AjaxUIObject.STATUS_STALE);
+ }
+ }
+ }
+ else if(modification instanceof StructuralStateModification)
+ {
+ StructuralStateModification structMod = (StructuralStateModification)modification;
+
+ /**
+ * TODO: Process Structural State Modifications
+ */
+ }
+ }
+ }
+}
18 years, 3 months
JBoss Portal SVN: r9593 - in modules/portlet/trunk: portlet/src/main/java/org/jboss/portal/portlet/impl/spi and 6 other directories.
by portal-commits@lists.jboss.org
Author: julien(a)jboss.com
Date: 2008-01-23 18:43:05 -0500 (Wed, 23 Jan 2008)
New Revision: 9593
Added:
modules/portlet/trunk/portlet/src/test/java/org/jboss/portal/test/portlet/jsr286/ext/portletrequests/ReadCookieTestCase.java
Modified:
modules/portlet/trunk/portlet/src/main/java/org/jboss/portal/portlet/impl/jsr168/api/PortletRequestImpl.java
modules/portlet/trunk/portlet/src/main/java/org/jboss/portal/portlet/impl/spi/AbstractClientContext.java
modules/portlet/trunk/portlet/src/main/java/org/jboss/portal/portlet/spi/ClientContext.java
modules/portlet/trunk/portlet/src/main/java/org/jboss/portal/portlet/support/spi/ClientContextSupport.java
modules/portlet/trunk/portlet/src/test/java/org/jboss/portal/unit/TestAction.java
modules/portlet/trunk/portlet/src/test/java/org/jboss/portal/unit/actions/PortletRenderTestAction.java
modules/portlet/trunk/portlet/src/test/java/org/jboss/portal/unit/actions/PortletResourceTestAction.java
modules/portlet/trunk/test/src/test/resources/jsr286/ext/portletrequests-war/WEB-INF/portlet.xml
Log:
- implemented getCookies()
- tested getCookies()
Modified: modules/portlet/trunk/portlet/src/main/java/org/jboss/portal/portlet/impl/jsr168/api/PortletRequestImpl.java
===================================================================
--- modules/portlet/trunk/portlet/src/main/java/org/jboss/portal/portlet/impl/jsr168/api/PortletRequestImpl.java 2008-01-23 22:49:55 UTC (rev 9592)
+++ modules/portlet/trunk/portlet/src/main/java/org/jboss/portal/portlet/impl/jsr168/api/PortletRequestImpl.java 2008-01-23 23:43:05 UTC (rev 9593)
@@ -73,6 +73,7 @@
public abstract class PortletRequestImpl implements PortletRequest
{
+ /** . */
protected static final Logger log = Logger.getLogger(PortletRequestImpl.class);
protected PortletInvocation invocation;
@@ -463,7 +464,17 @@
public Cookie[] getCookies()
{
- throw new NotYetImplemented();
+ List<Cookie> cookies = clientContext.getCookies();
+
+ //
+ if (cookies.isEmpty())
+ {
+ return null;
+ }
+ else
+ {
+ return cookies.toArray(new Cookie[cookies.size()]);
+ }
}
public Map<String, String[]> getPrivateParameterMap()
Modified: modules/portlet/trunk/portlet/src/main/java/org/jboss/portal/portlet/impl/spi/AbstractClientContext.java
===================================================================
--- modules/portlet/trunk/portlet/src/main/java/org/jboss/portal/portlet/impl/spi/AbstractClientContext.java 2008-01-23 22:49:55 UTC (rev 9592)
+++ modules/portlet/trunk/portlet/src/main/java/org/jboss/portal/portlet/impl/spi/AbstractClientContext.java 2008-01-23 23:43:05 UTC (rev 9593)
@@ -25,6 +25,7 @@
import org.jboss.portal.portlet.spi.ClientContext;
import javax.servlet.http.HttpServletRequest;
+import javax.servlet.http.Cookie;
import java.util.List;
import java.util.Set;
import java.util.Map;
@@ -32,6 +33,7 @@
import java.util.Enumeration;
import java.util.ArrayList;
import java.util.Collections;
+import java.util.Arrays;
/**
* @author <a href="mailto:julien@jboss.org">Julien Viet</a>
@@ -46,6 +48,9 @@
/** . */
private final Map<String, List<String>> headers;
+ /** . */
+ private final List<Cookie> cookies;
+
public AbstractClientContext(HttpServletRequest request)
{
Map<String, List<String>> headers = new HashMap<String, List<String>>();
@@ -75,10 +80,21 @@
headers.put(headerName, headerValues);
}
}
+ List<Cookie> cookies = null;
+ Cookie[] tmp = request.getCookies();
+ if (tmp == null || tmp.length == 0)
+ {
+ cookies = Collections.emptyList();
+ }
+ else
+ {
+ cookies = Arrays.asList(tmp);
+ }
//
this.headers = headers;
this.method = request.getMethod();
+ this.cookies = cookies;
}
public String getMethod()
@@ -99,4 +115,9 @@
{
return headers.keySet();
}
+
+ public List<Cookie> getCookies()
+ {
+ return cookies;
+ }
}
Modified: modules/portlet/trunk/portlet/src/main/java/org/jboss/portal/portlet/spi/ClientContext.java
===================================================================
--- modules/portlet/trunk/portlet/src/main/java/org/jboss/portal/portlet/spi/ClientContext.java 2008-01-23 22:49:55 UTC (rev 9592)
+++ modules/portlet/trunk/portlet/src/main/java/org/jboss/portal/portlet/spi/ClientContext.java 2008-01-23 23:43:05 UTC (rev 9593)
@@ -22,6 +22,7 @@
******************************************************************************/
package org.jboss.portal.portlet.spi;
+import javax.servlet.http.Cookie;
import java.util.Iterator;
import java.util.Set;
import java.util.List;
@@ -35,8 +36,17 @@
String getMethod();
- List<String> getProperties(String name);
+ /**
+ * Returns the list of values of a specified property as seen by the client.
+ *
+ * @param name the property
+ * @return the list of properties
+ * @throws IllegalArgumentException if the name is null
+ */
+ List<String> getProperties(String name) throws IllegalArgumentException;
Set<String> getPropertyNames();
+ List<Cookie> getCookies();
+
}
Modified: modules/portlet/trunk/portlet/src/main/java/org/jboss/portal/portlet/support/spi/ClientContextSupport.java
===================================================================
--- modules/portlet/trunk/portlet/src/main/java/org/jboss/portal/portlet/support/spi/ClientContextSupport.java 2008-01-23 22:49:55 UTC (rev 9592)
+++ modules/portlet/trunk/portlet/src/main/java/org/jboss/portal/portlet/support/spi/ClientContextSupport.java 2008-01-23 23:43:05 UTC (rev 9593)
@@ -24,6 +24,7 @@
import org.jboss.portal.portlet.spi.ClientContext;
+import javax.servlet.http.Cookie;
import java.util.List;
import java.util.Set;
@@ -47,4 +48,9 @@
{
throw new UnsupportedOperationException();
}
+
+ public List<Cookie> getCookies()
+ {
+ throw new UnsupportedOperationException();
+ }
}
Added: modules/portlet/trunk/portlet/src/test/java/org/jboss/portal/test/portlet/jsr286/ext/portletrequests/ReadCookieTestCase.java
===================================================================
--- modules/portlet/trunk/portlet/src/test/java/org/jboss/portal/test/portlet/jsr286/ext/portletrequests/ReadCookieTestCase.java (rev 0)
+++ modules/portlet/trunk/portlet/src/test/java/org/jboss/portal/test/portlet/jsr286/ext/portletrequests/ReadCookieTestCase.java 2008-01-23 23:43:05 UTC (rev 9593)
@@ -0,0 +1,131 @@
+/******************************************************************************
+ * 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.jsr286.ext.portletrequests;
+
+import org.jboss.portal.unit.PortletTestCase;
+import org.jboss.portal.unit.PortletTestContext;
+import org.jboss.portal.unit.annotations.TestCase;
+import org.jboss.portal.unit.actions.PortletRenderTestAction;
+import org.jboss.portal.unit.actions.PortletActionTestAction;
+import org.jboss.portal.unit.actions.PortletEventTestAction;
+import org.jboss.portal.unit.actions.PortletResourceTestAction;
+import org.jboss.portal.test.portlet.framework.UTP5;
+import org.jboss.unit.driver.DriverResponse;
+import org.jboss.unit.driver.response.EndTestResponse;
+import org.jboss.unit.remote.driver.handler.http.response.InvokeGetResponse;
+
+import static org.jboss.unit.api.Assert.*;
+
+import javax.portlet.Portlet;
+import javax.portlet.RenderRequest;
+import javax.portlet.RenderResponse;
+import javax.portlet.PortletException;
+import javax.portlet.ActionRequest;
+import javax.portlet.ActionResponse;
+import javax.portlet.EventRequest;
+import javax.portlet.EventResponse;
+import javax.portlet.ResourceRequest;
+import javax.portlet.ResourceResponse;
+import java.io.IOException;
+import java.util.Map;
+
+/**
+ * @author <a href="mailto:julien@jboss.org">Julien Viet</a>
+ * @version $Revision: 630 $
+ */
+@TestCase
+public class ReadCookieTestCase
+{
+ public ReadCookieTestCase(PortletTestCase seq)
+ {
+ seq.bindAction(0, UTP5.RENDER_JOIN_POINT, new PortletRenderTestAction()
+ {
+ protected DriverResponse run(Portlet portlet, RenderRequest request, RenderResponse response, PortletTestContext context) throws PortletException, IOException
+ {
+ Map<String, String> cookieMap = createCookieMap(request);
+ assertFalse(cookieMap.containsKey("foo"));
+ assertFalse(cookieMap.containsKey("bar"));
+
+ // Invoke render with header
+ InvokeGetResponse get = new InvokeGetResponse(response.createRenderURL().toString());
+ get.addHeader("Cookie").addElement("foo=foo_value1; bar=bar_value2");
+ return get;
+ }
+ });
+ seq.bindAction(1, UTP5.RENDER_JOIN_POINT, new PortletRenderTestAction()
+ {
+ protected DriverResponse run(Portlet portlet, RenderRequest request, RenderResponse response, PortletTestContext context) throws PortletException, IOException
+ {
+ Map<String, String> cookieMap = createCookieMap(request);
+ assertEquals("foo_value1", cookieMap.get("foo"));
+ assertEquals("bar_value2", cookieMap.get("bar"));
+
+ // Invoke render with header
+ InvokeGetResponse get = new InvokeGetResponse(response.createActionURL().toString());
+ get.addHeader("Cookie").addElement("foo=foo_value3; bar=bar_value4");
+ return get;
+ }
+ });
+ seq.bindAction(2, UTP5.ACTION_JOIN_POINT, new PortletActionTestAction()
+ {
+ protected void run(Portlet portlet, ActionRequest request, ActionResponse response, PortletTestContext context) throws PortletException, IOException
+ {
+ Map<String, String> cookieMap = createCookieMap(request);
+ assertEquals("foo_value3", cookieMap.get("foo"));
+ assertEquals("bar_value4", cookieMap.get("bar"));
+ response.setEvent("Event", null);
+ }
+ });
+ seq.bindAction(2, UTP5.EVENT_JOIN_POINT, new PortletEventTestAction()
+ {
+ protected void run(Portlet portlet, EventRequest request, EventResponse response, PortletTestContext context) throws PortletException, IOException
+ {
+ Map<String, String> cookieMap = createCookieMap(request);
+ assertEquals("foo_value3", cookieMap.get("foo"));
+ assertEquals("bar_value4", cookieMap.get("bar"));
+ }
+ });
+ seq.bindAction(2, UTP5.RENDER_JOIN_POINT, new PortletRenderTestAction()
+ {
+ protected DriverResponse run(Portlet portlet, RenderRequest request, RenderResponse response, PortletTestContext context) throws PortletException, IOException
+ {
+ // Invoke render with header
+ InvokeGetResponse get = new InvokeGetResponse(response.createResourceURL().toString());
+ get.addHeader("Cookie").addElement("foo=foo_value5; bar=bar_value6");
+ return get;
+ }
+ });
+ seq.bindAction(3, UTP5.RESOURCE_JOIN_POINT, new PortletResourceTestAction()
+ {
+ protected DriverResponse run(Portlet portlet, ResourceRequest request, ResourceResponse response, PortletTestContext context) throws PortletException, IOException
+ {
+ Map<String, String> cookieMap = createCookieMap(request);
+ assertEquals("foo_value5", cookieMap.get("foo"));
+ assertEquals("bar_value6", cookieMap.get("bar"));
+
+ //
+ return new EndTestResponse();
+ }
+ });
+ }
+}
Modified: modules/portlet/trunk/portlet/src/test/java/org/jboss/portal/unit/TestAction.java
===================================================================
--- modules/portlet/trunk/portlet/src/test/java/org/jboss/portal/unit/TestAction.java 2008-01-23 22:49:55 UTC (rev 9592)
+++ modules/portlet/trunk/portlet/src/test/java/org/jboss/portal/unit/TestAction.java 2008-01-23 23:43:05 UTC (rev 9593)
@@ -23,10 +23,12 @@
package org.jboss.portal.unit;
import javax.portlet.PortletRequest;
+import javax.servlet.http.Cookie;
import java.util.Map;
import java.util.List;
import java.util.ArrayList;
import java.util.Collections;
+import java.util.HashMap;
import static org.jboss.unit.api.Assert.*;
import org.jboss.portal.common.util.Tools;
@@ -68,7 +70,7 @@
* @param request the actual portlet request
* @throws AssertionError if the provided request does not match the expected map state
*/
- public final void assertParameterMap(Map<String, String[]> expectedMap, PortletRequest request) throws AssertionError
+ protected final void assertParameterMap(Map<String, String[]> expectedMap, PortletRequest request) throws AssertionError
{
assertNotNull(request);
@@ -105,7 +107,7 @@
* @param map the actual map
* @throws AssertionError if the provided map is not equals to the expected map
*/
- public final void assertParameterMap(Map<String, String[]> expectedMap, Map<String, String[]> map) throws AssertionError
+ protected final void assertParameterMap(Map<String, String[]> expectedMap, Map<String, String[]> map) throws AssertionError
{
assertNotNull(map);
assertEquals(expectedMap.size(), map.size());
@@ -115,4 +117,24 @@
assertEquals(entry.getValue(), expectedValues);
}
}
+
+ /**
+ * Build a cookie map from the request.
+ *
+ * @param request the request
+ * @return the cookie map
+ */
+ protected final Map<String, String> createCookieMap(PortletRequest request)
+ {
+ Map<String, String> cookieMap = new HashMap<String, String>();
+ Cookie[] cookies = request.getCookies();
+ if (cookies != null)
+ {
+ for (Cookie cookie : cookies)
+ {
+ cookieMap.put(cookie.getName(), cookie.getValue());
+ }
+ }
+ return cookieMap;
+ }
}
Modified: modules/portlet/trunk/portlet/src/test/java/org/jboss/portal/unit/actions/PortletRenderTestAction.java
===================================================================
--- modules/portlet/trunk/portlet/src/test/java/org/jboss/portal/unit/actions/PortletRenderTestAction.java 2008-01-23 22:49:55 UTC (rev 9592)
+++ modules/portlet/trunk/portlet/src/test/java/org/jboss/portal/unit/actions/PortletRenderTestAction.java 2008-01-23 23:43:05 UTC (rev 9593)
@@ -45,7 +45,7 @@
public abstract class PortletRenderTestAction extends TestAction
{
- public DriverResponse execute(Portlet portlet, RenderRequest request, RenderResponse response, PortletTestContext context) throws PortletException, IOException
+ public final DriverResponse execute(Portlet portlet, RenderRequest request, RenderResponse response, PortletTestContext context) throws PortletException, IOException
{
try
{
Modified: modules/portlet/trunk/portlet/src/test/java/org/jboss/portal/unit/actions/PortletResourceTestAction.java
===================================================================
--- modules/portlet/trunk/portlet/src/test/java/org/jboss/portal/unit/actions/PortletResourceTestAction.java 2008-01-23 22:49:55 UTC (rev 9592)
+++ modules/portlet/trunk/portlet/src/test/java/org/jboss/portal/unit/actions/PortletResourceTestAction.java 2008-01-23 23:43:05 UTC (rev 9593)
@@ -69,7 +69,7 @@
this(true);
}
- public DriverResponse execute(Portlet portlet, ResourceRequest request, ResourceResponse response, PortletTestContext context) throws PortletException, IOException
+ public final DriverResponse execute(Portlet portlet, ResourceRequest request, ResourceResponse response, PortletTestContext context) throws PortletException, IOException
{
// We attempty to do it
boolean sendResponse = false;
Modified: modules/portlet/trunk/test/src/test/resources/jsr286/ext/portletrequests-war/WEB-INF/portlet.xml
===================================================================
--- modules/portlet/trunk/test/src/test/resources/jsr286/ext/portletrequests-war/WEB-INF/portlet.xml 2008-01-23 22:49:55 UTC (rev 9592)
+++ modules/portlet/trunk/test/src/test/resources/jsr286/ext/portletrequests-war/WEB-INF/portlet.xml 2008-01-23 23:43:05 UTC (rev 9593)
@@ -68,6 +68,14 @@
</supports>
</portlet>
+ <portlet>
+ <portlet-name>UniversalTestPortletE</portlet-name>
+ <portlet-class>org.jboss.portal.test.portlet.framework.UTP5</portlet-class>
+ <supports>
+ <mime-type>text/html</mime-type>
+ </supports>
+ </portlet>
+
<event-definition>
<name>Event</name>
</event-definition>
18 years, 3 months
JBoss Portal SVN: r9592 - in modules/portlet/trunk: portlet/src/main/java/org/jboss/portal/portlet/impl/spi and 3 other directories.
by portal-commits@lists.jboss.org
Author: julien(a)jboss.com
Date: 2008-01-23 17:49:55 -0500 (Wed, 23 Jan 2008)
New Revision: 9592
Modified:
modules/portlet/trunk/portlet/src/main/java/org/jboss/portal/portlet/impl/jsr168/api/ClientDataRequestImpl.java
modules/portlet/trunk/portlet/src/main/java/org/jboss/portal/portlet/impl/jsr168/api/PortletRequestImpl.java
modules/portlet/trunk/portlet/src/main/java/org/jboss/portal/portlet/impl/jsr168/api/PortletResponseImpl.java
modules/portlet/trunk/portlet/src/main/java/org/jboss/portal/portlet/impl/spi/AbstractClientContext.java
modules/portlet/trunk/portlet/src/main/java/org/jboss/portal/portlet/impl/spi/AbstractPortalContext.java
modules/portlet/trunk/portlet/src/main/java/org/jboss/portal/portlet/spi/ClientContext.java
modules/portlet/trunk/portlet/src/main/java/org/jboss/portal/portlet/support/spi/ClientContextSupport.java
modules/portlet/trunk/test/src/main/java/org/jboss/portal/portlet/test/PortletController.java
Log:
refactored request properties using ClientContext
Modified: modules/portlet/trunk/portlet/src/main/java/org/jboss/portal/portlet/impl/jsr168/api/ClientDataRequestImpl.java
===================================================================
--- modules/portlet/trunk/portlet/src/main/java/org/jboss/portal/portlet/impl/jsr168/api/ClientDataRequestImpl.java 2008-01-23 22:37:14 UTC (rev 9591)
+++ modules/portlet/trunk/portlet/src/main/java/org/jboss/portal/portlet/impl/jsr168/api/ClientDataRequestImpl.java 2008-01-23 22:49:55 UTC (rev 9592)
@@ -25,8 +25,6 @@
import org.jboss.portal.portlet.invocation.ActionInvocation;
import org.jboss.portal.portlet.invocation.ResourceInvocation;
import org.jboss.portal.portlet.spi.RequestContext;
-import org.jboss.portal.portlet.spi.ClientContext;
-import org.jboss.portal.common.NotYetImplemented;
import javax.portlet.ClientDataRequest;
import java.io.InputStream;
@@ -44,16 +42,12 @@
/** . */
protected final RequestContext requestContext;
- /** . */
- protected final ClientContext clientContext;
-
public ClientDataRequestImpl(ActionInvocation invocation)
{
super(invocation);
//
this.requestContext = invocation.getRequestContext();
- this.clientContext = invocation.getClientContext();
}
public ClientDataRequestImpl(ResourceInvocation invocation)
@@ -62,7 +56,6 @@
//
this.requestContext = invocation.getRequestContext();
- this.clientContext = invocation.getClientContext();
}
public InputStream getPortletInputStream() throws IOException
Modified: modules/portlet/trunk/portlet/src/main/java/org/jboss/portal/portlet/impl/jsr168/api/PortletRequestImpl.java
===================================================================
--- modules/portlet/trunk/portlet/src/main/java/org/jboss/portal/portlet/impl/jsr168/api/PortletRequestImpl.java 2008-01-23 22:37:14 UTC (rev 9591)
+++ modules/portlet/trunk/portlet/src/main/java/org/jboss/portal/portlet/impl/jsr168/api/PortletRequestImpl.java 2008-01-23 22:49:55 UTC (rev 9592)
@@ -41,6 +41,7 @@
import org.jboss.portal.portlet.spi.SecurityContext;
import org.jboss.portal.portlet.spi.UserContext;
import org.jboss.portal.portlet.spi.WindowContext;
+import org.jboss.portal.portlet.spi.ClientContext;
import org.jboss.portal.portlet.state.PropertyContext;
import javax.portlet.PortalContext;
@@ -57,12 +58,10 @@
import java.security.Principal;
import java.util.Collections;
import java.util.Enumeration;
-import java.util.HashSet;
-import java.util.Iterator;
import java.util.Locale;
import java.util.Map;
import java.util.Set;
-import java.util.Collection;
+import java.util.List;
/**
* PortletRequest implemention. The parameter implementation is left to subclasses that can implement it differently.
@@ -77,6 +76,7 @@
protected static final Logger log = Logger.getLogger(PortletRequestImpl.class);
protected PortletInvocation invocation;
+ protected ClientContext clientContext;
protected UserContext userContext;
protected SecurityContext securityContext;
protected ServerContext serverContext;
@@ -111,6 +111,7 @@
this.userContext = userContext;
this.securityContext = invocation.getSecurityContext();
this.serverContext = invocation.getServerContext();
+ this.clientContext = invocation.getClientContext();
this.windowContext = invocation.getWindowContext();
this.container = container;
this.dreq = invocation.getDispatchedRequest();
@@ -219,24 +220,17 @@
}
//
- Object prop = invocation.getAttribute(PortletInvocation.REQUEST_PROPERTIES_SCOPE, name);
- if (prop instanceof Collection)
- {
- Iterator iterator = ((Collection)prop).iterator();
- if (iterator.hasNext())
- {
- prop = iterator.next();
- }
- }
+ List<String> properties = clientContext.getProperties(name);
//
- if (prop == null)
+ if (properties == null || properties.size() == 0)
{
- // Otherwise the request header
- prop = dreq.getHeader(name);
+ return null;
}
-
- return (String)prop;
+ else
+ {
+ return properties.get(0);
+ }
}
public Enumeration<String> getProperties(String name)
@@ -247,35 +241,23 @@
}
//
- Object prop = invocation.getAttribute(PortletInvocation.REQUEST_PROPERTIES_SCOPE, name);
+ List<String> properties = clientContext.getProperties(name);
- if (prop instanceof String)
+ //
+ if (properties == null)
{
- return Tools.toEnumeration((String)prop);
+ return Tools.emptyEnumeration();
}
- else if (prop instanceof Collection)
- {
- return Collections.enumeration(((Collection<String>)prop));
- }
else
{
- // Otherwise the request headers
- return (Enumeration<String>)dreq.getHeaders(name);
+ return Collections.enumeration(properties);
}
}
public Enumeration<String> getPropertyNames()
{
- // First the properties
- Set<String> names = new HashSet<String>((Set<String>)invocation.getContext().getAttributeResolver(PortletInvocation.REQUEST_PROPERTIES_SCOPE).getKeys());
+ Set<String> names = clientContext.getPropertyNames();
- // Then put the headers
- for (Enumeration<String> e = (Enumeration<String>)dreq.getHeaderNames();e.hasMoreElements();)
- {
- String name = e.nextElement();
- names.add(name);
- }
-
//
return Collections.enumeration(names);
}
Modified: modules/portlet/trunk/portlet/src/main/java/org/jboss/portal/portlet/impl/jsr168/api/PortletResponseImpl.java
===================================================================
--- modules/portlet/trunk/portlet/src/main/java/org/jboss/portal/portlet/impl/jsr168/api/PortletResponseImpl.java 2008-01-23 22:37:14 UTC (rev 9591)
+++ modules/portlet/trunk/portlet/src/main/java/org/jboss/portal/portlet/impl/jsr168/api/PortletResponseImpl.java 2008-01-23 22:49:55 UTC (rev 9592)
@@ -136,6 +136,8 @@
public Element createElement(String s) throws DOMException
{
+
+
throw new NotYetImplemented();
}
}
Modified: modules/portlet/trunk/portlet/src/main/java/org/jboss/portal/portlet/impl/spi/AbstractClientContext.java
===================================================================
--- modules/portlet/trunk/portlet/src/main/java/org/jboss/portal/portlet/impl/spi/AbstractClientContext.java 2008-01-23 22:37:14 UTC (rev 9591)
+++ modules/portlet/trunk/portlet/src/main/java/org/jboss/portal/portlet/impl/spi/AbstractClientContext.java 2008-01-23 22:49:55 UTC (rev 9592)
@@ -25,6 +25,13 @@
import org.jboss.portal.portlet.spi.ClientContext;
import javax.servlet.http.HttpServletRequest;
+import java.util.List;
+import java.util.Set;
+import java.util.Map;
+import java.util.HashMap;
+import java.util.Enumeration;
+import java.util.ArrayList;
+import java.util.Collections;
/**
* @author <a href="mailto:julien@jboss.org">Julien Viet</a>
@@ -36,8 +43,41 @@
/** . */
private final String method;
+ /** . */
+ private final Map<String, List<String>> headers;
+
public AbstractClientContext(HttpServletRequest request)
{
+ Map<String, List<String>> headers = new HashMap<String, List<String>>();
+ for (Enumeration e = request.getHeaderNames();e.hasMoreElements();)
+ {
+ String headerName = (String)e.nextElement();
+ Enumeration f = request.getHeaders(headerName);
+ if (f.hasMoreElements())
+ {
+ List<String> headerValues;
+ String headerValue = (String)f.nextElement();
+ if (f.hasMoreElements())
+ {
+ headerValues = new ArrayList<String>(4);
+ headerValues.add(headerValue);
+ headerValues.add((String)f.nextElement());
+ while (f.hasMoreElements())
+ {
+ headerValue = (String)f.nextElement();
+ headerValues.add(headerValue);
+ }
+ }
+ else
+ {
+ headerValues = Collections.singletonList(headerValue);
+ }
+ headers.put(headerName, headerValues);
+ }
+ }
+
+ //
+ this.headers = headers;
this.method = request.getMethod();
}
@@ -45,4 +85,18 @@
{
return method;
}
+
+ public List<String> getProperties(String name)
+ {
+ if (name == null)
+ {
+ throw new IllegalArgumentException("No null name accepted");
+ }
+ return headers.get(name);
+ }
+
+ public Set<String> getPropertyNames()
+ {
+ return headers.keySet();
+ }
}
Modified: modules/portlet/trunk/portlet/src/main/java/org/jboss/portal/portlet/impl/spi/AbstractPortalContext.java
===================================================================
--- modules/portlet/trunk/portlet/src/main/java/org/jboss/portal/portlet/impl/spi/AbstractPortalContext.java 2008-01-23 22:37:14 UTC (rev 9591)
+++ modules/portlet/trunk/portlet/src/main/java/org/jboss/portal/portlet/impl/spi/AbstractPortalContext.java 2008-01-23 22:49:55 UTC (rev 9592)
@@ -75,9 +75,14 @@
this.props = props;
}
+ public AbstractPortalContext(Map<String, String> props)
+ {
+ this(ALL_WINDOW_STATES, ALL_MODES, props);
+ }
+
public AbstractPortalContext()
{
- this(ALL_WINDOW_STATES, ALL_MODES, EMPTY_STRING_TO_STRING_MAP);
+ this(EMPTY_STRING_TO_STRING_MAP);
}
public String getInfo()
Modified: modules/portlet/trunk/portlet/src/main/java/org/jboss/portal/portlet/spi/ClientContext.java
===================================================================
--- modules/portlet/trunk/portlet/src/main/java/org/jboss/portal/portlet/spi/ClientContext.java 2008-01-23 22:37:14 UTC (rev 9591)
+++ modules/portlet/trunk/portlet/src/main/java/org/jboss/portal/portlet/spi/ClientContext.java 2008-01-23 22:49:55 UTC (rev 9592)
@@ -22,6 +22,10 @@
******************************************************************************/
package org.jboss.portal.portlet.spi;
+import java.util.Iterator;
+import java.util.Set;
+import java.util.List;
+
/**
* @author <a href="mailto:julien@jboss.org">Julien Viet</a>
* @version $Revision: 630 $
@@ -31,4 +35,8 @@
String getMethod();
+ List<String> getProperties(String name);
+
+ Set<String> getPropertyNames();
+
}
Modified: modules/portlet/trunk/portlet/src/main/java/org/jboss/portal/portlet/support/spi/ClientContextSupport.java
===================================================================
--- modules/portlet/trunk/portlet/src/main/java/org/jboss/portal/portlet/support/spi/ClientContextSupport.java 2008-01-23 22:37:14 UTC (rev 9591)
+++ modules/portlet/trunk/portlet/src/main/java/org/jboss/portal/portlet/support/spi/ClientContextSupport.java 2008-01-23 22:49:55 UTC (rev 9592)
@@ -24,6 +24,9 @@
import org.jboss.portal.portlet.spi.ClientContext;
+import java.util.List;
+import java.util.Set;
+
/**
* @author <a href="mailto:julien@jboss.org">Julien Viet</a>
* @version $Revision: 630 $
@@ -34,4 +37,14 @@
{
throw new UnsupportedOperationException();
}
+
+ public List<String> getProperties(String name)
+ {
+ throw new UnsupportedOperationException();
+ }
+
+ public Set<String> getPropertyNames()
+ {
+ throw new UnsupportedOperationException();
+ }
}
Modified: modules/portlet/trunk/test/src/main/java/org/jboss/portal/portlet/test/PortletController.java
===================================================================
--- modules/portlet/trunk/test/src/main/java/org/jboss/portal/portlet/test/PortletController.java 2008-01-23 22:37:14 UTC (rev 9591)
+++ modules/portlet/trunk/test/src/main/java/org/jboss/portal/portlet/test/PortletController.java 2008-01-23 22:49:55 UTC (rev 9592)
@@ -87,9 +87,18 @@
/** . */
private final Logger log;
+ /** . */
+ private final AbstractPortalContext portalContext;
+
public PortletController() throws IllegalRequestException, UnsupportedEncodingException
{
- log = Logger.getLogger(PortletController.class);
+ Map<String, String> portalProperties = new HashMap<String, String>();
+ portalProperties.put("javax.portlet.markup.head.element.support", "true");
+ AbstractPortalContext portalContext = new AbstractPortalContext(portalProperties);
+
+ //
+ this.log = Logger.getLogger(PortletController.class);
+ this.portalContext = portalContext;
}
private PortletInvocationResponse handle(PortletControllerContext context, ContainerRequest containerRequest) throws PortletInvokerException, IOException
@@ -162,7 +171,7 @@
actionInvocation.setInstanceContext(instanceContext);
actionInvocation.setUserContext(new AbstractUserContext(req));
actionInvocation.setWindowContext(new AbstractWindowContext(portlet.getContext().getId()));
- actionInvocation.setPortalContext(new AbstractPortalContext());
+ actionInvocation.setPortalContext(portalContext);
actionInvocation.setSecurityContext(new AbstractSecurityContext(req));
actionInvocation.setRequestContext(new AbstractRequestContext(req));
actionInvocation.setTarget(instanceContext.getTarget());
@@ -257,7 +266,7 @@
resourceInvocation.setInstanceContext(instanceContext);
resourceInvocation.setUserContext(new AbstractUserContext(req));
resourceInvocation.setWindowContext(new AbstractWindowContext(portlet.getContext().getId()));
- resourceInvocation.setPortalContext(new AbstractPortalContext());
+ resourceInvocation.setPortalContext(portalContext);
resourceInvocation.setSecurityContext(new AbstractSecurityContext(req));
resourceInvocation.setRequestContext(new AbstractRequestContext(req));
resourceInvocation.setTarget(instanceContext.getTarget());
@@ -313,7 +322,7 @@
eventInvocation.setInstanceContext(instanceContext);
eventInvocation.setUserContext(new AbstractUserContext(req));
eventInvocation.setWindowContext(new AbstractWindowContext(portlet.getContext().getId()));
- eventInvocation.setPortalContext(new AbstractPortalContext());
+ eventInvocation.setPortalContext(portalContext);
eventInvocation.setSecurityContext(new AbstractSecurityContext(req));
eventInvocation.setTarget(instanceContext.getTarget());
@@ -609,7 +618,7 @@
render.setInstanceContext(instanceContext);
render.setUserContext(new AbstractUserContext(req));
render.setWindowContext(new AbstractWindowContext(portlet.getContext().getId()));
- render.setPortalContext(new AbstractPortalContext());
+ render.setPortalContext(portalContext);
render.setSecurityContext(new AbstractSecurityContext(req));
render.setTarget(instanceContext.getTarget());
18 years, 3 months
JBoss Portal SVN: r9591 - modules/common/trunk/common/src/main/java/org/jboss/portal/common/util.
by portal-commits@lists.jboss.org
Author: julien(a)jboss.com
Date: 2008-01-23 17:37:14 -0500 (Wed, 23 Jan 2008)
New Revision: 9591
Modified:
modules/common/trunk/common/src/main/java/org/jboss/portal/common/util/Tools.java
Log:
added emptyIterator() and emptyEnumeration() on Tools that use generics
Modified: modules/common/trunk/common/src/main/java/org/jboss/portal/common/util/Tools.java
===================================================================
--- modules/common/trunk/common/src/main/java/org/jboss/portal/common/util/Tools.java 2008-01-23 22:22:16 UTC (rev 9590)
+++ modules/common/trunk/common/src/main/java/org/jboss/portal/common/util/Tools.java 2008-01-23 22:37:14 UTC (rev 9591)
@@ -138,6 +138,16 @@
}
};
+ public static <E> Enumeration<E> emptyEnumeration()
+ {
+ return (Enumeration<E>)EMPTY_ENUMERATION;
+ }
+
+ public static <E> Iterator<E> emptyIterator()
+ {
+ return (Iterator<E>)EMPTY_ITERATOR;
+ }
+
public static <E> Enumeration<E> toEnumeration(final Iterator<E> iterator)
{
if (iterator == null)
18 years, 3 months
JBoss Portal SVN: r9590 - in modules/test/trunk: tooling/maven2/src/main/java/org/jboss/unit/tooling/maven2 and 1 other directories.
by portal-commits@lists.jboss.org
Author: bdaw
Date: 2008-01-23 17:22:16 -0500 (Wed, 23 Jan 2008)
New Revision: 9590
Modified:
modules/test/trunk/tooling/ant/src/main/java/org/jboss/unit/tooling/ant/JBossUnitTask.java
modules/test/trunk/tooling/maven2/src/main/java/org/jboss/unit/tooling/maven2/UnitMojo.java
modules/test/trunk/unit/src/main/java/org/jboss/unit/tooling/filter/ExcludeTestFilter.java
modules/test/trunk/unit/src/main/java/org/jboss/unit/tooling/filter/IncludeTestFilter.java
Log:
- minor typo
- wrong filter behaviour for generic jboss unit tests
Modified: modules/test/trunk/tooling/ant/src/main/java/org/jboss/unit/tooling/ant/JBossUnitTask.java
===================================================================
--- modules/test/trunk/tooling/ant/src/main/java/org/jboss/unit/tooling/ant/JBossUnitTask.java 2008-01-23 21:58:05 UTC (rev 9589)
+++ modules/test/trunk/tooling/ant/src/main/java/org/jboss/unit/tooling/ant/JBossUnitTask.java 2008-01-23 22:22:16 UTC (rev 9590)
@@ -41,7 +41,7 @@
*/
public class JBossUnitTask extends Task
{
- public static final String MAVEN_SKIP_TEST = "maven.skip.test";
+ public static final String MAVEN_SKIP_TEST = "maven.test.skip";
List<TestsType> testsTypes = new LinkedList();
Modified: modules/test/trunk/tooling/maven2/src/main/java/org/jboss/unit/tooling/maven2/UnitMojo.java
===================================================================
--- modules/test/trunk/tooling/maven2/src/main/java/org/jboss/unit/tooling/maven2/UnitMojo.java 2008-01-23 21:58:05 UTC (rev 9589)
+++ modules/test/trunk/tooling/maven2/src/main/java/org/jboss/unit/tooling/maven2/UnitMojo.java 2008-01-23 22:22:16 UTC (rev 9590)
@@ -36,7 +36,7 @@
public class UnitMojo extends AbstractMojo
{
- public static final String MAVEN_SKIP_TEST = "maven.skip.test";
+ public static final String MAVEN_SKIP_TEST = "maven.test.skip";
/**
* @parameter
Modified: modules/test/trunk/unit/src/main/java/org/jboss/unit/tooling/filter/ExcludeTestFilter.java
===================================================================
--- modules/test/trunk/unit/src/main/java/org/jboss/unit/tooling/filter/ExcludeTestFilter.java 2008-01-23 21:58:05 UTC (rev 9589)
+++ modules/test/trunk/unit/src/main/java/org/jboss/unit/tooling/filter/ExcludeTestFilter.java 2008-01-23 22:22:16 UTC (rev 9590)
@@ -24,6 +24,7 @@
import org.jboss.unit.TestId;
import org.jboss.unit.info.TestInfo;
+import org.jboss.unit.info.TestSuiteInfo;
import java.util.Set;
@@ -48,6 +49,19 @@
{
// First check names
+ if (testInfo instanceof TestSuiteInfo)
+ {
+ TestSuiteInfo testSuiteInfo = (TestSuiteInfo)testInfo;
+
+ for (String name : testSuiteInfo.getNames())
+ {
+ if (checkName(name))
+ {
+ return false;
+ }
+ }
+ }
+
if (checkName(testInfo.getName()))
{
return false;
Modified: modules/test/trunk/unit/src/main/java/org/jboss/unit/tooling/filter/IncludeTestFilter.java
===================================================================
--- modules/test/trunk/unit/src/main/java/org/jboss/unit/tooling/filter/IncludeTestFilter.java 2008-01-23 21:58:05 UTC (rev 9589)
+++ modules/test/trunk/unit/src/main/java/org/jboss/unit/tooling/filter/IncludeTestFilter.java 2008-01-23 22:22:16 UTC (rev 9590)
@@ -24,6 +24,7 @@
import org.jboss.unit.TestId;
import org.jboss.unit.info.TestInfo;
+import org.jboss.unit.info.TestSuiteInfo;
import java.util.Set;
@@ -49,6 +50,20 @@
// First check names
+ if (testInfo instanceof TestSuiteInfo)
+ {
+ TestSuiteInfo testSuiteInfo = (TestSuiteInfo)testInfo;
+
+ for (String name : testSuiteInfo.getNames())
+ {
+ if (checkName(name))
+ {
+ return true;
+ }
+ }
+
+ }
+
if (checkName(testInfo.getName()))
{
return true;
18 years, 3 months
JBoss Portal SVN: r9589 - in branches/JBoss_Portal_Branch_2_6: core-admin/src/resources/portal-admin-war/WEB-INF/jsf and 1 other directories.
by portal-commits@lists.jboss.org
Author: wesleyhales
Date: 2008-01-23 16:58:05 -0500 (Wed, 23 Jan 2008)
New Revision: 9589
Modified:
branches/JBoss_Portal_Branch_2_6/core-admin/src/resources/portal-admin-war/WEB-INF/jsf/common/showPortletDetails.xhtml
branches/JBoss_Portal_Branch_2_6/core-admin/src/resources/portal-admin-war/WEB-INF/jsf/instances.xhtml
branches/JBoss_Portal_Branch_2_6/core-admin/src/resources/portal-admin-war/WEB-INF/jsf/portlets.xhtml
branches/JBoss_Portal_Branch_2_6/core/src/bin/portal-core-war/themes/renaissance/portal_style.css
Log:
Cleanup and fixes
Modified: branches/JBoss_Portal_Branch_2_6/core/src/bin/portal-core-war/themes/renaissance/portal_style.css
===================================================================
--- branches/JBoss_Portal_Branch_2_6/core/src/bin/portal-core-war/themes/renaissance/portal_style.css 2008-01-23 21:20:31 UTC (rev 9588)
+++ branches/JBoss_Portal_Branch_2_6/core/src/bin/portal-core-war/themes/renaissance/portal_style.css 2008-01-23 21:58:05 UTC (rev 9589)
@@ -226,7 +226,7 @@
margin-top: 39px;
min-width: 550px;
z-index: 100; /* added for submenu hover */
-/*position: relative; added for submenu hover */
+ position: relative; /*added for submenu hover */
}
ul#tabsHeader li {
Modified: branches/JBoss_Portal_Branch_2_6/core-admin/src/resources/portal-admin-war/WEB-INF/jsf/common/showPortletDetails.xhtml
===================================================================
--- branches/JBoss_Portal_Branch_2_6/core-admin/src/resources/portal-admin-war/WEB-INF/jsf/common/showPortletDetails.xhtml 2008-01-23 21:20:31 UTC (rev 9588)
+++ branches/JBoss_Portal_Branch_2_6/core-admin/src/resources/portal-admin-war/WEB-INF/jsf/common/showPortletDetails.xhtml 2008-01-23 21:58:05 UTC (rev 9589)
@@ -45,9 +45,10 @@
</f:subview>
</h:panelGrid>
<br/>
+
+ </h:form>
+ <f:subview id="displaynamecontainer" rendered="#{showDisplayNameEditor}">
<p class="portlet-area-header">Portlet Instance Display Names</p>
- </h:form>
-
<div class="float-left third-width-pad5">
<h:form id="displayNameForm">
<h3 class="sectionTitle zero">Add Instance Display Names</h3>
@@ -114,5 +115,5 @@
</div>
-
+ </f:subview>
</div>
\ No newline at end of file
Modified: branches/JBoss_Portal_Branch_2_6/core-admin/src/resources/portal-admin-war/WEB-INF/jsf/instances.xhtml
===================================================================
--- branches/JBoss_Portal_Branch_2_6/core-admin/src/resources/portal-admin-war/WEB-INF/jsf/instances.xhtml 2008-01-23 21:20:31 UTC (rev 9588)
+++ branches/JBoss_Portal_Branch_2_6/core-admin/src/resources/portal-admin-war/WEB-INF/jsf/instances.xhtml 2008-01-23 21:58:05 UTC (rev 9589)
@@ -92,6 +92,7 @@
<ui:include src="common/showPortletDetails.xhtml">
<ui:param name="portlet" value="#{instancemgr.selectedInstance.portlet}"/>
<ui:param name="portletmgr" value="#{portletmgr}"/>
+ <ui:param name="showDisplayNameEditor" value="true"/>
</ui:include>
</c:when>
<c:otherwise>
Modified: branches/JBoss_Portal_Branch_2_6/core-admin/src/resources/portal-admin-war/WEB-INF/jsf/portlets.xhtml
===================================================================
--- branches/JBoss_Portal_Branch_2_6/core-admin/src/resources/portal-admin-war/WEB-INF/jsf/portlets.xhtml 2008-01-23 21:20:31 UTC (rev 9588)
+++ branches/JBoss_Portal_Branch_2_6/core-admin/src/resources/portal-admin-war/WEB-INF/jsf/portlets.xhtml 2008-01-23 21:58:05 UTC (rev 9589)
@@ -104,6 +104,7 @@
<br/>
<ui:include src="common/showPortletDetails.xhtml">
<ui:param name="portlet" value="#{portletmgr.selectedPortlet}"/>
+ <ui:param name="showDisplayNameEditor" value="false"/>
</ui:include>
</c:if>
18 years, 3 months